/**
 * Strips every HTML tag from a string and collapses whitespace.
 *
 * Tags are replaced with a space (so `a</p><p>b` becomes `a b`, never `ab`),
 * then runs of whitespace collapse to a single space and the result is trimmed.
 * The `<[^>]*>` pattern matches any tag shape — `<p>`, `</p>`, `<p class="x">`,
 * even tags broken across newlines — so nothing like a stray `<p>` is left behind.
 *
 * Null/undefined input yields an empty string.
 */
export const stripHtml = (value?: string | null): string =>
  (value ?? '')
    .replace(/<[^>]*>/g, ' ')
    .replace(/\s+/g, ' ')
    .trim();
