import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { cookies } from 'next/headers';
import '@xyflow/react/dist/base.css';
import './globals.css';
import { AppShell } from '../components/layouts/app-shell/index.js';
import { Toaster } from '../components/ui/sonner.js';
import { getFeatureFlags } from '../lib/feature-flags.js';
import { getFabLayout } from '../lib/fab-layout.js';
import { FeatureFlagsProvider } from '../hooks/feature-flags-context.js';
import { FabLayoutProvider } from '../hooks/fab-layout-context.js';
import { QueryProvider } from '../components/providers/query-provider.js';
import { I18nProvider } from '../components/providers/i18n-provider.js';
import { getLanguagePreference } from '../lib/language.js';
import { SHELL_VARIANT_COOKIE, parseShellVariant } from '../lib/shell-variant.js';
/** Force dynamic rendering for all pages since they depend on client-side context. */
export const dynamic = 'force-dynamic';
export const metadata = {
    title: 'Shep AI',
    description: 'Autonomous AI-native SDLC platform — run parallel AI agents in isolated worktrees to automate the development cycle from idea to deploy.',
    icons: [
        {
            rel: 'icon',
            url: '/favicon-light.svg',
            type: 'image/svg+xml',
            media: '(prefers-color-scheme: light)',
        },
        {
            rel: 'icon',
            url: '/favicon-dark.svg',
            type: 'image/svg+xml',
            media: '(prefers-color-scheme: dark)',
        },
    ],
};
export default async function RootLayout({ children, }) {
    const cookieStore = await cookies();
    const sidebarOpen = cookieStore.get('shep-sidebar-open')?.value === 'true';
    const shellVariant = parseShellVariant(cookieStore.get(SHELL_VARIANT_COOKIE)?.value);
    const { language, dir } = getLanguagePreference();
    return (_jsxs("html", { lang: language, dir: dir, suppressHydrationWarning: true, children: [_jsx("head", { children: _jsx("script", { dangerouslySetInnerHTML: {
                        __html: shellVariant === 'apps-only'
                            ? `(function(){try{var d=document.documentElement,t=localStorage.getItem('shep-theme');if(t==='dark'){d.classList.add('dark')}}catch(e){}})();`
                            : `(function(){try{var d=document.documentElement,t=localStorage.getItem('shep-theme'),s=window.matchMedia('(prefers-color-scheme: dark)').matches;if(t==='dark'||(t==='system'&&s)||(!t&&s)){d.classList.add('dark')}}catch(e){}})();`,
                    } }) }), _jsxs("body", { className: shellVariant === 'apps-only'
                    ? // Transparent body so the AppsOnlyShell's rounded wrapper
                        // clips the visible surface. The Electron window itself is
                        // transparent — the rounded corners let the OS compositor
                        // blend the desktop behind the corner cut-outs.
                        'h-screen overflow-hidden bg-transparent antialiased'
                    : 'min-h-screen antialiased', children: [_jsx(I18nProvider, { initialLanguage: language, children: _jsx(QueryProvider, { children: _jsx(FeatureFlagsProvider, { flags: getFeatureFlags(), children: _jsx(FabLayoutProvider, { layout: getFabLayout(), children: _jsx(AppShell, { sidebarOpen: sidebarOpen, variant: shellVariant, children: children }) }) }) }) }), _jsx(Toaster, { position: "bottom-center" })] })] }));
}
