"use client"; import { useEffect, useState } from "react"; import type { AiCityForecastPayload, AiCityForecastState, } from "@/components/dashboard/scan-terminal/types"; export function AiEvidencePanel({ aiBullets, aiCityForecast, aiForecast, aiReadCompleteText, aiReadInProgressText, aiRuleEvidenceMode, aiRuleEvidenceText, fallbackAiReason, isCompactCard, isEn, isHkoObservation, localModelSupportNote, localizedFinalJudgment, rawObservationText, }: { aiBullets: string[]; aiCityForecast: AiCityForecastPayload["city_forecast"] | null; aiForecast: AiCityForecastState; aiReadCompleteText: string; aiReadInProgressText: string; aiRuleEvidenceMode: boolean; aiRuleEvidenceText: string; fallbackAiReason: string; isCompactCard: boolean; isEn: boolean; isHkoObservation: boolean; localModelSupportNote: string; localizedFinalJudgment: string; rawObservationText: string; }) { const [isOpen, setIsOpen] = useState(() => !isCompactCard); useEffect(() => { setIsOpen(!isCompactCard); }, [isCompactCard]); return (
setIsOpen(event.currentTarget.open)} > {isHkoObservation ? isEn ? "Evidence · AI HKO observation read" : "证据 · AI 香港天文台观测解读" : isEn ? "Evidence · AI airport read" : "证据 · AI 机场报文解读"} {isOpen ? (
{aiForecast.status === "loading" ? ( <>

{aiReadInProgressText}

{localizedFinalJudgment || aiForecast.streamText ? (

{localizedFinalJudgment || aiForecast.streamText}

) : null}

{isEn ? isHkoObservation ? "Rule evidence is shown first; the full HKO AI read will merge automatically." : "Rule evidence is shown first; the full airport AI read will merge automatically." : isHkoObservation ? "先展示规则证据,完整香港天文台 AI 解读返回后会自动合并。" : "先展示规则证据,完整机场 AI 解读返回后会自动合并。"}

) : aiForecast.status === "ready" && aiCityForecast ? ( <>

{aiRuleEvidenceMode ? aiRuleEvidenceText : aiReadCompleteText}

{rawObservationText}

) : aiForecast.status === "ready" ? ( <>

{aiRuleEvidenceText}

) : aiForecast.status === "failed" ? ( <>

{aiRuleEvidenceText}

) : (

{isEn ? isHkoObservation ? "Waiting for AI to read the latest HKO observation." : "Waiting for AI to read the latest airport bulletin." : isHkoObservation ? "等待 AI 解读最新香港天文台观测。" : "等待 AI 解读最新机场报文。"}

)}
) : null}
); }