import type { Metadata } from 'next' import { cookies } from 'next/headers' import { JetBrains_Mono } from 'next/font/google' import Script from 'next/script' import '@fontsource-variable/inter/index.css' import '@fontsource-variable/noto-sans-arabic/index.css' import { DashboardI18nProvider } from '@/components/I18nProvider' import { HOMEPAGE_THEME_COOKIE, SHARED_LANGUAGE_COOKIE, SHARED_THEME_KEY } from '@/lib/preferences' import './globals.css' const jetbrainsMono = JetBrains_Mono({ subsets: ['latin'], variable: '--font-mono', display: 'swap', }) export const metadata: Metadata = { title: 'RentalDriveGo Dashboard', description: 'Manage your rental car business', icons: { icon: '/icon.svg', shortcut: '/icon.svg', }, } function resolveInitialLanguage(value: string | undefined): 'en' | 'fr' | 'ar' { return value === 'fr' || value === 'ar' || value === 'en' ? value : 'ar' } export default async function RootLayout({ children }: { children: React.ReactNode }) { const cookieStore = await cookies() const initialLanguage = resolveInitialLanguage( cookieStore.get(SHARED_LANGUAGE_COOKIE)?.value ?? cookieStore.get('dashboard-language')?.value, ) const dir = initialLanguage === 'ar' ? 'rtl' : 'ltr' const cookieTheme = cookieStore.get(SHARED_THEME_KEY)?.value ?? cookieStore.get(HOMEPAGE_THEME_COOKIE)?.value const initialTheme = cookieTheme === 'light' ? 'light' : 'dark' return (