import { business, languages, type Locale } from "@/config/business";
import { messages } from "@/messages";

export const defaultLocale: Locale = "fr";

export function isLocale(value: string): value is Locale {
  return languages.some((language) => language.code === value);
}

export function getDirection(locale: Locale) {
  return languages.find((language) => language.code === locale)?.dir ?? "ltr";
}

export function getDictionary(locale: Locale) {
  return messages[locale] ?? messages[defaultLocale];
}

export function createWhatsAppMessage(locale: Locale) {
  const copy = getDictionary(locale).contact.whatsappMessage;
  return `${business.whatsappHref}?text=${encodeURIComponent(copy)}`;
}
