/** * WireRenderer — purely visual renderer for a single wire. * All interaction (click/hover/drag) is handled by SimulatorCanvas. */ import React from 'react'; import type { Wire } from '../../types/wire'; import { generateOrthogonalPath } from '../../utils/wireUtils'; interface WireRendererProps { wire: Wire; isSelected: boolean; isHovered: boolean; /** Temporary waypoints used during drag preview */ previewWaypoints?: { x: number; y: number }[]; /** Override the full SVG path string (used during segment drag preview) */ overridePath?: string; } export const WireRenderer: React.FC = ({ wire, isSelected, isHovered, previewWaypoints, overridePath, }) => { // Guard against null/undefined wire if (!wire || !wire.start || !wire.end) return null; const waypoints = previewWaypoints ?? wire.waypoints; const path = overridePath ?? generateOrthogonalPath(wire.start, waypoints, wire.end); if (!path) return null; const color = wire.color; const strokeW = isSelected ? 3 : 2; const outlineW = isSelected ? 6 : 5; const opacity = isSelected || isHovered ? 1 : 0.85; return ( {/* Dark outline for wire crossing effect */} {/* Hover highlight (below wire) */} {isHovered && !isSelected && ( )} {/* Visible wire */} {/* Selection dashed highlight */} {isSelected && ( )} {/* Endpoint dots */} {/* Waypoint dots */} {waypoints.map((wp, i) => ( ))} ); };