import { cookies } from 'next/headers'
import { PUBLIC_SITE_LANGUAGE_COOKIE, isPublicSiteLanguage, type PublicSiteLanguage } from './i18n'

export function getPublicSiteLanguage(): PublicSiteLanguage {
  const cookieValue = cookies().get(PUBLIC_SITE_LANGUAGE_COOKIE)?.value
  return isPublicSiteLanguage(cookieValue) ? cookieValue : 'en'
}
