import type { DecisionDetailBlock, InspectorPresentation, InspectorSemanticMeta, InspectorVisualRole } from "@/lib/types"; import { RichText } from "@/components/ui/RichText"; import { ChevronRight } from "lucide-react"; export function DecisionDetailRenderer({ blocks }: { blocks: DecisionDetailBlock[] }) { return
{blocks.map((block, index) => { if (block.type === "implementation-plan") return ; if (block.type === "creative-process") return ; if (block.type === "evaluation-branches") return ; if (block.type === "evaluation-matrix") return ; if (block.type === "comparison") return

{block.title}

; if (block.type === "items" && block.collapsible) return ; if (block.type === "items") return

{block.title}

; if (block.type === "notice") return

{block.title || "记录说明"}

; if (block.type === "artifact") return

{block.title}

    {block.refs.map((ref) =>
  • {ref.label}
  • )}
; return ; })}
; } type CreativeProcessBlock = Extract; function CreativeProcess({ block }: { block: CreativeProcessBlock }) { return

{block.title}

{block.steps.length} 个真实执行步骤

    {block.steps.map((step) =>
  1. 步骤 {String(step.stepIndex).padStart(2, "0")}{step.action}
    {step.summary && step.summary !== step.action ?

    {step.summary}

    : null} {step.plan ?
    执行计划
    : null} {step.reasoning ?
    : null}
  2. )}
; } type EvaluationBranchesBlock = Extract; function EvaluationBranches({ block }: { block: EvaluationBranchesBlock }) { return

{block.title}

{block.branches.map((branch) =>

{branch.subject}

{branch.conclusion ? {branch.conclusion} : null}
{branch.achievements?.length ? : null} {branch.problems?.length ? : null} {branch.evidence ?
有据扎实度
: null}
)}
; } function EvaluationList({ title, items, tone }: { title: string; items: string[]; tone: "success" | "warning" }) { return
{title}
    {items.map((item, index) =>
  • )}
; } type EvaluationMatrixBlock = Extract; function EvaluationMatrix({ block }: { block: EvaluationMatrixBlock }) { const subjects = block.rows[0]?.candidates.map((item) => item.subject) || []; return

{block.title}

{subjects.map((subject) => )}{block.rows.map((row) => {subjects.map((subject) => )})}
评审标准{subject}差异依据
{row.criterion}{row.candidates.find((item) => item.subject === subject)?.value || "未记录"}{row.basis || "未记录"}
; } type ImplementationPlanBlock = Extract; function ImplementationPlan({ block }: { block: ImplementationPlanBlock }) { return

{block.title}

{block.routes.length} 路实现方案

{block.mode ? {block.mode} : null}
    {block.routes.map((route) =>
  1. 路线 {route.pathIndex} {route.action ? {route.action} : null}{route.pathType ? {route.pathType} : null}
    {route.target ? : null} {route.method ? : null} {route.emphasis ? : null}
  2. )}
{block.reasoning ?

为什么这样规划

: null}
; } function PlanField({ label, value, wide = false }: { label: string; value: string; wide?: boolean }) { return
{label}
; } type ItemsBlock = Extract; function CollapsibleItems({ block }: { block: ItemsBlock }) { return
共 {block.items.length} 项
; } type SummaryDetailBlock = Extract; function SummaryBlock({ block }: { block: SummaryDetailBlock }) { const value = block.presentation === "document" ? normalizeDocumentMarkdown(block.value) : block.value; return

{block.title}

; } function normalizeDocumentMarkdown(value: string) { return value.replace(/\*\*(["“])([^"”\n]+)(["”])\*\*/g, "$1**$2**$3"); } function panelProps(meta: InspectorSemanticMeta, extraClass: string, fallbackRole: InspectorVisualRole, fallbackPresentation: InspectorPresentation) { const role = meta.visualRole || fallbackRole; return { className: ["inspectorPanel", extraClass, `is-role-${role}`].filter(Boolean).join(" "), "data-visual-role": role, "data-presentation": meta.presentation || fallbackPresentation, }; } function Items({ items }: { items: Array> }) { return
{items.map((item, index) => { if (typeof item === "string") return
{String(index + 1).padStart(2, "0")}
; const severity = item.severity ? String(item.severity) : undefined; const label = item.label ? String(item.label) : item.subject ? String(item.subject) : severity ? `问题 · ${severity}` : `项目 ${index + 1}`; const value = String(item.value || item.conclusion || item.summary || ""); const note = item.note ? String(item.note) : undefined; const achievements = stringList(item.achievements); const problems = stringList(item.problems); return
{label}
{value ? : null}{note ? {note} : null}{achievements.length ? : null}{problems.length ? : null}
; })}
; } function ReadableDecisionText({ value }: { value: string }) { return ; } function insertNumberedLineBreaks(value: string) { const markers = [...value.matchAll(/[ \t\u3000]+(\d+)\.(?=[ \t\u3000]+\S)/g)]; if (markers.length < 2) return value; const numbers = markers.map((match) => Number(match[1])); if (numbers[0] !== 1 || numbers.some((number, index) => index > 0 && number !== numbers[index - 1] + 1)) return value; let markerIndex = 0; return value.replace(/[ \t\u3000]+(\d+\.(?=[ \t\u3000]+\S))/g, (_match, marker: string) => `${markerIndex++ === 0 ? "\n\n" : "\n"}${marker}`); } function Comparison({ rows }: { rows: Array> }) { const showHandling = rows.some((row) => Boolean(row.handling)); return
候选方案评审建议最终决定{showHandling ? 对建议的处理 : null}
{rows.map((row, index) =>
{String(row.candidate || `方案 ${index + 1}`)}{String(row.recommendation || "未记录")}{String(row.finalDecision || "未记录")}{showHandling ? {String(row.handling || "未明确说明")} : null}
)}
; } function stringList(value: unknown): string[] { return Array.isArray(value) ? value.map((item) => typeof item === "string" ? item : String((item as Record)?.summary || "")).filter(Boolean) : []; } function NestedList({ title, items }: { title: string; items: string[] }) { return
{title}
    {items.map((item, index) =>
  • )}
; }