import { createContext, use } from 'react'; export type Theme = 'dark' | 'light' | 'system'; interface ThemeProviderState { theme: Theme; setTheme: (theme: Theme) => void; } const initialState: ThemeProviderState = { theme: 'system', setTheme: () => null, }; export const ThemeProviderContext = createContext(initialState); export function useTheme() { const context = use(ThemeProviderContext); if (context === undefined) throw new Error('useTheme must be used within a ThemeProvider'); return context; }