import type { Chapter } from '../types' import { activeChapterIndex, chapterKindLabel, chapterLapRange, chapterStartScrub, } from '../lib/chapters' import '../styles/chapters.css' interface Props { chapters: Chapter[] scrubTime: number | null tMin: number tRange: number tourActive: boolean tourChapterIndex: number | null onChapterClick: (index: number, scrub: number) => void onTourToggle: () => void } export function ChapterStrip({ chapters, scrubTime, tMin, tRange, tourActive, tourChapterIndex, onChapterClick, onTourToggle, }: Props) { if (chapters.length === 0) { return (

No story chapters for this session.

) } const activeIndex = activeChapterIndex(chapters, scrubTime, tMin, tRange) return (
Race chapters
{chapters.map((chapter, index) => { const scrub = chapterStartScrub(chapter, tMin, tRange) ?? index / Math.max(chapters.length - 1, 1) const isActive = tourActive ? tourChapterIndex === index : activeIndex === index const headline = chapter.headline || chapter.title return ( ) })}
) }