import { createContext, useContext } from 'react';

// Non-null only when an atom-driven media-viewer shell (the mobile
// bottom-up horseshoe or the desktop/tablet floating window
// `RoomViewMediaWindow`) is mounted in
// the React tree above this consumer. `ImageContent` reads this to
// decide between the new atom-open path (Room timeline) and the
// legacy local-state `<Overlay>` viewer (pin-menu, message search
// — surfaces where no shell is mounted). Carries `roomId` so the
// consumer doesn't need a separate `useRoom()` call (which throws
// outside `RoomProvider`).
//
// Defaults to `null` so unchanged callers keep their current
// behaviour; `Room.tsx` provides a non-null value for the chat
// column.
export type MediaViewerHostValue = { roomId: string } | null;

export const MediaViewerHostContext = createContext<MediaViewerHostValue>(null);

export const useMediaViewerHost = (): MediaViewerHostValue => useContext(MediaViewerHostContext);
