import { defaultMode, isLocale } from '@/lib/localization/config'
import { isThemePreference, themeCookie } from '@/lib/theme/config'
import { cookies } from 'next/headers'
import { notFound, redirect } from 'next/navigation'

export const metadata = { robots: { index: false, follow: false } }

export default async function LegacyComponentLabPage({
  params,
}: {
  params: Promise<{ locale: string }>
}) {
  const { locale } = await params
  if (!isLocale(locale)) notFound()
  const cookieStore = await cookies()
  const cookieMode = cookieStore.get(themeCookie)?.value
  const mode = isThemePreference(cookieMode) ? cookieMode : defaultMode
  redirect(`/${locale}/${mode}/component-lab`)
}
