import { cva } from "class-variance-authority"; import { cn } from "@/lib/utils"; import { ReaderThread } from "./cite-thread"; import { clock } from "./clock"; import { LitList, type LitDetail } from "./lit-list"; import { LitLine } from "./lit-line"; // --------------------------------------------------------------------------- // THE READER (canvas `.paper`): anything a SOURCE said -- a transcript window, // a quote, a post -- on the pale microfilm surface, apart from the desk. Paper // is the record; ink is our work. Wherever something cited is focused (Inbox, // Research, an article, the claim bench) it is this component. // // header the source's title; channel · date · track; the cite thread // (start, the cite, the end) when the cite and the length are known // body the cues as a lit list, the cited cue lit; `»` marks a change of // speaker when the transcript knows one // footer the actions (paperButtonVariants), and a fine line (the citation) // // A bench (P4b) passes its own handle and ref on the body (`bodyProps`), its own // cue rows unwrapped (`bare`), or follows the lit cue (`onLight`). // // Rules from the canvas critique: no verdict colour on the reader, ever; the // reader's own Signal is `--reader-signal`, a teal dark enough for the paper. // --------------------------------------------------------------------------- export type Cue = { t: number; text: React.ReactNode; turn?: boolean; lit?: boolean; id?: string; /** The line's own data attributes (a bench's handles; P4b). */ attrs?: Record<`data-${string}`, string | undefined>; }; export const paperButtonVariants = cva( "inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-[3px] border px-[11px] py-[5px] text-[12.5px] font-medium transition-[color,background-color,border-color,text-decoration-color,fill,stroke] disabled:pointer-events-none disabled:opacity-50", { variants: { variant: { outline: "border-reader-2 text-reader-ink hover:border-reader-ink", go: "border-reader-signal bg-reader-signal font-semibold text-white", }, }, defaultVariants: { variant: "outline" }, }, ); export function ReaderPane({ source, byline, cite, note, cues, label = "Transcript", footer, fine, bodyProps, bare = false, onLight, global = false, className, children, ...props }: Omit, "children"> & { /** The source's title. */ source: React.ReactNode; /** channel · date · track, as nodes; joined with a middle dot. */ byline?: React.ReactNode[]; /** The cited second and the recording's length, for the thread. */ cite?: { at: number; duration: number }; /** A line under the header ("Speaker not identified"). */ note?: React.ReactNode; cues?: Cue[]; label?: string; footer?: React.ReactNode; /** The fine print under the actions: the citation in the house format. */ fine?: React.ReactNode; /** Instead of cues: anything else the source said (a post, a quote). */ children?: React.ReactNode; /** Onto the scrolling body (a bench's handle, its ref; P4b). */ bodyProps?: React.ComponentProps<"div"> & Record<`data-${string}`, string | undefined>; /** `children` as they are, without the reader-text column (a bench's own cue rows; P4b). */ bare?: boolean; /** The lit cue moved (a bench seeks its player to it; P4b). */ onLight?: (d: LitDetail) => void; /** `j`/`k` from anywhere on the page move the cues (the page's one list: a bench; P4b). */ global?: boolean; }) { const parts = (byline ?? []).filter(Boolean); return ( ); }