import React from "react"; interface InteractiveSystemSummaryProps { summary: string; onEntityClick: (id: string) => void; selectedNodeId?: string | null; } export const InteractiveSystemSummary: React.FC< InteractiveSystemSummaryProps > = ({ summary, onEntityClick, selectedNodeId }) => { const parseSummary = (text: string) => { const regex = /[`'‘]([^`'’]+)[`'’][^()]*\(([^)]+)\)/g; const parts = []; let lastIndex = 0; let match; while ((match = regex.exec(text)) !== null) { if (match.index > lastIndex) { parts.push(text.substring(lastIndex, match.index)); } const [fullMatch, name, id] = match; if (name && id) { const isSelected = selectedNodeId === id; parts.push( { e.preventDefault(); onEntityClick(id); }} > {name} ); } else { parts.push(fullMatch); } lastIndex = regex.lastIndex; } if (lastIndex < text.length) { parts.push(text.substring(lastIndex)); } return parts; }; return (

{parseSummary(summary)}

); };