import { createContext, useContext } from 'react';

// Set by MobileTabsPager around each of its three listing panes. Lets
// the StreamHeader inside the pane discover (a) that it's mounted in
// pager mode at all, and (b) whether it's the currently active pane.
//
// "Mounted in pager mode" controls whether the per-pane tabs row
// renders visibly — when we're in pager mode the tabs row is hidden
// via visibility:hidden (the shared static header at pager root paints
// the visible tabs + icons), but the row still occupies its
// TABS_ROW_PX height so the curtain's snap geometry is unchanged.
//
// "isActive" controls which pane's curtain is wired to the shared
// static header's action icons via `mobilePagerCurtainAtom`.
export type MobilePagerPaneInfo = {
  isActive: boolean;
};

const MobilePagerPaneContext = createContext<MobilePagerPaneInfo | null>(null);

export const MobilePagerPaneProvider = MobilePagerPaneContext.Provider;

export function useMobilePagerPane(): MobilePagerPaneInfo | null {
  return useContext(MobilePagerPaneContext);
}
