brick-engine-js 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (477) hide show
  1. package/.env.local.example +2 -0
  2. package/.github/workflows/publish.yml +73 -0
  3. package/.prettierignore +2 -0
  4. package/.prettierrc.json +8 -0
  5. package/README.adoc +84 -0
  6. package/dist/8e23286c2fdf41fd795f.svg +32 -0
  7. package/dist/CNAME +1 -0
  8. package/dist/app.js +2 -0
  9. package/dist/app.js.map +1 -0
  10. package/dist/brick-engine.js +2 -0
  11. package/dist/brick-engine.js.map +1 -0
  12. package/dist/config/configs.d.ts +180 -0
  13. package/dist/config/configs.test.d.ts +1 -0
  14. package/dist/config/env.d.ts +2 -0
  15. package/dist/config/env.test.d.ts +1 -0
  16. package/dist/config/styles.d.ts +0 -0
  17. package/dist/core/Game.d.ts +107 -0
  18. package/dist/core/Game.test.d.ts +1 -0
  19. package/dist/core/InitialStateSnapshot.d.ts +19 -0
  20. package/dist/core/InitialStateSnapshot.test.d.ts +1 -0
  21. package/dist/core/helpers/CellHelper.d.ts +13 -0
  22. package/dist/core/helpers/CellHelper.test.d.ts +1 -0
  23. package/dist/core/helpers/ControlInputHandlerHelper.d.ts +32 -0
  24. package/dist/core/helpers/ControlInputHandlerHelper.test.d.ts +1 -0
  25. package/dist/core/helpers/CoordinateHelper.d.ts +54 -0
  26. package/dist/core/helpers/CoordinateHelper.test.d.ts +1 -0
  27. package/dist/core/helpers/InterfaceIdentifierHelper.d.ts +7 -0
  28. package/dist/core/helpers/InterfaceIdentifierHelper.test.d.ts +1 -0
  29. package/dist/core/helpers/RelativeValuesHelper.d.ts +23 -0
  30. package/dist/core/helpers/RelativeValuesHelper.test.d.ts +1 -0
  31. package/dist/core/module/control/GameControl.d.ts +62 -0
  32. package/dist/core/module/control/GameControl.test.d.ts +1 -0
  33. package/dist/core/module/control/GameControlKeyBinding.d.ts +36 -0
  34. package/dist/core/module/control/GameControlKeyBinding.test.d.ts +1 -0
  35. package/dist/core/module/grid/GameGrid.d.ts +399 -0
  36. package/dist/core/module/grid/GameGrid.test.d.ts +1 -0
  37. package/dist/core/module/grid/GameHudGrid.d.ts +24 -0
  38. package/dist/core/module/grid/GameHudGrid.test.d.ts +1 -0
  39. package/dist/core/module/grid/engines/GridAnalysisEngine.d.ts +29 -0
  40. package/dist/core/module/grid/engines/GridAnalysisEngine.test.d.ts +1 -0
  41. package/dist/core/module/grid/engines/GridLineEngine.d.ts +56 -0
  42. package/dist/core/module/grid/engines/GridLineEngine.test.d.ts +1 -0
  43. package/dist/core/module/grid/engines/GridMovementEngine.d.ts +29 -0
  44. package/dist/core/module/grid/engines/GridMovementEngine.test.d.ts +1 -0
  45. package/dist/core/module/grid/engines/GridRegionEngine.d.ts +26 -0
  46. package/dist/core/module/grid/engines/GridRegionEngine.test.d.ts +1 -0
  47. package/dist/core/module/grid/engines/GridTransformEngine.d.ts +24 -0
  48. package/dist/core/module/grid/engines/GridTransformEngine.test.d.ts +1 -0
  49. package/dist/core/module/renderer/DisplayRenderer.d.ts +51 -0
  50. package/dist/core/module/renderer/DisplayRenderer.test.d.ts +1 -0
  51. package/dist/core/module/renderer/GameRenderer.d.ts +59 -0
  52. package/dist/core/module/renderer/GameRenderer.test.d.ts +1 -0
  53. package/dist/core/module/renderer/HudRenderer.d.ts +56 -0
  54. package/dist/core/module/renderer/HudRenderer.test.d.ts +1 -0
  55. package/dist/core/module/score/GameScore.d.ts +117 -0
  56. package/dist/core/module/score/GameScore.test.d.ts +1 -0
  57. package/dist/core/module/session/GameSession.d.ts +20 -0
  58. package/dist/core/module/session/GameSession.test.d.ts +1 -0
  59. package/dist/core/module/sound/GameSound.d.ts +85 -0
  60. package/dist/core/module/sound/GameSound.test.d.ts +1 -0
  61. package/dist/core/module/state/GameState.d.ts +172 -0
  62. package/dist/core/module/state/GameState.test.d.ts +1 -0
  63. package/dist/core/module/text/GameText.d.ts +87 -0
  64. package/dist/core/module/text/GameText.test.d.ts +1 -0
  65. package/dist/core/module/time/GameTime.d.ts +76 -0
  66. package/dist/core/module/time/GameTime.test.d.ts +1 -0
  67. package/dist/core/types/Interfaces.d.ts +53 -0
  68. package/dist/core/types/Types.d.ts +114 -0
  69. package/dist/core/types/enums.d.ts +106 -0
  70. package/dist/core/types/modules.d.ts +723 -0
  71. package/dist/css/app.743066d8e4172b0e73f9.css +824 -0
  72. package/dist/css/app.743066d8e4172b0e73f9.css.map +1 -0
  73. package/dist/docs/GAME_DEVELOPER_GUIDE.html +727 -0
  74. package/dist/docs/brick-engine-guide.html +610 -0
  75. package/dist/docs/diagrams/lifecycle.mmd +19 -0
  76. package/dist/docs/documentation_style_guide.html +994 -0
  77. package/dist/docs/getting-started.html +648 -0
  78. package/dist/docs/images/lifecycle.svg +1 -0
  79. package/dist/docs/index.html +593 -0
  80. package/dist/docs/jsdoc_standard.html +656 -0
  81. package/dist/docs/publishing.html +573 -0
  82. package/dist/docs/reference/enums/Color.html +533 -0
  83. package/dist/docs/reference/enums/ControlEventType.html +505 -0
  84. package/dist/docs/reference/enums/ControlKey.html +529 -0
  85. package/dist/docs/reference/enums/FontAlignment.html +545 -0
  86. package/dist/docs/reference/enums/FontSize.html +517 -0
  87. package/dist/docs/reference/enums/Sound.html +558 -0
  88. package/dist/docs/reference/enums/StateProperty.html +525 -0
  89. package/dist/docs/reference/helpers/CellHelper.html +520 -0
  90. package/dist/docs/reference/helpers/ControlInputHandlerHelper.html +569 -0
  91. package/dist/docs/reference/helpers/CoordinateHelper.html +703 -0
  92. package/dist/docs/reference/helpers/RelativeValuesHelper.html +560 -0
  93. package/dist/docs/reference/interfaces/Debuggable.html +501 -0
  94. package/dist/docs/reference/interfaces/GameModules.html +544 -0
  95. package/dist/docs/reference/interfaces/Initializable.html +495 -0
  96. package/dist/docs/reference/interfaces/RendererInitializable.html +517 -0
  97. package/dist/docs/reference/interfaces/StateSyncable.html +542 -0
  98. package/dist/docs/reference/interfaces/modules/Control.html +648 -0
  99. package/dist/docs/reference/interfaces/modules/Grid.html +1256 -0
  100. package/dist/docs/reference/interfaces/modules/Renderer.html +522 -0
  101. package/dist/docs/reference/interfaces/modules/RendererComposite.html +577 -0
  102. package/dist/docs/reference/interfaces/modules/Score.html +669 -0
  103. package/dist/docs/reference/interfaces/modules/Session.html +585 -0
  104. package/dist/docs/reference/interfaces/modules/State.html +897 -0
  105. package/dist/docs/reference/interfaces/modules/Text.html +668 -0
  106. package/dist/docs/reference/interfaces/modules/Time.html +684 -0
  107. package/dist/docs/reference/modules/Debugger.html +579 -0
  108. package/dist/docs/reference/modules/DisplayRenderer.html +557 -0
  109. package/dist/docs/reference/modules/Game.html +909 -0
  110. package/dist/docs/reference/modules/GameControl.html +716 -0
  111. package/dist/docs/reference/modules/GameGrid.html +1910 -0
  112. package/dist/docs/reference/modules/GameHudGrid.html +508 -0
  113. package/dist/docs/reference/modules/GameMenu.html +538 -0
  114. package/dist/docs/reference/modules/GameRenderer.html +589 -0
  115. package/dist/docs/reference/modules/GameScore.html +664 -0
  116. package/dist/docs/reference/modules/GameSession.html +533 -0
  117. package/dist/docs/reference/modules/GameSound.html +636 -0
  118. package/dist/docs/reference/modules/GameState.html +922 -0
  119. package/dist/docs/reference/modules/GameText.html +701 -0
  120. package/dist/docs/reference/modules/GameTime.html +696 -0
  121. package/dist/docs/reference/modules/HudRenderer.html +568 -0
  122. package/dist/docs/reference/modules/InitialStateSnapshot.html +557 -0
  123. package/dist/docs/reference/modules/SessionModal.html +520 -0
  124. package/dist/docs/reference/types/Axis.html +505 -0
  125. package/dist/docs/reference/types/Cell.html +514 -0
  126. package/dist/docs/reference/types/ControlCallback.html +488 -0
  127. package/dist/docs/reference/types/Coordinate.html +510 -0
  128. package/dist/docs/reference/types/GameEntry.html +514 -0
  129. package/dist/docs/reference/types/GameEvent.html +514 -0
  130. package/dist/docs/reference/types/Piece.html +506 -0
  131. package/dist/docs/reference/types/RendererMetrics.html +514 -0
  132. package/dist/docs/reference/types/Vector.html +509 -0
  133. package/dist/docs/testing_best_practices.html +770 -0
  134. package/dist/favicon.ico +0 -0
  135. package/dist/fonts/digital-7.monoitalic.ttf +0 -0
  136. package/dist/images/cell.svg +32 -0
  137. package/dist/images/close.png +0 -0
  138. package/dist/images/games.png +0 -0
  139. package/dist/images/github.png +0 -0
  140. package/dist/images/letter-a.png +0 -0
  141. package/dist/images/letter-d.png +0 -0
  142. package/dist/images/letter-j.png +0 -0
  143. package/dist/images/letter-s.png +0 -0
  144. package/dist/images/letter-w.png +0 -0
  145. package/dist/images/meta-image.png +0 -0
  146. package/dist/images/number-1.png +0 -0
  147. package/dist/images/number-2.png +0 -0
  148. package/dist/images/number-3.png +0 -0
  149. package/dist/images/number-4.png +0 -0
  150. package/dist/images/number-5.png +0 -0
  151. package/dist/images/number-6.png +0 -0
  152. package/dist/images/splash.gif +0 -0
  153. package/dist/index.d.ts +8 -0
  154. package/dist/index.html +1 -0
  155. package/dist/index.test.d.ts +1 -0
  156. package/dist/main.d.ts +3 -0
  157. package/dist/main.test.d.ts +1 -0
  158. package/dist/menu/GameMenu.d.ts +15 -0
  159. package/dist/menu/GameMenu.test.d.ts +1 -0
  160. package/dist/menu/GameMenuSingleton.d.ts +6 -0
  161. package/dist/menu/GameMenuSingleton.test.d.ts +1 -0
  162. package/dist/menu/GameRepository.d.ts +7 -0
  163. package/dist/menu/GameRepository.test.d.ts +1 -0
  164. package/dist/menu/manager/GameManager.d.ts +6 -0
  165. package/dist/menu/manager/GameManager.test.d.ts +1 -0
  166. package/dist/sounds/sound_00.wav +0 -0
  167. package/dist/sounds/sound_01.wav +0 -0
  168. package/dist/sounds/sound_02.wav +0 -0
  169. package/dist/sounds/sound_03.wav +0 -0
  170. package/dist/sounds/sound_04.wav +0 -0
  171. package/dist/sounds/sound_05.wav +0 -0
  172. package/dist/sounds/sound_06.wav +0 -0
  173. package/dist/sounds/sound_07.wav +0 -0
  174. package/dist/sounds/sound_08.wav +0 -0
  175. package/dist/sounds/sound_09.wav +0 -0
  176. package/dist/sounds/sound_10.wav +0 -0
  177. package/dist/sounds/sound_11.wav +0 -0
  178. package/dist/sounds/sound_12.wav +0 -0
  179. package/dist/sounds/sound_13.wav +0 -0
  180. package/dist/sounds/sound_14.wav +0 -0
  181. package/dist/sounds/sound_15.wav +0 -0
  182. package/dist/types/interfaces.d.ts +5 -0
  183. package/dist/vendor/p5.min.js +1 -0
  184. package/dist/view/Debugger.d.ts +12 -0
  185. package/dist/view/Debugger.test.d.ts +1 -0
  186. package/dist/view/GameView.d.ts +101 -0
  187. package/dist/view/GameView.test.d.ts +1 -0
  188. package/dist/view/SessionModal.d.ts +12 -0
  189. package/dist/view/SessionModal.test.d.ts +4 -0
  190. package/dist/view/components/layout/ButtonLayout.d.ts +25 -0
  191. package/dist/view/components/layout/ButtonLayout.test.d.ts +1 -0
  192. package/dist/view/components/layout/ContainerLayout.d.ts +23 -0
  193. package/dist/view/components/layout/ContainerLayout.test.d.ts +1 -0
  194. package/dist/view/components/layout/FrameLayout.d.ts +11 -0
  195. package/dist/view/components/layout/FrameLayout.test.d.ts +1 -0
  196. package/dist/view/components/ui/BigButton.d.ts +13 -0
  197. package/dist/view/components/ui/BigButton.test.d.ts +1 -0
  198. package/dist/view/components/ui/Button.d.ts +12 -0
  199. package/dist/view/components/ui/Button.test.d.ts +1 -0
  200. package/dist/view/components/ui/Canvas.d.ts +22 -0
  201. package/dist/view/components/ui/Canvas.test.d.ts +1 -0
  202. package/dist/view/components/ui/SmallButton.d.ts +13 -0
  203. package/dist/view/components/ui/SmallButton.test.d.ts +1 -0
  204. package/dist/view/theme/applyColors.d.ts +10 -0
  205. package/dist/view/theme/applyColors.test.d.ts +1 -0
  206. package/dist/view/theme/dimensions.d.ts +13 -0
  207. package/dist/view/theme/dimensions.test.d.ts +1 -0
  208. package/docs/GAME_DEVELOPER_GUIDE.adoc +167 -0
  209. package/docs/brick-engine-guide.adoc +87 -0
  210. package/docs/diagrams/lifecycle.mmd +19 -0
  211. package/docs/documentation_style_guide.adoc +210 -0
  212. package/docs/getting-started.adoc +147 -0
  213. package/docs/images/lifecycle.svg +1 -0
  214. package/docs/jsdoc_standard.adoc +109 -0
  215. package/docs/publishing.adoc +58 -0
  216. package/docs/reference/enums/Color.adoc +35 -0
  217. package/docs/reference/enums/ControlEventType.adoc +28 -0
  218. package/docs/reference/enums/ControlKey.adoc +34 -0
  219. package/docs/reference/enums/FontAlignment.adoc +43 -0
  220. package/docs/reference/enums/FontSize.adoc +31 -0
  221. package/docs/reference/enums/Sound.adoc +42 -0
  222. package/docs/reference/enums/StateProperty.adoc +33 -0
  223. package/docs/reference/helpers/CellHelper.adoc +37 -0
  224. package/docs/reference/helpers/ControlInputHandlerHelper.adoc +57 -0
  225. package/docs/reference/helpers/CoordinateHelper.adoc +118 -0
  226. package/docs/reference/helpers/RelativeValuesHelper.adoc +53 -0
  227. package/docs/reference/interfaces/Debuggable.adoc +29 -0
  228. package/docs/reference/interfaces/GameModules.adoc +35 -0
  229. package/docs/reference/interfaces/Initializable.adoc +24 -0
  230. package/docs/reference/interfaces/RendererInitializable.adoc +33 -0
  231. package/docs/reference/interfaces/StateSyncable.adoc +41 -0
  232. package/docs/reference/interfaces/modules/Control.adoc +98 -0
  233. package/docs/reference/interfaces/modules/Grid.adoc +411 -0
  234. package/docs/reference/interfaces/modules/Renderer.adoc +34 -0
  235. package/docs/reference/interfaces/modules/RendererComposite.adoc +57 -0
  236. package/docs/reference/interfaces/modules/Score.adoc +107 -0
  237. package/docs/reference/interfaces/modules/Session.adoc +66 -0
  238. package/docs/reference/interfaces/modules/State.adoc +290 -0
  239. package/docs/reference/interfaces/modules/Text.adoc +110 -0
  240. package/docs/reference/interfaces/modules/Time.adoc +119 -0
  241. package/docs/reference/modules/Debugger.adoc +71 -0
  242. package/docs/reference/modules/DisplayRenderer.adoc +55 -0
  243. package/docs/reference/modules/Game.adoc +256 -0
  244. package/docs/reference/modules/GameControl.adoc +139 -0
  245. package/docs/reference/modules/GameGrid.adoc +794 -0
  246. package/docs/reference/modules/GameHudGrid.adoc +38 -0
  247. package/docs/reference/modules/GameMenu.adoc +39 -0
  248. package/docs/reference/modules/GameRenderer.adoc +79 -0
  249. package/docs/reference/modules/GameScore.adoc +138 -0
  250. package/docs/reference/modules/GameSession.adoc +43 -0
  251. package/docs/reference/modules/GameSound.adoc +111 -0
  252. package/docs/reference/modules/GameState.adoc +318 -0
  253. package/docs/reference/modules/GameText.adoc +139 -0
  254. package/docs/reference/modules/GameTime.adoc +141 -0
  255. package/docs/reference/modules/HudRenderer.adoc +56 -0
  256. package/docs/reference/modules/InitialStateSnapshot.adoc +47 -0
  257. package/docs/reference/modules/SessionModal.adoc +34 -0
  258. package/docs/reference/types/Axis.adoc +28 -0
  259. package/docs/reference/types/Cell.adoc +29 -0
  260. package/docs/reference/types/ControlCallback.adoc +23 -0
  261. package/docs/reference/types/Coordinate.adoc +29 -0
  262. package/docs/reference/types/GameEntry.adoc +29 -0
  263. package/docs/reference/types/GameEvent.adoc +29 -0
  264. package/docs/reference/types/Piece.adoc +32 -0
  265. package/docs/reference/types/RendererMetrics.adoc +29 -0
  266. package/docs/reference/types/Vector.adoc +28 -0
  267. package/docs/testing_best_practices.adoc +190 -0
  268. package/eslint.config.mjs +29 -0
  269. package/package.json +54 -0
  270. package/public/CNAME +1 -0
  271. package/public/docs/GAME_DEVELOPER_GUIDE.html +727 -0
  272. package/public/docs/brick-engine-guide.html +610 -0
  273. package/public/docs/diagrams/lifecycle.mmd +19 -0
  274. package/public/docs/documentation_style_guide.html +994 -0
  275. package/public/docs/getting-started.html +648 -0
  276. package/public/docs/images/lifecycle.svg +1 -0
  277. package/public/docs/index.html +593 -0
  278. package/public/docs/jsdoc_standard.html +656 -0
  279. package/public/docs/publishing.html +573 -0
  280. package/public/docs/reference/enums/Color.html +533 -0
  281. package/public/docs/reference/enums/ControlEventType.html +505 -0
  282. package/public/docs/reference/enums/ControlKey.html +529 -0
  283. package/public/docs/reference/enums/FontAlignment.html +545 -0
  284. package/public/docs/reference/enums/FontSize.html +517 -0
  285. package/public/docs/reference/enums/Sound.html +558 -0
  286. package/public/docs/reference/enums/StateProperty.html +525 -0
  287. package/public/docs/reference/helpers/CellHelper.html +520 -0
  288. package/public/docs/reference/helpers/ControlInputHandlerHelper.html +569 -0
  289. package/public/docs/reference/helpers/CoordinateHelper.html +703 -0
  290. package/public/docs/reference/helpers/RelativeValuesHelper.html +560 -0
  291. package/public/docs/reference/interfaces/Debuggable.html +501 -0
  292. package/public/docs/reference/interfaces/GameModules.html +544 -0
  293. package/public/docs/reference/interfaces/Initializable.html +495 -0
  294. package/public/docs/reference/interfaces/RendererInitializable.html +517 -0
  295. package/public/docs/reference/interfaces/StateSyncable.html +542 -0
  296. package/public/docs/reference/interfaces/modules/Control.html +648 -0
  297. package/public/docs/reference/interfaces/modules/Grid.html +1256 -0
  298. package/public/docs/reference/interfaces/modules/Renderer.html +522 -0
  299. package/public/docs/reference/interfaces/modules/RendererComposite.html +577 -0
  300. package/public/docs/reference/interfaces/modules/Score.html +669 -0
  301. package/public/docs/reference/interfaces/modules/Session.html +585 -0
  302. package/public/docs/reference/interfaces/modules/State.html +897 -0
  303. package/public/docs/reference/interfaces/modules/Text.html +668 -0
  304. package/public/docs/reference/interfaces/modules/Time.html +684 -0
  305. package/public/docs/reference/modules/Debugger.html +579 -0
  306. package/public/docs/reference/modules/DisplayRenderer.html +557 -0
  307. package/public/docs/reference/modules/Game.html +909 -0
  308. package/public/docs/reference/modules/GameControl.html +716 -0
  309. package/public/docs/reference/modules/GameGrid.html +1910 -0
  310. package/public/docs/reference/modules/GameHudGrid.html +508 -0
  311. package/public/docs/reference/modules/GameMenu.html +538 -0
  312. package/public/docs/reference/modules/GameRenderer.html +589 -0
  313. package/public/docs/reference/modules/GameScore.html +664 -0
  314. package/public/docs/reference/modules/GameSession.html +533 -0
  315. package/public/docs/reference/modules/GameSound.html +636 -0
  316. package/public/docs/reference/modules/GameState.html +922 -0
  317. package/public/docs/reference/modules/GameText.html +701 -0
  318. package/public/docs/reference/modules/GameTime.html +696 -0
  319. package/public/docs/reference/modules/HudRenderer.html +568 -0
  320. package/public/docs/reference/modules/InitialStateSnapshot.html +557 -0
  321. package/public/docs/reference/modules/SessionModal.html +520 -0
  322. package/public/docs/reference/types/Axis.html +505 -0
  323. package/public/docs/reference/types/Cell.html +514 -0
  324. package/public/docs/reference/types/ControlCallback.html +488 -0
  325. package/public/docs/reference/types/Coordinate.html +510 -0
  326. package/public/docs/reference/types/GameEntry.html +514 -0
  327. package/public/docs/reference/types/GameEvent.html +514 -0
  328. package/public/docs/reference/types/Piece.html +506 -0
  329. package/public/docs/reference/types/RendererMetrics.html +514 -0
  330. package/public/docs/reference/types/Vector.html +509 -0
  331. package/public/docs/testing_best_practices.html +770 -0
  332. package/public/favicon.ico +0 -0
  333. package/public/fonts/digital-7.monoitalic.ttf +0 -0
  334. package/public/images/cell.svg +32 -0
  335. package/public/images/close.png +0 -0
  336. package/public/images/games.png +0 -0
  337. package/public/images/github.png +0 -0
  338. package/public/images/letter-a.png +0 -0
  339. package/public/images/letter-d.png +0 -0
  340. package/public/images/letter-j.png +0 -0
  341. package/public/images/letter-s.png +0 -0
  342. package/public/images/letter-w.png +0 -0
  343. package/public/images/meta-image.png +0 -0
  344. package/public/images/number-1.png +0 -0
  345. package/public/images/number-2.png +0 -0
  346. package/public/images/number-3.png +0 -0
  347. package/public/images/number-4.png +0 -0
  348. package/public/images/number-5.png +0 -0
  349. package/public/images/number-6.png +0 -0
  350. package/public/images/splash.gif +0 -0
  351. package/public/index.html +15 -0
  352. package/public/sounds/sound_00.wav +0 -0
  353. package/public/sounds/sound_01.wav +0 -0
  354. package/public/sounds/sound_02.wav +0 -0
  355. package/public/sounds/sound_03.wav +0 -0
  356. package/public/sounds/sound_04.wav +0 -0
  357. package/public/sounds/sound_05.wav +0 -0
  358. package/public/sounds/sound_06.wav +0 -0
  359. package/public/sounds/sound_07.wav +0 -0
  360. package/public/sounds/sound_08.wav +0 -0
  361. package/public/sounds/sound_09.wav +0 -0
  362. package/public/sounds/sound_10.wav +0 -0
  363. package/public/sounds/sound_11.wav +0 -0
  364. package/public/sounds/sound_12.wav +0 -0
  365. package/public/sounds/sound_13.wav +0 -0
  366. package/public/sounds/sound_14.wav +0 -0
  367. package/public/sounds/sound_15.wav +0 -0
  368. package/public/style/body.css +86 -0
  369. package/public/style/buttons.css +233 -0
  370. package/public/style/debugger.css +117 -0
  371. package/public/style/sessionModal.css +155 -0
  372. package/public/style/sourceCodeAndCommands.css +74 -0
  373. package/public/style/splash.css +13 -0
  374. package/public/style/theme.css +137 -0
  375. package/scripts/generate-diagrams.sh +20 -0
  376. package/scripts/generate-docs.js +111 -0
  377. package/src/client-game.d.ts +1 -0
  378. package/src/config/configs.test.ts +20 -0
  379. package/src/config/configs.ts +197 -0
  380. package/src/config/env.test.ts +59 -0
  381. package/src/config/env.ts +7 -0
  382. package/src/config/styles.ts +5 -0
  383. package/src/core/Game.test.ts +167 -0
  384. package/src/core/Game.ts +307 -0
  385. package/src/core/InitialStateSnapshot.test.ts +51 -0
  386. package/src/core/InitialStateSnapshot.ts +46 -0
  387. package/src/core/helpers/CellHelper.test.ts +33 -0
  388. package/src/core/helpers/CellHelper.ts +21 -0
  389. package/src/core/helpers/ControlInputHandlerHelper.test.ts +116 -0
  390. package/src/core/helpers/ControlInputHandlerHelper.ts +68 -0
  391. package/src/core/helpers/CoordinateHelper.test.ts +113 -0
  392. package/src/core/helpers/CoordinateHelper.ts +82 -0
  393. package/src/core/helpers/InterfaceIdentifierHelper.test.ts +122 -0
  394. package/src/core/helpers/InterfaceIdentifierHelper.ts +43 -0
  395. package/src/core/helpers/RelativeValuesHelper.test.ts +47 -0
  396. package/src/core/helpers/RelativeValuesHelper.ts +29 -0
  397. package/src/core/module/control/GameControl.test.ts +82 -0
  398. package/src/core/module/control/GameControl.ts +142 -0
  399. package/src/core/module/control/GameControlKeyBinding.test.ts +59 -0
  400. package/src/core/module/control/GameControlKeyBinding.ts +92 -0
  401. package/src/core/module/grid/GameGrid.test.ts +83 -0
  402. package/src/core/module/grid/GameGrid.ts +610 -0
  403. package/src/core/module/grid/GameHudGrid.test.ts +22 -0
  404. package/src/core/module/grid/GameHudGrid.ts +40 -0
  405. package/src/core/module/grid/engines/GridAnalysisEngine.test.ts +157 -0
  406. package/src/core/module/grid/engines/GridAnalysisEngine.ts +124 -0
  407. package/src/core/module/grid/engines/GridLineEngine.test.ts +132 -0
  408. package/src/core/module/grid/engines/GridLineEngine.ts +165 -0
  409. package/src/core/module/grid/engines/GridMovementEngine.test.ts +125 -0
  410. package/src/core/module/grid/engines/GridMovementEngine.ts +113 -0
  411. package/src/core/module/grid/engines/GridRegionEngine.test.ts +136 -0
  412. package/src/core/module/grid/engines/GridRegionEngine.ts +52 -0
  413. package/src/core/module/grid/engines/GridTransformEngine.test.ts +98 -0
  414. package/src/core/module/grid/engines/GridTransformEngine.ts +70 -0
  415. package/src/core/module/renderer/DisplayRenderer.test.ts +86 -0
  416. package/src/core/module/renderer/DisplayRenderer.ts +152 -0
  417. package/src/core/module/renderer/GameRenderer.test.ts +103 -0
  418. package/src/core/module/renderer/GameRenderer.ts +144 -0
  419. package/src/core/module/renderer/HudRenderer.test.ts +108 -0
  420. package/src/core/module/renderer/HudRenderer.ts +203 -0
  421. package/src/core/module/score/GameScore.test.ts +71 -0
  422. package/src/core/module/score/GameScore.ts +188 -0
  423. package/src/core/module/session/GameSession.test.ts +176 -0
  424. package/src/core/module/session/GameSession.ts +103 -0
  425. package/src/core/module/sound/GameSound.test.ts +117 -0
  426. package/src/core/module/sound/GameSound.ts +229 -0
  427. package/src/core/module/state/GameState.test.ts +101 -0
  428. package/src/core/module/state/GameState.ts +339 -0
  429. package/src/core/module/text/GameText.test.ts +87 -0
  430. package/src/core/module/text/GameText.ts +150 -0
  431. package/src/core/module/time/GameTime.test.ts +86 -0
  432. package/src/core/module/time/GameTime.ts +144 -0
  433. package/src/core/types/Interfaces.ts +59 -0
  434. package/src/core/types/Types.ts +124 -0
  435. package/src/core/types/enums.ts +113 -0
  436. package/src/core/types/modules.ts +841 -0
  437. package/src/index.test.ts +15 -0
  438. package/src/index.ts +9 -0
  439. package/src/main.test.ts +137 -0
  440. package/src/main.ts +77 -0
  441. package/src/menu/GameMenu.test.ts +157 -0
  442. package/src/menu/GameMenu.ts +124 -0
  443. package/src/menu/GameMenuSingleton.test.ts +26 -0
  444. package/src/menu/GameMenuSingleton.ts +13 -0
  445. package/src/menu/GameRepository.test.ts +46 -0
  446. package/src/menu/GameRepository.ts +47 -0
  447. package/src/menu/manager/GameManager.test.ts +68 -0
  448. package/src/menu/manager/GameManager.ts +50 -0
  449. package/src/types/global.d.ts +8 -0
  450. package/src/types/interfaces.ts +5 -0
  451. package/src/view/Debugger.test.ts +152 -0
  452. package/src/view/Debugger.ts +124 -0
  453. package/src/view/GameView.test.ts +95 -0
  454. package/src/view/GameView.ts +244 -0
  455. package/src/view/SessionModal.test.ts +141 -0
  456. package/src/view/SessionModal.ts +73 -0
  457. package/src/view/components/layout/ButtonLayout.test.ts +28 -0
  458. package/src/view/components/layout/ButtonLayout.ts +63 -0
  459. package/src/view/components/layout/ContainerLayout.test.ts +48 -0
  460. package/src/view/components/layout/ContainerLayout.ts +50 -0
  461. package/src/view/components/layout/FrameLayout.test.ts +24 -0
  462. package/src/view/components/layout/FrameLayout.ts +25 -0
  463. package/src/view/components/ui/BigButton.test.ts +28 -0
  464. package/src/view/components/ui/BigButton.ts +31 -0
  465. package/src/view/components/ui/Button.test.ts +30 -0
  466. package/src/view/components/ui/Button.ts +30 -0
  467. package/src/view/components/ui/Canvas.test.ts +32 -0
  468. package/src/view/components/ui/Canvas.ts +34 -0
  469. package/src/view/components/ui/SmallButton.test.ts +48 -0
  470. package/src/view/components/ui/SmallButton.ts +32 -0
  471. package/src/view/theme/applyColors.test.ts +47 -0
  472. package/src/view/theme/applyColors.ts +38 -0
  473. package/src/view/theme/dimensions.test.ts +34 -0
  474. package/src/view/theme/dimensions.ts +53 -0
  475. package/tsconfig.json +16 -0
  476. package/vitest.config.ts +14 -0
  477. package/webpack.config.js +133 -0
