"use client"; import { GlassPanel } from "@/components/glass/panel"; import { cn } from "@/lib/utils"; interface AiAnalysisPanelProps { status?: string | null; severity?: string | null; confidence?: number | null; flags?: string[] | string | null; categories?: string[] | string | null; action?: string | null; score?: number | null; analysis?: string | null; } const severityColor: Record = { none: "text-emerald-500", low: "text-text-secondary", medium: "text-accent-amber", high: "text-accent-purple", critical: "text-destructive", }; export function AiAnalysisPanel({ status, severity, confidence, flags, categories, action, score, analysis, }: AiAnalysisPanelProps) { if (!status || status === "pending") { return ( AI analysis pending ); } const flagsArray = typeof flags === "string" ? (flags ? JSON.parse(flags) : []) : flags || []; const categoriesArray = typeof categories === "string" ? categories ? JSON.parse(categories) : [] : categories || []; return (
AI Analysis {status}
{severity && (
Severity: {severity}
)} {confidence !== null && confidence !== undefined && (
Confidence: {(confidence * 100).toFixed(0)}%
)} {score !== null && score !== undefined && (
Score: {score.toFixed(2)}
)} {flagsArray.length > 0 && (
{flagsArray.map((f: string) => ( {f} ))}
)} {categoriesArray.length > 0 && (
{categoriesArray.map((c: string) => ( {c} ))}
)} {analysis && (

{analysis}

)} {action && action !== "none" && (
Recommended: {action}
)}
); }