import type { Metadata } from "next";
import { Inter } from "next/font/google";
import "./globals.css";
import { ThemeProvider } from "@/components/theme-provider";
import { VersionChecker } from "@/components/version-checker";
import { AuthProvider } from "@/lib/auth-context";
import { ModelSelectionProvider } from "@/contexts/model-selection-context";

const inter = Inter({
  subsets: ["latin"],
  variable: "--font-sans",
});

export const metadata: Metadata = {
  title: "Stable Diffusion REST - Web UI",
  description: "Modern web interface for Stable Diffusion image generation",
};

export default function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode;
}>) {
  return (
    <html lang="en" suppressHydrationWarning>
      <head>
        {/* Load server configuration - this is dynamically generated by the server */}
        {/* Load synchronously to ensure config is available before React hydration */}
        <script src="/ui/config.js"></script>
      </head>
      <body className={`${inter.variable} font-sans antialiased`}>
        <ThemeProvider
          attribute="class"
          defaultTheme="system"
          enableSystem
          disableTransitionOnChange
        >
          <AuthProvider>
            <ModelSelectionProvider>
              <VersionChecker />
              {children}
            </ModelSelectionProvider>
          </AuthProvider>
        </ThemeProvider>
      </body>
    </html>
  );
}
