// "What changed since my first draft": your Observe / Interpret / Apply notes now, with the words added or // reworded since the copy kept when you first opened commentary. It shows whether commentary changed your thinking. import { diffVerses } from '../../utils/textDiff.js'; import { markRanges } from '../../utils/compareTranslations.js'; const FIELDS = [['observation', 'Observe'], ['interpretation', 'Interpret'], ['application', 'Apply']]; const count = (s) => (s ?? '').trim().split(/\s+/).filter(Boolean).length; export default function FirstDraft({ chunk }) { const draft = chunk.firstDraft; if (!draft) return null; const rows = FIELDS.map(([f, label]) => { const then = draft[f] ?? ''; const now = chunk[f] ?? ''; return { f, label, then, now, same: then.trim() === now.trim(), parts: markRanges(now, diffVerses(then, now).b) }; }).filter((r) => r.then.trim() || r.now.trim()); const changed = rows.filter((r) => !r.same).length; return (
First draft, before commentary · {new Date(draft.at).toLocaleDateString()} · {changed === 0 ? 'nothing changed since' : `${changed} of ${rows.length} notes changed since`}
{rows.length === 0 &&

You opened commentary before writing anything.

} {rows.map((r) => (

{r.label} · {count(r.then)} words then, {count(r.now)} now

{r.same ?

Unchanged.

:

{r.parts.map((p, i) => (p.mark ? {p.text} : {p.text}))}

} {!r.same && r.then.trim() &&
Show the first draft

{r.then}

}
))}

Highlighted words are new or reworded since the draft.

); }