import { notFound } from "next/navigation"; import { NotesProvider } from "@/components/notes/NotesProvider"; import { projectsHref, reelPlayHref, reelWalkHref } from "@/lib/hrefs"; import type { ProjectRef } from "@/lib/project-types"; import { reelBenchData } from "@/lib/report/reelBenchData"; import { isTakeId } from "@/lib/report/takes.mjs"; import { DEFAULT_REEL, isReelId } from "@/lib/report/trailerBeats.mjs"; import { BenchFrame, BenchTop } from "../bench/BenchShell"; import ReelBench from "./ReelBench"; import { CHANGED_STATES } from "./reelTypes"; // `/projects//trailer/walk?reel=&take=&beat=` -- the // reel's editor over one beat, on the take's rendered master (ReelBench.tsx, // built from the clip bench's parts; lib/report/reelBenchData.ts its data). export default async function ReelWalkPage({ project, reel = DEFAULT_REEL, take, beat, changed = false, }: { project: ProjectRef; reel?: string; take?: string; beat?: string; /** Walk only the beats the take changed under the reel (reelAnchor.mjs). */ changed?: boolean; }) { const r = reel || DEFAULT_REEL; if (!isReelId(r) || (take && !isTakeId(take))) notFound(); const n = Number(beat) > 0 ? Math.floor(Number(beat)) : 1; const data = await reelBenchData(project, { reel: r, take: take || null, beat: n }); const view = data.view; const all = view.rows ?? []; // `changed`: the walk visits only the beats the take changed (the beat asked for is shown either way). const rows = changed ? all.filter((x) => x.n === n || (x.status && CHANGED_STATES.includes(x.status.state))) : all; const i = rows.findIndex((x) => x.n === n); const t = view.take?.id ?? null; return ( = 0 ? { index: i + 1, total: rows.length, of: changed ? "changed beats" : "beats" } : null} prev={i > 0 ? { href: reelWalkHref(project.id, { reel: r, take: t, beat: rows[i - 1].n, changed }), label: `beat ${rows[i - 1].n}` } : null} next={i >= 0 && i < rows.length - 1 ? { href: reelWalkHref(project.id, { reel: r, take: t, beat: rows[i + 1].n, changed }), label: `beat ${rows[i + 1].n}` } : null} note={view.take ? `take ${view.take.id} · ${rows.filter((x) => x.verdict === "confirmed").length} of ${rows.length} confirmed` : "no master"} /> } > ); }