import { atom } from 'jotai';

// Transient open/closed state for the group-room members sheet — mirrors
// `userRoomProfileAtom` (the 1:1 peer-profile sheet) in semantics and
// lifetime. `undefined` ↔ closed; `{ roomId }` ↔ open against that room.
//
// Closes implicitly on:
//   • room change       (effect inside RoomViewMembersPanel /
//                        RoomViewMembersSidePanel mirrors the profile
//                        sheet's close-on-room-change effect)
//   • drag-up (mobile)  / `×` / Esc (desktop)
//   • user opens the per-row UserRoomProfile from the list — `useOpenUser
//     RoomProfile` already clears `mediaViewerAtom`; we use the same
//     mutual-exclusion pattern here so the two sheets don't fight for
//     the right-pane slot on desktop.
//
// Distinct from `settingsAtom.isPeopleDrawer` (localStorage flag) which
// still governs `LobbyHeader` + `Lobby` for space lobbies. The room view
// stops reading `isPeopleDrawer`; the lobby keeps it.
export type RoomMembersSheetState = {
  roomId: string;
};

export const roomMembersSheetAtom = atom<RoomMembersSheetState | undefined>(undefined);
