import type { Metadata } from 'next'
import { Poppins, Oleo_Script_Swash_Caps } from 'next/font/google'
import localFont from 'next/font/local'
import '../css/iconfont.css'
import './globals.css'
import { Providers } from '@/lib/providers'
import { MockProvider } from '@/components/mock-provider'
import { DeviceIdProvider } from '@/components/device-id-provider'
// import "@/lib/server-mock"; // 导入服务端 mock 初始化
import ProgressBar from '@/context/progress'
import { MainLayoutProvider } from '@/context/mainLayout'
import ConditionalLayout from '@/components/layout/ConditionalLayout'

const poppins = Poppins({
  variable: '--font-poppins',
  weight: ['400', '500', '600', '700'],
  display: 'swap',
  subsets: ['latin'],
})

const oleoScriptSwashCaps = Oleo_Script_Swash_Caps({
  variable: '--font-oleo-script-swash-caps',
  weight: ['400'],
  display: 'swap',
  subsets: ['latin'],
})

const NumDisplay = localFont({
  src: [
    {
      path: './DIN-Alternate-Bold.ttf',
      weight: '700',
      style: 'normal',
    },
  ],
  variable: '--font-display-num',
  display: 'swap',
})

export const metadata: Metadata = {
  title: 'CrushLevel',
  description: 'CrushLevel - Next Generation Social Platform',
}

export default async function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode
}>) {
  return (
    <html lang="en">
      <body
        className={`${poppins.variable} ${oleoScriptSwashCaps.variable} ${NumDisplay.variable} antialiased`}
      >
        <DeviceIdProvider>
          {/* <MockProvider> */}
          <Providers>
            <ProgressBar>
              <MainLayoutProvider>
                <ConditionalLayout>{children}</ConditionalLayout>
              </MainLayoutProvider>
            </ProgressBar>
          </Providers>
          {/* </MockProvider> */}
        </DeviceIdProvider>
      </body>
    </html>
  )
}
