import React from 'react' import { BezierEdge, BaseEdge } from 'reactflow' import { getSmartEdge } from '../getSmartEdge' import type { GetSmartEdgeOptions } from '../getSmartEdge' import type { EdgeProps, Node } from 'reactflow' export type EdgeElement = typeof BezierEdge export type SmartEdgeOptions = GetSmartEdgeOptions & { fallback?: EdgeElement } export interface SmartEdgeProps extends EdgeProps { nodes: Node[] options: SmartEdgeOptions } export function SmartEdge({ nodes, options, ...edgeProps }: SmartEdgeProps) { const { sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition, style, label, labelStyle, labelShowBg, labelBgStyle, labelBgPadding, labelBgBorderRadius, markerEnd, markerStart, interactionWidth } = edgeProps const smartResponse = getSmartEdge({ sourcePosition, targetPosition, sourceX, sourceY, targetX, targetY, options, nodes }) const FallbackEdge = options.fallback || BezierEdge if (smartResponse === null) { return } const { edgeCenterX, edgeCenterY, svgPathString } = smartResponse return ( ) } export type SmartEdgeFunction = typeof SmartEdge