"use client"; import React, { useEffect, useRef } from "react"; import { TimingCue } from "@/lib/tts/types"; import { Clock, PlayCircle } from "lucide-react"; interface TranscriptViewerProps { timings: TimingCue[]; currentTime: number; onSeek: (time: number) => void; } export function TranscriptViewer({ timings, currentTime, onSeek, }: TranscriptViewerProps) { const activeRef = useRef(null); // Auto-scroll active cue into view smoothly useEffect(() => { if (activeRef.current) { activeRef.current.scrollIntoView({ behavior: "smooth", block: "nearest", }); } }, [currentTime]); const formatSeconds = (secs: number) => { const m = Math.floor(secs / 60); const s = Math.floor(secs % 60); return `${m.toString().padStart(2, "0")}:${s.toString().padStart(2, "0")}`; }; if (!timings || timings.length === 0) { return (

No synchronized transcript available for this episode.

); } return (
{timings.map((cue, idx) => { const isActive = currentTime >= cue.startTime && currentTime <= cue.endTime; return (
onSeek(cue.startTime)} className={`group flex items-start gap-3 p-3 rounded-lg cursor-pointer transition-all duration-200 border ${ isActive ? "bg-blue-950/40 border-blue-500/40 text-blue-100 shadow-sm" : "bg-slate-900/30 border-slate-800/60 hover:bg-slate-850 hover:border-slate-700 text-slate-300" }`} > {/* Timestamp badge */} {formatSeconds(cue.startTime)} {/* Cue text */}

{cue.text}

); })}
); }