import { forwardRef } from 'react'
import type { ArchChapter, ArchStep } from '@/lib/types'
import { cn } from '@/lib/utils'
import { Diagram } from './Diagrams'
/** One chapter (one level of detail): its steps on the left, read top to bottom, and its
* diagram pinned on the right (on a phone, above the steps). The active step (the one
* being read, or the one clicked) lights up the boxes it talks about. */
export function Chapter({
chapter,
number,
active,
onStep,
stepRef,
}: {
chapter: ArchChapter
number: number
active: number // the step being read in this chapter, -1 for none
onStep: (i: number) => void
stepRef: (i: number, el: HTMLElement | null) => void
}) {
const lit = active >= 0 ? chapter.steps[active].highlight : null
return (