/**
 * Pure helpers for `CorrectionsPage` — the editable synonym/utterance
 * fields are one-per-line textareas, so these convert between that and the
 * `string[]` the API wants. Kept out of the `.tsx` per repo convention.
 */

/** Textarea value (one entry per line) → trimmed, non-empty `string[]`. */
export function linesToList(text: string): string[] {
  return text
    .split("\n")
    .map((line) => line.trim())
    .filter((line) => line.length > 0);
}

/** `string[]` → textarea value (one entry per line). */
export function listToLines(values: string[]): string {
  return values.join("\n");
}

/** True when two string lists differ (order-sensitive) — gates the "save" button. */
export function listsDiffer(a: string[], b: string[]): boolean {
  return a.length !== b.length || a.some((value, i) => value !== b[i]);
}
