| 265 | * @returns Normalized edge with only connection fields |
| 266 | */ |
| 267 | export function normalizeEdge(edge: Edge): NormalizedEdge { |
| 268 | const normalized: NormalizedEdge = { |
| 269 | source: edge.source, |
| 270 | target: edge.target, |
| 271 | } |
| 272 | // Only include handles if they have a non-null value |
| 273 | // This treats null and undefined as equivalent (both omitted) |
| 274 | if (edge.sourceHandle != null) { |
| 275 | normalized.sourceHandle = edge.sourceHandle |
| 276 | } |
| 277 | if (edge.targetHandle != null) { |
| 278 | normalized.targetHandle = edge.targetHandle |
| 279 | } |
| 280 | return normalized |
| 281 | } |
| 282 | |
| 283 | /** |
| 284 | * Sorts edges for consistent comparison |