kiwiengine 0.0.1-alpha → 0.5.3

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 (599) hide show
  1. package/README.ko.md +550 -0
  2. package/README.md +575 -4
  3. package/examples/auto-battle/assets/bgm/battle.mp3 +0 -0
  4. package/examples/auto-battle/assets/bitmap-fonts/white-peaberry.fnt +107 -0
  5. package/examples/auto-battle/assets/bitmap-fonts/white-peaberry.png +0 -0
  6. package/examples/auto-battle/assets/joystick/joystick.png +0 -0
  7. package/examples/auto-battle/assets/joystick/knob.png +0 -0
  8. package/examples/auto-battle/assets/sfx/hero/die/die.wav +0 -0
  9. package/examples/auto-battle/assets/sfx/hero/heal/heal.wav +0 -0
  10. package/examples/auto-battle/assets/sfx/hero/hit/hit1.wav +0 -0
  11. package/examples/auto-battle/assets/sfx/hero/hit/hit2.wav +0 -0
  12. package/examples/auto-battle/assets/sfx/hero/hit/hit3.wav +0 -0
  13. package/examples/auto-battle/assets/sfx/hero/miss/miss1.wav +0 -0
  14. package/examples/auto-battle/assets/sfx/hero/miss/miss2.wav +0 -0
  15. package/examples/auto-battle/assets/sfx/hero/miss/miss3.wav +0 -0
  16. package/examples/auto-battle/assets/sfx/orc/die/die.wav +0 -0
  17. package/examples/auto-battle/assets/sfx/orc/hit/hit1.wav +0 -0
  18. package/examples/auto-battle/assets/sfx/orc/hit/hit2.wav +0 -0
  19. package/examples/auto-battle/assets/sfx/orc/hit/hit3.wav +0 -0
  20. package/examples/auto-battle/assets/sfx/orc/miss/miss1.wav +0 -0
  21. package/examples/auto-battle/assets/sfx/orc/miss/miss2.wav +0 -0
  22. package/examples/auto-battle/assets/sfx/orc/miss/miss3.wav +0 -0
  23. package/examples/auto-battle/assets/spritesheets/hero-atlas.json +246 -0
  24. package/examples/auto-battle/assets/spritesheets/hero.png +0 -0
  25. package/examples/auto-battle/assets/spritesheets/orc-atlas.json +246 -0
  26. package/examples/auto-battle/assets/spritesheets/orc.png +0 -0
  27. package/examples/auto-battle/assets/spritesheets/potion-atlas.json +68 -0
  28. package/examples/auto-battle/assets/spritesheets/potion.png +0 -0
  29. package/examples/auto-battle/dist/game.js +2 -0
  30. package/examples/auto-battle/dist/game.js.LICENSE.txt +35 -0
  31. package/examples/auto-battle/hud/damage-text.ts +46 -0
  32. package/examples/auto-battle/hud/heal-text.ts +46 -0
  33. package/examples/auto-battle/hud/hp-bar.ts +38 -0
  34. package/examples/auto-battle/index.ts +41 -0
  35. package/examples/auto-battle/objects/character.ts +95 -0
  36. package/examples/auto-battle/objects/hero.ts +119 -0
  37. package/examples/auto-battle/objects/orc.ts +107 -0
  38. package/examples/auto-battle/objects/potion.ts +27 -0
  39. package/examples/auto-battle/stage.ts +366 -0
  40. package/examples/battle-benchmark-matterjs/assets/bgm/battle.mp3 +0 -0
  41. package/examples/battle-benchmark-matterjs/assets/bitmap-fonts/white-peaberry.fnt +107 -0
  42. package/examples/battle-benchmark-matterjs/assets/bitmap-fonts/white-peaberry.png +0 -0
  43. package/examples/battle-benchmark-matterjs/assets/joystick/joystick.png +0 -0
  44. package/examples/battle-benchmark-matterjs/assets/joystick/knob.png +0 -0
  45. package/examples/battle-benchmark-matterjs/assets/sfx/hero/die/die.wav +0 -0
  46. package/examples/battle-benchmark-matterjs/assets/sfx/hero/heal/heal.wav +0 -0
  47. package/examples/battle-benchmark-matterjs/assets/sfx/hero/hit/hit1.wav +0 -0
  48. package/examples/battle-benchmark-matterjs/assets/sfx/hero/hit/hit2.wav +0 -0
  49. package/examples/battle-benchmark-matterjs/assets/sfx/hero/hit/hit3.wav +0 -0
  50. package/examples/battle-benchmark-matterjs/assets/sfx/hero/miss/miss1.wav +0 -0
  51. package/examples/battle-benchmark-matterjs/assets/sfx/hero/miss/miss2.wav +0 -0
  52. package/examples/battle-benchmark-matterjs/assets/sfx/hero/miss/miss3.wav +0 -0
  53. package/examples/battle-benchmark-matterjs/assets/sfx/orc/die/die.wav +0 -0
  54. package/examples/battle-benchmark-matterjs/assets/sfx/orc/hit/hit1.wav +0 -0
  55. package/examples/battle-benchmark-matterjs/assets/sfx/orc/hit/hit2.wav +0 -0
  56. package/examples/battle-benchmark-matterjs/assets/sfx/orc/hit/hit3.wav +0 -0
  57. package/examples/battle-benchmark-matterjs/assets/sfx/orc/miss/miss1.wav +0 -0
  58. package/examples/battle-benchmark-matterjs/assets/sfx/orc/miss/miss2.wav +0 -0
  59. package/examples/battle-benchmark-matterjs/assets/sfx/orc/miss/miss3.wav +0 -0
  60. package/examples/battle-benchmark-matterjs/assets/spritesheets/hero-atlas.json +246 -0
  61. package/examples/battle-benchmark-matterjs/assets/spritesheets/hero.png +0 -0
  62. package/examples/battle-benchmark-matterjs/assets/spritesheets/orc-atlas.json +246 -0
  63. package/examples/battle-benchmark-matterjs/assets/spritesheets/orc.png +0 -0
  64. package/examples/battle-benchmark-matterjs/assets/spritesheets/potion-atlas.json +68 -0
  65. package/examples/battle-benchmark-matterjs/assets/spritesheets/potion.png +0 -0
  66. package/examples/battle-benchmark-matterjs/dist/game.js +2 -0
  67. package/examples/battle-benchmark-matterjs/dist/game.js.LICENSE.txt +35 -0
  68. package/examples/battle-benchmark-matterjs/hud/damage-text.ts +46 -0
  69. package/examples/battle-benchmark-matterjs/hud/heal-text.ts +46 -0
  70. package/examples/battle-benchmark-matterjs/hud/hp-bar.ts +38 -0
  71. package/examples/battle-benchmark-matterjs/index.html +24 -0
  72. package/examples/battle-benchmark-matterjs/index.ts +41 -0
  73. package/examples/battle-benchmark-matterjs/objects/character.ts +95 -0
  74. package/examples/battle-benchmark-matterjs/objects/hero.ts +111 -0
  75. package/examples/battle-benchmark-matterjs/objects/orc.ts +107 -0
  76. package/examples/battle-benchmark-matterjs/objects/potion.ts +27 -0
  77. package/examples/battle-benchmark-matterjs/stage.ts +177 -0
  78. package/examples/battle-benchmark-separation/assets/bgm/battle.mp3 +0 -0
  79. package/examples/battle-benchmark-separation/assets/bitmap-fonts/white-peaberry.fnt +107 -0
  80. package/examples/battle-benchmark-separation/assets/bitmap-fonts/white-peaberry.png +0 -0
  81. package/examples/battle-benchmark-separation/assets/joystick/joystick.png +0 -0
  82. package/examples/battle-benchmark-separation/assets/joystick/knob.png +0 -0
  83. package/examples/battle-benchmark-separation/assets/sfx/hero/die/die.wav +0 -0
  84. package/examples/battle-benchmark-separation/assets/sfx/hero/heal/heal.wav +0 -0
  85. package/examples/battle-benchmark-separation/assets/sfx/hero/hit/hit1.wav +0 -0
  86. package/examples/battle-benchmark-separation/assets/sfx/hero/hit/hit2.wav +0 -0
  87. package/examples/battle-benchmark-separation/assets/sfx/hero/hit/hit3.wav +0 -0
  88. package/examples/battle-benchmark-separation/assets/sfx/hero/miss/miss1.wav +0 -0
  89. package/examples/battle-benchmark-separation/assets/sfx/hero/miss/miss2.wav +0 -0
  90. package/examples/battle-benchmark-separation/assets/sfx/hero/miss/miss3.wav +0 -0
  91. package/examples/battle-benchmark-separation/assets/sfx/orc/die/die.wav +0 -0
  92. package/examples/battle-benchmark-separation/assets/sfx/orc/hit/hit1.wav +0 -0
  93. package/examples/battle-benchmark-separation/assets/sfx/orc/hit/hit2.wav +0 -0
  94. package/examples/battle-benchmark-separation/assets/sfx/orc/hit/hit3.wav +0 -0
  95. package/examples/battle-benchmark-separation/assets/sfx/orc/miss/miss1.wav +0 -0
  96. package/examples/battle-benchmark-separation/assets/sfx/orc/miss/miss2.wav +0 -0
  97. package/examples/battle-benchmark-separation/assets/sfx/orc/miss/miss3.wav +0 -0
  98. package/examples/battle-benchmark-separation/assets/spritesheets/hero-atlas.json +246 -0
  99. package/examples/battle-benchmark-separation/assets/spritesheets/hero.png +0 -0
  100. package/examples/battle-benchmark-separation/assets/spritesheets/orc-atlas.json +246 -0
  101. package/examples/battle-benchmark-separation/assets/spritesheets/orc.png +0 -0
  102. package/examples/battle-benchmark-separation/assets/spritesheets/potion-atlas.json +68 -0
  103. package/examples/battle-benchmark-separation/assets/spritesheets/potion.png +0 -0
  104. package/examples/battle-benchmark-separation/dist/game.js +2 -0
  105. package/examples/battle-benchmark-separation/dist/game.js.LICENSE.txt +35 -0
  106. package/examples/battle-benchmark-separation/hud/damage-text.ts +46 -0
  107. package/examples/battle-benchmark-separation/hud/heal-text.ts +46 -0
  108. package/examples/battle-benchmark-separation/hud/hp-bar.ts +38 -0
  109. package/examples/battle-benchmark-separation/index.html +24 -0
  110. package/examples/battle-benchmark-separation/index.ts +41 -0
  111. package/examples/battle-benchmark-separation/objects/character.ts +225 -0
  112. package/examples/battle-benchmark-separation/objects/hero.ts +110 -0
  113. package/examples/battle-benchmark-separation/objects/orc.ts +213 -0
  114. package/examples/battle-benchmark-separation/objects/potion.ts +27 -0
  115. package/examples/battle-benchmark-separation/stage.ts +178 -0
  116. package/examples/battle-benchmark-separation2/assets/bgm/battle.mp3 +0 -0
  117. package/examples/battle-benchmark-separation2/assets/bitmap-fonts/white-peaberry.fnt +107 -0
  118. package/examples/battle-benchmark-separation2/assets/bitmap-fonts/white-peaberry.png +0 -0
  119. package/examples/battle-benchmark-separation2/assets/joystick/joystick.png +0 -0
  120. package/examples/battle-benchmark-separation2/assets/joystick/knob.png +0 -0
  121. package/examples/battle-benchmark-separation2/assets/sfx/hero/die/die.wav +0 -0
  122. package/examples/battle-benchmark-separation2/assets/sfx/hero/heal/heal.wav +0 -0
  123. package/examples/battle-benchmark-separation2/assets/sfx/hero/hit/hit1.wav +0 -0
  124. package/examples/battle-benchmark-separation2/assets/sfx/hero/hit/hit2.wav +0 -0
  125. package/examples/battle-benchmark-separation2/assets/sfx/hero/hit/hit3.wav +0 -0
  126. package/examples/battle-benchmark-separation2/assets/sfx/hero/miss/miss1.wav +0 -0
  127. package/examples/battle-benchmark-separation2/assets/sfx/hero/miss/miss2.wav +0 -0
  128. package/examples/battle-benchmark-separation2/assets/sfx/hero/miss/miss3.wav +0 -0
  129. package/examples/battle-benchmark-separation2/assets/sfx/orc/die/die.wav +0 -0
  130. package/examples/battle-benchmark-separation2/assets/sfx/orc/hit/hit1.wav +0 -0
  131. package/examples/battle-benchmark-separation2/assets/sfx/orc/hit/hit2.wav +0 -0
  132. package/examples/battle-benchmark-separation2/assets/sfx/orc/hit/hit3.wav +0 -0
  133. package/examples/battle-benchmark-separation2/assets/sfx/orc/miss/miss1.wav +0 -0
  134. package/examples/battle-benchmark-separation2/assets/sfx/orc/miss/miss2.wav +0 -0
  135. package/examples/battle-benchmark-separation2/assets/sfx/orc/miss/miss3.wav +0 -0
  136. package/examples/battle-benchmark-separation2/assets/spritesheets/hero-atlas.json +246 -0
  137. package/examples/battle-benchmark-separation2/assets/spritesheets/hero.png +0 -0
  138. package/examples/battle-benchmark-separation2/assets/spritesheets/orc-atlas.json +246 -0
  139. package/examples/battle-benchmark-separation2/assets/spritesheets/orc.png +0 -0
  140. package/examples/battle-benchmark-separation2/assets/spritesheets/potion-atlas.json +68 -0
  141. package/examples/battle-benchmark-separation2/assets/spritesheets/potion.png +0 -0
  142. package/examples/battle-benchmark-separation2/dist/game.js +2 -0
  143. package/examples/battle-benchmark-separation2/dist/game.js.LICENSE.txt +35 -0
  144. package/examples/battle-benchmark-separation2/hud/damage-text.ts +46 -0
  145. package/examples/battle-benchmark-separation2/hud/heal-text.ts +46 -0
  146. package/examples/battle-benchmark-separation2/hud/hp-bar.ts +38 -0
  147. package/examples/battle-benchmark-separation2/index.html +24 -0
  148. package/examples/battle-benchmark-separation2/index.ts +41 -0
  149. package/examples/battle-benchmark-separation2/objects/character.ts +195 -0
  150. package/examples/battle-benchmark-separation2/objects/hero.ts +110 -0
  151. package/examples/battle-benchmark-separation2/objects/orc.ts +213 -0
  152. package/examples/battle-benchmark-separation2/objects/potion.ts +27 -0
  153. package/examples/battle-benchmark-separation2/stage.ts +178 -0
  154. package/examples/collision-test/assets/cat.png +0 -0
  155. package/examples/collision-test/dist/game.js +2 -0
  156. package/examples/collision-test/dist/game.js.LICENSE.txt +35 -0
  157. package/examples/collision-test/index.html +24 -0
  158. package/examples/collision-test/index.ts +30 -0
  159. package/examples/dom-particle-test/assets/bird.png +0 -0
  160. package/examples/dom-particle-test/dist/game.js +2 -0
  161. package/examples/dom-particle-test/dist/game.js.LICENSE.txt +35 -0
  162. package/examples/dom-particle-test/index.html +24 -0
  163. package/examples/dom-particle-test/index.ts +27 -0
  164. package/examples/dom-sprite-test/assets/bird.png +0 -0
  165. package/examples/dom-sprite-test/assets/fire.png +0 -0
  166. package/examples/dom-sprite-test/assets/run.png +0 -0
  167. package/examples/dom-sprite-test/dist/game.js +2 -0
  168. package/examples/dom-sprite-test/dist/game.js.LICENSE.txt +35 -0
  169. package/examples/dom-sprite-test/index.html +24 -0
  170. package/examples/dom-sprite-test/index.ts +35 -0
  171. package/examples/dom-test/dist/game.js +2 -0
  172. package/examples/dom-test/dist/game.js.LICENSE.txt +35 -0
  173. package/examples/dom-test/index.html +24 -0
  174. package/examples/dom-test/index.ts +22 -0
  175. package/examples/particle-test/assets/bird.png +0 -0
  176. package/examples/particle-test/dist/game.js +2 -0
  177. package/examples/particle-test/dist/game.js.LICENSE.txt +35 -0
  178. package/examples/particle-test/index.html +24 -0
  179. package/examples/particle-test/index.ts +30 -0
  180. package/examples/renderer-test/dist/game.js +2 -0
  181. package/examples/renderer-test/dist/game.js.LICENSE.txt +35 -0
  182. package/examples/renderer-test/index.html +24 -0
  183. package/examples/renderer-test/index.ts +9 -0
  184. package/examples/simple-battle/assets/bgm/battle.mp3 +0 -0
  185. package/examples/simple-battle/assets/bitmap-fonts/white-peaberry.fnt +107 -0
  186. package/examples/simple-battle/assets/bitmap-fonts/white-peaberry.png +0 -0
  187. package/examples/simple-battle/assets/joystick/joystick.png +0 -0
  188. package/examples/simple-battle/assets/joystick/knob.png +0 -0
  189. package/examples/simple-battle/assets/sfx/hero/die/die.wav +0 -0
  190. package/examples/simple-battle/assets/sfx/hero/heal/heal.wav +0 -0
  191. package/examples/simple-battle/assets/sfx/hero/hit/hit1.wav +0 -0
  192. package/examples/simple-battle/assets/sfx/hero/hit/hit2.wav +0 -0
  193. package/examples/simple-battle/assets/sfx/hero/hit/hit3.wav +0 -0
  194. package/examples/simple-battle/assets/sfx/hero/miss/miss1.wav +0 -0
  195. package/examples/simple-battle/assets/sfx/hero/miss/miss2.wav +0 -0
  196. package/examples/simple-battle/assets/sfx/hero/miss/miss3.wav +0 -0
  197. package/examples/simple-battle/assets/sfx/orc/die/die.wav +0 -0
  198. package/examples/simple-battle/assets/sfx/orc/hit/hit1.wav +0 -0
  199. package/examples/simple-battle/assets/sfx/orc/hit/hit2.wav +0 -0
  200. package/examples/simple-battle/assets/sfx/orc/hit/hit3.wav +0 -0
  201. package/examples/simple-battle/assets/sfx/orc/miss/miss1.wav +0 -0
  202. package/examples/simple-battle/assets/sfx/orc/miss/miss2.wav +0 -0
  203. package/examples/simple-battle/assets/sfx/orc/miss/miss3.wav +0 -0
  204. package/examples/simple-battle/assets/spritesheets/hero-atlas.json +246 -0
  205. package/examples/simple-battle/assets/spritesheets/hero.png +0 -0
  206. package/examples/simple-battle/assets/spritesheets/orc-atlas.json +246 -0
  207. package/examples/simple-battle/assets/spritesheets/orc.png +0 -0
  208. package/examples/simple-battle/assets/spritesheets/potion-atlas.json +68 -0
  209. package/examples/simple-battle/assets/spritesheets/potion.png +0 -0
  210. package/examples/simple-battle/dist/game.js +2 -0
  211. package/examples/simple-battle/dist/game.js.LICENSE.txt +35 -0
  212. package/examples/simple-battle/hud/damage-text.ts +46 -0
  213. package/examples/simple-battle/hud/heal-text.ts +46 -0
  214. package/examples/simple-battle/hud/hp-bar.ts +38 -0
  215. package/examples/simple-battle/index.html +24 -0
  216. package/examples/simple-battle/index.ts +41 -0
  217. package/examples/simple-battle/objects/character.ts +95 -0
  218. package/examples/simple-battle/objects/hero.ts +111 -0
  219. package/examples/simple-battle/objects/orc.ts +107 -0
  220. package/examples/simple-battle/objects/potion.ts +27 -0
  221. package/examples/simple-battle/stage.ts +174 -0
  222. package/examples/spine-test/assets/spine/spineboy.atlas +95 -0
  223. package/examples/spine-test/assets/spine/spineboy.png +0 -0
  224. package/examples/spine-test/assets/spine/spineboy.skel +0 -0
  225. package/examples/spine-test/dist/game.js +2 -0
  226. package/examples/spine-test/dist/game.js.LICENSE.txt +35 -0
  227. package/examples/spine-test/index.html +24 -0
  228. package/examples/spine-test/index.ts +29 -0
  229. package/examples/sprite-test/assets/bird.png +0 -0
  230. package/examples/sprite-test/assets/fire.png +0 -0
  231. package/examples/sprite-test/dist/game.js +2 -0
  232. package/examples/sprite-test/dist/game.js.LICENSE.txt +35 -0
  233. package/examples/sprite-test/index.html +24 -0
  234. package/examples/sprite-test/index.ts +38 -0
  235. package/examples/tsconfig.json +2 -1
  236. package/examples/webpack.config.js +17 -3
  237. package/jest.config.ts +10 -0
  238. package/lib/asset/audio.js +47 -11
  239. package/lib/asset/audio.js.map +1 -1
  240. package/lib/asset/loaders/audio.js +7 -4
  241. package/lib/asset/loaders/audio.js.map +1 -1
  242. package/lib/asset/loaders/binary.js +7 -4
  243. package/lib/asset/loaders/binary.js.map +1 -1
  244. package/lib/asset/loaders/bitmap-font.js +74 -0
  245. package/lib/asset/loaders/bitmap-font.js.map +1 -0
  246. package/lib/asset/loaders/font.js +4 -1
  247. package/lib/asset/loaders/font.js.map +1 -1
  248. package/lib/asset/loaders/loader.js +17 -12
  249. package/lib/asset/loaders/loader.js.map +1 -1
  250. package/lib/asset/loaders/spritesheet.js +18 -8
  251. package/lib/asset/loaders/spritesheet.js.map +1 -1
  252. package/lib/asset/loaders/text.js +6 -3
  253. package/lib/asset/loaders/text.js.map +1 -1
  254. package/lib/asset/loaders/texture.js +22 -26
  255. package/lib/asset/loaders/texture.js.map +1 -1
  256. package/lib/asset/preload.js +60 -56
  257. package/lib/asset/preload.js.map +1 -1
  258. package/lib/collision/check-collision.js +804 -0
  259. package/lib/collision/check-collision.js.map +1 -0
  260. package/lib/collision/check-collision.test.js +300 -0
  261. package/lib/collision/check-collision.test.js.map +1 -0
  262. package/lib/collision/colliders.js +8 -0
  263. package/lib/collision/colliders.js.map +1 -0
  264. package/lib/debug.js.map +1 -0
  265. package/lib/dom/dom-animated-sprite.js +106 -0
  266. package/lib/dom/dom-animated-sprite.js.map +1 -0
  267. package/lib/dom/dom-game-object.js +108 -0
  268. package/lib/dom/dom-game-object.js.map +1 -0
  269. package/lib/dom/dom-particle.js +105 -0
  270. package/lib/dom/dom-particle.js.map +1 -0
  271. package/lib/dom/dom-preload.js +43 -0
  272. package/lib/dom/dom-preload.js.map +1 -0
  273. package/lib/dom/dom-sprite.js +40 -0
  274. package/lib/dom/dom-sprite.js.map +1 -0
  275. package/lib/dom/dom-texture-loader.js +36 -0
  276. package/lib/dom/dom-texture-loader.js.map +1 -0
  277. package/lib/dom/dom-utils.js +20 -0
  278. package/lib/dom/dom-utils.js.map +1 -0
  279. package/lib/index copy.js +16 -0
  280. package/lib/index copy.js.map +1 -0
  281. package/lib/index.js +36 -10
  282. package/lib/index.js.map +1 -1
  283. package/lib/input/joystick.js +262 -0
  284. package/lib/input/joystick.js.map +1 -0
  285. package/lib/node/core/dirty-number.js +19 -0
  286. package/lib/node/core/dirty-number.js.map +1 -0
  287. package/lib/node/core/game-node.js +63 -0
  288. package/lib/node/core/game-node.js.map +1 -0
  289. package/lib/node/core/game-object.js +8 -0
  290. package/lib/node/core/game-object.js.map +1 -0
  291. package/lib/node/core/renderable.js +59 -0
  292. package/lib/node/core/renderable.js.map +1 -0
  293. package/lib/node/core/transform.js +70 -0
  294. package/lib/node/core/transform.js.map +1 -0
  295. package/lib/node/core/transformable.js +85 -0
  296. package/lib/node/core/transformable.js.map +1 -0
  297. package/lib/node/ext/animated-sprite.js +77 -0
  298. package/lib/node/ext/animated-sprite.js.map +1 -0
  299. package/lib/node/ext/bitmap-text.js +93 -0
  300. package/lib/node/ext/bitmap-text.js.map +1 -0
  301. package/lib/node/ext/circle.js +43 -0
  302. package/lib/node/ext/circle.js.map +1 -0
  303. package/lib/node/ext/deplay.js +22 -0
  304. package/lib/node/ext/deplay.js.map +1 -0
  305. package/lib/node/ext/dom-container.js +51 -0
  306. package/lib/node/ext/dom-container.js.map +1 -0
  307. package/lib/node/ext/interval.js +22 -0
  308. package/lib/node/ext/interval.js.map +1 -0
  309. package/lib/node/ext/particle.js +98 -0
  310. package/lib/node/ext/particle.js.map +1 -0
  311. package/lib/node/ext/rectangle.js +52 -0
  312. package/lib/node/ext/rectangle.js.map +1 -0
  313. package/lib/node/ext/spine.js +272 -0
  314. package/lib/node/ext/spine.js.map +1 -0
  315. package/lib/node/ext/sprite.js +42 -0
  316. package/lib/node/ext/sprite.js.map +1 -0
  317. package/lib/node/physics/physics-object.js +92 -0
  318. package/lib/node/physics/physics-object.js.map +1 -0
  319. package/lib/node/physics/physics-world.js +29 -0
  320. package/lib/node/physics/physics-world.js.map +1 -0
  321. package/lib/node/physics/rigidbodies.js +7 -0
  322. package/lib/node/physics/rigidbodies.js.map +1 -0
  323. package/lib/renderer/camera.js +19 -0
  324. package/lib/renderer/camera.js.map +1 -0
  325. package/lib/renderer/container-manager.js +29 -0
  326. package/lib/renderer/container-manager.js.map +1 -0
  327. package/lib/renderer/fps-display.js +18 -0
  328. package/lib/renderer/fps-display.js.map +1 -0
  329. package/lib/renderer/layer.js +12 -0
  330. package/lib/renderer/layer.js.map +1 -0
  331. package/lib/renderer/renderer.js +146 -0
  332. package/lib/renderer/renderer.js.map +1 -0
  333. package/lib/renderer/ticker.js +56 -0
  334. package/lib/renderer/ticker.js.map +1 -0
  335. package/lib/renderer/ticker.test.js +241 -0
  336. package/lib/renderer/ticker.test.js.map +1 -0
  337. package/lib/types/animation-atlas.js +2 -0
  338. package/lib/types/animation-atlas.js.map +1 -0
  339. package/lib/types/asset/audio.d.ts +5 -4
  340. package/lib/types/asset/audio.d.ts.map +1 -1
  341. package/lib/types/asset/loaders/audio.d.ts +2 -1
  342. package/lib/types/asset/loaders/audio.d.ts.map +1 -1
  343. package/lib/types/asset/loaders/binary.d.ts +2 -1
  344. package/lib/types/asset/loaders/binary.d.ts.map +1 -1
  345. package/lib/types/asset/loaders/bitmap-font.d.ts +17 -0
  346. package/lib/types/asset/loaders/bitmap-font.d.ts.map +1 -0
  347. package/lib/types/asset/loaders/font.d.ts +2 -1
  348. package/lib/types/asset/loaders/font.d.ts.map +1 -1
  349. package/lib/types/asset/loaders/loader.d.ts +6 -6
  350. package/lib/types/asset/loaders/loader.d.ts.map +1 -1
  351. package/lib/types/asset/loaders/spritesheet.d.ts +14 -6
  352. package/lib/types/asset/loaders/spritesheet.d.ts.map +1 -1
  353. package/lib/types/asset/loaders/text.d.ts +2 -1
  354. package/lib/types/asset/loaders/text.d.ts.map +1 -1
  355. package/lib/types/asset/loaders/texture.d.ts +2 -2
  356. package/lib/types/asset/loaders/texture.d.ts.map +1 -1
  357. package/lib/types/asset/preload.d.ts +7 -5
  358. package/lib/types/asset/preload.d.ts.map +1 -1
  359. package/lib/types/atlas copy.js +2 -0
  360. package/lib/types/atlas copy.js.map +1 -0
  361. package/lib/types/atlas.js +2 -0
  362. package/lib/types/atlas.js.map +1 -0
  363. package/lib/types/bitmap-font.js +2 -0
  364. package/lib/types/bitmap-font.js.map +1 -0
  365. package/lib/types/collision/check-collision.d.ts +4 -0
  366. package/lib/types/collision/check-collision.d.ts.map +1 -0
  367. package/lib/types/collision/check-collision.test.d.ts +2 -0
  368. package/lib/types/collision/check-collision.test.d.ts.map +1 -0
  369. package/lib/types/collision/colliders.d.ts +34 -0
  370. package/lib/types/collision/colliders.d.ts.map +1 -0
  371. package/lib/types/debug.d.ts.map +1 -0
  372. package/lib/types/dom/dom-animated-sprite.d.ts +23 -0
  373. package/lib/types/dom/dom-animated-sprite.d.ts.map +1 -0
  374. package/lib/types/dom/dom-game-object.d.ts +44 -0
  375. package/lib/types/dom/dom-game-object.d.ts.map +1 -0
  376. package/lib/types/dom/dom-particle.d.ts +30 -0
  377. package/lib/types/dom/dom-particle.d.ts.map +1 -0
  378. package/lib/types/dom/dom-preload.d.ts +2 -0
  379. package/lib/types/dom/dom-preload.d.ts.map +1 -0
  380. package/lib/types/dom/dom-sprite.d.ts +13 -0
  381. package/lib/types/dom/dom-sprite.d.ts.map +1 -0
  382. package/lib/types/dom/dom-texture-loader.d.ts +8 -0
  383. package/lib/types/dom/dom-texture-loader.d.ts.map +1 -0
  384. package/lib/types/dom/dom-utils.d.ts +3 -0
  385. package/lib/types/dom/dom-utils.d.ts.map +1 -0
  386. package/lib/types/index copy.d.ts +16 -0
  387. package/lib/types/index copy.d.ts.map +1 -0
  388. package/lib/types/index.d.ts +26 -11
  389. package/lib/types/index.d.ts.map +1 -1
  390. package/lib/types/input/joystick.d.ts +28 -0
  391. package/lib/types/input/joystick.d.ts.map +1 -0
  392. package/lib/types/node/core/dirty-number.d.ts +9 -0
  393. package/lib/types/node/core/dirty-number.d.ts.map +1 -0
  394. package/lib/types/node/core/game-node.d.ts +16 -0
  395. package/lib/types/node/core/game-node.d.ts.map +1 -0
  396. package/lib/types/node/core/game-object.d.ts +8 -0
  397. package/lib/types/node/core/game-object.d.ts.map +1 -0
  398. package/lib/types/node/core/renderable.d.ts +23 -0
  399. package/lib/types/node/core/renderable.d.ts.map +1 -0
  400. package/lib/types/node/core/transform.d.ts +27 -0
  401. package/lib/types/node/core/transform.d.ts.map +1 -0
  402. package/lib/types/node/core/transformable.d.ts +44 -0
  403. package/lib/types/node/core/transformable.d.ts.map +1 -0
  404. package/lib/types/node/ext/animated-sprite.d.ts +22 -0
  405. package/lib/types/node/ext/animated-sprite.d.ts.map +1 -0
  406. package/lib/types/node/ext/bitmap-text.d.ts +14 -0
  407. package/lib/types/node/ext/bitmap-text.d.ts.map +1 -0
  408. package/lib/types/node/ext/circle.d.ts +19 -0
  409. package/lib/types/node/ext/circle.d.ts.map +1 -0
  410. package/lib/types/node/ext/deplay.d.ts +8 -0
  411. package/lib/types/node/ext/deplay.d.ts.map +1 -0
  412. package/lib/types/node/ext/dom-container.d.ts +12 -0
  413. package/lib/types/node/ext/dom-container.d.ts.map +1 -0
  414. package/lib/types/node/ext/interval.d.ts +9 -0
  415. package/lib/types/node/ext/interval.d.ts.map +1 -0
  416. package/lib/types/node/ext/particle.d.ts +30 -0
  417. package/lib/types/node/ext/particle.d.ts.map +1 -0
  418. package/lib/types/node/ext/rectangle.d.ts +22 -0
  419. package/lib/types/node/ext/rectangle.d.ts.map +1 -0
  420. package/lib/types/node/ext/spine.d.ts +36 -0
  421. package/lib/types/node/ext/spine.d.ts.map +1 -0
  422. package/lib/types/node/ext/sprite.d.ts +13 -0
  423. package/lib/types/node/ext/sprite.d.ts.map +1 -0
  424. package/lib/types/node/physics/physics-object.d.ts +38 -0
  425. package/lib/types/node/physics/physics-object.d.ts.map +1 -0
  426. package/lib/types/node/physics/physics-world.d.ts +18 -0
  427. package/lib/types/node/physics/physics-world.d.ts.map +1 -0
  428. package/lib/types/node/physics/rigidbodies.d.ts +23 -0
  429. package/lib/types/node/physics/rigidbodies.d.ts.map +1 -0
  430. package/lib/types/renderer/camera.d.ts +13 -0
  431. package/lib/types/renderer/camera.d.ts.map +1 -0
  432. package/lib/types/renderer/container-manager.d.ts +9 -0
  433. package/lib/types/renderer/container-manager.d.ts.map +1 -0
  434. package/lib/types/renderer/fps-display.d.ts +7 -0
  435. package/lib/types/renderer/fps-display.d.ts.map +1 -0
  436. package/lib/types/renderer/layer.d.ts +7 -0
  437. package/lib/types/renderer/layer.d.ts.map +1 -0
  438. package/lib/types/renderer/renderer.d.ts +40 -0
  439. package/lib/types/renderer/renderer.d.ts.map +1 -0
  440. package/lib/types/renderer/ticker.d.ts +6 -0
  441. package/lib/types/renderer/ticker.d.ts.map +1 -0
  442. package/lib/types/renderer/ticker.test.d.ts +40 -0
  443. package/lib/types/renderer/ticker.test.d.ts.map +1 -0
  444. package/lib/types/sprite-atlas.js +2 -0
  445. package/lib/types/sprite-atlas.js.map +1 -0
  446. package/lib/types/types/animation-atlas.d.ts +14 -0
  447. package/lib/types/types/animation-atlas.d.ts.map +1 -0
  448. package/lib/types/types/atlas copy.d.ts +12 -0
  449. package/lib/types/types/atlas copy.d.ts.map +1 -0
  450. package/lib/types/types/atlas.d.ts +16 -0
  451. package/lib/types/types/atlas.d.ts.map +1 -0
  452. package/lib/types/types/bitmap-font.d.ts +18 -0
  453. package/lib/types/types/bitmap-font.d.ts.map +1 -0
  454. package/lib/types/types/sprite-atlas.d.ts +13 -0
  455. package/lib/types/types/sprite-atlas.d.ts.map +1 -0
  456. package/lib/types/utils/device.d.ts +2 -0
  457. package/lib/types/utils/device.d.ts.map +1 -0
  458. package/lib/utils/device.js +2 -0
  459. package/lib/utils/device.js.map +1 -0
  460. package/package.json +8 -7
  461. package/src/asset/audio.ts +134 -90
  462. package/src/asset/loaders/audio.ts +23 -20
  463. package/src/asset/loaders/binary.ts +20 -16
  464. package/src/asset/loaders/bitmap-font.ts +91 -0
  465. package/src/asset/loaders/font.ts +18 -14
  466. package/src/asset/loaders/loader.ts +27 -23
  467. package/src/asset/loaders/spritesheet.ts +47 -36
  468. package/src/asset/loaders/text.ts +19 -15
  469. package/src/asset/loaders/texture.ts +30 -37
  470. package/src/asset/preload.ts +71 -64
  471. package/src/collision/check-collision.test.ts +349 -0
  472. package/src/collision/check-collision.ts +821 -0
  473. package/src/collision/colliders.ts +19 -0
  474. package/src/debug.ts +5 -0
  475. package/src/dom/dom-animated-sprite.ts +132 -0
  476. package/src/dom/dom-game-object.ts +134 -0
  477. package/src/dom/dom-particle.ts +151 -0
  478. package/src/dom/dom-preload.ts +54 -0
  479. package/src/dom/dom-sprite.ts +50 -0
  480. package/src/dom/dom-texture-loader.ts +44 -0
  481. package/src/dom/dom-utils.ts +19 -0
  482. package/src/index.ts +47 -13
  483. package/src/input/joystick.ts +316 -0
  484. package/src/node/core/dirty-number.ts +21 -0
  485. package/src/node/core/game-node.ts +74 -0
  486. package/src/node/core/game-object.ts +11 -0
  487. package/src/node/core/renderable.ts +72 -0
  488. package/src/node/core/transform.ts +82 -0
  489. package/src/node/core/transformable.ts +111 -0
  490. package/src/node/ext/animated-sprite.ts +103 -0
  491. package/src/node/ext/bitmap-text.ts +113 -0
  492. package/src/node/ext/circle.ts +55 -0
  493. package/src/node/ext/deplay.ts +25 -0
  494. package/src/node/ext/dom-container.ts +62 -0
  495. package/src/node/ext/interval.ts +25 -0
  496. package/src/node/ext/particle.ts +142 -0
  497. package/src/node/ext/rectangle.ts +71 -0
  498. package/src/node/ext/spine.ts +323 -0
  499. package/src/node/ext/sprite.ts +53 -0
  500. package/src/node/physics/physics-object.ts +127 -0
  501. package/src/node/physics/physics-world.ts +41 -0
  502. package/src/node/physics/rigidbodies.ts +14 -0
  503. package/src/renderer/camera.ts +25 -0
  504. package/src/renderer/container-manager.ts +36 -0
  505. package/src/renderer/fps-display.ts +21 -0
  506. package/src/renderer/layer.ts +15 -0
  507. package/src/renderer/renderer.ts +181 -0
  508. package/src/renderer/ticker.test.ts +325 -0
  509. package/src/renderer/ticker.ts +54 -0
  510. package/src/types/atlas.ts +17 -0
  511. package/src/types/bitmap-font.ts +19 -0
  512. package/src/utils/device.ts +1 -0
  513. package/examples/test-dom/index.ts +0 -21
  514. package/lib/game-object/game-object-physics.js +0 -188
  515. package/lib/game-object/game-object-physics.js.map +0 -1
  516. package/lib/game-object/game-object-rendering.js +0 -35
  517. package/lib/game-object/game-object-rendering.js.map +0 -1
  518. package/lib/game-object/game-object.js +0 -162
  519. package/lib/game-object/game-object.js.map +0 -1
  520. package/lib/game-object/transform.js +0 -118
  521. package/lib/game-object/transform.js.map +0 -1
  522. package/lib/game-object-ext/animated-sprite.js +0 -117
  523. package/lib/game-object-ext/animated-sprite.js.map +0 -1
  524. package/lib/game-object-ext/dom-container.js +0 -56
  525. package/lib/game-object-ext/dom-container.js.map +0 -1
  526. package/lib/game-object-ext/rect.js +0 -30
  527. package/lib/game-object-ext/rect.js.map +0 -1
  528. package/lib/game-object-ext/spine.js +0 -206
  529. package/lib/game-object-ext/spine.js.map +0 -1
  530. package/lib/game-object-ext/sprite.js +0 -46
  531. package/lib/game-object-ext/sprite.js.map +0 -1
  532. package/lib/game-object-ext/text.js +0 -68
  533. package/lib/game-object-ext/text.js.map +0 -1
  534. package/lib/game-object-ext/tiling-sprite.js +0 -64
  535. package/lib/game-object-ext/tiling-sprite.js.map +0 -1
  536. package/lib/types/game-object/game-object-physics.d.ts +0 -42
  537. package/lib/types/game-object/game-object-physics.d.ts.map +0 -1
  538. package/lib/types/game-object/game-object-rendering.d.ts +0 -15
  539. package/lib/types/game-object/game-object-rendering.d.ts.map +0 -1
  540. package/lib/types/game-object/game-object.d.ts +0 -81
  541. package/lib/types/game-object/game-object.d.ts.map +0 -1
  542. package/lib/types/game-object/transform.d.ts +0 -43
  543. package/lib/types/game-object/transform.d.ts.map +0 -1
  544. package/lib/types/game-object-ext/animated-sprite.d.ts +0 -29
  545. package/lib/types/game-object-ext/animated-sprite.d.ts.map +0 -1
  546. package/lib/types/game-object-ext/dom-container.d.ts +0 -16
  547. package/lib/types/game-object-ext/dom-container.d.ts.map +0 -1
  548. package/lib/types/game-object-ext/rect.d.ts +0 -17
  549. package/lib/types/game-object-ext/rect.d.ts.map +0 -1
  550. package/lib/types/game-object-ext/spine.d.ts +0 -35
  551. package/lib/types/game-object-ext/spine.d.ts.map +0 -1
  552. package/lib/types/game-object-ext/sprite.d.ts +0 -14
  553. package/lib/types/game-object-ext/sprite.d.ts.map +0 -1
  554. package/lib/types/game-object-ext/text.d.ts +0 -26
  555. package/lib/types/game-object-ext/text.d.ts.map +0 -1
  556. package/lib/types/game-object-ext/tiling-sprite.d.ts +0 -20
  557. package/lib/types/game-object-ext/tiling-sprite.d.ts.map +0 -1
  558. package/lib/types/utils/debug.d.ts.map +0 -1
  559. package/lib/types/utils/go.d.ts +0 -26
  560. package/lib/types/utils/go.d.ts.map +0 -1
  561. package/lib/types/world/world-debug.d.ts +0 -11
  562. package/lib/types/world/world-debug.d.ts.map +0 -1
  563. package/lib/types/world/world-physics.d.ts +0 -16
  564. package/lib/types/world/world-physics.d.ts.map +0 -1
  565. package/lib/types/world/world-rendering.d.ts +0 -28
  566. package/lib/types/world/world-rendering.d.ts.map +0 -1
  567. package/lib/types/world/world.d.ts +0 -38
  568. package/lib/types/world/world.d.ts.map +0 -1
  569. package/lib/utils/debug.js.map +0 -1
  570. package/lib/utils/go.js +0 -33
  571. package/lib/utils/go.js.map +0 -1
  572. package/lib/world/world-debug.js +0 -89
  573. package/lib/world/world-debug.js.map +0 -1
  574. package/lib/world/world-physics.js +0 -45
  575. package/lib/world/world-physics.js.map +0 -1
  576. package/lib/world/world-rendering.js +0 -123
  577. package/lib/world/world-rendering.js.map +0 -1
  578. package/lib/world/world.js +0 -147
  579. package/lib/world/world.js.map +0 -1
  580. package/src/game-object/game-object-physics.ts +0 -191
  581. package/src/game-object/game-object-rendering.ts +0 -27
  582. package/src/game-object/game-object.ts +0 -190
  583. package/src/game-object/transform.ts +0 -164
  584. package/src/game-object-ext/animated-sprite.ts +0 -140
  585. package/src/game-object-ext/dom-container.ts +0 -67
  586. package/src/game-object-ext/rect.ts +0 -40
  587. package/src/game-object-ext/spine.ts +0 -235
  588. package/src/game-object-ext/sprite.ts +0 -55
  589. package/src/game-object-ext/text.ts +0 -83
  590. package/src/game-object-ext/tiling-sprite.ts +0 -73
  591. package/src/utils/debug.ts +0 -5
  592. package/src/utils/go.ts +0 -53
  593. package/src/world/world-debug.ts +0 -114
  594. package/src/world/world-physics.ts +0 -52
  595. package/src/world/world-rendering.ts +0 -145
  596. package/src/world/world.ts +0 -171
  597. /package/examples/{test-dom → auto-battle}/index.html +0 -0
  598. /package/lib/{utils/debug.js → debug.js} +0 -0
  599. /package/lib/types/{utils/debug.d.ts → debug.d.ts} +0 -0
@@ -0,0 +1,2 @@
1
+ /*! For license information please see game.js.LICENSE.txt */
2
+ (()=>{var t={59:(t,e,r)=>{"use strict";r.d(e,{b:()=>s});class s{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new s(this.x,this.y)}copyFrom(t){return this.set(t.x,t.y),this}copyTo(t){return t.set(this.x,this.y),t}equals(t){return t.x===this.x&&t.y===this.y}set(t=0,e=t){return this.x=t,this.y=e,this}toString(){return`[pixi.js/math:Point x=${this.x} y=${this.y}]`}static get shared(){return i.x=0,i.y=0,i}}const i=new s},498:(t,e,r)=>{"use strict";r.d(e,{q:()=>n});var s=r(7694),i=r(4988);function n(t,e){for(const r in t.attributes){const i=t.attributes[r],n=e[r];n?(i.format??(i.format=n.format),i.offset??(i.offset=n.offset),i.instance??(i.instance=n.instance)):(0,s.R)(`Attribute ${r} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`)}!function(t){const{buffers:e,attributes:r}=t,s={},n={};for(const t in e){const r=e[t];s[r.uid]=0,n[r.uid]=0}for(const t in r){const e=r[t];s[e.buffer.uid]+=(0,i.m)(e.format).stride}for(const t in r){const e=r[t];e.stride??(e.stride=s[e.buffer.uid]),e.start??(e.start=n[e.buffer.uid]),n[e.buffer.uid]+=(0,i.m)(e.format).stride}}(t)}},656:(t,e,r)=>{"use strict";r.d(e,{i:()=>v});var s=r(9375),i=r(4142),n=r(4696),o=r(1753),a=r(9062),l=r(3769),h=r(8574),c=r(6890);let u=null;class d{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let t=0;t<this.count;t++){const e=this.textures[t];this.textures[t]=null,this.ids[e.uid]=null}this.count=0}}class p{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new d,this.blendMode="normal",this.topology="triangle-strip",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null}}const f=[];let g=0;function m(){return g>0?f[--g]:new p}function x(t){f[g++]=t}o.L.register({clear:()=>{if(f.length>0)for(const t of f)t&&t.destroy();f.length=0,g=0}});let _=0;const y=class t{constructor(e){this.uid=(0,s.L)("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],(e={...t.defaultOptions,...e}).maxTextures||((0,n.t6)("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),e.maxTextures=function(){if(u)return u;const t=(0,h.W)();return u=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),u=(0,c.u)(u,t),t.getExtension("WEBGL_lose_context")?.loseContext(),u}());const{maxTextures:r,attributesInitialSize:o,indicesInitialSize:a}=e;this.attributeBuffer=new i.u(4*o),this.indexBuffer=new Uint16Array(a),this.maxTextures=r}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;t<this.batchIndex;t++)x(this.batches[t]);this.batchIndex=0,this._batchIndexStart=0,this._batchIndexSize=0,this.dirty=!0}add(t){this._elements[this.elementSize++]=t,t._indexStart=this.indexSize,t._attributeStart=this.attributeSize,t._batcher=this,this.indexSize+=t.indexSize,this.attributeSize+=t.attributeSize*this.vertexSize}checkAndUpdateTexture(t,e){const r=t._batch.textures.ids[e._source.uid];return!(!r&&0!==r||(t._textureId=r,t.texture=e,0))}updateElement(t){this.dirty=!0;const e=this.attributeBuffer;t.packAsQuad?this.packQuadAttributes(t,e.float32View,e.uint32View,t._attributeStart,t._textureId):this.packAttributes(t,e.float32View,e.uint32View,t._attributeStart,t._textureId)}break(t){const e=this._elements;if(!e[this.elementStart])return;let r=m(),s=r.textures;s.clear();const i=e[this.elementStart];let n=(0,l.i)(i.blendMode,i.texture._source),o=i.topology;4*this.attributeSize>this.attributeBuffer.size&&this._resizeAttributeBuffer(4*this.attributeSize),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const a=this.attributeBuffer.float32View,h=this.attributeBuffer.uint32View,c=this.indexBuffer;let u=this._batchIndexSize,d=this._batchIndexStart,p="startBatch";const f=this.maxTextures;for(let i=this.elementStart;i<this.elementSize;++i){const g=e[i];e[i]=null;const x=g.texture._source,y=(0,l.i)(g.blendMode,x),v=n!==y||o!==g.topology;x._batchTick!==_||v?(x._batchTick=_,(s.count>=f||v)&&(this._finishBatch(r,d,u-d,s,n,o,t,p),p="renderBatch",d=u,n=y,o=g.topology,r=m(),s=r.textures,s.clear(),++_),g._textureId=x._textureBindLocation=s.count,s.ids[x.uid]=s.count,s.textures[s.count++]=x,g._batch=r,u+=g.indexSize,g.packAsQuad?(this.packQuadAttributes(g,a,h,g._attributeStart,g._textureId),this.packQuadIndex(c,g._indexStart,g._attributeStart/this.vertexSize)):(this.packAttributes(g,a,h,g._attributeStart,g._textureId),this.packIndex(g,c,g._indexStart,g._attributeStart/this.vertexSize))):(g._textureId=x._textureBindLocation,u+=g.indexSize,g.packAsQuad?(this.packQuadAttributes(g,a,h,g._attributeStart,g._textureId),this.packQuadIndex(c,g._indexStart,g._attributeStart/this.vertexSize)):(this.packAttributes(g,a,h,g._attributeStart,g._textureId),this.packIndex(g,c,g._indexStart,g._attributeStart/this.vertexSize)),g._batch=r)}s.count>0&&(this._finishBatch(r,d,u-d,s,n,o,t,p),d=u,++_),this.elementStart=this.elementSize,this._batchIndexStart=d,this._batchIndexSize=u}_finishBatch(t,e,r,s,i,n,o,a){t.gpuBindGroup=null,t.bindGroup=null,t.action=a,t.batcher=this,t.textures=s,t.blendMode=i,t.topology=n,t.start=e,t.size=r,++_,this.batches[this.batchIndex++]=t,o.add(t)}finish(t){this.break(t)}ensureAttributeBuffer(t){4*t<=this.attributeBuffer.size||this._resizeAttributeBuffer(4*t)}ensureIndexBuffer(t){t<=this.indexBuffer.length||this._resizeIndexBuffer(t)}_resizeAttributeBuffer(t){const e=Math.max(t,2*this.attributeBuffer.size),r=new i.u(e);(0,a.W)(this.attributeBuffer.rawBinaryData,r.rawBinaryData),this.attributeBuffer=r}_resizeIndexBuffer(t){const e=this.indexBuffer;let r=Math.max(t,1.5*e.length);r+=r%2;const s=r>65535?new Uint32Array(r):new Uint16Array(r);if(s.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let t=0;t<e.length;t++)s[t]=e[t];else(0,a.W)(e.buffer,s.buffer);this.indexBuffer=s}packQuadIndex(t,e,r){t[e]=r+0,t[e+1]=r+1,t[e+2]=r+2,t[e+3]=r+0,t[e+4]=r+2,t[e+5]=r+3}packIndex(t,e,r,s){const i=t.indices,n=t.indexSize,o=t.indexOffset,a=t.attributeOffset;for(let t=0;t<n;t++)e[r++]=s+i[t+o]-a}destroy(){if(null!==this.batches){for(let t=0;t<this.batches.length;t++)x(this.batches[t]);this.batches=null;for(let t=0;t<this._elements.length;t++)this._elements[t]&&(this._elements[t]._batch=null);this._elements=null,this.indexBuffer=null,this.attributeBuffer.destroy(),this.attributeBuffer=null}}};y.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let v=y},761:(t,e,r)=>{"use strict";r.d(e,{Z:()=>n});var s=r(1753);class i{constructor(t,e){this._pool=[],this._count=0,this._index=0,this._classType=t,e&&this.prepopulate(e)}prepopulate(t){for(let e=0;e<t;e++)this._pool[this._index++]=new this._classType;this._count+=t}get(t){let e;return e=this._index>0?this._pool[--this._index]:new this._classType,e.init?.(t),e}return(t){t.reset?.(),this._pool[this._index++]=t}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){if(this._pool.length>0&&this._pool[0].destroy)for(let t=0;t<this._index;t++)this._pool[t].destroy();this._pool.length=0,this._count=0,this._index=0}}const n=new class{constructor(){this._poolsByClass=new Map}prepopulate(t,e){this.getPool(t).prepopulate(e)}get(t,e){return this.getPool(t).get(e)}return(t){this.getPool(t.constructor).return(t)}getPool(t){return this._poolsByClass.has(t)||this._poolsByClass.set(t,new i(t)),this._poolsByClass.get(t)}stats(){const t={};return this._poolsByClass.forEach(e=>{const r=t[e._classType.name]?e._classType.name+e._classType.ID:e._classType.name;t[r]={free:e.totalFree,used:e.totalUsed,size:e.totalSize}}),t}clear(){this._poolsByClass.forEach(t=>t.clear()),this._poolsByClass.clear()}};s.L.register(n)},769:(t,e,r)=>{"use strict";r.d(e,{E:()=>u});var s=r(5199);const i=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],n=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],o=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],a=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],l=[],h=[],c=Math.sign;!function(){for(let t=0;t<16;t++){const e=[];l.push(e);for(let r=0;r<16;r++){const s=c(i[t]*i[r]+o[t]*n[r]),l=c(n[t]*i[r]+a[t]*n[r]),h=c(i[t]*o[r]+o[t]*a[r]),u=c(n[t]*o[r]+a[t]*a[r]);for(let t=0;t<16;t++)if(i[t]===s&&n[t]===l&&o[t]===h&&a[t]===u){e.push(t);break}}}for(let t=0;t<16;t++){const e=new s.u;e.set(i[t],n[t],o[t],a[t],0,0),h.push(e)}}();const u={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:t=>i[t],uY:t=>n[t],vX:t=>o[t],vY:t=>a[t],inv:t=>8&t?15&t:7&-t,add:(t,e)=>l[t][e],sub:(t,e)=>l[t][u.inv(e)],rotate180:t=>4^t,isVertical:t=>2==(3&t),byDirection:(t,e)=>2*Math.abs(t)<=Math.abs(e)?e>=0?u.S:u.N:2*Math.abs(e)<=Math.abs(t)?t>0?u.E:u.W:e>0?t>0?u.SE:u.SW:t>0?u.NE:u.NW,matrixAppendRotationInv:(t,e,r=0,s=0)=>{const i=h[u.inv(e)];i.tx=r,i.ty=s,t.append(i)},transformRectCoords:(t,e,r,s)=>{const{x:i,y:n,width:o,height:a}=t,{x:l,y:h,width:c,height:d}=e;return r===u.E?(s.set(i+l,n+h,o,a),s):r===u.S?s.set(c-n-a+l,i+h,a,o):r===u.W?s.set(c-i-o+l,d-n-a+h,o,a):r===u.N?s.set(n+l,d-i-o+h,a,o):s.set(i+l,n+h,o,a)}}},792:t=>{"use strict";var e=Object.prototype.hasOwnProperty,r="~";function s(){}function i(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function n(t,e,s,n,o){if("function"!=typeof s)throw new TypeError("The listener must be a function");var a=new i(s,n||t,o),l=r?r+e:e;return t._events[l]?t._events[l].fn?t._events[l]=[t._events[l],a]:t._events[l].push(a):(t._events[l]=a,t._eventsCount++),t}function o(t,e){0===--t._eventsCount?t._events=new s:delete t._events[e]}function a(){this._events=new s,this._eventsCount=0}Object.create&&(s.prototype=Object.create(null),(new s).__proto__||(r=!1)),a.prototype.eventNames=function(){var t,s,i=[];if(0===this._eventsCount)return i;for(s in t=this._events)e.call(t,s)&&i.push(r?s.slice(1):s);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(t)):i},a.prototype.listeners=function(t){var e=r?r+t:t,s=this._events[e];if(!s)return[];if(s.fn)return[s.fn];for(var i=0,n=s.length,o=new Array(n);i<n;i++)o[i]=s[i].fn;return o},a.prototype.listenerCount=function(t){var e=r?r+t:t,s=this._events[e];return s?s.fn?1:s.length:0},a.prototype.emit=function(t,e,s,i,n,o){var a=r?r+t:t;if(!this._events[a])return!1;var l,h,c=this._events[a],u=arguments.length;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),u){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,e),!0;case 3:return c.fn.call(c.context,e,s),!0;case 4:return c.fn.call(c.context,e,s,i),!0;case 5:return c.fn.call(c.context,e,s,i,n),!0;case 6:return c.fn.call(c.context,e,s,i,n,o),!0}for(h=1,l=new Array(u-1);h<u;h++)l[h-1]=arguments[h];c.fn.apply(c.context,l)}else{var d,p=c.length;for(h=0;h<p;h++)switch(c[h].once&&this.removeListener(t,c[h].fn,void 0,!0),u){case 1:c[h].fn.call(c[h].context);break;case 2:c[h].fn.call(c[h].context,e);break;case 3:c[h].fn.call(c[h].context,e,s);break;case 4:c[h].fn.call(c[h].context,e,s,i);break;default:if(!l)for(d=1,l=new Array(u-1);d<u;d++)l[d-1]=arguments[d];c[h].fn.apply(c[h].context,l)}}return!0},a.prototype.on=function(t,e,r){return n(this,t,e,r,!1)},a.prototype.once=function(t,e,r){return n(this,t,e,r,!0)},a.prototype.removeListener=function(t,e,s,i){var n=r?r+t:t;if(!this._events[n])return this;if(!e)return o(this,n),this;var a=this._events[n];if(a.fn)a.fn!==e||i&&!a.once||s&&a.context!==s||o(this,n);else{for(var l=0,h=[],c=a.length;l<c;l++)(a[l].fn!==e||i&&!a[l].once||s&&a[l].context!==s)&&h.push(a[l]);h.length?this._events[n]=1===h.length?h[0]:h:o(this,n)}return this},a.prototype.removeAllListeners=function(t){var e;return t?(e=r?r+t:t,this._events[e]&&o(this,e)):(this._events=new s,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=r,a.EventEmitter=a,t.exports=a},966:(t,e,r)=>{"use strict";var s=r(1065),i=r(2445),n=r(4454),o=r(7926),a=r(5199),l=r(9677),h=r(2305),c=r(1570),u=r(7335),d=r(2478),p=r(1657),f=r(4449);const g={name:"local-uniform-msdf-bit",vertex:{header:"\n struct LocalUniforms {\n uColor:vec4<f32>,\n uTransformMatrix:mat3x3<f32>,\n uDistance: f32,\n uRound:f32,\n }\n\n @group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;\n ",main:"\n vColor *= localUniforms.uColor;\n modelMatrix *= localUniforms.uTransformMatrix;\n ",end:"\n if(localUniforms.uRound == 1)\n {\n vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);\n }\n "},fragment:{header:"\n struct LocalUniforms {\n uColor:vec4<f32>,\n uTransformMatrix:mat3x3<f32>,\n uDistance: f32\n }\n\n @group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;\n ",main:"\n outColor = vec4<f32>(calculateMSDFAlpha(outColor, localUniforms.uColor, localUniforms.uDistance));\n "}},m={name:"local-uniform-msdf-bit",vertex:{header:"\n uniform mat3 uTransformMatrix;\n uniform vec4 uColor;\n uniform float uRound;\n ",main:"\n vColor *= uColor;\n modelMatrix *= uTransformMatrix;\n ",end:"\n if(uRound == 1.)\n {\n gl_Position.xy = roundPixels(gl_Position.xy, uResolution);\n }\n "},fragment:{header:"\n uniform float uDistance;\n ",main:"\n outColor = vec4(calculateMSDFAlpha(outColor, vColor, uDistance));\n "}},x={name:"msdf-bit",fragment:{header:"\n fn calculateMSDFAlpha(msdfColor:vec4<f32>, shapeColor:vec4<f32>, distance:f32) -> f32 {\n\n // MSDF\n var median = msdfColor.r + msdfColor.g + msdfColor.b -\n min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -\n max(msdfColor.r, max(msdfColor.g, msdfColor.b));\n\n // SDF\n median = min(median, msdfColor.a);\n\n var screenPxDistance = distance * (median - 0.5);\n var alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);\n if (median < 0.01) {\n alpha = 0.0;\n } else if (median > 0.99) {\n alpha = 1.0;\n }\n\n // Gamma correction for coverage-like alpha\n var luma: f32 = dot(shapeColor.rgb, vec3<f32>(0.299, 0.587, 0.114));\n var gamma: f32 = mix(1.0, 1.0 / 2.2, luma);\n var coverage: f32 = pow(shapeColor.a * alpha, gamma);\n\n return coverage;\n\n }\n "}},_={name:"msdf-bit",fragment:{header:"\n float calculateMSDFAlpha(vec4 msdfColor, vec4 shapeColor, float distance) {\n\n // MSDF\n float median = msdfColor.r + msdfColor.g + msdfColor.b -\n min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -\n max(msdfColor.r, max(msdfColor.g, msdfColor.b));\n\n // SDF\n median = min(median, msdfColor.a);\n\n float screenPxDistance = distance * (median - 0.5);\n float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);\n\n if (median < 0.01) {\n alpha = 0.0;\n } else if (median > 0.99) {\n alpha = 1.0;\n }\n\n // Gamma correction for coverage-like alpha\n float luma = dot(shapeColor.rgb, vec3(0.299, 0.587, 0.114));\n float gamma = mix(1.0, 1.0 / 2.2, luma);\n float coverage = pow(shapeColor.a * alpha, gamma);\n\n return coverage;\n }\n "}};let y,v;class b extends p.M{constructor(t){const e=new f.k({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new a.u,type:"mat3x3<f32>"},uDistance:{value:4,type:"f32"},uRound:{value:0,type:"f32"}});y??(y=(0,l.v)({name:"sdf-shader",bits:[h.F,(0,c._)(t),g,x,u.b]})),v??(v=(0,l.I)({name:"sdf-shader",bits:[h.a,(0,c.P)(t),m,_,u.m]})),super({glProgram:v,gpuProgram:y,resources:{localUniforms:e,batchSamplers:(0,d.n)(t)}})}}var w=r(8598),T=r(5353);class S extends n.A{destroy(){this.context.customShader&&this.context.customShader.destroy(),super.destroy()}}class A{constructor(t){this._renderer=t}validateRenderable(t){const e=this._getGpuBitmapText(t);return this._renderer.renderPipes.graphics.validateRenderable(e)}addRenderable(t,e){const r=this._getGpuBitmapText(t);C(t,r),t._didTextUpdate&&(t._didTextUpdate=!1,this._updateContext(t,r)),this._renderer.renderPipes.graphics.addRenderable(r,e),r.context.customShader&&this._updateDistanceField(t)}updateRenderable(t){const e=this._getGpuBitmapText(t);C(t,e),this._renderer.renderPipes.graphics.updateRenderable(e),e.context.customShader&&this._updateDistanceField(t)}_updateContext(t,e){const{context:r}=e,s=w.c.getFont(t.text,t._style);r.clear(),"none"!==s.distanceField.type&&(r.customShader||(r.customShader=new b(this._renderer.limits.maxBatchableTextures)));const i=o.P.graphemeSegmenter(t.text),n=t._style;let a=s.baseLineOffset;const l=(0,T.Z)(i,n,s,!0),h=n.padding,c=l.scale;let u=l.width,d=l.height+l.offsetY;n._stroke&&(u+=n._stroke.width/c,d+=n._stroke.width/c),r.translate(-t._anchor._x*u-h,-t._anchor._y*d-h).scale(c,c);const p=s.applyFillAsTint?n._fill.color:16777215;let f=s.fontMetrics.fontSize,g=s.lineHeight;n.lineHeight&&(f=n.fontSize/c,g=n.lineHeight/c);let m=(g-f)/2;m-s.baseLineOffset<0&&(m=0);for(let t=0;t<l.lines.length;t++){const e=l.lines[t];for(let t=0;t<e.charPositions.length;t++){const i=e.chars[t],n=s.chars[i];if(n?.texture){const s=n.texture;r.texture(s,p||"black",Math.round(e.charPositions[t]+n.xOffset),Math.round(a+n.yOffset+m),s.orig.width,s.orig.height)}}a+=g}}_getGpuBitmapText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new S;return t._gpuData[this._renderer.uid]=e,this._updateContext(t,e),e}_updateDistanceField(t){const e=this._getGpuBitmapText(t).context,r=t._style.fontFamily,s=i.l.get(`${r}-bitmap`),{a:n,b:o,c:a,d:l}=t.groupTransform,h=Math.sqrt(n*n+o*o),c=Math.sqrt(a*a+l*l),u=(Math.abs(h)+Math.abs(c))/2,d=s.baseRenderedFontSize/t._style.fontSize,p=u*s.distanceField.range*(1/d);e.customShader.resources.localUniforms.uniforms.uDistance=p}destroy(){this._renderer=null}}function C(t,e){e.groupTransform=t.groupTransform,e.groupColorAlpha=t.groupColorAlpha,e.groupColor=t.groupColor,e.groupBlendMode=t.groupBlendMode,e.globalDisplayStatus=t.globalDisplayStatus,e.groupTransform=t.groupTransform,e.localDisplayStatus=t.localDisplayStatus,e.groupAlpha=t.groupAlpha,e._roundPixels=t._roundPixels}A.extension={type:[s.Ag.WebGLPipes,s.Ag.WebGPUPipes,s.Ag.CanvasPipes],name:"bitmapText"},s.XO.add(A)},1009:(t,e,r)=>{"use strict";r.d(e,{W:()=>o});var s=r(8883),i=r(1579),n=r(9798);class o{constructor(t){this._syncFunctionHash=Object.create(null),this._adaptor=t,this._systemCheck()}_systemCheck(){if(!(0,s.f)())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}ensureUniformGroup(t){const e=this.getUniformGroupData(t);t.buffer||(t.buffer=new i.h({data:new Float32Array(e.layout.size/4),usage:n.S.UNIFORM|n.S.COPY_DST}))}getUniformGroupData(t){return this._syncFunctionHash[t._signature]||this._initUniformGroup(t)}_initUniformGroup(t){const e=t._signature;let r=this._syncFunctionHash[e];if(!r){const s=Object.keys(t.uniformStructures).map(e=>t.uniformStructures[e]),i=this._adaptor.createUboElements(s),n=this._generateUboSync(i.uboElements);r=this._syncFunctionHash[e]={layout:i,syncFunction:n}}return this._syncFunctionHash[e]}_generateUboSync(t){return this._adaptor.generateUboSync(t)}syncUniformGroup(t,e,r){const s=this.getUniformGroupData(t);t.buffer||(t.buffer=new i.h({data:new Float32Array(s.layout.size/4),usage:n.S.UNIFORM|n.S.COPY_DST}));let o=null;return e||(e=t.buffer.data,o=t.buffer.dataInt32),r||(r=0),s.syncFunction(t.uniforms,e,o,r),!0}updateUniformGroup(t){if(t.isStatic&&!t._dirtyId)return!1;t._dirtyId=0;const e=this.syncUniformGroup(t);return t.buffer.update(),e}destroy(){this._syncFunctionHash=null}}},1065:(t,e,r)=>{"use strict";r.d(e,{Ag:()=>s,XO:()=>o});var s=(t=>(t.Application="application",t.WebGLPipes="webgl-pipes",t.WebGLPipesAdaptor="webgl-pipes-adaptor",t.WebGLSystem="webgl-system",t.WebGPUPipes="webgpu-pipes",t.WebGPUPipesAdaptor="webgpu-pipes-adaptor",t.WebGPUSystem="webgpu-system",t.CanvasSystem="canvas-system",t.CanvasPipesAdaptor="canvas-pipes-adaptor",t.CanvasPipes="canvas-pipes",t.Asset="asset",t.LoadParser="load-parser",t.ResolveParser="resolve-parser",t.CacheParser="cache-parser",t.DetectionParser="detection-parser",t.MaskEffect="mask-effect",t.BlendMode="blend-mode",t.TextureSource="texture-source",t.Environment="environment",t.ShapeBuilder="shape-builder",t.Batcher="batcher",t))(s||{});const i=t=>{if("function"==typeof t||"object"==typeof t&&t.extension){if(!t.extension)throw new Error("Extension class must have an extension object");t={..."object"!=typeof t.extension?{type:t.extension}:t.extension,ref:t}}if("object"!=typeof t)throw new Error("Invalid extension type");return"string"==typeof(t={...t}).type&&(t.type=[t.type]),t},n=(t,e)=>i(t).priority??e,o={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...t){return t.map(i).forEach(t=>{t.type.forEach(e=>this._removeHandlers[e]?.(t))}),this},add(...t){return t.map(i).forEach(t=>{t.type.forEach(e=>{const r=this._addHandlers,s=this._queue;r[e]?r[e]?.(t):(s[e]=s[e]||[],s[e]?.push(t))})}),this},handle(t,e,r){const s=this._addHandlers,i=this._removeHandlers;if(s[t]||i[t])throw new Error(`Extension type ${t} already has a handler`);s[t]=e,i[t]=r;const n=this._queue;return n[t]&&(n[t]?.forEach(t=>e(t)),delete n[t]),this},handleByMap(t,e){return this.handle(t,t=>{t.name&&(e[t.name]=t.ref)},t=>{t.name&&delete e[t.name]})},handleByNamedList(t,e,r=-1){return this.handle(t,t=>{e.findIndex(e=>e.name===t.name)>=0||(e.push({name:t.name,value:t.ref}),e.sort((t,e)=>n(e.value,r)-n(t.value,r)))},t=>{const r=e.findIndex(e=>e.name===t.name);-1!==r&&e.splice(r,1)})},handleByList(t,e,r=-1){return this.handle(t,t=>{e.includes(t.ref)||(e.push(t.ref),e.sort((t,e)=>n(e,r)-n(t,r)))},t=>{const r=e.indexOf(t.ref);-1!==r&&e.splice(r,1)})},mixin(t,...e){for(const r of e)Object.defineProperties(t.prototype,Object.getOwnPropertyDescriptors(r))}}},1174:(t,e,r)=>{"use strict";r.d(e,{u:()=>l});var s=r(1579),i=r(9798),n=r(8337),o=r(4696);const a=class t extends n.V{constructor(...e){let r=e[0]??{};r instanceof Float32Array&&((0,o.t6)(o.lj,"use new MeshGeometry({ positions, uvs, indices }) instead"),r={positions:r,uvs:e[1],indices:e[2]}),r={...t.defaultOptions,...r};const n=r.positions||new Float32Array([0,0,1,0,1,1,0,1]);let a=r.uvs;a||(a=r.positions?new Float32Array(n.length):new Float32Array([0,0,1,0,1,1,0,1]));const l=r.indices||new Uint32Array([0,1,2,0,2,3]),h=r.shrinkBuffersToFit;super({attributes:{aPosition:{buffer:new s.h({data:n,label:"attribute-mesh-positions",shrinkToFit:h,usage:i.S.VERTEX|i.S.COPY_DST}),format:"float32x2",stride:8,offset:0},aUV:{buffer:new s.h({data:a,label:"attribute-mesh-uvs",shrinkToFit:h,usage:i.S.VERTEX|i.S.COPY_DST}),format:"float32x2",stride:8,offset:0}},indexBuffer:new s.h({data:l,label:"index-mesh-buffer",shrinkToFit:h,usage:i.S.INDEX|i.S.COPY_DST}),topology:r.topology}),this.batchMode="auto"}get positions(){return this.attributes.aPosition.buffer.data}set positions(t){this.attributes.aPosition.buffer.data=t}get uvs(){return this.attributes.aUV.buffer.data}set uvs(t){this.attributes.aUV.buffer.data=t}get indices(){return this.indexBuffer.data}set indices(t){this.indexBuffer.data=t}};a.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let l=a},1228:(t,e,r)=>{"use strict";r.d(e,{U:()=>s});class s{constructor(){this.batcherName="default",this.packAsQuad=!1,this.indexOffset=0,this.attributeOffset=0,this.roundPixels=0,this._batcher=null,this._batch=null,this._textureMatrixUpdateId=-1,this._uvUpdateId=-1}get blendMode(){return this.renderable.groupBlendMode}get topology(){return this._topology||this.geometry.topology}set topology(t){this._topology=t}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.geometry=null,this._uvUpdateId=-1,this._textureMatrixUpdateId=-1}setTexture(t){this.texture!==t&&(this.texture=t,this._textureMatrixUpdateId=-1)}get uvs(){const t=this.geometry.getBuffer("aUV"),e=t.data;let r=e;const s=this.texture.textureMatrix;return s.isSimple||(r=this._transformedUvs,this._textureMatrixUpdateId===s._updateID&&this._uvUpdateId===t._updateID||((!r||r.length<e.length)&&(r=this._transformedUvs=new Float32Array(e.length)),this._textureMatrixUpdateId=s._updateID,this._uvUpdateId=t._updateID,s.multiplyUvs(e,r))),r}get positions(){return this.geometry.positions}get indices(){return this.geometry.indices}get color(){return this.renderable.groupColorAlpha}get groupTransform(){return this.renderable.groupTransform}get attributeSize(){return this.geometry.positions.length/2}get indexSize(){return this.geometry.indices.length}}},1268:(t,e,r)=>{"use strict";r.d(e,{M:()=>n});var s=r(8851);const i=new(r(6170).c);function n(t,e,r,n){const o=i;o.minX=0,o.minY=0,o.maxX=t.width/n|0,o.maxY=t.height/n|0;const a=s.W.getOptimalTexture(o.width,o.height,n,!1);return a.source.uploadMethodId="image",a.source.resource=t,a.source.alphaMode="premultiply-alpha-on-upload",a.frame.width=e/n,a.frame.height=r/n,a.source.emit("update",a.source),a.updateUvs(),a}},1386:(t,e,r)=>{"use strict";r.d(e,{q:()=>o});var s=r(5423),i=r(1065),n=r(4269);class o extends n.v{constructor(t){t.resource||(t.resource=s.e.get().createCanvas()),t.width||(t.width=t.resource.width,t.autoDensity||(t.width/=t.resolution)),t.height||(t.height=t.resource.height,t.autoDensity||(t.height/=t.resolution)),super(t),this.uploadMethodId="image",this.autoDensity=t.autoDensity,this.resizeCanvas(),this.transparent=!!t.transparent}resizeCanvas(){this.autoDensity&&"style"in this.resource&&(this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`),this.resource.width===this.pixelWidth&&this.resource.height===this.pixelHeight||(this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight)}resize(t=this.width,e=this.height,r=this._resolution){const s=super.resize(t,e,r);return s&&this.resizeCanvas(),s}static test(t){return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&t instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}}o.extension=i.Ag.TextureSource},1422:(t,e,r)=>{"use strict";r.d(e,{m:()=>o});var s=r(5199),i=r(4582),n=r(8851);class o{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new s.u,this.worldColorAlpha=4294967295,this.worldColor=16777215,this.worldAlpha=1,this.childrenToUpdate=Object.create(null),this.updateTick=0,this.gcTick=0,this.childrenRenderablesToUpdate={list:[],index:0},this.structureDidChange=!0,this.instructionSet=new i.L,this._onRenderContainers=[],this.textureNeedsUpdate=!0,this.isCachedAsTexture=!1,this._matrixDirty=7}init(t){this.root=t,t._onRender&&this.addOnRender(t),t.didChange=!0;const e=t.children;for(let t=0;t<e.length;t++){const r=e[t];r._updateFlags=15,this.addChild(r)}}enableCacheAsTexture(t={}){this.textureOptions=t,this.isCachedAsTexture=!0,this.textureNeedsUpdate=!0}disableCacheAsTexture(){this.isCachedAsTexture=!1,this.texture&&(n.W.returnTexture(this.texture,!0),this.texture=null)}updateCacheTexture(){this.textureNeedsUpdate=!0;const t=this._parentCacheAsTextureRenderGroup;t&&!t.textureNeedsUpdate&&t.updateCacheTexture()}reset(){this.renderGroupChildren.length=0;for(const t in this.childrenToUpdate){const e=this.childrenToUpdate[t];e.list.fill(null),e.index=0}this.childrenRenderablesToUpdate.index=0,this.childrenRenderablesToUpdate.list.fill(null),this.root=null,this.updateTick=0,this.structureDidChange=!0,this._onRenderContainers.length=0,this.renderGroupParent=null,this.disableCacheAsTexture()}get localTransform(){return this.root.localTransform}addRenderGroupChild(t){t.renderGroupParent&&t.renderGroupParent._removeRenderGroupChild(t),t.renderGroupParent=this,this.renderGroupChildren.push(t)}_removeRenderGroupChild(t){const e=this.renderGroupChildren.indexOf(t);e>-1&&this.renderGroupChildren.splice(e,1),t.renderGroupParent=null}addChild(t){if(this.structureDidChange=!0,t.parentRenderGroup=this,t.updateTick=-1,t.parent===this.root?t.relativeRenderGroupDepth=1:t.relativeRenderGroupDepth=t.parent.relativeRenderGroupDepth+1,t.didChange=!0,this.onChildUpdate(t),t.renderGroup)return void this.addRenderGroupChild(t.renderGroup);t._onRender&&this.addOnRender(t);const e=t.children;for(let t=0;t<e.length;t++)this.addChild(e[t])}removeChild(t){if(this.structureDidChange=!0,t._onRender&&(t.renderGroup||this.removeOnRender(t)),t.parentRenderGroup=null,t.renderGroup)return void this._removeRenderGroupChild(t.renderGroup);const e=t.children;for(let t=0;t<e.length;t++)this.removeChild(e[t])}removeChildren(t){for(let e=0;e<t.length;e++)this.removeChild(t[e])}onChildUpdate(t){let e=this.childrenToUpdate[t.relativeRenderGroupDepth];e||(e=this.childrenToUpdate[t.relativeRenderGroupDepth]={index:0,list:[]}),e.list[e.index++]=t}updateRenderable(t){t.globalDisplayStatus<7||(this.instructionSet.renderPipes[t.renderPipeId].updateRenderable(t),t.didViewUpdate=!1)}onChildViewUpdate(t){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=t}get isRenderable(){return 7===this.root.localDisplayStatus&&this.worldAlpha>0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(t){for(let e=0;e<this._onRenderContainers.length;e++)this._onRenderContainers[e]._onRender(t)}destroy(){this.disableCacheAsTexture(),this.renderGroupParent=null,this.root=null,this.childrenRenderablesToUpdate=null,this.childrenToUpdate=null,this.renderGroupChildren=null,this._onRenderContainers=null,this.instructionSet=null}getChildren(t=[]){const e=this.root.children;for(let r=0;r<e.length;r++)this._getChildren(e[r],t);return t}_getChildren(t,e=[]){if(e.push(t),t.renderGroup)return e;const r=t.children;for(let t=0;t<r.length;t++)this._getChildren(r[t],e);return e}invalidateMatrices(){this._matrixDirty=7}get inverseWorldTransform(){return 1&this._matrixDirty?(this._matrixDirty&=-2,this._inverseWorldTransform||(this._inverseWorldTransform=new s.u),this._inverseWorldTransform.copyFrom(this.worldTransform).invert()):this._inverseWorldTransform}get textureOffsetInverseTransform(){return 2&this._matrixDirty?(this._matrixDirty&=-3,this._textureOffsetInverseTransform||(this._textureOffsetInverseTransform=new s.u),this._textureOffsetInverseTransform.copyFrom(this.inverseWorldTransform).translate(-this._textureBounds.x,-this._textureBounds.y)):this._textureOffsetInverseTransform}get inverseParentTextureTransform(){if(!(4&this._matrixDirty))return this._inverseParentTextureTransform;this._matrixDirty&=-5;const t=this._parentCacheAsTextureRenderGroup;return t?(this._inverseParentTextureTransform||(this._inverseParentTextureTransform=new s.u),this._inverseParentTextureTransform.copyFrom(this.worldTransform).prepend(t.inverseWorldTransform).translate(-t._textureBounds.x,-t._textureBounds.y)):this.worldTransform}get cacheToLocalTransform(){return this.isCachedAsTexture?this.textureOffsetInverseTransform:this._parentCacheAsTextureRenderGroup?this._parentCacheAsTextureRenderGroup.textureOffsetInverseTransform:null}}},1566:(t,e,r)=>{"use strict";r.d(e,{N:()=>o});var s=r(5423),i=r(9437),n=r(1753);const o=new class{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const r=s.e.get().createCanvas();r.width=t,r.height=e;const i=r.getContext("2d");return{canvas:r,context:i}}getOptimalCanvasAndContext(t,e,r=1){t=Math.ceil(t*r-1e-6),e=Math.ceil(e*r-1e-6);const s=((t=(0,i.U5)(t))<<17)+((e=(0,i.U5)(e))<<1);this._canvasPool[s]||(this._canvasPool[s]=[]);let n=this._canvasPool[s].pop();return n||(n=this._createCanvasAndContext(t,e)),n}returnCanvasAndContext(t){const e=t.canvas,{width:r,height:s}=e,i=(r<<17)+(s<<1);t.context.resetTransform(),t.context.clearRect(0,0,r,s),this._canvasPool[i].push(t)}clear(){this._canvasPool={}}};n.L.register(o)},1570:(t,e,r)=>{"use strict";r.d(e,{P:()=>h,_:()=>o});const s={};function i(t){const e=[];if(1===t)e.push("@group(1) @binding(0) var textureSource1: texture_2d<f32>;"),e.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let r=0;for(let s=0;s<t;s++)e.push(`@group(1) @binding(${r++}) var textureSource${s+1}: texture_2d<f32>;`),e.push(`@group(1) @binding(${r++}) var textureSampler${s+1}: sampler;`)}return e.join("\n")}function n(t){const e=[];if(1===t)e.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{e.push("switch vTextureId {");for(let r=0;r<t;r++)r===t-1?e.push(" default:{"):e.push(` case ${r}:{`),e.push(` outColor = textureSampleGrad(textureSource${r+1}, textureSampler${r+1}, vUV, uvDx, uvDy);`),e.push(" break;}");e.push("}")}return e.join("\n")}function o(t){return s[t]||(s[t]={name:"texture-batch-bit",vertex:{header:"\n @in aTextureIdAndRound: vec2<u32>;\n @out @interpolate(flat) vTextureId : u32;\n ",main:"\n vTextureId = aTextureIdAndRound.y;\n ",end:"\n if(aTextureIdAndRound.x == 1)\n {\n vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);\n }\n "},fragment:{header:`\n @in @interpolate(flat) vTextureId: u32;\n\n ${i(t)}\n `,main:`\n var uvDx = dpdx(vUV);\n var uvDy = dpdy(vUV);\n\n ${n(t)}\n `}}),s[t]}const a={};function l(t){const e=[];for(let r=0;r<t;r++)r>0&&e.push("else"),r<t-1&&e.push(`if(vTextureId < ${r}.5)`),e.push("{"),e.push(`\toutColor = texture(uTextures[${r}], vUV);`),e.push("}");return e.join("\n")}function h(t){return a[t]||(a[t]={name:"texture-batch-bit",vertex:{header:"\n in vec2 aTextureIdAndRound;\n out float vTextureId;\n\n ",main:"\n vTextureId = aTextureIdAndRound.y;\n ",end:"\n if(aTextureIdAndRound.x == 1.)\n {\n gl_Position.xy = roundPixels(gl_Position.xy, uResolution);\n }\n "},fragment:{header:`\n in float vTextureId;\n\n uniform sampler2D uTextures[${t}];\n\n `,main:`\n\n ${l(t)}\n `}}),a[t]}},1579:(t,e,r)=>{"use strict";r.d(e,{h:()=>o});var s=r(4872),i=r(9375),n=r(9798);class o extends s.A{constructor(t){let{data:e,size:r}=t;const{usage:s,label:n,shrinkToFit:o}=t;super(),this.uid=(0,i.L)("buffer"),this._resourceType="buffer",this._resourceId=(0,i.L)("resource"),this._touched=0,this._updateID=1,this._dataInt32=null,this.shrinkToFit=!0,this.destroyed=!1,e instanceof Array&&(e=new Float32Array(e)),this._data=e,r??(r=e?.byteLength);const a=!!e;this.descriptor={size:r,usage:s,mappedAtCreation:a,label:n},this.shrinkToFit=o??!0}get data(){return this._data}set data(t){this.setDataWithSize(t,t.length,!0)}get dataInt32(){return this._dataInt32||(this._dataInt32=new Int32Array(this.data.buffer)),this._dataInt32}get static(){return!!(this.descriptor.usage&n.S.STATIC)}set static(t){t?this.descriptor.usage|=n.S.STATIC:this.descriptor.usage&=~n.S.STATIC}setDataWithSize(t,e,r){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t)return void(r&&this.emit("update",this));const s=this._data;this._data=t,this._dataInt32=null,s&&s.length===t.length||!this.shrinkToFit&&s&&t.byteLength<s.byteLength?r&&this.emit("update",this):(this.descriptor.size=t.byteLength,this._resourceId=(0,i.L)("resource"),this.emit("change",this))}update(t){this._updateSize=t??this._updateSize,this._updateID++,this.emit("update",this)}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this._data=null,this.descriptor=null,this.removeAllListeners()}}},1657:(t,e,r)=>{"use strict";r.d(e,{M:()=>c});var s=r(4872),i=r(9375),n=r(5007),o=r(3655),a=r(1790),l=r(5153),h=r(4449);class c extends s.A{constructor(t){super(),this.uid=(0,i.L)("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[];let{gpuProgram:e,glProgram:r,groups:s,resources:n,compatibleRenderers:a,groupMap:c}=t;this.gpuProgram=e,this.glProgram=r,void 0===a&&(a=0,e&&(a|=l.W.WEBGPU),r&&(a|=l.W.WEBGL)),this.compatibleRenderers=a;const u={};if(n||s||(n={}),n&&s)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&s&&!c)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&s&&c)for(const t in c)for(const e in c[t]){const r=c[t][e];u[r]={group:t,binding:e,name:r}}else if(e&&s&&!c){const t=e.structsAndGroups.groups;c={},t.forEach(t=>{c[t.group]=c[t.group]||{},c[t.group][t.binding]=t.name,u[t.name]=t})}else if(n){s={},c={},e&&e.structsAndGroups.groups.forEach(t=>{c[t.group]=c[t.group]||{},c[t.group][t.binding]=t.name,u[t.name]=t});let t=0;for(const e in n)u[e]||(s[99]||(s[99]=new o.T,this._ownedBindGroups.push(s[99])),u[e]={group:99,binding:t,name:e},c[99]=c[99]||{},c[99][t]=e,t++);for(const t in n){const e=t;let r=n[t];r.source||r._resourceType||(r=new h.k(r));const i=u[e];i&&(s[i.group]||(s[i.group]=new o.T,this._ownedBindGroups.push(s[i.group])),s[i.group].setResource(r,i.binding))}}this.groups=s,this._uniformBindMap=c,this.resources=this._buildResourceAccessor(s,u)}addResource(t,e,r){var s,i;(s=this._uniformBindMap)[e]||(s[e]={}),(i=this._uniformBindMap[e])[r]||(i[r]=t),this.groups[e]||(this.groups[e]=new o.T,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const r={};for(const s in e){const i=e[s];Object.defineProperty(r,i.name,{get:()=>t[i.group].getResource(i.binding),set(e){t[i.group].setResource(e,i.binding)}})}return r}destroy(t=!1){this.emit("destroy",this),t&&(this.gpuProgram?.destroy(),this.glProgram?.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(t=>{t.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null}static from(t){const{gpu:e,gl:r,...s}=t;let i,o;return e&&(i=a.B.from(e)),r&&(o=n.M.from(r)),new c({gpuProgram:i,glProgram:o,...s})}}},1673:(t,e,r)=>{"use strict";r.d(e,{f:()=>Ut,i:()=>Dt});var s=r(1065);class i{constructor(t){this._renderer=t}updateRenderable(){}destroyRenderable(){}validateRenderable(){return!1}addRenderable(t,e){this._renderer.renderPipes.batch.break(e),e.add(t)}execute(t){t.isRenderable&&t.render(this._renderer)}destroy(){this._renderer=null}}i.extension={type:[s.Ag.WebGLPipes,s.Ag.WebGPUPipes,s.Ag.CanvasPipes],name:"customRender"};var n=r(5199),o=r(761),a=r(3412);function l(t,e){const r=t.instructionSet,s=r.instructions;for(let t=0;t<r.instructionSize;t++){const r=s[t];e[r.renderPipeId].execute(r)}}const h=new n.u;class c{constructor(t){this._renderer=t}addRenderGroup(t,e){t.isCachedAsTexture?this._addRenderableCacheAsTexture(t,e):this._addRenderableDirect(t,e)}execute(t){t.isRenderable&&(t.isCachedAsTexture?this._executeCacheAsTexture(t):this._executeDirect(t))}destroy(){this._renderer=null}_addRenderableDirect(t,e){this._renderer.renderPipes.batch.break(e),t._batchableRenderGroup&&(o.Z.return(t._batchableRenderGroup),t._batchableRenderGroup=null),e.add(t)}_addRenderableCacheAsTexture(t,e){const r=t._batchableRenderGroup??(t._batchableRenderGroup=o.Z.get(a.K));r.renderable=t.root,r.transform=t.root.relativeGroupTransform,r.texture=t.texture,r.bounds=t._textureBounds,e.add(t),this._renderer.renderPipes.blendMode.pushBlendMode(t,t.root.groupBlendMode,e),this._renderer.renderPipes.batch.addToBatch(r,e),this._renderer.renderPipes.blendMode.popBlendMode(e)}_executeCacheAsTexture(t){if(t.textureNeedsUpdate){t.textureNeedsUpdate=!1;const e=h.identity().translate(-t._textureBounds.x,-t._textureBounds.y);this._renderer.renderTarget.push(t.texture,!0,null,t.texture.frame),this._renderer.globalUniforms.push({worldTransformMatrix:e,worldColor:4294967295,offset:{x:0,y:0}}),l(t,this._renderer.renderPipes),this._renderer.renderTarget.finishRenderPass(),this._renderer.renderTarget.pop(),this._renderer.globalUniforms.pop()}t._batchableRenderGroup._batcher.updateElement(t._batchableRenderGroup),t._batchableRenderGroup._batcher.geometry.buffers[0].update()}_executeDirect(t){this._renderer.globalUniforms.push({worldTransformMatrix:t.inverseParentTextureTransform,worldColor:t.worldColorAlpha}),l(t,this._renderer.renderPipes),this._renderer.globalUniforms.pop()}}c.extension={type:[s.Ag.WebGLPipes,s.Ag.WebGPUPipes,s.Ag.CanvasPipes],name:"renderGroup"};var u=r(8851),d=r(8896),p=r(6170);function f(t,e){e||(e=0);for(let r=e;r<t.length&&t[r];r++)t[r]=null}var g=r(4687),m=r(6851);const x=new g.mc,_=g.fR|g.ig|g.u;function y(t,e=!1){!function(t){const e=t.root;let r;if(t.renderGroupParent){const s=t.renderGroupParent;t.worldTransform.appendFrom(e.relativeGroupTransform,s.worldTransform),t.worldColor=(0,m.j)(e.groupColor,s.worldColor),r=e.groupAlpha*s.worldAlpha}else t.worldTransform.copyFrom(e.localTransform),t.worldColor=e.localColor,r=e.localAlpha;r=r<0?0:r>1?1:r,t.worldAlpha=r,t.worldColorAlpha=t.worldColor+(255*r<<24)}(t);const r=t.childrenToUpdate,s=t.updateTick++;for(const e in r){const i=Number(e),n=r[e],o=n.list,a=n.index;for(let e=0;e<a;e++){const r=o[e];r.parentRenderGroup===t&&r.relativeRenderGroupDepth===i&&v(r,s,0)}f(o,a),n.index=0}if(e)for(let r=0;r<t.renderGroupChildren.length;r++)y(t.renderGroupChildren[r],e)}function v(t,e,r){if(e===t.updateTick)return;t.updateTick=e,t.didChange=!1;const s=t.localTransform;t.updateLocalTransform();const i=t.parent;if(i&&!i.renderGroup?(r|=t._updateFlags,t.relativeGroupTransform.appendFrom(s,i.relativeGroupTransform),r&_&&b(t,i,r)):(r=t._updateFlags,t.relativeGroupTransform.copyFrom(s),r&_&&b(t,x,r)),!t.renderGroup){const s=t.children,i=s.length;for(let t=0;t<i;t++)v(s[t],e,r);const n=t.parentRenderGroup,o=t;o.renderPipeId&&!n.structureDidChange&&n.updateRenderable(o)}}function b(t,e,r){if(r&g.ig){t.groupColor=(0,m.j)(t.localColor,e.groupColor);let r=t.localAlpha*e.groupAlpha;r=r<0?0:r>1?1:r,t.groupAlpha=r,t.groupColorAlpha=t.groupColor+(255*r<<24)}r&g.u&&(t.groupBlendMode="inherit"===t.localBlendMode?e.groupBlendMode:t.localBlendMode),r&g.fR&&(t.globalDisplayStatus=t.localDisplayStatus&e.globalDisplayStatus),t._updateFlags=0}const w=new n.u;class T{constructor(t){this._renderer=t}render({container:t,transform:e}){const r=t.parent,s=t.renderGroup.renderGroupParent;t.parent=null,t.renderGroup.renderGroupParent=null;const i=this._renderer,n=w;e&&(n.copyFrom(t.renderGroup.localTransform),t.renderGroup.localTransform.copyFrom(e));const o=i.renderPipes;this._updateCachedRenderGroups(t.renderGroup,null),this._updateRenderGroups(t.renderGroup),i.globalUniforms.start({worldTransformMatrix:e?t.renderGroup.localTransform:t.renderGroup.worldTransform,worldColor:t.renderGroup.worldColorAlpha}),l(t.renderGroup,o),o.uniformBatch&&o.uniformBatch.renderEnd(),e&&t.renderGroup.localTransform.copyFrom(n),t.parent=r,t.renderGroup.renderGroupParent=s}destroy(){this._renderer=null}_updateCachedRenderGroups(t,e){if(t._parentCacheAsTextureRenderGroup=e,t.isCachedAsTexture){if(!t.textureNeedsUpdate)return;e=t}for(let r=t.renderGroupChildren.length-1;r>=0;r--)this._updateCachedRenderGroups(t.renderGroupChildren[r],e);if(t.invalidateMatrices(),t.isCachedAsTexture){if(t.textureNeedsUpdate){const e=t.root.getLocalBounds();e.ceil();const r=t.texture;t.texture&&u.W.returnTexture(t.texture,!0);const s=this._renderer,i=t.textureOptions.resolution||s.view.resolution,n=t.textureOptions.antialias??s.view.antialias,o=t.textureOptions.scaleMode??"linear",a=u.W.getOptimalTexture(e.width,e.height,i,n);a._source.style=new d.n({scaleMode:o}),t.texture=a,t._textureBounds||(t._textureBounds=new p.c),t._textureBounds.copyFrom(e),r!==t.texture&&t.renderGroupParent&&(t.renderGroupParent.structureDidChange=!0)}}else t.texture&&(u.W.returnTexture(t.texture,!0),t.texture=null)}_updateRenderGroups(t){const e=this._renderer,r=e.renderPipes;if(t.runOnRender(e),t.instructionSet.renderPipes=r,t.structureDidChange?f(t.childrenRenderablesToUpdate.list,0):function(t,e){const{list:r,index:s}=t.childrenRenderablesToUpdate;let i=!1;for(let t=0;t<s;t++){const s=r[t];if(i=e[s.renderPipeId].validateRenderable(s),i)break}t.structureDidChange=i}(t,r),y(t),t.structureDidChange?(t.structureDidChange=!1,this._buildInstructions(t,e)):this._updateRenderables(t),t.childrenRenderablesToUpdate.index=0,e.renderPipes.batch.upload(t.instructionSet),!t.isCachedAsTexture||t.textureNeedsUpdate)for(let e=0;e<t.renderGroupChildren.length;e++)this._updateRenderGroups(t.renderGroupChildren[e])}_updateRenderables(t){const{list:e,index:r}=t.childrenRenderablesToUpdate;for(let s=0;s<r;s++){const r=e[s];r.didViewUpdate&&t.updateRenderable(r)}f(e,r)}_buildInstructions(t,e){const r=t.root,s=t.instructionSet;s.reset();const i=e.renderPipes?e:e.batch.renderer,n=i.renderPipes;n.batch.buildStart(s),n.blendMode.buildStart(),n.colorMask.buildStart(),r.sortableChildren&&r.sortChildren(),r.collectRenderablesWithEffects(s,i,null),n.batch.buildEnd(s),n.blendMode.buildEnd(s)}}T.extension={type:[s.Ag.WebGLSystem,s.Ag.WebGPUSystem,s.Ag.CanvasSystem],name:"renderGroup"};class S{constructor(t){this._renderer=t}addRenderable(t,e){const r=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,r),this._renderer.renderPipes.batch.addToBatch(r,e)}updateRenderable(t){const e=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,e),e._batcher.updateElement(e)}validateRenderable(t){const e=this._getGpuSprite(t);return!e._batcher.checkAndUpdateTexture(e,t._texture)}_updateBatchableSprite(t,e){e.bounds=t.visualBounds,e.texture=t._texture}_getGpuSprite(t){return t._gpuData[this._renderer.uid]||this._initGPUSprite(t)}_initGPUSprite(t){const e=new a.K;return e.renderable=t,e.transform=t.groupTransform,e.texture=t._texture,e.bounds=t.visualBounds,e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._gpuData[this._renderer.uid]=e,e}destroy(){this._renderer=null}}S.extension={type:[s.Ag.WebGLPipes,s.Ag.WebGPUPipes,s.Ag.CanvasPipes],name:"sprite"},r(4872);const A="8.13.1";s.Ag.Application;class C{constructor(t){this._renderer=t}init(){globalThis.__PIXI_RENDERER_INIT__?.(this._renderer,A)}destroy(){this._renderer=null}}C.extension={type:[s.Ag.WebGLSystem,s.Ag.WebGPUSystem],name:"initHook",priority:-10};var P=r(7433),M=r(4404);const E=class t{constructor(t,e){this.state=P.U.for2d(),this._batchersByInstructionSet=Object.create(null),this._activeBatches=Object.create(null),this.renderer=t,this._adaptor=e,this._adaptor.init?.(this)}static getBatcher(t){return new this._availableBatchers[t]}buildStart(t){let e=this._batchersByInstructionSet[t.uid];e||(e=this._batchersByInstructionSet[t.uid]=Object.create(null),e.default||(e.default=new M.J({maxTextures:this.renderer.limits.maxBatchableTextures}))),this._activeBatches=e,this._activeBatch=this._activeBatches.default;for(const t in this._activeBatches)this._activeBatches[t].begin()}addToBatch(e,r){if(this._activeBatch.name!==e.batcherName){this._activeBatch.break(r);let s=this._activeBatches[e.batcherName];s||(s=this._activeBatches[e.batcherName]=t.getBatcher(e.batcherName),s.begin()),this._activeBatch=s}this._activeBatch.add(e)}break(t){this._activeBatch.break(t)}buildEnd(t){this._activeBatch.break(t);const e=this._activeBatches;for(const t in e){const r=e[t],s=r.geometry;s.indexBuffer.setDataWithSize(r.indexBuffer,r.indexSize,!0),s.buffers[0].setDataWithSize(r.attributeBuffer.float32View,r.attributeSize,!1)}}upload(t){const e=this._batchersByInstructionSet[t.uid];for(const t in e){const r=e[t],s=r.geometry;r.dirty&&(r.dirty=!1,s.buffers[0].update(4*r.attributeSize))}}execute(t){if("startBatch"===t.action){const e=t.batcher,r=e.geometry,s=e.shader;this._adaptor.start(this,r,s)}this._adaptor.execute(this,t)}destroy(){this.state=null,this.renderer=null,this._adaptor=null;for(const t in this._activeBatches)this._activeBatches[t].destroy();this._activeBatches=null}};E.extension={type:[s.Ag.WebGLPipes,s.Ag.WebGPUPipes,s.Ag.CanvasPipes],name:"batch"},E._availableBatchers=Object.create(null);let R=E;s.XO.handleByMap(s.Ag.Batcher,R._availableBatchers),s.XO.add(M.J);var k=r(4403),B=r(5007),I=r(1790),G=r(4449),F=r(1734),O=r(1657);const D=class t extends O.M{constructor(e){super(e={...t.defaultOptions,...e}),this.enabled=!0,this._state=P.U.for2d(),this.blendMode=e.blendMode,this.padding=e.padding,"boolean"==typeof e.antialias?this.antialias=e.antialias?"on":"off":this.antialias=e.antialias,this.resolution=e.resolution,this.blendRequired=e.blendRequired,this.clipToViewport=e.clipToViewport,this.addResource("uTexture",0,1)}apply(t,e,r,s){t.applyFilter(this,e,r,s)}get blendMode(){return this._state.blendMode}set blendMode(t){this._state.blendMode=t}static from(e){const{gpu:r,gl:s,...i}=e;let n,o;return r&&(n=I.B.from(r)),s&&(o=B.M.from(s)),new t({gpuProgram:n,glProgram:o,...i})}};D.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let U=D;var L="struct GlobalFilterUniforms {\n uInputSize:vec4<f32>,\n uInputPixel:vec4<f32>,\n uInputClamp:vec4<f32>,\n uOutputFrame:vec4<f32>,\n uGlobalFrame:vec4<f32>,\n uOutputTexture:vec4<f32>,\n};\n\nstruct MaskUniforms {\n uFilterMatrix:mat3x3<f32>,\n uMaskClamp:vec4<f32>,\n uAlpha:f32,\n uInverse:f32,\n};\n\n@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;\n@group(0) @binding(1) var uTexture: texture_2d<f32>;\n@group(0) @binding(2) var uSampler : sampler;\n\n@group(1) @binding(0) var<uniform> filterUniforms : MaskUniforms;\n@group(1) @binding(1) var uMaskTexture: texture_2d<f32>;\n\nstruct VSOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>,\n @location(1) filterUv : vec2<f32>,\n};\n\nfn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>\n{\n var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;\n\n position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;\n position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;\n\n return vec4(position, 0.0, 1.0);\n}\n\nfn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>\n{\n return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);\n}\n\nfn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>\n{\n return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);\n}\n\nfn getFilterCoord(aPosition:vec2<f32> ) -> vec2<f32>\n{\n return ( filterUniforms.uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;\n}\n\nfn getSize() -> vec2<f32>\n{\n return gfu.uGlobalFrame.zw;\n}\n\n@vertex\nfn mainVertex(\n @location(0) aPosition : vec2<f32>,\n) -> VSOutput {\n return VSOutput(\n filterVertexPosition(aPosition),\n filterTextureCoord(aPosition),\n getFilterCoord(aPosition)\n );\n}\n\n@fragment\nfn mainFragment(\n @location(0) uv: vec2<f32>,\n @location(1) filterUv: vec2<f32>,\n @builtin(position) position: vec4<f32>\n) -> @location(0) vec4<f32> {\n\n var maskClamp = filterUniforms.uMaskClamp;\n var uAlpha = filterUniforms.uAlpha;\n\n var clip = step(3.5,\n step(maskClamp.x, filterUv.x) +\n step(maskClamp.y, filterUv.y) +\n step(filterUv.x, maskClamp.z) +\n step(filterUv.y, maskClamp.w));\n\n var mask = textureSample(uMaskTexture, uSampler, filterUv);\n var source = textureSample(uTexture, uSampler, uv);\n var alphaMul = 1.0 - uAlpha * (1.0 - mask.a);\n\n var a: f32 = alphaMul * mask.r * uAlpha * clip;\n\n if (filterUniforms.uInverse == 1.0) {\n a = 1.0 - a;\n }\n\n return source * a;\n}\n";class N extends U{constructor(t){const{sprite:e,...r}=t,s=new F.N(e.texture),i=new G.k({uFilterMatrix:{value:new n.u,type:"mat3x3<f32>"},uMaskClamp:{value:s.uClampFrame,type:"vec4<f32>"},uAlpha:{value:1,type:"f32"},uInverse:{value:t.inverse?1:0,type:"f32"}});super({...r,gpuProgram:I.B.from({vertex:{source:L,entryPoint:"mainVertex"},fragment:{source:L,entryPoint:"mainFragment"}}),glProgram:B.M.from({vertex:"in vec2 aPosition;\n\nout vec2 vTextureCoord;\nout vec2 vMaskCoord;\n\n\nuniform vec4 uInputSize;\nuniform vec4 uOutputFrame;\nuniform vec4 uOutputTexture;\nuniform mat3 uFilterMatrix;\n\nvec4 filterVertexPosition( vec2 aPosition )\n{\n vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;\n \n position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;\n position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;\n\n return vec4(position, 0.0, 1.0);\n}\n\nvec2 filterTextureCoord( vec2 aPosition )\n{\n return aPosition * (uOutputFrame.zw * uInputSize.zw);\n}\n\nvec2 getFilterCoord( vec2 aPosition )\n{\n return ( uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;\n} \n\nvoid main(void)\n{\n gl_Position = filterVertexPosition(aPosition);\n vTextureCoord = filterTextureCoord(aPosition);\n vMaskCoord = getFilterCoord(aPosition);\n}\n",fragment:"in vec2 vMaskCoord;\nin vec2 vTextureCoord;\n\nuniform sampler2D uTexture;\nuniform sampler2D uMaskTexture;\n\nuniform float uAlpha;\nuniform vec4 uMaskClamp;\nuniform float uInverse;\n\nout vec4 finalColor;\n\nvoid main(void)\n{\n float clip = step(3.5,\n step(uMaskClamp.x, vMaskCoord.x) +\n step(uMaskClamp.y, vMaskCoord.y) +\n step(vMaskCoord.x, uMaskClamp.z) +\n step(vMaskCoord.y, uMaskClamp.w));\n\n // TODO look into why this is needed\n float npmAlpha = uAlpha;\n vec4 original = texture(uTexture, vTextureCoord);\n vec4 masky = texture(uMaskTexture, vMaskCoord);\n float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a);\n\n float a = alphaMul * masky.r * npmAlpha * clip;\n\n if (uInverse == 1.0) {\n a = 1.0 - a;\n }\n\n finalColor = original * a;\n}\n",name:"mask-filter"}),clipToViewport:!1,resources:{filterUniforms:i,uMaskTexture:e.texture.source}}),this.sprite=e,this._textureMatrix=s}set inverse(t){this.resources.filterUniforms.uniforms.uInverse=t?1:0}get inverse(){return 1===this.resources.filterUniforms.uniforms.uInverse}apply(t,e,r,s){this._textureMatrix.texture=this.sprite.texture,t.calculateSpriteMatrix(this.resources.filterUniforms.uniforms.uFilterMatrix,this.sprite).prepend(this._textureMatrix.mapCoord),this.resources.uMaskTexture=this.sprite.texture.source,t.applyFilter(this,e,r,s)}}var z=r(9565),W=r(4242),H=r(9739),X=r(5153);const V=new p.c;class Y extends k.a{constructor(){super(),this.filters=[new N({sprite:new W.k(H.g.EMPTY),inverse:!1,resolution:"inherit",antialias:"inherit"})]}get sprite(){return this.filters[0].sprite}set sprite(t){this.filters[0].sprite=t}get inverse(){return this.filters[0].inverse}set inverse(t){this.filters[0].inverse=t}}class j{constructor(t){this._activeMaskStage=[],this._renderer=t}push(t,e,r){const s=this._renderer;if(s.renderPipes.batch.break(r),r.add({renderPipeId:"alphaMask",action:"pushMaskBegin",mask:t,inverse:e._maskOptions.inverse,canBundle:!1,maskedContainer:e}),t.inverse=e._maskOptions.inverse,t.renderMaskToTexture){const e=t.mask;e.includeInBuild=!0,e.collectRenderables(r,s,null),e.includeInBuild=!1}s.renderPipes.batch.break(r),r.add({renderPipeId:"alphaMask",action:"pushMaskEnd",mask:t,maskedContainer:e,inverse:e._maskOptions.inverse,canBundle:!1})}pop(t,e,r){this._renderer.renderPipes.batch.break(r),r.add({renderPipeId:"alphaMask",action:"popMaskEnd",mask:t,inverse:e._maskOptions.inverse,canBundle:!1})}execute(t){const e=this._renderer,r=t.mask.renderMaskToTexture;if("pushMaskBegin"===t.action){const s=o.Z.get(Y);if(s.inverse=t.inverse,r){t.mask.mask.measurable=!0;const r=(0,z.f)(t.mask.mask,!0,V);t.mask.mask.measurable=!1,r.ceil();const i=e.renderTarget.renderTarget.colorTexture.source,n=u.W.getOptimalTexture(r.width,r.height,i._resolution,i.antialias);e.renderTarget.push(n,!0),e.globalUniforms.push({offset:r,worldColor:4294967295});const o=s.sprite;o.texture=n,o.worldTransform.tx=r.minX,o.worldTransform.ty=r.minY,this._activeMaskStage.push({filterEffect:s,maskedContainer:t.maskedContainer,filterTexture:n})}else s.sprite=t.mask.mask,this._activeMaskStage.push({filterEffect:s,maskedContainer:t.maskedContainer})}else if("pushMaskEnd"===t.action){const t=this._activeMaskStage[this._activeMaskStage.length-1];r&&(e.type===X.W.WEBGL&&e.renderTarget.finishRenderPass(),e.renderTarget.pop(),e.globalUniforms.pop()),e.filter.push({renderPipeId:"filter",action:"pushFilter",container:t.maskedContainer,filterEffect:t.filterEffect,canBundle:!1})}else if("popMaskEnd"===t.action){e.filter.pop();const t=this._activeMaskStage.pop();r&&u.W.returnTexture(t.filterTexture),o.Z.return(t.filterEffect)}}destroy(){this._renderer=null,this._activeMaskStage=null}}j.extension={type:[s.Ag.WebGLPipes,s.Ag.WebGPUPipes,s.Ag.CanvasPipes],name:"alphaMask"};class ${constructor(t){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=t}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(t,e,r){this._renderer.renderPipes.batch.break(r);const s=this._colorStack;s[this._colorStackIndex]=s[this._colorStackIndex-1]&t.mask;const i=this._colorStack[this._colorStackIndex];i!==this._currentColor&&(this._currentColor=i,r.add({renderPipeId:"colorMask",colorMask:i,canBundle:!1})),this._colorStackIndex++}pop(t,e,r){this._renderer.renderPipes.batch.break(r);const s=this._colorStack;this._colorStackIndex--;const i=s[this._colorStackIndex-1];i!==this._currentColor&&(this._currentColor=i,r.add({renderPipeId:"colorMask",colorMask:i,canBundle:!1}))}execute(t){this._renderer.colorMask.setMask(t.colorMask)}destroy(){this._renderer=null,this._colorStack=null}}$.extension={type:[s.Ag.WebGLPipes,s.Ag.WebGPUPipes,s.Ag.CanvasPipes],name:"colorMask"};var q=r(1711),K=r(8271);class Z{constructor(t){this._maskStackHash={},this._maskHash=new WeakMap,this._renderer=t}push(t,e,r){var s;const i=t,n=this._renderer;n.renderPipes.batch.break(r),n.renderPipes.blendMode.setBlendMode(i.mask,"none",r),r.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:t,inverse:e._maskOptions.inverse,canBundle:!1});const o=i.mask;o.includeInBuild=!0,this._maskHash.has(i)||this._maskHash.set(i,{instructionsStart:0,instructionsLength:0});const a=this._maskHash.get(i);a.instructionsStart=r.instructionSize,o.collectRenderables(r,n,null),o.includeInBuild=!1,n.renderPipes.batch.break(r),r.add({renderPipeId:"stencilMask",action:"pushMaskEnd",mask:t,inverse:e._maskOptions.inverse,canBundle:!1});const l=r.instructionSize-a.instructionsStart-1;a.instructionsLength=l;const h=n.renderTarget.renderTarget.uid;(s=this._maskStackHash)[h]??(s[h]=0)}pop(t,e,r){const s=t,i=this._renderer;i.renderPipes.batch.break(r),i.renderPipes.blendMode.setBlendMode(s.mask,"none",r),r.add({renderPipeId:"stencilMask",action:"popMaskBegin",inverse:e._maskOptions.inverse,canBundle:!1});const n=this._maskHash.get(t);for(let t=0;t<n.instructionsLength;t++)r.instructions[r.instructionSize++]=r.instructions[n.instructionsStart++];r.add({renderPipeId:"stencilMask",action:"popMaskEnd",canBundle:!1})}execute(t){var e;const r=this._renderer,s=r.renderTarget.renderTarget.uid;let i=(e=this._maskStackHash)[s]??(e[s]=0);"pushMaskBegin"===t.action?(r.renderTarget.ensureDepthStencil(),r.stencil.setStencilMode(K.K.RENDERING_MASK_ADD,i),i++,r.colorMask.setMask(0)):"pushMaskEnd"===t.action?(t.inverse?r.stencil.setStencilMode(K.K.INVERSE_MASK_ACTIVE,i):r.stencil.setStencilMode(K.K.MASK_ACTIVE,i),r.colorMask.setMask(15)):"popMaskBegin"===t.action?(r.colorMask.setMask(0),0!==i?r.stencil.setStencilMode(K.K.RENDERING_MASK_REMOVE,i):(r.renderTarget.clear(null,q.u.STENCIL),r.stencil.setStencilMode(K.K.DISABLED,i)),i--):"popMaskEnd"===t.action&&(t.inverse?r.stencil.setStencilMode(K.K.INVERSE_MASK_ACTIVE,i):r.stencil.setStencilMode(K.K.MASK_ACTIVE,i),r.colorMask.setMask(15)),this._maskStackHash[s]=i}destroy(){this._renderer=null,this._maskStackHash=null,this._maskHash=null}}Z.extension={type:[s.Ag.WebGLPipes,s.Ag.WebGPUPipes,s.Ag.CanvasPipes],name:"stencilMask"};var Q=r(6675),J=r(7694);const tt=class t{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new Q.Q(0),this.color=this._backgroundColor,this.alpha=1}init(e){e={...t.defaultOptions,...e},this.clearBeforeRender=e.clearBeforeRender,this.color=e.background||e.backgroundColor||this._backgroundColor,this.alpha=e.backgroundAlpha,this._backgroundColor.setAlpha(e.backgroundAlpha)}get color(){return this._backgroundColor}set color(t){Q.Q.shared.setValue(t).alpha<1&&1===this._backgroundColor.alpha&&(0,J.R)("Cannot set a transparent background on an opaque canvas. To enable transparency, set backgroundAlpha < 1 when initializing your Application."),this._backgroundColor.setValue(t)}get alpha(){return this._backgroundColor.alpha}set alpha(t){this._backgroundColor.setAlpha(t)}get colorRgba(){return this._backgroundColor.toArray()}destroy(){}};tt.extension={type:[s.Ag.WebGLSystem,s.Ag.WebGPUSystem,s.Ag.CanvasSystem],name:"background",priority:0},tt.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};let et=tt;var rt=r(1422);const st={};s.XO.handle(s.Ag.BlendMode,t=>{if(!t.name)throw new Error("BlendMode extension must have a name property");st[t.name]=t.ref},t=>{delete st[t.name]});class it{constructor(t){this._blendModeStack=[],this._isAdvanced=!1,this._filterHash=Object.create(null),this._renderer=t,this._renderer.runners.prerender.add(this)}prerender(){this._activeBlendMode="normal",this._isAdvanced=!1}pushBlendMode(t,e,r){this._blendModeStack.push(e),this.setBlendMode(t,e,r)}popBlendMode(t){this._blendModeStack.pop();const e=this._blendModeStack[this._activeBlendMode.length-1]??"normal";this.setBlendMode(null,e,t)}setBlendMode(t,e,r){const s=t instanceof rt.m;this._activeBlendMode!==e?(this._isAdvanced&&this._endAdvancedBlendMode(r),this._activeBlendMode=e,t&&(this._isAdvanced=!!st[e],this._isAdvanced&&this._beginAdvancedBlendMode(t,r))):this._isAdvanced&&t&&!s&&this._renderableList?.push(t)}_beginAdvancedBlendMode(t,e){this._renderer.renderPipes.batch.break(e);const r=this._activeBlendMode;if(!st[r])return void(0,J.R)(`Unable to assign BlendMode: '${r}'. You may want to include: import 'pixi.js/advanced-blend-modes'`);const s=this._ensureFilterEffect(r),i=t instanceof rt.m,n={renderPipeId:"filter",action:"pushFilter",filterEffect:s,renderables:i?null:[t],container:i?t.root:null,canBundle:!1};this._renderableList=n.renderables,e.add(n)}_ensureFilterEffect(t){let e=this._filterHash[t];return e||(e=this._filterHash[t]=new k.a,e.filters=[new st[t]]),e}_endAdvancedBlendMode(t){this._isAdvanced=!1,this._renderableList=null,this._renderer.renderPipes.batch.break(t),t.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}buildStart(){this._isAdvanced=!1}buildEnd(t){this._isAdvanced&&this._endAdvancedBlendMode(t)}destroy(){this._renderer=null,this._renderableList=null;for(const t in this._filterHash)this._filterHash[t].destroy();this._filterHash=null}}it.extension={type:[s.Ag.WebGLPipes,s.Ag.WebGPUPipes,s.Ag.CanvasPipes],name:"blendMode"};var nt=r(5423);const ot={png:"image/png",jpg:"image/jpeg",webp:"image/webp"},at=class t{constructor(t){this._renderer=t}_normalizeOptions(t,e={}){return t instanceof g.mc||t instanceof H.g?{target:t,...e}:{...e,...t}}async image(t){const e=nt.e.get().createImage();return e.src=await this.base64(t),e}async base64(e){e=this._normalizeOptions(e,t.defaultImageOptions);const{format:r,quality:s}=e,i=this.canvas(e);if(void 0!==i.toBlob)return new Promise((t,e)=>{i.toBlob(r=>{if(!r)return void e(new Error("ICanvas.toBlob failed!"));const s=new FileReader;s.onload=()=>t(s.result),s.onerror=e,s.readAsDataURL(r)},ot[r],s)});if(void 0!==i.toDataURL)return i.toDataURL(ot[r],s);if(void 0!==i.convertToBlob){const t=await i.convertToBlob({type:ot[r],quality:s});return new Promise((e,r)=>{const s=new FileReader;s.onload=()=>e(s.result),s.onerror=r,s.readAsDataURL(t)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(t){const e=(t=this._normalizeOptions(t)).target,r=this._renderer;if(e instanceof H.g)return r.texture.generateCanvas(e);const s=r.textureGenerator.generateTexture(t),i=r.texture.generateCanvas(s);return s.destroy(!0),i}pixels(t){const e=(t=this._normalizeOptions(t)).target,r=this._renderer,s=e instanceof H.g?e:r.textureGenerator.generateTexture(t),i=r.texture.getPixels(s);return e instanceof g.mc&&s.destroy(!0),i}texture(t){return(t=this._normalizeOptions(t)).target instanceof H.g?t.target:this._renderer.textureGenerator.generateTexture(t)}download(t){t=this._normalizeOptions(t);const e=this.canvas(t),r=document.createElement("a");r.download=t.filename??"image.png",r.href=e.toDataURL("image/png"),document.body.appendChild(r),r.click(),document.body.removeChild(r)}log(t){const e=t.width??200;t=this._normalizeOptions(t);const r=this.canvas(t),s=r.toDataURL();console.log(`[Pixi Texture] ${r.width}px ${r.height}px`);const i=["font-size: 1px;",`padding: ${e}px 300px;`,`background: url(${s}) no-repeat;`,"background-size: contain;"].join(" ");console.log("%c ",i)}destroy(){this._renderer=null}};at.extension={type:[s.Ag.WebGLSystem,s.Ag.WebGPUSystem],name:"extract"},at.defaultImageOptions={format:"png",quality:1};let lt=at;var ht=r(9390),ct=r(2071),ut=r(4269);class dt extends H.g{static create(t){return new dt({source:new ut.v(t)})}resize(t,e,r){return this.source.resize(t,e,r),this}}const pt=new ht.M,ft=new p.c,gt=[0,0,0,0];class mt{constructor(t){this._renderer=t}generateTexture(t){t instanceof g.mc&&(t={target:t,frame:void 0,textureSourceOptions:{},resolution:void 0});const e=t.resolution||this._renderer.resolution,r=t.antialias||this._renderer.view.antialias,s=t.target;let i=t.clearColor;i=i?Array.isArray(i)&&4===i.length?i:Q.Q.shared.setValue(i).toArray():gt;const o=t.frame?.copyTo(pt)||(0,ct.n)(s,ft).rectangle;o.width=0|Math.max(o.width,1/e),o.height=0|Math.max(o.height,1/e);const a=dt.create({...t.textureSourceOptions,width:o.width,height:o.height,resolution:e,antialias:r}),l=n.u.shared.translate(-o.x,-o.y);return this._renderer.render({container:s,transform:l,target:a,clearColor:i}),a.source.updateMipmaps(),a}destroy(){this._renderer=null}}mt.extension={type:[s.Ag.WebGLSystem,s.Ag.WebGPUSystem],name:"textureGenerator"};var xt=r(59),_t=r(9482),yt=r(3655);class vt{constructor(t){this._stackIndex=0,this._globalUniformDataStack=[],this._uniformsPool=[],this._activeUniforms=[],this._bindGroupPool=[],this._activeBindGroups=[],this._renderer=t}reset(){this._stackIndex=0;for(let t=0;t<this._activeUniforms.length;t++)this._uniformsPool.push(this._activeUniforms[t]);for(let t=0;t<this._activeBindGroups.length;t++)this._bindGroupPool.push(this._activeBindGroups[t]);this._activeUniforms.length=0,this._activeBindGroups.length=0}start(t){this.reset(),this.push(t)}bind({size:t,projectionMatrix:e,worldTransformMatrix:r,worldColor:s,offset:i}){const o=this._renderer.renderTarget.renderTarget,a=this._stackIndex?this._globalUniformDataStack[this._stackIndex-1]:{projectionData:o,worldTransformMatrix:new n.u,worldColor:4294967295,offset:new xt.b},l={projectionMatrix:e||this._renderer.renderTarget.projectionMatrix,resolution:t||o.size,worldTransformMatrix:r||a.worldTransformMatrix,worldColor:s||a.worldColor,offset:i||a.offset,bindGroup:null},h=this._uniformsPool.pop()||this._createUniforms();this._activeUniforms.push(h);const c=h.uniforms;let u;c.uProjectionMatrix=l.projectionMatrix,c.uResolution=l.resolution,c.uWorldTransformMatrix.copyFrom(l.worldTransformMatrix),c.uWorldTransformMatrix.tx-=l.offset.x,c.uWorldTransformMatrix.ty-=l.offset.y,(0,_t.V)(l.worldColor,c.uWorldColorAlpha,0),h.update(),this._renderer.renderPipes.uniformBatch?u=this._renderer.renderPipes.uniformBatch.getUniformBindGroup(h,!1):(u=this._bindGroupPool.pop()||new yt.T,this._activeBindGroups.push(u),u.setResource(h,0)),l.bindGroup=u,this._currentGlobalUniformData=l}push(t){this.bind(t),this._globalUniformDataStack[this._stackIndex++]=this._currentGlobalUniformData}pop(){this._currentGlobalUniformData=this._globalUniformDataStack[--this._stackIndex-1],this._renderer.type===X.W.WEBGL&&this._currentGlobalUniformData.bindGroup.resources[0].update()}get bindGroup(){return this._currentGlobalUniformData.bindGroup}get globalUniformData(){return this._currentGlobalUniformData}get uniformGroup(){return this._currentGlobalUniformData.bindGroup.resources[0]}_createUniforms(){return new G.k({uProjectionMatrix:{value:new n.u,type:"mat3x3<f32>"},uWorldTransformMatrix:{value:new n.u,type:"mat3x3<f32>"},uWorldColorAlpha:{value:new Float32Array(4),type:"vec4<f32>"},uResolution:{value:[0,0],type:"vec2<f32>"}},{isStatic:!0})}destroy(){this._renderer=null,this._globalUniformDataStack.length=0,this._uniformsPool.length=0,this._activeUniforms.length=0,this._bindGroupPool.length=0,this._activeBindGroups.length=0,this._currentGlobalUniformData=null}}vt.extension={type:[s.Ag.WebGLSystem,s.Ag.WebGPUSystem,s.Ag.CanvasSystem],name:"globalUniforms"};var bt=r(3651);let wt=1;class Tt{constructor(){this._tasks=[],this._offset=0}init(){bt.R.system.add(this._update,this)}repeat(t,e,r=!0){const s=wt++;let i=0;return r&&(this._offset+=1e3,i=this._offset),this._tasks.push({func:t,duration:e,start:performance.now(),offset:i,last:performance.now(),repeat:!0,id:s}),s}cancel(t){for(let e=0;e<this._tasks.length;e++)if(this._tasks[e].id===t)return void this._tasks.splice(e,1)}_update(){const t=performance.now();for(let e=0;e<this._tasks.length;e++){const r=this._tasks[e];if(t-r.offset-r.last>=r.duration){const e=t-r.start;r.func(e),r.last=t}}}destroy(){bt.R.system.remove(this._update,this),this._tasks.length=0}}Tt.extension={type:[s.Ag.WebGLSystem,s.Ag.WebGPUSystem,s.Ag.CanvasSystem],name:"scheduler",priority:0};let St=!1;class At{constructor(t){this._renderer=t}init(t){if(t.hello){let t=this._renderer.name;this._renderer.type===X.W.WEBGL&&(t+=` ${this._renderer.context.webGLVersion}`),function(t){if(!St){if(nt.e.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){const e=[`%c %c %c %c %c PixiJS %c v${A} (${t}) http://www.pixijs.com/\n\n`,"background: #E72264; padding:5px 0;","background: #6CA2EA; padding:5px 0;","background: #B5D33D; padding:5px 0;","background: #FED23F; padding:5px 0;","color: #FFFFFF; background: #E72264; padding:5px 0;","color: #E72264; background: #FFFFFF; padding:5px 0;"];globalThis.console.log(...e)}else globalThis.console&&globalThis.console.log(`PixiJS ${A} - ${t} - http://www.pixijs.com/`);St=!0}}(t)}}}function Ct(t){let e=!1;for(const r in t)if(null==t[r]){e=!0;break}if(!e)return t;const r=Object.create(null);for(const e in t){const s=t[e];s&&(r[e]=s)}return r}function Pt(t){let e=0;for(let r=0;r<t.length;r++)null==t[r]?e++:t[r-e]=t[r];return t.length-=e,t}At.extension={type:[s.Ag.WebGLSystem,s.Ag.WebGPUSystem,s.Ag.CanvasSystem],name:"hello",priority:-2},At.defaultOptions={hello:!1};let Mt=0;const Et=class t{constructor(t){this._managedRenderables=[],this._managedHashes=[],this._managedArrays=[],this._renderer=t}init(e){e={...t.defaultOptions,...e},this.maxUnusedTime=e.renderableGCMaxUnusedTime,this._frequency=e.renderableGCFrequency,this.enabled=e.renderableGCActive}get enabled(){return!!this._handler}set enabled(t){this.enabled!==t&&(t?(this._handler=this._renderer.scheduler.repeat(()=>this.run(),this._frequency,!1),this._hashHandler=this._renderer.scheduler.repeat(()=>{for(const t of this._managedHashes)t.context[t.hash]=Ct(t.context[t.hash])},this._frequency),this._arrayHandler=this._renderer.scheduler.repeat(()=>{for(const t of this._managedArrays)Pt(t.context[t.hash])},this._frequency)):(this._renderer.scheduler.cancel(this._handler),this._renderer.scheduler.cancel(this._hashHandler),this._renderer.scheduler.cancel(this._arrayHandler)))}addManagedHash(t,e){this._managedHashes.push({context:t,hash:e})}addManagedArray(t,e){this._managedArrays.push({context:t,hash:e})}prerender({container:t}){this._now=performance.now(),t.renderGroup.gcTick=Mt++,this._updateInstructionGCTick(t.renderGroup,t.renderGroup.gcTick)}addRenderable(t){this.enabled&&(-1===t._lastUsed&&(this._managedRenderables.push(t),t.once("destroyed",this._removeRenderable,this)),t._lastUsed=this._now)}run(){const t=this._now,e=this._managedRenderables,r=this._renderer.renderPipes;let s=0;for(let i=0;i<e.length;i++){const n=e[i];if(null===n){s++;continue}const o=n.renderGroup??n.parentRenderGroup,a=o?.instructionSet?.gcTick??-1;if((o?.gcTick??0)===a&&(n._lastUsed=t),t-n._lastUsed>this.maxUnusedTime){if(!n.destroyed){const t=r;o&&(o.structureDidChange=!0),t[n.renderPipeId].destroyRenderable(n)}n._lastUsed=-1,s++,n.off("destroyed",this._removeRenderable,this)}else e[i-s]=n}e.length-=s}destroy(){this.enabled=!1,this._renderer=null,this._managedRenderables.length=0,this._managedHashes.length=0,this._managedArrays.length=0}_removeRenderable(t){const e=this._managedRenderables.indexOf(t);e>=0&&(t.off("destroyed",this._removeRenderable,this),this._managedRenderables[e]=null)}_updateInstructionGCTick(t,e){t.instructionSet.gcTick=e;for(const r of t.renderGroupChildren)this._updateInstructionGCTick(r,e)}};Et.extension={type:[s.Ag.WebGLSystem,s.Ag.WebGPUSystem],name:"renderableGC",priority:0},Et.defaultOptions={renderableGCActive:!0,renderableGCMaxUnusedTime:6e4,renderableGCFrequency:3e4};let Rt=Et;const kt=class t{constructor(t){this._renderer=t,this.count=0,this.checkCount=0}init(e){e={...t.defaultOptions,...e},this.checkCountMax=e.textureGCCheckCountMax,this.maxIdle=e.textureGCAMaxIdle??e.textureGCMaxIdle,this.active=e.textureGCActive}postrender(){this._renderer.renderingToScreen&&(this.count++,this.active&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const t=this._renderer.texture.managedTextures;for(let e=0;e<t.length;e++){const r=t[e];r.autoGarbageCollect&&r.resource&&r._touched>-1&&this.count-r._touched>this.maxIdle&&(r._touched=-1,r.unload())}}destroy(){this._renderer=null}};kt.extension={type:[s.Ag.WebGLSystem,s.Ag.WebGPUSystem],name:"textureGC"},kt.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:null,textureGCMaxIdle:3600,textureGCCheckCountMax:600};let Bt=kt;var It=r(4696),Gt=r(2277),Ft=r(8955);const Ot=class t{get autoDensity(){return this.texture.source.autoDensity}set autoDensity(t){this.texture.source.autoDensity=t}get resolution(){return this.texture.source._resolution}set resolution(t){this.texture.source.resize(this.texture.source.width,this.texture.source.height,t)}init(e){(e={...t.defaultOptions,...e}).view&&((0,It.t6)(It.lj,"ViewSystem.view has been renamed to ViewSystem.canvas"),e.canvas=e.view),this.screen=new ht.M(0,0,e.width,e.height),this.canvas=e.canvas||nt.e.get().createCanvas(),this.antialias=!!e.antialias,this.texture=(0,Ft.c)(this.canvas,e),this.renderTarget=new Gt.O({colorTextures:[this.texture],depth:!!e.depth,isRoot:!0}),this.texture.source.transparent=e.backgroundAlpha<1,this.resolution=e.resolution}resize(t,e,r){this.texture.source.resize(t,e,r),this.screen.width=this.texture.frame.width,this.screen.height=this.texture.frame.height}destroy(t=!1){("boolean"==typeof t?t:!!t?.removeView)&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.texture.destroy()}};Ot.extension={type:[s.Ag.WebGLSystem,s.Ag.WebGPUSystem,s.Ag.CanvasSystem],name:"view",priority:0},Ot.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};const Dt=[et,vt,At,Ot,T,Bt,mt,lt,C,Rt,Tt],Ut=[it,R,S,c,j,Z,$,i]},1711:(t,e,r)=>{"use strict";r.d(e,{u:()=>s});var s=(t=>(t[t.NONE=0]="NONE",t[t.COLOR=16384]="COLOR",t[t.STENCIL=1024]="STENCIL",t[t.DEPTH=256]="DEPTH",t[t.COLOR_DEPTH=16640]="COLOR_DEPTH",t[t.COLOR_STENCIL=17408]="COLOR_STENCIL",t[t.DEPTH_STENCIL=1280]="DEPTH_STENCIL",t[t.ALL=17664]="ALL",t))(s||{})},1734:(t,e,r)=>{"use strict";r.d(e,{N:()=>n});var s=r(5199);const i=new s.u;class n{constructor(t,e){this.mapCoord=new s.u,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,this.clampMargin=void 0===e?t.width<10?0:.5:e,this.isSimple=!1,this.texture=t}get texture(){return this._texture}set texture(t){this.texture!==t&&(this._texture?.removeListener("update",this.update,this),this._texture=t,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(t,e){void 0===e&&(e=t);const r=this.mapCoord;for(let s=0;s<t.length;s+=2){const i=t[s],n=t[s+1];e[s]=i*r.a+n*r.c+r.tx,e[s+1]=i*r.b+n*r.d+r.ty}return e}update(){const t=this._texture;this._updateID++;const e=t.uvs;this.mapCoord.set(e.x1-e.x0,e.y1-e.y0,e.x3-e.x0,e.y3-e.y0,e.x0,e.y0);const r=t.orig,s=t.trim;s&&(i.set(r.width/s.width,0,0,r.height/s.height,-s.x/s.width,-s.y/s.height),this.mapCoord.append(i));const n=t.source,o=this.uClampFrame,a=this.clampMargin/n._resolution,l=this.clampOffset/n._resolution;return o[0]=(t.frame.x+a+l)/n.width,o[1]=(t.frame.y+a+l)/n.height,o[2]=(t.frame.x+t.frame.width-a+l)/n.width,o[3]=(t.frame.y+t.frame.height-a+l)/n.height,this.uClampOffset[0]=this.clampOffset/n.pixelWidth,this.uClampOffset[1]=this.clampOffset/n.pixelHeight,this.isSimple=t.frame.width===n.width&&t.frame.height===n.height&&0===t.rotate,!0}}},1753:(t,e,r)=>{"use strict";r.d(e,{L:()=>s});const s={_registeredResources:new Set,register(t){this._registeredResources.add(t)},unregister(t){this._registeredResources.delete(t)},release(){this._registeredResources.forEach(t=>t.clear())},get registeredCount(){return this._registeredResources.size},isRegistered(t){return this._registeredResources.has(t)},reset(){this._registeredResources.clear()}}},1790:(t,e,r)=>{"use strict";r.d(e,{B:()=>h});var s=r(8642),i=r(4988);const n={f32:"float32","vec2<f32>":"float32x2","vec3<f32>":"float32x3","vec4<f32>":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2<i32>":"sint32x2","vec3<i32>":"sint32x3","vec4<i32>":"sint32x4",u32:"uint32","vec2<u32>":"uint32x2","vec3<u32>":"uint32x3","vec4<u32>":"uint32x4",bool:"uint32","vec2<bool>":"uint32x2","vec3<bool>":"uint32x3","vec4<bool>":"uint32x4"};function o(t){const e=/@group\((\d+)\)/,r=/@binding\((\d+)\)/,s=/var(<[^>]+>)? (\w+)/,i=/:\s*(\w+)/,n=/(\w+)\s*:\s*([\w\<\>]+)/g,o=/struct\s+(\w+)/,a=t.match(/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g)?.map(t=>({group:parseInt(t.match(e)[1],10),binding:parseInt(t.match(r)[1],10),name:t.match(s)[2],isUniform:"<uniform>"===t.match(s)[1],type:t.match(i)[1]}));if(!a)return{groups:[],structs:[]};const l=t.match(/struct\s+(\w+)\s*{([^}]+)}/g)?.map(t=>{const e=t.match(o)[1],r=t.match(n).reduce((t,e)=>{const[r,s]=e.split(":");return t[r.trim()]=s.trim(),t},{});return r?{name:e,members:r}:null}).filter(({name:t})=>a.some(e=>e.type===t))??[];return{groups:a,structs:l}}var a=(t=>(t[t.VERTEX=1]="VERTEX",t[t.FRAGMENT=2]="FRAGMENT",t[t.COMPUTE=4]="COMPUTE",t))(a||{});const l=Object.create(null);class h{constructor(t){this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:e,vertex:r,layout:s,gpuLayout:i,name:n}=t;if(this.name=n,this.fragment=e,this.vertex=r,e.source===r.source){const t=o(e.source);this.structsAndGroups=t}else{const t=o(r.source),s=o(e.source);this.structsAndGroups=function(t,e){const r=new Set,s=new Set;return{structs:[...t.structs,...e.structs].filter(t=>!r.has(t.name)&&(r.add(t.name),!0)),groups:[...t.groups,...e.groups].filter(t=>{const e=`${t.name}-${t.binding}`;return!s.has(e)&&(s.add(e),!0)})}}(t,s)}this.layout=s??function({groups:t}){const e=[];for(let r=0;r<t.length;r++){const s=t[r];e[s.group]||(e[s.group]={}),e[s.group][s.name]=s.binding}return e}(this.structsAndGroups),this.gpuLayout=i??function({groups:t}){const e=[];for(let r=0;r<t.length;r++){const s=t[r];e[s.group]||(e[s.group]=[]),s.isUniform?e[s.group].push({binding:s.binding,visibility:a.VERTEX|a.FRAGMENT,buffer:{type:"uniform"}}):"sampler"===s.type?e[s.group].push({binding:s.binding,visibility:a.FRAGMENT,sampler:{type:"filtering"}}):"texture_2d"===s.type&&e[s.group].push({binding:s.binding,visibility:a.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}})}return e}(this.structsAndGroups),this.autoAssignGlobalUniforms=!(void 0===this.layout[0]?.globalUniforms),this.autoAssignLocalUniforms=!(void 0===this.layout[1]?.localUniforms),this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,r=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=(0,s.X)(r,"program")}get attributeData(){return this._attributeData??(this._attributeData=function({source:t,entryPoint:e}){const r={},s=t.indexOf(`fn ${e}`);if(-1!==s){const e=t.indexOf("->",s);if(-1!==e){const o=t.substring(s,e),a=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|$)/g;let l;for(;null!==(l=a.exec(o));){const t=n[l[3]]??"float32";r[l[2]]={location:parseInt(l[1],10),format:t,stride:(0,i.m)(t).stride,offset:0,instance:!1,start:0}}}}return r}(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,l[this._cacheKey]=null}static from(t){const e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return l[e]||(l[e]=new h(t),l[e]._cacheKey=e),l[e]}}},1990:(t,e,r)=>{"use strict";r.d(e,{r:()=>c});var s=r(6675),i=r(5199),n=r(9739),o=r(7694),a=r(6406),l=r(9776);const h=1e5;function c(t,e,r,c=0){if(t.texture===n.g.WHITE&&!t.fill)return s.Q.shared.setValue(t.color).setAlpha(t.alpha??1).toHexa();if(!t.fill){const r=e.createPattern(t.texture.source.resource,"repeat"),s=t.matrix.copyTo(i.u.shared);return s.scale(t.texture.frame.width,t.texture.frame.height),r.setTransform(s),r}if(t.fill instanceof l.m){const r=t.fill,s=e.createPattern(r.texture.source.resource,"repeat"),n=r.transform.copyTo(i.u.shared);return n.scale(r.texture.frame.width,r.texture.frame.height),s.setTransform(n),s}if(t.fill instanceof a._){const i=t.fill,n="linear"===i.type,o="local"===i.textureSpace;let a,l=1,u=1;o&&r&&(l=r.width+c,u=r.height+c);let d=!1;if(n){const{start:t,end:r}=i;a=e.createLinearGradient(t.x*l,t.y*u,r.x*l,r.y*u),d=Math.abs(r.x-t.x)<Math.abs(.1*(r.y-t.y))}else{const{center:t,innerRadius:r,outerCenter:s,outerRadius:n}=i;a=e.createRadialGradient(t.x*l,t.y*u,r*l,s.x*l,s.y*u,n*l)}if(d&&o&&r){const t=r.lineHeight/u;for(let e=0;e<r.lines.length;e++){const n=(e*r.lineHeight+c/2)/u;i.colorStops.forEach(e=>{const r=n+e.offset*t;a.addColorStop(Math.floor(r*h)/h,s.Q.shared.setValue(e.color).toHex())})}}else i.colorStops.forEach(t=>{a.addColorStop(t.offset,s.Q.shared.setValue(t.color).toHex())});return a}return(0,o.R)("FillStyle not recognised",t),"red"}},2015:(t,e,r)=>{"use strict";r.d(e,{d:()=>n});var s=r(4872),i=r(9375);class n extends s.A{constructor({buffer:t,offset:e,size:r}){super(),this.uid=(0,i.L)("buffer"),this._resourceType="bufferResource",this._touched=0,this._resourceId=(0,i.L)("resource"),this._bufferResource=!0,this.destroyed=!1,this.buffer=t,this.offset=0|e,this.size=r,this.buffer.on("change",this.onBufferChange,this)}onBufferChange(){this._resourceId=(0,i.L)("resource"),this.emit("change",this)}destroy(t=!1){this.destroyed=!0,t&&this.buffer.destroy(),this.emit("change",this),this.buffer=null}}},2027:(t,e,r)=>{"use strict";r.d(e,{x:()=>h});var s=r(7694),i=r(8869),n=r(8064);function o(t,e,r,s,i){const n=e[r];for(let a=0;a<n.length;a++){const l=n[a];r<e.length-1?o(t.replace(s[r],l),e,r+1,s,i):i.push(t.replace(s[r],l))}}function a(t){const e=t.match(/\{(.*?)\}/g),r=[];if(e){const s=[];e.forEach(t=>{const e=t.substring(1,t.length-1).split(",");s.push(e)}),o(t,s,0,e,r)}else r.push(t);return r}var l=r(2843);class h{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){if(this._bundleIdConnector=t.connector??this._bundleIdConnector,this._createBundleAssetId=t.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=t.extractAssetIdFromBundle??this._extractAssetIdFromBundle,"bar"!==this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar")))throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(t=>{this._preferredOrder.push(t),t.priority||(t.priority=Object.keys(t.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if("string"==typeof t)this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(t=>`${encodeURIComponent(t)}=${encodeURIComponent(e[t])}`).join("&")}}getAlias(t){const{alias:e,src:r}=t;return(0,n.z)(e||r,t=>"string"==typeof t?t:Array.isArray(t)?t.map(t=>t?.src??t):t?.src?t.src:t,!0)}addManifest(t){this._manifest&&(0,s.R)("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=t,t.bundles.forEach(t=>{this.addBundle(t.name,t.assets)})}addBundle(t,e){const r=[];let s=e;Array.isArray(e)||(s=Object.entries(e).map(([t,e])=>"string"==typeof e||Array.isArray(e)?{alias:t,src:e}:{alias:t,...e})),s.forEach(e=>{const s=e.src,i=e.alias;let n;if("string"==typeof i){const e=this._createBundleAssetId(t,i);r.push(e),n=[i,e]}else{const e=i.map(e=>this._createBundleAssetId(t,e));r.push(...e),n=[...i,...e]}this.add({...e,alias:n,src:s})}),this._bundles[t]=r}add(t){const e=[];let r;Array.isArray(t)?e.push(...t):e.push(t),r=t=>{this.hasKey(t)&&(0,s.R)(`[Resolver] already has key: ${t} overwriting`)},(0,n.z)(e).forEach(t=>{const{src:e}=t;let{data:s,format:i,loadParser:o,parser:l}=t;const h=(0,n.z)(e).map(t=>"string"==typeof t?a(t):Array.isArray(t)?t:[t]),c=this.getAlias(t);Array.isArray(c)?c.forEach(r):r(c);const u=[];h.forEach(t=>{t.forEach(t=>{let e={};if("object"!=typeof t){e.src=t;for(let r=0;r<this._parsers.length;r++){const s=this._parsers[r];if(s.test(t)){e=s.parse(t);break}}}else s=t.data??s,i=t.format??i,(t.loadParser||t.parser)&&(o=t.loadParser??o,l=t.parser??l),e={...e,...t};if(!c)throw new Error(`[Resolver] alias is undefined for this asset: ${e.src}`);e=this._buildResolvedAsset(e,{aliases:c,data:s,format:i,loadParser:o,parser:l}),u.push(e)})}),c.forEach(t=>{this._assetMap[t]=u})})}resolveBundle(t){const e=(0,l.a)(t);t=(0,n.z)(t);const r={};return t.forEach(t=>{const e=this._bundles[t];if(e){const s=this.resolve(e),i={};for(const e in s){const r=s[e];i[this._extractAssetIdFromBundle(t,e)]=r}r[t]=i}}),e?r[t[0]]:r}resolveUrl(t){const e=this.resolve(t);if("string"!=typeof t){const t={};for(const r in e)t[r]=e[r].src;return t}return e.src}resolve(t){const e=(0,l.a)(t);t=(0,n.z)(t);const r={};return t.forEach(t=>{if(!this._resolverHash[t])if(this._assetMap[t]){let e=this._assetMap[t];const r=this._getPreferredOrder(e);r?.priority.forEach(t=>{r.params[t].forEach(r=>{const s=e.filter(e=>!!e[t]&&e[t]===r);s.length&&(e=s)})}),this._resolverHash[t]=e[0]}else this._resolverHash[t]=this._buildResolvedAsset({alias:[t],src:t},{});r[t]=this._resolverHash[t]}),e?r[t[0]]:r}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;e<t.length;e++){const r=t[e],s=this._preferredOrder.find(t=>t.params.format.includes(r.format));if(s)return s}return this._preferredOrder[0]}_appendDefaultSearchParams(t){return this._defaultSearchParams?`${t}${/\?/.test(t)?"&":"?"}${this._defaultSearchParams}`:t}_buildResolvedAsset(t,e){const{aliases:r,data:s,loadParser:n,parser:o,format:a}=e;return(this._basePath||this._rootPath)&&(t.src=i.A.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=r??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...s||{},...t.data},t.loadParser=n??t.loadParser,t.parser=o??t.parser,t.format=a??t.format??t.src.split(".").pop().split("?").shift().split("#").shift(),t}}h.RETINA_PREFIX=/@([0-9\.]+)x/},2043:(t,e,r)=>{"use strict";r.d(e,{z:()=>a});var s=r(9390),i=r(4269),n=r(9739);const o=class t{constructor(t,e){this.linkedSheets=[];let r=t;t?.source instanceof i.v&&(r={texture:t,data:e});const{texture:s,data:o,cachePrefix:a=""}=r;this.cachePrefix=a,this._texture=s instanceof n.g?s:null,this.textureSource=s.source,this.textures={},this.animations={},this.data=o;const l=parseFloat(o.meta.scale);l?(this.resolution=l,s.source.resolution=this.resolution):this.resolution=s.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(e=>{this._callback=e,this._batchIndex=0,this._frameKeys.length<=t.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(e){let r=e;const i=t.BATCH_SIZE;for(;r-e<i&&r<this._frameKeys.length;){const t=this._frameKeys[r],e=this._frames[t],i=e.frame;if(i){let r=null,o=null;const a=!1!==e.trimmed&&e.sourceSize?e.sourceSize:e.frame,l=new s.M(0,0,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution);r=e.rotated?new s.M(Math.floor(i.x)/this.resolution,Math.floor(i.y)/this.resolution,Math.floor(i.h)/this.resolution,Math.floor(i.w)/this.resolution):new s.M(Math.floor(i.x)/this.resolution,Math.floor(i.y)/this.resolution,Math.floor(i.w)/this.resolution,Math.floor(i.h)/this.resolution),!1!==e.trimmed&&e.spriteSourceSize&&(o=new s.M(Math.floor(e.spriteSourceSize.x)/this.resolution,Math.floor(e.spriteSourceSize.y)/this.resolution,Math.floor(i.w)/this.resolution,Math.floor(i.h)/this.resolution)),this.textures[t]=new n.g({source:this.textureSource,frame:r,orig:l,trim:o,rotate:e.rotated?2:0,defaultAnchor:e.anchor,defaultBorders:e.borders,label:t.toString()})}r++}}_processAnimations(){const t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let r=0;r<t[e].length;r++){const s=t[e][r];this.animations[e].push(this.textures[s])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*t.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*t.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){for(const t in this.textures)this.textures[t].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&(this._texture?.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};o.BATCH_SIZE=1e3;let a=o},2071:(t,e,r)=>{"use strict";r.d(e,{n:()=>n});var s=r(5199),i=r(7882);function n(t,e,r){return e.clear(),r||(r=s.u.IDENTITY),o(t,e,r,t,!0),e.isValid||e.set(0,0,0,0),e}function o(t,e,r,n,a){let l;if(a)l=i.u.get(),l=r.copyTo(l);else{if(!t.visible||!t.measurable)return;t.updateLocalTransform();const e=t.localTransform;l=i.u.get(),l.appendFrom(e,r)}const h=e,c=!!t.effects.length;if(c&&(e=i.o.get().clear()),t.boundsArea)e.addRect(t.boundsArea,l);else{t.renderPipeId&&(e.matrix=l,e.addBounds(t.bounds));const r=t.children;for(let t=0;t<r.length;t++)o(r[t],e,l,n,!1)}if(c){for(let r=0;r<t.effects.length;r++)t.effects[r].addLocalBounds?.(e,n);h.addBounds(e,s.u.IDENTITY),i.o.return(e)}i.u.return(l)}},2255:(t,e,r)=>{"use strict";r.d(e,{C:()=>s});class s{constructor(t){this.items=[],this._name=t}emit(t,e,r,s,i,n,o,a){const{name:l,items:h}=this;for(let c=0,u=h.length;c<u;c++)h[c][l](t,e,r,s,i,n,o,a);return this}add(t){return t[this._name]&&(this.remove(t),this.items.push(t)),this}remove(t){const e=this.items.indexOf(t);return-1!==e&&this.items.splice(e,1),this}contains(t){return-1!==this.items.indexOf(t)}removeAll(){return this.items.length=0,this}destroy(){this.removeAll(),this.items=null,this._name=null}get empty(){return 0===this.items.length}get name(){return this._name}}},2276:(t,e,r)=>{"use strict";r.d(e,{$:()=>s});const s=[{type:"mat3x3<f32>",test:t=>void 0!==t.value.a,ubo:"\n var matrix = uv[name].toArray(true);\n data[offset] = matrix[0];\n data[offset + 1] = matrix[1];\n data[offset + 2] = matrix[2];\n data[offset + 4] = matrix[3];\n data[offset + 5] = matrix[4];\n data[offset + 6] = matrix[5];\n data[offset + 8] = matrix[6];\n data[offset + 9] = matrix[7];\n data[offset + 10] = matrix[8];\n ",uniform:"\n gl.uniformMatrix3fv(ud[name].location, false, uv[name].toArray(true));\n "},{type:"vec4<f32>",test:t=>"vec4<f32>"===t.type&&1===t.size&&void 0!==t.value.width,ubo:"\n v = uv[name];\n data[offset] = v.x;\n data[offset + 1] = v.y;\n data[offset + 2] = v.width;\n data[offset + 3] = v.height;\n ",uniform:"\n cv = ud[name].value;\n v = uv[name];\n if (cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height) {\n cv[0] = v.x;\n cv[1] = v.y;\n cv[2] = v.width;\n cv[3] = v.height;\n gl.uniform4f(ud[name].location, v.x, v.y, v.width, v.height);\n }\n "},{type:"vec2<f32>",test:t=>"vec2<f32>"===t.type&&1===t.size&&void 0!==t.value.x,ubo:"\n v = uv[name];\n data[offset] = v.x;\n data[offset + 1] = v.y;\n ",uniform:"\n cv = ud[name].value;\n v = uv[name];\n if (cv[0] !== v.x || cv[1] !== v.y) {\n cv[0] = v.x;\n cv[1] = v.y;\n gl.uniform2f(ud[name].location, v.x, v.y);\n }\n "},{type:"vec4<f32>",test:t=>"vec4<f32>"===t.type&&1===t.size&&void 0!==t.value.red,ubo:"\n v = uv[name];\n data[offset] = v.red;\n data[offset + 1] = v.green;\n data[offset + 2] = v.blue;\n data[offset + 3] = v.alpha;\n ",uniform:"\n cv = ud[name].value;\n v = uv[name];\n if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha) {\n cv[0] = v.red;\n cv[1] = v.green;\n cv[2] = v.blue;\n cv[3] = v.alpha;\n gl.uniform4f(ud[name].location, v.red, v.green, v.blue, v.alpha);\n }\n "},{type:"vec3<f32>",test:t=>"vec3<f32>"===t.type&&1===t.size&&void 0!==t.value.red,ubo:"\n v = uv[name];\n data[offset] = v.red;\n data[offset + 1] = v.green;\n data[offset + 2] = v.blue;\n ",uniform:"\n cv = ud[name].value;\n v = uv[name];\n if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue) {\n cv[0] = v.red;\n cv[1] = v.green;\n cv[2] = v.blue;\n gl.uniform3f(ud[name].location, v.red, v.green, v.blue);\n }\n "}]},2277:(t,e,r)=>{"use strict";r.d(e,{O:()=>a});var s=r(9375),i=r(4269),n=r(9739);const o=class t{constructor(e={}){if(this.uid=(0,s.L)("renderTarget"),this.colorTextures=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,e={...t.defaultOptions,...e},this.stencil=e.stencil,this.depth=e.depth,this.isRoot=e.isRoot,"number"==typeof e.colorTextures){this._managedColorTextures=!0;for(let t=0;t<e.colorTextures;t++)this.colorTextures.push(new i.v({width:e.width,height:e.height,resolution:e.resolution,antialias:e.antialias}))}else{this.colorTextures=[...e.colorTextures.map(t=>t.source)];const t=this.colorTexture.source;this.resize(t.width,t.height,t._resolution)}this.colorTexture.source.on("resize",this.onSourceResize,this),(e.depthStencilTexture||this.stencil)&&(e.depthStencilTexture instanceof n.g||e.depthStencilTexture instanceof i.v?this.depthStencilTexture=e.depthStencilTexture.source:this.ensureDepthStencilTexture())}get size(){const t=this._size;return t[0]=this.pixelWidth,t[1]=this.pixelHeight,t}get width(){return this.colorTexture.source.width}get height(){return this.colorTexture.source.height}get pixelWidth(){return this.colorTexture.source.pixelWidth}get pixelHeight(){return this.colorTexture.source.pixelHeight}get resolution(){return this.colorTexture.source._resolution}get colorTexture(){return this.colorTextures[0]}onSourceResize(t){this.resize(t.width,t.height,t._resolution,!0)}ensureDepthStencilTexture(){this.depthStencilTexture||(this.depthStencilTexture=new i.v({width:this.width,height:this.height,resolution:this.resolution,format:"depth24plus-stencil8",autoGenerateMipmaps:!1,antialias:!1,mipLevelCount:1}))}resize(t,e,r=this.resolution,s=!1){this.dirtyId++,this.colorTextures.forEach((i,n)=>{s&&0===n||i.source.resize(t,e,r)}),this.depthStencilTexture&&this.depthStencilTexture.source.resize(t,e,r)}destroy(){this.colorTexture.source.off("resize",this.onSourceResize,this),this._managedColorTextures&&this.colorTextures.forEach(t=>{t.destroy()}),this.depthStencilTexture&&(this.depthStencilTexture.destroy(),delete this.depthStencilTexture)}};o.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};let a=o},2288:(t,e,r)=>{"use strict";r.d(e,{Z:()=>i});const s=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function i(t){const e="number"==typeof t.fontSize?`${t.fontSize}px`:t.fontSize;let r=t.fontFamily;Array.isArray(t.fontFamily)||(r=t.fontFamily.split(","));for(let t=r.length-1;t>=0;t--){let e=r[t].trim();/([\"\'])[^\'\"]+\1/.test(e)||s.includes(e)||(e=`"${e}"`),r[t]=e}return`${t.fontStyle} ${t.fontVariant} ${t.fontWeight} ${e} ${r.join(",")}`}},2305:(t,e,r)=>{"use strict";r.d(e,{F:()=>s,a:()=>i});const s={name:"color-bit",vertex:{header:"\n @in aColor: vec4<f32>;\n ",main:"\n vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);\n "}},i={name:"color-bit",vertex:{header:"\n in vec4 aColor;\n ",main:"\n vColor *= vec4(aColor.rgb * aColor.a, aColor.a);\n "}}},2337:(t,e,r)=>{"use strict";r.d(e,{E:()=>i});var s=r(2276);function i(t,e,r,i){const n=["\n var v = null;\n var v2 = null;\n var t = 0;\n var index = 0;\n var name = null;\n var arrayOffset = null;\n "];let o=0;for(let a=0;a<t.length;a++){const l=t[a],h=l.data.name;let c=!1,u=0;for(let t=0;t<s.$.length;t++)if(s.$[t].test(l.data)){u=l.offset/4,n.push(`name = "${h}";`,`offset += ${u-o};`,s.$[t][e]||s.$[t].ubo),c=!0;break}if(!c)if(l.data.size>1)u=l.offset/4,n.push(r(l,u-o));else{const t=i[l.data.type];u=l.offset/4,n.push(`\n v = uv.${h};\n offset += ${u-o};\n ${t};\n `)}o=u}const a=n.join("\n");return new Function("uv","data","dataInt32","offset",a)}},2445:(t,e,r)=>{"use strict";r.d(e,{l:()=>n});var s=r(7694),i=r(8064);const n=new class{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(t){return this._cache.has(t)}get(t){const e=this._cache.get(t);return e||(0,s.R)(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const r=(0,i.z)(t);let n;for(let t=0;t<this.parsers.length;t++){const s=this.parsers[t];if(s.test(e)){n=s.getCacheableAssets(r,e);break}}const o=new Map(Object.entries(n||{}));n||r.forEach(t=>{o.set(t,e)});const a=[...o.keys()],l={cacheKeys:a,keys:r};r.forEach(t=>{this._cacheMap.set(t,l)}),a.forEach(t=>{const r=n?n[t]:e;this._cache.has(t)&&this._cache.get(t)!==r&&(0,s.R)("[Cache] already has key:",t),this._cache.set(t,o.get(t))})}remove(t){if(!this._cacheMap.has(t))return void(0,s.R)(`[Assets] Asset id ${t} was not found in the Cache`);const e=this._cacheMap.get(t);e.cacheKeys.forEach(t=>{this._cache.delete(t)}),e.keys.forEach(t=>{this._cacheMap.delete(t)})}get parsers(){return this._parsers}}},2478:(t,e,r)=>{"use strict";r.d(e,{n:()=>n});var s=r(4449);const i={};function n(t){let e=i[t];if(e)return e;const r=new Int32Array(t);for(let e=0;e<t;e++)r[e]=e;return e=i[t]=new s.k({uTextures:{value:r,type:"i32",size:t}},{isStatic:!0}),e}},2517:(t,e,r)=>{"use strict";var s=r(1065),i=r(3463),n=r(2027),o=r(9279),a=r(9739),l=r(8869),h=r(2043);const c=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function u(t,e,r){const s={};if(t.forEach(t=>{s[t]=e}),Object.keys(e.textures).forEach(t=>{s[`${e.cachePrefix}${t}`]=e.textures[t]}),!r){const r=l.A.dirname(t[0]);e.linkedSheets.forEach((t,i)=>{const n=u([`${r}/${e.data.meta.related_multi_packs[i]}`],t,!0);Object.assign(s,n)})}return s}const d={extension:s.Ag.Asset,cache:{test:t=>t instanceof h.z,getCacheableAssets:(t,e)=>u(t,e,!1)},resolver:{extension:{type:s.Ag.ResolveParser,name:"resolveSpritesheet"},test:t=>{const e=t.split("?")[0].split("."),r=e.pop(),s=e.pop();return"json"===r&&c.includes(s)},parse:t=>{const e=t.split(".");return{resolution:parseFloat(n.x.RETINA_PREFIX.exec(t)?.[1]??"1"),format:e[e.length-2],src:t}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:s.Ag.LoadParser,priority:i.T.Normal,name:"spritesheetLoader"},testParse:async(t,e)=>".json"===l.A.extname(e.src).toLowerCase()&&!!t.frames,async parse(t,e,r){const{texture:s,imageFilename:i,textureOptions:n,cachePrefix:c}=e?.data??{};let u,d=l.A.dirname(e.src);if(d&&d.lastIndexOf("/")!==d.length-1&&(d+="/"),s instanceof a.g)u=s;else{const s=(0,o.Y)(d+(i??t.meta.image),e.src);u=(await r.load([{src:s,data:n}]))[s]}const p=new h.z({texture:u.source,data:t,cachePrefix:c});await p.parse();const f=t?.meta?.related_multi_packs;if(Array.isArray(f)){const t=[];for(const s of f){if("string"!=typeof s)continue;let i=d+s;e.data?.ignoreMultiPack||(i=(0,o.Y)(i,e.src),t.push(r.load({src:i,data:{textureOptions:n,ignoreMultiPack:!0}})))}const s=await Promise.all(t);p.linkedSheets=s,s.forEach(t=>{t.linkedSheets=[p].concat(p.linkedSheets.filter(e=>e!==t))})}return p},async unload(t,e,r){await r.unload(t.textureSource._sourceOrigin),t.destroy(!1)}}};s.XO.add(d)},2542:(t,e,r)=>{"use strict";var s=r(1065),i=r(4242),n=r(6170),o=r(9565);const a=new n.c;function l(t,e,r){const s=a;t.measurable=!0,(0,o.f)(t,r,s),e.addBoundsMask(s),t.measurable=!1}var h=r(2071),c=r(7882),u=r(7694);function d(t,e,r){const s=c.o.get();t.measurable=!0;const i=c.u.get().identity(),n=p(t,r,i);(0,h.n)(t,s,n),t.measurable=!1,e.addBoundsMask(s),c.u.return(i),c.o.return(s)}function p(t,e,r){return t?(t!==e&&(p(t.parent,e,r),t.updateLocalTransform(),r.append(t.localTransform)),r):((0,u.R)("Mask bounds, renderable is not inside the root container"),r)}class f{constructor(t){this.priority=0,this.inverse=!1,this.pipe="alphaMask",t?.mask&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof i.k),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask=null}addBounds(t,e){this.inverse||l(this.mask,t,e)}addLocalBounds(t,e){d(this.mask,t,e)}containsPoint(t,e){return e(this.mask,t)}destroy(){this.reset()}static test(t){return t instanceof i.k}}f.extension=s.Ag.MaskEffect;class g{constructor(t){this.priority=0,this.pipe="colorMask",t?.mask&&this.init(t.mask)}init(t){this.mask=t}destroy(){}static test(t){return"number"==typeof t}}g.extension=s.Ag.MaskEffect;var m=r(4687);class x{constructor(t){this.priority=0,this.pipe="stencilMask",t?.mask&&this.init(t.mask)}init(t){this.mask=t,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null}addBounds(t,e){l(this.mask,t,e)}addLocalBounds(t,e){d(this.mask,t,e)}containsPoint(t,e){return e(this.mask,t)}destroy(){this.reset()}static test(t){return t instanceof m.mc}}x.extension=s.Ag.MaskEffect;var _=r(6185),y=r(1386),v=r(5947),b=r(5749);r(7935),s.XO.add(f,g,x,b.$,v.b,y.q,_.P)},2577:(t,e,r)=>{"use strict";r.d(e,{R:()=>s,m:()=>i});const s={name:"texture-bit",vertex:{header:"\n\n struct TextureUniforms {\n uTextureMatrix:mat3x3<f32>,\n }\n\n @group(2) @binding(2) var<uniform> textureUniforms : TextureUniforms;\n ",main:"\n uv = (textureUniforms.uTextureMatrix * vec3(uv, 1.0)).xy;\n "},fragment:{header:"\n @group(2) @binding(0) var uTexture: texture_2d<f32>;\n @group(2) @binding(1) var uSampler: sampler;\n\n\n ",main:"\n outColor = textureSample(uTexture, uSampler, vUV);\n "}},i={name:"texture-bit",vertex:{header:"\n uniform mat3 uTextureMatrix;\n ",main:"\n uv = (uTextureMatrix * vec3(uv, 1.0)).xy;\n "},fragment:{header:"\n uniform sampler2D uTexture;\n\n\n ",main:"\n outColor = texture(uTexture, vUV);\n "}}},2791:(t,e,r)=>{"use strict";r.d(e,{w:()=>o});var s=r(3655),i=r(9739);const n={};function o(t,e,r){let o=2166136261;for(let r=0;r<e;r++)o^=t[r].uid,o=Math.imul(o,16777619),o>>>=0;return n[o]||function(t,e,r,o){const a={};let l=0;for(let r=0;r<o;r++){const s=r<e?t[r]:i.g.EMPTY.source;a[l++]=s.source,a[l++]=s.style}const h=new s.T(a);return n[r]=h,h}(t,e,o,r)}},2843:(t,e,r)=>{"use strict";r.d(e,{a:()=>s});const s=t=>!Array.isArray(t)},3046:(t,e,r)=>{"use strict";var s=r(1065);class i{static init(t){Object.defineProperty(this,"resizeTo",{set(t){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=t,t&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;let t,e;if(this._cancelResize(),this._resizeTo===globalThis.window)t=globalThis.innerWidth,e=globalThis.innerHeight;else{const{clientWidth:r,clientHeight:s}=this._resizeTo;t=r,e=s}this.renderer.resize(t,e),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}i.extension=s.Ag.Application;var n=r(3880),o=r(3651);class a{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{set(t){this._ticker&&this._ticker.remove(this.render,this),this._ticker=t,t&&t.add(this.render,this,n.d.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?o.R.shared:new o.R,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}a.extension=s.Ag.Application,s.XO.add(i),s.XO.add(a)},3050:(t,e,r)=>{"use strict";var s=r(1065),i=r(6364),n=r(7433),o=r(761),a=r(9482),l=r(5008);class h{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach(t=>{o.Z.return(t)}),this.batches.length=0}}class c{constructor(t,e){this.state=n.U.for2d(),this.renderer=t,this._adaptor=e,this.renderer.runners.contextChange.add(this)}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(t){const e=t.context,r=!!t._gpuData,s=this.renderer.graphicsContext.updateGpuContext(e);return!(!s.isBatchable&&r===s.isBatchable)}addRenderable(t,e){const r=this.renderer.graphicsContext.updateGpuContext(t.context);t.didViewUpdate&&this._rebuild(t),r.isBatchable?this._addToBatcher(t,e):(this.renderer.renderPipes.batch.break(e),e.add(t))}updateRenderable(t){const e=this._getGpuDataForRenderable(t).batches;for(let t=0;t<e.length;t++){const r=e[t];r._batcher.updateElement(r)}}execute(t){if(!t.isRenderable)return;const e=this.renderer,r=t.context;if(!e.graphicsContext.getGpuContext(r).batches.length)return;const s=r.customShader||this._adaptor.shader;this.state.blendMode=t.groupBlendMode;const i=s.resources.localUniforms.uniforms;i.uTransformMatrix=t.groupTransform,i.uRound=e._roundPixels|t._roundPixels,(0,a.V)(t.groupColorAlpha,i.uColor,0),this._adaptor.execute(this,t)}_rebuild(t){const e=this._getGpuDataForRenderable(t),r=this.renderer.graphicsContext.updateGpuContext(t.context);e.destroy(),r.isBatchable&&this._updateBatchesForRenderable(t,e)}_addToBatcher(t,e){const r=this.renderer.renderPipes.batch,s=this._getGpuDataForRenderable(t).batches;for(let t=0;t<s.length;t++){const i=s[t];r.addToBatch(i,e)}}_getGpuDataForRenderable(t){return t._gpuData[this.renderer.uid]||this._initGpuDataForRenderable(t)}_initGpuDataForRenderable(t){const e=new h;return t._gpuData[this.renderer.uid]=e,e}_updateBatchesForRenderable(t,e){const r=t.context,s=this.renderer.graphicsContext.getGpuContext(r),i=this.renderer._roundPixels|t._roundPixels;e.batches=s.batches.map(e=>{const r=o.Z.get(l.G);return e.copyTo(r),r.renderable=t,r.roundPixels=i,r})}destroy(){this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null}}c.extension={type:[s.Ag.WebGLPipes,s.Ag.WebGPUPipes,s.Ag.CanvasPipes],name:"graphics"},s.XO.add(c),s.XO.add(i.GH)},3412:(t,e,r)=>{"use strict";r.d(e,{K:()=>s});class s{constructor(){this.batcherName="default",this.topology="triangle-list",this.attributeSize=4,this.indexSize=6,this.packAsQuad=!0,this.roundPixels=0,this._attributeStart=0,this._batcher=null,this._batch=null}get blendMode(){return this.renderable.groupBlendMode}get color(){return this.renderable.groupColorAlpha}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.bounds=null}destroy(){}}},3463:(t,e,r)=>{"use strict";r.d(e,{T:()=>s});var s=(t=>(t[t.Low=0]="Low",t[t.Normal=1]="Normal",t[t.High=2]="High",t))(s||{})},3590:(t,e,r)=>{"use strict";function s(t,e,r){const{width:s,height:i}=r.orig,n=r.trim;if(n){const r=n.width,o=n.height;t.minX=n.x-e._x*s,t.maxX=t.minX+r,t.minY=n.y-e._y*i,t.maxY=t.minY+o}else t.minX=-e._x*s,t.maxX=t.minX+s,t.minY=-e._y*i,t.maxY=t.minY+i}r.d(e,{y:()=>s})},3651:(t,e,r)=>{"use strict";r.d(e,{R:()=>o});var s=r(3880);class i{constructor(t,e=null,r=0,s=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=r,this._once=s}match(t,e=null){return this._fn===t&&this._context===e}emit(t){this._fn&&(this._context?this._fn.call(this._context,t):this._fn(t));const e=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!1){this._destroyed=!0,this._fn=null,this._context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const e=this.next;return this.next=t?null:e,this.previous=null,e}}const n=class t{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new i(null,null,1/0),this.deltaMS=1/t.targetFPMS,this.elapsedMS=1/t.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&null===this._requestId&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){null===this._requestId&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){null!==this._requestId&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,r=s.d.NORMAL){return this._addListener(new i(t,e,r))}addOnce(t,e,r=s.d.NORMAL){return this._addListener(new i(t,e,r,!0))}_addListener(t){let e=this._head.next,r=this._head;if(e){for(;e;){if(t.priority>e.priority){t.connect(r);break}r=e,e=e.next}t.previous||t.connect(r)}else t.connect(r);return this._startIfPossible(),this}remove(t,e){let r=this._head.next;for(;r;)r=r.match(t,e)?r.destroy():r.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(e=performance.now()){let r;if(e>this.lastTime){if(r=this.elapsedMS=e-this.lastTime,r>this._maxElapsedMS&&(r=this._maxElapsedMS),r*=this.speed,this._minElapsedMS){const t=e-this._lastFrame|0;if(t<this._minElapsedMS)return;this._lastFrame=e-t%this._minElapsedMS}this.deltaMS=r,this.deltaTime=this.deltaMS*t.targetFPMS;const s=this._head;let i=s.next;for(;i;)i=i.emit(this);s.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=e}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(e){const r=Math.min(this.maxFPS,e),s=Math.min(Math.max(0,r)/1e3,t.targetFPMS);this._maxElapsedMS=1/s}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(0===t)this._minElapsedMS=0;else{const e=Math.max(this.minFPS,t);this._minElapsedMS=1/(e/1e3)}}static get shared(){if(!t._shared){const e=t._shared=new t;e.autoStart=!0,e._protected=!0}return t._shared}static get system(){if(!t._system){const e=t._system=new t;e.autoStart=!0,e._protected=!0}return t._system}};n.targetFPMS=.06;let o=n},3655:(t,e,r)=>{"use strict";r.d(e,{T:()=>s});class s{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const r in t){const s=t[r];this.setResource(s,e++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let e=0;for(const r in this.resources)t[e++]=this.resources[r]._resourceId;this._key=t.join("|")}setResource(t,e){const r=this.resources[e];t!==r&&(r&&t.off?.("change",this.onResourceChange,this),t.on?.("change",this.onResourceChange,this),this.resources[e]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t){const e=this.resources;for(const r in e)e[r]._touched=t}destroy(){const t=this.resources;for(const e in t){const r=t[e];r.off?.("change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){if(this._dirty=!0,t.destroyed){const e=this.resources;for(const r in e)e[r]===t&&(e[r]=null)}else this._updateKey()}}},3769:(t,e,r)=>{"use strict";r.d(e,{i:()=>i});var s=r(8271);function i(t,e){return"no-premultiply-alpha"===e.alphaMode&&s.Q[t]||t}},3880:(t,e,r)=>{"use strict";r.d(e,{d:()=>s});var s=(t=>(t[t.INTERACTION=50]="INTERACTION",t[t.HIGH=25]="HIGH",t[t.NORMAL=0]="NORMAL",t[t.LOW=-25]="LOW",t[t.UTILITY=-50]="UTILITY",t))(s||{})},4025:(t,e,r)=>{"use strict";function s(t,e,r){const s=t.length;let i;if(e>=s||0===r)return;const n=s-(r=e+r>s?s-e:r);for(i=e;i<n;++i)t[i]=t[i+r];t.length=n}r.d(e,{d:()=>s})},4142:(t,e,r)=>{"use strict";r.d(e,{u:()=>s});class s{constructor(t){"number"==typeof t?this.rawBinaryData=new ArrayBuffer(t):t instanceof Uint8Array?this.rawBinaryData=t.buffer:this.rawBinaryData=t,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData),this.size=this.rawBinaryData.byteLength}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}get float64View(){return this._float64Array||(this._float64Array=new Float64Array(this.rawBinaryData)),this._float64Array}get bigUint64View(){return this._bigUint64Array||(this._bigUint64Array=new BigUint64Array(this.rawBinaryData)),this._bigUint64Array}view(t){return this[`${t}View`]}destroy(){this.rawBinaryData=null,this._int8View=null,this._uint8View=null,this._int16View=null,this.uint16View=null,this._int32View=null,this.uint32View=null,this.float32View=null}static sizeOf(t){switch(t){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${t} isn't a valid view type`)}}}},4242:(t,e,r)=>{"use strict";r.d(e,{k:()=>l});var s=r(7898),i=r(9739),n=r(3590),o=r(4696),a=r(4543);class l extends a.l{constructor(t=i.g.EMPTY){t instanceof i.g&&(t={texture:t});const{texture:e=i.g.EMPTY,anchor:r,roundPixels:n,width:o,height:a,...l}=t;super({label:"Sprite",...l}),this.renderPipeId="sprite",this.batched=!0,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new s.o({_onUpdate:()=>{this.onViewUpdate()}}),r?this.anchor=r:e.defaultAnchor&&(this.anchor=e.defaultAnchor),this.texture=e,this.allowChildren=!1,this.roundPixels=n??!1,void 0!==o&&(this.width=o),void 0!==a&&(this.height=a)}static from(t,e=!1){return t instanceof i.g?new l(t):new l(i.g.from(t,e))}set texture(t){t||(t=i.g.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this._width&&this._setWidth(this._width,this._texture.orig.width),this._height&&this._setHeight(this._height,this._texture.orig.height),this.onViewUpdate())}get texture(){return this._texture}get visualBounds(){return(0,n.y)(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return(0,o.t6)("8.6.1","Sprite.sourceBounds is deprecated, use visualBounds instead."),this.visualBounds}updateBounds(){const t=this._anchor,e=this._texture,r=this._bounds,{width:s,height:i}=e.orig;r.minX=-t._x*s,r.maxX=r.minX+s,r.minY=-t._y*i,r.maxY=r.minY+i}destroy(t=!1){if(super.destroy(t),"boolean"==typeof t?t:t?.texture){const e="boolean"==typeof t?t:t?.textureSource;this._texture.destroy(e)}this._texture=null,this._visualBounds=null,this._bounds=null,this._anchor=null,this._gpuData=null}get anchor(){return this._anchor}set anchor(t){"number"==typeof t?this._anchor.set(t):this._anchor.copyFrom(t)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this._setWidth(t,this._texture.orig.width),this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this._setHeight(t,this._texture.orig.height),this._height=t}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this._texture.orig.width,t.height=Math.abs(this.scale.y)*this._texture.orig.height,t}setSize(t,e){"object"==typeof t?(e=t.height??t.width,t=t.width):e??(e=t),void 0!==t&&this._setWidth(t,this._texture.orig.width),void 0!==e&&this._setHeight(e,this._texture.orig.height)}}},4269:(t,e,r)=>{"use strict";r.d(e,{v:()=>h});var s=r(4872),i=r(9437),n=r(7604),o=r(9375),a=r(8896);const l=class t extends s.A{constructor(e={}){super(),this.options=e,this.uid=(0,o.L)("textureSource"),this._resourceType="textureSource",this._resourceId=(0,o.L)("resource"),this.uploadMethodId="unknown",this._resolution=1,this.pixelWidth=1,this.pixelHeight=1,this.width=1,this.height=1,this.sampleCount=1,this.mipLevelCount=1,this.autoGenerateMipmaps=!1,this.format="rgba8unorm",this.dimension="2d",this.antialias=!1,this._touched=0,this._batchTick=-1,this._textureBindLocation=-1,e={...t.defaultOptions,...e},this.label=e.label??"",this.resource=e.resource,this.autoGarbageCollect=e.autoGarbageCollect,this._resolution=e.resolution,e.width?this.pixelWidth=e.width*this._resolution:this.pixelWidth=this.resource?this.resourceWidth??1:1,e.height?this.pixelHeight=e.height*this._resolution:this.pixelHeight=this.resource?this.resourceHeight??1:1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=e.format,this.dimension=e.dimensions,this.mipLevelCount=e.mipLevelCount,this.autoGenerateMipmaps=e.autoGenerateMipmaps,this.sampleCount=e.sampleCount,this.antialias=e.antialias,this.alphaMode=e.alphaMode,this.style=new a.n((0,n.S)(e)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){this.style!==t&&(this._style?.off("change",this._onStyleChange,this),this._style=t,this._style?.on("change",this._onStyleChange,this),this._onStyleChange())}set maxAnisotropy(t){this._style.maxAnisotropy=t}get maxAnisotropy(){return this._style.maxAnisotropy}get addressMode(){return this._style.addressMode}set addressMode(t){this._style.addressMode=t}get repeatMode(){return this._style.addressMode}set repeatMode(t){this._style.addressMode=t}get magFilter(){return this._style.magFilter}set magFilter(t){this._style.magFilter=t}get minFilter(){return this._style.minFilter}set minFilter(t){this._style.minFilter=t}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(t){this._style.mipmapFilter=t}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(t){this._style.lodMinClamp=t}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(t){this._style.lodMaxClamp=t}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const t=this._resolution;if(this.resize(this.resourceWidth/t,this.resourceHeight/t))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){this._resourceId=(0,o.L)("resource"),this.emit("change",this),this.emit("unload",this)}get resourceWidth(){const{resource:t}=this;return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}get resourceHeight(){const{resource:t}=this;return t.naturalHeight||t.videoHeight||t.displayHeight||t.height}get resolution(){return this._resolution}set resolution(t){this._resolution!==t&&(this._resolution=t,this.width=this.pixelWidth/t,this.height=this.pixelHeight/t)}resize(t,e,r){r||(r=this._resolution),t||(t=this.width),e||(e=this.height);const s=Math.round(t*r),i=Math.round(e*r);return this.width=s/r,this.height=i/r,this._resolution=r,(this.pixelWidth!==s||this.pixelHeight!==i)&&(this._refreshPOT(),this.pixelWidth=s,this.pixelHeight=i,this.emit("resize",this),this._resourceId=(0,o.L)("resource"),this.emit("change",this),!0)}updateMipmaps(){this.autoGenerateMipmaps&&this.mipLevelCount>1&&this.emit("updateMipmaps",this)}set wrapMode(t){this._style.wrapMode=t}get wrapMode(){return this._style.wrapMode}set scaleMode(t){this._style.scaleMode=t}get scaleMode(){return this._style.scaleMode}_refreshPOT(){this.isPowerOfTwo=(0,i.f3)(this.pixelWidth)&&(0,i.f3)(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};l.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let h=l},4364:(t,e,r)=>{"use strict";function s(t,e){return`\n for (let i = 0; i < ${t*e}; i++) {\n data[offset + (((i / ${t})|0) * 4) + (i % ${t})] = v[i];\n }\n `}r.d(e,{_:()=>n,g:()=>i});const i={f32:"\n data[offset] = v;",i32:"\n dataInt32[offset] = v;","vec2<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];","vec3<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 2] = v[2];","vec4<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 2] = v[2];\n data[offset + 3] = v[3];","vec2<i32>":"\n dataInt32[offset] = v[0];\n dataInt32[offset + 1] = v[1];","vec3<i32>":"\n dataInt32[offset] = v[0];\n dataInt32[offset + 1] = v[1];\n dataInt32[offset + 2] = v[2];","vec4<i32>":"\n dataInt32[offset] = v[0];\n dataInt32[offset + 1] = v[1];\n dataInt32[offset + 2] = v[2];\n dataInt32[offset + 3] = v[3];","mat2x2<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 4] = v[2];\n data[offset + 5] = v[3];","mat3x3<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 2] = v[2];\n data[offset + 4] = v[3];\n data[offset + 5] = v[4];\n data[offset + 6] = v[5];\n data[offset + 8] = v[6];\n data[offset + 9] = v[7];\n data[offset + 10] = v[8];","mat4x4<f32>":"\n for (let i = 0; i < 16; i++) {\n data[offset + i] = v[i];\n }","mat3x2<f32>":s(3,2),"mat4x2<f32>":s(4,2),"mat2x3<f32>":s(2,3),"mat4x3<f32>":s(4,3),"mat2x4<f32>":s(2,4),"mat3x4<f32>":s(3,4)},n={...i,"mat2x2<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 2] = v[2];\n data[offset + 3] = v[3];\n "}},4386:(t,e,r)=>{"use strict";r.d(e,{T:()=>Z});var s=r(4872),i=r(6675),n=r(5199),o=r(59),a=r(9739),l=r(9375),h=r(4696),c=r(6170),u=r(7694),d=r(6929),p=r(9390);class f{constructor(t=0,e=0,r=0){this.type="circle",this.x=t,this.y=e,this.radius=r}clone(){return new f(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const r=this.radius*this.radius;let s=this.x-t,i=this.y-e;return s*=s,i*=i,s+i<=r}strokeContains(t,e,r,s=.5){if(0===this.radius)return!1;const i=this.x-t,n=this.y-e,o=this.radius,a=(1-s)*r,l=Math.sqrt(i*i+n*n);return l<=o+a&&l>o-(r-a)}getBounds(t){return t||(t=new p.M),t.x=this.x-this.radius,t.y=this.y-this.radius,t.width=2*this.radius,t.height=2*this.radius,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.radius=t.radius,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`}}class g{constructor(t=0,e=0,r=0,s=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=r,this.halfHeight=s}clone(){return new g(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let r=(t-this.x)/this.halfWidth,s=(e-this.y)/this.halfHeight;return r*=r,s*=s,r+s<=1}strokeContains(t,e,r,s=.5){const{halfWidth:i,halfHeight:n}=this;if(i<=0||n<=0)return!1;const o=r*(1-s),a=r-o,l=i-a,h=n-a,c=i+o,u=n+o,d=t-this.x,p=e-this.y;return d*d/(l*l)+p*p/(h*h)>1&&d*d/(c*c)+p*p/(u*u)<=1}getBounds(t){return t||(t=new p.M),t.x=this.x-this.halfWidth,t.y=this.y-this.halfHeight,t.width=2*this.halfWidth,t.height=2*this.halfHeight,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.halfWidth=t.halfWidth,this.halfHeight=t.halfHeight,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:Ellipse x=${this.x} y=${this.y} halfWidth=${this.halfWidth} halfHeight=${this.halfHeight}]`}}function m(t,e,r,s,i,n){const o=i-r,a=n-s,l=o*o+a*a;let h,c,u=-1;0!==l&&(u=((t-r)*o+(e-s)*a)/l),u<0?(h=r,c=s):u>1?(h=i,c=n):(h=r+u*o,c=s+u*a);const d=t-h,p=e-c;return d*d+p*p}class x{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if("number"!=typeof e[0]){const t=[];for(let r=0,s=e.length;r<s;r++)t.push(e[r].x,e[r].y);e=t}this.points=e,this.closePath=!0}isClockwise(){let t=0;const e=this.points,r=e.length;for(let s=0;s<r;s+=2){const i=e[s],n=e[s+1];t+=(e[(s+2)%r]-i)*(e[(s+3)%r]+n)}return t<0}containsPolygon(t){const e=this.getBounds(void 0),r=t.getBounds(void 0);if(!e.containsRect(r))return!1;const s=t.points;for(let t=0;t<s.length;t+=2){const e=s[t],r=s[t+1];if(!this.contains(e,r))return!1}return!0}clone(){const t=this.points.slice(),e=new x(t);return e.closePath=this.closePath,e}contains(t,e){let r=!1;const s=this.points.length/2;for(let i=0,n=s-1;i<s;n=i++){const s=this.points[2*i],o=this.points[2*i+1],a=this.points[2*n],l=this.points[2*n+1];o>e!=l>e&&t<(e-o)/(l-o)*(a-s)+s&&(r=!r)}return r}strokeContains(t,e,r,s=.5){const i=r*r,n=i*(1-s),o=i-n,{points:a}=this,l=a.length-(this.closePath?0:2);for(let r=0;r<l;r+=2){const s=a[r],i=a[r+1],l=a[(r+2)%a.length],h=a[(r+3)%a.length];if(m(t,e,s,i,l,h)<=(Math.sign((l-s)*(e-i)-(h-i)*(t-s))<0?o:n))return!0}return!1}getBounds(t){t||(t=new p.M);const e=this.points;let r=1/0,s=-1/0,i=1/0,n=-1/0;for(let t=0,o=e.length;t<o;t+=2){const o=e[t],a=e[t+1];r=o<r?o:r,s=o>s?o:s,i=a<i?a:i,n=a>n?a:n}return t.x=r,t.width=s-r,t.y=i,t.height=n-i,t}copyFrom(t){return this.points=t.points.slice(),this.closePath=t.closePath,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:PolygoncloseStroke=${this.closePath}points=${this.points.reduce((t,e)=>`${t}, ${e}`,"")}]`}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return(0,h.t6)("8.11.0","Polygon.lastX is deprecated, please use Polygon.lastX instead."),this.points[this.points.length-2]}get y(){return(0,h.t6)("8.11.0","Polygon.y is deprecated, please use Polygon.lastY instead."),this.points[this.points.length-1]}get startX(){return this.points[0]}get startY(){return this.points[1]}}const _=(t,e,r,s,i,n,o)=>{const a=t-r,l=e-s,h=Math.sqrt(a*a+l*l);return h>=i-n&&h<=i+o};class y{constructor(t=0,e=0,r=0,s=0,i=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=r,this.height=s,this.radius=i}getBounds(t){return t||(t=new p.M),t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new y(this.x,this.y,this.width,this.height,this.radius)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const r=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+r&&e<=this.y+this.height-r||t>=this.x+r&&t<=this.x+this.width-r)return!0;let s=t-(this.x+r),i=e-(this.y+r);const n=r*r;if(s*s+i*i<=n)return!0;if(s=t-(this.x+this.width-r),s*s+i*i<=n)return!0;if(i=e-(this.y+this.height-r),s*s+i*i<=n)return!0;if(s=t-(this.x+r),s*s+i*i<=n)return!0}return!1}strokeContains(t,e,r,s=.5){const{x:i,y:n,width:o,height:a,radius:l}=this,h=r*(1-s),c=r-h,u=i+l,d=n+l,p=i+o,f=n+a;return(t>=i-h&&t<=i+c||t>=p-c&&t<=p+h)&&e>=d&&e<=d+(a-2*l)||(e>=n-h&&e<=n+c||e>=f-c&&e<=f+h)&&t>=u&&t<=u+(o-2*l)||t<u&&e<d&&_(t,e,u,d,l,c,h)||t>p-l&&e<d&&_(t,e,p-l,d,l,c,h)||t>p-l&&e>f-l&&_(t,e,p-l,f-l,l,c,h)||t<u&&e>f-l&&_(t,e,u,f-l,l,c,h)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}var v=r(6364);const b=1.1920929e-7;function w(t,e,r,s,i,n,o,a,l,h){let c=(1-Math.min(.99,Math.max(0,h??v.GH.defaultOptions.bezierSmoothness)))/1;return c*=c,function(t,e,r,s,i,n,o,a,l,h){T(t,e,r,s,i,n,o,a,l,h,0),l.push(o,a)}(e,r,s,i,n,o,a,l,t,c),t}function T(t,e,r,s,i,n,o,a,l,h,c){if(c>8)return;Math.PI;const u=(t+r)/2,d=(e+s)/2,p=(r+i)/2,f=(s+n)/2,g=(i+o)/2,m=(n+a)/2,x=(u+p)/2,_=(d+f)/2,y=(p+g)/2,v=(f+m)/2,w=(x+y)/2,S=(_+v)/2;if(c>0){let c=o-t,u=a-e;const d=Math.abs((r-o)*u-(s-a)*c),p=Math.abs((i-o)*u-(n-a)*c);if(d>b&&p>b){if((d+p)*(d+p)<=h*(c*c+u*u))return void l.push(w,S)}else if(d>b){if(d*d<=h*(c*c+u*u))return void l.push(w,S)}else if(p>b){if(p*p<=h*(c*c+u*u))return void l.push(w,S)}else if(c=w-(t+o)/2,u=S-(e+a)/2,c*c+u*u<=h)return void l.push(w,S)}T(t,e,u,d,x,_,w,S,l,h,c+1),T(w,S,y,v,g,m,o,a,l,h,c+1)}function S(t,e,r,s,i,n,o,a){let l=(1-Math.min(.99,Math.max(0,a??v.GH.defaultOptions.bezierSmoothness)))/1;return l*=l,function(t,e,r,s,i,n,o,a){A(o,t,e,r,s,i,n,a,0),o.push(i,n)}(e,r,s,i,n,o,t,l),t}function A(t,e,r,s,i,n,o,a,l){if(l>8)return;Math.PI;const h=(e+s)/2,c=(r+i)/2,u=(s+n)/2,d=(i+o)/2,p=(h+u)/2,f=(c+d)/2;let g=n-e,m=o-r;const x=Math.abs((s-n)*m-(i-o)*g);if(x>1.1920929e-7){if(x*x<=a*(g*g+m*m))return void t.push(p,f)}else if(g=p-(e+n)/2,m=f-(r+o)/2,g*g+m*m<=a)return void t.push(p,f);A(t,e,r,h,c,p,f,a,l+1),A(t,p,f,u,d,n,o,a,l+1)}function C(t,e,r,s,i,n,o,a){let l=Math.abs(i-n);(!o&&i>n||o&&n>i)&&(l=2*Math.PI-l),a||(a=Math.max(6,Math.floor(6*Math.pow(s,1/3)*(l/Math.PI))));let h=l/(a=Math.max(a,3)),c=i;h*=o?-1:1;for(let i=0;i<a+1;i++){const i=e+Math.cos(c)*s,n=r+Math.sin(c)*s;t.push(i,n),c+=h}}const P=2*Math.PI,M={centerX:0,centerY:0,ang1:0,ang2:0},E=({x:t,y:e},r,s,i,n,o,a,l)=>{const h=i*(t*=r)-n*(e*=s),c=n*t+i*e;return l.x=h+o,l.y=c+a,l};function R(t,e){const r=-1.5707963267948966===e?-.551915024494:4/3*Math.tan(e/4),s=1.5707963267948966===e?.551915024494:r,i=Math.cos(t),n=Math.sin(t),o=Math.cos(t+e),a=Math.sin(t+e);return[{x:i-n*s,y:n+i*s},{x:o+a*s,y:a-o*s},{x:o,y:a}]}const k=(t,e,r,s)=>{let i=t*r+e*s;return i>1&&(i=1),i<-1&&(i=-1),(t*s-e*r<0?-1:1)*Math.acos(i)};const B=new p.M;class I{constructor(t){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new c.c,this._graphicsPath2D=t,this.signed=t.checkForHoles}moveTo(t,e){return this.startPoly(t,e),this}lineTo(t,e){this._ensurePoly();const r=this._currentPoly.points,s=r[r.length-2],i=r[r.length-1];return s===t&&i===e||r.push(t,e),this}arc(t,e,r,s,i,n){return this._ensurePoly(!1),C(this._currentPoly.points,t,e,r,s,i,n),this}arcTo(t,e,r,s,i){return this._ensurePoly(),function(t,e,r,s,i,n){const o=t[t.length-2],a=t[t.length-1]-r,l=o-e,h=i-r,c=s-e,u=Math.abs(a*c-l*h);if(u<1e-8||0===n)return void(t[t.length-2]===e&&t[t.length-1]===r||t.push(e,r));const d=a*a+l*l,p=h*h+c*c,f=a*h+l*c,g=n*Math.sqrt(d)/u,m=n*Math.sqrt(p)/u,x=g*f/d,_=m*f/p,y=g*c+m*l,v=g*h+m*a,b=l*(m+x),w=a*(m+x),T=c*(g+_),S=h*(g+_);C(t,y+e,v+r,n,Math.atan2(w-v,b-y),Math.atan2(S-v,T-y),l*h>c*a)}(this._currentPoly.points,t,e,r,s,i),this}arcToSvg(t,e,r,s,i,n,o){return function(t,e,r,s,i,n,o,a=0,l=0,h=0){if(0===n||0===o)return;const c=Math.sin(a*P/360),u=Math.cos(a*P/360),d=u*(e-s)/2+c*(r-i)/2,p=-c*(e-s)/2+u*(r-i)/2;if(0===d&&0===p)return;n=Math.abs(n),o=Math.abs(o);const f=Math.pow(d,2)/Math.pow(n,2)+Math.pow(p,2)/Math.pow(o,2);f>1&&(n*=Math.sqrt(f),o*=Math.sqrt(f)),((t,e,r,s,i,n,o,a,l,h,c,u,d)=>{const p=Math.pow(i,2),f=Math.pow(n,2),g=Math.pow(c,2),m=Math.pow(u,2);let x=p*f-p*m-f*g;x<0&&(x=0),x/=p*m+f*g,x=Math.sqrt(x)*(o===a?-1:1);const _=x*i/n*u,y=x*-n/i*c,v=h*_-l*y+(t+r)/2,b=l*_+h*y+(e+s)/2,w=(c-_)/i,T=(u-y)/n,S=(-c-_)/i,A=(-u-y)/n,C=k(1,0,w,T);let M=k(w,T,S,A);0===a&&M>0&&(M-=P),1===a&&M<0&&(M+=P),d.centerX=v,d.centerY=b,d.ang1=C,d.ang2=M})(e,r,s,i,n,o,l,h,c,u,d,p,M);let{ang1:g,ang2:m}=M;const{centerX:x,centerY:_}=M;let y=Math.abs(m)/(P/4);Math.abs(1-y)<1e-7&&(y=1);const v=Math.max(Math.ceil(y),1);m/=v;let b=t[t.length-2],T=t[t.length-1];const S={x:0,y:0};for(let e=0;e<v;e++){const e=R(g,m),{x:r,y:s}=E(e[0],n,o,u,c,x,_,S),{x:i,y:a}=E(e[1],n,o,u,c,x,_,S),{x:l,y:h}=E(e[2],n,o,u,c,x,_,S);w(t,b,T,r,s,i,a,l,h),b=l,T=h,g+=m}}(this._currentPoly.points,this._currentPoly.lastX,this._currentPoly.lastY,n,o,t,e,r,s,i),this}bezierCurveTo(t,e,r,s,i,n,o){this._ensurePoly();const a=this._currentPoly;return w(this._currentPoly.points,a.lastX,a.lastY,t,e,r,s,i,n,o),this}quadraticCurveTo(t,e,r,s,i){this._ensurePoly();const n=this._currentPoly;return S(this._currentPoly.points,n.lastX,n.lastY,t,e,r,s,i),this}closePath(){return this.endPoly(!0),this}addPath(t,e){this.endPoly(),e&&!e.isIdentity()&&(t=t.clone(!0)).transform(e);const r=this.shapePrimitives,s=r.length;for(let e=0;e<t.instructions.length;e++){const r=t.instructions[e];this[r.action](...r.data)}if(t.checkForHoles&&r.length-s>1){let t=null;for(let e=s;e<r.length;e++){const s=r[e];if("polygon"===s.shape.type){const i=s.shape,n=t?.shape;n&&n.containsPolygon(i)?(t.holes||(t.holes=[]),t.holes.push(s),r.copyWithin(e,e+1),r.length--,e--):t=s}}}return this}finish(t=!1){this.endPoly(t)}rect(t,e,r,s,i){return this.drawShape(new p.M(t,e,r,s),i),this}circle(t,e,r,s){return this.drawShape(new f(t,e,r),s),this}poly(t,e,r){const s=new x(t);return s.closePath=e,this.drawShape(s,r),this}regularPoly(t,e,r,s,i=0,n){s=Math.max(0|s,3);const o=-1*Math.PI/2+i,a=2*Math.PI/s,l=[];for(let i=0;i<s;i++){const s=o-i*a;l.push(t+r*Math.cos(s),e+r*Math.sin(s))}return this.poly(l,!0,n),this}roundPoly(t,e,r,s,i,n=0,o){if(s=Math.max(0|s,3),i<=0)return this.regularPoly(t,e,r,s,n);const a=r*Math.sin(Math.PI/s)-.001;i=Math.min(i,a);const l=-1*Math.PI/2+n,h=2*Math.PI/s,c=(s-2)*Math.PI/s/2;for(let n=0;n<s;n++){const s=n*h+l,a=t+r*Math.cos(s),u=e+r*Math.sin(s),d=s+Math.PI+c,p=s-Math.PI-c,f=a+i*Math.cos(d),g=u+i*Math.sin(d),m=a+i*Math.cos(p),x=u+i*Math.sin(p);0===n?this.moveTo(f,g):this.lineTo(f,g),this.quadraticCurveTo(a,u,m,x,o)}return this.closePath()}roundShape(t,e,r=!1,s){return t.length<3?this:(r?function(t,e,r,s){const i=(t,e)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),n=(t,e,r)=>({x:t.x+(e.x-t.x)*r,y:t.y+(e.y-t.y)*r}),o=e.length;for(let a=0;a<o;a++){const l=e[(a+1)%o],h=l.radius??r;if(h<=0){0===a?t.moveTo(l.x,l.y):t.lineTo(l.x,l.y);continue}const c=e[a],u=e[(a+2)%o],d=i(c,l);let p;p=d<1e-4?l:n(l,c,Math.min(d/2,h)/d);const f=i(u,l);let g;g=f<1e-4?l:n(l,u,Math.min(f/2,h)/f),0===a?t.moveTo(p.x,p.y):t.lineTo(p.x,p.y),t.quadraticCurveTo(l.x,l.y,g.x,g.y,s)}}(this,t,e,s):function(t,e,r){const s=(t,e)=>{const r=e.x-t.x,s=e.y-t.y,i=Math.sqrt(r*r+s*s);return{len:i,nx:r/i,ny:s/i}},i=(e,r)=>{0===e?t.moveTo(r.x,r.y):t.lineTo(r.x,r.y)};let n=e[e.length-1];for(let o=0;o<e.length;o++){const a=e[o%e.length],l=a.radius??r;if(l<=0){i(o,a),n=a;continue}const h=e[(o+1)%e.length],c=s(a,n),u=s(a,h);if(c.len<1e-4||u.len<1e-4){i(o,a),n=a;continue}let d=Math.asin(c.nx*u.ny-c.ny*u.nx),p=1,f=!1;c.nx*u.nx-c.ny*-u.ny<0?d<0?d=Math.PI+d:(d=Math.PI-d,p=-1,f=!0):d>0&&(p=-1,f=!0);const g=d/2;let m,x=Math.abs(Math.cos(g)*l/Math.sin(g));x>Math.min(c.len/2,u.len/2)?(x=Math.min(c.len/2,u.len/2),m=Math.abs(x*Math.sin(g)/Math.cos(g))):m=l;const _=a.x+u.nx*x+-u.ny*m*p,y=a.y+u.ny*x+u.nx*m*p,v=Math.atan2(c.ny,c.nx)+Math.PI/2*p,b=Math.atan2(u.ny,u.nx)-Math.PI/2*p;0===o&&t.moveTo(_+Math.cos(v)*m,y+Math.sin(v)*m),t.arc(_,y,m,v,b,f),n=a}}(this,t,e),this.closePath())}filletRect(t,e,r,s,i){if(0===i)return this.rect(t,e,r,s);const n=Math.min(r,s)/2,o=Math.min(n,Math.max(-n,i)),a=t+r,l=e+s,h=o<0?-o:0,c=Math.abs(o);return this.moveTo(t,e+c).arcTo(t+h,e+h,t+c,e,c).lineTo(a-c,e).arcTo(a-h,e+h,a,e+c,c).lineTo(a,l-c).arcTo(a-h,l-h,t+r-c,l,c).lineTo(t+c,l).arcTo(t+h,l-h,t,l-c,c).closePath()}chamferRect(t,e,r,s,i,n){if(i<=0)return this.rect(t,e,r,s);const o=Math.min(i,Math.min(r,s)/2),a=t+r,l=e+s,h=[t+o,e,a-o,e,a,e+o,a,l-o,a-o,l,t+o,l,t,l-o,t,e+o];for(let t=h.length-1;t>=2;t-=2)h[t]===h[t-2]&&h[t-1]===h[t-3]&&h.splice(t-1,2);return this.poly(h,!0,n)}ellipse(t,e,r,s,i){return this.drawShape(new g(t,e,r,s),i),this}roundRect(t,e,r,s,i,n){return this.drawShape(new y(t,e,r,s,i),n),this}drawShape(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this}startPoly(t,e){let r=this._currentPoly;return r&&this.endPoly(),r=new x,r.points.push(t,e),this._currentPoly=r,this}endPoly(t=!1){const e=this._currentPoly;return e&&e.points.length>2&&(e.closePath=t,this.shapePrimitives.push({shape:e})),this._currentPoly=null,this}_ensurePoly(t=!0){if(!this._currentPoly&&(this._currentPoly=new x,t)){const t=this.shapePrimitives[this.shapePrimitives.length-1];if(t){let e=t.shape.x,r=t.shape.y;if(t.transform&&!t.transform.isIdentity()){const s=t.transform,i=e;e=s.a*e+s.c*r+s.tx,r=s.b*i+s.d*r+s.ty}this._currentPoly.points.push(e,r)}else this._currentPoly.points.push(0,0)}}buildPath(){const t=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let e=0;e<t.instructions.length;e++){const r=t.instructions[e];this[r.action](...r.data)}this.finish()}get bounds(){const t=this._bounds;t.clear();const e=this.shapePrimitives;for(let r=0;r<e.length;r++){const s=e[r],i=s.shape.getBounds(B);s.transform?t.addRect(i,s.transform):t.addRect(i)}return t}}class G{constructor(t,e=!1){this.instructions=[],this.uid=(0,l.L)("graphicsPath"),this._dirty=!0,this.checkForHoles=e,"string"==typeof t?function(t,e){const r=d(t),s=[];let i=null,n=0,o=0;for(let t=0;t<r.length;t++){const a=r[t],l=a[0],h=a;switch(l){case"M":n=h[1],o=h[2],e.moveTo(n,o);break;case"m":n+=h[1],o+=h[2],e.moveTo(n,o);break;case"H":n=h[1],e.lineTo(n,o);break;case"h":n+=h[1],e.lineTo(n,o);break;case"V":o=h[1],e.lineTo(n,o);break;case"v":o+=h[1],e.lineTo(n,o);break;case"L":n=h[1],o=h[2],e.lineTo(n,o);break;case"l":n+=h[1],o+=h[2],e.lineTo(n,o);break;case"C":n=h[5],o=h[6],e.bezierCurveTo(h[1],h[2],h[3],h[4],n,o);break;case"c":e.bezierCurveTo(n+h[1],o+h[2],n+h[3],o+h[4],n+h[5],o+h[6]),n+=h[5],o+=h[6];break;case"S":n=h[3],o=h[4],e.bezierCurveToShort(h[1],h[2],n,o);break;case"s":e.bezierCurveToShort(n+h[1],o+h[2],n+h[3],o+h[4]),n+=h[3],o+=h[4];break;case"Q":n=h[3],o=h[4],e.quadraticCurveTo(h[1],h[2],n,o);break;case"q":e.quadraticCurveTo(n+h[1],o+h[2],n+h[3],o+h[4]),n+=h[3],o+=h[4];break;case"T":n=h[1],o=h[2],e.quadraticCurveToShort(n,o);break;case"t":n+=h[1],o+=h[2],e.quadraticCurveToShort(n,o);break;case"A":n=h[6],o=h[7],e.arcToSvg(h[1],h[2],h[3],h[4],h[5],n,o);break;case"a":n+=h[6],o+=h[7],e.arcToSvg(h[1],h[2],h[3],h[4],h[5],n,o);break;case"Z":case"z":e.closePath(),s.length>0&&(i=s.pop(),i?(n=i.startX,o=i.startY):(n=0,o=0)),i=null;break;default:(0,u.R)(`Unknown SVG path command: ${l}`)}"Z"!==l&&"z"!==l&&null===i&&(i={startX:n,startY:o},s.push(i))}}(t,this):this.instructions=t?.slice()??[]}get shapePath(){return this._shapePath||(this._shapePath=new I(this)),this._dirty&&(this._dirty=!1,this._shapePath.buildPath()),this._shapePath}addPath(t,e){return t=t.clone(),this.instructions.push({action:"addPath",data:[t,e]}),this._dirty=!0,this}arc(...t){return this.instructions.push({action:"arc",data:t}),this._dirty=!0,this}arcTo(...t){return this.instructions.push({action:"arcTo",data:t}),this._dirty=!0,this}arcToSvg(...t){return this.instructions.push({action:"arcToSvg",data:t}),this._dirty=!0,this}bezierCurveTo(...t){return this.instructions.push({action:"bezierCurveTo",data:t}),this._dirty=!0,this}bezierCurveToShort(t,e,r,s,i){const n=this.instructions[this.instructions.length-1],a=this.getLastPoint(o.b.shared);let l=0,h=0;if(n&&"bezierCurveTo"===n.action){l=n.data[2],h=n.data[3];const t=a.x,e=a.y;l=t+(t-l),h=e+(e-h)}else l=a.x,h=a.y;return this.instructions.push({action:"bezierCurveTo",data:[l,h,t,e,r,s,i]}),this._dirty=!0,this}closePath(){return this.instructions.push({action:"closePath",data:[]}),this._dirty=!0,this}ellipse(...t){return this.instructions.push({action:"ellipse",data:t}),this._dirty=!0,this}lineTo(...t){return this.instructions.push({action:"lineTo",data:t}),this._dirty=!0,this}moveTo(...t){return this.instructions.push({action:"moveTo",data:t}),this}quadraticCurveTo(...t){return this.instructions.push({action:"quadraticCurveTo",data:t}),this._dirty=!0,this}quadraticCurveToShort(t,e,r){const s=this.instructions[this.instructions.length-1],i=this.getLastPoint(o.b.shared);let n=0,a=0;if(s&&"quadraticCurveTo"===s.action){n=s.data[0],a=s.data[1];const t=i.x,e=i.y;n=t+(t-n),a=e+(e-a)}else n=i.x,a=i.y;return this.instructions.push({action:"quadraticCurveTo",data:[n,a,t,e,r]}),this._dirty=!0,this}rect(t,e,r,s,i){return this.instructions.push({action:"rect",data:[t,e,r,s,i]}),this._dirty=!0,this}circle(t,e,r,s){return this.instructions.push({action:"circle",data:[t,e,r,s]}),this._dirty=!0,this}roundRect(...t){return this.instructions.push({action:"roundRect",data:t}),this._dirty=!0,this}poly(...t){return this.instructions.push({action:"poly",data:t}),this._dirty=!0,this}regularPoly(...t){return this.instructions.push({action:"regularPoly",data:t}),this._dirty=!0,this}roundPoly(...t){return this.instructions.push({action:"roundPoly",data:t}),this._dirty=!0,this}roundShape(...t){return this.instructions.push({action:"roundShape",data:t}),this._dirty=!0,this}filletRect(...t){return this.instructions.push({action:"filletRect",data:t}),this._dirty=!0,this}chamferRect(...t){return this.instructions.push({action:"chamferRect",data:t}),this._dirty=!0,this}star(t,e,r,s,i,n,o){i||(i=s/2);const a=-1*Math.PI/2+n,l=2*r,h=2*Math.PI/l,c=[];for(let r=0;r<l;r++){const n=r%2?i:s,o=r*h+a;c.push(t+n*Math.cos(o),e+n*Math.sin(o))}return this.poly(c,!0,o),this}clone(t=!1){const e=new G;if(e.checkForHoles=this.checkForHoles,t)for(let t=0;t<this.instructions.length;t++){const r=this.instructions[t];e.instructions.push({action:r.action,data:r.data.slice()})}else e.instructions=this.instructions.slice();return e}clear(){return this.instructions.length=0,this._dirty=!0,this}transform(t){if(t.isIdentity())return this;const e=t.a,r=t.b,s=t.c,i=t.d,n=t.tx,o=t.ty;let a=0,l=0,h=0,c=0,d=0,p=0,f=0,g=0;for(let m=0;m<this.instructions.length;m++){const x=this.instructions[m],_=x.data;switch(x.action){case"moveTo":case"lineTo":a=_[0],l=_[1],_[0]=e*a+s*l+n,_[1]=r*a+i*l+o;break;case"bezierCurveTo":h=_[0],c=_[1],d=_[2],p=_[3],a=_[4],l=_[5],_[0]=e*h+s*c+n,_[1]=r*h+i*c+o,_[2]=e*d+s*p+n,_[3]=r*d+i*p+o,_[4]=e*a+s*l+n,_[5]=r*a+i*l+o;break;case"quadraticCurveTo":h=_[0],c=_[1],a=_[2],l=_[3],_[0]=e*h+s*c+n,_[1]=r*h+i*c+o,_[2]=e*a+s*l+n,_[3]=r*a+i*l+o;break;case"arcToSvg":a=_[5],l=_[6],f=_[0],g=_[1],_[0]=e*f+s*g,_[1]=r*f+i*g,_[5]=e*a+s*l+n,_[6]=r*a+i*l+o;break;case"circle":_[4]=F(_[3],t);break;case"rect":_[4]=F(_[4],t);break;case"ellipse":_[8]=F(_[8],t);break;case"roundRect":_[5]=F(_[5],t);break;case"addPath":_[0].transform(t);break;case"poly":_[2]=F(_[2],t);break;default:(0,u.R)("unknown transform action",x.action)}}return this._dirty=!0,this}get bounds(){return this.shapePath.bounds}getLastPoint(t){let e=this.instructions.length-1,r=this.instructions[e];if(!r)return t.x=0,t.y=0,t;for(;"closePath"===r.action;){if(e--,e<0)return t.x=0,t.y=0,t;r=this.instructions[e]}switch(r.action){case"moveTo":case"lineTo":t.x=r.data[0],t.y=r.data[1];break;case"quadraticCurveTo":t.x=r.data[2],t.y=r.data[3];break;case"bezierCurveTo":t.x=r.data[4],t.y=r.data[5];break;case"arc":case"arcToSvg":t.x=r.data[5],t.y=r.data[6];break;case"addPath":r.data[0].getLastPoint(t)}return t}}function F(t,e){return t?t.prepend(e):e.clone()}var O=r(6406);function D(t,e,r){const s=t.getAttribute(e);return s?Number(s):r}function U(t){const e=D(t,"x1",0),r=D(t,"y1",0),s=D(t,"x2",1),n=D(t,"y2",0),o=t.getAttribute("gradientUnits")||"objectBoundingBox",a=new O._(e,r,s,n,"objectBoundingBox"===o?"local":"global");for(let e=0;e<t.children.length;e++){const r=t.children[e],s=D(r,"offset",0),n=i.Q.shared.setValue(r.getAttribute("stop-color")).toNumber();a.addColorStop(s,n)}return a}function L(t){return(0,u.R)("[SVG Parser] Radial gradients are not yet supported"),new O._(0,0,1,0)}function N(t){const e=t.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);return e?e[1]:""}const z={fill:{type:"paint",default:0},"fill-opacity":{type:"number",default:1},stroke:{type:"paint",default:0},"stroke-width":{type:"number",default:1},"stroke-opacity":{type:"number",default:1},"stroke-linecap":{type:"string",default:"butt"},"stroke-linejoin":{type:"string",default:"miter"},"stroke-miterlimit":{type:"number",default:10},"stroke-dasharray":{type:"string",default:"none"},"stroke-dashoffset":{type:"number",default:0},opacity:{type:"number",default:1}};function W(t,e){const r=t.getAttribute("style"),s={},i={},n={strokeStyle:s,fillStyle:i,useFill:!1,useStroke:!1};for(const r in z){const s=t.getAttribute(r);s&&H(e,n,r,s.trim())}if(r){const t=r.split(";");for(let r=0;r<t.length;r++){const s=t[r].trim(),[i,o]=s.split(":");z[i]&&H(e,n,i,o.trim())}}return{strokeStyle:n.useStroke?s:null,fillStyle:n.useFill?i:null,useFill:n.useFill,useStroke:n.useStroke}}function H(t,e,r,s){switch(r){case"stroke":if("none"!==s){if(s.startsWith("url(")){const r=N(s);e.strokeStyle.fill=t.defs[r]}else e.strokeStyle.color=i.Q.shared.setValue(s).toNumber();e.useStroke=!0}break;case"stroke-width":e.strokeStyle.width=Number(s);break;case"fill":if("none"!==s){if(s.startsWith("url(")){const r=N(s);e.fillStyle.fill=t.defs[r]}else e.fillStyle.color=i.Q.shared.setValue(s).toNumber();e.useFill=!0}break;case"fill-opacity":e.fillStyle.alpha=Number(s);break;case"stroke-opacity":e.strokeStyle.alpha=Number(s);break;case"opacity":e.fillStyle.alpha=Number(s),e.strokeStyle.alpha=Number(s)}}function X(t){const e=t.match(/[-+]?[0-9]*\.?[0-9]+/g);if(!e||e.length<4)return 0;const r=e.map(Number),s=[],i=[];for(let t=0;t<r.length;t+=2)t+1<r.length&&(s.push(r[t]),i.push(r[t+1]));if(0===s.length||0===i.length)return 0;const n=Math.min(...s),o=Math.max(...s),a=Math.min(...i);return(o-n)*(Math.max(...i)-a)}function V(t,e){const r=new G(t,!1);for(const t of r.instructions)e.instructions.push(t)}function Y(t,e,r,s){const i=t.children,{fillStyle:n,strokeStyle:o}=W(t,e);n&&r?r={...r,...n}:n&&(r=n),o&&s?s={...s,...o}:o&&(s=o);const a=!r&&!s;let l,h,c,d,p,f,g,m,x,_,y,v,b,w,T,S,A;switch(a&&(r={color:0}),t.nodeName.toLowerCase()){case"path":{w=t.getAttribute("d");const i=t.getAttribute("fill-rule"),n=w.split(/(?=[Mm])/).filter(t=>t.trim().length>0),o="evenodd"===i,a=n.length>1;if(o&&a){const t=n.map(t=>({path:t,area:X(t)}));t.sort((t,e)=>e.area-t.area);const i=n.length>3||!function(t){if(t.length<=2)return!0;const e=t.map(t=>t.area).sort((t,e)=>e-t),[r,s]=e,i=e[e.length-1];return!(r/s>3&&s/i<2)}(t);if(i)for(let i=0;i<t.length;i++){const n=t[i],o=0===i;e.context.beginPath();const a=new G(void 0,!0);V(n.path,a),e.context.path(a),o?(r&&e.context.fill(r),s&&e.context.stroke(s)):e.context.cut()}else for(let i=0;i<t.length;i++){const n=t[i],o=i%2==1;e.context.beginPath();const a=new G(void 0,!0);V(n.path,a),e.context.path(a),o?e.context.cut():(r&&e.context.fill(r),s&&e.context.stroke(s))}}else T=new G(w,!i||"evenodd"===i),e.context.path(T),r&&e.context.fill(r),s&&e.context.stroke(s);break}case"circle":g=D(t,"cx",0),m=D(t,"cy",0),x=D(t,"r",0),e.context.ellipse(g,m,x,x),r&&e.context.fill(r),s&&e.context.stroke(s);break;case"rect":l=D(t,"x",0),h=D(t,"y",0),S=D(t,"width",0),A=D(t,"height",0),_=D(t,"rx",0),y=D(t,"ry",0),_||y?e.context.roundRect(l,h,S,A,_||y):e.context.rect(l,h,S,A),r&&e.context.fill(r),s&&e.context.stroke(s);break;case"ellipse":g=D(t,"cx",0),m=D(t,"cy",0),_=D(t,"rx",0),y=D(t,"ry",0),e.context.beginPath(),e.context.ellipse(g,m,_,y),r&&e.context.fill(r),s&&e.context.stroke(s);break;case"line":c=D(t,"x1",0),d=D(t,"y1",0),p=D(t,"x2",0),f=D(t,"y2",0),e.context.beginPath(),e.context.moveTo(c,d),e.context.lineTo(p,f),s&&e.context.stroke(s);break;case"polygon":b=t.getAttribute("points"),v=b.match(/\d+/g).map(t=>parseInt(t,10)),e.context.poly(v,!0),r&&e.context.fill(r),s&&e.context.stroke(s);break;case"polyline":b=t.getAttribute("points"),v=b.match(/\d+/g).map(t=>parseInt(t,10)),e.context.poly(v,!1),s&&e.context.stroke(s);break;case"g":case"svg":break;default:(0,u.R)(`[SVG parser] <${t.nodeName}> elements unsupported`)}a&&(r=null);for(let t=0;t<i.length;t++)Y(i[t],e,r,s)}var j=r(5024);const $=new o.b,q=new n.u,K=class t extends s.A{constructor(){super(...arguments),this.uid=(0,l.L)("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this._activePath=new G,this._transform=new n.u,this._fillStyle={...t.defaultFillStyle},this._strokeStyle={...t.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new c.c,this._boundsDirty=!0}clone(){const e=new t;return e.batchMode=this.batchMode,e.instructions=this.instructions.slice(),e._activePath=this._activePath.clone(),e._transform=this._transform.clone(),e._fillStyle={...this._fillStyle},e._strokeStyle={...this._strokeStyle},e._stateStack=this._stateStack.slice(),e._bounds=this._bounds.clone(),e._boundsDirty=!0,e}get fillStyle(){return this._fillStyle}set fillStyle(e){this._fillStyle=(0,j.w)(e,t.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(e){this._strokeStyle=(0,j.T)(e,t.defaultStrokeStyle)}setFillStyle(e){return this._fillStyle=(0,j.w)(e,t.defaultFillStyle),this}setStrokeStyle(e){return this._strokeStyle=(0,j.w)(e,t.defaultStrokeStyle),this}texture(t,e,r,s,n,o){return this.instructions.push({action:"texture",data:{image:t,dx:r||0,dy:s||0,dw:n||t.frame.width,dh:o||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:e?i.Q.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new G,this}fill(e,r){let s;const i=this.instructions[this.instructions.length-1];return s=0===this._tick&&i&&"stroke"===i.action?i.data.path:this._activePath.clone(),s?(null!=e&&(void 0!==r&&"number"==typeof e&&((0,h.t6)(h.lj,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),e={color:e,alpha:r}),this._fillStyle=(0,j.w)(e,t.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:s}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:t,y:e}=this._activePath.getLastPoint(o.b.shared);this._activePath.clear(),this._activePath.moveTo(t,e)}stroke(e){let r;const s=this.instructions[this.instructions.length-1];return r=0===this._tick&&s&&"fill"===s.action?s.data.path:this._activePath.clone(),r?(null!=e&&(this._strokeStyle=(0,j.T)(e,t.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:r}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let t=0;t<2;t++){const e=this.instructions[this.instructions.length-1-t],r=this._activePath.clone();if(e&&("stroke"===e.action||"fill"===e.action)){if(!e.data.hole){e.data.hole=r;break}e.data.hole.addPath(r)}}return this._initNextPathLocation(),this}arc(t,e,r,s,i,n){this._tick++;const o=this._transform;return this._activePath.arc(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,r,s,i,n),this}arcTo(t,e,r,s,i){this._tick++;const n=this._transform;return this._activePath.arcTo(n.a*t+n.c*e+n.tx,n.b*t+n.d*e+n.ty,n.a*r+n.c*s+n.tx,n.b*r+n.d*s+n.ty,i),this}arcToSvg(t,e,r,s,i,n,o){this._tick++;const a=this._transform;return this._activePath.arcToSvg(t,e,r,s,i,a.a*n+a.c*o+a.tx,a.b*n+a.d*o+a.ty),this}bezierCurveTo(t,e,r,s,i,n,o){this._tick++;const a=this._transform;return this._activePath.bezierCurveTo(a.a*t+a.c*e+a.tx,a.b*t+a.d*e+a.ty,a.a*r+a.c*s+a.tx,a.b*r+a.d*s+a.ty,a.a*i+a.c*n+a.tx,a.b*i+a.d*n+a.ty,o),this}closePath(){return this._tick++,this._activePath?.closePath(),this}ellipse(t,e,r,s){return this._tick++,this._activePath.ellipse(t,e,r,s,this._transform.clone()),this}circle(t,e,r){return this._tick++,this._activePath.circle(t,e,r,this._transform.clone()),this}path(t){return this._tick++,this._activePath.addPath(t,this._transform.clone()),this}lineTo(t,e){this._tick++;const r=this._transform;return this._activePath.lineTo(r.a*t+r.c*e+r.tx,r.b*t+r.d*e+r.ty),this}moveTo(t,e){this._tick++;const r=this._transform,s=this._activePath.instructions,i=r.a*t+r.c*e+r.tx,n=r.b*t+r.d*e+r.ty;return 1===s.length&&"moveTo"===s[0].action?(s[0].data[0]=i,s[0].data[1]=n,this):(this._activePath.moveTo(i,n),this)}quadraticCurveTo(t,e,r,s,i){this._tick++;const n=this._transform;return this._activePath.quadraticCurveTo(n.a*t+n.c*e+n.tx,n.b*t+n.d*e+n.ty,n.a*r+n.c*s+n.tx,n.b*r+n.d*s+n.ty,i),this}rect(t,e,r,s){return this._tick++,this._activePath.rect(t,e,r,s,this._transform.clone()),this}roundRect(t,e,r,s,i){return this._tick++,this._activePath.roundRect(t,e,r,s,i,this._transform.clone()),this}poly(t,e){return this._tick++,this._activePath.poly(t,e,this._transform.clone()),this}regularPoly(t,e,r,s,i=0,n){return this._tick++,this._activePath.regularPoly(t,e,r,s,i,n),this}roundPoly(t,e,r,s,i,n){return this._tick++,this._activePath.roundPoly(t,e,r,s,i,n),this}roundShape(t,e,r,s){return this._tick++,this._activePath.roundShape(t,e,r,s),this}filletRect(t,e,r,s,i){return this._tick++,this._activePath.filletRect(t,e,r,s,i),this}chamferRect(t,e,r,s,i,n){return this._tick++,this._activePath.chamferRect(t,e,r,s,i,n),this}star(t,e,r,s,i=0,n=0){return this._tick++,this._activePath.star(t,e,r,s,i,n,this._transform.clone()),this}svg(t){return this._tick++,function(t,e){if("string"==typeof t){const e=document.createElement("div");e.innerHTML=t.trim(),t=e.querySelector("svg")}const r={context:e,defs:{},path:new G};!function(t,e){const r=t.querySelectorAll("defs");for(let t=0;t<r.length;t++){const s=r[t];for(let t=0;t<s.children.length;t++){const r=s.children[t];switch(r.nodeName.toLowerCase()){case"lineargradient":e.defs[r.id]=U(r);break;case"radialgradient":e.defs[r.id]=L()}}}}(t,r);const s=t.children,{fillStyle:i,strokeStyle:n}=W(t,r);for(let t=0;t<s.length;t++){const e=s[t];"defs"!==e.nodeName.toLowerCase()&&Y(e,r,i,n)}}(t,this),this}restore(){const t=this._stateStack.pop();return t&&(this._transform=t.transform,this._fillStyle=t.fillStyle,this._strokeStyle=t.strokeStyle),this}save(){return this._stateStack.push({transform:this._transform.clone(),fillStyle:{...this._fillStyle},strokeStyle:{...this._strokeStyle}}),this}getTransform(){return this._transform}resetTransform(){return this._transform.identity(),this}rotate(t){return this._transform.rotate(t),this}scale(t,e=t){return this._transform.scale(t,e),this}setTransform(t,e,r,s,i,o){return t instanceof n.u?(this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty),this):(this._transform.set(t,e,r,s,i,o),this)}transform(t,e,r,s,i,o){return t instanceof n.u?(this._transform.append(t),this):(q.set(t,e,r,s,i,o),this._transform.append(q),this)}translate(t,e=t){return this._transform.translate(t,e),this}clear(){return this._activePath.clear(),this.instructions.length=0,this.resetTransform(),this.onUpdate(),this}onUpdate(){this.dirty||(this.emit("update",this,16),this.dirty=!0,this._boundsDirty=!0)}get bounds(){if(!this._boundsDirty)return this._bounds;this._boundsDirty=!1;const t=this._bounds;t.clear();for(let e=0;e<this.instructions.length;e++){const r=this.instructions[e],s=r.action;if("fill"===s){const e=r.data;t.addBounds(e.path.bounds)}else if("texture"===s){const e=r.data;t.addFrame(e.dx,e.dy,e.dx+e.dw,e.dy+e.dh,e.transform)}if("stroke"===s){const e=r.data,s=e.style.alignment,i=e.style.width*(1-s),n=e.path.bounds;t.addFrame(n.minX-i,n.minY-i,n.maxX+i,n.maxY+i)}}return t}containsPoint(t){if(!this.bounds.containsPoint(t.x,t.y))return!1;const e=this.instructions;let r=!1;for(let s=0;s<e.length;s++){const i=e[s],n=i.data,o=n.path;if(!i.action||!o)continue;const a=n.style,l=o.shapePath.shapePrimitives;for(let e=0;e<l.length;e++){const s=l[e].shape;if(!a||!s)continue;const o=l[e].transform,h=o?o.applyInverse(t,$):t;if("fill"===i.action)r=s.contains(h.x,h.y);else{const t=a;r=s.strokeContains(h.x,h.y,t.width,t.alignment)}const c=n.hole;if(c){const t=c.shapePath?.shapePrimitives;if(t)for(let e=0;e<t.length;e++)t[e].shape.contains(h.x,h.y)&&(r=!1)}if(r)return!0}}return r}destroy(t=!1){if(this._stateStack.length=0,this._transform=null,this.emit("destroy",this),this.removeAllListeners(),"boolean"==typeof t?t:t?.texture){const e="boolean"==typeof t?t:t?.textureSource;this._fillStyle.texture&&(this._fillStyle.fill&&"uid"in this._fillStyle.fill?this._fillStyle.fill.destroy():this._fillStyle.texture.destroy(e)),this._strokeStyle.texture&&(this._strokeStyle.fill&&"uid"in this._strokeStyle.fill?this._strokeStyle.fill.destroy():this._strokeStyle.texture.destroy(e))}this._fillStyle=null,this._strokeStyle=null,this.instructions=null,this._activePath=null,this._bounds=null,this._stateStack=null,this.customShader=null,this._transform=null}};K.defaultFillStyle={color:16777215,alpha:1,texture:a.g.WHITE,matrix:null,fill:null,textureSpace:"local"},K.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:a.g.WHITE,matrix:null,fill:null,textureSpace:"local",pixelLine:!1};let Z=K},4403:(t,e,r)=>{"use strict";r.d(e,{a:()=>s});class s{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let t=0;t<this.filters.length;t++)this.filters[t].destroy();this.filters=null,this.filterArea=null}}},4404:(t,e,r)=>{"use strict";r.d(e,{J:()=>v});var s=r(1065),i=r(656),n=r(1579),o=r(9798),a=r(8337);const l=new Float32Array(1),h=new Uint32Array(1);class c extends a.V{constructor(){const t=new n.h({data:l,label:"attribute-batch-buffer",usage:o.S.VERTEX|o.S.COPY_DST,shrinkToFit:!1});super({attributes:{aPosition:{buffer:t,format:"float32x2",stride:24,offset:0},aUV:{buffer:t,format:"float32x2",stride:24,offset:8},aColor:{buffer:t,format:"unorm8x4",stride:24,offset:16},aTextureIdAndRound:{buffer:t,format:"uint16x2",stride:24,offset:20}},indexBuffer:new n.h({data:h,label:"index-batch-buffer",usage:o.S.INDEX|o.S.COPY_DST,shrinkToFit:!1})})}}var u=r(9677),d=r(2305),p=r(1570),f=r(7335),g=r(2478),m=r(1657);class x extends m.M{constructor(t){super({glProgram:(0,u.I)({name:"batch",bits:[d.a,(0,p.P)(t),f.m]}),gpuProgram:(0,u.v)({name:"batch",bits:[d.F,(0,p._)(t),f.b]}),resources:{batchSamplers:(0,g.n)(t)}})}}let _=null;const y=class t extends i.i{constructor(e){super(e),this.geometry=new c,this.name=t.extension.name,this.vertexSize=6,_??(_=new x(e.maxTextures)),this.shader=_}packAttributes(t,e,r,s,i){const n=i<<16|65535&t.roundPixels,o=t.transform,a=o.a,l=o.b,h=o.c,c=o.d,u=o.tx,d=o.ty,{positions:p,uvs:f}=t,g=t.color,m=t.attributeOffset,x=m+t.attributeSize;for(let t=m;t<x;t++){const i=2*t,o=p[i],m=p[i+1];e[s++]=a*o+h*m+u,e[s++]=c*m+l*o+d,e[s++]=f[i],e[s++]=f[i+1],r[s++]=g,r[s++]=n}}packQuadAttributes(t,e,r,s,i){const n=t.texture,o=t.transform,a=o.a,l=o.b,h=o.c,c=o.d,u=o.tx,d=o.ty,p=t.bounds,f=p.maxX,g=p.minX,m=p.maxY,x=p.minY,_=n.uvs,y=t.color,v=i<<16|65535&t.roundPixels;e[s+0]=a*g+h*x+u,e[s+1]=c*x+l*g+d,e[s+2]=_.x0,e[s+3]=_.y0,r[s+4]=y,r[s+5]=v,e[s+6]=a*f+h*x+u,e[s+7]=c*x+l*f+d,e[s+8]=_.x1,e[s+9]=_.y1,r[s+10]=y,r[s+11]=v,e[s+12]=a*f+h*m+u,e[s+13]=c*m+l*f+d,e[s+14]=_.x2,e[s+15]=_.y2,r[s+16]=y,r[s+17]=v,e[s+18]=a*g+h*m+u,e[s+19]=c*m+l*g+d,e[s+20]=_.x3,e[s+21]=_.y3,r[s+22]=y,r[s+23]=v}};y.extension={type:[s.Ag.Batcher],name:"default"};let v=y},4405:(t,e,r)=>{"use strict";r.d(e,{Ls:()=>s,_Q:()=>i,mA:()=>n});const s={name:"local-uniform-bit",vertex:{header:"\n\n struct LocalUniforms {\n uTransformMatrix:mat3x3<f32>,\n uColor:vec4<f32>,\n uRound:f32,\n }\n\n @group(1) @binding(0) var<uniform> localUniforms : LocalUniforms;\n ",main:"\n vColor *= localUniforms.uColor;\n modelMatrix *= localUniforms.uTransformMatrix;\n ",end:"\n if(localUniforms.uRound == 1)\n {\n vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);\n }\n "}},i={...s,vertex:{...s.vertex,header:s.vertex.header.replace("group(1)","group(2)")}},n={name:"local-uniform-bit",vertex:{header:"\n\n uniform mat3 uTransformMatrix;\n uniform vec4 uColor;\n uniform float uRound;\n ",main:"\n vColor *= uColor;\n modelMatrix = uTransformMatrix;\n ",end:"\n if(uRound == 1.)\n {\n gl_Position.xy = roundPixels(gl_Position.xy, uResolution);\n }\n "}}},4449:(t,e,r)=>{"use strict";r.d(e,{k:()=>h});var s=r(9375),i=r(8642);const n=["f32","i32","vec2<f32>","vec3<f32>","vec4<f32>","mat2x2<f32>","mat3x3<f32>","mat4x4<f32>","mat3x2<f32>","mat4x2<f32>","mat2x3<f32>","mat4x3<f32>","mat2x4<f32>","mat3x4<f32>","vec2<i32>","vec3<i32>","vec4<i32>"],o=n.reduce((t,e)=>(t[e]=!0,t),{});function a(t,e){switch(t){case"f32":return 0;case"vec2<f32>":return new Float32Array(2*e);case"vec3<f32>":return new Float32Array(3*e);case"vec4<f32>":return new Float32Array(4*e);case"mat2x2<f32>":return new Float32Array([1,0,0,1]);case"mat3x3<f32>":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4x4<f32>":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const l=class t{constructor(e,r){this._touched=0,this.uid=(0,s.L)("uniform"),this._resourceType="uniformGroup",this._resourceId=(0,s.L)("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,r={...t.defaultOptions,...r},this.uniformStructures=e;const l={};for(const t in e){const r=e[t];if(r.name=t,r.size=r.size??1,!o[r.type]){const t=r.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);if(t){const[,e,s]=t;throw new Error(`Uniform type ${r.type} is not supported. Use type: '${e}', size: ${s} instead.`)}throw new Error(`Uniform type ${r.type} is not supported. Supported uniform types are: ${n.join(", ")}`)}r.value??(r.value=a(r.type,r.size)),l[t]=r.value}this.uniforms=l,this._dirtyId=1,this.ubo=r.ubo,this.isStatic=r.isStatic,this._signature=(0,i.X)(Object.keys(l).map(t=>`${t}-${e[t].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};l.defaultOptions={ubo:!1,isStatic:!1};let h=l},4454:(t,e,r)=>{"use strict";r.d(e,{A:()=>o});var s=r(4696),i=r(4543),n=r(4386);class o extends i.l{constructor(t){t instanceof n.T&&(t={context:t});const{context:e,roundPixels:r,...s}=t||{};super({label:"Graphics",...s}),this.renderPipeId="graphics",this._context=e||(this._ownedContext=new n.T),this._context.on("update",this.onViewUpdate,this),this.didViewUpdate=!0,this.allowChildren=!1,this.roundPixels=r??!1}set context(t){t!==this._context&&(this._context.off("update",this.onViewUpdate,this),this._context=t,this._context.on("update",this.onViewUpdate,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}updateBounds(){}containsPoint(t){return this._context.containsPoint(t)}destroy(t){this._ownedContext&&!t?this._ownedContext.destroy(t):!0!==t&&!0!==t?.context||this._context.destroy(t),this._ownedContext=null,this._context=null,super.destroy(t)}_callContextMethod(t,e){return this.context[t](...e),this}setFillStyle(...t){return this._callContextMethod("setFillStyle",t)}setStrokeStyle(...t){return this._callContextMethod("setStrokeStyle",t)}fill(...t){return this._callContextMethod("fill",t)}stroke(...t){return this._callContextMethod("stroke",t)}texture(...t){return this._callContextMethod("texture",t)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...t){return this._callContextMethod("arc",t)}arcTo(...t){return this._callContextMethod("arcTo",t)}arcToSvg(...t){return this._callContextMethod("arcToSvg",t)}bezierCurveTo(...t){return this._callContextMethod("bezierCurveTo",t)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...t){return this._callContextMethod("ellipse",t)}circle(...t){return this._callContextMethod("circle",t)}path(...t){return this._callContextMethod("path",t)}lineTo(...t){return this._callContextMethod("lineTo",t)}moveTo(...t){return this._callContextMethod("moveTo",t)}quadraticCurveTo(...t){return this._callContextMethod("quadraticCurveTo",t)}rect(...t){return this._callContextMethod("rect",t)}roundRect(...t){return this._callContextMethod("roundRect",t)}poly(...t){return this._callContextMethod("poly",t)}regularPoly(...t){return this._callContextMethod("regularPoly",t)}roundPoly(...t){return this._callContextMethod("roundPoly",t)}roundShape(...t){return this._callContextMethod("roundShape",t)}filletRect(...t){return this._callContextMethod("filletRect",t)}chamferRect(...t){return this._callContextMethod("chamferRect",t)}star(...t){return this._callContextMethod("star",t)}svg(...t){return this._callContextMethod("svg",t)}restore(...t){return this._callContextMethod("restore",t)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...t){return this._callContextMethod("rotate",t)}scaleTransform(...t){return this._callContextMethod("scale",t)}setTransform(...t){return this._callContextMethod("setTransform",t)}transform(...t){return this._callContextMethod("transform",t)}translateTransform(...t){return this._callContextMethod("translate",t)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(t){this._context.fillStyle=t}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(t){this._context.strokeStyle=t}clone(t=!1){return t?new o(this._context.clone()):(this._ownedContext=null,new o(this._context))}lineStyle(t,e,r){(0,s.t6)(s.lj,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");const i={};return t&&(i.width=t),e&&(i.color=e),r&&(i.alpha=r),this.context.strokeStyle=i,this}beginFill(t,e){(0,s.t6)(s.lj,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");const r={};return void 0!==t&&(r.color=t),void 0!==e&&(r.alpha=e),this.context.fillStyle=r,this}endFill(){(0,s.t6)(s.lj,"Graphics#endFill is no longer needed. Use Graphics#fill to fill the shape with the desired style."),this.context.fill();const t=this.context.strokeStyle;return t.width===n.T.defaultStrokeStyle.width&&t.color===n.T.defaultStrokeStyle.color&&t.alpha===n.T.defaultStrokeStyle.alpha||this.context.stroke(),this}drawCircle(...t){return(0,s.t6)(s.lj,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",t)}drawEllipse(...t){return(0,s.t6)(s.lj,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",t)}drawPolygon(...t){return(0,s.t6)(s.lj,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",t)}drawRect(...t){return(0,s.t6)(s.lj,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",t)}drawRoundedRect(...t){return(0,s.t6)(s.lj,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",t)}drawStar(...t){return(0,s.t6)(s.lj,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",t)}}},4543:(t,e,r)=>{"use strict";r.d(e,{l:()=>n});var s=r(6170),i=r(4687);class n extends i.mc{constructor(t){super(t),this.canBundle=!0,this.allowChildren=!1,this._roundPixels=0,this._lastUsed=-1,this._gpuData=Object.create(null),this._bounds=new s.c(0,1,0,0),this._boundsDirty=!0}get bounds(){return this._boundsDirty?(this.updateBounds(),this._boundsDirty=!1,this._bounds):this._bounds}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}containsPoint(t){const e=this.bounds,{x:r,y:s}=t;return r>=e.minX&&r<=e.maxX&&s>=e.minY&&s<=e.maxY}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}destroy(t){super.destroy(t),this._bounds=null;for(const t in this._gpuData)this._gpuData[t].destroy?.();this._gpuData=null}collectRenderablesSimple(t,e,r){const{renderPipes:s}=e;s.blendMode.pushBlendMode(this,this.groupBlendMode,t),s[this.renderPipeId].addRenderable(this,t),this.didViewUpdate=!1;const i=this.children,n=i.length;for(let s=0;s<n;s++)i[s].collectRenderables(t,e,r);s.blendMode.popBlendMode(t)}}},4550:(t,e,r)=>{"use strict";var s=r(1065),i=r(1228),n=r(4696),o=r(1174);const a=class t extends o.u{constructor(...t){super({});let e=t[0]??{};"number"==typeof e&&((0,n.t6)(n.lj,"PlaneGeometry constructor changed please use { width, height, verticesX, verticesY } instead"),e={width:e,height:t[1],verticesX:t[2],verticesY:t[3]}),this.build(e)}build(e){e={...t.defaultOptions,...e},this.verticesX=this.verticesX??e.verticesX,this.verticesY=this.verticesY??e.verticesY,this.width=this.width??e.width,this.height=this.height??e.height;const r=this.verticesX*this.verticesY,s=[],i=[],n=[],o=this.verticesX-1,a=this.verticesY-1,l=this.width/o,h=this.height/a;for(let t=0;t<r;t++){const e=t%this.verticesX,r=t/this.verticesX|0;s.push(e*l,r*h),i.push(e/o,r/a)}const c=o*a;for(let t=0;t<c;t++){const e=t%o,r=t/o|0,s=r*this.verticesX+e,i=r*this.verticesX+e+1,a=(r+1)*this.verticesX+e,l=(r+1)*this.verticesX+e+1;n.push(s,i,a,i,l,a)}this.buffers[0].data=new Float32Array(s),this.buffers[1].data=new Float32Array(i),this.indexBuffer.data=new Uint32Array(n),this.buffers[0].update(),this.buffers[1].update(),this.indexBuffer.update()}};a.defaultOptions={width:100,height:100,verticesX:10,verticesY:10};let l=a;const h=class t extends l{constructor(e={}){super({width:(e={...t.defaultOptions,...e}).width,height:e.height,verticesX:4,verticesY:4}),this.update(e)}update(t){this.width=t.width??this.width,this.height=t.height??this.height,this._originalWidth=t.originalWidth??this._originalWidth,this._originalHeight=t.originalHeight??this._originalHeight,this._leftWidth=t.leftWidth??this._leftWidth,this._rightWidth=t.rightWidth??this._rightWidth,this._topHeight=t.topHeight??this._topHeight,this._bottomHeight=t.bottomHeight??this._bottomHeight,this._anchorX=t.anchor?.x,this._anchorY=t.anchor?.y,this.updateUvs(),this.updatePositions()}updatePositions(){const t=this.positions,{width:e,height:r,_leftWidth:s,_rightWidth:i,_topHeight:n,_bottomHeight:o,_anchorX:a,_anchorY:l}=this,h=s+i,c=e>h?1:e/h,u=n+o,d=r>u?1:r/u,p=Math.min(c,d),f=a*e,g=l*r;t[0]=t[8]=t[16]=t[24]=-f,t[2]=t[10]=t[18]=t[26]=s*p-f,t[4]=t[12]=t[20]=t[28]=e-i*p-f,t[6]=t[14]=t[22]=t[30]=e-f,t[1]=t[3]=t[5]=t[7]=-g,t[9]=t[11]=t[13]=t[15]=n*p-g,t[17]=t[19]=t[21]=t[23]=r-o*p-g,t[25]=t[27]=t[29]=t[31]=r-g,this.getBuffer("aPosition").update()}updateUvs(){const t=this.uvs;t[0]=t[8]=t[16]=t[24]=0,t[1]=t[3]=t[5]=t[7]=0,t[6]=t[14]=t[22]=t[30]=1,t[25]=t[27]=t[29]=t[31]=1;const e=1/this._originalWidth,r=1/this._originalHeight;t[2]=t[10]=t[18]=t[26]=e*this._leftWidth,t[9]=t[11]=t[13]=t[15]=r*this._topHeight,t[4]=t[12]=t[20]=t[28]=1-e*this._rightWidth,t[17]=t[19]=t[21]=t[23]=1-r*this._bottomHeight,this.getBuffer("aUV").update()}};h.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let c=h;class u extends i.U{constructor(){super(),this.geometry=new c}destroy(){this.geometry.destroy()}}class d{constructor(t){this._renderer=t}addRenderable(t,e){const r=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,r),this._renderer.renderPipes.batch.addToBatch(r,e)}updateRenderable(t){const e=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,e),e._batcher.updateElement(e)}validateRenderable(t){const e=this._getGpuSprite(t);return!e._batcher.checkAndUpdateTexture(e,t._texture)}_updateBatchableSprite(t,e){e.geometry.update(t),e.setTexture(t._texture)}_getGpuSprite(t){return t._gpuData[this._renderer.uid]||this._initGPUSprite(t)}_initGPUSprite(t){const e=t._gpuData[this._renderer.uid]=new u,r=e;return r.renderable=t,r.transform=t.groupTransform,r.texture=t._texture,r.roundPixels=this._renderer._roundPixels|t._roundPixels,t.didViewUpdate||this._updateBatchableSprite(t,r),e}destroy(){this._renderer=null}}d.extension={type:[s.Ag.WebGLPipes,s.Ag.WebGPUPipes,s.Ag.CanvasPipes],name:"nineSliceSprite"},s.XO.add(d)},4582:(t,e,r)=>{"use strict";r.d(e,{L:()=>i});var s=r(9375);class i{constructor(){this.uid=(0,s.L)("instructionSet"),this.instructions=[],this.instructionSize=0,this.renderables=[],this.gcTick=0}reset(){this.instructionSize=0}destroy(){this.instructions.length=0,this.renderables.length=0,this.renderPipes=null,this.gcTick=0}add(t){this.instructions[this.instructionSize++]=t}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,["type","action"])}}},4614:(t,e,r)=>{"use strict";r.d(e,{TO:()=>s,Td:()=>n,bO:()=>i});const s=2*Math.PI,i=180/Math.PI,n=Math.PI/180},4687:(t,e,r)=>{"use strict";r.d(e,{mc:()=>Y,u:()=>X,ig:()=>H,fR:()=>V});var s=r(4872),i=r(6675),n=r(1065),o=r(5199),a=r(4614),l=r(7898),h=r(9375),c=r(4696),u=r(7694),d=r(761);const p={get isCachedAsTexture(){return!!this.renderGroup?.isCachedAsTexture},cacheAsTexture(t){"boolean"==typeof t&&!1===t?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(!0===t?{}:t))},updateCacheTexture(){this.renderGroup?.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(t){(0,c.t6)("v8.6.0","cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(t)}};var f=r(4025);const g={allowChildren:!0,removeChildren(t=0,e){const r=e??this.children.length,s=r-t,i=[];if(s>0&&s<=r){for(let e=r-1;e>=t;e--){const t=this.children[e];t&&(i.push(t),t.parent=null)}(0,f.d)(this.children,t,r);const e=this.renderGroup||this.parentRenderGroup;e&&e.removeChildren(i);for(let t=0;t<i.length;++t){const e=i[t];e.parentRenderLayer?.detach(e),this.emit("childRemoved",e,this,t),i[t].emit("removed",this)}return i.length>0&&this._didViewChangeTick++,i}if(0===s&&0===this.children.length)return i;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(t){const e=this.getChildAt(t);return this.removeChild(e)},getChildAt(t){if(t<0||t>=this.children.length)throw new Error(`getChildAt: Index (${t}) does not exist.`);return this.children[t]},setChildIndex(t,e){if(e<0||e>=this.children.length)throw new Error(`The index ${e} supplied is out of bounds ${this.children.length}`);this.getChildIndex(t),this.addChildAt(t,e)},getChildIndex(t){const e=this.children.indexOf(t);if(-1===e)throw new Error("The supplied Container must be a child of the caller");return e},addChildAt(t,e){this.allowChildren||(0,c.t6)(c.lj,"addChildAt: Only Containers will be allowed to add children in v8.0.0");const{children:r}=this;if(e<0||e>r.length)throw new Error(`${t}addChildAt: The index ${e} supplied is out of bounds ${r.length}`);if(t.parent){const r=t.parent.children.indexOf(t);if(t.parent===this&&r===e)return t;-1!==r&&t.parent.children.splice(r,1)}e===r.length?r.push(t):r.splice(e,0,t),t.parent=this,t.didChange=!0,t._updateFlags=15;const s=this.renderGroup||this.parentRenderGroup;return s&&s.addChild(t),this.sortableChildren&&(this.sortDirty=!0),this.emit("childAdded",t,this,e),t.emit("added",this),t},swapChildren(t,e){if(t===e)return;const r=this.getChildIndex(t),s=this.getChildIndex(e);this.children[r]=e,this.children[s]=t;const i=this.renderGroup||this.parentRenderGroup;i&&(i.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){this.parent?.removeChild(this)},reparentChild(...t){return 1===t.length?this.reparentChildAt(t[0],this.children.length):(t.forEach(t=>this.reparentChildAt(t,this.children.length)),t[0])},reparentChildAt(t,e){if(t.parent===this)return this.setChildIndex(t,e),t;const r=t.worldTransform.clone();t.removeFromParent(),this.addChildAt(t,e);const s=this.worldTransform.clone();return s.invert(),r.prepend(s),t.setFromMatrix(r),t},replaceChild(t,e){t.updateLocalTransform(),this.addChildAt(e,this.getChildIndex(t)),e.setFromMatrix(t.localTransform),e.updateLocalTransform(),this.removeChild(t)}},m={collectRenderables(t,e,r){this.parentRenderLayer&&this.parentRenderLayer!==r||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(t,e,r):this.renderGroup?e.renderPipes.renderGroup.addRenderGroup(this.renderGroup,t):this.collectRenderablesWithEffects(t,e,r))},collectRenderablesSimple(t,e,r){const s=this.children,i=s.length;for(let n=0;n<i;n++)s[n].collectRenderables(t,e,r)},collectRenderablesWithEffects(t,e,r){const{renderPipes:s}=e;for(let e=0;e<this.effects.length;e++){const r=this.effects[e];s[r.pipe].push(r,this,t)}this.collectRenderablesSimple(t,e,r);for(let e=this.effects.length-1;e>=0;e--){const r=this.effects[e];s[r.pipe].pop(r,this,t)}}};var x=r(4403);const _=new class{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){this._initialized||(this._initialized=!0,this._effectClasses.forEach(t=>{this.add({test:t.test,maskClass:t})}))}add(t){this._tests.push(t)}getMaskEffect(t){this._initialized||this.init();for(let e=0;e<this._tests.length;e++){const r=this._tests[e];if(r.test(t))return d.Z.get(r.maskClass,t)}return t}returnMaskEffect(t){d.Z.return(t)}};n.XO.handleByList(n.Ag.MaskEffect,_._effectClasses);const y={_maskEffect:null,_maskOptions:{inverse:!1},_filterEffect:null,effects:[],_markStructureAsChanged(){const t=this.renderGroup||this.parentRenderGroup;t&&(t.structureDidChange=!0)},addEffect(t){-1===this.effects.indexOf(t)&&(this.effects.push(t),this.effects.sort((t,e)=>t.priority-e.priority),this._markStructureAsChanged(),this._updateIsSimple())},removeEffect(t){const e=this.effects.indexOf(t);-1!==e&&(this.effects.splice(e,1),this._markStructureAsChanged(),this._updateIsSimple())},set mask(t){const e=this._maskEffect;e?.mask!==t&&(e&&(this.removeEffect(e),_.returnMaskEffect(e),this._maskEffect=null),null!=t&&(this._maskEffect=_.getMaskEffect(t),this.addEffect(this._maskEffect)))},get mask(){return this._maskEffect?.mask},setMask(t){this._maskOptions={...this._maskOptions,...t},t.mask&&(this.mask=t.mask),this._markStructureAsChanged()},set filters(t){!Array.isArray(t)&&t&&(t=[t]);const e=this._filterEffect||(this._filterEffect=new x.a),r=t?.length>0,s=r!==e.filters?.length>0;t=Array.isArray(t)?t.slice(0):t,e.filters=Object.freeze(t),s&&(r?this.addEffect(e):(this.removeEffect(e),e.filters=t??null))},get filters(){return this._filterEffect?.filters},set filterArea(t){this._filterEffect||(this._filterEffect=new x.a),this._filterEffect.filterArea=t},get filterArea(){return this._filterEffect?.filterArea}},v={label:null,get name(){return(0,c.t6)(c.lj,"Container.name property has been removed, use Container.label instead"),this.label},set name(t){(0,c.t6)(c.lj,"Container.name property has been removed, use Container.label instead"),this.label=t},getChildByName(t,e=!1){return this.getChildByLabel(t,e)},getChildByLabel(t,e=!1){const r=this.children;for(let e=0;e<r.length;e++){const s=r[e];if(s.label===t||t instanceof RegExp&&t.test(s.label))return s}if(e)for(let e=0;e<r.length;e++){const s=r[e].getChildByLabel(t,!0);if(s)return s}return null},getChildrenByLabel(t,e=!1,r=[]){const s=this.children;for(let e=0;e<s.length;e++){const i=s[e];(i.label===t||t instanceof RegExp&&t.test(i.label))&&r.push(i)}if(e)for(let e=0;e<s.length;e++)s[e].getChildrenByLabel(t,!0,r);return r}};var b=r(6170),w=r(7882);const T=new o.u,S={getFastGlobalBounds(t,e){e||(e=new b.c),e.clear(),this._getGlobalBoundsRecursive(!!t,e,this.parentRenderLayer),e.isValid||e.set(0,0,0,0);const r=this.renderGroup||this.parentRenderGroup;return e.applyMatrix(r.worldTransform),e},_getGlobalBoundsRecursive(t,e,r){let s=e;if(t&&this.parentRenderLayer&&this.parentRenderLayer!==r)return;if(7!==this.localDisplayStatus||!this.measurable)return;const i=!!this.effects.length;if((this.renderGroup||i)&&(s=w.o.get().clear()),this.boundsArea)e.addRect(this.boundsArea,this.worldTransform);else{if(this.renderPipeId){const t=this.bounds;s.addFrame(t.minX,t.minY,t.maxX,t.maxY,this.groupTransform)}const e=this.children;for(let i=0;i<e.length;i++)e[i]._getGlobalBoundsRecursive(t,s,r)}if(i){let t=!1;const r=this.renderGroup||this.parentRenderGroup;for(let e=0;e<this.effects.length;e++)this.effects[e].addBounds&&(t||(t=!0,s.applyMatrix(r.worldTransform)),this.effects[e].addBounds(s,!0));t&&s.applyMatrix(r.worldTransform.copyTo(T).invert()),e.addBounds(s),w.o.return(s)}else this.renderGroup&&(e.addBounds(s,this.relativeGroupTransform),w.o.return(s))}};var A=r(9565),C=r(6851);function P(t){return((255&t)<<16)+(65280&t)+(t>>16&255)}const M={getGlobalAlpha(t){if(t)return this.renderGroup?this.renderGroup.worldAlpha:this.parentRenderGroup?this.parentRenderGroup.worldAlpha*this.alpha:this.alpha;let e=this.alpha,r=this.parent;for(;r;)e*=r.alpha,r=r.parent;return e},getGlobalTransform(t=new o.u,e){if(e)return t.copyFrom(this.worldTransform);this.updateLocalTransform();const r=(0,A.E)(this,w.u.get().identity());return t.appendFrom(this.localTransform,r),w.u.return(r),t},getGlobalTint(t){if(t)return this.renderGroup?P(this.renderGroup.worldColor):this.parentRenderGroup?P((0,C.j)(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let e=this.localColor,r=this.parent;for(;r;)e=(0,C.j)(e,r.localColor),r=r.parent;return P(e)}};var E=r(2071);function R(t,e){const r=t.children;for(let t=0;t<r.length;t++){const s=r[t],i=s.uid,n=(65535&s._didViewChangeTick)<<16|65535&s._didContainerChangeTick,o=e.index;e.data[o]===i&&e.data[o+1]===n||(e.data[e.index]=i,e.data[e.index+1]=n,e.didChange=!0),e.index=o+2,s.children.length&&R(s,e)}return e.didChange}const k=new o.u,B={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(t,e){const r=Math.sign(this.scale.x)||1;this.scale.x=0!==e?t/e*r:r},_setHeight(t,e){const r=Math.sign(this.scale.y)||1;this.scale.y=0!==e?t/e*r:r},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new b.c});const t=this._localBoundsCacheData;return t.index=1,t.didChange=!1,t.data[0]!==this._didViewChangeTick&&(t.didChange=!0,t.data[0]=this._didViewChangeTick),R(this,t),t.didChange&&(0,E.n)(this,t.localBounds,k),t.localBounds},getBounds(t,e){return(0,A.f)(this,t,e||new b.c)}},I={_onRender:null,set onRender(t){const e=this.renderGroup||this.parentRenderGroup;if(!t)return this._onRender&&e?.removeOnRender(this),void(this._onRender=null);this._onRender||e?.addOnRender(this),this._onRender=t},get onRender(){return this._onRender}},G={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(t){this._zIndex!==t&&(this._zIndex=t,this.depthOfChildModified())},depthOfChildModified(){this.parent&&(this.parent.sortableChildren=!0,this.parent.sortDirty=!0),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0)},sortChildren(){this.sortDirty&&(this.sortDirty=!1,this.children.sort(F))}};function F(t,e){return t._zIndex-e._zIndex}var O=r(59);const D={getGlobalPosition(t=new O.b,e=!1){return this.parent?this.parent.toGlobal(this._position,t,e):(t.x=this._position.x,t.y=this._position.y),t},toGlobal(t,e,r=!1){const s=this.getGlobalTransform(w.u.get(),r);return e=s.apply(t,e),w.u.return(s),e},toLocal(t,e,r,s){e&&(t=e.toGlobal(t,r,s));const i=this.getGlobalTransform(w.u.get(),s);return r=i.applyInverse(t,r),w.u.return(i),r}};var U=r(1422);const L=new l.o(null),N=new l.o(null),z=new l.o(null,1,1),W=new l.o(null),H=1,X=2,V=4;class Y extends s.A{constructor(t={}){super(),this.uid=(0,h.L)("renderable"),this._updateFlags=15,this.renderGroup=null,this.parentRenderGroup=null,this.parentRenderGroupIndex=0,this.didChange=!1,this.didViewUpdate=!1,this.relativeRenderGroupDepth=0,this.children=[],this.parent=null,this.includeInBuild=!0,this.measurable=!0,this.isSimple=!0,this.updateTick=-1,this.localTransform=new o.u,this.relativeGroupTransform=new o.u,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new l.o(this,0,0),this._scale=z,this._pivot=N,this._origin=W,this._skew=L,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._rotation=0,this.localColor=16777215,this.localAlpha=1,this.groupAlpha=1,this.groupColor=16777215,this.groupColorAlpha=4294967295,this.localBlendMode="inherit",this.groupBlendMode="normal",this.localDisplayStatus=7,this.globalDisplayStatus=7,this._didContainerChangeTick=0,this._didViewChangeTick=0,this._didLocalTransformChangeId=-1,this.effects=[],function(t,e,r={}){for(const s in e)r[s]||void 0===e[s]||(t[s]=e[s])}(this,t,{children:!0,parent:!0,effects:!0}),t.children?.forEach(t=>this.addChild(t)),t.parent?.addChild(this)}static mixin(t){(0,c.t6)("8.8.0","Container.mixin is deprecated, please use extensions.mixin instead."),n.XO.mixin(Y,t)}set _didChangeId(t){this._didViewChangeTick=t>>12&4095,this._didContainerChangeTick=4095&t}get _didChangeId(){return 4095&this._didContainerChangeTick|(4095&this._didViewChangeTick)<<12}addChild(...t){if(this.allowChildren||(0,c.t6)(c.lj,"addChild: Only Containers will be allowed to add children in v8.0.0"),t.length>1){for(let e=0;e<t.length;e++)this.addChild(t[e]);return t[0]}const e=t[0],r=this.renderGroup||this.parentRenderGroup;return e.parent===this?(this.children.splice(this.children.indexOf(e),1),this.children.push(e),r&&(r.structureDidChange=!0),e):(e.parent&&e.parent.removeChild(e),this.children.push(e),this.sortableChildren&&(this.sortDirty=!0),e.parent=this,e.didChange=!0,e._updateFlags=15,r&&r.addChild(e),this.emit("childAdded",e,this,this.children.length-1),e.emit("added",this),this._didViewChangeTick++,0!==e._zIndex&&e.depthOfChildModified(),e)}removeChild(...t){if(t.length>1){for(let e=0;e<t.length;e++)this.removeChild(t[e]);return t[0]}const e=t[0],r=this.children.indexOf(e);return r>-1&&(this._didViewChangeTick++,this.children.splice(r,1),this.renderGroup?this.renderGroup.removeChild(e):this.parentRenderGroup&&this.parentRenderGroup.removeChild(e),e.parentRenderLayer&&e.parentRenderLayer.detach(e),e.parent=null,this.emit("childRemoved",e,this,r),e.emit("removed",this)),e}_onUpdate(t){t&&t===this._skew&&this._updateSkew(),this._didContainerChangeTick++,this.didChange||(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(t){!!this.renderGroup!==t&&(t?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const t=this.parentRenderGroup;t?.removeChild(this),this.renderGroup=d.Z.get(U.m,this),this.groupTransform=o.u.IDENTITY,t?.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t?.removeChild(this),d.Z.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,t?.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&0===this.effects.length}get worldTransform(){return this._worldTransform||(this._worldTransform=new o.u),this.renderGroup?this._worldTransform.copyFrom(this.renderGroup.worldTransform):this.parentRenderGroup&&this._worldTransform.appendFrom(this.relativeGroupTransform,this.parentRenderGroup.worldTransform),this._worldTransform}get x(){return this._position.x}set x(t){this._position.x=t}get y(){return this._position.y}set y(t){this._position.y=t}get position(){return this._position}set position(t){this._position.copyFrom(t)}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this._onUpdate(this._skew))}get angle(){return this.rotation*a.bO}set angle(t){this.rotation=t*a.Td}get pivot(){return this._pivot===N&&(this._pivot=new l.o(this,0,0)),this._pivot}set pivot(t){this._pivot===N&&(this._pivot=new l.o(this,0,0),this._origin!==W&&(0,u.R)("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),"number"==typeof t?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===L&&(this._skew=new l.o(this,0,0)),this._skew}set skew(t){this._skew===L&&(this._skew=new l.o(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===z&&(this._scale=new l.o(this,1,1)),this._scale}set scale(t){this._scale===z&&(this._scale=new l.o(this,0,0)),"string"==typeof t&&(t=parseFloat(t)),"number"==typeof t?this._scale.set(t):this._scale.copyFrom(t)}get origin(){return this._origin===W&&(this._origin=new l.o(this,0,0)),this._origin}set origin(t){this._origin===W&&(this._origin=new l.o(this,0,0),this._pivot!==N&&(0,u.R)("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),"number"==typeof t?this._origin.set(t):this._origin.copyFrom(t)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(t){const e=this.getLocalBounds().width;this._setWidth(t,e)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(t){const e=this.getLocalBounds().height;this._setHeight(t,e)}getSize(t){t||(t={});const e=this.getLocalBounds();return t.width=Math.abs(this.scale.x*e.width),t.height=Math.abs(this.scale.y*e.height),t}setSize(t,e){const r=this.getLocalBounds();"object"==typeof t?(e=t.height??t.width,t=t.width):e??(e=t),void 0!==t&&this._setWidth(t,r.width),void 0!==e&&this._setHeight(e,r.height)}_updateSkew(){const t=this._rotation,e=this._skew;this._cx=Math.cos(t+e._y),this._sx=Math.sin(t+e._y),this._cy=-Math.sin(t-e._x),this._sy=Math.cos(t-e._x)}updateTransform(t){return this.position.set("number"==typeof t.x?t.x:this.position.x,"number"==typeof t.y?t.y:this.position.y),this.scale.set("number"==typeof t.scaleX?t.scaleX||1:this.scale.x,"number"==typeof t.scaleY?t.scaleY||1:this.scale.y),this.rotation="number"==typeof t.rotation?t.rotation:this.rotation,this.skew.set("number"==typeof t.skewX?t.skewX:this.skew.x,"number"==typeof t.skewY?t.skewY:this.skew.y),this.pivot.set("number"==typeof t.pivotX?t.pivotX:this.pivot.x,"number"==typeof t.pivotY?t.pivotY:this.pivot.y),this.origin.set("number"==typeof t.originX?t.originX:this.origin.x,"number"==typeof t.originY?t.originY:this.origin.y),this}setFromMatrix(t){t.decompose(this)}updateLocalTransform(){const t=this._didContainerChangeTick;if(this._didLocalTransformChangeId===t)return;this._didLocalTransformChangeId=t;const e=this.localTransform,r=this._scale,s=this._pivot,i=this._origin,n=this._position,o=r._x,a=r._y,l=s._x,h=s._y,c=-i._x,u=-i._y;e.a=this._cx*o,e.b=this._sx*o,e.c=this._cy*a,e.d=this._sy*a,e.tx=n._x-(l*e.a+h*e.c)+(c*e.a+u*e.c)-c,e.ty=n._y-(l*e.b+h*e.d)+(c*e.b+u*e.d)-u}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=H,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const e=i.Q.shared.setValue(t??16777215).toBgrNumber();e!==this.localColor&&(this.localColor=e,this._updateFlags|=H,this._onUpdate())}get tint(){return P(this.localColor)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=X,this.localBlendMode=t,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(2&this.localDisplayStatus)}set visible(t){const e=t?2:0;(2&this.localDisplayStatus)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=V,this.localDisplayStatus^=2,this._onUpdate())}get culled(){return!(4&this.localDisplayStatus)}set culled(t){const e=t?0:4;(4&this.localDisplayStatus)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=V,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(1&this.localDisplayStatus)}set renderable(t){const e=t?1:0;(1&this.localDisplayStatus)!==e&&(this._updateFlags|=V,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return 7===this.localDisplayStatus&&this.groupAlpha>0}destroy(t=!1){if(this.destroyed)return;let e;if(this.destroyed=!0,this.children.length&&(e=this.removeChildren(0,this.children.length)),this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._origin=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners(),("boolean"==typeof t?t:t?.children)&&e)for(let r=0;r<e.length;++r)e[r].destroy(t);this.renderGroup?.destroy(),this.renderGroup=null}}n.XO.mixin(Y,g,S,D,I,B,y,v,G,{cullArea:null,cullable:!1,cullableChildren:!0},p,M,m)},4696:(t,e,r)=>{"use strict";r.d(e,{Ek:()=>n,lj:()=>i,t6:()=>a});const s=new Set,i="8.0.0",n="8.3.4",o={quiet:!1,noColor:!1},a=(t,e,r=3)=>{if(o.quiet||s.has(e))return;let i=(new Error).stack;const n=`${e}\nDeprecated since v${t}`,a="function"==typeof console.groupCollapsed&&!o.noColor;void 0===i?console.warn("PixiJS Deprecation Warning: ",n):(i=i.split("\n").splice(r).join("\n"),a?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",n),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",n),console.warn(i))),s.add(e)};Object.defineProperties(a,{quiet:{get:()=>o.quiet,set:t=>{o.quiet=t},enumerable:!0,configurable:!1},noColor:{get:()=>o.noColor,set:t=>{o.noColor=t},enumerable:!0,configurable:!1}})},4872:(t,e,r)=>{"use strict";r.d(e,{A:()=>s});const s=r(792)},4988:(t,e,r)=>{"use strict";r.d(e,{m:()=>i});const s={uint8x2:{size:2,stride:2,normalised:!1},uint8x4:{size:4,stride:4,normalised:!1},sint8x2:{size:2,stride:2,normalised:!1},sint8x4:{size:4,stride:4,normalised:!1},unorm8x2:{size:2,stride:2,normalised:!0},unorm8x4:{size:4,stride:4,normalised:!0},snorm8x2:{size:2,stride:2,normalised:!0},snorm8x4:{size:4,stride:4,normalised:!0},uint16x2:{size:2,stride:4,normalised:!1},uint16x4:{size:4,stride:8,normalised:!1},sint16x2:{size:2,stride:4,normalised:!1},sint16x4:{size:4,stride:8,normalised:!1},unorm16x2:{size:2,stride:4,normalised:!0},unorm16x4:{size:4,stride:8,normalised:!0},snorm16x2:{size:2,stride:4,normalised:!0},snorm16x4:{size:4,stride:8,normalised:!0},float16x2:{size:2,stride:4,normalised:!1},float16x4:{size:4,stride:8,normalised:!1},float32:{size:1,stride:4,normalised:!1},float32x2:{size:2,stride:8,normalised:!1},float32x3:{size:3,stride:12,normalised:!1},float32x4:{size:4,stride:16,normalised:!1},uint32:{size:1,stride:4,normalised:!1},uint32x2:{size:2,stride:8,normalised:!1},uint32x3:{size:3,stride:12,normalised:!1},uint32x4:{size:4,stride:16,normalised:!1},sint32:{size:1,stride:4,normalised:!1},sint32x2:{size:2,stride:8,normalised:!1},sint32x3:{size:3,stride:12,normalised:!1},sint32x4:{size:4,stride:16,normalised:!1}};function i(t){return s[t]??s.float32}},5007:(t,e,r)=>{"use strict";r.d(e,{M:()=>d});var s=r(8642),i=r(8574);let n;function o(){if(!n){n="mediump";const t=(0,i.W)();if(t&&t.getShaderPrecisionFormat){const e=t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT);n=e.precision?"highp":"mediump"}}return n}const a={},l={},h={stripVersion:function(t,e){return e?t.replace("#version 300 es",""):t},ensurePrecision:function(t,e,r){const s=r?e.maxSupportedFragmentPrecision:e.maxSupportedVertexPrecision;if("precision"!==t.substring(0,9)){let i=r?e.requestedFragmentPrecision:e.requestedVertexPrecision;return"highp"===i&&"highp"!==s&&(i="mediump"),`precision ${i} float;\n${t}`}return"highp"!==s&&"precision highp"===t.substring(0,15)?t.replace("precision highp","precision mediump"):t},addProgramDefines:function(t,e,r){return e?t:r?`\n\n #ifdef GL_ES // This checks if it is WebGL1\n #define in varying\n #define finalColor gl_FragColor\n #define texture texture2D\n #endif\n ${t=t.replace("out vec4 finalColor;","")}\n `:`\n\n #ifdef GL_ES // This checks if it is WebGL1\n #define in attribute\n #define out varying\n #endif\n ${t}\n `},setProgramName:function(t,{name:e="pixi-program"},r=!0){e=e.replace(/\s+/g,"-");const s=r?a:l;return s[e+=r?"-fragment":"-vertex"]?(s[e]++,e+=`-${s[e]}`):s[e]=1,-1!==t.indexOf("#define SHADER_NAME")?t:`#define SHADER_NAME ${e}\n${t}`},insertVersion:function(t,e){return e?`#version 300 es\n${t}`:t}},c=Object.create(null),u=class t{constructor(e){const r=-1!==(e={...t.defaultOptions,...e}).fragment.indexOf("#version 300 es"),i={stripVersion:r,ensurePrecision:{requestedFragmentPrecision:e.preferredFragmentPrecision,requestedVertexPrecision:e.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:o()},setProgramName:{name:e.name},addProgramDefines:r,insertVersion:r};let n=e.fragment,a=e.vertex;Object.keys(h).forEach(t=>{const e=i[t];n=h[t](n,e,!0),a=h[t](a,e,!1)}),this.fragment=n,this.vertex=a,this.transformFeedbackVaryings=e.transformFeedbackVaryings,this._key=(0,s.X)(`${this.vertex}:${this.fragment}`,"gl-program")}destroy(){this.fragment=null,this.vertex=null,this._attributeData=null,this._uniformData=null,this._uniformBlockData=null,this.transformFeedbackVaryings=null,c[this._cacheKey]=null}static from(e){const r=`${e.vertex}:${e.fragment}`;return c[r]||(c[r]=new t(e),c[r]._cacheKey=r),c[r]}};u.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let d=u},5008:(t,e,r)=>{"use strict";r.d(e,{G:()=>o});var s=r(5199),i=r(5946);const n=new s.u;class o{constructor(){this.packAsQuad=!1,this.batcherName="default",this.topology="triangle-list",this.applyTransform=!0,this.roundPixels=0,this._batcher=null,this._batch=null}get uvs(){return this.geometryData.uvs}get positions(){return this.geometryData.vertices}get indices(){return this.geometryData.indices}get blendMode(){return this.renderable&&this.applyTransform?this.renderable.groupBlendMode:"normal"}get color(){const t=this.baseColor,e=t>>16|65280&t|(255&t)<<16,r=this.renderable;return r?(0,i.u)(e,r.groupColor)+(this.alpha*r.groupAlpha*255<<24):e+(255*this.alpha<<24)}get transform(){return this.renderable?.groupTransform||n}copyTo(t){t.indexOffset=this.indexOffset,t.indexSize=this.indexSize,t.attributeOffset=this.attributeOffset,t.attributeSize=this.attributeSize,t.baseColor=this.baseColor,t.alpha=this.alpha,t.texture=this.texture,t.geometryData=this.geometryData,t.topology=this.topology}reset(){this.applyTransform=!0,this.renderable=null,this.topology="triangle-list"}destroy(){this.renderable=null,this.texture=null,this.geometryData=null,this._batcher.destroy(),this._batcher=null,this._batch.destroy(),this._batch=null}}},5024:(t,e,r)=>{"use strict";r.d(e,{T:()=>d,w:()=>u});var s=r(6675),i=r(9739),n=r(6406),o=r(9776);function a(t){return t instanceof o.m}function l(t){return t instanceof n._}function h(t,e,r){return t.fill=e,t.color=16777215,t.texture=e.texture,t.matrix=e.transform,{...r,...t}}function c(t,e,r){return e.buildGradient(),t.fill=e,t.color=16777215,t.texture=e.texture,t.matrix=e.transform,t.textureSpace=e.textureSpace,{...r,...t}}function u(t,e){if(null==t)return null;const r={},n=t;return function(t){return s.Q.isColorLike(t)}(t)?function(t,e,r){const n=s.Q.shared.setValue(e??0);return t.color=n.toNumber(),t.alpha=1===n.alpha?r.alpha:n.alpha,t.texture=i.g.WHITE,{...r,...t}}(r,t,e):function(t){return t instanceof i.g}(t)?function(t,e,r){return t.texture=e,{...r,...t}}(r,t,e):a(t)?h(r,t,e):l(t)?c(r,t,e):n.fill&&a(n.fill)?h(n,n.fill,e):n.fill&&l(n.fill)?c(n,n.fill,e):function(t,e){const r={...e,...t},i=s.Q.shared.setValue(r.color);return r.alpha*=i.alpha,r.color=i.toNumber(),r}(n,e)}function d(t,e){const{width:r,alignment:s,miterLimit:i,cap:n,join:o,pixelLine:a,...l}=e,h=u(t,l);return h?{width:r,alignment:s,miterLimit:i,cap:n,join:o,pixelLine:a,...h}:null}},5105:(t,e,r)=>{"use strict";r.d(e,{x:()=>p});var s=r(4872),i=r(6675),n=r(9375),o=r(4696),a=r(7694),l=r(6406),h=r(9776),c=r(4386),u=r(5024);const d=class t extends s.A{constructor(e={}){super(),this.uid=(0,n.L)("textStyle"),this._tick=0,function(t){const e=t;if("boolean"==typeof e.dropShadow&&e.dropShadow){const r=p.defaultDropShadow;t.dropShadow={alpha:e.dropShadowAlpha??r.alpha,angle:e.dropShadowAngle??r.angle,blur:e.dropShadowBlur??r.blur,color:e.dropShadowColor??r.color,distance:e.dropShadowDistance??r.distance}}if(void 0!==e.strokeThickness){(0,o.t6)(o.lj,"strokeThickness is now a part of stroke");const r=e.stroke;let s={};if(i.Q.isColorLike(r))s.color=r;else if(r instanceof l._||r instanceof h.m)s.fill=r;else{if(!Object.hasOwnProperty.call(r,"color")&&!Object.hasOwnProperty.call(r,"fill"))throw new Error("Invalid stroke value.");s=r}t.stroke={...s,width:e.strokeThickness}}if(Array.isArray(e.fillGradientStops)){if((0,o.t6)(o.lj,"gradient fill is now a fill pattern: `new FillGradient(...)`"),!Array.isArray(e.fill)||0===e.fill.length)throw new Error("Invalid fill value. Expected an array of colors for gradient fill.");e.fill.length!==e.fillGradientStops.length&&(0,a.R)("The number of fill colors must match the number of fill gradient stops.");const r=new l._({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),s=e.fillGradientStops.slice(),n=e.fill.map(t=>i.Q.shared.setValue(t).toNumber());s.forEach((t,e)=>{r.addColorStop(t,n[e])}),t.fill={fill:r}}}(e);const r={...t.defaultTextStyle,...e};for(const t in r)this[t]=r[t];this.update(),this._tick=0}get align(){return this._align}set align(t){this._align=t,this.update()}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords=t,this.update()}get dropShadow(){return this._dropShadow}set dropShadow(e){this._dropShadow=null!==e&&"object"==typeof e?this._createProxy({...t.defaultDropShadow,...e}):e?this._createProxy({...t.defaultDropShadow}):null,this.update()}get fontFamily(){return this._fontFamily}set fontFamily(t){this._fontFamily=t,this.update()}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize="string"==typeof t?parseInt(t,10):t,this.update()}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle=t.toLowerCase(),this.update()}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant=t,this.update()}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight=t,this.update()}get leading(){return this._leading}set leading(t){this._leading=t,this.update()}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing=t,this.update()}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight=t,this.update()}get padding(){return this._padding}set padding(t){this._padding=t,this.update()}get filters(){return this._filters}set filters(t){this._filters=Object.freeze(t),this.update()}get trim(){return this._trim}set trim(t){this._trim=t,this.update()}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline=t,this.update()}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace=t,this.update()}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap=t,this.update()}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth=t,this.update()}get fill(){return this._originalFill}set fill(t){t!==this._originalFill&&(this._originalFill=t,this._isFillStyle(t)&&(this._originalFill=this._createProxy({...c.T.defaultFillStyle,...t},()=>{this._fill=(0,u.w)({...this._originalFill},c.T.defaultFillStyle)})),this._fill=(0,u.w)(0===t?"black":t,c.T.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy({...c.T.defaultStrokeStyle,...t},()=>{this._stroke=(0,u.T)({...this._originalStroke},c.T.defaultStrokeStyle)})),this._stroke=(0,u.T)(t,c.T.defaultStrokeStyle),this.update())}update(){this._tick++,this.emit("update",this)}reset(){const e=t.defaultTextStyle;for(const t in e)this[t]=e[t]}get styleKey(){return`${this.uid}-${this._tick}`}clone(){return new t({align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?{...this._dropShadow}:null,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,textBaseline:this.textBaseline,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,filters:this._filters?[...this._filters]:void 0})}_getFinalPadding(){let t=0;if(this._filters)for(let e=0;e<this._filters.length;e++)t+=this._filters[e].padding;return Math.max(this._padding,t)}destroy(t=!1){if(this.removeAllListeners(),"boolean"==typeof t?t:t?.texture){const e="boolean"==typeof t?t:t?.textureSource;this._fill?.texture&&this._fill.texture.destroy(e),this._originalFill?.texture&&this._originalFill.texture.destroy(e),this._stroke?.texture&&this._stroke.texture.destroy(e),this._originalStroke?.texture&&this._originalStroke.texture.destroy(e)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(t,e){return new Proxy(t,{set:(t,r,s)=>(t[r]=s,e?.(r,s),this.update(),!0)})}_isFillStyle(t){return null!==(t??null)&&!(i.Q.isColorLike(t)||t instanceof l._||t instanceof h.m)}};d.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5},d.defaultTextStyle={align:"left",breakWords:!1,dropShadow:null,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,padding:0,stroke:null,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let p=d},5153:(t,e,r)=>{"use strict";r.d(e,{W:()=>s});var s=(t=>(t[t.WEBGL=1]="WEBGL",t[t.WEBGPU=2]="WEBGPU",t[t.BOTH=3]="BOTH",t))(s||{})},5180:(t,e,r)=>{"use strict";r.d(e,{C:()=>n});var s=r(5423);let i;async function n(){return i??(i=(async()=>{const t=s.e.get().createCanvas(1,1).getContext("webgl");if(!t)return"premultiply-alpha-on-upload";const e=await new Promise(t=>{const e=document.createElement("video");e.onloadeddata=()=>t(e),e.onerror=()=>t(null),e.autoplay=!1,e.crossOrigin="anonymous",e.preload="auto",e.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",e.load()});if(!e)return"premultiply-alpha-on-upload";const r=t.createTexture();t.bindTexture(t.TEXTURE_2D,r);const i=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,i),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,r,0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.NONE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e);const n=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,n),t.deleteFramebuffer(i),t.deleteTexture(r),t.getExtension("WEBGL_lose_context")?.loseContext(),n[0]<=n[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),i}},5199:(t,e,r)=>{"use strict";r.d(e,{u:()=>n});var s=r(4614),i=r(59);class n{constructor(t=1,e=0,r=0,s=1,i=0,n=0){this.array=null,this.a=t,this.b=e,this.c=r,this.d=s,this.tx=i,this.ty=n}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,e,r,s,i,n){return this.a=t,this.b=e,this.c=r,this.d=s,this.tx=i,this.ty=n,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const r=e||this.array;return t?(r[0]=this.a,r[1]=this.b,r[2]=0,r[3]=this.c,r[4]=this.d,r[5]=0,r[6]=this.tx,r[7]=this.ty,r[8]=1):(r[0]=this.a,r[1]=this.c,r[2]=this.tx,r[3]=this.b,r[4]=this.d,r[5]=this.ty,r[6]=0,r[7]=0,r[8]=1),r}apply(t,e){e=e||new i.b;const r=t.x,s=t.y;return e.x=this.a*r+this.c*s+this.tx,e.y=this.b*r+this.d*s+this.ty,e}applyInverse(t,e){e=e||new i.b;const r=this.a,s=this.b,n=this.c,o=this.d,a=this.tx,l=this.ty,h=1/(r*o+n*-s),c=t.x,u=t.y;return e.x=o*h*c+-n*h*u+(l*n-a*o)*h,e.y=r*h*u+-s*h*c+(-l*r+a*s)*h,e}translate(t,e){return this.tx+=t,this.ty+=e,this}scale(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this}rotate(t){const e=Math.cos(t),r=Math.sin(t),s=this.a,i=this.c,n=this.tx;return this.a=s*e-this.b*r,this.b=s*r+this.b*e,this.c=i*e-this.d*r,this.d=i*r+this.d*e,this.tx=n*e-this.ty*r,this.ty=n*r+this.ty*e,this}append(t){const e=this.a,r=this.b,s=this.c,i=this.d;return this.a=t.a*e+t.b*s,this.b=t.a*r+t.b*i,this.c=t.c*e+t.d*s,this.d=t.c*r+t.d*i,this.tx=t.tx*e+t.ty*s+this.tx,this.ty=t.tx*r+t.ty*i+this.ty,this}appendFrom(t,e){const r=t.a,s=t.b,i=t.c,n=t.d,o=t.tx,a=t.ty,l=e.a,h=e.b,c=e.c,u=e.d;return this.a=r*l+s*c,this.b=r*h+s*u,this.c=i*l+n*c,this.d=i*h+n*u,this.tx=o*l+a*c+e.tx,this.ty=o*h+a*u+e.ty,this}setTransform(t,e,r,s,i,n,o,a,l){return this.a=Math.cos(o+l)*i,this.b=Math.sin(o+l)*i,this.c=-Math.sin(o-a)*n,this.d=Math.cos(o-a)*n,this.tx=t-(r*this.a+s*this.c),this.ty=e-(r*this.b+s*this.d),this}prepend(t){const e=this.tx;if(1!==t.a||0!==t.b||0!==t.c||1!==t.d){const e=this.a,r=this.c;this.a=e*t.a+this.b*t.c,this.b=e*t.b+this.b*t.d,this.c=r*t.a+this.d*t.c,this.d=r*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const e=this.a,r=this.b,i=this.c,n=this.d,o=t.pivot,a=-Math.atan2(-i,n),l=Math.atan2(r,e),h=Math.abs(a+l);return h<1e-5||Math.abs(s.TO-h)<1e-5?(t.rotation=l,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=a,t.skew.y=l),t.scale.x=Math.sqrt(e*e+r*r),t.scale.y=Math.sqrt(i*i+n*n),t.position.x=this.tx+(o.x*e+o.y*i),t.position.y=this.ty+(o.x*r+o.y*n),t}invert(){const t=this.a,e=this.b,r=this.c,s=this.d,i=this.tx,n=t*s-e*r;return this.a=s/n,this.b=-e/n,this.c=-r/n,this.d=t/n,this.tx=(r*this.ty-s*i)/n,this.ty=-(t*this.ty-e*i)/n,this}isIdentity(){return 1===this.a&&0===this.b&&0===this.c&&1===this.d&&0===this.tx&&0===this.ty}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const t=new n;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyTo(t){return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyFrom(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this}equals(t){return t.a===this.a&&t.b===this.b&&t.c===this.c&&t.d===this.d&&t.tx===this.tx&&t.ty===this.ty}toString(){return`[pixi.js:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`}static get IDENTITY(){return a.identity()}static get shared(){return o.identity()}}const o=new n,a=new n},5353:(t,e,r)=>{"use strict";function s(t,e,r,s){const i={width:0,height:0,offsetY:0,scale:e.fontSize/r.baseMeasurementFontSize,lines:[{width:0,charPositions:[],spaceWidth:0,spacesIndex:[],chars:[]}]};i.offsetY=r.baseLineOffset;let n=i.lines[0],o=null,a=!0;const l={spaceWord:!1,width:0,start:0,index:0,positions:[],chars:[]},h=r.baseMeasurementFontSize/e.fontSize,c=e.letterSpacing*h,u=e.wordWrapWidth*h,d=e.lineHeight?e.lineHeight*h:r.lineHeight,p=e.wordWrap&&e.breakWords,f=t=>{const e=n.width;for(let r=0;r<l.index;r++){const s=t.positions[r];n.chars.push(t.chars[r]),n.charPositions.push(s+e)}n.width+=t.width,a=!1,l.width=0,l.index=0,l.chars.length=0},g=()=>{let t=n.chars.length-1;if(s){let e=n.chars[t];for(;" "===e;)n.width-=r.chars[e].xAdvance,e=n.chars[--t]}i.width=Math.max(i.width,n.width),n={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},a=!0,i.lines.push(n),i.height+=d},m=t=>t-c>u;for(let s=0;s<t.length+1;s++){let i;const h=s===t.length;h||(i=t[s]);const u=r.chars[i]||r.chars[" "];if(/(?:\s)/.test(i)||"\r"===i||"\n"===i||h){if(!a&&e.wordWrap&&m(n.width+l.width)?(g(),f(l),h||n.charPositions.push(0)):(l.start=n.width,f(l),h||n.charPositions.push(0)),"\r"===i||"\n"===i)g();else if(!h){const t=u.xAdvance+(u.kerning[o]||0)+c;n.width+=t,n.spaceWidth=t,n.spacesIndex.push(n.charPositions.length),n.chars.push(i)}}else{const t=u.kerning[o]||0,e=u.xAdvance+t+c;p&&m(n.width+l.width+e)&&(f(l),g()),l.positions[l.index++]=l.width+t,l.chars.push(i),l.width+=e}o=i}return g(),"center"===e.align?function(t){for(let e=0;e<t.lines.length;e++){const r=t.lines[e],s=t.width/2-r.width/2;for(let t=0;t<r.charPositions.length;t++)r.charPositions[t]+=s}}(i):"right"===e.align?function(t){for(let e=0;e<t.lines.length;e++){const r=t.lines[e],s=t.width-r.width;for(let t=0;t<r.charPositions.length;t++)r.charPositions[t]+=s}}(i):"justify"===e.align&&function(t){const e=t.width;for(let r=0;r<t.lines.length;r++){const s=t.lines[r];let i=0,n=s.spacesIndex[i++],o=0;const a=s.spacesIndex.length,l=(e-s.width)/a;for(let t=0;t<s.charPositions.length;t++)t===n&&(n=s.spacesIndex[i++],o+=l),s.charPositions[t]+=o}}(i),i}r.d(e,{Z:()=>s})},5423:(t,e,r)=>{"use strict";r.d(e,{e:()=>i});let s={createCanvas:(t,e)=>{const r=document.createElement("canvas");return r.width=t,r.height=e,r},createImage:()=>new Image,getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(t,e)=>fetch(t,e),parseXML:t=>(new DOMParser).parseFromString(t,"text/xml")};const i={get:()=>s,set(t){s=t}}},5749:(t,e,r)=>{"use strict";r.d(e,{$:()=>l});var s=r(1065),i=r(3651),n=r(5180),o=r(4269);const a=class t extends o.v{constructor(e){super(e),this.isReady=!1,this.uploadMethodId="video",e={...t.defaultOptions,...e},this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=e.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=!1!==e.autoPlay,this.alphaMode=e.alphaMode??"premultiply-alpha-on-upload",this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onCanPlayThrough=this._onCanPlayThrough.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),!1!==e.autoLoad&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const t=i.R.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t)}(!this._updateFPS||this._msToNextUpdate<=0)&&(this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0),this.isValid&&this.update()}}_videoFrameRequestCallback(){this.updateFrame(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}async load(){if(this._load)return this._load;const t=this.resource,e=this.options;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(e.preload||t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlayThrough),t.addEventListener("error",this._onError,!0)),this.alphaMode=await(0,n.C)(),this._load=new Promise((r,s)=>{this.isValid?r(this):(this._resolve=r,this._reject=s,void 0!==e.preloadTimeoutMs&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${e.preloadTimeoutMs}ms`))})),t.load())}),this._load}_onError(t){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.resource;return!t.paused&&!t.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this.isValid||this._mediaReady(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlay),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const t=this.resource;this.isValid&&(this.isReady=!0,this.resize(t.videoWidth,t.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();const t=this.resource;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlayThrough),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(i.R.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),null===this._videoFrameRequestCallbackHandle&&(this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback))):(null!==this._videoFrameRequestCallbackHandle&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(i.R.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(null!==this._videoFrameRequestCallbackHandle&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(i.R.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};a.extension=s.Ag.TextureSource,a.defaultOptions={...o.v.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1},a.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let l=a},5946:(t,e,r)=>{"use strict";function s(t,e){return 16777215!==t&&e?16777215!==e&&t?((t>>16&255)*(e>>16&255)/255<<16)+((t>>8&255)*(e>>8&255)/255<<8)+((255&t)*(255&e)/255|0):t:e}r.d(e,{u:()=>s})},5947:(t,e,r)=>{"use strict";r.d(e,{b:()=>n});var s=r(1065),i=r(4269);class n extends i.v{constructor(t){super(t),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(t){return globalThis.HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap||globalThis.VideoFrame&&t instanceof VideoFrame}}n.extension=s.Ag.TextureSource},6114:(t,e,r)=>{"use strict";r.d(e,{k:()=>m});var s=r(6675),i=r(1065);const n=[];i.XO.handleByNamedList(i.Ag.Environment,n);var o=r(4687),a=r(8883),l=r(9375),h=r(4696),c=r(1753),u=r(1711),d=r(2255),p=r(4872);const f=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],g=class t extends p.A{constructor(t){super(),this.uid=(0,l.L)("renderer"),this.runners=Object.create(null),this.renderPipes=Object.create(null),this._initOptions={},this._systemsHash=Object.create(null),this.type=t.type,this.name=t.name,this.config=t;const e=[...f,...this.config.runners??[]];this._addRunners(...e),this._unsafeEvalCheck()}async init(e={}){const r=!0===e.skipExtensionImports||!1===e.manageImports;await async function(t){if(!t)for(let t=0;t<n.length;t++){const e=n[t];if(e.value.test())return void await e.value.load()}}(r),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const t in this._systemsHash)e={...this._systemsHash[t].constructor.defaultOptions,...e};e={...t.defaultOptions,...e},this._roundPixels=e.roundPixels?1:0;for(let t=0;t<this.runners.init.items.length;t++)await this.runners.init.items[t].init(e);this._initOptions=e}render(t,e){let r=t;if(r instanceof o.mc&&(r={container:r},e&&((0,h.t6)(h.lj,"passing a second argument is deprecated, please use render options instead"),r.target=e.renderTexture)),r.target||(r.target=this.view.renderTarget),r.target===this.view.renderTarget&&(this._lastObjectRendered=r.container,r.clearColor??(r.clearColor=this.background.colorRgba),r.clear??(r.clear=this.background.clearBeforeRender)),r.clearColor){const t=Array.isArray(r.clearColor)&&4===r.clearColor.length;r.clearColor=t?r.clearColor:s.Q.shared.setValue(r.clearColor).toArray()}r.transform||(r.container.updateLocalTransform(),r.transform=r.container.localTransform),r.container.visible&&(r.container.enableRenderGroup(),this.runners.prerender.emit(r),this.runners.renderStart.emit(r),this.runners.render.emit(r),this.runners.renderEnd.emit(r),this.runners.postrender.emit(r))}resize(t,e,r){const s=this.view.resolution;this.view.resize(t,e,r),this.emit("resize",this.view.screen.width,this.view.screen.height,this.view.resolution),void 0!==r&&r!==s&&this.runners.resolutionChange.emit(r)}clear(t={}){t.target||(t.target=this.renderTarget.renderTarget),t.clearColor||(t.clearColor=this.background.colorRgba),t.clear??(t.clear=u.u.ALL);const{clear:e,clearColor:r,target:i}=t;s.Q.shared.setValue(r??this.background.colorRgba),this.renderTarget.clear(i,e,s.Q.shared.toArray())}get resolution(){return this.view.resolution}set resolution(t){this.view.resolution=t,this.runners.resolutionChange.emit(t)}get width(){return this.view.texture.frame.width}get height(){return this.view.texture.frame.height}get canvas(){return this.view.canvas}get lastObjectRendered(){return this._lastObjectRendered}get renderingToScreen(){return this.renderTarget.renderingToScreen}get screen(){return this.view.screen}_addRunners(...t){t.forEach(t=>{this.runners[t]=new d.C(t)})}_addSystems(t){let e;for(e in t){const r=t[e];this._addSystem(r.value,r.name)}}_addSystem(t,e){const r=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=r,this._systemsHash[e]=r;for(const t in this.runners)this.runners[t].add(r);return this}_addPipes(t,e){const r=e.reduce((t,e)=>(t[e.name]=e.value,t),{});t.forEach(t=>{const e=t.value,s=t.name,i=r[s];this.renderPipes[s]=new e(this,i?new i:null),this.runners.destroy.add(this.renderPipes[s])})}destroy(t=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(t),Object.values(this.runners).forEach(t=>{t.destroy()}),(!0===t||"object"==typeof t&&t.releaseGlobalResources)&&c.L.release(),this._systemsHash=null,this.renderPipes=null}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!(0,a.f)())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}resetState(){this.runners.resetState.emit()}};g.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let m=g},6131:(t,e,r)=>{"use strict";var s=r(1065);class i{execute(t,e){const r=t.state,s=t.renderer,i=e.shader||t.defaultShader;i.resources.uTexture=e.texture._source,i.resources.uniforms=t.localUniforms;const n=s.gl,o=t.getBuffers(e);s.shader.bind(i),s.state.set(r),s.geometry.bind(o.geometry,i.glProgram);const a=2===o.geometry.indexBuffer.data.BYTES_PER_ELEMENT?n.UNSIGNED_SHORT:n.UNSIGNED_INT;n.drawElements(n.TRIANGLES,6*e.particleChildren.length,a,0)}}var n=r(5199),o=r(4449),a=r(3769),l=r(7433),h=r(9482),c=r(1579),u=r(9798),d=r(8337),p=r(4988),f=r(4142);function g(t,e=null){const r=6*t;if(r>65535?e||(e=new Uint32Array(r)):e||(e=new Uint16Array(r)),e.length!==r)throw new Error(`Out buffer length is incorrect, got ${e.length} and expected ${r}`);for(let t=0,s=0;t<r;t+=6,s+=4)e[t+0]=s+0,e[t+1]=s+1,e[t+2]=s+2,e[t+3]=s+0,e[t+4]=s+2,e[t+5]=s+3;return e}function m(t,e){const r=[];r.push("\n\n var index = 0;\n\n for (let i = 0; i < ps.length; ++i)\n {\n const p = ps[i];\n\n ");let s=0;for(const i in t){const n=t[i];e===n.dynamic&&(r.push(`offset = index + ${s}`),r.push(n.code),s+=(0,p.m)(n.format).stride/4)}r.push("\n index += stride * 4;\n }\n "),r.unshift(`\n var stride = ${s};\n `);const i=r.join("\n");return new Function("ps","f32v","u32v",i)}class x{constructor(t){this._size=0,this._generateParticleUpdateCache={};const e=this._size=t.size??1e3,r=t.properties;let s=0,i=0;for(const t in r){const e=r[t],n=(0,p.m)(e.format);e.dynamic?i+=n.stride:s+=n.stride}this._dynamicStride=i/4,this._staticStride=s/4,this.staticAttributeBuffer=new f.u(4*e*s),this.dynamicAttributeBuffer=new f.u(4*e*i),this.indexBuffer=g(e);const n=new d.V;let o=0,a=0;this._staticBuffer=new c.h({data:new Float32Array(1),label:"static-particle-buffer",shrinkToFit:!1,usage:u.S.VERTEX|u.S.COPY_DST}),this._dynamicBuffer=new c.h({data:new Float32Array(1),label:"dynamic-particle-buffer",shrinkToFit:!1,usage:u.S.VERTEX|u.S.COPY_DST});for(const t in r){const e=r[t],s=(0,p.m)(e.format);e.dynamic?(n.addAttribute(e.attributeName,{buffer:this._dynamicBuffer,stride:4*this._dynamicStride,offset:4*o,format:e.format}),o+=s.size):(n.addAttribute(e.attributeName,{buffer:this._staticBuffer,stride:4*this._staticStride,offset:4*a,format:e.format}),a+=s.size)}n.addIndex(this.indexBuffer);const l=this.getParticleUpdate(r);this._dynamicUpload=l.dynamicUpdate,this._staticUpload=l.staticUpdate,this.geometry=n}getParticleUpdate(t){const e=function(t){const e=[];for(const r in t){const s=t[r];e.push(r,s.code,s.dynamic?"d":"s")}return e.join("_")}(t);return this._generateParticleUpdateCache[e]||(this._generateParticleUpdateCache[e]=this.generateParticleUpdate(t)),this._generateParticleUpdateCache[e]}generateParticleUpdate(t){return function(t){return{dynamicUpdate:m(t,!0),staticUpdate:m(t,!1)}}(t)}update(t,e){t.length>this._size&&(e=!0,this._size=Math.max(t.length,1.5*this._size|0),this.staticAttributeBuffer=new f.u(this._size*this._staticStride*4*4),this.dynamicAttributeBuffer=new f.u(this._size*this._dynamicStride*4*4),this.indexBuffer=g(this._size),this.geometry.indexBuffer.setDataWithSize(this.indexBuffer,this.indexBuffer.byteLength,!0));const r=this.dynamicAttributeBuffer;if(this._dynamicUpload(t,r.float32View,r.uint32View),this._dynamicBuffer.setDataWithSize(this.dynamicAttributeBuffer.float32View,t.length*this._dynamicStride*4,!0),e){const e=this.staticAttributeBuffer;this._staticUpload(t,e.float32View,e.uint32View),this._staticBuffer.setDataWithSize(e.float32View,t.length*this._staticStride*4,!0)}}destroy(){this._staticBuffer.destroy(),this._dynamicBuffer.destroy(),this.geometry.destroy()}}var _=r(6675),y=r(5007),v=r(1790),b=r(1657),w=r(9739),T=r(8896),S="\nstruct ParticleUniforms {\n uTranslationMatrix:mat3x3<f32>,\n uColor:vec4<f32>,\n uRound:f32,\n uResolution:vec2<f32>,\n};\n\nfn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>\n{\n return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;\n}\n\n@group(0) @binding(0) var<uniform> uniforms: ParticleUniforms;\n\n@group(1) @binding(0) var uTexture: texture_2d<f32>;\n@group(1) @binding(1) var uSampler : sampler;\n\nstruct VSOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>,\n @location(1) color : vec4<f32>,\n };\n@vertex\nfn mainVertex(\n @location(0) aVertex: vec2<f32>,\n @location(1) aPosition: vec2<f32>,\n @location(2) aUV: vec2<f32>,\n @location(3) aColor: vec4<f32>,\n @location(4) aRotation: f32,\n) -> VSOutput {\n \n let v = vec2(\n aVertex.x * cos(aRotation) - aVertex.y * sin(aRotation),\n aVertex.x * sin(aRotation) + aVertex.y * cos(aRotation)\n ) + aPosition;\n\n var position = vec4((uniforms.uTranslationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);\n\n if(uniforms.uRound == 1.0) {\n position = vec4(roundPixels(position.xy, uniforms.uResolution), position.zw);\n }\n\n let vColor = vec4(aColor.rgb * aColor.a, aColor.a) * uniforms.uColor;\n\n return VSOutput(\n position,\n aUV,\n vColor,\n );\n}\n\n@fragment\nfn mainFragment(\n @location(0) uv: vec2<f32>,\n @location(1) color: vec4<f32>,\n @builtin(position) position: vec4<f32>,\n) -> @location(0) vec4<f32> {\n\n var sample = textureSample(uTexture, uSampler, uv) * color;\n \n return sample;\n}";class A extends b.M{constructor(){super({glProgram:y.M.from({vertex:"attribute vec2 aVertex;\nattribute vec2 aUV;\nattribute vec4 aColor;\n\nattribute vec2 aPosition;\nattribute float aRotation;\n\nuniform mat3 uTranslationMatrix;\nuniform float uRound;\nuniform vec2 uResolution;\nuniform vec4 uColor;\n\nvarying vec2 vUV;\nvarying vec4 vColor;\n\nvec2 roundPixels(vec2 position, vec2 targetSize)\n{ \n return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;\n}\n\nvoid main(void){\n float cosRotation = cos(aRotation);\n float sinRotation = sin(aRotation);\n float x = aVertex.x * cosRotation - aVertex.y * sinRotation;\n float y = aVertex.x * sinRotation + aVertex.y * cosRotation;\n\n vec2 v = vec2(x, y);\n v = v + aPosition;\n\n gl_Position = vec4((uTranslationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);\n\n if(uRound == 1.0)\n {\n gl_Position.xy = roundPixels(gl_Position.xy, uResolution);\n }\n\n vUV = aUV;\n vColor = vec4(aColor.rgb * aColor.a, aColor.a) * uColor;\n}\n",fragment:"varying vec2 vUV;\nvarying vec4 vColor;\n\nuniform sampler2D uTexture;\n\nvoid main(void){\n vec4 color = texture2D(uTexture, vUV) * vColor;\n gl_FragColor = color;\n}"}),gpuProgram:v.B.from({fragment:{source:S,entryPoint:"mainFragment"},vertex:{source:S,entryPoint:"mainVertex"}}),resources:{uTexture:w.g.WHITE.source,uSampler:new T.n({}),uniforms:{uTranslationMatrix:{value:new n.u,type:"mat3x3<f32>"},uColor:{value:new _.Q(16777215),type:"vec4<f32>"},uRound:{value:1,type:"f32"},uResolution:{value:[0,0],type:"vec2<f32>"}}}})}}class C{constructor(t,e){this.state=l.U.for2d(),this.localUniforms=new o.k({uTranslationMatrix:{value:new n.u,type:"mat3x3<f32>"},uColor:{value:new Float32Array(4),type:"vec4<f32>"},uRound:{value:1,type:"f32"},uResolution:{value:[0,0],type:"vec2<f32>"}}),this.renderer=t,this.adaptor=e,this.defaultShader=new A,this.state=l.U.for2d()}validateRenderable(t){return!1}addRenderable(t,e){this.renderer.renderPipes.batch.break(e),e.add(t)}getBuffers(t){return t._gpuData[this.renderer.uid]||this._initBuffer(t)}_initBuffer(t){return t._gpuData[this.renderer.uid]=new x({size:t.particleChildren.length,properties:t._properties}),t._gpuData[this.renderer.uid]}updateRenderable(t){}execute(t){const e=t.particleChildren;if(0===e.length)return;const r=this.renderer,s=this.getBuffers(t);t.texture||(t.texture=e[0].texture);const i=this.state;s.update(e,t._childrenDirty),t._childrenDirty=!1,i.blendMode=(0,a.i)(t.blendMode,t.texture._source);const n=this.localUniforms.uniforms,o=n.uTranslationMatrix;t.worldTransform.copyTo(o),o.prepend(r.globalUniforms.globalUniformData.projectionMatrix),n.uResolution=r.globalUniforms.globalUniformData.resolution,n.uRound=r._roundPixels|t._roundPixels,(0,h.V)(t.groupColorAlpha,n.uColor,0),this.adaptor.execute(this,t)}destroy(){this.renderer=null,this.defaultShader&&(this.defaultShader.destroy(),this.defaultShader=null)}}class P extends C{constructor(t){super(t,new i)}}P.extension={type:[s.Ag.WebGLPipes],name:"particle"};class M{execute(t,e){const r=t.renderer,s=e.shader||t.defaultShader;s.groups[0]=r.renderPipes.uniformBatch.getUniformBindGroup(t.localUniforms,!0),s.groups[1]=r.texture.getTextureBindGroup(e.texture);const i=t.state,n=t.getBuffers(e);r.encoder.draw({geometry:n.geometry,shader:e.shader||t.defaultShader,state:i,size:6*e.particleChildren.length})}}class E extends C{constructor(t){super(t,new M)}}E.extension={type:[s.Ag.WebGPUPipes],name:"particle"},s.XO.add(P),s.XO.add(E)},6170:(t,e,r)=>{"use strict";r.d(e,{c:()=>o});var s=r(5199),i=r(9390);const n=new s.u;class o{constructor(t=1/0,e=1/0,r=-1/0,s=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=n,this.minX=t,this.minY=e,this.maxX=r,this.maxY=s}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new i.M);const t=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(t.x=0,t.y=0,t.width=0,t.height=0):t.copyFromBounds(this),t}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=n,this}set(t,e,r,s){this.minX=t,this.minY=e,this.maxX=r,this.maxY=s}addFrame(t,e,r,s,i){i||(i=this.matrix);const n=i.a,o=i.b,a=i.c,l=i.d,h=i.tx,c=i.ty;let u=this.minX,d=this.minY,p=this.maxX,f=this.maxY,g=n*t+a*e+h,m=o*t+l*e+c;g<u&&(u=g),m<d&&(d=m),g>p&&(p=g),m>f&&(f=m),g=n*r+a*e+h,m=o*r+l*e+c,g<u&&(u=g),m<d&&(d=m),g>p&&(p=g),m>f&&(f=m),g=n*t+a*s+h,m=o*t+l*s+c,g<u&&(u=g),m<d&&(d=m),g>p&&(p=g),m>f&&(f=m),g=n*r+a*s+h,m=o*r+l*s+c,g<u&&(u=g),m<d&&(d=m),g>p&&(p=g),m>f&&(f=m),this.minX=u,this.minY=d,this.maxX=p,this.maxY=f}addRect(t,e){this.addFrame(t.x,t.y,t.x+t.width,t.y+t.height,e)}addBounds(t,e){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,e)}addBoundsMask(t){this.minX=this.minX>t.minX?this.minX:t.minX,this.minY=this.minY>t.minY?this.minY:t.minY,this.maxX=this.maxX<t.maxX?this.maxX:t.maxX,this.maxY=this.maxY<t.maxY?this.maxY:t.maxY}applyMatrix(t){const e=this.minX,r=this.minY,s=this.maxX,i=this.maxY,{a:n,b:o,c:a,d:l,tx:h,ty:c}=t;let u=n*e+a*r+h,d=o*e+l*r+c;this.minX=u,this.minY=d,this.maxX=u,this.maxY=d,u=n*s+a*r+h,d=o*s+l*r+c,this.minX=u<this.minX?u:this.minX,this.minY=d<this.minY?d:this.minY,this.maxX=u>this.maxX?u:this.maxX,this.maxY=d>this.maxY?d:this.maxY,u=n*e+a*i+h,d=o*e+l*i+c,this.minX=u<this.minX?u:this.minX,this.minY=d<this.minY?d:this.minY,this.maxX=u>this.maxX?u:this.maxX,this.maxY=d>this.maxY?d:this.maxY,u=n*s+a*i+h,d=o*s+l*i+c,this.minX=u<this.minX?u:this.minX,this.minY=d<this.minY?d:this.minY,this.maxX=u>this.maxX?u:this.maxX,this.maxY=d>this.maxY?d:this.maxY}fit(t){return this.minX<t.left&&(this.minX=t.left),this.maxX>t.right&&(this.maxX=t.right),this.minY<t.top&&(this.minY=t.top),this.maxY>t.bottom&&(this.maxY=t.bottom),this}fitBounds(t,e,r,s){return this.minX<t&&(this.minX=t),this.maxX>e&&(this.maxX=e),this.minY<r&&(this.minY=r),this.maxY>s&&(this.maxY=s),this}pad(t,e=t){return this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e,this}ceil(){return this.minX=Math.floor(this.minX),this.minY=Math.floor(this.minY),this.maxX=Math.ceil(this.maxX),this.maxY=Math.ceil(this.maxY),this}clone(){return new o(this.minX,this.minY,this.maxX,this.maxY)}scale(t,e=t){return this.minX*=t,this.minY*=e,this.maxX*=t,this.maxY*=e,this}get x(){return this.minX}set x(t){const e=this.maxX-this.minX;this.minX=t,this.maxX=t+e}get y(){return this.minY}set y(t){const e=this.maxY-this.minY;this.minY=t,this.maxY=t+e}get width(){return this.maxX-this.minX}set width(t){this.maxX=this.minX+t}get height(){return this.maxY-this.minY}set height(t){this.maxY=this.minY+t}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(t,e,r,s){let i=this.minX,n=this.minY,o=this.maxX,a=this.maxY;s||(s=this.matrix);const l=s.a,h=s.b,c=s.c,u=s.d,d=s.tx,p=s.ty;for(let s=e;s<r;s+=2){const e=t[s],r=t[s+1],f=l*e+c*r+d,g=h*e+u*r+p;i=f<i?f:i,n=g<n?g:n,o=f>o?f:o,a=g>a?g:a}this.minX=i,this.minY=n,this.maxX=o,this.maxY=a}containsPoint(t,e){return this.minX<=t&&this.minY<=e&&this.maxX>=t&&this.maxY>=e}toString(){return`[pixi.js:Bounds minX=${this.minX} minY=${this.minY} maxX=${this.maxX} maxY=${this.maxY} width=${this.width} height=${this.height}]`}copyFrom(t){return this.minX=t.minX,this.minY=t.minY,this.maxX=t.maxX,this.maxY=t.maxY,this}}},6185:(t,e,r)=>{"use strict";r.d(e,{P:()=>n});var s=r(1065),i=r(4269);class n extends i.v{constructor(t){const e=t.resource||new Float32Array(t.width*t.height*4);let r=t.format;r||(r=e instanceof Float32Array?"rgba32float":e instanceof Int32Array||e instanceof Uint32Array?"rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?"rgba16uint":(Int8Array,"bgra8unorm")),super({...t,resource:e,format:r}),this.uploadMethodId="buffer"}static test(t){return t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}n.extension=s.Ag.TextureSource},6364:(t,e,r)=>{"use strict";r.d(e,{GH:()=>ct});var s=r(1065),i=r(2791),n=r(4404),o=r(4582),a=r(4696),l=r(761),h=r(5199),c=r(9390);function u(t,e,r,s,i){const n=e.a,o=e.b,a=e.c,l=e.d,h=e.tx,c=e.ty;r||(r=0),s||(s=2),i||(i=t.length/s-r);let u=r*s;for(let e=0;e<i;e++){const e=t[u],r=t[u+1];t[u]=n*e+a*r+h,t[u+1]=o*e+l*r+c,u+=s}}var d=r(9739),p=r(5008);const f={extension:{type:s.Ag.ShapeBuilder,name:"circle"},build(t,e){let r,s,i,n,o,a;if("circle"===t.type){const e=t;if(o=a=e.radius,o<=0)return!1;r=e.x,s=e.y,i=n=0}else if("ellipse"===t.type){const e=t;if(o=e.halfWidth,a=e.halfHeight,o<=0||a<=0)return!1;r=e.x,s=e.y,i=n=0}else{const e=t,l=e.width/2,h=e.height/2;r=e.x+l,s=e.y+h,o=a=Math.max(0,Math.min(e.radius,Math.min(l,h))),i=l-o,n=h-a}if(i<0||n<0)return!1;const l=Math.ceil(2.3*Math.sqrt(o+a)),h=8*l+(i?4:0)+(n?4:0);if(0===h)return!1;if(0===l)return e[0]=e[6]=r+i,e[1]=e[3]=s+n,e[2]=e[4]=r-i,e[5]=e[7]=s-n,!0;let c=0,u=4*l+(i?2:0)+2,d=u,p=h,f=i+o,g=n,m=r+f,x=r-f,_=s+g;if(e[c++]=m,e[c++]=_,e[--u]=_,e[--u]=x,n){const t=s-g;e[d++]=x,e[d++]=t,e[--p]=t,e[--p]=m}for(let t=1;t<l;t++){const h=Math.PI/2*(t/l),f=i+Math.cos(h)*o,g=n+Math.sin(h)*a,m=r+f,x=r-f,_=s+g,y=s-g;e[c++]=m,e[c++]=_,e[--u]=_,e[--u]=x,e[d++]=x,e[d++]=y,e[--p]=y,e[--p]=m}f=i,g=n+a,m=r+f,x=r-f,_=s+g;const y=s-g;return e[c++]=m,e[c++]=_,e[--p]=y,e[--p]=m,i&&(e[c++]=x,e[c++]=_,e[--p]=y,e[--p]=x),!0},triangulate(t,e,r,s,i,n){if(0===t.length)return;let o=0,a=0;for(let e=0;e<t.length;e+=2)o+=t[e],a+=t[e+1];o/=t.length/2,a/=t.length/2;let l=s;e[l*r]=o,e[l*r+1]=a;const h=l++;for(let s=0;s<t.length;s+=2)e[l*r]=t[s],e[l*r+1]=t[s+1],s>0&&(i[n++]=l,i[n++]=h,i[n++]=l-1),l++;i[n++]=h+1,i[n++]=h,i[n++]=l-1}},g={...f,extension:{...f.extension,name:"ellipse"}},m={...f,extension:{...f.extension,name:"roundedRectangle"}};var x=r(59);const _=1e-4;function y(t,e,r,s,i,n,o,a){let l,h;o?(l=s,h=-r):(l=-s,h=r);const c=t-r*i+l,u=e-s*i+h,d=t+r*n+l,p=e+s*n+h;return a.push(c,u),a.push(d,p),2}function v(t,e,r,s,i,n,o,a){const l=r-t,h=s-e;let c=Math.atan2(l,h),u=Math.atan2(i-t,n-e);a&&c<u?c+=2*Math.PI:!a&&c>u&&(u+=2*Math.PI);let d=c;const p=u-c,f=Math.abs(p),g=Math.sqrt(l*l+h*h),m=1+(15*f*Math.sqrt(g)/Math.PI|0),x=p/m;if(d+=x,a){o.push(t,e),o.push(r,s);for(let r=1,s=d;r<m;r++,s+=x)o.push(t,e),o.push(t+Math.sin(s)*g,e+Math.cos(s)*g);o.push(t,e),o.push(i,n)}else{o.push(r,s),o.push(t,e);for(let r=1,s=d;r<m;r++,s+=x)o.push(t+Math.sin(s)*g,e+Math.cos(s)*g),o.push(t,e);o.push(i,n),o.push(t,e)}return 2*m}function b(t,e,r=2){const s=e&&e.length,i=s?e[0]*r:t.length;let n=w(t,0,i,r,!0);const o=[];if(!n||n.next===n.prev)return o;let a,l,h;if(s&&(n=function(t,e,r,s){const i=[];for(let r=0,n=e.length;r<n;r++){const o=w(t,e[r]*s,r<n-1?e[r+1]*s:t.length,s,!1);o===o.next&&(o.steiner=!0),i.push(I(o))}i.sort(E);for(let t=0;t<i.length;t++)r=R(i[t],r);return r}(t,e,n,r)),t.length>80*r){a=t[0],l=t[1];let e=a,s=l;for(let n=r;n<i;n+=r){const r=t[n],i=t[n+1];r<a&&(a=r),i<l&&(l=i),r>e&&(e=r),i>s&&(s=i)}h=Math.max(e-a,s-l),h=0!==h?32767/h:0}return S(n,o,r,a,l,h,0),o}function w(t,e,r,s,i){let n;if(i===function(t,e,r,s){let i=0;for(let n=e,o=r-s;n<r;n+=s)i+=(t[o]-t[n])*(t[n+1]+t[o+1]),o=n;return i}(t,e,r,s)>0)for(let i=e;i<r;i+=s)n=X(i/s|0,t[i],t[i+1],n);else for(let i=r-s;i>=e;i-=s)n=X(i/s|0,t[i],t[i+1],n);return n&&U(n,n.next)&&(V(n),n=n.next),n}function T(t,e){if(!t)return t;e||(e=t);let r,s=t;do{if(r=!1,s.steiner||!U(s,s.next)&&0!==D(s.prev,s,s.next))s=s.next;else{if(V(s),s=e=s.prev,s===s.next)break;r=!0}}while(r||s!==e);return e}function S(t,e,r,s,i,n,o){if(!t)return;!o&&n&&function(t,e,r,s){let i=t;do{0===i.z&&(i.z=B(i.x,i.y,e,r,s)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){let e,r=1;do{let s,i=t;t=null;let n=null;for(e=0;i;){e++;let o=i,a=0;for(let t=0;t<r&&(a++,o=o.nextZ,o);t++);let l=r;for(;a>0||l>0&&o;)0!==a&&(0===l||!o||i.z<=o.z)?(s=i,i=i.nextZ,a--):(s=o,o=o.nextZ,l--),n?n.nextZ=s:t=s,s.prevZ=n,n=s;i=o}n.nextZ=null,r*=2}while(e>1)}(i)}(t,s,i,n);let a=t;for(;t.prev!==t.next;){const l=t.prev,h=t.next;if(n?C(t,s,i,n):A(t))e.push(l.i,t.i,h.i),V(t),t=h.next,a=h.next;else if((t=h)===a){o?1===o?S(t=P(T(t),e),e,r,s,i,n,2):2===o&&M(t,e,r,s,i,n):S(T(t),e,r,s,i,n,1);break}}}function A(t){const e=t.prev,r=t,s=t.next;if(D(e,r,s)>=0)return!1;const i=e.x,n=r.x,o=s.x,a=e.y,l=r.y,h=s.y,c=Math.min(i,n,o),u=Math.min(a,l,h),d=Math.max(i,n,o),p=Math.max(a,l,h);let f=s.next;for(;f!==e;){if(f.x>=c&&f.x<=d&&f.y>=u&&f.y<=p&&F(i,a,n,l,o,h,f.x,f.y)&&D(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function C(t,e,r,s){const i=t.prev,n=t,o=t.next;if(D(i,n,o)>=0)return!1;const a=i.x,l=n.x,h=o.x,c=i.y,u=n.y,d=o.y,p=Math.min(a,l,h),f=Math.min(c,u,d),g=Math.max(a,l,h),m=Math.max(c,u,d),x=B(p,f,e,r,s),_=B(g,m,e,r,s);let y=t.prevZ,v=t.nextZ;for(;y&&y.z>=x&&v&&v.z<=_;){if(y.x>=p&&y.x<=g&&y.y>=f&&y.y<=m&&y!==i&&y!==o&&F(a,c,l,u,h,d,y.x,y.y)&&D(y.prev,y,y.next)>=0)return!1;if(y=y.prevZ,v.x>=p&&v.x<=g&&v.y>=f&&v.y<=m&&v!==i&&v!==o&&F(a,c,l,u,h,d,v.x,v.y)&&D(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;y&&y.z>=x;){if(y.x>=p&&y.x<=g&&y.y>=f&&y.y<=m&&y!==i&&y!==o&&F(a,c,l,u,h,d,y.x,y.y)&&D(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;v&&v.z<=_;){if(v.x>=p&&v.x<=g&&v.y>=f&&v.y<=m&&v!==i&&v!==o&&F(a,c,l,u,h,d,v.x,v.y)&&D(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function P(t,e){let r=t;do{const s=r.prev,i=r.next.next;!U(s,i)&&L(s,r,r.next,i)&&W(s,i)&&W(i,s)&&(e.push(s.i,r.i,i.i),V(r),V(r.next),r=t=i),r=r.next}while(r!==t);return T(r)}function M(t,e,r,s,i,n){let o=t;do{let t=o.next.next;for(;t!==o.prev;){if(o.i!==t.i&&O(o,t)){let a=H(o,t);return o=T(o,o.next),a=T(a,a.next),S(o,e,r,s,i,n,0),void S(a,e,r,s,i,n,0)}t=t.next}o=o.next}while(o!==t)}function E(t,e){let r=t.x-e.x;return 0===r&&(r=t.y-e.y,0===r)&&(r=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)),r}function R(t,e){const r=function(t,e){let r=e;const s=t.x,i=t.y;let n,o=-1/0;if(U(t,r))return r;do{if(U(t,r.next))return r.next;if(i<=r.y&&i>=r.next.y&&r.next.y!==r.y){const t=r.x+(i-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(t<=s&&t>o&&(o=t,n=r.x<r.next.x?r:r.next,t===s))return n}r=r.next}while(r!==e);if(!n)return null;const a=n,l=n.x,h=n.y;let c=1/0;r=n;do{if(s>=r.x&&r.x>=l&&s!==r.x&&G(i<h?s:o,i,l,h,i<h?o:s,i,r.x,r.y)){const e=Math.abs(i-r.y)/(s-r.x);W(r,t)&&(e<c||e===c&&(r.x>n.x||r.x===n.x&&k(n,r)))&&(n=r,c=e)}r=r.next}while(r!==a);return n}(t,e);if(!r)return e;const s=H(r,t);return T(s,s.next),T(r,r.next)}function k(t,e){return D(t.prev,t,e.prev)<0&&D(e.next,t,t.next)<0}function B(t,e,r,s,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-s)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function I(t){let e=t,r=t;do{(e.x<r.x||e.x===r.x&&e.y<r.y)&&(r=e),e=e.next}while(e!==t);return r}function G(t,e,r,s,i,n,o,a){return(i-o)*(e-a)>=(t-o)*(n-a)&&(t-o)*(s-a)>=(r-o)*(e-a)&&(r-o)*(n-a)>=(i-o)*(s-a)}function F(t,e,r,s,i,n,o,a){return!(t===o&&e===a)&&G(t,e,r,s,i,n,o,a)}function O(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&L(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}(t,e)&&(W(t,e)&&W(e,t)&&function(t,e){let r=t,s=!1;const i=(t.x+e.x)/2,n=(t.y+e.y)/2;do{r.y>n!=r.next.y>n&&r.next.y!==r.y&&i<(r.next.x-r.x)*(n-r.y)/(r.next.y-r.y)+r.x&&(s=!s),r=r.next}while(r!==t);return s}(t,e)&&(D(t.prev,t,e.prev)||D(t,e.prev,e))||U(t,e)&&D(t.prev,t,t.next)>0&&D(e.prev,e,e.next)>0)}function D(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function U(t,e){return t.x===e.x&&t.y===e.y}function L(t,e,r,s){const i=z(D(t,e,r)),n=z(D(t,e,s)),o=z(D(r,s,t)),a=z(D(r,s,e));return i!==n&&o!==a||!(0!==i||!N(t,r,e))||!(0!==n||!N(t,s,e))||!(0!==o||!N(r,t,s))||!(0!==a||!N(r,e,s))}function N(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function z(t){return t>0?1:t<0?-1:0}function W(t,e){return D(t.prev,t,t.next)<0?D(t,e,t.next)>=0&&D(t,t.prev,e)>=0:D(t,e,t.prev)<0||D(t,t.next,e)<0}function H(t,e){const r=Y(t.i,t.x,t.y),s=Y(e.i,e.x,e.y),i=t.next,n=e.prev;return t.next=e,e.prev=t,r.next=i,i.prev=r,s.next=r,r.prev=s,n.next=s,s.prev=n,s}function X(t,e,r,s){const i=Y(t,e,r);return s?(i.next=s.next,i.prev=s,s.next.prev=i,s.next=i):(i.prev=i,i.next=i),i}function V(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Y(t,e,r){return{i:t,x:e,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}r(4872);const j=b.default||b;function $(t,e,r,s,i,n,o){const a=j(t,e,2);if(!a)return;for(let t=0;t<a.length;t+=3)n[o++]=a[t]+i,n[o++]=a[t+1]+i,n[o++]=a[t+2]+i;let l=i*s;for(let e=0;e<t.length;e+=2)r[l]=t[e],r[l+1]=t[e+1],l+=s}const q=[],K={extension:{type:s.Ag.ShapeBuilder,name:"polygon"},build(t,e){for(let r=0;r<t.points.length;r++)e[r]=t.points[r];return!0},triangulate(t,e,r,s,i,n){$(t,q,e,r,s,i,n)}},Z={extension:{type:s.Ag.ShapeBuilder,name:"rectangle"},build(t,e){const r=t,s=r.x,i=r.y,n=r.width,o=r.height;return n>0&&o>0&&(e[0]=s,e[1]=i,e[2]=s+n,e[3]=i,e[4]=s+n,e[5]=i+o,e[6]=s,e[7]=i+o,!0)},triangulate(t,e,r,s,i,n){let o=0;e[(s*=r)+o]=t[0],e[s+o+1]=t[1],o+=r,e[s+o]=t[2],e[s+o+1]=t[3],o+=r,e[s+o]=t[6],e[s+o+1]=t[7],o+=r,e[s+o]=t[4],e[s+o+1]=t[5],o+=r;const a=s/r;i[n++]=a,i[n++]=a+1,i[n++]=a+2,i[n++]=a+1,i[n++]=a+3,i[n++]=a+2}},Q={extension:{type:s.Ag.ShapeBuilder,name:"triangle"},build:(t,e)=>(e[0]=t.x,e[1]=t.y,e[2]=t.x2,e[3]=t.y2,e[4]=t.x3,e[5]=t.y3,!0),triangulate(t,e,r,s,i,n){let o=0;e[(s*=r)+o]=t[0],e[s+o+1]=t[1],o+=r,e[s+o]=t[2],e[s+o+1]=t[3],o+=r,e[s+o]=t[4],e[s+o+1]=t[5];const a=s/r;i[n++]=a,i[n++]=a+1,i[n++]=a+2}};var J=r(6406);const tt=new h.u,et=new c.M,rt={};s.XO.handleByMap(s.Ag.ShapeBuilder,rt),s.XO.add(Z,K,Q,f,g,m);const st=new c.M,it=new h.u;function nt(t,e,r){const s=[],i=rt.rectangle,n=st;n.x=t.dx,n.y=t.dy,n.width=t.dw,n.height=t.dh;const o=t.transform;if(!i.build(n,s))return;const{vertices:a,uvs:h,indices:c}=r,d=c.length,f=a.length/2;o&&u(s,o),i.triangulate(s,a,2,f,c,d);const g=t.image,m=g.uvs;h.push(m.x0,m.y0,m.x1,m.y1,m.x3,m.y3,m.x2,m.y2);const x=l.Z.get(p.G);x.indexOffset=d,x.indexSize=c.length-d,x.attributeOffset=f,x.attributeSize=a.length/2-f,x.baseColor=t.style,x.alpha=t.alpha,x.texture=g,x.geometryData=r,e.push(x)}function ot(t,e,r,s,i){const{vertices:n,uvs:o,indices:a}=i;t.shapePrimitives.forEach(({shape:t,transform:h,holes:c})=>{const f=[],g=rt[t.type];if(!g.build(t,f))return;const m=a.length,b=n.length/2;let w="triangle-list";if(h&&u(f,h),r){const r=t.closePath??!0,s=e;s.pixelLine?(function(t,e,r,s){const i=_;if(0===t.length)return;const n=t[0],o=t[1],a=t[t.length-2],l=t[t.length-1],h=e||Math.abs(n-a)<i&&Math.abs(o-l)<i,c=r,u=t.length/2,d=c.length/2;for(let e=0;e<u;e++)c.push(t[2*e]),c.push(t[2*e+1]);for(let t=0;t<u-1;t++)s.push(d+t,d+t+1);h&&s.push(d+u-1,d)}(f,r,n,a),w="line-list"):function(t,e,r,s,i,n){const o=_;if(0===t.length)return;const a=e;let l=a.alignment;if(.5!==e.alignment){let e=function(t){const e=t.length;if(e<6)return 1;let r=0;for(let s=0,i=t[e-2],n=t[e-1];s<e;s+=2){const e=t[s],o=t[s+1];r+=(e-i)*(o+n),i=e,n=o}return r<0?-1:1}(t);l=(l-.5)*e+.5}const h=new x.b(t[0],t[1]),c=new x.b(t[t.length-2],t[t.length-1]),u=s,d=Math.abs(h.x-c.x)<o&&Math.abs(h.y-c.y)<o;if(u){t=t.slice(),d&&(t.pop(),t.pop(),c.set(t[t.length-2],t[t.length-1]));const e=.5*(h.x+c.x),r=.5*(c.y+h.y);t.unshift(e,r),t.push(e,r)}const p=i,f=t.length/2;let g=t.length;const m=p.length/2,b=a.width/2,w=b*b,T=a.miterLimit*a.miterLimit;let S=t[0],A=t[1],C=t[2],P=t[3],M=0,E=0,R=-(A-P),k=S-C,B=0,I=0,G=Math.sqrt(R*R+k*k);R/=G,k/=G,R*=b,k*=b;const F=2*(1-l),O=2*l;u||("round"===a.cap?g+=v(S-R*(F-O)*.5,A-k*(F-O)*.5,S-R*F,A-k*F,S+R*O,A+k*O,p,!0)+2:"square"===a.cap&&(g+=y(S,A,R,k,F,O,!0,p))),p.push(S-R*F,A-k*F),p.push(S+R*O,A+k*O);for(let e=1;e<f-1;++e){S=t[2*(e-1)],A=t[2*(e-1)+1],C=t[2*e],P=t[2*e+1],M=t[2*(e+1)],E=t[2*(e+1)+1],R=-(A-P),k=S-C,G=Math.sqrt(R*R+k*k),R/=G,k/=G,R*=b,k*=b,B=-(P-E),I=C-M,G=Math.sqrt(B*B+I*I),B/=G,I/=G,B*=b,I*=b;const r=C-S,s=A-P,i=C-M,n=E-P,o=r*i+s*n,l=s*i-n*r,h=l<0;if(Math.abs(l)<.001*Math.abs(o)){p.push(C-R*F,P-k*F),p.push(C+R*O,P+k*O),o>=0&&("round"===a.join?g+=v(C,P,C-R*F,P-k*F,C-B*F,P-I*F,p,!1)+4:g+=2,p.push(C-B*O,P-I*O),p.push(C+B*F,P+I*F));continue}const c=(-R+S)*(-k+P)-(-R+C)*(-k+A),u=(-B+M)*(-I+P)-(-B+C)*(-I+E),d=(r*u-i*c)/l,f=(n*c-s*u)/l,m=(d-C)*(d-C)+(f-P)*(f-P),x=C+(d-C)*F,_=P+(f-P)*F,y=C-(d-C)*O,D=P-(f-P)*O,U=h?F:O;m<=Math.min(r*r+s*s,i*i+n*n)+U*U*w?"bevel"===a.join||m/w>T?(h?(p.push(x,_),p.push(C+R*O,P+k*O),p.push(x,_),p.push(C+B*O,P+I*O)):(p.push(C-R*F,P-k*F),p.push(y,D),p.push(C-B*F,P-I*F),p.push(y,D)),g+=2):"round"===a.join?h?(p.push(x,_),p.push(C+R*O,P+k*O),g+=v(C,P,C+R*O,P+k*O,C+B*O,P+I*O,p,!0)+4,p.push(x,_),p.push(C+B*O,P+I*O)):(p.push(C-R*F,P-k*F),p.push(y,D),g+=v(C,P,C-R*F,P-k*F,C-B*F,P-I*F,p,!1)+4,p.push(C-B*F,P-I*F),p.push(y,D)):(p.push(x,_),p.push(y,D)):(p.push(C-R*F,P-k*F),p.push(C+R*O,P+k*O),"round"===a.join?g+=h?v(C,P,C+R*O,P+k*O,C+B*O,P+I*O,p,!0)+2:v(C,P,C-R*F,P-k*F,C-B*F,P-I*F,p,!1)+2:"miter"===a.join&&m/w<=T&&(h?(p.push(y,D),p.push(y,D)):(p.push(x,_),p.push(x,_)),g+=2),p.push(C-B*F,P-I*F),p.push(C+B*O,P+I*O),g+=2)}S=t[2*(f-2)],A=t[2*(f-2)+1],C=t[2*(f-1)],P=t[2*(f-1)+1],R=-(A-P),k=S-C,G=Math.sqrt(R*R+k*k),R/=G,k/=G,R*=b,k*=b,p.push(C-R*F,P-k*F),p.push(C+R*O,P+k*O),u||("round"===a.cap?g+=v(C-R*(F-O)*.5,P-k*(F-O)*.5,C-R*F,P-k*F,C+R*O,P+k*O,p,!1)+2:"square"===a.cap&&(g+=y(C,P,R,k,F,O,!1,p)));for(let t=m;t<g+m-2;++t)S=p[2*t],A=p[2*t+1],C=p[2*(t+1)],P=p[2*(t+1)+1],M=p[2*(t+2)],E=p[2*(t+2)+1],Math.abs(S*(P-E)+C*(E-A)+M*(A-P))<1e-8||n.push(t,t+1,t+2)}(f,s,0,r,n,a)}else if(c){const t=[],e=f.slice();(function(t){const e=[];for(let r=0;r<t.length;r++){const s=t[r].shape,i=[];rt[s.type].build(s,i)&&e.push(i)}return e})(c).forEach(r=>{t.push(e.length/2),e.push(...r)}),$(e,t,n,2,b,a,m)}else g.triangulate(f,n,2,b,a,m);const T=o.length/2,S=e.texture;if(S!==d.g.WHITE){const r=function(t,e,r,s){const i=e.matrix?t.copyFrom(e.matrix).invert():t.identity();if("local"===e.textureSpace){const t=r.getBounds(et);e.width&&t.pad(e.width);const{x:s,y:n}=t,o=1/t.width,a=1/t.height,l=-s*o,h=-n*a,c=i.a,u=i.b,d=i.c,p=i.d;i.a*=o,i.b*=o,i.c*=a,i.d*=a,i.tx=l*c+h*d+i.tx,i.ty=l*u+h*p+i.ty}else i.translate(e.texture.frame.x,e.texture.frame.y),i.scale(1/e.texture.source.width,1/e.texture.source.height);const n=e.texture.source.style;return e.fill instanceof J._||"clamp-to-edge"!==n.addressMode||(n.addressMode="repeat",n.update()),s&&i.append(tt.copyFrom(s).invert()),i}(it,e,t,h);!function(t,e,r,s,i,n,o,a=null){let l=0;r*=e,i*=n;const h=a.a,c=a.b,u=a.c,d=a.d,p=a.tx,f=a.ty;for(;l<o;){const o=t[r],a=t[r+1];s[i]=h*o+u*a+p,s[i+1]=c*o+d*a+f,i+=n,r+=e,l++}}(n,2,b,o,T,2,n.length/2-b,r)}else!function(t,e,r,s){let i=0;for(e*=2;i<s;)t[e]=0,t[e+1]=0,e+=2,i++}(o,T,0,n.length/2-b);const A=l.Z.get(p.G);A.indexOffset=m,A.indexSize=a.length-m,A.attributeOffset=b,A.attributeSize=n.length/2-b,A.baseColor=e.color,A.alpha=e.alpha,A.texture=S,A.geometryData=i,A.topology=w,s.push(A)})}class at{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}}class lt{constructor(){this.instructions=new o.L}init(t){this.batcher=new n.J({maxTextures:t}),this.instructions.reset()}get geometry(){return(0,a.t6)(a.Ek,"GraphicsContextRenderData#geometry is deprecated, please use batcher.geometry instead."),this.batcher.geometry}destroy(){this.batcher.destroy(),this.instructions.destroy(),this.batcher=null,this.instructions=null}}const ht=class t{constructor(t){this._gpuContextHash={},this._graphicsDataContextHash=Object.create(null),this._renderer=t,t.renderableGC.addManagedHash(this,"_gpuContextHash"),t.renderableGC.addManagedHash(this,"_graphicsDataContextHash")}init(e){t.defaultOptions.bezierSmoothness=e?.bezierSmoothness??t.defaultOptions.bezierSmoothness}getContextRenderData(t){return this._graphicsDataContextHash[t.uid]||this._initContextRenderData(t)}updateGpuContext(t){let e=this._gpuContextHash[t.uid]||this._initContext(t);if(t.dirty){e?this._cleanGraphicsContextData(t):e=this._initContext(t),function(t,e){const{geometryData:r,batches:s}=e;s.length=0,r.indices.length=0,r.vertices.length=0,r.uvs.length=0;for(let e=0;e<t.instructions.length;e++){const i=t.instructions[e];if("texture"===i.action)nt(i.data,s,r);else if("fill"===i.action||"stroke"===i.action){const t="stroke"===i.action,e=i.data.path.shapePath,n=i.data.style,o=i.data.hole;t&&o&&ot(o.shapePath,n,!0,s,r),o&&(e.shapePrimitives[e.shapePrimitives.length-1].holes=o.shapePath.shapePrimitives),ot(e,n,t,s,r)}}}(t,e);const r=t.batchMode;t.customShader||"no-batch"===r?e.isBatchable=!1:e.isBatchable="auto"!==r||e.geometryData.vertices.length<400,t.dirty=!1}return e}getGpuContext(t){return this._gpuContextHash[t.uid]||this._initContext(t)}_initContextRenderData(t){const e=l.Z.get(lt,{maxTextures:this._renderer.limits.maxBatchableTextures}),{batches:r,geometryData:s}=this._gpuContextHash[t.uid],n=s.vertices.length,o=s.indices.length;for(let t=0;t<r.length;t++)r[t].applyTransform=!1;const a=e.batcher;a.ensureAttributeBuffer(n),a.ensureIndexBuffer(o),a.begin();for(let t=0;t<r.length;t++){const e=r[t];a.add(e)}a.finish(e.instructions);const h=a.geometry;h.indexBuffer.setDataWithSize(a.indexBuffer,a.indexSize,!0),h.buffers[0].setDataWithSize(a.attributeBuffer.float32View,a.attributeSize,!0);const c=a.batches;for(let t=0;t<c.length;t++){const e=c[t];e.bindGroup=(0,i.w)(e.textures.textures,e.textures.count,this._renderer.limits.maxBatchableTextures)}return this._graphicsDataContextHash[t.uid]=e,e}_initContext(t){const e=new at;return e.context=t,this._gpuContextHash[t.uid]=e,t.on("destroy",this.onGraphicsContextDestroy,this),this._gpuContextHash[t.uid]}onGraphicsContextDestroy(t){this._cleanGraphicsContextData(t),t.off("destroy",this.onGraphicsContextDestroy,this),this._gpuContextHash[t.uid]=null}_cleanGraphicsContextData(t){const e=this._gpuContextHash[t.uid];e.isBatchable||this._graphicsDataContextHash[t.uid]&&(l.Z.return(this.getContextRenderData(t)),this._graphicsDataContextHash[t.uid]=null),e.batches&&e.batches.forEach(t=>{l.Z.return(t)})}destroy(){for(const t in this._gpuContextHash)this._gpuContextHash[t]&&this.onGraphicsContextDestroy(this._gpuContextHash[t].context)}};ht.extension={type:[s.Ag.WebGLSystem,s.Ag.WebGPUSystem,s.Ag.CanvasSystem],name:"graphicsContext"},ht.defaultOptions={bezierSmoothness:.5};let ct=ht},6406:(t,e,r)=>{"use strict";r.d(e,{_:()=>p});var s=r(6675),i=r(5423),n=r(5199),o=r(5947),a=r(9739),l=r(9375),h=r(4696),c=r(7604);const u=[{offset:0,color:"white"},{offset:1,color:"black"}],d=class t{constructor(...e){this.uid=(0,l.L)("fillGradient"),this._tick=0,this.type="linear",this.colorStops=[];let r=function(t){let e=t[0]??{};return("number"==typeof e||t[1])&&((0,h.t6)("8.5.2","use options object instead"),e={type:"linear",start:{x:t[0],y:t[1]},end:{x:t[2],y:t[3]},textureSpace:t[4],textureSize:t[5]??p.defaultLinearOptions.textureSize}),e}(e);r={..."radial"===r.type?t.defaultRadialOptions:t.defaultLinearOptions,...(0,c.S)(r)},this._textureSize=r.textureSize,this._wrapMode=r.wrapMode,"radial"===r.type?(this.center=r.center,this.outerCenter=r.outerCenter??this.center,this.innerRadius=r.innerRadius,this.outerRadius=r.outerRadius,this.scale=r.scale,this.rotation=r.rotation):(this.start=r.start,this.end=r.end),this.textureSpace=r.textureSpace,this.type=r.type,r.colorStops.forEach(t=>{this.addColorStop(t.offset,t.color)})}addColorStop(t,e){return this.colorStops.push({offset:t,color:s.Q.shared.setValue(e).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:t,y:e}=this.start,{x:r,y:s}=this.end,i=r-t,l=s-e;const h=i<0||l<0;if("clamp-to-edge"===this._wrapMode){if(i<0){const e=t;t=r,r=e,i*=-1}if(l<0){const t=e;e=s,s=t,l*=-1}}const c=this.colorStops.length?this.colorStops:u,d=this._textureSize,{canvas:p,context:m}=g(d,1),x=h?m.createLinearGradient(this._textureSize,0,0,0):m.createLinearGradient(0,0,this._textureSize,0);f(x,c),m.fillStyle=x,m.fillRect(0,0,d,1),this.texture=new a.g({source:new o.b({resource:p,addressMode:this._wrapMode})});const _=Math.sqrt(i*i+l*l),y=Math.atan2(l,i),v=new n.u;v.scale(_/d,1),v.rotate(y),v.translate(t,e),"local"===this.textureSpace&&v.scale(d,d),this.transform=v}buildGradient(){this.texture||this._tick++,"linear"===this.type?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;const t=this.colorStops.length?this.colorStops:u,e=this._textureSize,{canvas:r,context:s}=g(e,e),{x:i,y:l}=this.center,{x:h,y:c}=this.outerCenter,d=this.innerRadius,p=this.outerRadius,m=h-p,x=c-p,_=e/(2*p),y=(i-m)*_,v=(l-x)*_,b=s.createRadialGradient(y,v,d*_,(h-m)*_,(c-x)*_,p*_);f(b,t),s.fillStyle=t[t.length-1].color,s.fillRect(0,0,e,e),s.fillStyle=b,s.translate(y,v),s.rotate(this.rotation),s.scale(1,this.scale),s.translate(-y,-v),s.fillRect(0,0,e,e),this.texture=new a.g({source:new o.b({resource:r,addressMode:this._wrapMode})});const w=new n.u;w.scale(1/_,1/_),w.translate(m,x),"local"===this.textureSpace&&w.scale(e,e),this.transform=w}destroy(){this.texture?.destroy(!0),this.texture=null,this.transform=null,this.colorStops=[],this.start=null,this.end=null,this.center=null,this.outerCenter=null}get styleKey(){return`fill-gradient-${this.uid}-${this._tick}`}};d.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"},d.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};let p=d;function f(t,e){for(let r=0;r<e.length;r++){const s=e[r];t.addColorStop(s.offset,s.color)}}function g(t,e){const r=i.e.get().createCanvas(t,e),s=r.getContext("2d");return{canvas:r,context:s}}},6516:(t,e,r)=>{"use strict";r.r(e),r(3046),r(2517),r(2542),r(3050),r(8427),r(6131),r(6934),r(966),r(6841),r(9797),r(4550),r(8122)},6643:(t,e,r)=>{"use strict";r.d(e,{g:()=>i});class s{constructor(t=0,e=0,r=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=t,this.resetTtl=r,this.size=0,this.ttl=e}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(t){if(this.has(t)){const e=this.items[t];delete this.items[t],this.size--,null!==e.prev&&(e.prev.next=e.next),null!==e.next&&(e.next.prev=e.prev),this.first===e&&(this.first=e.next),this.last===e&&(this.last=e.prev)}return this}entries(t=this.keys()){return t.map(t=>[t,this.get(t)])}evict(t=!1){if(t||this.size>0){const t=this.first;delete this.items[t.key],0===--this.size?(this.first=null,this.last=null):(this.first=t.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){const e=this.items[t];if(void 0!==e)return this.ttl>0&&e.expiry<=Date.now()?void this.delete(t):(this.moveToEnd(e),e.value)}has(t){return t in this.items}moveToEnd(t){this.last!==t&&(null!==t.prev&&(t.prev.next=t.next),null!==t.next&&(t.next.prev=t.prev),this.first===t&&(this.first=t.next),t.prev=this.last,t.next=null,null!==this.last&&(this.last.next=t),this.last=t,null===this.first&&(this.first=t))}keys(){const t=[];let e=this.first;for(;null!==e;)t.push(e.key),e=e.next;return t}setWithEvicted(t,e,r=this.resetTtl){let s=null;if(this.has(t))this.set(t,e,!0,r);else{this.max>0&&this.size===this.max&&(s={...this.first},this.evict(!0));let r=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e};1===++this.size?this.first=r:this.last.next=r,this.last=r}return s}set(t,e,r=!1,s=this.resetTtl){let i=this.items[t];return r||void 0!==i?(i.value=e,!1===r&&s&&(i.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.moveToEnd(i)):(this.max>0&&this.size===this.max&&this.evict(!0),i=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},1===++this.size?this.first=i:this.last.next=i,this.last=i),this}values(t=this.keys()){return t.map(t=>this.get(t))}}function i(t=1e3,e=0,r=!1){if(isNaN(t)||t<0)throw new TypeError("Invalid max value");if(isNaN(e)||e<0)throw new TypeError("Invalid ttl value");if("boolean"!=typeof r)throw new TypeError("Invalid resetTtl value");return new s(t,e,r)}},6675:(t,e,r)=>{"use strict";r.d(e,{Q:()=>k});var s={grad:.9,turn:360,rad:360/(2*Math.PI)},i=function(t){return"string"==typeof t?t.length>0:"number"==typeof t},n=function(t,e,r){return void 0===e&&(e=0),void 0===r&&(r=Math.pow(10,e)),Math.round(r*t)/r+0},o=function(t,e,r){return void 0===e&&(e=0),void 0===r&&(r=1),t>r?r:t>e?t:e},a=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},l=function(t){return{r:o(t.r,0,255),g:o(t.g,0,255),b:o(t.b,0,255),a:o(t.a)}},h=function(t){return{r:n(t.r),g:n(t.g),b:n(t.b),a:n(t.a,3)}},c=/^#([0-9a-f]{3,8})$/i,u=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},d=function(t){var e=t.r,r=t.g,s=t.b,i=t.a,n=Math.max(e,r,s),o=n-Math.min(e,r,s),a=o?n===e?(r-s)/o:n===r?2+(s-e)/o:4+(e-r)/o:0;return{h:60*(a<0?a+6:a),s:n?o/n*100:0,v:n/255*100,a:i}},p=function(t){var e=t.h,r=t.s,s=t.v,i=t.a;e=e/360*6,r/=100,s/=100;var n=Math.floor(e),o=s*(1-r),a=s*(1-(e-n)*r),l=s*(1-(1-e+n)*r),h=n%6;return{r:255*[s,a,o,o,l,s][h],g:255*[l,s,s,a,o,o][h],b:255*[o,o,l,s,s,a][h],a:i}},f=function(t){return{h:a(t.h),s:o(t.s,0,100),l:o(t.l,0,100),a:o(t.a)}},g=function(t){return{h:n(t.h),s:n(t.s),l:n(t.l),a:n(t.a,3)}},m=function(t){return p((r=(e=t).s,{h:e.h,s:(r*=((s=e.l)<50?s:100-s)/100)>0?2*r/(s+r)*100:0,v:s+r,a:e.a}));var e,r,s},x=function(t){return{h:(e=d(t)).h,s:(i=(200-(r=e.s))*(s=e.v)/100)>0&&i<200?r*s/100/(i<=100?i:200-i)*100:0,l:i/2,a:e.a};var e,r,s,i},_=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,y=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,v=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,b=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,w={string:[[function(t){var e=c.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?n(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?n(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=v.exec(t)||b.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:l({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=_.exec(t)||y.exec(t);if(!e)return null;var r,i,n=f({h:(r=e[1],i=e[2],void 0===i&&(i="deg"),Number(r)*(s[i]||1)),s:Number(e[3]),l:Number(e[4]),a:void 0===e[5]?1:Number(e[5])/(e[6]?100:1)});return m(n)},"hsl"]],object:[[function(t){var e=t.r,r=t.g,s=t.b,n=t.a,o=void 0===n?1:n;return i(e)&&i(r)&&i(s)?l({r:Number(e),g:Number(r),b:Number(s),a:Number(o)}):null},"rgb"],[function(t){var e=t.h,r=t.s,s=t.l,n=t.a,o=void 0===n?1:n;if(!i(e)||!i(r)||!i(s))return null;var a=f({h:Number(e),s:Number(r),l:Number(s),a:Number(o)});return m(a)},"hsl"],[function(t){var e=t.h,r=t.s,s=t.v,n=t.a,l=void 0===n?1:n;if(!i(e)||!i(r)||!i(s))return null;var h=function(t){return{h:a(t.h),s:o(t.s,0,100),v:o(t.v,0,100),a:o(t.a)}}({h:Number(e),s:Number(r),v:Number(s),a:Number(l)});return p(h)},"hsv"]]},T=function(t,e){for(var r=0;r<e.length;r++){var s=e[r][0](t);if(s)return[s,e[r][1]]}return[null,void 0]},S=function(t,e){var r=x(t);return{h:r.h,s:o(r.s+100*e,0,100),l:r.l,a:r.a}},A=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},C=function(t,e){var r=x(t);return{h:r.h,s:r.s,l:o(r.l+100*e,0,100),a:r.a}},P=function(){function t(t){this.parsed=function(t){return"string"==typeof t?T(t.trim(),w.string):"object"==typeof t&&null!==t?T(t,w.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 n(A(this.rgba),2)},t.prototype.isDark=function(){return A(this.rgba)<.5},t.prototype.isLight=function(){return A(this.rgba)>=.5},t.prototype.toHex=function(){return e=(t=h(this.rgba)).r,r=t.g,s=t.b,o=(i=t.a)<1?u(n(255*i)):"","#"+u(e)+u(r)+u(s)+o;var t,e,r,s,i,o},t.prototype.toRgb=function(){return h(this.rgba)},t.prototype.toRgbString=function(){return e=(t=h(this.rgba)).r,r=t.g,s=t.b,(i=t.a)<1?"rgba("+e+", "+r+", "+s+", "+i+")":"rgb("+e+", "+r+", "+s+")";var t,e,r,s,i},t.prototype.toHsl=function(){return g(x(this.rgba))},t.prototype.toHslString=function(){return e=(t=g(x(this.rgba))).h,r=t.s,s=t.l,(i=t.a)<1?"hsla("+e+", "+r+"%, "+s+"%, "+i+")":"hsl("+e+", "+r+"%, "+s+"%)";var t,e,r,s,i},t.prototype.toHsv=function(){return t=d(this.rgba),{h:n(t.h),s:n(t.s),v:n(t.v),a:n(t.a,3)};var t},t.prototype.invert=function(){return M({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),M(S(this.rgba,t))},t.prototype.desaturate=function(t){return void 0===t&&(t=.1),M(S(this.rgba,-t))},t.prototype.grayscale=function(){return M(S(this.rgba,-1))},t.prototype.lighten=function(t){return void 0===t&&(t=.1),M(C(this.rgba,t))},t.prototype.darken=function(t){return void 0===t&&(t=.1),M(C(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?M({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):n(this.rgba.a,3);var e},t.prototype.hue=function(t){var e=x(this.rgba);return"number"==typeof t?M({h:t,s:e.s,l:e.l,a:e.a}):n(e.h)},t.prototype.isEqual=function(t){return this.toHex()===M(t).toHex()},t}(),M=function(t){return t instanceof P?t:new P(t)},E=[];!function(t){t.forEach(function(t){E.indexOf(t)<0&&(t(P,w),E.push(t))})}([function(t,e){var r={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},s={};for(var i in r)s[r[i]]=i;var n={};t.prototype.toName=function(e){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var i,o,a=s[this.toHex()];if(a)return a;if(null==e?void 0:e.closest){var l=this.toRgb(),h=1/0,c="black";if(!n.length)for(var u in r)n[u]=new t(r[u]).toRgb();for(var d in r){var p=(i=l,o=n[d],Math.pow(i.r-o.r,2)+Math.pow(i.g-o.g,2)+Math.pow(i.b-o.b,2));p<h&&(h=p,c=d)}return c}},e.string.push([function(e){var s=e.toLowerCase(),i="transparent"===s?"#0000":r[s];return i?new t(i).toRgb():null},"name"])}]);const R=class t{constructor(t=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=t}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(t){return this.value=t,this}set value(e){if(e instanceof t)this._value=this._cloneSource(e._value),this._int=e._int,this._components.set(e._components);else{if(null===e)throw new Error("Cannot set Color#value to null");null!==this._value&&this._isSourceEqual(this._value,e)||(this._value=this._cloneSource(e),this._normalize(this._value))}}get value(){return this._value}_cloneSource(t){return"string"==typeof t||"number"==typeof t||t instanceof Number||null===t?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):"object"==typeof t&&null!==t?{...t}:t}_isSourceEqual(t,e){const r=typeof t;if(r!==typeof e)return!1;if("number"===r||"string"===r||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length===e.length&&t.every((t,r)=>t===e[r]);if(null!==t&&null!==e){const r=Object.keys(t),s=Object.keys(e);return r.length===s.length&&r.every(r=>t[r]===e[r])}return t===e}toRgba(){const[t,e,r,s]=this._components;return{r:t,g:e,b:r,a:s}}toRgb(){const[t,e,r]=this._components;return{r:t,g:e,b:r}}toRgbaString(){const[t,e,r]=this.toUint8RgbArray();return`rgba(${t},${e},${r},${this.alpha})`}toUint8RgbArray(t){const[e,r,s]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb),t[0]=Math.round(255*e),t[1]=Math.round(255*r),t[2]=Math.round(255*s),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t||(t=this._arrayRgba);const[e,r,s,i]=this._components;return t[0]=e,t[1]=r,t[2]=s,t[3]=i,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb);const[e,r,s]=this._components;return t[0]=e,t[1]=r,t[2]=s,t}toNumber(){return this._int}toBgrNumber(){const[t,e,r]=this.toUint8RgbArray();return(r<<16)+(e<<8)+t}toLittleEndianNumber(){const t=this._int;return(t>>16)+(65280&t)+((255&t)<<16)}multiply(e){const[r,s,i,n]=t._temp.setValue(e)._components;return this._components[0]*=r,this._components[1]*=s,this._components[2]*=i,this._components[3]*=n,this._refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(1===t)return(255<<24)+this._int;if(0===t)return e?0:this._int;let r=this._int>>16&255,s=this._int>>8&255,i=255&this._int;return e&&(r=r*t+.5|0,s=s*t+.5|0,i=i*t+.5|0),(255*t<<24)+(r<<16)+(s<<8)+i}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(255*this._components[3]).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this}_normalize(e){let r,s,i,n;if(("number"==typeof e||e instanceof Number)&&e>=0&&e<=16777215)r=(e>>16&255)/255,s=(e>>8&255)/255,i=(255&e)/255,n=1;else if((Array.isArray(e)||e instanceof Float32Array)&&e.length>=3&&e.length<=4)e=this._clamp(e),[r,s,i,n=1]=e;else if((e instanceof Uint8Array||e instanceof Uint8ClampedArray)&&e.length>=3&&e.length<=4)e=this._clamp(e,0,255),[r,s,i,n=255]=e,r/=255,s/=255,i/=255,n/=255;else if("string"==typeof e||"object"==typeof e){if("string"==typeof e){const r=t.HEX_PATTERN.exec(e);r&&(e=`#${r[2]}`)}const o=M(e);o.isValid()&&(({r,g:s,b:i,a:n}=o.rgba),r/=255,s/=255,i/=255)}if(void 0===r)throw new Error(`Unable to convert color ${e}`);this._components[0]=r,this._components[1]=s,this._components[2]=i,this._components[3]=n,this._refreshInt()}_refreshInt(){this._clamp(this._components);const[t,e,r]=this._components;this._int=(255*t<<16)+(255*e<<8)+(255*r|0)}_clamp(t,e=0,r=1){return"number"==typeof t?Math.min(Math.max(t,e),r):(t.forEach((s,i)=>{t[i]=Math.min(Math.max(s,e),r)}),t)}static isColorLike(e){return"number"==typeof e||"string"==typeof e||e instanceof Number||e instanceof t||Array.isArray(e)||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Float32Array||void 0!==e.r&&void 0!==e.g&&void 0!==e.b||void 0!==e.r&&void 0!==e.g&&void 0!==e.b&&void 0!==e.a||void 0!==e.h&&void 0!==e.s&&void 0!==e.l||void 0!==e.h&&void 0!==e.s&&void 0!==e.l&&void 0!==e.a||void 0!==e.h&&void 0!==e.s&&void 0!==e.v||void 0!==e.h&&void 0!==e.s&&void 0!==e.v&&void 0!==e.a}};R.shared=new R,R._temp=new R,R.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let k=R},6841:(t,e,r)=>{"use strict";var s=r(1065),i=r(9739),n=r(8956),o=r(3412);class a extends o.K{constructor(t){super(),this.generatingTexture=!1,this.currentKey="--",this._renderer=t,t.runners.resolutionChange.add(this)}resolutionChange(){const t=this.renderable;t._autoResolution&&t.onViewUpdate()}destroy(){const{htmlText:t}=this._renderer;null===t.getReferenceCount(this.currentKey)?t.returnTexturePromise(this.texturePromise):t.decreaseReferenceCount(this.currentKey),this._renderer.runners.resolutionChange.remove(this),this.texturePromise=null,this._renderer=null}}class l{constructor(t){this._renderer=t}validateRenderable(t){const e=this._getGpuText(t),r=t.styleKey;return e.currentKey!==r}addRenderable(t,e){const r=this._getGpuText(t);if(t._didTextUpdate){const e=t._autoResolution?this._renderer.resolution:t.resolution;r.currentKey===t.styleKey&&t.resolution===e||this._updateGpuText(t).catch(t=>{console.error(t)}),t._didTextUpdate=!1,(0,n.s)(r,t)}this._renderer.renderPipes.batch.addToBatch(r,e)}updateRenderable(t){const e=this._getGpuText(t);e._batcher.updateElement(e)}async _updateGpuText(t){t._didTextUpdate=!1;const e=this._getGpuText(t);if(e.generatingTexture)return;const r=e.texturePromise;e.texturePromise=null,e.generatingTexture=!0,t._resolution=t._autoResolution?this._renderer.resolution:t.resolution;let s=this._renderer.htmlText.getTexturePromise(t);r&&(s=s.finally(()=>{this._renderer.htmlText.decreaseReferenceCount(e.currentKey),this._renderer.htmlText.returnTexturePromise(r)})),e.texturePromise=s,e.currentKey=t.styleKey,e.texture=await s;const i=t.renderGroup||t.parentRenderGroup;i&&(i.structureDidChange=!0),e.generatingTexture=!1,(0,n.s)(e,t)}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new a(this._renderer);return e.renderable=t,e.transform=t.groupTransform,e.texture=i.g.EMPTY,e.bounds={minX:0,maxX:1,minY:0,maxY:0},e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._resolution=t._autoResolution?this._renderer.resolution:t.resolution,t._gpuData[this._renderer.uid]=e,e}destroy(){this._renderer=null}}l.extension={type:[s.Ag.WebGLPipes,s.Ag.WebGPUPipes,s.Ag.CanvasPipes],name:"htmlText"};var h=r(1566),c=r(8851),u=r(5153),d=r(5423),p=r(7694),f=r(761),g=r(1268);const m="http://www.w3.org/2000/svg",x="http://www.w3.org/1999/xhtml";class _{constructor(){this.svgRoot=document.createElementNS(m,"svg"),this.foreignObject=document.createElementNS(m,"foreignObject"),this.domElement=document.createElementNS(x,"div"),this.styleElement=document.createElementNS(x,"style");const{foreignObject:t,svgRoot:e,styleElement:r,domElement:s}=this;t.setAttribute("width","10000"),t.setAttribute("height","10000"),t.style.overflow="hidden",e.appendChild(t),t.appendChild(r),t.appendChild(s),this.image=d.e.get().createImage()}destroy(){this.svgRoot.remove(),this.foreignObject.remove(),this.styleElement.remove(),this.domElement.remove(),this.image.src="",this.image.remove(),this.svgRoot=null,this.foreignObject=null,this.styleElement=null,this.domElement=null,this.image=null,this.canvasAndContext=null}}var y=r(2445);const v=new Map;let b;class w{constructor(t){this._activeTextures={},this._renderer=t,this._createCanvas=t.type===u.W.WEBGPU}getTexture(t){return this.getTexturePromise(t)}getManagedTexture(t){const e=t.styleKey;if(this._activeTextures[e])return this._increaseReferenceCount(e),this._activeTextures[e].promise;const r=this._buildTexturePromise(t).then(t=>(this._activeTextures[e].texture=t,t));return this._activeTextures[e]={texture:null,promise:r,usageCount:1},r}getReferenceCount(t){return this._activeTextures[t]?.usageCount??null}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}decreaseReferenceCount(t){const e=this._activeTextures[t];e&&(e.usageCount--,0===e.usageCount&&(e.texture?this._cleanUp(e.texture):e.promise.then(t=>{e.texture=t,this._cleanUp(e.texture)}).catch(()=>{(0,p.R)("HTMLTextSystem: Failed to clean texture")}),this._activeTextures[t]=null))}getTexturePromise(t){return this._buildTexturePromise(t)}async _buildTexturePromise(t){const{text:e,style:r,resolution:s,textureStyle:i}=t,n=f.Z.get(_),o=function(t,e){const r=e.fontFamily,s=[],i={},n=t.match(/font-family:([^;"\s]+)/g);function o(t){i[t]||(s.push(t),i[t]=!0)}if(Array.isArray(r))for(let t=0;t<r.length;t++)o(r[t]);else o(r);n&&n.forEach(t=>{o(t.split(":")[1].trim())});for(const t in e.tagStyles)o(e.tagStyles[t].fontFamily);return s}(e,r),a=await async function(t){const e=t.filter(t=>y.l.has(`${t}-and-url`)).map(t=>{if(!v.has(t)){const{entries:e}=y.l.get(`${t}-and-url`),r=[];e.forEach(e=>{const s=e.url,i=e.faces.map(t=>({weight:t.weight,style:t.style}));r.push(...i.map(e=>async function(t,e){const r=await async function(t){const e=await d.e.get().fetch(t),r=await e.blob(),s=new FileReader;return await new Promise((t,e)=>{s.onloadend=()=>t(s.result),s.onerror=e,s.readAsDataURL(r)})}(e);return`@font-face {\n font-family: "${t.fontFamily}";\n font-weight: ${t.fontWeight};\n font-style: ${t.fontStyle};\n src: url('${r}');\n }`}({fontWeight:e.weight,fontStyle:e.style,fontFamily:t},s)))}),v.set(t,Promise.all(r).then(t=>t.join("\n")))}return v.get(t)});return(await Promise.all(e)).join("\n")}(o),l=function(t,e,r,s){s||(s=b||(b=new _));const{domElement:i,styleElement:n,svgRoot:o}=s;i.innerHTML=`<style>${e.cssStyle};</style><div style='padding:0'>${t}</div>`,i.setAttribute("style","transform-origin: top left; display: inline-block"),r&&(n.textContent=r),document.body.appendChild(o);const a=i.getBoundingClientRect();o.remove();const l=2*e.padding;return{width:a.width-l,height:a.height-l}}(e,r,a,n),c=Math.ceil(Math.ceil(Math.max(1,l.width)+2*r.padding)*s),u=Math.ceil(Math.ceil(Math.max(1,l.height)+2*r.padding)*s),p=n.image;p.width=2+(0|c),p.height=2+(0|u);const m=function(t,e,r,s,i){const{domElement:n,styleElement:o,svgRoot:a}=i;n.innerHTML=`<style>${e.cssStyle}</style><div style='padding:0;'>${t}</div>`,n.setAttribute("style",`transform: scale(${r});transform-origin: top left; display: inline-block`),o.textContent=s;const{width:l,height:h}=i.image;return a.setAttribute("width",l.toString()),a.setAttribute("height",h.toString()),(new XMLSerializer).serializeToString(a)}(e,r,s,a,n);await function(t,e,r){return new Promise(async s=>{r&&await new Promise(t=>setTimeout(t,100)),t.onload=()=>{s()},t.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(e)}`,t.crossOrigin="anonymous"})}(p,m,function(){const{userAgent:t}=d.e.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(t)}()&&o.length>0);const x=p;let w;this._createCanvas&&(w=function(t,e){const r=h.N.getOptimalCanvasAndContext(t.width,t.height,e),{context:s}=r;return s.clearRect(0,0,t.width,t.height),s.drawImage(t,0,0),r}(p,s));const T=(0,g.M)(w?w.canvas:x,p.width-2,p.height-2,s);return i&&(T.source.style=i),this._createCanvas&&(this._renderer.texture.initSource(T.source),h.N.returnCanvasAndContext(w)),f.Z.return(n),T}returnTexturePromise(t){t.then(t=>{this._cleanUp(t)}).catch(()=>{(0,p.R)("HTMLTextSystem: Failed to clean texture")})}_cleanUp(t){c.W.returnTexture(t,!0),t.source.resource=null,t.source.uploadMethodId="unknown"}destroy(){this._renderer=null;for(const t in this._activeTextures)this._activeTextures[t]&&this.returnTexturePromise(this._activeTextures[t].promise);this._activeTextures=null}}w.extension={type:[s.Ag.WebGLSystem,s.Ag.WebGPUSystem,s.Ag.CanvasSystem],name:"htmlText"},s.XO.add(w),s.XO.add(l)},6851:(t,e,r)=>{"use strict";r.d(e,{j:()=>n});var s=r(5946);const i=16777215;function n(t,e){return t===i?e:e===i?t:(0,s.u)(t,e)}},6890:(t,e,r)=>{"use strict";r.d(e,{u:()=>n});const s=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join("\n");function i(t){let e="";for(let r=0;r<t;++r)r>0&&(e+="\nelse "),r<t-1&&(e+=`if(test == ${r}.0){}`);return e}function n(t,e){if(0===t)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const r=e.createShader(e.FRAGMENT_SHADER);try{for(;;){const n=s.replace(/%forloop%/gi,i(t));if(e.shaderSource(r,n),e.compileShader(r),e.getShaderParameter(r,e.COMPILE_STATUS))break;t=t/2|0}}finally{e.deleteShader(r)}return t}},6929:t=>{t.exports=function(t){var i=[];return t.replace(r,function(t,r,n){var o=r.toLowerCase();for(n=function(t){var e=t.match(s);return e?e.map(Number):[]}(n),"m"==o&&n.length>2&&(i.push([r].concat(n.splice(0,2))),o="l",r="m"==r?"l":"L");;){if(n.length==e[o])return n.unshift(r),i.push(n);if(n.length<e[o])throw new Error("malformed path data");i.push([r].concat(n.splice(0,e[o])))}}),i};var e={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},r=/([astvzqmhlc])([^astvzqmhlc]*)/gi,s=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi},6934:(t,e,r)=>{"use strict";var s=r(1065),i=r(8956),n=r(3412);class o extends n.K{constructor(t){super(),this._renderer=t,t.runners.resolutionChange.add(this)}resolutionChange(){const t=this.renderable;t._autoResolution&&t.onViewUpdate()}destroy(){const{canvasText:t}=this._renderer;null===t.getReferenceCount(this.currentKey)?t.returnTexture(this.texture):t.decreaseReferenceCount(this.currentKey),this._renderer.runners.resolutionChange.remove(this),this._renderer=null}}class a{constructor(t){this._renderer=t}validateRenderable(t){const e=this._getGpuText(t),r=t.styleKey;return e.currentKey!==r||t._didTextUpdate}addRenderable(t,e){const r=this._getGpuText(t);if(t._didTextUpdate){const e=t._autoResolution?this._renderer.resolution:t.resolution;r.currentKey===t.styleKey&&t.resolution===e||this._updateGpuText(t),t._didTextUpdate=!1}this._renderer.renderPipes.batch.addToBatch(r,e)}updateRenderable(t){const e=this._getGpuText(t);e._batcher.updateElement(e)}_updateGpuText(t){const e=this._getGpuText(t);e.texture&&this._renderer.canvasText.decreaseReferenceCount(e.currentKey),t._resolution=t._autoResolution?this._renderer.resolution:t.resolution,e.texture=this._renderer.canvasText.getManagedTexture(t),e.currentKey=t.styleKey,(0,i.s)(e,t)}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new o(this._renderer);return e.currentKey="--",e.renderable=t,e.transform=t.groupTransform,e.bounds={minX:0,maxX:1,minY:0,maxY:0},e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._gpuData[this._renderer.uid]=e,e}destroy(){this._renderer=null}}a.extension={type:[s.Ag.WebGLPipes,s.Ag.WebGPUPipes,s.Ag.CanvasPipes],name:"text"};var l=r(8851),h=r(8896),c=r(4696),u=r(5105),d=r(1268),p=r(6675),f=r(9390),g=r(1566),m=r(5423),x=r(9437);let _=null,y=null;function v(t,e,r){for(let s=0,i=4*r*e;s<e;++s,i+=4)if(0!==t[i+3])return!1;return!0}function b(t,e,r,s,i){const n=4*e;for(let e=s,o=s*n+4*r;e<=i;++e,o+=n)if(0!==t[o+3])return!1;return!0}function w(...t){let e=t[0];e.canvas||(e={canvas:t[0],resolution:t[1]});const{canvas:r}=e,s=Math.min(e.resolution??1,1),i=e.width??r.width,n=e.height??r.height;let o=e.output;if(function(t,e){_||(_=m.e.get().createCanvas(256,128),y=_.getContext("2d",{willReadFrequently:!0}),y.globalCompositeOperation="copy",y.globalAlpha=1),(_.width<t||_.height<e)&&(_.width=(0,x.U5)(t),_.height=(0,x.U5)(e))}(i,n),!y)throw new TypeError("Failed to get canvas 2D context");y.drawImage(r,0,0,i,n,0,0,i*s,n*s);const a=y.getImageData(0,0,i,n).data;let l=0,h=0,c=i-1,u=n-1;for(;h<n&&v(a,i,h);)++h;if(h===n)return f.M.EMPTY;for(;v(a,i,u);)--u;for(;b(a,i,l,h,u);)++l;for(;b(a,i,c,h,u);)--c;return++c,++u,y.globalCompositeOperation="source-over",y.strokeRect(l,h,c-l,u-h),y.globalCompositeOperation="copy",o??(o=new f.M),o.set(l/s,h/s,(c-l)/s,(u-h)/s),o}var T=r(7926),S=r(2288),A=r(1990);const C=new f.M,P=new class{getCanvasAndContext(t){const{text:e,style:r,resolution:s=1}=t,i=r._getFinalPadding(),n=T.P.measureText(e||" ",r),o=Math.ceil(Math.ceil(Math.max(1,n.width)+2*i)*s),a=Math.ceil(Math.ceil(Math.max(1,n.height)+2*i)*s),l=g.N.getOptimalCanvasAndContext(o,a);return this._renderTextToCanvas(e,r,i,s,l),{canvasAndContext:l,frame:r.trim?w({canvas:l.canvas,width:o,height:a,resolution:1,output:C}):C.set(0,0,o,a)}}returnCanvasAndContext(t){g.N.returnCanvasAndContext(t)}_renderTextToCanvas(t,e,r,s,i){const{canvas:n,context:o}=i,a=(0,S.Z)(e),l=T.P.measureText(t||" ",e),h=l.lines,c=l.lineHeight,u=l.lineWidths,d=l.maxLineWidth,f=l.fontProperties,g=n.height;if(o.resetTransform(),o.scale(s,s),o.textBaseline=e.textBaseline,e._stroke?.width){const t=e._stroke;o.lineWidth=t.width,o.miterLimit=t.miterLimit,o.lineJoin=t.join,o.lineCap=t.cap}let m,x;o.font=a;const _=e.dropShadow?2:1;for(let t=0;t<_;++t){const n=e.dropShadow&&0===t,a=n?Math.ceil(Math.max(1,g)+2*r):0,_=a*s;if(n){o.fillStyle="black",o.strokeStyle="black";const t=e.dropShadow,r=t.color,i=t.alpha;o.shadowColor=p.Q.shared.setValue(r).setAlpha(i).toRgbaString();const n=t.blur*s,a=t.distance*s;o.shadowBlur=n,o.shadowOffsetX=Math.cos(t.angle)*a,o.shadowOffsetY=Math.sin(t.angle)*a+_}else{if(o.fillStyle=e._fill?(0,A.r)(e._fill,o,l,2*r):null,e._stroke?.width){const t=.5*e._stroke.width+2*r;o.strokeStyle=(0,A.r)(e._stroke,o,l,t)}o.shadowColor="black"}let y=(c-f.fontSize)/2;c-f.fontSize<0&&(y=0);const v=e._stroke?.width??0;for(let t=0;t<h.length;t++)m=v/2,x=v/2+t*c+f.ascent+y,"right"===e.align?m+=d-u[t]:"center"===e.align&&(m+=(d-u[t])/2),e._stroke?.width&&this._drawLetterSpacing(h[t],e,i,m+r,x+r-a,!0),void 0!==e._fill&&this._drawLetterSpacing(h[t],e,i,m+r,x+r-a)}}_drawLetterSpacing(t,e,r,s,i,n=!1){const{context:o}=r,a=e.letterSpacing;let l=!1;if(T.P.experimentalLetterSpacingSupported&&(T.P.experimentalLetterSpacing?(o.letterSpacing=`${a}px`,o.textLetterSpacing=`${a}px`,l=!0):(o.letterSpacing="0px",o.textLetterSpacing="0px")),0===a||l)return void(n?o.strokeText(t,s,i):o.fillText(t,s,i));let h=s;const c=T.P.graphemeSegmenter(t);let u=o.measureText(t).width,d=0;for(let t=0;t<c.length;++t){const e=c[t];n?o.strokeText(e,h,i):o.fillText(e,h,i);let r="";for(let e=t+1;e<c.length;++e)r+=c[e];d=o.measureText(r).width,h+=u-d+a,u=d}}};class M{constructor(t){this._activeTextures={},this._renderer=t}getTexture(t,e,r,s){"string"==typeof t&&((0,c.t6)("8.0.0","CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),t={text:t,style:r,resolution:e}),t.style instanceof u.x||(t.style=new u.x(t.style)),t.textureStyle instanceof h.n||(t.textureStyle=new h.n(t.textureStyle)),"string"!=typeof t.text&&(t.text=t.text.toString());const{text:i,style:n,textureStyle:o}=t,a=t.resolution??this._renderer.resolution,{frame:l,canvasAndContext:p}=P.getCanvasAndContext({text:i,style:n,resolution:a}),f=(0,d.M)(p.canvas,l.width,l.height,a);if(o&&(f.source.style=o),n.trim&&(l.pad(n.padding),f.frame.copyFrom(l),f.frame.scale(1/a),f.updateUvs()),n.filters){const t=this._applyFilters(f,n.filters);return this.returnTexture(f),P.returnCanvasAndContext(p),t}return this._renderer.texture.initSource(f._source),P.returnCanvasAndContext(p),f}returnTexture(t){const e=t.source;e.resource=null,e.uploadMethodId="unknown",e.alphaMode="no-premultiply-alpha",l.W.returnTexture(t,!0)}renderTextToCanvas(){(0,c.t6)("8.10.0","CanvasTextSystem.renderTextToCanvas: no longer supported, use CanvasTextSystem.getTexture instead")}getManagedTexture(t){t._resolution=t._autoResolution?this._renderer.resolution:t.resolution;const e=t.styleKey;if(this._activeTextures[e])return this._increaseReferenceCount(e),this._activeTextures[e].texture;const r=this.getTexture({text:t.text,style:t.style,resolution:t._resolution,textureStyle:t.textureStyle});return this._activeTextures[e]={texture:r,usageCount:1},r}decreaseReferenceCount(t){const e=this._activeTextures[t];e.usageCount--,0===e.usageCount&&(this.returnTexture(e.texture),this._activeTextures[t]=null)}getReferenceCount(t){return this._activeTextures[t]?.usageCount??null}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}_applyFilters(t,e){const r=this._renderer.renderTarget.renderTarget,s=this._renderer.filter.generateFilteredTexture({texture:t,filters:e});return this._renderer.renderTarget.bind(r,!1),s}destroy(){this._renderer=null;for(const t in this._activeTextures)this._activeTextures[t]&&this.returnTexture(this._activeTextures[t].texture);this._activeTextures=null}}M.extension={type:[s.Ag.WebGLSystem,s.Ag.WebGPUSystem,s.Ag.CanvasSystem],name:"canvasText"},s.XO.add(M),s.XO.add(a)},7335:(t,e,r)=>{"use strict";r.d(e,{b:()=>s,m:()=>i});const s={name:"round-pixels-bit",vertex:{header:"\n fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>\n {\n return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;\n }\n "}},i={name:"round-pixels-bit",vertex:{header:"\n vec2 roundPixels(vec2 position, vec2 targetSize)\n {\n return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;\n }\n "}}},7433:(t,e,r)=>{"use strict";r.d(e,{U:()=>n});const s={normal:0,add:1,multiply:2,screen:3,overlay:4,erase:5,"normal-npm":6,"add-npm":7,"screen-npm":8,min:9,max:10},i=class t{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(1&this.data)}set blend(t){!!(1&this.data)!==t&&(this.data^=1)}get offsets(){return!!(2&this.data)}set offsets(t){!!(2&this.data)!==t&&(this.data^=2)}set cullMode(t){"none"!==t?(this.culling=!0,this.clockwiseFrontFace="front"===t):this.culling=!1}get cullMode(){return this.culling?this.clockwiseFrontFace?"front":"back":"none"}get culling(){return!!(4&this.data)}set culling(t){!!(4&this.data)!==t&&(this.data^=4)}get depthTest(){return!!(8&this.data)}set depthTest(t){!!(8&this.data)!==t&&(this.data^=8)}get depthMask(){return!!(32&this.data)}set depthMask(t){!!(32&this.data)!==t&&(this.data^=32)}get clockwiseFrontFace(){return!!(16&this.data)}set clockwiseFrontFace(t){!!(16&this.data)!==t&&(this.data^=16)}get blendMode(){return this._blendMode}set blendMode(t){this.blend="none"!==t,this._blendMode=t,this._blendModeId=s[t]||0}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}toString(){return`[pixi.js/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`}static for2d(){const e=new t;return e.depthTest=!1,e.blend=!0,e}};i.default2d=i.for2d();let n=i},7604:(t,e,r)=>{"use strict";function s(t){const e={};for(const r in t)void 0!==t[r]&&(e[r]=t[r]);return e}r.d(e,{S:()=>s})},7694:(t,e,r)=>{"use strict";r.d(e,{R:()=>n});let s=0;const i=500;function n(...t){s!==i&&(s++,s===i?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...t))}},7722:(t,e,r)=>{"use strict";r.d(e,{WebGLRenderer:()=>Kt});var s=r(1065),i=r(5199),n=r(9677),o=r(2305),a=r(1570),l=r(4405),h=r(7335),c=r(2478),u=r(1657),d=r(4449);class p{contextChange(t){const e=new d.k({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new i.u,type:"mat3x3<f32>"},uRound:{value:0,type:"f32"}}),r=t.limits.maxBatchableTextures,s=(0,n.I)({name:"graphics",bits:[o.a,(0,a.P)(r),l.mA,h.m]});this.shader=new u.M({glProgram:s,resources:{localUniforms:e,batchSamplers:(0,c.n)(r)}})}execute(t,e){const r=e.context,s=r.customShader||this.shader,i=t.renderer,n=i.graphicsContext,{batcher:o,instructions:a}=n.getContextRenderData(r);s.groups[0]=i.globalUniforms.bindGroup,i.state.set(t.state),i.shader.bind(s),i.geometry.bind(o.geometry,s.glProgram);const l=a.instructions;for(let t=0;t<a.instructionSize;t++){const e=l[t];if(e.size){for(let t=0;t<e.textures.count;t++)i.texture.bind(e.textures.textures[t],t);i.geometry.draw(e.topology,e.size,e.start)}}}destroy(){this.shader.destroy(!0),this.shader=null}}p.extension={type:[s.Ag.WebGLPipesAdaptor],name:"graphics"};var f=r(2577),g=r(9739),m=r(7694);class x{init(){const t=(0,n.I)({name:"mesh",bits:[l.mA,f.m,h.m]});this._shader=new u.M({glProgram:t,resources:{uTexture:g.g.EMPTY.source,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new i.u}}}})}execute(t,e){const r=t.renderer;let s=e._shader;if(s){if(!s.glProgram)return void(0,m.R)("Mesh shader has no glProgram",e.shader)}else{s=this._shader;const t=e.texture,r=t.source;s.resources.uTexture=r,s.resources.uSampler=r.style,s.resources.textureUniforms.uniforms.uTextureMatrix=t.textureMatrix.mapCoord}s.groups[100]=r.globalUniforms.bindGroup,s.groups[101]=t.localUniformsBindGroup,r.encoder.draw({geometry:e._geometry,shader:s,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}x.extension={type:[s.Ag.WebGLPipesAdaptor],name:"mesh"};var _=r(7433);class y{constructor(){this._tempState=_.U.for2d(),this._didUploadHash={}}init(t){t.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(t,e,r){const s=t.renderer,i=this._didUploadHash[r.uid];s.shader.bind(r,i),i||(this._didUploadHash[r.uid]=!0),s.shader.updateUniformGroup(s.globalUniforms.uniformGroup),s.geometry.bind(e,r.glProgram)}execute(t,e){const r=t.renderer;this._tempState.blendMode=e.blendMode,r.state.set(this._tempState);const s=e.textures.textures;for(let t=0;t<e.textures.count;t++)r.texture.bind(s[t],t);r.geometry.draw(e.topology,e.size,e.start)}}y.extension={type:[s.Ag.WebGLPipesAdaptor],name:"batch"};var v=r(6114),b=r(1673),w=r(5153),T=r(9798),S=(t=>(t[t.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",t[t.ARRAY_BUFFER=34962]="ARRAY_BUFFER",t[t.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",t))(S||{});class A{constructor(t,e){this._lastBindBaseLocation=-1,this._lastBindCallId=-1,this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.type=e}}class C{constructor(t){this._gpuBuffers=Object.create(null),this._boundBufferBases=Object.create(null),this._minBaseLocation=0,this._nextBindBaseIndex=this._minBaseLocation,this._bindCallId=0,this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_gpuBuffers")}destroy(){this._renderer=null,this._gl=null,this._gpuBuffers=null,this._boundBufferBases=null}contextChange(){this._gl=this._renderer.gl,this._gpuBuffers=Object.create(null),this._maxBindings=this._renderer.limits.maxUniformBindings}getGlBuffer(t){return this._gpuBuffers[t.uid]||this.createGLBuffer(t)}bind(t){const{_gl:e}=this,r=this.getGlBuffer(t);e.bindBuffer(r.type,r.buffer)}bindBufferBase(t,e){const{_gl:r}=this;this._boundBufferBases[e]!==t&&(this._boundBufferBases[e]=t,t._lastBindBaseLocation=e,r.bindBufferBase(r.UNIFORM_BUFFER,e,t.buffer))}nextBindBase(t){this._bindCallId++,this._minBaseLocation=0,t&&(this._boundBufferBases[0]=null,this._minBaseLocation=1,this._nextBindBaseIndex<1&&(this._nextBindBaseIndex=1))}freeLocationForBufferBase(t){let e=this.getLastBindBaseLocation(t);if(e>=this._minBaseLocation)return t._lastBindCallId=this._bindCallId,e;let r=0,s=this._nextBindBaseIndex;for(;r<2;){s>=this._maxBindings&&(s=this._minBaseLocation,r++);const t=this._boundBufferBases[s];if(!t||t._lastBindCallId!==this._bindCallId)break;s++}return e=s,this._nextBindBaseIndex=s+1,r>=2?-1:(t._lastBindCallId=this._bindCallId,this._boundBufferBases[e]=null,e)}getLastBindBaseLocation(t){const e=t._lastBindBaseLocation;return this._boundBufferBases[e]===t?e:-1}bindBufferRange(t,e,r,s){const{_gl:i}=this;r||(r=0),e||(e=0),this._boundBufferBases[e]=null,i.bindBufferRange(i.UNIFORM_BUFFER,e||0,t.buffer,256*r,s||256)}updateBuffer(t){const{_gl:e}=this,r=this.getGlBuffer(t);if(t._updateID===r.updateID)return r;r.updateID=t._updateID,e.bindBuffer(r.type,r.buffer);const s=t.data,i=t.descriptor.usage&T.S.STATIC?e.STATIC_DRAW:e.DYNAMIC_DRAW;return s?r.byteLength>=s.byteLength?e.bufferSubData(r.type,0,s,0,t._updateSize/s.BYTES_PER_ELEMENT):(r.byteLength=s.byteLength,e.bufferData(r.type,s,i)):(r.byteLength=t.descriptor.size,e.bufferData(r.type,r.byteLength,i)),r}destroyAll(){const t=this._gl;for(const e in this._gpuBuffers)t.deleteBuffer(this._gpuBuffers[e].buffer);this._gpuBuffers=Object.create(null)}onBufferDestroy(t,e){const r=this._gpuBuffers[t.uid],s=this._gl;e||s.deleteBuffer(r.buffer),this._gpuBuffers[t.uid]=null}createGLBuffer(t){const{_gl:e}=this;let r=S.ARRAY_BUFFER;t.descriptor.usage&T.S.INDEX?r=S.ELEMENT_ARRAY_BUFFER:t.descriptor.usage&T.S.UNIFORM&&(r=S.UNIFORM_BUFFER);const s=new A(e.createBuffer(),r);return this._gpuBuffers[t.uid]=s,t.on("destroy",this.onBufferDestroy,this),s}resetState(){this._boundBufferBases=Object.create(null)}}C.extension={type:[s.Ag.WebGLSystem],name:"buffer"};var P=r(5423);const M=class t{constructor(t){this.supports={uint32Indices:!0,uniformBufferObject:!0,vertexArrayObject:!0,srgbTextures:!0,nonPowOf2wrapping:!0,msaa:!0,nonPowOf2mipmaps:!0},this._renderer=t,this.extensions=Object.create(null),this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(t){this.gl=t,this._renderer.gl=t}init(e){e={...t.defaultOptions,...e};let r=this.multiView=e.multiView;if(e.context&&r&&((0,m.R)("Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together."),r=!1),this.canvas=r?P.e.get().createCanvas(this._renderer.canvas.width,this._renderer.canvas.height):this._renderer.view.canvas,e.context)this.initFromContext(e.context);else{const t=this._renderer.background.alpha<1,r=e.premultipliedAlpha??!0,s=e.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(e.preferWebGLVersion,{alpha:t,premultipliedAlpha:r,antialias:s,stencil:!0,preserveDrawingBuffer:e.preserveDrawingBuffer,powerPreference:e.powerPreference??"default"})}}ensureCanvasSize(t){if(!this.multiView)return void(t!==this.canvas&&(0,m.R)("multiView is disabled, but targetCanvas is not the main canvas"));const{canvas:e}=this;(e.width<t.width||e.height<t.height)&&(e.width=Math.max(t.width,t.width),e.height=Math.max(t.height,t.height))}initFromContext(t){this.gl=t,this.webGLVersion=t instanceof P.e.get().getWebGLRenderingContext()?1:2,this.getExtensions(),this.validateContext(t),this._renderer.runners.contextChange.emit(t);const e=this._renderer.view.canvas;e.addEventListener("webglcontextlost",this.handleContextLost,!1),e.addEventListener("webglcontextrestored",this.handleContextRestored,!1)}createContext(t,e){let r;const s=this.canvas;if(2===t&&(r=s.getContext("webgl2",e)),!r&&(r=s.getContext("webgl",e),!r))throw new Error("This browser does not support WebGL. Try using the canvas renderer");this.gl=r,this.initFromContext(this.gl)}getExtensions(){const{gl:t}=this,e={anisotropicFiltering:t.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),s3tc:t.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:t.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:t.getExtension("WEBGL_compressed_texture_etc"),etc1:t.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:t.getExtension("WEBGL_compressed_texture_atc"),astc:t.getExtension("WEBGL_compressed_texture_astc"),bptc:t.getExtension("EXT_texture_compression_bptc"),rgtc:t.getExtension("EXT_texture_compression_rgtc"),loseContext:t.getExtension("WEBGL_lose_context")};if(1===this.webGLVersion)this.extensions={...e,drawBuffers:t.getExtension("WEBGL_draw_buffers"),depthTexture:t.getExtension("WEBGL_depth_texture"),vertexArrayObject:t.getExtension("OES_vertex_array_object")||t.getExtension("MOZ_OES_vertex_array_object")||t.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:t.getExtension("OES_element_index_uint"),floatTexture:t.getExtension("OES_texture_float"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),textureHalfFloat:t.getExtension("OES_texture_half_float"),textureHalfFloatLinear:t.getExtension("OES_texture_half_float_linear"),vertexAttribDivisorANGLE:t.getExtension("ANGLE_instanced_arrays"),srgb:t.getExtension("EXT_sRGB")};else{this.extensions={...e,colorBufferFloat:t.getExtension("EXT_color_buffer_float")};const r=t.getExtension("WEBGL_provoking_vertex");r&&r.provokingVertexWEBGL(r.FIRST_VERTEX_CONVENTION_WEBGL)}}handleContextLost(t){t.preventDefault(),this._contextLossForced&&(this._contextLossForced=!1,setTimeout(()=>{this.gl.isContextLost()&&this.extensions.loseContext?.restoreContext()},0))}handleContextRestored(){this.getExtensions(),this._renderer.runners.contextChange.emit(this.gl)}destroy(){const t=this._renderer.view.canvas;this._renderer=null,t.removeEventListener("webglcontextlost",this.handleContextLost),t.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),this.extensions.loseContext?.loseContext()}forceContextLoss(){this.extensions.loseContext?.loseContext(),this._contextLossForced=!0}validateContext(t){const e=t.getContextAttributes();e&&!e.stencil&&(0,m.R)("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const r=this.supports,s=2===this.webGLVersion,i=this.extensions;r.uint32Indices=s||!!i.uint32ElementIndex,r.uniformBufferObject=s,r.vertexArrayObject=s||!!i.vertexArrayObject,r.srgbTextures=s||!!i.srgb,r.nonPowOf2wrapping=s,r.nonPowOf2mipmaps=s,r.msaa=s,r.uint32Indices||(0,m.R)("Provided WebGL context does not support 32 index buffer, large scenes may not render correctly")}};M.extension={type:[s.Ag.WebGLSystem],name:"context"},M.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};let E=M;var R=r(4988),k=r(498),B=(t=>(t[t.RGBA=6408]="RGBA",t[t.RGB=6407]="RGB",t[t.RG=33319]="RG",t[t.RED=6403]="RED",t[t.RGBA_INTEGER=36249]="RGBA_INTEGER",t[t.RGB_INTEGER=36248]="RGB_INTEGER",t[t.RG_INTEGER=33320]="RG_INTEGER",t[t.RED_INTEGER=36244]="RED_INTEGER",t[t.ALPHA=6406]="ALPHA",t[t.LUMINANCE=6409]="LUMINANCE",t[t.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",t[t.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",t[t.DEPTH_STENCIL=34041]="DEPTH_STENCIL",t))(B||{}),I=(t=>(t[t.TEXTURE_2D=3553]="TEXTURE_2D",t[t.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",t[t.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",t[t.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",t[t.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",t[t.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",t[t.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",t))(I||{}),G=(t=>(t[t.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",t[t.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",t[t.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",t[t.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",t[t.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",t[t.UNSIGNED_INT=5125]="UNSIGNED_INT",t[t.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",t[t.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",t[t.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",t[t.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",t[t.BYTE=5120]="BYTE",t[t.SHORT=5122]="SHORT",t[t.INT=5124]="INT",t[t.FLOAT=5126]="FLOAT",t[t.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",t[t.HALF_FLOAT=36193]="HALF_FLOAT",t))(G||{});const F={uint8x2:G.UNSIGNED_BYTE,uint8x4:G.UNSIGNED_BYTE,sint8x2:G.BYTE,sint8x4:G.BYTE,unorm8x2:G.UNSIGNED_BYTE,unorm8x4:G.UNSIGNED_BYTE,snorm8x2:G.BYTE,snorm8x4:G.BYTE,uint16x2:G.UNSIGNED_SHORT,uint16x4:G.UNSIGNED_SHORT,sint16x2:G.SHORT,sint16x4:G.SHORT,unorm16x2:G.UNSIGNED_SHORT,unorm16x4:G.UNSIGNED_SHORT,snorm16x2:G.SHORT,snorm16x4:G.SHORT,float16x2:G.HALF_FLOAT,float16x4:G.HALF_FLOAT,float32:G.FLOAT,float32x2:G.FLOAT,float32x3:G.FLOAT,float32x4:G.FLOAT,uint32:G.UNSIGNED_INT,uint32x2:G.UNSIGNED_INT,uint32x3:G.UNSIGNED_INT,uint32x4:G.UNSIGNED_INT,sint32:G.INT,sint32x2:G.INT,sint32x3:G.INT,sint32x4:G.INT};function O(t){return F[t]??F.float32}const D={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class U{constructor(t){this._geometryVaoHash=Object.create(null),this._renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this._renderer.renderableGC.addManagedHash(this,"_geometryVaoHash")}contextChange(){const t=this.gl=this._renderer.gl;if(!this._renderer.context.supports.vertexArrayObject)throw new Error("[PixiJS] Vertex Array Objects are not supported on this device");const e=this._renderer.context.extensions.vertexArrayObject;e&&(t.createVertexArray=()=>e.createVertexArrayOES(),t.bindVertexArray=t=>e.bindVertexArrayOES(t),t.deleteVertexArray=t=>e.deleteVertexArrayOES(t));const r=this._renderer.context.extensions.vertexAttribDivisorANGLE;r&&(t.drawArraysInstanced=(t,e,s,i)=>{r.drawArraysInstancedANGLE(t,e,s,i)},t.drawElementsInstanced=(t,e,s,i,n)=>{r.drawElementsInstancedANGLE(t,e,s,i,n)},t.vertexAttribDivisor=(t,e)=>r.vertexAttribDivisorANGLE(t,e)),this._activeGeometry=null,this._activeVao=null,this._geometryVaoHash=Object.create(null)}bind(t,e){const r=this.gl;this._activeGeometry=t;const s=this.getVao(t,e);this._activeVao!==s&&(this._activeVao=s,r.bindVertexArray(s)),this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this._renderer.buffer;for(let r=0;r<t.buffers.length;r++){const s=t.buffers[r];e.updateBuffer(s)}}checkCompatibility(t,e){const r=t.attributes,s=e._attributeData;for(const t in s)if(!r[t])throw new Error(`shader and geometry incompatible, geometry missing the "${t}" attribute`)}getSignature(t,e){const r=t.attributes,s=e._attributeData,i=["g",t.uid];for(const t in r)s[t]&&i.push(t,s[t].location);return i.join("-")}getVao(t,e){return this._geometryVaoHash[t.uid]?.[e._key]||this.initGeometryVao(t,e)}initGeometryVao(t,e,r=!0){const s=this._renderer.gl,i=this._renderer.buffer;this._renderer.shader._getProgramData(e),this.checkCompatibility(t,e);const n=this.getSignature(t,e);this._geometryVaoHash[t.uid]||(this._geometryVaoHash[t.uid]=Object.create(null),t.on("destroy",this.onGeometryDestroy,this));const o=this._geometryVaoHash[t.uid];let a=o[n];if(a)return o[e._key]=a,a;(0,k.q)(t,e._attributeData);const l=t.buffers;a=s.createVertexArray(),s.bindVertexArray(a);for(let t=0;t<l.length;t++){const e=l[t];i.bind(e)}return this.activateVao(t,e),o[e._key]=a,o[n]=a,s.bindVertexArray(null),a}onGeometryDestroy(t,e){const r=this._geometryVaoHash[t.uid],s=this.gl;if(r){if(e)for(const t in r)this._activeVao!==r[t]&&this.unbind(),s.deleteVertexArray(r[t]);this._geometryVaoHash[t.uid]=null}}destroyAll(t=!1){const e=this.gl;for(const r in this._geometryVaoHash){if(t)for(const t in this._geometryVaoHash[r]){const s=this._geometryVaoHash[r];this._activeVao!==s&&this.unbind(),e.deleteVertexArray(s[t])}this._geometryVaoHash[r]=null}}activateVao(t,e){const r=this._renderer.gl,s=this._renderer.buffer,i=t.attributes;t.indexBuffer&&s.bind(t.indexBuffer);let n=null;for(const t in i){const o=i[t],a=o.buffer,l=s.getGlBuffer(a),h=e._attributeData[t];if(h){n!==l&&(s.bind(a),n=l);const t=h.location;r.enableVertexAttribArray(t);const e=(0,R.m)(o.format),i=O(o.format);if("int"===h.format?.substring(1,4)?r.vertexAttribIPointer(t,e.size,i,o.stride,o.offset):r.vertexAttribPointer(t,e.size,i,e.normalised,o.stride,o.offset),o.instance){if(!this.hasInstance)throw new Error("geometry error, GPU Instancing is not supported on this device");{const e=o.divisor??1;r.vertexAttribDivisor(t,e)}}}}}draw(t,e,r,s){const{gl:i}=this._renderer,n=this._activeGeometry,o=D[t||n.topology];if(s??(s=n.instanceCount),n.indexBuffer){const t=n.indexBuffer.data.BYTES_PER_ELEMENT,a=2===t?i.UNSIGNED_SHORT:i.UNSIGNED_INT;s>1?i.drawElementsInstanced(o,e||n.indexBuffer.data.length,a,(r||0)*t,s):i.drawElements(o,e||n.indexBuffer.data.length,a,(r||0)*t)}else s>1?i.drawArraysInstanced(o,r||0,e||n.getSize(),s):i.drawArrays(o,r||0,e||n.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this._renderer=null,this.gl=null,this._activeVao=null,this._activeGeometry=null,this._geometryVaoHash=null}}U.extension={type:[s.Ag.WebGLSystem],name:"geometry"};var L=r(8337),N=r(4269),z=r(5007);const W=new L.V({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),H=class t{constructor(t){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=t}init(e={}){const{useBackBuffer:r,antialias:s}={...t.defaultOptions,...e};this.useBackBuffer=r,this._antialias=s,this._renderer.context.supports.msaa||((0,m.R)("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=_.U.for2d();const i=new z.M({vertex:"\n attribute vec2 aPosition;\n out vec2 vUv;\n\n void main() {\n gl_Position = vec4(aPosition, 0.0, 1.0);\n\n vUv = (aPosition + 1.0) / 2.0;\n\n // flip dem UVs\n vUv.y = 1.0 - vUv.y;\n }",fragment:"\n in vec2 vUv;\n out vec4 finalColor;\n\n uniform sampler2D uTexture;\n\n void main() {\n finalColor = texture(uTexture, vUv);\n }",name:"big-triangle"});this._bigTriangleShader=new u.M({glProgram:i,resources:{uTexture:g.g.WHITE.source}})}renderStart(t){const e=this._renderer.renderTarget.getRenderTarget(t.target);if(this._useBackBufferThisRender=this.useBackBuffer&&!!e.isRoot,this._useBackBufferThisRender){const e=this._renderer.renderTarget.getRenderTarget(t.target);this._targetTexture=e.colorTexture,t.target=this._getBackBufferTexture(e.colorTexture)}}renderEnd(){this._presentBackBuffer()}_presentBackBuffer(){const t=this._renderer;t.renderTarget.finishRenderPass(),this._useBackBufferThisRender&&(t.renderTarget.bind(this._targetTexture,!1),this._bigTriangleShader.resources.uTexture=this._backBufferTexture.source,t.encoder.draw({geometry:W,shader:this._bigTriangleShader,state:this._state}))}_getBackBufferTexture(t){return this._backBufferTexture=this._backBufferTexture||new g.g({source:new N.v({width:t.width,height:t.height,resolution:t._resolution,antialias:this._antialias})}),this._backBufferTexture.source.resize(t.width,t.height,t._resolution),this._backBufferTexture}destroy(){this._backBufferTexture&&(this._backBufferTexture.destroy(),this._backBufferTexture=null)}};H.extension={type:[s.Ag.WebGLSystem],name:"backBuffer",priority:1},H.defaultOptions={useBackBuffer:!1};let X=H;class V{constructor(t){this._colorMaskCache=15,this._renderer=t}setMask(t){this._colorMaskCache!==t&&(this._colorMaskCache=t,this._renderer.gl.colorMask(!!(8&t),!!(4&t),!!(2&t),!!(1&t)))}}V.extension={type:[s.Ag.WebGLSystem],name:"colorMask"};class Y{constructor(t){this.commandFinished=Promise.resolve(),this._renderer=t}setGeometry(t,e){this._renderer.geometry.bind(t,e.glProgram)}finishRenderPass(){}draw(t){const e=this._renderer,{geometry:r,shader:s,state:i,skipSync:n,topology:o,size:a,start:l,instanceCount:h}=t;e.shader.bind(s,n),e.geometry.bind(r,e.shader._activeProgram),i&&e.state.set(i),e.geometry.draw(o,a,l,h??r.instanceCount)}destroy(){this._renderer=null}}Y.extension={type:[s.Ag.WebGLSystem],name:"encoder"};var j=r(6890);class ${constructor(t){this._renderer=t}contextChange(){const t=this._renderer.gl;this.maxTextures=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),this.maxBatchableTextures=(0,j.u)(this.maxTextures,t);const e=2===this._renderer.context.webGLVersion;this.maxUniformBindings=e?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0}destroy(){}}$.extension={type:[s.Ag.WebGLSystem],name:"limits"};var q=r(9250),K=r(8271);class Z{constructor(t){this._stencilCache={enabled:!1,stencilReference:0,stencilMode:K.K.NONE},this._renderTargetStencilState=Object.create(null),t.renderTarget.onRenderTargetChange.add(this)}contextChange(t){this._gl=t,this._comparisonFuncMapping={always:t.ALWAYS,never:t.NEVER,equal:t.EQUAL,"not-equal":t.NOTEQUAL,less:t.LESS,"less-equal":t.LEQUAL,greater:t.GREATER,"greater-equal":t.GEQUAL},this._stencilOpsMapping={keep:t.KEEP,zero:t.ZERO,replace:t.REPLACE,invert:t.INVERT,"increment-clamp":t.INCR,"decrement-clamp":t.DECR,"increment-wrap":t.INCR_WRAP,"decrement-wrap":t.DECR_WRAP},this.resetState()}onRenderTargetChange(t){if(this._activeRenderTarget===t)return;this._activeRenderTarget=t;let e=this._renderTargetStencilState[t.uid];e||(e=this._renderTargetStencilState[t.uid]={stencilMode:K.K.DISABLED,stencilReference:0}),this.setStencilMode(e.stencilMode,e.stencilReference)}resetState(){this._stencilCache.enabled=!1,this._stencilCache.stencilMode=K.K.NONE,this._stencilCache.stencilReference=0}setStencilMode(t,e){const r=this._renderTargetStencilState[this._activeRenderTarget.uid],s=this._gl,i=q.g[t],n=this._stencilCache;r.stencilMode=t,r.stencilReference=e,t!==K.K.DISABLED?(this._stencilCache.enabled||(this._stencilCache.enabled=!0,s.enable(s.STENCIL_TEST)),t===n.stencilMode&&n.stencilReference===e||(n.stencilMode=t,n.stencilReference=e,s.stencilFunc(this._comparisonFuncMapping[i.stencilBack.compare],e,255),s.stencilOp(s.KEEP,s.KEEP,this._stencilOpsMapping[i.stencilBack.passOp]))):this._stencilCache.enabled&&(this._stencilCache.enabled=!1,s.disable(s.STENCIL_TEST))}}Z.extension={type:[s.Ag.WebGLSystem],name:"stencil"};var Q=r(1009);const J={f32:4,i32:4,"vec2<f32>":8,"vec3<f32>":12,"vec4<f32>":16,"vec2<i32>":8,"vec3<i32>":12,"vec4<i32>":16,"mat2x2<f32>":32,"mat3x3<f32>":48,"mat4x4<f32>":64};function tt(t){const e=t.map(t=>({data:t,offset:0,size:0}));let r=0,s=0;for(let t=0;t<e.length;t++){const i=e[t];if(r=J[i.data.type],!r)throw new Error(`Unknown type ${i.data.type}`);i.data.size>1&&(r=Math.max(r,16)*i.data.size);const n=12===r?16:r;i.size=r;const o=s%16;s+=o>0&&16-o<n?(16-o)%16:(r-o%r)%r,i.offset=s,s+=r}return s=16*Math.ceil(s/16),{uboElements:e,size:s}}var et=r(2337),rt=r(4364);function st(t,e){const r=Math.max(J[t.data.type]/16,1),s=t.data.value.length/t.data.size,i=(4-s%4)%4,n=t.data.type.indexOf("i32")>=0?"dataInt32":"data";return`\n v = uv.${t.data.name};\n offset += ${e};\n\n arrayOffset = offset;\n\n t = 0;\n\n for(var i=0; i < ${t.data.size*r}; i++)\n {\n for(var j = 0; j < ${s}; j++)\n {\n ${n}[arrayOffset++] = v[t++];\n }\n ${0!==i?`arrayOffset += ${i};`:""}\n }\n `}function it(t){return(0,et.E)(t,"uboStd40",st,rt.g)}class nt extends Q.W{constructor(){super({createUboElements:tt,generateUboSync:it})}}nt.extension={type:[s.Ag.WebGLSystem],name:"ubo"};var ot=r(8900),at=r(9390),lt=r(1386),ht=r(1711);class ct{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this.msaaRenderBuffer=[]}}class ut{constructor(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new at.M}init(t,e){this._renderer=t,this._renderTargetSystem=e,t.runners.contextChange.add(this)}contextChange(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new at.M}copyToTexture(t,e,r,s,i){const n=this._renderTargetSystem,o=this._renderer,a=n.getGpuRenderTarget(t),l=o.gl;return this.finishRenderPass(t),l.bindFramebuffer(l.FRAMEBUFFER,a.resolveTargetFramebuffer),o.texture.bind(e,0),l.copyTexSubImage2D(l.TEXTURE_2D,0,i.x,i.y,r.x,r.y,s.width,s.height),e}startRenderPass(t,e=!0,r,s){const i=this._renderTargetSystem,n=t.colorTexture,o=i.getGpuRenderTarget(t);let a=s.y;t.isRoot&&(a=n.pixelHeight-s.height),t.colorTextures.forEach(t=>{this._renderer.texture.unbind(t)});const l=this._renderer.gl;l.bindFramebuffer(l.FRAMEBUFFER,o.framebuffer);const h=this._viewPortCache;h.x===s.x&&h.y===a&&h.width===s.width&&h.height===s.height||(h.x=s.x,h.y=a,h.width=s.width,h.height=s.height,l.viewport(s.x,a,s.width,s.height)),o.depthStencilRenderBuffer||!t.stencil&&!t.depth||this._initStencil(o),this.clear(t,e,r)}finishRenderPass(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);if(!e.msaa)return;const r=this._renderer.gl;r.bindFramebuffer(r.FRAMEBUFFER,e.resolveTargetFramebuffer),r.bindFramebuffer(r.READ_FRAMEBUFFER,e.framebuffer),r.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,r.COLOR_BUFFER_BIT,r.NEAREST),r.bindFramebuffer(r.FRAMEBUFFER,e.framebuffer)}initGpuRenderTarget(t){const e=this._renderer.gl,r=new ct;return t.colorTexture instanceof lt.q?(this._renderer.context.ensureCanvasSize(t.colorTexture.resource),r.framebuffer=null,r):(this._initColor(t,r),e.bindFramebuffer(e.FRAMEBUFFER,null),r)}destroyGpuRenderTarget(t){const e=this._renderer.gl;t.framebuffer&&(e.deleteFramebuffer(t.framebuffer),t.framebuffer=null),t.resolveTargetFramebuffer&&(e.deleteFramebuffer(t.resolveTargetFramebuffer),t.resolveTargetFramebuffer=null),t.depthStencilRenderBuffer&&(e.deleteRenderbuffer(t.depthStencilRenderBuffer),t.depthStencilRenderBuffer=null),t.msaaRenderBuffer.forEach(t=>{e.deleteRenderbuffer(t)}),t.msaaRenderBuffer=null}clear(t,e,r){if(!e)return;const s=this._renderTargetSystem;"boolean"==typeof e&&(e=e?ht.u.ALL:ht.u.NONE);const i=this._renderer.gl;if(e&ht.u.COLOR){r??(r=s.defaultClearColor);const t=this._clearColorCache,e=r;t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]||(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],i.clearColor(e[0],e[1],e[2],e[3]))}i.clear(e)}resizeGpuRenderTarget(t){if(t.isRoot)return;const e=this._renderTargetSystem.getGpuRenderTarget(t);this._resizeColor(t,e),(t.stencil||t.depth)&&this._resizeStencil(e)}_initColor(t,e){const r=this._renderer,s=r.gl,i=s.createFramebuffer();if(e.resolveTargetFramebuffer=i,s.bindFramebuffer(s.FRAMEBUFFER,i),e.width=t.colorTexture.source.pixelWidth,e.height=t.colorTexture.source.pixelHeight,t.colorTextures.forEach((t,i)=>{const n=t.source;n.antialias&&(r.context.supports.msaa?e.msaa=!0:(0,m.R)("[RenderTexture] Antialiasing on textures is not supported in WebGL1")),r.texture.bindSource(n,0);const o=r.texture.getGlSource(n).texture;s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+i,3553,o,0)}),e.msaa){const r=s.createFramebuffer();e.framebuffer=r,s.bindFramebuffer(s.FRAMEBUFFER,r),t.colorTextures.forEach((t,r)=>{const i=s.createRenderbuffer();e.msaaRenderBuffer[r]=i})}else e.framebuffer=i;this._resizeColor(t,e)}_resizeColor(t,e){const r=t.colorTexture.source;if(e.width=r.pixelWidth,e.height=r.pixelHeight,t.colorTextures.forEach((t,e)=>{0!==e&&t.source.resize(r.width,r.height,r._resolution)}),e.msaa){const r=this._renderer,s=r.gl,i=e.framebuffer;s.bindFramebuffer(s.FRAMEBUFFER,i),t.colorTextures.forEach((t,i)=>{const n=t.source;r.texture.bindSource(n,0);const o=r.texture.getGlSource(n).internalFormat,a=e.msaaRenderBuffer[i];s.bindRenderbuffer(s.RENDERBUFFER,a),s.renderbufferStorageMultisample(s.RENDERBUFFER,4,o,n.pixelWidth,n.pixelHeight),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+i,s.RENDERBUFFER,a)})}}_initStencil(t){if(null===t.framebuffer)return;const e=this._renderer.gl,r=e.createRenderbuffer();t.depthStencilRenderBuffer=r,e.bindRenderbuffer(e.RENDERBUFFER,r),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,r),this._resizeStencil(t)}_resizeStencil(t){const e=this._renderer.gl;e.bindRenderbuffer(e.RENDERBUFFER,t.depthStencilRenderBuffer),t.msaa?e.renderbufferStorageMultisample(e.RENDERBUFFER,4,e.DEPTH24_STENCIL8,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,2===this._renderer.context.webGLVersion?e.DEPTH24_STENCIL8:e.DEPTH_STENCIL,t.width,t.height)}prerender(t){const e=t.colorTexture.resource;this._renderer.context.multiView&&lt.q.test(e)&&this._renderer.context.ensureCanvasSize(e)}postrender(t){if(this._renderer.context.multiView&&lt.q.test(t.colorTexture.resource)){const e=this._renderer.context.canvas,r=t.colorTexture;r.context2D.drawImage(e,0,r.pixelHeight-e.height)}}}class dt extends ot.l{constructor(t){super(t),this.adaptor=new ut,this.adaptor.init(t,this)}}dt.extension={type:[s.Ag.WebGLSystem],name:"renderTarget"};var pt=r(2015);class ft{constructor(t,e){this.program=t,this.uniformData=e,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBlockBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBlockBindings=null,this.program=null}}function gt(t,e,r){const s=t.createShader(e);return t.shaderSource(s,r),t.compileShader(s),s}function mt(t){const e=new Array(t);for(let t=0;t<e.length;t++)e[t]=!1;return e}function xt(t,e){switch(t){case"float":case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"vec2":return new Float32Array(2*e);case"vec3":return new Float32Array(3*e);case"vec4":return new Float32Array(4*e);case"ivec2":return new Int32Array(2*e);case"ivec3":return new Int32Array(3*e);case"ivec4":return new Int32Array(4*e);case"uvec2":return new Uint32Array(2*e);case"uvec3":return new Uint32Array(3*e);case"uvec4":return new Uint32Array(4*e);case"bool":return!1;case"bvec2":return mt(2*e);case"bvec3":return mt(3*e);case"bvec4":return mt(4*e);case"mat2":return new Float32Array([1,0,0,1]);case"mat3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}let _t=null;const yt={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",UNSIGNED_INT:"uint",UNSIGNED_INT_VEC2:"uvec2",UNSIGNED_INT_VEC3:"uvec3",UNSIGNED_INT_VEC4:"uvec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",INT_SAMPLER_2D:"sampler2D",UNSIGNED_INT_SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube",INT_SAMPLER_CUBE:"samplerCube",UNSIGNED_INT_SAMPLER_CUBE:"samplerCube",SAMPLER_2D_ARRAY:"sampler2DArray",INT_SAMPLER_2D_ARRAY:"sampler2DArray",UNSIGNED_INT_SAMPLER_2D_ARRAY:"sampler2DArray"},vt={float:"float32",vec2:"float32x2",vec3:"float32x3",vec4:"float32x4",int:"sint32",ivec2:"sint32x2",ivec3:"sint32x3",ivec4:"sint32x4",uint:"uint32",uvec2:"uint32x2",uvec3:"uint32x3",uvec4:"uint32x4",bool:"uint32",bvec2:"uint32x2",bvec3:"uint32x3",bvec4:"uint32x4"};function bt(t,e){if(!_t){const e=Object.keys(yt);_t={};for(let r=0;r<e.length;++r){const s=e[r];_t[t[s]]=yt[s]}}return _t[e]}function wt(t,e){const r=bt(t,e);return vt[r]||"float32"}function Tt(t,e){const r=t.getShaderSource(e).split("\n").map((t,e)=>`${e}: ${t}`),s=t.getShaderInfoLog(e),i=s.split("\n"),n={},o=i.map(t=>parseFloat(t.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(t=>!(!t||n[t]||(n[t]=!0,0))),a=[""];o.forEach(t=>{r[t-1]=`%c${r[t-1]}%c`,a.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const l=r.join("\n");a[0]=l,console.error(s),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}const St={textureCount:0,blockIndex:0};class At{constructor(t){this._activeProgram=null,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_programDataHash")}contextChange(t){this._gl=t,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._activeProgram=null}bind(t,e){if(this._setProgram(t.glProgram),e)return;St.textureCount=0,St.blockIndex=0;let r=this._shaderSyncFunctions[t.glProgram._key];r||(r=this._shaderSyncFunctions[t.glProgram._key]=this._generateShaderSync(t,this)),this._renderer.buffer.nextBindBase(!!t.glProgram.transformFeedbackVaryings),r(this._renderer,t,St)}updateUniformGroup(t){this._renderer.uniformGroup.updateUniformGroup(t,this._activeProgram,St)}bindUniformBlock(t,e,r=0){const s=this._renderer.buffer,i=this._getProgramData(this._activeProgram),n=t._bufferResource;n||this._renderer.ubo.updateUniformGroup(t);const o=t.buffer,a=s.updateBuffer(o),l=s.freeLocationForBufferBase(a);if(n){const{offset:e,size:r}=t;0===e&&r===o.data.byteLength?s.bindBufferBase(a,l):s.bindBufferRange(a,l,e)}else s.getLastBindBaseLocation(a)!==l&&s.bindBufferBase(a,l);const h=this._activeProgram._uniformBlockData[e].index;i.uniformBlockBindings[r]!==l&&(i.uniformBlockBindings[r]=l,this._renderer.gl.uniformBlockBinding(i.program,h,l))}_setProgram(t){if(this._activeProgram===t)return;this._activeProgram=t;const e=this._getProgramData(t);this._gl.useProgram(e.program)}_getProgramData(t){return this._programDataHash[t._key]||this._createProgramData(t)}_createProgramData(t){const e=t._key;return this._programDataHash[e]=function(t,e){const r=gt(t,t.VERTEX_SHADER,e.vertex),s=gt(t,t.FRAGMENT_SHADER,e.fragment),i=t.createProgram();t.attachShader(i,r),t.attachShader(i,s);const n=e.transformFeedbackVaryings;n&&("function"!=typeof t.transformFeedbackVaryings?(0,m.R)("TransformFeedback is not supported but TransformFeedbackVaryings are given."):t.transformFeedbackVaryings(i,n.names,"separate"===n.bufferMode?t.SEPARATE_ATTRIBS:t.INTERLEAVED_ATTRIBS)),t.linkProgram(i),t.getProgramParameter(i,t.LINK_STATUS)||function(t,e,r,s){t.getProgramParameter(e,t.LINK_STATUS)||(t.getShaderParameter(r,t.COMPILE_STATUS)||Tt(t,r),t.getShaderParameter(s,t.COMPILE_STATUS)||Tt(t,s),console.error("PixiJS Error: Could not initialize shader."),""!==t.getProgramInfoLog(e)&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",t.getProgramInfoLog(e)))}(t,i,r,s),e._attributeData=function(t,e,r=!1){const s={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){const i=e.getActiveAttrib(t,r);if(i.name.startsWith("gl_"))continue;const n=wt(e,i.type);s[i.name]={location:0,format:n,stride:(0,R.m)(n).stride,offset:0,instance:!1,start:0}}const n=Object.keys(s);if(r){n.sort((t,e)=>t>e?1:-1);for(let r=0;r<n.length;r++)s[n[r]].location=r,e.bindAttribLocation(t,r,n[r]);e.linkProgram(t)}else for(let r=0;r<n.length;r++)s[n[r]].location=e.getAttribLocation(t,n[r]);return s}(i,t,!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(e.vertex)),e._uniformData=function(t,e){const r={},s=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let i=0;i<s;i++){const s=e.getActiveUniform(t,i),n=s.name.replace(/\[.*?\]$/,""),o=!!s.name.match(/\[.*?\]$/),a=bt(e,s.type);r[n]={name:n,index:i,type:a,size:s.size,isArray:o,value:xt(a,s.size)}}return r}(i,t),e._uniformBlockData=function(t,e){if(!e.ACTIVE_UNIFORM_BLOCKS)return{};const r={},s=e.getProgramParameter(t,e.ACTIVE_UNIFORM_BLOCKS);for(let i=0;i<s;i++){const s=e.getActiveUniformBlockName(t,i),n=e.getUniformBlockIndex(t,s),o=e.getActiveUniformBlockParameter(t,i,e.UNIFORM_BLOCK_DATA_SIZE);r[s]={name:s,index:n,size:o}}return r}(i,t),t.deleteShader(r),t.deleteShader(s);const o={};for(const r in e._uniformData){const s=e._uniformData[r];o[r]={location:t.getUniformLocation(i,r),value:xt(s.type,s.size)}}return new ft(i,o)}(this._gl,t),this._programDataHash[e]}destroy(){for(const t of Object.keys(this._programDataHash))this._programDataHash[t].destroy(),this._programDataHash[t]=null;this._programDataHash=null,this._shaderSyncFunctions=null,this._activeProgram=null,this._renderer=null,this._gl=null}_generateShaderSync(t,e){return function(t,e){const r=[],s=["\n var g = s.groups;\n var sS = r.shader;\n var p = s.glProgram;\n var ugS = r.uniformGroup;\n var resources;\n "];let i=!1,n=0;const o=e._getProgramData(t.glProgram);for(const a in t.groups){const l=t.groups[a];r.push(`\n resources = g[${a}].resources;\n `);for(const h in l.resources){const c=l.resources[h];if(c instanceof d.k)if(c.ubo){const e=t._uniformBindMap[a][Number(h)];r.push(`\n sS.bindUniformBlock(\n resources[${h}],\n '${e}',\n ${t.glProgram._uniformBlockData[e].index}\n );\n `)}else r.push(`\n ugS.updateUniformGroup(resources[${h}], p, sD);\n `);else if(c instanceof pt.d){const e=t._uniformBindMap[a][Number(h)];r.push(`\n sS.bindUniformBlock(\n resources[${h}],\n '${e}',\n ${t.glProgram._uniformBlockData[e].index}\n );\n `)}else if(c instanceof N.v){const l=t._uniformBindMap[a][h],c=o.uniformData[l];c&&(i||(i=!0,s.push("\n var tS = r.texture;\n ")),e._gl.uniform1i(c.location,n),r.push(`\n tS.bind(resources[${h}], ${n});\n `),n++)}}}const a=[...s,...r].join("\n");return new Function("r","s","sD",a)}(t,e)}resetState(){this._activeProgram=null}}At.extension={type:[s.Ag.WebGLSystem],name:"shader"};var Ct=r(2276);const Pt={f32:"if (cv !== v) {\n cu.value = v;\n gl.uniform1f(location, v);\n }","vec2<f32>":"if (cv[0] !== v[0] || cv[1] !== v[1]) {\n cv[0] = v[0];\n cv[1] = v[1];\n gl.uniform2f(location, v[0], v[1]);\n }","vec3<f32>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n gl.uniform3f(location, v[0], v[1], v[2]);\n }","vec4<f32>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n gl.uniform4f(location, v[0], v[1], v[2], v[3]);\n }",i32:"if (cv !== v) {\n cu.value = v;\n gl.uniform1i(location, v);\n }","vec2<i32>":"if (cv[0] !== v[0] || cv[1] !== v[1]) {\n cv[0] = v[0];\n cv[1] = v[1];\n gl.uniform2i(location, v[0], v[1]);\n }","vec3<i32>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n gl.uniform3i(location, v[0], v[1], v[2]);\n }","vec4<i32>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n gl.uniform4i(location, v[0], v[1], v[2], v[3]);\n }",u32:"if (cv !== v) {\n cu.value = v;\n gl.uniform1ui(location, v);\n }","vec2<u32>":"if (cv[0] !== v[0] || cv[1] !== v[1]) {\n cv[0] = v[0];\n cv[1] = v[1];\n gl.uniform2ui(location, v[0], v[1]);\n }","vec3<u32>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n gl.uniform3ui(location, v[0], v[1], v[2]);\n }","vec4<u32>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n gl.uniform4ui(location, v[0], v[1], v[2], v[3]);\n }",bool:"if (cv !== v) {\n cu.value = v;\n gl.uniform1i(location, v);\n }","vec2<bool>":"if (cv[0] !== v[0] || cv[1] !== v[1]) {\n cv[0] = v[0];\n cv[1] = v[1];\n gl.uniform2i(location, v[0], v[1]);\n }","vec3<bool>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n gl.uniform3i(location, v[0], v[1], v[2]);\n }","vec4<bool>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n gl.uniform4i(location, v[0], v[1], v[2], v[3]);\n }","mat2x2<f32>":"gl.uniformMatrix2fv(location, false, v);","mat3x3<f32>":"gl.uniformMatrix3fv(location, false, v);","mat4x4<f32>":"gl.uniformMatrix4fv(location, false, v);"},Mt={f32:"gl.uniform1fv(location, v);","vec2<f32>":"gl.uniform2fv(location, v);","vec3<f32>":"gl.uniform3fv(location, v);","vec4<f32>":"gl.uniform4fv(location, v);","mat2x2<f32>":"gl.uniformMatrix2fv(location, false, v);","mat3x3<f32>":"gl.uniformMatrix3fv(location, false, v);","mat4x4<f32>":"gl.uniformMatrix4fv(location, false, v);",i32:"gl.uniform1iv(location, v);","vec2<i32>":"gl.uniform2iv(location, v);","vec3<i32>":"gl.uniform3iv(location, v);","vec4<i32>":"gl.uniform4iv(location, v);",u32:"gl.uniform1iv(location, v);","vec2<u32>":"gl.uniform2iv(location, v);","vec3<u32>":"gl.uniform3iv(location, v);","vec4<u32>":"gl.uniform4iv(location, v);",bool:"gl.uniform1iv(location, v);","vec2<bool>":"gl.uniform2iv(location, v);","vec3<bool>":"gl.uniform3iv(location, v);","vec4<bool>":"gl.uniform4iv(location, v);"};class Et{constructor(t){this._cache={},this._uniformGroupSyncHash={},this._renderer=t,this.gl=null,this._cache={}}contextChange(t){this.gl=t}updateUniformGroup(t,e,r){const s=this._renderer.shader._getProgramData(e);t.isStatic&&t._dirtyId===s.uniformDirtyGroups[t.uid]||(s.uniformDirtyGroups[t.uid]=t._dirtyId,this._getUniformSyncFunction(t,e)(s.uniformData,t.uniforms,this._renderer,r))}_getUniformSyncFunction(t,e){return this._uniformGroupSyncHash[t._signature]?.[e._key]||this._createUniformSyncFunction(t,e)}_createUniformSyncFunction(t,e){const r=this._uniformGroupSyncHash[t._signature]||(this._uniformGroupSyncHash[t._signature]={}),s=this._getSignature(t,e._uniformData,"u");return this._cache[s]||(this._cache[s]=this._generateUniformsSync(t,e._uniformData)),r[e._key]=this._cache[s],r[e._key]}_generateUniformsSync(t,e){return function(t,e){const r=["\n var v = null;\n var cv = null;\n var cu = null;\n var t = 0;\n var gl = renderer.gl;\n var name = null;\n "];for(const s in t.uniforms){if(!e[s]){t.uniforms[s]instanceof d.k?t.uniforms[s].ubo?r.push(`\n renderer.shader.bindUniformBlock(uv.${s}, "${s}");\n `):r.push(`\n renderer.shader.updateUniformGroup(uv.${s});\n `):t.uniforms[s]instanceof pt.d&&r.push(`\n renderer.shader.bindBufferResource(uv.${s}, "${s}");\n `);continue}const i=t.uniformStructures[s];let n=!1;for(let t=0;t<Ct.$.length;t++){const e=Ct.$[t];if(i.type===e.type&&e.test(i)){r.push(`name = "${s}";`,Ct.$[t].uniform),n=!0;break}}if(!n){const t=(1===i.size?Pt:Mt)[i.type].replace("location",`ud["${s}"].location`);r.push(`\n cu = ud["${s}"];\n cv = cu.value;\n v = uv["${s}"];\n ${t};`)}}return new Function("ud","uv","renderer","syncData",r.join("\n"))}(t,e)}_getSignature(t,e,r){const s=t.uniforms,i=[`${r}-`];for(const t in s)i.push(t),e[t]&&i.push(e[t].type);return i.join("-")}destroy(){this._renderer=null,this._cache=null}}Et.extension={type:[s.Ag.WebGLSystem],name:"uniformGroup"};const Rt=class t{constructor(t){this._invertFrontFace=!1,this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode="none",this._blendEq=!1,this.map=[],this.map[0]=this.setBlend,this.map[1]=this.setOffset,this.map[2]=this.setCullFace,this.map[3]=this.setDepthTest,this.map[4]=this.setFrontFace,this.map[5]=this.setDepthMask,this.checks=[],this.defaultState=_.U.for2d(),t.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(t){this._invertFrontFace=!t.isRoot,this._cullFace?this.setFrontFace(this._frontFace):this._frontFaceDirty=!0}contextChange(t){this.gl=t,this.blendModesMap=function(t){const e={};if(e.normal=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e.add=[t.ONE,t.ONE],e.multiply=[t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA],e.screen=[t.ONE,t.ONE_MINUS_SRC_COLOR,t.ONE,t.ONE_MINUS_SRC_ALPHA],e.none=[0,0],e["normal-npm"]=[t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA],e["add-npm"]=[t.SRC_ALPHA,t.ONE,t.ONE,t.ONE],e["screen-npm"]=[t.SRC_ALPHA,t.ONE_MINUS_SRC_COLOR,t.ONE,t.ONE_MINUS_SRC_ALPHA],e.erase=[t.ZERO,t.ONE_MINUS_SRC_ALPHA],t instanceof P.e.get().getWebGLRenderingContext()){const r=t.getExtension("EXT_blend_minmax");r&&(e.min=[t.ONE,t.ONE,t.ONE,t.ONE,r.MIN_EXT,r.MIN_EXT],e.max=[t.ONE,t.ONE,t.ONE,t.ONE,r.MAX_EXT,r.MAX_EXT])}else e.min=[t.ONE,t.ONE,t.ONE,t.ONE,t.MIN,t.MIN],e.max=[t.ONE,t.ONE,t.ONE,t.ONE,t.MAX,t.MAX];return e}(t),this.resetState()}set(t){if(t||(t=this.defaultState),this.stateId!==t.data){let e=this.stateId^t.data,r=0;for(;e;)1&e&&this.map[r].call(this,!!(t.data&1<<r)),e>>=1,r++;this.stateId=t.data}for(let e=0;e<this.checks.length;e++)this.checks[e](this,t)}forceState(t){t||(t=this.defaultState);for(let e=0;e<this.map.length;e++)this.map[e].call(this,!!(t.data&1<<e));for(let e=0;e<this.checks.length;e++)this.checks[e](this,t);this.stateId=t.data}setBlend(e){this._updateCheck(t._checkBlendMode,e),this.gl[e?"enable":"disable"](this.gl.BLEND)}setOffset(e){this._updateCheck(t._checkPolygonOffset,e),this.gl[e?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(t){this.gl[t?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(t){this.gl.depthMask(t)}setCullFace(t){this._cullFace=t,this.gl[t?"enable":"disable"](this.gl.CULL_FACE),this._cullFace&&this._frontFaceDirty&&this.setFrontFace(this._frontFace)}setFrontFace(t){this._frontFace=t,this._frontFaceDirty=!1;const e=this._invertFrontFace?!t:t;this._glFrontFace!==e&&(this._glFrontFace=e,this.gl.frontFace(this.gl[e?"CW":"CCW"]))}setBlendMode(t){if(this.blendModesMap[t]||(t="normal"),t===this.blendMode)return;this.blendMode=t;const e=this.blendModesMap[t],r=this.gl;2===e.length?r.blendFunc(e[0],e[1]):r.blendFuncSeparate(e[0],e[1],e[2],e[3]),6===e.length?(this._blendEq=!0,r.blendEquationSeparate(e[4],e[5])):this._blendEq&&(this._blendEq=!1,r.blendEquationSeparate(r.FUNC_ADD,r.FUNC_ADD))}setPolygonOffset(t,e){this.gl.polygonOffset(t,e)}resetState(){this._glFrontFace=!1,this._frontFace=!1,this._cullFace=!1,this._frontFaceDirty=!1,this._invertFrontFace=!1,this.gl.frontFace(this.gl.CCW),this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode="",this.setBlendMode("normal")}_updateCheck(t,e){const r=this.checks.indexOf(t);e&&-1===r?this.checks.push(t):e||-1===r||this.checks.splice(r,1)}static _checkBlendMode(t,e){t.setBlendMode(e.blendMode)}static _checkPolygonOffset(t,e){t.setPolygonOffset(1,e.polygonOffset)}destroy(){this.gl=null,this.checks.length=0}};Rt.extension={type:[s.Ag.WebGLSystem],name:"state"};let kt=Rt;class Bt{constructor(t){this.target=I.TEXTURE_2D,this.texture=t,this.width=-1,this.height=-1,this.type=G.UNSIGNED_BYTE,this.internalFormat=B.RGBA,this.format=B.RGBA,this.samplerType=0}}const It={id:"buffer",upload(t,e,r){e.width===t.width||e.height===t.height?r.texSubImage2D(r.TEXTURE_2D,0,0,0,t.width,t.height,e.format,e.type,t.resource):r.texImage2D(e.target,0,e.internalFormat,t.width,t.height,0,e.format,e.type,t.resource),e.width=t.width,e.height=t.height}},Gt={"bc1-rgba-unorm":!0,"bc1-rgba-unorm-srgb":!0,"bc2-rgba-unorm":!0,"bc2-rgba-unorm-srgb":!0,"bc3-rgba-unorm":!0,"bc3-rgba-unorm-srgb":!0,"bc4-r-unorm":!0,"bc4-r-snorm":!0,"bc5-rg-unorm":!0,"bc5-rg-snorm":!0,"bc6h-rgb-ufloat":!0,"bc6h-rgb-float":!0,"bc7-rgba-unorm":!0,"bc7-rgba-unorm-srgb":!0,"etc2-rgb8unorm":!0,"etc2-rgb8unorm-srgb":!0,"etc2-rgb8a1unorm":!0,"etc2-rgb8a1unorm-srgb":!0,"etc2-rgba8unorm":!0,"etc2-rgba8unorm-srgb":!0,"eac-r11unorm":!0,"eac-r11snorm":!0,"eac-rg11unorm":!0,"eac-rg11snorm":!0,"astc-4x4-unorm":!0,"astc-4x4-unorm-srgb":!0,"astc-5x4-unorm":!0,"astc-5x4-unorm-srgb":!0,"astc-5x5-unorm":!0,"astc-5x5-unorm-srgb":!0,"astc-6x5-unorm":!0,"astc-6x5-unorm-srgb":!0,"astc-6x6-unorm":!0,"astc-6x6-unorm-srgb":!0,"astc-8x5-unorm":!0,"astc-8x5-unorm-srgb":!0,"astc-8x6-unorm":!0,"astc-8x6-unorm-srgb":!0,"astc-8x8-unorm":!0,"astc-8x8-unorm-srgb":!0,"astc-10x5-unorm":!0,"astc-10x5-unorm-srgb":!0,"astc-10x6-unorm":!0,"astc-10x6-unorm-srgb":!0,"astc-10x8-unorm":!0,"astc-10x8-unorm-srgb":!0,"astc-10x10-unorm":!0,"astc-10x10-unorm-srgb":!0,"astc-12x10-unorm":!0,"astc-12x10-unorm-srgb":!0,"astc-12x12-unorm":!0,"astc-12x12-unorm-srgb":!0},Ft={id:"compressed",upload(t,e,r){r.pixelStorei(r.UNPACK_ALIGNMENT,4);let s=t.pixelWidth,i=t.pixelHeight;const n=!!Gt[t.format];for(let o=0;o<t.resource.length;o++){const a=t.resource[o];n?r.compressedTexImage2D(r.TEXTURE_2D,o,e.internalFormat,s,i,0,a):r.texImage2D(r.TEXTURE_2D,o,e.internalFormat,s,i,0,e.format,e.type,a),s=Math.max(s>>1,1),i=Math.max(i>>1,1)}}},Ot={id:"image",upload(t,e,r,s){const i=e.width,n=e.height,o=t.pixelWidth,a=t.pixelHeight,l=t.resourceWidth,h=t.resourceHeight;l<o||h<a?(i===o&&n===a||r.texImage2D(e.target,0,e.internalFormat,o,a,0,e.format,e.type,null),2===s?r.texSubImage2D(r.TEXTURE_2D,0,0,0,l,h,e.format,e.type,t.resource):r.texSubImage2D(r.TEXTURE_2D,0,0,0,e.format,e.type,t.resource)):i===o&&n===a?r.texSubImage2D(r.TEXTURE_2D,0,0,0,e.format,e.type,t.resource):2===s?r.texImage2D(e.target,0,e.internalFormat,o,a,0,e.format,e.type,t.resource):r.texImage2D(e.target,0,e.internalFormat,e.format,e.type,t.resource),e.width=o,e.height=a}},Dt={id:"video",upload(t,e,r,s){t.isValid?Ot.upload(t,e,r,s):r.texImage2D(e.target,0,e.internalFormat,1,1,0,e.format,e.type,null)}},Ut={linear:9729,nearest:9728},Lt={linear:{linear:9987,nearest:9985},nearest:{linear:9986,nearest:9984}},Nt={"clamp-to-edge":33071,repeat:10497,"mirror-repeat":33648},zt={never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519};function Wt(t,e,r,s,i,n,o,a){const l=n;if(!a||"repeat"!==t.addressModeU||"repeat"!==t.addressModeV||"repeat"!==t.addressModeW){const r=Nt[o?"clamp-to-edge":t.addressModeU],s=Nt[o?"clamp-to-edge":t.addressModeV],n=Nt[o?"clamp-to-edge":t.addressModeW];e[i](l,e.TEXTURE_WRAP_S,r),e[i](l,e.TEXTURE_WRAP_T,s),e.TEXTURE_WRAP_R&&e[i](l,e.TEXTURE_WRAP_R,n)}if(a&&"linear"===t.magFilter||e[i](l,e.TEXTURE_MAG_FILTER,Ut[t.magFilter]),r){if(!a||"linear"!==t.mipmapFilter){const r=Lt[t.minFilter][t.mipmapFilter];e[i](l,e.TEXTURE_MIN_FILTER,r)}}else e[i](l,e.TEXTURE_MIN_FILTER,Ut[t.minFilter]);if(s&&t.maxAnisotropy>1){const r=Math.min(t.maxAnisotropy,e.getParameter(s.MAX_TEXTURE_MAX_ANISOTROPY_EXT));e[i](l,s.TEXTURE_MAX_ANISOTROPY_EXT,r)}t.compare&&e[i](l,e.TEXTURE_COMPARE_FUNC,zt[t.compare])}class Ht{constructor(t){this.managedTextures=[],this._glTextures=Object.create(null),this._glSamplers=Object.create(null),this._boundTextures=[],this._activeTextureLocation=-1,this._boundSamplers=Object.create(null),this._uploads={image:Ot,buffer:It,video:Dt,compressed:Ft},this._premultiplyAlpha=!1,this._useSeparateSamplers=!1,this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_glTextures"),this._renderer.renderableGC.addManagedHash(this,"_glSamplers")}contextChange(t){this._gl=t,this._mapFormatToInternalFormat||(this._mapFormatToInternalFormat=function(t,e){let r={},s=t.RGBA;return t instanceof P.e.get().getWebGLRenderingContext()?e.srgb&&(r={"rgba8unorm-srgb":e.srgb.SRGB8_ALPHA8_EXT,"bgra8unorm-srgb":e.srgb.SRGB8_ALPHA8_EXT}):(r={"rgba8unorm-srgb":t.SRGB8_ALPHA8,"bgra8unorm-srgb":t.SRGB8_ALPHA8},s=t.RGBA8),{r8unorm:t.R8,r8snorm:t.R8_SNORM,r8uint:t.R8UI,r8sint:t.R8I,r16uint:t.R16UI,r16sint:t.R16I,r16float:t.R16F,rg8unorm:t.RG8,rg8snorm:t.RG8_SNORM,rg8uint:t.RG8UI,rg8sint:t.RG8I,r32uint:t.R32UI,r32sint:t.R32I,r32float:t.R32F,rg16uint:t.RG16UI,rg16sint:t.RG16I,rg16float:t.RG16F,rgba8unorm:t.RGBA,...r,rgba8snorm:t.RGBA8_SNORM,rgba8uint:t.RGBA8UI,rgba8sint:t.RGBA8I,bgra8unorm:s,rgb9e5ufloat:t.RGB9_E5,rgb10a2unorm:t.RGB10_A2,rg11b10ufloat:t.R11F_G11F_B10F,rg32uint:t.RG32UI,rg32sint:t.RG32I,rg32float:t.RG32F,rgba16uint:t.RGBA16UI,rgba16sint:t.RGBA16I,rgba16float:t.RGBA16F,rgba32uint:t.RGBA32UI,rgba32sint:t.RGBA32I,rgba32float:t.RGBA32F,stencil8:t.STENCIL_INDEX8,depth16unorm:t.DEPTH_COMPONENT16,depth24plus:t.DEPTH_COMPONENT24,"depth24plus-stencil8":t.DEPTH24_STENCIL8,depth32float:t.DEPTH_COMPONENT32F,"depth32float-stencil8":t.DEPTH32F_STENCIL8,...e.s3tc?{"bc1-rgba-unorm":e.s3tc.COMPRESSED_RGBA_S3TC_DXT1_EXT,"bc2-rgba-unorm":e.s3tc.COMPRESSED_RGBA_S3TC_DXT3_EXT,"bc3-rgba-unorm":e.s3tc.COMPRESSED_RGBA_S3TC_DXT5_EXT}:{},...e.s3tc_sRGB?{"bc1-rgba-unorm-srgb":e.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,"bc2-rgba-unorm-srgb":e.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,"bc3-rgba-unorm-srgb":e.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}:{},...e.rgtc?{"bc4-r-unorm":e.rgtc.COMPRESSED_RED_RGTC1_EXT,"bc4-r-snorm":e.rgtc.COMPRESSED_SIGNED_RED_RGTC1_EXT,"bc5-rg-unorm":e.rgtc.COMPRESSED_RED_GREEN_RGTC2_EXT,"bc5-rg-snorm":e.rgtc.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}:{},...e.bptc?{"bc6h-rgb-float":e.bptc.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,"bc6h-rgb-ufloat":e.bptc.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,"bc7-rgba-unorm":e.bptc.COMPRESSED_RGBA_BPTC_UNORM_EXT,"bc7-rgba-unorm-srgb":e.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT}:{},...e.etc?{"etc2-rgb8unorm":e.etc.COMPRESSED_RGB8_ETC2,"etc2-rgb8unorm-srgb":e.etc.COMPRESSED_SRGB8_ETC2,"etc2-rgb8a1unorm":e.etc.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgb8a1unorm-srgb":e.etc.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgba8unorm":e.etc.COMPRESSED_RGBA8_ETC2_EAC,"etc2-rgba8unorm-srgb":e.etc.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,"eac-r11unorm":e.etc.COMPRESSED_R11_EAC,"eac-rg11unorm":e.etc.COMPRESSED_SIGNED_RG11_EAC}:{},...e.astc?{"astc-4x4-unorm":e.astc.COMPRESSED_RGBA_ASTC_4x4_KHR,"astc-4x4-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,"astc-5x4-unorm":e.astc.COMPRESSED_RGBA_ASTC_5x4_KHR,"astc-5x4-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,"astc-5x5-unorm":e.astc.COMPRESSED_RGBA_ASTC_5x5_KHR,"astc-5x5-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,"astc-6x5-unorm":e.astc.COMPRESSED_RGBA_ASTC_6x5_KHR,"astc-6x5-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,"astc-6x6-unorm":e.astc.COMPRESSED_RGBA_ASTC_6x6_KHR,"astc-6x6-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,"astc-8x5-unorm":e.astc.COMPRESSED_RGBA_ASTC_8x5_KHR,"astc-8x5-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,"astc-8x6-unorm":e.astc.COMPRESSED_RGBA_ASTC_8x6_KHR,"astc-8x6-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,"astc-8x8-unorm":e.astc.COMPRESSED_RGBA_ASTC_8x8_KHR,"astc-8x8-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,"astc-10x5-unorm":e.astc.COMPRESSED_RGBA_ASTC_10x5_KHR,"astc-10x5-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,"astc-10x6-unorm":e.astc.COMPRESSED_RGBA_ASTC_10x6_KHR,"astc-10x6-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,"astc-10x8-unorm":e.astc.COMPRESSED_RGBA_ASTC_10x8_KHR,"astc-10x8-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,"astc-10x10-unorm":e.astc.COMPRESSED_RGBA_ASTC_10x10_KHR,"astc-10x10-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,"astc-12x10-unorm":e.astc.COMPRESSED_RGBA_ASTC_12x10_KHR,"astc-12x10-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,"astc-12x12-unorm":e.astc.COMPRESSED_RGBA_ASTC_12x12_KHR,"astc-12x12-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR}:{}}}(t,this._renderer.context.extensions),this._mapFormatToType=function(t){return{r8unorm:t.UNSIGNED_BYTE,r8snorm:t.BYTE,r8uint:t.UNSIGNED_BYTE,r8sint:t.BYTE,r16uint:t.UNSIGNED_SHORT,r16sint:t.SHORT,r16float:t.HALF_FLOAT,rg8unorm:t.UNSIGNED_BYTE,rg8snorm:t.BYTE,rg8uint:t.UNSIGNED_BYTE,rg8sint:t.BYTE,r32uint:t.UNSIGNED_INT,r32sint:t.INT,r32float:t.FLOAT,rg16uint:t.UNSIGNED_SHORT,rg16sint:t.SHORT,rg16float:t.HALF_FLOAT,rgba8unorm:t.UNSIGNED_BYTE,"rgba8unorm-srgb":t.UNSIGNED_BYTE,rgba8snorm:t.BYTE,rgba8uint:t.UNSIGNED_BYTE,rgba8sint:t.BYTE,bgra8unorm:t.UNSIGNED_BYTE,"bgra8unorm-srgb":t.UNSIGNED_BYTE,rgb9e5ufloat:t.UNSIGNED_INT_5_9_9_9_REV,rgb10a2unorm:t.UNSIGNED_INT_2_10_10_10_REV,rg11b10ufloat:t.UNSIGNED_INT_10F_11F_11F_REV,rg32uint:t.UNSIGNED_INT,rg32sint:t.INT,rg32float:t.FLOAT,rgba16uint:t.UNSIGNED_SHORT,rgba16sint:t.SHORT,rgba16float:t.HALF_FLOAT,rgba32uint:t.UNSIGNED_INT,rgba32sint:t.INT,rgba32float:t.FLOAT,stencil8:t.UNSIGNED_BYTE,depth16unorm:t.UNSIGNED_SHORT,depth24plus:t.UNSIGNED_INT,"depth24plus-stencil8":t.UNSIGNED_INT_24_8,depth32float:t.FLOAT,"depth32float-stencil8":t.FLOAT_32_UNSIGNED_INT_24_8_REV}}(t),this._mapFormatToFormat=function(t){return{r8unorm:t.RED,r8snorm:t.RED,r8uint:t.RED,r8sint:t.RED,r16uint:t.RED,r16sint:t.RED,r16float:t.RED,rg8unorm:t.RG,rg8snorm:t.RG,rg8uint:t.RG,rg8sint:t.RG,r32uint:t.RED,r32sint:t.RED,r32float:t.RED,rg16uint:t.RG,rg16sint:t.RG,rg16float:t.RG,rgba8unorm:t.RGBA,"rgba8unorm-srgb":t.RGBA,rgba8snorm:t.RGBA,rgba8uint:t.RGBA,rgba8sint:t.RGBA,bgra8unorm:t.RGBA,"bgra8unorm-srgb":t.RGBA,rgb9e5ufloat:t.RGB,rgb10a2unorm:t.RGBA,rg11b10ufloat:t.RGB,rg32uint:t.RG,rg32sint:t.RG,rg32float:t.RG,rgba16uint:t.RGBA,rgba16sint:t.RGBA,rgba16float:t.RGBA,rgba32uint:t.RGBA,rgba32sint:t.RGBA,rgba32float:t.RGBA,stencil8:t.STENCIL_INDEX8,depth16unorm:t.DEPTH_COMPONENT,depth24plus:t.DEPTH_COMPONENT,"depth24plus-stencil8":t.DEPTH_STENCIL,depth32float:t.DEPTH_COMPONENT,"depth32float-stencil8":t.DEPTH_STENCIL}}(t)),this._glTextures=Object.create(null),this._glSamplers=Object.create(null),this._boundSamplers=Object.create(null),this._premultiplyAlpha=!1;for(let t=0;t<16;t++)this.bind(g.g.EMPTY,t)}initSource(t){this.bind(t)}bind(t,e=0){const r=t.source;t?(this.bindSource(r,e),this._useSeparateSamplers&&this._bindSampler(r.style,e)):(this.bindSource(null,e),this._useSeparateSamplers&&this._bindSampler(null,e))}bindSource(t,e=0){const r=this._gl;if(t._touched=this._renderer.textureGC.count,this._boundTextures[e]!==t){this._boundTextures[e]=t,this._activateLocation(e),t||(t=g.g.EMPTY.source);const s=this.getGlSource(t);r.bindTexture(s.target,s.texture)}}_bindSampler(t,e=0){const r=this._gl;if(!t)return this._boundSamplers[e]=null,void r.bindSampler(e,null);const s=this._getGlSampler(t);this._boundSamplers[e]!==s&&(this._boundSamplers[e]=s,r.bindSampler(e,s))}unbind(t){const e=t.source,r=this._boundTextures,s=this._gl;for(let t=0;t<r.length;t++)if(r[t]===e){this._activateLocation(t);const i=this.getGlSource(e);s.bindTexture(i.target,null),r[t]=null}}_activateLocation(t){this._activeTextureLocation!==t&&(this._activeTextureLocation=t,this._gl.activeTexture(this._gl.TEXTURE0+t))}_initSource(t){const e=this._gl,r=new Bt(e.createTexture());if(r.type=this._mapFormatToType[t.format],r.internalFormat=this._mapFormatToInternalFormat[t.format],r.format=this._mapFormatToFormat[t.format],t.autoGenerateMipmaps&&(this._renderer.context.supports.nonPowOf2mipmaps||t.isPowerOfTwo)){const e=Math.max(t.width,t.height);t.mipLevelCount=Math.floor(Math.log2(e))+1}return this._glTextures[t.uid]=r,this.managedTextures.includes(t)||(t.on("update",this.onSourceUpdate,this),t.on("resize",this.onSourceUpdate,this),t.on("styleChange",this.onStyleChange,this),t.on("destroy",this.onSourceDestroy,this),t.on("unload",this.onSourceUnload,this),t.on("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.push(t)),this.onSourceUpdate(t),this.updateStyle(t,!1),r}onStyleChange(t){this.updateStyle(t,!1)}updateStyle(t,e){const r=this._gl,s=this.getGlSource(t);r.bindTexture(r.TEXTURE_2D,s.texture),this._boundTextures[this._activeTextureLocation]=t,Wt(t.style,r,t.mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"texParameteri",r.TEXTURE_2D,!this._renderer.context.supports.nonPowOf2wrapping&&!t.isPowerOfTwo,e)}onSourceUnload(t){const e=this._glTextures[t.uid];e&&(this.unbind(t),this._glTextures[t.uid]=null,this._gl.deleteTexture(e.texture))}onSourceUpdate(t){const e=this._gl,r=this.getGlSource(t);e.bindTexture(e.TEXTURE_2D,r.texture),this._boundTextures[this._activeTextureLocation]=t;const s="premultiply-alpha-on-upload"===t.alphaMode;this._premultiplyAlpha!==s&&(this._premultiplyAlpha=s,e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s)),this._uploads[t.uploadMethodId]?this._uploads[t.uploadMethodId].upload(t,r,e,this._renderer.context.webGLVersion):e.texImage2D(e.TEXTURE_2D,0,e.RGBA,t.pixelWidth,t.pixelHeight,0,e.RGBA,e.UNSIGNED_BYTE,null),t.autoGenerateMipmaps&&t.mipLevelCount>1&&this.onUpdateMipmaps(t,!1)}onUpdateMipmaps(t,e=!0){e&&this.bindSource(t,0);const r=this.getGlSource(t);this._gl.generateMipmap(r.target)}onSourceDestroy(t){t.off("destroy",this.onSourceDestroy,this),t.off("update",this.onSourceUpdate,this),t.off("resize",this.onSourceUpdate,this),t.off("unload",this.onSourceUnload,this),t.off("styleChange",this.onStyleChange,this),t.off("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.splice(this.managedTextures.indexOf(t),1),this.onSourceUnload(t)}_initSampler(t){const e=this._gl,r=this._gl.createSampler();return this._glSamplers[t._resourceId]=r,Wt(t,e,this._boundTextures[this._activeTextureLocation].mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"samplerParameteri",r,!1,!0),this._glSamplers[t._resourceId]}_getGlSampler(t){return this._glSamplers[t._resourceId]||this._initSampler(t)}getGlSource(t){return this._glTextures[t.uid]||this._initSource(t)}generateCanvas(t){const{pixels:e,width:r,height:s}=this.getPixels(t),i=P.e.get().createCanvas();i.width=r,i.height=s;const n=i.getContext("2d");if(n){const t=n.createImageData(r,s);t.data.set(e),n.putImageData(t,0,0)}return i}getPixels(t){const e=t.source.resolution,r=t.frame,s=Math.max(Math.round(r.width*e),1),i=Math.max(Math.round(r.height*e),1),n=new Uint8Array(4*s*i),o=this._renderer,a=o.renderTarget.getRenderTarget(t),l=o.renderTarget.getGpuRenderTarget(a),h=o.gl;return h.bindFramebuffer(h.FRAMEBUFFER,l.resolveTargetFramebuffer),h.readPixels(Math.round(r.x*e),Math.round(r.y*e),s,i,h.RGBA,h.UNSIGNED_BYTE,n),{pixels:new Uint8ClampedArray(n.buffer),width:s,height:i}}destroy(){this.managedTextures.slice().forEach(t=>this.onSourceDestroy(t)),this.managedTextures=null,this._glTextures=null,this._glSamplers=null,this._boundTextures=null,this._boundSamplers=null,this._mapFormatToInternalFormat=null,this._mapFormatToType=null,this._mapFormatToFormat=null,this._uploads=null,this._renderer=null}resetState(){this._activeTextureLocation=-1,this._boundTextures.fill(g.g.EMPTY.source),this._boundSamplers=Object.create(null);const t=this._gl;this._premultiplyAlpha=!1,t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this._premultiplyAlpha)}}Ht.extension={type:[s.Ag.WebGLSystem],name:"texture"};const Xt=[...b.i,nt,X,E,$,C,Ht,dt,U,Et,At,Y,kt,Z,V],Vt=[...b.f],Yt=[y,x,p],jt=[],$t=[],qt=[];s.XO.handleByNamedList(s.Ag.WebGLSystem,jt),s.XO.handleByNamedList(s.Ag.WebGLPipes,$t),s.XO.handleByNamedList(s.Ag.WebGLPipesAdaptor,qt),s.XO.add(...Xt,...Vt,...Yt);class Kt extends v.k{constructor(){super({name:"webgl",type:w.W.WEBGL,systems:jt,renderPipes:$t,renderPipeAdaptors:qt})}}},7882:(t,e,r)=>{"use strict";r.d(e,{o:()=>a,u:()=>o});var s=r(5199),i=r(761),n=r(6170);const o=i.Z.getPool(s.u),a=i.Z.getPool(n.c)},7898:(t,e,r)=>{"use strict";r.d(e,{o:()=>s});class s{constructor(t,e,r){this._x=e||0,this._y=r||0,this._observer=t}clone(t){return new s(t??this._observer,this._x,this._y)}set(t=0,e=t){return this._x===t&&this._y===e||(this._x=t,this._y=e,this._observer._onUpdate(this)),this}copyFrom(t){return this._x===t.x&&this._y===t.y||(this._x=t.x,this._y=t.y,this._observer._onUpdate(this)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}toString(){return`[pixi.js/math:ObservablePoint x=${this._x} y=${this._y} scope=${this._observer}]`}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this._observer._onUpdate(this))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this._observer._onUpdate(this))}}},7926:(t,e,r)=>{"use strict";r.d(e,{P:()=>l});var s=r(6643),i=r(5423),n=r(2288);const o={willReadFrequently:!0},a=class t{static get experimentalLetterSpacingSupported(){let e=t._experimentalLetterSpacingSupported;if(void 0===e){const r=i.e.get().getCanvasRenderingContext2D().prototype;e=t._experimentalLetterSpacingSupported="letterSpacing"in r||"textLetterSpacing"in r}return e}constructor(t,e,r,s,i,n,o,a,l){this.text=t,this.style=e,this.width=r,this.height=s,this.lines=i,this.lineWidths=n,this.lineHeight=o,this.maxLineWidth=a,this.fontProperties=l}static measureText(e=" ",r,s=t._canvas,i=r.wordWrap){const o=`${e}-${r.styleKey}-wordWrap-${i}`;if(t._measurementCache.has(o))return t._measurementCache.get(o);const a=(0,n.Z)(r),l=t.measureFont(a);0===l.fontSize&&(l.fontSize=r.fontSize,l.ascent=r.fontSize);const h=t.__context;h.font=a;const c=(i?t._wordWrap(e,r,s):e).split(/(?:\r\n|\r|\n)/),u=new Array(c.length);let d=0;for(let e=0;e<c.length;e++){const s=t._measureText(c[e],r.letterSpacing,h);u[e]=s,d=Math.max(d,s)}const p=r._stroke?.width||0;let f=d+p;r.dropShadow&&(f+=r.dropShadow.distance);const g=r.lineHeight||l.fontSize;let m=Math.max(g,l.fontSize+p)+(c.length-1)*(g+r.leading);r.dropShadow&&(m+=r.dropShadow.distance);const x=new t(e,r,f,m,c,u,g+r.leading,d,l);return t._measurementCache.set(o,x),x}static _measureText(e,r,s){let i=!1;t.experimentalLetterSpacingSupported&&(t.experimentalLetterSpacing?(s.letterSpacing=`${r}px`,s.textLetterSpacing=`${r}px`,i=!0):(s.letterSpacing="0px",s.textLetterSpacing="0px"));const n=s.measureText(e);let o=n.width;const a=-n.actualBoundingBoxLeft;let l=n.actualBoundingBoxRight-a;if(o>0)if(i)o-=r,l-=r;else{const s=(t.graphemeSegmenter(e).length-1)*r;o+=s,l+=s}return Math.max(o,l)}static _wordWrap(e,r,s=t._canvas){const i=s.getContext("2d",o);let n=0,a="",l="";const h=Object.create(null),{letterSpacing:c,whiteSpace:u}=r,d=t._collapseSpaces(u),p=t._collapseNewlines(u);let f=!d;const g=r.wordWrapWidth+c,m=t._tokenize(e);for(let e=0;e<m.length;e++){let s=m[e];if(t._isNewline(s)){if(!p){l+=t._addLine(a),f=!d,a="",n=0;continue}s=" "}if(d){const e=t.isBreakingSpace(s),r=t.isBreakingSpace(a[a.length-1]);if(e&&r)continue}const o=t._getFromCache(s,c,h,i);if(o>g)if(""!==a&&(l+=t._addLine(a),a="",n=0),t.canBreakWords(s,r.breakWords)){const e=t.wordWrapSplit(s);for(let o=0;o<e.length;o++){let u=e[o],d=u,p=1;for(;e[o+p];){const i=e[o+p];if(t.canBreakChars(d,i,s,o,r.breakWords))break;u+=i,d=i,p++}o+=p-1;const m=t._getFromCache(u,c,h,i);m+n>g&&(l+=t._addLine(a),f=!1,a="",n=0),a+=u,n+=m}}else{a.length>0&&(l+=t._addLine(a),a="",n=0);const r=e===m.length-1;l+=t._addLine(s,!r),f=!1,a="",n=0}else o+n>g&&(f=!1,l+=t._addLine(a),a="",n=0),(a.length>0||!t.isBreakingSpace(s)||f)&&(a+=s,n+=o)}return l+=t._addLine(a,!1),l}static _addLine(e,r=!0){return e=t._trimRight(e),r?`${e}\n`:e}static _getFromCache(e,r,s,i){let n=s[e];return"number"!=typeof n&&(n=t._measureText(e,r,i)+r,s[e]=n),n}static _collapseSpaces(t){return"normal"===t||"pre-line"===t}static _collapseNewlines(t){return"normal"===t}static _trimRight(e){if("string"!=typeof e)return"";for(let r=e.length-1;r>=0;r--){const s=e[r];if(!t.isBreakingSpace(s))break;e=e.slice(0,-1)}return e}static _isNewline(e){return"string"==typeof e&&t._newlines.includes(e.charCodeAt(0))}static isBreakingSpace(e,r){return"string"==typeof e&&t._breakingSpaces.includes(e.charCodeAt(0))}static _tokenize(e){const r=[];let s="";if("string"!=typeof e)return r;for(let i=0;i<e.length;i++){const n=e[i],o=e[i+1];t.isBreakingSpace(n,o)||t._isNewline(n)?(""!==s&&(r.push(s),s=""),"\r"===n&&"\n"===o?(r.push("\r\n"),i++):r.push(n)):s+=n}return""!==s&&r.push(s),r}static canBreakWords(t,e){return e}static canBreakChars(t,e,r,s,i){return!0}static wordWrapSplit(e){return t.graphemeSegmenter(e)}static measureFont(e){if(t._fonts[e])return t._fonts[e];const r=t._context;r.font=e;const s=r.measureText(t.METRICS_STRING+t.BASELINE_SYMBOL),i={ascent:s.actualBoundingBoxAscent,descent:s.actualBoundingBoxDescent,fontSize:s.actualBoundingBoxAscent+s.actualBoundingBoxDescent};return t._fonts[e]=i,i}static clearMetrics(e=""){e?delete t._fonts[e]:t._fonts={}}static get _canvas(){if(!t.__canvas){let e;try{const r=new OffscreenCanvas(0,0),s=r.getContext("2d",o);if(s?.measureText)return t.__canvas=r,r;e=i.e.get().createCanvas()}catch(t){e=i.e.get().createCanvas()}e.width=e.height=10,t.__canvas=e}return t.__canvas}static get _context(){return t.__context||(t.__context=t._canvas.getContext("2d",o)),t.__context}};a.METRICS_STRING="|ÉqÅ",a.BASELINE_SYMBOL="M",a.BASELINE_MULTIPLIER=1.4,a.HEIGHT_MULTIPLIER=2,a.graphemeSegmenter=(()=>{if("function"==typeof Intl?.Segmenter){const t=new Intl.Segmenter;return e=>{const r=t.segment(e),s=[];let i=0;for(const t of r)s[i++]=t.segment;return s}}return t=>[...t]})(),a.experimentalLetterSpacing=!1,a._fonts={},a._newlines=[10,13],a._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],a._measurementCache=(0,s.g)(1e3);let l=a},7935:(t,e,r)=>{"use strict";var s=r(2445),i=r(1065),n=r(4269),o=r(9739);const a=[];function l(t={}){const e=t&&t.resource,r=e?t.resource:t,s=e?t:{resource:t};for(let t=0;t<a.length;t++){const e=a[t];if(e.test(r))return new e(s)}throw new Error(`Could not find a source type for resource: ${s.resource}`)}i.XO.handleByList(i.Ag.TextureSource,a),o.g.from=function(t,e=!1){return"string"==typeof t?s.l.get(t):t instanceof n.v?new o.g({source:t}):function(t={},e=!1){const r=t&&t.resource,i=r?t.resource:t,n=r?t:{resource:t};if(!e&&s.l.has(i))return s.l.get(i);const a=new o.g({source:l(n)});return a.on("destroy",()=>{s.l.has(i)&&s.l.remove(i)}),e||s.l.set(i,a),a}(t,e)},n.v.from=l},8064:(t,e,r)=>{"use strict";r.d(e,{z:()=>s});const s=(t,e,r=!1)=>(Array.isArray(t)||(t=[t]),e?t.map(t=>"string"==typeof t||r?e(t):t):t)},8122:(t,e,r)=>{"use strict";var s=r(1065);class i{constructor(t){this._renderer=t}push(t,e,r){this._renderer.renderPipes.batch.break(r),r.add({renderPipeId:"filter",canBundle:!1,action:"pushFilter",container:e,filterEffect:t})}pop(t,e,r){this._renderer.renderPipes.batch.break(r),r.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}execute(t){"pushFilter"===t.action?this._renderer.filter.push(t):"popFilter"===t.action&&this._renderer.filter.pop()}destroy(){this._renderer=null}}i.extension={type:[s.Ag.WebGLPipes,s.Ag.WebGPUPipes,s.Ag.CanvasPipes],name:"filter"};var n=r(5199),o=r(3655),a=r(8337),l=r(4449),h=r(9739),c=r(8851),u=r(5153),d=r(6170);const p=new n.u;var f=r(7694);const g=new a.V({attributes:{aPosition:{buffer:new Float32Array([0,0,1,0,1,1,0,1]),format:"float32x2",stride:8,offset:0}},indexBuffer:new Uint32Array([0,1,2,0,2,3])});class m{constructor(){this.skip=!1,this.inputTexture=null,this.backTexture=null,this.filters=null,this.bounds=new d.c,this.container=null,this.blendRequired=!1,this.outputRenderSurface=null,this.globalFrame={x:0,y:0,width:0,height:0}}}class x{constructor(t){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new l.k({uInputSize:{value:new Float32Array(4),type:"vec4<f32>"},uInputPixel:{value:new Float32Array(4),type:"vec4<f32>"},uInputClamp:{value:new Float32Array(4),type:"vec4<f32>"},uOutputFrame:{value:new Float32Array(4),type:"vec4<f32>"},uGlobalFrame:{value:new Float32Array(4),type:"vec4<f32>"},uOutputTexture:{value:new Float32Array(4),type:"vec4<f32>"}}),this._globalFilterBindGroup=new o.T({}),this.renderer=t}get activeBackTexture(){return this._activeFilterData?.backTexture}push(t){const e=this.renderer,r=t.filterEffect.filters,s=this._pushFilterData();s.skip=!1,s.filters=r,s.container=t.container,s.outputRenderSurface=e.renderTarget.renderSurface;const i=e.renderTarget.renderTarget.colorTexture.source,n=i.resolution,o=i.antialias;if(0===r.length)return void(s.skip=!0);const a=s.bounds;if(this._calculateFilterArea(t,a),this._calculateFilterBounds(s,e.renderTarget.rootViewPort,o,n,1),s.skip)return;const l=this._getPreviousFilterData(),h=this._findFilterResolution(n);let c=0,u=0;l&&(c=l.bounds.minX,u=l.bounds.minY),this._calculateGlobalFrame(s,c,u,h,i.width,i.height),this._setupFilterTextures(s,a,e,l)}generateFilteredTexture({texture:t,filters:e}){const r=this._pushFilterData();this._activeFilterData=r,r.skip=!1,r.filters=e;const s=t.source,i=s.resolution,n=s.antialias;if(0===e.length)return r.skip=!0,t;const o=r.bounds;if(o.addRect(t.frame),this._calculateFilterBounds(r,o.rectangle,n,i,0),r.skip)return t;const a=i;this._calculateGlobalFrame(r,0,0,a,s.width,s.height),r.outputRenderSurface=c.W.getOptimalTexture(o.width,o.height,r.resolution,r.antialias),r.backTexture=h.g.EMPTY,r.inputTexture=t,this.renderer.renderTarget.finishRenderPass(),this._applyFiltersToTexture(r,!0);const l=r.outputRenderSurface;return l.source.alphaMode="premultiplied-alpha",l}pop(){const t=this.renderer,e=this._popFilterData();e.skip||(t.globalUniforms.pop(),t.renderTarget.finishRenderPass(),this._activeFilterData=e,this._applyFiltersToTexture(e,!1),e.blendRequired&&c.W.returnTexture(e.backTexture),c.W.returnTexture(e.inputTexture))}getBackTexture(t,e,r){const s=t.colorTexture.source._resolution,i=c.W.getOptimalTexture(e.width,e.height,s,!1);let n=e.minX,o=e.minY;r&&(n-=r.minX,o-=r.minY),n=Math.floor(n*s),o=Math.floor(o*s);const a=Math.ceil(e.width*s),l=Math.ceil(e.height*s);return this.renderer.renderTarget.copyToTexture(t,i,{x:n,y:o},{width:a,height:l},{x:0,y:0}),i}applyFilter(t,e,r,s){const i=this.renderer,n=this._activeFilterData,o=n.outputRenderSurface===r,a=i.renderTarget.rootRenderTarget.colorTexture.source._resolution,l=this._findFilterResolution(a);let h=0,c=0;if(o){const t=this._findPreviousFilterOffset();h=t.x,c=t.y}this._updateFilterUniforms(e,r,n,h,c,l,o,s),this._setupBindGroupsAndRender(t,e,i)}calculateSpriteMatrix(t,e){const r=this._activeFilterData,s=t.set(r.inputTexture._source.width,0,0,r.inputTexture._source.height,r.bounds.minX,r.bounds.minY),i=e.worldTransform.copyTo(n.u.shared),o=e.renderGroup||e.parentRenderGroup;return o&&o.cacheToLocalTransform&&i.prepend(o.cacheToLocalTransform),i.invert(),s.prepend(i),s.scale(1/e.texture.orig.width,1/e.texture.orig.height),s.translate(e.anchor.x,e.anchor.y),s}destroy(){}_setupBindGroupsAndRender(t,e,r){if(r.renderPipes.uniformBatch){const t=r.renderPipes.uniformBatch.getUboResource(this._filterGlobalUniforms);this._globalFilterBindGroup.setResource(t,0)}else this._globalFilterBindGroup.setResource(this._filterGlobalUniforms,0);this._globalFilterBindGroup.setResource(e.source,1),this._globalFilterBindGroup.setResource(e.source.style,2),t.groups[0]=this._globalFilterBindGroup,r.encoder.draw({geometry:g,shader:t,state:t._state,topology:"triangle-list"}),r.type===u.W.WEBGL&&r.renderTarget.finishRenderPass()}_setupFilterTextures(t,e,r,s){if(t.backTexture=h.g.EMPTY,t.inputTexture=c.W.getOptimalTexture(e.width,e.height,t.resolution,t.antialias),t.blendRequired){r.renderTarget.finishRenderPass();const i=r.renderTarget.getRenderTarget(t.outputRenderSurface);t.backTexture=this.getBackTexture(i,e,s?.bounds)}r.renderTarget.bind(t.inputTexture,!0),r.globalUniforms.push({offset:e})}_calculateGlobalFrame(t,e,r,s,i,n){const o=t.globalFrame;o.x=e*s,o.y=r*s,o.width=i*s,o.height=n*s}_updateFilterUniforms(t,e,r,s,i,n,o,a){const l=this._filterGlobalUniforms.uniforms,c=l.uOutputFrame,u=l.uInputSize,d=l.uInputPixel,p=l.uInputClamp,f=l.uGlobalFrame,g=l.uOutputTexture;o?(c[0]=r.bounds.minX-s,c[1]=r.bounds.minY-i):(c[0]=0,c[1]=0),c[2]=t.frame.width,c[3]=t.frame.height,u[0]=t.source.width,u[1]=t.source.height,u[2]=1/u[0],u[3]=1/u[1],d[0]=t.source.pixelWidth,d[1]=t.source.pixelHeight,d[2]=1/d[0],d[3]=1/d[1],p[0]=.5*d[2],p[1]=.5*d[3],p[2]=t.frame.width*u[2]-.5*d[2],p[3]=t.frame.height*u[3]-.5*d[3];const m=this.renderer.renderTarget.rootRenderTarget.colorTexture;f[0]=s*n,f[1]=i*n,f[2]=m.source.width*n,f[3]=m.source.height*n,e instanceof h.g&&(e.source.resource=null);const x=this.renderer.renderTarget.getRenderTarget(e);this.renderer.renderTarget.bind(e,!!a),e instanceof h.g?(g[0]=e.frame.width,g[1]=e.frame.height):(g[0]=x.width,g[1]=x.height),g[2]=x.isRoot?-1:1,this._filterGlobalUniforms.update()}_findFilterResolution(t){let e=this._filterStackIndex-1;for(;e>0&&this._filterStack[e].skip;)--e;return e>0&&this._filterStack[e].inputTexture?this._filterStack[e].inputTexture.source._resolution:t}_findPreviousFilterOffset(){let t=0,e=0,r=this._filterStackIndex;for(;r>0;){r--;const s=this._filterStack[r];if(!s.skip){t=s.bounds.minX,e=s.bounds.minY;break}}return{x:t,y:e}}_calculateFilterArea(t,e){if(t.renderables?function(t,e){e.clear();const r=e.matrix;for(let r=0;r<t.length;r++){const s=t[r];if(s.globalDisplayStatus<7)continue;const i=s.renderGroup??s.parentRenderGroup;e.matrix=i?.isCachedAsTexture?p.copyFrom(i.textureOffsetInverseTransform).append(s.worldTransform):i?._parentCacheAsTextureRenderGroup?p.copyFrom(i._parentCacheAsTextureRenderGroup.inverseWorldTransform).append(s.groupTransform):s.worldTransform,e.addBounds(s.bounds)}e.matrix=r}(t.renderables,e):t.filterEffect.filterArea?(e.clear(),e.addRect(t.filterEffect.filterArea),e.applyMatrix(t.container.worldTransform)):t.container.getFastGlobalBounds(!0,e),t.container){const r=(t.container.renderGroup||t.container.parentRenderGroup).cacheToLocalTransform;r&&e.applyMatrix(r)}}_applyFiltersToTexture(t,e){const r=t.inputTexture,s=t.bounds,i=t.filters;if(this._globalFilterBindGroup.setResource(r.source.style,2),this._globalFilterBindGroup.setResource(t.backTexture.source,3),1===i.length)i[0].apply(this,r,t.outputRenderSurface,e);else{let r=t.inputTexture;const n=c.W.getOptimalTexture(s.width,s.height,r.source._resolution,!1);let o=n,a=0;for(a=0;a<i.length-1;++a){i[a].apply(this,r,o,!0);const t=r;r=o,o=t}i[a].apply(this,r,t.outputRenderSurface,e),c.W.returnTexture(n)}}_calculateFilterBounds(t,e,r,s,i){const n=this.renderer,o=t.bounds,a=t.filters;let l=1/0,h=0,c=!0,u=!1,d=!1,p=!0;for(let t=0;t<a.length;t++){const e=a[t];if(l=Math.min(l,"inherit"===e.resolution?s:e.resolution),h+=e.padding,"off"===e.antialias?c=!1:"inherit"===e.antialias&&c&&(c=r),e.clipToViewport||(p=!1),!(e.compatibleRenderers&n.type)){d=!1;break}if(e.blendRequired&&!(n.backBuffer?.useBackBuffer??1)){(0,f.R)("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."),d=!1;break}d=e.enabled||d,u||(u=e.blendRequired)}d?(p&&o.fitBounds(0,e.width/s,0,e.height/s),o.scale(l).ceil().scale(1/l).pad((0|h)*i),o.isPositive?(t.antialias=c,t.resolution=l,t.blendRequired=u):t.skip=!0):t.skip=!0}_popFilterData(){return this._filterStackIndex--,this._filterStack[this._filterStackIndex]}_getPreviousFilterData(){let t,e=this._filterStackIndex-1;for(;e>0&&(e--,t=this._filterStack[e],t.skip););return t}_pushFilterData(){let t=this._filterStack[this._filterStackIndex];return t||(t=this._filterStack[this._filterStackIndex]=new m),this._filterStackIndex++,t}}x.extension={type:[s.Ag.WebGLSystem,s.Ag.WebGPUSystem],name:"filter"},s.XO.add(x),s.XO.add(i)},8271:(t,e,r)=>{"use strict";r.d(e,{K:()=>i,Q:()=>s});const s={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var i=(t=>(t[t.DISABLED=0]="DISABLED",t[t.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",t[t.MASK_ACTIVE=2]="MASK_ACTIVE",t[t.INVERSE_MASK_ACTIVE=3]="INVERSE_MASK_ACTIVE",t[t.RENDERING_MASK_REMOVE=4]="RENDERING_MASK_REMOVE",t[t.NONE=5]="NONE",t))(i||{})},8337:(t,e,r)=>{"use strict";r.d(e,{V:()=>h});var s=r(4872),i=r(6170),n=r(9375),o=r(1579),a=r(9798);function l(t,e){if(!(t instanceof o.h)){let r=e?a.S.INDEX:a.S.VERTEX;t instanceof Array&&(e?(t=new Uint32Array(t),r=a.S.INDEX|a.S.COPY_DST):(t=new Float32Array(t),r=a.S.VERTEX|a.S.COPY_DST)),t=new o.h({data:t,label:e?"index-mesh-buffer":"vertex-mesh-buffer",usage:r})}return t}class h extends s.A{constructor(t={}){super(),this.uid=(0,n.L)("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new i.c,this._boundsDirty=!0;const{attributes:e,indexBuffer:r,topology:s}=t;if(this.buffers=[],this.attributes={},e)for(const t in e)this.addAttribute(t,e[t]);this.instanceCount=t.instanceCount??1,r&&this.addIndex(r),this.topology=s||"triangle-list"}onBufferUpdate(){this._boundsDirty=!0,this.emit("update",this)}getAttribute(t){return this.attributes[t]}getIndex(){return this.indexBuffer}getBuffer(t){return this.getAttribute(t).buffer}getSize(){for(const t in this.attributes){const e=this.attributes[t];return e.buffer.data.length/(e.stride/4||e.size)}return 0}addAttribute(t,e){const r=function(t){return(t instanceof o.h||Array.isArray(t)||t.BYTES_PER_ELEMENT)&&(t={buffer:t}),t.buffer=l(t.buffer,!1),t}(e);-1===this.buffers.indexOf(r.buffer)&&(this.buffers.push(r.buffer),r.buffer.on("update",this.onBufferUpdate,this),r.buffer.on("change",this.onBufferUpdate,this)),this.attributes[t]=r}addIndex(t){this.indexBuffer=l(t,!0),this.buffers.push(this.indexBuffer)}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,function(t,e,r){const s=t.getAttribute("aPosition");if(!s)return r.minX=0,r.minY=0,r.maxX=0,r.maxY=0,r;const i=s.buffer.data;let n=1/0,o=1/0,a=-1/0,l=-1/0;const h=i.BYTES_PER_ELEMENT,c=(s.offset||0)/h,u=(s.stride||8)/h;for(let t=c;t<i.length;t+=u){const e=i[t],r=i[t+1];e>a&&(a=e),r>l&&(l=r),e<n&&(n=e),r<o&&(o=r)}return r.minX=n,r.minY=o,r.maxX=a,r.maxY=l,r}(this,0,this._bounds)):this._bounds}destroy(t=!1){this.emit("destroy",this),this.removeAllListeners(),t&&this.buffers.forEach(t=>t.destroy()),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}},8427:(t,e,r)=>{"use strict";var s=r(1065),i=r(5199),n=r(3655),o=r(4449),a=r(3769),l=r(9482),h=r(1228);class c{destroy(){}}class u{constructor(t,e){this.localUniforms=new o.k({uTransformMatrix:{value:new i.u,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),this.localUniformsBindGroup=new n.T({0:this.localUniforms}),this.renderer=t,this._adaptor=e,this._adaptor.init()}validateRenderable(t){const e=this._getMeshData(t),r=e.batched,s=t.batched;if(e.batched=s,r!==s)return!0;if(s){const r=t._geometry;if(r.indices.length!==e.indexSize||r.positions.length!==e.vertexSize)return e.indexSize=r.indices.length,e.vertexSize=r.positions.length,!0;const s=this._getBatchableMesh(t);return s.texture.uid!==t._texture.uid&&(s._textureMatrixUpdateId=-1),!s._batcher.checkAndUpdateTexture(s,t._texture)}return!1}addRenderable(t,e){const r=this.renderer.renderPipes.batch,s=this._getMeshData(t);if(t.didViewUpdate&&(s.indexSize=t._geometry.indices?.length,s.vertexSize=t._geometry.positions?.length),s.batched){const s=this._getBatchableMesh(t);s.setTexture(t._texture),s.geometry=t._geometry,r.addToBatch(s,e)}else r.break(e),e.add(t)}updateRenderable(t){if(t.batched){const e=this._getBatchableMesh(t);e.setTexture(t._texture),e.geometry=t._geometry,e._batcher.updateElement(e)}}execute(t){if(!t.isRenderable)return;t.state.blendMode=(0,a.i)(t.groupBlendMode,t.texture._source);const e=this.localUniforms;e.uniforms.uTransformMatrix=t.groupTransform,e.uniforms.uRound=this.renderer._roundPixels|t._roundPixels,e.update(),(0,l.V)(t.groupColorAlpha,e.uniforms.uColor,0),this._adaptor.execute(this,t)}_getMeshData(t){var e,r;return(e=t._gpuData)[r=this.renderer.uid]||(e[r]=new c),t._gpuData[this.renderer.uid].meshData||this._initMeshData(t)}_initMeshData(t){return t._gpuData[this.renderer.uid].meshData={batched:t.batched,indexSize:0,vertexSize:0},t._gpuData[this.renderer.uid].meshData}_getBatchableMesh(t){var e,r;return(e=t._gpuData)[r=this.renderer.uid]||(e[r]=new c),t._gpuData[this.renderer.uid].batchableMesh||this._initBatchableMesh(t)}_initBatchableMesh(t){const e=new h.U;return e.renderable=t,e.setTexture(t._texture),e.transform=t.groupTransform,e.roundPixels=this.renderer._roundPixels|t._roundPixels,t._gpuData[this.renderer.uid].batchableMesh=e,e}destroy(){this.localUniforms=null,this.localUniformsBindGroup=null,this._adaptor.destroy(),this._adaptor=null,this.renderer=null}}u.extension={type:[s.Ag.WebGLPipes,s.Ag.WebGPUPipes,s.Ag.CanvasPipes],name:"mesh"},s.XO.add(u)},8574:(t,e,r)=>{"use strict";r.d(e,{W:()=>n});var s=r(5423);let i;function n(){if(!i||i?.isContextLost()){const t=s.e.get().createCanvas();i=t.getContext("webgl",{})}return i}},8598:(t,e,r)=>{"use strict";r.d(e,{c:()=>w});var s=r(6643),i=r(2445),n=r(4696),o=r(7694),a=r(7926),l=r(5105),h=r(6675),c=r(9390),u=r(1566),d=r(5947),p=r(9739),f=r(8896),g=r(2288),m=r(1990),x=r(9359);const _=class t extends x.v{constructor(e){super(),this.resolution=1,this.pages=[],this._padding=0,this._measureCache=Object.create(null),this._currentChars=[],this._currentX=0,this._currentY=0,this._currentMaxCharHeight=0,this._currentPageIndex=-1,this._skipKerning=!1;const r={...t.defaultOptions,...e};this._textureSize=r.textureSize,this._mipmap=r.mipmap;const s=r.style.clone();r.overrideFill&&(s._fill.color=16777215,s._fill.alpha=1,s._fill.texture=p.g.WHITE,s._fill.fill=null),this.applyFillAsTint=r.overrideFill;const i=s.fontSize;s.fontSize=this.baseMeasurementFontSize;const n=(0,g.Z)(s);r.overrideSize?s._stroke&&(s._stroke.width*=this.baseRenderedFontSize/i):s.fontSize=this.baseRenderedFontSize=i,this._style=s,this._skipKerning=r.skipKerning??!1,this.resolution=r.resolution??1,this._padding=r.padding??4,r.textureStyle&&(this._textureStyle=r.textureStyle instanceof f.n?r.textureStyle:new f.n(r.textureStyle)),this.fontMetrics=a.P.measureFont(n),this.lineHeight=s.lineHeight||this.fontMetrics.fontSize||s.fontSize}ensureCharacters(t){const e=a.P.graphemeSegmenter(t).filter(t=>!this._currentChars.includes(t)).filter((t,e,r)=>r.indexOf(t)===e);if(!e.length)return;let r;this._currentChars=[...this._currentChars,...e],r=-1===this._currentPageIndex?this._nextPage():this.pages[this._currentPageIndex];let{canvas:s,context:i}=r.canvasAndContext,n=r.texture.source;const o=this._style;let l=this._currentX,h=this._currentY,u=this._currentMaxCharHeight;const d=this.baseRenderedFontSize/this.baseMeasurementFontSize,f=this._padding*d;let g=!1;const m=s.width/this.resolution,x=s.height/this.resolution;for(let t=0;t<e.length;t++){const r=e[t],_=a.P.measureText(r,o,s,!1);_.lineHeight=_.height;const y=_.width*d,v=Math.ceil(("italic"===o.fontStyle?2:1)*y)+2*f,b=_.height*d+2*f;if(g=!1,"\n"!==r&&"\r"!==r&&"\t"!==r&&" "!==r&&(g=!0,u=Math.ceil(Math.max(b,u))),l+v>m&&(h+=u,u=b,l=0,h+u>x)){n.update();const t=this._nextPage();s=t.canvasAndContext.canvas,i=t.canvasAndContext.context,n=t.texture.source,l=0,h=0,u=0}const w=y/d-(o.dropShadow?.distance??0)-(o._stroke?.width??0);if(this.chars[r]={id:r.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:w,kerning:{}},g){this._drawGlyph(i,_,l+f,h+f,d,o);const t=n.width*d,e=n.height*d,s=new c.M(l/t*n.width,h/e*n.height,v/t*n.width,b/e*n.height);this.chars[r].texture=new p.g({source:n,frame:s}),l+=Math.ceil(v)}}n.update(),this._currentX=l,this._currentY=h,this._currentMaxCharHeight=u,this._skipKerning&&this._applyKerning(e,i)}get pageTextures(){return(0,n.t6)(n.lj,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}_applyKerning(t,e){const r=this._measureCache;for(let s=0;s<t.length;s++){const i=t[s];for(let t=0;t<this._currentChars.length;t++){const s=this._currentChars[t];let n=r[i];n||(n=r[i]=e.measureText(i).width);let o=r[s];o||(o=r[s]=e.measureText(s).width);let a=e.measureText(i+s).width,l=a-(n+o);l&&(this.chars[i].kerning[s]=l),a=e.measureText(i+s).width,l=a-(n+o),l&&(this.chars[s].kerning[i]=l)}}}_nextPage(){this._currentPageIndex++;const t=this.resolution,e=u.N.getOptimalCanvasAndContext(this._textureSize,this._textureSize,t);this._setupContext(e.context,this._style,t);const r=t*(this.baseRenderedFontSize/this.baseMeasurementFontSize),s=new p.g({source:new d.b({resource:e.canvas,resolution:r,alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:this._mipmap})});this._textureStyle&&(s.source.style=this._textureStyle);const i={canvasAndContext:e,texture:s};return this.pages[this._currentPageIndex]=i,i}_setupContext(t,e,r){e.fontSize=this.baseRenderedFontSize,t.scale(r,r),t.font=(0,g.Z)(e),e.fontSize=this.baseMeasurementFontSize,t.textBaseline=e.textBaseline;const s=e._stroke,i=s?.width??0;if(s&&(t.lineWidth=i,t.lineJoin=s.join,t.miterLimit=s.miterLimit,t.strokeStyle=(0,m.r)(s,t)),e._fill&&(t.fillStyle=(0,m.r)(e._fill,t)),e.dropShadow){const s=e.dropShadow,i=h.Q.shared.setValue(s.color).toArray(),n=s.blur*r,o=s.distance*r;t.shadowColor=`rgba(${255*i[0]},${255*i[1]},${255*i[2]},${s.alpha})`,t.shadowBlur=n,t.shadowOffsetX=Math.cos(s.angle)*o,t.shadowOffsetY=Math.sin(s.angle)*o}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0}_drawGlyph(t,e,r,s,i,n){const o=e.text,a=e.fontProperties,l=n._stroke,h=(l?.width??0)*i,c=r+h/2,u=s-h/2,d=a.descent*i,p=e.lineHeight*i;let f=!1;n.stroke&&h&&(f=!0,t.strokeText(o,c,u+p-d));const{shadowBlur:g,shadowOffsetX:m,shadowOffsetY:x}=t;n._fill&&(f&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),t.fillText(o,c,u+p-d)),f&&(t.shadowBlur=g,t.shadowOffsetX=m,t.shadowOffsetY=x)}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){const{canvasAndContext:e,texture:r}=this.pages[t];u.N.returnCanvasAndContext(e),r.destroy(!0)}this.pages=null}};_.defaultOptions={textureSize:512,style:new l.x,mipmap:!0};let y=_;var v=r(5353);let b=0;const w=new class{constructor(){this.ALPHA=[["a","z"],["A","Z"]," "],this.NUMERIC=[["0","9"]],this.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],this.ASCII=[[" ","~"]],this.defaultOptions={chars:this.ALPHANUMERIC,resolution:1,padding:4,skipKerning:!1,textureStyle:null},this.measureCache=(0,s.g)(1e3)}getFont(t,e){let r=`${e.fontFamily}-bitmap`,s=!0;if(e._fill.fill&&!e._stroke?(r+=e._fill.fill.styleKey,s=!1):(e._stroke||e.dropShadow)&&(r=`${e.styleKey}-bitmap`,s=!1),!i.l.has(r)){const t=Object.create(e);t.lineHeight=0;const n=new y({style:t,overrideFill:s,overrideSize:!0,...this.defaultOptions});b++,b>50&&(0,o.R)("BitmapText",`You have dynamically created ${b} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),n.once("destroy",()=>{b--,i.l.remove(r)}),i.l.set(r,n)}const n=i.l.get(r);return n.ensureCharacters?.(t),n}getLayout(t,e,r=!0){const s=this.getFont(t,e),i=`${t}-${e.styleKey}-${r}`;if(this.measureCache.has(i))return this.measureCache.get(i);const n=a.P.graphemeSegmenter(t),o=(0,v.Z)(n,e,s,r);return this.measureCache.set(i,o),o}measureText(t,e,r=!0){return this.getLayout(t,e,r)}install(...t){let e=t[0];"string"==typeof e&&(e={name:e,style:t[1],chars:t[2]?.chars,resolution:t[2]?.resolution,padding:t[2]?.padding,skipKerning:t[2]?.skipKerning},(0,n.t6)(n.lj,"BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));const r=e?.name;if(!r)throw new Error("[BitmapFontManager] Property `name` is required.");e={...this.defaultOptions,...e};const s=e.style,o=s instanceof l.x?s:new l.x(s),a=e.dynamicFill??this._canUseTintForStyle(o),h=new y({style:o,overrideFill:a,skipKerning:e.skipKerning,padding:e.padding,resolution:e.resolution,overrideSize:!1,textureStyle:e.textureStyle}),c=function(t){if(""===t)return[];"string"==typeof t&&(t=[t]);const e=[];for(let r=0,s=t.length;r<s;r++){const s=t[r];if(Array.isArray(s)){if(2!==s.length)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${s.length}.`);if(0===s[0].length||0===s[1].length)throw new Error("[BitmapFont]: Invalid character delimiter.");const t=s[0].charCodeAt(0),r=s[1].charCodeAt(0);if(r<t)throw new Error("[BitmapFont]: Invalid character range.");for(let s=t,i=r;s<=i;s++)e.push(String.fromCharCode(s))}else e.push(...Array.from(s))}if(0===e.length)throw new Error("[BitmapFont]: Empty set when resolving characters.");return e}(e.chars);return h.ensureCharacters(c.join("")),i.l.set(`${r}-bitmap`,h),h.once("destroy",()=>i.l.remove(`${r}-bitmap`)),h}uninstall(t){const e=`${t}-bitmap`,r=i.l.get(e);r&&r.destroy()}_canUseTintForStyle(t){return!(t._stroke||t.dropShadow&&0!==t.dropShadow.color||t._fill.fill||16777215!==t._fill.color)}}},8628:(t,e,r)=>{"use strict";r.d(e,{WebGPURenderer:()=>At});var s=r(1065),i=r(5199),n=r(2791),o=r(9677),a=r(2305),l=r(1570),h=r(4405),c=r(7335),u=r(1657),d=r(4449);class p{constructor(){this._maxTextures=0}contextChange(t){const e=new d.k({uTransformMatrix:{value:new i.u,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}});this._maxTextures=t.limits.maxBatchableTextures;const r=(0,o.v)({name:"graphics",bits:[a.F,(0,l._)(this._maxTextures),h._Q,c.b]});this.shader=new u.M({gpuProgram:r,resources:{localUniforms:e}})}execute(t,e){const r=e.context,s=r.customShader||this.shader,i=t.renderer,o=i.graphicsContext,{batcher:a,instructions:l}=o.getContextRenderData(r),h=i.encoder;h.setGeometry(a.geometry,s.gpuProgram);const c=i.globalUniforms.bindGroup;h.setBindGroup(0,c,s.gpuProgram);const u=i.renderPipes.uniformBatch.getUniformBindGroup(s.resources.localUniforms,!0);h.setBindGroup(2,u,s.gpuProgram);const d=l.instructions;let p=null;for(let e=0;e<l.instructionSize;e++){const r=d[e];if(r.topology!==p&&(p=r.topology,h.setPipelineFromGeometryProgramAndState(a.geometry,s.gpuProgram,t.state,r.topology)),s.groups[1]=r.bindGroup,!r.gpuBindGroup){const t=r.textures;r.bindGroup=(0,n.w)(t.textures,t.count,this._maxTextures),r.gpuBindGroup=i.bindGroup.getBindGroup(r.bindGroup,s.gpuProgram,1)}h.setBindGroup(1,r.bindGroup,s.gpuProgram),h.renderPassEncoder.drawIndexed(r.size,1,r.start)}}destroy(){this.shader.destroy(!0),this.shader=null}}p.extension={type:[s.Ag.WebGPUPipesAdaptor],name:"graphics"};var f=r(2577),g=r(9739),m=r(7694);class x{init(){const t=(0,o.v)({name:"mesh",bits:[h.Ls,f.R,c.b]});this._shader=new u.M({gpuProgram:t,resources:{uTexture:g.g.EMPTY._source,uSampler:g.g.EMPTY._source.style,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new i.u}}}})}execute(t,e){const r=t.renderer;let s=e._shader;if(s){if(!s.gpuProgram)return void(0,m.R)("Mesh shader has no gpuProgram",e.shader)}else s=this._shader,s.groups[2]=r.texture.getTextureBindGroup(e.texture);const i=s.gpuProgram;if(i.autoAssignGlobalUniforms&&(s.groups[0]=r.globalUniforms.bindGroup),i.autoAssignLocalUniforms){const e=t.localUniforms;s.groups[1]=r.renderPipes.uniformBatch.getUniformBindGroup(e,!0)}r.encoder.draw({geometry:e._geometry,shader:s,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}x.extension={type:[s.Ag.WebGPUPipesAdaptor],name:"mesh"};var _=r(7433);const y=_.U.for2d();class v{start(t,e,r){const s=t.renderer,i=s.encoder,n=r.gpuProgram;this._shader=r,this._geometry=e,i.setGeometry(e,n),y.blendMode="normal",s.pipeline.getPipeline(e,n,y);const o=s.globalUniforms.bindGroup;i.resetBindGroup(1),i.setBindGroup(0,o,n)}execute(t,e){const r=this._shader.gpuProgram,s=t.renderer,i=s.encoder;if(!e.bindGroup){const t=e.textures;e.bindGroup=(0,n.w)(t.textures,t.count,s.limits.maxBatchableTextures)}y.blendMode=e.blendMode;const o=s.bindGroup.getBindGroup(e.bindGroup,r,1),a=s.pipeline.getPipeline(this._geometry,r,y,e.topology);e.bindGroup._touch(s.textureGC.count),i.setPipeline(a),i.renderPassEncoder.setBindGroup(1,o),i.renderPassEncoder.drawIndexed(e.size,1,e.start)}}v.extension={type:[s.Ag.WebGPUPipesAdaptor],name:"batch"};var b=r(6114),w=r(1673),T=r(5153);class S{constructor(t){this._hash=Object.create(null),this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_hash")}contextChange(t){this._gpu=t}getBindGroup(t,e,r){return t._updateKey(),this._hash[t._key]||this._createBindGroup(t,e,r)}_createBindGroup(t,e,r){const s=this._gpu.device,i=e.layout[r],n=[],o=this._renderer;for(const e in i){const r=t.resources[e]??t.resources[i[e]];let s;if("uniformGroup"===r._resourceType){const t=r;o.ubo.updateUniformGroup(t);const e=t.buffer;s={buffer:o.buffer.getGPUBuffer(e),offset:0,size:e.descriptor.size}}else if("buffer"===r._resourceType){const t=r;s={buffer:o.buffer.getGPUBuffer(t),offset:0,size:t.descriptor.size}}else if("bufferResource"===r._resourceType){const t=r;s={buffer:o.buffer.getGPUBuffer(t.buffer),offset:t.offset,size:t.size}}else if("textureSampler"===r._resourceType){const t=r;s=o.texture.getGpuSampler(t)}else if("textureSource"===r._resourceType){const t=r;s=o.texture.getGpuSource(t).createView({})}n.push({binding:i[e],resource:s})}const a=o.shader.getProgramData(e).bindGroups[r],l=s.createBindGroup({layout:a,entries:n});return this._hash[t._key]=l,l}destroy(){for(const t of Object.keys(this._hash))this._hash[t]=null;this._hash=null,this._renderer=null}}S.extension={type:[s.Ag.WebGPUSystem],name:"bindGroup"};var A=r(9062);class C{constructor(t){this._gpuBuffers=Object.create(null),this._managedBuffers=[],t.renderableGC.addManagedHash(this,"_gpuBuffers")}contextChange(t){this._gpu=t}getGPUBuffer(t){return this._gpuBuffers[t.uid]||this.createGPUBuffer(t)}updateBuffer(t){const e=this._gpuBuffers[t.uid]||this.createGPUBuffer(t),r=t.data;return t._updateID&&r&&(t._updateID=0,this._gpu.device.queue.writeBuffer(e,0,r.buffer,0,(t._updateSize||r.byteLength)+3&-4)),e}destroyAll(){for(const t in this._gpuBuffers)this._gpuBuffers[t].destroy();this._gpuBuffers={}}createGPUBuffer(t){this._gpuBuffers[t.uid]||(t.on("update",this.updateBuffer,this),t.on("change",this.onBufferChange,this),t.on("destroy",this.onBufferDestroy,this),this._managedBuffers.push(t));const e=this._gpu.device.createBuffer(t.descriptor);return t._updateID=0,t.data&&((0,A.W)(t.data.buffer,e.getMappedRange()),e.unmap()),this._gpuBuffers[t.uid]=e,e}onBufferChange(t){this._gpuBuffers[t.uid].destroy(),t._updateID=0,this._gpuBuffers[t.uid]=this.createGPUBuffer(t)}onBufferDestroy(t){this._managedBuffers.splice(this._managedBuffers.indexOf(t),1),this._destroyBuffer(t)}destroy(){this._managedBuffers.forEach(t=>this._destroyBuffer(t)),this._managedBuffers=null,this._gpuBuffers=null}_destroyBuffer(t){this._gpuBuffers[t.uid].destroy(),t.off("update",this.updateBuffer,this),t.off("change",this.onBufferChange,this),t.off("destroy",this.onBufferDestroy,this),this._gpuBuffers[t.uid]=null}}C.extension={type:[s.Ag.WebGPUSystem],name:"buffer"};class P{constructor(t){this._colorMaskCache=15,this._renderer=t}setMask(t){this._colorMaskCache!==t&&(this._colorMaskCache=t,this._renderer.pipeline.setColorMask(t))}destroy(){this._renderer=null,this._colorMaskCache=null}}P.extension={type:[s.Ag.WebGPUSystem],name:"colorMask"};var M=r(5423);class E{constructor(t){this._renderer=t}async init(t){return this._initPromise||(this._initPromise=(t.gpu?Promise.resolve(t.gpu):this._createDeviceAndAdaptor(t)).then(t=>{this.gpu=t,this._renderer.runners.contextChange.emit(this.gpu)})),this._initPromise}contextChange(t){this._renderer.gpu=t}async _createDeviceAndAdaptor(t){const e=await M.e.get().getNavigator().gpu.requestAdapter({powerPreference:t.powerPreference,forceFallbackAdapter:t.forceFallbackAdapter}),r=["texture-compression-bc","texture-compression-astc","texture-compression-etc2"].filter(t=>e.features.has(t)),s=await e.requestDevice({requiredFeatures:r});return{adapter:e,device:s}}destroy(){this.gpu=null,this._renderer=null}}E.extension={type:[s.Ag.WebGPUSystem],name:"device"},E.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};class R{constructor(t){this._boundBindGroup=Object.create(null),this._boundVertexBuffer=Object.create(null),this._renderer=t}renderStart(){this.commandFinished=new Promise(t=>{this._resolveCommandFinished=t}),this.commandEncoder=this._renderer.gpu.device.createCommandEncoder()}beginRenderPass(t){this.endRenderPass(),this._clearCache(),this.renderPassEncoder=this.commandEncoder.beginRenderPass(t.descriptor)}endRenderPass(){this.renderPassEncoder&&this.renderPassEncoder.end(),this.renderPassEncoder=null}setViewport(t){this.renderPassEncoder.setViewport(t.x,t.y,t.width,t.height,0,1)}setPipelineFromGeometryProgramAndState(t,e,r,s){const i=this._renderer.pipeline.getPipeline(t,e,r,s);this.setPipeline(i)}setPipeline(t){this._boundPipeline!==t&&(this._boundPipeline=t,this.renderPassEncoder.setPipeline(t))}_setVertexBuffer(t,e){this._boundVertexBuffer[t]!==e&&(this._boundVertexBuffer[t]=e,this.renderPassEncoder.setVertexBuffer(t,this._renderer.buffer.updateBuffer(e)))}_setIndexBuffer(t){if(this._boundIndexBuffer===t)return;this._boundIndexBuffer=t;const e=2===t.data.BYTES_PER_ELEMENT?"uint16":"uint32";this.renderPassEncoder.setIndexBuffer(this._renderer.buffer.updateBuffer(t),e)}resetBindGroup(t){this._boundBindGroup[t]=null}setBindGroup(t,e,r){if(this._boundBindGroup[t]===e)return;this._boundBindGroup[t]=e,e._touch(this._renderer.textureGC.count);const s=this._renderer.bindGroup.getBindGroup(e,r,t);this.renderPassEncoder.setBindGroup(t,s)}setGeometry(t,e){const r=this._renderer.pipeline.getBufferNamesToBind(t,e);for(const e in r)this._setVertexBuffer(parseInt(e,10),t.attributes[r[e]].buffer);t.indexBuffer&&this._setIndexBuffer(t.indexBuffer)}_setShaderBindGroups(t,e){for(const r in t.groups){const s=t.groups[r];e||this._syncBindGroup(s),this.setBindGroup(r,s,t.gpuProgram)}}_syncBindGroup(t){for(const e in t.resources){const r=t.resources[e];r.isUniformGroup&&this._renderer.ubo.updateUniformGroup(r)}}draw(t){const{geometry:e,shader:r,state:s,topology:i,size:n,start:o,instanceCount:a,skipSync:l}=t;this.setPipelineFromGeometryProgramAndState(e,r.gpuProgram,s,i),this.setGeometry(e,r.gpuProgram),this._setShaderBindGroups(r,l),e.indexBuffer?this.renderPassEncoder.drawIndexed(n||e.indexBuffer.data.length,a??e.instanceCount,o||0):this.renderPassEncoder.draw(n||e.getSize(),a??e.instanceCount,o||0)}finishRenderPass(){this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null)}postrender(){this.finishRenderPass(),this._gpu.device.queue.submit([this.commandEncoder.finish()]),this._resolveCommandFinished(),this.commandEncoder=null}restoreRenderPass(){const t=this._renderer.renderTarget.adaptor.getDescriptor(this._renderer.renderTarget.renderTarget,!1,[0,0,0,1]);this.renderPassEncoder=this.commandEncoder.beginRenderPass(t);const e=this._boundPipeline,r={...this._boundVertexBuffer},s=this._boundIndexBuffer,i={...this._boundBindGroup};this._clearCache();const n=this._renderer.renderTarget.viewport;this.renderPassEncoder.setViewport(n.x,n.y,n.width,n.height,0,1),this.setPipeline(e);for(const t in r)this._setVertexBuffer(t,r[t]);for(const t in i)this.setBindGroup(t,i[t],null);this._setIndexBuffer(s)}_clearCache(){for(let t=0;t<16;t++)this._boundBindGroup[t]=null,this._boundVertexBuffer[t]=null;this._boundIndexBuffer=null,this._boundPipeline=null}destroy(){this._renderer=null,this._gpu=null,this._boundBindGroup=null,this._boundVertexBuffer=null,this._boundIndexBuffer=null,this._boundPipeline=null}contextChange(t){this._gpu=t}}R.extension={type:[s.Ag.WebGPUSystem],name:"encoder",priority:1};class k{constructor(t){this._renderer=t}contextChange(){this.maxTextures=this._renderer.device.gpu.device.limits.maxSampledTexturesPerShaderStage,this.maxBatchableTextures=this.maxTextures}destroy(){}}k.extension={type:[s.Ag.WebGPUSystem],name:"limits"};var B=r(8271);class I{constructor(t){this._renderTargetStencilState=Object.create(null),this._renderer=t,t.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(t){let e=this._renderTargetStencilState[t.uid];e||(e=this._renderTargetStencilState[t.uid]={stencilMode:B.K.DISABLED,stencilReference:0}),this._activeRenderTarget=t,this.setStencilMode(e.stencilMode,e.stencilReference)}setStencilMode(t,e){const r=this._renderTargetStencilState[this._activeRenderTarget.uid];r.stencilMode=t,r.stencilReference=e;const s=this._renderer;s.pipeline.setStencilMode(t),s.encoder.renderPassEncoder.setStencilReference(e)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._renderTargetStencilState=null}}I.extension={type:[s.Ag.WebGPUSystem],name:"stencil"};var G=r(1009);const F={i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},f16:{align:2,size:2},"vec2<i32>":{align:8,size:8},"vec2<u32>":{align:8,size:8},"vec2<f32>":{align:8,size:8},"vec2<f16>":{align:4,size:4},"vec3<i32>":{align:16,size:12},"vec3<u32>":{align:16,size:12},"vec3<f32>":{align:16,size:12},"vec3<f16>":{align:8,size:6},"vec4<i32>":{align:16,size:16},"vec4<u32>":{align:16,size:16},"vec4<f32>":{align:16,size:16},"vec4<f16>":{align:8,size:8},"mat2x2<f32>":{align:8,size:16},"mat2x2<f16>":{align:4,size:8},"mat3x2<f32>":{align:8,size:24},"mat3x2<f16>":{align:4,size:12},"mat4x2<f32>":{align:8,size:32},"mat4x2<f16>":{align:4,size:16},"mat2x3<f32>":{align:16,size:32},"mat2x3<f16>":{align:8,size:16},"mat3x3<f32>":{align:16,size:48},"mat3x3<f16>":{align:8,size:24},"mat4x3<f32>":{align:16,size:64},"mat4x3<f16>":{align:8,size:32},"mat2x4<f32>":{align:16,size:32},"mat2x4<f16>":{align:8,size:16},"mat3x4<f32>":{align:16,size:48},"mat3x4<f16>":{align:8,size:24},"mat4x4<f32>":{align:16,size:64},"mat4x4<f16>":{align:8,size:32}};function O(t){const e=t.map(t=>({data:t,offset:0,size:0}));let r=0;for(let t=0;t<e.length;t++){const s=e[t];let i=F[s.data.type].size;const n=F[s.data.type].align;if(!F[s.data.type])throw new Error(`[Pixi.js] WebGPU UniformBuffer: Unknown type ${s.data.type}`);s.data.size>1&&(i=Math.max(i,n)*s.data.size),r=Math.ceil(r/n)*n,s.size=i,s.offset=r,r+=i}return r=16*Math.ceil(r/16),{uboElements:e,size:r}}var D=r(2337),U=r(4364);function L(t,e){const{size:r,align:s}=F[t.data.type],i=(s-r)/4,n=t.data.type.indexOf("i32")>=0?"dataInt32":"data";return`\n v = uv.${t.data.name};\n ${0!==e?`offset += ${e};`:""}\n\n arrayOffset = offset;\n\n t = 0;\n\n for(var i=0; i < ${t.data.size*(r/4)}; i++)\n {\n for(var j = 0; j < ${r/4}; j++)\n {\n ${n}[arrayOffset++] = v[t++];\n }\n ${0!==i?`arrayOffset += ${i};`:""}\n }\n `}function N(t){return(0,D.E)(t,"uboWgsl",L,U._)}class z extends G.W{constructor(){super({createUboElements:O,generateUboSync:N})}}z.extension={type:[s.Ag.WebGPUSystem],name:"ubo"};var W=r(1579),H=r(2015),X=r(9798);class V{constructor({minUniformOffsetAlignment:t}){this._minUniformOffsetAlignment=256,this.byteIndex=0,this._minUniformOffsetAlignment=t,this.data=new Float32Array(65535)}clear(){this.byteIndex=0}addEmptyGroup(t){if(t>this._minUniformOffsetAlignment/4)throw new Error("UniformBufferBatch: array is too large: "+4*t);const e=this.byteIndex;let r=e+4*t;if(r=Math.ceil(r/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment,r>4*this.data.length)throw new Error("UniformBufferBatch: ubo batch got too big");return this.byteIndex=r,e}addGroup(t){const e=this.addEmptyGroup(t.length);for(let r=0;r<t.length;r++)this.data[e/4+r]=t[r];return e}destroy(){this.data=null}}var Y=r(3655);const j=128;class ${constructor(t){this._bindGroupHash=Object.create(null),this._buffers=[],this._bindGroups=[],this._bufferResources=[],this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_bindGroupHash"),this._batchBuffer=new V({minUniformOffsetAlignment:j});for(let t=0;t<2;t++){let e=X.S.UNIFORM|X.S.COPY_DST;0===t&&(e|=X.S.COPY_SRC),this._buffers.push(new W.h({data:this._batchBuffer.data,usage:e}))}}renderEnd(){this._uploadBindGroups(),this._resetBindGroups()}_resetBindGroups(){for(const t in this._bindGroupHash)this._bindGroupHash[t]=null;this._batchBuffer.clear()}getUniformBindGroup(t,e){if(!e&&this._bindGroupHash[t.uid])return this._bindGroupHash[t.uid];this._renderer.ubo.ensureUniformGroup(t);const r=t.buffer.data,s=this._batchBuffer.addEmptyGroup(r.length);return this._renderer.ubo.syncUniformGroup(t,this._batchBuffer.data,s/4),this._bindGroupHash[t.uid]=this._getBindGroup(s/j),this._bindGroupHash[t.uid]}getUboResource(t){this._renderer.ubo.updateUniformGroup(t);const e=t.buffer.data,r=this._batchBuffer.addGroup(e);return this._getBufferResource(r/j)}getArrayBindGroup(t){const e=this._batchBuffer.addGroup(t);return this._getBindGroup(e/j)}getArrayBufferResource(t){const e=this._batchBuffer.addGroup(t)/j;return this._getBufferResource(e)}_getBufferResource(t){if(!this._bufferResources[t]){const e=this._buffers[t%2];this._bufferResources[t]=new H.d({buffer:e,offset:256*(t/2|0),size:j})}return this._bufferResources[t]}_getBindGroup(t){if(!this._bindGroups[t]){const e=new Y.T({0:this._getBufferResource(t)});this._bindGroups[t]=e}return this._bindGroups[t]}_uploadBindGroups(){const t=this._renderer.buffer,e=this._buffers[0];e.update(this._batchBuffer.byteIndex),t.updateBuffer(e);const r=this._renderer.gpu.device.createCommandEncoder();for(let s=1;s<this._buffers.length;s++){const i=this._buffers[s];r.copyBufferToBuffer(t.getGPUBuffer(e),j,t.getGPUBuffer(i),0,this._batchBuffer.byteIndex)}this._renderer.gpu.device.queue.submit([r.finish()])}destroy(){for(let t=0;t<this._bindGroups.length;t++)this._bindGroups[t]?.destroy();this._bindGroups=null,this._bindGroupHash=null;for(let t=0;t<this._buffers.length;t++)this._buffers[t].destroy();this._buffers=null;for(let t=0;t<this._bufferResources.length;t++)this._bufferResources[t].destroy();this._bufferResources=null,this._batchBuffer.destroy(),this._bindGroupHash=null,this._renderer=null}}$.extension={type:[s.Ag.WebGPUPipes],name:"uniformBatch"};var q=r(498),K=r(8642),Z=r(9250);const Q={"point-list":0,"line-list":1,"line-strip":2,"triangle-list":3,"triangle-strip":4};class J{constructor(t){this._moduleCache=Object.create(null),this._bufferLayoutsCache=Object.create(null),this._bindingNamesCache=Object.create(null),this._pipeCache=Object.create(null),this._pipeStateCaches=Object.create(null),this._colorMask=15,this._multisampleCount=1,this._renderer=t}contextChange(t){this._gpu=t,this.setStencilMode(B.K.DISABLED),this._updatePipeHash()}setMultisampleCount(t){this._multisampleCount!==t&&(this._multisampleCount=t,this._updatePipeHash())}setRenderTarget(t){this._multisampleCount=t.msaaSamples,this._depthStencilAttachment=t.descriptor.depthStencilAttachment?1:0,this._updatePipeHash()}setColorMask(t){this._colorMask!==t&&(this._colorMask=t,this._updatePipeHash())}setStencilMode(t){this._stencilMode!==t&&(this._stencilMode=t,this._stencilState=Z.g[t],this._updatePipeHash())}setPipeline(t,e,r,s){const i=this.getPipeline(t,e,r);s.setPipeline(i)}getPipeline(t,e,r,s){t._layoutKey||((0,q.q)(t,e.attributeData),this._generateBufferKey(t)),s||(s=t.topology);const i=function(t,e,r,s,i){return t<<24|e<<16|r<<10|s<<5|i}(t._layoutKey,e._layoutKey,r.data,r._blendModeId,Q[s]);return this._pipeCache[i]||(this._pipeCache[i]=this._createPipeline(t,e,r,s)),this._pipeCache[i]}_createPipeline(t,e,r,s){const i=this._gpu.device,n=this._createVertexBufferLayouts(t,e),o=this._renderer.state.getColorTargets(r);o[0].writeMask=this._stencilMode===B.K.RENDERING_MASK_ADD?0:this._colorMask;const a=this._renderer.shader.getProgramData(e).pipeline,l={vertex:{module:this._getModule(e.vertex.source),entryPoint:e.vertex.entryPoint,buffers:n},fragment:{module:this._getModule(e.fragment.source),entryPoint:e.fragment.entryPoint,targets:o},primitive:{topology:s,cullMode:r.cullMode},layout:a,multisample:{count:this._multisampleCount},label:"PIXI Pipeline"};return this._depthStencilAttachment&&(l.depthStencil={...this._stencilState,format:"depth24plus-stencil8",depthWriteEnabled:r.depthTest,depthCompare:r.depthTest?"less":"always"}),i.createRenderPipeline(l)}_getModule(t){return this._moduleCache[t]||this._createModule(t)}_createModule(t){const e=this._gpu.device;return this._moduleCache[t]=e.createShaderModule({code:t}),this._moduleCache[t]}_generateBufferKey(t){const e=[];let r=0;const s=Object.keys(t.attributes).sort();for(let i=0;i<s.length;i++){const n=t.attributes[s[i]];e[r++]=n.offset,e[r++]=n.format,e[r++]=n.stride,e[r++]=n.instance}const i=e.join("|");return t._layoutKey=(0,K.X)(i,"geometry"),t._layoutKey}_generateAttributeLocationsKey(t){const e=[];let r=0;const s=Object.keys(t.attributeData).sort();for(let i=0;i<s.length;i++){const n=t.attributeData[s[i]];e[r++]=n.location}const i=e.join("|");return t._attributeLocationsKey=(0,K.X)(i,"programAttributes"),t._attributeLocationsKey}getBufferNamesToBind(t,e){const r=t._layoutKey<<16|e._attributeLocationsKey;if(this._bindingNamesCache[r])return this._bindingNamesCache[r];const s=this._createVertexBufferLayouts(t,e),i=Object.create(null),n=e.attributeData;for(let t=0;t<s.length;t++){const e=Object.values(s[t].attributes)[0].shaderLocation;for(const r in n)if(n[r].location===e){i[t]=r;break}}return this._bindingNamesCache[r]=i,i}_createVertexBufferLayouts(t,e){e._attributeLocationsKey||this._generateAttributeLocationsKey(e);const r=t._layoutKey<<16|e._attributeLocationsKey;if(this._bufferLayoutsCache[r])return this._bufferLayoutsCache[r];const s=[];return t.buffers.forEach(r=>{const i={arrayStride:0,stepMode:"vertex",attributes:[]},n=i.attributes;for(const s in e.attributeData){const o=t.attributes[s];1!==(o.divisor??1)&&(0,m.R)(`Attribute ${s} has an invalid divisor value of '${o.divisor}'. WebGPU only supports a divisor value of 1`),o.buffer===r&&(i.arrayStride=o.stride,i.stepMode=o.instance?"instance":"vertex",n.push({shaderLocation:e.attributeData[s].location,offset:o.offset,format:o.format}))}n.length&&s.push(i)}),this._bufferLayoutsCache[r]=s,s}_updatePipeHash(){const t=(e=this._stencilMode,r=this._multisampleCount,this._colorMask<<6|e<<3|this._depthStencilAttachment<<1|r);var e,r;this._pipeStateCaches[t]||(this._pipeStateCaches[t]=Object.create(null)),this._pipeCache=this._pipeStateCaches[t]}destroy(){this._renderer=null,this._bufferLayoutsCache=null}}J.extension={type:[s.Ag.WebGPUSystem],name:"pipeline"};var tt=r(8900),et=r(1711),rt=r(1386),st=r(4269);class it{constructor(){this.contexts=[],this.msaaTextures=[],this.msaaSamples=1}}class nt{init(t,e){this._renderer=t,this._renderTargetSystem=e}copyToTexture(t,e,r,s,i){const n=this._renderer,o=this._getGpuColorTexture(t),a=n.texture.getGpuSource(e.source);return n.encoder.commandEncoder.copyTextureToTexture({texture:o,origin:r},{texture:a,origin:i},s),e}startRenderPass(t,e=!0,r,s){const i=this._renderTargetSystem.getGpuRenderTarget(t),n=this.getDescriptor(t,e,r);i.descriptor=n,this._renderer.pipeline.setRenderTarget(i),this._renderer.encoder.beginRenderPass(i),this._renderer.encoder.setViewport(s)}finishRenderPass(){this._renderer.encoder.endRenderPass()}_getGpuColorTexture(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);return e.contexts[0]?e.contexts[0].getCurrentTexture():this._renderer.texture.getGpuSource(t.colorTextures[0].source)}getDescriptor(t,e,r){"boolean"==typeof e&&(e=e?et.u.ALL:et.u.NONE);const s=this._renderTargetSystem,i=s.getGpuRenderTarget(t),n=t.colorTextures.map((t,n)=>{const o=i.contexts[n];let a,l;a=o?o.getCurrentTexture().createView():this._renderer.texture.getGpuSource(t).createView({mipLevelCount:1}),i.msaaTextures[n]&&(l=a,a=this._renderer.texture.getTextureView(i.msaaTextures[n]));const h=e&et.u.COLOR?"clear":"load";return r??(r=s.defaultClearColor),{view:a,resolveTarget:l,clearValue:r,storeOp:"store",loadOp:h}});let o;if(!t.stencil&&!t.depth||t.depthStencilTexture||(t.ensureDepthStencilTexture(),t.depthStencilTexture.source.sampleCount=i.msaa?4:1),t.depthStencilTexture){const r=e&et.u.STENCIL?"clear":"load",s=e&et.u.DEPTH?"clear":"load";o={view:this._renderer.texture.getGpuSource(t.depthStencilTexture.source).createView(),stencilStoreOp:"store",stencilLoadOp:r,depthClearValue:1,depthLoadOp:s,depthStoreOp:"store"}}return{colorAttachments:n,depthStencilAttachment:o}}clear(t,e=!0,r,s){if(!e)return;const{gpu:i,encoder:n}=this._renderer,o=i.device;if(null===n.commandEncoder){const i=o.createCommandEncoder(),n=this.getDescriptor(t,e,r),a=i.beginRenderPass(n);a.setViewport(s.x,s.y,s.width,s.height,0,1),a.end();const l=i.finish();o.queue.submit([l])}else this.startRenderPass(t,e,r,s)}initGpuRenderTarget(t){t.isRoot=!0;const e=new it;return t.colorTextures.forEach((t,r)=>{if(t instanceof rt.q){const s=t.resource.getContext("webgpu"),i=t.transparent?"premultiplied":"opaque";try{s.configure({device:this._renderer.gpu.device,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,format:"bgra8unorm",alphaMode:i})}catch(t){console.error(t)}e.contexts[r]=s}if(e.msaa=t.source.antialias,t.source.antialias){const t=new st.v({width:0,height:0,sampleCount:4});e.msaaTextures[r]=t}}),e.msaa&&(e.msaaSamples=4,t.depthStencilTexture&&(t.depthStencilTexture.source.sampleCount=4)),e}destroyGpuRenderTarget(t){t.contexts.forEach(t=>{t.unconfigure()}),t.msaaTextures.forEach(t=>{t.destroy()}),t.msaaTextures.length=0,t.contexts.length=0}ensureDepthStencilTexture(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);t.depthStencilTexture&&e.msaa&&(t.depthStencilTexture.source.sampleCount=4)}resizeGpuRenderTarget(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);e.width=t.width,e.height=t.height,e.msaa&&t.colorTextures.forEach((t,r)=>{const s=e.msaaTextures[r];s?.resize(t.source.width,t.source.height,t.source._resolution)})}}class ot extends tt.l{constructor(t){super(t),this.adaptor=new nt,this.adaptor.init(t,this)}}ot.extension={type:[s.Ag.WebGPUSystem],name:"renderTarget"};class at{constructor(){this._gpuProgramData=Object.create(null)}contextChange(t){this._gpu=t}getProgramData(t){return this._gpuProgramData[t._layoutKey]||this._createGPUProgramData(t)}_createGPUProgramData(t){const e=this._gpu.device,r=t.gpuLayout.map(t=>e.createBindGroupLayout({entries:t})),s={bindGroupLayouts:r};return this._gpuProgramData[t._layoutKey]={bindGroups:r,pipeline:e.createPipelineLayout(s)},this._gpuProgramData[t._layoutKey]}destroy(){this._gpu=null,this._gpuProgramData=null}}at.extension={type:[s.Ag.WebGPUSystem],name:"shader"};const lt={normal:{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}},add:{alpha:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one",operation:"add"}},multiply:{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"dst",dstFactor:"one-minus-src-alpha",operation:"add"}},screen:{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},overlay:{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},none:{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"zero",operation:"add"}},"normal-npm":{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"}},"add-npm":{alpha:{srcFactor:"one",dstFactor:"one",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one",operation:"add"}},"screen-npm":{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src",operation:"add"}},erase:{alpha:{srcFactor:"zero",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"one-minus-src",operation:"add"}},min:{alpha:{srcFactor:"one",dstFactor:"one",operation:"min"},color:{srcFactor:"one",dstFactor:"one",operation:"min"}},max:{alpha:{srcFactor:"one",dstFactor:"one",operation:"max"},color:{srcFactor:"one",dstFactor:"one",operation:"max"}}};class ht{constructor(){this.defaultState=new _.U,this.defaultState.blend=!0}contextChange(t){this.gpu=t}getColorTargets(t){return[{format:"bgra8unorm",writeMask:0,blend:lt[t.blendMode]||lt.normal}]}destroy(){this.gpu=null}}ht.extension={type:[s.Ag.WebGPUSystem],name:"state"};var ct=r(1566);const ut={type:"image",upload(t,e,r){const s=t.resource,i=(0|t.pixelWidth)*(0|t.pixelHeight),n=s.byteLength/i;r.device.queue.writeTexture({texture:e},s,{offset:0,rowsPerImage:t.pixelHeight,bytesPerRow:t.pixelHeight*n},{width:t.pixelWidth,height:t.pixelHeight,depthOrArrayLayers:1})}},dt={"bc1-rgba-unorm":{blockBytes:8,blockWidth:4,blockHeight:4},"bc2-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"bc3-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"bc7-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"etc1-rgb-unorm":{blockBytes:8,blockWidth:4,blockHeight:4},"etc2-rgba8unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"astc-4x4-unorm":{blockBytes:16,blockWidth:4,blockHeight:4}},pt={blockBytes:4,blockWidth:1,blockHeight:1},ft={type:"compressed",upload(t,e,r){let s=t.pixelWidth,i=t.pixelHeight;const n=dt[t.format]||pt;for(let o=0;o<t.resource.length;o++){const a=t.resource[o],l=Math.ceil(s/n.blockWidth)*n.blockBytes;r.device.queue.writeTexture({texture:e,mipLevel:o},a,{offset:0,bytesPerRow:l},{width:Math.ceil(s/n.blockWidth)*n.blockWidth,height:Math.ceil(i/n.blockHeight)*n.blockHeight,depthOrArrayLayers:1}),s=Math.max(s>>1,1),i=Math.max(i>>1,1)}}},gt={type:"image",upload(t,e,r){const s=t.resource;if(!s)return;if(globalThis.HTMLImageElement&&s instanceof HTMLImageElement){const e=M.e.get().createCanvas(s.width,s.height);e.getContext("2d").drawImage(s,0,0,s.width,s.height),t.resource=e,(0,m.R)("ImageSource: Image element passed, converting to canvas and replacing resource.")}const i=Math.min(e.width,t.resourceWidth||t.pixelWidth),n=Math.min(e.height,t.resourceHeight||t.pixelHeight),o="premultiply-alpha-on-upload"===t.alphaMode;r.device.queue.copyExternalImageToTexture({source:s},{texture:e,premultipliedAlpha:o},{width:i,height:n})}},mt={type:"video",upload(t,e,r){gt.upload(t,e,r)}};class xt{constructor(t){this.device=t,this.sampler=t.createSampler({minFilter:"linear"}),this.pipelines={}}_getMipmapPipeline(t){let e=this.pipelines[t];return e||(this.mipmapShaderModule||(this.mipmapShaderModule=this.device.createShaderModule({code:"\n var<private> pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(\n vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, 3.0), vec2<f32>(3.0, -1.0));\n\n struct VertexOutput {\n @builtin(position) position : vec4<f32>,\n @location(0) texCoord : vec2<f32>,\n };\n\n @vertex\n fn vertexMain(@builtin(vertex_index) vertexIndex : u32) -> VertexOutput {\n var output : VertexOutput;\n output.texCoord = pos[vertexIndex] * vec2<f32>(0.5, -0.5) + vec2<f32>(0.5);\n output.position = vec4<f32>(pos[vertexIndex], 0.0, 1.0);\n return output;\n }\n\n @group(0) @binding(0) var imgSampler : sampler;\n @group(0) @binding(1) var img : texture_2d<f32>;\n\n @fragment\n fn fragmentMain(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {\n return textureSample(img, imgSampler, texCoord);\n }\n "})),e=this.device.createRenderPipeline({layout:"auto",vertex:{module:this.mipmapShaderModule,entryPoint:"vertexMain"},fragment:{module:this.mipmapShaderModule,entryPoint:"fragmentMain",targets:[{format:t}]}}),this.pipelines[t]=e),e}generateMipmap(t){const e=this._getMipmapPipeline(t.format);if("3d"===t.dimension||"1d"===t.dimension)throw new Error("Generating mipmaps for non-2d textures is currently unsupported!");let r=t;const s=t.depthOrArrayLayers||1,i=t.usage&GPUTextureUsage.RENDER_ATTACHMENT;if(!i){const e={size:{width:Math.ceil(t.width/2),height:Math.ceil(t.height/2),depthOrArrayLayers:s},format:t.format,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT,mipLevelCount:t.mipLevelCount-1};r=this.device.createTexture(e)}const n=this.device.createCommandEncoder({}),o=e.getBindGroupLayout(0);for(let a=0;a<s;++a){let s=t.createView({baseMipLevel:0,mipLevelCount:1,dimension:"2d",baseArrayLayer:a,arrayLayerCount:1}),l=i?1:0;for(let i=1;i<t.mipLevelCount;++i){const t=r.createView({baseMipLevel:l++,mipLevelCount:1,dimension:"2d",baseArrayLayer:a,arrayLayerCount:1}),i=n.beginRenderPass({colorAttachments:[{view:t,storeOp:"store",loadOp:"clear",clearValue:{r:0,g:0,b:0,a:0}}]}),h=this.device.createBindGroup({layout:o,entries:[{binding:0,resource:this.sampler},{binding:1,resource:s}]});i.setPipeline(e),i.setBindGroup(0,h),i.draw(3,1,0,0),i.end(),s=t}}if(!i){const e={width:Math.ceil(t.width/2),height:Math.ceil(t.height/2),depthOrArrayLayers:s};for(let s=1;s<t.mipLevelCount;++s)n.copyTextureToTexture({texture:r,mipLevel:s-1},{texture:t,mipLevel:s},e),e.width=Math.ceil(e.width/2),e.height=Math.ceil(e.height/2)}return this.device.queue.submit([n.finish()]),i||r.destroy(),t}}class _t{constructor(t){this.managedTextures=[],this._gpuSources=Object.create(null),this._gpuSamplers=Object.create(null),this._bindGroupHash=Object.create(null),this._textureViewHash=Object.create(null),this._uploads={image:gt,buffer:ut,video:mt,compressed:ft},this._renderer=t,t.renderableGC.addManagedHash(this,"_gpuSources"),t.renderableGC.addManagedHash(this,"_gpuSamplers"),t.renderableGC.addManagedHash(this,"_bindGroupHash"),t.renderableGC.addManagedHash(this,"_textureViewHash")}contextChange(t){this._gpu=t}initSource(t){return this._gpuSources[t.uid]?this._gpuSources[t.uid]:this._initSource(t)}_initSource(t){if(t.autoGenerateMipmaps){const e=Math.max(t.pixelWidth,t.pixelHeight);t.mipLevelCount=Math.floor(Math.log2(e))+1}let e=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST;"compressed"!==t.uploadMethodId&&(e|=GPUTextureUsage.RENDER_ATTACHMENT,e|=GPUTextureUsage.COPY_SRC);const r=dt[t.format]||{blockBytes:4,blockWidth:1,blockHeight:1},s=Math.ceil(t.pixelWidth/r.blockWidth)*r.blockWidth,i=Math.ceil(t.pixelHeight/r.blockHeight)*r.blockHeight,n={label:t.label,size:{width:s,height:i},format:t.format,sampleCount:t.sampleCount,mipLevelCount:t.mipLevelCount,dimension:t.dimension,usage:e},o=this._gpuSources[t.uid]=this._gpu.device.createTexture(n);return this.managedTextures.includes(t)||(t.on("update",this.onSourceUpdate,this),t.on("resize",this.onSourceResize,this),t.on("destroy",this.onSourceDestroy,this),t.on("unload",this.onSourceUnload,this),t.on("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.push(t)),this.onSourceUpdate(t),o}onSourceUpdate(t){const e=this.getGpuSource(t);e&&(this._uploads[t.uploadMethodId]&&this._uploads[t.uploadMethodId].upload(t,e,this._gpu),t.autoGenerateMipmaps&&t.mipLevelCount>1&&this.onUpdateMipmaps(t))}onSourceUnload(t){const e=this._gpuSources[t.uid];e&&(this._gpuSources[t.uid]=null,e.destroy())}onUpdateMipmaps(t){this._mipmapGenerator||(this._mipmapGenerator=new xt(this._gpu.device));const e=this.getGpuSource(t);this._mipmapGenerator.generateMipmap(e)}onSourceDestroy(t){t.off("update",this.onSourceUpdate,this),t.off("unload",this.onSourceUnload,this),t.off("destroy",this.onSourceDestroy,this),t.off("resize",this.onSourceResize,this),t.off("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.splice(this.managedTextures.indexOf(t),1),this.onSourceUnload(t)}onSourceResize(t){const e=this._gpuSources[t.uid];e?e.width===t.pixelWidth&&e.height===t.pixelHeight||(this._textureViewHash[t.uid]=null,this._bindGroupHash[t.uid]=null,this.onSourceUnload(t),this.initSource(t)):this.initSource(t)}_initSampler(t){return this._gpuSamplers[t._resourceId]=this._gpu.device.createSampler(t),this._gpuSamplers[t._resourceId]}getGpuSampler(t){return this._gpuSamplers[t._resourceId]||this._initSampler(t)}getGpuSource(t){return this._gpuSources[t.uid]||this.initSource(t)}getTextureBindGroup(t){return this._bindGroupHash[t.uid]??this._createTextureBindGroup(t)}_createTextureBindGroup(t){const e=t.source;return this._bindGroupHash[t.uid]=new Y.T({0:e,1:e.style,2:new d.k({uTextureMatrix:{type:"mat3x3<f32>",value:t.textureMatrix.mapCoord}})}),this._bindGroupHash[t.uid]}getTextureView(t){const e=t.source;return this._textureViewHash[e.uid]??this._createTextureView(e)}_createTextureView(t){return this._textureViewHash[t.uid]=this.getGpuSource(t).createView(),this._textureViewHash[t.uid]}generateCanvas(t){const e=this._renderer,r=e.gpu.device.createCommandEncoder(),s=M.e.get().createCanvas();s.width=t.source.pixelWidth,s.height=t.source.pixelHeight;const i=s.getContext("webgpu");return i.configure({device:e.gpu.device,usage:GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC,format:M.e.get().getNavigator().gpu.getPreferredCanvasFormat(),alphaMode:"premultiplied"}),r.copyTextureToTexture({texture:e.texture.getGpuSource(t.source),origin:{x:0,y:0}},{texture:i.getCurrentTexture()},{width:s.width,height:s.height}),e.gpu.device.queue.submit([r.finish()]),s}getPixels(t){const e=this.generateCanvas(t),r=ct.N.getOptimalCanvasAndContext(e.width,e.height),s=r.context;s.drawImage(e,0,0);const{width:i,height:n}=e,o=s.getImageData(0,0,i,n),a=new Uint8ClampedArray(o.data.buffer);return ct.N.returnCanvasAndContext(r),{pixels:a,width:i,height:n}}destroy(){this.managedTextures.slice().forEach(t=>this.onSourceDestroy(t)),this.managedTextures=null;for(const t of Object.keys(this._bindGroupHash)){const e=Number(t),r=this._bindGroupHash[e];r?.destroy(),this._bindGroupHash[e]=null}this._gpu=null,this._mipmapGenerator=null,this._gpuSources=null,this._bindGroupHash=null,this._textureViewHash=null,this._gpuSamplers=null}}_t.extension={type:[s.Ag.WebGPUSystem],name:"texture"};const yt=[...w.i,z,R,E,k,C,_t,ot,at,ht,J,P,I,S],vt=[...w.f,$],bt=[v,x,p],wt=[],Tt=[],St=[];s.XO.handleByNamedList(s.Ag.WebGPUSystem,wt),s.XO.handleByNamedList(s.Ag.WebGPUPipes,Tt),s.XO.handleByNamedList(s.Ag.WebGPUPipesAdaptor,St),s.XO.add(...yt,...vt,...bt);class At extends b.k{constructor(){super({name:"webgpu",type:T.W.WEBGPU,systems:wt,renderPipes:Tt,renderPipeAdaptors:St})}}},8642:(t,e,r)=>{"use strict";r.d(e,{X:()=>n});const s=Object.create(null),i=Object.create(null);function n(t,e){let r=i[t];return void 0===r&&(void 0===s[e]&&(s[e]=1),i[t]=r=s[e]++),r}},8675:(t,e,r)=>{"use strict";var s=r(1065),i=r(4687),n=r(3880),o=r(3651);class a{constructor(t){this._lastTransform="",this._observer=null,this._tickerAttached=!1,this.updateTranslation=()=>{if(!this._canvas)return;const t=this._canvas.getBoundingClientRect(),e=this._canvas.width,r=this._canvas.height,s=t.width/e*this._renderer.resolution,i=t.height/r*this._renderer.resolution,n=`translate(${t.left}px, ${t.top}px) scale(${s}, ${i})`;n!==this._lastTransform&&(this._domElement.style.transform=n,this._lastTransform=n)},this._domElement=t.domElement,this._renderer=t.renderer,globalThis.OffscreenCanvas&&this._renderer.canvas instanceof OffscreenCanvas||(this._canvas=this._renderer.canvas,this._attachObserver())}get canvas(){return this._canvas}ensureAttached(){!this._domElement.parentNode&&this._canvas.parentNode&&(this._canvas.parentNode.appendChild(this._domElement),this.updateTranslation())}_attachObserver(){"ResizeObserver"in globalThis?(this._observer&&(this._observer.disconnect(),this._observer=null),this._observer=new ResizeObserver(t=>{for(const e of t){if(e.target!==this._canvas)continue;const t=this.canvas.width,r=this.canvas.height,s=e.contentRect.width/t*this._renderer.resolution,i=e.contentRect.height/r*this._renderer.resolution;(this._lastScaleX!==s||this._lastScaleY!==i)&&(this.updateTranslation(),this._lastScaleX=s,this._lastScaleY=i)}}),this._observer.observe(this._canvas)):this._tickerAttached||o.R.shared.add(this.updateTranslation,this,n.d.HIGH)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&o.R.shared.remove(this.updateTranslation),this._domElement=null,this._renderer=null,this._canvas=null,this._tickerAttached=!1,this._lastTransform="",this._lastScaleX=null,this._lastScaleY=null}}var l=r(59);class h{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=h.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new l.b,this.page=new l.b,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=t}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return!this.manager||this.path&&this.path[this.path.length-1]===this.target||(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(t,e,r){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(t,e,r,s,i){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}var c=/iPhone/i,u=/iPod/i,d=/iPad/i,p=/\biOS-universal(?:.+)Mac\b/i,f=/\bAndroid(?:.+)Mobile\b/i,g=/Android/i,m=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,x=/Silk/i,_=/Windows Phone/i,y=/\bWindows(?:.+)ARM\b/i,v=/BlackBerry/i,b=/BB10/i,w=/Opera Mini/i,T=/\b(CriOS|Chrome)(?:.+)Mobile/i,S=/Mobile(?:.+)Firefox\b/i,A=function(t){return void 0!==t&&"MacIntel"===t.platform&&"number"==typeof t.maxTouchPoints&&t.maxTouchPoints>1&&"undefined"==typeof MSStream};function C(t){var e={userAgent:"",platform:"",maxTouchPoints:0};t||"undefined"==typeof navigator?"string"==typeof t?e.userAgent=t:t&&t.userAgent&&(e={userAgent:t.userAgent,platform:t.platform,maxTouchPoints:t.maxTouchPoints||0}):e={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0};var r=e.userAgent,s=r.split("[FBAN");void 0!==s[1]&&(r=s[0]),void 0!==(s=r.split("Twitter"))[1]&&(r=s[0]);var i=function(t){return function(e){return e.test(t)}}(r),n={apple:{phone:i(c)&&!i(_),ipod:i(u),tablet:!i(c)&&(i(d)||A(e))&&!i(_),universal:i(p),device:(i(c)||i(u)||i(d)||i(p)||A(e))&&!i(_)},amazon:{phone:i(m),tablet:!i(m)&&i(x),device:i(m)||i(x)},android:{phone:!i(_)&&i(m)||!i(_)&&i(f),tablet:!i(_)&&!i(m)&&!i(f)&&(i(x)||i(g)),device:!i(_)&&(i(m)||i(x)||i(f)||i(g))||i(/\bokhttp\b/i)},windows:{phone:i(_),tablet:i(y),device:i(_)||i(y)},other:{blackberry:i(v),blackberry10:i(b),opera:i(w),firefox:i(S),chrome:i(T),device:i(v)||i(b)||i(w)||i(S)||i(T)},any:!1,phone:!1,tablet:!1};return n.any=n.apple.device||n.android.device||n.windows.device||n.other.device,n.phone=n.apple.phone||n.android.phone||n.windows.phone,n.tablet=n.apple.tablet||n.android.tablet||n.windows.tablet,n}const P=(C.default??C)(globalThis.navigator);var M=r(4025);const E=class t{constructor(t,e=P){this._mobileInfo=e,this.debug=!1,this._activateOnTab=!0,this._deactivateOnMouseMove=!0,this._isActive=!1,this._isMobileAccessibility=!1,this._div=null,this._pool=[],this._renderId=0,this._children=[],this._androidUpdateCount=0,this._androidUpdateFrequency=500,this._hookDiv=null,(e.tablet||e.phone)&&this._createTouchHook(),this._renderer=t}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}get hookDiv(){return this._hookDiv}_createTouchHook(){const t=document.createElement("button");t.style.width="1px",t.style.height="1px",t.style.position="absolute",t.style.top="-1000px",t.style.left="-1000px",t.style.zIndex=2..toString(),t.style.backgroundColor="#FF0000",t.title="select to enable accessibility for this content",t.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this._activate(),this._destroyTouchHook()}),document.body.appendChild(t),this._hookDiv=t}_destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}_activate(){if(this._isActive)return;this._isActive=!0,this._div||(this._div=document.createElement("div"),this._div.style.position="absolute",this._div.style.top="0px",this._div.style.left="0px",this._div.style.pointerEvents="none",this._div.style.zIndex=2..toString(),this._canvasObserver=new a({domElement:this._div,renderer:this._renderer})),this._activateOnTab&&(this._onKeyDown=this._onKeyDown.bind(this),globalThis.addEventListener("keydown",this._onKeyDown,!1)),this._deactivateOnMouseMove&&(this._onMouseMove=this._onMouseMove.bind(this),globalThis.document.addEventListener("mousemove",this._onMouseMove,!0));const t=this._renderer.view.canvas;if(t.parentNode)this._canvasObserver.ensureAttached(),this._initAccessibilitySetup();else{const e=new MutationObserver(()=>{t.parentNode&&(e.disconnect(),this._canvasObserver.ensureAttached(),this._initAccessibilitySetup())});e.observe(document.body,{childList:!0,subtree:!0})}}_initAccessibilitySetup(){this._renderer.runners.postrender.add(this),this._renderer.lastObjectRendered&&this._updateAccessibleObjects(this._renderer.lastObjectRendered)}_deactivate(){if(this._isActive&&!this._isMobileAccessibility){this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),this._activateOnTab&&globalThis.addEventListener("keydown",this._onKeyDown,!1),this._renderer.runners.postrender.remove(this);for(const t of this._children)t._accessibleDiv&&t._accessibleDiv.parentNode&&(t._accessibleDiv.parentNode.removeChild(t._accessibleDiv),t._accessibleDiv=null),t._accessibleActive=!1;this._pool.forEach(t=>{t.parentNode&&t.parentNode.removeChild(t)}),this._div&&this._div.parentNode&&this._div.parentNode.removeChild(this._div),this._pool=[],this._children=[]}}_updateAccessibleObjects(t){if(!t.visible||!t.accessibleChildren)return;t.accessible&&(t._accessibleActive||this._addChild(t),t._renderId=this._renderId);const e=t.children;if(e)for(let t=0;t<e.length;t++)this._updateAccessibleObjects(e[t])}init(e){const r={accessibilityOptions:{...t.defaultOptions,...e?.accessibilityOptions||{}}};this.debug=r.accessibilityOptions.debug,this._activateOnTab=r.accessibilityOptions.activateOnTab,this._deactivateOnMouseMove=r.accessibilityOptions.deactivateOnMouseMove,r.accessibilityOptions.enabledByDefault?this._activate():this._activateOnTab&&(this._onKeyDown=this._onKeyDown.bind(this),globalThis.addEventListener("keydown",this._onKeyDown,!1)),this._renderer.runners.postrender.remove(this)}postrender(){const t=performance.now();if(this._mobileInfo.android.device&&t<this._androidUpdateCount)return;if(this._androidUpdateCount=t+this._androidUpdateFrequency,!this._renderer.renderingToScreen||!this._renderer.view.canvas)return;const e=new Set;if(this._renderer.lastObjectRendered){this._updateAccessibleObjects(this._renderer.lastObjectRendered);for(const t of this._children)t._renderId===this._renderId&&e.add(this._children.indexOf(t))}for(let t=this._children.length-1;t>=0;t--){const r=this._children[t];e.has(t)||(r._accessibleDiv&&r._accessibleDiv.parentNode&&(r._accessibleDiv.parentNode.removeChild(r._accessibleDiv),this._pool.push(r._accessibleDiv),r._accessibleDiv=null),r._accessibleActive=!1,(0,M.d)(this._children,t,1))}this._renderer.renderingToScreen&&this._canvasObserver.ensureAttached();for(let t=0;t<this._children.length;t++){const e=this._children[t];if(!e._accessibleActive||!e._accessibleDiv)continue;const r=e._accessibleDiv,s=e.hitArea||e.getBounds().rectangle;if(e.hitArea){const t=e.worldTransform;r.style.left=`${t.tx+s.x*t.a}px`,r.style.top=`${t.ty+s.y*t.d}px`,r.style.width=s.width*t.a+"px",r.style.height=s.height*t.d+"px"}else this._capHitArea(s),r.style.left=`${s.x}px`,r.style.top=`${s.y}px`,r.style.width=`${s.width}px`,r.style.height=`${s.height}px`}this._renderId++}_updateDebugHTML(t){t.innerHTML=`type: ${t.type}</br> title : ${t.title}</br> tabIndex: ${t.tabIndex}`}_capHitArea(t){t.x<0&&(t.width+=t.x,t.x=0),t.y<0&&(t.height+=t.y,t.y=0);const{width:e,height:r}=this._renderer;t.x+t.width>e&&(t.width=e-t.x),t.y+t.height>r&&(t.height=r-t.y)}_addChild(t){let e=this._pool.pop();e||("button"===t.accessibleType?e=document.createElement("button"):(e=document.createElement(t.accessibleType),e.style.cssText="\n color: transparent;\n pointer-events: none;\n padding: 0;\n margin: 0;\n border: 0;\n outline: 0;\n background: transparent;\n box-sizing: border-box;\n user-select: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n ",t.accessibleText&&(e.innerText=t.accessibleText)),e.style.width="100px",e.style.height="100px",e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=2..toString(),e.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?e.setAttribute("aria-live","off"):e.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?e.setAttribute("aria-relevant","additions"):e.setAttribute("aria-relevant","text"),e.addEventListener("click",this._onClick.bind(this)),e.addEventListener("focus",this._onFocus.bind(this)),e.addEventListener("focusout",this._onFocusOut.bind(this))),e.style.pointerEvents=t.accessiblePointerEvents,e.type=t.accessibleType,t.accessibleTitle&&null!==t.accessibleTitle?e.title=t.accessibleTitle:t.accessibleHint&&null!==t.accessibleHint||(e.title=`container ${t.tabIndex}`),t.accessibleHint&&null!==t.accessibleHint&&e.setAttribute("aria-label",t.accessibleHint),t.interactive?e.tabIndex=t.tabIndex:e.tabIndex=0,this.debug&&this._updateDebugHTML(e),t._accessibleActive=!0,t._accessibleDiv=e,e.container=t,this._children.push(t),this._div.appendChild(t._accessibleDiv)}_dispatchEvent(t,e){const{container:r}=t.target,s=this._renderer.events.rootBoundary,i=Object.assign(new h(s),{target:r});s.rootTarget=this._renderer.lastObjectRendered,e.forEach(t=>s.dispatchEvent(i,t))}_onClick(t){this._dispatchEvent(t,["click","pointertap","tap"])}_onFocus(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","assertive"),this._dispatchEvent(t,["mouseover"])}_onFocusOut(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","polite"),this._dispatchEvent(t,["mouseout"])}_onKeyDown(t){9===t.keyCode&&this._activateOnTab&&this._activate()}_onMouseMove(t){0===t.movementX&&0===t.movementY||this._deactivate()}destroy(){this._deactivate(),this._destroyTouchHook(),this._canvasObserver?.destroy(),this._canvasObserver=null,this._div=null,this._pool=null,this._children=null,this._renderer=null,this._activateOnTab&&globalThis.removeEventListener("keydown",this._onKeyDown)}setAccessibilityEnabled(t){t?this._activate():this._deactivate()}};E.extension={type:[s.Ag.WebGLSystem,s.Ag.WebGPUSystem],name:"accessibility"},E.defaultOptions={enabledByDefault:!1,debug:!1,activateOnTab:!0,deactivateOnMouseMove:!0};let R=E;s.XO.add(R),s.XO.mixin(i.mc,{accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,accessibleType:"button",accessibleText:null,accessiblePointerEvents:"auto",accessibleChildren:!0,_accessibleActive:!1,_accessibleDiv:null,_renderId:-1}),r(3046);var k=r(4872),B=r(7694);const I=new class{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}init(t){this.removeTickerListener(),this.events=t,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(t){this._pauseUpdate=t}addTickerListener(){!this._tickerAdded&&this.domElement&&(o.R.system.add(this._tickerUpdate,this,n.d.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&(o.R.system.remove(this._tickerUpdate,this),this._tickerAdded=!1)}pointerMoved(){this._didMove=!0}_update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove)return void(this._didMove=!1);const t=this.events._rootPointerEvent;this.events.supportsTouchEvents&&"touch"===t.pointerType||globalThis.document.dispatchEvent(this.events.supportsPointerEvents?new PointerEvent("pointermove",{clientX:t.clientX,clientY:t.clientY,pointerType:t.pointerType,pointerId:t.pointerId}):new MouseEvent("mousemove",{clientX:t.clientX,clientY:t.clientY}))}_tickerUpdate(t){this._deltaTime+=t.deltaTime,this._deltaTime<this.interactionFrequency||(this._deltaTime=0,this._update())}destroy(){this.removeTickerListener(),this.events=null,this.domElement=null,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}};class G extends h{constructor(){super(...arguments),this.client=new l.b,this.movement=new l.b,this.offset=new l.b,this.global=new l.b,this.screen=new l.b}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(t,e,r){return t.worldTransform.applyInverse(r||this.global,e)}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,r,s,i,n,o,a,l,h,c,u,d,p,f){throw new Error("Method not implemented.")}}class F extends G{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return"pointermove"===this.type||"mousemove"===this.type||"touchmove"===this.type?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class O extends G{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}O.DOM_DELTA_PIXEL=0,O.DOM_DELTA_LINE=1,O.DOM_DELTA_PAGE=2;const D=new l.b,U=new l.b;class L{constructor(t){this.dispatch=new k.A,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=t,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.mappingTable={},this.addEventMapping("pointerdown",this.mapPointerDown),this.addEventMapping("pointermove",this.mapPointerMove),this.addEventMapping("pointerout",this.mapPointerOut),this.addEventMapping("pointerleave",this.mapPointerOut),this.addEventMapping("pointerover",this.mapPointerOver),this.addEventMapping("pointerup",this.mapPointerUp),this.addEventMapping("pointerupoutside",this.mapPointerUpOutside),this.addEventMapping("wheel",this.mapWheel)}addEventMapping(t,e){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:e,priority:0}),this.mappingTable[t].sort((t,e)=>t.priority-e.priority)}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(t,e),this.dispatch.emit(e||t.type,t)}mapEvent(t){if(!this.rootTarget)return;const e=this.mappingTable[t.type];if(e)for(let r=0,s=e.length;r<s;r++)e[r].fn(t);else(0,B.R)(`[EventBoundary]: Event mapping not defined for ${t.type}`)}hitTest(t,e){I.pauseUpdate=!0;const r=this[this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive"](this.rootTarget,this.rootTarget.eventMode,D.set(t,e),this.hitTestFn,this.hitPruneFn);return r&&r[0]}propagate(t,e){if(!t.target)return;const r=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let s=0,i=r.length-1;s<i;s++)if(t.currentTarget=r[s],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return;if(t.eventPhase=t.AT_TARGET,t.currentTarget=t.target,this.notifyTarget(t,e),!t.propagationStopped&&!t.propagationImmediatelyStopped){t.eventPhase=t.BUBBLING_PHASE;for(let s=r.length-2;s>=0;s--)if(t.currentTarget=r[s],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,r=this._allInteractiveElements){if(0===r.length)return;t.eventPhase=t.BUBBLING_PHASE;const s=Array.isArray(e)?e:[e];for(let e=r.length-1;e>=0;e--)s.forEach(s=>{t.currentTarget=r[e],this.notifyTarget(t,s)})}propagationPath(t){const e=[t];for(let r=0;r<2048&&t!==this.rootTarget&&t.parent;r++){if(!t.parent)throw new Error("Cannot find propagation path to disconnected target");e.push(t.parent),t=t.parent}return e.reverse(),e}hitTestMoveRecursive(t,e,r,s,i,n=!1){let o=!1;if(this._interactivePrune(t))return null;if("dynamic"!==t.eventMode&&"dynamic"!==e||(I.pauseUpdate=!1),t.interactiveChildren&&t.children){const a=t.children;for(let l=a.length-1;l>=0;l--){const h=a[l],c=this.hitTestMoveRecursive(h,this._isInteractive(e)?e:h.eventMode,r,s,i,n||i(t,r));if(c){if(c.length>0&&!c[c.length-1].parent)continue;const e=t.isInteractive();(c.length>0||e)&&(e&&this._allInteractiveElements.push(t),c.push(t)),0===this._hitElements.length&&(this._hitElements=c),o=!0}}}const a=this._isInteractive(e),l=t.isInteractive();return l&&l&&this._allInteractiveElements.push(t),n||this._hitElements.length>0?null:o?this._hitElements:a&&!i(t,r)&&s(t,r)?l?[t]:[]:null}hitTestRecursive(t,e,r,s,i){if(this._interactivePrune(t)||i(t,r))return null;if("dynamic"!==t.eventMode&&"dynamic"!==e||(I.pauseUpdate=!1),t.interactiveChildren&&t.children){const n=t.children,o=r;for(let r=n.length-1;r>=0;r--){const a=n[r],l=this.hitTestRecursive(a,this._isInteractive(e)?e:a.eventMode,o,s,i);if(l){if(l.length>0&&!l[l.length-1].parent)continue;const e=t.isInteractive();return(l.length>0||e)&&l.push(t),l}}}const n=this._isInteractive(e),o=t.isInteractive();return n&&s(t,r)?o?[t]:[]:null}_isInteractive(t){return"static"===t||"dynamic"===t}_interactivePrune(t){return!(t&&t.visible&&t.renderable&&t.measurable)||"none"===t.eventMode||"passive"===t.eventMode&&!t.interactiveChildren}hitPruneFn(t,e){if(t.hitArea&&(t.worldTransform.applyInverse(e,U),!t.hitArea.contains(U.x,U.y)))return!0;if(t.effects&&t.effects.length)for(let r=0;r<t.effects.length;r++){const s=t.effects[r];if(s.containsPoint&&!s.containsPoint(e,this.hitTestFn))return!0}return!1}hitTestFn(t,e){return!!t.hitArea||!!t?.containsPoint&&(t.worldTransform.applyInverse(e,U),t.containsPoint(U))}notifyTarget(t,e){if(!t.currentTarget.isInteractive())return;e??(e=t.type);const r=`on${e}`;t.currentTarget[r]?.(t);const s=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this._notifyListeners(t,s),t.eventPhase===t.AT_TARGET&&this._notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof F))return void(0,B.R)("EventBoundary cannot map a non-pointer event as a pointer event");const e=this.createPointerEvent(t);if(this.dispatchEvent(e,"pointerdown"),"touch"===e.pointerType)this.dispatchEvent(e,"touchstart");else if("mouse"===e.pointerType||"pen"===e.pointerType){const t=2===e.button;this.dispatchEvent(e,t?"rightdown":"mousedown")}this.trackingData(t.pointerId).pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){if(!(t instanceof F))return void(0,B.R)("EventBoundary cannot map a non-pointer event as a pointer event");this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const e=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const r="mouse"===e.pointerType||"pen"===e.pointerType,s=this.trackingData(t.pointerId),i=this.findMountedTarget(s.overTargets);if(s.overTargets?.length>0&&i!==e.target){const s="mousemove"===t.type?"mouseout":"pointerout",n=this.createPointerEvent(t,s,i);if(this.dispatchEvent(n,"pointerout"),r&&this.dispatchEvent(n,"mouseout"),!e.composedPath().includes(i)){const s=this.createPointerEvent(t,"pointerleave",i);for(s.eventPhase=s.AT_TARGET;s.target&&!e.composedPath().includes(s.target);)s.currentTarget=s.target,this.notifyTarget(s),r&&this.notifyTarget(s,"mouseleave"),s.target=s.target.parent;this.freeEvent(s)}this.freeEvent(n)}if(i!==e.target){const s="mousemove"===t.type?"mouseover":"pointerover",n=this.clonePointerEvent(e,s);this.dispatchEvent(n,"pointerover"),r&&this.dispatchEvent(n,"mouseover");let o=i?.parent;for(;o&&o!==this.rootTarget.parent&&o!==e.target;)o=o.parent;if(!o||o===this.rootTarget.parent){const t=this.clonePointerEvent(e,"pointerenter");for(t.eventPhase=t.AT_TARGET;t.target&&t.target!==i&&t.target!==this.rootTarget.parent;)t.currentTarget=t.target,this.notifyTarget(t),r&&this.notifyTarget(t,"mouseenter"),t.target=t.target.parent;this.freeEvent(t)}this.freeEvent(n)}const n=[],o=this.enableGlobalMoveEvents??!0;this.moveOnAll?n.push("pointermove"):this.dispatchEvent(e,"pointermove"),o&&n.push("globalpointermove"),"touch"===e.pointerType&&(this.moveOnAll?n.splice(1,0,"touchmove"):this.dispatchEvent(e,"touchmove"),o&&n.push("globaltouchmove")),r&&(this.moveOnAll?n.splice(1,0,"mousemove"):this.dispatchEvent(e,"mousemove"),o&&n.push("globalmousemove"),this.cursor=e.target?.cursor),n.length>0&&this.all(e,n),this._allInteractiveElements.length=0,this._hitElements.length=0,s.overTargets=e.composedPath(),this.freeEvent(e)}mapPointerOver(t){if(!(t instanceof F))return void(0,B.R)("EventBoundary cannot map a non-pointer event as a pointer event");const e=this.trackingData(t.pointerId),r=this.createPointerEvent(t),s="mouse"===r.pointerType||"pen"===r.pointerType;this.dispatchEvent(r,"pointerover"),s&&this.dispatchEvent(r,"mouseover"),"mouse"===r.pointerType&&(this.cursor=r.target?.cursor);const i=this.clonePointerEvent(r,"pointerenter");for(i.eventPhase=i.AT_TARGET;i.target&&i.target!==this.rootTarget.parent;)i.currentTarget=i.target,this.notifyTarget(i),s&&this.notifyTarget(i,"mouseenter"),i.target=i.target.parent;e.overTargets=r.composedPath(),this.freeEvent(r),this.freeEvent(i)}mapPointerOut(t){if(!(t instanceof F))return void(0,B.R)("EventBoundary cannot map a non-pointer event as a pointer event");const e=this.trackingData(t.pointerId);if(e.overTargets){const r="mouse"===t.pointerType||"pen"===t.pointerType,s=this.findMountedTarget(e.overTargets),i=this.createPointerEvent(t,"pointerout",s);this.dispatchEvent(i),r&&this.dispatchEvent(i,"mouseout");const n=this.createPointerEvent(t,"pointerleave",s);for(n.eventPhase=n.AT_TARGET;n.target&&n.target!==this.rootTarget.parent;)n.currentTarget=n.target,this.notifyTarget(n),r&&this.notifyTarget(n,"mouseleave"),n.target=n.target.parent;e.overTargets=null,this.freeEvent(i),this.freeEvent(n)}this.cursor=null}mapPointerUp(t){if(!(t instanceof F))return void(0,B.R)("EventBoundary cannot map a non-pointer event as a pointer event");const e=performance.now(),r=this.createPointerEvent(t);if(this.dispatchEvent(r,"pointerup"),"touch"===r.pointerType)this.dispatchEvent(r,"touchend");else if("mouse"===r.pointerType||"pen"===r.pointerType){const t=2===r.button;this.dispatchEvent(r,t?"rightup":"mouseup")}const s=this.trackingData(t.pointerId),i=this.findMountedTarget(s.pressTargetsByButton[t.button]);let n=i;if(i&&!r.composedPath().includes(i)){let e=i;for(;e&&!r.composedPath().includes(e);){if(r.currentTarget=e,this.notifyTarget(r,"pointerupoutside"),"touch"===r.pointerType)this.notifyTarget(r,"touchendoutside");else if("mouse"===r.pointerType||"pen"===r.pointerType){const t=2===r.button;this.notifyTarget(r,t?"rightupoutside":"mouseupoutside")}e=e.parent}delete s.pressTargetsByButton[t.button],n=e}if(n){const i=this.clonePointerEvent(r,"click");i.target=n,i.path=null,s.clicksByButton[t.button]||(s.clicksByButton[t.button]={clickCount:0,target:i.target,timeStamp:e});const o=s.clicksByButton[t.button];if(o.target===i.target&&e-o.timeStamp<200?++o.clickCount:o.clickCount=1,o.target=i.target,o.timeStamp=e,i.detail=o.clickCount,"mouse"===i.pointerType){const t=2===i.button;this.dispatchEvent(i,t?"rightclick":"click")}else"touch"===i.pointerType&&this.dispatchEvent(i,"tap");this.dispatchEvent(i,"pointertap"),this.freeEvent(i)}this.freeEvent(r)}mapPointerUpOutside(t){if(!(t instanceof F))return void(0,B.R)("EventBoundary cannot map a non-pointer event as a pointer event");const e=this.trackingData(t.pointerId),r=this.findMountedTarget(e.pressTargetsByButton[t.button]),s=this.createPointerEvent(t);if(r){let i=r;for(;i;)s.currentTarget=i,this.notifyTarget(s,"pointerupoutside"),"touch"===s.pointerType?this.notifyTarget(s,"touchendoutside"):"mouse"!==s.pointerType&&"pen"!==s.pointerType||this.notifyTarget(s,2===s.button?"rightupoutside":"mouseupoutside"),i=i.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(s)}mapWheel(t){if(!(t instanceof O))return void(0,B.R)("EventBoundary cannot map a non-wheel event as a wheel event");const e=this.createWheelEvent(t);this.dispatchEvent(e),this.freeEvent(e)}findMountedTarget(t){if(!t)return null;let e=t[0];for(let r=1;r<t.length&&t[r].parent===e;r++)e=t[r];return e}createPointerEvent(t,e,r){const s=this.allocateEvent(F);return this.copyPointerData(t,s),this.copyMouseData(t,s),this.copyData(t,s),s.nativeEvent=t.nativeEvent,s.originalEvent=t,s.target=r??this.hitTest(s.global.x,s.global.y)??this._hitElements[0],"string"==typeof e&&(s.type=e),s}createWheelEvent(t){const e=this.allocateEvent(O);return this.copyWheelData(t,e),this.copyMouseData(t,e),this.copyData(t,e),e.nativeEvent=t.nativeEvent,e.originalEvent=t,e.target=this.hitTest(e.global.x,e.global.y),e}clonePointerEvent(t,e){const r=this.allocateEvent(F);return r.nativeEvent=t.nativeEvent,r.originalEvent=t.originalEvent,this.copyPointerData(t,r),this.copyMouseData(t,r),this.copyData(t,r),r.target=t.target,r.path=t.composedPath().slice(),r.type=e??r.type,r}copyWheelData(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ}copyPointerData(t,e){t instanceof F&&e instanceof F&&(e.pointerId=t.pointerId,e.width=t.width,e.height=t.height,e.isPrimary=t.isPrimary,e.pointerType=t.pointerType,e.pressure=t.pressure,e.tangentialPressure=t.tangentialPressure,e.tiltX=t.tiltX,e.tiltY=t.tiltY,e.twist=t.twist)}copyMouseData(t,e){t instanceof G&&e instanceof G&&(e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.copyFrom(t.client),e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.copyFrom(t.movement),e.screen.copyFrom(t.screen),e.shiftKey=t.shiftKey,e.global.copyFrom(t.global))}copyData(t,e){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.detail=t.detail,e.view=t.view,e.which=t.which,e.layer.copyFrom(t.layer),e.page.copyFrom(t.page)}trackingData(t){return this.mappingState.trackingData[t]||(this.mappingState.trackingData[t]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[t]}allocateEvent(t){this.eventPool.has(t)||this.eventPool.set(t,[]);const e=this.eventPool.get(t).pop()||new t(this);return e.eventPhase=e.NONE,e.currentTarget=null,e.defaultPrevented=!1,e.path=null,e.target=null,e}freeEvent(t){if(t.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const e=t.constructor;this.eventPool.has(e)||this.eventPool.set(e,[]),this.eventPool.get(e).push(t)}_notifyListeners(t,e){const r=t.currentTarget._events[e];if(r)if("fn"in r)r.once&&t.currentTarget.removeListener(e,r.fn,void 0,!0),r.fn.call(r.context,t);else for(let s=0,i=r.length;s<i&&!t.propagationImmediatelyStopped;s++)r[s].once&&t.currentTarget.removeListener(e,r[s].fn,void 0,!0),r[s].fn.call(r[s].context,t)}}const N={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},z=class t{constructor(e){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=e,this.rootBoundary=new L(null),I.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new F(null),this._rootWheelEvent=new O(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...t.defaultEventFeatures},{set:(t,e,r)=>("globalMove"===e&&(this.rootBoundary.enableGlobalMoveEvents=r),t[e]=r,!0)}),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onPointerOverOut=this._onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(e){const{canvas:r,resolution:s}=this.renderer;this.setTargetElement(r),this.resolution=s,t._defaultEventMode=e.eventMode??"passive",Object.assign(this.features,e.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){I.destroy(),this.setTargetElement(null),this.renderer=null,this._currentCursor=null}setCursor(t){t||(t="default");let e=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(e=!1),this._currentCursor===t)return;this._currentCursor=t;const r=this.cursorStyles[t];if(r)switch(typeof r){case"string":e&&(this.domElement.style.cursor=r);break;case"function":r(t);break;case"object":e&&Object.assign(this.domElement.style,r)}else e&&"string"==typeof t&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}get pointer(){return this._rootPointerEvent}_onPointerDown(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this._normalizeToPointerData(t);this.autoPreventDefault&&e[0].isNormalized&&(t.cancelable||!("cancelable"in t))&&t.preventDefault();for(let t=0,r=e.length;t<r;t++){const r=e[t],s=this._bootstrapEvent(this._rootPointerEvent,r);this.rootBoundary.mapEvent(s)}this.setCursor(this.rootBoundary.cursor)}_onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,I.pointerMoved();const e=this._normalizeToPointerData(t);for(let t=0,r=e.length;t<r;t++){const r=this._bootstrapEvent(this._rootPointerEvent,e[t]);this.rootBoundary.mapEvent(r)}this.setCursor(this.rootBoundary.cursor)}_onPointerUp(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let e=t.target;t.composedPath&&t.composedPath().length>0&&(e=t.composedPath()[0]);const r=e!==this.domElement?"outside":"",s=this._normalizeToPointerData(t);for(let t=0,e=s.length;t<e;t++){const e=this._bootstrapEvent(this._rootPointerEvent,s[t]);e.type+=r,this.rootBoundary.mapEvent(e)}this.setCursor(this.rootBoundary.cursor)}_onPointerOverOut(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this._normalizeToPointerData(t);for(let t=0,r=e.length;t<r;t++){const r=this._bootstrapEvent(this._rootPointerEvent,e[t]);this.rootBoundary.mapEvent(r)}this.setCursor(this.rootBoundary.cursor)}onWheel(t){if(!this.features.wheel)return;const e=this.normalizeWheelEvent(t);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(e)}setTargetElement(t){this._removeEvents(),this.domElement=t,I.domElement=t,this._addEvents()}_addEvents(){if(this._eventsAdded||!this.domElement)return;I.addTickerListener();const t=this.domElement.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="none",t.msTouchAction="none"):this.supportsPointerEvents&&(t.touchAction="none")),this.supportsPointerEvents?(globalThis.document.addEventListener("pointermove",this._onPointerMove,!0),this.domElement.addEventListener("pointerdown",this._onPointerDown,!0),this.domElement.addEventListener("pointerleave",this._onPointerOverOut,!0),this.domElement.addEventListener("pointerover",this._onPointerOverOut,!0),globalThis.addEventListener("pointerup",this._onPointerUp,!0)):(globalThis.document.addEventListener("mousemove",this._onPointerMove,!0),this.domElement.addEventListener("mousedown",this._onPointerDown,!0),this.domElement.addEventListener("mouseout",this._onPointerOverOut,!0),this.domElement.addEventListener("mouseover",this._onPointerOverOut,!0),globalThis.addEventListener("mouseup",this._onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.addEventListener("touchstart",this._onPointerDown,!0),this.domElement.addEventListener("touchend",this._onPointerUp,!0),this.domElement.addEventListener("touchmove",this._onPointerMove,!0))),this.domElement.addEventListener("wheel",this.onWheel,{passive:!0,capture:!0}),this._eventsAdded=!0}_removeEvents(){if(!this._eventsAdded||!this.domElement)return;I.removeTickerListener();const t=this.domElement.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="",t.msTouchAction=""):this.supportsPointerEvents&&(t.touchAction="")),this.supportsPointerEvents?(globalThis.document.removeEventListener("pointermove",this._onPointerMove,!0),this.domElement.removeEventListener("pointerdown",this._onPointerDown,!0),this.domElement.removeEventListener("pointerleave",this._onPointerOverOut,!0),this.domElement.removeEventListener("pointerover",this._onPointerOverOut,!0),globalThis.removeEventListener("pointerup",this._onPointerUp,!0)):(globalThis.document.removeEventListener("mousemove",this._onPointerMove,!0),this.domElement.removeEventListener("mousedown",this._onPointerDown,!0),this.domElement.removeEventListener("mouseout",this._onPointerOverOut,!0),this.domElement.removeEventListener("mouseover",this._onPointerOverOut,!0),globalThis.removeEventListener("mouseup",this._onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.removeEventListener("touchstart",this._onPointerDown,!0),this.domElement.removeEventListener("touchend",this._onPointerUp,!0),this.domElement.removeEventListener("touchmove",this._onPointerMove,!0))),this.domElement.removeEventListener("wheel",this.onWheel,!0),this.domElement=null,this._eventsAdded=!1}mapPositionToPoint(t,e,r){const s=this.domElement.isConnected?this.domElement.getBoundingClientRect():{x:0,y:0,width:this.domElement.width,height:this.domElement.height,left:0,top:0},i=1/this.resolution;t.x=(e-s.left)*(this.domElement.width/s.width)*i,t.y=(r-s.top)*(this.domElement.height/s.height)*i}_normalizeToPointerData(t){const e=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let r=0,s=t.changedTouches.length;r<s;r++){const s=t.changedTouches[r];void 0===s.button&&(s.button=0),void 0===s.buttons&&(s.buttons=1),void 0===s.isPrimary&&(s.isPrimary=1===t.touches.length&&"touchstart"===t.type),void 0===s.width&&(s.width=s.radiusX||1),void 0===s.height&&(s.height=s.radiusY||1),void 0===s.tiltX&&(s.tiltX=0),void 0===s.tiltY&&(s.tiltY=0),void 0===s.pointerType&&(s.pointerType="touch"),void 0===s.pointerId&&(s.pointerId=s.identifier||0),void 0===s.pressure&&(s.pressure=s.force||.5),void 0===s.twist&&(s.twist=0),void 0===s.tangentialPressure&&(s.tangentialPressure=0),void 0===s.layerX&&(s.layerX=s.offsetX=s.clientX),void 0===s.layerY&&(s.layerY=s.offsetY=s.clientY),s.isNormalized=!0,s.type=t.type,e.push(s)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&!(this.supportsPointerEvents&&t instanceof globalThis.PointerEvent)){const r=t;void 0===r.isPrimary&&(r.isPrimary=!0),void 0===r.width&&(r.width=1),void 0===r.height&&(r.height=1),void 0===r.tiltX&&(r.tiltX=0),void 0===r.tiltY&&(r.tiltY=0),void 0===r.pointerType&&(r.pointerType="mouse"),void 0===r.pointerId&&(r.pointerId=1),void 0===r.pressure&&(r.pressure=.5),void 0===r.twist&&(r.twist=0),void 0===r.tangentialPressure&&(r.tangentialPressure=0),r.isNormalized=!0,e.push(r)}else e.push(t);return e}normalizeWheelEvent(t){const e=this._rootWheelEvent;return this._transferMouseData(e,t),e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ,e.deltaMode=t.deltaMode,this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.nativeEvent=t,e.type=t.type,e}_bootstrapEvent(t,e){return t.originalEvent=null,t.nativeEvent=e,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,this._transferMouseData(t,e),this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.isTrusted=e.isTrusted,"pointerleave"===t.type&&(t.type="pointerout"),t.type.startsWith("mouse")&&(t.type=t.type.replace("mouse","pointer")),t.type.startsWith("touch")&&(t.type=N[t.type]||t.type),t}_transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.altKey=e.altKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.ctrlKey=e.ctrlKey,t.metaKey=e.metaKey,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.relatedTarget=null,t.shiftKey=e.shiftKey}};z.extension={name:"events",type:[s.Ag.WebGLSystem,s.Ag.CanvasSystem,s.Ag.WebGPUSystem],priority:-1},z.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let W=z;const H={onclick:null,onmousedown:null,onmouseenter:null,onmouseleave:null,onmousemove:null,onglobalmousemove:null,onmouseout:null,onmouseover:null,onmouseup:null,onmouseupoutside:null,onpointercancel:null,onpointerdown:null,onpointerenter:null,onpointerleave:null,onpointermove:null,onglobalpointermove:null,onpointerout:null,onpointerover:null,onpointertap:null,onpointerup:null,onpointerupoutside:null,onrightclick:null,onrightdown:null,onrightup:null,onrightupoutside:null,ontap:null,ontouchcancel:null,ontouchend:null,ontouchendoutside:null,ontouchmove:null,onglobaltouchmove:null,ontouchstart:null,onwheel:null,get interactive(){return"dynamic"===this.eventMode||"static"===this.eventMode},set interactive(t){this.eventMode=t?"static":"passive"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??W.defaultEventMode},set eventMode(t){this._internalEventMode=t},isInteractive(){return"static"===this.eventMode||"dynamic"===this.eventMode},interactiveChildren:!0,hitArea:null,addEventListener(t,e,r){const s="boolean"==typeof r&&r||"object"==typeof r&&r.capture,i="object"==typeof r?r.signal:void 0,n="object"==typeof r&&!0===r.once,o="function"==typeof e?void 0:e;t=s?`${t}capture`:t;const a="function"==typeof e?e:e.handleEvent,l=this;i&&i.addEventListener("abort",()=>{l.off(t,a,o)}),n?l.once(t,a,o):l.on(t,a,o)},removeEventListener(t,e,r){const s="function"==typeof e?void 0:e;t="boolean"==typeof r&&r||"object"==typeof r&&r.capture?`${t}capture`:t,e="function"==typeof e?e:e.handleEvent,this.off(t,e,s)},dispatchEvent(t){if(!(t instanceof h))throw new Error("Container cannot propagate events outside of the Federated Events API");return t.defaultPrevented=!1,t.path=null,t.target=this,t.manager.dispatchEvent(t),!t.defaultPrevented}};s.XO.add(W),s.XO.mixin(i.mc,H);class X{constructor(t){this._attachedDomElements=[],this._renderer=t,this._renderer.runners.postrender.add(this),this._renderer.runners.init.add(this),this._domElement=document.createElement("div"),this._domElement.style.position="absolute",this._domElement.style.top="0",this._domElement.style.left="0",this._domElement.style.pointerEvents="none",this._domElement.style.zIndex="1000"}init(){this._canvasObserver=new a({domElement:this._domElement,renderer:this._renderer})}addRenderable(t,e){this._attachedDomElements.includes(t)||this._attachedDomElements.push(t)}updateRenderable(t){}validateRenderable(t){return!0}postrender(){const t=this._attachedDomElements;if(0!==t.length){this._canvasObserver.ensureAttached();for(let e=0;e<t.length;e++){const r=t[e],s=r.element;if(!r.parent||r.globalDisplayStatus<7)s?.remove(),t.splice(e,1),e--;else{this._domElement.contains(s)||(s.style.position="absolute",s.style.pointerEvents="auto",this._domElement.appendChild(s));const t=r.worldTransform,e=r._anchor,i=r.width*e.x,n=r.height*e.y;s.style.transformOrigin=`${i}px ${n}px`,s.style.transform=`matrix(${t.a}, ${t.b}, ${t.c}, ${t.d}, ${t.tx-i}, ${t.ty-n})`,s.style.opacity=r.groupAlpha.toString()}}}else this._domElement.remove()}destroy(){this._renderer.runners.postrender.remove(this);for(let t=0;t<this._attachedDomElements.length;t++){const e=this._attachedDomElements[t];e.element?.remove()}this._attachedDomElements.length=0,this._domElement.remove(),this._canvasObserver.destroy(),this._renderer=null}}X.extension={type:[s.Ag.WebGLPipes,s.Ag.WebGPUPipes,s.Ag.CanvasPipes],name:"dom"},s.XO.add(X),r(2517),r(2542),r(3050),r(8427),r(6131),r(6934),r(966),r(6841),r(9797),r(4550),r(8122)},8714:function(t,e,r){var s;s=function(){return function(t){var e={};function r(s){if(e[s])return e[s].exports;var i=e[s]={i:s,l:!1,exports:{}};return t[s].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,s){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:s})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var s=Object.create(null);if(r.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(s,i,function(e){return t[e]}.bind(null,i));return s},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=20)}([function(t,e){var s={};t.exports=s,function(){s._baseDelta=1e3/60,s._nextId=0,s._seed=0,s._nowStartTime=+new Date,s._warnedOnce={},s._decomp=null,s.extend=function(t,e){var r,i;"boolean"==typeof e?(r=2,i=e):(r=1,i=!0);for(var n=r;n<arguments.length;n++){var o=arguments[n];if(o)for(var a in o)i&&o[a]&&o[a].constructor===Object?t[a]&&t[a].constructor!==Object?t[a]=o[a]:(t[a]=t[a]||{},s.extend(t[a],i,o[a])):t[a]=o[a]}return t},s.clone=function(t,e){return s.extend({},e,t)},s.keys=function(t){if(Object.keys)return Object.keys(t);var e=[];for(var r in t)e.push(r);return e},s.values=function(t){var e=[];if(Object.keys){for(var r=Object.keys(t),s=0;s<r.length;s++)e.push(t[r[s]]);return e}for(var i in t)e.push(t[i]);return e},s.get=function(t,e,r,s){e=e.split(".").slice(r,s);for(var i=0;i<e.length;i+=1)t=t[e[i]];return t},s.set=function(t,e,r,i,n){var o=e.split(".").slice(i,n);return s.get(t,e,0,-1)[o[o.length-1]]=r,r},s.shuffle=function(t){for(var e=t.length-1;e>0;e--){var r=Math.floor(s.random()*(e+1)),i=t[e];t[e]=t[r],t[r]=i}return t},s.choose=function(t){return t[Math.floor(s.random()*t.length)]},s.isElement=function(t){return"undefined"!=typeof HTMLElement?t instanceof HTMLElement:!!(t&&t.nodeType&&t.nodeName)},s.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)},s.isFunction=function(t){return"function"==typeof t},s.isPlainObject=function(t){return"object"==typeof t&&t.constructor===Object},s.isString=function(t){return"[object String]"===toString.call(t)},s.clamp=function(t,e,r){return t<e?e:t>r?r:t},s.sign=function(t){return t<0?-1:1},s.now=function(){if("undefined"!=typeof window&&window.performance){if(window.performance.now)return window.performance.now();if(window.performance.webkitNow)return window.performance.webkitNow()}return Date.now?Date.now():new Date-s._nowStartTime},s.random=function(e,r){return r=void 0!==r?r:1,(e=void 0!==e?e:0)+t()*(r-e)};var t=function(){return s._seed=(9301*s._seed+49297)%233280,s._seed/233280};s.colorToNumber=function(t){return 3==(t=t.replace("#","")).length&&(t=t.charAt(0)+t.charAt(0)+t.charAt(1)+t.charAt(1)+t.charAt(2)+t.charAt(2)),parseInt(t,16)},s.logLevel=1,s.log=function(){console&&s.logLevel>0&&s.logLevel<=3&&console.log.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},s.info=function(){console&&s.logLevel>0&&s.logLevel<=2&&console.info.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},s.warn=function(){console&&s.logLevel>0&&s.logLevel<=3&&console.warn.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},s.warnOnce=function(){var t=Array.prototype.slice.call(arguments).join(" ");s._warnedOnce[t]||(s.warn(t),s._warnedOnce[t]=!0)},s.deprecated=function(t,e,r){t[e]=s.chain(function(){s.warnOnce("🔅 deprecated 🔅",r)},t[e])},s.nextId=function(){return s._nextId++},s.indexOf=function(t,e){if(t.indexOf)return t.indexOf(e);for(var r=0;r<t.length;r++)if(t[r]===e)return r;return-1},s.map=function(t,e){if(t.map)return t.map(e);for(var r=[],s=0;s<t.length;s+=1)r.push(e(t[s]));return r},s.topologicalSort=function(t){var e=[],r=[],i=[];for(var n in t)r[n]||i[n]||s._topologicalSort(n,r,i,t,e);return e},s._topologicalSort=function(t,e,r,i,n){var o=i[t]||[];r[t]=!0;for(var a=0;a<o.length;a+=1){var l=o[a];r[l]||e[l]||s._topologicalSort(l,e,r,i,n)}r[t]=!1,e[t]=!0,n.push(t)},s.chain=function(){for(var t=[],e=0;e<arguments.length;e+=1){var r=arguments[e];r._chained?t.push.apply(t,r._chained):t.push(r)}var s=function(){for(var e,r=new Array(arguments.length),s=0,i=arguments.length;s<i;s++)r[s]=arguments[s];for(s=0;s<t.length;s+=1){var n=t[s].apply(e,r);void 0!==n&&(e=n)}return e};return s._chained=t,s},s.chainPathBefore=function(t,e,r){return s.set(t,e,s.chain(r,s.get(t,e)))},s.chainPathAfter=function(t,e,r){return s.set(t,e,s.chain(s.get(t,e),r))},s.setDecomp=function(t){s._decomp=t},s.getDecomp=function(){var t=s._decomp;try{t||"undefined"==typeof window||(t=window.decomp),t||void 0===r.g||(t=r.g.decomp)}catch(e){t=null}return t}}()},function(t,e){var r={};t.exports=r,r.create=function(t){var e={min:{x:0,y:0},max:{x:0,y:0}};return t&&r.update(e,t),e},r.update=function(t,e,r){t.min.x=1/0,t.max.x=-1/0,t.min.y=1/0,t.max.y=-1/0;for(var s=0;s<e.length;s++){var i=e[s];i.x>t.max.x&&(t.max.x=i.x),i.x<t.min.x&&(t.min.x=i.x),i.y>t.max.y&&(t.max.y=i.y),i.y<t.min.y&&(t.min.y=i.y)}r&&(r.x>0?t.max.x+=r.x:t.min.x+=r.x,r.y>0?t.max.y+=r.y:t.min.y+=r.y)},r.contains=function(t,e){return e.x>=t.min.x&&e.x<=t.max.x&&e.y>=t.min.y&&e.y<=t.max.y},r.overlaps=function(t,e){return t.min.x<=e.max.x&&t.max.x>=e.min.x&&t.max.y>=e.min.y&&t.min.y<=e.max.y},r.translate=function(t,e){t.min.x+=e.x,t.max.x+=e.x,t.min.y+=e.y,t.max.y+=e.y},r.shift=function(t,e){var r=t.max.x-t.min.x,s=t.max.y-t.min.y;t.min.x=e.x,t.max.x=e.x+r,t.min.y=e.y,t.max.y=e.y+s}},function(t,e){var r={};t.exports=r,r.create=function(t,e){return{x:t||0,y:e||0}},r.clone=function(t){return{x:t.x,y:t.y}},r.magnitude=function(t){return Math.sqrt(t.x*t.x+t.y*t.y)},r.magnitudeSquared=function(t){return t.x*t.x+t.y*t.y},r.rotate=function(t,e,r){var s=Math.cos(e),i=Math.sin(e);r||(r={});var n=t.x*s-t.y*i;return r.y=t.x*i+t.y*s,r.x=n,r},r.rotateAbout=function(t,e,r,s){var i=Math.cos(e),n=Math.sin(e);s||(s={});var o=r.x+((t.x-r.x)*i-(t.y-r.y)*n);return s.y=r.y+((t.x-r.x)*n+(t.y-r.y)*i),s.x=o,s},r.normalise=function(t){var e=r.magnitude(t);return 0===e?{x:0,y:0}:{x:t.x/e,y:t.y/e}},r.dot=function(t,e){return t.x*e.x+t.y*e.y},r.cross=function(t,e){return t.x*e.y-t.y*e.x},r.cross3=function(t,e,r){return(e.x-t.x)*(r.y-t.y)-(e.y-t.y)*(r.x-t.x)},r.add=function(t,e,r){return r||(r={}),r.x=t.x+e.x,r.y=t.y+e.y,r},r.sub=function(t,e,r){return r||(r={}),r.x=t.x-e.x,r.y=t.y-e.y,r},r.mult=function(t,e){return{x:t.x*e,y:t.y*e}},r.div=function(t,e){return{x:t.x/e,y:t.y/e}},r.perp=function(t,e){return{x:(e=!0===e?-1:1)*-t.y,y:e*t.x}},r.neg=function(t){return{x:-t.x,y:-t.y}},r.angle=function(t,e){return Math.atan2(e.y-t.y,e.x-t.x)},r._temp=[r.create(),r.create(),r.create(),r.create(),r.create(),r.create()]},function(t,e,r){var s={};t.exports=s;var i=r(2),n=r(0);s.create=function(t,e){for(var r=[],s=0;s<t.length;s++){var i=t[s],n={x:i.x,y:i.y,index:s,body:e,isInternal:!1};r.push(n)}return r},s.fromPath=function(t,e){var r=[];return t.replace(/L?\s*([-\d.e]+)[\s,]*([-\d.e]+)*/gi,function(t,e,s){r.push({x:parseFloat(e),y:parseFloat(s)})}),s.create(r,e)},s.centre=function(t){for(var e,r,n,o=s.area(t,!0),a={x:0,y:0},l=0;l<t.length;l++)n=(l+1)%t.length,e=i.cross(t[l],t[n]),r=i.mult(i.add(t[l],t[n]),e),a=i.add(a,r);return i.div(a,6*o)},s.mean=function(t){for(var e={x:0,y:0},r=0;r<t.length;r++)e.x+=t[r].x,e.y+=t[r].y;return i.div(e,t.length)},s.area=function(t,e){for(var r=0,s=t.length-1,i=0;i<t.length;i++)r+=(t[s].x-t[i].x)*(t[s].y+t[i].y),s=i;return e?r/2:Math.abs(r)/2},s.inertia=function(t,e){for(var r,s,n=0,o=0,a=t,l=0;l<a.length;l++)s=(l+1)%a.length,n+=(r=Math.abs(i.cross(a[s],a[l])))*(i.dot(a[s],a[s])+i.dot(a[s],a[l])+i.dot(a[l],a[l])),o+=r;return e/6*(n/o)},s.translate=function(t,e,r){r=void 0!==r?r:1;var s,i=t.length,n=e.x*r,o=e.y*r;for(s=0;s<i;s++)t[s].x+=n,t[s].y+=o;return t},s.rotate=function(t,e,r){if(0!==e){var s,i,n,o,a=Math.cos(e),l=Math.sin(e),h=r.x,c=r.y,u=t.length;for(o=0;o<u;o++)i=(s=t[o]).x-h,n=s.y-c,s.x=h+(i*a-n*l),s.y=c+(i*l+n*a);return t}},s.contains=function(t,e){for(var r,s=e.x,i=e.y,n=t.length,o=t[n-1],a=0;a<n;a++){if(r=t[a],(s-o.x)*(r.y-o.y)+(i-o.y)*(o.x-r.x)>0)return!1;o=r}return!0},s.scale=function(t,e,r,n){if(1===e&&1===r)return t;var o,a;n=n||s.centre(t);for(var l=0;l<t.length;l++)o=t[l],a=i.sub(o,n),t[l].x=n.x+a.x*e,t[l].y=n.y+a.y*r;return t},s.chamfer=function(t,e,r,s,o){e="number"==typeof e?[e]:e||[8],r=void 0!==r?r:-1,s=s||2,o=o||14;for(var a=[],l=0;l<t.length;l++){var h=t[l-1>=0?l-1:t.length-1],c=t[l],u=t[(l+1)%t.length],d=e[l<e.length?l:e.length-1];if(0!==d){var p=i.normalise({x:c.y-h.y,y:h.x-c.x}),f=i.normalise({x:u.y-c.y,y:c.x-u.x}),g=Math.sqrt(2*Math.pow(d,2)),m=i.mult(n.clone(p),d),x=i.normalise(i.mult(i.add(p,f),.5)),_=i.sub(c,i.mult(x,g)),y=r;-1===r&&(y=1.75*Math.pow(d,.32)),(y=n.clamp(y,s,o))%2==1&&(y+=1);for(var v=Math.acos(i.dot(p,f))/y,b=0;b<y;b++)a.push(i.add(i.rotate(m,v*b),_))}else a.push(c)}return a},s.clockwiseSort=function(t){var e=s.mean(t);return t.sort(function(t,r){return i.angle(e,t)-i.angle(e,r)}),t},s.isConvex=function(t){var e,r,s,i,n=0,o=t.length;if(o<3)return null;for(e=0;e<o;e++)if(s=(e+2)%o,i=(t[r=(e+1)%o].x-t[e].x)*(t[s].y-t[r].y),(i-=(t[r].y-t[e].y)*(t[s].x-t[r].x))<0?n|=1:i>0&&(n|=2),3===n)return!1;return 0!==n||null},s.hull=function(t){var e,r,s=[],n=[];for((t=t.slice(0)).sort(function(t,e){var r=t.x-e.x;return 0!==r?r:t.y-e.y}),r=0;r<t.length;r+=1){for(e=t[r];n.length>=2&&i.cross3(n[n.length-2],n[n.length-1],e)<=0;)n.pop();n.push(e)}for(r=t.length-1;r>=0;r-=1){for(e=t[r];s.length>=2&&i.cross3(s[s.length-2],s[s.length-1],e)<=0;)s.pop();s.push(e)}return s.pop(),n.pop(),s.concat(n)}},function(t,e,r){var s={};t.exports=s;var i=r(3),n=r(2),o=r(7),a=r(0),l=r(1),h=r(11);!function(){s._timeCorrection=!0,s._inertiaScale=4,s._nextCollidingGroupId=1,s._nextNonCollidingGroupId=-1,s._nextCategory=1,s._baseDelta=1e3/60,s.create=function(e){var r={id:a.nextId(),type:"body",label:"Body",parts:[],plugin:{},angle:0,vertices:i.fromPath("L 0 0 L 40 0 L 40 40 L 0 40"),position:{x:0,y:0},force:{x:0,y:0},torque:0,positionImpulse:{x:0,y:0},constraintImpulse:{x:0,y:0,angle:0},totalContacts:0,speed:0,angularSpeed:0,velocity:{x:0,y:0},angularVelocity:0,isSensor:!1,isStatic:!1,isSleeping:!1,motion:0,sleepThreshold:60,density:.001,restitution:0,friction:.1,frictionStatic:.5,frictionAir:.01,collisionFilter:{category:1,mask:4294967295,group:0},slop:.05,timeScale:1,render:{visible:!0,opacity:1,strokeStyle:null,fillStyle:null,lineWidth:null,sprite:{xScale:1,yScale:1,xOffset:0,yOffset:0}},events:null,bounds:null,chamfer:null,circleRadius:0,positionPrev:null,anglePrev:0,parent:null,axes:null,area:0,mass:0,inertia:0,deltaTime:1e3/60,_original:null},s=a.extend(r,e);return t(s,e),s},s.nextGroup=function(t){return t?s._nextNonCollidingGroupId--:s._nextCollidingGroupId++},s.nextCategory=function(){return s._nextCategory=s._nextCategory<<1,s._nextCategory};var t=function(t,e){e=e||{},s.set(t,{bounds:t.bounds||l.create(t.vertices),positionPrev:t.positionPrev||n.clone(t.position),anglePrev:t.anglePrev||t.angle,vertices:t.vertices,parts:t.parts||[t],isStatic:t.isStatic,isSleeping:t.isSleeping,parent:t.parent||t}),i.rotate(t.vertices,t.angle,t.position),h.rotate(t.axes,t.angle),l.update(t.bounds,t.vertices,t.velocity),s.set(t,{axes:e.axes||t.axes,area:e.area||t.area,mass:e.mass||t.mass,inertia:e.inertia||t.inertia});var r=t.isStatic?"#14151f":a.choose(["#f19648","#f5d259","#f55a3c","#063e7b","#ececd1"]),o=t.isStatic?"#555":"#ccc",c=t.isStatic&&null===t.render.fillStyle?1:0;t.render.fillStyle=t.render.fillStyle||r,t.render.strokeStyle=t.render.strokeStyle||o,t.render.lineWidth=t.render.lineWidth||c,t.render.sprite.xOffset+=-(t.bounds.min.x-t.position.x)/(t.bounds.max.x-t.bounds.min.x),t.render.sprite.yOffset+=-(t.bounds.min.y-t.position.y)/(t.bounds.max.y-t.bounds.min.y)};s.set=function(t,e,r){var i;for(i in"string"==typeof e&&(i=e,(e={})[i]=r),e)if(Object.prototype.hasOwnProperty.call(e,i))switch(r=e[i],i){case"isStatic":s.setStatic(t,r);break;case"isSleeping":o.set(t,r);break;case"mass":s.setMass(t,r);break;case"density":s.setDensity(t,r);break;case"inertia":s.setInertia(t,r);break;case"vertices":s.setVertices(t,r);break;case"position":s.setPosition(t,r);break;case"angle":s.setAngle(t,r);break;case"velocity":s.setVelocity(t,r);break;case"angularVelocity":s.setAngularVelocity(t,r);break;case"speed":s.setSpeed(t,r);break;case"angularSpeed":s.setAngularSpeed(t,r);break;case"parts":s.setParts(t,r);break;case"centre":s.setCentre(t,r);break;default:t[i]=r}},s.setStatic=function(t,e){for(var r=0;r<t.parts.length;r++){var s=t.parts[r];e?(s.isStatic||(s._original={restitution:s.restitution,friction:s.friction,mass:s.mass,inertia:s.inertia,density:s.density,inverseMass:s.inverseMass,inverseInertia:s.inverseInertia}),s.restitution=0,s.friction=1,s.mass=s.inertia=s.density=1/0,s.inverseMass=s.inverseInertia=0,s.positionPrev.x=s.position.x,s.positionPrev.y=s.position.y,s.anglePrev=s.angle,s.angularVelocity=0,s.speed=0,s.angularSpeed=0,s.motion=0):s._original&&(s.restitution=s._original.restitution,s.friction=s._original.friction,s.mass=s._original.mass,s.inertia=s._original.inertia,s.density=s._original.density,s.inverseMass=s._original.inverseMass,s.inverseInertia=s._original.inverseInertia,s._original=null),s.isStatic=e}},s.setMass=function(t,e){var r=t.inertia/(t.mass/6);t.inertia=r*(e/6),t.inverseInertia=1/t.inertia,t.mass=e,t.inverseMass=1/t.mass,t.density=t.mass/t.area},s.setDensity=function(t,e){s.setMass(t,e*t.area),t.density=e},s.setInertia=function(t,e){t.inertia=e,t.inverseInertia=1/t.inertia},s.setVertices=function(t,e){e[0].body===t?t.vertices=e:t.vertices=i.create(e,t),t.axes=h.fromVertices(t.vertices),t.area=i.area(t.vertices),s.setMass(t,t.density*t.area);var r=i.centre(t.vertices);i.translate(t.vertices,r,-1),s.setInertia(t,s._inertiaScale*i.inertia(t.vertices,t.mass)),i.translate(t.vertices,t.position),l.update(t.bounds,t.vertices,t.velocity)},s.setParts=function(t,e,r){var n;for(e=e.slice(0),t.parts.length=0,t.parts.push(t),t.parent=t,n=0;n<e.length;n++){var o=e[n];o!==t&&(o.parent=t,t.parts.push(o))}if(1!==t.parts.length){if(r=void 0===r||r){var a=[];for(n=0;n<e.length;n++)a=a.concat(e[n].vertices);i.clockwiseSort(a);var l=i.hull(a),h=i.centre(l);s.setVertices(t,l),i.translate(t.vertices,h)}var c=s._totalProperties(t);t.area=c.area,t.parent=t,t.position.x=c.centre.x,t.position.y=c.centre.y,t.positionPrev.x=c.centre.x,t.positionPrev.y=c.centre.y,s.setMass(t,c.mass),s.setInertia(t,c.inertia),s.setPosition(t,c.centre)}},s.setCentre=function(t,e,r){r?(t.positionPrev.x+=e.x,t.positionPrev.y+=e.y,t.position.x+=e.x,t.position.y+=e.y):(t.positionPrev.x=e.x-(t.position.x-t.positionPrev.x),t.positionPrev.y=e.y-(t.position.y-t.positionPrev.y),t.position.x=e.x,t.position.y=e.y)},s.setPosition=function(t,e,r){var s=n.sub(e,t.position);r?(t.positionPrev.x=t.position.x,t.positionPrev.y=t.position.y,t.velocity.x=s.x,t.velocity.y=s.y,t.speed=n.magnitude(s)):(t.positionPrev.x+=s.x,t.positionPrev.y+=s.y);for(var o=0;o<t.parts.length;o++){var a=t.parts[o];a.position.x+=s.x,a.position.y+=s.y,i.translate(a.vertices,s),l.update(a.bounds,a.vertices,t.velocity)}},s.setAngle=function(t,e,r){var s=e-t.angle;r?(t.anglePrev=t.angle,t.angularVelocity=s,t.angularSpeed=Math.abs(s)):t.anglePrev+=s;for(var o=0;o<t.parts.length;o++){var a=t.parts[o];a.angle+=s,i.rotate(a.vertices,s,t.position),h.rotate(a.axes,s),l.update(a.bounds,a.vertices,t.velocity),o>0&&n.rotateAbout(a.position,s,t.position,a.position)}},s.setVelocity=function(t,e){var r=t.deltaTime/s._baseDelta;t.positionPrev.x=t.position.x-e.x*r,t.positionPrev.y=t.position.y-e.y*r,t.velocity.x=(t.position.x-t.positionPrev.x)/r,t.velocity.y=(t.position.y-t.positionPrev.y)/r,t.speed=n.magnitude(t.velocity)},s.getVelocity=function(t){var e=s._baseDelta/t.deltaTime;return{x:(t.position.x-t.positionPrev.x)*e,y:(t.position.y-t.positionPrev.y)*e}},s.getSpeed=function(t){return n.magnitude(s.getVelocity(t))},s.setSpeed=function(t,e){s.setVelocity(t,n.mult(n.normalise(s.getVelocity(t)),e))},s.setAngularVelocity=function(t,e){var r=t.deltaTime/s._baseDelta;t.anglePrev=t.angle-e*r,t.angularVelocity=(t.angle-t.anglePrev)/r,t.angularSpeed=Math.abs(t.angularVelocity)},s.getAngularVelocity=function(t){return(t.angle-t.anglePrev)*s._baseDelta/t.deltaTime},s.getAngularSpeed=function(t){return Math.abs(s.getAngularVelocity(t))},s.setAngularSpeed=function(t,e){s.setAngularVelocity(t,a.sign(s.getAngularVelocity(t))*e)},s.translate=function(t,e,r){s.setPosition(t,n.add(t.position,e),r)},s.rotate=function(t,e,r,i){if(r){var n=Math.cos(e),o=Math.sin(e),a=t.position.x-r.x,l=t.position.y-r.y;s.setPosition(t,{x:r.x+(a*n-l*o),y:r.y+(a*o+l*n)},i),s.setAngle(t,t.angle+e,i)}else s.setAngle(t,t.angle+e,i)},s.scale=function(t,e,r,n){var o=0,a=0;n=n||t.position;for(var c=0;c<t.parts.length;c++){var u=t.parts[c];i.scale(u.vertices,e,r,n),u.axes=h.fromVertices(u.vertices),u.area=i.area(u.vertices),s.setMass(u,t.density*u.area),i.translate(u.vertices,{x:-u.position.x,y:-u.position.y}),s.setInertia(u,s._inertiaScale*i.inertia(u.vertices,u.mass)),i.translate(u.vertices,{x:u.position.x,y:u.position.y}),c>0&&(o+=u.area,a+=u.inertia),u.position.x=n.x+(u.position.x-n.x)*e,u.position.y=n.y+(u.position.y-n.y)*r,l.update(u.bounds,u.vertices,t.velocity)}t.parts.length>1&&(t.area=o,t.isStatic||(s.setMass(t,t.density*o),s.setInertia(t,a))),t.circleRadius&&(e===r?t.circleRadius*=e:t.circleRadius=null)},s.update=function(t,e){var r=(e=(void 0!==e?e:1e3/60)*t.timeScale)*e,o=s._timeCorrection?e/(t.deltaTime||e):1,c=1-t.frictionAir*(e/a._baseDelta),u=(t.position.x-t.positionPrev.x)*o,d=(t.position.y-t.positionPrev.y)*o;t.velocity.x=u*c+t.force.x/t.mass*r,t.velocity.y=d*c+t.force.y/t.mass*r,t.positionPrev.x=t.position.x,t.positionPrev.y=t.position.y,t.position.x+=t.velocity.x,t.position.y+=t.velocity.y,t.deltaTime=e,t.angularVelocity=(t.angle-t.anglePrev)*c*o+t.torque/t.inertia*r,t.anglePrev=t.angle,t.angle+=t.angularVelocity;for(var p=0;p<t.parts.length;p++){var f=t.parts[p];i.translate(f.vertices,t.velocity),p>0&&(f.position.x+=t.velocity.x,f.position.y+=t.velocity.y),0!==t.angularVelocity&&(i.rotate(f.vertices,t.angularVelocity,t.position),h.rotate(f.axes,t.angularVelocity),p>0&&n.rotateAbout(f.position,t.angularVelocity,t.position,f.position)),l.update(f.bounds,f.vertices,t.velocity)}},s.updateVelocities=function(t){var e=s._baseDelta/t.deltaTime,r=t.velocity;r.x=(t.position.x-t.positionPrev.x)*e,r.y=(t.position.y-t.positionPrev.y)*e,t.speed=Math.sqrt(r.x*r.x+r.y*r.y),t.angularVelocity=(t.angle-t.anglePrev)*e,t.angularSpeed=Math.abs(t.angularVelocity)},s.applyForce=function(t,e,r){var s=e.x-t.position.x,i=e.y-t.position.y;t.force.x+=r.x,t.force.y+=r.y,t.torque+=s*r.y-i*r.x},s._totalProperties=function(t){for(var e={mass:0,area:0,inertia:0,centre:{x:0,y:0}},r=1===t.parts.length?0:1;r<t.parts.length;r++){var s=t.parts[r],i=s.mass!==1/0?s.mass:1;e.mass+=i,e.area+=s.area,e.inertia+=s.inertia,e.centre=n.add(e.centre,n.mult(s.position,i))}return e.centre=n.div(e.centre,e.mass),e}}()},function(t,e,r){var s={};t.exports=s;var i=r(0);s.on=function(t,e,r){for(var s,i=e.split(" "),n=0;n<i.length;n++)s=i[n],t.events=t.events||{},t.events[s]=t.events[s]||[],t.events[s].push(r);return r},s.off=function(t,e,r){if(e){"function"==typeof e&&(r=e,e=i.keys(t.events).join(" "));for(var s=e.split(" "),n=0;n<s.length;n++){var o=t.events[s[n]],a=[];if(r&&o)for(var l=0;l<o.length;l++)o[l]!==r&&a.push(o[l]);t.events[s[n]]=a}}else t.events={}},s.trigger=function(t,e,r){var s,n,o,a,l=t.events;if(l&&i.keys(l).length>0){r||(r={}),s=e.split(" ");for(var h=0;h<s.length;h++)if(o=l[n=s[h]]){(a=i.clone(r,!1)).name=n,a.source=t;for(var c=0;c<o.length;c++)o[c].apply(t,[a])}}}},function(t,e,r){var s={};t.exports=s;var i=r(5),n=r(0),o=r(1),a=r(4);s.create=function(t){return n.extend({id:n.nextId(),type:"composite",parent:null,isModified:!1,bodies:[],constraints:[],composites:[],label:"Composite",plugin:{},cache:{allBodies:null,allConstraints:null,allComposites:null}},t)},s.setModified=function(t,e,r,i){if(t.isModified=e,e&&t.cache&&(t.cache.allBodies=null,t.cache.allConstraints=null,t.cache.allComposites=null),r&&t.parent&&s.setModified(t.parent,e,r,i),i)for(var n=0;n<t.composites.length;n++){var o=t.composites[n];s.setModified(o,e,r,i)}},s.add=function(t,e){var r=[].concat(e);i.trigger(t,"beforeAdd",{object:e});for(var o=0;o<r.length;o++){var a=r[o];switch(a.type){case"body":if(a.parent!==a){n.warn("Composite.add: skipped adding a compound body part (you must add its parent instead)");break}s.addBody(t,a);break;case"constraint":s.addConstraint(t,a);break;case"composite":s.addComposite(t,a);break;case"mouseConstraint":s.addConstraint(t,a.constraint)}}return i.trigger(t,"afterAdd",{object:e}),t},s.remove=function(t,e,r){var n=[].concat(e);i.trigger(t,"beforeRemove",{object:e});for(var o=0;o<n.length;o++){var a=n[o];switch(a.type){case"body":s.removeBody(t,a,r);break;case"constraint":s.removeConstraint(t,a,r);break;case"composite":s.removeComposite(t,a,r);break;case"mouseConstraint":s.removeConstraint(t,a.constraint)}}return i.trigger(t,"afterRemove",{object:e}),t},s.addComposite=function(t,e){return t.composites.push(e),e.parent=t,s.setModified(t,!0,!0,!1),t},s.removeComposite=function(t,e,r){var i=n.indexOf(t.composites,e);if(-1!==i){var o=s.allBodies(e);s.removeCompositeAt(t,i);for(var a=0;a<o.length;a++)o[a].sleepCounter=0}if(r)for(a=0;a<t.composites.length;a++)s.removeComposite(t.composites[a],e,!0);return t},s.removeCompositeAt=function(t,e){return t.composites.splice(e,1),s.setModified(t,!0,!0,!1),t},s.addBody=function(t,e){return t.bodies.push(e),s.setModified(t,!0,!0,!1),t},s.removeBody=function(t,e,r){var i=n.indexOf(t.bodies,e);if(-1!==i&&(s.removeBodyAt(t,i),e.sleepCounter=0),r)for(var o=0;o<t.composites.length;o++)s.removeBody(t.composites[o],e,!0);return t},s.removeBodyAt=function(t,e){return t.bodies.splice(e,1),s.setModified(t,!0,!0,!1),t},s.addConstraint=function(t,e){return t.constraints.push(e),s.setModified(t,!0,!0,!1),t},s.removeConstraint=function(t,e,r){var i=n.indexOf(t.constraints,e);if(-1!==i&&s.removeConstraintAt(t,i),r)for(var o=0;o<t.composites.length;o++)s.removeConstraint(t.composites[o],e,!0);return t},s.removeConstraintAt=function(t,e){return t.constraints.splice(e,1),s.setModified(t,!0,!0,!1),t},s.clear=function(t,e,r){if(r)for(var i=0;i<t.composites.length;i++)s.clear(t.composites[i],e,!0);return e?t.bodies=t.bodies.filter(function(t){return t.isStatic}):t.bodies.length=0,t.constraints.length=0,t.composites.length=0,s.setModified(t,!0,!0,!1),t},s.allBodies=function(t){if(t.cache&&t.cache.allBodies)return t.cache.allBodies;for(var e=[].concat(t.bodies),r=0;r<t.composites.length;r++)e=e.concat(s.allBodies(t.composites[r]));return t.cache&&(t.cache.allBodies=e),e},s.allConstraints=function(t){if(t.cache&&t.cache.allConstraints)return t.cache.allConstraints;for(var e=[].concat(t.constraints),r=0;r<t.composites.length;r++)e=e.concat(s.allConstraints(t.composites[r]));return t.cache&&(t.cache.allConstraints=e),e},s.allComposites=function(t){if(t.cache&&t.cache.allComposites)return t.cache.allComposites;for(var e=[].concat(t.composites),r=0;r<t.composites.length;r++)e=e.concat(s.allComposites(t.composites[r]));return t.cache&&(t.cache.allComposites=e),e},s.get=function(t,e,r){var i,n;switch(r){case"body":i=s.allBodies(t);break;case"constraint":i=s.allConstraints(t);break;case"composite":i=s.allComposites(t).concat(t)}return i?0===(n=i.filter(function(t){return t.id.toString()===e.toString()})).length?null:n[0]:null},s.move=function(t,e,r){return s.remove(t,e),s.add(r,e),t},s.rebase=function(t){for(var e=s.allBodies(t).concat(s.allConstraints(t)).concat(s.allComposites(t)),r=0;r<e.length;r++)e[r].id=n.nextId();return t},s.translate=function(t,e,r){for(var i=r?s.allBodies(t):t.bodies,n=0;n<i.length;n++)a.translate(i[n],e);return t},s.rotate=function(t,e,r,i){for(var n=Math.cos(e),o=Math.sin(e),l=i?s.allBodies(t):t.bodies,h=0;h<l.length;h++){var c=l[h],u=c.position.x-r.x,d=c.position.y-r.y;a.setPosition(c,{x:r.x+(u*n-d*o),y:r.y+(u*o+d*n)}),a.rotate(c,e)}return t},s.scale=function(t,e,r,i,n){for(var o=n?s.allBodies(t):t.bodies,l=0;l<o.length;l++){var h=o[l],c=h.position.x-i.x,u=h.position.y-i.y;a.setPosition(h,{x:i.x+c*e,y:i.y+u*r}),a.scale(h,e,r)}return t},s.bounds=function(t){for(var e=s.allBodies(t),r=[],i=0;i<e.length;i+=1){var n=e[i];r.push(n.bounds.min,n.bounds.max)}return o.create(r)}},function(t,e,r){var s={};t.exports=s;var i=r(4),n=r(5),o=r(0);s._motionWakeThreshold=.18,s._motionSleepThreshold=.08,s._minBias=.9,s.update=function(t,e){for(var r=e/o._baseDelta,n=s._motionSleepThreshold,a=0;a<t.length;a++){var l=t[a],h=i.getSpeed(l),c=i.getAngularSpeed(l),u=h*h+c*c;if(0===l.force.x&&0===l.force.y){var d=Math.min(l.motion,u),p=Math.max(l.motion,u);l.motion=s._minBias*d+(1-s._minBias)*p,l.sleepThreshold>0&&l.motion<n?(l.sleepCounter+=1,l.sleepCounter>=l.sleepThreshold/r&&s.set(l,!0)):l.sleepCounter>0&&(l.sleepCounter-=1)}else s.set(l,!1)}},s.afterCollisions=function(t){for(var e=s._motionSleepThreshold,r=0;r<t.length;r++){var i=t[r];if(i.isActive){var n=i.collision,o=n.bodyA.parent,a=n.bodyB.parent;if(!(o.isSleeping&&a.isSleeping||o.isStatic||a.isStatic)&&(o.isSleeping||a.isSleeping)){var l=o.isSleeping&&!o.isStatic?o:a,h=l===o?a:o;!l.isStatic&&h.motion>e&&s.set(l,!1)}}}},s.set=function(t,e){var r=t.isSleeping;e?(t.isSleeping=!0,t.sleepCounter=t.sleepThreshold,t.positionImpulse.x=0,t.positionImpulse.y=0,t.positionPrev.x=t.position.x,t.positionPrev.y=t.position.y,t.anglePrev=t.angle,t.speed=0,t.angularSpeed=0,t.motion=0,r||n.trigger(t,"sleepStart")):(t.isSleeping=!1,t.sleepCounter=0,r&&n.trigger(t,"sleepEnd"))}},function(t,e,r){var s={};t.exports=s;var i,n,o,a=r(3),l=r(9);i=[],n={overlap:0,axis:null},o={overlap:0,axis:null},s.create=function(t,e){return{pair:null,collided:!1,bodyA:t,bodyB:e,parentA:t.parent,parentB:e.parent,depth:0,normal:{x:0,y:0},tangent:{x:0,y:0},penetration:{x:0,y:0},supports:[null,null],supportCount:0}},s.collides=function(t,e,r){if(s._overlapAxes(n,t.vertices,e.vertices,t.axes),n.overlap<=0)return null;if(s._overlapAxes(o,e.vertices,t.vertices,e.axes),o.overlap<=0)return null;var i,h,c=r&&r.table[l.id(t,e)];c?i=c.collision:((i=s.create(t,e)).collided=!0,i.bodyA=t.id<e.id?t:e,i.bodyB=t.id<e.id?e:t,i.parentA=i.bodyA.parent,i.parentB=i.bodyB.parent),t=i.bodyA,e=i.bodyB,h=n.overlap<o.overlap?n:o;var u=i.normal,d=i.tangent,p=i.penetration,f=i.supports,g=h.overlap,m=h.axis,x=m.x,_=m.y;x*(e.position.x-t.position.x)+_*(e.position.y-t.position.y)>=0&&(x=-x,_=-_),u.x=x,u.y=_,d.x=-_,d.y=x,p.x=x*g,p.y=_*g,i.depth=g;var y=s._findSupports(t,e,u,1),v=0;if(a.contains(t.vertices,y[0])&&(f[v++]=y[0]),a.contains(t.vertices,y[1])&&(f[v++]=y[1]),v<2){var b=s._findSupports(e,t,u,-1);a.contains(e.vertices,b[0])&&(f[v++]=b[0]),v<2&&a.contains(e.vertices,b[1])&&(f[v++]=b[1])}return 0===v&&(f[v++]=y[0]),i.supportCount=v,i},s._overlapAxes=function(t,e,r,s){var i,n,o,a,l,h,c=e.length,u=r.length,d=e[0].x,p=e[0].y,f=r[0].x,g=r[0].y,m=s.length,x=Number.MAX_VALUE,_=0;for(l=0;l<m;l++){var y=s[l],v=y.x,b=y.y,w=d*v+p*b,T=f*v+g*b,S=w,A=T;for(h=1;h<c;h+=1)(a=e[h].x*v+e[h].y*b)>S?S=a:a<w&&(w=a);for(h=1;h<u;h+=1)(a=r[h].x*v+r[h].y*b)>A?A=a:a<T&&(T=a);if((i=(n=S-T)<(o=A-w)?n:o)<x&&(x=i,_=l,i<=0))break}t.axis=s[_],t.overlap=x},s._findSupports=function(t,e,r,s){var n,o,a,l=e.vertices,h=l.length,c=t.position.x,u=t.position.y,d=r.x*s,p=r.y*s,f=l[0],g=f,m=d*(c-g.x)+p*(u-g.y);for(a=1;a<h;a+=1)(o=d*(c-(g=l[a]).x)+p*(u-g.y))<m&&(m=o,f=g);return m=d*(c-(n=l[(h+f.index-1)%h]).x)+p*(u-n.y),d*(c-(g=l[(f.index+1)%h]).x)+p*(u-g.y)<m?(i[0]=f,i[1]=g,i):(i[0]=f,i[1]=n,i)}},function(t,e,r){var s={};t.exports=s;var i=r(16);s.create=function(t,e){var r=t.bodyA,n=t.bodyB,o={id:s.id(r,n),bodyA:r,bodyB:n,collision:t,contacts:[i.create(),i.create()],contactCount:0,separation:0,isActive:!0,isSensor:r.isSensor||n.isSensor,timeCreated:e,timeUpdated:e,inverseMass:0,friction:0,frictionStatic:0,restitution:0,slop:0};return s.update(o,t,e),o},s.update=function(t,e,r){var s=e.supports,i=e.supportCount,n=t.contacts,o=e.parentA,a=e.parentB;t.isActive=!0,t.timeUpdated=r,t.collision=e,t.separation=e.depth,t.inverseMass=o.inverseMass+a.inverseMass,t.friction=o.friction<a.friction?o.friction:a.friction,t.frictionStatic=o.frictionStatic>a.frictionStatic?o.frictionStatic:a.frictionStatic,t.restitution=o.restitution>a.restitution?o.restitution:a.restitution,t.slop=o.slop>a.slop?o.slop:a.slop,t.contactCount=i,e.pair=t;var l=s[0],h=n[0],c=s[1],u=n[1];u.vertex!==l&&h.vertex!==c||(n[1]=h,n[0]=h=u,u=n[1]),h.vertex=l,u.vertex=c},s.setActive=function(t,e,r){e?(t.isActive=!0,t.timeUpdated=r):(t.isActive=!1,t.contactCount=0)},s.id=function(t,e){return t.id<e.id?t.id.toString(36)+":"+e.id.toString(36):e.id.toString(36)+":"+t.id.toString(36)}},function(t,e,r){var s={};t.exports=s;var i=r(3),n=r(2),o=r(7),a=r(1),l=r(11),h=r(0);s._warming=.4,s._torqueDampen=1,s._minLength=1e-6,s.create=function(t){var e=t;e.bodyA&&!e.pointA&&(e.pointA={x:0,y:0}),e.bodyB&&!e.pointB&&(e.pointB={x:0,y:0});var r=e.bodyA?n.add(e.bodyA.position,e.pointA):e.pointA,s=e.bodyB?n.add(e.bodyB.position,e.pointB):e.pointB,i=n.magnitude(n.sub(r,s));e.length=void 0!==e.length?e.length:i,e.id=e.id||h.nextId(),e.label=e.label||"Constraint",e.type="constraint",e.stiffness=e.stiffness||(e.length>0?1:.7),e.damping=e.damping||0,e.angularStiffness=e.angularStiffness||0,e.angleA=e.bodyA?e.bodyA.angle:e.angleA,e.angleB=e.bodyB?e.bodyB.angle:e.angleB,e.plugin={};var o={visible:!0,lineWidth:2,strokeStyle:"#ffffff",type:"line",anchors:!0};return 0===e.length&&e.stiffness>.1?(o.type="pin",o.anchors=!1):e.stiffness<.9&&(o.type="spring"),e.render=h.extend(o,e.render),e},s.preSolveAll=function(t){for(var e=0;e<t.length;e+=1){var r=t[e],s=r.constraintImpulse;r.isStatic||0===s.x&&0===s.y&&0===s.angle||(r.position.x+=s.x,r.position.y+=s.y,r.angle+=s.angle)}},s.solveAll=function(t,e){for(var r=h.clamp(e/h._baseDelta,0,1),i=0;i<t.length;i+=1){var n=t[i],o=!n.bodyA||n.bodyA&&n.bodyA.isStatic,a=!n.bodyB||n.bodyB&&n.bodyB.isStatic;(o||a)&&s.solve(t[i],r)}for(i=0;i<t.length;i+=1)o=!(n=t[i]).bodyA||n.bodyA&&n.bodyA.isStatic,a=!n.bodyB||n.bodyB&&n.bodyB.isStatic,o||a||s.solve(t[i],r)},s.solve=function(t,e){var r=t.bodyA,i=t.bodyB,o=t.pointA,a=t.pointB;if(r||i){r&&!r.isStatic&&(n.rotate(o,r.angle-t.angleA,o),t.angleA=r.angle),i&&!i.isStatic&&(n.rotate(a,i.angle-t.angleB,a),t.angleB=i.angle);var l=o,h=a;if(r&&(l=n.add(r.position,o)),i&&(h=n.add(i.position,a)),l&&h){var c=n.sub(l,h),u=n.magnitude(c);u<s._minLength&&(u=s._minLength);var d,p,f,g,m,x=(u-t.length)/u,_=t.stiffness>=1||0===t.length?t.stiffness*e:t.stiffness*e*e,y=t.damping*e,v=n.mult(c,x*_),b=(r?r.inverseMass:0)+(i?i.inverseMass:0),w=b+((r?r.inverseInertia:0)+(i?i.inverseInertia:0));if(y>0){var T=n.create();f=n.div(c,u),m=n.sub(i&&n.sub(i.position,i.positionPrev)||T,r&&n.sub(r.position,r.positionPrev)||T),g=n.dot(f,m)}r&&!r.isStatic&&(p=r.inverseMass/b,r.constraintImpulse.x-=v.x*p,r.constraintImpulse.y-=v.y*p,r.position.x-=v.x*p,r.position.y-=v.y*p,y>0&&(r.positionPrev.x-=y*f.x*g*p,r.positionPrev.y-=y*f.y*g*p),d=n.cross(o,v)/w*s._torqueDampen*r.inverseInertia*(1-t.angularStiffness),r.constraintImpulse.angle-=d,r.angle-=d),i&&!i.isStatic&&(p=i.inverseMass/b,i.constraintImpulse.x+=v.x*p,i.constraintImpulse.y+=v.y*p,i.position.x+=v.x*p,i.position.y+=v.y*p,y>0&&(i.positionPrev.x+=y*f.x*g*p,i.positionPrev.y+=y*f.y*g*p),d=n.cross(a,v)/w*s._torqueDampen*i.inverseInertia*(1-t.angularStiffness),i.constraintImpulse.angle+=d,i.angle+=d)}}},s.postSolveAll=function(t){for(var e=0;e<t.length;e++){var r=t[e],h=r.constraintImpulse;if(!(r.isStatic||0===h.x&&0===h.y&&0===h.angle)){o.set(r,!1);for(var c=0;c<r.parts.length;c++){var u=r.parts[c];i.translate(u.vertices,h),c>0&&(u.position.x+=h.x,u.position.y+=h.y),0!==h.angle&&(i.rotate(u.vertices,h.angle,r.position),l.rotate(u.axes,h.angle),c>0&&n.rotateAbout(u.position,h.angle,r.position,u.position)),a.update(u.bounds,u.vertices,r.velocity)}h.angle*=s._warming,h.x*=s._warming,h.y*=s._warming}}},s.pointAWorld=function(t){return{x:(t.bodyA?t.bodyA.position.x:0)+(t.pointA?t.pointA.x:0),y:(t.bodyA?t.bodyA.position.y:0)+(t.pointA?t.pointA.y:0)}},s.pointBWorld=function(t){return{x:(t.bodyB?t.bodyB.position.x:0)+(t.pointB?t.pointB.x:0),y:(t.bodyB?t.bodyB.position.y:0)+(t.pointB?t.pointB.y:0)}},s.currentLength=function(t){var e=(t.bodyA?t.bodyA.position.x:0)+(t.pointA?t.pointA.x:0),r=(t.bodyA?t.bodyA.position.y:0)+(t.pointA?t.pointA.y:0),s=e-((t.bodyB?t.bodyB.position.x:0)+(t.pointB?t.pointB.x:0)),i=r-((t.bodyB?t.bodyB.position.y:0)+(t.pointB?t.pointB.y:0));return Math.sqrt(s*s+i*i)}},function(t,e,r){var s={};t.exports=s;var i=r(2),n=r(0);s.fromVertices=function(t){for(var e={},r=0;r<t.length;r++){var s=(r+1)%t.length,o=i.normalise({x:t[s].y-t[r].y,y:t[r].x-t[s].x}),a=0===o.y?1/0:o.x/o.y;e[a=a.toFixed(3).toString()]=o}return n.values(e)},s.rotate=function(t,e){if(0!==e)for(var r=Math.cos(e),s=Math.sin(e),i=0;i<t.length;i++){var n,o=t[i];n=o.x*r-o.y*s,o.y=o.x*s+o.y*r,o.x=n}}},function(t,e,r){var s={};t.exports=s;var i=r(3),n=r(0),o=r(4),a=r(1),l=r(2);s.rectangle=function(t,e,r,s,a){a=a||{};var l={label:"Rectangle Body",position:{x:t,y:e},vertices:i.fromPath("L 0 0 L "+r+" 0 L "+r+" "+s+" L 0 "+s)};if(a.chamfer){var h=a.chamfer;l.vertices=i.chamfer(l.vertices,h.radius,h.quality,h.qualityMin,h.qualityMax),delete a.chamfer}return o.create(n.extend({},l,a))},s.trapezoid=function(t,e,r,s,a,l){l=l||{},a>=1&&n.warn("Bodies.trapezoid: slope parameter must be < 1.");var h,c=r*(a*=.5),u=c+(1-2*a)*r,d=u+c;h=a<.5?"L 0 0 L "+c+" "+-s+" L "+u+" "+-s+" L "+d+" 0":"L 0 0 L "+u+" "+-s+" L "+d+" 0";var p={label:"Trapezoid Body",position:{x:t,y:e},vertices:i.fromPath(h)};if(l.chamfer){var f=l.chamfer;p.vertices=i.chamfer(p.vertices,f.radius,f.quality,f.qualityMin,f.qualityMax),delete l.chamfer}return o.create(n.extend({},p,l))},s.circle=function(t,e,r,i,o){i=i||{};var a={label:"Circle Body",circleRadius:r};o=o||25;var l=Math.ceil(Math.max(10,Math.min(o,r)));return l%2==1&&(l+=1),s.polygon(t,e,l,r,n.extend({},a,i))},s.polygon=function(t,e,r,a,l){if(l=l||{},r<3)return s.circle(t,e,a,l);for(var h=2*Math.PI/r,c="",u=.5*h,d=0;d<r;d+=1){var p=u+d*h,f=Math.cos(p)*a,g=Math.sin(p)*a;c+="L "+f.toFixed(3)+" "+g.toFixed(3)+" "}var m={label:"Polygon Body",position:{x:t,y:e},vertices:i.fromPath(c)};if(l.chamfer){var x=l.chamfer;m.vertices=i.chamfer(m.vertices,x.radius,x.quality,x.qualityMin,x.qualityMax),delete l.chamfer}return o.create(n.extend({},m,l))},s.fromVertices=function(t,e,r,s,h,c,u,d){var p,f,g,m,x,_,y,v,b,w,T=n.getDecomp();for(p=Boolean(T&&T.quickDecomp),s=s||{},g=[],h=void 0!==h&&h,c=void 0!==c?c:.01,u=void 0!==u?u:10,d=void 0!==d?d:.01,n.isArray(r[0])||(r=[r]),b=0;b<r.length;b+=1)if(x=r[b],!(m=i.isConvex(x))&&!p&&n.warnOnce("Bodies.fromVertices: Install the 'poly-decomp' library and use Common.setDecomp or provide 'decomp' as a global to decompose concave vertices."),m||!p)x=m?i.clockwiseSort(x):i.hull(x),g.push({position:{x:t,y:e},vertices:x});else{var S=x.map(function(t){return[t.x,t.y]});T.makeCCW(S),!1!==c&&T.removeCollinearPoints(S,c),!1!==d&&T.removeDuplicatePoints&&T.removeDuplicatePoints(S,d);var A=T.quickDecomp(S);for(_=0;_<A.length;_++){var C=A[_].map(function(t){return{x:t[0],y:t[1]}});u>0&&i.area(C)<u||g.push({position:i.centre(C),vertices:C})}}for(_=0;_<g.length;_++)g[_]=o.create(n.extend(g[_],s));if(h)for(_=0;_<g.length;_++){var P=g[_];for(y=_+1;y<g.length;y++){var M=g[y];if(a.overlaps(P.bounds,M.bounds)){var E=P.vertices,R=M.vertices;for(v=0;v<P.vertices.length;v++)for(w=0;w<M.vertices.length;w++){var k=l.magnitudeSquared(l.sub(E[(v+1)%E.length],R[w])),B=l.magnitudeSquared(l.sub(E[v],R[(w+1)%R.length]));k<5&&B<5&&(E[v].isInternal=!0,R[w].isInternal=!0)}}}}return g.length>1?(f=o.create(n.extend({parts:g.slice(0)},s)),o.setPosition(f,{x:t,y:e}),f):g[0]}},function(t,e,r){var s={};t.exports=s;var i=r(0),n=r(8);s.create=function(t){return i.extend({bodies:[],collisions:[],pairs:null},t)},s.setBodies=function(t,e){t.bodies=e.slice(0)},s.clear=function(t){t.bodies=[],t.collisions=[]},s.collisions=function(t){var e,r,i=t.pairs,o=t.bodies,a=o.length,l=s.canCollide,h=n.collides,c=t.collisions,u=0;for(o.sort(s._compareBoundsX),e=0;e<a;e++){var d=o[e],p=d.bounds,f=d.bounds.max.x,g=d.bounds.max.y,m=d.bounds.min.y,x=d.isStatic||d.isSleeping,_=d.parts.length,y=1===_;for(r=e+1;r<a;r++){var v=o[r];if((M=v.bounds).min.x>f)break;if(!(g<M.min.y||m>M.max.y)&&(!x||!v.isStatic&&!v.isSleeping)&&l(d.collisionFilter,v.collisionFilter)){var b=v.parts.length;if(y&&1===b)(C=h(d,v,i))&&(c[u++]=C);else for(var w=b>1?1:0,T=_>1?1:0;T<_;T++)for(var S=d.parts[T],A=(p=S.bounds,w);A<b;A++){var C,P=v.parts[A],M=P.bounds;p.min.x>M.max.x||p.max.x<M.min.x||p.max.y<M.min.y||p.min.y>M.max.y||(C=h(S,P,i))&&(c[u++]=C)}}}}return c.length!==u&&(c.length=u),c},s.canCollide=function(t,e){return t.group===e.group&&0!==t.group?t.group>0:0!==(t.mask&e.category)&&0!==(e.mask&t.category)},s._compareBoundsX=function(t,e){return t.bounds.min.x-e.bounds.min.x}},function(t,e,r){var s={};t.exports=s;var i=r(0);s.create=function(t){var e={};return t||i.log("Mouse.create: element was undefined, defaulting to document.body","warn"),e.element=t||document.body,e.absolute={x:0,y:0},e.position={x:0,y:0},e.mousedownPosition={x:0,y:0},e.mouseupPosition={x:0,y:0},e.offset={x:0,y:0},e.scale={x:1,y:1},e.wheelDelta=0,e.button=-1,e.pixelRatio=parseInt(e.element.getAttribute("data-pixel-ratio"),10)||1,e.sourceEvents={mousemove:null,mousedown:null,mouseup:null,mousewheel:null},e.mousemove=function(t){var r=s._getRelativeMousePosition(t,e.element,e.pixelRatio);t.changedTouches&&(e.button=0,t.preventDefault()),e.absolute.x=r.x,e.absolute.y=r.y,e.position.x=e.absolute.x*e.scale.x+e.offset.x,e.position.y=e.absolute.y*e.scale.y+e.offset.y,e.sourceEvents.mousemove=t},e.mousedown=function(t){var r=s._getRelativeMousePosition(t,e.element,e.pixelRatio);t.changedTouches?(e.button=0,t.preventDefault()):e.button=t.button,e.absolute.x=r.x,e.absolute.y=r.y,e.position.x=e.absolute.x*e.scale.x+e.offset.x,e.position.y=e.absolute.y*e.scale.y+e.offset.y,e.mousedownPosition.x=e.position.x,e.mousedownPosition.y=e.position.y,e.sourceEvents.mousedown=t},e.mouseup=function(t){var r=s._getRelativeMousePosition(t,e.element,e.pixelRatio);t.changedTouches&&t.preventDefault(),e.button=-1,e.absolute.x=r.x,e.absolute.y=r.y,e.position.x=e.absolute.x*e.scale.x+e.offset.x,e.position.y=e.absolute.y*e.scale.y+e.offset.y,e.mouseupPosition.x=e.position.x,e.mouseupPosition.y=e.position.y,e.sourceEvents.mouseup=t},e.mousewheel=function(t){e.wheelDelta=Math.max(-1,Math.min(1,t.wheelDelta||-t.detail)),t.preventDefault(),e.sourceEvents.mousewheel=t},s.setElement(e,e.element),e},s.setElement=function(t,e){t.element=e,e.addEventListener("mousemove",t.mousemove,{passive:!0}),e.addEventListener("mousedown",t.mousedown,{passive:!0}),e.addEventListener("mouseup",t.mouseup,{passive:!0}),e.addEventListener("wheel",t.mousewheel,{passive:!1}),e.addEventListener("touchmove",t.mousemove,{passive:!1}),e.addEventListener("touchstart",t.mousedown,{passive:!1}),e.addEventListener("touchend",t.mouseup,{passive:!1})},s.clearSourceEvents=function(t){t.sourceEvents.mousemove=null,t.sourceEvents.mousedown=null,t.sourceEvents.mouseup=null,t.sourceEvents.mousewheel=null,t.wheelDelta=0},s.setOffset=function(t,e){t.offset.x=e.x,t.offset.y=e.y,t.position.x=t.absolute.x*t.scale.x+t.offset.x,t.position.y=t.absolute.y*t.scale.y+t.offset.y},s.setScale=function(t,e){t.scale.x=e.x,t.scale.y=e.y,t.position.x=t.absolute.x*t.scale.x+t.offset.x,t.position.y=t.absolute.y*t.scale.y+t.offset.y},s._getRelativeMousePosition=function(t,e,r){var s,i,n=e.getBoundingClientRect(),o=document.documentElement||document.body.parentNode||document.body,a=void 0!==window.pageXOffset?window.pageXOffset:o.scrollLeft,l=void 0!==window.pageYOffset?window.pageYOffset:o.scrollTop,h=t.changedTouches;return h?(s=h[0].pageX-n.left-a,i=h[0].pageY-n.top-l):(s=t.pageX-n.left-a,i=t.pageY-n.top-l),{x:s/(e.clientWidth/(e.width||e.clientWidth)*r),y:i/(e.clientHeight/(e.height||e.clientHeight)*r)}}},function(t,e,r){var s={};t.exports=s;var i=r(0);s._registry={},s.register=function(t){if(s.isPlugin(t)||i.warn("Plugin.register:",s.toString(t),"does not implement all required fields."),t.name in s._registry){var e=s._registry[t.name],r=s.versionParse(t.version).number,n=s.versionParse(e.version).number;r>n?(i.warn("Plugin.register:",s.toString(e),"was upgraded to",s.toString(t)),s._registry[t.name]=t):r<n?i.warn("Plugin.register:",s.toString(e),"can not be downgraded to",s.toString(t)):t!==e&&i.warn("Plugin.register:",s.toString(t),"is already registered to different plugin object")}else s._registry[t.name]=t;return t},s.resolve=function(t){return s._registry[s.dependencyParse(t).name]},s.toString=function(t){return"string"==typeof t?t:(t.name||"anonymous")+"@"+(t.version||t.range||"0.0.0")},s.isPlugin=function(t){return t&&t.name&&t.version&&t.install},s.isUsed=function(t,e){return t.used.indexOf(e)>-1},s.isFor=function(t,e){var r=t.for&&s.dependencyParse(t.for);return!t.for||e.name===r.name&&s.versionSatisfies(e.version,r.range)},s.use=function(t,e){if(t.uses=(t.uses||[]).concat(e||[]),0!==t.uses.length){for(var r=s.dependencies(t),n=i.topologicalSort(r),o=[],a=0;a<n.length;a+=1)if(n[a]!==t.name){var l=s.resolve(n[a]);l?s.isUsed(t,l.name)||(s.isFor(l,t)||(i.warn("Plugin.use:",s.toString(l),"is for",l.for,"but installed on",s.toString(t)+"."),l._warned=!0),l.install?l.install(t):(i.warn("Plugin.use:",s.toString(l),"does not specify an install function."),l._warned=!0),l._warned?(o.push("🔶 "+s.toString(l)),delete l._warned):o.push("✅ "+s.toString(l)),t.used.push(l.name)):o.push("❌ "+n[a])}o.length>0&&i.info(o.join(" "))}else i.warn("Plugin.use:",s.toString(t),"does not specify any dependencies to install.")},s.dependencies=function(t,e){var r=s.dependencyParse(t),n=r.name;if(!(n in(e=e||{}))){t=s.resolve(t)||t,e[n]=i.map(t.uses||[],function(e){s.isPlugin(e)&&s.register(e);var n=s.dependencyParse(e),o=s.resolve(e);return o&&!s.versionSatisfies(o.version,n.range)?(i.warn("Plugin.dependencies:",s.toString(o),"does not satisfy",s.toString(n),"used by",s.toString(r)+"."),o._warned=!0,t._warned=!0):o||(i.warn("Plugin.dependencies:",s.toString(e),"used by",s.toString(r),"could not be resolved."),t._warned=!0),n.name});for(var o=0;o<e[n].length;o+=1)s.dependencies(e[n][o],e);return e}},s.dependencyParse=function(t){return i.isString(t)?(/^[\w-]+(@(\*|[\^~]?\d+\.\d+\.\d+(-[0-9A-Za-z-+]+)?))?$/.test(t)||i.warn("Plugin.dependencyParse:",t,"is not a valid dependency string."),{name:t.split("@")[0],range:t.split("@")[1]||"*"}):{name:t.name,range:t.range||t.version}},s.versionParse=function(t){var e=/^(\*)|(\^|~|>=|>)?\s*((\d+)\.(\d+)\.(\d+))(-[0-9A-Za-z-+]+)?$/;e.test(t)||i.warn("Plugin.versionParse:",t,"is not a valid version or range.");var r=e.exec(t),s=Number(r[4]),n=Number(r[5]),o=Number(r[6]);return{isRange:Boolean(r[1]||r[2]),version:r[3],range:t,operator:r[1]||r[2]||"",major:s,minor:n,patch:o,parts:[s,n,o],prerelease:r[7],number:1e8*s+1e4*n+o}},s.versionSatisfies=function(t,e){e=e||"*";var r=s.versionParse(e),i=s.versionParse(t);if(r.isRange){if("*"===r.operator||"*"===t)return!0;if(">"===r.operator)return i.number>r.number;if(">="===r.operator)return i.number>=r.number;if("~"===r.operator)return i.major===r.major&&i.minor===r.minor&&i.patch>=r.patch;if("^"===r.operator)return r.major>0?i.major===r.major&&i.number>=r.number:r.minor>0?i.minor===r.minor&&i.patch>=r.patch:i.patch===r.patch}return t===e||"*"===t}},function(t,e){var r={};t.exports=r,r.create=function(t){return{vertex:t,normalImpulse:0,tangentImpulse:0}}},function(t,e,r){var s={};t.exports=s;var i=r(7),n=r(18),o=r(13),a=r(19),l=r(5),h=r(6),c=r(10),u=r(0),d=r(4);s._deltaMax=1e3/60,s.create=function(t){t=t||{};var e=u.extend({positionIterations:6,velocityIterations:4,constraintIterations:2,enableSleeping:!1,events:[],plugin:{},gravity:{x:0,y:1,scale:.001},timing:{timestamp:0,timeScale:1,lastDelta:0,lastElapsed:0,lastUpdatesPerFrame:0}},t);return e.world=t.world||h.create({label:"World"}),e.pairs=t.pairs||a.create(),e.detector=t.detector||o.create(),e.detector.pairs=e.pairs,e.grid={buckets:[]},e.world.gravity=e.gravity,e.broadphase=e.grid,e.metrics={},e},s.update=function(t,e){var r,d=u.now(),p=t.world,f=t.detector,g=t.pairs,m=t.timing,x=m.timestamp;e>s._deltaMax&&u.warnOnce("Matter.Engine.update: delta argument is recommended to be less than or equal to",s._deltaMax.toFixed(3),"ms."),e=void 0!==e?e:u._baseDelta,e*=m.timeScale,m.timestamp+=e,m.lastDelta=e;var _={timestamp:m.timestamp,delta:e};l.trigger(t,"beforeUpdate",_);var y=h.allBodies(p),v=h.allConstraints(p);for(p.isModified&&(o.setBodies(f,y),h.setModified(p,!1,!1,!0)),t.enableSleeping&&i.update(y,e),s._bodiesApplyGravity(y,t.gravity),e>0&&s._bodiesUpdate(y,e),l.trigger(t,"beforeSolve",_),c.preSolveAll(y),r=0;r<t.constraintIterations;r++)c.solveAll(v,e);c.postSolveAll(y);var b=o.collisions(f);a.update(g,b,x),t.enableSleeping&&i.afterCollisions(g.list),g.collisionStart.length>0&&l.trigger(t,"collisionStart",{pairs:g.collisionStart,timestamp:m.timestamp,delta:e});var w=u.clamp(20/t.positionIterations,0,1);for(n.preSolvePosition(g.list),r=0;r<t.positionIterations;r++)n.solvePosition(g.list,e,w);for(n.postSolvePosition(y),c.preSolveAll(y),r=0;r<t.constraintIterations;r++)c.solveAll(v,e);for(c.postSolveAll(y),n.preSolveVelocity(g.list),r=0;r<t.velocityIterations;r++)n.solveVelocity(g.list,e);return s._bodiesUpdateVelocities(y),g.collisionActive.length>0&&l.trigger(t,"collisionActive",{pairs:g.collisionActive,timestamp:m.timestamp,delta:e}),g.collisionEnd.length>0&&l.trigger(t,"collisionEnd",{pairs:g.collisionEnd,timestamp:m.timestamp,delta:e}),s._bodiesClearForces(y),l.trigger(t,"afterUpdate",_),t.timing.lastElapsed=u.now()-d,t},s.merge=function(t,e){if(u.extend(t,e),e.world){t.world=e.world,s.clear(t);for(var r=h.allBodies(t.world),n=0;n<r.length;n++){var o=r[n];i.set(o,!1),o.id=u.nextId()}}},s.clear=function(t){a.clear(t.pairs),o.clear(t.detector)},s._bodiesClearForces=function(t){for(var e=t.length,r=0;r<e;r++){var s=t[r];s.force.x=0,s.force.y=0,s.torque=0}},s._bodiesApplyGravity=function(t,e){var r=void 0!==e.scale?e.scale:.001,s=t.length;if((0!==e.x||0!==e.y)&&0!==r)for(var i=0;i<s;i++){var n=t[i];n.isStatic||n.isSleeping||(n.force.y+=n.mass*e.y*r,n.force.x+=n.mass*e.x*r)}},s._bodiesUpdate=function(t,e){for(var r=t.length,s=0;s<r;s++){var i=t[s];i.isStatic||i.isSleeping||d.update(i,e)}},s._bodiesUpdateVelocities=function(t){for(var e=t.length,r=0;r<e;r++)d.updateVelocities(t[r])}},function(t,e,r){var s={};t.exports=s;var i=r(3),n=r(0),o=r(1);s._restingThresh=2,s._restingThreshTangent=Math.sqrt(6),s._positionDampen=.9,s._positionWarming=.8,s._frictionNormalMultiplier=5,s._frictionMaxStatic=Number.MAX_VALUE,s.preSolvePosition=function(t){var e,r,s,i=t.length;for(e=0;e<i;e++)(r=t[e]).isActive&&(s=r.contactCount,r.collision.parentA.totalContacts+=s,r.collision.parentB.totalContacts+=s)},s.solvePosition=function(t,e,r){var i,o,a,l,h,c,u,d,p=s._positionDampen*(r||1),f=n.clamp(e/n._baseDelta,0,1),g=t.length;for(i=0;i<g;i++)(o=t[i]).isActive&&!o.isSensor&&(l=(a=o.collision).parentA,h=a.parentB,c=a.normal,o.separation=a.depth+c.x*(h.positionImpulse.x-l.positionImpulse.x)+c.y*(h.positionImpulse.y-l.positionImpulse.y));for(i=0;i<g;i++)(o=t[i]).isActive&&!o.isSensor&&(l=(a=o.collision).parentA,h=a.parentB,c=a.normal,d=o.separation-o.slop*f,(l.isStatic||h.isStatic)&&(d*=2),l.isStatic||l.isSleeping||(u=p/l.totalContacts,l.positionImpulse.x+=c.x*d*u,l.positionImpulse.y+=c.y*d*u),h.isStatic||h.isSleeping||(u=p/h.totalContacts,h.positionImpulse.x-=c.x*d*u,h.positionImpulse.y-=c.y*d*u))},s.postSolvePosition=function(t){for(var e=s._positionWarming,r=t.length,n=i.translate,a=o.update,l=0;l<r;l++){var h=t[l],c=h.positionImpulse,u=c.x,d=c.y,p=h.velocity;if(h.totalContacts=0,0!==u||0!==d){for(var f=0;f<h.parts.length;f++){var g=h.parts[f];n(g.vertices,c),a(g.bounds,g.vertices,p),g.position.x+=u,g.position.y+=d}h.positionPrev.x+=u,h.positionPrev.y+=d,u*p.x+d*p.y<0?(c.x=0,c.y=0):(c.x*=e,c.y*=e)}}},s.preSolveVelocity=function(t){var e,r,s=t.length;for(e=0;e<s;e++){var i=t[e];if(i.isActive&&!i.isSensor){var n=i.contacts,o=i.contactCount,a=i.collision,l=a.parentA,h=a.parentB,c=a.normal,u=a.tangent;for(r=0;r<o;r++){var d=n[r],p=d.vertex,f=d.normalImpulse,g=d.tangentImpulse;if(0!==f||0!==g){var m=c.x*f+u.x*g,x=c.y*f+u.y*g;l.isStatic||l.isSleeping||(l.positionPrev.x+=m*l.inverseMass,l.positionPrev.y+=x*l.inverseMass,l.anglePrev+=l.inverseInertia*((p.x-l.position.x)*x-(p.y-l.position.y)*m)),h.isStatic||h.isSleeping||(h.positionPrev.x-=m*h.inverseMass,h.positionPrev.y-=x*h.inverseMass,h.anglePrev-=h.inverseInertia*((p.x-h.position.x)*x-(p.y-h.position.y)*m))}}}}},s.solveVelocity=function(t,e){var r,i,o,a,l=e/n._baseDelta,h=l*l*l,c=-s._restingThresh*l,u=s._restingThreshTangent,d=s._frictionNormalMultiplier*l,p=s._frictionMaxStatic,f=t.length;for(o=0;o<f;o++){var g=t[o];if(g.isActive&&!g.isSensor){var m=g.collision,x=m.parentA,_=m.parentB,y=m.normal.x,v=m.normal.y,b=m.tangent.x,w=m.tangent.y,T=g.inverseMass,S=g.friction*g.frictionStatic*d,A=g.contacts,C=g.contactCount,P=1/C,M=x.position.x-x.positionPrev.x,E=x.position.y-x.positionPrev.y,R=x.angle-x.anglePrev,k=_.position.x-_.positionPrev.x,B=_.position.y-_.positionPrev.y,I=_.angle-_.anglePrev;for(a=0;a<C;a++){var G=A[a],F=G.vertex,O=F.x-x.position.x,D=F.y-x.position.y,U=F.x-_.position.x,L=F.y-_.position.y,N=M-D*R-(k-L*I),z=E+O*R-(B+U*I),W=y*N+v*z,H=b*N+w*z,X=g.separation+W,V=Math.min(X,1),Y=(V=X<0?0:V)*S;H<-Y||H>Y?(i=H>0?H:-H,(r=g.friction*(H>0?1:-1)*h)<-i?r=-i:r>i&&(r=i)):(r=H,i=p);var j=O*v-D*y,$=U*v-L*y,q=P/(T+x.inverseInertia*j*j+_.inverseInertia*$*$),K=(1+g.restitution)*W*q;if(r*=q,W<c)G.normalImpulse=0;else{var Z=G.normalImpulse;G.normalImpulse+=K,G.normalImpulse>0&&(G.normalImpulse=0),K=G.normalImpulse-Z}if(H<-u||H>u)G.tangentImpulse=0;else{var Q=G.tangentImpulse;G.tangentImpulse+=r,G.tangentImpulse<-i&&(G.tangentImpulse=-i),G.tangentImpulse>i&&(G.tangentImpulse=i),r=G.tangentImpulse-Q}var J=y*K+b*r,tt=v*K+w*r;x.isStatic||x.isSleeping||(x.positionPrev.x+=J*x.inverseMass,x.positionPrev.y+=tt*x.inverseMass,x.anglePrev+=(O*tt-D*J)*x.inverseInertia),_.isStatic||_.isSleeping||(_.positionPrev.x-=J*_.inverseMass,_.positionPrev.y-=tt*_.inverseMass,_.anglePrev-=(U*tt-L*J)*_.inverseInertia)}}}}},function(t,e,r){var s={};t.exports=s;var i=r(9),n=r(0);s.create=function(t){return n.extend({table:{},list:[],collisionStart:[],collisionActive:[],collisionEnd:[]},t)},s.update=function(t,e,r){var s,n,o,a=i.update,l=i.create,h=i.setActive,c=t.table,u=t.list,d=u.length,p=d,f=t.collisionStart,g=t.collisionEnd,m=t.collisionActive,x=e.length,_=0,y=0,v=0;for(o=0;o<x;o++)(n=(s=e[o]).pair)?(n.isActive&&(m[v++]=n),a(n,s,r)):(c[(n=l(s,r)).id]=n,f[_++]=n,u[p++]=n);for(p=0,d=u.length,o=0;o<d;o++)(n=u[o]).timeUpdated>=r?u[p++]=n:(h(n,!1,r),n.collision.bodyA.sleepCounter>0&&n.collision.bodyB.sleepCounter>0?u[p++]=n:(g[y++]=n,delete c[n.id]));u.length!==p&&(u.length=p),f.length!==_&&(f.length=_),g.length!==y&&(g.length=y),m.length!==v&&(m.length=v)},s.clear=function(t){return t.table={},t.list.length=0,t.collisionStart.length=0,t.collisionActive.length=0,t.collisionEnd.length=0,t}},function(t,e,r){var s=t.exports=r(21);s.Axes=r(11),s.Bodies=r(12),s.Body=r(4),s.Bounds=r(1),s.Collision=r(8),s.Common=r(0),s.Composite=r(6),s.Composites=r(22),s.Constraint=r(10),s.Contact=r(16),s.Detector=r(13),s.Engine=r(17),s.Events=r(5),s.Grid=r(23),s.Mouse=r(14),s.MouseConstraint=r(24),s.Pair=r(9),s.Pairs=r(19),s.Plugin=r(15),s.Query=r(25),s.Render=r(26),s.Resolver=r(18),s.Runner=r(27),s.SAT=r(28),s.Sleeping=r(7),s.Svg=r(29),s.Vector=r(2),s.Vertices=r(3),s.World=r(30),s.Engine.run=s.Runner.run,s.Common.deprecated(s.Engine,"run","Engine.run ➤ use Matter.Runner.run(engine) instead")},function(t,e,r){var s={};t.exports=s;var i=r(15),n=r(0);s.name="matter-js",s.version="0.20.0",s.uses=[],s.used=[],s.use=function(){i.use(s,Array.prototype.slice.call(arguments))},s.before=function(t,e){return t=t.replace(/^Matter./,""),n.chainPathBefore(s,t,e)},s.after=function(t,e){return t=t.replace(/^Matter./,""),n.chainPathAfter(s,t,e)}},function(t,e,r){var s={};t.exports=s;var i=r(6),n=r(10),o=r(0),a=r(4),l=r(12),h=o.deprecated;s.stack=function(t,e,r,s,n,o,l){for(var h,c=i.create({label:"Stack"}),u=t,d=e,p=0,f=0;f<s;f++){for(var g=0,m=0;m<r;m++){var x=l(u,d,m,f,h,p);if(x){var _=x.bounds.max.y-x.bounds.min.y,y=x.bounds.max.x-x.bounds.min.x;_>g&&(g=_),a.translate(x,{x:.5*y,y:.5*_}),u=x.bounds.max.x+n,i.addBody(c,x),h=x,p+=1}else u+=n}d+=g+o,u=t}return c},s.chain=function(t,e,r,s,a,l){for(var h=t.bodies,c=1;c<h.length;c++){var u=h[c-1],d=h[c],p=u.bounds.max.y-u.bounds.min.y,f=u.bounds.max.x-u.bounds.min.x,g=d.bounds.max.y-d.bounds.min.y,m={bodyA:u,pointA:{x:f*e,y:p*r},bodyB:d,pointB:{x:(d.bounds.max.x-d.bounds.min.x)*s,y:g*a}},x=o.extend(m,l);i.addConstraint(t,n.create(x))}return t.label+=" Chain",t},s.mesh=function(t,e,r,s,a){var l,h,c,u,d,p=t.bodies;for(l=0;l<r;l++){for(h=1;h<e;h++)c=p[h-1+l*e],u=p[h+l*e],i.addConstraint(t,n.create(o.extend({bodyA:c,bodyB:u},a)));if(l>0)for(h=0;h<e;h++)c=p[h+(l-1)*e],u=p[h+l*e],i.addConstraint(t,n.create(o.extend({bodyA:c,bodyB:u},a))),s&&h>0&&(d=p[h-1+(l-1)*e],i.addConstraint(t,n.create(o.extend({bodyA:d,bodyB:u},a)))),s&&h<e-1&&(d=p[h+1+(l-1)*e],i.addConstraint(t,n.create(o.extend({bodyA:d,bodyB:u},a))))}return t.label+=" Mesh",t},s.pyramid=function(t,e,r,i,n,o,l){return s.stack(t,e,r,i,n,o,function(e,s,o,h,c,u){var d=Math.min(i,Math.ceil(r/2)),p=c?c.bounds.max.x-c.bounds.min.x:0;if(!(h>d||o<(h=d-h)||o>r-1-h))return 1===u&&a.translate(c,{x:(o+(r%2==1?1:-1))*p,y:0}),l(t+(c?o*p:0)+o*n,s,o,h,c,u)})},s.newtonsCradle=function(t,e,r,s,o){for(var a=i.create({label:"Newtons Cradle"}),h=0;h<r;h++){var c=l.circle(t+h*(1.9*s),e+o,s,{inertia:1/0,restitution:1,friction:0,frictionAir:1e-4,slop:1}),u=n.create({pointA:{x:t+h*(1.9*s),y:e},bodyB:c});i.addBody(a,c),i.addConstraint(a,u)}return a},h(s,"newtonsCradle","Composites.newtonsCradle ➤ moved to newtonsCradle example"),s.car=function(t,e,r,s,o){var h=a.nextGroup(!0),c=.5*-r+20,u=.5*r-20,d=i.create({label:"Car"}),p=l.rectangle(t,e,r,s,{collisionFilter:{group:h},chamfer:{radius:.5*s},density:2e-4}),f=l.circle(t+c,e+0,o,{collisionFilter:{group:h},friction:.8}),g=l.circle(t+u,e+0,o,{collisionFilter:{group:h},friction:.8}),m=n.create({bodyB:p,pointB:{x:c,y:0},bodyA:f,stiffness:1,length:0}),x=n.create({bodyB:p,pointB:{x:u,y:0},bodyA:g,stiffness:1,length:0});return i.addBody(d,p),i.addBody(d,f),i.addBody(d,g),i.addConstraint(d,m),i.addConstraint(d,x),d},h(s,"car","Composites.car ➤ moved to car example"),s.softBody=function(t,e,r,i,n,a,h,c,u,d){u=o.extend({inertia:1/0},u),d=o.extend({stiffness:.2,render:{type:"line",anchors:!1}},d);var p=s.stack(t,e,r,i,n,a,function(t,e){return l.circle(t,e,c,u)});return s.mesh(p,r,i,h,d),p.label="Soft Body",p},h(s,"softBody","Composites.softBody ➤ moved to softBody and cloth examples")},function(t,e,r){var s={};t.exports=s;var i=r(9),n=r(0),o=n.deprecated;s.create=function(t){return n.extend({buckets:{},pairs:{},pairsList:[],bucketWidth:48,bucketHeight:48},t)},s.update=function(t,e,r,i){var n,o,a,l,h,c=r.world,u=t.buckets,d=!1;for(n=0;n<e.length;n++){var p=e[n];if((!p.isSleeping||i)&&(!c.bounds||!(p.bounds.max.x<c.bounds.min.x||p.bounds.min.x>c.bounds.max.x||p.bounds.max.y<c.bounds.min.y||p.bounds.min.y>c.bounds.max.y))){var f=s._getRegion(t,p);if(!p.region||f.id!==p.region.id||i){p.region&&!i||(p.region=f);var g=s._regionUnion(f,p.region);for(o=g.startCol;o<=g.endCol;o++)for(a=g.startRow;a<=g.endRow;a++){l=u[h=s._getBucketId(o,a)];var m=o>=f.startCol&&o<=f.endCol&&a>=f.startRow&&a<=f.endRow,x=o>=p.region.startCol&&o<=p.region.endCol&&a>=p.region.startRow&&a<=p.region.endRow;!m&&x&&x&&l&&s._bucketRemoveBody(t,l,p),(p.region===f||m&&!x||i)&&(l||(l=s._createBucket(u,h)),s._bucketAddBody(t,l,p))}p.region=f,d=!0}}}d&&(t.pairsList=s._createActivePairsList(t))},o(s,"update","Grid.update ➤ replaced by Matter.Detector"),s.clear=function(t){t.buckets={},t.pairs={},t.pairsList=[]},o(s,"clear","Grid.clear ➤ replaced by Matter.Detector"),s._regionUnion=function(t,e){var r=Math.min(t.startCol,e.startCol),i=Math.max(t.endCol,e.endCol),n=Math.min(t.startRow,e.startRow),o=Math.max(t.endRow,e.endRow);return s._createRegion(r,i,n,o)},s._getRegion=function(t,e){var r=e.bounds,i=Math.floor(r.min.x/t.bucketWidth),n=Math.floor(r.max.x/t.bucketWidth),o=Math.floor(r.min.y/t.bucketHeight),a=Math.floor(r.max.y/t.bucketHeight);return s._createRegion(i,n,o,a)},s._createRegion=function(t,e,r,s){return{id:t+","+e+","+r+","+s,startCol:t,endCol:e,startRow:r,endRow:s}},s._getBucketId=function(t,e){return"C"+t+"R"+e},s._createBucket=function(t,e){return t[e]=[]},s._bucketAddBody=function(t,e,r){var s,n=t.pairs,o=i.id,a=e.length;for(s=0;s<a;s++){var l=e[s];if(!(r.id===l.id||r.isStatic&&l.isStatic)){var h=o(r,l),c=n[h];c?c[2]+=1:n[h]=[r,l,1]}}e.push(r)},s._bucketRemoveBody=function(t,e,r){var s,o=t.pairs,a=i.id;e.splice(n.indexOf(e,r),1);var l=e.length;for(s=0;s<l;s++){var h=o[a(r,e[s])];h&&(h[2]-=1)}},s._createActivePairsList=function(t){var e,r,s=t.pairs,i=n.keys(s),o=i.length,a=[];for(r=0;r<o;r++)(e=s[i[r]])[2]>0?a.push(e):delete s[i[r]];return a}},function(t,e,r){var s={};t.exports=s;var i=r(3),n=r(7),o=r(14),a=r(5),l=r(13),h=r(10),c=r(6),u=r(0),d=r(1);s.create=function(t,e){var r=(t?t.mouse:null)||(e?e.mouse:null);r||(t&&t.render&&t.render.canvas?r=o.create(t.render.canvas):e&&e.element?r=o.create(e.element):(r=o.create(),u.warn("MouseConstraint.create: options.mouse was undefined, options.element was undefined, may not function as expected")));var i={type:"mouseConstraint",mouse:r,element:null,body:null,constraint:h.create({label:"Mouse Constraint",pointA:r.position,pointB:{x:0,y:0},length:.01,stiffness:.1,angularStiffness:1,render:{strokeStyle:"#90EE90",lineWidth:3}}),collisionFilter:{category:1,mask:4294967295,group:0}},n=u.extend(i,e);return a.on(t,"beforeUpdate",function(){var e=c.allBodies(t.world);s.update(n,e),s._triggerEvents(n)}),n},s.update=function(t,e){var r=t.mouse,s=t.constraint,o=t.body;if(0===r.button){if(s.bodyB)n.set(s.bodyB,!1),s.pointA=r.position;else for(var h=0;h<e.length;h++)if(o=e[h],d.contains(o.bounds,r.position)&&l.canCollide(o.collisionFilter,t.collisionFilter))for(var c=o.parts.length>1?1:0;c<o.parts.length;c++){var u=o.parts[c];if(i.contains(u.vertices,r.position)){s.pointA=r.position,s.bodyB=t.body=o,s.pointB={x:r.position.x-o.position.x,y:r.position.y-o.position.y},s.angleB=o.angle,n.set(o,!1),a.trigger(t,"startdrag",{mouse:r,body:o});break}}}else s.bodyB=t.body=null,s.pointB=null,o&&a.trigger(t,"enddrag",{mouse:r,body:o})},s._triggerEvents=function(t){var e=t.mouse,r=e.sourceEvents;r.mousemove&&a.trigger(t,"mousemove",{mouse:e}),r.mousedown&&a.trigger(t,"mousedown",{mouse:e}),r.mouseup&&a.trigger(t,"mouseup",{mouse:e}),o.clearSourceEvents(e)}},function(t,e,r){var s={};t.exports=s;var i=r(2),n=r(8),o=r(1),a=r(12),l=r(3);s.collides=function(t,e){for(var r=[],s=e.length,i=t.bounds,a=n.collides,l=o.overlaps,h=0;h<s;h++){var c=e[h],u=c.parts.length,d=1===u?0:1;if(l(c.bounds,i))for(var p=d;p<u;p++){var f=c.parts[p];if(l(f.bounds,i)){var g=a(f,t);if(g){r.push(g);break}}}}return r},s.ray=function(t,e,r,n){n=n||1e-100;for(var o=i.angle(e,r),l=i.magnitude(i.sub(e,r)),h=.5*(r.x+e.x),c=.5*(r.y+e.y),u=a.rectangle(h,c,l,n,{angle:o}),d=s.collides(u,t),p=0;p<d.length;p+=1){var f=d[p];f.body=f.bodyB=f.bodyA}return d},s.region=function(t,e,r){for(var s=[],i=0;i<t.length;i++){var n=t[i],a=o.overlaps(n.bounds,e);(a&&!r||!a&&r)&&s.push(n)}return s},s.point=function(t,e){for(var r=[],s=0;s<t.length;s++){var i=t[s];if(o.contains(i.bounds,e))for(var n=1===i.parts.length?0:1;n<i.parts.length;n++){var a=i.parts[n];if(o.contains(a.bounds,e)&&l.contains(a.vertices,e)){r.push(i);break}}}return r}},function(t,e,r){var s={};t.exports=s;var i=r(4),n=r(0),o=r(6),a=r(1),l=r(5),h=r(2),c=r(14);!function(){var t,e;"undefined"!=typeof window&&(t=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(t){window.setTimeout(function(){t(n.now())},1e3/60)},e=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame),s._goodFps=30,s._goodDelta=1e3/60,s.create=function(t){var e={engine:null,element:null,canvas:null,mouse:null,frameRequestId:null,timing:{historySize:60,delta:0,deltaHistory:[],lastTime:0,lastTimestamp:0,lastElapsed:0,timestampElapsed:0,timestampElapsedHistory:[],engineDeltaHistory:[],engineElapsedHistory:[],engineUpdatesHistory:[],elapsedHistory:[]},options:{width:800,height:600,pixelRatio:1,background:"#14151f",wireframeBackground:"#14151f",wireframeStrokeStyle:"#bbb",hasBounds:!!t.bounds,enabled:!0,wireframes:!0,showSleeping:!0,showDebug:!1,showStats:!1,showPerformance:!1,showBounds:!1,showVelocity:!1,showCollisions:!1,showSeparations:!1,showAxes:!1,showPositions:!1,showAngleIndicator:!1,showIds:!1,showVertexNumbers:!1,showConvexHulls:!1,showInternalEdges:!1,showMousePosition:!1}},r=n.extend(e,t);return r.canvas&&(r.canvas.width=r.options.width||r.canvas.width,r.canvas.height=r.options.height||r.canvas.height),r.mouse=t.mouse,r.engine=t.engine,r.canvas=r.canvas||d(r.options.width,r.options.height),r.context=r.canvas.getContext("2d"),r.textures={},r.bounds=r.bounds||{min:{x:0,y:0},max:{x:r.canvas.width,y:r.canvas.height}},r.controller=s,r.options.showBroadphase=!1,1!==r.options.pixelRatio&&s.setPixelRatio(r,r.options.pixelRatio),n.isElement(r.element)&&r.element.appendChild(r.canvas),r},s.run=function(e){!function i(n){e.frameRequestId=t(i),r(e,n),s.world(e,n),e.context.setTransform(e.options.pixelRatio,0,0,e.options.pixelRatio,0,0),(e.options.showStats||e.options.showDebug)&&s.stats(e,e.context,n),(e.options.showPerformance||e.options.showDebug)&&s.performance(e,e.context,n),e.context.setTransform(1,0,0,1,0,0)}()},s.stop=function(t){e(t.frameRequestId)},s.setPixelRatio=function(t,e){var r=t.options,s=t.canvas;"auto"===e&&(e=p(s)),r.pixelRatio=e,s.setAttribute("data-pixel-ratio",e),s.width=r.width*e,s.height=r.height*e,s.style.width=r.width+"px",s.style.height=r.height+"px"},s.setSize=function(t,e,r){t.options.width=e,t.options.height=r,t.bounds.max.x=t.bounds.min.x+e,t.bounds.max.y=t.bounds.min.y+r,1!==t.options.pixelRatio?s.setPixelRatio(t,t.options.pixelRatio):(t.canvas.width=e,t.canvas.height=r)},s.lookAt=function(t,e,r,s){s=void 0===s||s,e=n.isArray(e)?e:[e],r=r||{x:0,y:0};for(var i={min:{x:1/0,y:1/0},max:{x:-1/0,y:-1/0}},o=0;o<e.length;o+=1){var a=e[o],l=a.bounds?a.bounds.min:a.min||a.position||a,h=a.bounds?a.bounds.max:a.max||a.position||a;l&&h&&(l.x<i.min.x&&(i.min.x=l.x),h.x>i.max.x&&(i.max.x=h.x),l.y<i.min.y&&(i.min.y=l.y),h.y>i.max.y&&(i.max.y=h.y))}var u=i.max.x-i.min.x+2*r.x,d=i.max.y-i.min.y+2*r.y,p=t.canvas.height,f=t.canvas.width/p,g=u/d,m=1,x=1;g>f?x=g/f:m=f/g,t.options.hasBounds=!0,t.bounds.min.x=i.min.x,t.bounds.max.x=i.min.x+u*m,t.bounds.min.y=i.min.y,t.bounds.max.y=i.min.y+d*x,s&&(t.bounds.min.x+=.5*u-u*m*.5,t.bounds.max.x+=.5*u-u*m*.5,t.bounds.min.y+=.5*d-d*x*.5,t.bounds.max.y+=.5*d-d*x*.5),t.bounds.min.x-=r.x,t.bounds.max.x-=r.x,t.bounds.min.y-=r.y,t.bounds.max.y-=r.y,t.mouse&&(c.setScale(t.mouse,{x:(t.bounds.max.x-t.bounds.min.x)/t.canvas.width,y:(t.bounds.max.y-t.bounds.min.y)/t.canvas.height}),c.setOffset(t.mouse,t.bounds.min))},s.startViewTransform=function(t){var e=t.bounds.max.x-t.bounds.min.x,r=t.bounds.max.y-t.bounds.min.y,s=e/t.options.width,i=r/t.options.height;t.context.setTransform(t.options.pixelRatio/s,0,0,t.options.pixelRatio/i,0,0),t.context.translate(-t.bounds.min.x,-t.bounds.min.y)},s.endViewTransform=function(t){t.context.setTransform(t.options.pixelRatio,0,0,t.options.pixelRatio,0,0)},s.world=function(t,e){var r,i=n.now(),u=t.engine,d=u.world,p=t.canvas,f=t.context,m=t.options,x=t.timing,_=o.allBodies(d),y=o.allConstraints(d),v=m.wireframes?m.wireframeBackground:m.background,b=[],w=[],T={timestamp:u.timing.timestamp};if(l.trigger(t,"beforeRender",T),t.currentBackground!==v&&g(t,v),f.globalCompositeOperation="source-in",f.fillStyle="transparent",f.fillRect(0,0,p.width,p.height),f.globalCompositeOperation="source-over",m.hasBounds){for(r=0;r<_.length;r++){var S=_[r];a.overlaps(S.bounds,t.bounds)&&b.push(S)}for(r=0;r<y.length;r++){var A=y[r],C=A.bodyA,P=A.bodyB,M=A.pointA,E=A.pointB;C&&(M=h.add(C.position,A.pointA)),P&&(E=h.add(P.position,A.pointB)),M&&E&&(a.contains(t.bounds,M)||a.contains(t.bounds,E))&&w.push(A)}s.startViewTransform(t),t.mouse&&(c.setScale(t.mouse,{x:(t.bounds.max.x-t.bounds.min.x)/t.options.width,y:(t.bounds.max.y-t.bounds.min.y)/t.options.height}),c.setOffset(t.mouse,t.bounds.min))}else w=y,b=_,1!==t.options.pixelRatio&&t.context.setTransform(t.options.pixelRatio,0,0,t.options.pixelRatio,0,0);!m.wireframes||u.enableSleeping&&m.showSleeping?s.bodies(t,b,f):(m.showConvexHulls&&s.bodyConvexHulls(t,b,f),s.bodyWireframes(t,b,f)),m.showBounds&&s.bodyBounds(t,b,f),(m.showAxes||m.showAngleIndicator)&&s.bodyAxes(t,b,f),m.showPositions&&s.bodyPositions(t,b,f),m.showVelocity&&s.bodyVelocity(t,b,f),m.showIds&&s.bodyIds(t,b,f),m.showSeparations&&s.separations(t,u.pairs.list,f),m.showCollisions&&s.collisions(t,u.pairs.list,f),m.showVertexNumbers&&s.vertexNumbers(t,b,f),m.showMousePosition&&s.mousePosition(t,t.mouse,f),s.constraints(w,f),m.hasBounds&&s.endViewTransform(t),l.trigger(t,"afterRender",T),x.lastElapsed=n.now()-i},s.stats=function(t,e,r){for(var s=t.engine,i=s.world,n=o.allBodies(i),a=0,l=0,h=0;h<n.length;h+=1)a+=n[h].parts.length;var c={Part:a,Body:n.length,Cons:o.allConstraints(i).length,Comp:o.allComposites(i).length,Pair:s.pairs.list.length};for(var u in e.fillStyle="#0e0f19",e.fillRect(l,0,302.5,44),e.font="12px Arial",e.textBaseline="top",e.textAlign="right",c){var d=c[u];e.fillStyle="#aaa",e.fillText(u,l+55,8),e.fillStyle="#eee",e.fillText(d,l+55,26),l+=55}},s.performance=function(t,e){var r=t.engine,i=t.timing,o=i.deltaHistory,a=i.elapsedHistory,l=i.timestampElapsedHistory,h=i.engineDeltaHistory,c=i.engineUpdatesHistory,d=i.engineElapsedHistory,p=r.timing.lastUpdatesPerFrame,f=r.timing.lastDelta,g=u(o),m=u(a),x=u(h),_=u(c),y=u(d),v=u(l)/g||0,b=Math.round(g/f),w=1e3/g||0,T=60,S=69;e.fillStyle="#0e0f19",e.fillRect(0,50,442,34),s.status(e,10,S,T,4,o.length,Math.round(w)+" fps",w/s._goodFps,function(t){return o[t]/g-1}),s.status(e,82,S,T,4,h.length,f.toFixed(2)+" dt",s._goodDelta/f,function(t){return h[t]/x-1}),s.status(e,154,S,T,4,c.length,p+" upf",Math.pow(n.clamp(_/b||1,0,1),4),function(t){return c[t]/_-1}),s.status(e,226,S,T,4,d.length,y.toFixed(2)+" ut",1-p*y/s._goodFps,function(t){return d[t]/y-1}),s.status(e,298,S,T,4,a.length,m.toFixed(2)+" rt",1-m/s._goodFps,function(t){return a[t]/m-1}),s.status(e,370,S,T,4,l.length,v.toFixed(2)+" x",v*v*v,function(t){return(l[t]/o[t]/v||0)-1})},s.status=function(t,e,r,s,i,o,a,l,h){t.strokeStyle="#888",t.fillStyle="#444",t.lineWidth=1,t.fillRect(e,r+7,s,1),t.beginPath(),t.moveTo(e,r+7-i*n.clamp(.4*h(0),-2,2));for(var c=0;c<s;c+=1)t.lineTo(e+c,r+7-(c<o?i*n.clamp(.4*h(c),-2,2):0));t.stroke(),t.fillStyle="hsl("+n.clamp(25+95*l,0,120)+",100%,60%)",t.fillRect(e,r-7,4,4),t.font="12px Arial",t.textBaseline="middle",t.textAlign="right",t.fillStyle="#eee",t.fillText(a,e+s,r-5)},s.constraints=function(t,e){for(var r=e,s=0;s<t.length;s++){var i=t[s];if(i.render.visible&&i.pointA&&i.pointB){var o,a,l=i.bodyA,c=i.bodyB;if(o=l?h.add(l.position,i.pointA):i.pointA,"pin"===i.render.type)r.beginPath(),r.arc(o.x,o.y,3,0,2*Math.PI),r.closePath();else{if(a=c?h.add(c.position,i.pointB):i.pointB,r.beginPath(),r.moveTo(o.x,o.y),"spring"===i.render.type)for(var u,d=h.sub(a,o),p=h.perp(h.normalise(d)),f=Math.ceil(n.clamp(i.length/5,12,20)),g=1;g<f;g+=1)u=g%2==0?1:-1,r.lineTo(o.x+d.x*(g/f)+p.x*u*4,o.y+d.y*(g/f)+p.y*u*4);r.lineTo(a.x,a.y)}i.render.lineWidth&&(r.lineWidth=i.render.lineWidth,r.strokeStyle=i.render.strokeStyle,r.stroke()),i.render.anchors&&(r.fillStyle=i.render.strokeStyle,r.beginPath(),r.arc(o.x,o.y,3,0,2*Math.PI),r.arc(a.x,a.y,3,0,2*Math.PI),r.closePath(),r.fill())}}},s.bodies=function(t,e,r){var s,i,n,o,a=r,l=(t.engine,t.options),h=l.showInternalEdges||!l.wireframes;for(n=0;n<e.length;n++)if((s=e[n]).render.visible)for(o=s.parts.length>1?1:0;o<s.parts.length;o++)if((i=s.parts[o]).render.visible){if(l.showSleeping&&s.isSleeping?a.globalAlpha=.5*i.render.opacity:1!==i.render.opacity&&(a.globalAlpha=i.render.opacity),i.render.sprite&&i.render.sprite.texture&&!l.wireframes){var c=i.render.sprite,u=f(t,c.texture);a.translate(i.position.x,i.position.y),a.rotate(i.angle),a.drawImage(u,u.width*-c.xOffset*c.xScale,u.height*-c.yOffset*c.yScale,u.width*c.xScale,u.height*c.yScale),a.rotate(-i.angle),a.translate(-i.position.x,-i.position.y)}else{if(i.circleRadius)a.beginPath(),a.arc(i.position.x,i.position.y,i.circleRadius,0,2*Math.PI);else{a.beginPath(),a.moveTo(i.vertices[0].x,i.vertices[0].y);for(var d=1;d<i.vertices.length;d++)!i.vertices[d-1].isInternal||h?a.lineTo(i.vertices[d].x,i.vertices[d].y):a.moveTo(i.vertices[d].x,i.vertices[d].y),i.vertices[d].isInternal&&!h&&a.moveTo(i.vertices[(d+1)%i.vertices.length].x,i.vertices[(d+1)%i.vertices.length].y);a.lineTo(i.vertices[0].x,i.vertices[0].y),a.closePath()}l.wireframes?(a.lineWidth=1,a.strokeStyle=t.options.wireframeStrokeStyle,a.stroke()):(a.fillStyle=i.render.fillStyle,i.render.lineWidth&&(a.lineWidth=i.render.lineWidth,a.strokeStyle=i.render.strokeStyle,a.stroke()),a.fill())}a.globalAlpha=1}},s.bodyWireframes=function(t,e,r){var s,i,n,o,a,l=r,h=t.options.showInternalEdges;for(l.beginPath(),n=0;n<e.length;n++)if((s=e[n]).render.visible)for(a=s.parts.length>1?1:0;a<s.parts.length;a++){for(i=s.parts[a],l.moveTo(i.vertices[0].x,i.vertices[0].y),o=1;o<i.vertices.length;o++)!i.vertices[o-1].isInternal||h?l.lineTo(i.vertices[o].x,i.vertices[o].y):l.moveTo(i.vertices[o].x,i.vertices[o].y),i.vertices[o].isInternal&&!h&&l.moveTo(i.vertices[(o+1)%i.vertices.length].x,i.vertices[(o+1)%i.vertices.length].y);l.lineTo(i.vertices[0].x,i.vertices[0].y)}l.lineWidth=1,l.strokeStyle=t.options.wireframeStrokeStyle,l.stroke()},s.bodyConvexHulls=function(t,e,r){var s,i,n,o=r;for(o.beginPath(),i=0;i<e.length;i++)if((s=e[i]).render.visible&&1!==s.parts.length){for(o.moveTo(s.vertices[0].x,s.vertices[0].y),n=1;n<s.vertices.length;n++)o.lineTo(s.vertices[n].x,s.vertices[n].y);o.lineTo(s.vertices[0].x,s.vertices[0].y)}o.lineWidth=1,o.strokeStyle="rgba(255,255,255,0.2)",o.stroke()},s.vertexNumbers=function(t,e,r){var s,i,n,o=r;for(s=0;s<e.length;s++){var a=e[s].parts;for(n=a.length>1?1:0;n<a.length;n++){var l=a[n];for(i=0;i<l.vertices.length;i++)o.fillStyle="rgba(255,255,255,0.2)",o.fillText(s+"_"+i,l.position.x+.8*(l.vertices[i].x-l.position.x),l.position.y+.8*(l.vertices[i].y-l.position.y))}}},s.mousePosition=function(t,e,r){var s=r;s.fillStyle="rgba(255,255,255,0.8)",s.fillText(e.position.x+" "+e.position.y,e.position.x+5,e.position.y-5)},s.bodyBounds=function(t,e,r){var s=r,i=(t.engine,t.options);s.beginPath();for(var n=0;n<e.length;n++)if(e[n].render.visible)for(var o=e[n].parts,a=o.length>1?1:0;a<o.length;a++){var l=o[a];s.rect(l.bounds.min.x,l.bounds.min.y,l.bounds.max.x-l.bounds.min.x,l.bounds.max.y-l.bounds.min.y)}i.wireframes?s.strokeStyle="rgba(255,255,255,0.08)":s.strokeStyle="rgba(0,0,0,0.1)",s.lineWidth=1,s.stroke()},s.bodyAxes=function(t,e,r){var s,i,n,o,a=r,l=(t.engine,t.options);for(a.beginPath(),i=0;i<e.length;i++){var h=e[i],c=h.parts;if(h.render.visible)if(l.showAxes)for(n=c.length>1?1:0;n<c.length;n++)for(s=c[n],o=0;o<s.axes.length;o++){var u=s.axes[o];a.moveTo(s.position.x,s.position.y),a.lineTo(s.position.x+20*u.x,s.position.y+20*u.y)}else for(n=c.length>1?1:0;n<c.length;n++)for(s=c[n],o=0;o<s.axes.length;o++)a.moveTo(s.position.x,s.position.y),a.lineTo((s.vertices[0].x+s.vertices[s.vertices.length-1].x)/2,(s.vertices[0].y+s.vertices[s.vertices.length-1].y)/2)}l.wireframes?(a.strokeStyle="indianred",a.lineWidth=1):(a.strokeStyle="rgba(255, 255, 255, 0.4)",a.globalCompositeOperation="overlay",a.lineWidth=2),a.stroke(),a.globalCompositeOperation="source-over"},s.bodyPositions=function(t,e,r){var s,i,n,o,a=r,l=(t.engine,t.options);for(a.beginPath(),n=0;n<e.length;n++)if((s=e[n]).render.visible)for(o=0;o<s.parts.length;o++)i=s.parts[o],a.arc(i.position.x,i.position.y,3,0,2*Math.PI,!1),a.closePath();for(l.wireframes?a.fillStyle="indianred":a.fillStyle="rgba(0,0,0,0.5)",a.fill(),a.beginPath(),n=0;n<e.length;n++)(s=e[n]).render.visible&&(a.arc(s.positionPrev.x,s.positionPrev.y,2,0,2*Math.PI,!1),a.closePath());a.fillStyle="rgba(255,165,0,0.8)",a.fill()},s.bodyVelocity=function(t,e,r){var s=r;s.beginPath();for(var n=0;n<e.length;n++){var o=e[n];if(o.render.visible){var a=i.getVelocity(o);s.moveTo(o.position.x,o.position.y),s.lineTo(o.position.x+a.x,o.position.y+a.y)}}s.lineWidth=3,s.strokeStyle="cornflowerblue",s.stroke()},s.bodyIds=function(t,e,r){var s,i,n=r;for(s=0;s<e.length;s++)if(e[s].render.visible){var o=e[s].parts;for(i=o.length>1?1:0;i<o.length;i++){var a=o[i];n.font="12px Arial",n.fillStyle="rgba(255,255,255,0.5)",n.fillText(a.id,a.position.x+10,a.position.y-10)}}},s.collisions=function(t,e,r){var s,i,n,o,a=r,l=t.options;for(a.beginPath(),n=0;n<e.length;n++)if((s=e[n]).isActive)for(i=s.collision,o=0;o<s.contactCount;o++){var h=s.contacts[o].vertex;a.rect(h.x-1.5,h.y-1.5,3.5,3.5)}for(l.wireframes?a.fillStyle="rgba(255,255,255,0.7)":a.fillStyle="orange",a.fill(),a.beginPath(),n=0;n<e.length;n++)if((s=e[n]).isActive&&(i=s.collision,s.contactCount>0)){var c=s.contacts[0].vertex.x,u=s.contacts[0].vertex.y;2===s.contactCount&&(c=(s.contacts[0].vertex.x+s.contacts[1].vertex.x)/2,u=(s.contacts[0].vertex.y+s.contacts[1].vertex.y)/2),i.bodyB===i.supports[0].body||!0===i.bodyA.isStatic?a.moveTo(c-8*i.normal.x,u-8*i.normal.y):a.moveTo(c+8*i.normal.x,u+8*i.normal.y),a.lineTo(c,u)}l.wireframes?a.strokeStyle="rgba(255,165,0,0.7)":a.strokeStyle="orange",a.lineWidth=1,a.stroke()},s.separations=function(t,e,r){var s,i,n,o,a,l=r,h=t.options;for(l.beginPath(),a=0;a<e.length;a++)if((s=e[a]).isActive){n=(i=s.collision).bodyA;var c=1;(o=i.bodyB).isStatic||n.isStatic||(c=.5),o.isStatic&&(c=0),l.moveTo(o.position.x,o.position.y),l.lineTo(o.position.x-i.penetration.x*c,o.position.y-i.penetration.y*c),c=1,o.isStatic||n.isStatic||(c=.5),n.isStatic&&(c=0),l.moveTo(n.position.x,n.position.y),l.lineTo(n.position.x+i.penetration.x*c,n.position.y+i.penetration.y*c)}h.wireframes?l.strokeStyle="rgba(255,165,0,0.5)":l.strokeStyle="orange",l.stroke()},s.inspector=function(t,e){t.engine;var r,s=t.selected,i=t.render,n=i.options;if(n.hasBounds){var o=i.bounds.max.x-i.bounds.min.x,a=i.bounds.max.y-i.bounds.min.y,l=o/i.options.width,h=a/i.options.height;e.scale(1/l,1/h),e.translate(-i.bounds.min.x,-i.bounds.min.y)}for(var c=0;c<s.length;c++){var u=s[c].data;switch(e.translate(.5,.5),e.lineWidth=1,e.strokeStyle="rgba(255,165,0,0.9)",e.setLineDash([1,2]),u.type){case"body":r=u.bounds,e.beginPath(),e.rect(Math.floor(r.min.x-3),Math.floor(r.min.y-3),Math.floor(r.max.x-r.min.x+6),Math.floor(r.max.y-r.min.y+6)),e.closePath(),e.stroke();break;case"constraint":var d=u.pointA;u.bodyA&&(d=u.pointB),e.beginPath(),e.arc(d.x,d.y,10,0,2*Math.PI),e.closePath(),e.stroke()}e.setLineDash([]),e.translate(-.5,-.5)}null!==t.selectStart&&(e.translate(.5,.5),e.lineWidth=1,e.strokeStyle="rgba(255,165,0,0.6)",e.fillStyle="rgba(255,165,0,0.1)",r=t.selectBounds,e.beginPath(),e.rect(Math.floor(r.min.x),Math.floor(r.min.y),Math.floor(r.max.x-r.min.x),Math.floor(r.max.y-r.min.y)),e.closePath(),e.stroke(),e.fill(),e.translate(-.5,-.5)),n.hasBounds&&e.setTransform(1,0,0,1,0,0)};var r=function(t,e){var r=t.engine,i=t.timing,n=i.historySize,o=r.timing.timestamp;i.delta=e-i.lastTime||s._goodDelta,i.lastTime=e,i.timestampElapsed=o-i.lastTimestamp||0,i.lastTimestamp=o,i.deltaHistory.unshift(i.delta),i.deltaHistory.length=Math.min(i.deltaHistory.length,n),i.engineDeltaHistory.unshift(r.timing.lastDelta),i.engineDeltaHistory.length=Math.min(i.engineDeltaHistory.length,n),i.timestampElapsedHistory.unshift(i.timestampElapsed),i.timestampElapsedHistory.length=Math.min(i.timestampElapsedHistory.length,n),i.engineUpdatesHistory.unshift(r.timing.lastUpdatesPerFrame),i.engineUpdatesHistory.length=Math.min(i.engineUpdatesHistory.length,n),i.engineElapsedHistory.unshift(r.timing.lastElapsed),i.engineElapsedHistory.length=Math.min(i.engineElapsedHistory.length,n),i.elapsedHistory.unshift(i.lastElapsed),i.elapsedHistory.length=Math.min(i.elapsedHistory.length,n)},u=function(t){for(var e=0,r=0;r<t.length;r+=1)e+=t[r];return e/t.length||0},d=function(t,e){var r=document.createElement("canvas");return r.width=t,r.height=e,r.oncontextmenu=function(){return!1},r.onselectstart=function(){return!1},r},p=function(t){var e=t.getContext("2d");return(window.devicePixelRatio||1)/(e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1)},f=function(t,e){var r=t.textures[e];return r||((r=t.textures[e]=new Image).src=e,r)},g=function(t,e){var r=e;/(jpg|gif|png)$/.test(e)&&(r="url("+e+")"),t.canvas.style.background=r,t.canvas.style.backgroundSize="contain",t.currentBackground=e}}()},function(t,e,r){var s={};t.exports=s;var i=r(5),n=r(17),o=r(0);!function(){s._maxFrameDelta=1e3/15,s._frameDeltaFallback=1e3/60,s._timeBufferMargin=1.5,s._elapsedNextEstimate=1,s._smoothingLowerBound=.1,s._smoothingUpperBound=.9,s.create=function(t){var e=o.extend({delta:1e3/60,frameDelta:null,frameDeltaSmoothing:!0,frameDeltaSnapping:!0,frameDeltaHistory:[],frameDeltaHistorySize:100,frameRequestId:null,timeBuffer:0,timeLastTick:null,maxUpdates:null,maxFrameTime:1e3/30,lastUpdatesDeferred:0,enabled:!0},t);return e.fps=0,e},s.run=function(t,e){return t.timeBuffer=s._frameDeltaFallback,function r(i){t.frameRequestId=s._onNextFrame(t,r),i&&t.enabled&&s.tick(t,e,i)}(),t},s.tick=function(e,r,a){var l=o.now(),h=e.delta,c=0,u=a-e.timeLastTick;if((!u||!e.timeLastTick||u>Math.max(s._maxFrameDelta,e.maxFrameTime))&&(u=e.frameDelta||s._frameDeltaFallback),e.frameDeltaSmoothing){e.frameDeltaHistory.push(u),e.frameDeltaHistory=e.frameDeltaHistory.slice(-e.frameDeltaHistorySize);var d=e.frameDeltaHistory.slice(0).sort(),p=e.frameDeltaHistory.slice(d.length*s._smoothingLowerBound,d.length*s._smoothingUpperBound);u=t(p)||u}e.frameDeltaSnapping&&(u=1e3/Math.round(1e3/u)),e.frameDelta=u,e.timeLastTick=a,e.timeBuffer+=e.frameDelta,e.timeBuffer=o.clamp(e.timeBuffer,0,e.frameDelta+h*s._timeBufferMargin),e.lastUpdatesDeferred=0;var f=e.maxUpdates||Math.ceil(e.maxFrameTime/h),g={timestamp:r.timing.timestamp};i.trigger(e,"beforeTick",g),i.trigger(e,"tick",g);for(var m=o.now();h>0&&e.timeBuffer>=h*s._timeBufferMargin;){i.trigger(e,"beforeUpdate",g),n.update(r,h),i.trigger(e,"afterUpdate",g),e.timeBuffer-=h,c+=1;var x=o.now()-l,_=o.now()-m,y=x+s._elapsedNextEstimate*_/c;if(c>=f||y>e.maxFrameTime){e.lastUpdatesDeferred=Math.round(Math.max(0,e.timeBuffer/h-s._timeBufferMargin));break}}r.timing.lastUpdatesPerFrame=c,i.trigger(e,"afterTick",g),e.frameDeltaHistory.length>=100&&(e.lastUpdatesDeferred&&Math.round(e.frameDelta/h)>f?o.warnOnce("Matter.Runner: runner reached runner.maxUpdates, see docs."):e.lastUpdatesDeferred&&o.warnOnce("Matter.Runner: runner reached runner.maxFrameTime, see docs."),void 0!==e.isFixed&&o.warnOnce("Matter.Runner: runner.isFixed is now redundant, see docs."),(e.deltaMin||e.deltaMax)&&o.warnOnce("Matter.Runner: runner.deltaMin and runner.deltaMax were removed, see docs."),0!==e.fps&&o.warnOnce("Matter.Runner: runner.fps was replaced by runner.delta, see docs."))},s.stop=function(t){s._cancelNextFrame(t)},s._onNextFrame=function(t,e){if("undefined"==typeof window||!window.requestAnimationFrame)throw new Error("Matter.Runner: missing required global window.requestAnimationFrame.");return t.frameRequestId=window.requestAnimationFrame(e),t.frameRequestId},s._cancelNextFrame=function(t){if("undefined"==typeof window||!window.cancelAnimationFrame)throw new Error("Matter.Runner: missing required global window.cancelAnimationFrame.");window.cancelAnimationFrame(t.frameRequestId)};var t=function(t){for(var e=0,r=t.length,s=0;s<r;s+=1)e+=t[s];return e/r||0}}()},function(t,e,r){var s={};t.exports=s;var i=r(8),n=r(0).deprecated;s.collides=function(t,e){return i.collides(t,e)},n(s,"collides","SAT.collides ➤ replaced by Collision.collides")},function(t,e,r){var s={};t.exports=s,r(1);var i=r(0);s.pathToVertices=function(t,e){"undefined"==typeof window||"SVGPathSeg"in window||i.warn("Svg.pathToVertices: SVGPathSeg not defined, a polyfill is required.");var r,n,o,a,l,h,c,u,d,p,f,g=[],m=0,x=0,_=0;e=e||15;var y=function(t,e,r){var s=r%2==1&&r>1;if(!d||t!=d.x||e!=d.y){d&&s?(p=d.x,f=d.y):(p=0,f=0);var i={x:p+t,y:f+e};!s&&d||(d=i),g.push(i),x=p+t,_=f+e}},v=function(t){var e=t.pathSegTypeAsLetter.toUpperCase();if("Z"!==e){switch(e){case"M":case"L":case"T":case"C":case"S":case"Q":x=t.x,_=t.y;break;case"H":x=t.x;break;case"V":_=t.y}y(x,_,t.pathSegType)}};for(s._svgPathToAbsolute(t),o=t.getTotalLength(),h=[],r=0;r<t.pathSegList.numberOfItems;r+=1)h.push(t.pathSegList.getItem(r));for(c=h.concat();m<o;){if((l=h[t.getPathSegAtLength(m)])!=u){for(;c.length&&c[0]!=l;)v(c.shift());u=l}switch(l.pathSegTypeAsLetter.toUpperCase()){case"C":case"T":case"S":case"Q":case"A":a=t.getPointAtLength(m),y(a.x,a.y,0)}m+=e}for(r=0,n=c.length;r<n;++r)v(c[r]);return g},s._svgPathToAbsolute=function(t){for(var e,r,s,i,n,o,a=t.pathSegList,l=0,h=0,c=a.numberOfItems,u=0;u<c;++u){var d=a.getItem(u),p=d.pathSegTypeAsLetter;if(/[MLHVCSQTA]/.test(p))"x"in d&&(l=d.x),"y"in d&&(h=d.y);else switch("x1"in d&&(s=l+d.x1),"x2"in d&&(n=l+d.x2),"y1"in d&&(i=h+d.y1),"y2"in d&&(o=h+d.y2),"x"in d&&(l+=d.x),"y"in d&&(h+=d.y),p){case"m":a.replaceItem(t.createSVGPathSegMovetoAbs(l,h),u);break;case"l":a.replaceItem(t.createSVGPathSegLinetoAbs(l,h),u);break;case"h":a.replaceItem(t.createSVGPathSegLinetoHorizontalAbs(l),u);break;case"v":a.replaceItem(t.createSVGPathSegLinetoVerticalAbs(h),u);break;case"c":a.replaceItem(t.createSVGPathSegCurvetoCubicAbs(l,h,s,i,n,o),u);break;case"s":a.replaceItem(t.createSVGPathSegCurvetoCubicSmoothAbs(l,h,n,o),u);break;case"q":a.replaceItem(t.createSVGPathSegCurvetoQuadraticAbs(l,h,s,i),u);break;case"t":a.replaceItem(t.createSVGPathSegCurvetoQuadraticSmoothAbs(l,h),u);break;case"a":a.replaceItem(t.createSVGPathSegArcAbs(l,h,d.r1,d.r2,d.angle,d.largeArcFlag,d.sweepFlag),u);break;case"z":case"Z":l=e,h=r}"M"!=p&&"m"!=p||(e=l,r=h)}}},function(t,e,r){var s={};t.exports=s;var i=r(6);r(0),s.create=i.create,s.add=i.add,s.remove=i.remove,s.clear=i.clear,s.addComposite=i.addComposite,s.addBody=i.addBody,s.addConstraint=i.addConstraint}])},t.exports=s()},8851:(t,e,r)=>{"use strict";r.d(e,{W:()=>h});var s=r(9437),i=r(1753),n=r(4269),o=r(9739),a=r(8896);let l=0;const h=new class{constructor(t){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this.textureStyle=new a.n(this.textureOptions)}createTexture(t,e,r){const s=new n.v({...this.textureOptions,width:t,height:e,resolution:1,antialias:r,autoGarbageCollect:!1});return new o.g({source:s,label:"texturePool_"+l++})}getOptimalTexture(t,e,r=1,i){let n=Math.ceil(t*r-1e-6),o=Math.ceil(e*r-1e-6);n=(0,s.U5)(n),o=(0,s.U5)(o);const a=(n<<17)+(o<<1)+(i?1:0);this._texturePool[a]||(this._texturePool[a]=[]);let l=this._texturePool[a].pop();return l||(l=this.createTexture(n,o,i)),l.source._resolution=r,l.source.width=n/r,l.source.height=o/r,l.source.pixelWidth=n,l.source.pixelHeight=o,l.frame.x=0,l.frame.y=0,l.frame.width=t,l.frame.height=e,l.updateUvs(),this._poolKeyHash[l.uid]=a,l}getSameSizeTexture(t,e=!1){const r=t.source;return this.getOptimalTexture(t.width,t.height,r._resolution,e)}returnTexture(t,e=!1){const r=this._poolKeyHash[t.uid];e&&(t.source.style=this.textureStyle),this._texturePool[r].push(t)}clear(t){if(t=!1!==t)for(const t in this._texturePool){const e=this._texturePool[t];if(e)for(let t=0;t<e.length;t++)e[t].destroy(!0)}this._texturePool={}}};i.L.register(h)},8869:(t,e,r)=>{"use strict";r.d(e,{A:()=>o});var s=r(5423);function i(t){if("string"!=typeof t)throw new TypeError(`Path must be a string. Received ${JSON.stringify(t)}`)}function n(t){return t.split("?")[0].split("#")[0]}const o={toPosix:t=>t.replace(new RegExp("\\".replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),"/"),isUrl(t){return/^https?:/.test(this.toPosix(t))},isDataUrl:t=>/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(t),isBlobUrl:t=>t.startsWith("blob:"),hasProtocol(t){return/^[^/:]+:/.test(this.toPosix(t))},getProtocol(t){i(t),t=this.toPosix(t);const e=/^file:\/\/\//.exec(t);if(e)return e[0];const r=/^[^/:]+:\/{0,2}/.exec(t);return r?r[0]:""},toAbsolute(t,e,r){if(i(t),this.isDataUrl(t)||this.isBlobUrl(t))return t;const a=n(this.toPosix(e??s.e.get().getBaseUrl())),l=n(this.toPosix(r??this.rootname(a)));return(t=this.toPosix(t)).startsWith("/")?o.join(l,t.slice(1)):this.isAbsolute(t)?t:this.join(a,t)},normalize(t){if(i(t),0===t.length)return".";if(this.isDataUrl(t)||this.isBlobUrl(t))return t;let e="";const r=(t=this.toPosix(t)).startsWith("/");this.hasProtocol(t)&&(e=this.rootname(t),t=t.slice(e.length));const s=t.endsWith("/");return(t=function(t){let e="",r=0,s=-1,i=0,n=-1;for(let o=0;o<=t.length;++o){if(o<t.length)n=t.charCodeAt(o);else{if(47===n)break;n=47}if(47===n){if(s===o-1||1===i);else if(s!==o-1&&2===i){if(e.length<2||2!==r||46!==e.charCodeAt(e.length-1)||46!==e.charCodeAt(e.length-2))if(e.length>2){const t=e.lastIndexOf("/");if(t!==e.length-1){-1===t?(e="",r=0):(e=e.slice(0,t),r=e.length-1-e.lastIndexOf("/")),s=o,i=0;continue}}else if(2===e.length||1===e.length){e="",r=0,s=o,i=0;continue}}else e.length>0?e+=`/${t.slice(s+1,o)}`:e=t.slice(s+1,o),r=o-s-1;s=o,i=0}else 46===n&&-1!==i?++i:i=-1}return e}(t)).length>0&&s&&(t+="/"),r?`/${t}`:e+t},isAbsolute(t){return i(t),t=this.toPosix(t),!!this.hasProtocol(t)||t.startsWith("/")},join(...t){if(0===t.length)return".";let e;for(let r=0;r<t.length;++r){const s=t[r];if(i(s),s.length>0)if(void 0===e)e=s;else{const i=t[r-1]??"";this.joinExtensions.includes(this.extname(i).toLowerCase())?e+=`/../${s}`:e+=`/${s}`}}return void 0===e?".":this.normalize(e)},dirname(t){if(i(t),0===t.length)return".";let e=(t=this.toPosix(t)).charCodeAt(0);const r=47===e;let s=-1,n=!0;const o=this.getProtocol(t),a=t;for(let r=(t=t.slice(o.length)).length-1;r>=1;--r)if(e=t.charCodeAt(r),47===e){if(!n){s=r;break}}else n=!1;return-1===s?r?"/":this.isUrl(a)?o+t:o:r&&1===s?"//":o+t.slice(0,s)},rootname(t){i(t);let e="";if(e=(t=this.toPosix(t)).startsWith("/")?"/":this.getProtocol(t),this.isUrl(t)){const r=t.indexOf("/",e.length);e=-1!==r?t.slice(0,r):t,e.endsWith("/")||(e+="/")}return e},basename(t,e){i(t),e&&i(e),t=n(this.toPosix(t));let r,s=0,o=-1,a=!0;if(void 0!==e&&e.length>0&&e.length<=t.length){if(e.length===t.length&&e===t)return"";let i=e.length-1,n=-1;for(r=t.length-1;r>=0;--r){const l=t.charCodeAt(r);if(47===l){if(!a){s=r+1;break}}else-1===n&&(a=!1,n=r+1),i>=0&&(l===e.charCodeAt(i)?-1===--i&&(o=r):(i=-1,o=n))}return s===o?o=n:-1===o&&(o=t.length),t.slice(s,o)}for(r=t.length-1;r>=0;--r)if(47===t.charCodeAt(r)){if(!a){s=r+1;break}}else-1===o&&(a=!1,o=r+1);return-1===o?"":t.slice(s,o)},extname(t){i(t);let e=-1,r=0,s=-1,o=!0,a=0;for(let i=(t=n(this.toPosix(t))).length-1;i>=0;--i){const n=t.charCodeAt(i);if(47!==n)-1===s&&(o=!1,s=i+1),46===n?-1===e?e=i:1!==a&&(a=1):-1!==e&&(a=-1);else if(!o){r=i+1;break}}return-1===e||-1===s||0===a||1===a&&e===s-1&&e===r+1?"":t.slice(e,s)},parse(t){i(t);const e={root:"",dir:"",base:"",ext:"",name:""};if(0===t.length)return e;let r=(t=n(this.toPosix(t))).charCodeAt(0);const s=this.isAbsolute(t);let o;e.root=this.rootname(t),o=s||this.hasProtocol(t)?1:0;let a=-1,l=0,h=-1,c=!0,u=t.length-1,d=0;for(;u>=o;--u)if(r=t.charCodeAt(u),47!==r)-1===h&&(c=!1,h=u+1),46===r?-1===a?a=u:1!==d&&(d=1):-1!==a&&(d=-1);else if(!c){l=u+1;break}return-1===a||-1===h||0===d||1===d&&a===h-1&&a===l+1?-1!==h&&(e.base=e.name=0===l&&s?t.slice(1,h):t.slice(l,h)):(0===l&&s?(e.name=t.slice(1,a),e.base=t.slice(1,h)):(e.name=t.slice(l,a),e.base=t.slice(l,h)),e.ext=t.slice(a,h)),e.dir=this.dirname(t),e},sep:"/",delimiter:":",joinExtensions:[".html"]}},8883:(t,e,r)=>{"use strict";let s;function i(){if("boolean"==typeof s)return s;try{const t=new Function("param1","param2","param3","return param1[param2] === param3;");s=!0===t({a:"b"},"a","b")}catch(t){s=!1}return s}r.d(e,{f:()=>i})},8896:(t,e,r)=>{"use strict";r.d(e,{n:()=>l});var s=r(4872),i=r(9375),n=r(4696);const o=Object.create(null),a=class t extends s.A{constructor(e={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,e={...t.defaultOptions,...e},this.addressMode=e.addressMode,this.addressModeU=e.addressModeU??this.addressModeU,this.addressModeV=e.addressModeV??this.addressModeV,this.addressModeW=e.addressModeW??this.addressModeW,this.scaleMode=e.scaleMode,this.magFilter=e.magFilter??this.magFilter,this.minFilter=e.minFilter??this.minFilter,this.mipmapFilter=e.mipmapFilter??this.mipmapFilter,this.lodMinClamp=e.lodMinClamp,this.lodMaxClamp=e.lodMaxClamp,this.compare=e.compare,this.maxAnisotropy=e.maxAnisotropy??1}set addressMode(t){this.addressModeU=t,this.addressModeV=t,this.addressModeW=t}get addressMode(){return this.addressModeU}set wrapMode(t){(0,n.t6)(n.lj,"TextureStyle.wrapMode is now TextureStyle.addressMode"),this.addressMode=t}get wrapMode(){return this.addressMode}set scaleMode(t){this.magFilter=t,this.minFilter=t,this.mipmapFilter=t}get scaleMode(){return this.magFilter}set maxAnisotropy(t){this._maxAnisotropy=Math.min(t,16),this._maxAnisotropy>1&&(this.scaleMode="linear")}get maxAnisotropy(){return this._maxAnisotropy}get _resourceId(){return this._sharedResourceId||this._generateResourceId()}update(){this.emit("change",this),this._sharedResourceId=null}_generateResourceId(){const t=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=function(t){const e=o[t];return void 0===e&&(o[t]=(0,i.L)("resource")),e}(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};a.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let l=a},8900:(t,e,r)=>{"use strict";r.d(e,{l:()=>d});var s=r(5199),i=r(9390),n=r(1711),o=r(2255),a=r(1386),l=r(4269),h=r(9739),c=r(8955),u=r(2277);class d{constructor(t){this.rootViewPort=new i.M,this.viewport=new i.M,this.onRenderTargetChange=new o.C("onRenderTargetChange"),this.projectionMatrix=new s.u,this.defaultClearColor=[0,0,0,0],this._renderSurfaceToRenderTargetHash=new Map,this._gpuRenderTargetHash=Object.create(null),this._renderTargetStack=[],this._renderer=t,t.renderableGC.addManagedHash(this,"_gpuRenderTargetHash")}finishRenderPass(){this.adaptor.finishRenderPass(this.renderTarget)}renderStart({target:t,clear:e,clearColor:r,frame:s}){this._renderTargetStack.length=0,this.push(t,e,r,s),this.rootViewPort.copyFrom(this.viewport),this.rootRenderTarget=this.renderTarget,this.renderingToScreen=function(t){const e=t.colorTexture.source.resource;return globalThis.HTMLCanvasElement&&e instanceof HTMLCanvasElement&&document.body.contains(e)}(this.rootRenderTarget),this.adaptor.prerender?.(this.rootRenderTarget)}postrender(){this.adaptor.postrender?.(this.rootRenderTarget)}bind(t,e=!0,r,s){const i=this.getRenderTarget(t),n=this.renderTarget!==i;this.renderTarget=i,this.renderSurface=t;const o=this.getGpuRenderTarget(i);i.pixelWidth===o.width&&i.pixelHeight===o.height||(this.adaptor.resizeGpuRenderTarget(i),o.width=i.pixelWidth,o.height=i.pixelHeight);const a=i.colorTexture,l=this.viewport,c=a.pixelWidth,u=a.pixelHeight;if(!s&&t instanceof h.g&&(s=t.frame),s){const t=a._resolution;l.x=s.x*t+.5|0,l.y=s.y*t+.5|0,l.width=s.width*t+.5|0,l.height=s.height*t+.5|0}else l.x=0,l.y=0,l.width=c,l.height=u;return function(t,e,r,s,i,n){const o=n?1:-1;t.identity(),t.a=1/s*2,t.d=o*(1/i*2),t.tx=-1-0*t.a,t.ty=-o-0*t.d}(this.projectionMatrix,0,0,l.width/a.resolution,l.height/a.resolution,!i.isRoot),this.adaptor.startRenderPass(i,e,r,l),n&&this.onRenderTargetChange.emit(i),i}clear(t,e=n.u.ALL,r){e&&(t&&(t=this.getRenderTarget(t)),this.adaptor.clear(t||this.renderTarget,e,r,this.viewport))}contextChange(){this._gpuRenderTargetHash=Object.create(null)}push(t,e=n.u.ALL,r,s){const i=this.bind(t,e,r,s);return this._renderTargetStack.push({renderTarget:i,frame:s}),i}pop(){this._renderTargetStack.pop();const t=this._renderTargetStack[this._renderTargetStack.length-1];this.bind(t.renderTarget,!1,null,t.frame)}getRenderTarget(t){return t.isTexture&&(t=t.source),this._renderSurfaceToRenderTargetHash.get(t)??this._initRenderTarget(t)}copyToTexture(t,e,r,s,i){r.x<0&&(s.width+=r.x,i.x-=r.x,r.x=0),r.y<0&&(s.height+=r.y,i.y-=r.y,r.y=0);const{pixelWidth:n,pixelHeight:o}=t;return s.width=Math.min(s.width,n-r.x),s.height=Math.min(s.height,o-r.y),this.adaptor.copyToTexture(t,e,r,s,i)}ensureDepthStencil(){this.renderTarget.stencil||(this.renderTarget.stencil=!0,this.adaptor.startRenderPass(this.renderTarget,!1,null,this.viewport))}destroy(){this._renderer=null,this._renderSurfaceToRenderTargetHash.forEach((t,e)=>{t!==e&&t.destroy()}),this._renderSurfaceToRenderTargetHash.clear(),this._gpuRenderTargetHash=Object.create(null)}_initRenderTarget(t){let e=null;return a.q.test(t)&&(t=(0,c.c)(t).source),t instanceof u.O?e=t:t instanceof l.v&&(e=new u.O({colorTextures:[t]}),t.source instanceof a.q&&(e.isRoot=!0),t.once("destroy",()=>{e.destroy(),this._renderSurfaceToRenderTargetHash.delete(t);const r=this._gpuRenderTargetHash[e.uid];r&&(this._gpuRenderTargetHash[e.uid]=null,this.adaptor.destroyGpuRenderTarget(r))})),this._renderSurfaceToRenderTargetHash.set(t,e),e}getGpuRenderTarget(t){return this._gpuRenderTargetHash[t.uid]||(this._gpuRenderTargetHash[t.uid]=this.adaptor.initGpuRenderTarget(t))}resetState(){this.renderTarget=null,this.renderSurface=null}}},8955:(t,e,r)=>{"use strict";r.d(e,{c:()=>a});var s=r(1753),i=r(1386),n=r(9739);const o=new Map;function a(t,e){if(!o.has(t)){const r=new n.g({source:new i.q({resource:t,...e})}),s=()=>{o.get(t)===r&&o.delete(t)};r.once("destroy",s),r.source.once("destroy",s),o.set(t,r)}return o.get(t)}s.L.register(o)},8956:(t,e,r)=>{"use strict";r.d(e,{s:()=>i});var s=r(3590);function i(t,e){const{texture:r,bounds:i}=t,n=e._style._getFinalPadding();(0,s.y)(i,e._anchor,r);const o=e._anchor._x*n*2,a=e._anchor._y*n*2;i.minX-=n-o,i.minY-=n-a,i.maxX-=n-o,i.maxY-=n-a}},9062:(t,e,r)=>{"use strict";function s(t,e){const r=t.byteLength/8|0,s=new Float64Array(t,0,r);new Float64Array(e,0,r).set(s);const i=t.byteLength-8*r;if(i>0){const s=new Uint8Array(t,8*r,i);new Uint8Array(e,8*r,i).set(s)}}r.d(e,{W:()=>s})},9087:function(t){var e;t.exports=((e=function(){function t(t){return i.appendChild(t.dom),t}function r(t){for(var e=0;e<i.children.length;e++)i.children[e].style.display=e===t?"block":"none";s=t}var s=0,i=document.createElement("div");i.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",i.addEventListener("click",function(t){t.preventDefault(),r(++s%i.children.length)},!1);var n=(performance||Date).now(),o=n,a=0,l=t(new e.Panel("FPS","#0ff","#002")),h=t(new e.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var c=t(new e.Panel("MB","#f08","#201"));return r(0),{REVISION:16,dom:i,addPanel:t,showPanel:r,begin:function(){n=(performance||Date).now()},end:function(){a++;var t=(performance||Date).now();if(h.update(t-n,200),t>o+1e3&&(l.update(1e3*a/(t-o),100),o=t,a=0,c)){var e=performance.memory;c.update(e.usedJSHeapSize/1048576,e.jsHeapSizeLimit/1048576)}return t},update:function(){n=this.end()},domElement:i,setMode:r}}).Panel=function(t,e,r){var s=1/0,i=0,n=Math.round,o=n(window.devicePixelRatio||1),a=80*o,l=48*o,h=3*o,c=2*o,u=3*o,d=15*o,p=74*o,f=30*o,g=document.createElement("canvas");g.width=a,g.height=l,g.style.cssText="width:80px;height:48px";var m=g.getContext("2d");return m.font="bold "+9*o+"px Helvetica,Arial,sans-serif",m.textBaseline="top",m.fillStyle=r,m.fillRect(0,0,a,l),m.fillStyle=e,m.fillText(t,h,c),m.fillRect(u,d,p,f),m.fillStyle=r,m.globalAlpha=.9,m.fillRect(u,d,p,f),{dom:g,update:function(l,x){s=Math.min(s,l),i=Math.max(i,l),m.fillStyle=r,m.globalAlpha=1,m.fillRect(0,0,a,d),m.fillStyle=e,m.fillText(n(l)+" "+t+" ("+n(s)+"-"+n(i)+")",h,c),m.drawImage(g,u+o,d,p-o,f,u,d,p-o,f),m.fillRect(u+p-o,d,o,f),m.fillStyle=r,m.globalAlpha=.9,m.fillRect(u+p-o,d,o,n((1-l/x)*f))}}},e)},9250:(t,e,r)=>{"use strict";r.d(e,{g:()=>i});var s=r(8271);const i=[];i[s.K.NONE]=void 0,i[s.K.DISABLED]={stencilWriteMask:0,stencilReadMask:0},i[s.K.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}},i[s.K.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}},i[s.K.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}},i[s.K.INVERSE_MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"not-equal",passOp:"keep"},stencilBack:{compare:"not-equal",passOp:"keep"}}},9279:(t,e,r)=>{"use strict";r.d(e,{Y:()=>s});const s=(t,e)=>{const r=e.split("?")[1];return r&&(t+=`?${r}`),t}},9359:(t,e,r)=>{"use strict";r.d(e,{v:()=>n});var s=r(4872),i=r(4696);class n extends s.A{constructor(){super(...arguments),this.chars=Object.create(null),this.lineHeight=0,this.fontFamily="",this.fontMetrics={fontSize:0,ascent:0,descent:0},this.baseLineOffset=0,this.distanceField={type:"none",range:0},this.pages=[],this.applyFillAsTint=!0,this.baseMeasurementFontSize=100,this.baseRenderedFontSize=100}get font(){return(0,i.t6)(i.lj,"BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."),this.fontFamily}get pageTextures(){return(0,i.t6)(i.lj,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}get size(){return(0,i.t6)(i.lj,"BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."),this.fontMetrics.fontSize}get distanceFieldRange(){return(0,i.t6)(i.lj,"BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."),this.distanceField.range}get distanceFieldType(){return(0,i.t6)(i.lj,"BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead."),this.distanceField.type}destroy(t=!1){this.emit("destroy",this),this.removeAllListeners();for(const t in this.chars)this.chars[t].texture?.destroy();this.chars=null,t&&(this.pages.forEach(t=>t.texture.destroy(!0)),this.pages=null)}}},9375:(t,e,r)=>{"use strict";r.d(e,{L:()=>i});const s={default:-1};function i(t="default"){return void 0===s[t]&&(s[t]=-1),++s[t]}},9390:(t,e,r)=>{"use strict";r.d(e,{M:()=>n});var s=r(59);const i=[new s.b,new s.b,new s.b,new s.b];class n{constructor(t=0,e=0,r=0,s=0){this.type="rectangle",this.x=Number(t),this.y=Number(e),this.width=Number(r),this.height=Number(s)}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}isEmpty(){return this.left===this.right||this.top===this.bottom}static get EMPTY(){return new n(0,0,0,0)}clone(){return new n(this.x,this.y,this.width,this.height)}copyFromBounds(t){return this.x=t.minX,this.y=t.minY,this.width=t.maxX-t.minX,this.height=t.maxY-t.minY,this}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){return!(this.width<=0||this.height<=0)&&t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height}strokeContains(t,e,r,s=.5){const{width:i,height:n}=this;if(i<=0||n<=0)return!1;const o=this.x,a=this.y,l=r*(1-s),h=r-l;return t>=o-l&&t<=o+i+l&&e>=a-l&&e<=a+n+l&&!(t>o+h&&t<o+i-h&&e>a+h&&e<a+n-h)}intersects(t,e){if(!e){const e=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=e)return!1;const r=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>r}const r=this.left,s=this.right,n=this.top,o=this.bottom;if(s<=r||o<=n)return!1;const a=i[0].set(t.left,t.top),l=i[1].set(t.left,t.bottom),h=i[2].set(t.right,t.top),c=i[3].set(t.right,t.bottom);if(h.x<=a.x||l.y<=a.y)return!1;const u=Math.sign(e.a*e.d-e.b*e.c);if(0===u)return!1;if(e.apply(a,a),e.apply(l,l),e.apply(h,h),e.apply(c,c),Math.max(a.x,l.x,h.x,c.x)<=r||Math.min(a.x,l.x,h.x,c.x)>=s||Math.max(a.y,l.y,h.y,c.y)<=n||Math.min(a.y,l.y,h.y,c.y)>=o)return!1;const d=u*(l.y-a.y),p=u*(a.x-l.x),f=d*r+p*n,g=d*s+p*n,m=d*r+p*o,x=d*s+p*o;if(Math.max(f,g,m,x)<=d*a.x+p*a.y||Math.min(f,g,m,x)>=d*c.x+p*c.y)return!1;const _=u*(a.y-h.y),y=u*(h.x-a.x),v=_*r+y*n,b=_*s+y*n,w=_*r+y*o,T=_*s+y*o;return!(Math.max(v,b,w,T)<=_*a.x+y*a.y||Math.min(v,b,w,T)>=_*c.x+y*c.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=2*t,this.height+=2*e,this}fit(t){const e=Math.max(this.x,t.x),r=Math.min(this.x+this.width,t.x+t.width),s=Math.max(this.y,t.y),i=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(r-e,0),this.y=s,this.height=Math.max(i-s,0),this}ceil(t=1,e=.001){const r=Math.ceil((this.x+this.width-e)*t)/t,s=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=r-this.x,this.height=s-this.y,this}scale(t,e=t){return this.x*=t,this.y*=e,this.width*=t,this.height*=e,this}enlarge(t){const e=Math.min(this.x,t.x),r=Math.max(this.x+this.width,t.x+t.width),s=Math.min(this.y,t.y),i=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=r-e,this.y=s,this.height=i-s,this}getBounds(t){return t||(t=new n),t.copyFrom(this),t}containsRect(t){if(this.width<=0||this.height<=0)return!1;const e=t.x,r=t.y,s=t.x+t.width,i=t.y+t.height;return e>=this.x&&e<this.x+this.width&&r>=this.y&&r<this.y+this.height&&s>=this.x&&s<this.x+this.width&&i>=this.y&&i<this.y+this.height}set(t,e,r,s){return this.x=t,this.y=e,this.width=r,this.height=s,this}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}},9437:(t,e,r)=>{"use strict";function s(t){return t+=0===t?1:0,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,1+(t|=t>>>16)}function i(t){return!(t&t-1||!t)}r.d(e,{U5:()=>s,f3:()=>i})},9482:(t,e,r)=>{"use strict";function s(t,e,r){const s=(t>>24&255)/255;e[r++]=(255&t)/255*s,e[r++]=(t>>8&255)/255*s,e[r++]=(t>>16&255)/255*s,e[r++]=s}r.d(e,{V:()=>s})},9565:(t,e,r)=>{"use strict";r.d(e,{E:()=>a,f:()=>n});var s=r(5199),i=r(7882);function n(t,e,r){let n,l;return r.clear(),t.parent?e?n=t.parent.worldTransform:(l=i.u.get().identity(),n=a(t,l)):n=s.u.IDENTITY,o(t,r,n,e),l&&i.u.return(l),r.isValid||r.set(0,0,0,0),r}function o(t,e,r,n){if(!t.visible||!t.measurable)return;let a;n?a=t.worldTransform:(t.updateLocalTransform(),a=i.u.get(),a.appendFrom(t.localTransform,r));const l=e,h=!!t.effects.length;if(h&&(e=i.o.get().clear()),t.boundsArea)e.addRect(t.boundsArea,a);else{const r=t.bounds;r&&!r.isEmpty()&&(e.matrix=a,e.addBounds(r));for(let r=0;r<t.children.length;r++)o(t.children[r],e,a,n)}if(h){for(let r=0;r<t.effects.length;r++)t.effects[r].addBounds?.(e);l.addBounds(e,s.u.IDENTITY),i.o.return(e)}n||i.u.return(a)}function a(t,e){const r=t.parent;return r&&(a(r,e),r.updateLocalTransform(),e.append(r.localTransform)),e}},9677:(t,e,r)=>{"use strict";r.d(e,{I:()=>C,v:()=>A});var s=r(5007),i=r(1790),n=r(7694);function o(t,e,r){if(t)for(const s in t){const i=e[s.toLocaleLowerCase()];if(i){let e=t[s];"header"===s&&(e=e.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),r&&i.push(`//----${r}----//`),i.push(e)}else(0,n.R)(`${s} placement hook does not exist in shader`)}}const a=/\{\{(.*?)\}\}/g;function l(t){const e={};return(t.match(a)?.map(t=>t.replace(/[{()}]/g,""))??[]).forEach(t=>{e[t]=[]}),e}function h(t,e){let r;const s=/@in\s+([^;]+);/g;for(;null!==(r=s.exec(t));)e.push(r[1])}function c(t,e,r=!1){const s=[];h(e,s),t.forEach(t=>{t.header&&h(t.header,s)});const i=s;r&&i.sort();const n=i.map((t,e)=>` @location(${e}) ${t},`).join("\n");let o=e.replace(/@in\s+[^;]+;\s*/g,"");return o=o.replace("{{in}}",`\n${n}\n`),o}function u(t,e){let r;const s=/@out\s+([^;]+);/g;for(;null!==(r=s.exec(t));)e.push(r[1])}function d(t,e){let r=t;for(const t in e){const s=e[t];r=s.join("\n").length?r.replace(`{{${t}}}`,`//-----${t} START-----//\n${s.join("\n")}\n//----${t} FINISH----//`):r.replace(`{{${t}}}`,"")}return r}const p=Object.create(null),f=new Map;let g=0;function m({template:t,bits:e}){const r=x(t,e);return p[r]||(p[r]=_(t.vertex,t.fragment,e)),p[r]}function x(t,e){return e.map(t=>(f.has(t)||f.set(t,g++),f.get(t))).sort((t,e)=>t-e).join("-")+t.vertex+t.fragment}function _(t,e,r){const s=l(t),i=l(e);return r.forEach(t=>{o(t.vertex,s,t.name),o(t.fragment,i,t.name)}),{vertex:d(t,s),fragment:d(e,i)}}const y="\n @in aPosition: vec2<f32>;\n @in aUV: vec2<f32>;\n\n @out @builtin(position) vPosition: vec4<f32>;\n @out vUV : vec2<f32>;\n @out vColor : vec4<f32>;\n\n {{header}}\n\n struct VSOutput {\n {{struct}}\n };\n\n @vertex\n fn main( {{in}} ) -> VSOutput {\n\n var worldTransformMatrix = globalUniforms.uWorldTransformMatrix;\n var modelMatrix = mat3x3<f32>(\n 1.0, 0.0, 0.0,\n 0.0, 1.0, 0.0,\n 0.0, 0.0, 1.0\n );\n var position = aPosition;\n var uv = aUV;\n\n {{start}}\n\n vColor = vec4<f32>(1., 1., 1., 1.);\n\n {{main}}\n\n vUV = uv;\n\n var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix;\n\n vPosition = vec4<f32>((modelViewProjectionMatrix * vec3<f32>(position, 1.0)).xy, 0.0, 1.0);\n\n vColor *= globalUniforms.uWorldColorAlpha;\n\n {{end}}\n\n {{return}}\n };\n",v="\n @in vUV : vec2<f32>;\n @in vColor : vec4<f32>;\n\n {{header}}\n\n @fragment\n fn main(\n {{in}}\n ) -> @location(0) vec4<f32> {\n\n {{start}}\n\n var outColor:vec4<f32>;\n\n {{main}}\n\n var finalColor:vec4<f32> = outColor * vColor;\n\n {{end}}\n\n return finalColor;\n };\n",b="\n in vec2 aPosition;\n in vec2 aUV;\n\n out vec4 vColor;\n out vec2 vUV;\n\n {{header}}\n\n void main(void){\n\n mat3 worldTransformMatrix = uWorldTransformMatrix;\n mat3 modelMatrix = mat3(\n 1.0, 0.0, 0.0,\n 0.0, 1.0, 0.0,\n 0.0, 0.0, 1.0\n );\n vec2 position = aPosition;\n vec2 uv = aUV;\n\n {{start}}\n\n vColor = vec4(1.);\n\n {{main}}\n\n vUV = uv;\n\n mat3 modelViewProjectionMatrix = uProjectionMatrix * worldTransformMatrix * modelMatrix;\n\n gl_Position = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);\n\n vColor *= uWorldColorAlpha;\n\n {{end}}\n }\n",w="\n\n in vec4 vColor;\n in vec2 vUV;\n\n out vec4 finalColor;\n\n {{header}}\n\n void main(void) {\n\n {{start}}\n\n vec4 outColor;\n\n {{main}}\n\n finalColor = outColor * vColor;\n\n {{end}}\n }\n",T={name:"global-uniforms-bit",vertex:{header:"\n struct GlobalUniforms {\n uProjectionMatrix:mat3x3<f32>,\n uWorldTransformMatrix:mat3x3<f32>,\n uWorldColorAlpha: vec4<f32>,\n uResolution: vec2<f32>,\n }\n\n @group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;\n "}},S={name:"global-uniforms-bit",vertex:{header:"\n uniform mat3 uProjectionMatrix;\n uniform mat3 uWorldTransformMatrix;\n uniform vec4 uWorldColorAlpha;\n uniform vec2 uResolution;\n "}};function A({bits:t,name:e}){const r=function({template:t,bits:e}){const r=x(t,e);if(p[r])return p[r];const{vertex:s,fragment:i}=function(t,e){const r=e.map(t=>t.vertex).filter(t=>!!t),s=e.map(t=>t.fragment).filter(t=>!!t);let i=c(r,t.vertex,!0);return i=function(t,e){const r=[];u(e,r),t.forEach(t=>{t.header&&u(t.header,r)});let s=0;const i=r.sort().map(t=>t.indexOf("builtin")>-1?t:`@location(${s++}) ${t}`).join(",\n"),n=r.sort().map(t=>{return` var ${e=t,e.replace(/@.*?\s+/g,"")};`;var e}).join("\n"),o=`return VSOutput(\n ${r.sort().map(t=>` ${function(t){const e=/\b(\w+)\s*:/g.exec(t);return e?e[1]:""}(t)}`).join(",\n")});`;let a=e.replace(/@out\s+[^;]+;\s*/g,"");return a=a.replace("{{struct}}",`\n${i}\n`),a=a.replace("{{start}}",`\n${n}\n`),a=a.replace("{{return}}",`\n${o}\n`),a}(r,i),{vertex:i,fragment:c(s,t.fragment,!0)}}(t,e);return p[r]=_(s,i,e),p[r]}({template:{fragment:v,vertex:y},bits:[T,...t]});return i.B.from({name:e,vertex:{source:r.vertex,entryPoint:"main"},fragment:{source:r.fragment,entryPoint:"main"}})}function C({bits:t,name:e}){return new s.M({name:e,...m({template:{vertex:b,fragment:w},bits:[S,...t]})})}},9739:(t,e,r)=>{"use strict";r.d(e,{g:()=>d});var s=r(4872),i=r(769),n=r(9390),o=r(9375),a=r(4696);const l=()=>{};var h=r(6185),c=r(4269),u=r(1734);class d extends s.A{constructor({source:t,label:e,frame:r,orig:s,trim:i,defaultAnchor:a,defaultBorders:l,rotate:h,dynamic:u}={}){if(super(),this.uid=(0,o.L)("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new n.M,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=e,this.source=t?.source??new c.v,this.noFrame=!r,r)this.frame.copyFrom(r);else{const{width:t,height:e}=this._source;this.frame.width=t,this.frame.height=e}this.orig=s||this.frame,this.trim=i,this.rotate=h??0,this.defaultAnchor=a,this.defaultBorders=l,this.destroyed=!1,this.dynamic=u||!1,this.updateUvs()}set source(t){this._source&&this._source.off("resize",this.update,this),this._source=t,t.on("resize",this.update,this),this.emit("update",this)}get source(){return this._source}get textureMatrix(){return this._textureMatrix||(this._textureMatrix=new u.N(this)),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){const{uvs:t,frame:e}=this,{width:r,height:s}=this._source,n=e.x/r,o=e.y/s,a=e.width/r,l=e.height/s;let h=this.rotate;if(h){const e=a/2,r=l/2,s=n+e,c=o+r;h=i.E.add(h,i.E.NW),t.x0=s+e*i.E.uX(h),t.y0=c+r*i.E.uY(h),h=i.E.add(h,2),t.x1=s+e*i.E.uX(h),t.y1=c+r*i.E.uY(h),h=i.E.add(h,2),t.x2=s+e*i.E.uX(h),t.y2=c+r*i.E.uY(h),h=i.E.add(h,2),t.x3=s+e*i.E.uX(h),t.y3=c+r*i.E.uY(h)}else t.x0=n,t.y0=o,t.x1=n+a,t.y1=o,t.x2=n+a,t.y2=o+l,t.x3=n,t.y3=o+l}destroy(t=!1){this._source&&t&&(this._source.destroy(),this._source=null),this._textureMatrix=null,this.destroyed=!0,this.emit("destroy",this),this.removeAllListeners()}update(){this.noFrame&&(this.frame.width=this._source.width,this.frame.height=this._source.height),this.updateUvs(),this.emit("update",this)}get baseTexture(){return(0,a.t6)(a.lj,"Texture.baseTexture is now Texture.source"),this._source}}d.EMPTY=new d({label:"EMPTY",source:new c.v({label:"EMPTY"})}),d.EMPTY.destroy=l,d.WHITE=new d({source:new h.P({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"}),d.WHITE.destroy=l},9776:(t,e,r)=>{"use strict";r.d(e,{m:()=>o});var s=r(5199),i=r(9375);const n={repeat:{addressModeU:"repeat",addressModeV:"repeat"},"repeat-x":{addressModeU:"repeat",addressModeV:"clamp-to-edge"},"repeat-y":{addressModeU:"clamp-to-edge",addressModeV:"repeat"},"no-repeat":{addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}};class o{constructor(t,e){this.uid=(0,i.L)("fillPattern"),this._tick=0,this.transform=new s.u,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),e&&(t.source.style.addressModeU=n[e].addressModeU,t.source.style.addressModeV=n[e].addressModeV)}setTransform(t){const e=this.texture;this.transform.copyFrom(t),this.transform.invert(),this.transform.scale(1/e.frame.width,1/e.frame.height),this._tick++}get texture(){return this._texture}set texture(t){this._texture!==t&&(this._texture=t,this._tick++)}get styleKey(){return`fill-pattern-${this.uid}-${this._tick}`}destroy(){this.texture.destroy(!0),this.texture=null}}},9797:(t,e,r)=>{"use strict";var s=r(1065),i=r(3769),n=r(7433),o=r(5153),a=r(9482),l=r(1228),h=r(1174),c=r(5199),u=r(9677),d=r(4405),p=r(7335),f=r(1657),g=r(4449),m=r(9739);const x={name:"tiling-bit",vertex:{header:"\n struct TilingUniforms {\n uMapCoord:mat3x3<f32>,\n uClampFrame:vec4<f32>,\n uClampOffset:vec2<f32>,\n uTextureTransform:mat3x3<f32>,\n uSizeAnchor:vec4<f32>\n };\n\n @group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;\n @group(2) @binding(1) var uTexture: texture_2d<f32>;\n @group(2) @binding(2) var uSampler: sampler;\n ",main:"\n uv = (tilingUniforms.uTextureTransform * vec3(uv, 1.0)).xy;\n\n position = (position - tilingUniforms.uSizeAnchor.zw) * tilingUniforms.uSizeAnchor.xy;\n "},fragment:{header:"\n struct TilingUniforms {\n uMapCoord:mat3x3<f32>,\n uClampFrame:vec4<f32>,\n uClampOffset:vec2<f32>,\n uTextureTransform:mat3x3<f32>,\n uSizeAnchor:vec4<f32>\n };\n\n @group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;\n @group(2) @binding(1) var uTexture: texture_2d<f32>;\n @group(2) @binding(2) var uSampler: sampler;\n ",main:"\n\n var coord = vUV + ceil(tilingUniforms.uClampOffset - vUV);\n coord = (tilingUniforms.uMapCoord * vec3(coord, 1.0)).xy;\n var unclamped = coord;\n coord = clamp(coord, tilingUniforms.uClampFrame.xy, tilingUniforms.uClampFrame.zw);\n\n var bias = 0.;\n\n if(unclamped.x == coord.x && unclamped.y == coord.y)\n {\n bias = -32.;\n }\n\n outColor = textureSampleBias(uTexture, uSampler, coord, bias);\n "}},_={name:"tiling-bit",vertex:{header:"\n uniform mat3 uTextureTransform;\n uniform vec4 uSizeAnchor;\n\n ",main:"\n uv = (uTextureTransform * vec3(aUV, 1.0)).xy;\n\n position = (position - uSizeAnchor.zw) * uSizeAnchor.xy;\n "},fragment:{header:"\n uniform sampler2D uTexture;\n uniform mat3 uMapCoord;\n uniform vec4 uClampFrame;\n uniform vec2 uClampOffset;\n ",main:"\n\n vec2 coord = vUV + ceil(uClampOffset - vUV);\n coord = (uMapCoord * vec3(coord, 1.0)).xy;\n vec2 unclamped = coord;\n coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);\n\n outColor = texture(uTexture, coord, unclamped == coord ? 0.0 : -32.0);// lod-bias very negative to force lod 0\n\n "}};let y,v;class b extends f.M{constructor(){y??(y=(0,u.v)({name:"tiling-sprite-shader",bits:[d.Ls,x,p.b]})),v??(v=(0,u.I)({name:"tiling-sprite-shader",bits:[d.mA,_,p.m]}));const t=new g.k({uMapCoord:{value:new c.u,type:"mat3x3<f32>"},uClampFrame:{value:new Float32Array([0,0,1,1]),type:"vec4<f32>"},uClampOffset:{value:new Float32Array([0,0]),type:"vec2<f32>"},uTextureTransform:{value:new c.u,type:"mat3x3<f32>"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4<f32>"}});super({glProgram:v,gpuProgram:y,resources:{localUniforms:new g.k({uTransformMatrix:{value:new c.u,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),tilingUniforms:t,uTexture:m.g.EMPTY.source,uSampler:m.g.EMPTY.source.style}})}updateUniforms(t,e,r,s,i,n){const o=this.resources.tilingUniforms,a=n.width,l=n.height,h=n.textureMatrix,c=o.uniforms.uTextureTransform;c.set(r.a*a/t,r.b*a/e,r.c*l/t,r.d*l/e,r.tx/t,r.ty/e),c.invert(),o.uniforms.uMapCoord=h.mapCoord,o.uniforms.uClampFrame=h.uClampFrame,o.uniforms.uClampOffset=h.uClampOffset,o.uniforms.uTextureTransform=c,o.uniforms.uSizeAnchor[0]=t,o.uniforms.uSizeAnchor[1]=e,o.uniforms.uSizeAnchor[2]=s,o.uniforms.uSizeAnchor[3]=i,n&&(this.resources.uTexture=n.source,this.resources.uSampler=n.source.style)}}class w extends h.u{constructor(){super({positions:new Float32Array([0,0,1,0,1,1,0,1]),uvs:new Float32Array([0,0,1,0,1,1,0,1]),indices:new Uint32Array([0,1,2,0,2,3])})}}const T=new w;class S{constructor(){this.canBatch=!0,this.geometry=new h.u({indices:T.indices.slice(),positions:T.positions.slice(),uvs:T.uvs.slice()})}destroy(){this.geometry.destroy(),this.shader?.destroy()}}class A{constructor(t){this._state=n.U.default2d,this._renderer=t}validateRenderable(t){const e=this._getTilingSpriteData(t),r=e.canBatch;this._updateCanBatch(t);const s=e.canBatch;if(s&&s===r){const{batchableMesh:r}=e;return!r._batcher.checkAndUpdateTexture(r,t.texture)}return r!==s}addRenderable(t,e){const r=this._renderer.renderPipes.batch;this._updateCanBatch(t);const s=this._getTilingSpriteData(t),{geometry:i,canBatch:n}=s;if(n){s.batchableMesh||(s.batchableMesh=new l.U);const n=s.batchableMesh;t.didViewUpdate&&(this._updateBatchableMesh(t),n.geometry=i,n.renderable=t,n.transform=t.groupTransform,n.setTexture(t._texture)),n.roundPixels=this._renderer._roundPixels|t._roundPixels,r.addToBatch(n,e)}else r.break(e),s.shader||(s.shader=new b),this.updateRenderable(t),e.add(t)}execute(t){const{shader:e}=this._getTilingSpriteData(t);e.groups[0]=this._renderer.globalUniforms.bindGroup;const r=e.resources.localUniforms.uniforms;r.uTransformMatrix=t.groupTransform,r.uRound=this._renderer._roundPixels|t._roundPixels,(0,a.V)(t.groupColorAlpha,r.uColor,0),this._state.blendMode=(0,i.i)(t.groupBlendMode,t.texture._source),this._renderer.encoder.draw({geometry:T,shader:e,state:this._state})}updateRenderable(t){const e=this._getTilingSpriteData(t),{canBatch:r}=e;if(r){const{batchableMesh:r}=e;t.didViewUpdate&&this._updateBatchableMesh(t),r._batcher.updateElement(r)}else if(t.didViewUpdate){const{shader:r}=e;r.updateUniforms(t.width,t.height,t._tileTransform.matrix,t.anchor.x,t.anchor.y,t.texture)}}_getTilingSpriteData(t){return t._gpuData[this._renderer.uid]||this._initTilingSpriteData(t)}_initTilingSpriteData(t){const e=new S;return e.renderable=t,t._gpuData[this._renderer.uid]=e,e}_updateBatchableMesh(t){const e=this._getTilingSpriteData(t),{geometry:r}=e,s=t.texture.source.style;"repeat"!==s.addressMode&&(s.addressMode="repeat",s.update()),function(t,e){const r=t.texture,s=r.frame.width,i=r.frame.height;let n=0,o=0;t.applyAnchorToTexture&&(n=t.anchor.x,o=t.anchor.y),e[0]=e[6]=-n,e[2]=e[4]=1-n,e[1]=e[3]=-o,e[5]=e[7]=1-o;const a=c.u.shared;a.copyFrom(t._tileTransform.matrix),a.tx/=t.width,a.ty/=t.height,a.invert(),a.scale(t.width/s,t.height/i),function(t,e,r,s){let i=0;const n=t.length/2,o=s.a,a=s.b,l=s.c,h=s.d,c=s.tx,u=s.ty;for(r*=2;i<n;){const e=t[r],s=t[r+1];t[r]=o*e+l*s+c,t[r+1]=a*e+h*s+u,r+=2,i++}}(e,0,0,a)}(t,r.uvs),function(t,e){const r=t.anchor.x,s=t.anchor.y;e[0]=-r*t.width,e[1]=-s*t.height,e[2]=(1-r)*t.width,e[3]=-s*t.height,e[4]=(1-r)*t.width,e[5]=(1-s)*t.height,e[6]=-r*t.width,e[7]=(1-s)*t.height}(t,r.positions)}destroy(){this._renderer=null}_updateCanBatch(t){const e=this._getTilingSpriteData(t),r=t.texture;let s=!0;return this._renderer.type===o.W.WEBGL&&(s=this._renderer.context.supports.nonPowOf2wrapping),e.canBatch=r.textureMatrix.isSimple&&(s||r.source.isPowerOfTwo),e.canBatch}}A.extension={type:[s.Ag.WebGLPipes,s.Ag.WebGPUPipes,s.Ag.CanvasPipes],name:"tilingSprite"},s.XO.add(A)},9798:(t,e,r)=>{"use strict";r.d(e,{S:()=>s});var s=(t=>(t[t.MAP_READ=1]="MAP_READ",t[t.MAP_WRITE=2]="MAP_WRITE",t[t.COPY_SRC=4]="COPY_SRC",t[t.COPY_DST=8]="COPY_DST",t[t.INDEX=16]="INDEX",t[t.VERTEX=32]="VERTEX",t[t.UNIFORM=64]="UNIFORM",t[t.STORAGE=128]="STORAGE",t[t.INDIRECT=256]="INDIRECT",t[t.QUERY_RESOLVE=512]="QUERY_RESOLVE",t[t.STATIC=1024]="STATIC",t))(s||{})}},e={};function r(s){var i=e[s];if(void 0!==i)return i.exports;var n=e[s]={exports:{}};return t[s].call(n.exports,n,n.exports,r),n.exports}r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var s in e)r.o(e,s)&&!r.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{"use strict";var t=r(1065);const e={extension:{type:t.Ag.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Promise.resolve().then(r.bind(r,8675))}},s={extension:{type:t.Ag.Environment,name:"webworker",priority:0},test:()=>"undefined"!=typeof self&&void 0!==self.WorkerGlobalScope,load:async()=>{await Promise.resolve().then(r.bind(r,6516))}};r(2542),r(2517);var i=r(3463),n=r(9279),o=r(5423),a=r(8869),l=r(769),h=r(9390),c=r(9739),u=r(9359),d=r(8598);class p extends u.v{constructor(t,e){super();const{textures:r,data:s}=t;Object.keys(s.pages).forEach(t=>{const e=s.pages[parseInt(t,10)],i=r[e.id];this.pages.push({texture:i})}),Object.keys(s.chars).forEach(t=>{const e=s.chars[t],{frame:i,source:n,rotate:o}=r[e.page],a=l.E.transformRectCoords(e,i,o,new h.M),u=new c.g({frame:a,orig:new h.M(0,0,e.width,e.height),source:n,rotate:o});this.chars[t]={id:t.codePointAt(0),xOffset:e.xOffset,yOffset:e.yOffset,xAdvance:e.xAdvance,kerning:e.kerning??{},texture:u}}),this.baseRenderedFontSize=s.fontSize,this.baseMeasurementFontSize=s.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:s.fontSize},this.baseLineOffset=s.baseLineOffset,this.lineHeight=s.lineHeight,this.fontFamily=s.fontFamily,this.distanceField=s.distanceField??{type:"none",range:0},this.url=e}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){const{texture:e}=this.pages[t];e.destroy(!0)}this.pages=null}static install(t){d.c.install(t)}static uninstall(t){d.c.uninstall(t)}}const f={test:t=>"string"==typeof t&&t.startsWith("info face="),parse(t){const e=t.match(/^[a-z]+\s+.+$/gm),r={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const t in e){const s=e[t].match(/^[a-z]+/gm)[0],i=e[t].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),n={};for(const t in i){const e=i[t].split("="),r=e[0],s=e[1].replace(/"/gm,""),o=parseFloat(s),a=isNaN(o)?s:o;n[r]=a}r[s].push(n)}const s={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},[i]=r.info,[n]=r.common,[o]=r.distanceField??[];o&&(s.distanceField={range:parseInt(o.distanceRange,10),type:o.fieldType}),s.fontSize=parseInt(i.size,10),s.fontFamily=i.face,s.lineHeight=parseInt(n.lineHeight,10);const a=r.page;for(let t=0;t<a.length;t++)s.pages.push({id:parseInt(a[t].id,10)||0,file:a[t].file});const l={};s.baseLineOffset=s.lineHeight-parseInt(n.base,10);const h=r.char;for(let t=0;t<h.length;t++){const e=h[t],r=parseInt(e.id,10);let i=e.letter??e.char??String.fromCharCode(r);"space"===i&&(i=" "),l[r]=i,s.chars[i]={id:r,page:parseInt(e.page,10)||0,x:parseInt(e.x,10),y:parseInt(e.y,10),width:parseInt(e.width,10),height:parseInt(e.height,10),xOffset:parseInt(e.xoffset,10),yOffset:parseInt(e.yoffset,10),xAdvance:parseInt(e.xadvance,10),kerning:{}}}const c=r.kerning||[];for(let t=0;t<c.length;t++){const e=parseInt(c[t].first,10),r=parseInt(c[t].second,10),i=parseInt(c[t].amount,10);s.chars[l[r]].kerning[l[e]]=i}return s}},g={test(t){const e=t;return"string"!=typeof e&&"getElementsByTagName"in e&&e.getElementsByTagName("page").length&&null!==e.getElementsByTagName("info")[0].getAttribute("face")},parse(t){const e={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},r=t.getElementsByTagName("info")[0],s=t.getElementsByTagName("common")[0],i=t.getElementsByTagName("distanceField")[0];i&&(e.distanceField={type:i.getAttribute("fieldType"),range:parseInt(i.getAttribute("distanceRange"),10)});const n=t.getElementsByTagName("page"),o=t.getElementsByTagName("char"),a=t.getElementsByTagName("kerning");e.fontSize=parseInt(r.getAttribute("size"),10),e.fontFamily=r.getAttribute("face"),e.lineHeight=parseInt(s.getAttribute("lineHeight"),10);for(let t=0;t<n.length;t++)e.pages.push({id:parseInt(n[t].getAttribute("id"),10)||0,file:n[t].getAttribute("file")});const l={};e.baseLineOffset=e.lineHeight-parseInt(s.getAttribute("base"),10);for(let t=0;t<o.length;t++){const r=o[t],s=parseInt(r.getAttribute("id"),10);let i=r.getAttribute("letter")??r.getAttribute("char")??String.fromCharCode(s);"space"===i&&(i=" "),l[s]=i,e.chars[i]={id:s,page:parseInt(r.getAttribute("page"),10)||0,x:parseInt(r.getAttribute("x"),10),y:parseInt(r.getAttribute("y"),10),width:parseInt(r.getAttribute("width"),10),height:parseInt(r.getAttribute("height"),10),xOffset:parseInt(r.getAttribute("xoffset"),10),yOffset:parseInt(r.getAttribute("yoffset"),10),xAdvance:parseInt(r.getAttribute("xadvance"),10),kerning:{}}}for(let t=0;t<a.length;t++){const r=parseInt(a[t].getAttribute("first"),10),s=parseInt(a[t].getAttribute("second"),10),i=parseInt(a[t].getAttribute("amount"),10);e.chars[l[s]].kerning[l[r]]=i}return e}},m=t=>!("string"!=typeof t||!t.includes("<font>"))&&g.test(o.e.get().parseXML(t)),x=t=>g.parse(o.e.get().parseXML(t)),_=[".xml",".fnt"],y={extension:{type:t.Ag.CacheParser,name:"cacheBitmapFont"},test:t=>t instanceof p,getCacheableAssets(t,e){const r={};return t.forEach(t=>{r[t]=e,r[`${t}-bitmap`]=e}),r[`${e.fontFamily}-bitmap`]=e,r}},v={extension:{type:t.Ag.LoadParser,priority:i.T.Normal},name:"loadBitmapFont",id:"bitmap-font",test:t=>_.includes(a.A.extname(t).toLowerCase()),testParse:async t=>f.test(t)||m(t),async parse(t,e,r){const s=f.test(t)?f.parse(t):x(t),{src:i}=e,{pages:o}=s,l=[],h=s.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let t=0;t<o.length;++t){const e=o[t].file;let r=a.A.join(a.A.dirname(i),e);r=(0,n.Y)(r,i),l.push({src:r,data:h})}const c=await r.load(l),u=l.map(t=>c[t.src]);return new p({data:s,textures:u},i)},async load(t,e){const r=await o.e.get().fetch(t);return await r.text()},async unload(t,e,r){await Promise.all(t.pages.map(t=>r.unload(t.texture.source._sourceOrigin))),t.destroy()}};var b=r(7694);class w{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach(t=>{this._assetList.push(t)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let r=0;r<e;r++)t.push(this._assetList.pop());await this._loader.load(t),this._isLoading=!1,this._next()}}get active(){return this._isActive}set active(t){this._isActive!==t&&(this._isActive=t,t&&!this._isLoading&&this._next())}}var T=r(2445);const S={extension:{type:t.Ag.CacheParser,name:"cacheTextureArray"},test:t=>Array.isArray(t)&&t.every(t=>t instanceof c.g),getCacheableAssets:(t,e)=>{const r={};return t.forEach(t=>{e.forEach((e,s)=>{r[t+(0===s?"":s+1)]=e})}),r}};async function A(t){if("Image"in globalThis)return new Promise(e=>{const r=new Image;r.onload=()=>{e(!0)},r.onerror=()=>{e(!1)},r.src=t});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const e=await(await fetch(t)).blob();await createImageBitmap(e)}catch(t){return!1}return!0}return!1}const C={extension:{type:t.Ag.DetectionParser,priority:1},test:async()=>A("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async t=>[...t,"avif"],remove:async t=>t.filter(t=>"avif"!==t)},P=["png","jpg","jpeg"],M={extension:{type:t.Ag.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async t=>[...t,...P],remove:async t=>t.filter(t=>!P.includes(t))},E="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function R(t){return!E&&""!==document.createElement("video").canPlayType(t)}const k={extension:{type:t.Ag.DetectionParser,priority:0},test:async()=>R("video/mp4"),add:async t=>[...t,"mp4","m4v"],remove:async t=>t.filter(t=>"mp4"!==t&&"m4v"!==t)},B={extension:{type:t.Ag.DetectionParser,priority:0},test:async()=>R("video/ogg"),add:async t=>[...t,"ogv"],remove:async t=>t.filter(t=>"ogv"!==t)},I={extension:{type:t.Ag.DetectionParser,priority:0},test:async()=>R("video/webm"),add:async t=>[...t,"webm"],remove:async t=>t.filter(t=>"webm"!==t)},G={extension:{type:t.Ag.DetectionParser,priority:0},test:async()=>A("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async t=>[...t,"webp"],remove:async t=>t.filter(t=>"webp"!==t)};var F=r(8064),O=r(2843);class D{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,r)=>(this._parsersValidated=!1,t[e]=r,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const r={promise:null,parser:null};return r.promise=(async()=>{let s=null,i=null;if((e.parser||e.loadParser)&&(i=this._parserHash[e.parser||e.loadParser],e.loadParser&&(0,b.R)(`[Assets] "loadParser" is deprecated, use "parser" instead for ${t}`),i||(0,b.R)(`[Assets] specified load parser "${e.parser||e.loadParser}" not found while loading ${t}`)),!i){for(let r=0;r<this.parsers.length;r++){const s=this.parsers[r];if(s.load&&s.test?.(t,e,this)){i=s;break}}if(!i)return(0,b.R)(`[Assets] ${t} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}s=await i.load(t,e,this),r.parser=i;for(let t=0;t<this.parsers.length;t++){const i=this.parsers[t];i.parse&&i.parse&&await(i.testParse?.(s,e,this))&&(s=await i.parse(s,e,this)||s,r.parser=i)}return s})(),r}async load(t,e){this._parsersValidated||this._validateParsers();let r=0;const s={},i=(0,O.a)(t),n=(0,F.z)(t,t=>({alias:[t],src:t,data:{}})),o=n.length,l=n.map(async t=>{const i=a.A.toAbsolute(t.src);if(!s[t.src])try{this.promiseCache[i]||(this.promiseCache[i]=this._getLoadPromiseAndParser(i,t)),s[t.src]=await this.promiseCache[i].promise,e&&e(++r/o)}catch(e){throw delete this.promiseCache[i],delete s[t.src],new Error(`[Loader.load] Failed to load ${i}.\n${e}`)}});return await Promise.all(l),i?s[n[0].src]:s}async unload(t){const e=(0,F.z)(t,t=>({alias:[t],src:t})).map(async t=>{const e=a.A.toAbsolute(t.src),r=this.promiseCache[e];if(r){const s=await r.promise;delete this.promiseCache[e],await(r.parser?.unload?.(s,t,this))}});await Promise.all(e)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name||t.id).reduce((t,e)=>(e.name||e.id?(t[e.name]||t[e.id])&&(0,b.R)(`[Assets] parser id conflict "${e.id}"`):(0,b.R)("[Assets] parser should have an id"),t[e.name]=e,e.id&&(t[e.id]=e),t),{})}}function U(t,e){if(Array.isArray(e)){for(const r of e)if(t.startsWith(`data:${r}`))return!0;return!1}return t.startsWith(`data:${e}`)}function L(t,e){const r=t.split("?")[0],s=a.A.extname(r).toLowerCase();return Array.isArray(e)?e.includes(s):s===e}const N={extension:{type:t.Ag.LoadParser,priority:i.T.Low},name:"loadJson",id:"json",test:t=>U(t,"application/json")||L(t,".json"),async load(t){const e=await o.e.get().fetch(t);return await e.json()}},z={name:"loadTxt",id:"text",extension:{type:t.Ag.LoadParser,priority:i.T.Low,name:"loadTxt"},test:t=>U(t,"text/plain")||L(t,".txt"),async load(t){const e=await o.e.get().fetch(t);return await e.text()}},W=["normal","bold","100","200","300","400","500","600","700","800","900"],H=[".ttf",".otf",".woff",".woff2"],X=["font/ttf","font/otf","font/woff","font/woff2"],V=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i,Y=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function j(t){return Y.test(t)?t:encodeURI(t)}const $={extension:{type:t.Ag.LoadParser,priority:i.T.Low},name:"loadWebFont",id:"web-font",test:t=>U(t,X)||L(t,H),async load(t,e){const r=o.e.get().getFontFaceSet();if(r){const s=[],i=e.data?.family??function(t){const e=a.A.extname(t),r=a.A.basename(t,e).replace(/(-|_)/g," ").toLowerCase().split(" ").map(t=>t.charAt(0).toUpperCase()+t.slice(1));let s=r.length>0;for(const t of r)if(!t.match(V)){s=!1;break}let i=r.join(" ");return s||(i=`"${i.replace(/[\\"]/g,"\\$&")}"`),i}(t),n=e.data?.weights?.filter(t=>W.includes(t))??["normal"],o=e.data??{};for(let e=0;e<n.length;e++){const a=n[e],l=new FontFace(i,`url(${j(t)})`,{...o,weight:a});await l.load(),r.add(l),s.push(l)}return T.l.has(`${i}-and-url`)?T.l.get(`${i}-and-url`).entries.push({url:t,faces:s}):T.l.set(`${i}-and-url`,{entries:[{url:t,faces:s}]}),1===s.length?s[0]:s}return(0,b.R)("[loadWebFont] FontFace API is not supported. Skipping loading font"),null},unload(t){const e=Array.isArray(t)?t:[t],r=e[0].family,s=T.l.get(`${r}-and-url`),i=s.entries.find(t=>t.faces.some(t=>-1!==e.indexOf(t)));i.faces=i.faces.filter(t=>-1===e.indexOf(t)),0===i.faces.length&&(s.entries=s.entries.filter(t=>t!==i)),e.forEach(t=>{o.e.get().getFontFaceSet().delete(t)}),0===s.entries.length&&T.l.remove(`${r}-and-url`)}};var q=r(5947),K=r(4386),Z=r(2027);function Q(t,e=1){const r=Z.x.RETINA_PREFIX?.exec(t);return r?parseFloat(r[1]):e}function J(t,e,r){t.label=r,t._sourceOrigin=r;const s=new c.g({source:t,label:r}),i=()=>{delete e.promiseCache[r],T.l.has(r)&&T.l.remove(r)};return s.source.once("destroy",()=>{e.promiseCache[r]&&((0,b.R)("[Assets] A TextureSource managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the TextureSource."),i())}),s.once("destroy",()=>{t.destroyed||((0,b.R)("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),i())}),s}const tt={extension:{type:t.Ag.LoadParser,priority:i.T.Low,name:"loadSVG"},name:"loadSVG",id:"svg",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test:t=>U(t,"image/svg+xml")||L(t,".svg"),async load(t,e,r){return e.data?.parseAsGraphicsContext??this.config.parseAsGraphicsContext?async function(t){const e=await o.e.get().fetch(t),r=await e.text(),s=new K.T;return s.svg(r),s}(t):async function(t,e,r,s){const i=await o.e.get().fetch(t),n=o.e.get().createImage();n.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(await i.text())}`,n.crossOrigin=s,await n.decode();const a=e.data?.width??n.width,l=e.data?.height??n.height,h=e.data?.resolution||Q(t),c=Math.ceil(a*h),u=Math.ceil(l*h),d=o.e.get().createCanvas(c,u),p=d.getContext("2d");p.imageSmoothingEnabled=!0,p.imageSmoothingQuality="high",p.drawImage(n,0,0,a*h,l*h);const{parseAsGraphicsContext:f,...g}=e.data??{};return J(new q.b({resource:d,alphaMode:"premultiply-alpha-on-upload",resolution:h,...g}),r,t)}(t,e,r,this.config.crossOrigin)},unload(t){t.destroy(!0)}};let et=null;class rt{constructor(){et||(et=URL.createObjectURL(new Blob(['(function () {\n \'use strict\';\n\n const WHITE_PNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";\n async function checkImageBitmap() {\n try {\n if (typeof createImageBitmap !== "function")\n return false;\n const response = await fetch(WHITE_PNG);\n const imageBlob = await response.blob();\n const imageBitmap = await createImageBitmap(imageBlob);\n return imageBitmap.width === 1 && imageBitmap.height === 1;\n } catch (_e) {\n return false;\n }\n }\n void checkImageBitmap().then((result) => {\n self.postMessage(result);\n });\n\n})();\n'],{type:"application/javascript"}))),this.worker=new Worker(et)}}rt.revokeObjectURL=function(){et&&(URL.revokeObjectURL(et),et=null)};let st=null;class it{constructor(){st||(st=URL.createObjectURL(new Blob(['(function () {\n \'use strict\';\n\n async function loadImageBitmap(url, alphaMode) {\n const response = await fetch(url);\n if (!response.ok) {\n throw new Error(`[WorkerManager.loadImageBitmap] Failed to fetch ${url}: ${response.status} ${response.statusText}`);\n }\n const imageBlob = await response.blob();\n return alphaMode === "premultiplied-alpha" ? createImageBitmap(imageBlob, { premultiplyAlpha: "none" }) : createImageBitmap(imageBlob);\n }\n self.onmessage = async (event) => {\n try {\n const imageBitmap = await loadImageBitmap(event.data.data[0], event.data.data[1]);\n self.postMessage({\n data: imageBitmap,\n uuid: event.data.uuid,\n id: event.data.id\n }, [imageBitmap]);\n } catch (e) {\n self.postMessage({\n error: e,\n uuid: event.data.uuid,\n id: event.data.id\n });\n }\n };\n\n})();\n'],{type:"application/javascript"}))),this.worker=new Worker(st)}}it.revokeObjectURL=function(){st&&(URL.revokeObjectURL(st),st=null)};let nt,ot=0;const at=new class{constructor(){this._initialized=!1,this._createdWorkers=0,this._workerPool=[],this._queue=[],this._resolveHash={}}isImageBitmapSupported(){return void 0!==this._isImageBitmapSupported||(this._isImageBitmapSupported=new Promise(t=>{const{worker:e}=new rt;e.addEventListener("message",r=>{e.terminate(),rt.revokeObjectURL(),t(r.data)})})),this._isImageBitmapSupported}loadImageBitmap(t,e){return this._run("loadImageBitmap",[t,e?.data?.alphaMode])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){void 0===nt&&(nt=navigator.hardwareConcurrency||4);let t=this._workerPool.pop();return!t&&this._createdWorkers<nt&&(this._createdWorkers++,t=(new it).worker,t.addEventListener("message",t=>{this._complete(t.data),this._returnWorker(t.target),this._next()})),t}_returnWorker(t){this._workerPool.push(t)}_complete(t){void 0!==t.error?this._resolveHash[t.uuid].reject(t.error):this._resolveHash[t.uuid].resolve(t.data),this._resolveHash[t.uuid]=null}async _run(t,e){await this._initWorkers();const r=new Promise((r,s)=>{this._queue.push({id:t,arguments:e,resolve:r,reject:s})});return this._next(),r}_next(){if(!this._queue.length)return;const t=this._getWorker();if(!t)return;const e=this._queue.pop(),r=e.id;this._resolveHash[ot]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:ot++,id:r})}reset(){this._workerPool.forEach(t=>t.terminate()),this._workerPool.length=0,Object.values(this._resolveHash).forEach(({reject:t})=>{t?.(new Error("WorkerManager destroyed"))}),this._resolveHash={},this._queue.length=0,this._initialized=!1,this._createdWorkers=0}},lt=[".jpeg",".jpg",".png",".webp",".avif"],ht=["image/jpeg","image/png","image/webp","image/avif"],ct={name:"loadTextures",id:"texture",extension:{type:t.Ag.LoadParser,priority:i.T.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test:t=>U(t,ht)||L(t,lt),async load(t,e,r){let s=null;return s=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await at.isImageBitmapSupported()?await at.loadImageBitmap(t,e):await async function(t,e){const r=await o.e.get().fetch(t);if(!r.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${t}: ${r.status} ${r.statusText}`);const s=await r.blob();return"premultiplied-alpha"===e?.data?.alphaMode?createImageBitmap(s,{premultiplyAlpha:"none"}):createImageBitmap(s)}(t,e):await new Promise((e,r)=>{s=o.e.get().createImage(),s.crossOrigin=this.config.crossOrigin,s.src=t,s.complete?e(s):(s.onload=()=>{e(s)},s.onerror=r)}),J(new q.b({resource:s,alphaMode:"premultiply-alpha-on-upload",resolution:e.data?.resolution||Q(t),...e.data}),r,t)},unload(t){t.destroy(!0)}};var ut=r(5749),dt=r(5180);const pt=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"];let ft,gt;const mt={name:"loadVideo",id:"video",extension:{type:t.Ag.LoadParser,name:"loadVideo"},test(t){if(!ft||!gt){const{validVideoExtensions:t,validVideoMime:e}=function(){const t=[],e=[];for(const r of pt){const s=ut.$.MIME_TYPES[r.substring(1)]||`video/${r.substring(1)}`;R(s)&&(t.push(r),e.includes(s)||e.push(s))}return{validVideoExtensions:t,validVideoMime:e}}();ft=t,gt=e}const e=U(t,gt),r=L(t,ft);return e||r},async load(t,e,r){const s={...ut.$.defaultOptions,resolution:e.data?.resolution||Q(t),alphaMode:e.data?.alphaMode||await(0,dt.C)(),...e.data},i=document.createElement("video"),n={preload:!1!==s.autoLoad?"auto":void 0,"webkit-playsinline":!1!==s.playsinline?"":void 0,playsinline:!1!==s.playsinline?"":void 0,muted:!0===s.muted?"":void 0,loop:!0===s.loop?"":void 0,autoplay:!1!==s.autoPlay?"":void 0};Object.keys(n).forEach(t=>{const e=n[t];void 0!==e&&i.setAttribute(t,e)}),!0===s.muted&&(i.muted=!0),function(t,e,r){void 0!==r||e.startsWith("data:")?!1!==r&&(t.crossOrigin="string"==typeof r?r:"anonymous"):t.crossOrigin=function(t,e=globalThis.location){if(t.startsWith("data:"))return"";e||(e=globalThis.location);const r=new URL(t,document.baseURI);return r.hostname!==e.hostname||r.port!==e.port||r.protocol!==e.protocol?"anonymous":""}(e)}(i,t,s.crossorigin);const o=document.createElement("source");let a;if(s.mime)a=s.mime;else if(t.startsWith("data:"))a=t.slice(5,t.indexOf(";"));else if(!t.startsWith("blob:")){const e=t.split("?")[0].slice(t.lastIndexOf(".")+1).toLowerCase();a=ut.$.MIME_TYPES[e]||`video/${e}`}return o.src=t,a&&(o.type=a),new Promise(n=>{const a=async()=>{const o=new ut.$({...s,resource:i});var l;i.removeEventListener("canplay",a),e.data.preload&&await(l=i,new Promise((t,e)=>{function r(){i(),t()}function s(t){i(),e(t)}function i(){l.removeEventListener("canplaythrough",r),l.removeEventListener("error",s)}l.addEventListener("canplaythrough",r),l.addEventListener("error",s),l.load()})),n(J(o,r,t))};s.preload&&!s.autoPlay&&i.load(),i.addEventListener("canplay",a),i.appendChild(o)})},unload(t){t.destroy(!0)}},xt={extension:{type:t.Ag.ResolveParser,name:"resolveTexture"},test:ct.test,parse:t=>({resolution:parseFloat(Z.x.RETINA_PREFIX.exec(t)?.[1]??"1"),format:t.split(".").pop(),src:t})},_t={extension:{type:t.Ag.ResolveParser,priority:-2,name:"resolveJson"},test:t=>Z.x.RETINA_PREFIX.test(t)&&t.endsWith(".json"),parse:xt.parse},yt=new class{constructor(){this._detections=[],this._initialized=!1,this.resolver=new Z.x,this.loader=new D,this.cache=T.l,this._backgroundLoader=new w(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){if(this._initialized)return void(0,b.R)("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let e=t.manifest;"string"==typeof e&&(e=await this.load(e)),this.resolver.addManifest(e)}const e=t.texturePreference?.resolution??1,r="number"==typeof e?[e]:e,s=await this._detectFormats({preferredFormats:t.texturePreference?.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:s,resolution:r}}),t.preferences&&this.setPreferences(t.preferences)}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();const r=(0,O.a)(t),s=(0,F.z)(t).map(t=>{if("string"!=typeof t){const e=this.resolver.getAlias(t);return e.some(t=>!this.resolver.hasKey(t))&&this.add(t),Array.isArray(e)?e[0]:e}return this.resolver.hasKey(t)||this.add({alias:t,src:t}),t}),i=this.resolver.resolve(s),n=await this._mapLoadToResolve(i,e);return r?n[s[0]]:n}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let r=!1;"string"==typeof t&&(r=!0,t=[t]);const s=this.resolver.resolveBundle(t),i={},n=Object.keys(s);let o=0,a=0;const l=()=>{e?.(++o/a)},h=n.map(t=>{const e=s[t],r=Object.values(e),n=[...new Set(r.flat())];return a+=n.length,this._mapLoadToResolve(e,l).then(e=>{i[t]=e})});return await Promise.all(h),r?i[t[0]]:i}async backgroundLoad(t){this._initialized||await this.init(),"string"==typeof t&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),"string"==typeof t&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach(t=>{this._backgroundLoader.add(Object.values(t))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if("string"==typeof t)return T.l.get(t);const e={};for(let r=0;r<t.length;r++)e[r]=T.l.get(t[r]);return e}async _mapLoadToResolve(t,e){const r=[...new Set(Object.values(t))];this._backgroundLoader.active=!1;const s=await this.loader.load(r,e);this._backgroundLoader.active=!0;const i={};return r.forEach(t=>{const e=s[t.src],r=[t.src];t.alias&&r.push(...t.alias),r.forEach(t=>{i[t]=e}),T.l.set(r,e)}),i}async unload(t){this._initialized||await this.init();const e=(0,F.z)(t).map(t=>"string"!=typeof t?t.src:t),r=this.resolver.resolve(e);await this._unloadFromResolved(r)}async unloadBundle(t){this._initialized||await this.init(),t=(0,F.z)(t);const e=this.resolver.resolveBundle(t),r=Object.keys(e).map(t=>this._unloadFromResolved(e[t]));await Promise.all(r)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(t=>{T.l.remove(t.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const r of t.detections)t.skipDetections||await r.test()?e=await r.add(e):t.skipDetections||(e=await r.remove(e));return e=e.filter((t,r)=>e.indexOf(t)===r),e}get detections(){return this._detections}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(e=>e in t).forEach(r=>{e.config[r]=t[r]})})}};t.XO.handleByList(t.Ag.LoadParser,yt.loader.parsers).handleByList(t.Ag.ResolveParser,yt.resolver.parsers).handleByList(t.Ag.CacheParser,yt.cache.parsers).handleByList(t.Ag.DetectionParser,yt.detections),t.XO.add(S,M,C,G,k,B,I,N,z,$,tt,ct,mt,v,y,xt,_t);const vt={loader:t.Ag.LoadParser,resolver:t.Ag.ResolveParser,cache:t.Ag.CacheParser,detection:t.Ag.DetectionParser};t.XO.handle(t.Ag.Asset,e=>{const r=e.ref;Object.entries(vt).filter(([t])=>!!r[t]).forEach(([e,s])=>t.XO.add(Object.assign(r[e],{extension:r[e].extension??s})))},e=>{const r=e.ref;Object.keys(vt).filter(t=>!!r[t]).forEach(e=>t.XO.remove(r[e]))});var bt=r(6675),wt=r(656),Tt=r(9677),St=r(2305),At=r(1570),Ct=r(7335),Pt=r(6114);let Mt,Et;function Rt(t){return void 0!==Mt||(Mt=(()=>{const e={stencil:!0,failIfMajorPerformanceCaveat:t??Pt.k.defaultOptions.failIfMajorPerformanceCaveat};try{if(!o.e.get().getWebGLRenderingContext())return!1;let t=o.e.get().createCanvas().getContext("webgl",e);const r=!!t?.getContextAttributes()?.stencil;if(t){const e=t.getExtension("WEBGL_lose_context");e&&e.loseContext()}return t=null,r}catch(t){return!1}})()),Mt}async function kt(t={}){return void 0!==Et||(Et=await(async()=>{const e=o.e.get().getNavigator().gpu;if(!e)return!1;try{const r=await e.requestAdapter(t);return await r.requestDevice(),!0}catch(t){return!1}})()),Et}const Bt=["webgl","webgpu","canvas"];var It=r(2478),Gt=r(1579),Ft=r(9798),Ot=(r(9062),r(8337)),Dt=r(1657),Ut=r(4269),Lt=(r(7935),r(4687)),Nt=r(4454);(r(3880),r(3651),r(4242)).k;var zt=r(4543),Wt=r(2043);r(4872),t.XO.add(e,s);class Ht{#t;#e;constructor(t){this.#t=t,this.#e=!1}get dirty(){return this.#e}get v(){return this.#t}set v(t){this.#t!==t&&(this.#e=!0),this.#t=t}resetDirty(){this.#e=!1}}class Xt extends Ht{#r;#s;constructor(t){super(t),this.#r=Math.cos(t),this.#s=Math.sin(t)}get cos(){return this.#r}get sin(){return this.#s}set v(t){super.v!==t&&(this.#r=Math.cos(t),this.#s=Math.sin(t)),super.v=t}get v(){return super.v}}class Vt{#i={};on(t,e){return this.#i[t]||(this.#i[t]=[]),this.#i[t].push({listener:e}),this}once(t,e){return this.#i[t]||(this.#i[t]=[]),this.#i[t].push({listener:e,once:!0}),this}off(t,e){const r=this.#i[t];return r?(this.#i[t]=r.filter(t=>t.listener!==e),0===this.#i[t].length&&delete this.#i[t],this):this}async emit(t,...e){const r=this.#i[t];if(!r)return[];const s=[],i=[];for(const n of r){const r=n.listener(...e);n.once&&this.off(t,n.listener),r instanceof Promise?i.push(r):s.push(r)}return s.concat(await Promise.all(i))}#n=[];bindTo(t,e,r){this.on(e,r);const s=()=>{this.off(e,r);const s=this.#n.findIndex(s=>s.target===t&&s.key===e&&s.listener===r);-1!==s&&this.#n.splice(s,1)};return t.on("remove",s),this.#n.push({key:e,target:t,listener:r,removeHandler:s}),this}remove(){this.emit("remove");for(const t of this.#n)t.target.off("remove",t.removeHandler);this.#n.length=0}}class Yt extends Vt{#o;children=[];paused=!1;set parent(t){this.#o=t}get parent(){return this.#o}add(...t){for(const e of t){if(e.#o){const t=e.#o.children.indexOf(e);-1!==t&&e.#o.children.splice(t,1)}e.parent=this,this.children.push(e)}}remove(){if(super.remove(),this.#o){const t=this.#o.children.indexOf(this);-1!==t&&this.#o.children.splice(t,1),this.#o=void 0}for(const t of this.children)t.parent=void 0,t.remove();this.children.length=0}pause(){this.paused=!0;for(const t of this.children)t.pause()}resume(){this.paused=!1;for(const t of this.children)t.resume()}update(t){if(!this.paused){for(const e of this.children)e.paused||e.update(t);this.emit("update",t)}}}class jt{x=0;y=0;scaleX=1;scaleY=1;pivotX=0;pivotY=0;#a=0;#r=1;#s=0;get cos(){return this.#r}get sin(){return this.#s}get rotation(){return this.#a}set rotation(t){this.#a!==t&&(this.#a=t,this.#r=Math.cos(t),this.#s=Math.sin(t))}}class $t{x=new Ht(Number.NEGATIVE_INFINITY);y=new Ht(Number.NEGATIVE_INFINITY);scaleX=new Ht(1);scaleY=new Ht(1);rotation=new Xt(0);update(t,e){const r=e.x*t.scaleX.v,s=e.y*t.scaleY.v,i=t.rotation.cos,n=t.rotation.sin;this.scaleX.v=t.scaleX.v*e.scaleX,this.scaleY.v=t.scaleY.v*e.scaleY;const o=e.pivotX*this.scaleX.v,a=e.pivotY*this.scaleY.v,l=e.cos,h=e.sin;this.x.v=t.x.v+(r*i-s*n)-(o*l-a*h),this.y.v=t.y.v+(r*n+s*i)-(o*h+a*l),this.rotation.v=t.rotation.v+e.rotation}get dirty(){return this.x.dirty||this.y.dirty||this.scaleX.dirty||this.scaleY.dirty||this.rotation.dirty}resetDirty(){this.x.resetDirty(),this.y.resetDirty(),this.scaleX.resetDirty(),this.scaleY.resetDirty(),this.rotation.resetDirty()}}function qt(t){return void 0!==t.worldTransform}class Kt extends Yt{#l;_pixiContainer;worldTransform=new $t;worldAlpha=new Ht(1);constructor(t){super(),this._pixiContainer=t}set renderer(t){this.#l=t;for(const e of this.children)qt(e)&&(e.renderer=t)}get renderer(){return this.#l}add(...t){super.add(...t);for(const e of t)qt(e)&&(this._pixiContainer.addChild(e._pixiContainer),this.#l&&(e.renderer=this.#l))}remove(){this._pixiContainer.destroy({children:!0}),super.remove()}_updateWorldTransform(){for(const t of this.children)qt(t)&&t._updateWorldTransform();this.worldTransform.resetDirty()}set tint(t){this._pixiContainer.tint=t}get tint(){return this._pixiContainer.tint}}class Zt extends Kt{localTransform=new jt;alpha=1;#h;#c=!1;constructor(t,e){super(t),void 0!==e.x&&(this.x=e.x),void 0!==e.y&&(this.y=e.y),void 0!==e.scale&&(this.scale=e.scale),void 0!==e.scaleX&&(this.scaleX=e.scaleX),void 0!==e.scaleY&&(this.scaleY=e.scaleY),void 0!==e.pivotX&&(this.pivotX=e.pivotX),void 0!==e.pivotY&&(this.pivotY=e.pivotY),void 0!==e.rotation&&(this.rotation=e.rotation),void 0!==e.alpha&&(this.alpha=e.alpha),this.#h=e.layer,this.#c=e.useYSort??!1}set renderer(t){super.renderer=t,this.#h&&t&&t._addToLayer(this,this.#h)}get renderer(){return super.renderer}_updateWorldTransform(){const t=this.parent;t&&qt(t)&&(this.worldTransform.update(t.worldTransform,this.localTransform),this.worldAlpha.v=t.worldAlpha.v*this.alpha);const e=this._pixiContainer,r=this.renderer;if(this.#h&&r){const t=this.worldTransform;e.position.set(t.x.v,t.y.v),e.scale.set(t.scaleX.v,t.scaleY.v),e.rotation=t.rotation.v,e.alpha=this.worldAlpha.v}else{const t=this.localTransform;e.position.set(t.x,t.y),this.#c&&(e.zIndex=t.y),e.pivot.set(t.pivotX,t.pivotY),e.scale.set(t.scaleX,t.scaleY),e.rotation=t.rotation,e.alpha=this.alpha}super._updateWorldTransform()}set x(t){this.localTransform.x=t}get x(){return this.localTransform.x}set y(t){this.localTransform.y=t}get y(){return this.localTransform.y}set scale(t){this.localTransform.scaleX=t,this.localTransform.scaleY=t}get scale(){return this.localTransform.scaleX}set scaleX(t){this.localTransform.scaleX=t}get scaleX(){return this.localTransform.scaleX}set scaleY(t){this.localTransform.scaleY=t}get scaleY(){return this.localTransform.scaleY}set pivotX(t){this.localTransform.pivotX=t}get pivotX(){return this.localTransform.pivotX}set pivotY(t){this.localTransform.pivotY=t}get pivotY(){return this.localTransform.pivotY}set rotation(t){this.localTransform.rotation=t}get rotation(){return this.localTransform.rotation}}class Qt extends Zt{constructor(t){super(new Lt.mc({sortableChildren:!0}),t??{})}}let Jt=!1;function te(t,e){if(t)return Object.assign(t.style,e),t}class ee extends Vt{#u=0;#d=0;#p=1;get x(){return this.#u}get y(){return this.#d}get scale(){return this.#p}setPosition(t,e){this.#u=t,this.#d=e,this.emit("positionChanged")}setScale(t){this.#p=t,this.emit("scaleChanged")}}class re extends Vt{#f;#g;#m=new Ht(0);#x=new Ht(0);constructor(t){super(),this.#f=t,this.#g=new ResizeObserver(this.#_.bind(this)),this.#g.observe(t)}#_(){const t=this.#f.getBoundingClientRect();this.#m.v=t.width,this.#x.v=t.height,(this.#m.dirty||this.#x.dirty)&&(this.emit("resize",this.#m.v,this.#x.v),this.#m.resetDirty(),this.#x.resetDirty())}remove(){this.#g.disconnect(),super.remove()}}var se=r(9087),ie=r.n(se);class ne{#y;constructor(t){const e=new(ie());e.dom.style.position="absolute",e.showPanel(0),t.appendChild(e.dom),this.#y=e}update(){this.#y.update()}remove(){this.#y.dom.remove()}}class oe extends Kt{constructor(t){super(new Lt.mc({sortableChildren:!0})),this._pixiContainer.zIndex=t,this.worldTransform.x.v=0,this.worldTransform.y.v=0,this.worldTransform.resetDirty()}}class ae{#v;#b=0;constructor(t){let e=0,r=0;const s=i=>{const n=(i-e)/1e3;if(n>0){const s=this.#v;if(void 0!==s&&s>0){r+=n;const e=1/s;r>=e&&(t(e),r>=2*e?(t(n),r=0):r-=e)}else t(n);e=i}this.#b=requestAnimationFrame(s)};this.#b=requestAnimationFrame(s),Jt&&(document.hasFocus()||(this.#v=6),window.addEventListener("blur",this.#w),window.addEventListener("focus",this.#T),window.addEventListener("pageshow",this.#S))}#w=()=>{this.#v=6};#T=()=>{this.#v=void 0};#S=t=>{t.persisted&&(this.#v=void 0)};remove(){cancelAnimationFrame(this.#b),window.removeEventListener("blur",this.#w),window.removeEventListener("focus",this.#T),window.removeEventListener("pageshow",this.#S)}}const le=/Android|iPhone|iPad|iPod/i.test(navigator.userAgent);class he{cachedAssets=new Map;loadingPromises=new Map;#A=new Map;#C(t){this.#A.set(t,(this.#A.get(t)||0)+1)}hasActiveRef(t){return this.#A.get(t)>0}cleanup(t,e){}checkCached(t){return this.cachedAssets.has(t)}getCached(t){if(!this.checkCached(t))throw new Error(`Asset not found: ${t}`);return this.#C(t),this.cachedAssets.get(t)}async load(t,...e){return this.#C(t),this.checkCached(t)?this.cachedAssets.get(t):this.loadingPromises.has(t)?await this.loadingPromises.get(t):await this.doLoad(t,...e)}release(t){const e=this.#A.get(t);if(void 0===e)throw new Error(`Asset not found: ${t}`);if(1===e){this.#A.delete(t);const e=this.cachedAssets.get(t);e&&(this.cleanup(t,e),this.cachedAssets.delete(t))}else this.#A.set(t,e-1)}}const ce=new class extends he{async doLoad(t){const e=(async()=>{const e=await fetch(t);if(!e.ok)return void console.error(`Failed to load audio data: ${t}`);const r=await e.arrayBuffer();try{const e=await ue.decodeAudioData(r);if(this.loadingPromises.delete(t),this.hasActiveRef(t)){if(!this.cachedAssets.has(t))return this.cachedAssets.set(t,e),e;console.error(`Audio buffer already exists: ${t}`)}}catch(e){console.error(`Failed to decode audio data: ${t}`,e),this.loadingPromises.delete(t)}})();return this.loadingPromises.set(t,e),await e}},ue=new(window.AudioContext||window.webkitAudioContext);window.addEventListener("mousedown",()=>ue.resume()),window.addEventListener("touchend",()=>ue.resume());let de=!document.hidden;window.addEventListener("visibilitychange",()=>de=!document.hidden);const pe=function(){const t=(()=>{const t=new Map;return{persistent:!1,getItem:e=>t.has(e)?t.get(e):null,setItem:(e,r)=>{t.set(e,String(r))},removeItem:e=>{t.delete(e)}}})();if("undefined"==typeof window)return t;try{const t=window.localStorage,e="__safe_ls_probe__"+Math.random().toString(36).slice(2);return t.setItem(e,"1"),t.removeItem(e),{persistent:!0,getItem:e=>t.getItem(e),setItem:(e,r)=>t.setItem(e,r),removeItem:e=>t.removeItem(e)}}catch{return t}}();class fe{src;#P;#M;#E;#R;#k;#B;#I=!1;#G=!1;#F=0;#O=0;#D=0;constructor(t,e,r){this.src=t,this.#P=e,this.#M=r,this.play()}get volume(){return this.#P}set volume(t){this.#P=t,this.#k&&(this.#k.gain.value=Math.max(0,Math.min(1,t)))}async play(){le&&!de||(this.#E||(ce.checkCached(this.src)?this.#E=ce.getCached(this.src):(console.info(`Audio not preloaded. Loading now: ${this.src}`),this.#E=await ce.load(this.src))),this.#E&&(this.#I&&this.stop(),this.#G||(this.#D=0),this.#I=!0,this.#G=!1,this.#R||(this.#R=await async function(){return"suspended"===ue.state&&await ue.resume(),ue}()),this.#I&&(this.#k||(this.#k=this.#R.createGain(),this.#k.gain.value=this.#P,this.#k.connect(this.#R.destination)),this.#B=this.#R.createBufferSource(),this.#B.buffer=this.#E,this.#B.loop=this.#M,this.#B.connect(this.#k),this.#B.start(0,this.#D),this.#F=this.#R.currentTime,this.#B.onended=()=>{this.#G||this.#M||this.stop()})))}#U(){this.#B&&(this.#B.stop(),this.#B.disconnect(),this.#B=void 0)}pause(){this.#I&&!this.#G&&(this.#R&&(this.#O=this.#R.currentTime,this.#D+=this.#O-this.#F),this.#G=!0,this.#I=!1,this.#U())}stop(){this.#I=!1,this.#G=!1,this.#D=0,this.#U()}}new class{#P=.7;#L;constructor(){const t=parseFloat(pe.getItem("musicVolume")||"");this.#P=Number.isNaN(t)?this.#P:t,le&&document.addEventListener("visibilitychange",()=>{document.hidden?this.pause():(de=!0,this.#L?.play())})}get volume(){return this.#P}set volume(t){this.#P=t,pe.setItem("musicVolume",t.toString()),this.#L&&(this.#L.volume=t)}play(t){this.#L?.src!==t&&(this.#L?.stop(),this.#L=new fe(t,this.#P,!0))}pause(){this.#L?.pause()}stop(){this.#L?.stop(),this.#L=void 0}},new class{#P=1;constructor(){const t=parseFloat(pe.getItem("sfxVolume")||"");this.#P=Number.isNaN(t)?this.#P:t}get volume(){return this.#P}set volume(t){this.#P=t,pe.setItem("sfxVolume",t.toString())}play(t){new fe(t,this.#P,!1)}playRandom(...t){this.play(t[Math.floor(Math.random()*t.length)])}},new class extends he{async doLoad(t){const e=(async()=>{const e=await fetch(t);if(!e.ok)return void console.error(`Failed to load binary data: ${t}`);const r=await e.arrayBuffer(),s=new Uint8Array(r);if(this.loadingPromises.delete(t),this.hasActiveRef(t)){if(!this.cachedAssets.has(t))return this.cachedAssets.set(t,s),s;console.error(`Binary data already exists: ${t}`)}})();return this.loadingPromises.set(t,e),await e}};const ge=new class extends he{async doLoad(t){const e=new Promise(e=>{const r=new Image;r.crossOrigin="anonymous",r.src=t,r.onload=()=>{if(this.loadingPromises.delete(t),!this.hasActiveRef(t))return void e(void 0);if(this.cachedAssets.has(t))return console.error(`Texture already loaded: ${t}`),void e(void 0);const s=c.g.from(r);s.source.scaleMode="nearest",this.cachedAssets.set(t,s),e(s)},r.onerror=r=>{this.loadingPromises.delete(t),console.error(`Failed to load texture: ${t}`,r),e(void 0)}});return this.loadingPromises.set(t,e),await e}cleanup(t,e){e.destroy(!0)}};var me,xe,_e,ye,ve,be;if(new class extends he{#N=new Map;async doLoad(t,e){this.#N.set(t,e);const r=(async()=>{const r=await ge.load(e);if(!r)return void console.error(`Failed to load texture: ${e}`);const s=await fetch(t);if(s.ok)try{const i=await s.text(),n=(new DOMParser).parseFromString(i,"application/xml"),o=n.getElementsByTagName("info")[0],a=n.getElementsByTagName("common")[0],l=n.getElementsByTagName("char"),h=parseInt(o.getAttribute("size")||"16",10),c=parseInt(a.getAttribute("lineHeight")||"32",10),u={};for(let t=0;t<l.length;t++){const e=l[t],r=parseInt(e.getAttribute("id"),10),s=parseInt(e.getAttribute("x"),10),i=parseInt(e.getAttribute("y"),10),n=parseInt(e.getAttribute("width"),10),o=parseInt(e.getAttribute("height"),10),a=parseInt(e.getAttribute("xoffset"),10),h=parseInt(e.getAttribute("yoffset"),10),c=parseInt(e.getAttribute("xadvance"),10);u[r]={x:s,y:i,width:n,height:o,xoffset:a,yoffset:h,xadvance:c}}this.loadingPromises.delete(t);const d={src:e,chars:u,texture:r,size:h,lineHeight:c};if(this.hasActiveRef(t)){if(!this.cachedAssets.has(t))return this.cachedAssets.set(t,d),d;ge.release(e),console.error(`Bitmap font already exists: ${t}`)}else ge.release(e)}catch(e){console.error(`Failed to decode font xml: ${t}`,e),this.loadingPromises.delete(t)}else console.error(`Failed to load font xml: ${t}`)})();return this.loadingPromises.set(t,r),await r}cleanup(t){const e=this.#N.get(t);e&&ge.release(e)}},new class extends he{async doLoad(t){const e=(async()=>{if("fonts"in document)try{return await document.fonts.load(`1em ${t}`),await document.fonts.ready,this.loadingPromises.delete(t),!0}catch(e){console.error(`Failed to load font: ${t}`,e),this.loadingPromises.delete(t)}else console.warn("This browser does not support the Font Loading API"),this.loadingPromises.delete(t)})();return this.loadingPromises.set(t,e),await e}},new WeakMap,new class extends he{#z=new Map;async doLoad(t,e,r){this.#z.set(t,e);const s=(async()=>{const s=await ge.load(e);if(!s)return void console.error(`Failed to load texture: ${e}`);const i=new Wt.z(s,r);if(await i.parse(),this.loadingPromises.delete(t),this.hasActiveRef(t)){if(!this.cachedAssets.has(t))return this.cachedAssets.set(t,i),i;ge.release(e),console.error(`Spritesheet already exists: ${e}`)}else ge.release(e)})();return this.loadingPromises.set(t,s),await s}cleanup(t,e){e.destroy();const r=this.#z.get(t);r&&ge.release(r)}},new class extends he{async doLoad(t){const e=(async()=>{const e=await fetch(t);if(!e.ok)return void console.error(`Failed to load text: ${t}`);const r=await e.text();if(this.loadingPromises.delete(t),this.hasActiveRef(t)){if(!this.cachedAssets.has(t))return this.cachedAssets.set(t,r),r;console.error(`Text already exists: ${t}`)}})();return this.loadingPromises.set(t,e),await e}},(xe=me||(me={}))[xe.Rectangle=0]="Rectangle",xe[xe.Circle=1]="Circle",xe[xe.Ellipse=2]="Ellipse",xe[xe.Polygon=3]="Polygon",function(t){t[t.None=0]="None",t[t.Ellipse=1]="Ellipse",t[t.OBB=2]="OBB",t[t.Circle=3]="Circle",t[t.Poly=4]="Poly",t[t.PolyLocal=5]="PolyLocal"}(_e||(_e={})),"undefined"!=typeof window&&window.PIXI){const t=window.require;window.require=e=>t?t(e):e.startsWith("@pixi/")||e.startsWith("pixi.js")?window.PIXI:void 0}class we{entries={};size=0;add(t){let e=this.entries[t];return this.entries[t]=!0,!e&&(this.size++,!0)}addAll(t){let e=this.size;for(var r=0,s=t.length;r<s;r++)this.add(t[r]);return e!=this.size}contains(t){return this.entries[t]}clear(){this.entries={},this.size=0}}class Te{r;g;b;a;static WHITE=new Te(1,1,1,1);static RED=new Te(1,0,0,1);static GREEN=new Te(0,1,0,1);static BLUE=new Te(0,0,1,1);static MAGENTA=new Te(1,0,1,1);constructor(t=0,e=0,r=0,s=0){this.r=t,this.g=e,this.b=r,this.a=s}set(t,e,r,s){return this.r=t,this.g=e,this.b=r,this.a=s,this.clamp()}setFromColor(t){return this.r=t.r,this.g=t.g,this.b=t.b,this.a=t.a,this}setFromString(t){return t="#"==t.charAt(0)?t.substr(1):t,this.r=parseInt(t.substr(0,2),16)/255,this.g=parseInt(t.substr(2,2),16)/255,this.b=parseInt(t.substr(4,2),16)/255,this.a=8!=t.length?1:parseInt(t.substr(6,2),16)/255,this}add(t,e,r,s){return this.r+=t,this.g+=e,this.b+=r,this.a+=s,this.clamp()}clamp(){return this.r<0?this.r=0:this.r>1&&(this.r=1),this.g<0?this.g=0:this.g>1&&(this.g=1),this.b<0?this.b=0:this.b>1&&(this.b=1),this.a<0?this.a=0:this.a>1&&(this.a=1),this}static rgba8888ToColor(t,e){t.r=((4278190080&e)>>>24)/255,t.g=((16711680&e)>>>16)/255,t.b=((65280&e)>>>8)/255,t.a=(255&e)/255}static rgb888ToColor(t,e){t.r=((16711680&e)>>>16)/255,t.g=((65280&e)>>>8)/255,t.b=(255&e)/255}toRgb888(){const t=t=>("0"+(255*t).toString(16)).slice(-2);return Number("0x"+t(this.r)+t(this.g)+t(this.b))}static fromString(t,e=new Te){return e.setFromString(t)}}class Se{static PI=3.1415927;static PI2=2*Se.PI;static invPI2=1/Se.PI2;static radiansToDegrees=180/Se.PI;static radDeg=Se.radiansToDegrees;static degreesToRadians=Se.PI/180;static degRad=Se.degreesToRadians;static clamp(t,e,r){return t<e?e:t>r?r:t}static cosDeg(t){return Math.cos(t*Se.degRad)}static sinDeg(t){return Math.sin(t*Se.degRad)}static atan2Deg(t,e){return Math.atan2(t,e)*Se.degRad}static signum(t){return t>0?1:t<0?-1:0}static toInt(t){return t>0?Math.floor(t):Math.ceil(t)}static cbrt(t){let e=Math.pow(Math.abs(t),1/3);return t<0?-e:e}static randomTriangular(t,e){return Se.randomTriangularWith(t,e,.5*(t+e))}static randomTriangularWith(t,e,r){let s=Math.random(),i=e-t;return s<=(r-t)/i?t+Math.sqrt(s*i*(r-t)):e-Math.sqrt((1-s)*i*(e-r))}static isPowerOfTwo(t){return t&&!(t&t-1)}}class Ae{static SUPPORTS_TYPED_ARRAYS="undefined"!=typeof Float32Array;static arrayCopy(t,e,r,s,i){for(let n=e,o=s;n<e+i;n++,o++)r[o]=t[n]}static arrayFill(t,e,r,s){for(let i=e;i<r;i++)t[i]=s}static setArraySize(t,e,r=0){let s=t.length;if(s==e)return t;if(t.length=e,s<e)for(let i=s;i<e;i++)t[i]=r;return t}static ensureArrayCapacity(t,e,r=0){return t.length>=e?t:Ae.setArraySize(t,e,r)}static newArray(t,e){let r=new Array(t);for(let s=0;s<t;s++)r[s]=e;return r}static newFloatArray(t){if(Ae.SUPPORTS_TYPED_ARRAYS)return new Float32Array(t);{let e=new Array(t);for(let t=0;t<e.length;t++)e[t]=0;return e}}static newShortArray(t){if(Ae.SUPPORTS_TYPED_ARRAYS)return new Int16Array(t);{let e=new Array(t);for(let t=0;t<e.length;t++)e[t]=0;return e}}static toFloatArray(t){return Ae.SUPPORTS_TYPED_ARRAYS?new Float32Array(t):t}static toSinglePrecision(t){return Ae.SUPPORTS_TYPED_ARRAYS?Math.fround(t):t}static webkit602BugfixHelper(t,e){}static contains(t,e,r=!0){for(var s=0;s<t.length;s++)if(t[s]==e)return!0;return!1}static enumValue(t,e){return t[e[0].toUpperCase()+e.slice(1)]}}class Ce{items=new Array;instantiator;constructor(t){this.instantiator=t}obtain(){return this.items.length>0?this.items.pop():this.instantiator()}free(t){t.reset&&t.reset(),this.items.push(t)}freeAll(t){for(let e=0;e<t.length;e++)this.free(t[e])}clear(){this.items.length=0}}class Pe{x;y;constructor(t=0,e=0){this.x=t,this.y=e}set(t,e){return this.x=t,this.y=e,this}length(){let t=this.x,e=this.y;return Math.sqrt(t*t+e*e)}normalize(){let t=this.length();return 0!=t&&(this.x/=t,this.y/=t),this}}class Me{name;constructor(t){if(!t)throw new Error("name cannot be null.");this.name=t}}class Ee extends Me{static nextID=0;id=Ee.nextID++;bones=null;vertices=[];worldVerticesLength=0;timelineAttachment=this;constructor(t){super(t)}computeWorldVertices(t,e,r,s,i,n){r=i+(r>>1)*n;let o=t.bone.skeleton,a=t.deform,l=this.vertices,h=this.bones;if(!h){a.length>0&&(l=a);let o=t.bone,h=o.worldX,c=o.worldY,u=o.a,d=o.b,p=o.c,f=o.d;for(let t=e,o=i;o<r;t+=2,o+=n){let e=l[t],r=l[t+1];s[o]=e*u+r*d+h,s[o+1]=e*p+r*f+c}return}let c=0,u=0;for(let t=0;t<e;t+=2){let t=h[c];c+=t+1,u+=t}let d=o.bones;if(0==a.length)for(let t=i,e=3*u;t<r;t+=n){let r=0,i=0,n=h[c++];for(n+=c;c<n;c++,e+=3){let t=d[h[c]],s=l[e],n=l[e+1],o=l[e+2];r+=(s*t.a+n*t.b+t.worldX)*o,i+=(s*t.c+n*t.d+t.worldY)*o}s[t]=r,s[t+1]=i}else{let t=a;for(let e=i,o=3*u,a=u<<1;e<r;e+=n){let r=0,i=0,n=h[c++];for(n+=c;c<n;c++,o+=3,a+=2){let e=d[h[c]],s=l[o]+t[a],n=l[o+1]+t[a+1],u=l[o+2];r+=(s*e.a+n*e.b+e.worldX)*u,i+=(s*e.c+n*e.d+e.worldY)*u}s[e]=r,s[e+1]=i}}}copyTo(t){this.bones?(t.bones=new Array(this.bones.length),Ae.arrayCopy(this.bones,0,t.bones,0,this.bones.length)):t.bones=null,this.vertices&&(t.vertices=Ae.newFloatArray(this.vertices.length),Ae.arrayCopy(this.vertices,0,t.vertices,0,this.vertices.length)),t.worldVerticesLength=this.worldVerticesLength,t.timelineAttachment=this.timelineAttachment}}!function(t){t[t.hold=0]="hold",t[t.once=1]="once",t[t.loop=2]="loop",t[t.pingpong=3]="pingpong",t[t.onceReverse=4]="onceReverse",t[t.loopReverse=5]="loopReverse",t[t.pingpongReverse=6]="pingpongReverse"}(ye||(ye={})),ye.hold,ye.once,ye.loop,ye.pingpong,ye.onceReverse,ye.loopReverse,ye.pingpongReverse;!function(t){t[t.setup=0]="setup",t[t.first=1]="first",t[t.replace=2]="replace",t[t.add=3]="add"}(ve||(ve={})),function(t){t[t.mixIn=0]="mixIn",t[t.mixOut=1]="mixOut"}(be||(be={}));const Re={rotate:0,x:1,y:2,scaleX:3,scaleY:4,shearX:5,shearY:6,inherit:7,rgb:8,alpha:9,rgb2:10,attachment:11,deform:12,event:13,drawOrder:14,ikConstraint:15,transformConstraint:16,pathConstraintPosition:17,pathConstraintSpacing:18,pathConstraintMix:19,physicsConstraintInertia:20,physicsConstraintStrength:21,physicsConstraintDamping:22,physicsConstraintMass:23,physicsConstraintWind:24,physicsConstraintGravity:25,physicsConstraintMix:26,physicsConstraintReset:27,sequence:28};var ke,Be,Ie,Ge,Fe,Oe,De,Ue,Le,Ne,ze,We;Re.event,Re.drawOrder,Re.physicsConstraintReset.toString(),new class{name;timelines=[];timelineIds=new we;duration;constructor(t,e,r){if(!t)throw new Error("name cannot be null.");this.name=t,this.setTimelines(e),this.duration=r}setTimelines(t){if(!t)throw new Error("timelines cannot be null.");this.timelines=t,this.timelineIds.clear();for(var e=0;e<t.length;e++)this.timelineIds.addAll(t[e].getPropertyIds())}hasTimeline(t){for(let e=0;e<t.length;e++)if(this.timelineIds.contains(t[e]))return!0;return!1}apply(t,e,r,s,i,n,o,a){if(!t)throw new Error("skeleton cannot be null.");s&&0!=this.duration&&(r%=this.duration,e>0&&(e%=this.duration));let l=this.timelines;for(let s=0,h=l.length;s<h;s++)l[s].apply(t,e,r,i,n,o,a)}}("<empty>",[],0),function(t){t[t.start=0]="start",t[t.interrupt=1]="interrupt",t[t.end=2]="end",t[t.dispose=3]="dispose",t[t.complete=4]="complete",t[t.event=5]="event"}(ke||(ke={}));class He extends Ee{endSlot=null;color=new Te(.2275,.2275,.8078,1);constructor(t){super(t)}copy(){let t=new He(this.name);return this.copyTo(t),t.endSlot=this.endSlot,t.color.setFromColor(this.color),t}}class Xe{_image;constructor(t){this._image=t}getImage(){return this._image}}!function(t){t[t.Nearest=9728]="Nearest",t[t.Linear=9729]="Linear",t[t.MipMap=9987]="MipMap",t[t.MipMapNearestNearest=9984]="MipMapNearestNearest",t[t.MipMapLinearNearest=9985]="MipMapLinearNearest",t[t.MipMapNearestLinear=9986]="MipMapNearestLinear",t[t.MipMapLinearLinear=9987]="MipMapLinearLinear"}(Be||(Be={})),function(t){t[t.MirroredRepeat=33648]="MirroredRepeat",t[t.ClampToEdge=33071]="ClampToEdge",t[t.Repeat=10497]="Repeat"}(Ie||(Ie={}));class Ve{texture;u=0;v=0;u2=0;v2=0;width=0;height=0;degrees=0;offsetX=0;offsetY=0;originalWidth=0;originalHeight=0}class Ye{pages=new Array;regions=new Array;constructor(t){let e=new je(t),r=new Array(4),s={size:t=>{t.width=parseInt(r[1]),t.height=parseInt(r[2])},format:()=>{},filter:t=>{t.minFilter=Ae.enumValue(Be,r[1]),t.magFilter=Ae.enumValue(Be,r[2])},repeat:t=>{-1!=r[1].indexOf("x")&&(t.uWrap=Ie.Repeat),-1!=r[1].indexOf("y")&&(t.vWrap=Ie.Repeat)},pma:t=>{t.pma="true"==r[1]}};var i={xy:t=>{t.x=parseInt(r[1]),t.y=parseInt(r[2])},size:t=>{t.width=parseInt(r[1]),t.height=parseInt(r[2])},bounds:t=>{t.x=parseInt(r[1]),t.y=parseInt(r[2]),t.width=parseInt(r[3]),t.height=parseInt(r[4])},offset:t=>{t.offsetX=parseInt(r[1]),t.offsetY=parseInt(r[2])},orig:t=>{t.originalWidth=parseInt(r[1]),t.originalHeight=parseInt(r[2])},offsets:t=>{t.offsetX=parseInt(r[1]),t.offsetY=parseInt(r[2]),t.originalWidth=parseInt(r[3]),t.originalHeight=parseInt(r[4])},rotate:t=>{let e=r[1];"true"==e?t.degrees=90:"false"!=e&&(t.degrees=parseInt(e))},index:t=>{t.index=parseInt(r[1])}};let n=e.readLine();for(;n&&0==n.trim().length;)n=e.readLine();for(;n&&0!=n.trim().length&&0!=e.readEntry(r,n);)n=e.readLine();let o=null,a=null,l=null;for(;null!==n;)if(0==n.trim().length)o=null,n=e.readLine();else if(o){let t=new qe(o,n);for(;;){let s=e.readEntry(r,n=e.readLine());if(0==s)break;let o=i[r[0]];if(o)o(t);else{a||(a=[]),l||(l=[]),a.push(r[0]);let t=[];for(let e=0;e<s;e++)t.push(parseInt(r[e+1]));l.push(t)}}0==t.originalWidth&&0==t.originalHeight&&(t.originalWidth=t.width,t.originalHeight=t.height),a&&a.length>0&&l&&l.length>0&&(t.names=a,t.values=l,a=null,l=null),t.u=t.x/o.width,t.v=t.y/o.height,90==t.degrees?(t.u2=(t.x+t.height)/o.width,t.v2=(t.y+t.width)/o.height):(t.u2=(t.x+t.width)/o.width,t.v2=(t.y+t.height)/o.height),this.regions.push(t)}else{for(o=new $e(n.trim());0!=e.readEntry(r,n=e.readLine());){let t=s[r[0]];t&&t(o)}this.pages.push(o)}}findRegion(t){for(let e=0;e<this.regions.length;e++)if(this.regions[e].name==t)return this.regions[e];return null}setTextures(t,e=""){for(let r of this.pages)r.setTexture(t.get(e+r.name))}dispose(){for(let t=0;t<this.pages.length;t++)this.pages[t].texture?.dispose()}}class je{lines;index=0;constructor(t){this.lines=t.split(/\r\n|\r|\n/)}readLine(){return this.index>=this.lines.length?null:this.lines[this.index++]}readEntry(t,e){if(!e)return 0;if(0==(e=e.trim()).length)return 0;let r=e.indexOf(":");if(-1==r)return 0;t[0]=e.substr(0,r).trim();for(let s=1,i=r+1;;s++){let r=e.indexOf(",",i);if(-1==r)return t[s]=e.substr(i).trim(),s;if(t[s]=e.substr(i,r-i).trim(),i=r+1,4==s)return 4}}}class $e{name;minFilter=Be.Nearest;magFilter=Be.Nearest;uWrap=Ie.ClampToEdge;vWrap=Ie.ClampToEdge;texture=null;width=0;height=0;pma=!1;regions=new Array;constructor(t){this.name=t}setTexture(t){this.texture=t,t.setFilters(this.minFilter,this.magFilter),t.setWraps(this.uWrap,this.vWrap);for(let e of this.regions)e.texture=t}}class qe extends Ve{page;name;x=0;y=0;offsetX=0;offsetY=0;originalWidth=0;originalHeight=0;index=0;degrees=0;names=null;values=null;constructor(t,e){super(),this.page=t,this.name=e,t.regions.push(this)}}class Ke extends Ee{region=null;path;regionUVs=[];uvs=[];triangles=[];color=new Te(1,1,1,1);width=0;height=0;hullLength=0;edges=[];parentMesh=null;sequence=null;tempColor=new Te(0,0,0,0);constructor(t,e){super(t),this.path=e}updateRegion(){if(!this.region)throw new Error("Region not set.");let t=this.regionUVs;this.uvs&&this.uvs.length==t.length||(this.uvs=Ae.newFloatArray(t.length));let e=this.uvs,r=this.uvs.length,s=this.region.u,i=this.region.v,n=0,o=0;if(this.region instanceof qe){let a=this.region,l=a.page,h=l.width,c=l.height;switch(a.degrees){case 90:s-=(a.originalHeight-a.offsetY-a.height)/h,i-=(a.originalWidth-a.offsetX-a.width)/c,n=a.originalHeight/h,o=a.originalWidth/c;for(let a=0;a<r;a+=2)e[a]=s+t[a+1]*n,e[a+1]=i+(1-t[a])*o;return;case 180:s-=(a.originalWidth-a.offsetX-a.width)/h,i-=a.offsetY/c,n=a.originalWidth/h,o=a.originalHeight/c;for(let a=0;a<r;a+=2)e[a]=s+(1-t[a])*n,e[a+1]=i+(1-t[a+1])*o;return;case 270:s-=a.offsetY/h,i-=a.offsetX/c,n=a.originalHeight/h,o=a.originalWidth/c;for(let a=0;a<r;a+=2)e[a]=s+(1-t[a+1])*n,e[a+1]=i+t[a]*o;return}s-=a.offsetX/h,i-=(a.originalHeight-a.offsetY-a.height)/c,n=a.originalWidth/h,o=a.originalHeight/c}else this.region?(n=this.region.u2-s,o=this.region.v2-i):(s=i=0,n=o=1);for(let a=0;a<r;a+=2)e[a]=s+t[a]*n,e[a+1]=i+t[a+1]*o}getParentMesh(){return this.parentMesh}setParentMesh(t){this.parentMesh=t,t&&(this.bones=t.bones,this.vertices=t.vertices,this.worldVerticesLength=t.worldVerticesLength,this.regionUVs=t.regionUVs,this.triangles=t.triangles,this.hullLength=t.hullLength,this.worldVerticesLength=t.worldVerticesLength)}copy(){if(this.parentMesh)return this.newLinkedMesh();let t=new Ke(this.name,this.path);return t.region=this.region,t.color.setFromColor(this.color),this.copyTo(t),t.regionUVs=new Array(this.regionUVs.length),Ae.arrayCopy(this.regionUVs,0,t.regionUVs,0,this.regionUVs.length),t.uvs=this.uvs instanceof Float32Array?Ae.newFloatArray(this.uvs.length):new Array(this.uvs.length),Ae.arrayCopy(this.uvs,0,t.uvs,0,this.uvs.length),t.triangles=new Array(this.triangles.length),Ae.arrayCopy(this.triangles,0,t.triangles,0,this.triangles.length),t.hullLength=this.hullLength,t.sequence=null!=this.sequence?this.sequence.copy():null,this.edges&&(t.edges=new Array(this.edges.length),Ae.arrayCopy(this.edges,0,t.edges,0,this.edges.length)),t.width=this.width,t.height=this.height,t}computeWorldVertices(t,e,r,s,i,n){null!=this.sequence&&this.sequence.apply(t,this),super.computeWorldVertices(t,e,r,s,i,n)}newLinkedMesh(){let t=new Ke(this.name,this.path);return t.region=this.region,t.color.setFromColor(this.color),t.timelineAttachment=this.timelineAttachment,t.setParentMesh(this.parentMesh?this.parentMesh:this),null!=t.region&&t.updateRegion(),t}}class Ze extends Ee{lengths=[];closed=!1;constantSpeed=!1;color=new Te(1,1,1,1);constructor(t){super(t)}copy(){let t=new Ze(this.name);return this.copyTo(t),t.lengths=new Array(this.lengths.length),Ae.arrayCopy(this.lengths,0,t.lengths,0,this.lengths.length),t.closed=closed,t.constantSpeed=this.constantSpeed,t.color.setFromColor(this.color),t}}class Qe extends Me{x=0;y=0;scaleX=1;scaleY=1;rotation=0;width=0;height=0;color=new Te(1,1,1,1);path;region=null;sequence=null;offset=Ae.newFloatArray(8);uvs=Ae.newFloatArray(8);tempColor=new Te(1,1,1,1);constructor(t,e){super(t),this.path=e}updateRegion(){if(!this.region)throw new Error("Region not set.");let t=this.region,e=this.uvs;if(null==t)return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e[4]=1,e[5]=1,e[6]=1,void(e[7]=0);let r=this.width/this.region.originalWidth*this.scaleX,s=this.height/this.region.originalHeight*this.scaleY,i=-this.width/2*this.scaleX+this.region.offsetX*r,n=-this.height/2*this.scaleY+this.region.offsetY*s,o=i+this.region.width*r,a=n+this.region.height*s,l=this.rotation*Se.degRad,h=Math.cos(l),c=Math.sin(l),u=this.x,d=this.y,p=i*h+u,f=i*c,g=n*h+d,m=n*c,x=o*h+u,_=o*c,y=a*h+d,v=a*c,b=this.offset;b[0]=p-m,b[1]=g+f,b[2]=p-v,b[3]=y+f,b[4]=x-v,b[5]=y+_,b[6]=x-m,b[7]=g+_,90==t.degrees?(e[0]=t.u2,e[1]=t.v2,e[2]=t.u,e[3]=t.v2,e[4]=t.u,e[5]=t.v,e[6]=t.u2,e[7]=t.v):(e[0]=t.u,e[1]=t.v2,e[2]=t.u,e[3]=t.v,e[4]=t.u2,e[5]=t.v,e[6]=t.u2,e[7]=t.v2)}computeWorldVertices(t,e,r,s){null!=this.sequence&&this.sequence.apply(t,this);let i=t.bone,n=this.offset,o=i.worldX,a=i.worldY,l=i.a,h=i.b,c=i.c,u=i.d,d=0,p=0;d=n[0],p=n[1],e[r]=d*l+p*h+o,e[r+1]=d*c+p*u+a,r+=s,d=n[2],p=n[3],e[r]=d*l+p*h+o,e[r+1]=d*c+p*u+a,r+=s,d=n[4],p=n[5],e[r]=d*l+p*h+o,e[r+1]=d*c+p*u+a,r+=s,d=n[6],p=n[7],e[r]=d*l+p*h+o,e[r+1]=d*c+p*u+a}copy(){let t=new Qe(this.name,this.path);return t.region=this.region,t.x=this.x,t.y=this.y,t.scaleX=this.scaleX,t.scaleY=this.scaleY,t.rotation=this.rotation,t.width=this.width,t.height=this.height,Ae.arrayCopy(this.uvs,0,t.uvs,0,8),Ae.arrayCopy(this.offset,0,t.offset,0,8),t.color.setFromColor(this.color),t.sequence=null!=this.sequence?this.sequence.copy():null,t}static X1=0;static Y1=1;static C1R=2;static C1G=3;static C1B=4;static C1A=5;static U1=6;static V1=7;static X2=8;static Y2=9;static C2R=10;static C2G=11;static C2B=12;static C2A=13;static U2=14;static V2=15;static X3=16;static Y3=17;static C3R=18;static C3G=19;static C3B=20;static C3A=21;static U3=22;static V3=23;static X4=24;static Y4=25;static C4R=26;static C4G=27;static C4B=28;static C4A=29;static U4=30;static V4=31}!function(t){t[t.Normal=0]="Normal",t[t.OnlyTranslation=1]="OnlyTranslation",t[t.NoRotationOrReflection=2]="NoRotationOrReflection",t[t.NoScale=3]="NoScale",t[t.NoScaleOrReflection=4]="NoScaleOrReflection"}(Ge||(Ge={}));class Je{data;skeleton;parent=null;children=new Array;x=0;y=0;rotation=0;scaleX=0;scaleY=0;shearX=0;shearY=0;ax=0;ay=0;arotation=0;ascaleX=0;ascaleY=0;ashearX=0;ashearY=0;a=0;b=0;c=0;d=0;worldY=0;worldX=0;inherit=Ge.Normal;sorted=!1;active=!1;constructor(t,e,r){if(!t)throw new Error("data cannot be null.");if(!e)throw new Error("skeleton cannot be null.");this.data=t,this.skeleton=e,this.parent=r,this.setToSetupPose()}isActive(){return this.active}update(t){this.updateWorldTransformWith(this.ax,this.ay,this.arotation,this.ascaleX,this.ascaleY,this.ashearX,this.ashearY)}updateWorldTransform(){this.updateWorldTransformWith(this.x,this.y,this.rotation,this.scaleX,this.scaleY,this.shearX,this.shearY)}updateWorldTransformWith(t,e,r,s,i,n,o){this.ax=t,this.ay=e,this.arotation=r,this.ascaleX=s,this.ascaleY=i,this.ashearX=n,this.ashearY=o;let a=this.parent;if(!a){let a=this.skeleton;const l=a.scaleX,h=a.scaleY,c=(r+n)*Se.degRad,u=(r+90+o)*Se.degRad;return this.a=Math.cos(c)*s*l,this.b=Math.cos(u)*i*l,this.c=Math.sin(c)*s*h,this.d=Math.sin(u)*i*h,this.worldX=t*l+a.x,void(this.worldY=e*h+a.y)}let l=a.a,h=a.b,c=a.c,u=a.d;switch(this.worldX=l*t+h*e+a.worldX,this.worldY=c*t+u*e+a.worldY,this.inherit){case Ge.Normal:{const t=(r+n)*Se.degRad,e=(r+90+o)*Se.degRad,a=Math.cos(t)*s,d=Math.cos(e)*i,p=Math.sin(t)*s,f=Math.sin(e)*i;return this.a=l*a+h*p,this.b=l*d+h*f,this.c=c*a+u*p,void(this.d=c*d+u*f)}case Ge.OnlyTranslation:{const t=(r+n)*Se.degRad,e=(r+90+o)*Se.degRad;this.a=Math.cos(t)*s,this.b=Math.cos(e)*i,this.c=Math.sin(t)*s,this.d=Math.sin(e)*i;break}case Ge.NoRotationOrReflection:{let t=1/this.skeleton.scaleX,e=1/this.skeleton.scaleY;l*=t,c*=e;let a=l*l+c*c,d=0;a>1e-4?(a=Math.abs(l*u*e-h*t*c)/a,h=c*a,u=l*a,d=Math.atan2(c,l)*Se.radDeg):(l=0,c=0,d=90-Math.atan2(u,h)*Se.radDeg);const p=(r+n-d)*Se.degRad,f=(r+o-d+90)*Se.degRad,g=Math.cos(p)*s,m=Math.cos(f)*i,x=Math.sin(p)*s,_=Math.sin(f)*i;this.a=l*g-h*x,this.b=l*m-h*_,this.c=c*g+u*x,this.d=c*m+u*_;break}case Ge.NoScale:case Ge.NoScaleOrReflection:{r*=Se.degRad;const t=Math.cos(r),e=Math.sin(r);let a=(l*t+h*e)/this.skeleton.scaleX,d=(c*t+u*e)/this.skeleton.scaleY,p=Math.sqrt(a*a+d*d);p>1e-5&&(p=1/p),a*=p,d*=p,p=Math.sqrt(a*a+d*d),this.inherit==Ge.NoScale&&l*u-h*c<0!=(this.skeleton.scaleX<0!=this.skeleton.scaleY<0)&&(p=-p),r=Math.PI/2+Math.atan2(d,a);const f=Math.cos(r)*p,g=Math.sin(r)*p;n*=Se.degRad,o=(90+o)*Se.degRad;const m=Math.cos(n)*s,x=Math.cos(o)*i,_=Math.sin(n)*s,y=Math.sin(o)*i;this.a=a*m+f*_,this.b=a*x+f*y,this.c=d*m+g*_,this.d=d*x+g*y;break}}this.a*=this.skeleton.scaleX,this.b*=this.skeleton.scaleX,this.c*=this.skeleton.scaleY,this.d*=this.skeleton.scaleY}setToSetupPose(){let t=this.data;this.x=t.x,this.y=t.y,this.rotation=t.rotation,this.scaleX=t.scaleX,this.scaleY=t.scaleY,this.shearX=t.shearX,this.shearY=t.shearY,this.inherit=t.inherit}updateAppliedTransform(){let t=this.parent;if(!t)return this.ax=this.worldX-this.skeleton.x,this.ay=this.worldY-this.skeleton.y,this.arotation=Math.atan2(this.c,this.a)*Se.radDeg,this.ascaleX=Math.sqrt(this.a*this.a+this.c*this.c),this.ascaleY=Math.sqrt(this.b*this.b+this.d*this.d),this.ashearX=0,void(this.ashearY=Math.atan2(this.a*this.b+this.c*this.d,this.a*this.d-this.b*this.c)*Se.radDeg);let e,r,s,i,n=t.a,o=t.b,a=t.c,l=t.d,h=1/(n*l-o*a),c=l*h,u=o*h,d=a*h,p=n*h,f=this.worldX-t.worldX,g=this.worldY-t.worldY;if(this.ax=f*c-g*u,this.ay=g*p-f*d,this.inherit==Ge.OnlyTranslation)e=this.a,r=this.b,s=this.c,i=this.d;else{switch(this.inherit){case Ge.NoRotationOrReflection:{let t=Math.abs(n*l-o*a)/(n*n+a*a);o=-a*this.skeleton.scaleX*t/this.skeleton.scaleY,l=n*this.skeleton.scaleY*t/this.skeleton.scaleX,h=1/(n*l-o*a),c=l*h,u=o*h;break}case Ge.NoScale:case Ge.NoScaleOrReflection:let t=Se.cosDeg(this.rotation),e=Se.sinDeg(this.rotation);n=(n*t+o*e)/this.skeleton.scaleX,a=(a*t+l*e)/this.skeleton.scaleY;let r=Math.sqrt(n*n+a*a);r>1e-5&&(r=1/r),n*=r,a*=r,r=Math.sqrt(n*n+a*a),this.inherit==Ge.NoScale&&h<0!=(this.skeleton.scaleX<0!=this.skeleton.scaleY<0)&&(r=-r);let s=Se.PI/2+Math.atan2(a,n);o=Math.cos(s)*r,l=Math.sin(s)*r,h=1/(n*l-o*a),c=l*h,u=o*h,d=a*h,p=n*h}e=c*this.a-u*this.c,r=c*this.b-u*this.d,s=p*this.c-d*this.a,i=p*this.d-d*this.b}if(this.ashearX=0,this.ascaleX=Math.sqrt(e*e+s*s),this.ascaleX>1e-4){let t=e*i-r*s;this.ascaleY=t/this.ascaleX,this.ashearY=-Math.atan2(e*r+s*i,t)*Se.radDeg,this.arotation=Math.atan2(s,e)*Se.radDeg}else this.ascaleX=0,this.ascaleY=Math.sqrt(r*r+i*i),this.ashearY=0,this.arotation=90-Math.atan2(i,r)*Se.radDeg}getWorldRotationX(){return Math.atan2(this.c,this.a)*Se.radDeg}getWorldRotationY(){return Math.atan2(this.d,this.b)*Se.radDeg}getWorldScaleX(){return Math.sqrt(this.a*this.a+this.c*this.c)}getWorldScaleY(){return Math.sqrt(this.b*this.b+this.d*this.d)}worldToLocal(t){let e=1/(this.a*this.d-this.b*this.c),r=t.x-this.worldX,s=t.y-this.worldY;return t.x=r*this.d*e-s*this.b*e,t.y=s*this.a*e-r*this.c*e,t}localToWorld(t){let e=t.x,r=t.y;return t.x=e*this.a+r*this.b+this.worldX,t.y=e*this.c+r*this.d+this.worldY,t}worldToParent(t){if(null==t)throw new Error("world cannot be null.");return null==this.parent?t:this.parent.worldToLocal(t)}parentToWorld(t){if(null==t)throw new Error("world cannot be null.");return null==this.parent?t:this.parent.localToWorld(t)}worldToLocalRotation(t){let e=Se.sinDeg(t),r=Se.cosDeg(t);return Math.atan2(this.a*e-this.c*r,this.d*r-this.b*e)*Se.radDeg+this.rotation-this.shearX}localToWorldRotation(t){t-=this.rotation-this.shearX;let e=Se.sinDeg(t),r=Se.cosDeg(t);return Math.atan2(r*this.c+e*this.d,r*this.a+e*this.b)*Se.radDeg}rotateWorld(t){t*=Se.degRad;const e=Math.sin(t),r=Math.cos(t),s=this.a,i=this.b;this.a=r*s-e*this.c,this.b=r*i-e*this.d,this.c=e*s+r*this.c,this.d=e*i+r*this.d}}new Map;class tr{data;bones;target;bendDirection=0;compress=!1;stretch=!1;mix=1;softness=0;active=!1;constructor(t,e){if(!t)throw new Error("data cannot be null.");if(!e)throw new Error("skeleton cannot be null.");this.data=t,this.bones=new Array;for(let r=0;r<t.bones.length;r++){let s=e.findBone(t.bones[r].name);if(!s)throw new Error(`Couldn't find bone ${t.bones[r].name}`);this.bones.push(s)}let r=e.findBone(t.target.name);if(!r)throw new Error(`Couldn't find bone ${t.target.name}`);this.target=r,this.mix=t.mix,this.softness=t.softness,this.bendDirection=t.bendDirection,this.compress=t.compress,this.stretch=t.stretch}isActive(){return this.active}setToSetupPose(){const t=this.data;this.mix=t.mix,this.softness=t.softness,this.bendDirection=t.bendDirection,this.compress=t.compress,this.stretch=t.stretch}update(t){if(0==this.mix)return;let e=this.target,r=this.bones;switch(r.length){case 1:this.apply1(r[0],e.worldX,e.worldY,this.compress,this.stretch,this.data.uniform,this.mix);break;case 2:this.apply2(r[0],r[1],e.worldX,e.worldY,this.bendDirection,this.stretch,this.data.uniform,this.softness,this.mix)}}apply1(t,e,r,s,i,n,o){let a=t.parent;if(!a)throw new Error("IK bone must have parent.");let l=a.a,h=a.b,c=a.c,u=a.d,d=-t.ashearX-t.arotation,p=0,f=0;switch(t.inherit){case Ge.OnlyTranslation:p=(e-t.worldX)*Se.signum(t.skeleton.scaleX),f=(r-t.worldY)*Se.signum(t.skeleton.scaleY);break;case Ge.NoRotationOrReflection:let s=Math.abs(l*u-h*c)/Math.max(1e-4,l*l+c*c),i=l/t.skeleton.scaleX,n=c/t.skeleton.scaleY;h=-n*s*t.skeleton.scaleX,u=i*s*t.skeleton.scaleY,d+=Math.atan2(n,i)*Se.radDeg;default:let o=e-a.worldX,g=r-a.worldY,m=l*u-h*c;Math.abs(m)<=1e-4?(p=0,f=0):(p=(o*u-g*h)/m-t.ax,f=(g*l-o*c)/m-t.ay)}d+=Math.atan2(f,p)*Se.radDeg,t.ascaleX<0&&(d+=180),d>180?d-=360:d<-180&&(d+=360);let g=t.ascaleX,m=t.ascaleY;if(s||i){switch(t.inherit){case Ge.NoScale:case Ge.NoScaleOrReflection:p=e-t.worldX,f=r-t.worldY}const a=t.data.length*g;if(a>1e-4){const t=p*p+f*f;if(s&&t<a*a||i&&t>a*a){const e=(Math.sqrt(t)/a-1)*o+1;g*=e,n&&(m*=e)}}}t.updateWorldTransformWith(t.ax,t.ay,t.arotation+d*o,g,m,t.ashearX,t.ashearY)}apply2(t,e,r,s,i,n,o,a,l){if(t.inherit!=Ge.Normal||e.inherit!=Ge.Normal)return;let h=t.ax,c=t.ay,u=t.ascaleX,d=t.ascaleY,p=u,f=d,g=e.ascaleX,m=0,x=0,_=0;u<0?(u=-u,m=180,_=-1):(m=0,_=1),d<0&&(d=-d,_=-_),g<0?(g=-g,x=180):x=0;let y=e.ax,v=0,b=0,w=0,T=t.a,S=t.b,A=t.c,C=t.d,P=Math.abs(u-d)<=1e-4;!P||n?(v=0,b=T*y+t.worldX,w=A*y+t.worldY):(v=e.ay,b=T*y+S*v+t.worldX,w=A*y+C*v+t.worldY);let M=t.parent;if(!M)throw new Error("IK parent must itself have a parent.");T=M.a,S=M.b,A=M.c,C=M.d;let E=T*C-S*A,R=b-M.worldX,k=w-M.worldY;E=Math.abs(E)<=1e-4?0:1/E;let B,I,G=(R*C-k*S)*E-h,F=(k*T-R*A)*E-c,O=Math.sqrt(G*G+F*F),D=e.data.length*g;if(O<1e-4)return this.apply1(t,r,s,!1,n,!1,l),void e.updateWorldTransformWith(y,v,0,e.ascaleX,e.ascaleY,e.ashearX,e.ashearY);R=r-M.worldX,k=s-M.worldY;let U=(R*C-k*S)*E-h,L=(k*T-R*A)*E-c,N=U*U+L*L;if(0!=a){a*=u*(g+1)*.5;let t=Math.sqrt(N),e=t-O-D*u+a;if(e>0){let r=Math.min(1,e/(2*a))-1;r=(e-a*(1-r*r))/t,U-=r*U,L-=r*L,N=U*U+L*L}}t:if(P){D*=u;let t=(N-O*O-D*D)/(2*O*D);t<-1?(t=-1,I=Math.PI*i):t>1?(t=1,I=0,n&&(T=(Math.sqrt(N)/(O+D)-1)*l+1,p*=T,o&&(f*=T))):I=Math.acos(t)*i,T=O+D*t,S=D*Math.sin(I),B=Math.atan2(L*T-U*S,U*T+L*S)}else{T=u*D,S=d*D;let t=T*T,e=S*S,r=Math.atan2(L,U);A=e*O*O+t*N-t*e;let s=-2*e*O,n=e-t;if(C=s*s-4*n*A,C>=0){let t=Math.sqrt(C);s<0&&(t=-t),t=.5*-(s+t);let e=t/n,o=A/t,a=Math.abs(e)<Math.abs(o)?e:o;if(e=N-a*a,e>=0){k=Math.sqrt(e)*i,B=r-Math.atan2(k,a),I=Math.atan2(k/d,(a-O)/u);break t}}let o=Se.PI,a=O-T,l=a*a,h=0,c=0,p=O+T,f=p*p,g=0;A=-T*O/(t-e),A>=-1&&A<=1&&(A=Math.acos(A),R=T*Math.cos(A)+O,k=S*Math.sin(A),C=R*R+k*k,C<l&&(o=A,l=C,a=R,h=k),C>f&&(c=A,f=C,p=R,g=k)),N<=.5*(l+f)?(B=r-Math.atan2(h*i,a),I=o*i):(B=r-Math.atan2(g*i,p),I=c*i)}let z=Math.atan2(v,y)*_,W=t.arotation;B=(B-z)*Se.radDeg+m-W,B>180?B-=360:B<-180&&(B+=360),t.updateWorldTransformWith(h,c,W+B*l,p,f,0,0),W=e.arotation,I=((I+z)*Se.radDeg-e.ashearX)*_+x-W,I>180?I-=360:I<-180&&(I+=360),e.updateWorldTransformWith(y,v,W+I*l,e.ascaleX,e.ascaleY,e.ashearX,e.ashearY)}}!function(t){t[t.Fixed=0]="Fixed",t[t.Percent=1]="Percent"}(Fe||(Fe={})),function(t){t[t.Length=0]="Length",t[t.Fixed=1]="Fixed",t[t.Percent=2]="Percent",t[t.Proportional=3]="Proportional"}(Oe||(Oe={})),function(t){t[t.Tangent=0]="Tangent",t[t.Chain=1]="Chain",t[t.ChainScale=2]="ChainScale"}(De||(De={}));class er{static NONE=-1;static BEFORE=-2;static AFTER=-3;static epsilon=1e-5;data;bones;target;position=0;spacing=0;mixRotate=0;mixX=0;mixY=0;spaces=new Array;positions=new Array;world=new Array;curves=new Array;lengths=new Array;segments=new Array;active=!1;constructor(t,e){if(!t)throw new Error("data cannot be null.");if(!e)throw new Error("skeleton cannot be null.");this.data=t,this.bones=new Array;for(let r=0,s=t.bones.length;r<s;r++){let s=e.findBone(t.bones[r].name);if(!s)throw new Error(`Couldn't find bone ${t.bones[r].name}.`);this.bones.push(s)}let r=e.findSlot(t.target.name);if(!r)throw new Error(`Couldn't find target bone ${t.target.name}`);this.target=r,this.position=t.position,this.spacing=t.spacing,this.mixRotate=t.mixRotate,this.mixX=t.mixX,this.mixY=t.mixY}isActive(){return this.active}setToSetupPose(){const t=this.data;this.position=t.position,this.spacing=t.spacing,this.mixRotate=t.mixRotate,this.mixX=t.mixX,this.mixY=t.mixY}update(t){let e=this.target.getAttachment();if(!(e instanceof Ze))return;let r=this.mixRotate,s=this.mixX,i=this.mixY;if(0==r&&0==s&&0==i)return;let n=this.data,o=n.rotateMode==De.Tangent,a=n.rotateMode==De.ChainScale,l=this.bones,h=l.length,c=o?h:h+1,u=Ae.setArraySize(this.spaces,c),d=a?this.lengths=Ae.setArraySize(this.lengths,h):[],p=this.spacing;switch(n.spacingMode){case Oe.Percent:if(a)for(let t=0,e=c-1;t<e;t++){let e=l[t],r=e.data.length,s=r*e.a,i=r*e.c;d[t]=Math.sqrt(s*s+i*i)}Ae.arrayFill(u,1,c,p);break;case Oe.Proportional:let t=0;for(let e=0,r=c-1;e<r;){let r=l[e],s=r.data.length;if(s<er.epsilon)a&&(d[e]=0),u[++e]=p;else{let i=s*r.a,n=s*r.c,o=Math.sqrt(i*i+n*n);a&&(d[e]=o),u[++e]=o,t+=o}}if(t>0){t=c/t*p;for(let e=1;e<c;e++)u[e]*=t}break;default:let e=n.spacingMode==Oe.Length;for(let t=0,r=c-1;t<r;){let r=l[t],s=r.data.length;if(s<er.epsilon)a&&(d[t]=0),u[++t]=p;else{let i=s*r.a,n=s*r.c,o=Math.sqrt(i*i+n*n);a&&(d[t]=o),u[++t]=(e?s+p:p)*o/s}}}let f=this.computeWorldPositions(e,c,o),g=f[0],m=f[1],x=n.offsetRotation,_=!1;if(0==x)_=n.rotateMode==De.Chain;else{_=!1;let t=this.target.bone;x*=t.a*t.d-t.b*t.c>0?Se.degRad:-Se.degRad}for(let t=0,e=3;t<h;t++,e+=3){let n=l[t];n.worldX+=(g-n.worldX)*s,n.worldY+=(m-n.worldY)*i;let h=f[e],c=f[e+1],p=h-g,y=c-m;if(a){let e=d[t];if(0!=e){let t=(Math.sqrt(p*p+y*y)/e-1)*r+1;n.a*=t,n.c*=t}}if(g=h,m=c,r>0){let s=n.a,i=n.b,a=n.c,l=n.d,h=0,c=0,d=0;if(h=o?f[e-1]:0==u[t+1]?f[e+2]:Math.atan2(y,p),h-=Math.atan2(a,s),_){c=Math.cos(h),d=Math.sin(h);let t=n.data.length;g+=(t*(c*s-d*a)-p)*r,m+=(t*(d*s+c*a)-y)*r}else h+=x;h>Se.PI?h-=Se.PI2:h<-Se.PI&&(h+=Se.PI2),h*=r,c=Math.cos(h),d=Math.sin(h),n.a=c*s-d*a,n.b=c*i-d*l,n.c=d*s+c*a,n.d=d*i+c*l}n.updateAppliedTransform()}}computeWorldPositions(t,e,r){let s=this.target,i=this.position,n=this.spaces,o=Ae.setArraySize(this.positions,3*e+2),a=this.world,l=t.closed,h=t.worldVerticesLength,c=h/6,u=er.NONE;if(!t.constantSpeed){let d=t.lengths;c-=l?1:2;let p,f=d[c];switch(this.data.positionMode==Fe.Percent&&(i*=f),this.data.spacingMode){case Oe.Percent:p=f;break;case Oe.Proportional:p=f/e;break;default:p=1}a=Ae.setArraySize(this.world,8);for(let g=0,m=0,x=0;g<e;g++,m+=3){let e=n[g]*p;i+=e;let _=i;if(l)_%=f,_<0&&(_+=f),x=0;else{if(_<0){u!=er.BEFORE&&(u=er.BEFORE,t.computeWorldVertices(s,2,4,a,0,2)),this.addBeforePosition(_,a,0,o,m);continue}if(_>f){u!=er.AFTER&&(u=er.AFTER,t.computeWorldVertices(s,h-6,4,a,0,2)),this.addAfterPosition(_-f,a,0,o,m);continue}}for(;;x++){let t=d[x];if(!(_>t)){if(0==x)_/=t;else{let e=d[x-1];_=(_-e)/(t-e)}break}}x!=u&&(u=x,l&&x==c?(t.computeWorldVertices(s,h-4,4,a,0,2),t.computeWorldVertices(s,0,4,a,4,2)):t.computeWorldVertices(s,6*x+2,8,a,0,2)),this.addCurvePosition(_,a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],o,m,r||g>0&&0==e)}return o}l?(h+=2,a=Ae.setArraySize(this.world,h),t.computeWorldVertices(s,2,h-4,a,0,2),t.computeWorldVertices(s,0,2,a,h-4,2),a[h-2]=a[0],a[h-1]=a[1]):(c--,h-=4,a=Ae.setArraySize(this.world,h),t.computeWorldVertices(s,2,h,a,0,2));let d,p=Ae.setArraySize(this.curves,c),f=0,g=a[0],m=a[1],x=0,_=0,y=0,v=0,b=0,w=0,T=0,S=0,A=0,C=0,P=0,M=0,E=0,R=0;for(let t=0,e=2;t<c;t++,e+=6)x=a[e],_=a[e+1],y=a[e+2],v=a[e+3],b=a[e+4],w=a[e+5],T=.1875*(g-2*x+y),S=.1875*(m-2*_+v),A=.09375*(3*(x-y)-g+b),C=.09375*(3*(_-v)-m+w),P=2*T+A,M=2*S+C,E=.75*(x-g)+T+.16666667*A,R=.75*(_-m)+S+.16666667*C,f+=Math.sqrt(E*E+R*R),E+=P,R+=M,P+=A,M+=C,f+=Math.sqrt(E*E+R*R),E+=P,R+=M,f+=Math.sqrt(E*E+R*R),E+=P+A,R+=M+C,f+=Math.sqrt(E*E+R*R),p[t]=f,g=b,m=w;switch(this.data.positionMode==Fe.Percent&&(i*=f),this.data.spacingMode){case Oe.Percent:d=f;break;case Oe.Proportional:d=f/e;break;default:d=1}let k=this.segments,B=0;for(let t=0,s=0,c=0,I=0;t<e;t++,s+=3){let e=n[t]*d;i+=e;let G=i;if(l)G%=f,G<0&&(G+=f),c=0;else{if(G<0){this.addBeforePosition(G,a,0,o,s);continue}if(G>f){this.addAfterPosition(G-f,a,h-4,o,s);continue}}for(;;c++){let t=p[c];if(!(G>t)){if(0==c)G/=t;else{let e=p[c-1];G=(G-e)/(t-e)}break}}if(c!=u){u=c;let t=6*c;for(g=a[t],m=a[t+1],x=a[t+2],_=a[t+3],y=a[t+4],v=a[t+5],b=a[t+6],w=a[t+7],T=.03*(g-2*x+y),S=.03*(m-2*_+v),A=.006*(3*(x-y)-g+b),C=.006*(3*(_-v)-m+w),P=2*T+A,M=2*S+C,E=.3*(x-g)+T+.16666667*A,R=.3*(_-m)+S+.16666667*C,B=Math.sqrt(E*E+R*R),k[0]=B,t=1;t<8;t++)E+=P,R+=M,P+=A,M+=C,B+=Math.sqrt(E*E+R*R),k[t]=B;E+=P,R+=M,B+=Math.sqrt(E*E+R*R),k[8]=B,E+=P+A,R+=M+C,B+=Math.sqrt(E*E+R*R),k[9]=B,I=0}for(G*=B;;I++){let t=k[I];if(!(G>t)){if(0==I)G/=t;else{let e=k[I-1];G=I+(G-e)/(t-e)}break}}this.addCurvePosition(.1*G,g,m,x,_,y,v,b,w,o,s,r||t>0&&0==e)}return o}addBeforePosition(t,e,r,s,i){let n=e[r],o=e[r+1],a=e[r+2]-n,l=e[r+3]-o,h=Math.atan2(l,a);s[i]=n+t*Math.cos(h),s[i+1]=o+t*Math.sin(h),s[i+2]=h}addAfterPosition(t,e,r,s,i){let n=e[r+2],o=e[r+3],a=n-e[r],l=o-e[r+1],h=Math.atan2(l,a);s[i]=n+t*Math.cos(h),s[i+1]=o+t*Math.sin(h),s[i+2]=h}addCurvePosition(t,e,r,s,i,n,o,a,l,h,c,u){if(0==t||isNaN(t))return h[c]=e,h[c+1]=r,void(h[c+2]=Math.atan2(i-r,s-e));let d=t*t,p=d*t,f=1-t,g=f*f,m=g*f,x=f*t,_=3*x,y=f*_,v=_*t,b=e*m+s*y+n*v+a*p,w=r*m+i*y+o*v+l*p;h[c]=b,h[c+1]=w,u&&(h[c+2]=t<.001?Math.atan2(i-r,s-e):Math.atan2(w-(r*g+i*x*2+o*d),b-(e*g+s*x*2+n*d)))}}class rr{data;_bone=null;set bone(t){this._bone=t}get bone(){if(this._bone)return this._bone;throw new Error("Bone not set.")}inertia=0;strength=0;damping=0;massInverse=0;wind=0;gravity=0;mix=0;_reset=!0;ux=0;uy=0;cx=0;cy=0;tx=0;ty=0;xOffset=0;xVelocity=0;yOffset=0;yVelocity=0;rotateOffset=0;rotateVelocity=0;scaleOffset=0;scaleVelocity=0;active=!1;skeleton;remaining=0;lastTime=0;constructor(t,e){this.data=t,this.skeleton=e,this.bone=e.bones[t.bone.index],this.inertia=t.inertia,this.strength=t.strength,this.damping=t.damping,this.massInverse=t.massInverse,this.wind=t.wind,this.gravity=t.gravity,this.mix=t.mix}reset(){this.remaining=0,this.lastTime=this.skeleton.time,this._reset=!0,this.xOffset=0,this.xVelocity=0,this.yOffset=0,this.yVelocity=0,this.rotateOffset=0,this.rotateVelocity=0,this.scaleOffset=0,this.scaleVelocity=0}setToSetupPose(){const t=this.data;this.inertia=t.inertia,this.strength=t.strength,this.damping=t.damping,this.massInverse=t.massInverse,this.wind=t.wind,this.gravity=t.gravity,this.mix=t.mix}isActive(){return this.active}update(t){const e=this.mix;if(0==e)return;const r=this.data.x>0,s=this.data.y>0,i=this.data.rotate>0||this.data.shearX>0,n=this.data.scaleX>0,o=this.bone,a=o.data.length;switch(t){case Ue.none:return;case Ue.reset:this.reset();case Ue.update:const t=this.skeleton,l=Math.max(this.skeleton.time-this.lastTime,0);this.remaining+=l,this.lastTime=t.time;const h=o.worldX,c=o.worldY;if(this._reset)this._reset=!1,this.ux=h,this.uy=c;else{let u=this.remaining,d=this.inertia,p=this.data.step,f=this.skeleton.data.referenceScale,g=-1,m=this.data.limit*l,x=m*Math.abs(t.scaleY);if(m*=Math.abs(t.scaleX),r||s){if(r){const t=(this.ux-h)*d;this.xOffset+=t>m?m:t<-m?-m:t,this.ux=h}if(s){const t=(this.uy-c)*d;this.yOffset+=t>x?x:t<-x?-x:t,this.uy=c}if(u>=p){g=Math.pow(this.damping,60*p);const e=this.massInverse*p,i=this.strength,n=this.wind*f*t.scaleX,o=this.gravity*f*t.scaleY;do{r&&(this.xVelocity+=(n-this.xOffset*i)*e,this.xOffset+=this.xVelocity*p,this.xVelocity*=g),s&&(this.yVelocity-=(o+this.yOffset*i)*e,this.yOffset+=this.yVelocity*p,this.yVelocity*=g),u-=p}while(u>=p)}r&&(o.worldX+=this.xOffset*e*this.data.x),s&&(o.worldY+=this.yOffset*e*this.data.y)}if(i||n){let t=Math.atan2(o.c,o.a),r=0,s=0,l=0,h=this.cx-o.worldX,c=this.cy-o.worldY;if(h>m?h=m:h<-m&&(h=-m),c>x?c=x:c<-x&&(c=-x),i){l=(this.data.rotate+this.data.shearX)*e;let i=Math.atan2(c+this.ty,h+this.tx)-t-this.rotateOffset*l;this.rotateOffset+=(i-Math.ceil(i*Se.invPI2-.5)*Se.PI2)*d,i=this.rotateOffset*l+t,r=Math.cos(i),s=Math.sin(i),n&&(i=a*o.getWorldScaleX(),i>0&&(this.scaleOffset+=(h*r+c*s)*d/i))}else{r=Math.cos(t),s=Math.sin(t);const e=a*o.getWorldScaleX();e>0&&(this.scaleOffset+=(h*r+c*s)*d/e)}if(u=this.remaining,u>=p){-1==g&&(g=Math.pow(this.damping,60*p));const e=this.massInverse*p,o=this.strength,h=this.wind,c=nr.yDown?-this.gravity:this.gravity,d=a/f;for(;;)if(u-=p,n&&(this.scaleVelocity+=(h*r-c*s-this.scaleOffset*o)*e,this.scaleOffset+=this.scaleVelocity*p,this.scaleVelocity*=g),i){if(this.rotateVelocity-=((h*s+c*r)*d+this.rotateOffset*o)*e,this.rotateOffset+=this.rotateVelocity*p,this.rotateVelocity*=g,u<p)break;const i=this.rotateOffset*l+t;r=Math.cos(i),s=Math.sin(i)}else if(u<p)break}}this.remaining=u}this.cx=o.worldX,this.cy=o.worldY;break;case Ue.pose:r&&(o.worldX+=this.xOffset*e*this.data.x),s&&(o.worldY+=this.yOffset*e*this.data.y)}if(i){let t=this.rotateOffset*e,r=0,s=0,i=0;if(this.data.shearX>0){let e=0;this.data.rotate>0&&(e=t*this.data.rotate,r=Math.sin(e),s=Math.cos(e),i=o.b,o.b=s*i-r*o.d,o.d=r*i+s*o.d),e+=t*this.data.shearX,r=Math.sin(e),s=Math.cos(e),i=o.a,o.a=s*i-r*o.c,o.c=r*i+s*o.c}else t*=this.data.rotate,r=Math.sin(t),s=Math.cos(t),i=o.a,o.a=s*i-r*o.c,o.c=r*i+s*o.c,i=o.b,o.b=s*i-r*o.d,o.d=r*i+s*o.d}if(n){const t=1+this.scaleOffset*e*this.data.scaleX;o.a*=t,o.c*=t}t!=Ue.pose&&(this.tx=a*o.a,this.ty=a*o.c),o.updateAppliedTransform()}translate(t,e){this.ux-=t,this.uy-=e,this.cx-=t,this.cy-=e}rotate(t,e,r){const s=r*Se.degRad,i=Math.cos(s),n=Math.sin(s),o=this.cx-t,a=this.cy-e;this.translate(o*i-a*n-o,o*n+a*i-a)}}class sr{data;bone;color;darkColor=null;attachment=null;attachmentState=0;sequenceIndex=-1;deform=new Array;constructor(t,e){if(!t)throw new Error("data cannot be null.");if(!e)throw new Error("bone cannot be null.");this.data=t,this.bone=e,this.color=new Te,this.darkColor=t.darkColor?new Te:null,this.setToSetupPose()}getSkeleton(){return this.bone.skeleton}getAttachment(){return this.attachment}setAttachment(t){this.attachment!=t&&(t instanceof Ee&&this.attachment instanceof Ee&&t.timelineAttachment==this.attachment.timelineAttachment||(this.deform.length=0),this.attachment=t,this.sequenceIndex=-1)}setToSetupPose(){this.color.setFromColor(this.data.color),this.darkColor&&this.darkColor.setFromColor(this.data.darkColor),this.data.attachmentName?(this.attachment=null,this.setAttachment(this.bone.skeleton.getAttachment(this.data.index,this.data.attachmentName))):this.attachment=null}}class ir{data;bones;target;mixRotate=0;mixX=0;mixY=0;mixScaleX=0;mixScaleY=0;mixShearY=0;temp=new Pe;active=!1;constructor(t,e){if(!t)throw new Error("data cannot be null.");if(!e)throw new Error("skeleton cannot be null.");this.data=t,this.bones=new Array;for(let r=0;r<t.bones.length;r++){let s=e.findBone(t.bones[r].name);if(!s)throw new Error(`Couldn't find bone ${t.bones[r].name}.`);this.bones.push(s)}let r=e.findBone(t.target.name);if(!r)throw new Error(`Couldn't find target bone ${t.target.name}.`);this.target=r,this.mixRotate=t.mixRotate,this.mixX=t.mixX,this.mixY=t.mixY,this.mixScaleX=t.mixScaleX,this.mixScaleY=t.mixScaleY,this.mixShearY=t.mixShearY}isActive(){return this.active}setToSetupPose(){const t=this.data;this.mixRotate=t.mixRotate,this.mixX=t.mixX,this.mixY=t.mixY,this.mixScaleX=t.mixScaleX,this.mixScaleY=t.mixScaleY,this.mixShearY=t.mixShearY}update(t){0==this.mixRotate&&0==this.mixX&&0==this.mixY&&0==this.mixScaleX&&0==this.mixScaleY&&0==this.mixShearY||(this.data.local?this.data.relative?this.applyRelativeLocal():this.applyAbsoluteLocal():this.data.relative?this.applyRelativeWorld():this.applyAbsoluteWorld())}applyAbsoluteWorld(){let t=this.mixRotate,e=this.mixX,r=this.mixY,s=this.mixScaleX,i=this.mixScaleY,n=this.mixShearY,o=0!=e||0!=r,a=this.target,l=a.a,h=a.b,c=a.c,u=a.d,d=l*u-h*c>0?Se.degRad:-Se.degRad,p=this.data.offsetRotation*d,f=this.data.offsetShearY*d,g=this.bones;for(let d=0,m=g.length;d<m;d++){let m=g[d];if(0!=t){let e=m.a,r=m.b,s=m.c,i=m.d,n=Math.atan2(c,l)-Math.atan2(s,e)+p;n>Se.PI?n-=Se.PI2:n<-Se.PI&&(n+=Se.PI2),n*=t;let o=Math.cos(n),a=Math.sin(n);m.a=o*e-a*s,m.b=o*r-a*i,m.c=a*e+o*s,m.d=a*r+o*i}if(o){let t=this.temp;a.localToWorld(t.set(this.data.offsetX,this.data.offsetY)),m.worldX+=(t.x-m.worldX)*e,m.worldY+=(t.y-m.worldY)*r}if(0!=s){let t=Math.sqrt(m.a*m.a+m.c*m.c);0!=t&&(t=(t+(Math.sqrt(l*l+c*c)-t+this.data.offsetScaleX)*s)/t),m.a*=t,m.c*=t}if(0!=i){let t=Math.sqrt(m.b*m.b+m.d*m.d);0!=t&&(t=(t+(Math.sqrt(h*h+u*u)-t+this.data.offsetScaleY)*i)/t),m.b*=t,m.d*=t}if(n>0){let t=m.b,e=m.d,r=Math.atan2(e,t),s=Math.atan2(u,h)-Math.atan2(c,l)-(r-Math.atan2(m.c,m.a));s>Se.PI?s-=Se.PI2:s<-Se.PI&&(s+=Se.PI2),s=r+(s+f)*n;let i=Math.sqrt(t*t+e*e);m.b=Math.cos(s)*i,m.d=Math.sin(s)*i}m.updateAppliedTransform()}}applyRelativeWorld(){let t=this.mixRotate,e=this.mixX,r=this.mixY,s=this.mixScaleX,i=this.mixScaleY,n=this.mixShearY,o=0!=e||0!=r,a=this.target,l=a.a,h=a.b,c=a.c,u=a.d,d=l*u-h*c>0?Se.degRad:-Se.degRad,p=this.data.offsetRotation*d,f=this.data.offsetShearY*d,g=this.bones;for(let d=0,m=g.length;d<m;d++){let m=g[d];if(0!=t){let e=m.a,r=m.b,s=m.c,i=m.d,n=Math.atan2(c,l)+p;n>Se.PI?n-=Se.PI2:n<-Se.PI&&(n+=Se.PI2),n*=t;let o=Math.cos(n),a=Math.sin(n);m.a=o*e-a*s,m.b=o*r-a*i,m.c=a*e+o*s,m.d=a*r+o*i}if(o){let t=this.temp;a.localToWorld(t.set(this.data.offsetX,this.data.offsetY)),m.worldX+=t.x*e,m.worldY+=t.y*r}if(0!=s){let t=(Math.sqrt(l*l+c*c)-1+this.data.offsetScaleX)*s+1;m.a*=t,m.c*=t}if(0!=i){let t=(Math.sqrt(h*h+u*u)-1+this.data.offsetScaleY)*i+1;m.b*=t,m.d*=t}if(n>0){let t=Math.atan2(u,h)-Math.atan2(c,l);t>Se.PI?t-=Se.PI2:t<-Se.PI&&(t+=Se.PI2);let e=m.b,r=m.d;t=Math.atan2(r,e)+(t-Se.PI/2+f)*n;let s=Math.sqrt(e*e+r*r);m.b=Math.cos(t)*s,m.d=Math.sin(t)*s}m.updateAppliedTransform()}}applyAbsoluteLocal(){let t=this.mixRotate,e=this.mixX,r=this.mixY,s=this.mixScaleX,i=this.mixScaleY,n=this.mixShearY,o=this.target,a=this.bones;for(let l=0,h=a.length;l<h;l++){let h=a[l],c=h.arotation;0!=t&&(c+=(o.arotation-c+this.data.offsetRotation)*t);let u=h.ax,d=h.ay;u+=(o.ax-u+this.data.offsetX)*e,d+=(o.ay-d+this.data.offsetY)*r;let p=h.ascaleX,f=h.ascaleY;0!=s&&0!=p&&(p=(p+(o.ascaleX-p+this.data.offsetScaleX)*s)/p),0!=i&&0!=f&&(f=(f+(o.ascaleY-f+this.data.offsetScaleY)*i)/f);let g=h.ashearY;0!=n&&(g+=(o.ashearY-g+this.data.offsetShearY)*n),h.updateWorldTransformWith(u,d,c,p,f,h.ashearX,g)}}applyRelativeLocal(){let t=this.mixRotate,e=this.mixX,r=this.mixY,s=this.mixScaleX,i=this.mixScaleY,n=this.mixShearY,o=this.target,a=this.bones;for(let l=0,h=a.length;l<h;l++){let h=a[l],c=h.arotation+(o.arotation+this.data.offsetRotation)*t,u=h.ax+(o.ax+this.data.offsetX)*e,d=h.ay+(o.ay+this.data.offsetY)*r,p=h.ascaleX*((o.ascaleX-1+this.data.offsetScaleX)*s+1),f=h.ascaleY*((o.ascaleY-1+this.data.offsetScaleY)*i+1),g=h.ashearY+(o.ashearY+this.data.offsetShearY)*n;h.updateWorldTransformWith(u,d,c,p,f,h.ashearX,g)}}}class nr{static quadTriangles=[0,1,2,2,3,0];static yDown=!1;data;bones;slots;drawOrder;ikConstraints;transformConstraints;pathConstraints;physicsConstraints;_updateCache=new Array;skin=null;color;scaleX=1;_scaleY=1;get scaleY(){return nr.yDown?-this._scaleY:this._scaleY}set scaleY(t){this._scaleY=t}x=0;y=0;time=0;constructor(t){if(!t)throw new Error("data cannot be null.");this.data=t,this.bones=new Array;for(let e=0;e<t.bones.length;e++){let r,s=t.bones[e];if(s.parent){let t=this.bones[s.parent.index];r=new Je(s,this,t),t.children.push(r)}else r=new Je(s,this,null);this.bones.push(r)}this.slots=new Array,this.drawOrder=new Array;for(let e=0;e<t.slots.length;e++){let r=t.slots[e],s=this.bones[r.boneData.index],i=new sr(r,s);this.slots.push(i),this.drawOrder.push(i)}this.ikConstraints=new Array;for(let e=0;e<t.ikConstraints.length;e++){let r=t.ikConstraints[e];this.ikConstraints.push(new tr(r,this))}this.transformConstraints=new Array;for(let e=0;e<t.transformConstraints.length;e++){let r=t.transformConstraints[e];this.transformConstraints.push(new ir(r,this))}this.pathConstraints=new Array;for(let e=0;e<t.pathConstraints.length;e++){let r=t.pathConstraints[e];this.pathConstraints.push(new er(r,this))}this.physicsConstraints=new Array;for(let e=0;e<t.physicsConstraints.length;e++){let r=t.physicsConstraints[e];this.physicsConstraints.push(new rr(r,this))}this.color=new Te(1,1,1,1),this.updateCache()}updateCache(){this._updateCache.length=0;let t=this.bones;for(let e=0,r=t.length;e<r;e++){let r=t[e];r.sorted=r.data.skinRequired,r.active=!r.sorted}if(this.skin){let t=this.skin.bones;for(let e=0,r=this.skin.bones.length;e<r;e++){let r=this.bones[t[e].index];do{r.sorted=!1,r.active=!0,r=r.parent}while(r)}}let e=this.ikConstraints,r=this.transformConstraints,s=this.pathConstraints,i=this.physicsConstraints,n=e.length,o=r.length,a=s.length,l=this.physicsConstraints.length,h=n+o+a+l;t:for(let t=0;t<h;t++){for(let r=0;r<n;r++){let s=e[r];if(s.data.order==t){this.sortIkConstraint(s);continue t}}for(let e=0;e<o;e++){let s=r[e];if(s.data.order==t){this.sortTransformConstraint(s);continue t}}for(let e=0;e<a;e++){let r=s[e];if(r.data.order==t){this.sortPathConstraint(r);continue t}}for(let e=0;e<l;e++){const r=i[e];if(r.data.order==t){this.sortPhysicsConstraint(r);continue t}}}for(let e=0,r=t.length;e<r;e++)this.sortBone(t[e])}sortIkConstraint(t){if(t.active=t.target.isActive()&&(!t.data.skinRequired||this.skin&&Ae.contains(this.skin.constraints,t.data,!0)),!t.active)return;let e=t.target;this.sortBone(e);let r=t.bones,s=r[0];if(this.sortBone(s),1==r.length)this._updateCache.push(t),this.sortReset(s.children);else{let e=r[r.length-1];this.sortBone(e),this._updateCache.push(t),this.sortReset(s.children),e.sorted=!0}}sortPathConstraint(t){if(t.active=t.target.bone.isActive()&&(!t.data.skinRequired||this.skin&&Ae.contains(this.skin.constraints,t.data,!0)),!t.active)return;let e=t.target,r=e.data.index,s=e.bone;this.skin&&this.sortPathConstraintAttachment(this.skin,r,s),this.data.defaultSkin&&this.data.defaultSkin!=this.skin&&this.sortPathConstraintAttachment(this.data.defaultSkin,r,s);for(let t=0,e=this.data.skins.length;t<e;t++)this.sortPathConstraintAttachment(this.data.skins[t],r,s);let i=e.getAttachment();i instanceof Ze&&this.sortPathConstraintAttachmentWith(i,s);let n=t.bones,o=n.length;for(let t=0;t<o;t++)this.sortBone(n[t]);this._updateCache.push(t);for(let t=0;t<o;t++)this.sortReset(n[t].children);for(let t=0;t<o;t++)n[t].sorted=!0}sortTransformConstraint(t){if(t.active=t.target.isActive()&&(!t.data.skinRequired||this.skin&&Ae.contains(this.skin.constraints,t.data,!0)),!t.active)return;this.sortBone(t.target);let e=t.bones,r=e.length;if(t.data.local)for(let t=0;t<r;t++){let r=e[t];this.sortBone(r.parent),this.sortBone(r)}else for(let t=0;t<r;t++)this.sortBone(e[t]);this._updateCache.push(t);for(let t=0;t<r;t++)this.sortReset(e[t].children);for(let t=0;t<r;t++)e[t].sorted=!0}sortPathConstraintAttachment(t,e,r){let s=t.attachments[e];if(s)for(let t in s)this.sortPathConstraintAttachmentWith(s[t],r)}sortPathConstraintAttachmentWith(t,e){if(!(t instanceof Ze))return;let r=t.bones;if(r){let t=this.bones;for(let e=0,s=r.length;e<s;){let s=r[e++];for(s+=e;e<s;)this.sortBone(t[r[e++]])}}else this.sortBone(e)}sortPhysicsConstraint(t){const e=t.bone;t.active=e.active&&(!t.data.skinRequired||null!=this.skin&&Ae.contains(this.skin.constraints,t.data,!0)),t.active&&(this.sortBone(e),this._updateCache.push(t),this.sortReset(e.children),e.sorted=!0)}sortBone(t){if(!t)return;if(t.sorted)return;let e=t.parent;e&&this.sortBone(e),t.sorted=!0,this._updateCache.push(t)}sortReset(t){for(let e=0,r=t.length;e<r;e++){let r=t[e];r.active&&(r.sorted&&this.sortReset(r.children),r.sorted=!1)}}updateWorldTransform(t){if(null==t)throw new Error("physics is undefined");let e=this.bones;for(let t=0,r=e.length;t<r;t++){let r=e[t];r.ax=r.x,r.ay=r.y,r.arotation=r.rotation,r.ascaleX=r.scaleX,r.ascaleY=r.scaleY,r.ashearX=r.shearX,r.ashearY=r.shearY}let r=this._updateCache;for(let e=0,s=r.length;e<s;e++)r[e].update(t)}updateWorldTransformWith(t,e){if(!e)throw new Error("parent cannot be null.");let r=this.bones;for(let t=1,e=r.length;t<e;t++){let e=r[t];e.ax=e.x,e.ay=e.y,e.arotation=e.rotation,e.ascaleX=e.scaleX,e.ascaleY=e.scaleY,e.ashearX=e.shearX,e.ashearY=e.shearY}let s=this.getRootBone();if(!s)throw new Error("Root bone must not be null.");let i=e.a,n=e.b,o=e.c,a=e.d;s.worldX=i*this.x+n*this.y+e.worldX,s.worldY=o*this.x+a*this.y+e.worldY;const l=(s.rotation+s.shearX)*Se.degRad,h=(s.rotation+90+s.shearY)*Se.degRad,c=Math.cos(l)*s.scaleX,u=Math.cos(h)*s.scaleY,d=Math.sin(l)*s.scaleX,p=Math.sin(h)*s.scaleY;s.a=(i*c+n*d)*this.scaleX,s.b=(i*u+n*p)*this.scaleX,s.c=(o*c+a*d)*this.scaleY,s.d=(o*u+a*p)*this.scaleY;let f=this._updateCache;for(let e=0,r=f.length;e<r;e++){let r=f[e];r!=s&&r.update(t)}}setToSetupPose(){this.setBonesToSetupPose(),this.setSlotsToSetupPose()}setBonesToSetupPose(){for(const t of this.bones)t.setToSetupPose();for(const t of this.ikConstraints)t.setToSetupPose();for(const t of this.transformConstraints)t.setToSetupPose();for(const t of this.pathConstraints)t.setToSetupPose();for(const t of this.physicsConstraints)t.setToSetupPose()}setSlotsToSetupPose(){let t=this.slots;Ae.arrayCopy(t,0,this.drawOrder,0,t.length);for(let e=0,r=t.length;e<r;e++)t[e].setToSetupPose()}getRootBone(){return 0==this.bones.length?null:this.bones[0]}findBone(t){if(!t)throw new Error("boneName cannot be null.");let e=this.bones;for(let r=0,s=e.length;r<s;r++){let s=e[r];if(s.data.name==t)return s}return null}findSlot(t){if(!t)throw new Error("slotName cannot be null.");let e=this.slots;for(let r=0,s=e.length;r<s;r++){let s=e[r];if(s.data.name==t)return s}return null}setSkinByName(t){let e=this.data.findSkin(t);if(!e)throw new Error("Skin not found: "+t);this.setSkin(e)}setSkin(t){if(t!=this.skin){if(t)if(this.skin)t.attachAll(this,this.skin);else{let e=this.slots;for(let r=0,s=e.length;r<s;r++){let s=e[r],i=s.data.attachmentName;if(i){let e=t.getAttachment(r,i);e&&s.setAttachment(e)}}}this.skin=t,this.updateCache()}}getAttachmentByName(t,e){let r=this.data.findSlot(t);if(!r)throw new Error(`Can't find slot with name ${t}`);return this.getAttachment(r.index,e)}getAttachment(t,e){if(!e)throw new Error("attachmentName cannot be null.");if(this.skin){let r=this.skin.getAttachment(t,e);if(r)return r}return this.data.defaultSkin?this.data.defaultSkin.getAttachment(t,e):null}setAttachment(t,e){if(!t)throw new Error("slotName cannot be null.");let r=this.slots;for(let s=0,i=r.length;s<i;s++){let i=r[s];if(i.data.name==t){let r=null;if(e&&(r=this.getAttachment(s,e),!r))throw new Error("Attachment not found: "+e+", for slot: "+t);return void i.setAttachment(r)}}throw new Error("Slot not found: "+t)}findIkConstraint(t){if(!t)throw new Error("constraintName cannot be null.");return this.ikConstraints.find(e=>e.data.name==t)??null}findTransformConstraint(t){if(!t)throw new Error("constraintName cannot be null.");return this.transformConstraints.find(e=>e.data.name==t)??null}findPathConstraint(t){if(!t)throw new Error("constraintName cannot be null.");return this.pathConstraints.find(e=>e.data.name==t)??null}findPhysicsConstraint(t){if(null==t)throw new Error("constraintName cannot be null.");return this.physicsConstraints.find(e=>e.data.name==t)??null}getBoundsRect(t){let e=new Pe,r=new Pe;return this.getBounds(e,r,void 0,t),{x:e.x,y:e.y,width:r.x,height:r.y}}getBounds(t,e,r=new Array(2),s=null){if(!t)throw new Error("offset cannot be null.");if(!e)throw new Error("size cannot be null.");let i=this.drawOrder,n=Number.POSITIVE_INFINITY,o=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY;for(let t=0,e=i.length;t<e;t++){let e=i[t];if(!e.bone.active)continue;let h=0,c=null,u=null,d=e.getAttachment();if(d instanceof Qe)h=8,c=Ae.setArraySize(r,h,0),d.computeWorldVertices(e,c,0,2),u=nr.quadTriangles;else if(d instanceof Ke){let t=d;h=t.worldVerticesLength,c=Ae.setArraySize(r,h,0),t.computeWorldVertices(e,0,h,c,0,2),u=t.triangles}else if(d instanceof He&&null!=s){s.clipStart(e,d);continue}if(c&&u){null!=s&&s.isClipping()&&(s.clipTriangles(c,u,u.length),c=s.clippedVertices,h=s.clippedVertices.length);for(let t=0,e=c.length;t<e;t+=2){let e=c[t],r=c[t+1];n=Math.min(n,e),o=Math.min(o,r),a=Math.max(a,e),l=Math.max(l,r)}}null!=s&&s.clipEndWithSlot(e)}null!=s&&s.clipEnd(),t.set(n,o),e.set(a-n,l-o)}update(t){this.time+=t}physicsTranslate(t,e){const r=this.physicsConstraints;for(let s=0,i=r.length;s<i;s++)r[s].translate(t,e)}physicsRotate(t,e,r){const s=this.physicsConstraints;for(let i=0,n=s.length;i<n;i++)s[i].rotate(t,e,r)}}(ze=Ue||(Ue={}))[ze.none=0]="none",ze[ze.reset=1]="reset",ze[ze.update=2]="update",ze[ze.pose=3]="pose",function(t){t[t.Normal=0]="Normal",t[t.Additive=1]="Additive",t[t.Multiply=2]="Multiply",t[t.Screen=3]="Screen"}(Le||(Le={})),function(t){t[t.Region=0]="Region",t[t.BoundingBox=1]="BoundingBox",t[t.Mesh=2]="Mesh",t[t.LinkedMesh=3]="LinkedMesh",t[t.Path=4]="Path",t[t.Point=5]="Point",t[t.Clipping=6]="Clipping"}(Ne||(Ne={}));class or{convexPolygons=new Array;convexPolygonsIndices=new Array;indicesArray=new Array;isConcaveArray=new Array;triangles=new Array;polygonPool=new Ce(()=>new Array);polygonIndicesPool=new Ce(()=>new Array);triangulate(t){let e=t,r=t.length>>1,s=this.indicesArray;s.length=0;for(let t=0;t<r;t++)s[t]=t;let i=this.isConcaveArray;i.length=0;for(let t=0,n=r;t<n;++t)i[t]=or.isConcave(t,r,e,s);let n=this.triangles;for(n.length=0;r>3;){let t=r-1,o=0,a=1;for(;;){t:if(!i[o]){let n=s[t]<<1,l=s[o]<<1,h=s[a]<<1,c=e[n],u=e[n+1],d=e[l],p=e[l+1],f=e[h],g=e[h+1];for(let n=(a+1)%r;n!=t;n=(n+1)%r){if(!i[n])continue;let t=s[n]<<1,r=e[t],o=e[t+1];if(or.positiveArea(f,g,c,u,r,o)&&or.positiveArea(c,u,d,p,r,o)&&or.positiveArea(d,p,f,g,r,o))break t}break}if(0==a){do{if(!i[o])break;o--}while(o>0);break}t=o,o=a,a=(a+1)%r}n.push(s[(r+o-1)%r]),n.push(s[o]),n.push(s[(o+1)%r]),s.splice(o,1),i.splice(o,1),r--;let l=(r+o-1)%r,h=o==r?0:o;i[l]=or.isConcave(l,r,e,s),i[h]=or.isConcave(h,r,e,s)}return 3==r&&(n.push(s[2]),n.push(s[0]),n.push(s[1])),n}decompose(t,e){let r=t,s=this.convexPolygons;this.polygonPool.freeAll(s),s.length=0;let i=this.convexPolygonsIndices;this.polygonIndicesPool.freeAll(i),i.length=0;let n=this.polygonIndicesPool.obtain();n.length=0;let o=this.polygonPool.obtain();o.length=0;let a=-1,l=0;for(let t=0,h=e.length;t<h;t+=3){let h=e[t]<<1,c=e[t+1]<<1,u=e[t+2]<<1,d=r[h],p=r[h+1],f=r[c],g=r[c+1],m=r[u],x=r[u+1],_=!1;if(a==h){let t=o.length-4,e=or.winding(o[t],o[t+1],o[t+2],o[t+3],m,x),r=or.winding(m,x,o[0],o[1],o[2],o[3]);e==l&&r==l&&(o.push(m),o.push(x),n.push(u),_=!0)}_||(o.length>0?(s.push(o),i.push(n)):(this.polygonPool.free(o),this.polygonIndicesPool.free(n)),o=this.polygonPool.obtain(),o.length=0,o.push(d),o.push(p),o.push(f),o.push(g),o.push(m),o.push(x),n=this.polygonIndicesPool.obtain(),n.length=0,n.push(h),n.push(c),n.push(u),l=or.winding(d,p,f,g,m,x),a=h)}o.length>0&&(s.push(o),i.push(n));for(let t=0,e=s.length;t<e;t++){if(n=i[t],0==n.length)continue;let r=n[0],a=n[n.length-1];o=s[t];let l=o.length-4,h=o[l],c=o[l+1],u=o[l+2],d=o[l+3],p=o[0],f=o[1],g=o[2],m=o[3],x=or.winding(h,c,u,d,p,f);for(let l=0;l<e;l++){if(l==t)continue;let e=i[l];if(3!=e.length)continue;let _=e[0],y=e[1],v=e[2],b=s[l],w=b[b.length-2],T=b[b.length-1];if(_!=r||y!=a)continue;let S=or.winding(h,c,u,d,w,T),A=or.winding(w,T,p,f,g,m);S==x&&A==x&&(b.length=0,e.length=0,o.push(w),o.push(T),n.push(v),h=u,c=d,u=w,d=T,l=0)}}for(let t=s.length-1;t>=0;t--)o=s[t],0==o.length&&(s.splice(t,1),this.polygonPool.free(o),n=i[t],i.splice(t,1),this.polygonIndicesPool.free(n));return s}static isConcave(t,e,r,s){let i=s[(e+t-1)%e]<<1,n=s[t]<<1,o=s[(t+1)%e]<<1;return!this.positiveArea(r[i],r[i+1],r[n],r[n+1],r[o],r[o+1])}static positiveArea(t,e,r,s,i,n){return t*(n-s)+r*(e-n)+i*(s-e)>=0}static winding(t,e,r,s,i,n){let o=r-t,a=s-e;return i*a-n*o+o*e-t*a>=0?1:-1}}class ar{triangulator=new or;clippingPolygon=new Array;clipOutput=new Array;clippedVertices=new Array;clippedUVs=new Array;clippedTriangles=new Array;scratch=new Array;clipAttachment=null;clippingPolygons=null;clipStart(t,e){if(this.clipAttachment)return 0;this.clipAttachment=e;let r=e.worldVerticesLength,s=Ae.setArraySize(this.clippingPolygon,r);e.computeWorldVertices(t,0,r,s,0,2);let i=this.clippingPolygon;ar.makeClockwise(i);let n=this.clippingPolygons=this.triangulator.decompose(i,this.triangulator.triangulate(i));for(let t=0,e=n.length;t<e;t++){let e=n[t];ar.makeClockwise(e),e.push(e[0]),e.push(e[1])}return n.length}clipEndWithSlot(t){this.clipAttachment&&this.clipAttachment.endSlot==t.data&&this.clipEnd()}clipEnd(){this.clipAttachment&&(this.clipAttachment=null,this.clippingPolygons=null,this.clippedVertices.length=0,this.clippedTriangles.length=0,this.clippingPolygon.length=0)}isClipping(){return null!=this.clipAttachment}clipTriangles(t,e,r,s,i,n,o,a){let l,h,c,u,d,p;"number"==typeof e?(l=r,h=s,c=i,u=n,d=o,p=a):(l=e,h=r,c=s,u=i,d=n,p=o),c&&u&&d&&"boolean"==typeof p?this.clipTrianglesRender(t,l,h,c,u,d,p):this.clipTrianglesNoRender(t,l,h)}clipTrianglesNoRender(t,e,r){let s=this.clipOutput,i=this.clippedVertices,n=this.clippedTriangles,o=this.clippingPolygons,a=o.length,l=0;i.length=0,n.length=0;for(let h=0;h<r;h+=3){let r=e[h]<<1,c=t[r],u=t[r+1];r=e[h+1]<<1;let d=t[r],p=t[r+1];r=e[h+2]<<1;let f=t[r],g=t[r+1];for(let t=0;t<a;t++){let e=i.length;if(!this.clip(c,u,d,p,f,g,o[t],s)){let t=Ae.setArraySize(i,e+6);t[e]=c,t[e+1]=u,t[e+2]=d,t[e+3]=p,t[e+4]=f,t[e+5]=g,e=n.length;let r=Ae.setArraySize(n,e+3);r[e]=l,r[e+1]=l+1,r[e+2]=l+2,l+=3;break}{let t=s.length;if(0==t)continue;let r=t>>1,o=this.clipOutput,a=Ae.setArraySize(i,e+2*r);for(let r=0;r<t;r+=2,e+=2){let t=o[r],s=o[r+1];a[e]=t,a[e+1]=s}e=n.length;let h=Ae.setArraySize(n,e+3*(r-2));r--;for(let t=1;t<r;t++,e+=3)h[e]=l,h[e+1]=l+t,h[e+2]=l+t+1;l+=r+1}}}}clipTrianglesRender(t,e,r,s,i,n,o){let a=this.clipOutput,l=this.clippedVertices,h=this.clippedTriangles,c=this.clippingPolygons,u=c.length,d=o?12:8,p=0;l.length=0,h.length=0;for(let f=0;f<r;f+=3){let r=e[f]<<1,g=t[r],m=t[r+1],x=s[r],_=s[r+1];r=e[f+1]<<1;let y=t[r],v=t[r+1],b=s[r],w=s[r+1];r=e[f+2]<<1;let T=t[r],S=t[r+1],A=s[r],C=s[r+1];for(let t=0;t<u;t++){let e=l.length;if(!this.clip(g,m,y,v,T,S,c[t],a)){let t=Ae.setArraySize(l,e+3*d);t[e]=g,t[e+1]=m,t[e+2]=i.r,t[e+3]=i.g,t[e+4]=i.b,t[e+5]=i.a,o?(t[e+6]=x,t[e+7]=_,t[e+8]=n.r,t[e+9]=n.g,t[e+10]=n.b,t[e+11]=n.a,t[e+12]=y,t[e+13]=v,t[e+14]=i.r,t[e+15]=i.g,t[e+16]=i.b,t[e+17]=i.a,t[e+18]=b,t[e+19]=w,t[e+20]=n.r,t[e+21]=n.g,t[e+22]=n.b,t[e+23]=n.a,t[e+24]=T,t[e+25]=S,t[e+26]=i.r,t[e+27]=i.g,t[e+28]=i.b,t[e+29]=i.a,t[e+30]=A,t[e+31]=C,t[e+32]=n.r,t[e+33]=n.g,t[e+34]=n.b,t[e+35]=n.a):(t[e+6]=x,t[e+7]=_,t[e+8]=y,t[e+9]=v,t[e+10]=i.r,t[e+11]=i.g,t[e+12]=i.b,t[e+13]=i.a,t[e+14]=b,t[e+15]=w,t[e+16]=T,t[e+17]=S,t[e+18]=i.r,t[e+19]=i.g,t[e+20]=i.b,t[e+21]=i.a,t[e+22]=A,t[e+23]=C),e=h.length;let r=Ae.setArraySize(h,e+3);r[e]=p,r[e+1]=p+1,r[e+2]=p+2,p+=3;break}{let t=a.length;if(0==t)continue;let r=v-S,s=T-y,c=g-T,u=S-m,f=1/(r*c+s*(m-S)),P=t>>1,M=this.clipOutput,E=Ae.setArraySize(l,e+P*d);for(let a=0;a<t;a+=2,e+=d){let t=M[a],l=M[a+1];E[e]=t,E[e+1]=l,E[e+2]=i.r,E[e+3]=i.g,E[e+4]=i.b,E[e+5]=i.a;let h=t-T,d=l-S,p=(r*h+s*d)*f,g=(u*h+c*d)*f,m=1-p-g;E[e+6]=x*p+b*g+A*m,E[e+7]=_*p+w*g+C*m,o&&(E[e+8]=n.r,E[e+9]=n.g,E[e+10]=n.b,E[e+11]=n.a)}e=h.length;let R=Ae.setArraySize(h,e+3*(P-2));P--;for(let t=1;t<P;t++,e+=3)R[e]=p,R[e+1]=p+t,R[e+2]=p+t+1;p+=P+1}}}}clipTrianglesUnpacked(t,e,r,s){let i=this.clipOutput,n=this.clippedVertices,o=this.clippedUVs,a=this.clippedTriangles,l=this.clippingPolygons,h=l.length,c=0;n.length=0,o.length=0,a.length=0;for(let u=0;u<r;u+=3){let r=e[u]<<1,d=t[r],p=t[r+1],f=s[r],g=s[r+1];r=e[u+1]<<1;let m=t[r],x=t[r+1],_=s[r],y=s[r+1];r=e[u+2]<<1;let v=t[r],b=t[r+1],w=s[r],T=s[r+1];for(let t=0;t<h;t++){let e=n.length;if(!this.clip(d,p,m,x,v,b,l[t],i)){let t=Ae.setArraySize(n,e+6);t[e]=d,t[e+1]=p,t[e+2]=m,t[e+3]=x,t[e+4]=v,t[e+5]=b;let r=Ae.setArraySize(o,e+6);r[e]=f,r[e+1]=g,r[e+2]=_,r[e+3]=y,r[e+4]=w,r[e+5]=T,e=a.length;let s=Ae.setArraySize(a,e+3);s[e]=c,s[e+1]=c+1,s[e+2]=c+2,c+=3;break}{let t=i.length;if(0==t)continue;let r=x-b,s=v-m,l=d-v,h=b-p,u=1/(r*l+s*(p-b)),S=t>>1,A=this.clipOutput,C=Ae.setArraySize(n,e+2*S),P=Ae.setArraySize(o,e+2*S);for(let i=0;i<t;i+=2,e+=2){let t=A[i],n=A[i+1];C[e]=t,C[e+1]=n;let o=t-v,a=n-b,c=(r*o+s*a)*u,d=(h*o+l*a)*u,p=1-c-d;P[e]=f*c+_*d+w*p,P[e+1]=g*c+y*d+T*p}e=a.length;let M=Ae.setArraySize(a,e+3*(S-2));S--;for(let t=1;t<S;t++,e+=3)M[e]=c,M[e+1]=c+t,M[e+2]=c+t+1;c+=S+1}}}}clip(t,e,r,s,i,n,o,a){let l,h=a,c=!1;o.length%4>=2?(l=a,a=this.scratch):l=this.scratch,l.length=0,l.push(t),l.push(e),l.push(r),l.push(s),l.push(i),l.push(n),l.push(t),l.push(e),a.length=0;let u=o.length-4,d=o;for(let t=0;;t+=2){let e=d[t],r=d[t+1],s=e-d[t+2],i=r-d[t+3],n=a.length,o=l;for(let t=0,n=l.length-2;t<n;){let n=o[t],l=o[t+1];t+=2;let h=o[t],u=o[t+1],d=i*(e-h)>s*(r-u),p=i*(e-n)-s*(r-l);if(p>0){if(d){a.push(h),a.push(u);continue}let t=h-n,e=u-l,r=p/(t*i-e*s);if(!(r>=0&&r<=1)){a.push(h),a.push(u);continue}a.push(n+t*r),a.push(l+e*r)}else if(d){let t=h-n,e=u-l,r=p/(t*i-e*s);if(!(r>=0&&r<=1)){a.push(h),a.push(u);continue}a.push(n+t*r),a.push(l+e*r),a.push(h),a.push(u)}c=!0}if(n==a.length)return h.length=0,!0;if(a.push(a[0]),a.push(a[1]),t==u)break;let p=a;(a=l).length=0,l=p}if(h!=a){h.length=0;for(let t=0,e=a.length-2;t<e;t++)h[t]=a[t]}else h.length=h.length-2;return c}static makeClockwise(t){let e=t,r=t.length,s=e[r-2]*e[1]-e[0]*e[r-1],i=0,n=0,o=0,a=0;for(let t=0,l=r-3;t<l;t+=2)i=e[t],n=e[t+1],o=e[t+2],a=e[t+3],s+=i*a-o*n;if(!(s<0))for(let t=0,s=r-2,i=r>>1;t<i;t+=2){let r=e[t],i=e[t+1],n=s-t;e[t]=e[n],e[t+1]=e[n+1],e[n]=r,e[n+1]=i}}}void 0===Math.fround&&(Math.fround=(We=new Float32Array(1),function(t){return We[0]=t,We[0]}));class lr extends Xe{static textureMap=new Map;static from(t){return lr.textureMap.has(t)?lr.textureMap.get(t):new lr(t)}texture;constructor(t){super(t.resource),this.texture=c.g.from(t)}setFilters(t,e){const r=this.texture.source.style;r.minFilter=lr.toPixiTextureFilter(t),r.magFilter=lr.toPixiTextureFilter(e),this.texture.source.autoGenerateMipmaps=lr.toPixiMipMap(t),this.texture.source.updateMipmaps()}setWraps(t,e){const r=this.texture.source.style;r.addressModeU=lr.toPixiTextureWrap(t),r.addressModeV=lr.toPixiTextureWrap(e)}dispose(){this.texture.destroy()}static toPixiMipMap(t){switch(t){case Be.Nearest:case Be.Linear:return!1;case Be.MipMapNearestLinear:case Be.MipMapNearestNearest:case Be.MipMapLinearLinear:case Be.MipMapLinearNearest:return!0;default:throw new Error(`Unknown texture filter: ${String(t)}`)}}static toPixiTextureFilter(t){switch(t){case Be.Nearest:case Be.MipMapNearestLinear:case Be.MipMapNearestNearest:return"nearest";case Be.Linear:case Be.MipMapLinearLinear:case Be.MipMapLinearNearest:return"linear";default:throw new Error(`Unknown texture filter: ${String(t)}`)}}static toPixiTextureWrap(t){switch(t){case Ie.ClampToEdge:return"clamp-to-edge";case Ie.MirroredRepeat:return"mirror-repeat";case Ie.Repeat:return"repeat";default:throw new Error(`Unknown texture wrap: ${String(t)}`)}}static toPixiBlending(t){switch(t){case Le.Normal:return"normal";case Le.Additive:return"add";case Le.Multiply:return"multiply";case Le.Screen:return"screen";default:throw new Error(`Unknown blendMode: ${String(t)}`)}}}const hr="spineTextureAtlasLoader",cr={extension:t.Ag.Asset,resolver:{test:t=>L(t,".atlas"),parse:t=>{const e=t.split(".");return{resolution:parseFloat(Z.x.RETINA_PREFIX?.exec(t)?.[1]??"1"),format:e[e.length-2],src:t}}},loader:{id:hr,name:hr,extension:{type:t.Ag.LoadParser,priority:i.T.Normal,name:hr},test:t=>L(t,".atlas"),async load(t){const e=await o.e.get().fetch(t);return await e.text()},testParse(t,e){const r=L(e.src,".atlas"),s="string"==typeof t,i=e.parser===hr||e.loadParser===hr;return Promise.resolve((r||i)&&s)},unload(t){t.dispose()},async parse(t,e,r){const s=e.data||{};let i=a.A.dirname(e.src);i&&i.lastIndexOf("/")!==i.length-1&&(i+="/");const o=new Ye(t);if(s.images instanceof Ut.v||"string"==typeof s.images){const t=s.images;s.images={},s.images[o.pages[0].name]=t}const l=[];for(const t of o.pages){const o=t.name,h=s?.images?s.images[o]:void 0;if(h instanceof Ut.v)t.setTexture(lr.from(h));else{const c=h??a.A.normalize([...i.split(a.A.sep),o].join(a.A.sep)),u={src:(0,n.Y)(c,e.src),data:{...s.imageMetadata,alphaMode:t.pma?"premultiplied-alpha":"premultiply-alpha-on-upload"}},d=r.load(u).then(e=>{t.setTexture(lr.from(e.source))});l.push(d)}}return await Promise.all(l),o}}};t.XO.add(cr);const ur="spineSkeletonLoader",dr={extension:t.Ag.Asset,loader:{id:ur,name:ur,extension:{type:t.Ag.LoadParser,priority:i.T.Normal,name:ur},test:t=>L(t,".skel"),async load(t){const e=await o.e.get().fetch(t);return new Uint8Array(await e.arrayBuffer())},testParse(t,e){const r=L(e.src,".json")&&(s=t,Object.prototype.hasOwnProperty.call(s,"bones"));var s;const i=L(e.src,".skel")&&function(t){return t instanceof Uint8Array}(t),n=e.parser===ur||e.loadParser===ur;return Promise.resolve(r||i||n)}}};t.XO.add(dr);const pr=new Float32Array(1),fr=new Uint32Array(1);class gr extends Ot.V{constructor(){const t=new Gt.h({data:pr,label:"attribute-batch-buffer",usage:Ft.S.VERTEX|Ft.S.COPY_DST,shrinkToFit:!1});super({attributes:{aPosition:{buffer:t,format:"float32x2",stride:28,offset:0},aUV:{buffer:t,format:"float32x2",stride:28,offset:8},aColor:{buffer:t,format:"unorm8x4",stride:28,offset:16},aDarkColor:{buffer:t,format:"unorm8x4",stride:28,offset:20},aTextureIdAndRound:{buffer:t,format:"uint16x2",stride:28,offset:24}},indexBuffer:new Gt.h({data:fr,label:"index-batch-buffer",usage:Ft.S.INDEX|Ft.S.COPY_DST,shrinkToFit:!1})})}}const mr={name:"color-bit",vertex:{header:"\n @in aDarkColor: vec4<f32>;\n @out vDarkColor: vec4<f32>;\n ",main:"\n vDarkColor = aDarkColor;\n "},fragment:{header:"\n @in vDarkColor: vec4<f32>;\n ",end:"\n\n let alpha = outColor.a * vColor.a;\n let rgb = ((outColor.a - 1.0) * vDarkColor.a + 1.0 - outColor.rgb) * vDarkColor.rgb + outColor.rgb * vColor.rgb;\n\n finalColor = vec4<f32>(rgb, alpha);\n\n "}},xr={name:"color-bit",vertex:{header:"\n in vec4 aDarkColor;\n out vec4 vDarkColor;\n ",main:"\n vDarkColor = aDarkColor;\n "},fragment:{header:"\n in vec4 vDarkColor;\n ",end:"\n\n finalColor.a = outColor.a * vColor.a;\n finalColor.rgb = ((outColor.a - 1.0) * vDarkColor.a + 1.0 - outColor.rgb) * vDarkColor.rgb + outColor.rgb * vColor.rgb;\n "}};class _r extends Dt.M{constructor(t){super({glProgram:(0,Tt.I)({name:"dark-tint-batch",bits:[St.a,xr,(0,At.P)(t),Ct.m]}),gpuProgram:(0,Tt.v)({name:"dark-tint-batch",bits:[St.F,mr,(0,At._)(t),Ct.b]}),resources:{batchSamplers:(0,It.n)(t)}})}}let yr=null;class vr extends wt.i{static extension={type:[t.Ag.Batcher],name:"darkTint"};geometry=new gr;shader=yr||(yr=new _r(this.maxTextures));name=vr.extension.name;vertexSize=7;packAttributes(t,e,r,s,i){const n=i<<16|65535&t.roundPixels,o=t.transform,a=o.a,l=o.b,h=o.c,c=o.d,u=o.tx,d=o.ty,{positions:p,uvs:f}=t,g=t.color,m=(g>>24&255)/255,x=bt.Q.shared.setValue(t.darkColor).premultiply(m,!0).toPremultiplied(1,!1),_=t.attributeOffset,y=_+t.attributeSize;for(let t=_;t<y;t++){const i=2*t,o=p[i],m=p[i+1];e[s++]=a*o+h*m+u,e[s++]=c*m+l*o+d,e[s++]=f[i],e[s++]=f[i+1],r[s++]=g,r[s++]=x,r[s++]=n}}packQuadAttributes(t,e,r,s,i){const n=t.texture,o=t.transform,a=o.a,l=o.b,h=o.c,c=o.d,u=o.tx,d=o.ty,p=t.bounds,f=p.maxX,g=p.minX,m=p.maxY,x=p.minY,_=n.uvs,y=t.color,v=t.darkColor,b=i<<16|65535&t.roundPixels;e[s+0]=a*g+h*x+u,e[s+1]=c*x+l*g+d,e[s+2]=_.x0,e[s+3]=_.y0,r[s+4]=y,r[s+5]=v,r[s+6]=b,e[s+7]=a*f+h*x+u,e[s+8]=c*x+l*f+d,e[s+9]=_.x1,e[s+10]=_.y1,r[s+11]=y,r[s+12]=v,r[s+13]=b,e[s+14]=a*f+h*m+u,e[s+15]=c*m+l*f+d,e[s+16]=_.x2,e[s+17]=_.y2,r[s+18]=y,r[s+19]=v,r[s+20]=b,e[s+21]=a*g+h*m+u,e[s+22]=c*m+l*g+d,e[s+23]=_.x3,e[s+24]=_.y3,r[s+25]=y,r[s+26]=v,r[s+27]=b}}t.XO.add(vr);class br{indexOffset=0;attributeOffset=0;indexSize;attributeSize;batcherName="darkTint";topology="triangle-list";packAsQuad=!1;renderable;positions;indices;uvs;roundPixels;data;blendMode;darkTint;texture;transform;_textureId;_attributeStart;_indexStart;_batcher;_batch;get color(){const t=this.data.color,e=this.renderable.groupColor,r=this.renderable.groupAlpha;let s;const i=t.a*r*255;if(16777215!==e){const r=e>>16&255,n=e>>8&255,o=255&e,a=t.r*o,l=t.g*n;s=i<<24|t.b*r<<16|l<<8|a}else s=i<<24|255*t.b<<16|255*t.g<<8|255*t.r;return s}get darkColor(){const t=this.data.darkColor;return 255*t.b<<16|255*t.g<<8|255*t.r}get groupTransform(){return this.renderable.groupTransform}setData(t,e,r,s){if(this.renderable=t,this.transform=t.groupTransform,this.data=e,e.clipped){const t=e.clippedData;this.indexSize=t.indicesCount,this.attributeSize=t.vertexCount,this.positions=t.vertices,this.indices=t.indices,this.uvs=t.uvs}else this.indexSize=e.indices.length,this.attributeSize=e.vertices.length/2,this.positions=e.vertices,this.indices=e.indices,this.uvs=e.uvs;this.texture=e.texture,this.roundPixels=s,this.blendMode=r,this.batcherName=e.darkTint?"darkTint":"default"}}const wr={0:"normal",1:"add",2:"multiply",3:"screen"};class Tr{static extension={type:[t.Ag.WebGLPipes,t.Ag.WebGPUPipes,t.Ag.CanvasPipes],name:"spine"};renderer;gpuSpineData={};_destroyRenderableBound=this.destroyRenderable.bind(this);constructor(t){this.renderer=t}validateRenderable(t){if(t._validateAndTransformAttachments(),t.spineAttachmentsDirty)return!0;if(t.spineTexturesDirty){const e=t.skeleton.drawOrder,r=this.gpuSpineData[t.uid];for(let s=0,i=e.length;s<i;s++){const i=e[s],n=i.getAttachment();if(n instanceof Qe||n instanceof Ke){const e=t._getCachedData(i,n),s=r.slotBatches[e.id],o=e.texture;if(o!==s.texture&&!s._batcher.checkAndUpdateTexture(s,o))return!0}}}return!1}addRenderable(t,e){const r=this._getSpineData(t),s=this.renderer.renderPipes.batch,i=t.skeleton.drawOrder,n=this.renderer._roundPixels|t._roundPixels;t._validateAndTransformAttachments(),t.spineAttachmentsDirty=!1,t.spineTexturesDirty=!1;for(let o=0,a=i.length;o<a;o++){const a=i[o],l=a.getAttachment(),h=wr[a.data.blendMode];if(l instanceof Qe||l instanceof Ke){const i=t._getCachedData(a,l),o=r.slotBatches[i.id]||=new br;o.setData(t,i,h,n),i.skipRender||s.addToBatch(o,e)}const c=t._slotsObject[a.data.name];if(c){const t=c.container;t.includeInBuild=!0,t.collectRenderables(e,this.renderer,null),t.includeInBuild=!1}}}updateRenderable(t){const e=this.gpuSpineData[t.uid];t._validateAndTransformAttachments(),t.spineAttachmentsDirty=!1,t.spineTexturesDirty=!1;const r=t.skeleton.drawOrder;for(let s=0,i=r.length;s<i;s++){const i=r[s],n=i.getAttachment();if((n instanceof Qe||n instanceof Ke)&&!t._getCachedData(i,n).skipRender){const r=e.slotBatches[t._getCachedData(i,n).id];r._batcher?.updateElement(r)}}}destroyRenderable(t){this.gpuSpineData[t.uid]=null,t.off("destroyed",this._destroyRenderableBound)}destroy(){this.gpuSpineData=null,this.renderer=null}_getSpineData(t){return this.gpuSpineData[t.uid]||this._initMeshData(t)}_initMeshData(t){return this.gpuSpineData[t.uid]={slotBatches:{}},t.on("destroyed",this._destroyRenderableBound),this.gpuSpineData[t.uid]}}t.XO.add(Tr),new Pe,nr.yDown=!0,new ar,new Ce(()=>new Nt.A),zt.l,r(8714),new class extends he{async doLoad(t){const e=new Promise(e=>{const r=new Image;r.crossOrigin="anonymous",r.src=t,r.onload=()=>{if(this.loadingPromises.delete(t),this.hasActiveRef(t)){if(this.cachedAssets.has(t))return console.error(`Dom texture already loaded: ${t}`),void e(void 0);this.cachedAssets.set(t,r),e(r)}else e(void 0)},r.onerror=r=>{this.loadingPromises.delete(t),console.error(`Failed to load dom texture: ${t}`,r),e(void 0)}});return this.loadingPromises.set(t,e),await e}cleanup(t,e){e.remove()}},new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]),Jt=!0;const Sr=new class extends Kt{container;#W;#H=new ae(t=>this.#X(t));camera=new ee;fpsDisplay;#V;#Y;#j;#$;#q={};_isSizeDirty=!1;canvasWidth=0;canvasHeight=0;canvasLeft=0;canvasTop=0;viewportScale=1;centerX=0;centerY=0;constructor(t,e){if(super(new Lt.mc({sortableChildren:!0})),this.container=t,this.renderer=this,this.worldTransform.x.v=0,this.worldTransform.y.v=0,this.worldTransform.resetDirty(),this.#W=new re(t),this.#W.on("resize",(t,e)=>this.#K(t,e)),this.camera.on("positionChanged",()=>this.#Z()),this.camera.on("scaleChanged",()=>this.#Z()),e&&(void 0!==e.logicalWidth&&(this.#V=e.logicalWidth),void 0!==e.logicalHeight&&(this.#Y=e.logicalHeight),void 0!==e.backgroundColor&&(this.#j=e.backgroundColor),e.layers))for(const t of e.layers){const e=new oe(t.drawOrder);this._pixiContainer.addChild(e._pixiContainer),this.#q[t.name]=e}Jt&&(this.fpsDisplay=new ne(t));const r=this.container.getBoundingClientRect();this.#K(r.width,r.height),this.init()}async init(){const t=await async function(t){let e,s=[];t.preference?(s.push(t.preference),Bt.forEach(e=>{e!==t.preference&&s.push(e)})):s=Bt.slice();let i={};for(let n=0;n<s.length;n++){const o=s[n];if("webgpu"===o&&await kt()){const{WebGPURenderer:s}=await Promise.resolve().then(r.bind(r,8628));e=s,i={...t,...t.webgpu};break}if("webgl"===o&&Rt(t.failIfMajorPerformanceCaveat??Pt.k.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:s}=await Promise.resolve().then(r.bind(r,7722));e=s,i={...t,...t.webgl};break}if("canvas"===o)throw i={...t},new Error("CanvasRenderer is not yet implemented")}if(delete i.webgpu,delete i.webgl,!e)throw new Error("No available renderer for the current environment");const n=new e;return await n.init(i),n}({width:this.#V,height:this.#Y,backgroundColor:this.#j,eventMode:"none",resolution:window.devicePixelRatio});te(t.canvas,{position:"absolute",touchAction:"auto"}),this.container.appendChild(t.canvas),this.#$=t}#Z(){const t=this.camera.scale;this._pixiContainer.scale=t,this._pixiContainer.position.set(this.centerX-this.camera.x*t,this.centerY-this.camera.y*t)}#K(t,e){const r=this.#V??t,s=this.#Y??e;this.canvasWidth=r,this.canvasHeight=s,this.centerX=r/2,this.centerY=s/2,this.#Z();const i=Math.min(t/r,e/s);this.viewportScale=i;const n=r*i,o=s*i,a=(t-n)/2,l=(e-o)/2;this.canvasLeft=a,this.canvasTop=l,this.#$&&(this.#$.resize(r,s),te(this.#$.canvas,{width:`${n}px`,height:`${o}px`,left:`${a}px`,top:`${l}px`}),this.emit("resize",r,s)),this._isSizeDirty=!0}#X(t){this._isSizeDirty=!1,this.update(t),this._updateWorldTransform(),this.#$?.render(this._pixiContainer),this.fpsDisplay?.update()}_addToLayer(t,e){const r=this.#q[e];if(!r)throw new Error(`Layer ${e} does not exist.`);r._pixiContainer.addChild(t._pixiContainer)}remove(){this.#W.remove(),this.#H.remove(),this.#$?.destroy(),this.fpsDisplay?.remove(),super.remove()}screenToWorld(t,e){return{x:(t-this.canvasLeft)/this.viewportScale-this.canvasWidth/2,y:(e-this.canvasTop)/this.viewportScale-this.canvasHeight/2}}}(document.body,{logicalWidth:800,logicalHeight:600,backgroundColor:"#304C79"}),Ar=document.createElement("div");Ar.textContent="Hello World",Ar.style.color="red",Ar.onclick=()=>alert("click");const Cr=new class extends Qt{#Q;constructor(t,e){super(e),t.style.position="absolute",t.style.left="0",t.style.top="0",t.style.zIndex="1",this.#Q=t}#J(){const t=this.renderer;if(t){const e=this.worldTransform,r=t.viewportScale;this.#Q.style.transform=`\n translate(\n calc(-50% + ${e.x.v*r+t.canvasLeft+t.centerX*r}px),\n calc(-50% + ${e.y.v*r+t.canvasTop+t.centerY*r}px)\n )\n scale(${e.scaleX.v*r}, ${e.scaleY.v*r})\n rotate(${e.rotation.v}rad)\n `}}set renderer(t){super.renderer=t,t&&(t.container.appendChild(this.#Q),this.#J())}get renderer(){return super.renderer}update(t){super.update(t);const e=this.renderer;e&&(e._isSizeDirty||this.worldTransform.dirty)&&this.#J(),this.worldAlpha.dirty&&(this.#Q.style.opacity=this.worldAlpha.v.toString())}remove(){this.#Q.remove(),super.remove()}}(Ar);Cr.alpha=.5,Sr.add(Cr),Sr.on("update",t=>{Cr.rotation+=t})})()})();