import {useEffect,useState} from 'react'; import type {Actor,ReviewEvent,ReviewQuestion,ScriptReview,SegmentView} from './contract.ts'; import {getJSON} from './api.ts'; import {actorStyle,shapePath} from './visual.ts'; import {adjacentEvent,arrangementList,entityScript,splitLine} from './script-aside.ts'; import {FactsPanel} from './FactsPanel.tsx'; import type {ScriptEvent} from './script-aside.ts'; import './script-aside.css'; const OP_LABELS:Record={fact:'读取事实',distance:'计算距离',divide:'相除',multiply:'相乘',identity:'取结果',add:'相加',subtract:'求差',sum:'求和'}; export type ProofDetail={candidate_id:string;decision:{result:string;remaining_margin?:number};proof:{nodes:{id:string;op:string;inputs?:string[];fact_id?:string}[];output:string}|null;facts:{fact_id:string;status:string;source_kind?:string;value?:unknown;error?:number;support_ref?:unknown}[]|null;replay:unknown;binding:unknown;world_span_s:number[]|null;scope:string}; export function QuestionPicker({review,selected,onSelect}:{review:ScriptReview;selected:string|null;onSelect:(q:ReviewQuestion|null)=>void}){ const [open,setOpen]=useState(false),[status,setStatus]=useState(''); const questions=review.questions.filter(q=>!status||q.decision===status); return
PASS {review.question_counts.PASS} · FAIL {review.question_counts.FAIL} · UNKNOWN {review.question_counts.UNKNOWN}{open&&
}
; } function Proof({question}:{question:ReviewQuestion}){ const [value,setValue]=useState(null),[error,setError]=useState(''); useEffect(()=>{setValue(null);setError('');const c=new AbortController();getJSON(question.proof_url,c.signal).then(setValue).catch(e=>{if(!c.signal.aborted)setError(String(e));});return()=>c.abort();},[question]); return

证明步骤 {question.decision}

{question.text}

{question.version_id}{error?

{error}

:!value?

读取原证明…

:<>

R13 原始计划模型结果;不是正式接收

{value.proof?.nodes?.length?
    {value.proof.nodes.map(node=>
  1. {node.id} · {OP_LABELS[node.op]||node.op}{node.fact_id?'读取 '+node.fact_id:(node.inputs||[]).join(' → ')}
  2. )}
:

没有证明步骤。

}
原始事实与重放结果
{JSON.stringify({facts:value.facts,replay:value.replay,decision:value.decision},null,2)}
}
; } function EntitySymbol({actor}: {actor: Actor}) { const {color,shape}=actorStyle(actor); return ; } const EVENT_STATUS:Record={effective:'生效',deviated:'偏了',ineffective:'没生效',NOT_CHECKED:'未检查'}; const timeSpan=(event:ReviewEvent)=>event.span_s ? event.span_s.map(t=>Number(t.toFixed(2))).join('–')+' s' : '时段无数据'; export function ScriptReviewPanel({view,review,selected,question,onSelect,onSeek}:{ view:Pick;review?:ScriptReview;selected:ReviewEvent|null; question:ReviewQuestion|null;onSelect:(event:ReviewEvent|null)=>void;onSeek:(time:number)=>void; }){ const [tab,setTab]=useState<'situations'|'script'|'facts'>('situations'),[entityId,setEntityId]=useState(view.actors[0]?.id||''); const actorId=view.actors.some(a=>a.id===entityId)?entityId:(view.actors[0]?.id||''); const [all,setAll]=useState(false),{groups,total,problems}=arrangementList(review,all); const events=groups.flatMap(group=>group.events),index=events.findIndex(event=>event.id===selected?.id); const script=entityScript(review,view.intents,actorId); const select=(event:ReviewEvent|null)=>{onSelect(event);if(event?.span_s)onSeek(event.span_s[0]);}; const eventRow=(event:ScriptEvent,isScript=false)=>; return
{question&&} {tab==='situations'?
{splitLine(view.observers)&&

{splitLine(view.observers)}

}

安排 {total} 条 · 没生效或偏了 {problems} 条{groups.length>0&&':'+groups.map(g=>g.label+' '+g.count).join(' · ')}

{events.length?groups.map(group=>

{group.label} · {group.count}

{group.events.map(event=>eventRow(event))}
):

{total&&!all?`${total} 条安排都生效了`:review?`本段没有安排情形:生成器没计划(planned ${review.planned.length} 条),证据层算出 ${review.situations.length} 段`:'本段没有安排情形数据:生成器计划与证据层均未提供。'}

} 证据层从轨迹算出,表示采样正支持;0 段不解释为真实不可见。{review?.situation_missing.join(';')} {review?.situation_source&&
情形计算来源{review.situation_source}
}
:tab==='facts'?:
{view.actors.map(actor=>)}

{actorId||'无主体'} · 共 {script.length} 段 · {review?'生成器安排':'原始意图'}

{script.length?script.map(event=>eventRow(event,true)):

{review?.actual_arrangements===null?'生成器未输出主体安排。':'该主体没有剧本记录。'}

}
} {selected&&
{selected.basis&&

{selected.basis}

}
}
; }