@zylem/game-lib 0.7.0 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/README.md +15 -1
  2. package/dist/actions.d.ts +71 -8
  3. package/dist/actions.js +1 -1
  4. package/dist/api/game-lib.api.json +55350 -0
  5. package/dist/api/game-lib.api.md +4608 -0
  6. package/dist/api/game-lib.d.ts +8447 -0
  7. package/dist/api/game-lib.typedoc.json +352456 -0
  8. package/dist/audio.js +1 -1
  9. package/dist/{base-node-life-cycle-CnJ-7zX-.d.ts → base-node-life-cycle-BK9xebT9.d.ts} +18 -4
  10. package/dist/behavior.d.ts +2 -3
  11. package/dist/behavior.js +1 -1
  12. package/dist/blueprints-TbGY-h53.d.ts +162 -0
  13. package/dist/chunk-3PRBSSTS.js +24 -0
  14. package/dist/chunk-47DG7I7M.js +1 -0
  15. package/dist/chunk-7GYFZKK7.js +1 -0
  16. package/dist/chunk-7QF6YTEZ.js +1 -0
  17. package/dist/chunk-7WRQ2UAN.js +1 -0
  18. package/dist/chunk-BH53MBAZ.js +1 -0
  19. package/dist/chunk-BIGH6D34.js +0 -0
  20. package/dist/chunk-CD7ZOZ35.js +1 -0
  21. package/dist/chunk-CFVRRRZZ.js +1 -0
  22. package/dist/chunk-CM5YRNBJ.js +19 -0
  23. package/dist/chunk-COM6HJ2L.js +1 -0
  24. package/dist/chunk-D2PATZCC.js +1 -0
  25. package/dist/chunk-DFLI7ICU.js +0 -0
  26. package/dist/chunk-EVYHPR3J.js +1 -0
  27. package/dist/chunk-IPWUDOV5.js +1 -0
  28. package/dist/chunk-JNFFTNMH.js +1 -0
  29. package/dist/chunk-JQKS42G4.js +1 -0
  30. package/dist/chunk-KVSJE4XD.js +1 -0
  31. package/dist/chunk-MZZCDXFB.js +1 -0
  32. package/dist/chunk-ORIDWL3T.js +0 -0
  33. package/dist/{chunk-RXDTAWI2.js → chunk-PCFF4LLO.js} +1 -1
  34. package/dist/chunk-QB3NL7VQ.js +1 -0
  35. package/dist/chunk-TAUWDQZF.js +9 -0
  36. package/dist/chunk-UG22Z42P.js +1 -0
  37. package/dist/chunk-VS2D4B3W.js +1 -0
  38. package/dist/chunk-WQ3WMMZD.js +1 -0
  39. package/dist/chunk-XK63E4SX.js +1 -0
  40. package/dist/chunk-YAOXFYOD.js +1 -0
  41. package/dist/chunk-ZRT3ZQVH.js +1 -0
  42. package/dist/collision-builder-B_tm8OVy.d.ts +49 -0
  43. package/dist/core.d.ts +45 -30
  44. package/dist/core.js +1 -24
  45. package/dist/debug-state-DRoeasG2.d.ts +17 -0
  46. package/dist/debug.d.ts +71 -19
  47. package/dist/debug.js +1 -1
  48. package/dist/{default-controls-BGc61yYl.d.ts → default-controls-CAKJ5zlo.d.ts} +3 -3
  49. package/dist/entity-B9yZeBm4.d.ts +34 -0
  50. package/dist/{entity-DNkYKfdp.d.ts → entity-BGEq1yfC.d.ts} +91 -444
  51. package/dist/{entity-type-map-C94h2TDW.d.ts → entity-type-map-CW6RHQkx.d.ts} +153 -6
  52. package/dist/entity.d.ts +15 -10
  53. package/dist/entity.js +1 -1
  54. package/dist/events.d.ts +10 -1
  55. package/dist/events.js +1 -1
  56. package/dist/{game-Cuj5gy7U.d.ts → game-DbqBQiFC.d.ts} +460 -135
  57. package/dist/game-default-6AZZCNST.js +1 -0
  58. package/dist/{game-interfaces-tfpM5NBk.d.ts → game-interfaces-vF5sRi1n.d.ts} +8 -2
  59. package/dist/globals.d.ts +12 -1
  60. package/dist/globals.js +1 -1
  61. package/dist/graphics.d.ts +16 -46
  62. package/dist/graphics.js +1 -1
  63. package/dist/input-ui.d.ts +5 -4
  64. package/dist/input-ui.js +1 -1
  65. package/dist/input.d.ts +48 -4
  66. package/dist/input.js +1 -1
  67. package/dist/{material-Wz83vTTp.d.ts → material-DbSuZBbP.d.ts} +25 -50
  68. package/dist/public.d.ts +38 -0
  69. package/dist/public.js +1 -0
  70. package/dist/runtime.d.ts +7 -381
  71. package/dist/runtime.js +1 -1
  72. package/dist/schema/entity.schema.json +244 -0
  73. package/dist/schema/game-config.schema.json +643 -0
  74. package/dist/schema/input-config.schema.json +517 -0
  75. package/dist/schema/stage-config.schema.json +93 -0
  76. package/dist/schema/stage.schema.json +271 -0
  77. package/dist/schema.d.ts +550 -0
  78. package/dist/schema.js +1 -0
  79. package/dist/stage-transition-CmGpV4tc.d.ts +46 -0
  80. package/dist/vector-DN6zlPoE.d.ts +161 -0
  81. package/dist/web-components.d.ts +15 -12
  82. package/dist/web-components.js +1 -9
  83. package/dist/{zylem-stage-runtime-Cs-UDEVU.d.ts → zylem-camera-Du2UPW9O.d.ts} +74 -264
  84. package/package.json +28 -20
  85. package/dist/chunk-73VZQZUL.js +0 -1
  86. package/dist/chunk-A34ZG3L4.js +0 -1
  87. package/dist/chunk-CDPY4VOQ.js +0 -1
  88. package/dist/chunk-DR6XXZE7.js +0 -19
  89. package/dist/chunk-FM5TBEPO.js +0 -1
  90. package/dist/chunk-G2IIMSUH.js +0 -1
  91. package/dist/chunk-MSC2BEO5.js +0 -1
  92. package/dist/chunk-NIH5CONO.js +0 -1
  93. package/dist/chunk-ONWXGBWB.js +0 -1
  94. package/dist/chunk-QEDQDR27.js +0 -1
  95. package/dist/chunk-WKHW2QO2.js +0 -1
  96. package/dist/chunk-YHKXQ2ZN.js +0 -1
  97. package/dist/game-default-PZLLHYL7.js +0 -1
  98. package/dist/world-C9zdyl5d.d.ts +0 -103
package/dist/audio.js CHANGED
@@ -1 +1 @@
1
- function r(i=800,t=.05){c(i,t)}function c(i,t){let e=new(window.AudioContext||window.webkitAudioContext),n=e.createOscillator(),o=e.createGain();n.type="sawtooth",n.frequency.value=i,o.gain.setValueAtTime(.05,e.currentTime),o.gain.exponentialRampToValueAtTime(.001,e.currentTime+t),n.connect(o),o.connect(e.destination),n.start(),n.stop(e.currentTime+t)}function a(i=440,t=.1){u(i,t)}function u(i,t){let e=new(window.AudioContext||window.webkitAudioContext),n=e.createOscillator(),o=e.createGain();n.type="square",n.frequency.value=i,o.gain.setValueAtTime(.05,e.currentTime),o.gain.exponentialRampToValueAtTime(.001,e.currentTime+t),n.connect(o),o.connect(e.destination),n.start(),n.stop(e.currentTime+t)}import{Howl as x}from"howler";export{x as Howl,a as pingPongBeep,r as ricochetSound};
1
+ import{a,b,c}from"./chunk-ZRT3ZQVH.js";export{c as Howl,b as pingPongBeep,a as ricochetSound};
@@ -1,4 +1,5 @@
1
1
  import { Vector3 } from 'three';
2
+ import { S as StageTransitionConfig } from './stage-transition-CmGpV4tc.js';
2
3
 
3
4
  /** Input
4
5
  *
@@ -47,8 +48,14 @@ interface InputGamepad {
47
48
  };
48
49
  /** Screen-space cursor position (normalized 0..1). Only populated by MouseProvider. */
49
50
  pointer?: {
51
+ /** Window-normalized X (0 = left, 1 = right). */
50
52
  x: number;
53
+ /** Window-normalized Y (0 = top, 1 = bottom). */
51
54
  y: number;
55
+ /** Canvas-center-relative X (−1 = left edge, +1 = right edge). */
56
+ centerX: number;
57
+ /** Canvas-center-relative Y (−1 = top edge, +1 = bottom edge). */
58
+ centerY: number;
52
59
  };
53
60
  }
54
61
  type Inputs = Record<InputPlayer, InputGamepad>;
@@ -67,11 +74,18 @@ type LoadingEvent = {
67
74
  total?: number;
68
75
  current?: number;
69
76
  };
