import Announcement from '@/components/announcement';
// import LanguageSwitch from '@/components/language-switch';
import { SidebarInset, SidebarProvider } from '@workspace/airo-ui/components/sidebar';
import { cookies } from 'next/headers';
import { Header } from './Header';
import { SidebarLeft } from './sidebar-left';

export default async function DashboardLayout({ children }: { children: React.ReactNode }) {
  const cookieStore = await cookies();
  const defaultOpen = cookieStore.get('sidebar:state')?.value !== 'false'; // 默认 true，除非明确为 'false'
  return (
    <SidebarProvider className='' defaultOpen={defaultOpen}>
      <SidebarLeft className='w-[288px] border-r-0 bg-transparent lg:flex' />
      <SidebarInset className='relative flex-grow overflow-hidden'>
        {/*<LanguageSwitch />*/}
        <div className='h-screen flex-grow gap-4 overflow-auto p-4 sm:pt-9'>
          <Header />
          {children}
        </div>
      </SidebarInset>
      <Announcement type='popup' Authorization={(await cookies()).get('Authorization')?.value} />
    </SidebarProvider>
  );
}
