import type { PrivateState, PublicState } from '@pintrush/engine';
import type { RoomSnapshot } from '@pintrush/protocol';
import type { GameConnection, GameViewState } from '@/lib/game';
import type { ChampionshipStage } from '@/lib/play/screen';
import type { PlayController } from './usePlayController';

export type MenuTab = 'leaders' | 'teams' | 'board' | 'power' | 'rules';

/** Everything a screen may read. Screens render only from these views (never from message order). */
export interface PlayCtx {
  conn: GameConnection | null;
  state: GameViewState;
  snapshot: RoomSnapshot;
  pub: PublicState | null;
  me: PrivateState | null;
  ctl: PlayController;
  embed: boolean;
  joinHref: string;
  venueName: string;
  /** The current screen was entered through a live message (not a reload/resync): celebrate it. */
  live: boolean;
  openMenu: (tab?: MenuTab) => void;
  /** Lobby or live, for the room's active championship when this phone plays another session. */
  championshipStage: ChampionshipStage;
}

export type ActivePublic = PublicState & { round: NonNullable<PublicState['round']> };
