@vpmedia/phaser 1.123.0 → 1.125.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (221) hide show
  1. package/dist/index.js +635 -623
  2. package/dist/index.js.map +1 -1
  3. package/dist/phaser/core/animation.d.ts +3 -3
  4. package/dist/phaser/core/animation.d.ts.map +1 -1
  5. package/dist/phaser/core/animation_manager.d.ts.map +1 -1
  6. package/dist/phaser/core/animation_parser.d.ts +27 -2
  7. package/dist/phaser/core/animation_parser.d.ts.map +1 -1
  8. package/dist/phaser/core/array_set.d.ts +11 -11
  9. package/dist/phaser/core/array_set.d.ts.map +1 -1
  10. package/dist/phaser/core/cache.d.ts.map +1 -1
  11. package/dist/phaser/core/callback.d.ts.map +1 -1
  12. package/dist/phaser/core/dom.d.ts +125 -19
  13. package/dist/phaser/core/dom.d.ts.map +1 -1
  14. package/dist/phaser/core/factory.d.ts +3 -2
  15. package/dist/phaser/core/factory.d.ts.map +1 -1
  16. package/dist/phaser/core/frame_data.d.ts.map +1 -1
  17. package/dist/phaser/core/input.d.ts +3 -2
  18. package/dist/phaser/core/input.d.ts.map +1 -1
  19. package/dist/phaser/core/input_handler.d.ts.map +1 -1
  20. package/dist/phaser/core/input_mouse.d.ts +5 -1
  21. package/dist/phaser/core/input_mouse.d.ts.map +1 -1
  22. package/dist/phaser/core/input_pointer.d.ts +3 -3
  23. package/dist/phaser/core/input_pointer.d.ts.map +1 -1
  24. package/dist/phaser/core/input_touch.d.ts +8 -8
  25. package/dist/phaser/core/input_touch.d.ts.map +1 -1
  26. package/dist/phaser/core/loader.d.ts +11 -2
  27. package/dist/phaser/core/loader.d.ts.map +1 -1
  28. package/dist/phaser/core/loader_parser.d.ts +14 -1
  29. package/dist/phaser/core/loader_parser.d.ts.map +1 -1
  30. package/dist/phaser/core/raf.d.ts +1 -1
  31. package/dist/phaser/core/raf.d.ts.map +1 -1
  32. package/dist/phaser/core/scale_manager.d.ts.map +1 -1
  33. package/dist/phaser/core/scene_manager.d.ts.map +1 -1
  34. package/dist/phaser/core/signal.d.ts.map +1 -1
  35. package/dist/phaser/core/sound.d.ts.map +1 -1
  36. package/dist/phaser/core/sound_manager.d.ts +1 -1
  37. package/dist/phaser/core/sound_manager.d.ts.map +1 -1
  38. package/dist/phaser/core/stage.d.ts +16 -6
  39. package/dist/phaser/core/stage.d.ts.map +1 -1
  40. package/dist/phaser/core/time.d.ts.map +1 -1
  41. package/dist/phaser/core/timer.d.ts +1 -1
  42. package/dist/phaser/core/timer.d.ts.map +1 -1
  43. package/dist/phaser/core/tween.d.ts +13 -5
  44. package/dist/phaser/core/tween.d.ts.map +1 -1
  45. package/dist/phaser/core/tween_data.d.ts +9 -7
  46. package/dist/phaser/core/tween_data.d.ts.map +1 -1
  47. package/dist/phaser/core/tween_manager.d.ts.map +1 -1
  48. package/dist/phaser/display/button.d.ts +6 -5
  49. package/dist/phaser/display/button.d.ts.map +1 -1
  50. package/dist/phaser/display/canvas/buffer.d.ts +1 -1
  51. package/dist/phaser/display/canvas/buffer.d.ts.map +1 -1
  52. package/dist/phaser/display/canvas/masker.d.ts +1 -1
  53. package/dist/phaser/display/canvas/masker.d.ts.map +1 -1
  54. package/dist/phaser/display/canvas/pool.d.ts +2 -2
  55. package/dist/phaser/display/canvas/pool.d.ts.map +1 -1
  56. package/dist/phaser/display/canvas/renderer.d.ts +9 -8
  57. package/dist/phaser/display/canvas/renderer.d.ts.map +1 -1
  58. package/dist/phaser/display/display_object.d.ts +5 -3
  59. package/dist/phaser/display/display_object.d.ts.map +1 -1
  60. package/dist/phaser/display/graphics.d.ts +1 -1
  61. package/dist/phaser/display/graphics.d.ts.map +1 -1
  62. package/dist/phaser/display/group.d.ts +1 -1
  63. package/dist/phaser/display/group.d.ts.map +1 -1
  64. package/dist/phaser/display/image.d.ts +6 -5
  65. package/dist/phaser/display/image.d.ts.map +1 -1
  66. package/dist/phaser/display/sprite_util.d.ts +3 -2
  67. package/dist/phaser/display/sprite_util.d.ts.map +1 -1
  68. package/dist/phaser/display/text.d.ts +2 -16
  69. package/dist/phaser/display/text.d.ts.map +1 -1
  70. package/dist/phaser/display/webgl/abstract_filter.d.ts +14 -8
  71. package/dist/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
  72. package/dist/phaser/display/webgl/blend_manager.d.ts +2 -3
  73. package/dist/phaser/display/webgl/blend_manager.d.ts.map +1 -1
  74. package/dist/phaser/display/webgl/earcut.d.ts.map +1 -1
  75. package/dist/phaser/display/webgl/fast_sprite_batch.d.ts +11 -5
  76. package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
  77. package/dist/phaser/display/webgl/filter_manager.d.ts +6 -4
  78. package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
  79. package/dist/phaser/display/webgl/filter_texture.d.ts +4 -4
  80. package/dist/phaser/display/webgl/filter_texture.d.ts.map +1 -1
  81. package/dist/phaser/display/webgl/graphics.d.ts +2 -2
  82. package/dist/phaser/display/webgl/graphics.d.ts.map +1 -1
  83. package/dist/phaser/display/webgl/mask_manager.d.ts +3 -2
  84. package/dist/phaser/display/webgl/mask_manager.d.ts.map +1 -1
  85. package/dist/phaser/display/webgl/render_texture.d.ts +11 -8
  86. package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
  87. package/dist/phaser/display/webgl/renderer.d.ts +8 -4
  88. package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
  89. package/dist/phaser/display/webgl/shader/normal.d.ts +28 -3
  90. package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
  91. package/dist/phaser/display/webgl/sprite_batch.d.ts +6 -5
  92. package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
  93. package/dist/phaser/display/webgl/stencil_manager.d.ts +3 -3
  94. package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
  95. package/dist/phaser/display/webgl/texture.d.ts.map +1 -1
  96. package/dist/phaser/display/webgl/texture_util.d.ts +2 -2
  97. package/dist/phaser/display/webgl/texture_util.d.ts.map +1 -1
  98. package/dist/phaser/display/webgl/util.d.ts +1 -1
  99. package/dist/phaser/display/webgl/util.d.ts.map +1 -1
  100. package/dist/phaser/geom/circle.d.ts.map +1 -1
  101. package/dist/phaser/geom/line.d.ts +10 -1
  102. package/dist/phaser/geom/line.d.ts.map +1 -1
  103. package/dist/phaser/geom/rectangle.d.ts.map +1 -1
  104. package/dist/phaser/geom/util/circle.d.ts +2 -1
  105. package/dist/phaser/geom/util/circle.d.ts.map +1 -1
  106. package/dist/phaser/geom/util/point.d.ts +1 -1
  107. package/dist/phaser/geom/util/point.d.ts.map +1 -1
  108. package/dist/phaser/geom/util/rectangle.d.ts +1 -1
  109. package/dist/phaser/geom/util/rectangle.d.ts.map +1 -1
  110. package/dist/phaser/util/math.d.ts.map +1 -1
  111. package/package.json +1 -1
  112. package/src/phaser/core/animation.ts +11 -11
  113. package/src/phaser/core/animation_manager.ts +12 -12
  114. package/src/phaser/core/animation_parser.ts +39 -37
  115. package/src/phaser/core/array_set.ts +28 -28
  116. package/src/phaser/core/cache.test.ts +33 -33
  117. package/src/phaser/core/cache.ts +7 -7
  118. package/src/phaser/core/callback.ts +1 -0
  119. package/src/phaser/core/callback_context.test.ts +8 -8
  120. package/src/phaser/core/device_util.ts +4 -4
  121. package/src/phaser/core/dom.ts +38 -24
  122. package/src/phaser/core/factory.ts +9 -2
  123. package/src/phaser/core/frame_data.test.ts +23 -23
  124. package/src/phaser/core/frame_data.ts +2 -5
  125. package/src/phaser/core/game.ts +12 -12
  126. package/src/phaser/core/input.ts +11 -10
  127. package/src/phaser/core/input_handler.test.ts +18 -18
  128. package/src/phaser/core/input_handler.ts +14 -14
  129. package/src/phaser/core/input_mouse.ts +13 -12
  130. package/src/phaser/core/input_pointer.test.ts +26 -26
  131. package/src/phaser/core/input_pointer.ts +4 -4
  132. package/src/phaser/core/input_touch.ts +8 -8
  133. package/src/phaser/core/loader.test.ts +26 -26
  134. package/src/phaser/core/loader.ts +63 -75
  135. package/src/phaser/core/loader_parser.test.ts +16 -16
  136. package/src/phaser/core/loader_parser.ts +16 -6
  137. package/src/phaser/core/raf.ts +1 -1
  138. package/src/phaser/core/registry.test.ts +6 -6
  139. package/src/phaser/core/scale_manager.ts +12 -11
  140. package/src/phaser/core/scene_manager.test.ts +30 -30
  141. package/src/phaser/core/scene_manager.ts +3 -3
  142. package/src/phaser/core/signal.test.ts +8 -8
  143. package/src/phaser/core/signal.ts +3 -3
  144. package/src/phaser/core/signal_dispatch.test.ts +30 -30
  145. package/src/phaser/core/sound.ts +45 -40
  146. package/src/phaser/core/sound_manager.ts +18 -22
  147. package/src/phaser/core/sound_sprite.ts +1 -1
  148. package/src/phaser/core/stage.ts +22 -12
  149. package/src/phaser/core/time.ts +1 -1
  150. package/src/phaser/core/timer.test.ts +47 -47
  151. package/src/phaser/core/timer.ts +2 -2
  152. package/src/phaser/core/tween.ts +34 -36
  153. package/src/phaser/core/tween_data.test.ts +119 -0
  154. package/src/phaser/core/tween_data.ts +54 -39
  155. package/src/phaser/core/tween_easing.test.ts +5 -5
  156. package/src/phaser/core/tween_manager.ts +2 -2
  157. package/src/phaser/display/bitmap_text.test.ts +30 -30
  158. package/src/phaser/display/bitmap_text.ts +3 -3
  159. package/src/phaser/display/button.ts +20 -18
  160. package/src/phaser/display/canvas/buffer.ts +2 -2
  161. package/src/phaser/display/canvas/graphics.ts +2 -2
  162. package/src/phaser/display/canvas/masker.ts +1 -1
  163. package/src/phaser/display/canvas/pool.test.ts +20 -20
  164. package/src/phaser/display/canvas/pool.ts +6 -6
  165. package/src/phaser/display/canvas/renderer.ts +18 -16
  166. package/src/phaser/display/canvas/tinter.ts +1 -1
  167. package/src/phaser/display/canvas/util.test.ts +25 -25
  168. package/src/phaser/display/canvas/util.ts +2 -2
  169. package/src/phaser/display/display_object.ts +16 -15
  170. package/src/phaser/display/graphics.test.ts +70 -20
  171. package/src/phaser/display/graphics.ts +46 -42
  172. package/src/phaser/display/group.ts +13 -12
  173. package/src/phaser/display/image.ts +35 -31
  174. package/src/phaser/display/sprite_util.ts +4 -3
  175. package/src/phaser/display/text.test.ts +28 -25
  176. package/src/phaser/display/text.ts +56 -62
  177. package/src/phaser/display/webgl/abstract_filter.ts +21 -11
  178. package/src/phaser/display/webgl/blend_manager.ts +4 -5
  179. package/src/phaser/display/webgl/earcut.test.ts +20 -20
  180. package/src/phaser/display/webgl/earcut.ts +46 -42
  181. package/src/phaser/display/webgl/fast_sprite_batch.ts +21 -16
  182. package/src/phaser/display/webgl/filter_manager.ts +7 -4
  183. package/src/phaser/display/webgl/filter_texture.ts +5 -5
  184. package/src/phaser/display/webgl/graphics.ts +3 -3
  185. package/src/phaser/display/webgl/mask_manager.ts +9 -14
  186. package/src/phaser/display/webgl/render_texture.ts +15 -14
  187. package/src/phaser/display/webgl/renderer.ts +10 -9
  188. package/src/phaser/display/webgl/shader/normal.ts +45 -35
  189. package/src/phaser/display/webgl/shader/shader.test.ts +24 -24
  190. package/src/phaser/display/webgl/shader_manager.test.ts +18 -18
  191. package/src/phaser/display/webgl/shader_manager.ts +1 -1
  192. package/src/phaser/display/webgl/sprite_batch.ts +10 -10
  193. package/src/phaser/display/webgl/stencil_manager.ts +4 -4
  194. package/src/phaser/display/webgl/texture.ts +2 -1
  195. package/src/phaser/display/webgl/texture_util.ts +2 -2
  196. package/src/phaser/display/webgl/util.ts +4 -4
  197. package/src/phaser/geom/circle.test.ts +38 -38
  198. package/src/phaser/geom/circle.ts +7 -7
  199. package/src/phaser/geom/ellipse.test.ts +12 -12
  200. package/src/phaser/geom/line.test.ts +15 -15
  201. package/src/phaser/geom/line.ts +5 -2
  202. package/src/phaser/geom/matrix.test.ts +31 -31
  203. package/src/phaser/geom/point.test.ts +31 -31
  204. package/src/phaser/geom/polygon.test.ts +27 -27
  205. package/src/phaser/geom/polygon.ts +2 -2
  206. package/src/phaser/geom/rectangle.test.ts +87 -87
  207. package/src/phaser/geom/rectangle.ts +12 -13
  208. package/src/phaser/geom/rounded_rectangle.test.ts +9 -9
  209. package/src/phaser/geom/util/circle.test.ts +5 -5
  210. package/src/phaser/geom/util/circle.ts +8 -11
  211. package/src/phaser/geom/util/ellipse.test.ts +2 -2
  212. package/src/phaser/geom/util/line.test.ts +2 -2
  213. package/src/phaser/geom/util/matrix.test.ts +4 -4
  214. package/src/phaser/geom/util/point.test.ts +2 -2
  215. package/src/phaser/geom/util/point.ts +6 -8
  216. package/src/phaser/geom/util/polygon.test.ts +2 -2
  217. package/src/phaser/geom/util/rectangle.test.ts +2 -2
  218. package/src/phaser/geom/util/rectangle.ts +1 -1
  219. package/src/phaser/geom/util/rounded_rectangle.test.ts +2 -2
  220. package/src/phaser/util/math.test.ts +41 -41
  221. package/src/phaser/util/math.ts +7 -5
