import { createPortal } from 'react-dom'; import DOMPurify from 'dompurify'; import { useApp } from '../context/AppContext.js'; import { STUDY_TABS, COMMENTARY_OPTIONS, NT_BOOK_NUMBER, formatChunkReference, CrossRefChip } from '../App.jsx'; import DrawCanvas from './DrawCanvas.jsx'; export default function StudyPage() { const { headerButtons, project, allChunks, selectedChunk, selectedChunkChapterIndex, selectedChunkChapter, selectedChunkVerses, selectedChunkGlobalIndex, studyLayout, setStudyLayout, activeStudyTab, setActiveStudyTab, mobileStudyTab, setMobileStudyTab, collapsedSections, setCollapsedSections, interlinearData, interlinearLoading, interlinearError, commentarySource, setCommentarySource, commentaryData, commentaryLoading, commentaryError, crossRefInput, setCrossRefInput, suggestingCrossRefs, crossRefSuggestions, tagInput, setTagInput, suggestModal, setSuggestModal, suggestSelection, setSuggestSelection, suggestingGreekForChunkId, suggestingHebrewForChunkId, projectIndex, goToPreviousChunk, goToNextChunk, updateProject, updateChunk, addCrossRef, removeCrossRef, suggestCrossRefsForChunk, addSuggestedCrossRef, addTag, removeTag, addGreekWord, removeGreekWord, updateChunkWord, lookupWord, suggestGreekWordsForChunk, suggestHebrewWordsForChunk, confirmSuggestWords, speakOriginalWord, externalLookupLinks, buildGreekDefinitionHtml, loadVerseText, importFinalScriptDocx, formatChunkReference: _ignored, } = useApp(); return (

Bible Study Project

{project?.title ?? ''}

{selectedChunk && selectedChunkChapterIndex >= 0 && (

{formatChunkReference(project, selectedChunkChapterIndex, selectedChunk, '–')}

)}
{headerButtons}
{/* Sidebar */} {/* Chunk editor */}

Chunk editor

{selectedChunk ? `Section ${formatChunkReference(project, selectedChunkChapterIndex, selectedChunk, '–')}` : 'Select a chunk'}

{selectedChunk && ( <>
{`Chunk ${selectedChunkGlobalIndex + 1} of ${allChunks.length}`}
)} {!selectedChunk && (
Choose a chunk to study.
)}
{[ { id: 'stacked', label: '☰ Stacked' }, { id: 'split', label: '◫ Split' }, { id: 'annotate', label: '✏ Draw' }, ].map((m) => ( ))}
{/* Mobile tab bar */}
{[ { id: 'scripture', label: 'Scripture' }, { id: 'notes', label: 'Notes' }, { id: 'crossRefs', label: 'Refs' }, { id: 'wordStudy', label: 'Words' }, { id: 'commentary', label: 'Commentary' }, { id: 'script', label: 'Script' }, ].map((tab) => ( ))}
{selectedChunk ? (
{studyLayout === 'annotate' ? (
{/* Compact scripture strip */}
Scripture · read-only {formatChunkReference(project, selectedChunkChapterIndex, selectedChunk, '–')}

{selectedChunkVerses.map((verse) => ( {verse.chapter}:{verse.number} {verse.text}{' '} ))}

{/* Notebook canvas */} updateChunk(selectedChunk.id, { inkStrokes: s })} onDone={() => setStudyLayout('stacked')} />
) : (
{/* Scripture */}

Scripture

Read-only passage for the selected chunk.

{formatChunkReference(project, selectedChunkChapterIndex, selectedChunk, '–')}
{selectedChunkVerses .map((verse) => (

{verse.chapter}:{verse.number}. {verse.text}

))}
{/* Interlinear */}
{!collapsedSections.interlinear && (
{interlinearLoading &&

Loading interlinear text...

} {interlinearError &&

{interlinearError}

} {!interlinearLoading && !interlinearError && interlinearData && Array.from( { length: selectedChunk.endVerse - selectedChunk.startVerse + 1 }, (_, i) => selectedChunk.startVerse + i, ) .filter((num) => interlinearData[String(num)]) .map((num) => (
{selectedChunkChapter.chapter}:{num}.{' '} {interlinearData[String(num)].map((w, i) => ( {w.o} {w.g || '—'} ))}
))}
)}
{/* Right column (study panels) */}
{studyLayout === 'split' && (
{STUDY_TABS.map((tab) => ( ))}
)} {/* Session metadata */}

Session Info

Optional — only fill this in if this chunk is part of a numbered series (a podcast episode, sermon, or class session). Used to label it in exports and in "Prepare for Podcast."

updateChunk(selectedChunk.id, { episodeNumber: e.target.value })} placeholder="Session #" className="w-full rounded-2xl border border-slate-300 bg-white px-3 py-2 text-sm text-slate-900 shadow-sm focus:border-sky-500 focus:outline-none focus:ring-2 focus:ring-sky-200 sm:w-32" /> updateChunk(selectedChunk.id, { episodeTitle: e.target.value })} placeholder="Session title" className="w-full rounded-2xl border border-slate-300 bg-white px-3 py-2 text-sm text-slate-900 shadow-sm focus:border-sky-500 focus:outline-none focus:ring-2 focus:ring-sky-200" />
{/* Background / general notes */}
{!collapsedSections.generalNotes && (