'use client'; import Link from 'next/link'; import { usePathname, useRouter } from 'next/navigation'; import { useState } from 'react'; import { Activity, BookOpenText, ChartCandlestick, Eye, LineChart, LogOut } from 'lucide-react'; import { authClient } from '@/lib/auth-client'; import { Button } from '@/components/ui/button'; import { cn } from '@/lib/utils'; type AppShellProps = { title: string; subtitle?: string; actions?: React.ReactNode; children: React.ReactNode; }; const NAV_ITEMS = [ { href: '/', label: 'Command Center', icon: Activity }, { href: '/analysis', label: 'Company Analysis', icon: LineChart }, { href: '/filings', label: 'Filings Stream', icon: BookOpenText }, { href: '/portfolio', label: 'Portfolio Matrix', icon: ChartCandlestick }, { href: '/watchlist', label: 'Watchlist', icon: Eye } ]; export function AppShell({ title, subtitle, actions, children }: AppShellProps) { const pathname = usePathname(); const router = useRouter(); const [isSigningOut, setIsSigningOut] = useState(false); const { data: session } = authClient.useSession(); const sessionUser = (session?.user ?? null) as { name?: string | null; email?: string | null; role?: unknown } | null; const role = typeof sessionUser?.role === 'string' ? sessionUser.role : Array.isArray(sessionUser?.role) ? sessionUser.role.filter((entry): entry is string => typeof entry === 'string').join(', ') : null; const displayName = sessionUser?.name || sessionUser?.email || 'Authenticated user'; const signOut = async () => { if (isSigningOut) { return; } setIsSigningOut(true); try { await authClient.signOut(); router.replace('/auth/signin'); } finally { setIsSigningOut(false); } }; return (