import { useMemo } from 'react' import { ExplainHeader } from './ExplainVisualizer.Header' import { ExplainNodeRow } from './ExplainVisualizer.NodeRow' import { calculateMaxDuration, calculateSummary, createNodeTree } from './ExplainVisualizer.parser' import type { QueryPlanRow } from './ExplainVisualizer.types' export interface ExplainVisualizerProps { rows: readonly QueryPlanRow[] onShowRaw?: () => void id?: string } export function ExplainVisualizer({ rows, onShowRaw, id }: ExplainVisualizerProps) { const parsedTree = useMemo(() => createNodeTree(rows), [rows]) const maxDuration = useMemo(() => calculateMaxDuration(parsedTree), [parsedTree]) const summary = useMemo(() => calculateSummary(parsedTree), [parsedTree]) if (parsedTree.length === 0) { return (
No execution plan data available