// Turns a chunk's study notes into a starting script outline for a talk or episode. const has = (s) => (s ?? '').trim().length > 0; export function buildScriptDraft(chunk, reference) { const title = [chunk.episodeNumber, chunk.episodeTitle].filter(has).join(': '); const words = (chunk.greekWords ?? []) .filter((w) => w.lexeme || w.transliteration) .map((w) => `• ${[w.lexeme, w.transliteration && `(${w.transliteration})`].filter(Boolean).join(' ')}${w.englishGloss || w.shortDefinition ? ` — ${w.englishGloss || w.shortDefinition}` : ''}`); const section = (heading, body) => `${heading}\n${has(body) ? body.trim() : '[…]'}`; return [ title || reference, title ? reference : null, '', section('OPENING', ''), '', section('WHAT THE TEXT SAYS', chunk.observation), '', section('WHAT IT MEANS', chunk.interpretation), ...(words.length ? ['', 'KEY WORDS', ...words] : []), '', section('WHAT IT MEANS FOR US', chunk.application), '', section('CLOSING', ''), ].filter((line) => line !== null).join('\n'); } export const wordCount = (s) => (s ?? '').trim().split(/\s+/).filter(Boolean).length; // Speaking pace for the time estimate: about 150 words a minute. export const spokenMinutes = (s) => Math.round((wordCount(s) / 150) * 10) / 10;