'use client';

import { useEffect, type ReactNode } from 'react';
import { useThemeStore } from '@/store/theme.store';

/**
 * ThemeProvider
 * ---------------------------------------------------------------
 * Applies the active theme class to <html> and hydrates the stored
 * preference on mount (avoids flash of wrong theme).
 */
export function ThemeProvider({ children }: { children: ReactNode }) {
  const hydrate = useThemeStore((s) => s.hydrate);

  useEffect(() => {
    hydrate();
  }, [hydrate]);

  return <>{children}</>;
}
