/**
 * Split a workshop duration such as "5 Days" into the big number and the small
 * unit shown beside it.
 *
 * English keeps its original rule exactly - anything containing "day"/"days" is
 * split on that word - so English pages render as before. That rule only knows
 * English, though: "5 jours" or "6 Días" never matched, the whole string landed
 * in the big 30px slot and broke over two lines. Every other value is split on
 * a leading number instead ("5 jours" -> "5" + "jours"); a value without one is
 * shown whole, as before.
 */
export function splitDuration(value: string): { amount: string; unit: string } {
  const days = value.match(/Days?/i);
  if (days) {
    return { amount: value.replace(/\s*Days?/i, ""), unit: days[0] };
  }

  const numbered = value.match(/^(\d+(?:[.,]\d+)?)\s+(.+)$/);
  if (numbered) {
    return { amount: numbered[1], unit: numbered[2] };
  }

  return { amount: value, unit: "" };
}
