/**
 * Strapi text fields often store manual line breaks as `<br>` or `<br/>`.
 * Strips other HTML tags, then returns non-empty trimmed lines.
 */
export function parseStrapiBrTitleLines(raw: string): string[] {
  return raw
    .replace(/<br\s*\/?>/gi, "\n")
    .replace(/<[^>]*>/g, "")
    .split("\n")
    .map((line) => line.trim())
    .filter(Boolean);
}

/** Prefer `<br>`-split lines; if only one line, fall back to one word per line (legacy titles). */
export function heroTitleDisplayLines(heroTitle: string): string[] {
  const fromBr = parseStrapiBrTitleLines(heroTitle);
  if (fromBr.length > 1) return fromBr;
  return heroTitle.split(/\s+/).filter(Boolean);
}