package/dist/index.js CHANGED
@@ -128,11 +128,11 @@ const distance$1 = (a, b, round = false) => {
128
128
  * @returns {Point} The rotated point instance for chaining.
129
129
  */
130
130
  const rotate = (a, x, y, ang, asDegrees, dist) => {
131
- if (asDegrees) ang *= Math.PI / 180;
131
+ const radians = asDegrees ? ang * (Math.PI / 180) : ang;
132
132
  if (dist === void 0 || dist === null) {
133
133
  a.subtract(x, y);
134
- const s = Math.sin(ang);
135
- const c = Math.cos(ang);
134
+ const s = Math.sin(radians);
135
+ const c = Math.cos(radians);
136
136
  const tx = c * a.x - s * a.y;
137
137
  const ty = s * a.x + c * a.y;
138
138
  a.x = tx + x;
@@ -886,9 +886,8 @@ var Rectangle = class {
886
886
  * @returns {Rectangle} This rectangle instance for chaining.
887
887
  */
888
888
  scale(x, y) {
889
- y ??= x;
890
889
  this.width *= x;
891
- this.height *= y;
890
+ this.height *= y ?? x;
892
891
  return this;
893
892
  }
894
893
  /**
@@ -1342,9 +1341,7 @@ const between = (min, max) => Math.floor(Math.random() * (max - min + 1) + min);
1342
1341
  /** Snaps a value to the nearest multiple of gap, starting from start. */
1343
1342
  const snapToCeil = (input, gap = 0, start = 0) => {
1344
1343
  if (gap === 0) return input;
1345
- input -= start;
1346
- input = gap * Math.ceil(input / gap);
1347
- return start + input;
1344
+ return start + gap * Math.ceil((input - start) / gap);
1348
1345
  };
1349
1346
  /** Wraps a value within a range. */
1350
1347
  const wrap = (value, min, max) => {
@@ -1377,8 +1374,8 @@ const getColor32 = (a, r, g, b) => a << 24 | r << 16 | g << 8 | b;
1377
1374
  const getColor = (r, g, b) => r << 16 | g << 8 | b;
1378
1375
  /** Converts a hex color string to RGB components. */
1379
1376
  const hexToColor = (value, out) => {
1380
- value = value.replace(/^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i, (_m, r, g, b) => r + r + g + g + b + b);
1381
- const result = /^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(value);
1377
+ const expanded = value.replace(/^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i, (_match, r, g, b) => r + r + g + g + b + b);
1378
+ const result = /^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(expanded);
1382
1379
  if (result) {
1383
1380
  out.r = Number.parseInt(result[1], 16);
1384
1381
  out.g = Number.parseInt(result[2], 16);
@@ -1465,7 +1462,7 @@ const getPool = () => {
1465
1462
  */
1466
1463
  const getFirst = () => {
1467
1464
  const pool = getPool();
1468
- for (let i = 0; i < pool.length; i += 1) if (!pool[i].parent) return i;
1465
+ for (let i = 0; i < pool.length; i += 1) if (pool[i].parent === null) return i;
1469
1466
  return -1;
1470
1467
  };
1471
1468
  /**
@@ -1518,7 +1515,7 @@ const create$1 = (parent, width, height, skipPool = false) => {
1518
1515
  const { canvas } = entry;
1519
1516
  if (width !== void 0) {
1520
1517
  canvas.width = width;
1521
- canvas.height = height;
1518
+ canvas.height = height ?? 0;
1522
1519
  }
1523
1520
  return canvas;
1524
1521
  };
@@ -1631,7 +1628,7 @@ const canUseNewCanvasBlendModes = () => {
1631
1628
  context.globalCompositeOperation = "multiply";
1632
1629
  context.drawImage(magenta, 0, 0);
1633
1630
  context.drawImage(yellow, 2, 0);
1634
- if (!context.getImageData(2, 0, 1, 1)) return false;
1631
+ if (context.getImageData(2, 0, 1, 1) === null) return false;
1635
1632
  const { data } = context.getImageData(2, 0, 1, 1);
1636
1633
  try {
1637
1634
  context.reset();
@@ -1750,7 +1747,7 @@ const getSmoothingPrefix = (context) => {
1750
1747
  const smoothingFlags = context;
1751
1748
  for (const vendor of VENDORS) {
1752
1749
  const flag = `${vendor}mageSmoothingEnabled`;
1753
- if (smoothingFlags[flag]) return flag;
1750
+ if (smoothingFlags[flag] !== void 0) return flag;
1754
1751
  }
1755
1752
  return null;
1756
1753
  };
@@ -1918,7 +1915,7 @@ const renderCanvas = (target, renderSession, matrix = null) => {
1918
1915
  if (target.texture.valid) {
1919
1916
  const resolution = target.texture.baseTexture.resolution / renderSession.resolution;
1920
1917
  renderSession.context.globalAlpha = target.worldAlpha;
1921
- if (renderSession.smoothProperty && renderSession.scaleMode !== target.texture.baseTexture.scaleMode) {
1918
+ if (renderSession.smoothProperty !== null && renderSession.scaleMode !== target.texture.baseTexture.scaleMode) {
1922
1919
  renderSession.scaleMode = target.texture.baseTexture.scaleMode;
1923
1920
  setSmoothing(renderSession.context, renderSession.smoothProperty, renderSession.scaleMode === 0);
1924
1921
  }
@@ -2061,8 +2058,10 @@ var DisplayObject = class {
2061
2058
  }
2062
2059
  /**
2063
2060
  * Destroys this display object and cleans up resources.
2061
+ * @param {boolean} _destroyChildren - Whether the subclass should destroy its children too.
2062
+ * @param {boolean} _destroyTexture - Whether the subclass should destroy its texture too.
2064
2063
  */
2065
- destroy() {
2064
+ destroy(_destroyChildren = true, _destroyTexture = false) {
2066
2065
  if (this.children) {
2067
2066
  let i = this.children.length;
2068
2067
  while (i) {
@@ -2186,11 +2185,11 @@ var DisplayObject = class {
2186
2185
  * @throws {Error} If the range is invalid.
2187
2186
  */
2188
2187
  removeChildren(beginIndex, endIndex) {
2189
- beginIndex ??= 0;
2190
- endIndex ??= this.children.length;
2191
- const range = endIndex - beginIndex;
2192
- if (range > 0 && range <= endIndex) {
2193
- const removed = this.children.splice(beginIndex, range);
2188
+ const begin = beginIndex ?? 0;
2189
+ const end = endIndex ?? this.children.length;
2190
+ const range = end - begin;
2191
+ if (range > 0 && range <= end) {
2192
+ const removed = this.children.splice(begin, range);
2194
2193
  for (const child of removed) child.parent = null;
2195
2194
  return removed;
2196
2195
  }
@@ -2438,9 +2437,9 @@ var DisplayObject = class {
2438
2437
  * @returns {Point} The converted local position.
2439
2438
  */
2440
2439
  toLocal(position, from) {
2441
- if (from) position = from.toGlobal(position);
2440
+ const global = from ? from.toGlobal(position) : position;
2442
2441
  this.updateTransform();
2443
- return this.worldTransform.applyInverse(position);
2442
+ return this.worldTransform.applyInverse(global);
2444
2443
  }
2445
2444
  /**
2446
2445
  * Renders a cached sprite for this display object.
@@ -2884,14 +2883,14 @@ var Signal = class {
2884
2883
  let n = this._bindings.length;
2885
2884
  while (n) {
2886
2885
  n -= 1;
2887
- if (context) {
2886
+ if (context !== null) {
2888
2887
  if (this._bindings[n].context === context) {
2889
2888
  this._bindings[n]._destroy();
2890
2889
  this._bindings.splice(n, 1);
2891
2890
  }
2892
2891
  } else this._bindings[n]._destroy();
2893
2892
  }
2894
- if (!context) this._bindings.length = 0;
2893
+ if (context === null) this._bindings.length = 0;
2895
2894
  }
2896
2895
  /**
2897
2896
  * Get the number of listeners registered with the signal.
@@ -3117,7 +3116,7 @@ var Animation = class {
3117
3116
  if (useLocalFrameIndex) frameIndex = frameId;
3118
3117
  else for (let i = 0; i < this._frames.length; i += 1) if (this._frames[i] === frameId) frameIndex = i;
3119
3118
  }
3120
- if (frameIndex) {
3119
+ if (frameIndex !== void 0 && frameIndex !== 0) {
3121
3120
  this._frameIndex = frameIndex - 1;
3122
3121
  this._timeNextFrame = this.game.time.time;
3123
3122
  this.update();
@@ -3134,7 +3133,7 @@ var Animation = class {
3134
3133
  this.paused = false;
3135
3134
  if (resetFrame) {
3136
3135
  this.currentFrame = this._frameData.getFrame(this._frames[0]);
3137
- if (this.currentFrame) this._parent.setFrame(this.currentFrame);
3136
+ if (this.currentFrame !== null) this._parent.setFrame(this.currentFrame);
3138
3137
  }
3139
3138
  if (dispatchComplete) {
3140
3139
  this._parent.events.onAnimationComplete$dispatch(this._parent, this);
@@ -3175,7 +3174,7 @@ var Animation = class {
3175
3174
  this._frameIndex = Math.abs(this._frameIndex) % this._frames.length;
3176
3175
  if (this.isReversed) this._frameIndex = this._frames.length - 1 - this._frameIndex;
3177
3176
  this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
3178
- if (this.currentFrame) this._parent.setFrame(this.currentFrame);
3177
+ if (this.currentFrame !== null) this._parent.setFrame(this.currentFrame);
3179
3178
  this.loopCount += 1;
3180
3179
  this._parent.events.onAnimationLoop$dispatch(this._parent, this);
3181
3180
  this.onLoop.dispatch(this._parent, this);
@@ -3199,10 +3198,10 @@ var Animation = class {
3199
3198
  * @returns {boolean} True if the frame was updated, false otherwise.
3200
3199
  */
3201
3200
  updateCurrentFrame(signalUpdate, fromPlay = false) {
3202
- if (!this._frameData || !this.currentFrame) return false;
3201
+ if (!this._frameData || this.currentFrame === null) return false;
3203
3202
  const idx = this.currentFrame.index;
3204
3203
  this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
3205
- if (this.currentFrame && (fromPlay || !fromPlay && idx !== this.currentFrame.index)) this._parent.setFrame(this.currentFrame);
3204
+ if (this.currentFrame !== null && (fromPlay || idx !== this.currentFrame.index)) this._parent.setFrame(this.currentFrame);
3206
3205
  if (this.onUpdate && signalUpdate) {
3207
3206
  this.onUpdate.dispatch(this, this.currentFrame);
3208
3207
  return Boolean(this._frameData);
@@ -3597,7 +3596,7 @@ var AnimationManager = class {
3597
3596
  set frame(value) {
3598
3597
  if (typeof value === "number" && this._frameData && this._frameData.getFrame(value) !== null) {
3599
3598
  this.currentFrame = this._frameData.getFrame(value);
3600
- if (this.currentFrame) this.sprite.setFrame(this.currentFrame);
3599
+ if (this.currentFrame !== null) this.sprite.setFrame(this.currentFrame);
3601
3600
  } else this.game.logger.fatal("AnimationManager", {
3602
3601
  error: /* @__PURE__ */ new Error(ENGINE_ERROR_CANNOT_SET_FRAME),
3603
3602
  tags: { "asset.key": value }
@@ -3617,7 +3616,7 @@ var AnimationManager = class {
3617
3616
  set frameName(value) {
3618
3617
  if (typeof value === "string" && this._frameData && this._frameData.getFrameByName(value) !== null) {
3619
3618
  this.currentFrame = this._frameData.getFrameByName(value);
3620
- if (this.currentFrame) {
3619
+ if (this.currentFrame !== null) {
3621
3620
  this._frameIndex = this.currentFrame.index;
3622
3621
  this.sprite.setFrame(this.currentFrame);
3623
3622
  }
@@ -3884,7 +3883,7 @@ var Texture = class Texture {
3884
3883
  this.valid = false;
3885
3884
  return;
3886
3885
  }
3887
- this.valid = Boolean(frame && frame.width && frame.height && this.baseTexture.source && this.baseTexture.hasLoaded);
3886
+ this.valid = frame.width !== 0 && frame.height !== 0 && this.baseTexture.source !== null && this.baseTexture.hasLoaded;
3888
3887
  if (this.trim) {
3889
3888
  this.width = this.trim.width;
3890
3889
  this.height = this.trim.height;
@@ -3912,6 +3911,152 @@ var Texture = class Texture {
3912
3911
  }
3913
3912
  };
3914
3913
  //#endregion
3914
+ //#region src/phaser/core/frame_data.ts
3915
+ var FrameData = class {
3916
+ _frames;
3917
+ _frameNames;
3918
+ constructor() {
3919
+ this._frames = [];
3920
+ this._frameNames = {};
3921
+ }
3922
+ addFrame(frame) {
3923
+ frame.index = this._frames.length;
3924
+ this._frames.push(frame);
3925
+ if (frame.name !== "") this._frameNames[frame.name] = frame.index;
3926
+ return frame;
3927
+ }
3928
+ getFrame(index = 0) {
3929
+ return this._frames[index >= this._frames.length ? 0 : index];
3930
+ }
3931
+ getFrameByName(name) {
3932
+ const index = this._frameNames[name];
3933
+ if (typeof index === "number") return this._frames[index] ?? null;
3934
+ return null;
3935
+ }
3936
+ checkFrameName(name) {
3937
+ if (this._frameNames[name] == null) return false;
3938
+ return true;
3939
+ }
3940
+ clone() {
3941
+ return cloneFrameData(this);
3942
+ }
3943
+ getFrameRange(start, end, output = null) {
3944
+ const result = output ?? [];
3945
+ for (let i = start; i <= end; i += 1) result.push(this._frames[i]);
3946
+ return result;
3947
+ }
3948
+ getFrameIndexes(frames, useNumericIndex = true, output = null) {
3949
+ const result = output ?? [];
3950
+ if (frames.length > 0) for (const f of frames) if (useNumericIndex && this._frames[f]) result.push(this._frames[f].index);
3951
+ else {
3952
+ const found = this.getFrameByName(f);
3953
+ if (found) result.push(found.index);
3954
+ }
3955
+ else for (const frame of this._frames) result.push(frame.index);
3956
+ return result;
3957
+ }
3958
+ destroy() {
3959
+ this._frames = null;
3960
+ this._frameNames = null;
3961
+ }
3962
+ get total() {
3963
+ return this._frames.length;
3964
+ }
3965
+ };
3966
+ //#endregion
3967
+ //#region src/phaser/core/frame_util.ts
3968
+ const cloneFrame = (frame, output = null) => {
3969
+ const result = output ?? new Frame(frame.index, frame.x, frame.y, frame.width, frame.height);
3970
+ result.initialize(frame.index, frame.x, frame.y, frame.width, frame.height);
3971
+ return result;
3972
+ };
3973
+ const cloneFrameData = (frameData, output = null) => {
3974
+ const result = output ?? new FrameData();
3975
+ for (let i = 0; i < frameData.total; i += 1) result.addFrame(frameData.getFrame(i).clone());
3976
+ return result;
3977
+ };
3978
+ //#endregion
3979
+ //#region src/phaser/core/frame.ts
3980
+ var Frame = class {
3981
+ index;
3982
+ x;
3983
+ y;
3984
+ width;
3985
+ height;
3986
+ name;
3987
+ centerX;
3988
+ centerY;
3989
+ distance;
3990
+ rotated;
3991
+ rotationDirection;
3992
+ trimmed;
3993
+ sourceSizeW;
3994
+ sourceSizeH;
3995
+ spriteSourceSizeX;
3996
+ spriteSourceSizeY;
3997
+ spriteSourceSizeW;
3998
+ spriteSourceSizeH;
3999
+ right;
4000
+ bottom;
4001
+ constructor(index, x, y, width, height, name) {
4002
+ this.initialize(index, x, y, width, height, name);
4003
+ }
4004
+ initialize(index, x, y, width, height, name) {
4005
+ this.index = index;
4006
+ this.x = x;
4007
+ this.y = y;
4008
+ this.width = width;
4009
+ this.height = height;
4010
+ this.name = name;
4011
+ this.centerX = Math.floor(width / 2);
4012
+ this.centerY = Math.floor(height / 2);
4013
+ this.distance = distance(0, 0, width, height);
4014
+ this.rotated = false;
4015
+ this.rotationDirection = "cw";
4016
+ this.trimmed = false;
4017
+ this.sourceSizeW = width;
4018
+ this.sourceSizeH = height;
4019
+ this.spriteSourceSizeX = 0;
4020
+ this.spriteSourceSizeY = 0;
4021
+ this.spriteSourceSizeW = 0;
4022
+ this.spriteSourceSizeH = 0;
4023
+ this.right = this.x + this.width;
4024
+ this.bottom = this.y + this.height;
4025
+ }
4026
+ resize(width, height) {
4027
+ this.width = width;
4028
+ this.height = height;
4029
+ this.centerX = Math.floor(width / 2);
4030
+ this.centerY = Math.floor(height / 2);
4031
+ this.distance = distance(0, 0, width, height);
4032
+ this.sourceSizeW = width;
4033
+ this.sourceSizeH = height;
4034
+ this.right = this.x + width;
4035
+ this.bottom = this.y + height;
4036
+ }
4037
+ setTrim(trimmed, actualWidth, actualHeight, destX, destY, destWidth, destHeight) {
4038
+ this.trimmed = trimmed;
4039
+ if (trimmed) {
4040
+ this.sourceSizeW = actualWidth;
4041
+ this.sourceSizeH = actualHeight;
4042
+ this.centerX = Math.floor(actualWidth / 2);
4043
+ this.centerY = Math.floor(actualHeight / 2);
4044
+ this.spriteSourceSizeX = destX;
4045
+ this.spriteSourceSizeY = destY;
4046
+ this.spriteSourceSizeW = destWidth;
4047
+ this.spriteSourceSizeH = destHeight;
4048
+ }
4049
+ }
4050
+ clone() {
4051
+ return cloneFrame(this);
4052
+ }
4053
+ getRect(output = null) {
4054
+ const result = output ?? new Rectangle();
4055
+ result.setTo(this.x, this.y, this.width, this.height);
4056
+ return result;
4057
+ }
4058
+ };
4059
+ //#endregion
3915
4060
  //#region src/phaser/display/image.ts
3916
4061
  var Image$1 = class extends DisplayObject {
3917
4062
  key;
@@ -4000,7 +4145,7 @@ var Image$1 = class extends DisplayObject {
4000
4145
  this.destroy();
4001
4146
  return;
4002
4147
  }
4003
- if (!this.exists || !this.parent?.exists) {
4148
+ if (!this.exists || this.parent?.exists !== true) {
4004
4149
  this.renderOrderID = -1;
4005
4150
  return;
4006
4151
  }
@@ -4054,18 +4199,19 @@ var Image$1 = class extends DisplayObject {
4054
4199
  this.texture.crop.y = frame.y;
4055
4200
  this.texture.crop.width = frame.width;
4056
4201
  this.texture.crop.height = frame.height;
4057
- if (frame.trimmed) {
4202
+ const trimmed = frame instanceof Frame && frame.trimmed ? frame : null;
4203
+ if (trimmed) {
4058
4204
  if (this.texture.trim) {
4059
- this.texture.trim.x = frame.spriteSourceSizeX;
4060
- this.texture.trim.y = frame.spriteSourceSizeY;
4061
- this.texture.trim.width = frame.sourceSizeW;
4062
- this.texture.trim.height = frame.sourceSizeH;
4063
- } else this.texture.trim = new Rectangle(frame.spriteSourceSizeX, frame.spriteSourceSizeY, frame.sourceSizeW, frame.sourceSizeH);
4064
- this.texture.width = frame.sourceSizeW;
4065
- this.texture.height = frame.sourceSizeH;
4066
- this.texture.frame.width = frame.sourceSizeW;
4067
- this.texture.frame.height = frame.sourceSizeH;
4068
- } else if (!frame.trimmed && this.texture.trim) this.texture.trim = null;
4205
+ this.texture.trim.x = trimmed.spriteSourceSizeX;
4206
+ this.texture.trim.y = trimmed.spriteSourceSizeY;
4207
+ this.texture.trim.width = trimmed.sourceSizeW;
4208
+ this.texture.trim.height = trimmed.sourceSizeH;
4209
+ } else this.texture.trim = new Rectangle(trimmed.spriteSourceSizeX, trimmed.spriteSourceSizeY, trimmed.sourceSizeW, trimmed.sourceSizeH);
4210
+ this.texture.width = trimmed.sourceSizeW;
4211
+ this.texture.height = trimmed.sourceSizeH;
4212
+ this.texture.frame.width = trimmed.sourceSizeW;
4213
+ this.texture.frame.height = trimmed.sourceSizeH;
4214
+ } else if (this.texture.trim) this.texture.trim = null;
4069
4215
  if (this.cropRect) this.updateCrop();
4070
4216
  this.texture.requiresReTint = true;
4071
4217
  this.texture._updateUvs();
@@ -4141,13 +4287,14 @@ var Image$1 = class extends DisplayObject {
4141
4287
  const oldY = this.texture.crop.y;
4142
4288
  const oldW = this.texture.crop.width;
4143
4289
  const oldH = this.texture.crop.height;
4290
+ const frame = this._frame;
4144
4291
  this._crop = clone$5(this.cropRect, this._crop);
4145
- this._crop.x += this._frame.x;
4146
- this._crop.y += this._frame.y;
4147
- const cx = Math.max(this._frame.x, this._crop.x);
4148
- const cy = Math.max(this._frame.y, this._crop.y);
4149
- const cw = Math.min(this._frame.right, this._crop.right) - cx;
4150
- const ch = Math.min(this._frame.bottom, this._crop.bottom) - cy;
4292
+ this._crop.x += frame.x;
4293
+ this._crop.y += frame.y;
4294
+ const cx = Math.max(frame.x, this._crop.x);
4295
+ const cy = Math.max(frame.y, this._crop.y);
4296
+ const cw = Math.min(frame.right, this._crop.right) - cx;
4297
+ const ch = Math.min(frame.bottom, this._crop.bottom) - cy;
4151
4298
  this.texture.crop.x = cx;
4152
4299
  this.texture.crop.y = cy;
4153
4300
  this.texture.crop.width = cw;
@@ -4298,7 +4445,7 @@ var BitmapText = class extends DisplayObject {
4298
4445
  this.destroy();
4299
4446
  return;
4300
4447
  }
4301
- if (!this.exists || !this.parent?.exists) {
4448
+ if (!this.exists || this.parent?.exists !== true) {
4302
4449
  this.renderOrderID = -1;
4303
4450
  return;
4304
4451
  }
@@ -4353,7 +4500,7 @@ var BitmapText = class extends DisplayObject {
4353
4500
  wrappedWidth = w;
4354
4501
  }
4355
4502
  c = (kerning + (charData.texture?.width ?? 0) + charData.xOffset) * scale;
4356
- if (maxWidth && w + c >= maxWidth && lastSpace > -1) return {
4503
+ if (maxWidth !== null && w + c >= maxWidth && lastSpace > -1) return {
4357
4504
  width: wrappedWidth || w,
4358
4505
  text: text.slice(0, lastSpace),
4359
4506
  end,
@@ -4616,7 +4763,7 @@ var BitmapText = class extends DisplayObject {
4616
4763
  * @returns {boolean} True if smoothing is enabled, false otherwise.
4617
4764
  */
4618
4765
  get smoothed() {
4619
- return !this._data?.base.scaleMode;
4766
+ return this._data?.base.scaleMode === 0;
4620
4767
  }
4621
4768
  /**
4622
4769
  * Sets whether smoothing is enabled for this bitmap text's font.
@@ -4802,7 +4949,7 @@ var InputHandler = class {
4802
4949
  * TBD.
4803
4950
  */
4804
4951
  destroy() {
4805
- if (this.sprite) {
4952
+ if (this.sprite !== null) {
4806
4953
  if (this._setHandCursor) {
4807
4954
  this.game.canvas.style.cursor = "default";
4808
4955
  this._setHandCursor = false;
@@ -4939,7 +5086,7 @@ var InputHandler = class {
4939
5086
  * @returns {boolean} TBD.
4940
5087
  */
4941
5088
  checkPointerDown(pointer, fastTest = false) {
4942
- if (!pointer.isDown || !this.enabled || !this.sprite || !this.sprite.parent || !this.sprite.visible || !this.sprite.parent.visible || this.sprite.worldScale.x === 0 || this.sprite.worldScale.y === 0) return false;
5089
+ if (!pointer.isDown || !this.enabled || this.sprite === null || !this.sprite.parent || !this.sprite.visible || !this.sprite.parent.visible || this.sprite.worldScale.x === 0 || this.sprite.worldScale.y === 0) return false;
4943
5090
  if (this.game.input.hitTest(this.sprite, pointer, this._tempPoint)) {
4944
5091
  if (!fastTest && this.pixelPerfectClick) return this.checkPixel(this._tempPoint.x, this._tempPoint.y);
4945
5092
  return true;
@@ -4953,7 +5100,7 @@ var InputHandler = class {
4953
5100
  * @returns {boolean} TBD.
4954
5101
  */
4955
5102
  checkPointerOver(pointer, fastTest = false) {
4956
- if (!this.enabled || !this.sprite || !this.sprite.parent || !this.sprite.visible || !this.sprite.parent.visible || this.sprite.worldScale.x === 0 || this.sprite.worldScale.y === 0) return false;
5103
+ if (!this.enabled || this.sprite === null || !this.sprite.parent || !this.sprite.visible || !this.sprite.parent.visible || this.sprite.worldScale.x === 0 || this.sprite.worldScale.y === 0) return false;
4957
5104
  if (this.game.input.hitTest(this.sprite, pointer, this._tempPoint)) {
4958
5105
  if (!fastTest && this.pixelPerfectOver) return this.checkPixel(this._tempPoint.x, this._tempPoint.y);
4959
5106
  return true;
@@ -5003,7 +5150,7 @@ var InputHandler = class {
5003
5150
  */
5004
5151
  update(pointer) {
5005
5152
  if (this.sprite === null || this.sprite.parent === void 0) return false;
5006
- if (!this.enabled || !this.sprite.visible || !this.sprite.parent?.visible) {
5153
+ if (!this.enabled || !this.sprite.visible || this.sprite.parent?.visible !== true) {
5007
5154
  this._pointerOutHandler(pointer);
5008
5155
  return false;
5009
5156
  }
@@ -5042,7 +5189,7 @@ var InputHandler = class {
5042
5189
  this.game.canvas.style.cursor = "pointer";
5043
5190
  this._setHandCursor = true;
5044
5191
  }
5045
- if (!silent && sendEvent && this.sprite && this.sprite.events) this.sprite.events.onInputOver$dispatch(this.sprite, pointer);
5192
+ if (!silent && sendEvent && this.sprite !== null) this.sprite.events.onInputOver$dispatch(this.sprite, pointer);
5046
5193
  if (this.sprite.parent && this.sprite.parent.type === 7) this.sprite.parent.onChildInputOver.dispatch(this.sprite, pointer);
5047
5194
  }
5048
5195
  }
@@ -5061,9 +5208,9 @@ var InputHandler = class {
5061
5208
  this.game.canvas.style.cursor = "default";
5062
5209
  this._setHandCursor = false;
5063
5210
  }
5064
- if (!silent && this.sprite && this.sprite.events) {
5211
+ if (!silent && this.sprite !== null) {
5065
5212
  this.sprite.events.onInputOut$dispatch(this.sprite, pointer);
5066
- if (this.sprite && this.sprite.parent && this.sprite.parent.type === 7) this.sprite.parent.onChildInputOut.dispatch(this.sprite, pointer);
5213
+ if (this.sprite?.parent?.type === 7) this.sprite.parent.onChildInputOut.dispatch(this.sprite, pointer);
5067
5214
  }
5068
5215
  }
5069
5216
  /**
@@ -5080,9 +5227,9 @@ var InputHandler = class {
5080
5227
  data.timeDown = this.game.time.time;
5081
5228
  this.downPoint.setTo(pointer.x, pointer.y);
5082
5229
  pointer.dirty = true;
5083
- if (this.sprite && this.sprite.events) {
5230
+ if (this.sprite !== null) {
5084
5231
  this.sprite.events.onInputDown$dispatch(this.sprite, pointer);
5085
- if (this.sprite && this.sprite.parent && this.sprite.parent.type === 7) this.sprite.parent.onChildInputDown.dispatch(this.sprite, pointer);
5232
+ if (this.sprite?.parent?.type === 7) this.sprite.parent.onChildInputDown.dispatch(this.sprite, pointer);
5086
5233
  if (this.sprite === null) return;
5087
5234
  }
5088
5235
  if (this.draggable && !this.isDragged) {
@@ -5104,7 +5251,7 @@ var InputHandler = class {
5104
5251
  */
5105
5252
  dragTimeElapsed(pointer) {
5106
5253
  this._dragTimePass = true;
5107
- if (this._pendingDrag && this.sprite && this._dragDistancePass) this.startDrag(pointer);
5254
+ if (this._pendingDrag && this.sprite !== null && this._dragDistancePass) this.startDrag(pointer);
5108
5255
  }
5109
5256
  /**
5110
5257
  * TBD.
@@ -5119,9 +5266,9 @@ var InputHandler = class {
5119
5266
  data.timeUp = this.game.time.time;
5120
5267
  data.downDuration = data.timeUp - data.timeDown;
5121
5268
  let isOver = this.checkPointerOver(pointer);
5122
- if (this.sprite && this.sprite.events) {
5269
+ if (this.sprite !== null) {
5123
5270
  if (!this.dragStopBlocksInputUp || this.dragStopBlocksInputUp && !(this.draggable && this.isDragged && this._draggedPointerID === pointer.id)) this.sprite.events.onInputUp$dispatch(this.sprite, pointer, isOver);
5124
- if (this.sprite && this.sprite.parent && this.sprite.parent.type === 7) this.sprite.parent.onChildInputUp.dispatch(this.sprite, pointer, isOver);
5271
+ if (this.sprite?.parent?.type === 7) this.sprite.parent.onChildInputUp.dispatch(this.sprite, pointer, isOver);
5125
5272
  if (isOver) isOver = this.checkPointerOver(pointer);
5126
5273
  }
5127
5274
  data.isOver = isOver;
@@ -5238,7 +5385,7 @@ var InputHandler = class {
5238
5385
  * TBD.
5239
5386
  */
5240
5387
  disableDrag() {
5241
- if (this._pointerData) for (let i = 0; i < 10; i += 1) this.pointerData(i).isDragged = false;
5388
+ if (this._pointerData.length > 0) for (let i = 0; i < 10; i += 1) this.pointerData(i).isDragged = false;
5242
5389
  this.draggable = false;
5243
5390
  this.isDragged = false;
5244
5391
  this._draggedPointerID = -1;
@@ -5423,7 +5570,7 @@ var Button = class extends Image$1 {
5423
5570
  this._onDownFrame = null;
5424
5571
  this._onUpFrame = null;
5425
5572
  this._onDisabledFrame = null;
5426
- if (this.onInputOver) {
5573
+ if (this.onInputOver !== null) {
5427
5574
  this.onInputOver.dispose();
5428
5575
  this.onInputOut.dispose();
5429
5576
  this.onInputDown.dispose();
@@ -5433,7 +5580,7 @@ var Button = class extends Image$1 {
5433
5580
  this.onInputOut = null;
5434
5581
  this.onInputDown = null;
5435
5582
  this.onInputUp = null;
5436
- if (this.input) this.input.destroy();
5583
+ if (this.input !== null) this.input.destroy();
5437
5584
  this.input = null;
5438
5585
  super.destroy();
5439
5586
  }
@@ -5469,7 +5616,7 @@ var Button = class extends Image$1 {
5469
5616
  */
5470
5617
  setStateFrame(state, frame, switchImmediately = false) {
5471
5618
  const frameKey = `_on${state}Frame`;
5472
- if (frame) {
5619
+ if (frame !== null) {
5473
5620
  this[frameKey] = frame;
5474
5621
  if (switchImmediately) this.changeStateFrame(state);
5475
5622
  } else this[frameKey] = null;
@@ -5481,7 +5628,7 @@ var Button = class extends Image$1 {
5481
5628
  */
5482
5629
  changeStateFrame(newState) {
5483
5630
  if (this.freezeFrames) return false;
5484
- const frameKey = `_on${this.input.enabled || !this._onDisabledFrame ? newState : STATE_DISABLED}Frame`;
5631
+ const frameKey = `_on${this.input.enabled || this._onDisabledFrame === null ? newState : STATE_DISABLED}Frame`;
5485
5632
  const frame = this[frameKey];
5486
5633
  if (typeof frame === "string") {
5487
5634
  this.frameName = frame;
@@ -5505,7 +5652,7 @@ var Button = class extends Image$1 {
5505
5652
  this.setStateFrame(STATE_OUT, outFrame, !this.input.pointerOver());
5506
5653
  this.setStateFrame(STATE_DOWN, downFrame, this.input.pointerDown());
5507
5654
  this.setStateFrame(STATE_UP, upFrame, this.input.pointerUp());
5508
- if (disabledFrame) this.setStateFrame(STATE_DISABLED, disabledFrame, !this.input.enabled);
5655
+ if (disabledFrame !== null) this.setStateFrame(STATE_DISABLED, disabledFrame, !this.input.enabled);
5509
5656
  }
5510
5657
  /**
5511
5658
  * Handles the input over event for this button.
@@ -5516,7 +5663,7 @@ var Button = class extends Image$1 {
5516
5663
  if (pointer.justReleased() && (this.justReleasedPreventsOver & pointer.pointerMode) === pointer.pointerMode) return;
5517
5664
  this.changeStateFrame(STATE_OVER);
5518
5665
  if (this.onOverMouseOnly && !pointer.isMouse) return;
5519
- if (this.onInputOver) this.onInputOver.dispatch(this, pointer);
5666
+ if (this.onInputOver !== null) this.onInputOver.dispatch(this, pointer);
5520
5667
  }
5521
5668
  /**
5522
5669
  * Handles the input out event for this button.
@@ -5525,7 +5672,7 @@ var Button = class extends Image$1 {
5525
5672
  */
5526
5673
  onInputOutHandler(_sprite, pointer) {
5527
5674
  this.changeStateFrame(STATE_OUT);
5528
- if (this.onInputOut) this.onInputOut.dispatch(this, pointer);
5675
+ if (this.onInputOut !== null) this.onInputOut.dispatch(this, pointer);
5529
5676
  }
5530
5677
  /**
5531
5678
  * Handles the input down event for this button.
@@ -5534,7 +5681,7 @@ var Button = class extends Image$1 {
5534
5681
  */
5535
5682
  onInputDownHandler(_sprite, pointer) {
5536
5683
  this.changeStateFrame(STATE_DOWN);
5537
- if (this.onInputDown) this.onInputDown.dispatch(this, pointer);
5684
+ if (this.onInputDown !== null) this.onInputDown.dispatch(this, pointer);
5538
5685
  }
5539
5686
  /**
5540
5687
  * Handles the input up event for this button.
@@ -5543,9 +5690,10 @@ var Button = class extends Image$1 {
5543
5690
  * @param {boolean} isOver - Whether the pointer is currently over the button (default: true).
5544
5691
  */
5545
5692
  onInputUpHandler(_sprite, pointer, isOver) {
5546
- if (this.onInputUp) this.onInputUp.dispatch(this, pointer, isOver);
5693
+ if (this.onInputUp !== null) this.onInputUp.dispatch(this, pointer, isOver);
5547
5694
  if (this.freezeFrames) return;
5548
- if (this.forceOut === true || (this.forceOut & pointer.pointerMode) === pointer.pointerMode) this.changeStateFrame(STATE_OUT);
5695
+ const forcedOutMode = typeof this.forceOut === "number" ? this.forceOut : 0;
5696
+ if (this.forceOut === true || (forcedOutMode & pointer.pointerMode) === pointer.pointerMode) this.changeStateFrame(STATE_OUT);
5549
5697
  else if (!this.changeStateFrame(STATE_UP)) {
5550
5698
  if (isOver) this.changeStateFrame(STATE_OVER);
5551
5699
  else this.changeStateFrame(STATE_OUT);
@@ -5556,7 +5704,7 @@ var Button = class extends Image$1 {
5556
5704
  * @returns {boolean} True if input is enabled, false otherwise.
5557
5705
  */
5558
5706
  get inputEnabled() {
5559
- return this.input && this.input.enabled;
5707
+ return this.input !== null && this.input.enabled;
5560
5708
  }
5561
5709
  /**
5562
5710
  * Sets whether input is currently enabled for this button.
@@ -5567,8 +5715,8 @@ var Button = class extends Image$1 {
5567
5715
  if (this.input === null) {
5568
5716
  this.input = new InputHandler(this);
5569
5717
  this.input.start();
5570
- } else if (this.input && !this.input.enabled) this.input.start();
5571
- } else if (this.input && this.input.enabled) this.input.stop();
5718
+ } else if (this.input !== null && !this.input.enabled) this.input.start();
5719
+ } else if (this.input !== null && this.input.enabled) this.input.stop();
5572
5720
  }
5573
5721
  };
5574
5722
  //#endregion
@@ -5607,9 +5755,9 @@ const contains$1 = (a, x, y) => {
5607
5755
  */
5608
5756
  const circumferencePoint = (a, angle, asDegrees = false, output = null) => {
5609
5757
  const result = output ?? new Point();
5610
- if (asDegrees) angle = degToRad(angle);
5611
- result.x = a.x + a.radius * Math.cos(angle);
5612
- result.y = a.y + a.radius * Math.sin(angle);
5758
+ const radians = asDegrees ? degToRad(angle) : angle;
5759
+ result.x = a.x + a.radius * Math.cos(radians);
5760
+ result.y = a.y + a.radius * Math.sin(radians);
5613
5761
  return result;
5614
5762
  };
5615
5763
  //#endregion
@@ -6035,7 +6183,7 @@ var Polygon = class {
6035
6183
  this.flattened = false;
6036
6184
  /** @type {number} */
6037
6185
  this.type = 12;
6038
- if (points) this.setTo(points);
6186
+ if (points !== null) this.setTo(points);
6039
6187
  }
6040
6188
  /**
6041
6189
  * Converts the polygon's points to a number array.
@@ -6105,7 +6253,7 @@ var Polygon = class {
6105
6253
  this.area = 0;
6106
6254
  const vertices = [];
6107
6255
  this._points = vertices;
6108
- if (points) {
6256
+ if (points.length > 0) {
6109
6257
  if (!Array.isArray(points)) console.error("[Polygon] setTo() error, input parameter is not an array", points);
6110
6258
  let y0 = Number.MAX_VALUE;
6111
6259
  for (let i = 0, len = points.length; i < len; i += 1) {
@@ -6317,7 +6465,7 @@ const renderGraphics$1 = (graphics, context) => {
6317
6465
  context.stroke();
6318
6466
  }
6319
6467
  } else if (shape instanceof Rectangle) {
6320
- if (data.fillColor || data.fillColor === 0) {
6468
+ if (data.fillColor !== null) {
6321
6469
  context.globalAlpha = data.fillAlpha * worldAlpha;
6322
6470
  context.fillStyle = `#${`00000${Math.trunc(fillColor ?? 0).toString(16)}`.slice(-6)}`;
6323
6471
  context.fillRect(shape.x, shape.y, shape.width, shape.height);
@@ -6389,7 +6537,7 @@ const renderGraphics$1 = (graphics, context) => {
6389
6537
  context.lineTo(rx + radius, ry);
6390
6538
  context.quadraticCurveTo(rx, ry, rx, ry + radius);
6391
6539
  context.closePath();
6392
- if (data.fillColor || data.fillColor === 0) {
6540
+ if (data.fillColor !== null) {
6393
6541
  context.globalAlpha = data.fillAlpha * worldAlpha;
6394
6542
  context.fillStyle = `#${`00000${Math.trunc(fillColor ?? 0).toString(16)}`.slice(-6)}`;
6395
6543
  context.fill();
@@ -6556,10 +6704,11 @@ var Node = class {
6556
6704
  function sortLinked(list) {
6557
6705
  let numMerges;
6558
6706
  let inSize = 1;
6707
+ let sorted = list;
6559
6708
  do {
6560
- let p = list;
6709
+ let p = sorted;
6561
6710
  let tail = null;
6562
- list = null;
6711
+ sorted = null;
6563
6712
  numMerges = 0;
6564
6713
  while (p) {
6565
6714
  numMerges += 1;
@@ -6593,7 +6742,7 @@ function sortLinked(list) {
6593
6742
  qSize -= 1;
6594
6743
  }
6595
6744
  if (tail) tail.nextZ = e;
6596
- else list = e;
6745
+ else sorted = e;
6597
6746
  e.prevZ = tail;
6598
6747
  tail = e;
6599
6748
  }
@@ -6602,7 +6751,7 @@ function sortLinked(list) {
6602
6751
  if (tail) tail.nextZ = null;
6603
6752
  inSize *= 2;
6604
6753
  } while (numMerges > 1);
6605
- return list;
6754
+ return sorted;
6606
6755
  }
6607
6756
  /**
6608
6757
  * Calculates the area of a triangle defined by three points.
@@ -6623,17 +6772,17 @@ function compareX(a, b) {
6623
6772
  * @returns {number} The calculated distance from the point to the triangle edge.
6624
6773
  */
6625
6774
  function zOrder(x, y, minX, minY, size) {
6626
- x = 32767 * (x - minX) / size;
6627
- y = 32767 * (y - minY) / size;
6628
- x = (x | x << 8) & 16711935;
6629
- x = (x | x << 4) & 252645135;
6630
- x = (x | x << 2) & 858993459;
6631
- x = (x | x << 1) & 1431655765;
6632
- y = (y | y << 8) & 16711935;
6633
- y = (y | y << 4) & 252645135;
6634
- y = (y | y << 2) & 858993459;
6635
- y = (y | y << 1) & 1431655765;
6636
- return x | y << 1;
6775
+ let ix = 32767 * (x - minX) / size;
6776
+ let iy = 32767 * (y - minY) / size;
6777
+ ix = (ix | ix << 8) & 16711935;
6778
+ ix = (ix | ix << 4) & 252645135;
6779
+ ix = (ix | ix << 2) & 858993459;
6780
+ ix = (ix | ix << 1) & 1431655765;
6781
+ iy = (iy | iy << 8) & 16711935;
6782
+ iy = (iy | iy << 4) & 252645135;
6783
+ iy = (iy | iy << 2) & 858993459;
6784
+ iy = (iy | iy << 1) & 1431655765;
6785
+ return ix | iy << 1;
6637
6786
  }
6638
6787
  /**
6639
6788
  * Calculates the orientation of three points (clockwise, counterclockwise, or collinear).
@@ -6892,7 +7041,7 @@ function linkedList(data, start, end, dim, clockwise) {
6892
7041
  */
6893
7042
  function filterPoints(start, end) {
6894
7043
  if (!start) return start;
6895
- end ??= start;
7044
+ let last = end ?? start;
6896
7045
  let p = start;
6897
7046
  let again;
6898
7047
  do {
@@ -6900,12 +7049,12 @@ function filterPoints(start, end) {
6900
7049
  if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {
6901
7050
  removeNode(p);
6902
7051
  p = p.prev;
6903
- end = p;
7052
+ last = p;
6904
7053
  if (p === p.next) return null;
6905
7054
  again = true;
6906
7055
  } else p = p.next;
6907
- } while (again || p !== end);
6908
- return end;
7056
+ } while (again || p !== last);
7057
+ return last;
6909
7058
  }
6910
7059
  /**
6911
7060
  * Calculates the minimum and maximum coordinates of a set of points.
@@ -6983,12 +7132,13 @@ function eliminateHoles(data, holeIndices, outerNode, dim) {
6983
7132
  queue.push(getLeftmost(list));
6984
7133
  }
6985
7134
  queue.sort(compareX);
7135
+ let outer = outerNode;
6986
7136
  for (i = 0; i < queue.length; i += 1) {
6987
- if (!outerNode) return outerNode;
6988
- eliminateHole(queue[i], outerNode);
6989
- outerNode = filterPoints(outerNode, outerNode.next);
7137
+ if (!outer) return outer;
7138
+ eliminateHole(queue[i], outer);
7139
+ outer = filterPoints(outer, outer.next);
6990
7140
  }
6991
- return outerNode;
7141
+ return outer;
6992
7142
  }
6993
7143
  /**
6994
7144
  * Calculates the centroid of a polygon.
@@ -6999,6 +7149,7 @@ function eliminateHoles(data, holeIndices, outerNode, dim) {
6999
7149
  */
7000
7150
  function cureLocalIntersections(start, triangles, dim) {
7001
7151
  let p = start;
7152
+ let first = start;
7002
7153
  do {
7003
7154
  const a = p.prev;
7004
7155
  const b = p.next.next;
@@ -7009,10 +7160,10 @@ function cureLocalIntersections(start, triangles, dim) {
7009
7160
  removeNode(p);
7010
7161
  removeNode(p.next);
7011
7162
  p = b;
7012
- start = p;
7163
+ first = p;
7013
7164
  }
7014
7165
  p = p.next;
7015
- } while (p !== start);
7166
+ } while (p !== first);
7016
7167
  return p;
7017
7168
  }
7018
7169
  /**
@@ -7054,28 +7205,29 @@ function splitEarcut(start, triangles, dim, minX = 0, minY = 0, size = 0) {
7054
7205
  */
7055
7206
  function earcutLinked(ear, triangles, dim, minX, minY, size, pass) {
7056
7207
  if (!ear) return;
7057
- if (!pass && size) indexCurve(ear, minX, minY, size);
7058
- let stop = ear;
7208
+ let current = ear;
7209
+ if (pass === void 0 && size !== void 0) indexCurve(current, minX, minY, size);
7210
+ let stop = current;
7059
7211
  let prev;
7060
7212
  let next;
7061
- while (ear.prev !== ear.next) {
7062
- ({prev, next} = ear);
7063
- if (size ? isEarHashed(ear, minX, minY, size) : isEar(ear)) {
7213
+ while (current.prev !== current.next) {
7214
+ ({prev, next} = current);
7215
+ if (size === void 0 ? isEar(current) : isEarHashed(current, minX, minY, size)) {
7064
7216
  triangles.push(prev.i / dim);
7065
- triangles.push(ear.i / dim);
7217
+ triangles.push(current.i / dim);
7066
7218
  triangles.push(next.i / dim);
7067
- removeNode(ear);
7068
- ear = next.next;
7219
+ removeNode(current);
7220
+ current = next.next;
7069
7221
  stop = next.next;
7070
7222
  continue;
7071
7223
  }
7072
- ear = next;
7073
- if (ear === stop) {
7074
- if (!pass) earcutLinked(filterPoints(ear), triangles, dim, minX, minY, size, 1);
7224
+ current = next;
7225
+ if (current === stop) {
7226
+ if (pass === void 0) earcutLinked(filterPoints(current), triangles, dim, minX, minY, size, 1);
7075
7227
  else if (pass === 1) {
7076
- ear = cureLocalIntersections(ear, triangles, dim);
7077
- earcutLinked(ear, triangles, dim, minX, minY, size, 2);
7078
- } else if (pass === 2) splitEarcut(ear, triangles, dim, minX, minY, size);
7228
+ current = cureLocalIntersections(current, triangles, dim);
7229
+ earcutLinked(current, triangles, dim, minX, minY, size, 2);
7230
+ } else if (pass === 2) splitEarcut(current, triangles, dim, minX, minY, size);
7079
7231
  break;
7080
7232
  }
7081
7233
  }
@@ -7585,7 +7737,7 @@ const buildPoly = (graphicsData, webGLData) => {
7585
7737
  const g = color[1] * alpha;
7586
7738
  const b = color[2] * alpha;
7587
7739
  const triangles = triangulate(points, null, 2);
7588
- if (!triangles) return false;
7740
+ if (triangles.length === 0) return false;
7589
7741
  const vertPos = verts.length / 6;
7590
7742
  for (let i = 0; i < triangles.length; i += 3) {
7591
7743
  indices.push(triangles[i] + vertPos);
@@ -7801,6 +7953,18 @@ const baseTextureFromCanvas = (canvas, scaleMode) => {
7801
7953
  const textureFromCanvas = (canvas, scaleMode) => new Texture(baseTextureFromCanvas(canvas, scaleMode));
7802
7954
  //#endregion
7803
7955
  //#region src/phaser/display/graphics.ts
7956
+ /**
7957
+ * Reports whether a triangle winds towards the viewer. In two dimensions the cross product is a
7958
+ * scalar, so its sign alone says which way the face points.
7959
+ * @param {Point[]} points - The three corners of the triangle, in order.
7960
+ * @returns {boolean} True when the triangle faces the viewer.
7961
+ */
7962
+ const isFrontFacing = (points) => {
7963
+ const [a, b, c] = points;
7964
+ if (!a || !b || !c) return true;
7965
+ const ab = new Point(b.x - a.x, b.y - a.y);
7966
+ return new Point(b.x - c.x, b.y - c.y).cross(ab) > 0;
7967
+ };
7804
7968
  var Graphics = class extends DisplayObject {
7805
7969
  fillAlpha;
7806
7970
  lineWidth;
@@ -8042,13 +8206,14 @@ var Graphics = class extends DisplayObject {
8042
8206
  */
8043
8207
  arc(cx, cy, radius, startAngle, endAngle, anticlockwise = false, segments = 40) {
8044
8208
  if (startAngle === endAngle) return this;
8045
- if (!anticlockwise && endAngle <= startAngle) endAngle += Math.PI * 2;
8046
- else if (anticlockwise && startAngle <= endAngle) startAngle += Math.PI * 2;
8047
- const sweep = anticlockwise ? (startAngle - endAngle) * -1 : endAngle - startAngle;
8209
+ const fullTurn = Math.PI * 2;
8210
+ const from = anticlockwise && startAngle <= endAngle ? startAngle + fullTurn : startAngle;
8211
+ const to = !anticlockwise && endAngle <= startAngle ? endAngle + fullTurn : endAngle;
8212
+ const sweep = anticlockwise ? (from - to) * -1 : to - from;
8048
8213
  const segs = Math.ceil(Math.abs(sweep) / (Math.PI * 2)) * segments;
8049
8214
  if (sweep === 0) return this;
8050
- const startX = cx + Math.cos(startAngle) * radius;
8051
- const startY = cy + Math.sin(startAngle) * radius;
8215
+ const startX = cx + Math.cos(from) * radius;
8216
+ const startY = cy + Math.sin(from) * radius;
8052
8217
  if (anticlockwise && this.filling) this.moveTo(cx, cy);
8053
8218
  else this.moveTo(startX, startY);
8054
8219
  const { points } = this.currentPath.shape;
@@ -8060,7 +8225,7 @@ var Graphics = class extends DisplayObject {
8060
8225
  const remainder = segMinus % 1 / segMinus;
8061
8226
  for (let i = 0; i <= segMinus; i += 1) {
8062
8227
  const real = i + remainder * i;
8063
- const angle = theta + startAngle + theta2 * real;
8228
+ const angle = theta + from + theta2 * real;
8064
8229
  const c = Math.cos(angle);
8065
8230
  const s = -Math.sin(angle);
8066
8231
  points.push((cTheta * c + sTheta * s) * radius + cx, (cTheta * -s + sTheta * c) * radius + cy);
@@ -8486,13 +8651,8 @@ var Graphics = class extends DisplayObject {
8486
8651
  */
8487
8652
  drawTriangle(points, cull = false) {
8488
8653
  const triangle = new Polygon(points);
8489
- if (cull) {
8490
- const [a, b, c] = points;
8491
- const cameraToFace = new Point(0 - a.x, 0 - a.y);
8492
- const ab = new Point(b.x - a.x, b.y - a.y);
8493
- const faceNormal = new Point(b.x - c.x, b.y - c.y).cross(ab);
8494
- if (cameraToFace.dot(faceNormal) > 0) this.drawPolygon(triangle);
8495
- } else this.drawPolygon(triangle);
8654
+ if (cull && !isFrontFacing(points)) return;
8655
+ this.drawPolygon(triangle);
8496
8656
  }
8497
8657
  /**
8498
8658
  * Draws triangles with the specified vertices and indices.
@@ -8501,46 +8661,41 @@ var Graphics = class extends DisplayObject {
8501
8661
  * @param {boolean} cull - Whether to perform backface culling.
8502
8662
  */
8503
8663
  drawTriangles(vertices, indices, cull = false) {
8504
- const point1 = new Point();
8505
- const point2 = new Point();
8506
- const point3 = new Point();
8507
8664
  let points = [];
8508
8665
  let i;
8509
- if (!indices) {
8510
- if (vertices[0] instanceof Point) for (i = 0; i < vertices.length / 3; i += 1) this.drawTriangle([
8511
- vertices[i * 3],
8512
- vertices[i * 3 + 1],
8513
- vertices[i * 3 + 2]
8514
- ], cull);
8515
- else for (i = 0; i < vertices.length / 6; i += 1) {
8516
- point1.x = vertices[i * 6 + 0];
8517
- point1.y = vertices[i * 6 + 1];
8518
- point2.x = vertices[i * 6 + 2];
8519
- point2.y = vertices[i * 6 + 3];
8520
- point3.x = vertices[i * 6 + 4];
8521
- point3.y = vertices[i * 6 + 5];
8522
- this.drawTriangle([
8523
- point1,
8524
- point2,
8525
- point3
8666
+ if (indices === null) {
8667
+ if (vertices[0] instanceof Point) {
8668
+ const corners = vertices;
8669
+ for (i = 0; i < corners.length / 3; i += 1) this.drawTriangle([
8670
+ corners[i * 3],
8671
+ corners[i * 3 + 1],
8672
+ corners[i * 3 + 2]
8673
+ ], cull);
8674
+ } else {
8675
+ const coordinates = vertices;
8676
+ for (i = 0; i < coordinates.length / 6; i += 1) this.drawTriangle([
8677
+ new Point(coordinates[i * 6 + 0], coordinates[i * 6 + 1]),
8678
+ new Point(coordinates[i * 6 + 2], coordinates[i * 6 + 3]),
8679
+ new Point(coordinates[i * 6 + 4], coordinates[i * 6 + 5])
8526
8680
  ], cull);
8527
8681
  }
8528
- } else if (vertices[0] instanceof Point) for (i = 0; i < indices.length / 3; i += 1) {
8529
- points.push(vertices[indices[i * 3]]);
8530
- points.push(vertices[indices[i * 3 + 1]]);
8531
- points.push(vertices[indices[i * 3 + 2]]);
8532
- if (points.length === 3) {
8533
- this.drawTriangle(points, cull);
8534
- points = [];
8682
+ } else if (vertices[0] instanceof Point) {
8683
+ const corners = vertices;
8684
+ for (i = 0; i < indices.length / 3; i += 1) {
8685
+ points.push(corners[indices[i * 3]], corners[indices[i * 3 + 1]], corners[indices[i * 3 + 2]]);
8686
+ if (points.length === 3) {
8687
+ this.drawTriangle(points, cull);
8688
+ points = [];
8689
+ }
8535
8690
  }
8536
- }
8537
- else for (i = 0; i < indices.length; i += 1) {
8538
- point1.x = vertices[indices[i] * 2];
8539
- point1.y = vertices[indices[i] * 2 + 1];
8540
- points.push(point1.copyTo({}));
8541
- if (points.length === 3) {
8542
- this.drawTriangle(points, cull);
8543
- points = [];
8691
+ } else {
8692
+ const coordinates = vertices;
8693
+ for (i = 0; i < indices.length; i += 1) {
8694
+ points.push(new Point(coordinates[indices[i] * 2], coordinates[indices[i] * 2 + 1]));
8695
+ if (points.length === 3) {
8696
+ this.drawTriangle(points, cull);
8697
+ points = [];
8698
+ }
8544
8699
  }
8545
8700
  }
8546
8701
  }
@@ -8572,7 +8727,7 @@ var Group = class extends DisplayObject {
8572
8727
  super(game);
8573
8728
  /** @type {number} */
8574
8729
  this.type = 7;
8575
- parent ??= game.world;
8730
+ const target = parent ?? game.world;
8576
8731
  /** @type {string} */
8577
8732
  this.name = name ?? "group";
8578
8733
  /** @type {number} */
@@ -8580,9 +8735,9 @@ var Group = class extends DisplayObject {
8580
8735
  if (addToStage) {
8581
8736
  this.game.stage.addChild(this);
8582
8737
  this.z = this.game.stage.children.length;
8583
- } else if (parent) {
8584
- parent.addChild(this);
8585
- this.z = parent.children.length;
8738
+ } else if (target) {
8739
+ target.addChild(this);
8740
+ this.z = target.children.length;
8586
8741
  }
8587
8742
  /** @type {boolean} */
8588
8743
  this.ignoreDestroy = false;
@@ -8643,7 +8798,7 @@ var Group = class extends DisplayObject {
8643
8798
  this.updateZ();
8644
8799
  }
8645
8800
  const inputChild = child;
8646
- if (this.inputEnableChildren && (!inputChild.input || inputChild.inputEnabled)) inputChild.inputEnabled = true;
8801
+ if (this.inputEnableChildren && (inputChild.input === void 0 || inputChild.inputEnabled === true)) inputChild.inputEnabled = true;
8647
8802
  if (!silent && child.events) child.events.onAddedToGroup$dispatch(child, this);
8648
8803
  this.cursor ??= child;
8649
8804
  return child;
@@ -8758,7 +8913,7 @@ var Group = class extends DisplayObject {
8758
8913
  this.destroy();
8759
8914
  return;
8760
8915
  }
8761
- if (!this.exists || !this.parent?.exists) {
8916
+ if (!this.exists || this.parent?.exists !== true) {
8762
8917
  this.renderOrderID = -1;
8763
8918
  return;
8764
8919
  }
@@ -8789,7 +8944,7 @@ var Group = class extends DisplayObject {
8789
8944
  */
8790
8945
  remove(child, destroy = true, silent = false) {
8791
8946
  if (this.children.length === 0 || !this.children.includes(child)) return false;
8792
- if (!silent && child.events && !child.destroyPhase) child.events.onRemovedFromGroup$dispatch(child, this);
8947
+ if (!silent && child.events) child.events.onRemovedFromGroup$dispatch(child, this);
8793
8948
  const removed = this.removeChild(child);
8794
8949
  this.updateZ();
8795
8950
  if (this.cursor === child) this.next();
@@ -8938,10 +9093,10 @@ var Text = class extends Image$1 {
8938
9093
  tabs: source.tabs ?? 0
8939
9094
  };
8940
9095
  const components = this.fontToComponents(resolved.font);
8941
- if (resolved.fontStyle) components.fontStyle = resolved.fontStyle;
8942
- if (resolved.fontVariant) components.fontVariant = resolved.fontVariant;
8943
- if (resolved.fontWeight) components.fontWeight = String(resolved.fontWeight);
8944
- if (resolved.fontSize) {
9096
+ if (resolved.fontStyle !== void 0 && resolved.fontStyle !== "") components.fontStyle = resolved.fontStyle;
9097
+ if (resolved.fontVariant !== void 0 && resolved.fontVariant !== "") components.fontVariant = resolved.fontVariant;
9098
+ if (resolved.fontWeight !== void 0 && resolved.fontWeight !== "") components.fontWeight = String(resolved.fontWeight);
9099
+ if (resolved.fontSize !== void 0 && resolved.fontSize !== "") {
8945
9100
  const fontSize = typeof resolved.fontSize === "number" ? `${resolved.fontSize}px` : resolved.fontSize;
8946
9101
  resolved.fontSize = fontSize;
8947
9102
  components.fontSize = fontSize;
@@ -8959,9 +9114,7 @@ var Text = class extends Image$1 {
8959
9114
  updateText() {
8960
9115
  this.texture.baseTexture.resolution = this._res;
8961
9116
  this.context.font = this.style.font;
8962
- let outputText = this.text;
8963
- if (this.style.wordWrap) outputText = this.runWordWrap(this.text);
8964
- const lines = outputText.split(/(?:\r\n|\r|\n)/);
9117
+ const lines = (this.style.wordWrap ? this.runWordWrap(this.text) : this.text).split(/(?:\r\n|\r|\n)/);
8965
9118
  const { tabs } = this.style;
8966
9119
  const lineWidths = [];
8967
9120
  let lineWidth = 0;
@@ -8972,17 +9125,19 @@ var Text = class extends Image$1 {
8972
9125
  if (this.style.maxLines > 0 && this.style.maxLines < lines.length) drawnLines = this.style.maxLines;
8973
9126
  this._charCount = 0;
8974
9127
  for (let i = 0; i < drawnLines; i += 1) {
9128
+ const currentLine = lines[i];
8975
9129
  if (tabs === 0) {
8976
9130
  lineWidth = this.style.strokeThickness + this.padding.x;
8977
- lineWidth += this.hasCharacterStyles() ? this.measureLine(lines[i]) : this.context.measureText(lines[i]).width;
9131
+ lineWidth += this.hasCharacterStyles() ? this.measureLine(currentLine) : this.context.measureText(currentLine).width;
8978
9132
  if (this.style.wordWrap) lineWidth -= this.context.measureText(" ").width;
8979
9133
  } else {
8980
- const line = lines[i].split(/(?:\t)/);
9134
+ const line = currentLine.split(/(?:\t)/);
8981
9135
  lineWidth = this.padding.x + this.style.strokeThickness;
8982
9136
  if (Array.isArray(tabs)) {
8983
9137
  let tab = 0;
8984
9138
  for (let c = 0; c < line.length; c += 1) {
8985
- const section = this.hasCharacterStyles() ? this.measureLine(line[c]) : Math.ceil(this.context.measureText(line[c]).width);
9139
+ const part = line[c];
9140
+ const section = this.hasCharacterStyles() ? this.measureLine(part) : Math.ceil(this.context.measureText(part).width);
8986
9141
  if (c > 0) tab += tabs[c - 1];
8987
9142
  lineWidth = tab + section;
8988
9143
  }
@@ -9003,7 +9158,7 @@ var Text = class extends Image$1 {
9003
9158
  if (lineSpacing !== 0) height += lineSpacing > 0 ? lineSpacing * lines.length : lineSpacing * (lines.length - 1);
9004
9159
  this.canvas.height = height * this._res;
9005
9160
  this.context.scale(this._res, this._res);
9006
- if (this.style.backgroundColor) {
9161
+ if (this.style.backgroundColor !== null && this.style.backgroundColor !== "") {
9007
9162
  this.context.fillStyle = this.style.backgroundColor;
9008
9163
  this.context.fillRect(0, 0, this.canvas.width, this.canvas.height);
9009
9164
  }
@@ -9018,6 +9173,7 @@ var Text = class extends Image$1 {
9018
9173
  let linePositionY;
9019
9174
  this._charCount = 0;
9020
9175
  for (let i = 0; i < drawnLines; i += 1) {
9176
+ const line = lines[i];
9021
9177
  linePositionX = this.style.strokeThickness / 2;
9022
9178
  linePositionY = this.style.strokeThickness / 2 + i * lineHeight + fontProperties.ascent;
9023
9179
  if (i > 0) linePositionY += lineSpacing * i;
@@ -9027,17 +9183,17 @@ var Text = class extends Image$1 {
9027
9183
  linePositionX = Math.round(linePositionX);
9028
9184
  linePositionY = Math.round(linePositionY);
9029
9185
  }
9030
- if (this.hasCharacterStyles()) this.updateLine(lines[i], linePositionX, linePositionY);
9186
+ if (this.hasCharacterStyles()) this.updateLine(line, linePositionX, linePositionY);
9031
9187
  else {
9032
9188
  if (this.style.stroke && this.style.strokeThickness) {
9033
9189
  this.updateShadow(this.style.shadowStroke ?? false);
9034
- if (tabs === 0) this.context.strokeText(lines[i], linePositionX, linePositionY);
9035
- else this.renderTabLine(lines[i], linePositionX, linePositionY, false);
9190
+ if (tabs === 0) this.context.strokeText(line, linePositionX, linePositionY);
9191
+ else this.renderTabLine(line, linePositionX, linePositionY, false);
9036
9192
  }
9037
9193
  if (this.style.fill) {
9038
9194
  this.updateShadow(this.style.shadowFill ?? false);
9039
- if (tabs === 0) this.context.fillText(lines[i], linePositionX, linePositionY);
9040
- else this.renderTabLine(lines[i], linePositionX, linePositionY, true);
9195
+ if (tabs === 0) this.context.fillText(line, linePositionX, linePositionY);
9196
+ else this.renderTabLine(line, linePositionX, linePositionY, true);
9041
9197
  }
9042
9198
  }
9043
9199
  }
@@ -9063,12 +9219,15 @@ var Text = class extends Image$1 {
9063
9219
  if (fill) this.context.fillText(text[c], snap, y);
9064
9220
  else this.context.strokeText(text[c], snap, y);
9065
9221
  }
9066
- } else for (const part of text) {
9067
- const section = Math.ceil(this.context.measureText(part).width);
9068
- snap = snapToCeil(x, tabs);
9069
- if (fill) this.context.fillText(part, snap, y);
9070
- else this.context.strokeText(part, snap, y);
9071
- x = snap + section;
9222
+ } else {
9223
+ let cursor = x;
9224
+ for (const part of text) {
9225
+ const section = Math.ceil(this.context.measureText(part).width);
9226
+ snap = snapToCeil(cursor, tabs);
9227
+ if (fill) this.context.fillText(part, snap, y);
9228
+ else this.context.strokeText(part, snap, y);
9229
+ cursor = snap + section;
9230
+ }
9072
9231
  }
9073
9232
  }
9074
9233
  /**
@@ -9107,18 +9266,18 @@ var Text = class extends Image$1 {
9107
9266
  const components = this.fontToComponents(this.context.font);
9108
9267
  const charFontStyle = this.fontStyles[this._charCount];
9109
9268
  const charFontWeight = this.fontWeights[this._charCount];
9110
- if (charFontStyle) components.fontStyle = charFontStyle;
9111
- if (charFontWeight) components.fontWeight = charFontWeight;
9269
+ if (charFontStyle !== void 0 && charFontStyle !== null && charFontStyle !== "") components.fontStyle = charFontStyle;
9270
+ if (charFontWeight !== void 0 && charFontWeight !== null && charFontWeight !== "") components.fontWeight = charFontWeight;
9112
9271
  this.context.font = this.componentsToFont(components);
9113
9272
  }
9114
9273
  if (this.style.stroke && this.style.strokeThickness) {
9115
9274
  const charStrokeColor = this.strokeColors[this._charCount];
9116
- if (charStrokeColor) this.context.strokeStyle = charStrokeColor;
9275
+ if (charStrokeColor !== void 0 && charStrokeColor !== null && charStrokeColor !== "") this.context.strokeStyle = charStrokeColor;
9117
9276
  this.updateShadow(this.style.shadowStroke ?? false);
9118
9277
  }
9119
9278
  if (this.style.fill) {
9120
9279
  const charFillColor = this.colors[this._charCount];
9121
- if (charFillColor) this.context.fillStyle = charFillColor;
9280
+ if (charFillColor !== void 0 && charFillColor !== null && charFillColor !== "") this.context.fillStyle = charFillColor;
9122
9281
  this.updateShadow(this.style.shadowFill ?? false);
9123
9282
  }
9124
9283
  lineLength += this.context.measureText(letter).width;
@@ -9133,28 +9292,29 @@ var Text = class extends Image$1 {
9133
9292
  * @param {number} y - The y position to start updating from.
9134
9293
  */
9135
9294
  updateLine(line, x, y) {
9295
+ let cursor = x;
9136
9296
  for (const letter of line) {
9137
9297
  if (this.fontWeights.length > 0 || this.fontStyles.length > 0) {
9138
9298
  const components = this.fontToComponents(this.context.font);
9139
9299
  const charFontStyle = this.fontStyles[this._charCount];
9140
9300
  const charFontWeight = this.fontWeights[this._charCount];
9141
- if (charFontStyle) components.fontStyle = charFontStyle;
9142
- if (charFontWeight) components.fontWeight = charFontWeight;
9301
+ if (charFontStyle !== void 0 && charFontStyle !== null && charFontStyle !== "") components.fontStyle = charFontStyle;
9302
+ if (charFontWeight !== void 0 && charFontWeight !== null && charFontWeight !== "") components.fontWeight = charFontWeight;
9143
9303
  this.context.font = this.componentsToFont(components);
9144
9304
  }
9145
9305
  if (this.style.stroke && this.style.strokeThickness) {
9146
9306
  const charStrokeColor = this.strokeColors[this._charCount];
9147
- if (charStrokeColor) this.context.strokeStyle = charStrokeColor;
9307
+ if (charStrokeColor !== void 0 && charStrokeColor !== null && charStrokeColor !== "") this.context.strokeStyle = charStrokeColor;
9148
9308
  this.updateShadow(this.style.shadowStroke ?? false);
9149
- this.context.strokeText(letter, x, y);
9309
+ this.context.strokeText(letter, cursor, y);
9150
9310
  }
9151
9311
  if (this.style.fill) {
9152
9312
  const charFillColor = this.colors[this._charCount];
9153
- if (charFillColor) this.context.fillStyle = charFillColor;
9313
+ if (charFillColor !== void 0 && charFillColor !== null && charFillColor !== "") this.context.fillStyle = charFillColor;
9154
9314
  this.updateShadow(this.style.shadowFill ?? false);
9155
- this.context.fillText(letter, x, y);
9315
+ this.context.fillText(letter, cursor, y);
9156
9316
  }
9157
- x += this.context.measureText(letter).width;
9317
+ cursor += this.context.measureText(letter).width;
9158
9318
  this._charCount += 1;
9159
9319
  }
9160
9320
  }
@@ -9362,18 +9522,15 @@ var Text = class extends Image$1 {
9362
9522
  */
9363
9523
  componentsToFont(components) {
9364
9524
  const parts = [];
9365
- let v;
9366
- v = components.fontStyle;
9367
- if (v && v !== "normal") parts.push(v);
9368
- v = components.fontVariant;
9369
- if (v && v !== "normal") parts.push(v);
9370
- v = components.fontWeight;
9371
- if (v && v !== "normal") parts.push(v);
9372
- v = components.fontSize;
9373
- if (v && v !== "medium") parts.push(v);
9374
- v = components.fontFamily;
9375
- if (v) parts.push(v);
9376
- if (parts.length === 0) parts.push(components.font);
9525
+ const push = (value, skip) => {
9526
+ if (value !== void 0 && value !== "" && value !== skip) parts.push(String(value));
9527
+ };
9528
+ push(components.fontStyle, "normal");
9529
+ push(components.fontVariant, "normal");
9530
+ push(components.fontWeight, "normal");
9531
+ push(components.fontSize, "medium");
9532
+ push(components.fontFamily, "");
9533
+ if (parts.length === 0) parts.push(components.font ?? "");
9377
9534
  return parts.join(" ");
9378
9535
  }
9379
9536
  /**
@@ -9396,12 +9553,15 @@ var Text = class extends Image$1 {
9396
9553
  parseList(list) {
9397
9554
  if (!Array.isArray(list)) return this;
9398
9555
  let s = "";
9399
- for (let i = 0; i < list.length; i += 1) if (Array.isArray(list[i])) {
9400
- s += list[i].join(" ");
9401
- if (i < list.length - 1) s += "\n";
9402
- } else {
9403
- s += list[i];
9404
- if (i < list.length - 1) s += " ";
9556
+ for (let i = 0; i < list.length; i += 1) {
9557
+ const row = list[i];
9558
+ if (Array.isArray(row)) {
9559
+ s += row.join(" ");
9560
+ if (i < list.length - 1) s += "\n";
9561
+ } else {
9562
+ s += row;
9563
+ if (i < list.length - 1) s += " ";
9564
+ }
9405
9565
  }
9406
9566
  this.text = s;
9407
9567
  this.dirty = true;
@@ -9501,7 +9661,7 @@ var Text = class extends Image$1 {
9501
9661
  * @returns {CanvasRenderingContext2D} The font properties canvas context.
9502
9662
  */
9503
9663
  getFontPropertiesContext() {
9504
- if (!globalThis.PhaserRegistry.fontPropertiesContext) {
9664
+ if (globalThis.PhaserRegistry.fontPropertiesContext === void 0) {
9505
9665
  const context = this.getFontPropertiesCanvas().getContext("2d", { willReadFrequently: true });
9506
9666
  if (!context) throw new Error(ENGINE_ERROR_CREATING_CANVAS_2D_CONTEXT);
9507
9667
  globalThis.PhaserRegistry.fontPropertiesContext = context;
@@ -9550,7 +9710,7 @@ var Text = class extends Image$1 {
9550
9710
  context.textBaseline = "alphabetic";
9551
9711
  context.fillStyle = "#000";
9552
9712
  context.fillText("|MÉq", 0, baseline);
9553
- if (!context.getImageData(0, 0, width, height)) {
9713
+ if (context.getImageData(0, 0, width, height) === null) {
9554
9714
  const fallback = {
9555
9715
  ascent: baseline,
9556
9716
  descent: baseline + 6,
@@ -9666,7 +9826,7 @@ var Text = class extends Image$1 {
9666
9826
  get fontSize() {
9667
9827
  const size = this._fontComponents.fontSize;
9668
9828
  if (typeof size === "number") return size;
9669
- if (size && /(?:^0$|px$)/.exec(size)) return Number.parseInt(size, 10);
9829
+ if (size !== void 0 && size !== "" && /(?:^0$|px$)/.exec(size)) return Number.parseInt(size, 10);
9670
9830
  return 0;
9671
9831
  }
9672
9832
  /**
@@ -10071,7 +10231,7 @@ var GameObjectFactory = class {
10071
10231
  * @param {Group} group - The parent group for the image.
10072
10232
  * @returns {Image} The created Image object.
10073
10233
  */
10074
- image(x, y, key, frame, group = null) {
10234
+ image(x, y, key, frame = null, group = null) {
10075
10235
  return (group ?? this.game.world).add(new Image$1(this.game, x, y, key, frame));
10076
10236
  }
10077
10237
  /**
@@ -10194,7 +10354,7 @@ var CanvasRenderer = class {
10194
10354
  this.type = 1;
10195
10355
  this.resolution = game.config.resolution;
10196
10356
  this.clearBeforeRender = game.config.clearBeforeRender;
10197
- this.transparent = game.config.transparent;
10357
+ this.transparent = Boolean(game.config.transparent);
10198
10358
  this.autoResize = false;
10199
10359
  this.contextLost = false;
10200
10360
  this.width = game.width * this.resolution;
@@ -10260,7 +10420,7 @@ var CanvasRenderer = class {
10260
10420
  this.view.style.width = `${this.width / this.resolution}px`;
10261
10421
  this.view.style.height = `${this.height / this.resolution}px`;
10262
10422
  }
10263
- if (this.renderSession.smoothProperty) setSmoothing(this.context, this.renderSession.smoothProperty, this.renderSession.scaleMode === 0);
10423
+ if (this.renderSession.smoothProperty !== null) setSmoothing(this.context, this.renderSession.smoothProperty, this.renderSession.scaleMode === 0);
10264
10424
  }
10265
10425
  /**
10266
10426
  * Renders a display object to canvas.
@@ -10268,10 +10428,10 @@ var CanvasRenderer = class {
10268
10428
  * @param {CanvasRenderingContext2D} context - The canvas rendering context.
10269
10429
  * @param {Matrix} matrix - The transformation matrix.
10270
10430
  */
10271
- renderDisplayObject(displayObject, context, matrix) {
10431
+ renderDisplayObject(displayObject, context) {
10272
10432
  this.renderSession.context = context ?? this.context;
10273
10433
  this.renderSession.resolution = this.resolution;
10274
- displayObject.renderCanvas(this.renderSession, matrix);
10434
+ displayObject.renderCanvas(this.renderSession);
10275
10435
  }
10276
10436
  /**
10277
10437
  * Maps blend modes to canvas rendering operations.
@@ -10308,7 +10468,7 @@ var CanvasRenderer = class {
10308
10468
  //#endregion
10309
10469
  //#region src/phaser/display/webgl/blend_manager.ts
10310
10470
  var WebGLBlendModeManager = class {
10311
- gl = null;
10471
+ gl;
10312
10472
  currentBlendMode = 99999;
10313
10473
  /**
10314
10474
  * Creates a new BlendModeManager instance.
@@ -10403,8 +10563,9 @@ var mask_manager_exports = /* @__PURE__ */ __exportAll({
10403
10563
  const pushMask = (maskData, renderSession) => {
10404
10564
  const { gl } = renderSession;
10405
10565
  if (maskData.dirty) updateGraphics(maskData, gl);
10406
- if (maskData._webGL[gl.id] === void 0 || maskData._webGL[gl.id].data === void 0 || maskData._webGL[gl.id].data.length === 0) return;
10407
- renderSession.stencilManager.pushStencil(maskData, maskData._webGL[gl.id].data[0], renderSession);
10566
+ const [first] = maskData._webGL[gl.id]?.data ?? [];
10567
+ if (!first) return;
10568
+ renderSession.stencilManager.pushStencil(maskData, first, renderSession);
10408
10569
  };
10409
10570
  /**
10410
10571
  * Sets up the mask manager for WebGL rendering.
@@ -10413,8 +10574,9 @@ const pushMask = (maskData, renderSession) => {
10413
10574
  */
10414
10575
  const popMask = (maskData, renderSession) => {
10415
10576
  const { gl } = renderSession;
10416
- if (maskData._webGL[gl.id] === void 0 || maskData._webGL[gl.id].data === void 0 || maskData._webGL[gl.id].data.length === 0) return;
10417
- renderSession.stencilManager.popStencil(maskData, maskData._webGL[gl.id].data[0], renderSession);
10577
+ const [first] = maskData?._webGL[gl.id]?.data ?? [];
10578
+ if (!first) return;
10579
+ renderSession.stencilManager.popStencil(maskData, first, renderSession);
10418
10580
  };
10419
10581
  const INVALID_ENUM = 1280;
10420
10582
  const INVALID_VALUE = 1281;
@@ -10458,7 +10620,7 @@ const compileShader = (gl, shaderSrc, shaderType) => {
10458
10620
  if (!shader) return null;
10459
10621
  gl.shaderSource(shader, src);
10460
10622
  gl.compileShader(shader);
10461
- if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
10623
+ if (gl.getShaderParameter(shader, gl.COMPILE_STATUS) !== true) {
10462
10624
  getRegistry();
10463
10625
  globalThis.PhaserRegistry.GL_SHADER_INFO_LOG = gl.getShaderInfoLog(shader);
10464
10626
  return null;
@@ -10490,11 +10652,11 @@ const compileProgram = (gl, vertexSrc, fragmentSrc) => {
10490
10652
  const fragmentShader = compileFragmentShader(gl, fragmentSrc);
10491
10653
  const vertexShader = compileVertexShader(gl, vertexSrc);
10492
10654
  const shaderProgram = gl.createProgram();
10493
- if (!shaderProgram || !vertexShader || !fragmentShader) return null;
10655
+ if (shaderProgram === null || vertexShader === null || fragmentShader === null) return null;
10494
10656
  gl.attachShader(shaderProgram, vertexShader);
10495
10657
  gl.attachShader(shaderProgram, fragmentShader);
10496
10658
  gl.linkProgram(shaderProgram);
10497
- if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) {
10659
+ if (gl.getProgramParameter(shaderProgram, gl.LINK_STATUS) !== true) {
10498
10660
  getRegistry();
10499
10661
  globalThis.PhaserRegistry.GL_PROGRAM_INFO_LOG = gl.getProgramInfoLog(shaderProgram);
10500
10662
  }
@@ -10815,34 +10977,35 @@ var NormalShader = class {
10815
10977
  * @param {object} uniform - The uniform to set.
10816
10978
  */
10817
10979
  initSampler2D(uniform) {
10818
- if (!uniform.value || !uniform.value.baseTexture || !uniform.value.baseTexture.hasLoaded) return;
10980
+ const texture = uniform.value;
10981
+ if (texture?.baseTexture.hasLoaded !== true) return;
10819
10982
  const { gl } = this;
10820
10983
  gl.activeTexture(glMember(gl, `TEXTURE${this.textureCount}`));
10821
- gl.bindTexture(gl.TEXTURE_2D, uniform.value.baseTexture._glTextures[gl.id]);
10984
+ gl.bindTexture(gl.TEXTURE_2D, texture.baseTexture._glTextures[gl.id] ?? null);
10822
10985
  if (uniform.textureData) {
10823
10986
  const data = uniform.textureData;
10824
10987
  const magFilter = data.magFilter ?? gl.LINEAR;
10825
10988
  const minFilter = data.minFilter ?? gl.LINEAR;
10826
10989
  let wrapS = data.wrapS ?? gl.CLAMP_TO_EDGE;
10827
10990
  let wrapT = data.wrapT ?? gl.CLAMP_TO_EDGE;
10828
- const format = data.luminance ? gl.LUMINANCE : gl.RGBA;
10829
- if (data.repeat) {
10991
+ const format = data.luminance === true ? gl.LUMINANCE : gl.RGBA;
10992
+ if (data.repeat === true) {
10830
10993
  wrapS = gl.REPEAT;
10831
10994
  wrapT = gl.REPEAT;
10832
10995
  }
10833
10996
  gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, Boolean(data.flipY));
10834
- if (data.width) {
10997
+ if (data.width !== void 0) {
10835
10998
  const width = data.width ?? 512;
10836
10999
  const height = data.height ?? 2;
10837
11000
  const border = data.border ?? 0;
10838
11001
  gl.texImage2D(gl.TEXTURE_2D, 0, format, width, height, border, format, gl.UNSIGNED_BYTE, null);
10839
- } else gl.texImage2D(gl.TEXTURE_2D, 0, format, gl.RGBA, gl.UNSIGNED_BYTE, uniform.value.baseTexture.source);
11002
+ } else gl.texImage2D(gl.TEXTURE_2D, 0, format, gl.RGBA, gl.UNSIGNED_BYTE, texture.baseTexture.source);
10840
11003
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter);
10841
11004
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter);
10842
11005
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrapS);
10843
11006
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrapT);
10844
11007
  }
10845
- gl.uniform1i(uniform.uniformLocation, this.textureCount);
11008
+ gl.uniform1i(uniform.uniformLocation ?? null, this.textureCount);
10846
11009
  uniform._init = true;
10847
11010
  this.textureCount += 1;
10848
11011
  }
@@ -10852,20 +11015,25 @@ var NormalShader = class {
10852
11015
  syncUniforms() {
10853
11016
  this.textureCount = 1;
10854
11017
  const { gl } = this;
10855
- for (const uniform of Object.values(this.uniforms)) if (uniform.glValueLength === 1) {
10856
- if (uniform.glMatrix === true) callUniformSetter(uniform.glFunc, gl, uniform.uniformLocation, uniform.transpose, uniform.value);
10857
- else callUniformSetter(uniform.glFunc, gl, uniform.uniformLocation, uniform.value);
10858
- } else if (uniform.glValueLength === 2) callUniformSetter(uniform.glFunc, gl, uniform.uniformLocation, uniform.value.x, uniform.value.y);
10859
- else if (uniform.glValueLength === 3) callUniformSetter(uniform.glFunc, gl, uniform.uniformLocation, uniform.value.x, uniform.value.y, uniform.value.z);
10860
- else if (uniform.glValueLength === 4) callUniformSetter(uniform.glFunc, gl, uniform.uniformLocation, uniform.value.x, uniform.value.y, uniform.value.z, uniform.value.w);
10861
- else if (uniform.type === "sampler2D") {
10862
- if (uniform._init) {
10863
- gl.activeTexture(glMember(gl, `TEXTURE${this.textureCount}`));
10864
- if (uniform.value.baseTexture._dirty[gl.id]) globalThis.PhaserRegistry.INSTANCES[gl.id]?.updateTexture(uniform.value.baseTexture);
10865
- else gl.bindTexture(gl.TEXTURE_2D, uniform.value.baseTexture._glTextures[gl.id]);
10866
- gl.uniform1i(uniform.uniformLocation ?? null, this.textureCount);
10867
- this.textureCount += 1;
10868
- } else this.initSampler2D(uniform);
11018
+ for (const uniform of Object.values(this.uniforms)) {
11019
+ const vector = uniform.value;
11020
+ const sampler = uniform;
11021
+ if (uniform.glValueLength === 1) {
11022
+ if (uniform.glMatrix === true) callUniformSetter(uniform.glFunc, gl, uniform.uniformLocation, uniform.transpose, uniform.value);
11023
+ else callUniformSetter(uniform.glFunc, gl, uniform.uniformLocation, uniform.value);
11024
+ } else if (uniform.glValueLength === 2) callUniformSetter(uniform.glFunc, gl, uniform.uniformLocation, vector.x, vector.y);
11025
+ else if (uniform.glValueLength === 3) callUniformSetter(uniform.glFunc, gl, uniform.uniformLocation, vector.x, vector.y, vector.z);
11026
+ else if (uniform.glValueLength === 4) callUniformSetter(uniform.glFunc, gl, uniform.uniformLocation, vector.x, vector.y, vector.z, vector.w);
11027
+ else if (uniform.type === "sampler2D") {
11028
+ if (uniform._init === true) {
11029
+ gl.activeTexture(glMember(gl, `TEXTURE${this.textureCount}`));
11030
+ const { baseTexture } = sampler.value;
11031
+ if (baseTexture._dirty[gl.id] === true) globalThis.PhaserRegistry.INSTANCES[gl.id]?.updateTexture(baseTexture);
11032
+ else gl.bindTexture(gl.TEXTURE_2D, baseTexture._glTextures[gl.id] ?? null);
11033
+ gl.uniform1i(uniform.uniformLocation ?? null, this.textureCount);
11034
+ this.textureCount += 1;
11035
+ } else this.initSampler2D(sampler);
11036
+ }
10869
11037
  }
10870
11038
  }
10871
11039
  /**
@@ -11090,7 +11258,7 @@ var WebGLShaderManager = class {
11090
11258
  const { gl } = this;
11091
11259
  for (i = 0; i < this.attribState.length; i += 1) if (this.attribState[i] !== this.tempAttribState[i]) {
11092
11260
  this.attribState[i] = this.tempAttribState[i];
11093
- if (this.tempAttribState[i]) gl.enableVertexAttribArray(i);
11261
+ if (this.tempAttribState[i] === true) gl.enableVertexAttribArray(i);
11094
11262
  else gl.disableVertexAttribArray(i);
11095
11263
  }
11096
11264
  }
@@ -11125,6 +11293,7 @@ var WebGLShaderManager = class {
11125
11293
  //#endregion
11126
11294
  //#region src/phaser/display/webgl/abstract_filter.ts
11127
11295
  var AbstractFilter = class {
11296
+ _UID;
11128
11297
  passes;
11129
11298
  shaders;
11130
11299
  dirty;
@@ -11137,18 +11306,19 @@ var AbstractFilter = class {
11137
11306
  * @param {object} uniforms - The uniform variables for the shader.
11138
11307
  */
11139
11308
  constructor(fragmentSrc, uniforms) {
11309
+ this._UID = v4();
11140
11310
  this.passes = [this];
11141
11311
  this.shaders = [];
11142
11312
  this.dirty = true;
11143
11313
  this.padding = 0;
11144
11314
  this.uniforms = uniforms ?? {};
11145
- this.fragmentSrc = fragmentSrc || [];
11315
+ this.fragmentSrc = fragmentSrc;
11146
11316
  }
11147
11317
  /**
11148
11318
  * Initializes the filter.
11149
11319
  */
11150
11320
  syncUniforms() {
11151
- for (let i = 0, j = this.shaders.length; i < j; i += 1) this.shaders[i].dirty = true;
11321
+ for (const shader of this.shaders) shader.dirty = true;
11152
11322
  }
11153
11323
  };
11154
11324
  //#endregion
@@ -11369,7 +11539,7 @@ var WebGLSpriteBatch = class {
11369
11539
  nextBlendMode = sprite.blendMode;
11370
11540
  nextShader = sprite.shader ?? this.defaultShader;
11371
11541
  blendSwap = currentBlendMode !== nextBlendMode;
11372
- shaderSwap = !currentShader || !nextShader || currentShader._UID !== nextShader._UID;
11542
+ shaderSwap = currentShader === null || currentShader._UID !== nextShader._UID;
11373
11543
  let skip = nextTexture.skipRender;
11374
11544
  if (skip && sprite.children.length > 0) skip = false;
11375
11545
  if (currentBaseTexture !== nextTexture && !skip || blendSwap || shaderSwap) {
@@ -11411,9 +11581,9 @@ var WebGLSpriteBatch = class {
11411
11581
  * @param {number} startIndex - The start index in the batch.
11412
11582
  */
11413
11583
  renderBatch(texture, size, startIndex) {
11414
- if (size === 0) return;
11584
+ if (size === 0 || !texture) return;
11415
11585
  const { gl } = this;
11416
- if (texture._dirty[gl.id]) {
11586
+ if (texture._dirty[gl.id] === true) {
11417
11587
  if (!this.renderSession.renderer.updateTexture(texture)) return;
11418
11588
  } else gl.bindTexture(gl.TEXTURE_2D, texture._glTextures[gl.id] ?? null);
11419
11589
  gl.drawElements(gl.TRIANGLES, size * 6, gl.UNSIGNED_SHORT, startIndex * 6 * 2);
@@ -11471,7 +11641,7 @@ var WebGLStencilManager = class {
11471
11641
  * Sets up the stencil buffer for rendering.
11472
11642
  */
11473
11643
  destroy() {
11474
- this.stencilStack = null;
11644
+ this.stencilStack = [];
11475
11645
  }
11476
11646
  /**
11477
11647
  * Renders the stencil buffer for graphics.
@@ -11650,7 +11820,7 @@ var WebGLRenderer = class {
11650
11820
  alpha: Boolean(game.config.transparent),
11651
11821
  depth: false,
11652
11822
  antialias: game.config.antialias,
11653
- premultipliedAlpha: game.config.transparent && game.config.transparent !== "notMultiplied",
11823
+ premultipliedAlpha: game.config.transparent !== false && game.config.transparent !== "notMultiplied",
11654
11824
  stencil: true,
11655
11825
  failIfMajorPerformanceCaveat: false,
11656
11826
  preserveDrawingBuffer: game.config.preserveDrawingBuffer
@@ -11762,15 +11932,15 @@ var WebGLRenderer = class {
11762
11932
  * @param {object} buffer - The render buffer.
11763
11933
  * @param {Matrix} matrix - The transformation matrix.
11764
11934
  */
11765
- renderDisplayObject(displayObject, projection, buffer, matrix) {
11935
+ renderDisplayObject(displayObject, projection, buffer) {
11766
11936
  this.renderSession.blendModeManager.setBlendMode(0);
11767
11937
  this.renderSession.drawCount = 0;
11768
11938
  this.renderSession.flipY = buffer ? -1 : 1;
11769
11939
  this.renderSession.projection = projection;
11770
11940
  this.renderSession.offset = this.offset;
11771
11941
  this.spriteBatch.begin(this.renderSession);
11772
- this.filterManager.begin(this.renderSession, buffer);
11773
- displayObject.renderWebGL(this.renderSession, matrix);
11942
+ this.filterManager.begin();
11943
+ displayObject.renderWebGL(this.renderSession);
11774
11944
  this.spriteBatch.end();
11775
11945
  }
11776
11946
  /**
@@ -11846,153 +12016,6 @@ var WebGLRenderer = class {
11846
12016
  }
11847
12017
  };
11848
12018
  //#endregion
11849
- //#region src/phaser/core/frame_data.ts
11850
- var FrameData = class {
11851
- _frames;
11852
- _frameNames;
11853
- constructor() {
11854
- this._frames = [];
11855
- this._frameNames = {};
11856
- }
11857
- addFrame(frame) {
11858
- frame.index = this._frames.length;
11859
- this._frames.push(frame);
11860
- if (frame.name !== "") this._frameNames[frame.name] = frame.index;
11861
- return frame;
11862
- }
11863
- getFrame(index = 0) {
11864
- if (index >= this._frames.length) index = 0;
11865
- return this._frames[index];
11866
- }
11867
- getFrameByName(name) {
11868
- const index = this._frameNames[name];
11869
- if (typeof index === "number") return this._frames[index] ?? null;
11870
- return null;
11871
- }
11872
- checkFrameName(name) {
11873
- if (this._frameNames[name] == null) return false;
11874
- return true;
11875
- }
11876
- clone() {
11877
- return cloneFrameData(this);
11878
- }
11879
- getFrameRange(start, end, output = null) {
11880
- const result = output ?? [];
11881
- for (let i = start; i <= end; i += 1) result.push(this._frames[i]);
11882
- return result;
11883
- }
11884
- getFrameIndexes(frames, useNumericIndex = true, output = null) {
11885
- const result = output ?? [];
11886
- if (frames && frames.length > 0) for (const f of frames) if (useNumericIndex && this._frames[f]) result.push(this._frames[f].index);
11887
- else {
11888
- const found = this.getFrameByName(f);
11889
- if (found) result.push(found.index);
11890
- }
11891
- else for (const frame of this._frames) result.push(frame.index);
11892
- return result;
11893
- }
11894
- destroy() {
11895
- this._frames = null;
11896
- this._frameNames = null;
11897
- }
11898
- get total() {
11899
- return this._frames.length;
11900
- }
11901
- };
11902
- //#endregion
11903
- //#region src/phaser/core/frame_util.ts
11904
- const cloneFrame = (frame, output = null) => {
11905
- const result = output ?? new Frame(frame.index, frame.x, frame.y, frame.width, frame.height);
11906
- result.initialize(frame.index, frame.x, frame.y, frame.width, frame.height);
11907
- return result;
11908
- };
11909
- const cloneFrameData = (frameData, output = null) => {
11910
- const result = output ?? new FrameData();
11911
- for (let i = 0; i < frameData.total; i += 1) result.addFrame(frameData.getFrame(i).clone());
11912
- return result;
11913
- };
11914
- //#endregion
11915
- //#region src/phaser/core/frame.ts
11916
- var Frame = class {
11917
- index;
11918
- x;
11919
- y;
11920
- width;
11921
- height;
11922
- name;
11923
- centerX;
11924
- centerY;
11925
- distance;
11926
- rotated;
11927
- rotationDirection;
11928
- trimmed;
11929
- sourceSizeW;
11930
- sourceSizeH;
11931
- spriteSourceSizeX;
11932
- spriteSourceSizeY;
11933
- spriteSourceSizeW;
11934
- spriteSourceSizeH;
11935
- right;
11936
- bottom;
11937
- constructor(index, x, y, width, height, name) {
11938
- this.initialize(index, x, y, width, height, name);
11939
- }
11940
- initialize(index, x, y, width, height, name) {
11941
- this.index = index;
11942
- this.x = x;
11943
- this.y = y;
11944
- this.width = width;
11945
- this.height = height;
11946
- this.name = name;
11947
- this.centerX = Math.floor(width / 2);
11948
- this.centerY = Math.floor(height / 2);
11949
- this.distance = distance(0, 0, width, height);
11950
- this.rotated = false;
11951
- this.rotationDirection = "cw";
11952
- this.trimmed = false;
11953
- this.sourceSizeW = width;
11954
- this.sourceSizeH = height;
11955
- this.spriteSourceSizeX = 0;
11956
- this.spriteSourceSizeY = 0;
11957
- this.spriteSourceSizeW = 0;
11958
- this.spriteSourceSizeH = 0;
11959
- this.right = this.x + this.width;
11960
- this.bottom = this.y + this.height;
11961
- }
11962
- resize(width, height) {
11963
- this.width = width;
11964
- this.height = height;
11965
- this.centerX = Math.floor(width / 2);
11966
- this.centerY = Math.floor(height / 2);
11967
- this.distance = distance(0, 0, width, height);
11968
- this.sourceSizeW = width;
11969
- this.sourceSizeH = height;
11970
- this.right = this.x + width;
11971
- this.bottom = this.y + height;
11972
- }
11973
- setTrim(trimmed, actualWidth, actualHeight, destX, destY, destWidth, destHeight) {
11974
- this.trimmed = trimmed;
11975
- if (trimmed) {
11976
- this.sourceSizeW = actualWidth;
11977
- this.sourceSizeH = actualHeight;
11978
- this.centerX = Math.floor(actualWidth / 2);
11979
- this.centerY = Math.floor(actualHeight / 2);
11980
- this.spriteSourceSizeX = destX;
11981
- this.spriteSourceSizeY = destY;
11982
- this.spriteSourceSizeW = destWidth;
11983
- this.spriteSourceSizeH = destHeight;
11984
- }
11985
- }
11986
- clone() {
11987
- return cloneFrame(this);
11988
- }
11989
- getRect(output = null) {
11990
- const result = output ?? new Rectangle();
11991
- result.setTo(this.x, this.y, this.width, this.height);
11992
- return result;
11993
- }
11994
- };
11995
- //#endregion
11996
12019
  //#region src/phaser/core/animation_parser.ts
11997
12020
  /**
11998
12021
  * TBD.
@@ -12006,28 +12029,27 @@ var Frame = class {
12006
12029
  * @returns {FrameData} TBD.
12007
12030
  */
12008
12031
  const spriteSheet = (game, key, frameWidth, frameHeight, frameMax, margin, spacing) => {
12009
- let img = key;
12010
- if (typeof key === "string") img = game.cache.getImage(key);
12032
+ const img = typeof key === "string" ? game.cache.getImage(key) : key;
12011
12033
  if (img === null) return null;
12012
12034
  const { width } = img;
12013
12035
  const { height } = img;
12014
- if (frameWidth <= 0) frameWidth = Math.floor(-width / Math.min(-1, frameWidth));
12015
- if (frameHeight <= 0) frameHeight = Math.floor(-height / Math.min(-1, frameHeight));
12016
- let total = Math.floor((width - margin) / (frameWidth + spacing)) * Math.floor((height - margin) / (frameHeight + spacing));
12036
+ const cellWidth = frameWidth <= 0 ? Math.floor(-width / Math.min(-1, frameWidth)) : frameWidth;
12037
+ const cellHeight = frameHeight <= 0 ? Math.floor(-height / Math.min(-1, frameHeight)) : frameHeight;
12038
+ let total = Math.floor((width - margin) / (cellWidth + spacing)) * Math.floor((height - margin) / (cellHeight + spacing));
12017
12039
  if (frameMax !== -1) total = frameMax;
12018
- if (width === 0 || height === 0 || width < frameWidth || height < frameHeight || total === 0) {
12019
- game.logger.warn(`AnimationParser.spriteSheet: '${key}'s width/height zero or width/height < given frameWidth/frameHeight`);
12040
+ if (width === 0 || height === 0 || width < cellWidth || height < cellHeight || total === 0) {
12041
+ game.logger.warn(`AnimationParser.spriteSheet: '${typeof key === "string" ? key : "image"}'s width/height zero or width/height < given cellWidth/cellHeight`);
12020
12042
  return null;
12021
12043
  }
12022
12044
  const data = new FrameData();
12023
12045
  let x = margin;
12024
12046
  let y = margin;
12025
12047
  for (let i = 0; i < total; i += 1) {
12026
- data.addFrame(new Frame(i, x, y, frameWidth, frameHeight, ""));
12027
- x += frameWidth + spacing;
12028
- if (x + frameWidth > width) {
12048
+ data.addFrame(new Frame(i, x, y, cellWidth, cellHeight, ""));
12049
+ x += cellWidth + spacing;
12050
+ if (x + cellWidth > width) {
12029
12051
  x = margin;
12030
- y += frameHeight + spacing;
12052
+ y += cellHeight + spacing;
12031
12053
  }
12032
12054
  }
12033
12055
  return data;
@@ -12039,18 +12061,17 @@ const spriteSheet = (game, key, frameWidth, frameHeight, frameMax, margin, spaci
12039
12061
  * @returns {FrameData} TBD.
12040
12062
  */
12041
12063
  const jsonDataHash = (game, json, _key) => {
12042
- if (!json.frames) {
12043
- game.logger.warn("jsonDataHash: Invalid Texture Atlas JSON given, missing frames object", json);
12064
+ const atlas = json;
12065
+ if (!atlas?.frames) {
12066
+ game.logger.warn("jsonDataHash: Invalid Texture Atlas JSON given, missing frames object");
12044
12067
  return null;
12045
12068
  }
12046
12069
  const data = new FrameData();
12047
- const { frames } = json;
12048
- let newFrame;
12070
+ const { frames } = atlas;
12049
12071
  let i = 0;
12050
- const keys = Object.keys(frames);
12051
- for (const key of keys) {
12052
- newFrame = data.addFrame(new Frame(i, frames[key].frame.x, frames[key].frame.y, frames[key].frame.w, frames[key].frame.h, key));
12053
- if (frames[key].trimmed) newFrame.setTrim(frames[key].trimmed, frames[key].sourceSize.w, frames[key].sourceSize.h, frames[key].spriteSourceSize.x, frames[key].spriteSourceSize.y, frames[key].spriteSourceSize.w, frames[key].spriteSourceSize.h);
12072
+ for (const [key, entry] of Object.entries(frames)) {
12073
+ const newFrame = data.addFrame(new Frame(i, entry.frame.x, entry.frame.y, entry.frame.w, entry.frame.h, key));
12074
+ if (entry.trimmed === true && entry.sourceSize !== void 0 && entry.spriteSourceSize !== void 0) newFrame.setTrim(entry.trimmed, entry.sourceSize.w, entry.sourceSize.h, entry.spriteSourceSize.x, entry.spriteSourceSize.y, entry.spriteSourceSize.w, entry.spriteSourceSize.h);
12054
12075
  i += 1;
12055
12076
  }
12056
12077
  return data;
@@ -12111,9 +12132,9 @@ const xmlBitmapFont = (xml, baseTexture, xSpacing, ySpacing) => {
12111
12132
  */
12112
12133
  const jsonBitmapFont = (json, baseTexture, xSpacing, ySpacing) => {
12113
12134
  const data = {
12114
- font: json.font.info._face,
12115
- size: Math.trunc(Number(json.font.info._size)),
12116
- lineHeight: Math.trunc(Number(json.font.common._lineHeight)) + ySpacing,
12135
+ font: json.font.info["_face"] ?? "",
12136
+ size: Math.trunc(Number(json.font.info["_size"])),
12137
+ lineHeight: Math.trunc(Number(json.font.common["_lineHeight"])) + ySpacing,
12117
12138
  chars: {}
12118
12139
  };
12119
12140
  for (const letter of json.font.chars.char) {
@@ -12401,7 +12422,7 @@ var Cache = class {
12401
12422
  */
12402
12423
  checkURL(url) {
12403
12424
  const resolved = this._resolveURL(url);
12404
- if (resolved && this._urlMap?.[resolved]) return true;
12425
+ if (resolved !== null && this._urlMap?.[resolved] !== void 0) return true;
12405
12426
  return false;
12406
12427
  }
12407
12428
  /**
@@ -12487,7 +12508,7 @@ var Cache = class {
12487
12508
  getItem(key, cache, _method, property = null) {
12488
12509
  if (this.checkKey(cache, key)) {
12489
12510
  const entry = this._cacheMap[cache][key];
12490
- if (!property) return entry;
12511
+ if (property === null) return entry;
12491
12512
  return entry[property];
12492
12513
  }
12493
12514
  return null;
@@ -12668,7 +12689,7 @@ var Cache = class {
12668
12689
  */
12669
12690
  getURL(url) {
12670
12691
  const resolvedURL = this._resolveURL(url);
12671
- if (resolvedURL) return this._urlMap?.[resolvedURL] ?? null;
12692
+ if (resolvedURL !== null) return this._urlMap?.[resolvedURL] ?? null;
12672
12693
  this.game.logger.warn("Cache invalid url", { resolvedURL });
12673
12694
  return null;
12674
12695
  }
@@ -12792,7 +12813,7 @@ var Cache = class {
12792
12813
  */
12793
12814
  destroy() {
12794
12815
  for (const cache of this._cacheMap) {
12795
- const keys = cache ? Object.keys(cache) : [];
12816
+ const keys = Object.keys(cache);
12796
12817
  for (const key of keys) if (key !== "__default" && key !== "__missing") {
12797
12818
  cache[key].destroy?.();
12798
12819
  delete cache[key];
@@ -12898,18 +12919,18 @@ const checkFullScreenSupport = (device) => {
12898
12919
  "mozExitFullscreen"
12899
12920
  ];
12900
12921
  const elementApi = document.createElement("div");
12901
- for (const name of fs) if (elementApi[name]) {
12922
+ for (const name of fs) if (elementApi[name] !== void 0) {
12902
12923
  device.fullscreen = true;
12903
12924
  device.requestFullscreen = name;
12904
12925
  break;
12905
12926
  }
12906
12927
  if (device.fullscreen) {
12907
12928
  const documentApi = document;
12908
- for (const name of cfs) if (documentApi[name]) {
12929
+ for (const name of cfs) if (documentApi[name] !== void 0) {
12909
12930
  device.cancelFullscreen = name;
12910
12931
  break;
12911
12932
  }
12912
- if (globalThis.Element && Element.ALLOW_KEYBOARD_INPUT) device.fullscreenKeyboard = true;
12933
+ if (Element.ALLOW_KEYBOARD_INPUT !== void 0) device.fullscreenKeyboard = true;
12913
12934
  }
12914
12935
  };
12915
12936
  /**
@@ -13006,7 +13027,7 @@ const checkAudio = (device) => {
13006
13027
  }
13007
13028
  ]) {
13008
13029
  const { type, codecs } = format;
13009
- for (const codec of codecs) if (!device.supportedAudioFormats[type]) {
13030
+ for (const codec of codecs) if (device.supportedAudioFormats[type] !== true) {
13010
13031
  const isSupported = isMediaSourceTypeSupported(codec) || canPlayType(audioElement, codec);
13011
13032
  if (isSupported) device.supportedAudioFormats[type] = isSupported;
13012
13033
  }
@@ -13064,11 +13085,7 @@ var ArraySet = class {
13064
13085
  * @returns {object} TBD.
13065
13086
  */
13066
13087
  getByKey(property, value) {
13067
- let i = this.list.length;
13068
- while (i) {
13069
- i -= 1;
13070
- if (this.list[i][property] === value) return this.list[i];
13071
- }
13088
+ for (let i = this.list.length - 1; i >= 0; i -= 1) if (this.list[i]?.[property] === value) return this.list[i];
13072
13089
  return null;
13073
13090
  }
13074
13091
  /**
@@ -13104,7 +13121,7 @@ var ArraySet = class {
13104
13121
  * @param {object} value - TBD.
13105
13122
  */
13106
13123
  setAll(key, value) {
13107
- for (const item of this.list) if (item) item[key] = value;
13124
+ for (const item of this.list) if (item !== void 0) item[key] = value;
13108
13125
  }
13109
13126
  /**
13110
13127
  * TBD.
@@ -13114,7 +13131,7 @@ var ArraySet = class {
13114
13131
  callAll(key, ...args) {
13115
13132
  for (let i = this.list.length - 1; i >= 0; i -= 1) {
13116
13133
  const item = this.list[i];
13117
- if (item && item[key]) item[key](...args);
13134
+ if (item?.[key]) item[key](...args);
13118
13135
  }
13119
13136
  }
13120
13137
  /**
@@ -13122,12 +13139,11 @@ var ArraySet = class {
13122
13139
  * @param {boolean} destroy - TBD.
13123
13140
  */
13124
13141
  removeAll(destroy = false) {
13125
- let i = this.list.length;
13126
- while (i) {
13127
- i -= 1;
13128
- if (this.list[i]) {
13129
- const item = this.remove(this.list[i]);
13130
- if (destroy) item.destroy();
13142
+ for (let i = this.list.length - 1; i >= 0; i -= 1) {
13143
+ const entry = this.list[i];
13144
+ if (entry !== void 0) {
13145
+ const item = this.remove(entry);
13146
+ if (destroy) item?.destroy?.();
13131
13147
  }
13132
13148
  }
13133
13149
  this.position = 0;
@@ -13156,7 +13172,7 @@ var ArraySet = class {
13156
13172
  get next() {
13157
13173
  if (this.position < this.list.length) {
13158
13174
  this.position += 1;
13159
- return this.list[this.position];
13175
+ return this.list[this.position] ?? null;
13160
13176
  }
13161
13177
  return null;
13162
13178
  }
@@ -13257,7 +13273,7 @@ var Mouse = class {
13257
13273
  canvas.addEventListener("mouseover", this._onMouseOver, true);
13258
13274
  canvas.addEventListener("mouseout", this._onMouseOut, true);
13259
13275
  const { wheelEvent } = this.game.device;
13260
- if (wheelEvent) canvas.addEventListener(wheelEvent, this._onMouseWheel, true);
13276
+ if (wheelEvent !== null) canvas.addEventListener(wheelEvent, this._onMouseWheel, true);
13261
13277
  }
13262
13278
  /**
13263
13279
  * TBD.
@@ -13270,9 +13286,9 @@ var Mouse = class {
13270
13286
  if (this._onMouseOver) canvas.removeEventListener("mouseover", this._onMouseOver, true);
13271
13287
  if (this._onMouseOut) canvas.removeEventListener("mouseout", this._onMouseOut, true);
13272
13288
  const { wheelEvent } = this.game.device;
13273
- if (wheelEvent && this._onMouseWheel) canvas.removeEventListener(wheelEvent, this._onMouseWheel, true);
13274
- if (this._onMouseUpGlobal) globalThis.removeEventListener("mouseup", this._onMouseUpGlobal, true);
13275
- if (this._onMouseOutGlobal) globalThis.removeEventListener("mouseout", this._onMouseOutGlobal, true);
13289
+ if (wheelEvent !== null && this._onMouseWheel) canvas.removeEventListener(wheelEvent, this._onMouseWheel, true);
13290
+ if (this._onMouseUpGlobal !== null) globalThis.removeEventListener("mouseup", this._onMouseUpGlobal, true);
13291
+ if (this._onMouseOutGlobal !== null) globalThis.removeEventListener("mouseout", this._onMouseOutGlobal, true);
13276
13292
  }
13277
13293
  /**
13278
13294
  * TBD.
@@ -13362,11 +13378,11 @@ var Mouse = class {
13362
13378
  * @param {WheelEvent} event - TBD.
13363
13379
  */
13364
13380
  onMouseWheel(event) {
13365
- if (this._wheelEvent) event = this._wheelEvent.bindEvent(event);
13366
- this.event = event;
13367
- this.eventPreventDefault(event);
13368
- this.wheelDelta = Math.max(-1, Math.min(1, -(event.deltaY ?? 0)));
13369
- if (this.mouseWheelCallback) this.mouseWheelCallback.call(this.callbackContext, event);
13381
+ const wheelEvent = this._wheelEvent ? this._wheelEvent.bindEvent(event) : event;
13382
+ this.event = wheelEvent;
13383
+ this.eventPreventDefault(wheelEvent);
13384
+ this.wheelDelta = Math.max(-1, Math.min(1, -(wheelEvent.deltaY ?? 0)));
13385
+ if (this.mouseWheelCallback) this.mouseWheelCallback.call(this.callbackContext, wheelEvent);
13370
13386
  }
13371
13387
  /**
13372
13388
  * TBD.
@@ -13694,7 +13710,7 @@ var Pointer = class {
13694
13710
  */
13695
13711
  start(event) {
13696
13712
  const { input } = this.game;
13697
- if (event.pointerId) this.pointerId = event.pointerId;
13713
+ if (event.pointerId !== void 0) this.pointerId = event.pointerId;
13698
13714
  this.identifier = event.identifier ?? null;
13699
13715
  this.target = event.target;
13700
13716
  if (this.isMouse) this.updateButtons(event);
@@ -13905,7 +13921,7 @@ var Pointer = class {
13905
13921
  * @param {number} duration - TBD.
13906
13922
  * @returns {boolean} TBD.
13907
13923
  */
13908
- justPressed(duration) {
13924
+ justPressed(duration = 0) {
13909
13925
  const window = duration || this.game.input.justPressedRate;
13910
13926
  return this.isDown && this.timeDown + window > this.game.time.time;
13911
13927
  }
@@ -13914,7 +13930,7 @@ var Pointer = class {
13914
13930
  * @param {number} duration - TBD.
13915
13931
  * @returns {boolean} TBD.
13916
13932
  */
13917
- justReleased(duration) {
13933
+ justReleased(duration = 0) {
13918
13934
  const window = duration || this.game.input.justReleasedRate;
13919
13935
  return this.isUp && this.timeUp + window > this.game.time.time;
13920
13936
  }
@@ -14519,7 +14535,7 @@ var Input = class {
14519
14535
  if (!displayObject.worldVisible) return false;
14520
14536
  this.getLocalPosition(displayObject, pointer, this._localPoint);
14521
14537
  localPoint.copyFrom(this._localPoint);
14522
- if (displayObject.hitArea && displayObject.hitArea.contains) return displayObject.hitArea.contains(this._localPoint.x, this._localPoint.y);
14538
+ if (displayObject.hitArea !== null) return displayObject.hitArea.contains(this._localPoint.x, this._localPoint.y);
14523
14539
  else if (displayObject instanceof Image$1) {
14524
14540
  const { width } = displayObject.texture.frame;
14525
14541
  const { height } = displayObject.texture.frame;
@@ -14529,7 +14545,7 @@ var Input = class {
14529
14545
  if (this._localPoint.y >= y1 && this._localPoint.y < y1 + height) return true;
14530
14546
  }
14531
14547
  } else if (displayObject instanceof Graphics) {
14532
- for (const data of displayObject.graphicsData) if (data.fill && data.shape && data.shape.contains(this._localPoint.x, this._localPoint.y)) return true;
14548
+ for (const data of displayObject.graphicsData) if (data.fill && (data.shape?.contains(this._localPoint.x, this._localPoint.y) ?? false)) return true;
14533
14549
  }
14534
14550
  for (const child of displayObject.children) if (this.hitTest(child, pointer, localPoint)) return true;
14535
14551
  return false;
@@ -14683,9 +14699,8 @@ var Loader = class {
14683
14699
  direction,
14684
14700
  width: sprite.width,
14685
14701
  height: sprite.height,
14686
- rect: null
14702
+ rect: direction === 0 ? new Rectangle(0, 0, 1, sprite.height) : new Rectangle(0, 0, sprite.width, 1)
14687
14703
  };
14688
- this.preloadSprite.rect = direction === 0 ? new Rectangle(0, 0, 1, sprite.height) : new Rectangle(0, 0, sprite.width, 1);
14689
14704
  sprite.crop(this.preloadSprite.rect);
14690
14705
  sprite.visible = true;
14691
14706
  }
@@ -14775,18 +14790,19 @@ var Loader = class {
14775
14790
  this.game.logger.warn(`Loader: Invalid or no key given of type ${type}`);
14776
14791
  return this;
14777
14792
  }
14778
- if (url === void 0 || url === null) {
14779
- if (extension) url = key + extension;
14780
- else {
14793
+ let resolvedUrl = url;
14794
+ if (resolvedUrl === void 0 || resolvedUrl === null) {
14795
+ if (extension === null) {
14781
14796
  this.game.logger.warn(`Loader: No URL given for file type: ${type} key: ${key}`);
14782
14797
  return this;
14783
14798
  }
14799
+ resolvedUrl = key + extension;
14784
14800
  }
14785
14801
  const file = {
14786
14802
  type,
14787
14803
  key,
14788
14804
  path: this.path,
14789
- url,
14805
+ url: resolvedUrl,
14790
14806
  syncPoint: this._withSyncPointDepth > 0,
14791
14807
  data: null,
14792
14808
  loading: false,
@@ -14840,9 +14856,8 @@ var Loader = class {
14840
14856
  error: false,
14841
14857
  callbackContext
14842
14858
  };
14843
- if (data) {
14844
- if (typeof data === "string") data = JSON.parse(data);
14845
- pack.data = data ?? {};
14859
+ if (data !== null) {
14860
+ pack.data = (typeof data === "string" ? JSON.parse(data) : data) ?? {};
14846
14861
  pack.loaded = true;
14847
14862
  }
14848
14863
  for (let i = 0; i < this._fileList.length + 1; i += 1) {
@@ -14935,8 +14950,8 @@ var Loader = class {
14935
14950
  */
14936
14951
  audio(key, urls, autoDecode = true) {
14937
14952
  if (this.game.sound.noAudio || this.game.device.noAudioFormat) return this;
14938
- if (typeof urls === "string") urls = [urls];
14939
- return this.addToFileList("audio", key, urls, {
14953
+ const sources = typeof urls === "string" ? [urls] : urls;
14954
+ return this.addToFileList("audio", key, sources, {
14940
14955
  buffer: null,
14941
14956
  autoDecode
14942
14957
  });
@@ -14954,9 +14969,9 @@ var Loader = class {
14954
14969
  if (this.game.sound.noAudio || this.game.device.noAudioFormat) return this;
14955
14970
  this.audio(key, urls, autoDecode);
14956
14971
  if (jsonURL) this.json(`${key}-audioatlas`, jsonURL);
14957
- else if (jsonData) {
14958
- if (typeof jsonData === "string") jsonData = JSON.parse(jsonData);
14959
- this.cache.addJSON(`${key}-audioatlas`, "", jsonData);
14972
+ else if (jsonData !== null) {
14973
+ const parsed = typeof jsonData === "string" ? JSON.parse(jsonData) : jsonData;
14974
+ this.cache.addJSON(`${key}-audioatlas`, "", parsed);
14960
14975
  }
14961
14976
  return this;
14962
14977
  }
@@ -14972,10 +14987,10 @@ var Loader = class {
14972
14987
  * @throws {Error} If the bitmap font atlas data is invalid.
14973
14988
  */
14974
14989
  bitmapFont(key, textureURL = null, atlasURL = null, atlasData = null, xSpacing = 0, ySpacing = 0) {
14975
- textureURL ??= `${key}.png`;
14976
- if (atlasURL === null && atlasData === null) atlasURL = `${key}.xml`;
14977
- if (atlasURL) this.addToFileList("bitmapfont", key, textureURL, {
14978
- atlasURL,
14990
+ const texture = textureURL ?? `${key}.png`;
14991
+ const atlas = atlasURL === null && atlasData === null ? `${key}.xml` : atlasURL;
14992
+ if (atlas !== null) this.addToFileList("bitmapfont", key, texture, {
14993
+ atlasURL: atlas,
14979
14994
  xSpacing,
14980
14995
  ySpacing
14981
14996
  });
@@ -14987,11 +15002,11 @@ var Loader = class {
14987
15002
  } catch {
14988
15003
  xml = this.parseXml(atlasData);
14989
15004
  }
14990
- if (!xml && !json) throw new Error(ENGINE_ERROR_INVALID_BITMAP_FONT_ATLAS);
14991
- this.addToFileList("bitmapfont", key, textureURL, {
15005
+ if (xml === null && json === null) throw new Error(ENGINE_ERROR_INVALID_BITMAP_FONT_ATLAS);
15006
+ this.addToFileList("bitmapfont", key, texture, {
14992
15007
  atlasURL: null,
14993
15008
  atlasData: json ?? xml,
14994
- atlasType: json ? "json" : "xml",
15009
+ atlasType: json === null ? "xml" : "json",
14995
15010
  xSpacing,
14996
15011
  ySpacing
14997
15012
  });
@@ -15008,13 +15023,13 @@ var Loader = class {
15008
15023
  * @returns {Loader} This Loader instance for chaining.
15009
15024
  */
15010
15025
  atlas(key, textureURL, atlasURL = null, atlasData = null, format = TEXTURE_ATLAS_JSON_HASH) {
15011
- textureURL ??= `${key}.png`;
15012
- if (!atlasURL && !atlasData) atlasURL = `${key}.json`;
15013
- if (atlasURL) this.addToFileList("textureatlas", key, textureURL, {
15014
- atlasURL,
15026
+ const texture = textureURL ?? `${key}.png`;
15027
+ const atlas = atlasURL === null && atlasData === null ? `${key}.json` : atlasURL;
15028
+ if (atlas !== null) this.addToFileList("textureatlas", key, texture, {
15029
+ atlasURL: atlas,
15015
15030
  format
15016
15031
  });
15017
- else this.addToFileList("textureatlas", key, textureURL, {
15032
+ else this.addToFileList("textureatlas", key, texture, {
15018
15033
  atlasURL: null,
15019
15034
  atlasData,
15020
15035
  format
@@ -15112,7 +15127,7 @@ var Loader = class {
15112
15127
  if (file.loaded || file.error) {
15113
15128
  if (i === this._processingHead) this._processingHead = i + 1;
15114
15129
  } else if (!file.loading && this._flightQueue.length < inflightLimit) {
15115
- if (file.type === "packfile" && !file.data) {
15130
+ if (file.type === "packfile" && file.data === null) {
15116
15131
  this._flightQueue.push(file);
15117
15132
  file.loading = true;
15118
15133
  this.loadFile(file);
@@ -15241,7 +15256,7 @@ var Loader = class {
15241
15256
  break;
15242
15257
  case "audio": {
15243
15258
  const resolved = this.getAudioURL(file.url);
15244
- if (resolved) {
15259
+ if (resolved !== null) {
15245
15260
  file.url = resolved;
15246
15261
  this.xhrLoad(file, this.transformUrl(resolved, file), "arraybuffer", this.fileComplete);
15247
15262
  } else if (this.game.sound.noAudio) this.fileError(file, null, "Device does not have audio playback support");
@@ -15276,8 +15291,8 @@ var Loader = class {
15276
15291
  }
15277
15292
  }, { once: true });
15278
15293
  image.addEventListener("error", () => {
15279
- if (this.isUseRetry && (!file.numRetry || file.numRetry < this.maxRetry)) setTimeout(() => {
15280
- file.numRetry = file.numRetry ? file.numRetry + 1 : 1;
15294
+ if (this.isUseRetry && (file.numRetry === void 0 || file.numRetry < this.maxRetry)) setTimeout(() => {
15295
+ file.numRetry = file.numRetry === void 0 ? 1 : file.numRetry + 1;
15281
15296
  this.loadImageTag(file);
15282
15297
  }, 1e3);
15283
15298
  else if (!settled) {
@@ -15312,12 +15327,12 @@ var Loader = class {
15312
15327
  const { requestedWith } = this.headers;
15313
15328
  if (requestedWith !== false && requestedWith !== void 0) xhr.setRequestHeader("X-Requested-With", requestedWith);
15314
15329
  const acceptHeader = this.headers[file.type];
15315
- if (acceptHeader) xhr.setRequestHeader("Accept", acceptHeader);
15330
+ if (acceptHeader !== void 0 && acceptHeader !== false) xhr.setRequestHeader("Accept", acceptHeader);
15316
15331
  const handleError = onerror ?? this.fileError;
15317
15332
  const retry = () => {
15318
- if (!this.isUseRetry || file.numRetry && file.numRetry >= this.maxRetry) return false;
15333
+ if (!this.isUseRetry || file.numRetry !== void 0 && file.numRetry >= this.maxRetry) return false;
15319
15334
  setTimeout(() => {
15320
- file.numRetry = file.numRetry ? file.numRetry + 1 : 1;
15335
+ file.numRetry = file.numRetry === void 0 ? 1 : file.numRetry + 1;
15321
15336
  this.xhrLoad(file, url, type, onload, handleError);
15322
15337
  }, 1e3);
15323
15338
  return true;
@@ -15393,8 +15408,8 @@ var Loader = class {
15393
15408
  * @param {number | string} reason - The error code or message explaining the failure.
15394
15409
  */
15395
15410
  fileError(file, xhr = null, reason = 0) {
15396
- if (!reason && xhr) reason = xhr.status;
15397
- const message = `Error loading asset (${String(reason)})`;
15411
+ const cause = reason === 0 && xhr !== null ? xhr.status : reason;
15412
+ const message = `Error loading asset (${String(cause)})`;
15398
15413
  this.asyncComplete(file, message);
15399
15414
  }
15400
15415
  /**
@@ -15426,7 +15441,7 @@ var Loader = class {
15426
15441
  }
15427
15442
  break;
15428
15443
  case "bitmapfont":
15429
- if (!file.atlasURL) this.cache.addBitmapFont(file.key, url, file.data, file.atlasData, file.atlasType ?? "xml", file.xSpacing ?? 0, file.ySpacing ?? 0);
15444
+ if (file.atlasURL === null || file.atlasURL === void 0) this.cache.addBitmapFont(file.key, url, file.data, file.atlasData, file.atlasType ?? "xml", file.xSpacing ?? 0, file.ySpacing ?? 0);
15430
15445
  else {
15431
15446
  loadNext = false;
15432
15447
  this.xhrLoad(file, this.transformUrl(file.atlasURL, file), "text", (bitmapFontFile, bitmapFontXhr) => {
@@ -15434,7 +15449,7 @@ var Loader = class {
15434
15449
  try {
15435
15450
  json = JSON.parse(bitmapFontXhr.responseText);
15436
15451
  } catch {}
15437
- if (json) {
15452
+ if (json !== void 0) {
15438
15453
  bitmapFontFile.atlasType = "json";
15439
15454
  this.jsonLoadComplete(bitmapFontFile, bitmapFontXhr);
15440
15455
  } else {
@@ -15448,7 +15463,7 @@ var Loader = class {
15448
15463
  const audio = response.response;
15449
15464
  file.data = audio;
15450
15465
  this.cache.addSound(file.key, url, audio);
15451
- if (file.autoDecode) this.game.sound.decode(file.key);
15466
+ if (file.autoDecode === true) this.game.sound.decode(file.key);
15452
15467
  break;
15453
15468
  }
15454
15469
  case "text": {
@@ -15507,16 +15522,11 @@ var Loader = class {
15507
15522
  parseXml(data) {
15508
15523
  let xml = null;
15509
15524
  try {
15510
- if (globalThis.DOMParser) xml = new DOMParser().parseFromString(data, "text/xml");
15511
- else {
15512
- xml = new globalThis.ActiveXObject("Microsoft.XMLDOM");
15513
- xml.async = "false";
15514
- xml.loadXML(data);
15515
- }
15525
+ xml = new DOMParser().parseFromString(data, "text/xml");
15516
15526
  } catch {
15517
15527
  xml = null;
15518
15528
  }
15519
- if (!xml || !xml.documentElement || xml.querySelectorAll("parsererror").length > 0) return null;
15529
+ if (!xml?.documentElement || xml.querySelectorAll("parsererror").length > 0) return null;
15520
15530
  return xml;
15521
15531
  }
15522
15532
  /**
@@ -15526,7 +15536,7 @@ var Loader = class {
15526
15536
  if (this.preloadSprite) {
15527
15537
  if (this.preloadSprite.direction === 0) this.preloadSprite.rect.width = Math.floor(this.preloadSprite.width / 100 * this.progress);
15528
15538
  else this.preloadSprite.rect.height = Math.floor(this.preloadSprite.height / 100 * this.progress);
15529
- if (this.preloadSprite.sprite) this.preloadSprite.sprite.updateCrop();
15539
+ if (this.preloadSprite.sprite !== null) this.preloadSprite.sprite.updateCrop();
15530
15540
  else this.preloadSprite = null;
15531
15541
  }
15532
15542
  }
@@ -15628,14 +15638,14 @@ var VisualBoundsDesktopRectangle = class {
15628
15638
  * @returns {number} The horizontal scroll position in pixels.
15629
15639
  */
15630
15640
  get x() {
15631
- return globalThis && "pageXOffset" in globalThis ? window.pageXOffset : document.documentElement.scrollLeft;
15641
+ return "pageXOffset" in globalThis ? window.pageXOffset : document.documentElement.scrollLeft;
15632
15642
  }
15633
15643
  /**
15634
15644
  * Gets the vertical scroll position of the window.
15635
15645
  * @returns {number} The vertical scroll position in pixels.
15636
15646
  */
15637
15647
  get y() {
15638
- return globalThis && "pageYOffset" in globalThis ? window.pageYOffset : document.documentElement.scrollTop;
15648
+ return "pageYOffset" in globalThis ? window.pageYOffset : document.documentElement.scrollTop;
15639
15649
  }
15640
15650
  /**
15641
15651
  * Gets the width of the window.
@@ -15684,14 +15694,14 @@ var VisualBoundsRectangle = class {
15684
15694
  * @returns {number} The horizontal scroll position in pixels.
15685
15695
  */
15686
15696
  get x() {
15687
- return globalThis && "pageXOffset" in globalThis ? window.pageXOffset : document.documentElement.scrollLeft;
15697
+ return "pageXOffset" in globalThis ? window.pageXOffset : document.documentElement.scrollLeft;
15688
15698
  }
15689
15699
  /**
15690
15700
  * Gets the vertical scroll position of the document.
15691
15701
  * @returns {number} The vertical scroll position in pixels.
15692
15702
  */
15693
15703
  get y() {
15694
- return globalThis && "pageYOffset" in globalThis ? window.pageYOffset : document.documentElement.scrollTop;
15704
+ return "pageYOffset" in globalThis ? window.pageYOffset : document.documentElement.scrollTop;
15695
15705
  }
15696
15706
  /**
15697
15707
  * TBD.
@@ -15782,8 +15792,8 @@ var DOM = class {
15782
15792
  this.visualBounds = this.treatAsDesktop ? new VisualBoundsDesktopRectangle() : new VisualBoundsRectangle();
15783
15793
  this.layoutBounds = this.treatAsDesktop ? new LayoutBoundsDesktopRectangle() : new LayoutBoundsRectangle();
15784
15794
  this.documentBounds = new DocumentBoundsRectangle();
15785
- this.scrollXProvider = globalThis && "pageXOffset" in globalThis ? () => window.pageXOffset : () => document.documentElement.scrollLeft;
15786
- this.scrollYProvider = globalThis && "pageYOffset" in globalThis ? () => window.pageYOffset : () => document.documentElement.scrollTop;
15795
+ this.scrollXProvider = "pageXOffset" in globalThis ? () => window.pageXOffset : () => document.documentElement.scrollLeft;
15796
+ this.scrollYProvider = "pageYOffset" in globalThis ? () => window.pageYOffset : () => document.documentElement.scrollTop;
15787
15797
  }
15788
15798
  /**
15789
15799
  * Gets the offset position of an element relative to the document.
@@ -15809,9 +15819,9 @@ var DOM = class {
15809
15819
  * @returns {boolean} True if bounds were successfully retrieved, false otherwise.
15810
15820
  */
15811
15821
  getBounds(element, cushion = 0) {
15812
- element = element && !element.nodeType ? element[0] : element;
15813
- if (!element || element.nodeType !== 1) return false;
15814
- return this.calibrate(element.getBoundingClientRect(), cushion);
15822
+ const target = element.nodeType === void 0 ? element[0] : element;
15823
+ if (target?.nodeType !== 1) return false;
15824
+ return this.calibrate(target.getBoundingClientRect(), cushion);
15815
15825
  }
15816
15826
  /**
15817
15827
  * Calibrates DOM rectangle coordinates with optional cushion.
@@ -15838,17 +15848,17 @@ var DOM = class {
15838
15848
  * @returns {string} The screen orientation ('portrait-primary', 'landscape-primary', etc.).
15839
15849
  */
15840
15850
  getScreenOrientation(primaryFallback = null) {
15841
- const { screen } = globalThis;
15842
- const orientation = screen.orientation || screen.mozOrientation || screen.msOrientation;
15843
- if (orientation && typeof orientation.type === "string") return orientation.type;
15844
- else if (typeof orientation === "string") return orientation;
15851
+ const screen = globalThis.screen;
15852
+ const orientation = screen.orientation ?? screen.mozOrientation ?? screen.msOrientation;
15853
+ if (typeof orientation === "string") return orientation;
15854
+ if (typeof orientation?.type === "string") return orientation.type;
15845
15855
  const PORTRAIT = "portrait-primary";
15846
15856
  const LANDSCAPE = "landscape-primary";
15847
15857
  if (primaryFallback === "screen") return screen.height > screen.width ? PORTRAIT : LANDSCAPE;
15848
15858
  else if (primaryFallback === "viewport") return this.visualBounds.height > this.visualBounds.width ? PORTRAIT : LANDSCAPE;
15849
15859
  const { orientation: legacyOrientation } = globalThis;
15850
15860
  if (primaryFallback === "window.orientation" && typeof legacyOrientation === "number") return legacyOrientation === 0 || legacyOrientation === 180 ? PORTRAIT : LANDSCAPE;
15851
- else if (globalThis.matchMedia) {
15861
+ else if (typeof globalThis.matchMedia === "function") {
15852
15862
  if (globalThis.matchMedia("(orientation: portrait)").matches) return PORTRAIT;
15853
15863
  else if (globalThis.matchMedia("(orientation: landscape)").matches) return LANDSCAPE;
15854
15864
  }
@@ -16096,7 +16106,7 @@ var ScaleManager = class {
16096
16106
  const rect = new Rectangle();
16097
16107
  if (this.game.parent !== "") {
16098
16108
  if (typeof this.game.parent === "string") target = document.querySelector(`#${CSS.escape(this.game.parent)}`);
16099
- else if (this.game.parent && this.game.parent.nodeType === 1) target = this.game.parent;
16109
+ else if (typeof this.game.parent === "object" && this.game.parent.nodeType === 1) target = this.game.parent;
16100
16110
  }
16101
16111
  if (!target) {
16102
16112
  this.parentNode = null;
@@ -16251,7 +16261,7 @@ var ScaleManager = class {
16251
16261
  this.aspectRatio = this.width / this.height;
16252
16262
  if (this.game.canvas) this.dom.getOffset(this.game.canvas, this.offset);
16253
16263
  this.bounds.setTo(this.offset.x, this.offset.y, this.width, this.height);
16254
- if (this.game.input && this.game.input.scale) this.game.input.scale.setTo(this.scaleFactor.x, this.scaleFactor.y);
16264
+ if (this.game.input) this.game.input.scale.setTo(this.scaleFactor.x, this.scaleFactor.y);
16255
16265
  }
16256
16266
  /**
16257
16267
  * TBD.
@@ -16352,7 +16362,7 @@ var ScaleManager = class {
16352
16362
  * @returns {Rectangle} TBD.
16353
16363
  */
16354
16364
  getParentBounds(target) {
16355
- const bounds = target || new Rectangle();
16365
+ const bounds = target ?? new Rectangle();
16356
16366
  const parentNode = this.boundingParent;
16357
16367
  const { visualBounds } = this.dom;
16358
16368
  const { layoutBounds } = this.dom;
@@ -16501,8 +16511,8 @@ var ScaleManager = class {
16501
16511
  this.width = bounds.width;
16502
16512
  this.height = bounds.height;
16503
16513
  if (this.isFullScreen) return;
16504
- if (this.maxWidth) this.width = Math.min(this.width, this.maxWidth);
16505
- if (this.maxHeight) this.height = Math.min(this.height, this.maxHeight);
16514
+ if (this.maxWidth !== null) this.width = Math.min(this.width, this.maxWidth);
16515
+ if (this.maxHeight !== null) this.height = Math.min(this.height, this.maxHeight);
16506
16516
  }
16507
16517
  /**
16508
16518
  * TBD.
@@ -16531,7 +16541,7 @@ var ScaleManager = class {
16531
16541
  }
16532
16542
  if (this.compatibility.clickTrampoline === "when-not-mouse") {
16533
16543
  const { input } = this.game;
16534
- if (input.activePointer && input.activePointer !== input.mousePointer && allowTrampoline) {
16544
+ if (input.activePointer !== null && input.activePointer !== input.mousePointer && allowTrampoline) {
16535
16545
  input.activePointer.addClickTrampoline("startFullScreen", this.startFullScreen, this, [antialias, false]);
16536
16546
  return false;
16537
16547
  }
@@ -16653,7 +16663,7 @@ var ScaleManager = class {
16653
16663
  */
16654
16664
  get boundingParent() {
16655
16665
  if (this.parentIsWindow || this.isFullScreen && this.hasPhaserSetFullScreen && !this._createdFullScreenTarget) return null;
16656
- return (this.game.canvas ? this.game.canvas.parentNode : null) ?? null;
16666
+ return this.game.canvas.parentNode ?? null ?? null;
16657
16667
  }
16658
16668
  /**
16659
16669
  * TBD.
@@ -16894,7 +16904,7 @@ var SceneManager = class {
16894
16904
  this._pendingState = key;
16895
16905
  this._clearWorld = clearWorld;
16896
16906
  this._clearCache = clearCache;
16897
- if (args && args.length > 0) this._args = [...args];
16907
+ if (args.length > 0) this._args = [...args];
16898
16908
  }
16899
16909
  }
16900
16910
  /**
@@ -16907,7 +16917,7 @@ var SceneManager = class {
16907
16917
  this._pendingState = this.current;
16908
16918
  this._clearWorld = clearWorld;
16909
16919
  this._clearCache = clearCache;
16910
- if (args && args.length > 0) this._args = [...args];
16920
+ if (args.length > 0) this._args = [...args];
16911
16921
  }
16912
16922
  /**
16913
16923
  * Pre-update the scene manager.
@@ -17125,7 +17135,7 @@ var Sound = class {
17125
17135
  * @param {boolean} connect - Whether to connect to the master gain node.
17126
17136
  */
17127
17137
  constructor(game, key, volume = 1, loop = false, connect = null) {
17128
- connect ??= game.sound.connectToMaster;
17138
+ const connectToMaster = connect ?? game.sound.connectToMaster;
17129
17139
  this.game = game;
17130
17140
  this.name = key;
17131
17141
  this.key = key;
@@ -17157,7 +17167,7 @@ var Sound = class {
17157
17167
  const gainNode = this.context.createGain === void 0 ? this.context.createGainNode() : this.context.createGain();
17158
17168
  this.gainNode = gainNode;
17159
17169
  gainNode.gain.value = volume * this.game.sound.volume;
17160
- if (connect && this.masterGainNode) gainNode.connect(this.masterGainNode);
17170
+ if (connectToMaster && this.masterGainNode !== null) gainNode.connect(this.masterGainNode);
17161
17171
  this.onPlay = new Signal();
17162
17172
  this.onPause = new Signal();
17163
17173
  this.onResume = new Signal();
@@ -17288,8 +17298,7 @@ var Sound = class {
17288
17298
  * @returns {Sound} This Sound instance for chaining.
17289
17299
  */
17290
17300
  play(marker = "", position = 0, volume = 1, loop = false, forceRestart = true) {
17291
- if (marker === void 0 || marker === false || marker === null) marker = "";
17292
- forceRestart ??= true;
17301
+ const markerName = marker === void 0 || marker === false || marker === null ? "" : marker;
17293
17302
  if (this.isPlaying && !this.allowMultiple && !forceRestart && !this.override) return this;
17294
17303
  if (this._sound && this.isPlaying && !this.allowMultiple && (this.override || forceRestart)) {
17295
17304
  if (this._sound.stop === void 0) this._sound.noteOff(0);
@@ -17298,11 +17307,11 @@ var Sound = class {
17298
17307
  else if (this.gainNode) this._sound.disconnect(this.gainNode);
17299
17308
  this.isPlaying = false;
17300
17309
  }
17301
- if (marker === "" && Object.keys(this.markers).length > 0) return this;
17302
- const markerData = marker === "" ? void 0 : this.markers[marker];
17303
- if (marker !== "") {
17310
+ if (markerName === "" && Object.keys(this.markers).length > 0) return this;
17311
+ const markerData = markerName === "" ? void 0 : this.markers[markerName];
17312
+ if (markerName !== "") {
17304
17313
  if (markerData) {
17305
- this.currentMarker = marker;
17314
+ this.currentMarker = markerName;
17306
17315
  this.position = markerData.start;
17307
17316
  this.volume = markerData.volume;
17308
17317
  this.loop = markerData.loop;
@@ -17310,43 +17319,40 @@ var Sound = class {
17310
17319
  this.durationMS = markerData.durationMS;
17311
17320
  if (volume !== void 0) this.volume = volume;
17312
17321
  if (loop !== void 0) this.loop = loop;
17313
- this._tempMarker = marker;
17322
+ this._tempMarker = markerName;
17314
17323
  this._tempPosition = this.position;
17315
17324
  this._tempVolume = this.volume;
17316
17325
  this._tempLoop = this.loop;
17317
17326
  } else {
17318
- this.game.logger.warn(`Sound.play: audio marker ${marker} does not exist`);
17327
+ this.game.logger.warn(`Sound.play: audio marker ${markerName} does not exist`);
17319
17328
  return this;
17320
17329
  }
17321
17330
  } else {
17322
- position ??= 0;
17323
- volume ??= this._volume;
17324
- if (loop === void 0) ({loop} = this);
17325
- this.position = Math.max(0, position);
17326
- this.volume = volume;
17327
- this.loop = loop;
17331
+ this.position = Math.max(0, position ?? 0);
17332
+ this.volume = volume ?? this._volume;
17333
+ this.loop = loop ?? this.loop;
17328
17334
  this.duration = 0;
17329
17335
  this.durationMS = 0;
17330
- this._tempMarker = marker;
17336
+ this._tempMarker = markerName;
17331
17337
  this._tempPosition = position;
17332
17338
  this._tempVolume = volume;
17333
17339
  this._tempLoop = loop;
17334
17340
  }
17335
- if (this.game.cache.isSoundDecoded(this.key)) {
17341
+ if (this.game.cache.isSoundDecoded(this.key) === true) {
17336
17342
  this._sound = this.context.createBufferSource();
17337
17343
  if (this.externalNode) this._sound.connect(this.externalNode);
17338
17344
  else this._sound.connect(this.gainNode);
17339
17345
  this._buffer = this.game.cache.getSoundData(this.key);
17340
17346
  this._sound.buffer = this._buffer;
17341
- if (this.loop && marker === "") this._sound.loop = true;
17342
- if (!this.loop && marker === "") this._sound.addEventListener("ended", this.onEndedHandler, { once: true });
17347
+ if (this.loop && markerName === "") this._sound.loop = true;
17348
+ if (!this.loop && markerName === "") this._sound.addEventListener("ended", this.onEndedHandler, { once: true });
17343
17349
  this.totalDuration = this._sound.buffer?.duration ?? 0;
17344
17350
  if (this.duration === 0) {
17345
17351
  this.duration = this.totalDuration;
17346
17352
  this.durationMS = Math.ceil(this.totalDuration * 1e3);
17347
17353
  }
17348
17354
  if (this._sound.start === void 0) this._sound.noteGrainOn(0, this.position, this.duration);
17349
- else if (this.loop && marker === "") this._sound.start(0, 0);
17355
+ else if (this.loop && markerName === "") this._sound.start(0, 0);
17350
17356
  else this._sound.start(0, this.position, this.duration);
17351
17357
  this.isPlaying = true;
17352
17358
  this.startTime = this.game.time.time;
@@ -17551,7 +17557,7 @@ var SoundSprite = class {
17551
17557
  sound.addMarker(markerKey, marker.start, marker.end - marker.start, void 0, marker.loop);
17552
17558
  this.sounds[markerKey] = sound;
17553
17559
  }
17554
- if (this.config.autoplay) {
17560
+ if (this.config.autoplay !== void 0) {
17555
17561
  this.autoplayKey = this.config.autoplay;
17556
17562
  this.play(this.autoplayKey);
17557
17563
  this.autoplay = this.sounds[this.autoplayKey];
@@ -17794,21 +17800,21 @@ var SoundManager = class {
17794
17800
  */
17795
17801
  stopAll() {
17796
17802
  if (this.noAudio) return;
17797
- for (const sound of this._sounds) if (sound) sound.stop();
17803
+ for (const sound of this._sounds) if (sound !== null) sound.stop();
17798
17804
  }
17799
17805
  /**
17800
17806
  * Pauses all sounds in the manager.
17801
17807
  */
17802
17808
  pauseAll() {
17803
17809
  if (this.noAudio) return;
17804
- for (const sound of this._sounds) if (sound) sound.pause();
17810
+ for (const sound of this._sounds) if (sound !== null) sound.pause();
17805
17811
  }
17806
17812
  /**
17807
17813
  * Resumes all sounds in the manager.
17808
17814
  */
17809
17815
  resumeAll() {
17810
17816
  if (this.noAudio) return;
17811
- for (const sound of this._sounds) if (sound) sound.resume();
17817
+ for (const sound of this._sounds) if (sound !== null) sound.resume();
17812
17818
  }
17813
17819
  /**
17814
17820
  * Decodes an audio file for playback.
@@ -17844,7 +17850,7 @@ var SoundManager = class {
17844
17850
  this._watchList.reset();
17845
17851
  for (const file of candidates) {
17846
17852
  const key = file instanceof Sound ? file.key : file;
17847
- if (!this.game.cache.isSoundDecoded(key)) this._watchList.add(key);
17853
+ if (this.game.cache.isSoundDecoded(key) !== true) this._watchList.add(key);
17848
17854
  }
17849
17855
  if (this._watchList.total === 0) {
17850
17856
  this._watching = false;
@@ -17863,8 +17869,8 @@ var SoundManager = class {
17863
17869
  for (const sound of this._sounds) sound.update();
17864
17870
  if (this._watching) {
17865
17871
  let key = this._watchList.first;
17866
- while (key) {
17867
- if (this.game.cache.isSoundDecoded(key)) this._watchList.remove(key);
17872
+ while (key !== null) {
17873
+ if (this.game.cache.isSoundDecoded(key) === true) this._watchList.remove(key);
17868
17874
  key = this._watchList.next;
17869
17875
  }
17870
17876
  if (this._watchList.total === 0) {
@@ -17969,7 +17975,7 @@ var SoundManager = class {
17969
17975
  */
17970
17976
  destroy() {
17971
17977
  this.stopAll();
17972
- for (const sound of this._sounds) if (sound) sound.destroy();
17978
+ for (const sound of this._sounds) if (sound !== null) sound.destroy();
17973
17979
  this._sounds = [];
17974
17980
  this.onChange.dispose();
17975
17981
  if (this.context?.close) this.context.close();
@@ -18006,11 +18012,10 @@ var SoundManager = class {
18006
18012
  * Sets the volume level of the sound manager.
18007
18013
  */
18008
18014
  set volume(value) {
18009
- if (value < 0) value = 0;
18010
- else if (value > 1) value = 1;
18011
- if (this._volume !== value) {
18012
- this._volume = value;
18013
- if (!this.noAudio) this.masterGain.gain.value = value;
18015
+ const level = Math.min(1, Math.max(0, value));
18016
+ if (this._volume !== level) {
18017
+ this._volume = level;
18018
+ if (!this.noAudio) this.masterGain.gain.value = level;
18014
18019
  }
18015
18020
  }
18016
18021
  };
@@ -18036,15 +18041,15 @@ var Stage = class extends DisplayObject {
18036
18041
  color: 0,
18037
18042
  rgba: "#000000"
18038
18043
  };
18039
- if (!game.config.transparent) this._bgColor.a = 1;
18040
- if (game.config.backgroundColor && !this.game.config.transparent) this.setBackgroundColor(game.config.backgroundColor);
18044
+ if (game.config.transparent === false) this._bgColor.a = 1;
18045
+ if (game.config.backgroundColor !== 0 && this.game.config.transparent === false) this.setBackgroundColor(game.config.backgroundColor);
18041
18046
  }
18042
18047
  /**
18043
18048
  * Sets the background color of the stage.
18044
18049
  * @param {number} color - The color to set as the background.
18045
18050
  */
18046
18051
  setBackgroundColor(color) {
18047
- if (this.game.config.transparent) return;
18052
+ if (this.game.config.transparent !== false) return;
18048
18053
  valueToColor(color, this._bgColor);
18049
18054
  this._bgColor.r /= 255;
18050
18055
  this._bgColor.g /= 255;
@@ -18326,7 +18331,7 @@ var Timer = class {
18326
18331
  this._i = this.events.length;
18327
18332
  while (this._i) {
18328
18333
  this._i -= 1;
18329
- if (this.events[this._i]?.pendingDelete) this.events.splice(this._i, 1);
18334
+ if (this.events[this._i]?.pendingDelete === true) this.events.splice(this._i, 1);
18330
18335
  }
18331
18336
  this._len = this.events.length;
18332
18337
  this._i = 0;
@@ -18842,14 +18847,15 @@ var TweenData = class {
18842
18847
  loadValues() {
18843
18848
  const keys = Object.keys(this.parent.properties);
18844
18849
  for (const property of keys) {
18845
- this.vStart[property] = this.parent.properties[property];
18846
- if (Array.isArray(this.vEnd[property])) {
18847
- if (this.vEnd[property].length === 0) {} else if (this.percent === 0) this.vEnd[property] = [this.vStart[property], ...this.vEnd[property]];
18848
- }
18849
- if (this.vEnd[property] !== void 0) {
18850
- if (typeof this.vEnd[property] === "string") this.vEnd[property] = this.vStart[property] + Number(this.vEnd[property]);
18850
+ const start = this.parent.properties[property];
18851
+ this.vStart[property] = start;
18852
+ const end = this.vEnd[property];
18853
+ if (Array.isArray(end) && end.length > 0 && this.percent === 0) this.vEnd[property] = [Number(start), ...end];
18854
+ if (end === void 0) this.vEnd[property] = start;
18855
+ else {
18856
+ if (typeof end === "string") this.vEnd[property] = Number(start) + Number(end);
18851
18857
  this.parent.properties[property] = this.vEnd[property];
18852
- } else this.vEnd[property] = this.vStart[property];
18858
+ }
18853
18859
  this.vStartCache[property] = this.vStart[property];
18854
18860
  this.vEndCache[property] = this.vEnd[property];
18855
18861
  }
@@ -18877,9 +18883,9 @@ var TweenData = class {
18877
18883
  this.value = this.easingFunction(this.percent);
18878
18884
  const keys = Object.keys(this.vEnd);
18879
18885
  for (const property of keys) {
18880
- const start = this.vStart[property];
18881
18886
  const end = this.vEnd[property];
18882
- this.parent.target[property] = Array.isArray(end) ? this.interpolationFunction.call(this.interpolationContext, end, this.value) : start + (end - start) * this.value;
18887
+ const start = Number(this.vStart[property]);
18888
+ this.parent.target[property] = Array.isArray(end) ? this.interpolationFunction.call(this.interpolationContext, end, this.value) : start + (Number(end) - start) * this.value;
18883
18889
  }
18884
18890
  if (!this.parent.reverse && this.percent === 1 || this.parent.reverse && this.percent === 0) return this.repeat();
18885
18891
  return 1;
@@ -18907,9 +18913,9 @@ var TweenData = class {
18907
18913
  const blob = {};
18908
18914
  const keys = Object.keys(this.vEnd);
18909
18915
  for (const property of keys) {
18910
- const start = this.vStart[property];
18911
18916
  const end = this.vEnd[property];
18912
- blob[property] = Array.isArray(end) ? this.interpolationFunction(end, this.value) : start + (end - start) * this.value;
18917
+ const start = Number(this.vStart[property]);
18918
+ blob[property] = Array.isArray(end) ? this.interpolationFunction(end, this.value) : start + (Number(end) - start) * this.value;
18913
18919
  }
18914
18920
  data.push(blob);
18915
18921
  if (!this.parent.reverse && this.percent === 1 || this.parent.reverse && this.percent === 0) complete = true;
@@ -19041,9 +19047,9 @@ var Tween = class {
19041
19047
  * @returns {Tween} This Tween object for chaining.
19042
19048
  */
19043
19049
  to(properties, duration = 1e3, ease = "Linear", autoStart = false, delay = 0, repeat = 0, yoyo = false) {
19044
- if (typeof ease === "string" && this.manager.easeMap[ease]) ease = this.manager.easeMap[ease];
19050
+ const easing = this.resolveEasing(ease);
19045
19051
  if (this.isRunning) return this;
19046
- this.timeline.push(new TweenData(this).to(properties, duration, ease, delay, repeat, yoyo));
19052
+ this.timeline.push(new TweenData(this).to(properties, duration, easing, delay, repeat, yoyo));
19047
19053
  if (autoStart) this.start();
19048
19054
  return this;
19049
19055
  }
@@ -19059,12 +19065,11 @@ var Tween = class {
19059
19065
  * @returns {Tween} This Tween object for chaining.
19060
19066
  */
19061
19067
  from(properties, duration = 1e3, ease = "Linear", autoStart = false, delay = 0, repeat = 0, yoyo = false) {
19062
- if (typeof ease === "string" && this.manager.easeMap[ease]) ease = this.manager.easeMap[ease];
19063
19068
  if (this.isRunning) {
19064
19069
  this.game.logger.warn("Tween.from cannot be called after Tween.start");
19065
19070
  return this;
19066
19071
  }
19067
- this.timeline.push(new TweenData(this).from(properties, duration, ease, delay, repeat, yoyo));
19072
+ this.timeline.push(new TweenData(this).from(properties, duration, this.resolveEasing(ease), delay, repeat, yoyo));
19068
19073
  if (autoStart) this.start();
19069
19074
  return this;
19070
19075
  }
@@ -19079,15 +19084,13 @@ var Tween = class {
19079
19084
  const keys = Object.keys(tweenData.vEnd);
19080
19085
  for (const property of keys) {
19081
19086
  const targetProperties = this.target;
19082
- this.properties[property] = targetProperties[property] ?? 0;
19083
- if (!Array.isArray(this.properties[property])) this.properties[property] *= 1;
19087
+ this.properties[property] = Number(targetProperties[property] ?? 0);
19084
19088
  }
19085
19089
  }
19086
19090
  for (const tweenData of this.timeline) tweenData.loadValues();
19087
19091
  this.manager.add(this);
19088
19092
  this.isRunning = true;
19089
- if (index < 0 || index > this.timeline.length - 1) index = 0;
19090
- this.current = index;
19093
+ this.current = index < 0 || index > this.timeline.length - 1 ? 0 : index;
19091
19094
  this.timeline[this.current].start();
19092
19095
  return this;
19093
19096
  }
@@ -19176,9 +19179,18 @@ var Tween = class {
19176
19179
  * @param {number} index - The index in the timeline to apply easing to.
19177
19180
  * @returns {Tween} This Tween object for chaining.
19178
19181
  */
19182
+ resolveEasing(ease) {
19183
+ if (typeof ease !== "string") return ease;
19184
+ return this.manager.easeMap[ease] ?? this.manager.easeMap["Linear"];
19185
+ }
19186
+ /**
19187
+ * Sets the easing function for a tween in the timeline.
19188
+ * @param {string | Function} ease - The easing function or its name.
19189
+ * @param {number} index - The index of the tween in the timeline.
19190
+ * @returns {Tween} This Tween object for chaining.
19191
+ */
19179
19192
  easing(ease, index) {
19180
- if (typeof ease === "string" && this.manager.easeMap[ease]) ease = this.manager.easeMap[ease];
19181
- return this.updateTweenData("easingFunction", ease, index);
19193
+ return this.updateTweenData("easingFunction", this.resolveEasing(ease), index);
19182
19194
  }
19183
19195
  /**
19184
19196
  * Sets the interpolation function for a timeline entry.
@@ -19338,13 +19350,13 @@ var Tween = class {
19338
19350
  const keys = Object.keys(tweenData.vEnd);
19339
19351
  for (const property of keys) {
19340
19352
  const targetProperties = this.target;
19341
- this.properties[property] = targetProperties[property] ?? 0;
19342
- if (!Array.isArray(this.properties[property])) this.properties[property] *= 1;
19353
+ this.properties[property] = Number(targetProperties[property] ?? 0);
19343
19354
  }
19344
19355
  }
19345
19356
  for (const tweenData of this.timeline) tweenData.loadValues();
19346
- for (const tweenData of this.timeline) data = [...data, ...tweenData.generateData(frameRate)];
19347
- return data;
19357
+ const frames = [...data];
19358
+ for (const tweenData of this.timeline) frames.push(...tweenData.generateData(frameRate));
19359
+ return frames;
19348
19360
  }
19349
19361
  /**
19350
19362
  * Gets the total duration of all timeline entries.
@@ -19950,8 +19962,8 @@ var Game = class {
19950
19962
  this.input.boot();
19951
19963
  this.sound.boot();
19952
19964
  this.state.boot();
19953
- if (window.focus) window.focus();
19954
- if (!this.config.isSkipTicker) {
19965
+ if (typeof window.focus === "function") window.focus();
19966
+ if (this.config.isSkipTicker !== true) {
19955
19967
  this.raf = new RequestAnimationFrame(this);
19956
19968
  this.raf.start();
19957
19969
  }
@@ -19986,8 +19998,8 @@ var Game = class {
19986
19998
  isWebGlReady = true;
19987
19999
  } catch (error) {
19988
20000
  isWebGlReady = false;
19989
- if (globalThis.PhaserRegistry?.GL_PROGRAM_INFO_LOG) this.logger.warn("WebGL program info", { log: globalThis.PhaserRegistry.GL_PROGRAM_INFO_LOG });
19990
- if (globalThis.PhaserRegistry?.GL_SHADER_INFO_LOG) this.logger.warn("WebGL shader info", { log: globalThis.PhaserRegistry.GL_SHADER_INFO_LOG });
20001
+ if (globalThis.PhaserRegistry?.GL_PROGRAM_INFO_LOG != null) this.logger.warn("WebGL program info", { log: globalThis.PhaserRegistry.GL_PROGRAM_INFO_LOG });
20002
+ if (globalThis.PhaserRegistry?.GL_SHADER_INFO_LOG != null) this.logger.warn("WebGL shader info", { log: globalThis.PhaserRegistry.GL_SHADER_INFO_LOG });
19991
20003
  const typedError = error instanceof Error ? error : new Error(String(error));
19992
20004
  this.logger.fatal("Game", { error: typedError });
19993
20005
  }
@@ -20035,7 +20047,7 @@ var Game = class {
20035
20047
  this.parseConfigElement(config, "renderType", 0);
20036
20048
  this.parseConfigElement(config, "isForceDisabledAudio", false);
20037
20049
  this.parseConfigElement(config, "maxParallelDownloads", 16);
20038
- if (config.parent) this.parent = config.parent;
20050
+ if (config.parent !== void 0) this.parent = config.parent;
20039
20051
  this.state = new SceneManager(this, config.state ?? null);
20040
20052
  }
20041
20053
  /**