export type SessionStatus = "lobby" | "active" | "ended";
export type PlayerRole = "banker" | "player";

export type Player = {
  id: string;
  name: string;
  role: PlayerRole;
  balance: number;
  connected: boolean;
  isDummy: boolean;
  joinedAt: number;
  lastActiveAt: number;
};

export type TransactionKind =
  | "transfer"
  | "banker_adjust"
  | "banker_force_transfer";

export type Transaction = {
  id: string;
  kind: TransactionKind;
  fromId: string | null;
  toId: string | null;
  amount: number;
  note: string | null;
  createdAt: number;
  initiatedBy: PlayerRole;
};

export type ChatGroup = {
  id: string;
  name: string;
  memberIds: string[];
  createdAt: number;
  createdBy: string;
};

export type ChatMessage = {
  id: string;
  fromId: string;
  body: string;
  createdAt: number;
  groupId: string | null;
};

export type TakeoverRequest = {
  id: string;
  dummyId: string;
  requesterId: string;
  requesterName?: string | null;
  requesterToken?: string | null;
  createdAt: number;
  status: "pending" | "approved" | "rejected";
};

export type SessionSnapshot = {
  id: string;
  code: string;
  status: SessionStatus;
  createdAt: number;
  bankerId: string;
  blackoutActive: boolean;
  blackoutReason: string | null;
  players: Player[];
  transactions: Transaction[];
  chats: ChatMessage[];
  groups: ChatGroup[];
  takeoverRequests: TakeoverRequest[];
};

export type SessionPreviewPlayer = {
  id: string;
  name: string;
  role: PlayerRole;
  isDummy: boolean;
  connected: boolean;
};

export type SessionPreview = {
  sessionId: string;
  code: string;
  status: SessionStatus;
  players: SessionPreviewPlayer[];
};

export type JoinResponse = {
  sessionId: string;
  sessionCode: string;
  playerId: string;
  role: PlayerRole;
  status: SessionStatus;
};