77
+ /**
78
+ * Options for stage navigation (`nextStage` / `previousStage` / `reset`).
79
+ */
80
+ interface StageNavigationOptions {
81
+ /** Visual transition to blend from the outgoing stage to the incoming one. */
82
+ transition?: StageTransitionConfig;
83
+ }
70
84
  interface IGame<TGlobals extends Record<string, unknown> = any> {
71
85
  start: () => Promise<this>;
72
- nextStage: () => void;
73
- previousStage: () => void;
74
- reset: () => Promise<void>;
86
+ nextStage: (options?: StageNavigationOptions) => void;
87
+ previousStage: (options?: StageNavigationOptions) => void;
88
+ reset: (options?: StageNavigationOptions) => Promise<void>;
75
89
  pause: () => Promise<void>;
76
90
  resume: () => Promise<void>;
77
91
  onLoading: (callback: (event: LoadingEvent) => void) => void;
@@ -140,4 +154,4 @@ interface CleanupFunction<T, TGlobals extends GlobalRecord = any> {
140
154
  (context: CleanupContext<T, TGlobals>): void;
141
155
  }
142
156
 
143
- export type { AnalogState as A, ButtonState as B, CleanupContext as C, DestroyContext as D, InputPlayer as I, LoadedContext as L, SetupContext as S, UpdateFunction as U, Inputs as a, InputGamepad as b, ButtonName as c, InputPlayerNumber as d, InputProvider as e, UpdateContext as f, LoadingEvent as g, SetupFunction as h, LoadedFunction as i, DestroyFunction as j, CleanupFunction as k, IGame as l };
157
+ export type { AnalogState as A, ButtonState as B, CleanupFunction as C, DestroyContext as D, Inputs as I, LoadingEvent as L, StageNavigationOptions as S, UpdateContext as U, SetupContext as a, InputPlayer as b, InputGamepad as c, ButtonName as d, InputPlayerNumber as e, InputProvider as f, UpdateFunction as g, SetupFunction as h, LoadedFunction as i, DestroyFunction as j, LoadedContext as k, CleanupContext as l, IGame as m };
@@ -1,3 +1,2 @@
1
- export { Behavior, BehaviorDescriptor, BehaviorHandle, BehaviorRef, BehaviorSystem, BehaviorSystemFactory, BoundaryRicochet3DCoordinator, BoundaryRicochetCoordinator, BurstParticlePresetOptions, CooldownBehavior, CooldownConfig, CooldownEntry, CooldownHandle, CooldownOptions, DefineBehaviorConfig, Destructible3DBehavior, Destructible3DBehaviorOptions, Destructible3DColliderOptions, Destructible3DFragmentColliderShape, Destructible3DFragmentPhysicsOptions, Destructible3DHandle, DestructibleMesh, DestructiblePrebakeWorkerAPI, FirstPersonContext, FirstPersonController, FirstPersonControllerBehavior, FirstPersonControllerOptions, FirstPersonEntity, FirstPersonEvent, FirstPersonFSM, FirstPersonInputComponent, FirstPersonMovementComponent, FirstPersonShooterCoordinator, FirstPersonShooterInput, FirstPersonState, FirstPersonStateComponent, FractureOptions, FractureOptionsInput, JumpConfig2D, JumpConfig3D, JumpContext2D, JumpContext3D, JumpInput2D, JumpInput3D, JumpState2D, JumpState3D, Jumper2D, Jumper2DBehavior, Jumper2DBehaviorOptions, Jumper2DEntity, Jumper2DEvent, Jumper2DFSM, Jumper2DState, Jumper2DTickEvent, Jumper2DTickResult, Jumper3D, Jumper3DBehavior, Jumper3DBehaviorOptions, Jumper3DEntity, Jumper3DEvent, Jumper3DFSM, Jumper3DState, JumperTickEvent, JumperTickResult, MultidirectionalSpaceShooterCoordinator, MultidirectionalSpaceShooterInput, ParticleEffectDefinition, ParticleEmitterBehavior, ParticleEmitterBehaviorOptions, ParticleEmitterHandle, ParticleMagicAgency, ParticleMagicAlignment, ParticleMagicModifierInput, ParticleMagicModifierOptions, ParticleMagicOrder, ParticleMagicRealityEffect, ParticleMagicTemperament, ParticlePresetMaterialOptions, PhysicsBodyComponent, PlainBufferGeometryPayload, PlainFractureOptions, Platformer3DBehavior, Platformer3DBehaviorOptions, Platformer3DContext, Platformer3DEntity, Platformer3DEvent, Platformer3DFSM, Platformer3DInputComponent, Platformer3DMovementBehavior, Platformer3DMovementComponent, Platformer3DState, Platformer3DStateComponent, PlatformerCollisionContext, PlayerInput, PrebakeWorkerRequest, PrebakeWorkerResponse, Ricochet2DBehavior, Ricochet2DCollisionContext, Ricochet2DEvent, Ricochet2DFSM, Ricochet2DHandle, Ricochet2DOptions, Ricochet2DResult, Ricochet2DState, Ricochet3DBehavior, Ricochet3DCallback, Ricochet3DCollisionContext, Ricochet3DEvent, Ricochet3DFSM, Ricochet3DHandle, Ricochet3DOptions, Ricochet3DResult, Ricochet3DState, RicochetCallback, ScreenVisibilityBehavior, ScreenVisibilityChangeContext, ScreenVisibilityFSM, ScreenVisibilityHandle, ScreenVisibilityOptions, ScreenVisibilitySize, ScreenVisibilitySnapshot, ScreenWrapBehavior, ScreenWrapEvent, ScreenWrapFSM, ScreenWrapOptions, ScreenWrapState, SemanticParticlePresetOptions, Shooter2DBehavior, Shooter2DBehaviorOptions, Shooter2DFireArgs, Shooter2DHandle, Shooter2DProjectileFactory, Shooter2DSourceEntity, Shooter2DStageLike, Shooter2DStateComponent, Shooter2DTarget, ThrusterBehavior, ThrusterBehaviorOptions, ThrusterEntity, ThrusterEvent, ThrusterFSM, ThrusterFSMContext, ThrusterInputComponent, ThrusterMovementBehavior, ThrusterMovementComponent, ThrusterState, ThrusterStateComponent, TopDownMovementBehavior, TopDownMovementBehaviorOptions, TopDownMovementComponent, TopDownMovementEntity, TopDownMovementHandle, TopDownMovementInputComponent, TopDownMovementRuntimeBehavior, TopDownMovementStateComponent, TopDownShooterCoordinator, TopDownShooterInput, TransformComponent, Vec3Like, ViewmodelConfig, VoronoiOptions, WorldBoundary2DBehavior, WorldBoundary2DBounds, WorldBoundary2DEvent, WorldBoundary2DFSM, WorldBoundary2DHandle, WorldBoundary2DHit, WorldBoundary2DHits, WorldBoundary2DOptions, WorldBoundary2DPosition, WorldBoundary2DState, WorldBoundary3DBehavior, WorldBoundary3DBounds, WorldBoundary3DEvent, WorldBoundary3DFSM, WorldBoundary3DHandle, WorldBoundary3DHit, WorldBoundary3DHits, WorldBoundary3DOptions, WorldBoundary3DPosition, WorldBoundary3DState, computeWorldBoundary2DHits, computeWorldBoundary3DHits, createFirstPersonInputComponent, createFirstPersonMovementComponent, createFirstPersonStateComponent, createJumpConfig2D, createJumpConfig3D, createJumpInput2D, createJumpInput3D, createJumpState2D, createJumpState3D, createPhysicsBodyComponent, createPlatformer3DInputComponent, createPlatformer3DMovementComponent, createPlatformer3DStateComponent, createShooter2DStateComponent, createThrusterInputComponent, createThrusterMovementComponent, createThrusterStateComponent, createTopDownMovementComponent, createTopDownMovementInputComponent, createTopDownMovementStateComponent, createTransformComponent, defineBehavior, fireCooldown, getCooldown, getCooldownStore, hasAnyWorldBoundary2DHit, hasAnyWorldBoundary3DHit, particleEffect, particlePresets, registerCooldown, resetCooldown, tickCooldowns, useBehavior } from '@zylem/behaviors';
2
- export { RUNTIME_GOAL_ZONE_2D_BEHAVIOR_KEY, RUNTIME_PADDLE_INPUT_2D_BEHAVIOR_KEY, RUNTIME_PONG_BALL_BEHAVIOR_KEY, RUNTIME_RICOCHET_2D_BEHAVIOR_KEY, RUNTIME_TRIGGER_REGION_2D_BEHAVIOR_KEY, RUNTIME_WORLD_BOUNDARY_2D_BEHAVIOR_KEY, RuntimeGoalZone2DBehavior, RuntimeGoalZone2DEvent, RuntimeGoalZone2DHandle, RuntimeGoalZone2DOptions, RuntimePaddleInput2DBehavior, RuntimePaddleInput2DOptions, RuntimePongBallBehavior, RuntimePongBallHandle, RuntimePongBallOptions, RuntimeRicochet2DBehavior, RuntimeRicochet2DEvent, RuntimeRicochet2DHandle, RuntimeRicochet2DOptions, RuntimeTriggerRegion2DBehavior, RuntimeTriggerRegion2DEvent, RuntimeTriggerRegion2DHandle, RuntimeTriggerRegion2DOptions, RuntimeWorldBoundary2DBehavior, RuntimeWorldBoundary2DOptions, bindRuntimePongBallHandle, emitRuntimeGoal, emitRuntimeRicochet, emitRuntimeTriggerRegionEnter } from '@zylem/behaviors/runtime-pong';
3
- export { RUNTIME_BOUNDARY_2D_BEHAVIOR_KEY, RUNTIME_DYNAMIC_CIRCLE_BODY_2D_BEHAVIOR_KEY, RUNTIME_PLAYER_INPUT_2D_BEHAVIOR_KEY, RuntimeBoundary2DBehavior, RuntimeBoundary2DOptions, RuntimeDynamicCircleBody2DBehavior, RuntimeDynamicCircleBody2DHandle, RuntimeDynamicCircleBody2DOptions, RuntimePlayerInput2DBehavior, RuntimePlayerInput2DOptions, RuntimeRicochet2DBehavior as RuntimeRicochet2DDescriptor, RuntimeTriggerRegion2DBehavior as RuntimeTriggerRegion2DDescriptor, bindRuntimeDynamicCircleBody2DHandle } from '@zylem/behaviors/runtime-2d';
1
+ export { BehaviorDescriptor, BehaviorHandle, BehaviorRef, BehaviorSystem, BehaviorSystemFactory, BoundaryRicochet3DCoordinator, BoundaryRicochet3DEntity, BoundaryRicochetCoordinator, BoundaryRicochetEntity, BoundaryRicochetUpdate, BurstParticlePresetOptions, CooldownBehavior, CooldownConfig, CooldownEntry, CooldownHandle, CooldownOptions, DefineBehaviorConfig, Destructible3DBehavior, Destructible3DBehaviorOptions, Destructible3DColliderOptions, Destructible3DFragmentColliderShape, Destructible3DFragmentPhysicsOptions, Destructible3DHandle, DestructibleMesh, DestructiblePrebakeWorkerAPI, FacingAngle2DEntity, FirstPersonBehavior, FirstPersonBehaviorOptions, FirstPersonContext, FirstPersonEntity, FirstPersonEvent, FirstPersonFSM, FirstPersonInputComponent, FirstPersonMovementComponent, FirstPersonPresentation, FirstPersonShooterCoordinator, FirstPersonShooterEntity, FirstPersonShooterInput, FirstPersonState, FirstPersonStateComponent, FractureOptions, FractureOptionsInput, JumpConfig2D, JumpConfig3D, JumpContext2D, JumpContext3D, JumpInput2D, JumpInput3D, JumpState2D, JumpState3D, Jumper2DBehavior, Jumper2DBehaviorOptions, Jumper2DEntity, Jumper2DEvent, Jumper2DFSM, Jumper2DState, Jumper3DBehavior, Jumper3DBehaviorOptions, Jumper3DEntity, Jumper3DEvent, Jumper3DFSM, Jumper3DState, MultidirectionalSpaceShooterCoordinator, MultidirectionalSpaceShooterEntity, MultidirectionalSpaceShooterInput, ParticleEffectDefinition, ParticleEmitterBehavior, ParticleEmitterBehaviorOptions, ParticleEmitterHandle, ParticleMagicAgency, ParticleMagicAlignment, ParticleMagicModifierInput, ParticleMagicModifierOptions, ParticleMagicOrder, ParticleMagicRealityEffect, ParticleMagicTemperament, ParticlePresetMaterialOptions, PhysicsBodyComponent, PlainBufferGeometryPayload, PlainFractureOptions, Platformer2DBehavior, Platformer2DBehaviorOptions, Platformer2DCollisionContext, Platformer2DContext, Platformer2DEntity, Platformer2DEvent, Platformer2DFSM, Platformer2DInputComponent, Platformer2DMovementComponent, Platformer2DState, Platformer2DStateComponent, Platformer3DBehavior, Platformer3DBehaviorOptions, Platformer3DContext, Platformer3DEntity, Platformer3DEvent, Platformer3DFSM, Platformer3DInputComponent, Platformer3DMovementComponent, Platformer3DState, Platformer3DStateComponent, PlatformerCollisionContext, PlayerInput, PrebakeWorkerRequest, PrebakeWorkerResponse, ResolvedAim2D, Ricochet2DBehavior, Ricochet2DCollisionContext, Ricochet2DEvent, Ricochet2DFSM, Ricochet2DHandle, Ricochet2DOptions, Ricochet2DResult, Ricochet2DState, Ricochet3DBehavior, Ricochet3DCallback, Ricochet3DCollisionContext, Ricochet3DEvent, Ricochet3DFSM, Ricochet3DHandle, Ricochet3DOptions, Ricochet3DResult, Ricochet3DState, RicochetCallback, ScreenVisibilityBehavior, ScreenVisibilityChangeContext, ScreenVisibilityFSM, ScreenVisibilityHandle, ScreenVisibilityOptions, ScreenVisibilitySize, ScreenVisibilitySnapshot, ScreenWrapBehavior, ScreenWrapEvent, ScreenWrapFSM, ScreenWrapOptions, ScreenWrapState, SemanticParticlePresetOptions, Shooter2DAimFireInput, Shooter2DBehavior, Shooter2DBehaviorOptions, Shooter2DFireArgs, Shooter2DHandle, Shooter2DProjectileFactory, Shooter2DSourceEntity, Shooter2DStageLike, Shooter2DStateComponent, Shooter2DTarget, ThrusterBehavior, ThrusterBehaviorOptions, ThrusterEntity, ThrusterEvent, ThrusterFSM, ThrusterFSMContext, ThrusterInputComponent, ThrusterMovementComponent, ThrusterState, ThrusterStateComponent, TopDownMovementBehavior, TopDownMovementBehaviorOptions, TopDownMovementComponent, TopDownMovementEntity, TopDownMovementHandle, TopDownMovementInputComponent, TopDownMovementStateComponent, TopDownShooterCoordinator, TopDownShooterEntity, TopDownShooterInput, TransformComponent, Vec3Like, ViewmodelConfig, VoronoiOptions, WorldBoundary2DBehavior, WorldBoundary2DBounds, WorldBoundary2DEvent, WorldBoundary2DFSM, WorldBoundary2DHandle, WorldBoundary2DHit, WorldBoundary2DHits, WorldBoundary2DOptions, WorldBoundary2DPosition, WorldBoundary2DState, WorldBoundary3DBehavior, WorldBoundary3DBounds, WorldBoundary3DEvent, WorldBoundary3DFSM, WorldBoundary3DHandle, WorldBoundary3DHit, WorldBoundary3DHits, WorldBoundary3DOptions, WorldBoundary3DPosition, WorldBoundary3DState, computeWorldBoundary2DHits, computeWorldBoundary3DHits, createFirstPersonInputComponent, createFirstPersonMovementComponent, createFirstPersonStateComponent, createJumpConfig2D, createJumpConfig3D, createJumpInput2D, createJumpInput3D, createJumpState2D, createJumpState3D, createPhysicsBodyComponent, createPlatformer2DInputComponent, createPlatformer2DMovementComponent, createPlatformer2DStateComponent, createPlatformer3DInputComponent, createPlatformer3DMovementComponent, createPlatformer3DStateComponent, createShooter2DStateComponent, createThrusterInputComponent, createThrusterMovementComponent, createThrusterStateComponent, createTopDownMovementComponent, createTopDownMovementInputComponent, createTopDownMovementStateComponent, createTransformComponent, defineBehavior, fireCooldown, fireShooter2DIfRequested, getCooldown, getCooldownStore, getEntityFacingAngle2D, hasAnyWorldBoundary2DHit, hasAnyWorldBoundary3DHit, particleEffect, particlePresets, registerCooldown, resetCooldown, resolveAim2D, tickCooldowns, updateBoundaryRicochet, useBehavior } from '@zylem/behaviors';
2
+ export { RUNTIME_BOUNDARY_2D_BEHAVIOR_KEY, RUNTIME_DYNAMIC_CIRCLE_BODY_2D_BEHAVIOR_KEY, RUNTIME_GOAL_ZONE_2D_BEHAVIOR_KEY, RUNTIME_PLAYER_INPUT_2D_BEHAVIOR_KEY, RUNTIME_RICOCHET_2D_BEHAVIOR_KEY, RUNTIME_TRIGGER_REGION_2D_BEHAVIOR_KEY, RuntimeBoundary2DBehavior, RuntimeBoundary2DOptions, RuntimeDynamicCircleBody2DBehavior, RuntimeDynamicCircleBody2DHandle, RuntimeDynamicCircleBody2DOptions, RuntimeGoalZone2DBehavior, RuntimeGoalZone2DEvent, RuntimeGoalZone2DHandle, RuntimeGoalZone2DOptions, RuntimePlayerInput2DBehavior, RuntimePlayerInput2DOptions, RuntimeRicochet2DBehavior, RuntimeRicochet2DEvent, RuntimeRicochet2DHandle, RuntimeRicochet2DOptions, RuntimeTriggerRegion2DBehavior, RuntimeTriggerRegion2DEvent, RuntimeTriggerRegion2DHandle, RuntimeTriggerRegion2DOptions, bindRuntimeDynamicCircleBody2DHandle, emitRuntimeGoal, emitRuntimeRicochet, emitRuntimeTriggerRegionEnter } from '@zylem/behaviors/runtime-2d';
package/dist/behavior.js CHANGED
@@ -1 +1 @@
1
- import{BoundaryRicochet3DCoordinator as t,BoundaryRicochetCoordinator as r,CooldownBehavior as n,Destructible3DBehavior as i,DestructibleMesh as a,FirstPersonController as D,FirstPersonControllerBehavior as m,FirstPersonEvent as l,FirstPersonFSM as u,FirstPersonShooterCoordinator as p,FirstPersonState as c,FractureOptions as s,Jumper2D as h,Jumper2DBehavior as d,Jumper2DEvent as R,Jumper2DFSM as B,Jumper2DState as v,Jumper2DTickEvent as C,Jumper3D as y,Jumper3DBehavior as P,Jumper3DEvent as S,Jumper3DFSM as E,Jumper3DState as T,JumperTickEvent as M,MultidirectionalSpaceShooterCoordinator as O,ParticleEmitterBehavior as g,Platformer3DBehavior as I,Platformer3DEvent as f,Platformer3DFSM as _,Platformer3DMovementBehavior as F,Platformer3DState as H,Ricochet2DBehavior as W,Ricochet2DEvent as J,Ricochet2DFSM as b,Ricochet2DState as w,Ricochet3DBehavior as A,Ricochet3DEvent as V,Ricochet3DFSM as N,Ricochet3DState as x,ScreenVisibilityBehavior as k,ScreenVisibilityFSM as Y,ScreenWrapBehavior as U,ScreenWrapEvent as G,ScreenWrapFSM as K,ScreenWrapState as L,Shooter2DBehavior as Z,ThrusterBehavior as z,ThrusterEvent as j,ThrusterFSM as q,ThrusterMovementBehavior as Q,ThrusterState as X,TopDownMovementBehavior as $,TopDownMovementRuntimeBehavior as ee,TopDownShooterCoordinator as oe,WorldBoundary2DBehavior as te,WorldBoundary2DEvent as re,WorldBoundary2DFSM as ne,WorldBoundary2DState as ie,WorldBoundary3DBehavior as ae,WorldBoundary3DEvent as De,WorldBoundary3DFSM as me,WorldBoundary3DState as le,computeWorldBoundary2DHits as ue,computeWorldBoundary3DHits as pe,createFirstPersonInputComponent as ce,createFirstPersonMovementComponent as se,createFirstPersonStateComponent as he,createJumpConfig2D as de,createJumpConfig3D as Re,createJumpInput2D as Be,createJumpInput3D as ve,createJumpState2D as Ce,createJumpState3D as ye,createPhysicsBodyComponent as Pe,createPlatformer3DInputComponent as Se,createPlatformer3DMovementComponent as Ee,createPlatformer3DStateComponent as Te,createShooter2DStateComponent as Me,createThrusterInputComponent as Oe,createThrusterMovementComponent as ge,createThrusterStateComponent as Ie,createTopDownMovementComponent as fe,createTopDownMovementInputComponent as _e,createTopDownMovementStateComponent as Fe,createTransformComponent as He,defineBehavior as We,fireCooldown as Je,getCooldown as be,getCooldownStore as we,hasAnyWorldBoundary2DHit as Ae,hasAnyWorldBoundary3DHit as Ve,particleEffect as Ne,particlePresets as xe,registerCooldown as ke,resetCooldown as Ye,tickCooldowns as Ue,useBehavior as Ge}from"@zylem/behaviors";import{RuntimeGoalZone2DBehavior as ze,RuntimePaddleInput2DBehavior as je,RuntimePongBallBehavior as qe,RuntimeRicochet2DBehavior as Qe,RuntimeTriggerRegion2DBehavior as Xe,RuntimeWorldBoundary2DBehavior as $e,RUNTIME_GOAL_ZONE_2D_BEHAVIOR_KEY as eo,RUNTIME_PADDLE_INPUT_2D_BEHAVIOR_KEY as oo,RUNTIME_PONG_BALL_BEHAVIOR_KEY as to,RUNTIME_RICOCHET_2D_BEHAVIOR_KEY as ro,RUNTIME_TRIGGER_REGION_2D_BEHAVIOR_KEY as no,RUNTIME_WORLD_BOUNDARY_2D_BEHAVIOR_KEY as io,bindRuntimePongBallHandle as ao,emitRuntimeGoal as Do,emitRuntimeRicochet as mo,emitRuntimeTriggerRegionEnter as lo}from"@zylem/behaviors/runtime-pong";import{RuntimeBoundary2DBehavior as po,RuntimeDynamicCircleBody2DBehavior as co,RuntimePlayerInput2DBehavior as so,RuntimeRicochet2DBehavior as ho,RuntimeTriggerRegion2DBehavior as Ro,RUNTIME_BOUNDARY_2D_BEHAVIOR_KEY as Bo,RUNTIME_DYNAMIC_CIRCLE_BODY_2D_BEHAVIOR_KEY as vo,RUNTIME_PLAYER_INPUT_2D_BEHAVIOR_KEY as Co,bindRuntimeDynamicCircleBody2DHandle as yo}from"@zylem/behaviors/runtime-2d";export{t as BoundaryRicochet3DCoordinator,r as BoundaryRicochetCoordinator,n as CooldownBehavior,i as Destructible3DBehavior,a as DestructibleMesh,D as FirstPersonController,m as FirstPersonControllerBehavior,l as FirstPersonEvent,u as FirstPersonFSM,p as FirstPersonShooterCoordinator,c as FirstPersonState,s as FractureOptions,h as Jumper2D,d as Jumper2DBehavior,R as Jumper2DEvent,B as Jumper2DFSM,v as Jumper2DState,C as Jumper2DTickEvent,y as Jumper3D,P as Jumper3DBehavior,S as Jumper3DEvent,E as Jumper3DFSM,T as Jumper3DState,M as JumperTickEvent,O as MultidirectionalSpaceShooterCoordinator,g as ParticleEmitterBehavior,I as Platformer3DBehavior,f as Platformer3DEvent,_ as Platformer3DFSM,F as Platformer3DMovementBehavior,H as Platformer3DState,Bo as RUNTIME_BOUNDARY_2D_BEHAVIOR_KEY,vo as RUNTIME_DYNAMIC_CIRCLE_BODY_2D_BEHAVIOR_KEY,eo as RUNTIME_GOAL_ZONE_2D_BEHAVIOR_KEY,oo as RUNTIME_PADDLE_INPUT_2D_BEHAVIOR_KEY,Co as RUNTIME_PLAYER_INPUT_2D_BEHAVIOR_KEY,to as RUNTIME_PONG_BALL_BEHAVIOR_KEY,ro as RUNTIME_RICOCHET_2D_BEHAVIOR_KEY,no as RUNTIME_TRIGGER_REGION_2D_BEHAVIOR_KEY,io as RUNTIME_WORLD_BOUNDARY_2D_BEHAVIOR_KEY,W as Ricochet2DBehavior,J as Ricochet2DEvent,b as Ricochet2DFSM,w as Ricochet2DState,A as Ricochet3DBehavior,V as Ricochet3DEvent,N as Ricochet3DFSM,x as Ricochet3DState,po as RuntimeBoundary2DBehavior,co as RuntimeDynamicCircleBody2DBehavior,ze as RuntimeGoalZone2DBehavior,je as RuntimePaddleInput2DBehavior,so as RuntimePlayerInput2DBehavior,qe as RuntimePongBallBehavior,Qe as RuntimeRicochet2DBehavior,ho as RuntimeRicochet2DDescriptor,Xe as RuntimeTriggerRegion2DBehavior,Ro as RuntimeTriggerRegion2DDescriptor,$e as RuntimeWorldBoundary2DBehavior,k as ScreenVisibilityBehavior,Y as ScreenVisibilityFSM,U as ScreenWrapBehavior,G as ScreenWrapEvent,K as ScreenWrapFSM,L as ScreenWrapState,Z as Shooter2DBehavior,z as ThrusterBehavior,j as ThrusterEvent,q as ThrusterFSM,Q as ThrusterMovementBehavior,X as ThrusterState,$ as TopDownMovementBehavior,ee as TopDownMovementRuntimeBehavior,oe as TopDownShooterCoordinator,te as WorldBoundary2DBehavior,re as WorldBoundary2DEvent,ne as WorldBoundary2DFSM,ie as WorldBoundary2DState,ae as WorldBoundary3DBehavior,De as WorldBoundary3DEvent,me as WorldBoundary3DFSM,le as WorldBoundary3DState,yo as bindRuntimeDynamicCircleBody2DHandle,ao as bindRuntimePongBallHandle,ue as computeWorldBoundary2DHits,pe as computeWorldBoundary3DHits,ce as createFirstPersonInputComponent,se as createFirstPersonMovementComponent,he as createFirstPersonStateComponent,de as createJumpConfig2D,Re as createJumpConfig3D,Be as createJumpInput2D,ve as createJumpInput3D,Ce as createJumpState2D,ye as createJumpState3D,Pe as createPhysicsBodyComponent,Se as createPlatformer3DInputComponent,Ee as createPlatformer3DMovementComponent,Te as createPlatformer3DStateComponent,Me as createShooter2DStateComponent,Oe as createThrusterInputComponent,ge as createThrusterMovementComponent,Ie as createThrusterStateComponent,fe as createTopDownMovementComponent,_e as createTopDownMovementInputComponent,Fe as createTopDownMovementStateComponent,He as createTransformComponent,We as defineBehavior,Do as emitRuntimeGoal,mo as emitRuntimeRicochet,lo as emitRuntimeTriggerRegionEnter,Je as fireCooldown,be as getCooldown,we as getCooldownStore,Ae as hasAnyWorldBoundary2DHit,Ve as hasAnyWorldBoundary3DHit,Ne as particleEffect,xe as particlePresets,ke as registerCooldown,Ye as resetCooldown,Ue as tickCooldowns,Ge as useBehavior};
1
+ import{$,$a,A,Aa,B,Ba,C,Ca,D,Da,E,Ea,F,Fa,G,Ga,H,Ha,I,Ia,J,Ja,K,Ka,L,La,M,Ma,N,Na,O,Oa,P,Pa,Q,Qa,R,Ra,S,Sa,T,Ta,U,Ua,V,Va,W,Wa,X,Xa,Y,Ya,Z,Za,_,_a,a,aa,ab,b,ba,bb,c,ca,cb,d,da,db,e,ea,eb,f,fa,fb,g,ga,gb,h,ha,hb,i,ia,ib,j,ja,k,ka,l,la,m,ma,n,na,o,oa,p,pa,q,qa,r,ra,s,sa,t,ta,u,ua,v,va,w,wa,x,xa,y,ya,z,za}from"./chunk-XK63E4SX.js";export{a as BoundaryRicochet3DCoordinator,b as BoundaryRicochetCoordinator,c as CooldownBehavior,d as Destructible3DBehavior,e as DestructibleMesh,f as FirstPersonBehavior,g as FirstPersonEvent,h as FirstPersonFSM,k as FirstPersonPresentation,i as FirstPersonShooterCoordinator,j as FirstPersonState,l as FractureOptions,m as Jumper2DBehavior,n as Jumper2DEvent,o as Jumper2DFSM,p as Jumper2DState,q as Jumper3DBehavior,r as Jumper3DEvent,s as Jumper3DFSM,t as Jumper3DState,u as MultidirectionalSpaceShooterCoordinator,v as ParticleEmitterBehavior,w as Platformer2DBehavior,x as Platformer2DEvent,y as Platformer2DFSM,z as Platformer2DState,A as Platformer3DBehavior,B as Platformer3DEvent,C as Platformer3DFSM,D as Platformer3DState,$a as RUNTIME_BOUNDARY_2D_BEHAVIOR_KEY,ab as RUNTIME_DYNAMIC_CIRCLE_BODY_2D_BEHAVIOR_KEY,bb as RUNTIME_GOAL_ZONE_2D_BEHAVIOR_KEY,cb as RUNTIME_PLAYER_INPUT_2D_BEHAVIOR_KEY,db as RUNTIME_RICOCHET_2D_BEHAVIOR_KEY,eb as RUNTIME_TRIGGER_REGION_2D_BEHAVIOR_KEY,E as Ricochet2DBehavior,F as Ricochet2DEvent,G as Ricochet2DFSM,H as Ricochet2DState,I as Ricochet3DBehavior,J as Ricochet3DEvent,K as Ricochet3DFSM,L as Ricochet3DState,Va as RuntimeBoundary2DBehavior,Wa as RuntimeDynamicCircleBody2DBehavior,Xa as RuntimeGoalZone2DBehavior,Ya as RuntimePlayerInput2DBehavior,Za as RuntimeRicochet2DBehavior,_a as RuntimeTriggerRegion2DBehavior,M as ScreenVisibilityBehavior,N as ScreenVisibilityFSM,O as ScreenWrapBehavior,P as ScreenWrapEvent,Q as ScreenWrapFSM,R as ScreenWrapState,S as Shooter2DBehavior,T as ThrusterBehavior,U as ThrusterEvent,V as ThrusterFSM,W as ThrusterState,X as TopDownMovementBehavior,Y as TopDownShooterCoordinator,Z as WorldBoundary2DBehavior,_ as WorldBoundary2DEvent,$ as WorldBoundary2DFSM,aa as WorldBoundary2DState,ba as WorldBoundary3DBehavior,ca as WorldBoundary3DEvent,da as WorldBoundary3DFSM,ea as WorldBoundary3DState,fb as bindRuntimeDynamicCircleBody2DHandle,fa as computeWorldBoundary2DHits,ga as computeWorldBoundary3DHits,ha as createFirstPersonInputComponent,ia as createFirstPersonMovementComponent,ja as createFirstPersonStateComponent,ka as createJumpConfig2D,la as createJumpConfig3D,ma as createJumpInput2D,na as createJumpInput3D,oa as createJumpState2D,pa as createJumpState3D,qa as createPhysicsBodyComponent,ra as createPlatformer2DInputComponent,sa as createPlatformer2DMovementComponent,ta as createPlatformer2DStateComponent,ua as createPlatformer3DInputComponent,va as createPlatformer3DMovementComponent,wa as createPlatformer3DStateComponent,xa as createShooter2DStateComponent,ya as createThrusterInputComponent,za as createThrusterMovementComponent,Aa as createThrusterStateComponent,Ba as createTopDownMovementComponent,Ca as createTopDownMovementInputComponent,Da as createTopDownMovementStateComponent,Ea as createTransformComponent,Fa as defineBehavior,gb as emitRuntimeGoal,hb as emitRuntimeRicochet,ib as emitRuntimeTriggerRegionEnter,Ga as fireCooldown,Ha as fireShooter2DIfRequested,Ia as getCooldown,Ja as getCooldownStore,Ka as getEntityFacingAngle2D,La as hasAnyWorldBoundary2DHit,Ma as hasAnyWorldBoundary3DHit,Na as particleEffect,Oa as particlePresets,Pa as registerCooldown,Qa as resetCooldown,Ra as resolveAim2D,Sa as tickCooldowns,Ta as updateBoundaryRicochet,Ua as useBehavior};
@@ -0,0 +1,162 @@
1
+ import * as _sinclair_typebox from '@sinclair/typebox';
2
+ import { Static } from '@sinclair/typebox';
3
+
4
+ /** 2D position tuple `[x, y]` used by blueprint entities. */
5
+ declare const Vector2Schema: _sinclair_typebox.TTuple<[_sinclair_typebox.TNumber, _sinclair_typebox.TNumber]>;
6
+ /**
7
+ * Runtime entity blueprint (open `data` for factory spreading).
8
+ * Prefer {@link EntityJsonSchema} for editor / Monaco JSON Schema.
9
+ */
10
+ declare const EntitySchema: _sinclair_typebox.TObject<{
11
+ id: _sinclair_typebox.TString;
12
+ type: _sinclair_typebox.TString;
13
+ position: _sinclair_typebox.TOptional<_sinclair_typebox.TTuple<[_sinclair_typebox.TNumber, _sinclair_typebox.TNumber]>>;
14
+ data: _sinclair_typebox.TOptional<_sinclair_typebox.TRecord<_sinclair_typebox.TString, _sinclair_typebox.TAny>>;
15
+ }>;
16
+ /** Stage blueprint: id, optional name, entities, and optional asset URLs. */
17
+ declare const StageSchema: _sinclair_typebox.TObject<{
18
+ id: _sinclair_typebox.TString;
19
+ name: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
20
+ entities: _sinclair_typebox.TArray<_sinclair_typebox.TObject<{
21
+ id: _sinclair_typebox.TString;
22
+ type: _sinclair_typebox.TString;
23
+ position: _sinclair_typebox.TOptional<_sinclair_typebox.TTuple<[_sinclair_typebox.TNumber, _sinclair_typebox.TNumber]>>;
24
+ data: _sinclair_typebox.TOptional<_sinclair_typebox.TRecord<_sinclair_typebox.TString, _sinclair_typebox.TAny>>;
25
+ }>>;
26
+ assets: _sinclair_typebox.TOptional<_sinclair_typebox.TArray<_sinclair_typebox.TString>>;
27
+ }>;
28
+ /** JSON-serializable data for blueprint entities of type `text`. */
29
+ declare const TextEntityDataSchema: _sinclair_typebox.TObject<{
30
+ value: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
31
+ color: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
32
+ fontSize: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
33
+ fontFamily: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
34
+ }>;
35
+ /** 3D position tuple `[x, y, z]` for line vertices. */
36
+ declare const Vector3TupleSchema: _sinclair_typebox.TTuple<[_sinclair_typebox.TNumber, _sinclair_typebox.TNumber, _sinclair_typebox.TNumber]>;
37
+ /** JSON-serializable data for blueprint entities of type `line`. */
38
+ declare const LineEntityDataSchema: _sinclair_typebox.TObject<{
39
+ points: _sinclair_typebox.TArray<_sinclair_typebox.TTuple<[_sinclair_typebox.TNumber, _sinclair_typebox.TNumber, _sinclair_typebox.TNumber]>>;
40
+ color: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
41
+ colors: _sinclair_typebox.TOptional<_sinclair_typebox.TArray<_sinclair_typebox.TString>>;
42
+ linewidth: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
43
+ worldUnits: _sinclair_typebox.TOptional<_sinclair_typebox.TBoolean>;
44
+ alphaToCoverage: _sinclair_typebox.TOptional<_sinclair_typebox.TBoolean>;
45
+ opacity: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
46
+ transparent: _sinclair_typebox.TOptional<_sinclair_typebox.TBoolean>;
47
+ dashed: _sinclair_typebox.TOptional<_sinclair_typebox.TBoolean>;
48
+ dashSize: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
49
+ gapSize: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
50
+ pickThreshold: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
51
+ }>;
52
+ /** JSON-serializable data for blueprint entities of type `sprite`. */
53
+ declare const SpriteEntityDataSchema: _sinclair_typebox.TObject<{
54
+ imagePath: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
55
+ width: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
56
+ height: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
57
+ }>;
58
+ /**
59
+ * Editor-oriented entity blueprint with discriminated `type` / `data`.
60
+ * Used for published JSON Schema; runtime code uses {@link EntitySchema}.
61
+ */
62
+ declare const EntityJsonSchema: _sinclair_typebox.TUnion<[_sinclair_typebox.TObject<{
63
+ id: _sinclair_typebox.TString;
64
+ type: _sinclair_typebox.TLiteral<"text">;
65
+ position: _sinclair_typebox.TOptional<_sinclair_typebox.TTuple<[_sinclair_typebox.TNumber, _sinclair_typebox.TNumber]>>;
66
+ data: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
67
+ value: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
68
+ color: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
69
+ fontSize: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
70
+ fontFamily: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
71
+ }>>;
72
+ }>, _sinclair_typebox.TObject<{
73
+ id: _sinclair_typebox.TString;
74
+ type: _sinclair_typebox.TLiteral<"sprite">;
75
+ position: _sinclair_typebox.TOptional<_sinclair_typebox.TTuple<[_sinclair_typebox.TNumber, _sinclair_typebox.TNumber]>>;
76
+ data: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
77
+ imagePath: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
78
+ width: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
79
+ height: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
80
+ }>>;
81
+ }>, _sinclair_typebox.TObject<{
82
+ id: _sinclair_typebox.TString;
83
+ type: _sinclair_typebox.TLiteral<"line">;
84
+ position: _sinclair_typebox.TOptional<_sinclair_typebox.TTuple<[_sinclair_typebox.TNumber, _sinclair_typebox.TNumber]>>;
85
+ data: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
86
+ points: _sinclair_typebox.TArray<_sinclair_typebox.TTuple<[_sinclair_typebox.TNumber, _sinclair_typebox.TNumber, _sinclair_typebox.TNumber]>>;
87
+ color: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
88
+ colors: _sinclair_typebox.TOptional<_sinclair_typebox.TArray<_sinclair_typebox.TString>>;
89
+ linewidth: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
90
+ worldUnits: _sinclair_typebox.TOptional<_sinclair_typebox.TBoolean>;
91
+ alphaToCoverage: _sinclair_typebox.TOptional<_sinclair_typebox.TBoolean>;
92
+ opacity: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
93
+ transparent: _sinclair_typebox.TOptional<_sinclair_typebox.TBoolean>;
94
+ dashed: _sinclair_typebox.TOptional<_sinclair_typebox.TBoolean>;
95
+ dashSize: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
96
+ gapSize: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
97
+ pickThreshold: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
98
+ }>>;
99
+ }>, _sinclair_typebox.TObject<{
100
+ id: _sinclair_typebox.TString;
101
+ type: _sinclair_typebox.TString;
102
+ position: _sinclair_typebox.TOptional<_sinclair_typebox.TTuple<[_sinclair_typebox.TNumber, _sinclair_typebox.TNumber]>>;
103
+ data: _sinclair_typebox.TOptional<_sinclair_typebox.TRecord<_sinclair_typebox.TString, _sinclair_typebox.TUnknown>>;
104
+ }>]>;
105
+ /** Editor-oriented stage blueprint referencing {@link EntityJsonSchema}. */
106
+ declare const StageJsonSchema: _sinclair_typebox.TObject<{
107
+ id: _sinclair_typebox.TString;
108
+ name: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
109
+ entities: _sinclair_typebox.TArray<_sinclair_typebox.TUnion<[_sinclair_typebox.TObject<{
110
+ id: _sinclair_typebox.TString;
111
+ type: _sinclair_typebox.TLiteral<"text">;
112
+ position: _sinclair_typebox.TOptional<_sinclair_typebox.TTuple<[_sinclair_typebox.TNumber, _sinclair_typebox.TNumber]>>;
113
+ data: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
114
+ value: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
115
+ color: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
116
+ fontSize: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
117
+ fontFamily: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
118
+ }>>;
119
+ }>, _sinclair_typebox.TObject<{
120
+ id: _sinclair_typebox.TString;
121
+ type: _sinclair_typebox.TLiteral<"sprite">;
122
+ position: _sinclair_typebox.TOptional<_sinclair_typebox.TTuple<[_sinclair_typebox.TNumber, _sinclair_typebox.TNumber]>>;
123
+ data: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
124
+ imagePath: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
125
+ width: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
126
+ height: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
127
+ }>>;
128
+ }>, _sinclair_typebox.TObject<{
129
+ id: _sinclair_typebox.TString;
130
+ type: _sinclair_typebox.TLiteral<"line">;
131
+ position: _sinclair_typebox.TOptional<_sinclair_typebox.TTuple<[_sinclair_typebox.TNumber, _sinclair_typebox.TNumber]>>;
132
+ data: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
133
+ points: _sinclair_typebox.TArray<_sinclair_typebox.TTuple<[_sinclair_typebox.TNumber, _sinclair_typebox.TNumber, _sinclair_typebox.TNumber]>>;
134
+ color: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
135
+ colors: _sinclair_typebox.TOptional<_sinclair_typebox.TArray<_sinclair_typebox.TString>>;
136
+ linewidth: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
137
+ worldUnits: _sinclair_typebox.TOptional<_sinclair_typebox.TBoolean>;
138
+ alphaToCoverage: _sinclair_typebox.TOptional<_sinclair_typebox.TBoolean>;
139
+ opacity: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
140
+ transparent: _sinclair_typebox.TOptional<_sinclair_typebox.TBoolean>;
141
+ dashed: _sinclair_typebox.TOptional<_sinclair_typebox.TBoolean>;
142
+ dashSize: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
143
+ gapSize: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
144
+ pickThreshold: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
145
+ }>>;
146
+ }>, _sinclair_typebox.TObject<{
147
+ id: _sinclair_typebox.TString;
148
+ type: _sinclair_typebox.TString;
149
+ position: _sinclair_typebox.TOptional<_sinclair_typebox.TTuple<[_sinclair_typebox.TNumber, _sinclair_typebox.TNumber]>>;
150
+ data: _sinclair_typebox.TOptional<_sinclair_typebox.TRecord<_sinclair_typebox.TString, _sinclair_typebox.TUnknown>>;
151
+ }>]>>;
152
+ assets: _sinclair_typebox.TOptional<_sinclair_typebox.TArray<_sinclair_typebox.TString>>;
153
+ }>;
154
+ type EntityBlueprint = Static<typeof EntitySchema>;
155
+ type StageBlueprint = Static<typeof StageSchema>;
156
+ type TextEntityData = Static<typeof TextEntityDataSchema>;
157
+ type SpriteEntityData = Static<typeof SpriteEntityDataSchema>;
158
+ type LineEntityData = Static<typeof LineEntityDataSchema>;
159
+ type EntityJson = Static<typeof EntityJsonSchema>;
160
+ type StageJson = Static<typeof StageJsonSchema>;
161
+
162
+ export { EntitySchema as E, LineEntityDataSchema as L, type StageBlueprint as S, TextEntityDataSchema as T, Vector2Schema as V, Vector3TupleSchema as a, SpriteEntityDataSchema as b, StageSchema as c, EntityJsonSchema as d, StageJsonSchema as e, type EntityBlueprint as f, type TextEntityData as g, type SpriteEntityData as h, type LineEntityData as i, type EntityJson as j, type StageJson as k };
@@ -0,0 +1,24 @@
1
+ import{b as ye}from"./chunk-7GYFZKK7.js";import{b}from"./chunk-COM6HJ2L.js";import{b as he,d as P,j as ve,u as L,v as G}from"./chunk-CFVRRRZZ.js";import{a as g,b as me,c as K}from"./chunk-JQKS42G4.js";import{l as Se}from"./chunk-MZZCDXFB.js";import{a as $,r as j}from"./chunk-KVSJE4XD.js";import{j as be}from"./chunk-CM5YRNBJ.js";import{a as fe,b as y}from"./chunk-YHEWKN7N.js";import{c as S}from"./chunk-D2PATZCC.js";import{c as re,d as C,e as le,h as ue,i as pe,j as de,k as J,l as x,m as ce}from"./chunk-4QLJUQSJ.js";import{j as W}from"./chunk-7WRQ2UAN.js";import{g as ge}from"./chunk-PCFF4LLO.js";import{l as v}from"./chunk-UG22Z42P.js";function De(){return{pressed:!1,released:!1,held:0}}function ke(){return{value:0,held:0}}function D(a){let e=new Map;if(!a)return e;for(let[t,n]of Object.entries(a)){if(!n||n.length===0)continue;let i=[];for(let o of n){let[r,s]=(o||"").split(".");if(!r||!s)continue;let l=r.toLowerCase(),u=s.toLowerCase();if(l==="buttons"){let p={a:"A",b:"B",x:"X",y:"Y",start:"Start",select:"Select",l:"L",r:"R"}[u];p&&i.push({category:"buttons",property:p})}else if(l==="directions"){let p={up:"Up",down:"Down",left:"Left",right:"Right"}[u];p&&i.push({category:"directions",property:p})}else if(l==="shoulders"){let p={ltrigger:"LTrigger",rtrigger:"RTrigger"}[u];p&&i.push({category:"shoulders",property:p})}else if(l==="axes"){let p={left:{property:"Horizontal",direction:-1},right:{property:"Horizontal",direction:1},up:{property:"Vertical",direction:-1},down:{property:"Vertical",direction:1},secondaryleft:{property:"SecondaryHorizontal",direction:-1},secondaryright:{property:"SecondaryHorizontal",direction:1},secondaryup:{property:"SecondaryVertical",direction:-1},secondarydown:{property:"SecondaryVertical",direction:1}}[u];p&&i.push({category:"axes",property:p.property,axisDirection:p.direction})}}i.length>0&&e.set(t,i)}return e}function d(a,e){return!a&&!e?De():a?e?{pressed:a.pressed||e.pressed,released:a.released||e.released,held:a.held+e.held}:{...a}:{...e}}function f(a,e){return!a&&!e?ke():a?e?{value:a.value+e.value,held:a.held+e.held}:{...a}:{...e}}var w=class{keyStates=new Map;keyButtonStates=new Map;analogStates=new Map;compiledMapping;includeDefaultBase=!0;onKeyDown=({key:e})=>this.keyStates.set(e,!0);onKeyUp=({key:e})=>this.keyStates.set(e,!1);constructor(e,t){this.includeDefaultBase=t?.includeDefaultBase??!0,this.compiledMapping=D(e??null),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp)}dispose(){window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp),this.keyStates.clear(),this.keyButtonStates.clear(),this.analogStates.clear()}isKeyPressed(e){return this.keyStates.get(e)||!1}handleButtonState(e,t){let n=this.keyButtonStates.get(e);n||(n={pressed:!1,released:!1,held:0},this.keyButtonStates.set(e,n));let i=this.isKeyPressed(e);return n.pressed=i&&n.held===0,n.released=!i&&n.held>0,n.held=i?n.held+t:0,n}handleAnalogState(e,t,n){let i=`${e}:${t}`,o=this.analogStates.get(i);return o||(o={value:0,held:0},this.analogStates.set(i,o)),o.value=this.getAxisValue(e,t),o.held=o.value!==0?o.held+n:0,o}applyCustomMapping(e,t){if(this.compiledMapping.size===0)return e;let n=new Map;for(let[i,o]of this.compiledMapping.entries()){let r=null;for(let s of o)if(s.category==="axes")n.has(s.property)||n.set(s.property,0),this.isKeyPressed(i)&&n.set(s.property,n.get(s.property)+s.axisDirection);else{r||(r=this.handleButtonState(i,t));let l=e[s.category]??={};l[s.property]=d(l[s.property],r)}}if(n.size>0){e.axes||(e.axes={});for(let[i,o]of n.entries()){let r=`custom:${i}`,s=this.analogStates.get(r);s||(s={value:0,held:0},this.analogStates.set(r,s)),s.value=o,s.held=o!==0?s.held+t:0,e.axes[i]=f(e.axes[i],s)}}return e}getInput(e){let t={};return this.includeDefaultBase&&(t.buttons={A:this.handleButtonState("z",e),B:this.handleButtonState("x",e),X:this.handleButtonState("a",e),Y:this.handleButtonState("s",e),Start:this.handleButtonState(" ",e),Select:this.handleButtonState("Enter",e),L:this.handleButtonState("q",e),R:this.handleButtonState("e",e)},t.directions={Up:this.handleButtonState("ArrowUp",e),Down:this.handleButtonState("ArrowDown",e),Left:this.handleButtonState("ArrowLeft",e),Right:this.handleButtonState("ArrowRight",e)},t.shoulders={LTrigger:this.handleButtonState("Q",e),RTrigger:this.handleButtonState("E",e)}),this.applyCustomMapping(t,e)}getName(){return"keyboard"}getAxisValue(e,t){return(this.isKeyPressed(t)?1:0)-(this.isKeyPressed(e)?1:0)}isConnected(){return!0}};var k=class{gamepadIndex;connected=!1;buttonStates={};analogStates={};onConnected=e=>{e.gamepad.index===this.gamepadIndex&&(this.connected=!0)};onDisconnected=e=>{e.gamepad.index===this.gamepadIndex&&(this.connected=!1)};constructor(e){this.gamepadIndex=e,window.addEventListener("gamepadconnected",this.onConnected),window.addEventListener("gamepaddisconnected",this.onDisconnected)}dispose(){window.removeEventListener("gamepadconnected",this.onConnected),window.removeEventListener("gamepaddisconnected",this.onDisconnected),this.buttonStates={},this.analogStates={}}handleButtonState(e,t,n){let i=this.buttonStates[e];i||(i={pressed:!1,released:!1,held:0},this.buttonStates[e]=i);let o=t.buttons[e].pressed;return i.pressed=o&&i.held===0,i.released=!o&&i.held>0,i.held=o?i.held+n:0,i}handleAnalogState(e,t,n){let i=this.analogStates[e];return i||(i={value:0,held:0},this.analogStates[e]=i),i.value=t.axes[e],i.held=i.value!==0?i.held+n:0,i}getInput(e){let t=navigator.getGamepads()[this.gamepadIndex];return t?{buttons:{A:this.handleButtonState(0,t,e),B:this.handleButtonState(1,t,e),X:this.handleButtonState(2,t,e),Y:this.handleButtonState(3,t,e),Start:this.handleButtonState(9,t,e),Select:this.handleButtonState(8,t,e),L:this.handleButtonState(4,t,e),R:this.handleButtonState(5,t,e)},directions:{Up:this.handleButtonState(12,t,e),Down:this.handleButtonState(13,t,e),Left:this.handleButtonState(14,t,e),Right:this.handleButtonState(15,t,e)},axes:{Horizontal:this.handleAnalogState(0,t,e),Vertical:this.handleAnalogState(1,t,e),SecondaryHorizontal:this.handleAnalogState(2,t,e),SecondaryVertical:this.handleAnalogState(3,t,e)},shoulders:{LTrigger:this.handleButtonState(6,t,e),RTrigger:this.handleButtonState(7,t,e)}}:{}}getName(){return`gamepad-${this.gamepadIndex+1}`}isConnected(){return this.connected}};import{subscribe as ze}from"valtio/vanilla";var Ae=.002;function z(a,e,t){return Math.max(e,Math.min(t,a))}function Ve(a){if(a instanceof HTMLCanvasElement)return a;let e=a.querySelector("canvas");if(e instanceof HTMLCanvasElement)return e;for(let t of a.querySelectorAll("*")){let n=t.shadowRoot;if(!n)continue;let i=n.querySelector("canvas");if(i instanceof HTMLCanvasElement)return i}return null}var T=class{buttonStates=new Map;analogStates=new Map;compiledMapping;movementX=0;movementY=0;pointerX=.5;pointerY=.5;pointerCenterX=0;pointerCenterY=0;mouseButtonDown=new Set;sensitivity;usePointerLock;lookMode;isLocked=!1;targetElement;debugUnsubscribe=null;updatePointerPosition(e,t){this.pointerX=e/window.innerWidth,this.pointerY=t/window.innerHeight;let n=Ve(this.targetElement);if(n){let i=n.getBoundingClientRect();if(i.width>0&&i.height>0){let o=i.left+i.width/2,r=i.top+i.height/2;this.pointerCenterX=z((e-o)/(i.width/2),-1,1),this.pointerCenterY=z((t-r)/(i.height/2),-1,1);return}}this.pointerCenterX=z((this.pointerX-.5)*2,-1,1),this.pointerCenterY=z((this.pointerY-.5)*2,-1,1)}onMouseMove=e=>{this.updatePointerPosition(e.clientX,e.clientY),!(g.enabled||this.lookMode==="screenCenter")&&(this.movementX+=e.movementX,this.movementY+=e.movementY)};onMouseDown=e=>{let t=e.target;t instanceof HTMLCanvasElement&&this.targetElement.contains(t)&&(this.mouseButtonDown.add(e.button),this.usePointerLock&&!this.isLocked&&!g.enabled&&this.targetElement.requestPointerLock())};onMouseUp=e=>{this.mouseButtonDown.delete(e.button)};onContextMenu=e=>{e.preventDefault()};onPointerLockChange=()=>{this.isLocked=document.pointerLockElement===this.targetElement};constructor(e,t){this.sensitivity=e?.sensitivity??Ae,this.lookMode=e?.lookMode??"delta",this.usePointerLock=e?.pointerLock??!1,this.compiledMapping=D(e?.mapping??null),this.targetElement=t??document.body,window.addEventListener("mousemove",this.onMouseMove),this.targetElement.addEventListener("mousedown",this.onMouseDown),this.targetElement.addEventListener("mouseup",this.onMouseUp),this.targetElement.addEventListener("contextmenu",this.onContextMenu),this.usePointerLock&&(document.addEventListener("pointerlockchange",this.onPointerLockChange),this.debugUnsubscribe=ze(g,()=>{g.enabled&&document.pointerLockElement===this.targetElement&&document.exitPointerLock()}))}dispose(){window.removeEventListener("mousemove",this.onMouseMove),this.targetElement.removeEventListener("mousedown",this.onMouseDown),this.targetElement.removeEventListener("mouseup",this.onMouseUp),this.targetElement.removeEventListener("contextmenu",this.onContextMenu),document.removeEventListener("pointerlockchange",this.onPointerLockChange),this.debugUnsubscribe?.(),this.debugUnsubscribe=null,this.isLocked&&document.exitPointerLock(),this.buttonStates.clear(),this.analogStates.clear(),this.mouseButtonDown.clear(),this.movementX=0,this.movementY=0}handleMouseButton(e,t){let n=this.buttonStates.get(e);n||(n={pressed:!1,released:!1,held:0},this.buttonStates.set(e,n));let i=this.mouseButtonDown.has(e);return n.pressed=i&&n.held===0,n.released=!i&&n.held>0,n.held=i?n.held+t:0,n}handleMovementAxis(e,t){let n=this.analogStates.get(e);n||(n={value:0,held:0},this.analogStates.set(e,n));let i=e==="x"?this.movementX:this.movementY;return n.value=Math.max(-1,Math.min(1,i*this.sensitivity)),n.held=n.value!==0?n.held+t:0,n}applyCustomMapping(e,t){if(this.compiledMapping.size===0)return e;let n=new Map,i={leftbutton:()=>this.handleMouseButton(0,t),rightbutton:()=>this.handleMouseButton(2,t),middlebutton:()=>this.handleMouseButton(1,t)};for(let[o,r]of this.compiledMapping.entries()){let s=o.toLowerCase();for(let l of r)if(l.category==="axes")n.has(l.property)||n.set(l.property,0),s==="movex"?n.set(l.property,n.get(l.property)+Math.max(-1,Math.min(1,this.movementX*this.sensitivity))*l.axisDirection):s==="movey"?n.set(l.property,n.get(l.property)+Math.max(-1,Math.min(1,this.movementY*this.sensitivity))*l.axisDirection):s in i&&this.mouseButtonDown.has(this.buttonIndexForAction(s))&&n.set(l.property,n.get(l.property)+l.axisDirection);else{let u=i[s];if(u){let m=u();if(m){let p=e[l.category]??={};p[l.property]=d(p[l.property],m)}}}}if(n.size>0){e.axes||(e.axes={});for(let[o,r]of n.entries()){let s=`custom:${o}`,l=this.analogStates.get(s);l||(l={value:0,held:0},this.analogStates.set(s,l)),l.value=Math.max(-1,Math.min(1,r)),l.held=r!==0?l.held+t:0,e.axes[o]=f(e.axes[o],l)}}return e}buttonIndexForAction(e){switch(e){case"leftbutton":return 0;case"middlebutton":return 1;case"rightbutton":return 2;default:return-1}}getInput(e){g.enabled&&(this.movementX=0,this.movementY=0);let t={value:0,held:0},n=this.lookMode==="delta",i={axes:{Horizontal:t,Vertical:t,SecondaryHorizontal:n?this.handleMovementAxis("x",e):t,SecondaryVertical:n?this.handleMovementAxis("y",e):t},shoulders:{LTrigger:this.handleMouseButton(0,e),RTrigger:this.handleMouseButton(2,e)},pointer:{x:this.pointerX,y:this.pointerY,centerX:this.pointerCenterX,centerY:this.pointerCenterY}};return this.movementX=0,this.movementY=0,this.applyCustomMapping(i,e)}getName(){return"mouse"}isConnected(){return!0}};function R(a={}){if(typeof window>"u"||typeof navigator>"u")return!1;let e=navigator.userAgent,t=/android/i.test(e)||/iPad|iPhone|iPod/.test(e),n="ontouchstart"in window||navigator.maxTouchPoints>0,i=typeof window.matchMedia=="function"?window.matchMedia("(pointer: coarse)").matches:!1,o=a.viewportSize?.width??window.innerWidth??0,r=a.viewportSize?.height??window.innerHeight??0,s=Math.max(o,r),l=s===0||s<=1024;return a.allowViewportOnly&&a.viewportSize?l:t||(n||i)&&l}var He=["A","B","X","Y","Start","Select","L","R","LTrigger","RTrigger","Up","Down","Left","Right"],Oe=new Set(["flex","flexGrow","flexShrink","fontWeight","lineHeight","opacity","order","zIndex","zoom"]),_e={A:{size:72,label:"A",position:{right:98,bottom:44}},B:{size:72,label:"B",position:{right:24,bottom:108}},X:{size:72,label:"X",position:{right:172,bottom:108}},Y:{size:72,label:"Y",position:{right:98,bottom:172}},Start:{size:64,label:"Start",position:{left:"50%",top:24,transform:"translateX(28px)"}},Select:{size:64,label:"Select",position:{left:"50%",top:24,transform:"translateX(-108px)"}},L:{size:62,label:"L",position:{left:28,bottom:184}},R:{size:62,label:"R",position:{right:236,bottom:184}},LTrigger:{size:76,label:"LT",position:{left:24,top:24}},RTrigger:{size:76,label:"RT",position:{right:24,top:24}},Up:{enabled:!1,size:64,label:"Up"},Down:{enabled:!1,size:64,label:"Down"},Left:{enabled:!1,size:64,label:"Left"},Right:{enabled:!1,size:64,label:"Right"}},Ne={left:{size:140,thumbSize:58,maxDistance:44,deadzone:.12,directionThreshold:.34,horizontalAxis:"Horizontal",verticalAxis:"Vertical",emitDirections:!0,position:{left:24,bottom:24}},right:{size:140,thumbSize:58,maxDistance:44,deadzone:.12,directionThreshold:.34,horizontalAxis:"SecondaryHorizontal",verticalAxis:"SecondaryVertical",emitDirections:!1,position:{right:24,bottom:236}}},M=class{config;targetElement;buttonStates=new Map;analogStates=new Map;buttons=new Map;joysticks=new Map;rootElement=null;enabled=!1;onPointerMove=e=>{for(let t of this.joysticks.values())t.pointerId===e.pointerId&&(this.consumeEvent(e),this.updateJoystickFromPoint(t,e.clientX,e.clientY))};onPointerUp=e=>{for(let t of this.buttons.values())t.pointerId===e.pointerId&&(this.consumeEvent(e),this.releaseButton(t));for(let t of this.joysticks.values())t.pointerId===e.pointerId&&(this.consumeEvent(e),this.releaseJoystick(t))};onWindowBlur=()=>{for(let e of this.buttons.values())this.releaseButton(e);for(let e of this.joysticks.values())this.releaseJoystick(e)};constructor(e,t){this.config=e??{},this.targetElement=t??document.body,this.enabled=this.resolveEnabledState(),this.enabled&&(this.mountControls(),window.addEventListener("pointermove",this.onPointerMove),window.addEventListener("pointerup",this.onPointerUp),window.addEventListener("pointercancel",this.onPointerUp),window.addEventListener("blur",this.onWindowBlur))}getInput(e){if(!this.enabled)return{};let t={};for(let n of this.buttons.values()){let i=this.handleButtonState(`button:${n.slot}`,n.pointerId!==null,e);this.assignButtonState(t,this.resolveButtonTarget(n.slot),i)}for(let n of this.joysticks.values()){let i=this.handleAnalogState(`joystick:${n.id}:x`,n.valueX,e),o=this.handleAnalogState(`joystick:${n.id}:y`,n.valueY,e);this.assignAxisState(t,n.config.horizontalAxis,i),this.assignAxisState(t,n.config.verticalAxis,o),n.config.emitDirections&&(this.assignButtonState(t,this.resolveButtonTarget("Left"),this.handleButtonState(`joystick:${n.id}:left`,n.valueX<=-n.config.directionThreshold,e)),this.assignButtonState(t,this.resolveButtonTarget("Right"),this.handleButtonState(`joystick:${n.id}:right`,n.valueX>=n.config.directionThreshold,e)),this.assignButtonState(t,this.resolveButtonTarget("Up"),this.handleButtonState(`joystick:${n.id}:up`,n.valueY<=-n.config.directionThreshold,e)),this.assignButtonState(t,this.resolveButtonTarget("Down"),this.handleButtonState(`joystick:${n.id}:down`,n.valueY>=n.config.directionThreshold,e)))}return t}getName(){return"virtual-touch"}isConnected(){return this.enabled}dispose(){window.removeEventListener("pointermove",this.onPointerMove),window.removeEventListener("pointerup",this.onPointerUp),window.removeEventListener("pointercancel",this.onPointerUp),window.removeEventListener("blur",this.onWindowBlur),this.rootElement?.remove(),this.rootElement=null,this.buttons.clear(),this.joysticks.clear(),this.buttonStates.clear(),this.analogStates.clear()}resolveEnabledState(){return typeof window>"u"||typeof document>"u"?!1:this.config.enabled===!0?!0:this.config.enabled===!1?!1:R()}mountControls(){this.rootElement=document.createElement("div"),this.rootElement.className="zylem-virtual-touch",this.rootElement.dataset.zylemTouchRoot="true",this.rootElement.style.position="absolute",this.rootElement.style.inset="0",this.rootElement.style.pointerEvents="none",this.rootElement.style.touchAction="none",this.rootElement.style.userSelect="none",this.rootElement.style.WebkitUserSelect="none",this.rootElement.style.WebkitTouchCallout="none",this.rootElement.style.color="rgba(245, 247, 255, 0.96)",this.rootElement.style.zIndex="20",this.appendClassName(this.rootElement,this.config.className),E(this.rootElement,this.config.style),this.rootElement.addEventListener("contextmenu",e=>e.preventDefault());for(let[e,t]of this.resolveButtons())this.rootElement.appendChild(this.createButton(e,t));for(let[e,t]of this.resolveJoysticks())this.rootElement.appendChild(this.createJoystick(e,t));this.targetElement.appendChild(this.rootElement)}resolveButtons(){if(this.config.buttons===!1)return[];let e=this.config.buttons,t=[];for(let n of He){let i=_e[n],o=e?.[n];if(o===!1)continue;let r={...i,...o??{},style:{...i.style,...o?.style},position:{...i.position,...o?.position},label:o?.label??i.label??n,size:o?.size??i.size??72};r.enabled!==!1&&t.push([n,r])}return t}resolveJoysticks(){if(this.config.joysticks===!1)return[];let e=this.config.joysticks,t=[];for(let n of["left","right"]){let i=Ne[n],o=e?.[n];if(o===!1)continue;let r={...i,...o??{},style:{...i.style,...o?.style},position:{...i.position,...o?.position},svg:{...i.svg,...o?.svg},size:o?.size??i.size??140,thumbSize:o?.thumbSize??i.thumbSize??58,maxDistance:o?.maxDistance??i.maxDistance??44,deadzone:o?.deadzone??i.deadzone??.12,directionThreshold:o?.directionThreshold??i.directionThreshold??.34,horizontalAxis:o?.horizontalAxis??i.horizontalAxis??"Horizontal",verticalAxis:o?.verticalAxis??i.verticalAxis??"Vertical",emitDirections:o?.emitDirections??i.emitDirections??!1};r.enabled!==!1&&t.push([n,r])}return t}createButton(e,t){let n=document.createElement("button"),i=document.createElement("div");n.type="button",n.ariaLabel=t.label,n.className=`zylem-virtual-touch__button zylem-virtual-touch__button--${e}`,n.dataset.zylemTouchButton=e,n.dataset.active="false",n.style.position="absolute",n.style.width=`${t.size}px`,n.style.height=`${t.size}px`,n.style.padding="0",n.style.margin="0",n.style.border="0",n.style.background="transparent",n.style.pointerEvents="auto",n.style.touchAction="none",n.style.cursor="pointer",n.style.appearance="none",n.style.outline="none",n.style.userSelect="none",n.style.WebkitTapHighlightColor="transparent",E(n,t.position),E(n,t.style),this.appendClassName(n,t.className),i.className="zylem-virtual-touch__button-content",i.style.width="100%",i.style.height="100%",i.style.pointerEvents="none",i.style.transform="scale(1)",i.style.transformOrigin="center",i.style.transition="transform 120ms ease, opacity 120ms ease",i.style.opacity="0.92",i.innerHTML=t.svg??Fe(t.label),n.appendChild(i),n.addEventListener("pointerdown",r=>{if(!we(r))return;let s=this.buttons.get(e);!s||s.pointerId!==null||(this.consumeEvent(r),s.pointerId=r.pointerId,this.updateButtonVisual(s,!0))});let o={slot:e,config:t,element:n,content:i,pointerId:null};return this.buttons.set(e,o),n}createJoystick(e,t){let n=document.createElement("div"),i=document.createElement("div"),o=document.createElement("div");n.className=`zylem-virtual-touch__joystick zylem-virtual-touch__joystick--${e}`,n.dataset.zylemTouchJoystick=e,n.dataset.active="false",n.style.position="absolute",n.style.width=`${t.size}px`,n.style.height=`${t.size}px`,n.style.pointerEvents="auto",n.style.touchAction="none",n.style.userSelect="none",E(n,t.position),E(n,t.style),this.appendClassName(n,t.className),i.className="zylem-virtual-touch__joystick-base",i.style.position="absolute",i.style.inset="0",i.style.pointerEvents="none",i.style.opacity="0.88",i.style.transition="opacity 120ms ease",i.innerHTML=t.svg?.base??Xe(),o.className="zylem-virtual-touch__joystick-thumb",o.style.position="absolute",o.style.left="50%",o.style.top="50%",o.style.width=`${t.thumbSize}px`,o.style.height=`${t.thumbSize}px`,o.style.pointerEvents="none",o.style.transform="translate(-50%, -50%) translate(0px, 0px)",o.style.transition="transform 60ms linear, opacity 120ms ease",o.style.opacity="0.94",o.innerHTML=t.svg?.thumb??Ye(),n.append(i,o);let r={id:e,config:t,element:n,base:i,thumb:o,pointerId:null,centerX:0,centerY:0,rawX:0,rawY:0,valueX:0,valueY:0};return this.joysticks.set(e,r),n.addEventListener("pointerdown",s=>{if(!we(s))return;let l=this.joysticks.get(e);if(!l||l.pointerId!==null)return;this.consumeEvent(s);let u=l.element.getBoundingClientRect();l.pointerId=s.pointerId,l.centerX=u.left+u.width/2,l.centerY=u.top+u.height/2,this.updateJoystickVisual(l,!0),this.updateJoystickFromPoint(l,s.clientX,s.clientY)}),n}handleButtonState(e,t,n){let i=this.buttonStates.get(e);return i||(i={pressed:!1,released:!1,held:0},this.buttonStates.set(e,i)),i.pressed=t&&i.held===0,i.released=!t&&i.held>0,i.held=t?i.held+n:0,i}handleAnalogState(e,t,n){let i=this.analogStates.get(e);return i||(i={value:0,held:0},this.analogStates.set(e,i)),i.value=t,i.held=t!==0?i.held+n:0,i}assignAxisState(e,t,n){e.axes||(e.axes={}),e.axes[t]=f(e.axes[t],n)}assignButtonState(e,t,n){if(t.category==="buttons"){e.buttons??={},e.buttons[t.property]=d(e.buttons[t.property],n);return}if(t.category==="directions"){e.directions??={},e.directions[t.property]=d(e.directions[t.property],n);return}e.shoulders??={},e.shoulders[t.property]=d(e.shoulders[t.property],n)}resolveButtonTarget(e){switch(e){case"LTrigger":case"RTrigger":return{category:"shoulders",property:e};case"Up":case"Down":case"Left":case"Right":return{category:"directions",property:e};default:return{category:"buttons",property:e}}}updateJoystickFromPoint(e,t,n){let i=t-e.centerX,o=n-e.centerY,r=Math.hypot(i,o),s=e.config.maxDistance,l=r>s&&r>0?s/r:1;e.rawX=i*l,e.rawY=o*l;let u=Ue(e.rawX/s,e.rawY/s,e.config.deadzone);e.valueX=u.x,e.valueY=u.y,e.thumb.style.transform=`translate(-50%, -50%) translate(${e.rawX}px, ${e.rawY}px)`}releaseButton(e){e.pointerId=null,this.updateButtonVisual(e,!1)}releaseJoystick(e){e.pointerId=null,e.rawX=0,e.rawY=0,e.valueX=0,e.valueY=0,e.thumb.style.transform="translate(-50%, -50%) translate(0px, 0px)",this.updateJoystickVisual(e,!1)}updateButtonVisual(e,t){e.element.dataset.active=String(t),e.content.style.transform=t?"scale(0.94)":"scale(1)",e.content.style.opacity=t?"1":"0.92"}updateJoystickVisual(e,t){e.element.dataset.active=String(t),e.base.style.opacity=t?"1":"0.88",e.thumb.style.opacity=t?"1":"0.94"}consumeEvent(e){e.cancelable&&e.preventDefault(),e.stopPropagation()}appendClassName(e,t){t&&(e.className=`${e.className} ${t}`.trim())}};function E(a,e){if(e)for(let[t,n]of Object.entries(e)){if(n==null)continue;let i=typeof n=="number"&&!Oe.has(t)?`${n}px`:String(n);t.includes("-")?a.style.setProperty(t,i):a.style[t]=i}}function Ue(a,e,t){let n=Math.hypot(a,e);if(n===0||n<=t)return{x:0,y:0};let o=Math.min(1,(n-t)/Math.max(1-t,1e-4))/n;return{x:a*o,y:e*o}}function Fe(a){let e=Ze(a);return`
2
+ <svg viewBox="0 0 100 100" width="100%" height="100%" aria-hidden="true">
3
+ <circle cx="50" cy="50" r="45" fill="rgba(12,18,24,0.72)" stroke="currentColor" stroke-width="4" />
4
+ <circle cx="50" cy="50" r="34" fill="rgba(255,255,255,0.06)" stroke="rgba(255,255,255,0.12)" stroke-width="1.5" />
5
+ <text
6
+ x="50"
7
+ y="56"
8
+ text-anchor="middle"
9
+ font-family="ui-sans-serif, system-ui, sans-serif"
10
+ font-size="${e.length>2?24:34}"
11
+ font-weight="700"
12
+ fill="currentColor"
13
+ >${e}</text>
14
+ </svg>
15
+ `}function Xe(){return`
16
+ <svg viewBox="0 0 140 140" width="100%" height="100%" aria-hidden="true">
17
+ <circle cx="70" cy="70" r="62" fill="rgba(10,16,20,0.64)" stroke="currentColor" stroke-width="4" />
18
+ <circle cx="70" cy="70" r="40" fill="rgba(255,255,255,0.04)" stroke="rgba(255,255,255,0.12)" stroke-width="1.5" />
19
+ </svg>
20
+ `}function Ye(){return`
21
+ <svg viewBox="0 0 64 64" width="100%" height="100%" aria-hidden="true">
22
+ <circle cx="32" cy="32" r="28" fill="rgba(22,30,38,0.9)" stroke="currentColor" stroke-width="3.5" />
23
+ </svg>
24
+ `}function Ze(a){return a.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#39;")}function we(a){return a.pointerType==="touch"}var A=class{inputMap=new Map;currentInputs={};previousInputs={};targetElement;mouseTargetElement;constructor(e,t){this.targetElement=t?.targetElement,this.mouseTargetElement=t?.mouseTargetElement??t?.targetElement;let n=this.buildPlayerEntries(e);for(let{player:i,config:o,gamepadIndex:r,isP1:s}of n)this.addConfigurableProviders(i,o,s),this.addInputProvider(i,new k(r))}configure(e){let t=this.buildPlayerEntries(e);for(let{player:n,config:i,isP1:o}of t){let s=(this.inputMap.get(n)??[]).filter(l=>l instanceof w||l instanceof T||l instanceof M?(l.dispose(),!1):!0);this.inputMap.set(n,[...this.createConfigurableProviders(i,o),...s])}}addInputProvider(e,t){this.inputMap.has(e)||this.inputMap.set(e,[]),this.inputMap.get(e)?.push(t)}dispose(){for(let e of this.inputMap.values())for(let t of e)t.dispose?.();this.inputMap.clear(),this.currentInputs={},this.previousInputs={}}getInputs(e){let t={};return this.inputMap.forEach((n,i)=>{let o=`p${i}`,r=n.reduce((s,l)=>{let u=l.getInput(e);return this.mergeInputs(s,u)},{});t[o]={playerNumber:i,...r}}),t}buildPlayerEntries(e){return[{player:1,config:e?.p1,gamepadIndex:0,isP1:!0},{player:2,config:e?.p2,gamepadIndex:1,isP1:!1},{player:3,config:e?.p3,gamepadIndex:2,isP1:!1},{player:4,config:e?.p4,gamepadIndex:3,isP1:!1},{player:5,config:e?.p5,gamepadIndex:4,isP1:!1},{player:6,config:e?.p6,gamepadIndex:5,isP1:!1},{player:7,config:e?.p7,gamepadIndex:6,isP1:!1},{player:8,config:e?.p8,gamepadIndex:7,isP1:!1}]}addConfigurableProviders(e,t,n){for(let i of this.createConfigurableProviders(t,n))this.addInputProvider(e,i)}createConfigurableProviders(e,t){let n=[];if(e?.key){let i=e.includeDefaults??t;n.push(new w(e.key,{includeDefaultBase:i}))}else t&&n.push(new w);return e?.mouse&&n.push(new T(e.mouse,this.mouseTargetElement)),e?.touch&&n.push(new M(e.touch,this.targetElement)),n}mergeInputs(e,t){return{buttons:{A:d(e.buttons?.A,t.buttons?.A),B:d(e.buttons?.B,t.buttons?.B),X:d(e.buttons?.X,t.buttons?.X),Y:d(e.buttons?.Y,t.buttons?.Y),Start:d(e.buttons?.Start,t.buttons?.Start),Select:d(e.buttons?.Select,t.buttons?.Select),L:d(e.buttons?.L,t.buttons?.L),R:d(e.buttons?.R,t.buttons?.R)},directions:{Up:d(e.directions?.Up,t.directions?.Up),Down:d(e.directions?.Down,t.directions?.Down),Left:d(e.directions?.Left,t.directions?.Left),Right:d(e.directions?.Right,t.directions?.Right)},axes:{Horizontal:f(e.axes?.Horizontal,t.axes?.Horizontal),Vertical:f(e.axes?.Vertical,t.axes?.Vertical),SecondaryHorizontal:f(e.axes?.SecondaryHorizontal,t.axes?.SecondaryHorizontal),SecondaryVertical:f(e.axes?.SecondaryVertical,t.axes?.SecondaryVertical)},shoulders:{LTrigger:d(e.shoulders?.LTrigger,t.shoulders?.LTrigger),RTrigger:d(e.shoulders?.RTrigger,t.shoulders?.RTrigger)},pointer:t.pointer??e.pointer}}};var V=class{_previousTime;_currentTime;_startTime;_delta;_elapsed;_timescale;_document;_pageVisibilityHandler;constructor(){this._previousTime=0,this._currentTime=0,this._startTime=q(),this._delta=0,this._elapsed=0,this._timescale=1,this._document=null,this._pageVisibilityHandler=null}connect(e){this._document=e,e.hidden!==void 0&&(this._pageVisibilityHandler=Je.bind(this),e.addEventListener("visibilitychange",this._pageVisibilityHandler,!1))}disconnect(){this._pageVisibilityHandler!==null&&(this._document.removeEventListener("visibilitychange",this._pageVisibilityHandler),this._pageVisibilityHandler=null),this._document=null}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getTimescale(){return this._timescale}setTimescale(e){return this._timescale=e,this}reset(){return this._currentTime=q()-this._startTime,this}dispose(){this.disconnect()}update(e){return this._pageVisibilityHandler!==null&&this._document.hidden===!0?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(e!==void 0?e:q())-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}};function q(){return performance.now()}function Je(){this._document.hidden===!1&&this.reset()}var I={FourByThree:1.3333333333333333,SixteenByNine:1.7777777777777777,NineBySixteen:.5625,TwentyOneByNine:2.3333333333333335,OneByOne:1},H=class{container;canvas;aspectRatio;onResize;handleResizeBound;resizeObserver=null;constructor(e){this.container=e.container,this.canvas=e.canvas,this.aspectRatio=(typeof e.aspectRatio=="number",e.aspectRatio),this.onResize=e.onResize,this.handleResizeBound=this.apply.bind(this)}attach(){window.addEventListener("resize",this.handleResizeBound),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(this.handleResizeBound),this.resizeObserver.observe(this.container)),this.apply()}detach(){window.removeEventListener("resize",this.handleResizeBound),this.resizeObserver?.disconnect(),this.resizeObserver=null}measure(){let e=this.container.getBoundingClientRect(),t=Math.round(e.width||this.container.clientWidth||0),n=Math.round(e.height||this.container.clientHeight||0);if(t>0&&n>0){if(t/n>this.aspectRatio){let u=n;return{width:Math.round(u*this.aspectRatio),height:u}}let s=t,l=Math.round(s/this.aspectRatio);return{width:s,height:l}}if(t>0){let r=t,s=Math.round(r/this.aspectRatio);return{width:r,height:s}}if(n>0){let r=n;return{width:Math.round(r*this.aspectRatio),height:r}}let i=window.innerWidth,o=Math.round(i/this.aspectRatio);return{width:i,height:o}}apply(){let{width:e,height:t}=this.measure();this.canvas.style.width=`${e}px`,this.canvas.style.height=`${t}px`,this.onResize?.(e,t)}};var Ce={NES:{displayAspect:1.3333333333333333,resolutions:[{key:"256x240",width:256,height:240,notes:"Standard NTSC; effective 240p."}]},SNES:{displayAspect:1.3333333333333333,resolutions:[{key:"256x224",width:256,height:224,notes:"Common 240p-equivalent mode."},{key:"512x448",width:512,height:448,notes:"Hi-res interlaced (480i)."}]},N64:{displayAspect:1.3333333333333333,resolutions:[{key:"320x240",width:320,height:240,notes:"Common 240p mode."},{key:"640x480",width:640,height:480,notes:"Higher resolution (480i)."}]},PS1:{displayAspect:1.3333333333333333,resolutions:[{key:"320x240",width:320,height:240,notes:"Progressive 240p common."},{key:"640x480",width:640,height:480,notes:"Interlaced 480i for higher detail."}]},PS2:{displayAspect:1.3333333333333333,resolutions:[{key:"640x480",width:640,height:480,notes:"480i/480p baseline."},{key:"720x480",width:720,height:480,notes:"480p (widescreen capable in some titles)."},{key:"1280x720",width:1280,height:720,notes:"720p (select titles)."}]},PS5:{displayAspect:1.7777777777777777,resolutions:[{key:"720x480",width:720,height:480,notes:"Legacy compatibility."},{key:"1280x720",width:1280,height:720,notes:"720p."},{key:"1920x1080",width:1920,height:1080,notes:"1080p."},{key:"2560x1440",width:2560,height:1440,notes:"1440p."},{key:"3840x2160",width:3840,height:2160,notes:"4K (up to 120Hz)."},{key:"7680x4320",width:7680,height:4320,notes:"8K (limited)."}]},XboxOne:{displayAspect:1.7777777777777777,resolutions:[{key:"1280x720",width:1280,height:720,notes:"720p (original)."},{key:"1920x1080",width:1920,height:1080,notes:"1080p (original)."},{key:"3840x2160",width:3840,height:2160,notes:"4K UHD (S/X models)."}]},MobilePortrait:{displayAspect:.5625,resolutions:[{key:"360x640",width:360,height:640,notes:"Low-density phone portrait baseline."},{key:"720x1280",width:720,height:1280,notes:"HD phone portrait."},{key:"1080x1920",width:1080,height:1920,notes:"Full HD phone portrait."}]}};function Q(a){return Ce[a].displayAspect}function ee(a,e){let t=Ce[a]?.resolutions||[];if(!e)return t[0];let n=e.toLowerCase().replace(/\s+/g,"").replace("\xD7","x");return t.find(i=>i.key.toLowerCase()===n)}function te(a){if(!a)return null;let t=String(a).toLowerCase().trim().replace(/\s+/g,"").replace("\xD7","x").match(/^(\d+)x(\d+)$/);if(!t)return null;let n=parseInt(t[1],10),i=parseInt(t[2],10);return!Number.isFinite(n)||!Number.isFinite(i)?null:{width:n,height:i}}var ne=null,ie=class{constructor(e,t,n,i,o,r,s,l,u,m,p,h,Z){this.id=e;this.globals=t;this.stages=n;this.debug=i;this.time=o;this.input=r;this.aspectRatio=s;this.internalResolution=l;this.fullscreen=u;this.bodyBackground=m;this.container=p;this.containerId=h;this.canvas=Z}};function Ke(a={}){return a.deviceProfile==="mobile"?!0:a.deviceProfile==="desktop"?!1:a.viewportSize?R({viewportSize:a.viewportSize,allowViewportOnly:!0}):R()}function $e(a,e){if(e)return e;if(a){let i=document.getElementById(a);if(i)return i}let t=a||"zylem-root",n=document.createElement("main");return n.setAttribute("id",t),n.style.position="relative",n.style.width="100%",n.style.height="100%",document.body.appendChild(n),n}function We(a){let e=a?.id??"zylem";return{id:e,globals:a?.globals??{},stages:a?.stages??[],debug:!!a?.debug,time:a?.time??0,input:a?.input,aspectRatio:I.SixteenByNine,fullscreen:!0,bodyBackground:"#000000",containerId:e}}var xe=360;function Ge(a,e){if(!a)return;if(typeof a=="string"){if(a==="native")return ne;let i=te(a);if(i)return i;if(e){let o=ee(e,a);if(o)return{width:o.width,height:o.height}}return}let t=a.width,n=a.height;if(Number.isFinite(t)&&Number.isFinite(n))return{width:t,height:n}}function je(a,e,t,n){if(typeof a=="number")return a;if(typeof a=="string")return I[a]??t;if(e)try{return Q(e)||t}catch{return t}return n?n.width/n.height:t}function qe(a){let e=Number.isFinite(a)&&a>0?a:I.SixteenByNine;if(e>=1){let i=xe;return{width:Math.round(i*e),height:i}}let t=xe,n=Math.round(t/e);return{width:t,height:n}}function B(a,e={}){let t=We({id:a?.id??"zylem",debug:!!a?.debug,time:a?.time??0,input:a?.input,stages:a?.stages??[],globals:a?.globals??{}}),n=a?.containerId??t.containerId,i=$e(n,a?.container??null),o=a?.mobile,r=Ke(e),s=r?o?.preset??a?.preset:a?.preset,l=Ge(a?.resolution,a?.preset),u=Ge(o?.resolution,o?.preset??a?.preset),m=(r?Te(u):void 0)??Te(l),p=r?o?.aspectRatio??a?.aspectRatio:a?.aspectRatio,h=je(p,s,t.aspectRatio,m),Z=Qe(r,u,l,h),Ie=a?.fullscreen??t.fullscreen,Be=a?.bodyBackground??t.bodyBackground,Pe=a?.canvas??void 0,Le=et(a?.input??t.input,o?.controls);return new ie(a?.id??t.id,a?.globals??t.globals,a?.stages??t.stages,!!(a?.debug??t.debug),a?.time??t.time,Le,h,Z,Ie,Be,i,n,Pe)}function Te(a){if(a)return a}function Qe(a,e,t,n){if(a)return e===ne?void 0:e??qe(n);if(t!==ne)return t}function et(a,e){if(!e)return a;let n=ge("p1",{enabled:"auto",...e===!0?{}:e});return v(n,a??{})}function tt(a){return{...a}}var O=class{id;container;canvas;bodyBackground;fullscreen;aspectRatio;ratioDelegate=null;overlayContainer=null;constructor(e){this.id=e.id,this.container=this.ensureContainer(e.containerId??e.id,e.container),this.canvas=e.canvas??document.createElement("canvas"),this.bodyBackground=e.bodyBackground,this.fullscreen=!!e.fullscreen,this.aspectRatio=(typeof e.aspectRatio=="number",e.aspectRatio)}applyBodyBackground(){this.bodyBackground&&(document.body.style.background=this.bodyBackground)}mountCanvas(){this.mountChildren(this.canvas)}mountRenderer(e,t){this.mountChildren(e),this.canvas=e,this.attachAspectRatio(t)}getOverlayContainer(){return this.ensureOverlayContainer()}centerIfFullscreen(){if(!this.fullscreen)return;let e=this.container.style;e.display="flex",e.alignItems="center",e.justifyContent="center",e.position="relative",e.inset="0"}attachAspectRatio(e){this.ratioDelegate?(this.ratioDelegate.canvas=this.canvas,this.ratioDelegate.onResize=e,this.ratioDelegate.aspectRatio=this.aspectRatio,this.ratioDelegate.apply()):(this.ratioDelegate=new H({container:this.container,canvas:this.canvas,aspectRatio:this.aspectRatio,onResize:e}),this.ratioDelegate.attach())}setAspectRatio(e){this.aspectRatio=e,this.ratioDelegate&&(this.ratioDelegate.aspectRatio=e,this.ratioDelegate.apply())}reapplyLayout(){this.ratioDelegate?.apply()}destroy(){this.ratioDelegate?.detach(),this.ratioDelegate=null}mountChildren(e){for(;this.container.firstChild;)this.container.removeChild(this.container.firstChild);this.container.appendChild(e),this.container.appendChild(this.ensureOverlayContainer())}ensureOverlayContainer(){if(this.overlayContainer)return this.overlayContainer;let e=document.createElement("div");return e.dataset.zylemOverlayRoot="true",e.style.position="absolute",e.style.inset="0",e.style.pointerEvents="none",e.style.touchAction="none",e.style.zIndex="10",this.overlayContainer=e,e}ensureContainer(e,t){if(t)return t;if(e){let o=document.getElementById(e);if(o)return o}let n=e||this.id||"zylem-root",i=document.createElement("main");return i.setAttribute("id",n),i.style.position="relative",i.style.width="100%",i.style.height="100%",document.body.appendChild(i),i}};import nt from"stats.js";import{subscribe as it}from"valtio/vanilla";var _=class{statsRef=null;unsubscribe=null;constructor(){this.updateDebugUI(),this.unsubscribe=it(g,()=>{this.updateDebugUI()})}begin(){this.statsRef?.begin()}end(){this.statsRef?.end()}updateDebugUI(){g.enabled&&!this.statsRef?(this.statsRef=new nt,this.statsRef.showPanel(0),this.statsRef.dom.style.position="absolute",this.statsRef.dom.style.bottom="0",this.statsRef.dom.style.right="0",this.statsRef.dom.style.top="auto",this.statsRef.dom.style.left="auto",document.body.appendChild(this.statsRef.dom)):!g.enabled&&this.statsRef&&(this.statsRef.dom.parentNode&&this.statsRef.dom.parentNode.removeChild(this.statsRef.dom),this.statsRef=null)}dispose(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null),this.statsRef?.dom?.parentNode&&this.statsRef.dom.parentNode.removeChild(this.statsRef.dom),this.statsRef=null}};var N=class{loadingHandlers=[];stageLoadingUnsubscribes=[];onLoading(e){return this.loadingHandlers.push(e),()=>{this.loadingHandlers=this.loadingHandlers.filter(t=>t!==e)}}emit(e){for(let n of this.loadingHandlers)try{n(e)}catch(i){console.error("Game loading handler failed",i)}let t=`loading:${e.type}`;y.emit(t,e)}wireStageLoading(e,t){let n=e.onLoading(i=>{this.emit({type:i.type,message:i.message??"",progress:i.progress??0,current:i.current,total:i.total,stageName:e.uuid??`Stage ${t}`,stageIndex:t})});typeof n=="function"&&this.stageLoadingUnsubscribes.push(n)}unwireAllStages(){for(let e of this.stageLoadingUnsubscribes)try{e()}catch{}this.stageLoadingUnsubscribes=[]}dispose(){this.unwireAllStages(),this.loadingHandlers=[]}};var U=class{container=null;camera=null;rendererManager=null;gameCanvas=null;config=null;stage=null;mounted=!1;setGameCanvas(e){this.gameCanvas=e,this.tryMount()}setConfig(e){this.config=e,this.tryMount()}setContainer(e){this.container=e,this.tryMount()}setStage(e){this.stage=e,this.mounted&&this.gameCanvas?.reapplyLayout()}setCamera(e){this.camera=e,this.tryMount()}setRendererManager(e){this.rendererManager=e,this.tryMount()}tryMount(){this.mounted||!this.container||!this.gameCanvas||(this.rendererManager?this.mountWithRendererManager():this.camera&&this.mountWithCamera())}mountWithRendererManager(){if(!this.rendererManager||!this.gameCanvas)return;let e=this.rendererManager.getDomElement();this.gameCanvas.mountRenderer(e,(t,n)=>{if(!this.rendererManager)return;let i=this.config?.internalResolution;if(i)this.rendererManager.setPixelRatio(1),this.rendererManager.resize(i.width,i.height),this.stage?.resize(i.width,i.height);else{let o=window.devicePixelRatio||1;this.rendererManager.setPixelRatio(o),this.rendererManager.resize(t,n),this.stage?.resize(t,n)}}),this.mounted=!0}mountWithCamera(){if(!this.camera||!this.gameCanvas)return;let e=this.camera.getDomElement();this.gameCanvas.mountRenderer(e,(t,n)=>{if(!this.camera)return;let i=this.config?.internalResolution;if(i)this.camera.setPixelRatio(1),this.camera.resize(i.width,i.height);else{let o=window.devicePixelRatio||1;this.camera.setPixelRatio(o),this.camera.resize(t,n)}}),this.mounted=!0}reset(){this.camera=null,this.stage=null,this.mounted=!1}dispose(){this.container=null,this.camera=null,this.rendererManager=null,this.gameCanvas=null,this.config=null,this.stage=null,this.mounted=!1}};var F=class a{id;initialGlobals={};customSetup=null;customUpdate=null;customDestroy=null;stages=[];stageMap=new Map;currentStageId="";previousTimeStamp=0;totalTime=0;timer;inputManager;wrapperRef;globalInputConfig;defaultCamera=null;rendererManager=null;container=null;canvas=null;aspectRatioDelegate=null;resolvedConfig=null;gameCanvas=null;animationFrameId=null;isDisposed=!1;loadInFlight=!1;hasStarted=!1;debugDelegate=null;loadingDelegate=new N;rendererObserver=new U;eventBusUnsubscribes=[];thumbnailUnsubscribes=[];entityDispatchTimer=null;pendingEntityDispatchPath=null;static ENTITY_DISPATCH_DEBOUNCE_MS=150;gameUpdateParams={};stageSetupParams={};stageUpdateParams={};frameCallback=e=>this.loop(e);sourceOptions;displayRuntime;static FRAME_LIMIT=120;static FRAME_DURATION=1e3/a.FRAME_LIMIT;static MAX_DELTA_SECONDS=1/30;constructor(e,t,n={}){this.wrapperRef=t,this.timer=new V,this.timer.connect(document),this.sourceOptions={...e},this.displayRuntime={...n};let i=B(e,this.displayRuntime);this.globalInputConfig=i.input,this.id=i.id,this.stages=i.stages||[],this.container=i.container,this.canvas=i.canvas??null,this.resolvedConfig=i,this.loadGameCanvas(i),this.container=this.gameCanvas?.container??this.container,this.inputManager=new A(i.input,{targetElement:this.gameCanvas?.getOverlayContainer(),mouseTargetElement:this.gameCanvas?.container}),this.loadDebugOptions(e),this.setGlobals(e)}setDisplayRuntime(e){this.displayRuntime={...e};let t=B(this.sourceOptions,this.displayRuntime);this.resolvedConfig=t,this.rendererObserver.setConfig(t),this.gameCanvas?.setAspectRatio(t.aspectRatio),this.emitStateDispatch("@game:display-config")}loadGameCanvas(e){this.gameCanvas=new O({id:e.id,container:e.container,containerId:e.containerId,canvas:this.canvas??void 0,bodyBackground:e.bodyBackground,fullscreen:e.fullscreen,aspectRatio:e.aspectRatio}),this.gameCanvas.applyBodyBackground(),this.gameCanvas.mountCanvas(),this.gameCanvas.centerIfFullscreen(),this.rendererObserver.setGameCanvas(this.gameCanvas),this.resolvedConfig&&this.rendererObserver.setConfig(this.resolvedConfig),this.container&&this.rendererObserver.setContainer(this.container),this.subscribeToEventBus()}loadDebugOptions(e){e.debug!==void 0&&(g.enabled=!!e.debug),this.debugDelegate=new _}isLoading(){return this.loadInFlight}async loadStage(e,t=0,n){if(this.loadInFlight){console.warn("loadStage ignored: a stage load is already in progress");return}this.loadInFlight=!0;try{await this.performLoadStage(e,t,n)}finally{this.loadInFlight=!1}}async performLoadStage(e,t=0,n){let i=n?ye(n):null,o=this.currentStage()??null,r=o?.wrappedStage??null,s=r?.scene?.scene??null,l=r?.cameraManagerRef?.primaryCamera?.camera??r?.cameraRef?.camera??null;i&&this.rendererManager?.initialized&&o&&s&&l&&this.rendererManager.beginSnapshotTransition(i,s,l),this.unloadCurrentStage();let m=e.options[0];if(this.loadingDelegate.wireStageLoading(e,t),this.rendererManager||(this.rendererManager=new he,await this.rendererManager.initRenderer()),b.setRenderer(this.rendererManager.renderer),await e.load(this.id,m?.camera,this.rendererManager),this.stageMap.set(e.wrappedStage.uuid,e),this.currentStageId=e.wrappedStage.uuid,this.defaultCamera=e.wrappedStage.cameraRef,this.wireEntityThumbnails(e),this.rendererObserver.setStage(e.wrappedStage??null),this.rendererManager&&this.rendererObserver.setRendererManager(this.rendererManager),this.applyInputConfig(e),e.onInputConfigChanged=()=>this.applyInputConfig(e),this.hasStarted&&e.wrappedStage&&!e.wrappedStage.hasSetup){let p=this.params(),h={...this.stageSetupParams};h.inputs=p.inputs,h.globals=p.globals,h.camera=p.camera,h.stage=p.stage,h.game=p.game,h.me=e.wrappedStage,e.start(h)}this.emitStateDispatch("@stage:loaded")}applyInputConfig(e){let t=v(this.globalInputConfig??{},e.inputConfig??{});this.inputManager.configure(t)}setGlobalInputConfig(e){this.globalInputConfig=e;let t=this.currentStage();t&&this.applyInputConfig(t)}unloadCurrentStage(){if(!this.currentStageId)return;let e=this.getStage(this.currentStageId);if(e){if(this.clearEntityThumbnailWiring(),b.clear(),e.onInputConfigChanged=null,e?.wrappedStage){try{e.wrappedStage.nodeDestroy({me:e.wrappedStage,globals:C.globals})}catch(t){console.error("Failed to destroy previous stage",t)}e.wrappedStage=null}e.dispose(),this.stageMap.delete(this.currentStageId),this.currentStageId="",this.defaultCamera=null,this.rendererObserver.reset()}}setGlobals(e){this.initialGlobals={...e.globals};for(let t in this.initialGlobals){let n=this.initialGlobals[t];n===void 0&&console.error(`global ${t} is undefined`),le(t,n)}}params(){let e=this.currentStage(),t=this.timer.getDelta(),n=this.inputManager.getInputs(t),i=e?.wrappedStage?.cameraRef||this.defaultCamera,o=this.gameUpdateParams;return o.delta=t,o.inputs=n,o.globals=de(),o.me=this,o.camera=i,o.stage=e,o.game=this.wrapperRef,o}start(){let e=this.currentStage(),t=this.params(),n=this.stageSetupParams;n.inputs=t.inputs,n.globals=t.globals,n.camera=t.camera,n.stage=t.stage,n.game=t.game,n.me=e.wrappedStage,e.start(n),this.customSetup&&this.customSetup(t),this.hasStarted=!0,this.loop(0)}step(e){let t=this.currentStage();if(!t||!t.wrappedStage)return;let n=this.params(),i=e!==void 0?e:n.delta,o=Math.min(Math.max(i,0),a.MAX_DELTA_SECONDS);n.delta=o,this.customUpdate&&this.customUpdate(n);let r=this.currentStage();if(r!==t||!r?.wrappedStage){this.totalTime+=o,C.time=this.totalTime;return}let s=this.stageUpdateParams;s.delta=n.delta,s.inputs=n.inputs,s.globals=n.globals,s.camera=n.camera,s.stage=n.stage,s.game=n.game,s.me=t.wrappedStage,t.wrappedStage?.nodeUpdate(s),this.totalTime+=o,C.time=this.totalTime}loop(e){this.debugDelegate?.begin(),me()||(this.timer.update(e),this.step(),this.previousTimeStamp=e),this.debugDelegate?.end(),this.outOfLoop(),this.isDisposed||(this.animationFrameId=requestAnimationFrame(this.frameCallback))}dispose(){this.isDisposed=!0,this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.unloadCurrentStage(),this.debugDelegate&&(this.debugDelegate.dispose(),this.debugDelegate=null),this.eventBusUnsubscribes.forEach(e=>e()),this.eventBusUnsubscribes=[],this.rendererObserver.dispose(),this.inputManager.dispose(),this.rendererManager&&(b.setRenderer(null),this.rendererManager.dispose(),this.rendererManager=null),this.timer.dispose(),this.customDestroy&&this.customDestroy({me:this,globals:C.globals}),x()}outOfLoop(){let e=this.currentStage();e&&e.wrappedStage.outOfLoop()}getStage(e){return this.stageMap.get(e)}currentStage(){return this.getStage(this.currentStageId)}onLoading(e){return this.loadingDelegate.onLoading(e)}buildStageConfigPayload(){let e=this.currentStage();if(!e?.wrappedStage)return null;let t=e.wrappedStage.state,n=t.backgroundColor,i=typeof n=="string"?n:`#${n.getHexString()}`;return{id:e.wrappedStage.uuid,backgroundColor:i,backgroundImage:t.backgroundImage,gravity:{x:t.gravity.x,y:t.gravity.y,z:t.gravity.z},inputs:t.inputs,variables:t.variables}}buildEntitiesPayload(){let e=this.currentStage();if(!e?.wrappedStage)return null;let t=[];return e.wrappedStage.entityDelegate.childrenMap.forEach(n=>{if(P(n.options))return;let i=n.constructor.type,o=i?String(i).replace("Symbol(","").replace(")",""):"Unknown",r=n.position??{x:0,y:0,z:0},s=n.rotation??{x:0,y:0,z:0},l=n.scale??{x:1,y:1,z:1},u=b.get(n.uuid);t.push({uuid:n.uuid,name:n.name||"Unnamed",type:o,position:{x:r.x??0,y:r.y??0,z:r.z??0},rotation:{x:s.x??0,y:s.y??0,z:s.z??0},scale:{x:l.x??1,y:l.y??1,z:l.z??1},thumbnail:u?.dataUrl??null,bounds:u?.bounds})}),t}wireEntityThumbnails(e){if(this.clearEntityThumbnailWiring(),!e.wrappedStage)return;let t=r=>{if(P(r.options))return;let s=r.group??r.mesh??null;s&&b.ensure(r.uuid,s).then(l=>{l&&this.queueEntityStateDispatch("@entity:thumbnail")})},n=e.wrappedStage.onEntityAdded(r=>{t(r)},{replayExisting:!0});this.thumbnailUnsubscribes.push(n);let i=r=>{if(!r.success)return;let s=e.wrappedStage?.entityDelegate.childrenMap.get(r.entityId);s&&(b.invalidate(r.entityId),t(s))};y.on("entity:model:loaded",i),this.thumbnailUnsubscribes.push(()=>{y.off("entity:model:loaded",i)});let o=r=>{b.invalidate(r.entityId),this.queueEntityStateDispatch("@entity:destroyed")};y.on("entity:destroyed",o),this.thumbnailUnsubscribes.push(()=>{y.off("entity:destroyed",o)})}clearEntityThumbnailWiring(){this.thumbnailUnsubscribes.forEach(e=>{try{e()}catch{}}),this.thumbnailUnsubscribes=[],this.entityDispatchTimer!==null&&(clearTimeout(this.entityDispatchTimer),this.entityDispatchTimer=null),this.pendingEntityDispatchPath=null}queueEntityStateDispatch(e){this.pendingEntityDispatchPath=e,this.entityDispatchTimer===null&&(this.entityDispatchTimer=setTimeout(()=>{this.entityDispatchTimer=null;let t=this.pendingEntityDispatchPath;this.pendingEntityDispatchPath=null,t&&!this.isDisposed&&this.emitStateDispatch(t)},a.ENTITY_DISPATCH_DEBOUNCE_MS))}emitStateDispatch(e,t,n){let i={scope:"game",path:e,value:t,previousValue:n,config:this.resolvedConfig?{id:this.resolvedConfig.id,aspectRatio:this.resolvedConfig.aspectRatio,fullscreen:this.resolvedConfig.fullscreen,bodyBackground:this.resolvedConfig.bodyBackground,internalResolution:this.resolvedConfig.internalResolution,debug:this.resolvedConfig.debug}:null,stageConfig:this.buildStageConfigPayload(),entities:this.buildEntitiesPayload()};y.emit("state:dispatch",i)}subscribeToEventBus(){this.eventBusUnsubscribes.push(re.on("game:state:updated",e=>{this.emitStateDispatch(e.path,e.value,e.previousValue)}))}};async function Re(a){let{getGameDefaultConfig:e}=await import("./game-default-6AZZCNST.js"),t={...e()},n=[],i=[],o=[];Object.values(a).forEach(s=>{if(s instanceof L)i.push(s);else if(s instanceof j)o.push(s);else if(s instanceof $)o.push(s);else if(s?.constructor?.name==="Object"&&typeof s=="object"){let l=Object.assign({...e()},{...s});n.push(l)}}),n.forEach(s=>{t=Object.assign(t,{...s})});let r=t;return r.input=n[0].input,i.forEach(s=>{s.addEntities(o)}),i.length?r.stages=i:r.stages[0].addEntities(o),r}function Ee(a){return!!a.find(t=>t instanceof L)}function ae(a){for(let e of a)if(e&&typeof e=="object"&&!(e instanceof L)&&!(e instanceof $)&&!(e instanceof j)){let t=e;if(t.globals)return t.globals}}import{proxy as at}from"valtio/vanilla";import{get as ot,set as st}from"idb-keyval";import{pack as rt,unpack as lt}from"msgpackr";var c=at({previous:null,current:null,next:null,isLoading:!1}),X={staticRegistry:new Map,registerStaticStage(a,e){this.staticRegistry.set(a,e)},async loadStageData(a){try{let e=await ot(a);if(e)return lt(e)}catch(e){console.warn(`Failed to load stage ${a} from storage`,e)}if(this.staticRegistry.has(a))return this.staticRegistry.get(a);throw new Error(`Stage ${a} not found in storage and static loading not fully implemented.`)},async transitionForward(a,e){if(!c.isLoading){c.isLoading=!0;try{c.current&&await st(c.current.id,rt(c.current)),c.previous=c.current,c.current=c.next,c.current?.id!==a&&(e?c.current=await e(a):c.current=await this.loadStageData(a)),c.next=null}catch(t){console.error("Failed to transition stage:",t)}finally{c.isLoading=!1}}},async preloadNext(a,e){e?c.next=await e(a):c.next=await this.loadStageData(a)}};var oe={async createFromBlueprint(a){let e=G({});if(a.entities)for(let t of a.entities)try{let n=await Se.createFromBlueprint(t);e.add(n)}catch(n){console.error(`Failed to create entity ${t.id} for stage ${a.id}`,n)}return e}};var Y=class{wrappedGame=null;options;setupCallbacks=[];updateCallbacks=[];destroyCallbacks=[];pendingLoadingCallbacks=[];globalChangeCallbacks=[];globalChangesCallbacks=[];activeGlobalSubscriptions=[];eventDelegate=new fe;pendingInputConfig=null;displayRuntime={};refErrorMessage="lost reference to game";constructor(e){this.options=e,Ee(e)||this.options.push(G());let t=ae(e);t&&J(t)}onSetup(...e){return this.setupCallbacks.push(...e),this}onUpdate(...e){return this.updateCallbacks.push(...e),this}onDestroy(...e){return this.destroyCallbacks.push(...e),this}setInputConfiguration(...e){let t=v(...e);return this.pendingInputConfig=t,this.wrappedGame&&this.wrappedGame.setGlobalInputConfig(t),this}async start(){x();let e=ae(this.options);e&&J(e);let t=await this.load();return this.wrappedGame=t,this.setOverrides(),this.registerGlobalSubscriptions(),t.start(),this}setDisplayRuntime(e){return this.displayRuntime={...this.displayRuntime,...e},this.wrappedGame&&this.wrappedGame.setDisplayRuntime(this.displayRuntime),this}setDeviceProfile(e){return this.setDisplayRuntime({deviceProfile:e})}setViewportSize(e,t){return this.setDisplayRuntime({viewportSize:{width:e,height:t}})}async load(){let e=await Re(this.options),t=B(e,this.displayRuntime);this.pendingInputConfig&&(t.input=v(t.input??{},this.pendingInputConfig));let n=new F({...e,...t},this,this.displayRuntime);for(let i of this.pendingLoadingCallbacks)n.onLoading(i);return await n.loadStage(e.stages[0]),n}setOverrides(){if(!this.wrappedGame){console.error(this.refErrorMessage);return}this.wrappedGame.customSetup=e=>{this.setupCallbacks.forEach(t=>t(e))},this.wrappedGame.customUpdate=e=>{this.updateCallbacks.forEach(t=>t(e))},this.wrappedGame.customDestroy=e=>{this.destroyCallbacks.forEach(t=>t(e))}}onGlobalChange(e,t){return this.globalChangeCallbacks.push({path:e,callback:t}),this}onGlobalChanges(e,t){return this.globalChangesCallbacks.push({paths:e,callback:t}),this}registerGlobalSubscriptions(){for(let{path:e,callback:t}of this.globalChangeCallbacks){let n=ue(e,i=>{t(i,this.getCurrentStage())});this.activeGlobalSubscriptions.push(n)}for(let{paths:e,callback:t}of this.globalChangesCallbacks){let n=pe(e,i=>{t(i,this.getCurrentStage())});this.activeGlobalSubscriptions.push(n)}}getCurrentStage(){return this.wrappedGame?.currentStage()??null}experimental={getRuntime:()=>this.getCurrentStage()?.wrappedStage?.world?.simulation??null};async pause(){K(!0)}async resume(){K(!1),this.wrappedGame&&(this.wrappedGame.previousTimeStamp=0,this.wrappedGame.timer.reset())}step(e=1/60){if(!this.wrappedGame){console.error(this.refErrorMessage);return}this.wrappedGame.step(e)}async reset(e){if(!this.wrappedGame){console.error(this.refErrorMessage);return}this.wrappedGame.isLoading()||await this.wrappedGame.loadStage(this.wrappedGame.stages[0],0,e?.transition)}previousStage(e){if(!this.wrappedGame){console.error(this.refErrorMessage);return}if(this.wrappedGame.isLoading())return;let t=this.wrappedGame.currentStageId,n=this.wrappedGame.stages.findIndex(o=>o.wrappedStage?.uuid===t),i=this.wrappedGame.stages[n-1];if(!i){console.error("previous stage called on first stage");return}this.wrappedGame.loadStage(i,n-1,e?.transition)}async loadStageFromId(e){if(!this.wrappedGame){console.error(this.refErrorMessage);return}try{let t=await X.loadStageData(e),n=await oe.createFromBlueprint(t);await this.wrappedGame.loadStage(n),c.current=t}catch(t){console.error(`Failed to load stage ${e}`,t)}}nextStage(e){if(!this.wrappedGame){console.error(this.refErrorMessage);return}if(this.wrappedGame.isLoading())return;if(c.next){console.log("next stage called");let o=c.next.id;if(X.transitionForward(o),c.current){oe.createFromBlueprint(c.current).then(r=>{this.wrappedGame?.loadStage(r,0,e?.transition)});return}}let t=this.wrappedGame.currentStageId,n=this.wrappedGame.stages.findIndex(o=>o.wrappedStage?.uuid===t),i=this.wrappedGame.stages[n+1];if(!i){console.error("next stage called on last stage");return}this.wrappedGame.loadStage(i,n+1,e?.transition)}async goToStage(){}async end(){}dispose(){this.eventDelegate.dispose();for(let e of this.activeGlobalSubscriptions)e();this.activeGlobalSubscriptions=[],this.wrappedGame&&(this.wrappedGame.dispose(),this.wrappedGame=null),ce(),x(),be.clearSharedMaterialCache()}dispatch(e,t){this.eventDelegate.dispatch(e,t),y.emit(e,t)}listen(e,t){return this.eventDelegate.listen(e,t)}onLoading(e){return this.wrappedGame?this.wrappedGame.onLoading(e):(this.pendingLoadingCallbacks.push(e),()=>{this.pendingLoadingCallbacks=this.pendingLoadingCallbacks.filter(t=>t!==e),this.wrappedGame})}};function ut(...a){return new Y(a)}import{Euler as pt,Quaternion as dt,Vector2 as ct}from"three";function mt(a){return{spawn:async(e,t,n)=>{let i=await Promise.resolve(a(t,n));return e.add(i),i},spawnRelative:async(e,t,n=new ct(0,1))=>{if(!e.body){console.warn("body missing for entity during spawnRelative");return}let{x:i,y:o,z:r}=e.body.translation(),s=e._rotation2DAngle??0;try{let p=e.body.rotation(),h=new dt(p.x,p.y,p.z,p.w);s=new pt().setFromQuaternion(h,"XYZ").z}catch{}let l=Math.sin(-s)*(n.x??0),u=Math.cos(-s)*(n.y??0),m=await Promise.resolve(a(i+l,o+u));return t.add(m),m}}}import{subscribe as ht}from"valtio/vanilla";var se="STAGE_STATE_CHANGE";function gt(){return ht(S,()=>{let a={entities:S.entities,variables:S.variables};window.dispatchEvent(new CustomEvent(se,{detail:a}))})}function ft(){let a={entities:S.entities,variables:S.variables};window.dispatchEvent(new CustomEvent(se,{detail:a}))}import{MathUtils as yt,Vector3 as bt}from"three";var Me={targetKey:"primary",offset:new bt(0,0,0),lerpFactor:.1};function vt(a){let e={...Me,...a,offset:W(a?.offset,Me.offset)},t=null;return{priority:0,enabled:!0,onAttach(){t=null},update(n,i){let o=n.targets[e.targetKey];if(!o)return i;let r=o.position.clone().add(e.offset),s=ve(i);if(!t)t=r.clone();else{let l=yt.clamp(e.lerpFactor,0,1),u=1-Math.pow(1-l,n.dt*60);t.lerp(r,u)}return s.position.copy(t),s.lookAt=o.position.clone(),s},onDetach(){t=null}}}import{MeshBasicMaterial as St}from"three";function wt(a,e,t){let n=e.cameraRef;if(!n.renderTarget){let r=t?.width??512,s=t?.height??512;n.createRenderTarget(r,s)}let i=n.getRenderTexture();if(!i){console.warn("setCameraFeed: Failed to obtain render texture from camera.");return}if(!a.mesh){console.warn("setCameraFeed: Entity has no mesh to apply the camera feed to.");return}let o=new St({map:i});a.mesh.material=o}export{I as a,Q as b,ee as c,te as d,tt as e,c as f,X as g,Y as h,ut as i,mt as j,se as k,gt as l,ft as m,vt as n,wt as o};
@@ -0,0 +1 @@
1
+ import{b as a}from"./chunk-EVYHPR3J.js";import{c as r,d as u,h as t}from"./chunk-7WRQ2UAN.js";import{StageBodyKind as T,StageBoundaryDim as V,StageEventType as F,StageRicochetDim as H,StageRicochetReflection as z,StageTopDownPlane as A,createSimulation as I}from"@zylem/behaviors/core";import{StageBodyKind as g}from"@zylem/behaviors/core";var n={kind:g.Dynamic,position:[0,0,0],rotation:[0,0,0,1],linearDamping:0,angularDamping:0,gravityScale:1,canSleep:!1,ccdEnabled:!0,lockRotation:[!1,!1,!1],lockTranslation:[!1,!1,!1]};function c(e={}){let i=t(e.position,r);return{kind:e.kind??n.kind,position:[i.x,i.y,i.z],rotation:e.rotation??n.rotation,linearDamping:e.linearDamping??n.linearDamping,angularDamping:e.angularDamping??n.angularDamping,gravityScale:e.gravityScale??n.gravityScale,canSleep:e.canSleep??n.canSleep,ccdEnabled:e.ccdEnabled??n.ccdEnabled,lockRotation:e.lockRotation??n.lockRotation,lockTranslation:e.lockTranslation??n.lockTranslation}}function l(e,i){let o=t(i.offset,r);return{shape:e,offset:[o.x,o.y,o.z],friction:i.friction??.5,restitution:i.restitution??0,sensor:i.sensor??!1,collisionGroups:a(i.collisionType,i.collisionFilter)}}function p(e,i={}){let o=t(e,u);return l({type:"box",halfExtents:[o.x/2,o.y/2,o.z/2]},i)}function C(e,i={}){return l({type:"sphere",radius:e},i)}function s(e,i,o={}){return l({type:"capsule",halfHeight:e,radius:i},o)}function f(e,i,o={}){return l({type:"cylinder",halfHeight:e,radius:i},o)}function y(e,i={}){return l({type:"convexHull",vertices:e},i)}function S(e,i,o={}){return l({type:"trimesh",vertices:e,indices:i},o)}function b(e,i,o,d,m={}){return l({type:"heightfield",rows:e,cols:i,heights:o,scale:d},m)}function R(e,i){return{body:e,colliders:i}}export{c as a,p as b,C as c,s as d,f as e,y as f,S as g,b as h,R as i,T as j,V as k,F as l,H as m,z as n,A as o,I as p};
@@ -0,0 +1 @@
1
+ import{clamp as t,mix as a}from"three/tsl";var o=({fromNode:e,toNode:n,progress:r})=>a(e,n,t(r,0,1));function i(e){return e<.5?2*e*e:1-(-2*e+2)**2/2}function s(e){return typeof e=="function"?e:e==="linear"?n=>n:i}function m(e={}){let n=e.shader,r=typeof n=="function"?n:n?.shader??o;return{duration:Math.max(.01,e.duration??.8),shader:r,easing:s(e.easing),onComplete:e.onComplete}}export{o as a,m as b};
@@ -0,0 +1 @@
1
+ function n(r,t){let e=t-r;for(;e>Math.PI;)e-=2*Math.PI;for(;e<-Math.PI;)e+=2*Math.PI;return e}function a(r,t,e=45){let o=e*Math.PI/180;return{targetYaw:-r*o,targetPitch:-t*o}}function m(r,t,e,o,s={}){let{targetYaw:i,targetPitch:c}=a(r,t,s.maxLookDegrees??45),u=s.lookSensitivity??2;return{lookX:n(e,i)/u,lookY:n(o,c)/u}}export{n as a,a as b,m as c};
@@ -0,0 +1 @@
1
+ import{Vector2 as s,Vector3 as x}from"three";var c=Object.freeze({x:0,y:0}),d=Object.freeze({x:1,y:1}),i=Object.freeze({x:0,y:0,z:0}),w=Object.freeze({x:1,y:1,z:1});function p(n){return typeof n=="number"&&Number.isFinite(n)}function b(n){return n!=null&&typeof n=="object"&&("x"in n||"y"in n)}function f(n){return n!=null&&typeof n=="object"&&("x"in n||"y"in n||"z"in n)}function V(n,t,e){if(!n)return e;let r=n[t];return p(r)?r:e}function y(n,t,e){if(!n)return e;let r=n[t];return p(r)?r:e}function u(n,t,e,r){return n?Array.isArray(n)?V(n,e,r):y(n,t,r):r}function o(n,t,e,r){return n?Array.isArray(n)?V(n,e,r):y(n,t,r):r}function a(n){return{x:u(n,"x",0,0),y:u(n,"y",1,0)}}function z(n){return{x:o(n,"x",0,0),y:o(n,"y",1,0),z:o(n,"z",2,0)}}function k(n){return Array.isArray(n)||b(n)}function A(n){return Array.isArray(n)||f(n)}function C(n,t=c){let e=a(t);return{x:u(n,"x",0,e.x),y:u(n,"y",1,e.y)}}function l(n,t=i){let e=z(t);return{x:o(n,"x",0,e.x),y:o(n,"y",1,e.y),z:o(n,"z",2,e.z)}}function h(n,t=c){let{x:e,y:r}=C(n,t);return new s(e,r)}function T(n,t=i){let{x:e,y:r,z:m}=l(n,t);return new x(e,r,m)}export{c as a,d as b,i as c,w as d,k as e,A as f,C as g,l as h,h as i,T as j};
@@ -0,0 +1 @@
1
+ function d(e,n){return e.priority!==n.priority?e.priority-n.priority:e.sourceId.localeCompare(n.sourceId)}function m(e,n,t){let r=!1,l=0,u=!1,y=e,a=Number.NEGATIVE_INFINITY;for(let i of n){let o=i[t];if(o!=null){if(r=!0,i.mode==="add"){l+=o;continue}(!u||i.priority>=a)&&(u=!0,a=i.priority,y=o)}}return{touched:r,value:(u?y:0)+l}}function b(e,n){return{x:m(e.x,n,"x"),y:m(e.y,n,"y"),z:m(e.z,n,"z")}}function v(e){for(let n in e.velocityChannels)delete e.velocityChannels[n];e.dirty.velocityChannels=!1}function f(e){let n=[];if(e.dirty.velocityChannels)for(let t in e.velocityChannels){let r=e.velocityChannels[t];n.push({sourceId:t,mode:r.mode??"replace",priority:r.priority??0,x:r.x,y:r.y,z:r.z})}return(e.dirty.velocityX||e.dirty.velocityY||e.dirty.velocityZ)&&n.push({sourceId:"__legacy_per_axis__",mode:"replace",priority:-100,x:e.dirty.velocityX?e.velocity.x:void 0,y:e.dirty.velocityY?e.velocity.y:void 0,z:e.dirty.velocityZ?e.velocity.z:void 0}),n}function p(e){e.dirty.position=!1,e.dirty.rotation=!1,e.dirty.velocityX=!1,e.dirty.velocityY=!1,e.dirty.velocityZ=!1,v(e),e.dirty.angularVelocity=!1}function x(e,n,t){let r=t.dirty.position,l=t.dirty.rotation,u=t.dirty.angularVelocity,y=t.dirty.velocityX||t.dirty.velocityY||t.dirty.velocityZ,a=t.dirty.velocityChannels;if(!r&&!l&&!u&&!y&&!a)return;let i=f(t);if(i.length>0){let o=e.getLinearVelocity(n)??[0,0,0],c={x:o[0],y:o[1],z:o[2]};i.length>1&&i.sort(d);let s=b(c,i);e.setLinearVelocity(n,s.x.touched?s.x.value:c.x,s.y.touched?s.y.value:c.y,s.z.touched?s.z.value:c.z)}if(l){let o=t.rotation;e.setRotation(n,o.x,o.y,o.z,o.w)}if(u){let o=t.angularVelocity;e.setAngularVelocity(n,o.x,o.y,o.z)}if(r){let o=e.getPose(n);o&&e.setPosition(n,o.position[0]+t.position.x,o.position[1]+t.position.y,o.position[2]+t.position.z)}p(t)}function h(e,n){if(!e.body){e.wasmStageRef&&(e.runtimeHandle??-1)>=0&&x(e.wasmStageRef,e.runtimeHandle,n);return}let t=n.dirty.position,r=n.dirty.rotation,l=n.dirty.angularVelocity,u=n.dirty.velocityX||n.dirty.velocityY||n.dirty.velocityZ,y=n.dirty.velocityChannels;if(!t&&!r&&!l&&!u&&!y)return;let a=f(n);if(a.length>0){let i=e.body.linvel();a.length>1&&a.sort(d);let o=b(i,a);e.body.setLinvel({x:o.x.touched?o.x.value:i.x,y:o.y.touched?o.y.value:i.y,z:o.z.touched?o.z.value:i.z},!0)}if(r&&e.body.setRotation(n.rotation,!0),l&&e.body.setAngvel(n.angularVelocity,!0),t){let i=e.body.translation();e.body.setTranslation({x:i.x+n.position.x,y:i.y+n.position.y,z:i.z+n.position.z},!0)}p(n)}export{h as a};
File without changes
@@ -0,0 +1 @@
1
+ import{a as P}from"./chunk-MZZCDXFB.js";import{a as Dt,b as Z,c as Y,d as N,e as W,f as X,g as U,h as j,j as q,p as m,q as w,r as c,t as x,u as R,v as $,w as K,x as D}from"./chunk-KVSJE4XD.js";import{j as kt}from"./chunk-CM5YRNBJ.js";import{d as V,j as Rt}from"./chunk-4QLJUQSJ.js";import{a as It,b as gt,c as zt,d as Lt,g as Bt,h as xt,i as E,j as Ht}from"./chunk-7WRQ2UAN.js";import{Vector3 as Fe}from"three";import{BoxGeometry as ze,CapsuleGeometry as Le,ConeGeometry as Ft,CylinderGeometry as Be,Mesh as I,MeshStandardMaterial as He,SphereGeometry as ke}from"three";function z(i,t=Symbol("mesh")){if(i.material||i.color){let e=new kt;if(e.build({...i.material,color:i.color??i.material?.color},t),e.materials.length>0)return e.materials}return[new He]}function L(i,t){if(t.position){let e=xt(t.position,zt);i.position.set(e.x,e.y,e.z)}return i.castShadow=!0,i.receiveShadow=!0,i}function Q(i={}){let t=xt(i.size,Lt),e=new ze(t.x,t.y,t.z),o=z(i);return L(new I(e,o.at(-1)),i)}function J(i={}){let t=new ke(i.radius??1),e=z(i);return L(new I(t,e.at(-1)),i)}function tt(i={}){let t=new Ft(i.radius??1,i.height??2,i.radialSegments??32),e=z(i);return L(new I(t,e.at(-1)),i)}function et(i={}){let t=new Ft(i.radius??1,i.height??2,4),e=z(i);return L(new I(t,e.at(-1)),i)}function it(i={}){let t=new Be(i.radiusTop??1,i.radiusBottom??1,i.height??2,i.radialSegments??32),e=z(i);return L(new I(t,e.at(-1)),i)}function ot(i={}){let t=new Le(i.radius??.5,i.length??1,i.capSegments??10,i.radialSegments??20),e=z(i);return L(new I(t,e.at(-1)),i)}var Gt={...m,size:new Fe(1,1,1)},At=Symbol("Box"),nt=class i extends c{static type=At;constructor(t){super(),this.options={...Gt,...t}}buildInfo(){let e=new P(this).buildDebugInfo(),{x:o,y:n,z:s}=this.options.size??{x:1,y:1,z:1};return{...e,type:String(i.type),size:`${o}, ${n}, ${s}`}}};function Vt(...i){let t=w(i,Gt),e=new nt(t);return e.add(Q({size:t.size,material:t.material,color:t.color}),Y({size:t.size,static:t.collision?.static,sensor:t.collision?.sensor,canSleep:t.collision?.canSleep,ccdEnabled:t.collision?.ccdEnabled,gravityScale:t.collision?.gravityScale,lockRotations:t.collision?.lockRotations,lockTranslations:t.collision?.lockTranslations,collisionType:t.collisionType,collisionFilter:t.collisionFilter})),x(e,o=>Vt(o??{}))}var Yt={...m,radius:1},Nt=Symbol("Sphere"),st=class i extends c{static type=Nt;constructor(t){super(),this.options={...Yt,...t}}buildInfo(){let e=new P(this).buildDebugInfo(),o=this.options.radius??1;return{...e,type:String(i.type),radius:o.toFixed(2)}}};function Wt(...i){let t=w(i,Yt),e=new st(t);return e.add(J({radius:t.radius,material:t.material,color:t.color}),N({radius:t.radius,static:t.collision?.static,sensor:t.collision?.sensor,gravityScale:t.collision?.gravityScale,lockRotations:t.collision?.lockRotations,lockTranslations:t.collision?.lockTranslations,collisionType:t.collisionType,collisionFilter:t.collisionFilter})),x(e,o=>Wt(o??{}))}import{PlaneGeometry as Ae,Vector2 as Xt,Vector3 as Ut}from"three";import{BufferGeometry as Ge,Float32BufferAttribute as bt}from"three";var rt=class i extends Ge{constructor(t=1,e=1,o=1,n=1){super(),this.type="XZPlaneGeometry",this.parameters={width:t,height:e,widthSegments:o,heightSegments:n};let s=t/2,a=e/2,r=Math.floor(o),l=Math.floor(n),p=r+1,O=l+1,u=t/r,d=e/l,b=[],f=[],y=[],_=[];for(let g=0;g<O;g++){let h=g*d-a;for(let C=0;C<p;C++){let T=C*u-s;f.push(T,0,h),y.push(0,1,0),_.push(C/r),_.push(1-g/l)}}for(let g=0;g<l;g++)for(let h=0;h<r;h++){let C=h+p*g,T=h+p*(g+1),S=h+1+p*(g+1),v=h+1+p*g;b.push(C,T,v),b.push(T,S,v)}this.setIndex(b),this.setAttribute("position",new bt(f,3)),this.setAttribute("normal",new bt(y,3)),this.setAttribute("uv",new bt(_,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new i(t.width,t.height,t.widthSegments,t.heightSegments)}};var at=4,jt={...m,tile:new Xt(10,10),repeat:new Xt(1,1),collision:{static:!0},subdivisions:at,randomizeHeight:!1,heightScale:1};function qt(i){let t=i.subdivisions??at,e=i.heightMap2D,o=i.heightMap,n=i.subdivisionsX??t,s=i.subdivisionsZ??t;return e&&e.length>0&&e[0]?.length>0?(s=e.length-1,n=e[0].length-1):o&&o.length>0&&(n=o.length-1),{subdivisionsX:n,subdivisionsZ:s}}var Ot=class extends ${collider(t){let e=E(t.tile,gt),{subdivisionsX:o,subdivisionsZ:n}=qt(t),s=new Ut(e.x,1,e.y),a=t._builders?.meshBuilder?.heightData??new Float32Array((o+1)*(n+1));return{shape:{type:"heightfield",rows:o,cols:n,heights:a,scale:[s.x,1,s.z]}}}},Pt=class extends K{heightData=new Float32Array;columnsRows=new Map;subdivisionsX=at;subdivisionsZ=at;build(t){let e=E(t.tile,gt),{subdivisionsX:o,subdivisionsZ:n}=qt(t);this.subdivisionsX=o,this.subdivisionsZ=n;let s=new Ut(e.x,1,e.y),a=t.heightScale??1,r=new rt(s.x,s.z,o,n),l=new Ae(s.x,s.z,o,n),p=o>0?s.x/o:1,O=n>0?s.z/n:1,u=r.attributes.position.array,d=l.attributes.position.array,b=new Map,f=t.heightMap2D,y=t.heightMap,_=t.randomizeHeight??!1,g=(h,C)=>h<0?0:h>C?C:h;for(let h=0;h<d.length;h+=3){let C=d[h],T=d[h+1],S=g(Math.round((C+s.x/2)/p),o),v=g(Math.round((s.z/2-T)/O),n),M=0;if(f){let Mt=f[v];Mt&&(M=Mt[S]??0)}else y&&y.length>0?M=y[S]??0:_&&(M=Math.random()*4);let G=M*a;d[h+2]=G,u[h+1]=G,b.get(v)||b.set(v,new Map),b.get(v).set(S,G)}return this.columnsRows=b,r}postBuild(){let t=[];for(let e=0;e<=this.subdivisionsX;++e)for(let o=0;o<=this.subdivisionsZ;++o){let n=this.columnsRows.get(o);t.push(n?.get(e)??0)}this.heightData=new Float32Array(t)}},St=class extends D{createEntity(t){return new B(t)}},$t=Symbol("Plane"),B=class extends c{static type=$t;constructor(t){super(),this.options=Z(jt,t)}};function Kt(...i){return R({args:i,defaultConfig:jt,EntityClass:B,BuilderClass:St,MeshBuilderClass:Pt,CollisionBuilderClass:Ot,entityType:B.type,cloneFactory:t=>Kt(t??{})})}import{Vector3 as Ve}from"three";var Qt={...m,size:new Ve(1,1,1),collision:{static:!0}},Jt=Symbol("Zone"),lt=class extends c{static type=Jt;_enteredZone=new Map;_exitedZone=new Map;_zoneEntities=new Map;constructor(t){super(),this.options=Z(Qt,t)}handlePostCollision({delta:t}){return this._enteredZone.forEach((e,o)=>{this.exited(t,o)}),this._enteredZone.size>0}handleIntersectionEvent({other:t,delta:e}){this._enteredZone.get(t.uuid)?this.held(e,t):(this.entered(t),this._zoneEntities.set(t.uuid,t))}onEnter(t){return this.options.onEnter=t,this}onHeld(t){return this.options.onHeld=t,this}onExit(t){return this.options.onExit=t,this}entered(t){this._enteredZone.set(t.uuid,1),this.options.onEnter&&this.options.onEnter({self:this,visitor:t,globals:V.globals})}exited(t,e){let o=this._exitedZone.get(e);if(o&&o>1+t){this._exitedZone.delete(e),this._enteredZone.delete(e);let n=this._zoneEntities.get(e);this.options.onExit&&this.options.onExit({self:this,visitor:n,globals:V.globals});return}this._exitedZone.set(e,1+t)}held(t,e){let o=this._enteredZone.get(e.uuid)??0;this._enteredZone.set(e.uuid,o+t),this._exitedZone.set(e.uuid,1),this.options.onHeld&&this.options.onHeld({delta:t,self:this,visitor:e,globals:V.globals,heldTime:o})}};function te(...i){let t=w(i,Qt),e=new lt(t);return e.add(q({size:t.size,static:t.collision?.static??!0,collisionType:t.collisionType,collisionFilter:t.collisionFilter})),x(e,o=>te(o??{}))}import{Color as ee,Group as Ye,Sprite as Ne,SpriteMaterial as We,CanvasTexture as ie,LinearFilter as ct,Vector2 as pt,ClampToEdgeWrapping as oe,ShaderMaterial as ne,Mesh as Xe,PlaneGeometry as Ue,Vector3 as se}from"three";var H={position:void 0,width:120,height:48,fillColor:"#FFFFFF",strokeColor:null,strokeWidth:0,radius:0,padding:0,stickToViewport:!0,screenPosition:new pt(24,24),zDistance:1,anchor:new pt(0,0)},wt=class extends D{createEntity(t){return new k(t)}},re=Symbol("Rect"),k=class i extends c{static type=re;_sprite=null;_mesh=null;_texture=null;_canvas=null;_ctx=null;_cameraRef=null;_lastCanvasW=0;_lastCanvasH=0;constructor(t){super(),this.options=Z(H,t),this.options.screenPosition=E(this.options.screenPosition,H.screenPosition),this.options.anchor=E(this.options.anchor,H.anchor),this.group=new Ye,this.createSprite(),this.prependSetup(this.rectSetup.bind(this)),this.prependUpdate(this.rectUpdate.bind(this))}createSprite(){this._canvas=document.createElement("canvas"),this._ctx=this._canvas.getContext("2d"),this._texture=new ie(this._canvas),this._texture.minFilter=ct,this._texture.magFilter=ct;let t=new We({map:this._texture,transparent:!0,depthTest:!1,depthWrite:!1,alphaTest:.5});this._sprite=new Ne(t),this.group?.add(this._sprite),this.redrawRect()}redrawRect(){if(!this._canvas||!this._ctx)return;let t=Math.max(2,Math.floor(this.options.width??120)),e=Math.max(2,Math.floor(this.options.height??48)),o=this.options.padding??0,n=this.options.strokeWidth??0,s=t+o*2+n,a=e+o*2+n,r=Math.max(2,s),l=Math.max(2,a),p=r!==this._lastCanvasW||l!==this._lastCanvasH;this._canvas.width=r,this._canvas.height=l,this._lastCanvasW=r,this._lastCanvasH=l,this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height);let O=Math.max(0,this.options.radius??0),u=Math.floor(o+n/2),d=Math.floor(o+n/2),b=Math.floor(t),f=Math.floor(e);if(this._ctx.beginPath(),O>0?this.roundedRectPath(this._ctx,u,d,b,f,O):this._ctx.rect(u,d,b,f),this.options.fillColor&&(this._ctx.fillStyle=this.toCssColor(this.options.fillColor),this._ctx.fill()),this.options.strokeColor&&n>0&&(this._ctx.lineWidth=n,this._ctx.strokeStyle=this.toCssColor(this.options.strokeColor),this._ctx.stroke()),this._texture){if(p&&(this._texture.dispose(),this._texture=new ie(this._canvas),this._texture.minFilter=ct,this._texture.magFilter=ct,this._texture.wrapS=oe,this._texture.wrapT=oe,this._sprite&&this._sprite.material instanceof ne)){let y=this._sprite.material;y.uniforms?.tDiffuse&&(y.uniforms.tDiffuse.value=this._texture),y.uniforms?.iResolution&&y.uniforms.iResolution.value.set(this._canvas.width,this._canvas.height,1)}this._texture.image=this._canvas,this._texture.needsUpdate=!0,this._sprite&&this._sprite.material&&(this._sprite.material.map=this._texture,this._sprite.material.needsUpdate=!0)}}getWidth(){return this.options.width??0}getHeight(){return this.options.height??0}roundedRectPath(t,e,o,n,s,a){let r=Math.min(a,Math.floor(Math.min(n,s)/2));t.moveTo(e+r,o),t.lineTo(e+n-r,o),t.quadraticCurveTo(e+n,o,e+n,o+r),t.lineTo(e+n,o+s-r),t.quadraticCurveTo(e+n,o+s,e+n-r,o+s),t.lineTo(e+r,o+s),t.quadraticCurveTo(e,o+s,e,o+s-r),t.lineTo(e,o+r),t.quadraticCurveTo(e,o,e+r,o)}toCssColor(t){return typeof t=="string"?t:`#${(t instanceof ee?t:new ee(t)).getHexString()}`}getResolution(){try{let t=this._cameraRef?.renderer?.domElement;if(t)return{width:t.clientWidth||1,height:t.clientHeight||1}}catch{}return{width:this._cameraRef?.screenResolution?.x??1,height:this._cameraRef?.screenResolution?.y??1}}rectSetup(t){if(this._cameraRef=t.camera,this.options.stickToViewport&&this._cameraRef&&this._cameraRef.camera.add(this.group),this.materials?.length&&this._sprite){let e=this.materials[0];e instanceof ne&&(e.transparent=!0,e.depthTest=!1,e.depthWrite=!1,this._texture&&(e.uniforms?.tDiffuse&&(e.uniforms.tDiffuse.value=this._texture),e.uniforms?.iResolution&&this._canvas&&e.uniforms.iResolution.value.set(this._canvas.width,this._canvas.height,1)),this._mesh=new Xe(new Ue(1,1),e),this.group?.add(this._mesh),this._sprite.visible=!1)}}rectUpdate(t){if(this._sprite){if(this._cameraRef&&this.options.bounds){let e=this.computeScreenBoundsFromOptions(this.options.bounds);if(e){let{x:o,y:n,width:s,height:a}=e,r=Math.max(2,Math.floor(s)),l=Math.max(2,Math.floor(a)),p=r!==(this.options.width??0)||l!==(this.options.height??0);this.options.screenPosition=new pt(Math.floor(o),Math.floor(n)),this.options.width=r,this.options.height=l,this.options.anchor=new pt(0,0),p&&this.redrawRect()}}this.options.stickToViewport&&this._cameraRef&&this.updateStickyTransform()}}updateStickyTransform(){if(!this._sprite||!this._cameraRef)return;let t=this._cameraRef.camera,{width:e,height:o}=this.getResolution(),n=E(this.options.screenPosition,H.screenPosition),s=n.x,a=n.y,r=Math.max(.001,this.options.zDistance??1),l=1,p=1;if(t.isPerspectiveCamera){let S=t,v=Math.tan(S.fov*Math.PI/180/2)*r;l=v*S.aspect,p=v}else if(t.isOrthographicCamera){let S=t;l=(S.right-S.left)/2,p=(S.top-S.bottom)/2}let O=s/e*2-1,u=1-a/o*2,d=O*l,b=u*p,f=1,y=1;if(this._canvas){let v=p*2/o,M=this._canvas.height;y=Math.max(1e-4,M*v);let G=this._canvas.width/this._canvas.height;f=y*G,this._sprite.scale.set(f,y,1),this._mesh&&this._mesh.scale.set(f,y,1)}let _=E(this.options.anchor,H.anchor),g=Math.min(100,Math.max(0,_.x))/100,h=Math.min(100,Math.max(0,_.y))/100,C=(.5-g)*f,T=(h-.5)*y;this.group?.position.set(d+C,b+T,-r)}worldToScreen(t){if(!this._cameraRef)return{x:0,y:0};let e=this._cameraRef.camera,{width:o,height:n}=this.getResolution(),s=t.clone().project(e),a=(s.x+1)/2*o,r=(1-s.y)/2*n;return{x:a,y:r}}computeScreenBoundsFromOptions(t){if(!this._cameraRef)return null;if(t.screen)return{...t.screen};if(t.world){let{left:e,right:o,top:n,bottom:s,z:a=0}=t.world,r=this.worldToScreen(new se(e,n,a)),l=this.worldToScreen(new se(o,s,a)),p=Math.min(r.x,l.x),O=Math.min(r.y,l.y),u=Math.abs(l.x-r.x),d=Math.abs(l.y-r.y);return{x:p,y:O,width:u,height:d}}return null}updateRect(t){this.options={...this.options,...t},this.redrawRect(),this.options.stickToViewport&&this._cameraRef&&this.updateStickyTransform()}buildInfo(){return{...new P(this).buildDebugInfo(),type:String(i.type),width:this.options.width??0,height:this.options.height??0,sticky:this.options.stickToViewport}}};function ae(...i){return R({args:i,defaultConfig:{...H},EntityClass:k,BuilderClass:wt,entityType:k.type,cloneFactory:t=>ae(t??{})})}import{Group as je,RingGeometry as qe}from"three";var le={...m,innerRadius:0,outerRadius:1,thetaSegments:32},Ct=class extends ${collider(t){let e=t.outerRadius??1;return{shape:{type:"cylinder",halfHeight:.1/2,radius:e}}}},vt=class extends K{build(t){let e=t.innerRadius??0,o=t.outerRadius??1,n=t.thetaSegments??32,s=new qe(e,o,n);return s.rotateX(-Math.PI/2),s}},_t=class extends D{createEntity(t){return new F(t)}build(){let t=super.build();return t.mesh&&!t.group&&(t.group=new je,t.group.add(t.mesh)),t}},ce=Symbol("Disk"),F=class i extends c{static type=ce;constructor(t){super(),this.options={...le,...t}}buildInfo(){let e=new P(this).buildDebugInfo(),o=this.options.innerRadius??0,n=this.options.outerRadius??1;return{...e,type:String(i.type),innerRadius:o.toFixed(2),outerRadius:n.toFixed(2)}}};function pe(...i){return R({args:i,defaultConfig:le,EntityClass:F,BuilderClass:_t,MeshBuilderClass:vt,CollisionBuilderClass:Ct,entityType:F.type,cloneFactory:t=>pe(t??{})})}var he={...m,radius:1,height:2,radialSegments:32},me=Symbol("Cone"),ht=class i extends c{static type=me;constructor(t){super(),this.options={...he,...t}}buildInfo(){let e=new P(this).buildDebugInfo(),o=this.options.radius??1,n=this.options.height??2;return{...e,type:String(i.type),radius:o.toFixed(2),height:n.toFixed(2)}}};function ue(...i){let t=w(i,he),e=new ht(t);return e.add(tt({radius:t.radius,height:t.height,radialSegments:t.radialSegments,material:t.material,color:t.color}),W({radius:t.radius,height:t.height,static:t.collision?.static,sensor:t.collision?.sensor,gravityScale:t.collision?.gravityScale,lockRotations:t.collision?.lockRotations,lockTranslations:t.collision?.lockTranslations,collisionType:t.collisionType,collisionFilter:t.collisionFilter})),x(e,o=>ue(o??{}))}var de={...m,radius:1,height:2},ye=Symbol("Pyramid"),mt=class i extends c{static type=ye;constructor(t){super(),this.options={...de,...t}}buildInfo(){let e=new P(this).buildDebugInfo(),o=this.options.radius??1,n=this.options.height??2;return{...e,type:String(i.type),radius:o.toFixed(2),height:n.toFixed(2)}}};function fe(...i){let t=w(i,de),e=new mt(t);return e.add(et({radius:t.radius,height:t.height,material:t.material,color:t.color}),X({radius:t.radius,height:t.height,static:t.collision?.static,sensor:t.collision?.sensor,gravityScale:t.collision?.gravityScale,lockRotations:t.collision?.lockRotations,lockTranslations:t.collision?.lockTranslations,collisionType:t.collisionType,collisionFilter:t.collisionFilter})),x(e,o=>fe(o??{}))}var ge={...m,radiusTop:1,radiusBottom:1,height:2,radialSegments:32},xe=Symbol("Cylinder"),ut=class i extends c{static type=xe;constructor(t){super(),this.options={...ge,...t}}buildInfo(){let e=new P(this).buildDebugInfo(),o=this.options.radiusTop??1,n=this.options.radiusBottom??1,s=this.options.height??2;return{...e,type:String(i.type),radiusTop:o.toFixed(2),radiusBottom:n.toFixed(2),height:s.toFixed(2)}}};function be(...i){let t=w(i,ge),e=new ut(t);return e.add(it({radiusTop:t.radiusTop,radiusBottom:t.radiusBottom,height:t.height,radialSegments:t.radialSegments,material:t.material,color:t.color}),U({radiusTop:t.radiusTop,radiusBottom:t.radiusBottom,height:t.height,static:t.collision?.static,sensor:t.collision?.sensor,gravityScale:t.collision?.gravityScale,lockRotations:t.collision?.lockRotations,lockTranslations:t.collision?.lockTranslations,collisionType:t.collisionType,collisionFilter:t.collisionFilter})),x(e,o=>be(o??{}))}var Oe={...m,radius:.5,length:1,capSegments:10,radialSegments:20},Pe=Symbol("Pill"),dt=class i extends c{static type=Pe;constructor(t){super(),this.options={...Oe,...t}}buildInfo(){let e=new P(this).buildDebugInfo(),o=this.options.radius??.5,n=this.options.length??1;return{...e,type:String(i.type),radius:o.toFixed(2),length:n.toFixed(2)}}};function Se(...i){let t=w(i,Oe),e=new dt(t);return e.add(ot({radius:t.radius,length:t.length,capSegments:t.capSegments,radialSegments:t.radialSegments,material:t.material,color:t.color}),j({radius:t.radius,length:t.length,static:t.collision?.static,sensor:t.collision?.sensor,gravityScale:t.collision?.gravityScale,lockRotations:t.collision?.lockRotations,lockTranslations:t.collision?.lockTranslations,collisionType:t.collisionType,collisionFilter:t.collisionFilter})),x(e,o=>Se(o??{}))}import{Group as $e,Quaternion as Ke,Vector3 as Qe}from"three";import{ParticleEmitterBehavior as Et}from"@zylem/behaviors/particle-emitter";var Je={...m,effect:{create(){throw new Error("createParticleSystem(...) requires an effect or preset definition.")}},preset:void 0,autoplay:!0,localOffset:void 0,followPosition:!0,followRotation:!0,autoDestroy:!1},we=Symbol("ParticleSystem");function ti(i){return{effect:i.preset??i.effect,autoplay:i.autoplay,localOffset:i.localOffset,followPosition:i.followPosition,followRotation:i.followRotation,autoDestroy:i.autoDestroy}}var yt=class i extends c{static type=we;particleHandle=null;constructor(t,e=!0){super(),this.options=Z(Je,t),this.group=new $e;let o=this.options.position;o&&this.group.position.copy(Ht(o)),this.__zylemParticleSystemEntity=!0,this.bindStandaloneTransforms(),e&&(this.particleHandle=this.use(Et,ti(this.options)))}bindStandaloneTransforms(){let t=()=>{this.options.position=new Qe(this.group?.position.x??0,this.group?.position.y??0,this.group?.position.z??0)},e=()=>{this.group&&(this._rotation2DAngle=this.group.rotation.z)};this.setPosition=(o,n,s)=>{this.group?.position.set(o,n,s),t()},this.setPositionX=o=>{this.group&&(this.group.position.x=o,t())},this.setPositionY=o=>{this.group&&(this.group.position.y=o,t())},this.setPositionZ=o=>{this.group&&(this.group.position.z=o,t())},this.getPosition=()=>this.group?{x:this.group.position.x,y:this.group.position.y,z:this.group.position.z}:null,this.setRotation=(o,n,s)=>{this.group?.rotation.set(o,n,s),e()},this.setRotationX=o=>{this.group&&(this.group.rotation.x=o,e())},this.setRotationY=o=>{this.group&&(this.group.rotation.y=o,e())},this.setRotationZ=o=>{this.group&&(this.group.rotation.z=o,e())},this.setRotationDegrees=(o,n,s)=>{this.group?.rotation.set(o*Math.PI/180,n*Math.PI/180,s*Math.PI/180),e()},this.setRotationDegreesX=o=>{this.group&&(this.group.rotation.x=o*Math.PI/180,e())},this.setRotationDegreesY=o=>{this.group&&(this.group.rotation.y=o*Math.PI/180,e())},this.setRotationDegreesZ=o=>{this.group&&(this.group.rotation.z=o*Math.PI/180,e())},this.rotateX=o=>{this.group?.rotateX(o),e()},this.rotateY=o=>{this.group?.rotateY(o),e()},this.rotateZ=o=>{this.group?.rotateZ(o),e()},this.getRotation=()=>{if(!this.group)return null;let o=new Ke;return this.group.getWorldQuaternion(o),o}}resolveParticleHandle(){if(this.particleHandle)return this.particleHandle;let t=this.getBehaviorRefs().find(n=>n.descriptor.key===Et.key);if(!t)return null;let e={getFSM:()=>t.fsm??null,getOptions:()=>t.options,ref:t},o=Et.createHandle?.(t)??{};return this.particleHandle={...e,...o},this.particleHandle}play(){this.resolveParticleHandle()?.play()}stop(){this.resolveParticleHandle()?.stop()}pause(){this.resolveParticleHandle()?.pause()}restart(){this.resolveParticleHandle()?.restart()}burst(){this.resolveParticleHandle()?.burst()}isPlaying(){return this.resolveParticleHandle()?.isPlaying()??!1}getSystem(){return this.resolveParticleHandle()?.getSystem()}buildInfo(){return{...super.buildInfo(),type:String(i.type)}}};function Ce(i,t=!0){let e=new yt(i,t);return x(e,o=>Ce(o,!1))}function ei(i){return Ce(i,!0)}import{AmbientLight as ii,DirectionalLight as oi,Group as ni,HemisphereLight as si,Object3D as ri,PointLight as ai,SpotLight as li}from"three";var ve=Symbol("Light"),ci={x:0,y:0,z:0},A=16777215,pi={mapSize:2048,near:.1,far:500,bias:0,radius:1,left:-100,right:100,top:100,bottom:-100},hi={mapSize:1024,near:.1,far:500,bias:0,radius:1},ft=class extends c{static type=ve;light=null;lightTarget=null;constructor(t){super(),this.options={...t}}create(){super.create();let t=new ni,{light:e,target:o}=mi(this.options);return t.add(e),o&&t.add(o),this.group=t,this.light=e,this.lightTarget=o,this}_cleanup(t){this.light?.shadow?.map?.dispose?.(),this.light=null,this.lightTarget=null,super._cleanup(t)}};function mi(i){switch(i.type){case"ambient":return{light:ui(i),target:null};case"hemisphere":return{light:di(i),target:null};case"directional":return yi(i);case"point":return{light:fi(i),target:null};case"spot":return gi(i)}}function ui(i){let t=new ii(i.color??A,i.intensity??1);return i.name&&(t.name=i.name),t}function di(i){let t=i.skyColor??i.color??A,e=i.groundColor??0,o=new si(t,e,i.intensity??1);return i.name&&(o.name=i.name),o}function yi(i){let t=new oi(i.color??A,i.intensity??1);i.name&&(t.name=i.name),xi(t,i.castShadow??!1,i.shadow);let e=_e(i.position,i.target);return e&&(t.target=e),{light:t,target:e}}function fi(i){let t=new ai(i.color??A,i.intensity??1,i.distance,i.decay);return i.name&&(t.name=i.name),Ee(t,i.castShadow??!1,i.shadow),t}function gi(i){let t=new li(i.color??A,i.intensity??1,i.distance,i.angle,i.penumbra,i.decay);i.name&&(t.name=i.name),Ee(t,i.castShadow??!1,i.shadow);let e=_e(i.position,i.target);return e&&(t.target=e),{light:t,target:e}}function _e(i,t){if(!t)return null;let e=i??ci,o=new ri;return o.position.set(t.x-e.x,t.y-e.y,t.z-e.z),o}function xi(i,t,e){if(!t){i.castShadow=!1;return}i.castShadow=!0;let o={...pi,...e??{}};i.shadow.mapSize.set(o.mapSize,o.mapSize),i.shadow.camera.near=o.near,i.shadow.camera.far=o.far,i.shadow.camera.left=o.left,i.shadow.camera.right=o.right,i.shadow.camera.top=o.top,i.shadow.camera.bottom=o.bottom,i.shadow.bias=o.bias,i.shadow.radius=o.radius,i.shadow.camera.updateProjectionMatrix()}function Ee(i,t,e){if(!t){i.castShadow=!1;return}i.castShadow=!0;let o={...hi,...e??{}};i.shadow.mapSize.set(o.mapSize,o.mapSize),i.shadow.camera.near=o.near,i.shadow.camera.far=o.far,i.shadow.bias=o.bias,i.shadow.radius=o.radius,i.shadow.camera.updateProjectionMatrix()}function bi(i){return new ft(i)}import{Group as Oi,Sprite as Pi,SpriteMaterial as Si,CanvasTexture as wi,LinearFilter as Ze,Color as Te,ClampToEdgeWrapping as Me}from"three";import{getCooldown as Re}from"@zylem/behaviors/cooldown";var Ci={"top-left":{fx:0,fy:0},"top-center":{fx:.5,fy:0},"top-right":{fx:1,fy:0},"center-left":{fx:0,fy:.5},center:{fx:.5,fy:.5},"center-right":{fx:1,fy:.5},"bottom-left":{fx:0,fy:1},"bottom-center":{fx:.5,fy:1},"bottom-right":{fx:1,fy:1}},De=192,vi={xs:8,sm:16,md:32,lg:48,xl:64},Zt={position:void 0,cooldown:"",iconSize:"md",fillColor:"#333333",showTimer:!0,stickToViewport:!0,screenAnchor:"top-left",screenPosition:{x:0,y:0},zDistance:1,overlayColor:"rgba(0, 0, 0, 0.65)"},_i=Symbol("CooldownIcon"),Tt=class extends c{static type=_i;_sprite=null;_texture=null;_canvas=null;_ctx=null;_cameraRef=null;_iconTexture=null;_iconImage=null;_lastRenderedProgress=-1;constructor(t){super(),this.options=Z(Zt,t),this.options.screenPosition=E(this.options.screenPosition,Zt.screenPosition),this.group=new Oi,this.createSprite(),this.prependSetup(this.iconSetup.bind(this)),this.prependUpdate(this.iconUpdate.bind(this)),this.onCleanup(this.iconDestroy.bind(this))}createSprite(){this._canvas=document.createElement("canvas"),this._canvas.width=256,this._canvas.height=256,this._ctx=this._canvas.getContext("2d"),this._texture=new wi(this._canvas),this._texture.minFilter=Ze,this._texture.magFilter=Ze,this._texture.wrapS=Me,this._texture.wrapT=Me;let e=new Si({map:this._texture,transparent:!0,depthTest:!1,depthWrite:!1});if(this._sprite=new Pi(e),this.group?.add(this._sprite),this.options.icon){let o=new Image;o.crossOrigin="anonymous",o.onload=()=>{this._iconImage=o,this.redraw(this._lastRenderedProgress>=0?this._lastRenderedProgress:1)},o.src=this.options.icon}this.redraw(1)}redraw(t){if(!this._canvas||!this._ctx)return;let e=this._ctx,o=this._canvas.width,n=this._canvas.height,s=o/2,a=n/2,r=Math.min(s,a);if(e.clearRect(0,0,o,n),this._iconImage?e.drawImage(this._iconImage,0,0,o,n):(e.fillStyle=this.toCssColor(this.options.fillColor??"#333333"),e.fillRect(0,0,o,n)),t<1){let l=(1-t)*Math.PI*2,p=-Math.PI/2,O=p+l;if(e.save(),e.fillStyle=this.options.overlayColor??"rgba(0, 0, 0, 0.65)",e.beginPath(),e.moveTo(s,a),e.arc(s,a,r+1,p,O,!1),e.closePath(),e.fill(),e.restore(),this.options.showTimer){let u=Re(this.options.cooldown);if(u){let d=Math.max(0,u.duration-u.elapsed),b=d>=10?Math.ceil(d).toString():d.toFixed(1),f=Math.floor(o*.3);e.font=`bold ${f}px sans-serif`,e.textAlign="center",e.textBaseline="middle",e.fillStyle="#FFFFFF",e.strokeStyle="#000000",e.lineWidth=2,e.strokeText(b,s,a),e.fillText(b,s,a)}}}this._texture&&(this._texture.needsUpdate=!0),this._lastRenderedProgress=t}toCssColor(t){return typeof t=="string"?t:`#${(t instanceof Te?t:new Te(t)).getHexString()}`}getResolution(){try{let t=this._cameraRef?.renderer?.domElement;if(t)return{width:t.clientWidth||1,height:t.clientHeight||1}}catch{}return{width:this._cameraRef?.screenResolution?.x??1,height:this._cameraRef?.screenResolution?.y??1}}iconSetup(t){this._sprite||this.createSprite(),this._cameraRef=t.camera,this.options.stickToViewport&&this._cameraRef&&(this._cameraRef.camera.add(this.group),this.updateStickyTransform())}iconUpdate(t){let o=Re(this.options.cooldown)?.progress??1;(Math.abs(o-this._lastRenderedProgress)>.02||o===1&&this._lastRenderedProgress!==1)&&this.redraw(o),this.options.stickToViewport&&this._cameraRef&&this.updateStickyTransform()}resolveScreenPosition(t,e){let o=this.options.screenAnchor??"top-left",n=Bt(this.options.screenPosition,It),s=n.x,a=n.y,{fx:r,fy:l}=Ci[o],p=r*t,O=l*e,u=e/De;return{px:p+s*u,py:O+a*u}}resolveIconSize(t){let e=this.options.iconSize??"md",o,n;typeof e=="string"?o=n=vi[e]:typeof e=="number"?o=n=e:(o=e.width,n=e.height);let s=t/De;return{widthPx:o*s,heightPx:n*s}}computeWorldExtents(t,e){let o=1,n=1;if(t.isPerspectiveCamera){let s=t,a=Math.tan(s.fov*Math.PI/180/2)*e;o=a*s.aspect,n=a}else if(t.isOrthographicCamera){let s=t;o=(s.right-s.left)/2,n=(s.top-s.bottom)/2}return{worldHalfW:o,worldHalfH:n}}updateStickyTransform(){if(!this._sprite||!this._cameraRef)return;let t=this._cameraRef.camera,{width:e,height:o}=this.getResolution(),{px:n,py:s}=this.resolveScreenPosition(e,o),a=Math.max(.001,this.options.zDistance??1),{worldHalfW:r,worldHalfH:l}=this.computeWorldExtents(t,a),p=n/e*2-1,O=1-s/o*2,u=p*r,d=O*l;{let f=l*2/o,{widthPx:y,heightPx:_}=this.resolveIconSize(o),g=Math.max(1e-4,y*f),h=Math.max(1e-4,_*f);this._sprite.scale.set(g,h,1)}this.group?.position.set(u,d,-a)}iconDestroy(){this._texture?.dispose(),this._sprite?.material&&this._sprite.material.dispose(),this._sprite&&this._sprite.removeFromParent(),this.group?.removeFromParent(),this._iconTexture?.dispose(),this._sprite=null,this._texture=null,this._canvas=null,this._ctx=null,this._cameraRef=null,this._iconTexture=null,this._iconImage=null}};function Ie(...i){let t=i.filter(o=>!(o instanceof Dt)),e={...Zt};for(let o of t)e={...e,...o};return x(new Tt(e),o=>Ie(o??{}))}function Ei(i,t,e){e({me:i,globals:t})}function Zi(i,t){let e=t??Rt();Ei(i,e,i.nodeDestroy.bind(i))}export{Q as a,J as b,tt as c,et as d,it as e,ot as f,At as g,nt as h,Vt as i,Nt as j,st as k,Wt as l,$t as m,B as n,Kt as o,Jt as p,lt as q,te as r,re as s,k as t,ae as u,ce as v,F as w,pe as x,me as y,ht as z,ue as A,ye as B,mt as C,fe as D,xe as E,ut as F,be as G,Pe as H,dt as I,Se as J,we as K,yt as L,ei as M,ve as N,ft as O,bi as P,Ie as Q,Zi as R};