{"version":3,"sources":["../src/index.ts","../src/DebugPlugin.ts","../src/types.ts","../src/DebugClock.ts","../src/VectorDrawStore.ts","../src/DebugRegistryImpl.ts","../src/DebugScene.ts","../src/StatsStore.ts","../src/GraphicsPool.ts","../src/TextPool.ts","../src/WorldDebugApiImpl.ts","../src/cameraSelection.ts","../src/HudDebugApiImpl.ts","../src/DebugRenderSystem.ts","../src/contributors/FpsContributor.ts","../src/contributors/EntityCountContributor.ts","../src/contributors/SystemTimingContributor.ts","../src/contributors/VectorContributor.ts"],"sourcesContent":["export { DebugPlugin } from \"./DebugPlugin.js\";\nexport type {\n  DebugConfig,\n  DebugDiagnostics,\n  LayerTransformSnapshot,\n  CameraStackSnapshot,\n} from \"./DebugPlugin.js\";\n// Mirrored from the ./api subpath, which stays the import to reach for in game\n// code — it carries the same surface without pulling in pixi.js.\nexport { DebugRegistryKey } from \"./types.js\";\nexport type {\n  DebugGraphics,\n  WorldDebugApi,\n  SceneWorldDebugApi,\n  HudDebugApi,\n  StatsApi,\n  DebugContributor,\n  DebugRegistry,\n  DebugVectorProvider,\n  DebugVectorOptions,\n} from \"./types.js\";\nexport { DebugRegistryImpl } from \"./DebugRegistryImpl.js\";\nexport { StatsStore } from \"./StatsStore.js\";\n","import {\n  ErrorBoundaryKey,\n  EventBusKey,\n  GameLoopKey,\n  InspectorKey,\n  installInspector,\n  SceneManagerKey,\n  SceneHookRegistryKey,\n  SceneRandomSourceKey,\n} from \"@yagejs/core\";\nimport type {\n  EngineContext,\n  EventBus,\n  EngineEvents,\n  Plugin,\n  SceneManager,\n  System,\n  SystemScheduler,\n} from \"@yagejs/core\";\nimport { DebugRegistryKey } from \"./types.js\";\nimport { CameraComponent, RendererKey } from \"@yagejs/renderer\";\nimport type { RendererPlugin, SceneRenderTreeProvider } from \"@yagejs/renderer\";\nimport { SceneRenderTreeProviderKey } from \"@yagejs/renderer\";\nimport type { Application, Container } from \"pixi.js\";\nimport { DebugClock } from \"./DebugClock.js\";\nimport type { DebugClockHost } from \"./DebugClock.js\";\nimport { DebugRegistryImpl } from \"./DebugRegistryImpl.js\";\nimport { DebugScene } from \"./DebugScene.js\";\nimport { StatsStore } from \"./StatsStore.js\";\nimport { GraphicsPool } from \"./GraphicsPool.js\";\nimport { TextPool } from \"./TextPool.js\";\nimport { WorldDebugApiImpl } from \"./WorldDebugApiImpl.js\";\nimport { HudDebugApiImpl } from \"./HudDebugApiImpl.js\";\nimport { DebugRenderSystem } from \"./DebugRenderSystem.js\";\nimport { FpsContributor } from \"./contributors/FpsContributor.js\";\nimport { EntityCountContributor } from \"./contributors/EntityCountContributor.js\";\nimport { SystemTimingContributor } from \"./contributors/SystemTimingContributor.js\";\nimport { VectorContributor } from \"./contributors/VectorContributor.js\";\n\n/** Configuration for the DebugPlugin. */\nexport interface DebugConfig {\n  /** Key code to toggle debug overlay. Default: \"Backquote\" */\n  toggleKey?: string;\n  /** Key code to advance one fixed-timestep frame while the debug clock is frozen. Default: \"Period\" */\n  stepKey?: string;\n  /** Max pooled Graphics objects. Default: 256 */\n  maxGraphics?: number;\n  /** Max HUD text lines. Default: 32 */\n  maxHudLines?: number;\n  /** Whether the overlay starts enabled. Default: false */\n  startEnabled?: boolean;\n  /**\n   * Whether the Inspector records bus, entity and scene events at startup.\n   * Default: true. Set false to skip the per-event allocation entirely (the EventBus\n   * tap never attaches) when nothing reads `inspector.events.getLog()` or\n   * `waitFor()` — toggle back on at runtime with `inspector.events.setEnabled(true)`.\n   */\n  eventLog?: boolean;\n  /** Initial flag overrides, keyed by \"contributorName.flagName\". */\n  flags?: Record<string, boolean>;\n  /**\n   * If set, every scene's RNG is initialized with this seed instead of an\n   * unspecified default. Use for deterministic E2E runs. Leave undefined for\n   * normal debug builds so randomness behaves the same as in production.\n   */\n  deterministicSeed?: number;\n  /**\n   * If true, the engine boots with a paused Pixi ticker so no auto-frames\n   * tick before user code can intervene — equivalent to calling\n   * `inspector.time.freeze()` at frame zero, but applied during plugin\n   * `install()` (before `loop.start()`). Use for deterministic E2E runs:\n   * any later `engine.scenes.push(...)` resolves under frozen time, so\n   * snapshots taken right after only depend on the explicit `time.step()`\n   * calls — not on how many auto-frames slipped in between\n   * `await engine.start()` and the test's first `freeze()`.\n   */\n  startFrozen?: boolean;\n}\n\nexport interface LayerTransformSnapshot {\n  x: number;\n  y: number;\n  scaleX: number;\n  scaleY: number;\n  rotation: number;\n}\n\nexport interface CameraStackSnapshot {\n  scene: string;\n  name: string | undefined;\n  priority: number;\n  /** Whether the camera applies: its own `enabled` flag and an active entity. */\n  enabled: boolean;\n}\n\n/**\n * Renderer-aware diagnostics exposed through the inspector extension\n * namespace `debug`. Kept out of the core Inspector surface so the core\n * package stays renderer-agnostic while plugins can still publish optional\n * runtime helpers in a uniform way.\n */\nexport interface DebugDiagnostics {\n  getLayerTransform(\n    sceneName: string,\n    layerName: string,\n  ): LayerTransformSnapshot | undefined;\n  getCameraStack(): CameraStackSnapshot[];\n  /** Whether the HUD layer (text readouts) is currently visible. */\n  isHudVisible(): boolean;\n  /**\n   * Show/hide the HUD layer — the screen-space text readouts (FPS, system\n   * timings, entity counts). World-space debug graphics (collider outlines\n   * etc.) are unaffected. The stage re-renders immediately, so the change\n   * lands on the canvas even while the debug clock is frozen — capture\n   * tooling can hide the wall-clock-dependent text before screenshotting\n   * without stepping the simulation.\n   */\n  setHudVisible(visible: boolean): void;\n}\n\n/**\n * Debug overlay plugin. Mounts a private `DebugScene` through\n * `SceneManager._mountDetached` so it goes through the same scoped-DI\n * lifecycle as stacked scenes (the renderer's `beforeEnter` hook creates\n * its render tree) while staying off the user-visible scene stack.\n */\nexport class DebugPlugin implements Plugin {\n  readonly name = \"debug\";\n  readonly version = \"3.0.0\";\n  readonly dependencies = [\"renderer\"] as const;\n\n  private readonly config: DebugConfig;\n  private registry!: DebugRegistryImpl;\n  private stats!: StatsStore;\n  private graphicsPool: GraphicsPool | null = null;\n  private textPool: TextPool | null = null;\n  private worldApi: WorldDebugApiImpl | null = null;\n  private hudApi: HudDebugApiImpl | null = null;\n  private renderSystem: DebugRenderSystem | null = null;\n  private systemTimings = new Map<string, number>();\n  private originalUpdates = new Map<System, (dt: number) => void>();\n  private keyListener: ((e: KeyboardEvent) => void) | null = null;\n  private context!: EngineContext;\n  private renderer!: RendererPlugin;\n  private scheduler!: SystemScheduler;\n  private sceneManager!: SceneManager;\n  private debugScene: DebugScene | null = null;\n  private hudContainer: Container | null = null;\n  private provider: SceneRenderTreeProvider | null = null;\n  private eventUnsubs: Array<() => void> = [];\n  private clock: DebugClock | null = null;\n  private uninstallInspector: (() => void) | undefined;\n\n  constructor(config?: DebugConfig) {\n    const seed = config?.deterministicSeed;\n    if (seed !== undefined && !Number.isFinite(seed)) {\n      throw new Error(\n        `DebugPlugin: deterministicSeed must be finite, got ${seed}.`,\n      );\n    }\n    this.config = config ?? {};\n  }\n\n  install(context: EngineContext): void {\n    this.context = context;\n    // The overlay's clock, step key and event log all run through the\n    // Inspector, so the plugin installs one when the game has not. An\n    // Inspector the game installed itself is reused and left to its owner.\n    this.uninstallInspector = installInspector(context);\n    this.renderer = context.resolve(RendererKey);\n    if (this.config.deterministicSeed !== undefined) {\n      context\n        .resolve(SceneRandomSourceKey)\n        .setDefaultSeed(this.config.deterministicSeed);\n    }\n    if (this.config.startFrozen) {\n      // Stop Pixi's ticker before `loop.start()` runs, so no frames tick\n      // between `app.init()` (which auto-starts the ticker) and the user's\n      // first `inspector.time.freeze()`. Without this, even the few auto-\n      // frames that slip in between RendererPlugin install and user-space\n      // `await engine.start()` resolution mutate physics / input clocks,\n      // breaking bit-identical replay snapshots. The DebugClock created in\n      // `onStart` will pick this up via its own `freeze()` call.\n      this.renderer.application.stop();\n    }\n\n    this.registry = new DebugRegistryImpl();\n    this.registry.enabled = this.config.startEnabled ?? false;\n\n    if (this.config.flags) {\n      for (const [key, value] of Object.entries(this.config.flags)) {\n        const dot = key.indexOf(\".\");\n        if (dot > 0) {\n          this.registry.setFlag(key.slice(0, dot), key.slice(dot + 1), value);\n        }\n      }\n    }\n\n    this.stats = new StatsStore();\n    this.eventUnsubs.push(\n      context.resolve(SceneHookRegistryKey).register({\n        afterExit: (scene) => this.worldApi?.releaseScene(scene),\n      }),\n    );\n\n    // Drop a destroyed entity's `drawVector` registrations here rather than\n    // while drawing: the overlay may never draw a frame, and a provider\n    // closure holding a dead entity would keep it alive for the session.\n    const bus = context.resolve(EventBusKey) as EventBus<EngineEvents>;\n    this.eventUnsubs.push(\n      bus.on(\"entity:destroyed\", ({ entity }) => {\n        this.registry.vectors.dropEntity(entity.id);\n      }),\n    );\n\n    context.register(DebugRegistryKey, this.registry);\n  }\n\n  registerSystems(scheduler: SystemScheduler): void {\n    // DebugRenderSystem is registered lazily once the debug scene is ready —\n    // its constructor needs the scene's layer containers.\n    this.scheduler = scheduler;\n  }\n\n  async onStart(): Promise<void> {\n    this.sceneManager = this.context.resolve(SceneManagerKey);\n    const bus = this.context.resolve(EventBusKey) as EventBus<EngineEvents>;\n\n    // Key listeners (toggle, manual-clock step)\n    const toggleKey = this.config.toggleKey ?? \"Backquote\";\n    const stepKey = this.config.stepKey ?? \"Period\";\n    this.keyListener = (e: KeyboardEvent) => {\n      if (e.code === toggleKey) {\n        this.registry.toggle();\n        return;\n      }\n      if (e.code === stepKey && this.clock?.isFrozen) {\n        e.preventDefault();\n        this.context.resolve(InspectorKey).time.step();\n      }\n    };\n    if (typeof window !== \"undefined\") {\n      window.addEventListener(\"keydown\", this.keyListener);\n    }\n\n    // Instrument system timings — reuse the scheduler captured in\n    // `registerSystems`, which ran before `onStart`.\n    for (const system of this.scheduler.getAllSystems()) {\n      if (system instanceof DebugRenderSystem) continue;\n      const name = system.constructor.name;\n      const original = system.update.bind(system);\n      this.originalUpdates.set(system, original);\n      system.update = (dt: number) => {\n        const t0 = performance.now();\n        original(dt);\n        this.systemTimings.set(name, performance.now() - t0);\n      };\n    }\n\n    // Built-in contributors\n    const inspector = this.context.resolve(InspectorKey);\n    this.registry.register(new FpsContributor());\n    this.registry.register(new EntityCountContributor(inspector));\n    this.registry.register(new SystemTimingContributor(this.systemTimings));\n    this.registry.register(\n      new VectorContributor(\n        this.registry.vectors,\n        this.context.resolve(ErrorBoundaryKey),\n      ),\n    );\n\n    // Manual clock for deterministic stepping. The host drives `app.ticker`\n    // directly so a manual `step()` fires every ticker subscriber\n    // (AnimatedSprite, pixi-filters, render, user `app.ticker.add` callbacks)\n    // with the same synthetic dt as gameplay state.\n    const gameLoop = this.context.resolve(GameLoopKey);\n    const app = this.renderer.application;\n    // The clock drives `app.ticker` in milliseconds (Pixi's `deltaMS` unit),\n    // while `gameLoop.fixedTimestep` is in seconds — convert for the default\n    // per-step delta.\n    this.clock = new DebugClock(\n      createPixiTickerHost(app, gameLoop.fixedTimestep * 1000, this.renderer),\n    );\n    inspector.attachTimeController(this.clock);\n    inspector.setEventLogEnabled(this.config.eventLog ?? true);\n    if (this.config.startFrozen) {\n      // `install()` already called `app.stop()`. Run the clock's own\n      // `freeze()` now to take ownership: it captures `minFPS`, zeroes\n      // `syntheticTime` / `lastTime`, and flips `_isFrozen` so the public\n      // `inspector.time.isFrozen()` reflects reality without a redundant\n      // freeze cycle from the caller.\n      this.clock.freeze();\n    }\n\n    // Materialize the debug scene off-stack. `_mountDetached` routes through\n    // the same beforeEnter hooks as `push`, so the renderer materializes the\n    // debug scene's tree and registers SceneRenderTreeKey on its scope.\n    this.provider = this.context.tryResolve(SceneRenderTreeProviderKey) ?? null;\n    this.registerInspectorDiagnostics();\n    await this.materializeDebugScene();\n\n    // Keep the debug scene visually on top of the user stack after any\n    // push/pop/replace by reordering its root containers.\n    const bringToFront = () => {\n      if (this.debugScene && this.provider?.bringSceneToFront) {\n        this.provider.bringSceneToFront(this.debugScene);\n      }\n    };\n    this.eventUnsubs.push(bus.on(\"scene:pushed\", bringToFront));\n    this.eventUnsubs.push(bus.on(\"scene:popped\", bringToFront));\n    this.eventUnsubs.push(bus.on(\"scene:replaced\", bringToFront));\n  }\n\n  onDestroy(): void {\n    for (const unsub of this.eventUnsubs) unsub();\n    this.eventUnsubs.length = 0;\n\n    for (const [system, original] of this.originalUpdates) {\n      system.update = original;\n    }\n    this.originalUpdates.clear();\n\n    if (this.keyListener) {\n      if (typeof window !== \"undefined\") {\n        window.removeEventListener(\"keydown\", this.keyListener);\n      }\n      this.keyListener = null;\n    }\n\n    // A tool that installed the Inspector itself may have removed it before\n    // the engine is destroyed; there is nothing of ours to detach then.\n    const inspector = this.context.tryResolve(InspectorKey);\n    if (inspector) {\n      inspector.removeExtension(\"debug\");\n      // Only detach our own clock — passing undefined would clear whatever\n      // controller is registered, which could belong to another plugin if\n      // onDestroy runs after a failed onStart.\n      if (this.clock) {\n        inspector.detachTimeController(this.clock);\n      }\n      inspector.setEventLogEnabled(false);\n    }\n    if (this.config.deterministicSeed !== undefined) {\n      this.context.resolve(SceneRandomSourceKey).setDefaultSeed(undefined);\n    }\n    this.clock = null;\n\n    for (const contributor of this.registry.contributors.values()) {\n      contributor.dispose?.();\n    }\n    this.registry.contributors.clear();\n    this.registry.vectors.clear();\n\n    this.tearDownDebugInfra();\n    this.teardownDebugScene();\n\n    this.uninstallInspector?.();\n    this.uninstallInspector = undefined;\n  }\n\n  private async materializeDebugScene(): Promise<void> {\n    const scene = new DebugScene();\n    scene.onReady = (worldContainer, hudContainer) =>\n      this.setUpDebugInfra(worldContainer, hudContainer);\n    scene.onTearDown = () => this.tearDownDebugInfra();\n    await this.sceneManager._mountDetached(scene);\n    this.debugScene = scene;\n  }\n\n  private teardownDebugScene(): void {\n    // If destroy is called while `_mountDetached` is still pending, we don't\n    // yet hold a reference to the partially-mounted scene. Skipping unmount\n    // here is safe: onDestroy still runs `tearDownDebugInfra` below, and the\n    // engine teardown tears down the renderer next which destroys any\n    // half-created provider entries.\n    if (!this.debugScene) return;\n    this.sceneManager._unmountDetached(this.debugScene);\n    this.debugScene = null;\n    this.provider = null;\n  }\n\n  private setUpDebugInfra(\n    worldContainer: Container,\n    hudContainer: Container,\n  ): void {\n    const vw = this.renderer.virtualSize.width;\n    const vh = this.renderer.virtualSize.height;\n\n    this.graphicsPool = new GraphicsPool(\n      worldContainer,\n      this.config.maxGraphics,\n    );\n    this.textPool = new TextPool(hudContainer, this.config.maxHudLines);\n    this.hudContainer = hudContainer;\n\n    this.worldApi = new WorldDebugApiImpl(\n      this.graphicsPool,\n      this.registry,\n      this.sceneManager,\n      this.provider!,\n      worldContainer,\n    );\n    this.hudApi = new HudDebugApiImpl(this.textPool, this.registry, vw, vh);\n\n    this.renderSystem = new DebugRenderSystem(\n      this.registry,\n      this.graphicsPool,\n      this.textPool,\n      this.worldApi,\n      this.hudApi,\n      this.stats,\n      worldContainer,\n      hudContainer,\n    );\n    this.scheduler.add(this.renderSystem);\n  }\n\n  private tearDownDebugInfra(): void {\n    if (this.renderSystem) {\n      this.scheduler.remove(this.renderSystem);\n      this.renderSystem = null;\n    }\n    this.graphicsPool?.destroy();\n    this.textPool?.destroy();\n    this.graphicsPool = null;\n    this.textPool = null;\n    this.worldApi = null;\n    this.hudApi = null;\n    this.hudContainer = null;\n  }\n\n  private registerInspectorDiagnostics(): void {\n    const diagnostics: DebugDiagnostics = {\n      getLayerTransform: (sceneName, layerName) => {\n        const scene = this.sceneManager.all.find(\n          (candidate) => candidate.name === sceneName,\n        );\n        if (!scene) return undefined;\n\n        const layer = this.provider?.getTree(scene)?.tryGet(layerName);\n        if (!layer) return undefined;\n\n        const container = layer.container;\n        return {\n          x: container.position.x,\n          y: container.position.y,\n          scaleX: container.scale.x,\n          scaleY: container.scale.y,\n          rotation: container.rotation,\n        };\n      },\n      getCameraStack: () => {\n        const cameras: CameraStackSnapshot[] = [];\n        for (const scene of this.sceneManager.all) {\n          for (const entity of scene.getEntities()) {\n            const cam = entity.tryGet(CameraComponent);\n            if (!cam) continue;\n            cameras.push({\n              scene: scene.name,\n              name: cam.cameraName,\n              priority: cam.priority,\n              enabled: cam.effectiveEnabled,\n            });\n          }\n        }\n        return cameras;\n      },\n      isHudVisible: () => this.hudContainer?.visible ?? false,\n      setHudVisible: (visible) => {\n        if (!this.hudContainer || this.hudContainer.visible === visible) {\n          return;\n        }\n        this.hudContainer.visible = visible;\n        // Render synchronously so the toggle reaches the canvas even while\n        // the debug clock is frozen (no ticker frames are running).\n        this.renderer.application.render();\n      },\n    };\n    this.context.resolve(InspectorKey).addExtension(\"debug\", diagnostics);\n  }\n}\n\n/**\n * Wire a `DebugClockHost` against a Pixi v8 `Application`. Driving\n * `app.ticker.update(syntheticTime)` while the ticker is stopped fires every\n * subscriber — Pixi's `Ticker.update` doesn't gate on `started`, only the\n * rAF-driven `_tick` does — so a single advance replaces the old\n * `gameLoop.tick(dt)` + `app.render()` quad and along the way fixes the\n * AnimatedSprite / pixi-filters / `app.ticker.add` subscriber freeze.\n */\nfunction createPixiTickerHost(\n  app: Application,\n  fixedTimestep: number,\n  renderer: RendererPlugin,\n): DebugClockHost {\n  let syntheticTime = 0;\n  let savedMinFPS: number | null = null;\n  return {\n    fixedTimestep,\n    freeze(): void {\n      app.stop();\n      // Reset both to zero so synthetic time starts from a clean origin\n      // and `(syntheticTime + dt) - syntheticTime` stays an exact `dt`\n      // — keeps deltaMS deterministic regardless of how long the page\n      // ran in auto mode before the freeze.\n      syntheticTime = 0;\n      app.ticker.lastTime = 0;\n      // Default minFPS=10 clamps deltaMS at 100ms — `step(200)` would\n      // silently see deltaMS=100. Disable for the duration of the freeze.\n      savedMinFPS = app.ticker.minFPS;\n      app.ticker.minFPS = 0;\n    },\n    thaw(): void {\n      if (savedMinFPS !== null) {\n        app.ticker.minFPS = savedMinFPS;\n        savedMinFPS = null;\n      }\n      // `app.start()` calls `Ticker._requestIfNeeded` which resets\n      // `lastTime` to `performance.now()` itself, so the next rAF\n      // doesn't see `realNow - 0` as a giant first-frame delta. No\n      // need to set it manually here.\n      app.start();\n    },\n    renderFrame(): void {\n      renderer.render();\n    },\n    get drawingEnabled(): boolean {\n      return renderer.drawingEnabled;\n    },\n    set drawingEnabled(enabled: boolean) {\n      renderer.drawingEnabled = enabled;\n    },\n    advance(dtMs: number): void {\n      syntheticTime += dtMs;\n      app.ticker.update(syntheticTime);\n    },\n  };\n}\n","import { ServiceKey } from \"@yagejs/core\";\nimport type { Entity, Scene, Vec2Like } from \"@yagejs/core\";\n\n/**\n * Minimal subset of PixiJS Graphics used by debug drawing.\n * Avoids a runtime pixi.js dependency in the ./api subpath.\n */\nexport interface DebugGraphics {\n  position: { x: number; y: number };\n  rotation: number;\n  visible: boolean;\n  clear(): DebugGraphics;\n  rect(x: number, y: number, width: number, height: number): DebugGraphics;\n  roundRect(\n    x: number,\n    y: number,\n    width: number,\n    height: number,\n    radius: number,\n  ): DebugGraphics;\n  circle(x: number, y: number, radius: number): DebugGraphics;\n  moveTo(x: number, y: number): DebugGraphics;\n  lineTo(x: number, y: number): DebugGraphics;\n  stroke(style: {\n    width: number;\n    color: number;\n    alpha?: number;\n  }): DebugGraphics;\n  fill(style: { color: number; alpha?: number }): DebugGraphics;\n}\n\n/** Camera-space drawing API passed to contributors. */\nexport interface SceneWorldDebugApi {\n  acquireGraphics(): DebugGraphics | undefined;\n  readonly cameraZoom: number;\n}\n\nexport interface WorldDebugApi extends SceneWorldDebugApi {\n  isFlagEnabled(flag: string): boolean;\n  /** Drawing for a visible scene, or undefined while hidden or off the stack. */\n  forScene(scene: Scene): SceneWorldDebugApi | undefined;\n}\n\n/** Screen-space HUD API passed to contributors. */\nexport interface HudDebugApi {\n  addLine(text: string): void;\n  isFlagEnabled(flag: string): boolean;\n  readonly screenWidth: number;\n  readonly screenHeight: number;\n}\n\n/** Rolling-window statistics collector. */\nexport interface StatsApi {\n  push(key: string, value: number): void;\n  average(key: string): number;\n  latest(key: string): number;\n  min(key: string): number;\n  max(key: string): number;\n}\n\n/** A debug contributor that registers drawing/sampling callbacks. */\nexport interface DebugContributor {\n  readonly name: string;\n  readonly flags: readonly string[];\n  drawWorld?(api: WorldDebugApi): void;\n  drawHud?(api: HudDebugApi): void;\n  sample?(stats: StatsApi, dt: number): void;\n  dispose?(): void;\n}\n\n/**\n * Supplies the vector to draw this frame, in the entity's world space. Return\n * `null` or `undefined` to draw nothing this frame.\n */\nexport type DebugVectorProvider = () => Vec2Like | null | undefined;\n\n/** Appearance and cutoff options for {@link DebugRegistry.drawVector}. */\nexport interface DebugVectorOptions {\n  /** Pixels of arrow per unit of the vector. Default 1. */\n  scale?: number;\n  /** Arrow color. Default `0xffffff`. */\n  color?: number;\n  /** Arrow opacity, 0-1. Default 0.9. */\n  alpha?: number;\n  /**\n   * World-space pixel offset added to the entity's position, so the arrow can\n   * start at a muzzle or a hand instead of the entity's origin. Not rotated by\n   * the entity. Default `{ x: 0, y: 0 }`.\n   */\n  origin?: Vec2Like;\n  /**\n   * Draw nothing while the vector is shorter than this. Measured on the value\n   * the provider returns, before `scale` is applied, so the cutoff is in the\n   * vector's own units (px/s for a velocity). Default 0 — a zero-length vector\n   * never draws either way, since it has no direction. */\n  minLength?: number;\n  /** Shaft thickness in screen pixels, held constant across camera zoom. Default 2. */\n  width?: number;\n  /** Arrowhead length in screen pixels, held constant across camera zoom. Default 8. */\n  headSize?: number;\n}\n\n/** Service interface for the debug registry. */\nexport interface DebugRegistry {\n  register(contributor: DebugContributor): void;\n  isEnabled(): boolean;\n  /** Switch all debug drawing on or off. */\n  toggle(): void;\n  isFlagEnabled(contributorName: string, flag: string): boolean;\n  /** Set whether a contributor's named view is drawn. */\n  setFlag(contributorName: string, flag: string, value: boolean): void;\n  /**\n   * Draw an arrow on `entity` for a vector that is read fresh every frame —\n   * velocity, aim direction, knockback, steering output.\n   *\n   * ```ts\n   * // tryResolve, not use(): use() throws without DebugPlugin installed.\n   * const debug = this.context.tryResolve(DebugRegistryKey);\n   * this.stopArrow = debug?.drawVector(this.entity, () => agent.velocity, {\n   *   scale: 0.35,\n   *   color: 0x4ade80,\n   *   minLength: 1,\n   * });\n   * ```\n   *\n   * The arrow starts at the entity's world position (plus `options.origin`)\n   * and points along the vector. Nothing is retained but the provider itself:\n   * it is called once per frame while the overlay is on and the `vectors`\n   * contributor's `arrows` flag is enabled, and not at all otherwise — a\n   * `drawVector` call in a hot path costs nothing while debug is off.\n   *\n   * Returns a disposer that stops the drawing. Calling it twice is harmless.\n   * The registration is also dropped when the entity's life ends — destroyed,\n   * or a pool member whose lease ended — so a provider closure never outlives\n   * the entity it draws for, and a per-lease registration never accumulates.\n   */\n  drawVector(\n    entity: Entity,\n    vector: DebugVectorProvider,\n    options?: DebugVectorOptions,\n  ): () => void;\n}\n\n/** Service key for resolving the DebugRegistry via DI. */\nexport const DebugRegistryKey = new ServiceKey<DebugRegistry>(\"debugRegistry\");\n","/** Controller infrastructure used by DebugPlugin. Use Inspector.time to drive games. */\nexport interface IDebugClock {\n  readonly isFrozen: boolean;\n  drawingEnabled: boolean;\n  step(dtMs?: number): void;\n  stepFrames(count: number, dtMs?: number): void;\n  renderFrame(): void;\n  freeze(): void;\n  thaw(): void;\n  setDelta(ms: number): void;\n}\n\n/**\n * Hooks the clock uses to drive the host. The host owns the synthetic-time\n * bookkeeping and the ticker plumbing — `DebugClock` stays a pure state\n * machine. Production wires this against Pixi's `app.ticker` so a manual\n * `step()` fires every ticker subscriber (GameLoop, AnimatedSprite,\n * pixi-filters, render) with the same synthetic dt.\n */\nexport interface DebugClockHost {\n  readonly fixedTimestep: number;\n  /** The renderer setting, when the host can draw. */\n  drawingEnabled?: boolean;\n  /** Advance one synthetic frame of `dtMs`. Fires every ticker subscriber. */\n  advance(dtMs: number): void;\n  /** Draw without advancing time. Omit for hosts without drawing. */\n  renderFrame?(): void;\n  /** Stop auto-advance. Capture state needed to make `advance` deterministic. */\n  freeze(): void;\n  /** Resume auto-advance. Restore captured state so the next rAF is sane. */\n  thaw(): void;\n}\n\n/**\n * Controls engine time-stepping for deterministic E2E tests.\n *\n * While frozen the renderer ticker is paused and frames advance only via\n * explicit `step()` / `stepFrames()` calls.\n */\nexport class DebugClock implements IDebugClock {\n  private _isFrozen = false;\n  private deltaMs: number;\n\n  constructor(private readonly host: DebugClockHost) {\n    this.deltaMs = host.fixedTimestep;\n  }\n\n  get isFrozen(): boolean {\n    return this._isFrozen;\n  }\n\n  get drawingEnabled(): boolean {\n    return this.host.drawingEnabled ?? true;\n  }\n\n  set drawingEnabled(enabled: boolean) {\n    if (this.host.drawingEnabled !== undefined)\n      this.host.drawingEnabled = enabled;\n  }\n\n  thaw(): void {\n    if (!this._isFrozen) return;\n    this.host.thaw();\n    this._isFrozen = false;\n  }\n\n  freeze(): void {\n    if (this._isFrozen) return;\n    this.host.freeze();\n    this._isFrozen = true;\n  }\n\n  setDelta(ms: number): void {\n    if (!Number.isFinite(ms) || ms <= 0) {\n      throw new Error(\"DebugClock.setDelta(ms) requires a positive number.\");\n    }\n    this.deltaMs = ms;\n  }\n\n  step(dtMs?: number): void {\n    if (!this._isFrozen) {\n      throw new Error(\"DebugClock is not frozen. Call clock.freeze() first.\");\n    }\n    const dt = dtMs ?? this.deltaMs;\n    if (!Number.isFinite(dt) || dt <= 0) {\n      throw new Error(\"DebugClock.step(dtMs) requires a positive number.\");\n    }\n    this.host.advance(dt);\n  }\n\n  renderFrame(): void {\n    this.host.renderFrame?.();\n  }\n\n  stepFrames(count: number, dtMs?: number): void {\n    if (!Number.isInteger(count) || count < 0) {\n      throw new Error(\n        \"stepFrames(count) requires a non-negative integer count.\",\n      );\n    }\n    for (let i = 0; i < count; i++) {\n      this.step(dtMs);\n    }\n  }\n}\n","import { devWarn, Transform } from \"@yagejs/core\";\nimport type { Entity, Scene } from \"@yagejs/core\";\nimport type { DebugVectorOptions, DebugVectorProvider } from \"./types.js\";\n\n/** A registered vector arrow, with every option resolved to a value. */\nexport interface VectorEntry {\n  readonly entity: Entity;\n  readonly scene: Scene;\n  /**\n   * The entity life this registration belongs to. Both destruction and an\n   * `EntityPool` release end a life and move `Entity.generation` on, so a\n   * mismatch means the registration is stale.\n   */\n  readonly generation: number;\n  readonly vector: DebugVectorProvider;\n  readonly scale: number;\n  readonly color: number;\n  readonly alpha: number;\n  readonly originX: number;\n  readonly originY: number;\n  readonly minLength: number;\n  readonly width: number;\n  readonly headSize: number;\n}\n\n/**\n * The vector arrows registered through `DebugRegistry.drawVector`, indexed by\n * entity id so a destroyed entity's registrations can be dropped in one step\n * — that happens on the `entity:destroyed` bus event, which fires whether or\n * not the overlay is on, so nothing accumulates in a build that never draws.\n *\n * A pooled entity is never destroyed, so that event never covers it: the pool\n * ends a lease by moving the member's `generation` on and parking it dormant.\n * Every registration records the life it was made in, and a stale one is\n * dropped both while drawing and on the next `add` for the same entity —\n * `add` because it is the one cleanup point that still runs with the overlay\n * off, which is exactly when a per-lease registration would otherwise pile up\n * unseen.\n */\nexport class VectorDrawStore {\n  private readonly byEntity = new Map<number, Set<VectorEntry>>();\n  private count = 0;\n\n  /** Register an arrow, returning an idempotent disposer. */\n  add(\n    entity: Entity,\n    vector: DebugVectorProvider,\n    options: DebugVectorOptions = {},\n  ): () => void {\n    if (!entity.tryGet(Transform)) {\n      // The arrow is positioned from the entity's world position, so there is\n      // nowhere to draw it. Warn once here rather than staying silent every\n      // frame — the registration still stands in case a Transform arrives.\n      devWarn(\n        `debug.drawVector() on \"${entity.name}\", which has no Transform — ` +\n          `the arrow has no position to start from and will not draw.`,\n      );\n    }\n\n    const entry: VectorEntry = {\n      entity,\n      scene: entity.scene,\n      generation: entity.generation,\n      vector,\n      scale: options.scale ?? 1,\n      color: options.color ?? 0xffffff,\n      alpha: options.alpha ?? 0.9,\n      originX: options.origin?.x ?? 0,\n      originY: options.origin?.y ?? 0,\n      minLength: options.minLength ?? 0,\n      width: options.width ?? 2,\n      headSize: options.headSize ?? 8,\n    };\n\n    const id = entity.id;\n    let entries = this.byEntity.get(id);\n    if (!entries) {\n      entries = new Set();\n      this.byEntity.set(id, entries);\n    } else {\n      // A pooled entity re-registering for a new lease: retire the previous\n      // lease's arrows here, since nothing else will while the overlay is off.\n      for (const stale of entries) {\n        if (stale.generation !== entry.generation) {\n          entries.delete(stale);\n          this.count--;\n        }\n      }\n    }\n    entries.add(entry);\n    this.count++;\n\n    return () => {\n      this.remove(id, entry);\n    };\n  }\n\n  /** Drop one arrow. Called by its disposer and when its life has ended. */\n  remove(entityId: number, entry: VectorEntry): void {\n    const entries = this.byEntity.get(entityId);\n    if (!entries?.delete(entry)) return;\n    this.count--;\n    if (entries.size === 0) this.byEntity.delete(entityId);\n  }\n\n  /** Drop every arrow registered for an entity. */\n  dropEntity(entityId: number): void {\n    const entries = this.byEntity.get(entityId);\n    if (!entries) return;\n    this.count -= entries.size;\n    this.byEntity.delete(entityId);\n  }\n\n  clear(): void {\n    this.byEntity.clear();\n    this.count = 0;\n  }\n\n  /** How many arrows are registered. */\n  get size(): number {\n    return this.count;\n  }\n\n  /** Safe to `dropEntity` mid-iteration — Map and Set iterators tolerate it. */\n  *[Symbol.iterator](): IterableIterator<VectorEntry> {\n    for (const entries of this.byEntity.values()) {\n      yield* entries;\n    }\n  }\n}\n","import type { Entity } from \"@yagejs/core\";\nimport type {\n  DebugContributor,\n  DebugRegistry,\n  DebugVectorOptions,\n  DebugVectorProvider,\n} from \"./types.js\";\nimport { VectorDrawStore } from \"./VectorDrawStore.js\";\n\n/** Concrete implementation of the DebugRegistry interface. */\nexport class DebugRegistryImpl implements DebugRegistry {\n  readonly contributors = new Map<string, DebugContributor>();\n  /** Backs `drawVector`; read by the built-in `vectors` contributor. */\n  readonly vectors = new VectorDrawStore();\n  enabled = false;\n  private flags = new Map<string, boolean>();\n\n  register(contributor: DebugContributor): void {\n    if (this.contributors.has(contributor.name)) return;\n    this.contributors.set(contributor.name, contributor);\n    // Flags default to true on read (`?? true`), so registration must not\n    // write them — contributors register after install applies the user's\n    // DebugConfig.flags overrides, and a write here would clobber them.\n  }\n\n  drawVector(\n    entity: Entity,\n    vector: DebugVectorProvider,\n    options?: DebugVectorOptions,\n  ): () => void {\n    return this.vectors.add(entity, vector, options);\n  }\n\n  isEnabled(): boolean {\n    return this.enabled;\n  }\n\n  isFlagEnabled(contributorName: string, flag: string): boolean {\n    return this.flags.get(`${contributorName}.${flag}`) ?? true;\n  }\n\n  toggle(): void {\n    this.enabled = !this.enabled;\n  }\n\n  toggleFlag(contributorName: string, flag: string): void {\n    const key = `${contributorName}.${flag}`;\n    this.flags.set(key, !(this.flags.get(key) ?? true));\n  }\n\n  setFlag(contributorName: string, flag: string, value: boolean): void {\n    this.flags.set(`${contributorName}.${flag}`, value);\n  }\n}\n","import { LoggerKey, Scene } from \"@yagejs/core\";\nimport type { Logger } from \"@yagejs/core\";\nimport type { LayerDef } from \"@yagejs/renderer\";\nimport { SceneRenderTreeKey } from \"@yagejs/renderer\";\nimport type { Container } from \"pixi.js\";\n\n/**\n * Scene mounted by the debug plugin via `SceneManager._mountDetached`.\n * Declares two layers:\n * - `\"debug-world\"` — world-space, rides the camera (for collision shapes).\n * - `\"debug-hud\"`   — screen-space, fixed overlay (text readouts).\n *\n * `pauseBelow: false` / `transparentBelow: true` so the underlying game\n * keeps running and rendering behind the overlay.\n */\nexport class DebugScene extends Scene {\n  readonly name = \"__debug__\";\n  override readonly pauseBelow = false;\n  override readonly transparentBelow = true;\n  readonly layers: readonly LayerDef[] = [\n    { name: \"debug-world\", order: 999999 },\n    { name: \"debug-hud\", order: 999999 },\n  ];\n\n  /** Called after `_mountDetached` has materialized the render tree. */\n  onReady?: (worldContainer: Container, hudContainer: Container) => void;\n\n  /** Called by the plugin when the scene is unmounted. */\n  onTearDown?: () => void;\n\n  onEnter(): void {\n    const tree = this._resolveScoped(SceneRenderTreeKey);\n    if (!tree) {\n      // Shouldn't happen — DebugPlugin declares `renderer` as a dependency\n      // so the renderer's `beforeEnter` hook should have materialized a\n      // tree before this runs. Surface it rather than silently skipping\n      // the overlay wiring.\n      const logger = this.context.tryResolve(LoggerKey) as Logger | undefined;\n      const msg =\n        \"DebugScene.onEnter: SceneRenderTreeKey missing — debug overlay will not render. Is RendererPlugin registered?\";\n      if (logger) logger.warn(\"debug\", msg);\n      else console.warn(`[yage] ${msg}`);\n      return;\n    }\n    const worldContainer = tree.get(\"debug-world\").container;\n    const hudContainer = tree.get(\"debug-hud\").container;\n    worldContainer.eventMode = \"none\";\n    hudContainer.eventMode = \"none\";\n    this.onReady?.(worldContainer, hudContainer);\n  }\n\n  onExit(): void {\n    this.onTearDown?.();\n  }\n}\n","import type { StatsApi } from \"./types.js\";\n\nconst WINDOW_SIZE = 120;\n\ninterface RingBuffer {\n  data: Float64Array;\n  count: number;\n  index: number;\n}\n\n/** Rolling-window statistics store backed by Float64Array ring buffers. */\nexport class StatsStore implements StatsApi {\n  private rings = new Map<string, RingBuffer>();\n\n  push(key: string, value: number): void {\n    let ring = this.rings.get(key);\n    if (!ring) {\n      ring = { data: new Float64Array(WINDOW_SIZE), count: 0, index: 0 };\n      this.rings.set(key, ring);\n    }\n    ring.data[ring.index] = value;\n    ring.index = (ring.index + 1) % WINDOW_SIZE;\n    if (ring.count < WINDOW_SIZE) ring.count++;\n  }\n\n  average(key: string): number {\n    const ring = this.rings.get(key);\n    if (!ring || ring.count === 0) return 0;\n    const { data, count } = ring;\n    let sum = 0;\n    for (let i = 0; i < count; i++) sum += data[i] ?? 0;\n    return sum / count;\n  }\n\n  latest(key: string): number {\n    const ring = this.rings.get(key);\n    if (!ring || ring.count === 0) return 0;\n    return ring.data[(ring.index - 1 + WINDOW_SIZE) % WINDOW_SIZE] ?? 0;\n  }\n\n  min(key: string): number {\n    const ring = this.rings.get(key);\n    if (!ring || ring.count === 0) return 0;\n    const { data, count } = ring;\n    let m = Infinity;\n    for (let i = 0; i < count; i++) {\n      const v = data[i] ?? 0;\n      if (v < m) m = v;\n    }\n    return m;\n  }\n\n  max(key: string): number {\n    const ring = this.rings.get(key);\n    if (!ring || ring.count === 0) return 0;\n    const { data, count } = ring;\n    let m = -Infinity;\n    for (let i = 0; i < count; i++) {\n      const v = data[i] ?? 0;\n      if (v > m) m = v;\n    }\n    return m;\n  }\n}\n","import { Graphics, Container } from \"pixi.js\";\n\n/** Allocation-free pool of PixiJS Graphics objects for debug drawing. */\nexport class GraphicsPool {\n  private pool: Graphics[] | null = null;\n  private index = 0;\n  private readonly container: Container;\n  private readonly maxSize: number;\n\n  constructor(container: Container, maxSize = 256) {\n    this.container = container;\n    this.maxSize = maxSize;\n  }\n\n  /** Lazily create Graphics objects on first use (ensures PixiJS is fully ready). */\n  private ensure(): Graphics[] {\n    if (this.pool) return this.pool;\n    this.pool = [];\n    for (let i = 0; i < this.maxSize; i++) {\n      const g = new Graphics();\n      g.visible = false;\n      g.eventMode = \"none\";\n      this.container.addChild(g);\n      this.pool.push(g);\n    }\n    return this.pool;\n  }\n\n  /** Return the next available Graphics, or undefined if the pool is exhausted. */\n  acquire(target: Container = this.container): Graphics | undefined {\n    const pool = this.ensure();\n    if (this.index >= pool.length) return undefined;\n    const g = pool[this.index]!;\n    target.addChild(g);\n    g.visible = true;\n    this.index++;\n    return g;\n  }\n\n  /** Clear and hide all previously acquired graphics, reset index. */\n  resetFrame(): void {\n    if (!this.pool) return;\n    for (let i = 0; i < this.index; i++) {\n      const g = this.pool[i]!;\n      g.clear();\n      g.visible = false;\n      g.position.set(0, 0);\n      g.rotation = 0;\n      g.scale.set(1, 1);\n      this.container.addChild(g);\n    }\n    this.index = 0;\n  }\n\n  destroy(): void {\n    if (!this.pool) return;\n    for (const g of this.pool) {\n      g.destroy();\n    }\n    this.pool.length = 0;\n  }\n\n  /** Park graphics before destroying a scene's target container. */\n  releaseTarget(target: Container): void {\n    for (const graphics of this.pool ?? []) {\n      if (graphics.parent !== target) continue;\n      graphics.clear();\n      graphics.visible = false;\n      this.container.addChild(graphics);\n    }\n  }\n}\n","import { Text, Container } from \"pixi.js\";\n\nconst LINE_HEIGHT = 16;\nconst FONT_SIZE = 14;\nconst PADDING = 4;\n\n/** Allocation-free pool of PixiJS Text objects for HUD debug lines. */\nexport class TextPool {\n  private pool: Text[] | null = null;\n  private index = 0;\n  private readonly container: Container;\n  private readonly maxLines: number;\n\n  constructor(container: Container, maxLines = 32) {\n    this.container = container;\n    this.maxLines = maxLines;\n  }\n\n  /** Lazily create Text objects on first use (ensures PixiJS is fully ready). */\n  private ensure(): Text[] {\n    if (this.pool) return this.pool;\n    this.pool = [];\n    for (let i = 0; i < this.maxLines; i++) {\n      const t = new Text({\n        text: \"\",\n        style: {\n          fontFamily: \"monospace\",\n          fontSize: FONT_SIZE,\n          fill: 0xffffff,\n        },\n      });\n      t.visible = false;\n      t.eventMode = \"none\";\n      this.container.addChild(t);\n      this.pool.push(t);\n    }\n    return this.pool;\n  }\n\n  /** Show a text line at the next available slot. */\n  addLine(text: string): void {\n    const pool = this.ensure();\n    if (this.index >= pool.length) return;\n    const t = pool[this.index]!;\n    t.text = text;\n    t.visible = true;\n    t.position.set(PADDING, PADDING + this.index * LINE_HEIGHT);\n    this.index++;\n  }\n\n  /** Hide all lines and reset for the next frame. */\n  resetFrame(): void {\n    if (!this.pool) return;\n    for (let i = 0; i < this.index; i++) {\n      this.pool[i]!.visible = false;\n    }\n    this.index = 0;\n  }\n\n  destroy(): void {\n    if (!this.pool) return;\n    for (const t of this.pool) {\n      t.destroy();\n    }\n    this.pool.length = 0;\n  }\n}\n","import { ServiceKey } from \"@yagejs/core\";\nimport type { Scene, SceneManager } from \"@yagejs/core\";\nimport { syncCameraTransform } from \"@yagejs/renderer\";\nimport type { SceneRenderTreeProvider } from \"@yagejs/renderer\";\nimport { Container } from \"pixi.js\";\nimport { findSceneCamera, findTopmostCamera } from \"./cameraSelection.js\";\nimport type {\n  WorldDebugApi,\n  SceneWorldDebugApi,\n  DebugGraphics,\n} from \"./types.js\";\nimport type { GraphicsPool } from \"./GraphicsPool.js\";\nimport type { DebugRegistryImpl } from \"./DebugRegistryImpl.js\";\n\nconst DebugWorldTargetKey = new ServiceKey<Container>(\"debugWorldTarget\", {\n  scope: \"scene\",\n});\n\n/** One graphics pool serves visible scenes and the default camera target. */\nexport class WorldDebugApiImpl implements WorldDebugApi {\n  private _contributorName = \"\";\n  private readonly defaultTarget = new Container();\n  private zoom = 1;\n\n  constructor(\n    private readonly pool: GraphicsPool,\n    private readonly registry: DebugRegistryImpl,\n    private readonly scenes: SceneManager,\n    private readonly provider: SceneRenderTreeProvider,\n    private readonly root: Container,\n  ) {\n    root.addChild(this.defaultTarget);\n  }\n\n  prepareFrame(): void {\n    const defaultCamera = findTopmostCamera(\n      this.scenes.all.filter(\n        (scene) => this.provider.getTree(scene)?.root.visible,\n      ),\n    );\n    for (const scene of this.scenes.all) {\n      const visible = this.provider.getTree(scene)?.root.visible === true;\n      const target = scene._resolveScoped(DebugWorldTargetKey);\n      if (target) {\n        target.visible = visible;\n        this.root.addChild(target);\n        if (visible) syncCameraTransform(target, findSceneCamera(scene));\n      }\n    }\n    syncCameraTransform(this.defaultTarget, defaultCamera);\n    this.zoom = defaultCamera?.effectiveZoom ?? 1;\n    this.root.addChild(this.defaultTarget);\n  }\n\n  forScene(scene: Scene): SceneWorldDebugApi | undefined {\n    if (\n      !this.scenes.all.includes(scene) ||\n      !this.provider.getTree(scene)?.root.visible\n    )\n      return undefined;\n    let target = scene._resolveScoped(DebugWorldTargetKey);\n    if (!target) {\n      target = new Container();\n      target.eventMode = \"none\";\n      scene._registerScoped(DebugWorldTargetKey, target);\n      this.root.addChild(target);\n      this.prepareFrame();\n    }\n    const camera = findSceneCamera(scene);\n    syncCameraTransform(target, camera);\n    const container = target;\n    return {\n      acquireGraphics: () =>\n        this.pool.acquire(container) as unknown as DebugGraphics | undefined,\n      cameraZoom: camera?.effectiveZoom ?? 1,\n    };\n  }\n\n  releaseScene(scene: Scene): void {\n    const target = scene._resolveScoped(DebugWorldTargetKey);\n    if (!target) return;\n    this.pool.releaseTarget(target);\n    target.destroy();\n  }\n\n  /** Set the current contributor name (called before each contributor's drawWorld). */\n  setContributor(name: string): void {\n    this._contributorName = name;\n  }\n\n  acquireGraphics(): DebugGraphics | undefined {\n    return this.pool.acquire(this.defaultTarget) as unknown as\n      | DebugGraphics\n      | undefined;\n  }\n\n  isFlagEnabled(flag: string): boolean {\n    return this.registry.isFlagEnabled(this._contributorName, flag);\n  }\n\n  get cameraZoom(): number {\n    return this.zoom;\n  }\n}\n","import type { Scene } from \"@yagejs/core\";\nimport { CameraComponent } from \"@yagejs/renderer\";\n\n/** Highest-priority enabled camera on an active entity; ties keep the first. */\nexport function findSceneCamera(scene: Scene): CameraComponent | undefined {\n  let selected: CameraComponent | undefined;\n  for (const entity of scene.getEntities()) {\n    if (!entity.isActive) continue;\n    const camera = entity.tryGet(CameraComponent);\n    if (camera?.enabled && (!selected || camera.priority > selected.priority))\n      selected = camera;\n  }\n  return selected;\n}\n\n/** Scenes are in bottom-to-top order. Callers select which scenes are visible. */\nexport function findTopmostCamera(\n  scenes: readonly Scene[],\n): CameraComponent | undefined {\n  for (let index = scenes.length - 1; index >= 0; index--) {\n    const camera = findSceneCamera(scenes[index]!);\n    if (camera) return camera;\n  }\n  return undefined;\n}\n","import type { HudDebugApi } from \"./types.js\";\nimport type { TextPool } from \"./TextPool.js\";\nimport type { DebugRegistryImpl } from \"./DebugRegistryImpl.js\";\n\n/** HudDebugApi backed by a TextPool. Contributor name is swapped per iteration. */\nexport class HudDebugApiImpl implements HudDebugApi {\n  private _contributorName = \"\";\n\n  constructor(\n    private readonly textPool: TextPool,\n    private readonly registry: DebugRegistryImpl,\n    public readonly screenWidth: number,\n    public readonly screenHeight: number,\n  ) {}\n\n  /** Set the current contributor name (called before each contributor's drawHud). */\n  setContributor(name: string): void {\n    this._contributorName = name;\n  }\n\n  addLine(text: string): void {\n    this.textPool.addLine(text);\n  }\n\n  isFlagEnabled(flag: string): boolean {\n    return this.registry.isFlagEnabled(this._contributorName, flag);\n  }\n}\n","import { System, Phase, ErrorBoundaryKey } from \"@yagejs/core\";\nimport type { EngineContext, ErrorBoundary } from \"@yagejs/core\";\nimport type { Container } from \"pixi.js\";\nimport type { DebugRegistryImpl } from \"./DebugRegistryImpl.js\";\nimport type { GraphicsPool } from \"./GraphicsPool.js\";\nimport type { TextPool } from \"./TextPool.js\";\nimport type { WorldDebugApiImpl } from \"./WorldDebugApiImpl.js\";\nimport type { HudDebugApiImpl } from \"./HudDebugApiImpl.js\";\nimport type { StatsStore } from \"./StatsStore.js\";\n\n/** Renders all debug contributors. Runs after DisplaySystem in the Render phase. */\nexport class DebugRenderSystem extends System {\n  readonly phase = Phase.Render;\n  readonly priority = 9999;\n  private boundary!: ErrorBoundary;\n\n  onRegister(context: EngineContext): void {\n    this.boundary = context.resolve(ErrorBoundaryKey);\n  }\n\n  constructor(\n    private readonly registry: DebugRegistryImpl,\n    private readonly graphicsPool: GraphicsPool,\n    private readonly textPool: TextPool,\n    private readonly worldApi: WorldDebugApiImpl,\n    private readonly hudApi: HudDebugApiImpl,\n    private readonly stats: StatsStore,\n    private readonly worldContainer: Container,\n    private readonly hudContainer: Container,\n  ) {\n    super();\n  }\n\n  update(dt: number): void {\n    if (!this.registry.enabled) {\n      this.worldContainer.visible = false;\n      this.hudContainer.visible = false;\n      return;\n    }\n\n    this.worldContainer.visible = true;\n    this.hudContainer.visible = true;\n\n    this.graphicsPool.resetFrame();\n    this.worldApi.prepareFrame();\n    this.textPool.resetFrame();\n\n    for (const [name, contributor] of this.registry.contributors) {\n      if (contributor.sample)\n        this.boundary.wrapCallback(() => contributor.sample!(this.stats, dt), {\n          kind: \"Debug contributor sample\",\n          event: name,\n        });\n\n      if (contributor.drawWorld) {\n        this.worldApi.setContributor(name);\n        this.boundary.wrapCallback(\n          () => contributor.drawWorld!(this.worldApi),\n          { kind: \"Debug contributor drawWorld\", event: name },\n        );\n      }\n\n      if (contributor.drawHud) {\n        this.hudApi.setContributor(name);\n        this.boundary.wrapCallback(() => contributor.drawHud!(this.hudApi), {\n          kind: \"Debug contributor drawHud\",\n          event: name,\n        });\n      }\n    }\n  }\n}\n","import type { DebugContributor, StatsApi, HudDebugApi } from \"../types.js\";\n\nexport class FpsContributor implements DebugContributor {\n  readonly name = \"fps\";\n  readonly flags: readonly string[] = [];\n  private stats: StatsApi | null = null;\n\n  sample(stats: StatsApi, dt: number): void {\n    this.stats = stats;\n    if (dt > 0) stats.push(\"fps\", 1 / dt);\n  }\n\n  drawHud(api: HudDebugApi): void {\n    const avg = this.stats?.average(\"fps\") ?? 0;\n    api.addLine(`FPS: ${Math.round(avg)}`);\n  }\n}\n","import type { DebugContributor, HudDebugApi } from \"../types.js\";\nimport type { Inspector } from \"@yagejs/core\";\n\nexport class EntityCountContributor implements DebugContributor {\n  readonly name = \"entities\";\n  readonly flags: readonly string[] = [];\n\n  constructor(private readonly inspector: Inspector) {}\n\n  drawHud(api: HudDebugApi): void {\n    const count = this.inspector.getEntityCount();\n    api.addLine(`Entities: ${count}`);\n  }\n}\n","import type { DebugContributor, StatsApi, HudDebugApi } from \"../types.js\";\n\nexport class SystemTimingContributor implements DebugContributor {\n  readonly name = \"timing\";\n  readonly flags = [\"breakdown\"] as const;\n  private stats: StatsApi | null = null;\n\n  constructor(private readonly timings: Map<string, number>) {}\n\n  sample(stats: StatsApi): void {\n    this.stats = stats;\n    for (const [name, ms] of this.timings) {\n      stats.push(`system.${name}`, ms);\n    }\n  }\n\n  drawHud(api: HudDebugApi): void {\n    if (!this.stats) return;\n\n    let total = 0;\n    const entries: Array<[string, number]> = [];\n    for (const name of this.timings.keys()) {\n      const avg = this.stats.average(`system.${name}`);\n      total += avg;\n      entries.push([name, avg]);\n    }\n\n    api.addLine(`Systems: ${total.toFixed(2)}ms`);\n\n    if (api.isFlagEnabled(\"breakdown\")) {\n      entries.sort((a, b) => b[1] - a[1]);\n      for (const [name, avg] of entries) {\n        api.addLine(`  ${name}: ${avg.toFixed(2)}ms`);\n      }\n    }\n  }\n}\n","import { Transform, Vec2Buffer } from \"@yagejs/core\";\nimport type { ErrorBoundary, Vec2Like } from \"@yagejs/core\";\nimport type {\n  DebugContributor,\n  DebugGraphics,\n  WorldDebugApi,\n} from \"../types.js\";\nimport type { VectorDrawStore, VectorEntry } from \"../VectorDrawStore.js\";\n\n/** Arrowhead width as a fraction of its length. */\nconst HEAD_WIDTH_RATIO = 0.75;\n\n/**\n * Draws every arrow registered through `DebugRegistry.drawVector`. Providers\n * are read here and nowhere else, so they stay uncalled while the overlay is\n * off or the `arrows` flag is disabled.\n */\nexport class VectorContributor implements DebugContributor {\n  private readonly positionScratch = new Vec2Buffer();\n  readonly name = \"vectors\";\n  readonly flags = [\"arrows\"] as const;\n\n  constructor(\n    private readonly store: VectorDrawStore,\n    private readonly boundary: ErrorBoundary,\n  ) {}\n\n  drawWorld(api: WorldDebugApi): void {\n    if (this.store.size === 0 || !api.isFlagEnabled(\"arrows\")) return;\n\n    // A zoomed-in camera scales world-space strokes up with everything else;\n    // dividing by the zoom keeps shaft and head at their configured size on\n    // screen while the arrow's length stays in world pixels.\n\n    for (const entry of this.store) {\n      const entity = entry.entity;\n      // A registration belongs to one life of one entity. Destruction and an\n      // EntityPool release both end a life; `generation` covers either, and\n      // the destroyed check covers the window before a destroy is flushed.\n      if (entity.isDestroyed || entity.generation !== entry.generation) {\n        this.store.remove(entity.id, entry);\n        continue;\n      }\n      // A dormant entity keeps its registration — it draws again when it\n      // comes back — but draws nothing while it is off.\n      if (!entity.isActive) continue;\n      const target = api.forScene(entry.scene);\n      if (!target) continue;\n      const zoom = target.cameraZoom;\n\n      const transform = entity.tryGet(Transform);\n      if (!transform) continue;\n\n      const v = this.readVector(entry);\n      if (!v) continue;\n\n      const length = Math.hypot(v.x, v.y);\n      if (length === 0 || length < entry.minLength) continue;\n\n      // Measure the drawn arrow before taking a pool slot, so a scale that\n      // collapses it to nothing doesn't spend one on an invisible arrow.\n      const tipX = v.x * entry.scale;\n      const tipY = v.y * entry.scale;\n      const drawnLength = Math.hypot(tipX, tipY);\n      if (drawnLength === 0) continue;\n\n      const g = target.acquireGraphics();\n      if (!g) return; // pool exhausted — skip the remaining arrows this frame\n\n      // worldPosition walks the parent chain, so a child entity's arrow sits\n      // where the entity is drawn, not where its local offset would put it.\n      const origin = transform.getWorldPositionInto(this.positionScratch);\n      g.position.x = origin.x + entry.originX;\n      g.position.y = origin.y + entry.originY;\n\n      drawArrow(g, tipX, tipY, drawnLength, entry, zoom);\n    }\n  }\n\n  /**\n   * The provider is game code the engine calls on its own, so a throw is\n   * attributed to it rather than to whichever system was on the stack.\n   * `wrapCallback` records and logs, then rethrows — nothing is muted.\n   */\n  private readVector(entry: VectorEntry): Vec2Like | null | undefined {\n    let v: Vec2Like | null | undefined;\n    this.boundary.wrapCallback(\n      () => {\n        v = entry.vector();\n      },\n      { kind: \"drawVector provider\", entity: entry.entity.name },\n    );\n    return v;\n  }\n}\n\n/** Shaft plus a filled head, from the graphics node's origin to (tipX, tipY). */\nfunction drawArrow(\n  g: DebugGraphics,\n  tipX: number,\n  tipY: number,\n  length: number,\n  entry: VectorEntry,\n  zoom: number,\n): void {\n  const dirX = tipX / length;\n  const dirY = tipY / length;\n  const style = { color: entry.color, alpha: entry.alpha };\n\n  // Clamping the head to the arrow's own length keeps a short arrow from\n  // growing a head that points past its own origin.\n  const head = Math.min(entry.headSize / zoom, length);\n  const baseX = tipX - dirX * head;\n  const baseY = tipY - dirY * head;\n\n  if (length > head) {\n    g.moveTo(0, 0)\n      .lineTo(baseX, baseY)\n      .stroke({ ...style, width: entry.width / zoom });\n  }\n\n  const halfWidth = (head * HEAD_WIDTH_RATIO) / 2;\n  const perpX = -dirY;\n  const perpY = dirX;\n  g.moveTo(tipX, tipY)\n    .lineTo(baseX + perpX * halfWidth, baseY + perpY * halfWidth)\n    .lineTo(baseX - perpX * halfWidth, baseY - perpY * halfWidth)\n    .fill(style);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,eASO;;;ACTP,kBAA2B;AAgJpB,IAAM,mBAAmB,IAAI,uBAA0B,eAAe;;;AD5H7E,IAAAC,mBAA6C;AAE7C,IAAAA,mBAA2C;;;AEiBpC,IAAM,aAAN,MAAwC;AAAA,EAI7C,YAA6B,MAAsB;AAAtB;AAC3B,SAAK,UAAU,KAAK;AAAA,EAC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Y,GAAG;AACxC,kBAAM,MAAM,OAAO,OAAO,gCAAe;AACzC,gBAAI,CAAC,IAAK;AACV,oBAAQ,KAAK;AAAA,cACX,OAAO,MAAM;AAAA,cACb,MAAM,IAAI;AAAA,cACV,UAAU,IAAI;AAAA,cACd,SAAS,IAAI;AAAA,YACf,CAAC;AAAA,UACH;AAAA,QACF;AACA,eAAO;AAAA,MACT,GAfgB;AAAA,MAgBhB,cAAc,6BAAM,KAAK,cAAc,WAAW,OAApC;AAAA,MACd,eAAe,wBAAC,YAAY;AAC1B,YAAI,CAAC,KAAK,gBAAgB,KAAK,aAAa,YAAY,SAAS;AAC/D;AAAA,QACF;AACA,aAAK,aAAa,UAAU;AAG5B,aAAK,SAAS,YAAY,OAAO;AAAA,MACnC,GARe;AAAA,IASjB;AACA,SAAK,QAAQ,QAAQ,yBAAY,EAAE,aAAa,SAAS,WAAW;AAAA,EACtE;AACF;AAUA,SAAS,qBACP,KACA,eACA,UACgB;AAChB,MAAI,gBAAgB;AACpB,MAAI,cAA6B;AACjC,SAAO;AAAA,IACL;AAAA,IACA,SAAe;AACb,UAAI,KAAK;AAKT,sBAAgB;AAChB,UAAI,OAAO,WAAW;AAGtB,oBAAc,IAAI,OAAO;AACzB,UAAI,OAAO,SAAS;AAAA,IACtB;AAAA,IACA,OAAa;AACX,UAAI,gBAAgB,MAAM;AACxB,YAAI,OAAO,SAAS;AACpB,sBAAc;AAAA,MAChB;AAKA,UAAI,MAAM;AAAA,IACZ;AAAA,IACA,cAAoB;AAClB,eAAS,OAAO;AAAA,IAClB;AAAA,IACA,IAAI,iBAA0B;AAC5B,aAAO,SAAS;AAAA,IAClB;AAAA,IACA,IAAI,eAAe,SAAkB;AACnC,eAAS,iBAAiB;AAAA,IAC5B;AAAA,IACA,QAAQ,MAAoB;AAC1B,uBAAiB;AACjB,UAAI,OAAO,OAAO,aAAa;AAAA,IACjC;AAAA,EACF;AACF;AA/CS;","names":["import_core","import_renderer","import_core","import_core","import_pixi","import_core","import_renderer","import_pixi","import_renderer","import_core","import_core"]}