export const LOCALES = ["en", "hi"] as const;
export type Locale = (typeof LOCALES)[number];

export const DEFAULT_LOCALE: Locale = "en";

export const LOCALE_LABELS: Record<Locale, string> = {
  en: "English",
  hi: "हिन्दी",
};

export function isLocale(value: string | undefined): value is Locale {
  return !!value && (LOCALES as readonly string[]).includes(value);
}

/*
* Confirmed live: the content-generation APIs (horoscope, panchang,
* tarot, kundli/kundli-matching) are backed by a separate third-party
* astrology engine that only understands a subset of the site's UI
* languages — it accepts "en" and "hi", but 400s on "kn" ("astrology
* service error (status 400)"). Route any unsupported locale to
* English content rather than surfacing that error, while the rest of
* the page chrome stays in the selected UI language.
*/
const CONTENT_API_LOCALES: readonly Locale[] = ["en", "hi"];

export function toContentLang(locale: Locale): Locale {
  return CONTENT_API_LOCALES.includes(locale) ? locale : DEFAULT_LOCALE;
}
