// In-memory live state shared between the HTTP routes and the WebSocket signaling layer.
// NOTE (roadmap): this is the piece that must move to Redis to run multiple instances.
module.exports = {
  onlineAgents: new Map(),   // machineId -> { ws, machine }
  liveSessions: new Map(),   // sessionId -> { agentWs, viewerWs, machine, user }
  pendingShares: new Map(),  // code -> { sharerWs, sessionId } (no-install ad-hoc shares)
  chatClients: new Map(),    // userId -> Set<ws> (a user may have several tabs/devices open)
  meetingRooms: new Map(),   // roomCode -> Map(peerId -> { ws, name })  (mesh meetings MVP)
  groupCalls: new Map(),     // groupId -> { room, startedAt, startedBy, startedByName }  (shared group calls)
  roomToGroupCall: new Map(),// roomCode -> groupId  (end a group call when its room empties)
  dmCalls: new Map(),        // pairKey "a|b" -> { room, startedAt, startedBy, startedByName, users:[a,b] }
  roomToDmCall: new Map(),   // roomCode -> pairKey  (end a 1:1 call when its room empties)
  roomHost: new Map(),       // roomCode -> userId  (the meeting creator = host; transferable in-call)
  transcriptBuffers: new Map(),// roomCode -> [{ t, speaker, text }]  (shared full-conversation buffer)
  transcriptSubs: new Map(),  // roomCode -> Set(userId)  (who wants a private copy of the transcript)
};
