import type { Dispatch, SetStateAction } from 'react';
import type {
  CampusInfo,
  Module,
  ModuleId,
  StaffProfile,
  UserRole,
} from '@/shared/types/app';
import type { TopBarProps } from '@/business/top-bar/types';

export interface GuestPreviewRoleOption {
  readonly value: UserRole;
  readonly label: string;
  readonly color: string;
}

export interface UseAppShellOptions {
  readonly isAuthenticated: boolean;
  readonly profile: StaffProfile | null;
  readonly isMobile: boolean;
}

export interface AppShellState {
  readonly activeModule: ModuleId;
  readonly currentModule: ModuleId;
  readonly userRole: UserRole;
  readonly userName: string;
  readonly userCampus: string;
  readonly campusInfo?: CampusInfo;
  readonly sidebarCollapsed: boolean;
  readonly mobileSidebarOpen: boolean;
  readonly mobileOverlayVisible: boolean;
  readonly zoneCheckIn: string | null;
  readonly showSignInModal: boolean;
  readonly guestPreviewRole: UserRole;
  readonly showGuestRolePicker: boolean;
  readonly guestPreviewRoles: readonly GuestPreviewRoleOption[];
  readonly currentGuestPreviewRole: GuestPreviewRoleOption;
  readonly sidebarProps: SidebarProps;
  readonly topBarProps: TopBarProps;
  readonly shellOutletContext: ShellOutletContext;
  readonly guestBannerProps: GuestBannerProps;
  readonly footerProps: AppFooterProps;
  readonly signInModalProps: SignInModalProps;
  readonly setSidebarCollapsed: Dispatch<SetStateAction<boolean>>;
  readonly setMobileSidebarOpen: Dispatch<SetStateAction<boolean>>;
  readonly setZoneCheckIn: Dispatch<SetStateAction<string | null>>;
  readonly setShowSignInModal: Dispatch<SetStateAction<boolean>>;
  readonly setGuestPreviewRole: Dispatch<SetStateAction<UserRole>>;
  readonly setShowGuestRolePicker: Dispatch<SetStateAction<boolean>>;
  readonly setCurrentModule: (id: ModuleId) => void;
}

export interface ShellOutletContext {
  readonly userRole: UserRole;
  readonly userName: string;
  readonly userCampus: string;
  readonly zoneCheckIn: string | null;
  readonly setZoneCheckIn: (zone: string | null) => void;
  readonly setCurrentModule: (id: ModuleId) => void;
}

export interface SidebarProps {
  readonly currentModule: ModuleId;
  readonly setCurrentModule: (id: ModuleId) => void;
  readonly userRole: UserRole;
  readonly collapsed: boolean;
  readonly setCollapsed: (value: boolean) => void;
  readonly campusInfo?: CampusInfo;
}

export interface SidebarPage {
  readonly currentModule: ModuleId;
  readonly userRole: UserRole;
  readonly collapsed: boolean;
  readonly campusInfo?: CampusInfo;
  readonly modules: readonly Module[];
  readonly roleLabel: string;
  readonly campusInitial: string | null;
  readonly setCurrentModule: (id: ModuleId) => void;
  readonly toggleCollapsed: () => void;
}

export interface GuestBannerProps {
  readonly guestPreviewRole: UserRole;
  readonly guestPreviewRoles: readonly GuestPreviewRoleOption[];
  readonly currentGuestPreviewRole: GuestPreviewRoleOption;
  readonly showGuestRolePicker: boolean;
  readonly setGuestPreviewRole: (role: UserRole) => void;
  readonly setShowGuestRolePicker: (open: boolean) => void;
  readonly onSignInClick: () => void;
}

export interface AppFooterProps {
  readonly isAuthenticated: boolean;
  readonly userName: string;
  readonly userRole: UserRole;
  readonly currentGuestPreviewRole: GuestPreviewRoleOption;
  readonly setCurrentModule: (id: ModuleId) => void;
}

export interface SignInModalProps {
  readonly isOpen: boolean;
  readonly onClose: () => void;
}