@@ -0,0 +1,2 @@
1
+ SUPABASE_URL="http://127.0.0.1:54321"
2
+ SUPABASE_ANON_KEY=""
@@ -0,0 +1,73 @@
1
+ name: Publish and Deploy
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ - master
8
+
9
+ jobs:
10
+ publish:
11
+ runs-on: ubuntu-latest
12
+ permissions:
13
+ contents: write
14
+ packages: write
15
+
16
+ steps:
17
+ - name: Checkout repository
18
+ uses: actions/checkout@v4
19
+ with:
20
+ fetch-depth: 0 # ensures history is available for tag and push
21
+ token: ${{ secrets.GITHUB_TOKEN }} # Needed to push back to the repository
22
+
23
+ - name: Setup Node.js
24
+ uses: actions/setup-node@v4
25
+ with:
26
+ node-version: '22'
27
+ registry-url: 'https://registry.npmjs.org/'
28
+
29
+ - name: Validate NPM Token
30
+ run: npm whoami
31
+ env:
32
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
33
+
34
+ - name: Install dependencies
35
+ run: npm ci
36
+
37
+ - name: Build project
38
+ run: npm run build
39
+ env:
40
+ SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
41
+ SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }}
42
+
43
+ - name: Configure Git
44
+ run: |
45
+ git config --global user.name 'LeonardoPinheiroLacerda'
46
+ git config --global user.email 'leon.lacerda2015@gmail.com'
47
+
48
+ - name: Bump Version
49
+ run: |
50
+ npm version patch --no-git-tag-version
51
+ VERSION=$(node -p "require('./package.json').version")
52
+ echo "VERSION=$VERSION" >> $GITHUB_ENV
53
+ git add package.json package-lock.json
54
+ git commit -m "chore: bump version to v${VERSION} [skip ci]"
55
+ git tag -a "v${VERSION}" -m "Version ${VERSION}"
56
+
57
+ - name: Push adjustments
58
+ run: |
59
+ git push origin HEAD:${{ github.ref }}
60
+ git push origin --tags
61
+
62
+ - name: Publish to NPM
63
+ run: npm publish --access public
64
+ env:
65
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
66
+
67
+ - name: Create GitHub Release
68
+ env:
69
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70
+ run: |
71
+ gh release create "v${{ env.VERSION }}" \
72
+ --title "Release v${{ env.VERSION }}" \
73
+ --generate-notes
@@ -0,0 +1,2 @@
1
+ package.json
2
+ package-lock.json
@@ -0,0 +1,8 @@
1
+ {
2
+ "trailingComma": "all",
3
+ "singleQuote": true,
4
+ "endOfLine": "lf",
5
+ "tabWidth": 4,
6
+ "arrowParens": "avoid",
7
+ "printWidth": 160
8
+ }
package/README.adoc ADDED
@@ -0,0 +1,84 @@
1
+ = Brick Engine JS Documentation
2
+ :description: Modular TypeScript game engine for retro grid-based games.
3
+ :keywords: typescript, game-engine, retro, grid-based, p5js, modular
4
+ :toc: left
5
+ :toclevels: 3
6
+ :sectnums:
7
+ :sectlinks:
8
+ :icons: font
9
+ :source-highlighter: highlight.js
10
+ :reproducible:
11
+ :experimental:
12
+ :idprefix:
13
+ :idseparator: -
14
+
15
+ == Objective
16
+
17
+ The **Brick Engine** is a modular, TypeScript-based game engine designed for creating retro grid-based games (like Tetris, Snake, Breakout) that run in a browser. It leverages **P5.js** for rendering and simulates the experience of a classic handheld gaming device, complete with a dot-matrix style display, a HUD (Head-Up Display), and physical button controls.
18
+
19
+ == Key Features
20
+
21
+ * **Grid-Based Logic**: Built-in support for 2D grid management, collision detection, and row/column manipulations.
22
+ * **Retro Aesthetic**: Simulates a physical device with customizable colors and responsive layout.
23
+ * **Modular Architecture**: core functionality is split into distinct modules (Grid, Control, Renderer, State, Text, Time, Score) for clean separation of concerns.
24
+ * **Input Handling**: Unified control system supporting keyboard and on-screen button inputs.
25
+ * **Game Loop**: Separated logic ticks (game speed) from rendering frames (60fps smooth animations).
26
+ * **Debugger**: Built-in real-time state inspector. See xref:docs/reference/modules/Debugger.adoc[Debugger Reference].
27
+
28
+ == Getting Started
29
+
30
+ The fastest way to start is using the **Brick Engine CLI**, which scaffolds a complete project with build tools, standard scripts, and a boilerplate `src/index.ts` ready for development.
31
+
32
+ [source,bash]
33
+ ----
34
+ npx brick-engine-cli init my-brick-game
35
+ ----
36
+
37
+ For a detailed walkthrough on installation, project structure, and how to implement your game logic, see our **xref:docs/getting-started.adoc[Getting Started Guide]**.
38
+
39
+ == Publishing Your Game
40
+
41
+ Once your game is ready, you can bundle and publish it directly to the Brick Engine library using the CLI. This will submit your game for review and make it available in the main engine menu.
42
+
43
+ [source,bash]
44
+ ----
45
+ npx brick-engine-cli publish
46
+ ----
47
+
48
+ For detailed information about the publishing and review process, see the **xref:docs/publishing.adoc[Publishing Guide]**.
49
+
50
+ == Structure
51
+
52
+ The engine is organized into the following core modules:
53
+
54
+ [cols="1,3", options="header"]
55
+ |===
56
+ | Module | Description
57
+
58
+ | xref:docs/reference/modules/Game.adoc[Game (Core)]
59
+ | The central orchestrator. It manages the main loop (ticks and frames), and coordinates dynamic game loading and transitions via an instance-based switch handler.
60
+
61
+ | xref:docs/reference/modules/GameGrid.adoc[GameGrid]
62
+ | Manages the 2D grid data structure. Handles cell values, colors, row/column operations, and collision detection. Includes `GameHudGrid` for custom HUD content.
63
+
64
+ | xref:docs/reference/modules/GameControl.adoc[GameControl]
65
+ | The input system. Abstracts physical keys into virtual actions (UP, DOWN, ACTION) and provides an event subscription API.
66
+
67
+ | xref:docs/reference/modules/GameRenderer.adoc[GameRenderer]
68
+ | Handles visual representation. Draws the grid, cells, and UI elements to the canvas using P5.js.
69
+
70
+ | xref:docs/reference/modules/GameState.adoc[GameState]
71
+ | Tracks global game properties (playing, paused, score) and supports state persistence.
72
+
73
+ | xref:docs/reference/modules/GameText.adoc[GameText]
74
+ | Specialized renderer for drawing retro-style pixelated text on the HUD and main display.
75
+
76
+ | xref:docs/reference/modules/GameTime.adoc[GameTime]
77
+ | Controls game loop timing, separating logic updates (Ticks) from visual rendering (Frames).
78
+
79
+ | xref:docs/reference/modules/GameSound.adoc[GameSound]
80
+ | Manages audio playback using the Web Audio API, supporting simultaneous sounds and volume control.
81
+
82
+ | xref:docs/reference/modules/GameScore.adoc[GameScore]
83
+ | Tracks session score, level logic, and syncs high scores with `GameState`.
84
+ |===
@@ -0,0 +1,32 @@
1
+ <?xml version="1.0" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
3
+ "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
4
+ <svg version="1.0" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 3 3">
5
+
6
+ <rect
7
+ x="0"
8
+ y="0"
9
+ width="3"
10
+ height="3"
11
+ fill="rgb(172, 189, 173)"
12
+ />
13
+
14
+ <rect
15
+ x="0.3"
16
+ y="0.3"
17
+ width="2.5"
18
+ height="2.5"
19
+ stroke="rgb(161, 178, 160)"
20
+ stroke-width=".2"
21
+ fill="none"
22
+ />
23
+
24
+ <rect
25
+ x=".8"
26
+ y=".8"
27
+ width="1.5"
28
+ height="1.5"
29
+ fill="rgb(161, 178, 160)"
30
+ />
31
+
32
+ </svg>
package/dist/CNAME ADDED
@@ -0,0 +1 @@
1
+ brickengine.com.br
package/dist/app.js ADDED
@@ -0,0 +1,2 @@
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("p5")):"function"==typeof define&&define.amd?define(["p5"],e):"object"==typeof exports?exports.BrickEngine=e(require("p5")):t.BrickEngine=e(t.p5)}(self,t=>(()=>{var e={902(t,e,i){"use strict";i.r(e)},35(t,e,i){"use strict";i.r(e)},287(t,e,i){"use strict";i.r(e)},949(t,e,i){"use strict";i.r(e)},545(t,e,i){"use strict";i.r(e)},623(t,e,i){"use strict";i.r(e)},839(t,e,i){"use strict";i.r(e)},257(t,e,i){i(881)},881(t,e,i){var n={"./body.css":902,"./buttons.css":35,"./debugger.css":287,"./sessionModal.css":949,"./sourceCodeAndCommands.css":545,"./splash.css":623,"./theme.css":839};function r(t){var e=o(t);return i(e)}function o(t){if(!i.o(n,t)){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}return n[t]}r.keys=function(){return Object.keys(n)},r.resolve=o,t.exports=r,r.id=881},991(e){"use strict";e.exports=t}},i={};function n(t){var r=i[t];if(void 0!==r)return r.exports;var o=i[t]={exports:{}};return e[t](o,o.exports,n),o.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};return(()=>{"use strict";n.r(r),n.d(r,{p5Instance:()=>be});var t=n(991),e=n.n(t);const i={background:"rgb(172, 189, 173)",active:"rgb(19, 26, 18)",inactive:"rgba(161, 178, 160, 1)",bodyMain:"rgb(0, 68, 187)",bodyButton:"rgb(247, 222, 57)"},o={columns:11,rows:18},s={width:.65,height:.956,margin:.022,borderWeight:.0075},a={extraSmall:.05,small:.065,medium:.1,large:.125,extraLarge:.15},u={margin:.1,padding:.3,strokeWeight:.075},c=1.9,l=600,h={widthRatio:.7,aspectRatio:1.114},p=250,d={borderRadiusRatio:.05,borderWidthRatio:.006,button:{smSizeRatio:.08,mdSizeRatio:.18,lgSizeRatio:.25,mobile:{smSizeRatio:.13,mdSizeRatio:.26,lgSizeRatio:.35,fontRatio:.05,smFontRatio:.04,lgFontRatio:.055,spacingRatio:.018},borderRatio:.0045,animationDuration:"0.15s"}},f="3px",g="body-color",y="button-color",_="#brick-game",v="#splash",m={canvas:"brick-game-canvas",container:"container",frame:"frame",buttonContainer:"button-container",smallButtonContainer:"small-button-container",innerButtonContainer:"inner-button-container",mediumButtonContainer:"medium-button-container",directionVerticalContainer:"direction-vertical-container",directionHorizontalContainer:"direction-horizontal-container",largeButtonContainer:"large-button-container"},b=250,w=50,E=1e3/30,x=1e3/60,S={msInterval:100,enabled:!0},C={volume:.025};var R,P,O,T,M,D,A,I,G={grad:.9,turn:360,rad:360/(2*Math.PI)},L=function(t){return"string"==typeof t?t.length>0:"number"==typeof t},B=function(t,e,i){return void 0===e&&(e=0),void 0===i&&(i=Math.pow(10,e)),Math.round(i*t)/i+0},k=function(t,e,i){return void 0===e&&(e=0),void 0===i&&(i=1),t>i?i:t>e?t:e},z=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},N=function(t){return{r:k(t.r,0,255),g:k(t.g,0,255),b:k(t.b,0,255),a:k(t.a)}},H=function(t){return{r:B(t.r),g:B(t.g),b:B(t.b),a:B(t.a,3)}},F=/^#([0-9a-f]{3,8})$/i,j=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},U=function(t){var e=t.r,i=t.g,n=t.b,r=t.a,o=Math.max(e,i,n),s=o-Math.min(e,i,n),a=s?o===e?(i-n)/s:o===i?2+(n-e)/s:4+(e-i)/s:0;return{h:60*(a<0?a+6:a),s:o?s/o*100:0,v:o/255*100,a:r}},W=function(t){var e=t.h,i=t.s,n=t.v,r=t.a;e=e/360*6,i/=100,n/=100;var o=Math.floor(e),s=n*(1-i),a=n*(1-(e-o)*i),u=n*(1-(1-e+o)*i),c=o%6;return{r:255*[n,a,s,s,u,n][c],g:255*[u,n,n,a,s,s][c],b:255*[s,s,u,n,n,a][c],a:r}},V=function(t){return{h:z(t.h),s:k(t.s,0,100),l:k(t.l,0,100),a:k(t.a)}},K=function(t){return{h:B(t.h),s:B(t.s),l:B(t.l),a:B(t.a,3)}},Y=function(t){return W((i=(e=t).s,{h:e.h,s:(i*=((n=e.l)<50?n:100-n)/100)>0?2*i/(n+i)*100:0,v:n+i,a:e.a}));var e,i,n},X=function(t){return{h:(e=U(t)).h,s:(r=(200-(i=e.s))*(n=e.v)/100)>0&&r<200?i*n/100/(r<=100?r:200-r)*100:0,l:r/2,a:e.a};var e,i,n,r},J=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,q=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,$=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Q=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Z={string:[[function(t){var e=F.exec(t);return e?(t=e[1]).length<=4?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:4===t.length?B(parseInt(t[3]+t[3],16)/255,2):1}:6===t.length||8===t.length?{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16),a:8===t.length?B(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=$.exec(t)||Q.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:N({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:void 0===e[7]?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(t){var e=J.exec(t)||q.exec(t);if(!e)return null;var i,n,r=V({h:(i=e[1],n=e[2],void 0===n&&(n="deg"),Number(i)*(G[n]||1)),s:Number(e[3]),l:Number(e[4]),a:void 0===e[5]?1:Number(e[5])/(e[6]?100:1)});return Y(r)},"hsl"]],object:[[function(t){var e=t.r,i=t.g,n=t.b,r=t.a,o=void 0===r?1:r;return L(e)&&L(i)&&L(n)?N({r:Number(e),g:Number(i),b:Number(n),a:Number(o)}):null},"rgb"],[function(t){var e=t.h,i=t.s,n=t.l,r=t.a,o=void 0===r?1:r;if(!L(e)||!L(i)||!L(n))return null;var s=V({h:Number(e),s:Number(i),l:Number(n),a:Number(o)});return Y(s)},"hsl"],[function(t){var e=t.h,i=t.s,n=t.v,r=t.a,o=void 0===r?1:r;if(!L(e)||!L(i)||!L(n))return null;var s=function(t){return{h:z(t.h),s:k(t.s,0,100),v:k(t.v,0,100),a:k(t.a)}}({h:Number(e),s:Number(i),v:Number(n),a:Number(o)});return W(s)},"hsv"]]},tt=function(t,e){for(var i=0;i<e.length;i++){var n=e[i][0](t);if(n)return[n,e[i][1]]}return[null,void 0]},et=function(t,e){var i=X(t);return{h:i.h,s:k(i.s+100*e,0,100),l:i.l,a:i.a}},it=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},nt=function(t,e){var i=X(t);return{h:i.h,s:i.s,l:k(i.l+100*e,0,100),a:i.a}},rt=function(){function t(t){this.parsed=function(t){return"string"==typeof t?tt(t.trim(),Z.string):"object"==typeof t&&null!==t?tt(t,Z.object):[null,void 0]}(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return t.prototype.isValid=function(){return null!==this.parsed},t.prototype.brightness=function(){return B(it(this.rgba),2)},t.prototype.isDark=function(){return it(this.rgba)<.5},t.prototype.isLight=function(){return it(this.rgba)>=.5},t.prototype.toHex=function(){return e=(t=H(this.rgba)).r,i=t.g,n=t.b,o=(r=t.a)<1?j(B(255*r)):"","#"+j(e)+j(i)+j(n)+o;var t,e,i,n,r,o},t.prototype.toRgb=function(){return H(this.rgba)},t.prototype.toRgbString=function(){return e=(t=H(this.rgba)).r,i=t.g,n=t.b,(r=t.a)<1?"rgba("+e+", "+i+", "+n+", "+r+")":"rgb("+e+", "+i+", "+n+")";var t,e,i,n,r},t.prototype.toHsl=function(){return K(X(this.rgba))},t.prototype.toHslString=function(){return e=(t=K(X(this.rgba))).h,i=t.s,n=t.l,(r=t.a)<1?"hsla("+e+", "+i+"%, "+n+"%, "+r+")":"hsl("+e+", "+i+"%, "+n+"%)";var t,e,i,n,r},t.prototype.toHsv=function(){return t=U(this.rgba),{h:B(t.h),s:B(t.s),v:B(t.v),a:B(t.a,3)};var t},t.prototype.invert=function(){return ot({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},t.prototype.saturate=function(t){return void 0===t&&(t=.1),ot(et(this.rgba,t))},t.prototype.desaturate=function(t){return void 0===t&&(t=.1),ot(et(this.rgba,-t))},t.prototype.grayscale=function(){return ot(et(this.rgba,-1))},t.prototype.lighten=function(t){return void 0===t&&(t=.1),ot(nt(this.rgba,t))},t.prototype.darken=function(t){return void 0===t&&(t=.1),ot(nt(this.rgba,-t))},t.prototype.rotate=function(t){return void 0===t&&(t=15),this.hue(this.hue()+t)},t.prototype.alpha=function(t){return"number"==typeof t?ot({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):B(this.rgba.a,3);var e},t.prototype.hue=function(t){var e=X(this.rgba);return"number"==typeof t?ot({h:t,s:e.s,l:e.l,a:e.a}):B(e.h)},t.prototype.isEqual=function(t){return this.toHex()===ot(t).toHex()},t}(),ot=function(t){return t instanceof rt?t:new rt(t)};function st(t,e,i){var n=t.createDiv();n.parent(e),n.addClass("btn-container");var r=t.createButton(i);return r.parent(n),r.addClass("btn"),r}function at(t,e,i,n){var r=t.createDiv();r.parent(e),r.addClass("sm-btn-container"),r.addClass(n?"sm-btn-container-top":"sm-btn-container-bottom");var o=t.createButton("");o.parent(r),o.addClass("sm-btn");var s=t.createP(i);return s.parent(r),s.addClass("sm-btn-p"),o}!function(t){t.DEFAULT="rgb(19, 26, 18)",t.BLUE="rgb(0, 0, 128)",t.CYAN="rgb(0, 128, 128)",t.GRAY="rgb(128, 128, 128)",t.GREEN="rgb(0, 128, 0)",t.PURPLE="rgb(128, 0, 128)",t.RED="rgb(128, 0, 0)",t.YELLOW="rgb(128, 128, 0)",t.INACTIVE="rgb(166, 183, 165)"}(R||(R={})),function(t){t.CENTER="center",t.LEFT="left",t.RIGHT="right"}(P||(P={})),function(t){t[t.EXTRA_SMALL=0]="EXTRA_SMALL",t[t.SMALL=1]="SMALL",t[t.MEDIUM=2]="MEDIUM",t[t.LARGE=3]="LARGE",t[t.EXTRA_LARGE=4]="EXTRA_LARGE"}(O||(O={})),function(t){t.CENTER="center",t.TOP="top",t.BOTTOM="bottom"}(T||(T={})),function(t){t.SPAWN="./sounds/sound_01.wav",t.SCORE_1="./sounds/sound_15.wav",t.SCORE_2="./sounds/sound_03.wav",t.SCORE_3="./sounds/sound_02.wav",t.KEY_PRESS="./sounds/sound_14.wav",t.ACTION_1="./sounds/sound_05.wav",t.ACTION_2="./sounds/sound_13.wav",t.HIT_1="./sounds/sound_06.wav",t.HIT_2="./sounds/sound_08.wav",t.DODGE="./sounds/sound_07.wav",t.DROP="./sounds/sound_11.wav",t.EXPLOSION="./sounds/sound_09.wav",t.GAME_START="./sounds/sound_04.wav",t.SHOT="./sounds/sound_12.wav",t.START_THEME="./sounds/sound_10.wav"}(M||(M={})),function(t){t.UP="up;control",t.DOWN="down;control",t.LEFT="left;control",t.RIGHT="right;control",t.ACTION="action;control",t.POWER="power;system",t.START_PAUSE="start_pause;system",t.SOUND="sound;system",t.RESET="reset;system",t.EXIT="exit;system",t.COLOR="color;system"}(D||(D={})),function(t){t.PRESSED="pressed",t.HELD="held"}(A||(A={})),function(t){t.ON="on",t.START="start",t.PLAYING="playing",t.GAME_OVER="gameOver",t.COLOR_ENABLED="colorEnabled",t.MUTED="muted"}(I||(I={}));const ut=function(){function t(t){this._activeKeys=new Map,this._control=t}return t.prototype.handlePress=function(t){var e=this;if(!this._activeKeys.has(t)){this._control.notify(t,A.PRESSED);var i=setTimeout(function(){var i=setInterval(function(){e._control.notify(t,A.HELD)},w),n=e._activeKeys.get(t);n&&(n.hold=i)},b);this._activeKeys.set(t,{delay:i,hold:null})}},t.prototype.handleRelease=function(t){var e=this._activeKeys.get(t);e&&(clearTimeout(e.delay),e.hold&&clearInterval(e.hold),this._activeKeys.delete(t))},t}();var ct=function(){function t(t,e){this._moduleElements=[],this._gameModules=t,this._p=e}return t.prototype.setup=function(){var t=this;if(S.enabled){var e=this._p.select("#debugger"),i=!!e&&e.elt.hasAttribute("open"),n=new Set;e&&(this._p.selectAll(".debugger-module").forEach(function(t){t.elt.hasAttribute("open")&&n.add(t.id())}),e.remove()),this._moduleElements=[];var r=this._p.createElement("details");r.id("debugger"),i&&r.attribute("open",""),r.parent(this._p.select("body"));var o=this._p.createElement("summary");o.id("debugger-summary"),o.html("Debug"),o.parent(r),Object.entries(this._gameModules).forEach(function(e){var i=e[0],o=e[1];if("getDebugData"in o){var s={module:o,properties:[]},a=t._p.createElement("details");a.class("debugger-module"),a.id("debugger-".concat(i)),n.has("debugger-".concat(i))&&a.attribute("open",""),a.parent(r);var u=t._p.createElement("summary");u.id("debugger-".concat(i,"-summary")),u.html(i),u.class("debugger-module-summary"),u.parent(a);var c=o.getDebugData();Object.entries(c).forEach(function(e){var i=e[0],n=e[1],r=t._p.createElement("div");r.class("debugger-container"),r.id("debugger-container-".concat(i,"-").concat(n)),r.parent(a),r.mouseClicked(function(){r.toggleClass("highlight")});var o=t._p.createElement("p");o.id("debugger-".concat(i,"-").concat(n)),o.html("".concat(i,":")),o.parent(r);var u=t._p.createElement("span");u.id("debugger-".concat(i,"-").concat(n,"-value")),u.html("".concat(n)),u.parent(r),s.properties.push({key:i,element:u})}),t._moduleElements.push(s)}})}},t.prototype.setGameModules=function(t){this._gameModules=t,this.setup()},t.prototype.update=function(){this._moduleElements.forEach(function(t){var e=t.module.getDebugData();t.properties.forEach(function(t){t.element.html("".concat(e[t.key]))})})},t}();const lt=ct;var ht=function(){function t(t){this._p=t}return t.prototype.setup=function(){this._container=this._p.createDiv(),this._container.parent(this._p.select("body")),this._container.id("modal-background"),this._container.class("hidden");var t=this._p.createDiv();t.parent(this._container),t.id("session-modal");var e=this._p.createDiv();e.parent(t),e.id("session-modal-frame");var i=this._p.createP();i.parent(e),i.html("Brick Engine Session");var n=this._p.createDiv();n.parent(e),n.id("session-modal-screen");var r=this._p.createP();r.parent(n),r.html("<span>Looks like you have an active session.</span><br><br>Do you want to continue?");var o=this._p.createDiv();o.parent(t),o.id("session-modal-buttons"),this._cancelButton=this._p.createButton("Cancel"),this._cancelButton.parent(o),this._cancelButton.class("session-modal-button"),this._confirmButton=this._p.createButton("Confirm"),this._confirmButton.parent(o),this._confirmButton.class("session-modal-button")},t.prototype.show=function(t,e){var i=this;this._confirmButton.mousePressed(function(){t(),i._hide()}),this._cancelButton.mousePressed(function(){e(),i._hide()}),this._container.removeClass("hidden")},t.prototype._hide=function(){this._confirmButton.mousePressed(null),this._cancelButton.mousePressed(null),this._container.addClass("hidden")},t}();const pt=ht;var dt=function(){function t(t,e){this._parent=e,this._p=t}return t.prototype.isBodyBuilt=function(){return null!=this._cachedCanvas},t.prototype.build=function(){if(this._cachedCanvas)return this._cachedCanvas;var t,e,n,r,o;t=document.querySelector(":root"),e=window.location.href.substring(window.location.href.indexOf("?")+1),r=(n=new URLSearchParams(e)).has(g)?n.get(g):i.bodyMain,o=n.has(y)?n.get(y):i.bodyButton,t.style.setProperty("--main-color",r),t.style.setProperty("--button-color",o),t.style.setProperty("--color-shadow",ot(r).darken(.15).toHex()),t.style.setProperty("--color-shadow-reflexion",ot(r).lighten(.15).toHex()),t.style.setProperty("--button-color-reflexion",ot(o).lighten(.15).toHex()),t.style.setProperty("--button-color-shadow",ot(o).darken(.15).toHex());var s=function(t,e){var i,n=t.createDiv();if(n.parent(_),n.id(m.container),e.clientWidth<=l)return{container:n,width:i=e.clientWidth,height:e.clientHeight};var r=e.clientHeight/(1.05*c);return{container:n,width:i=Math.min(e.clientWidth,r),height:i*c}}(this._p,this._parent),a=s.container,u=s.height,p=s.width,v=function(t,e){var i=t.createDiv();i.parent(e),i.id(m.frame);var n=t.createDiv();return n.parent(i),t.createP("Brick Game").parent(n),i}(this._p,a),b=function(t,e,i){var n=i*h.widthRatio,r=n*h.aspectRatio,o=t.createCanvas(n,r);return o.parent(e),o.id(m.canvas),{canvasWidth:n,canvasHeight:r,canvas:o}}(this._p,v,p),w=b.canvas,E=b.canvasHeight,x=b.canvasWidth,S=function(t,e){var i=t.createDiv();i.parent(e),i.id(m.buttonContainer);var n=t.createDiv();n.parent(i),n.id(m.smallButtonContainer);var r=t.createDiv();r.parent(i),r.id(m.innerButtonContainer);var o=t.createDiv();o.parent(r),o.id(m.mediumButtonContainer);var s=t.createDiv();s.parent(o),s.id(m.directionVerticalContainer);var a=t.createDiv();a.parent(o),a.id(m.directionHorizontalContainer);var u=t.createDiv();return u.parent(r),u.id(m.largeButtonContainer),{smallButtonContainer:n,mediumButtonContainer:o,largeButtonContainer:u,directionVerticalContainer:s,directionHorizontalContainer:a}}(this._p,a),C=S.largeButtonContainer,R=S.smallButtonContainer,P=S.directionHorizontalContainer,O=S.directionVerticalContainer;return this._onOffBtn=at(this._p,R,"On<br/>Off",!0),this._startPauseBtn=at(this._p,R,"Start<br/>Pause",!1),this._soundBtn=at(this._p,R,"Sound",!0),this._resetBtn=at(this._p,R,"Reset",!1),this._exitBtn=at(this._p,R,"Exit",!0),this._enableColorBtn=at(this._p,R,"Enable<br/>Colors",!1),this._upBtn=st(this._p,O,"UP"),this._leftBtn=st(this._p,P,"LEFT"),this._downBtn=st(this._p,O,"DOWN"),this._rightBtn=st(this._p,P,"RIGHT"),this._actionBtn=function(t,e){var i=t.createDiv();i.parent(e),i.addClass("lg-btn-container");var n=t.createButton("Action");return n.parent(i),n.addClass("lg-btn"),n}(this._p,C),function(t,e,i,n){var r=document.querySelector(":root");r.style.setProperty("--dispersion",f),r.style.setProperty("--width","".concat(t,"px")),r.style.setProperty("--height","".concat(e,"px")),r.style.setProperty("--canvas-width","".concat(i,"px")),r.style.setProperty("--canvas-height","".concat(n,"px")),r.style.setProperty("--border-radius","".concat(t*d.borderRadiusRatio,"px")),r.style.setProperty("--border","".concat(t*d.borderWidthRatio,"px solid black")),r.style.setProperty("--sm-button-size","".concat(t*d.button.smSizeRatio,"px")),r.style.setProperty("--button-size","".concat(t*d.button.mdSizeRatio,"px")),r.style.setProperty("--lg-button-size","".concat(t*d.button.lgSizeRatio,"px")),r.style.setProperty("--sm-button-size-mobile","".concat(t*d.button.mobile.smSizeRatio,"px")),r.style.setProperty("--button-size-mobile","".concat(t*d.button.mobile.mdSizeRatio,"px")),r.style.setProperty("--lg-button-size-mobile","".concat(t*d.button.mobile.lgSizeRatio,"px")),r.style.setProperty("--sm-button-size-mobile-font-size","".concat(t*d.button.mobile.smFontRatio,"px")),r.style.setProperty("--sm-button-size-mobile-line-height","".concat(t*d.button.mobile.smFontRatio,"px")),r.style.setProperty("--button-size-mobile-font-size","".concat(t*d.button.mobile.fontRatio,"px")),r.style.setProperty("--lg-button-size-mobile-font-size","".concat(t*d.button.mobile.lgFontRatio,"px")),r.style.setProperty("--button-size-mobile-spacing","".concat(t*d.button.mobile.spacingRatio,"px")),r.style.setProperty("--button-border","".concat(t*d.button.borderRatio,"px solid black")),r.style.setProperty("--button-animation-duration",d.button.animationDuration)}(p,u,x,E),this._hideSplash(),this._cachedCanvas={canvas:w,canvasWidth:x,canvasHeight:E},this._cachedCanvas},t.prototype.setupSessionModal=function(){this._sessionModal=new pt(this._p),this._sessionModal.setup()},t.prototype.showSessionModal=function(t,e){this._sessionModal.show(t,e)},t.prototype.setupDebugger=function(t){this._debugger=new lt(t,this._p),this._debugger.setup()},t.prototype.updateDebuggerGameModules=function(t){this._debugger.setGameModules(t)},t.prototype.updateDebugger=function(){this._debugger.update()},t.prototype.bindControls=function(t){this._inputHandler=new ut(t),this._bindButtonEvents(this._onOffBtn,D.POWER),this._bindButtonEvents(this._startPauseBtn,D.START_PAUSE),this._bindButtonEvents(this._soundBtn,D.SOUND),this._bindButtonEvents(this._resetBtn,D.RESET),this._bindButtonEvents(this._exitBtn,D.EXIT),this._bindButtonEvents(this._enableColorBtn,D.COLOR),this._bindButtonEvents(this._upBtn,D.UP),this._bindButtonEvents(this._downBtn,D.DOWN),this._bindButtonEvents(this._rightBtn,D.RIGHT),this._bindButtonEvents(this._leftBtn,D.LEFT),this._bindButtonEvents(this._actionBtn,D.ACTION)},t.prototype.unbindControls=function(){this._onOffBtn.mousePressed(function(){}).mouseReleased(function(){}),this._startPauseBtn.mousePressed(function(){}).mouseReleased(function(){}),this._soundBtn.mousePressed(function(){}).mouseReleased(function(){}),this._resetBtn.mousePressed(function(){}).mouseReleased(function(){}),this._exitBtn.mousePressed(function(){}).mouseReleased(function(){}),this._enableColorBtn.mousePressed(function(){}).mouseReleased(function(){}),this._upBtn.mousePressed(function(){}).mouseReleased(function(){}),this._downBtn.mousePressed(function(){}).mouseReleased(function(){}),this._rightBtn.mousePressed(function(){}).mouseReleased(function(){}),this._leftBtn.mousePressed(function(){}).mouseReleased(function(){}),this._actionBtn.mousePressed(function(){}).mouseReleased(function(){})},t.prototype._bindButtonEvents=function(t,e){var i=this;t.mousePressed(function(){return i._inputHandler.handlePress(e)}),t.mouseReleased(function(){return i._inputHandler.handleRelease(e)}),t.mouseOut(function(){return i._inputHandler.handleRelease(e)})},t.prototype._hideSplash=function(t){void 0===t&&(t=p);var e=document.querySelector(v);setTimeout(function(){e.style.display="none"},t)},t}();const ft=dt;var gt={ArrowUp:D.UP,ArrowDown:D.DOWN,ArrowLeft:D.LEFT,ArrowRight:D.RIGHT,KeyW:D.UP,KeyS:D.DOWN,KeyA:D.LEFT,KeyD:D.RIGHT,KeyJ:D.ACTION,Digit1:D.POWER,Digit2:D.START_PAUSE,Digit3:D.SOUND,Digit4:D.RESET,Digit5:D.EXIT,Digit6:D.COLOR};const yt=function(){function t(t){this._inputHandler=new ut(t),this._boundHandleKeyDown=this._handleKeyDown.bind(this),this._boundHandleKeyUp=this._handleKeyUp.bind(this)}return t.prototype.bindControls=function(){window.addEventListener("keydown",this._boundHandleKeyDown),window.addEventListener("keyup",this._boundHandleKeyUp)},t.prototype.unbindControls=function(){window.removeEventListener("keydown",this._boundHandleKeyDown),window.removeEventListener("keyup",this._boundHandleKeyUp)},t.prototype._handleKeyDown=function(t){var e=gt[t.code];e&&(t.repeat||this._inputHandler.handlePress(e))},t.prototype._handleKeyUp=function(t){var e=gt[t.code];e&&this._inputHandler.handleRelease(e)},t}();var _t=function(){function t(){this._subscribers=new Map}return t.prototype.setup=function(){this._keyBinding=new yt(this),this._keyBinding.bindControls()},t.prototype.unbindControls=function(){this._keyBinding.unbindControls(),this._subscribers.clear()},t.prototype.bindControls=function(){this._keyBinding.bindControls()},t.prototype.setModules=function(t){this._modules=t},t.prototype.subscribe=function(t,e,i){this._subscribers.has(t)||this._subscribers.set(t,new Map);var n=this._subscribers.get(t);n.has(e)||n.set(e,new Set),n.get(e).add(i)},t.prototype.unsubscribe=function(t,e,i){var n=this._subscribers.get(t);if(n){var r=n.get(e);r&&r.delete(i)}},t.prototype.notify=function(t,e){var i;if(!this._modules)throw new Error("Modules not initialized");var n={key:t,type:e,modules:this._modules},r=this._modules.state,o=!1;r.isOff()?o=t===D.POWER:!r.isStarted()||r.isPlaying()||r.isGameOver()?o=!0:r.isPaused()&&(o=t.endsWith(";system"));var s=null===(i=this._subscribers.get(t))||void 0===i?void 0:i.get(e);s&&o&&s.forEach(function(t){return t(n)})},t.prototype.getDebugData=function(){var t=0;return this._subscribers.forEach(function(e){e.forEach(function(e){t+=e.size})}),{total_subscribers:t,tracked_keys:this._subscribers.size}},t}();const vt=_t,mt=function(){function t(){}return t.emptyCell=function(t){return{value:0,color:R.DEFAULT,coordinate:t}},t}();var bt=function(){return bt=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},bt.apply(this,arguments)},wt=function(){function t(t){this.grid=t}return t.prototype.movePiece=function(t,e){var i=this,n=t.map(function(t){return bt(bt({},t),{coordinate:{x:t.coordinate.x+(e.x||0),y:t.coordinate.y+(e.y||0)}})}),r=n.some(function(e){return!i.grid.isValidCoordinate(e.coordinate)||i.grid.isCellActive(e.coordinate)&&(n=e.coordinate,!t.some(function(t){return t.coordinate.x===n.x&&t.coordinate.y===n.y}));var n});return r?null:n},t.prototype.movePieceLeft=function(t){return this.movePiece(t,{x:-1,y:0})},t.prototype.movePieceRight=function(t){return this.movePiece(t,{x:1,y:0})},t.prototype.movePieceUp=function(t){return this.movePiece(t,{x:0,y:-1})},t.prototype.movePieceDown=function(t){return this.movePiece(t,{x:0,y:1})},t.prototype.moveCell=function(t,e){var i={x:t.coordinate.x+(e.x||0),y:t.coordinate.y+(e.y||0)};return!this.grid.isValidCoordinate(i)||this.grid.isCellActive(i)?null:bt(bt({},t),{coordinate:i})},t.prototype.moveCellLeft=function(t){return this.moveCell(t,{x:-1,y:0})},t.prototype.moveCellRight=function(t){return this.moveCell(t,{x:1,y:0})},t.prototype.moveCellUp=function(t){return this.moveCell(t,{x:0,y:-1})},t.prototype.moveCellDown=function(t){return this.moveCell(t,{x:0,y:1})},t.prototype.getDropPath=function(t){for(var e=t,i=this.movePieceDown(e);null!==i;)e=i,i=this.movePieceDown(e);return e},t.prototype.getRisePath=function(t){for(var e=t,i=this.movePieceUp(e);null!==i;)e=i,i=this.movePieceUp(e);return e},t.prototype.getReachPathLeft=function(t){for(var e=t,i=this.movePieceLeft(e);null!==i;)e=i,i=this.movePieceLeft(e);return e},t.prototype.getReachPathRight=function(t){for(var e=t,i=this.movePieceRight(e);null!==i;)e=i,i=this.movePieceRight(e);return e},t}();const Et=wt;var xt=function(){return xt=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},xt.apply(this,arguments)},St=function(){function t(t){this.grid=t}return t.prototype.rotatePiece=function(t,e,i){var n=this;void 0===i&&(i=!0);var r=t.map(function(t){var n=t.coordinate.x-e.x,r=t.coordinate.y-e.y,o=i?-r:r,s=i?n:-n;return xt(xt({},t),{coordinate:{x:e.x+o,y:e.y+s}})}),o=r.some(function(e){return!n.grid.isValidCoordinate(e.coordinate)||n.grid.isCellActive(e.coordinate)&&(i=e.coordinate,!t.some(function(t){return t.coordinate.x===i.x&&t.coordinate.y===i.y}));var i});return o?null:r},t.prototype.mirrorPiece=function(t,e){if(0===t.length)return[];var i=this.getPieceBounds(t),n="x"===e?(i.min.x+i.max.x)/2:(i.min.y+i.max.y)/2;return t.map(function(t){return xt(xt({},t),{coordinate:{x:"x"===e?Math.round(2*n-t.coordinate.x):t.coordinate.x,y:"y"===e?Math.round(2*n-t.coordinate.y):t.coordinate.y}})})},t.prototype.getPieceBounds=function(t){var e=t.map(function(t){return t.coordinate.x}),i=t.map(function(t){return t.coordinate.y});return{min:{x:Math.min.apply(Math,e),y:Math.min.apply(Math,i)},max:{x:Math.max.apply(Math,e),y:Math.max.apply(Math,i)}}},t}();const Ct=St;var Rt=function(){return Rt=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},Rt.apply(this,arguments)},Pt=function(){function t(t){this.grid=t}return t.prototype.getFullRows=function(){for(var t=[],e=0;e<this.grid.height;e++){for(var i=!0,n=0;n<this.grid.width;n++)if(!this.grid.isCellActive({x:n,y:e})){i=!1;break}i&&t.push(e)}return t},t.prototype.getFullColumns=function(){for(var t=[],e=0;e<this.grid.width;e++){for(var i=!0,n=0;n<this.grid.height;n++)if(!this.grid.isCellActive({x:e,y:n})){i=!1;break}i&&t.push(e)}return t},t.prototype.getNeighbors=function(t,e){var i=this;void 0===e&&(e=!1);var n=[],r=[{x:-1,y:0},{x:1,y:0},{x:0,y:-1},{x:0,y:1}];return e&&r.push({x:-1,y:-1},{x:1,y:-1},{x:-1,y:1},{x:1,y:1}),r.forEach(function(e){var r={x:t.x+e.x,y:t.y+e.y};i.grid.isValidCoordinate(r)&&n.push(i.grid.getCell(r))}),n},t.prototype.findConnectedCells=function(t){var e=this;if(!this.grid.isCellActive(t))return[];var i=this.grid.getCell(t).value,n=[],r=new Set,o=[t],s=function(t){return"".concat(t.x,",").concat(t.y)};for(r.add(s(t));o.length>0;){var a=o.shift(),u=this.grid.getCell(a);u.value===i&&(n.push(u),[{x:a.x-1,y:a.y},{x:a.x+1,y:a.y},{x:a.x,y:a.y-1},{x:a.x,y:a.y+1}].forEach(function(t){var i=s(t);e.grid.isValidCoordinate(t)&&!r.has(i)&&e.grid.isCellActive(t)&&(r.add(i),o.push(t))}))}return n},t.prototype.swapCells=function(t,e){var i=Rt({},this.grid.getCell(t)),n=Rt({},this.grid.getCell(e));this.grid.stampCell(Rt(Rt({},n),{coordinate:t})),this.grid.stampCell(Rt(Rt({},i),{coordinate:e}))},t}();const Ot=Pt;var Tt=function(){function t(t){this.grid=t}return t.prototype.isRowFull=function(t){var e=this.grid.getGrid();return!(t<0||t>=this.grid.height)&&e[t].every(function(t){return t.value>0})},t.prototype.isRowEmpty=function(t){var e=this.grid.getGrid();return t<0||t>=this.grid.height||e[t].every(function(t){return 0===t.value})},t.prototype.clearRow=function(t){var e=this.grid.getGrid();if(!(t<0||t>=this.grid.height))for(var i=0;i<this.grid.width;i++)e[t][i]=mt.emptyCell({x:i,y:t})},t.prototype.shiftRowsDown=function(t){for(var e=this.grid.getGrid(),i=t;i>0;i--)for(var n=0;n<this.grid.width;n++){var r=e[i-1][n];e[i][n].value=r.value,e[i][n].color=r.color}this.clearRow(0)},t.prototype.shiftRowsUp=function(t){for(var e=this.grid.getGrid(),i=t;i<this.grid.height-1;i++)for(var n=0;n<this.grid.width;n++){var r=e[i+1][n];e[i][n].value=r.value,e[i][n].color=r.color}this.clearRow(this.grid.height-1)},t.prototype.clearFullRows=function(){for(var t=0,e=this.grid.height-1;e>=0;e--)this.isRowFull(e)&&(this.clearRow(e),this.shiftRowsDown(e),t++,e++);return t},t.prototype.isColumnFull=function(t){var e=this.grid.getGrid();if(t<0||t>=this.grid.width)return!1;for(var i=0;i<this.grid.height;i++)if(0===e[i][t].value)return!1;return!0},t.prototype.isColumnEmpty=function(t){var e=this.grid.getGrid();if(t<0||t>=this.grid.width)return!0;for(var i=0;i<this.grid.height;i++)if(0!==e[i][t].value)return!1;return!0},t.prototype.clearColumn=function(t){var e=this.grid.getGrid();if(!(t<0||t>=this.grid.width))for(var i=0;i<this.grid.height;i++)e[i][t]=mt.emptyCell({x:t,y:i})},t.prototype.shiftColumnsRight=function(t){for(var e=this.grid.getGrid(),i=t;i>0;i--)for(var n=0;n<this.grid.height;n++){var r=e[n][i-1];e[n][i].value=r.value,e[n][i].color=r.color}this.clearColumn(0)},t.prototype.shiftColumnsLeft=function(t){for(var e=this.grid.getGrid(),i=t;i<this.grid.width-1;i++)for(var n=0;n<this.grid.height;n++){var r=e[n][i+1];e[n][i].value=r.value,e[n][i].color=r.color}this.clearColumn(this.grid.width-1)},t.prototype.clearFullColumns=function(){for(var t=0,e=this.grid.width-1;e>=0;e--)this.isColumnFull(e)&&(this.clearColumn(e),this.shiftColumnsRight(e),t++,e++);return t},t}();const Mt=Tt;var Dt=function(){function t(t){this.grid=t}return t.prototype.isAreaOccupied=function(t){var e=this;return t.some(function(t){return!e.grid.isValidCoordinate(t)||e.grid.isCellActive(t)})},t.prototype.fillArea=function(t,e,i,n){for(var r=Math.max(0,Math.min(t.x,e.x)),o=Math.min(this.grid.width-1,Math.max(t.x,e.x)),s=Math.max(0,Math.min(t.y,e.y)),a=Math.min(this.grid.height-1,Math.max(t.y,e.y)),u=s;u<=a;u++)for(var c=r;c<=o;c++)this.grid.setCellValue({x:c,y:u},i),this.grid.setCellColor({x:c,y:u},n)},t.prototype.stampPiece=function(t){var e=this;t.forEach(function(t){return e.grid.stampCell(t)})},t.prototype.stampCell=function(t){this.grid.setCellValue(t.coordinate,t.value),this.grid.setCellColor(t.coordinate,t.color)},t}();const At=Dt;var It=function(){function t(){this._grid=[],this.serialId="grid",this._movementEngine=new Et(this),this._transformEngine=new Ct(this),this._analysisEngine=new Ot(this),this._lineEngine=new Mt(this),this._regionEngine=new At(this)}return t.prototype.getGrid=function(){return this._grid},Object.defineProperty(t.prototype,"width",{get:function(){return o.columns},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return o.rows},enumerable:!1,configurable:!0}),t.prototype.setup=function(){this.resetGrid()},t.prototype.resetGrid=function(){this._grid=[];for(var t=0;t<this.height;t++){this._grid[t]=[];for(var e=0;e<this.width;e++)this._grid[t][e]=mt.emptyCell({x:e,y:t})}},t.prototype.forEach=function(t){for(var e=0;e<this.height;e++)for(var i=0;i<this.width;i++)t(this._grid[e][i])},t.prototype.isValidCoordinate=function(t){return t.x>=0&&t.x<this.width&&t.y>=0&&t.y<this.height},t.prototype.getCell=function(t){return this.isValidCoordinate(t)?this._grid[t.y][t.x]:null},t.prototype.setCellValue=function(t,e){this.isValidCoordinate(t)&&(this._grid[t.y][t.x].value=e)},t.prototype.setCellColor=function(t,e){this.isValidCoordinate(t)&&(this._grid[t.y][t.x].color=e)},t.prototype.isCellActive=function(t){var e=this.getCell(t);return null!==e&&e.value>0},t.prototype.isCellInactive=function(t){var e=this.getCell(t);return null!==e&&0===e.value},t.prototype.isRowFull=function(t){return this._lineEngine.isRowFull(t)},t.prototype.isRowEmpty=function(t){return this._lineEngine.isRowEmpty(t)},t.prototype.clearRow=function(t){this._lineEngine.clearRow(t)},t.prototype.shiftRowsDown=function(t){this._lineEngine.shiftRowsDown(t)},t.prototype.shiftRowsUp=function(t){this._lineEngine.shiftRowsUp(t)},t.prototype.clearFullRows=function(){return this._lineEngine.clearFullRows()},t.prototype.isColumnFull=function(t){return this._lineEngine.isColumnFull(t)},t.prototype.isColumnEmpty=function(t){return this._lineEngine.isColumnEmpty(t)},t.prototype.clearColumn=function(t){this._lineEngine.clearColumn(t)},t.prototype.shiftColumnsRight=function(t){this._lineEngine.shiftColumnsRight(t)},t.prototype.shiftColumnsLeft=function(t){this._lineEngine.shiftColumnsLeft(t)},t.prototype.clearFullColumns=function(){return this._lineEngine.clearFullColumns()},t.prototype.isAreaOccupied=function(t){return this._regionEngine.isAreaOccupied(t)},t.prototype.fillArea=function(t,e,i,n){this._regionEngine.fillArea(t,e,i,n)},t.prototype.stampPiece=function(t){this._regionEngine.stampPiece(t)},t.prototype.stampCell=function(t){this._regionEngine.stampCell(t)},t.prototype.movePiece=function(t,e){return this._movementEngine.movePiece(t,e)},t.prototype.movePieceLeft=function(t){return this._movementEngine.movePieceLeft(t)},t.prototype.movePieceRight=function(t){return this._movementEngine.movePieceRight(t)},t.prototype.movePieceUp=function(t){return this._movementEngine.movePieceUp(t)},t.prototype.movePieceDown=function(t){return this._movementEngine.movePieceDown(t)},t.prototype.moveCell=function(t,e){return this._movementEngine.moveCell(t,e)},t.prototype.moveCellLeft=function(t){return this._movementEngine.moveCellLeft(t)},t.prototype.moveCellRight=function(t){return this._movementEngine.moveCellRight(t)},t.prototype.moveCellUp=function(t){return this._movementEngine.moveCellUp(t)},t.prototype.moveCellDown=function(t){return this._movementEngine.moveCellDown(t)},t.prototype.rotatePiece=function(t,e,i){return void 0===i&&(i=!0),this._transformEngine.rotatePiece(t,e,i)},t.prototype.getFullRows=function(){return this._analysisEngine.getFullRows()},t.prototype.getFullColumns=function(){return this._analysisEngine.getFullColumns()},t.prototype.getDropPath=function(t){return this._movementEngine.getDropPath(t)},t.prototype.getRisePath=function(t){return this._movementEngine.getRisePath(t)},t.prototype.getReachPathLeft=function(t){return this._movementEngine.getReachPathLeft(t)},t.prototype.getReachPathRight=function(t){return this._movementEngine.getReachPathRight(t)},t.prototype.getNeighbors=function(t,e){return void 0===e&&(e=!1),this._analysisEngine.getNeighbors(t,e)},t.prototype.findConnectedCells=function(t){return this._analysisEngine.findConnectedCells(t)},t.prototype.mirrorPiece=function(t,e){return this._transformEngine.mirrorPiece(t,e)},t.prototype.swapCells=function(t,e){this._analysisEngine.swapCells(t,e)},t.prototype.getPieceBounds=function(t){return this._transformEngine.getPieceBounds(t)},t.prototype.getDebugData=function(){return{width:this.width,height:this.height,activeCells:this._grid.flat().filter(function(t){return t.value>0}).length}},t.prototype.serialize=function(){return console.log("serialize"),JSON.stringify({grid:this._grid})},t.prototype.deserialize=function(t){console.log("deserialize");var e=JSON.parse(t);this._grid=e.grid},t}();const Gt=It;var Lt=function(){function t(){}return t.getRelativeWidth=function(t,e){return e*t.width},t.getRelativeHeight=function(t,e){return e*t.height},t}();const Bt=Lt;var kt=function(){function t(t){this._p=t}return t.prototype.setup=function(t){this._rendererMetrics=t;var e=u,i=e.margin,n=e.padding,r=e.strokeWeight,o=this._rendererMetrics.cell.size;this._cellPreCalculatedGeometry={innerOffset:i*o,innerSize:o-i*o*2,paddingOffset:n*o,paddingSize:o-n*o*2,strokeWeight:r*o},this._renderStaticElements()},t.prototype.render=function(t,e){this._p.push(),this._p.image(this._staticGraphics,0,0),this.renderGrid(t,e.state),this._p.pop()},t.prototype._renderStaticElements=function(){var t=s.borderWeight;this._staticGraphics=this._p.createGraphics(this._p.width,this._p.height),this._staticGraphics.background(i.background),this._staticGraphics.strokeWeight(Bt.getRelativeWidth(this._p,t)),this._staticGraphics.noFill(),this._staticGraphics.stroke(i.active),this._staticGraphics.rect(this._rendererMetrics.display.origin.x,this._rendererMetrics.display.origin.y,this._rendererMetrics.display.width,this._rendererMetrics.display.height)},t.prototype.renderCell=function(t,e){var i=t.coordinate,n=t.color,r=t.value,o=i.x,s=i.y,a=this._cellPreCalculatedGeometry,u=a.innerOffset,c=a.innerSize,l=a.paddingOffset,h=a.paddingSize,p=a.strokeWeight;n=0===r||!e.isPlaying()&&!e.isPaused()?R.INACTIVE:e.isColorEnabled()?n:R.DEFAULT,this._p.push(),this._p.translate(this._rendererMetrics.display.origin.x+o*this._rendererMetrics.cell.size,this._rendererMetrics.display.origin.y+s*this._rendererMetrics.cell.size),this._p.strokeWeight(p),this._p.stroke(n),this._p.noFill(),this._p.rect(u,u,c,c),this._p.fill(n),this._p.rect(l,l,h,h),this._p.pop()},t.prototype.renderGrid=function(t,e){var i=this;t.forEach(function(t){t.forEach(function(t){i.renderCell(t,e)})})},t}();const zt=kt;var Nt=function(){function t(){}return t.getRelativeCoordinate=function(t,e){return{x:Bt.getRelativeWidth(t,e.x),y:Bt.getRelativeHeight(t,e.y)}},t.getDisplayPosX=function(t,e,i){var n=s.margin;return i*e+Bt.getRelativeWidth(t,n)},t.getDisplayPosY=function(t,e,i){var n=s.margin;return i*e+Bt.getRelativeHeight(t,n)},t.getHudPosX=function(t,e,i){var n=s.margin,r=i+2*Bt.getRelativeWidth(t,n);return(t.width-r-Bt.getRelativeWidth(t,n))*e+r},t.getHudPosY=function(t,e,i){var n=s.margin;return i*e+Bt.getRelativeHeight(t,n)},t}();const Ht=Nt;var Ft=function(){function t(t){this._p=t}return t.prototype.setup=function(t){this._cellSize=t.cell.size,this._gridOrigin={x:Ht.getHudPosX(this._p,.078,t.display.width),y:Ht.getHudPosY(this._p,.375,t.display.height)},this._hudBorderRect={x:this._gridOrigin.x-Bt.getRelativeWidth(this._p,.005),y:this._gridOrigin.y-Bt.getRelativeHeight(this._p,.005),w:4*this._cellSize+Bt.getRelativeWidth(this._p,.01),h:4*this._cellSize+Bt.getRelativeHeight(this._p,.01)}},t.prototype.render=function(t,e){this._renderHud(e),this._drawHudGrid(e)},t.prototype._renderHud=function(t){var e=t.text,i=t.state,n=t.score;this._p.push(),e.setTextSize(O.SMALL),e.setInactiveText(),e.setTextAlign(P.LEFT,T.BOTTOM),e.textOnHud("88888888",{x:.05,y:.13}),e.textOnHud("88888888",{x:.05,y:.3}),e.textOnHud("88 - 88",{x:.05,y:.8}),i.isOn()&&e.setActiveText(),e.textOnHud("Score",{x:.05,y:.06}),e.textOnHud(n.score.toString(),{x:.05,y:.13}),e.textOnHud("Hi-Score",{x:.05,y:.23}),e.textOnHud(n.highScore.toString(),{x:.05,y:.3}),e.textOnHud("Level",{x:.05,y:.72});var r="".concat(n.level<10?"0"+n.level:n.level," - ").concat(n.maxLevel);e.textOnHud(r,{x:.05,y:.8}),e.setTextAlign(P.CENTER,T.BOTTOM),i.isPaused()?e.setActiveText():e.setInactiveText(),e.textOnHud("Paused",{x:.5,y:.9}),i.isOn()&&i.isMuted()?e.setActiveText():e.setInactiveText(),e.textOnHud("Muted",{x:.5,y:.97}),this._p.pop(),this._drawHudGrid(t)},t.prototype._drawHudGrid=function(t){var e=this,i=t.hudGrid,n=t.state;this._p.push(),i.forEach(function(t){var i=t.coordinate,r=i.x,o=i.y;n.isOff()&&!n.isPlaying()&&(t.value=0);var s=0!==t.value?R.DEFAULT:R.INACTIVE;n.isColorEnabled()&&0!==t.value&&(s=t.color),e.drawCellElement({w:e._cellSize,h:e._cellSize,posX:e._gridOrigin.x+e._cellSize*r,posY:e._gridOrigin.y+e._cellSize*o,color:s})}),this._p.noFill(),this._p.stroke(n.isOn()?R.DEFAULT:R.INACTIVE),this._p.rect(this._hudBorderRect.x,this._hudBorderRect.y,this._hudBorderRect.w,this._hudBorderRect.h),this._p.pop()},t.prototype.drawCellElement=function(t){var e=t.w,i=t.posX,n=t.posY,r=t.color,o=u,s=o.margin,a=o.padding,c=s*e,l=e-s*e*2,h=a*e,p=e-a*e*2,d=o.strokeWeight*e;this._p.push(),this._p.translate(i,n),this._p.strokeWeight(d),this._p.stroke(r),this._p.noFill(),this._p.rect(c,c,l,l),this._p.fill(r),this._p.rect(h,h,p,p),this._p.pop()},t}();const jt=Ft;var Ut=function(){function t(t){this._p=t}return t.prototype.addRenderer=function(t){this._renderers.push(t)},t.prototype.setup=function(){var t=this;this._displayRenderer=new zt(this._p),this._hudRenderer=new jt(this._p),this._renderers=[],this.addRenderer(this._displayRenderer),this.addRenderer(this._hudRenderer),this._calculateMetrics(),this._renderers.forEach(function(e){return e.setup(t.rendererMetrics)})},t.prototype._calculateMetrics=function(){var t=s,e=t.width,i=t.height,n=t.margin,r=o.columns,a=Bt.getRelativeWidth(this._p,e),u=Bt.getRelativeHeight(this._p,i),c=Ht.getRelativeCoordinate(this._p,{x:n,y:n}),l=a/r,h={x:Ht.getHudPosX(this._p,0,a),y:Ht.getHudPosY(this._p,0,u)},p=Ht.getHudPosX(this._p,1,a)-h.x,d=Ht.getHudPosY(this._p,1,u)-h.y;this._rendererMetrics={display:{width:a,height:u,origin:c},hud:{width:p,height:d,origin:h},cell:{size:l}}},t.prototype.render=function(t,e){this._renderers.forEach(function(i){return i.render(t,e)})},Object.defineProperty(t.prototype,"rendererMetrics",{get:function(){return this._rendererMetrics},enumerable:!1,configurable:!0}),t.prototype.getDebugData=function(){return{display_width:this._rendererMetrics.display.width.toFixed(2),display_height:this._rendererMetrics.display.height.toFixed(2),hud_width:this._rendererMetrics.hud.width.toFixed(2),hud_height:this._rendererMetrics.hud.height.toFixed(2),cell_size:this._rendererMetrics.cell.size.toFixed(2)}},t}();const Wt=Ut;var Vt,Kt=((Vt={})[I.ON]={defaultValue:!1},Vt[I.START]={defaultValue:!1},Vt[I.PLAYING]={defaultValue:!1},Vt[I.GAME_OVER]={defaultValue:!1},Vt[I.COLOR_ENABLED]={defaultValue:!0,storageKey:"colorEnabled"},Vt[I.MUTED]={defaultValue:!1,storageKey:"muted"},Vt),Yt=function(){function t(){this._state=new Map,this._subscribers=new Map}return t.prototype.setup=function(){var t=this;Object.values(I).forEach(function(e){var i=Kt[e];t._state.set(e,i.defaultValue)}),this._loadPersistentState()},t.prototype._loadPersistentState=function(){var t=this;Object.values(I).forEach(function(e){var i=Kt[e];if(i.storageKey){var n=localStorage.getItem(i.storageKey);null!==n&&t._state.set(e,JSON.parse(n))}})},t.prototype._set=function(t,e){if(this._state.get(t)!==e){this._state.set(t,e);var i=Kt[t];i.storageKey&&localStorage.setItem(i.storageKey,JSON.stringify(e)),this._notify(t,e)}},t.prototype._notify=function(t,e){var i=this._subscribers.get(t);i&&i.forEach(function(t){return t(e)})},t.prototype.isOn=function(){return this._state.get(I.ON)},t.prototype.isOff=function(){return!this.isOn()},t.prototype.isStarted=function(){return this._state.get(I.START)},t.prototype.isPlaying=function(){return this._state.get(I.PLAYING)},t.prototype.isPaused=function(){return this.isStarted()&&!this.isPlaying()&&!this.isGameOver()},t.prototype.isGameOver=function(){return this._state.get(I.GAME_OVER)},t.prototype.turnOn=function(){this._set(I.ON,!0),this._set(I.START,!1),this._set(I.PLAYING,!1),this._set(I.GAME_OVER,!1)},t.prototype.turnOff=function(){this._set(I.ON,!1),this._set(I.START,!1),this._set(I.PLAYING,!1),this._set(I.GAME_OVER,!1)},t.prototype.startGame=function(){this.isOn()&&(this._set(I.START,!0),this._set(I.PLAYING,!0),this._set(I.GAME_OVER,!1))},t.prototype.resetGameOver=function(){this._set(I.GAME_OVER,!1),this._set(I.START,!0),this._set(I.PLAYING,!0)},t.prototype.exitGame=function(){this._set(I.START,!1),this._set(I.PLAYING,!1),this._set(I.GAME_OVER,!1)},t.prototype.pause=function(){this.isStarted()&&!this.isGameOver()&&this._set(I.PLAYING,!1)},t.prototype.resume=function(){this.isStarted()&&!this.isGameOver()&&this._set(I.PLAYING,!0)},t.prototype.triggerGameOver=function(){this._set(I.PLAYING,!1),this._set(I.GAME_OVER,!0)},t.prototype.resetGame=function(){this.isOn()&&(this._set(I.GAME_OVER,!1),this._set(I.START,!0),this._set(I.PLAYING,!0))},t.prototype.isColorEnabled=function(){return this._state.get(I.COLOR_ENABLED)},t.prototype.setColorEnabled=function(t){this._set(I.COLOR_ENABLED,t)},t.prototype.isMuted=function(){return this._state.get(I.MUTED)},t.prototype.setMuted=function(t){this._set(I.MUTED,t)},t.prototype.toggleColorEnabled=function(){this.setColorEnabled(!this.isColorEnabled())},t.prototype.toggleMuted=function(){this.setMuted(!this.isMuted())},t.prototype.subscribe=function(t,e){var i;this._subscribers.has(t)||this._subscribers.set(t,[]),null===(i=this._subscribers.get(t))||void 0===i||i.push(e)},t.prototype.unsubscribe=function(t,e){var i=this._subscribers.get(t);i&&this._subscribers.set(t,i.filter(function(t){return t!==e}))},t.prototype.getDebugData=function(){return{on:this.isOn(),start:this.isStarted(),playing:this.isPlaying(),paused:this.isPaused(),game_over:this.isGameOver(),color_enabled:this.isColorEnabled(),muted:this.isMuted()}},t}();const Xt=Yt;var Jt=function(){function t(t){this.defaultFontFamily="retro-gamming",this.fontSizes=[0],this._p=t}return t.prototype.setup=function(){var t=a,e=t.extraSmall,i=t.small,n=t.medium,r=t.large,o=t.extraLarge;this._p.textFont(this.defaultFontFamily),this.fontSizes=[],this.fontSizes[O.EXTRA_SMALL]=Bt.getRelativeWidth(this._p,e),this.fontSizes[O.SMALL]=Bt.getRelativeWidth(this._p,i),this.fontSizes[O.MEDIUM]=Bt.getRelativeWidth(this._p,n),this.fontSizes[O.LARGE]=Bt.getRelativeWidth(this._p,r),this.fontSizes[O.EXTRA_LARGE]=Bt.getRelativeWidth(this._p,o)},t.prototype.setRendererMetrics=function(t){this._rendererMetrics=t},t.prototype.setTextState=function(t){var e=i.active,n=i.inactive;this._p.fill(t?e:n)},t.prototype.setActiveText=function(){this.setTextState(!0)},t.prototype.setInactiveText=function(){this.setTextState(!1)},t.prototype.setTextSize=function(t){this._p.textSize(this.fontSizes[t])},t.prototype.setTextAlign=function(t,e){this._p.textAlign(t,e)},t.prototype.textOnHud=function(t,e){var i=Ht.getHudPosX(this._p,e.x,this._rendererMetrics.display.width),n=Ht.getHudPosY(this._p,e.y,this._rendererMetrics.display.height);this._p.text(t,i,n)},t.prototype.textOnDisplay=function(t,e){var i=Ht.getDisplayPosX(this._p,e.x,this._rendererMetrics.display.width),n=Ht.getDisplayPosY(this._p,e.y,this._rendererMetrics.display.height);this._p.text(t,i,n)},t.prototype.getDebugData=function(){return{current_font_family:this.defaultFontFamily,font_sizes_count:this.fontSizes.length}},t}();const qt=Jt,$t=function(){function t(){this._accumulatedTime=0,this._initialTickInterval=E,this._minTickInterval=x,this._tickInterval=E,this._fps=0,this._tps=0,this._tickCounter=0,this._timeSinceLastTpsUpdate=0,this.serialId="time"}return t.prototype.setup=function(){this.reset()},t.prototype.update=function(t){this._accumulatedTime+=t,this._fps=1e3/t,this._timeSinceLastTpsUpdate+=t,this._timeSinceLastTpsUpdate>=1e3&&(this._tps=this._tickCounter,this._tickCounter=0,this._timeSinceLastTpsUpdate-=1e3)},t.prototype.shouldTick=function(){return this._accumulatedTime>=this._tickInterval&&(this._accumulatedTime-=this._tickInterval,this._tickCounter++,!0)},t.prototype.reset=function(){this._accumulatedTime=0,this._fps=0,this._tps=0,this._tickCounter=0,this._timeSinceLastTpsUpdate=0,this._tickInterval=this._initialTickInterval},Object.defineProperty(t.prototype,"tickInterval",{get:function(){return this._tickInterval},set:function(t){this._tickInterval=t},enumerable:!1,configurable:!0}),t.prototype.incrementTickInterval=function(t){this.tickInterval=this._tickInterval+t},t.prototype.decrementTickInterval=function(t){var e=Math.max(this._minTickInterval,this._tickInterval-t);this.tickInterval=e},t.prototype.getDebugData=function(){return{fps:Math.round(this._fps),tps:this._tps,tick_interval:this._tickInterval.toFixed(2),accumulated_time:this._accumulatedTime.toFixed(2)}},t.prototype.serialize=function(){return JSON.stringify({tickInterval:this._tickInterval})},t.prototype.deserialize=function(t){var e=JSON.parse(t);this._tickInterval=e.tickInterval},t.prototype.setTickInterval=function(t){this._tickInterval=t},t.prototype.setMinTickInterval=function(t){this._minTickInterval=t},t}();var Qt=function(t,e,i,n){return new(i||(i=Promise))(function(r,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(s,a)}u((n=n.apply(t,e||[])).next())})},Zt=function(t,e){var i,n,r,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(u){return function(a){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(i=1,n&&(r=2&a[0]?n.return:a[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,a[1])).done)return r;switch(n=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((r=(r=o.trys).length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]<r[3])){o.label=a[1];break}if(6===a[0]&&o.label<r[1]){o.label=r[1],r=a;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(a);break}r[2]&&o.ops.pop(),o.trys.pop();continue}a=e.call(t,o)}catch(t){a=[6,t],n=0}finally{i=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},te=function(){function t(){this._buffers=new Map,this._activeSources=new Map,this._volume=1}return t.prototype.setup=function(){var t=C.volume;this._volume=t;var e=window.AudioContext||window.webkitAudioContext;this._audioContext=new e({latencyHint:"interactive"}),this._gainNode=this._audioContext.createGain(),this._gainNode.connect(this._audioContext.destination),this._updateGain(),this._loadAll()},t.prototype.play=function(t){return Qt(this,void 0,void 0,function(){var e,i,n;return Zt(this,function(r){return"suspended"===this._audioContext.state&&this._audioContext.resume(),(e=this._buffers.get(t))?((i=this._audioContext.createBufferSource()).buffer=e,i.connect(this._gainNode),this._activeSources.has(t)||this._activeSources.set(t,[]),(n=this._activeSources.get(t)).push(i),i.onended=function(){var t=n.indexOf(i);t>-1&&n.splice(t,1)},i.start(0),[2]):(console.warn("Sound buffer not found for: ".concat(t)),[2])})})},t.prototype.stop=function(t){return Qt(this,void 0,void 0,function(){var e;return Zt(this,function(i){return(e=this._activeSources.get(t))&&(e.forEach(function(t){try{t.stop()}catch(t){}}),e.length=0),[2]})})},t.prototype.stopAll=function(){return Qt(this,void 0,void 0,function(){var t,e,i,n;return Zt(this,function(r){switch(r.label){case 0:t=Array.from(this._activeSources.keys()),e=0,i=t,r.label=1;case 1:return e<i.length?(n=i[e],[4,this.stop(n)]):[3,4];case 2:r.sent(),r.label=3;case 3:return e++,[3,1];case 4:return[2]}})})},t.prototype._updateGain=function(){var t=!!this._state&&this._state.isMuted();this._gainNode&&(t?this._gainNode.gain.setValueAtTime(0,this._audioContext.currentTime):this._gainNode.gain.setValueAtTime(this._volume,this._audioContext.currentTime))},t.prototype._loadAll=function(){return Qt(this,void 0,void 0,function(){var t,e=this;return Zt(this,function(i){switch(i.label){case 0:return t=Object.values(M).map(function(t){return Qt(e,void 0,void 0,function(){var e,i,n;return Zt(this,function(r){switch(r.label){case 0:return r.trys.push([0,4,,5]),[4,fetch(t)];case 1:return[4,r.sent().arrayBuffer()];case 2:return e=r.sent(),[4,this._audioContext.decodeAudioData(e)];case 3:return i=r.sent(),this._buffers.set(t,i),[3,5];case 4:return n=r.sent(),console.error("Failed to load sound: ".concat(t),n),[3,5];case 5:return[2]}})})}),[4,Promise.all(t)];case 1:return i.sent(),[2]}})})},t.prototype.toggleMute=function(){this._state.toggleMuted(),this._updateGain()},t.prototype.syncState=function(t){var e=this;this._state=t,t.subscribe(I.MUTED,function(){e._updateGain()}),this._updateGain()},t.prototype.getDebugData=function(){var t=0;return this._activeSources.forEach(function(e){return t+=e.length}),{muted:!!this._state&&this._state.isMuted(),volume:this._volume,active_sources:t,loaded_buffers:this._buffers.size}},t}();const ee=te,ie=function(){function t(){this._score=0,this._multiplier=1,this._level=1,this._maxLevel=10,this._highScore=0,this.serialId="score"}return t.prototype.setup=function(){this._highScore=Number(localStorage.getItem("highScore"))},t.prototype.increaseScore=function(t){this._score+=t*this._multiplier,this._score>this._highScore&&(this.highScore=this._score)},t.prototype.resetScore=function(){this._score=0},t.prototype.getFormattedScore=function(t){return void 0===t&&(t=6),this._score.toString().padStart(t,"0")},t.prototype.increaseLevel=function(t){this._level+=t},t.prototype.resetLevel=function(){this._level=1},Object.defineProperty(t.prototype,"multiplier",{get:function(){return this._multiplier},set:function(t){this._multiplier=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"level",{get:function(){return this._level},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"score",{get:function(){return this._score},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"maxLevel",{get:function(){return this._maxLevel},set:function(t){this._maxLevel=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"highScore",{get:function(){return this._highScore},set:function(t){this._highScore=t,localStorage.setItem("highScore",t.toString())},enumerable:!1,configurable:!0}),t.prototype.getDebugData=function(){return{score:this._score,multiplier:this._multiplier,level:this._level,max_level:this._maxLevel}},t.prototype.serialize=function(){return JSON.stringify({score:this._score,multiplier:this._multiplier,level:this._level,max_level:this._maxLevel})},t.prototype.deserialize=function(t){var e=JSON.parse(t);this._score=e.score,this._multiplier=e.multiplier,this._level=e.level,this._maxLevel=e.max_level},t}();var ne,re=(ne=function(t,e){return ne=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},ne(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}ne(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});const oe=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.serialId="hud_grid",e}return re(e,t),Object.defineProperty(e.prototype,"width",{get:function(){return 4},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return 4},enumerable:!1,configurable:!0}),e.prototype.serialize=function(){return JSON.stringify({grid:this._grid})},e.prototype.deserialize=function(t){var e=JSON.parse(t);this._grid=e.grid},e}(Gt),se=function(){function t(){}return t.isSerializable=function(t){if(null==t)return!1;var e=t,i="function"==typeof e.serialize,n="function"==typeof e.deserialize,r="string"==typeof e.serialId;return i&&n&&r},t.isInitializable=function(t){return null!=t&&"function"==typeof t.setup},t.isStateSyncable=function(t){if(null==t)return!1;var e=t;return"function"==typeof e.syncState&&!(e instanceof Xt)},t.isDebuggable=function(t){return null!=t&&"function"==typeof t.getDebugData},t}();var ae=function(){function t(){this._initialState=new Map,this._baseProperties=[]}return t.prototype.captureBaseProperties=function(t){this._baseProperties=Object.keys(t)},t.prototype.captureInitialState=function(t){var e=this;console.log("capturing initial state for snapshot"),Object.entries(t).forEach(function(t){var i=t[0],n=t[1];if(!e._baseProperties.includes(i)&&"function"!=typeof n){var r=n;try{r=structuredClone(n),console.log("capturing property",i,r)}catch(t){console.error("Failed to clone property ".concat(i,":"),t)}e._initialState.set(i,r)}})},t.prototype.restoreInitialState=function(t){console.log("restoring initial snapshot"),this._initialState.forEach(function(e,i){t[i]=e,console.log("restoring property",i,e)})},t}();const ue=ae,ce=function(){function t(){this._isModalClosed=!1,this._serializables=[]}return t.prototype.register=function(t){this._serializables.push(t)},t.prototype.saveSession=function(){var t=this;this._isModalClosed&&!this._isGameMenuInstance()&&this._serializables.forEach(function(e){localStorage.setItem(t._key(e.serialId),e.serialize())})},t.prototype.clearSession=function(){var t=this;this._serializables.forEach(function(e){localStorage.removeItem(t._key(e.serialId))})},t.prototype.setShowModalFunction=function(t){this._showSessionModal=t},t.prototype._isGameMenuInstance=function(){return"game-menu"===this.gameId},t.prototype._hasSession=function(){var t=this;return this._serializables.every(function(e){return null!==localStorage.getItem(t._key(e.serialId))})},t.prototype._loadSession=function(){var t=this;this._serializables.forEach(function(e){var i=localStorage.getItem(t._key(e.serialId));i&&e.deserialize(i)})},t.prototype._destroySession=function(){var t=this;this._serializables.forEach(function(e){localStorage.removeItem(t._key(e.serialId))})},t.prototype.syncState=function(t){var e=this;t.subscribe(I.PLAYING,function(t){if(t&&!1===e._isModalClosed){if(!e._hasSession()||e._isGameMenuInstance())return void(e._isModalClosed=!0);e._showSessionModal(function(){e._hasSession()&&!e._isGameMenuInstance()&&e._loadSession(),e._isModalClosed=!0},function(){e._destroySession(),e._isModalClosed=!0})}}),t.subscribe(I.GAME_OVER,function(t){t&&e._destroySession()}),t.subscribe(I.ON,function(t){t||(e._isModalClosed=!1)})},t.prototype.getDebugData=function(){return{gameId:this.gameId,serializables:this._serializables.map(function(t){return t.serialId}).join(", ")}},t.prototype._key=function(t){return"".concat(this.gameId,"::").concat(t)},t}();var le=function(){function t(t,e){this._modules=void 0,this._initialStateSnapshot=new ue,this._gameId="unknown",this._switchHandler=void 0,this._p=t,this._view=e,this._initialStateSnapshot.captureBaseProperties(this)}return Object.defineProperty(t.prototype,"gameId",{get:function(){return this._gameId},set:function(t){this._gameId=t},enumerable:!1,configurable:!0}),t.prototype.setSwitchHandler=function(t){this._switchHandler=t},t.prototype.propagateSwitchHandler=function(t){this.setSwitchHandler(t._switchHandler)},Object.defineProperty(t.prototype,"view",{get:function(){return this._view},enumerable:!1,configurable:!0}),t.prototype.switchGame=function(t){this.destroy(),this._switchHandler?this._switchHandler(t):console.error("Game switch handler not registered. Cannot switch game.")},Object.defineProperty(t.prototype,"modules",{get:function(){return this._modules},enumerable:!1,configurable:!0}),t.prototype.setup=function(){var t=this;this._view.build(),this._modules={renderer:new Wt(this._p),grid:new Gt,hudGrid:new oe,text:new qt(this._p),state:new Xt,control:new vt,time:new $t,sound:new ee,score:new ie,session:new ce},Object.values(this._modules).forEach(function(t){se.isInitializable(t)&&t.setup()}),Object.values(this._modules).forEach(function(e){se.isStateSyncable(e)&&e.syncState(t._modules.state)}),Object.values(this._modules).forEach(function(e){se.isSerializable(e)&&t._modules.session.register(e)});var e=this._modules,i=e.text,n=e.control,r=e.renderer,o=e.session;o.gameId=this.gameId,o.setShowModalFunction(this._view.showSessionModal.bind(this._view)),n.setModules(this._modules),i.setRendererMetrics(r.rendererMetrics),this.setupGame(),this._initialStateSnapshot.captureInitialState(this),this._subscribeSystemControls(),this._view.bindControls(n)},t.prototype.draw=function(){if(this._modules){var t=this._modules,e=t.renderer,i=t.grid,n=t.time,r=t.state;e.render(i.getGrid(),this._modules),r.isOn()&&(r.isStarted()?r.isPlaying()?(n.update(this._p.deltaTime),n.shouldTick()&&(this.update(this._p.deltaTime),this._modules.session.saveSession()),this.render()):r.isPaused()&&this.render():this.drawTitleScreen(),r.isGameOver()&&this.drawGameOverScreen())}},t.prototype.destroy=function(){this._p.noLoop(),this._modules&&(this._modules.control.unbindControls(),this._modules.sound.stopAll())},Object.defineProperty(t.prototype,"p",{get:function(){return this._p},enumerable:!1,configurable:!0}),t.prototype._subscribeSystemControls=function(){var t=this,e=this._modules,i=e.control,n=e.state,r=e.grid;i.subscribe(D.POWER,A.PRESSED,function(){n.isOn()?(n.turnOff(),t.modules.sound.stopAll()):n.turnOn()}),i.subscribe(D.SOUND,A.PRESSED,function(){return n.toggleMuted()}),i.subscribe(D.COLOR,A.PRESSED,function(){return n.toggleColorEnabled()}),i.subscribe(D.RESET,A.PRESSED,function(){r.resetGrid(),t.modules.score.resetScore(),t.modules.score.resetLevel(),t.modules.time.reset(),t._modules.session.clearSession(),n.resetGame(),t._initialStateSnapshot.restoreInitialState(t)}),i.subscribe(D.EXIT,A.PRESSED,function(){t._modules.session.clearSession()}),i.subscribe(D.START_PAUSE,A.PRESSED,function(){n.isStarted()?n.isPlaying()?n.pause():n.isPaused()?n.resume():n.isGameOver()&&(r.resetGrid(),t.modules.score.resetScore(),t.modules.score.resetLevel(),t.modules.time.reset(),t.modules.session.clearSession(),t._initialStateSnapshot.restoreInitialState(t),n.resetGameOver()):n.startGame()}),n.subscribe(I.ON,function(e){e||(r.resetGrid(),t.modules.score.resetScore(),t.modules.score.resetLevel(),t.modules.time.reset())})},t}();const he=le;var pe=function(){function t(){this._games=[{id:"loading",name:"Loading...",url:""}],this.fetchGames()}return t.prototype.fetchGames=function(){return t=this,e=void 0,n=function(){var t,e,i,n;return function(t,e){var i,n,r,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(u){return function(a){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(i=1,n&&(r=2&a[0]?n.return:a[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,a[1])).done)return r;switch(n=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((r=(r=o.trys).length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]<r[3])){o.label=a[1];break}if(6===a[0]&&o.label<r[1]){o.label=r[1],r=a;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(a);break}r[2]&&o.ops.pop(),o.trys.pop();continue}a=e.call(t,o)}catch(t){a=[6,t],n=0}finally{i=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}(this,function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),t={},[4,fetch("".concat("http://127.0.0.1:54321","/functions/v1/list"),{headers:t})];case 1:if(!(e=r.sent()).ok)throw new Error("Error fetching games: ".concat(e.statusText));return[4,e.json()];case 2:return(i=r.sent())&&i.games&&i.games.length>0?this._games=i.games.map(function(t){return{id:t.id,name:t.name,url:t.url}}):this._games=[{id:"empty",name:"Not found",url:""}],[3,4];case 3:return n=r.sent(),console.error(n),this._games=[{id:"error",name:"Error",url:""}],[3,4];case 4:return[2]}})},new((i=void 0)||(i=Promise))(function(r,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(s,a)}u((n=n.apply(t,e||[])).next())});var t,e,i,n},Object.defineProperty(t.prototype,"games",{get:function(){return Object.freeze(this._games)},enumerable:!1,configurable:!0}),t}();const de=pe;var fe=function(){function t(){}return t.prototype.handleGameSwitch=function(t,e){return i=this,n=void 0,o=function(){var i,n;return function(t,e){var i,n,r,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(u){return function(a){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(i=1,n&&(r=2&a[0]?n.return:a[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,a[1])).done)return r;switch(n=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((r=(r=o.trys).length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]<r[3])){o.label=a[1];break}if(6===a[0]&&o.label<r[1]){o.label=r[1],r=a;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(a);break}r[2]&&o.ops.pop(),o.trys.pop();continue}a=e.call(t,o)}catch(t){a=[6,t],n=0}finally{i=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this._loadGameScript(t.url)];case 1:return r.sent(),console.log("Game instance defined on window.BrickEngineGame by client project: ",window.BrickEngineGame),window.BrickEngineGame?(i=new window.BrickEngineGame(e.p,e.view),console.log("Game loaded: ",t.name),console.log("Game loaded: ",t.name),i.gameId=t.id,console.log("Switching to game"),e.switchGame(i),console.log("Game switched"),console.log("Cleaning up window.BrickEngineGame"),delete window.BrickEngineGame):console.error("Game bundle loaded but window.BrickEngineGame was not set."),[3,3];case 2:return n=r.sent(),console.error("Failed to load game:",n),[3,3];case 3:return[2]}})},new((r=void 0)||(r=Promise))(function(t,e){function s(t){try{u(o.next(t))}catch(t){e(t)}}function a(t){try{u(o.throw(t))}catch(t){e(t)}}function u(e){var i;e.done?t(e.value):(i=e.value,i instanceof r?i:new r(function(t){t(i)})).then(s,a)}u((o=o.apply(i,n||[])).next())});var i,n,r,o},t.prototype._loadGameScript=function(t){return new Promise(function(e,i){var n=document.getElementById("game-client-script");n&&n.remove();var r=document.createElement("script");r.src=t,r.id="game-client-script",r.onload=function(){return e()},r.onerror=function(){return i(new Error("Failed to load script ".concat(t)))},document.head.appendChild(r)})},t}();const ge=fe;var ye=function(){var t=function(e,i){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},t(e,i)};return function(e,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}(),_e=function(t){function e(e,i){var n=t.call(this,e,i)||this;return n._gameSelectionPointer=0,n._isLoading=!1,n._gameRepository=new de,n._gameManager=new ge,n}return ye(e,t),e.prototype.setupGame=function(){var t=this,e=this.modules,i=e.state,n=e.control,r=e.sound;n.subscribe(D.ACTION,A.PRESSED,function(){if(!t._isLoading&&i.isStarted()){var e=t._gameRepository.games[t._gameSelectionPointer];t._gameManager.handleGameSwitch(e,t)}}),n.subscribe(D.LEFT,A.PRESSED,function(){i.isPlaying()&&(r.play(M.ACTION_1),0===t._gameSelectionPointer?t._gameSelectionPointer=t._gameRepository.games.length-1:t._gameSelectionPointer--)}),n.subscribe(D.RIGHT,A.PRESSED,function(){i.isPlaying()&&(r.play(M.ACTION_1),t._gameSelectionPointer===t._gameRepository.games.length-1?t._gameSelectionPointer=0:t._gameSelectionPointer++)}),i.subscribe(I.ON,function(t){t&&r.play(M.START_THEME)})},e.prototype.update=function(){},e.prototype.render=function(){var t=this.modules.text,e=this.p;e.push(),t.setTextSize(O.LARGE),t.setActiveText(),t.setTextAlign(P.CENTER,T.BOTTOM),t.textOnDisplay("Menu",{x:.5,y:.15}),t.setTextSize(O.SMALL),t.textOnDisplay("Choose a game and",{x:.5,y:.25}),t.textOnDisplay("Press action to play",{x:.5,y:.32}),t.setTextAlign(P.RIGHT,T.BOTTOM),t.textOnDisplay("<",{x:.1,y:.54}),t.setTextAlign(P.LEFT,T.BOTTOM),t.textOnDisplay(">",{x:.9,y:.54}),t.setTextSize(O.MEDIUM),t.setTextAlign(P.CENTER,T.BOTTOM),t.textOnDisplay(this._gameRepository.games[this._gameSelectionPointer].name,{x:.5,y:.55}),t.setTextSize(O.EXTRA_SMALL),t.setTextAlign(P.LEFT,T.BOTTOM),t.textOnDisplay("Left: Previous option",{x:.05,y:.78}),t.textOnDisplay("Right: Next option",{x:.05,y:.84}),t.textOnDisplay("Action: Select",{x:.05,y:.9}),e.pop()},e.prototype.drawTitleScreen=function(){var t=this.modules.text;this.p.push(),t.setTextSize(O.LARGE),t.setActiveText(),t.setTextAlign(P.CENTER,T.TOP),t.textOnDisplay("Menu",{x:.5,y:.15}),t.setTextSize(O.SMALL),t.textOnDisplay("Wellcome to your",{x:.5,y:.25}),t.textOnDisplay("favorite brick game",{x:.5,y:.32}),t.textOnDisplay("simulator!",{x:.5,y:.39}),t.textOnDisplay("Press start",{x:.5,y:.66}),t.textOnDisplay("to continue.",{x:.5,y:.72}),this.p.pop()},e.prototype.drawGameOverScreen=function(){},e}(he);const ve=_e;n(257);const me=function(){function t(){}return t.setInstance=function(e){t._instance=e},t.getInstance=function(){return t._instance},t}();var be=new(e())(function(t){var e,i=new ft(t,document.body);(e=new ve(t,i)).gameId="game-menu",me.setInstance(e),e.setSwitchHandler(function(i){try{e.view.unbindControls(),i.propagateSwitchHandler(e),(e=i).setup(),e.view.updateDebuggerGameModules(e.modules),e.view.bindControls(e.modules.control),e.modules.state.turnOn(),i!==me.getInstance()&&(i.modules.control.subscribe(D.EXIT,A.PRESSED,function(){i.switchGame(me.getInstance())}),i.modules.control.subscribe(D.POWER,A.PRESSED,function(){i.switchGame(me.getInstance()),e.modules.state.turnOff()}))}catch(t){console.error("Error switching game:",t)}t.loop()}),t.setup=function(){e.setup(),e.view.setupDebugger(e.modules),e.view.setupSessionModal()},t.draw=function(){e.draw(),e.view.updateDebugger()}},document.body)})(),r})());
2
+ //# sourceMappingURL=app.js.map