"use client"; import { useEffect, useRef, useState } from "react"; import type { ChoiceKey, RectificationChoiceCard as ChoiceCard, } from "@/lib/rectification-agentic/v9/choice-card"; type RectificationChoiceCardProps = Readonly<{ card: ChoiceCard; pending: boolean; disabled: boolean; selectedKey?: ChoiceKey | "stop" | ""; onSelect: (key: ChoiceKey) => void; onStop: () => void; }>; export function RectificationChoiceCard(props: RectificationChoiceCardProps) { const [localSelected, setLocalSelected] = useState(""); const selectedKey = props.selectedKey || localSelected; const firstChoiceRef = useRef(null); const answered = Boolean(selectedKey); useEffect(() => { if (props.pending || answered) return; firstChoiceRef.current?.focus(); }, [answered, props.card.question_id, props.pending]); function select(key: ChoiceKey) { if (props.pending || props.disabled || selectedKey) return; setLocalSelected(key); props.onSelect(key); } function stop() { if (props.pending || props.disabled || selectedKey) return; setLocalSelected("stop"); props.onStop(); } return (
{props.card.prompt} {props.card.why ?

{props.card.why}

: null}
{props.card.options.map((option, index) => ( ))}
); }