{"version":3,"file":"index.umd.cjs","sources":["../src/types.ts","../src/layout/utils.ts","../src/layout/elkLayout.ts","../src/layout/useLayout.ts","../src/utils/useEdgeDrag.ts","../src/utils/useZoom.ts","../src/utils/CanvasProvider.tsx","../src/utils/helpers.ts","../src/utils/useNodeDrag.ts","../src/symbols/Port/Port.tsx","../src/symbols/Label/Label.tsx","../src/symbols/Remove/Remove.tsx","../src/symbols/Edge/utils.ts","../src/symbols/Add/Add.tsx","../src/symbols/Edge/Edge.tsx","../src/symbols/Node/Node.tsx","../src/symbols/Arrow/Arrow.tsx","../src/symbols/Arrow/MarkerArrow.tsx","../src/Canvas.tsx","../src/symbols/Icon/Icon.tsx","../src/helpers/crudHelpers.ts","../src/helpers/useSelection.ts","../src/helpers/useUndo.ts","../src/helpers/useProximity.ts","../src/helpers/graphHelpers.ts"],"sourcesContent":["import { ElkNodeLayoutOptions } from './layout';\n\nexport enum CanvasPosition {\n  CENTER = 'center',\n  TOP = 'top',\n  LEFT = 'left',\n  RIGHT = 'right',\n  BOTTOM = 'bottom'\n}\n\nexport interface NodeData<T = any> {\n  /**\n   * Unique ID for the node.\n   */\n  id: string;\n\n  /**\n   * Whether the node is disabled or not.\n   */\n  disabled?: boolean;\n\n  /**\n   * Text label for the node.\n   */\n  text?: any;\n\n  /**\n   * Optional height attribute. If not passed with calculate\n   * default sizes using text.\n   */\n  height?: number;\n\n  /**\n   * Optional width attribute. If not passed with calculate\n   * default sizes using text.\n   */\n  width?: number;\n\n  /**\n   * Parent node id for nesting.\n   */\n  parent?: string;\n\n  /**\n   * List of ports.\n   */\n  ports?: PortData[];\n\n  /**\n   * Icon for the node.\n   */\n  icon?: IconData;\n\n  /**\n   * Padding for the node.\n   */\n  nodePadding?: number | [number, number] | [number, number, number, number];\n\n  /**\n   * Data for the node.\n   */\n  data?: T;\n\n  /**\n   * CSS classname for the node.\n   */\n  className?: string;\n\n  /**\n   * ELK layout options.\n   */\n  layoutOptions?: ElkNodeLayoutOptions;\n\n  /**\n   * Whether the node can be clicked.\n   */\n  selectionDisabled?: boolean;\n}\n\nexport interface LayoutNodeData extends NodeData {\n  x: number;\n  y: number;\n  children?: LayoutNodeData[];\n}\n\nexport interface IconData {\n  /**\n   * URL for the icon.\n   */\n  url: string;\n\n  /**\n   * Height of the icon.\n   */\n  height: number;\n\n  /**\n   * Width of the icon.\n   */\n  width: number;\n}\n\nexport interface EdgeData<T = any> {\n  /**\n   * Unique ID of the edge.\n   */\n  id: string;\n\n  /**\n   * Whether the edge is disabled or not.\n   */\n  disabled?: boolean;\n\n  /**\n   * Text label for the edge.\n   */\n  text?: any;\n\n  /**\n   * ID of the from node.\n   */\n  from?: string;\n\n  /**\n   * ID of the to node.\n   */\n  to?: string;\n\n  /**\n   * Optional ID of the from port.\n   */\n  fromPort?: string;\n\n  /**\n   * Optional ID of the to port.\n   */\n  toPort?: string;\n\n  /**\n   * Data about the edge.\n   */\n  data?: T;\n\n  /**\n   * CSS class name for the edge (\"path\" element).\n   */\n  className?: string;\n\n  /**\n   * CSS class name for the edge (main \"g\" element).\n   */\n  containerClassName?: string;\n\n  /**\n   * Optional arrow head type.\n   */\n  arrowHeadType?: any;\n\n  /**\n   * Parent of the edge for nesting.\n   */\n  parent?: string;\n\n  /**\n   * Whether the edge can be clicked.\n   */\n  selectionDisabled?: boolean;\n}\n\nexport type PortSide = 'NORTH' | 'SOUTH' | 'EAST' | 'WEST';\n\nexport interface PortData {\n  /**\n   * Unique ID of the port.\n   */\n  id: string;\n\n  /**\n   * Port is disabled.\n   */\n  disabled?: boolean;\n\n  /**\n   * Height of the port.\n   */\n  height: number;\n\n  /**\n   * Width of the port.\n   */\n  width: number;\n\n  /**\n   * Whether the port is visually hidden or not.\n   */\n  hidden?: boolean;\n\n  /**\n   * Classname for the port.\n   */\n  className?: string;\n\n  /**\n   * Alignment of the port.\n   */\n  alignment?: 'CENTER';\n\n  /**\n   * Side the port is located.\n   */\n  side: PortSide;\n}\n","import calculateSize from 'calculate-size';\nimport { LayoutNodeData, NodeData } from '../types';\nimport ellipsize from 'ellipsize';\n\nconst MAX_CHAR_COUNT = 35;\nconst MIN_NODE_WIDTH = 50;\nconst DEFAULT_NODE_HEIGHT = 50;\nconst NODE_PADDING = 30;\nconst ICON_PADDING = 10;\n\nexport function measureText(text: string) {\n  let result = { height: 0, width: 0 };\n\n  if (text) {\n    // Reference: https://github.com/reaviz/reaflow/pull/229\n    // @ts-ignore\n    const fn = typeof calculateSize === 'function' ? calculateSize : calculateSize.default;\n    result = fn(text, {\n      font: 'Arial, sans-serif',\n      fontSize: '14px'\n    });\n  }\n\n  return result;\n}\n\nexport function parsePadding(padding: NodeData['nodePadding']) {\n  let top = 50;\n  let right = 50;\n  let bottom = 50;\n  let left = 50;\n\n  if (Array.isArray(padding)) {\n    if (padding.length === 2) {\n      top = padding[0];\n      bottom = padding[0];\n      left = padding[1];\n      right = padding[1];\n    } else if (padding.length === 4) {\n      top = padding[0];\n      right = padding[1];\n      bottom = padding[2];\n      left = padding[3];\n    }\n  } else if (padding !== undefined) {\n    top = padding;\n    right = padding;\n    bottom = padding;\n    left = padding;\n  }\n\n  return {\n    top,\n    right,\n    bottom,\n    left\n  };\n}\n\nexport function formatText(node: NodeData) {\n  const text = node.text ? ellipsize(node.text, MAX_CHAR_COUNT) : node.text;\n\n  const labelDim = measureText(text);\n  const nodePadding = parsePadding(node.nodePadding);\n\n  let width = node.width;\n  if (width === undefined) {\n    if (text && node.icon) {\n      width = labelDim.width + node.icon.width + NODE_PADDING + ICON_PADDING;\n    } else {\n      if (text) {\n        width = labelDim.width + NODE_PADDING;\n      } else if (node.icon) {\n        width = node.icon.width + NODE_PADDING;\n      }\n\n      width = Math.max(width, MIN_NODE_WIDTH);\n    }\n  }\n\n  let height = node.height;\n  if (height === undefined) {\n    if (text && node.icon) {\n      height = labelDim.height + node.icon.height;\n    } else if (text) {\n      height = labelDim.height + NODE_PADDING;\n    } else if (node.icon) {\n      height = node.icon.height + NODE_PADDING;\n    }\n\n    height = Math.max(height, DEFAULT_NODE_HEIGHT);\n  }\n\n  return {\n    text,\n    originalText: node.text,\n    width,\n    height,\n    nodePadding,\n    labelHeight: labelDim.height,\n    labelWidth: labelDim.width\n  };\n}\n\n/**\n * Finds a node in a tree of nodes\n * @param nodes - The nodes to search through\n * @param nodeId - The id of the node to find\n * @returns The node if found, undefined otherwise\n */\nexport const findNode = (nodes: LayoutNodeData[], nodeId: string): any | undefined => {\n  for (const node of nodes) {\n    if (node.id === nodeId) {\n      return node;\n    }\n    if (node.children) {\n      const foundNode = findNode(node.children, nodeId);\n      if (foundNode) {\n        return foundNode;\n      }\n    }\n  }\n  return undefined;\n};\n\n/**\n * Finds the number of nested children a node has\n * @param node - The node to search through\n * @returns The number of children\n */\nexport const getChildCount = (node: LayoutNodeData): number => {\n  return (\n    node.children?.reduce((acc, child) => {\n      if (child.children) {\n        return acc + 1 + getChildCount(child);\n      }\n      return acc + 1;\n    }, 0) ?? 0\n  );\n};\n\n/**\n * Calculates the zoom for a group of nodes when fitting to the viewport\n * @param nodes - The nodes to calculate the zoom for\n * @param viewportWidth - The width of the viewport\n * @param viewportHeight - The height of the viewport\n * @param maxViewportCoverage - The maximum percentage of the viewport that the node group will take up\n * @param minViewportCoverage - The minimum percentage of the viewport that the node group will take up\n * @returns The zoom\n */\nexport const calculateZoom = ({ nodes, viewportWidth, viewportHeight, maxViewportCoverage = 0.9, minViewportCoverage = 0.2 }: { nodes: LayoutNodeData[]; viewportWidth: number; viewportHeight: number; maxViewportCoverage?: number; minViewportCoverage?: number }) => {\n  const maxChildren = Math.max(\n    0,\n    nodes.map(getChildCount).reduce((acc, curr) => acc + curr, 0)\n  );\n  const boundingBox = getNodesBoundingBox(nodes);\n  const boundingBoxWidth = boundingBox.x1 - boundingBox.x0;\n  const boundingBoxHeight = boundingBox.y1 - boundingBox.y0;\n\n  // calculate the maximum zoom to ensure no single node takes up more than 20% of the viewport\n  const maxNodeWidth = Math.max(...nodes.map((node) => node.width));\n  const maxNodeHeight = Math.max(...nodes.map((node) => node.height));\n  // if a node has children, let it take up an extra 10% per child\n  const maxNodeZoomX = ((0.2 + maxChildren * 0.1) * viewportWidth) / maxNodeWidth;\n  const maxNodeZoomY = ((0.2 + maxChildren * 0.1) * viewportHeight) / maxNodeHeight;\n  const maxNodeZoom = Math.min(maxNodeZoomX, maxNodeZoomY);\n\n  const viewportCoverage = Math.max(Math.min(maxViewportCoverage, maxNodeZoom), minViewportCoverage);\n\n  const updatedHorizontalZoom = (viewportCoverage * viewportWidth) / boundingBoxWidth;\n  const updatedVerticalZoom = (viewportCoverage * viewportHeight) / boundingBoxHeight;\n  const updatedZoom = Math.min(updatedHorizontalZoom, updatedVerticalZoom, maxNodeZoom);\n\n  return updatedZoom;\n};\n\n/**\n * Calculates the scroll position for the canvas when fitting nodes to the viewport - assumes the chart is centered\n * @param nodes - The nodes to calculate the zoom and position for\n * @param viewportWidth - The width of the viewport\n * @param viewportHeight - The height of the viewport\n * @param canvasWidth - The width of the canvas\n * @param canvasHeight - The height of the canvas\n * @param chartWidth - The width of the chart\n * @param chartHeight - The height of the chart\n * @param zoom - The zoom level of the canvas\n * @returns The scroll position\n */\nexport const calculateScrollPosition = ({ nodes, viewportWidth, viewportHeight, canvasWidth, canvasHeight, chartWidth, chartHeight, zoom }: { nodes: LayoutNodeData[]; viewportWidth: number; viewportHeight: number; canvasWidth: number; canvasHeight: number; chartWidth: number; chartHeight: number; zoom: number }): [number, number] => {\n  const { x0, y0, x1, y1 } = getNodesBoundingBox(nodes);\n  const boundingBoxWidth = (x1 - x0) * zoom;\n  const boundingBoxHeight = (y1 - y0) * zoom;\n\n  // the chart is centered so we can assume the x and y positions\n  const chartPosition = {\n    x: (canvasWidth - chartWidth * zoom) / 2,\n    y: (canvasHeight - chartHeight * zoom) / 2\n  };\n\n  const boxXPosition = chartPosition.x + x0 * zoom;\n  const boxYPosition = chartPosition.y + y0 * zoom;\n\n  const boxCenterXPosition = boxXPosition + boundingBoxWidth / 2;\n  const boxCenterYPosition = boxYPosition + boundingBoxHeight / 2;\n\n  // scroll to the spot that centers the node in the viewport\n  const scrollX = boxCenterXPosition - viewportWidth / 2;\n  const scrollY = boxCenterYPosition - viewportHeight / 2;\n\n  return [scrollX, scrollY];\n};\n\n/**\n * Calculates the bounding box of a group of nodes\n * @param nodes - The nodes to calculate the bounding box for\n * @returns The bounding box\n */\nexport const getNodesBoundingBox = (nodes: LayoutNodeData[]) => {\n  return nodes.reduce(\n    (acc, node) => ({\n      x0: Math.min(acc.x0, node.x),\n      y0: Math.min(acc.y0, node.y),\n      x1: Math.max(acc.x1, node.x + node.width),\n      y1: Math.max(acc.y1, node.y + node.height)\n    }),\n    { x0: nodes[0].x, y0: nodes[0].y, x1: nodes[0].x + nodes[0].width, y1: nodes[0].y + nodes[0].height }\n  );\n};\n","import { EdgeData, NodeData } from '../types';\nimport ELK, { ElkNode } from 'elkjs/lib/elk.bundled.js';\nimport PCancelable from 'p-cancelable';\nimport { formatText, measureText } from './utils';\n\nexport type CanvasDirection = 'LEFT' | 'RIGHT' | 'DOWN' | 'UP';\n\n/**\n * ELKjs layout options for the Canvas.\n *\n * Unfortunately, the ELKjs documentation is not straightforward.\n * You'll likely need to take a look at the ELK options reference to see all available options.\n *\n * @see https://github.com/kieler/elkjs#layout-options\n * @see https://www.eclipse.org/elk/reference/options.html\n */\nexport interface ElkCanvasLayoutOptions {\n  'elk.direction'?: CanvasDirection;\n  [key: string]: string;\n}\n\n/**\n * ELKjs layout option for a node.\n *\n * TODO add reference link, I don't know what are the available options.\n *\n * @see https://www.eclipse.org/elk/reference/options.html\n */\nexport interface ElkNodeLayoutOptions {\n  [key: string]: string;\n\n  /**\n   * @example [left=12, top=12, right=12, bottom=12]\n   * @see https://www.eclipse.org/elk/reference/options/org-eclipse-elk-padding.html\n   */\n  'elk.padding': string;\n\n  /**\n   * @see https://www.eclipse.org/elk/reference/options/org-eclipse-elk-portConstraints.html\n   */\n  portConstraints: 'UNDEFINED' | 'FREE' | 'FIXED_SIDE' | 'FIXED_ORDER' | 'FIXED_RATIO' | 'FIXED_POS';\n}\n\n/**\n * ELK layout options applied by default, unless overridden through <Canvas layoutOptions> property.\n *\n * XXX Not to be confounded with ELK \"defaultLayoutOptions\" property, which is meant to be used as fallback, when no layout option is provided.\n *\n * @see https://www.eclipse.org/elk/reference/options.html\n */\nconst defaultLayoutOptions: ElkCanvasLayoutOptions = {\n  /**\n   * Hints for where node labels are to be placed; if empty, the node label’s position is not modified.\n   *\n   * @see https://www.eclipse.org/elk/reference/options/org-eclipse-elk-nodeLabels-placement.html\n   */\n  'elk.nodeLabels.placement': 'INSIDE V_CENTER H_RIGHT',\n\n  /**\n   * Select a specific layout algorithm.\n   *\n   * Uses \"layered\" strategy.\n   * It emphasizes the direction of edges by pointing as many edges as possible into the same direction.\n   * The nodes are arranged in layers, which are sometimes called “hierarchies”,\n   * and then reordered such that the number of edge crossings is minimized.\n   * Afterwards, concrete coordinates are computed for the nodes and edge bend points.\n   *\n   * @see https://www.eclipse.org/elk/reference/algorithms.html\n   * @see https://www.eclipse.org/elk/reference/options/org-eclipse-elk-algorithm.html\n   * @see https://www.eclipse.org/elk/reference/algorithms/org-eclipse-elk-layered.html\n   */\n  'elk.algorithm': 'org.eclipse.elk.layered',\n\n  /**\n   * Overall direction of edges: horizontal (right / left) or vertical (down / up).\n   *\n   * @see https://www.eclipse.org/elk/reference/options/org-eclipse-elk-direction.html\n   */\n  'elk.direction': 'DOWN',\n\n  /**\n   * The node order given by the model does not change to produce a better layout.\n   * E.g. if node A is before node B in the model this is not changed during crossing minimization.\n   * This assumes that the node model order is already respected before crossing minimization. This\n   * can be achieved by setting considerModelOrder.strategy to NODES_AND_EDGES.\n   *\n   * @see https://eclipse.dev/elk/reference/options/org-eclipse-elk-layered-crossingMinimization-forceNodeModelOrder.html\n   */\n  'layered.crossingMinimization.forceNodeModelOrder': 'true',\n\n  /**\n   * Strategy for node layering.\n   *\n   * @see https://www.eclipse.org/elk/reference/options/org-eclipse-elk-layered-layering-strategy.html\n   */\n  'org.eclipse.elk.layered.layering.strategy': 'INTERACTIVE',\n\n  /**\n   * What kind of edge routing style should be applied for the content of a parent node.\n   * Algorithms may also set this option to single edges in order to mark them as splines.\n   * The bend point list of edges with this option set to SPLINES\n   * must be interpreted as control points for a piecewise cubic spline.\n   *\n   * @see https://www.eclipse.org/elk/reference/options/org-eclipse-elk-edgeRouting.html\n   */\n  'org.eclipse.elk.edgeRouting': 'ORTHOGONAL',\n\n  /**\n   * Adds bend points even if an edge does not change direction.\n   * If true, each long edge dummy will contribute a bend point to its edges\n   * and hierarchy-crossing edges will always get a bend point where they cross hierarchy boundaries.\n   * By default, bend points are only added where an edge changes direction.\n   *\n   * @see https://www.eclipse.org/elk/reference/options/org-eclipse-elk-layered-unnecessaryBendpoints.html\n   */\n  'elk.layered.unnecessaryBendpoints': 'true',\n\n  /**\n   * The spacing to be preserved between nodes and edges that are routed next to the node’s layer.\n   * For the spacing between nodes and edges that cross the node’s layer ‘spacing.edgeNode’ is used.\n   *\n   * @see https://www.eclipse.org/elk/reference/options/org-eclipse-elk-layered-spacing-edgeNodeBetweenLayers.html\n   */\n  'elk.layered.spacing.edgeNodeBetweenLayers': '50',\n\n  /**\n   * Tells the BK node placer to use a certain alignment (out of its four)\n   * instead of the one producing the smallest height, or the combination of all four.\n   *\n   * @see https://www.eclipse.org/elk/reference/options/org-eclipse-elk-layered-nodePlacement-bk-fixedAlignment.html\n   */\n  'org.eclipse.elk.layered.nodePlacement.bk.fixedAlignment': 'BALANCED',\n\n  /**\n   * Strategy for cycle breaking.\n   *\n   * Cycle breaking looks for cycles in the graph and determines which edges to reverse to break the cycles.\n   * Reversed edges will end up pointing to the opposite direction of regular edges\n   * (that is, reversed edges will point left if edges usually point right).\n   *\n   * @see https://www.eclipse.org/elk/reference/options/org-eclipse-elk-layered-cycleBreaking-strategy.html\n   */\n  'org.eclipse.elk.layered.cycleBreaking.strategy': 'DEPTH_FIRST',\n\n  /**\n   * Whether this node allows to route self loops inside of it instead of around it.\n   *\n   * If set to true, this will make the node a compound node if it isn’t already,\n   * and will require the layout algorithm to support compound nodes with hierarchical ports.\n   *\n   * @see https://www.eclipse.org/elk/reference/options/org-eclipse-elk-insideSelfLoops-activate.html\n   */\n  'org.eclipse.elk.insideSelfLoops.activate': 'true',\n\n  /**\n   * Whether each connected component should be processed separately.\n   *\n   * @see https://www.eclipse.org/elk/reference/options/org-eclipse-elk-separateConnectedComponents.html\n   */\n  separateConnectedComponents: 'false',\n\n  /**\n   * Spacing to be preserved between pairs of connected components.\n   * This option is only relevant if ‘separateConnectedComponents’ is activated.\n   *\n   * @see https://www.eclipse.org/elk/reference/options/org-eclipse-elk-spacing-componentComponent.html\n   */\n  'spacing.componentComponent': '70',\n\n  /**\n   * TODO: Should be spacing.baseValue?\n   * An optional base value for all other layout options of the ‘spacing’ group.\n   * It can be used to conveniently alter the overall ‘spaciousness’ of the drawing.\n   * Whenever an explicit value is set for the other layout options, this base value will have no effect.\n   * The base value is not inherited, i.e. it must be set for each hierarchical node.\n   *\n   * @see https://www.eclipse.org/elk/reference/groups/org-eclipse-elk-layered-spacing.html\n   */\n  spacing: '75',\n\n  /**\n   * The spacing to be preserved between any pair of nodes of two adjacent layers.\n   * Note that ‘spacing.nodeNode’ is used for the spacing between nodes within the layer itself.\n   *\n   * @see https://www.eclipse.org/elk/reference/options/org-eclipse-elk-layered-spacing-nodeNodeBetweenLayers.html\n   */\n  'spacing.nodeNodeBetweenLayers': '70'\n};\n\nfunction mapNode(nodes: NodeData[], edges: EdgeData[], node: NodeData) {\n  const { text, width, height, labelHeight, labelWidth, nodePadding, originalText } = formatText(node);\n\n  const children = nodes.filter((n) => n.parent === node.id).map((n) => mapNode(nodes, edges, n));\n\n  const childEdges = edges.filter((e) => e.parent === node.id).map((e) => mapEdge({ edge: e }));\n\n  const nodeLayoutOptions: ElkNodeLayoutOptions = {\n    'elk.padding': `[left=${nodePadding.left}, top=${nodePadding.top}, right=${nodePadding.right}, bottom=${nodePadding.bottom}]`,\n    portConstraints: 'FIXED_ORDER',\n    ...(node.layoutOptions || {})\n  };\n\n  return {\n    id: node.id,\n    height,\n    width,\n    children,\n    edges: childEdges,\n    ports: node.ports\n      ? node.ports.map((port) => ({\n        id: port.id,\n        properties: {\n          ...port,\n          'port.side': port.side,\n          'port.alignment': port.alignment || 'CENTER'\n        }\n      }))\n      : [],\n    layoutOptions: nodeLayoutOptions,\n    properties: {\n      ...node\n    },\n    labels: text\n      ? [\n        {\n          width: labelWidth,\n          height: -(labelHeight / 2),\n          text,\n          originalText\n          // layoutOptions: { 'elk.nodeLabels.placement': 'INSIDE V_CENTER H_CENTER' }\n        }\n      ]\n      : []\n  };\n}\n\nfunction mapEdge({ edge: { data, ...edge }, direction }: { edge: EdgeData; direction?: CanvasDirection }) {\n  const labelDim = measureText(edge.text);\n  const validEdgeData = data ? { data } : {};\n  let labelWidth = labelDim.width / 2;\n\n  if (direction === 'LEFT' || direction === 'RIGHT') {\n    labelWidth = labelDim.width;\n  }\n\n  return {\n    id: edge.id,\n    source: edge.from,\n    target: edge.to,\n    properties: {\n      ...edge\n    },\n    ...validEdgeData,\n    sourcePort: edge.fromPort,\n    targetPort: edge.toPort,\n    labels: edge.text\n      ? [\n        {\n          width: labelWidth,\n          height: -(labelDim.height / 2),\n          text: edge.text,\n          layoutOptions: {\n            'elk.edgeLabels.placement': 'INSIDE V_CENTER H_CENTER'\n          }\n        }\n      ]\n      : []\n  };\n}\n\nfunction mapInput({ nodes, edges, direction }: { nodes: NodeData[]; edges: EdgeData[]; direction?: CanvasDirection }) {\n  const children = [];\n  const mappedEdges = [];\n\n  for (const node of nodes) {\n    if (!node.parent) {\n      const mappedNode = mapNode(nodes, edges, node);\n      if (mappedNode !== null) {\n        children.push(mappedNode);\n      }\n    }\n  }\n\n  for (const edge of edges) {\n    if (!edge.parent) {\n      const mappedEdge = mapEdge({ edge, direction });\n      if (mappedEdge !== null) {\n        mappedEdges.push(mappedEdge);\n      }\n    }\n  }\n\n  return {\n    children,\n    edges: mappedEdges\n  };\n}\n\nfunction postProcessNode(nodes: any[]): any[] {\n  for (const node of nodes) {\n    const hasLabels = node.labels?.length > 0;\n\n    if (hasLabels && node.properties.icon) {\n      const [label] = node.labels;\n      label.x = node.properties.icon.width + 25;\n      node.properties.icon.x = 25;\n      node.properties.icon.y = node.height / 2;\n    } else if (hasLabels) {\n      const [label] = node.labels;\n      label.x = (node.width - label.width) / 2;\n    } else if (node.properties.icon) {\n      node.properties.icon.x = node.width / 2;\n      node.properties.icon.y = node.height / 2;\n    }\n\n    if (node.children) {\n      postProcessNode(node.children);\n    }\n  }\n\n  return nodes;\n}\n\nexport const elkLayout = (nodes: NodeData[], edges: EdgeData[], options: ElkCanvasLayoutOptions) => {\n  const graph = new ELK();\n  const layoutOptions: ElkCanvasLayoutOptions = {\n    ...defaultLayoutOptions,\n    ...options\n  };\n\n  return new PCancelable<ElkNode>((resolve, reject) => {\n    graph\n      .layout(\n        {\n          id: 'root',\n          ...mapInput({ nodes, edges, direction: layoutOptions?.['elk.direction'] })\n        },\n        {\n          layoutOptions: layoutOptions\n        }\n      )\n      .then((data) => {\n        resolve({\n          ...data,\n          children: postProcessNode(data.children)\n        });\n      })\n      .catch(reject);\n  });\n};\n","import { RefObject, useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport useDimensions from 'react-cool-dimensions';\nimport isEqual from 'react-fast-compare';\nimport { CanvasPosition, EdgeData, NodeData } from '../types';\nimport { CanvasDirection, ElkCanvasLayoutOptions, elkLayout } from './elkLayout';\nimport { calculateScrollPosition, calculateZoom, findNode } from './utils';\n\nexport interface ElkRoot {\n  x?: number;\n  y?: number;\n  width?: number;\n  height?: number;\n  children?: any[];\n  edges?: any[];\n  direction?: CanvasDirection;\n}\n\nexport interface LayoutProps {\n  maxHeight: number;\n  maxWidth: number;\n  nodes: NodeData[];\n  edges: EdgeData[];\n  pannable: boolean;\n  defaultPosition: CanvasPosition;\n  fit: boolean;\n  zoom: number;\n  layoutOptions?: ElkCanvasLayoutOptions;\n  direction: CanvasDirection;\n  setZoom: (factor: number) => void;\n  onLayoutChange: (layout: ElkRoot) => void;\n}\n\nexport interface LayoutResult {\n  /**\n   * X/Y offset.\n   */\n  xy: [number, number];\n\n  /**\n   * Scroll offset.\n   */\n  scrollXY: [number, number];\n\n  /**\n   * ELK Layout object.\n   */\n  layout: ElkRoot;\n\n  /**\n   * Ref to container div.\n   */\n  containerRef: RefObject<HTMLDivElement | null>;\n\n  /**\n   * Height of the svg.\n   */\n  canvasHeight?: number;\n\n  /**\n   * Width of the svg.\n   */\n  canvasWidth?: number;\n\n  /**\n   * Width of the container div.\n   */\n  containerWidth?: number;\n\n  /**\n   * Height of the container div.\n   */\n  containerHeight?: number;\n\n  /**\n   * Positions the canvas to the viewport.\n   */\n  positionCanvas?: (position: CanvasPosition, animated?: boolean) => void;\n\n  /**\n   * Fit the canvas to the viewport.\n   */\n  fitCanvas?: (animated?: boolean) => void;\n\n  /**\n   * Fit a group of nodes to the viewport.\n   */\n  fitNodes?: (nodeIds: string | string[], animated?: boolean) => void;\n\n  /**\n   * Scroll to X/Y\n   */\n  setScrollXY?: (xy: [number, number], animated?: boolean) => void;\n\n  observe: (el: HTMLDivElement) => void;\n}\n\nexport const useLayout = ({ maxWidth, maxHeight, nodes = [], edges = [], fit, pannable, defaultPosition, direction, layoutOptions = {}, zoom, setZoom, onLayoutChange }: LayoutProps) => {\n  const scrolled = useRef<boolean>(false);\n  const ref = useRef<HTMLDivElement>();\n  const { observe, width, height } = useDimensions<HTMLDivElement>();\n  const [layout, setLayout] = useState<ElkRoot | null>(null);\n  const [xy, setXY] = useState<[number, number]>([0, 0]);\n  const [scrollXY, setScrollXY] = useState<[number, number]>([0, 0]);\n  const canvasHeight = pannable ? maxHeight : height;\n  const canvasWidth = pannable ? maxWidth : width;\n\n  const scrollToXY = (xy: [number, number], animated = false) => {\n    ref.current.scrollTo({ left: xy[0], top: xy[1], behavior: animated ? 'smooth' : 'auto' });\n    setScrollXY(xy);\n  };\n\n  useEffect(() => {\n    const promise = elkLayout(nodes, edges, {\n      'elk.direction': direction,\n      ...layoutOptions\n    });\n\n    promise\n      .then((result) => {\n        if (!isEqual(layout, result)) {\n          setLayout(result);\n          onLayoutChange(result);\n        }\n      })\n      .catch((err) => {\n        if (err.name !== 'CancelError') {\n          console.error('Layout Error:', err);\n        }\n      });\n\n    return () => promise.cancel();\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [nodes, edges]);\n\n  const positionVector = useCallback(\n    (position: CanvasPosition) => {\n      if (layout) {\n        const centerX = (canvasWidth - layout.width * zoom) / 2;\n        const centerY = (canvasHeight - layout.height * zoom) / 2;\n        switch (position) {\n          case CanvasPosition.CENTER:\n            setXY([centerX, centerY]);\n            break;\n          case CanvasPosition.TOP:\n            setXY([centerX, 0]);\n            break;\n          case CanvasPosition.LEFT:\n            setXY([0, centerY]);\n            break;\n          case CanvasPosition.RIGHT:\n            setXY([canvasWidth - layout.width * zoom, centerY]);\n            break;\n          case CanvasPosition.BOTTOM:\n            setXY([centerX, canvasHeight - layout.height * zoom]);\n            break;\n        }\n      }\n    },\n    [canvasWidth, canvasHeight, layout, zoom]\n  );\n\n  const positionScroll = useCallback(\n    (position: CanvasPosition, animated = false) => {\n      const scrollCenterX = (canvasWidth - width) / 2;\n      const scrollCenterY = (canvasHeight - height) / 2;\n      if (pannable) {\n        switch (position) {\n          case CanvasPosition.CENTER:\n            scrollToXY([scrollCenterX, scrollCenterY], animated);\n            break;\n          case CanvasPosition.TOP:\n            scrollToXY([scrollCenterX, 0], animated);\n            break;\n          case CanvasPosition.LEFT:\n            scrollToXY([0, scrollCenterY], animated);\n            break;\n          case CanvasPosition.RIGHT:\n            scrollToXY([canvasWidth - width, scrollCenterY], animated);\n            break;\n          case CanvasPosition.BOTTOM:\n            scrollToXY([scrollCenterX, canvasHeight - height], animated);\n            break;\n        }\n      }\n    },\n    [canvasWidth, canvasHeight, width, height, pannable]\n  );\n\n  const positionCanvas = useCallback(\n    (position: CanvasPosition, animated = false) => {\n      positionVector(position);\n      positionScroll(position, animated);\n    },\n    [positionScroll, positionVector]\n  );\n\n  useEffect(() => {\n    if (scrolled.current && defaultPosition) {\n      positionVector(defaultPosition);\n    }\n  }, [positionVector, zoom, defaultPosition]);\n\n  const fitCanvas = useCallback(\n    (animated = false) => {\n      if (layout) {\n        const heightZoom = height / layout.height;\n        const widthZoom = width / layout.width;\n        const scale = Math.min(heightZoom, widthZoom, 1);\n        setZoom(scale - 1);\n        positionCanvas(CanvasPosition.CENTER, animated);\n      }\n    },\n    [height, layout, width, setZoom, positionCanvas]\n  );\n\n  /**\n   * This centers the chart on the canvas, zooms in to fit the specified nodes, and scrolls to center the nodes in the viewport\n   */\n  const fitNodes = useCallback(\n    (nodeIds: string | string[], animated = true) => {\n      if (layout && layout.children) {\n        const nodes = Array.isArray(nodeIds) ? nodeIds.map((nodeId) => findNode(layout.children, nodeId)) : [findNode(layout.children, nodeIds)];\n\n        if (nodes) {\n          // center the chart\n          positionVector(CanvasPosition.CENTER);\n\n          const updatedZoom = calculateZoom({ nodes, viewportWidth: width, viewportHeight: height, maxViewportCoverage: 0.9, minViewportCoverage: 0.2 });\n          const scrollPosition = calculateScrollPosition({ nodes, viewportWidth: width, viewportHeight: height, canvasWidth, canvasHeight, chartWidth: layout.width, chartHeight: layout.height, zoom: updatedZoom });\n\n          setZoom(updatedZoom - 1);\n          scrollToXY(scrollPosition, animated);\n        }\n      }\n    },\n    [canvasHeight, canvasWidth, height, layout, positionVector, setZoom, width]\n  );\n\n  useLayoutEffect(() => {\n    const scroller = ref.current;\n    if (scroller && !scrolled.current && layout && height && width) {\n      if (fit) {\n        fitCanvas();\n      } else if (defaultPosition) {\n        positionCanvas(defaultPosition);\n      }\n\n      scrolled.current = true;\n    }\n  }, [canvasWidth, pannable, canvasHeight, layout, height, fit, width, defaultPosition, positionCanvas, fitCanvas, ref]);\n\n  useLayoutEffect(() => {\n    function onResize() {\n      if (fit) {\n        fitCanvas();\n      } else if (defaultPosition) {\n        positionCanvas(defaultPosition);\n      }\n    }\n\n    window.addEventListener('resize', onResize);\n\n    return () => window.removeEventListener('resize', onResize);\n  }, [fit, positionCanvas, defaultPosition, fitCanvas]);\n\n  return {\n    xy,\n    observe,\n    containerRef: ref,\n    canvasHeight,\n    canvasWidth,\n    containerWidth: width,\n    containerHeight: height,\n    layout,\n    scrollXY,\n    positionCanvas,\n    fitCanvas,\n    fitNodes,\n    setScrollXY: scrollToXY\n  } as LayoutResult;\n};\n","import React, { useCallback, useState } from 'react';\nimport { EdgeSections } from '../symbols/Edge';\nimport { NodeData, PortData } from '../types';\nimport { DragEvent, NodeDragEvents, Position } from './useNodeDrag';\nimport { Point2D } from 'kld-affine';\nimport { NodeDragType } from '../symbols/Node';\n\nexport interface EdgeDragResult extends NodeDragEvents {\n  dragCoords: EdgeSections[] | null;\n  canLinkNode: boolean | null;\n  dragNode: NodeData | null;\n  dragPort: PortData | null;\n  enteredNode: NodeData | null;\n  onEnter?: (\n    event: React.MouseEvent<SVGGElement, MouseEvent>,\n    data: NodeData | PortData\n  ) => void;\n  onLeave?: (\n    event: React.MouseEvent<SVGGElement, MouseEvent>,\n    data: NodeData | PortData\n  ) => void;\n}\n\nexport const useEdgeDrag = ({\n  onNodeLink,\n  onNodeLinkCheck\n}): EdgeDragResult => {\n  const [dragNode, setDragNode] = useState<NodeData | null>(null);\n  const [dragPort, setDragPort] = useState<PortData | null>(null);\n  const [dragType, setDragType] = useState<NodeDragType | null>(null);\n  const [enteredNode, setEnteredNode] = useState<NodeData | null>(null);\n  const [dragCoords, setDragCoords] = useState<EdgeSections[] | null>(null);\n  const [canLinkNode, setCanLinkNode] = useState<boolean | null>(null);\n\n  const onDragStart = useCallback(\n    (state: DragEvent, _initial: Position, node: NodeData, port?: PortData) => {\n      setDragType(state.dragType);\n      setDragNode(node);\n      setDragPort(port);\n    },\n    []\n  );\n\n  const onDrag = useCallback(\n    ({ memo: [matrix], xy: [x, y] }: DragEvent, [ix, iy]: Position) => {\n      const endPoint = new Point2D(x, y).transform(matrix);\n      setDragCoords([\n        {\n          startPoint: {\n            x: ix,\n            y: iy\n          },\n          endPoint\n        }\n      ]);\n    },\n    []\n  );\n\n  const onDragEnd = useCallback(\n    (event: DragEvent) => {\n      if (dragNode && enteredNode && canLinkNode) {\n        onNodeLink(event, dragNode, enteredNode, dragPort);\n      }\n\n      setDragNode(null);\n      setDragPort(null);\n      setEnteredNode(null);\n      setDragCoords(null);\n    },\n    [canLinkNode, dragNode, dragPort, enteredNode, onNodeLink]\n  );\n\n  const onEnter = useCallback(\n    (event: React.MouseEvent<SVGGElement, MouseEvent>, node: NodeData) => {\n      if (dragNode && node) {\n        setEnteredNode(node);\n        const canLink = onNodeLinkCheck(event, dragNode, node, dragPort);\n        const result =\n          (canLink === undefined || canLink) &&\n          (dragNode.parent === node.parent || dragType === 'node');\n\n        setCanLinkNode(result);\n      }\n    },\n    [dragNode, dragPort, dragType, onNodeLinkCheck]\n  );\n\n  const onLeave = useCallback(\n    (event: React.MouseEvent<SVGGElement, MouseEvent>, node: NodeData) => {\n      if (dragNode && node) {\n        setEnteredNode(null);\n        setCanLinkNode(null);\n      }\n    },\n    [dragNode]\n  );\n\n  return {\n    dragCoords,\n    canLinkNode,\n    dragNode,\n    dragPort,\n    enteredNode,\n    onDragStart,\n    onDrag,\n    onDragEnd,\n    onEnter,\n    onLeave\n  };\n};\n","import { RefObject, useCallback, useRef, useState } from 'react';\nimport { useGesture } from 'react-use-gesture';\n\nconst limit = (scale: number, min: number, max: number) => (scale < max ? (scale > min ? scale : min) : max);\n\nexport interface ZoomProps {\n  disabled?: boolean;\n  zoom?: number;\n  minZoom?: number;\n  maxZoom?: number;\n  onZoomChange: (zoom: number) => void;\n}\n\nexport interface ZoomResult {\n  /**\n   * Factor of zoom.\n   */\n  zoom: number;\n\n  /**\n   * SVG Ref for the Canvas.\n   */\n  svgRef: RefObject<SVGSVGElement | null>;\n\n  /**\n   * Set a zoom factor of the canvas.\n   */\n  setZoom?: (factor: number) => void;\n\n  /**\n   * Zoom in on the canvas.\n   */\n  zoomIn?: (zoomFactor?: number) => void;\n\n  /**\n   * Zoom out on the canvas.\n   */\n  zoomOut?: (zoomFactor?: number) => void;\n}\n\nexport const useZoom = ({ disabled = false, zoom = 1, minZoom = -0.5, maxZoom = 1, onZoomChange }: ZoomProps) => {\n  const [factor, setFactor] = useState<number>(zoom - 1);\n  const svgRef = useRef<SVGSVGElement | null>(null);\n\n  useGesture(\n    {\n      onPinch: ({ offset: [d], event }) => {\n        event.preventDefault();\n        // TODO: Set X/Y on center of zoom\n        const next = limit(d / 100, minZoom, maxZoom);\n        setFactor(next);\n        onZoomChange(next + 1);\n      }\n    },\n    {\n      enabled: !disabled,\n      domTarget: svgRef,\n      eventOptions: { passive: false }\n    }\n  );\n\n  const setZoom = useCallback(\n    (f: number) => {\n      const next = limit(f, minZoom, maxZoom);\n      setFactor(next);\n      onZoomChange(next + 1);\n    },\n    [maxZoom, minZoom, onZoomChange]\n  );\n\n  const zoomIn = useCallback(\n    (zoomFactor: number = 0.1) => {\n      setZoom(factor + zoomFactor);\n    },\n    [factor, setZoom]\n  );\n\n  const zoomOut = useCallback(\n    (zoomFactor: number = -0.1) => {\n      setZoom(factor + zoomFactor);\n    },\n    [factor, setZoom]\n  );\n\n  return {\n    svgRef,\n    zoom: factor + 1,\n    setZoom,\n    zoomIn,\n    zoomOut\n  } as ZoomResult;\n};\n","import React, { createContext, useContext } from 'react';\nimport { LayoutResult, useLayout } from '../layout/useLayout';\nimport { NodeData, PortData } from '../types';\nimport { EdgeDragResult, useEdgeDrag } from './useEdgeDrag';\nimport { useZoom, ZoomResult } from './useZoom';\n\nexport interface CanvasProviderValue\n  extends EdgeDragResult,\n    LayoutResult,\n    ZoomResult {\n  selections?: string[];\n  readonly?: boolean;\n  pannable: boolean;\n  panType: 'scroll' | 'drag'; \n}\n\nexport const CanvasContext = createContext<CanvasProviderValue>({} as any);\n\nexport interface CanvasProviderProps {\n  onNodeLink?: (\n    event: any,\n    fromNode: NodeData,\n    toNode: NodeData,\n    fromPort?: PortData\n  ) => void;\n  onNodeLinkCheck?: (\n    event: any,\n    fromNode: NodeData,\n    toNode: NodeData,\n    fromPort?: PortData\n  ) => undefined | boolean;\n}\n\nexport const CanvasProvider = ({\n  selections,\n  onNodeLink,\n  readonly,\n  children,\n  nodes,\n  edges,\n  maxHeight,\n  fit,\n  maxWidth,\n  direction,\n  layoutOptions,\n  pannable,\n  panType,\n  defaultPosition,\n  zoomable,\n  zoom,\n  minZoom,\n  maxZoom,\n  onNodeLinkCheck,\n  onLayoutChange,\n  onZoomChange\n}) => {\n  const zoomProps = useZoom({\n    zoom,\n    minZoom,\n    maxZoom,\n    disabled: !zoomable,\n    onZoomChange\n  });\n\n  const layoutProps = useLayout({\n    nodes,\n    edges,\n    maxHeight,\n    maxWidth,\n    direction,\n    pannable,\n    panType,\n    defaultPosition,\n    fit,\n    layoutOptions,\n    zoom: zoomProps.zoom,\n    setZoom: zoomProps.setZoom,\n    onLayoutChange\n  });\n\n  const dragProps = useEdgeDrag({\n    onNodeLink,\n    onNodeLinkCheck\n  });\n\n  return (\n    <CanvasContext.Provider\n      value={{\n        selections,\n        readonly,\n        pannable,\n        panType,\n        ...layoutProps,\n        ...zoomProps,\n        ...dragProps\n      }}\n    >\n      {children}\n    </CanvasContext.Provider>\n  );\n};\n\nexport const useCanvas = () => {\n  const context = useContext(CanvasContext);\n\n  if (context === undefined) {\n    throw new Error(\n      '`useCanvas` hook must be used within a `CanvasContext` component'\n    );\n  }\n\n  return context;\n};\n","import { RefObject } from 'react';\nimport { NodeData } from '../types';\nimport { Matrix2D } from 'kld-affine';\n\n/**\n * Checks if the node can be linked or not.\n */\nexport function checkNodeLinkable(\n  curNode: NodeData,\n  enteredNode: NodeData | null,\n  canLinkNode: boolean | null\n) {\n  if (canLinkNode === null || !enteredNode) {\n    return null;\n  }\n\n  if (!enteredNode || !curNode) {\n    return false;\n  }\n\n  // TODO: Revisit how to do self-linking better...\n  return !(canLinkNode === false && enteredNode.id === curNode.id);\n}\n\nexport interface CoordProps {\n  zoom: number;\n  layoutXY: [number, number];\n  containerRef: RefObject<HTMLDivElement | null>;\n}\n\n/**\n * Given various dimensions and positions, create a matrix\n * used for determining position.\n */\nexport function getCoords({ zoom, layoutXY, containerRef }: CoordProps) {\n  const { top, left } = containerRef.current.getBoundingClientRect();\n  const tx = layoutXY[0] - containerRef.current.scrollLeft + left;\n  const ty = layoutXY[1] - containerRef.current.scrollTop + top;\n\n  return new Matrix2D().translate(tx, ty).scale(zoom).inverse();\n}\n\n/**\n * Given a nodeId to find, a list of nodes to check against, and an optional parentId of the node\n * find the node from the list of nodes\n */\nexport function findNestedNode(\n  nodeId: string,\n  children: any[],\n  parentId?: string\n): { [key: string]: any } {\n  if (!nodeId || !children) {\n    return {};\n  }\n\n  const foundNode = children.find((n) => n.id === nodeId);\n  if (foundNode) {\n    return foundNode;\n  }\n\n  if (parentId) {\n    const parentNode = children.find((n) => n.id === parentId);\n    if (parentNode?.children) {\n      return findNestedNode(nodeId, parentNode.children, parentId);\n    }\n  }\n\n  // Check for nested children\n  const nodesWithChildren = children.filter((n) => n.children?.length);\n  // Iterate over all nested nodes and check if any of them contain the node\n  for (const n of nodesWithChildren) {\n    const foundChild = findNestedNode(nodeId, n.children, parentId);\n\n    if (foundChild && Object.keys(foundChild).length) {\n      return foundChild;\n    }\n  }\n\n  return {};\n}\n\n/**\n * Return the layout node that is currently being dragged on the Canvas\n */\nexport function getDragNodeData(\n  dragNode: NodeData,\n  children: any[] = []\n): { [key: string]: any } {\n  if (!dragNode) {\n    return {};\n  }\n\n  const { parent } = dragNode;\n  if (!parent) {\n    return children?.find((n) => n.id === dragNode.id) || {};\n  }\n\n  return findNestedNode(dragNode.id, children, parent);\n}\n","import { useRef } from 'react';\nimport { useDrag } from 'react-use-gesture';\nimport { State } from 'react-use-gesture/dist/types';\nimport { NodeDragType } from 'symbols';\nimport { NodeData } from '../types';\nimport { useCanvas } from './CanvasProvider';\nimport { getCoords } from './helpers';\n\nexport type DragEvent = State['drag'] & { dragType?: NodeDragType };\nexport type Position = [number, number];\n\nexport interface NodeDragEvents<T = any, TT = any | undefined> {\n  onDrag?: (event: DragEvent, initial: Position, data: T, extra?: TT) => void;\n  onDragEnd?: (\n    event: DragEvent,\n    initial: Position,\n    data: T,\n    extra?: TT\n  ) => void;\n  onDragStart?: (\n    event: DragEvent,\n    initial: Position,\n    data: T,\n    extra?: TT\n  ) => void;\n}\n\nexport interface NodeDragProps extends NodeDragEvents {\n  node: NodeData;\n  height: number;\n  width: number;\n  x: number;\n  y: number;\n  disabled: boolean;\n}\n\nexport const useNodeDrag = ({\n  x,\n  y,\n  height,\n  width,\n  onDrag,\n  onDragEnd,\n  onDragStart,\n  node,\n  disabled\n}: NodeDragProps) => {\n  const initial: Position = [width / 2 + x, height + y];\n  const targetRef = useRef<EventTarget | null>(null);\n  const { zoom, xy, containerRef } = useCanvas();\n\n  const bind = useDrag(\n    (state) => {\n      if (state.event.type === 'pointerdown') {\n        targetRef.current = state.event.currentTarget;\n      }\n\n      if (!state.intentional || !targetRef.current) {\n        return;\n      }\n\n      if (state.first) {\n        const matrix = getCoords({\n          containerRef,\n          zoom,\n          layoutXY: xy\n        });\n\n        // memo will hold the difference between the\n        // first point of impact and the origin\n        const memo = [matrix];\n\n        onDragStart({ ...state, memo }, initial, node);\n\n        return memo;\n      }\n\n      onDrag(state, initial, node);\n\n      if (state.last) {\n        targetRef.current = null;\n        onDragEnd(state, initial, node);\n      }\n    },\n    {\n      enabled: !disabled,\n      triggerAllEvents: true,\n      threshold: 5\n    }\n  );\n\n  return bind;\n};\n","import React, { forwardRef, Fragment, ReactNode, Ref, useState } from 'react';\nimport { motion } from 'motion/react';\nimport { PortData } from '../../types';\nimport { NodeDragEvents, DragEvent, useNodeDrag, Position } from '../../utils/useNodeDrag';\nimport classNames from 'classnames';\nimport { useCanvas } from '../../utils/CanvasProvider';\nimport css from './Port.module.css';\n\nexport interface ElkPortProperties {\n  index: number;\n  width: number;\n  height: number;\n  'port.side': string;\n  'port.alignment': string;\n}\n\nexport interface PortChildProps {\n  port: PortData;\n  isDisabled: boolean;\n  isDragging: boolean;\n  isHovered: boolean;\n  x: number;\n  y: number;\n  rx: number;\n  ry: number;\n  offsetX: number;\n  offsetY: number;\n}\n\nexport type PortChildrenAsFunction = (portChildProps: PortChildProps) => ReactNode;\n\nexport interface PortProps extends NodeDragEvents<PortData> {\n  id: string;\n  x: number;\n  y: number;\n  rx: number;\n  ry: number;\n  offsetX: number;\n  offsetY: number;\n  disabled?: boolean;\n  className?: string;\n  properties: ElkPortProperties & PortData;\n  style?: any;\n  children?: ReactNode | PortChildrenAsFunction;\n  active?: boolean;\n  onEnter?: (event: React.MouseEvent<SVGGElement, MouseEvent>, port: PortData) => void;\n  onLeave?: (event: React.MouseEvent<SVGGElement, MouseEvent>, port: PortData) => void;\n  onClick?: (event: React.MouseEvent<SVGGElement, MouseEvent>, port: PortData) => void;\n}\n\nexport const Port = forwardRef(({ id, x, y, rx, ry, disabled, style, children, properties, offsetX, offsetY, className, active, onDrag = () => undefined, onDragStart = () => undefined, onDragEnd = () => undefined, onEnter = () => undefined, onLeave = () => undefined, onClick = () => undefined }: Partial<PortProps>, ref: Ref<SVGRectElement>) => {\n  const { readonly } = useCanvas();\n  const [isDragging, setIsDragging] = useState<boolean>(false);\n  const [isHovered, setIsHovered] = useState<boolean>(false);\n  const newX = x - properties.width / 2;\n  const newY = y - properties.height / 2;\n\n  const onDragStartInternal = (event: DragEvent, initial: Position) => {\n    onDragStart(event, initial, properties);\n    setIsDragging(true);\n  };\n\n  const onDragEndInternal = (event: DragEvent, initial: Position) => {\n    onDragEnd(event, initial, properties);\n    setIsDragging(false);\n  };\n\n  const bind = useNodeDrag({\n    x: newX + offsetX,\n    y: newY + offsetY,\n    height: properties.height,\n    width: properties.width,\n    disabled: disabled || readonly || properties?.disabled,\n    node: properties,\n    onDrag,\n    onDragStart: onDragStartInternal,\n    onDragEnd: onDragEndInternal\n  });\n\n  if (properties.hidden) {\n    return null;\n  }\n\n  const isDisabled = properties.disabled || disabled;\n\n  const portChildProps: PortChildProps = {\n    port: properties,\n    isDragging,\n    isHovered,\n    isDisabled,\n    x,\n    y,\n    rx,\n    ry,\n    offsetX,\n    offsetY\n  };\n\n  return (\n    <g id={id}>\n      <rect\n        {...bind()}\n        ref={ref}\n        height={properties.height + 14}\n        width={properties.width + 14}\n        x={newX - 7}\n        y={newY - 7}\n        className={classNames(css.clicker, { [css.disabled]: isDisabled })}\n        onMouseEnter={(event) => {\n          event.stopPropagation();\n          if (!isDisabled) {\n            setIsHovered(true);\n            onEnter(event, properties);\n          }\n        }}\n        onMouseLeave={(event) => {\n          event.stopPropagation();\n          if (!isDisabled) {\n            setIsHovered(false);\n            onLeave(event, properties);\n          }\n        }}\n        onClick={(event) => {\n          event.stopPropagation();\n          if (!isDisabled) {\n            onClick(event, properties);\n          }\n        }}\n      />\n      <motion.rect\n        key={`${x}-${y}`}\n        style={style}\n        className={classNames(css.port, className, properties?.className)}\n        height={properties.height}\n        width={properties.width}\n        rx={rx}\n        ry={ry}\n        initial={{\n          scale: 0,\n          opacity: 0,\n          x: newX,\n          y: newY\n        }}\n        animate={{\n          x: newX,\n          y: newY,\n          scale: (isDragging || active || isHovered) && !isDisabled ? 1.5 : 1,\n          opacity: 1\n        }}\n      />\n      {children && <Fragment>{typeof children === 'function' ? (children as PortChildrenAsFunction)(portChildProps) : children}</Fragment>}\n    </g>\n  );\n});\n","import React, { FC } from 'react';\nimport classNames from 'classnames';\nimport css from './Label.module.css';\n\nexport interface LabelProps {\n  x: number;\n  y: number;\n  height: number;\n  width: number;\n  text: string;\n  style?: any;\n  className?: string;\n  originalText?: string;\n}\n\nexport const Label: FC<Partial<LabelProps>> = ({ text, x, y, style, className, originalText }) => {\n  const isString = typeof originalText === 'string';\n  return (\n    <>\n      {isString && <title>{originalText}</title>}\n      <g transform={`translate(${x}, ${y})`}>\n        <text className={classNames(css.text, className)} style={style}>\n          {text}\n        </text>\n      </g>\n    </>\n  );\n};\n","import React, { FC } from 'react';\nimport classNames from 'classnames';\nimport { motion } from 'motion/react';\nimport css from './Remove.module.css';\n\nexport interface RemoveProps {\n  x: number;\n  y: number;\n  hidden?: boolean;\n  size?: number;\n  className?: string;\n  onEnter?: (event: React.MouseEvent<SVGGElement, MouseEvent>) => void;\n  onLeave?: (event: React.MouseEvent<SVGGElement, MouseEvent>) => void;\n  onClick?: (event: React.MouseEvent<SVGGElement, MouseEvent>) => void;\n}\n\nexport const Remove: FC<Partial<RemoveProps>> = ({ size = 15, className, hidden, x, y, onClick = () => undefined, onEnter = () => undefined, onLeave = () => undefined }) => {\n  if (hidden) {\n    return null;\n  }\n\n  const half = size / 2;\n  const translateX = x - half;\n  const translateY = y - half;\n\n  return (\n    <motion.g className={classNames(className, css.container)} initial={{ scale: 0, opacity: 0, translateX, translateY }} animate={{ scale: 1, opacity: 1, translateX, translateY }} whileHover={{ scale: 1.2 }} whileTap={{ scale: 0.8 }}>\n      <rect\n        height={size * 1.5}\n        width={size * 1.5}\n        className={css.drop}\n        onMouseEnter={onEnter}\n        onMouseLeave={onLeave}\n        onClick={(event) => {\n          event.preventDefault();\n          event.stopPropagation();\n          onClick(event);\n        }}\n      />\n      <rect height={size} width={size} className={css.rect} />\n      <line x1=\"2\" y1={size - 2} x2={size - 2} y2=\"2\" className={css.deleteX} strokeWidth=\"1\" />\n      <line x1=\"2\" y1=\"2\" x2={size - 2} y2={size - 2} className={css.deleteX} strokeWidth=\"1\" />\n    </motion.g>\n  );\n};\n","export interface PointCoords {\n  x: number;\n  y: number;\n}\n\nexport interface CenterCoords {\n  angle: number;\n  x: number;\n  y: number;\n}\n\n/**\n * Center helper.\n * Ref: https://github.com/wbkd/react-flow/blob/main/src/components/Edges/utils.ts#L18\n */\nfunction getBezierCenter({\n  sourceX,\n  sourceY,\n  targetX,\n  targetY\n}): [number, number, number, number] {\n  const xOffset = Math.abs(targetX - sourceX) / 2;\n  const centerX = targetX < sourceX ? targetX + xOffset : targetX - xOffset;\n\n  const yOffset = Math.abs(targetY - sourceY) / 2;\n  const centerY = targetY < sourceY ? targetY + yOffset : targetY - yOffset;\n\n  return [centerX, centerY, xOffset, yOffset];\n}\n\n/**\n * Path helper utils.\n * Ref: https://github.com/wbkd/react-flow/blob/main/src/components/Edges/BezierEdge.tsx#L19\n */\nexport function getBezierPath({\n  sourceX,\n  sourceY,\n  sourcePosition = 'bottom',\n  targetX,\n  targetY,\n  targetPosition = 'top'\n}): string {\n  const leftAndRight = ['left', 'right'];\n  const [centerX, centerY] = getBezierCenter({\n    sourceX,\n    sourceY,\n    targetX,\n    targetY\n  });\n\n  let path = `M${sourceX},${sourceY} C${sourceX},${centerY} ${targetX},${centerY} ${targetX},${targetY}`;\n\n  if (\n    leftAndRight.includes(sourcePosition) &&\n    leftAndRight.includes(targetPosition)\n  ) {\n    path = `M${sourceX},${sourceY} C${centerX},${sourceY} ${centerX},${targetY} ${targetX},${targetY}`;\n  } else if (leftAndRight.includes(targetPosition)) {\n    path = `M${sourceX},${sourceY} C${sourceX},${targetY} ${sourceX},${targetY} ${targetX},${targetY}`;\n  } else if (leftAndRight.includes(sourcePosition)) {\n    path = `M${sourceX},${sourceY} C${targetX},${sourceY} ${targetX},${sourceY} ${targetX},${targetY}`;\n  }\n\n  return path;\n}\n\n/**\n * Calculate actual center for a path element.\n */\nfunction getCenter(pathElm: SVGPathElement) {\n  const pLength = pathElm.getTotalLength();\n  const pieceSize = pLength / 2;\n  const { x, y } = pathElm.getPointAtLength(pieceSize);\n  const angle = (Math.atan2(x, y) * 180) / Math.PI;\n  return { x, y, angle };\n}\n\n/**\n * Get the angle for the path.\n */\nfunction getAngle(source: PointCoords, target: PointCoords) {\n  const dx = source.x - target.x;\n  const dy = source.y - target.y;\n\n  let theta = Math.atan2(-dy, -dx);\n  theta *= 180 / Math.PI;\n  if (theta < 0) {\n    theta += 360;\n  }\n\n  return theta;\n}\n\n/**\n * Get the center for the path element.\n */\nexport function getPathCenter(\n  pathElm: SVGPathElement,\n  firstPoint: PointCoords,\n  lastPoint: PointCoords\n): CenterCoords {\n  if (!pathElm) {\n    return null;\n  }\n\n  const angle = getAngle(firstPoint, lastPoint);\n  const point = getCenter(pathElm);\n  return {\n    ...point,\n    angle\n  };\n}\n","import React, { FC } from 'react';\nimport classNames from 'classnames';\nimport { motion } from 'motion/react';\nimport css from './Add.module.css';\n\nexport interface AddProps {\n  x: number;\n  y: number;\n  size?: number;\n  className?: string;\n  hidden?: boolean;\n  onEnter?: (event: React.MouseEvent<SVGGElement, MouseEvent>) => void;\n  onLeave?: (event: React.MouseEvent<SVGGElement, MouseEvent>) => void;\n  onClick?: (event: React.MouseEvent<SVGGElement, MouseEvent>) => void;\n}\n\nexport const Add: FC<Partial<AddProps>> = ({ x, y, className, size = 15, hidden = true, onEnter = () => undefined, onLeave = () => undefined, onClick = () => undefined }) => {\n  if (hidden) {\n    return null;\n  }\n\n  const half = size / 2;\n  const translateX = x - half;\n  const translateY = y - half;\n\n  return (\n    <motion.g className={classNames(className, css.container)} initial={{ scale: 0, opacity: 0, translateX, translateY }} animate={{ scale: 1, opacity: 1, translateX, translateY }} whileHover={{ scale: 1.2 }} whileTap={{ scale: 0.8 }}>\n      <rect\n        height={size * 2}\n        width={size * 2}\n        className={css.drop}\n        onClick={(event) => {\n          event.preventDefault();\n          event.stopPropagation();\n          onClick(event);\n        }}\n        onMouseEnter={onEnter}\n        onMouseLeave={onLeave}\n      />\n      <rect height={size} width={size} className={css.rect} />\n      <line x1=\"2\" x2={size - 2} y1={half} y2={half} className={css.plus} strokeWidth=\"1\" />\n      <line x1={half} x2={half} y1=\"2\" y2={size - 2} className={css.plus} strokeWidth=\"1\" />\n    </motion.g>\n  );\n};\n","import React, { FC, Fragment, MutableRefObject, ReactElement, ReactNode, useEffect, useMemo, useRef, useState } from 'react';\nimport { EdgeData } from '../../types';\nimport { Label, LabelProps } from '../Label';\nimport { CloneElement } from 'reablocks';\nimport classNames from 'classnames';\nimport { CenterCoords, getBezierPath, getPathCenter } from './utils';\nimport { curveBundle, line } from 'd3-shape';\nimport { Remove, RemoveProps } from '../Remove';\nimport { Add, AddProps } from '../Add';\nimport { useCanvas } from '../../utils/CanvasProvider';\nimport css from './Edge.module.css';\n\nexport interface EdgeSections {\n  id?: string;\n  startPoint?: {\n    x: number;\n    y: number;\n  };\n  endPoint?: {\n    x: number;\n    y: number;\n  };\n  bendPoints?: {\n    x: number;\n    y: number;\n  };\n}\n\nexport interface EdgeChildProps {\n  edge: EdgeData;\n  pathRef: MutableRefObject<SVGPathElement> | null;\n  center: CenterCoords | null;\n}\n\nexport type EdgeChildrenAsFunction = (edgeChildProps: EdgeChildProps) => ReactNode;\n\nexport interface EdgeProps {\n  id: string;\n  disabled?: boolean;\n  removable?: boolean;\n  selectable?: boolean;\n  upsertable?: boolean;\n  source: string;\n  sourcePort: string;\n  target: string;\n  targetPort: string;\n  properties?: EdgeData;\n  style?: any;\n  children?: ReactNode | EdgeChildrenAsFunction;\n  sections: EdgeSections[];\n  interpolation: 'linear' | 'curved' | Function;\n  labels?: LabelProps[];\n  className?: string;\n  containerClassName?: string;\n\n  add: ReactElement<AddProps, typeof Add>;\n  label: ReactElement<LabelProps, typeof Label>;\n  remove: ReactElement<RemoveProps, typeof Remove>;\n\n  onClick?: (event: React.MouseEvent<SVGGElement, MouseEvent>, data: EdgeData) => void;\n  onKeyDown?: (event: React.KeyboardEvent<SVGGElement>, data: EdgeData) => void;\n  onEnter?: (event: React.MouseEvent<SVGGElement, MouseEvent>, node: EdgeData) => void;\n  onLeave?: (event: React.MouseEvent<SVGGElement, MouseEvent>, node: EdgeData) => void;\n  onRemove?: (event: React.MouseEvent<SVGGElement, MouseEvent>, edge: EdgeData) => void;\n  onAdd?: (event: React.MouseEvent<SVGGElement, MouseEvent>, edge: EdgeData) => void;\n}\n\nexport const Edge: FC<Partial<EdgeProps>> = ({ sections, interpolation = 'curved', properties, labels, className, containerClassName, disabled, removable = true, selectable = true, upsertable = true, style, children, add = <Add />, remove = <Remove />, label = <Label />, onClick = () => undefined, onKeyDown = () => undefined, onEnter = () => undefined, onLeave = () => undefined, onRemove = () => undefined, onAdd = () => undefined }) => {\n  const pathRef = useRef<SVGPathElement | null>(null);\n  const [deleteHovered, setDeleteHovered] = useState<boolean>(false);\n  const [center, setCenter] = useState<CenterCoords | null>(null);\n  const { selections, readonly } = useCanvas();\n  const isActive: boolean = selections?.length ? selections.includes(properties?.id) : false;\n  const isDisabled = disabled || properties?.disabled;\n  const canSelect = selectable && !properties?.selectionDisabled;\n\n  // The \"d\" attribute defines a path to be drawn. See https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d\n  const d = useMemo(() => {\n    if (!sections?.length) {\n      return null;\n    }\n\n    // Handle bend points that elk gives\n    // us separately from drag points\n    if (sections[0].bendPoints) {\n      const points: any[] = sections ? [sections[0].startPoint, ...(sections[0].bendPoints || ([] as any)), sections[0].endPoint] : [];\n\n      let pathFn: any = line()\n        .x((d: any) => d.x)\n        .y((d: any) => d.y);\n      if (interpolation !== 'linear') {\n        pathFn = interpolation === 'curved' ? pathFn.curve(curveBundle.beta(1)) : interpolation;\n      }\n      return pathFn(points);\n    } else {\n      return getBezierPath({\n        sourceX: sections[0].startPoint.x,\n        sourceY: sections[0].startPoint.y,\n        targetX: sections[0].endPoint.x,\n        targetY: sections[0].endPoint.y\n      });\n    }\n  }, [interpolation, sections]);\n\n  useEffect(() => {\n    if (sections?.length > 0) {\n      setCenter(getPathCenter(pathRef.current, sections[0].startPoint, sections[0].endPoint));\n    }\n  }, [sections]);\n\n  const edgeChildProps: EdgeChildProps = {\n    edge: properties,\n    center,\n    pathRef\n  };\n\n  return (\n    <g\n      className={classNames(css.edge, containerClassName, {\n        [css.disabled]: isDisabled,\n        [css.selectionDisabled]: !canSelect\n      })}\n    >\n      <path\n        ref={pathRef}\n        style={style}\n        className={classNames(css.path, properties?.className, className, {\n          [css.active]: isActive,\n          [css.deleteHovered]: deleteHovered\n        })}\n        d={d}\n        markerEnd=\"url(#end-arrow)\"\n      />\n      <path\n        className={css.clicker}\n        d={d}\n        tabIndex={-1}\n        onClick={(event) => {\n          event.preventDefault();\n          event.stopPropagation();\n          if (!isDisabled && canSelect) {\n            onClick(event, properties);\n          }\n        }}\n        onKeyDown={(event) => {\n          event.preventDefault();\n          event.stopPropagation();\n          if (!isDisabled) {\n            onKeyDown(event, properties);\n          }\n        }}\n        onMouseEnter={(event) => {\n          event.stopPropagation();\n          if (!isDisabled) {\n            onEnter(event, properties);\n          }\n        }}\n        onMouseLeave={(event) => {\n          event.stopPropagation();\n          if (!isDisabled) {\n            onLeave(event, properties);\n          }\n        }}\n      />\n      {children && <Fragment>{typeof children === 'function' ? (children as EdgeChildrenAsFunction)(edgeChildProps) : children}</Fragment>}\n      {labels?.length > 0 && labels.map((l, index) => <CloneElement<LabelProps> element={label} key={index} edgeChildProps={edgeChildProps} {...(l as LabelProps)} />)}\n      {!isDisabled && center && !readonly && remove && removable && (\n        <CloneElement<RemoveProps>\n          element={remove}\n          {...center}\n          hidden={remove.props.hidden !== undefined ? remove.props.hidden : !isActive}\n          onClick={(event: React.MouseEvent<SVGGElement, MouseEvent>) => {\n            event.preventDefault();\n            event.stopPropagation();\n            onRemove(event, properties);\n            setDeleteHovered(false);\n          }}\n          onEnter={() => setDeleteHovered(true)}\n          onLeave={() => setDeleteHovered(false)}\n        />\n      )}\n      {!isDisabled && center && !readonly && add && upsertable && (\n        <CloneElement<AddProps>\n          element={add}\n          {...center}\n          onClick={(event) => {\n            event.preventDefault();\n            event.stopPropagation();\n            onAdd(event, properties);\n          }}\n        />\n      )}\n    </g>\n  );\n};\n","import React, { FC, Fragment, ReactElement, ReactNode, useCallback, useEffect, useRef, useState } from 'react';\nimport { motion, useAnimation } from 'motion/react';\nimport { Port, PortProps } from '../Port';\nimport { Label, LabelProps } from '../Label';\nimport { EdgeData, NodeData, PortData } from '../../types';\nimport { CloneElement } from 'reablocks';\nimport { Icon, IconProps } from '../Icon';\nimport classNames from 'classnames';\nimport { Remove, RemoveProps } from '../Remove';\nimport { NodeDragEvents, DragEvent, useNodeDrag, Position } from '../../utils/useNodeDrag';\nimport { Edge, EdgeProps } from '../Edge';\nimport { useCanvas } from '../../utils/CanvasProvider';\nimport { checkNodeLinkable } from '../../utils/helpers';\nimport css from './Node.module.css';\n\nexport interface NodeChildProps {\n  height: number;\n  width: number;\n  x: number;\n  y: number;\n  node: NodeData;\n  nodes?: NodeData[];\n  edges?: EdgeData[];\n}\n\nexport type NodeDragType = 'node' | 'port' | 'multiportOnly' | 'all';\n\nexport type NodeChildrenAsFunction = (nodeChildProps: NodeChildProps) => ReactNode;\n\nexport interface NodeProps<T = any> extends NodeDragEvents<NodeData<T>, PortData> {\n  id: string;\n  height: number;\n  width: number;\n  x: number;\n  y: number;\n  rx: number;\n  ry: number;\n  offsetX?: number;\n  offsetY?: number;\n  disabled?: boolean;\n  ports?: PortProps[];\n  labels?: LabelProps[];\n  properties: NodeData<T>;\n  className?: string;\n  style?: any;\n  children?: ReactNode | NodeChildrenAsFunction;\n  parent?: string;\n  animated?: boolean;\n  draggable?: boolean;\n  linkable?: boolean;\n  selectable?: boolean;\n  removable?: boolean;\n  dragType?: NodeDragType;\n  dragCursor?: string;\n\n  nodes?: NodeData[];\n  edges?: EdgeData[];\n\n  onRemove?: (event: React.MouseEvent<SVGGElement, MouseEvent>, node: NodeData) => void;\n\n  onClick?: (event: React.MouseEvent<SVGGElement, MouseEvent>, data: NodeData) => void;\n\n  onKeyDown?: (event: React.KeyboardEvent<SVGGElement>, data: NodeData) => void;\n\n  onEnter?: (event: React.MouseEvent<SVGGElement, MouseEvent>, node: NodeData) => void;\n\n  onLeave?: (event: React.MouseEvent<SVGGElement, MouseEvent>, node: NodeData) => void;\n\n  childNode?: ReactElement<NodeProps, typeof Node> | ((node: NodeProps) => ReactElement<NodeProps, typeof Node>);\n\n  childEdge?: ReactElement<EdgeProps, typeof Edge> | ((edge: EdgeProps) => ReactElement<NodeProps, typeof Edge>);\n\n  remove: ReactElement<RemoveProps, typeof Remove>;\n  icon: ReactElement<IconProps, typeof Icon>;\n  label: ReactElement<LabelProps, typeof Label>;\n  port: ReactElement<PortProps, typeof Port>;\n  tooltip?: React.ElementType;\n}\n\nexport const Node: FC<Partial<NodeProps>> = ({ id, x, y, ports, labels, height, width, properties, animated, className, rx = 2, ry = 2, offsetX = 0, offsetY = 0, icon, disabled, style, children, nodes, edges, draggable = true, linkable = true, selectable = true, removable = true, dragType = 'multiportOnly', dragCursor = 'crosshair', childEdge = <Edge />, childNode = <Node />, remove = <Remove />, port = <Port />, label = <Label />, tooltip: Tooltip = React.Fragment, onRemove, onDrag, onDragStart, onDragEnd, onClick, onKeyDown, onEnter, onLeave }) => {\n  const nodeRef = useRef<SVGRectElement | null>(null);\n  const controls = useAnimation();\n  const { canLinkNode, enteredNode, selections, readonly, ...canvas } = useCanvas();\n  const [deleteHovered, setDeleteHovered] = useState<boolean>(false);\n  const [dragging, setDragging] = useState<boolean>(false);\n  const [isLinkable, setIsLinkable] = useState<boolean>(true);\n  const isActive = selections?.length ? selections.includes(properties.id) : null;\n  const isNodeDrag = id.includes('node-drag');\n  const newX = x + offsetX;\n  const newY = y + offsetY;\n  const isMultiPort = dragType === 'multiportOnly' && ports?.filter((p) => !p.properties?.hidden).length > 1;\n  const isDisabled = disabled || properties?.disabled;\n  const canDrag = ['port', 'multiportOnly'].includes(dragType) ? linkable : draggable;\n  const canSelect = selectable && !properties?.selectionDisabled;\n\n  const getDragType = useCallback(\n    (hasPort: boolean) => {\n      let activeDragType: NodeDragType = null;\n      if (!hasPort) {\n        if (dragType === 'all' || dragType === 'node') {\n          activeDragType = 'node';\n        } else if (!isMultiPort) {\n          activeDragType = 'port';\n        }\n      } else {\n        if (dragType === 'all' || dragType === 'port' || isMultiPort) {\n          activeDragType = 'port';\n        }\n      }\n      return activeDragType;\n    },\n    [dragType, isMultiPort]\n  );\n\n  const setDragCursor = useCallback((dragType: NodeDragType | null) => {\n    if (dragType) {\n      document.body.classList.add('dragging');\n      document.body.style.cursor = dragType === 'node' ? 'grab' : 'crosshair';\n    } else {\n      document.body.classList.remove('dragging');\n      document.body.style.cursor = 'auto';\n    }\n  }, []);\n\n  const bind = useNodeDrag({\n    x: newX,\n    y: newY,\n    height,\n    width,\n    disabled: isDisabled || isMultiPort || readonly || !canDrag || dragType === 'port',\n    node: properties,\n    onDrag: (...props) => {\n      if (!isDisabled && canDrag) {\n        canvas.onDrag(...props);\n        onDrag?.(...props);\n      }\n    },\n    onDragStart: (event, coords, node, port) => {\n      if (!isDisabled && canDrag) {\n        // @ts-ignore\n        event.dragType = getDragType(false);\n        // @ts-ignore\n        setDragCursor(event.dragType);\n\n        canvas.onDragStart(event, coords, node, port);\n        onDragStart?.(event, coords, node, port);\n        setDragging(true);\n      }\n    },\n    onDragEnd: (event, coords, node, port) => {\n      if (!isDisabled && canDrag) {\n        // @ts-ignore\n        event.dragType = getDragType(false);\n        // @ts-ignore\n        event.srcElement = nodeRef.current;\n\n        canvas.onDragEnd(event, coords, node, port);\n        onDragEnd?.(event, coords, node, port);\n        setDragging(false);\n        setDragCursor(null);\n      }\n    }\n  });\n\n  useEffect(() => {\n    if (enteredNode?.id === properties.id) {\n      setIsLinkable(checkNodeLinkable(properties, enteredNode, canLinkNode));\n    }\n\n    return () => setIsLinkable(true);\n  }, [canLinkNode, enteredNode, properties]);\n\n  useEffect(() => {\n    controls.set({\n      opacity: 1,\n      translateX: x,\n      translateY: y\n    });\n  }, [controls, x, y]);\n\n  const nodeChildProps: NodeChildProps = {\n    height,\n    width,\n    x,\n    y,\n    node: properties,\n    nodes,\n    edges\n  };\n\n  const onClickCallback = useCallback(\n    (event) => {\n      event.preventDefault();\n      event.stopPropagation();\n      if (!isDisabled && canSelect) {\n        onClick?.(event, properties);\n      }\n    },\n    [canSelect, isDisabled, onClick, properties]\n  );\n\n  const onKeyDownCallback = useCallback(\n    (event) => {\n      event.preventDefault();\n      if (!isDisabled) {\n        onKeyDown?.(event, properties);\n      }\n    },\n    [isDisabled, onKeyDown, properties]\n  );\n\n  const onTouchStartCallback = useCallback((event) => {\n    event.preventDefault();\n    event.stopPropagation();\n  }, []);\n\n  const onMouseEnterCallback = useCallback(\n    (event) => {\n      event.stopPropagation();\n      canvas.onEnter(event, properties);\n      if (!isDisabled) {\n        onEnter?.(event, properties);\n      }\n    },\n    [canvas, isDisabled, onEnter, properties]\n  );\n\n  const onMouseLeaveCallback = useCallback(\n    (event) => {\n      event.stopPropagation();\n      canvas.onLeave(event, properties);\n      if (!isDisabled) {\n        onLeave?.(event, properties);\n      }\n    },\n    [canvas, isDisabled, onLeave, properties]\n  );\n\n  const onDragStartCallback = useCallback(\n    (event: DragEvent, initial: Position, data: PortData) => {\n      if (!isDisabled && linkable) {\n        // @ts-ignore\n        event.dragType = getDragType(true);\n        // @ts-ignore\n        setDragCursor(event.dragType);\n\n        canvas.onDragStart(event, initial, properties, data);\n        onDragStart?.(event, initial, properties, data);\n        setDragging(true);\n      }\n    },\n    [canvas, getDragType, isDisabled, linkable, onDragStart, properties, setDragCursor]\n  );\n\n  const onDragCallback = useCallback(\n    (event: DragEvent, initial: Position, data: PortData) => {\n      if (!isDisabled && linkable) {\n        canvas.onDrag(event, initial, properties, data);\n        onDrag?.(event, initial, properties, data);\n      }\n    },\n    [canvas, isDisabled, linkable, onDrag, properties]\n  );\n\n  const onDragEndCallback = useCallback(\n    (event: DragEvent, initial: Position, data: PortData) => {\n      if (!isDisabled && linkable) {\n        // @ts-ignore\n        event.dragType = getDragType(true);\n        setDragCursor(null);\n\n        canvas.onDragEnd(event, initial, properties, data);\n        onDragEnd?.(event, initial, properties, data);\n        setDragging(false);\n      }\n    },\n    [canvas, getDragType, isDisabled, linkable, onDragEnd, properties, setDragCursor]\n  );\n\n  return (\n    <motion.g\n      id={id}\n      initial={{\n        cursor: 'initial',\n        opacity: 0,\n        translateX: x,\n        translateY: y\n      }}\n      animate={controls}\n    >\n      <foreignObject width={width} height={height} style={{ pointerEvents: 'none' }}>\n        <Tooltip>\n          <svg width={width} height={height}>\n            <motion.rect\n              {...bind()}\n              ref={nodeRef}\n              tabIndex={-1}\n              onKeyDown={onKeyDownCallback}\n              onClick={onClickCallback}\n              onTouchStart={onTouchStartCallback}\n              onMouseEnter={onMouseEnterCallback}\n              onMouseLeave={onMouseLeaveCallback}\n              className={classNames(css.rect, className, properties?.className, {\n                [css.active]: isActive,\n                [css.disabled]: isDisabled,\n                [css.unlinkable]: isLinkable === false && !isNodeDrag,\n                [css.dragging]: dragging,\n                [css.children]: nodes?.length > 0,\n                [css.deleteHovered]: deleteHovered,\n                [css.selectionDisabled]: !canSelect\n              })}\n              style={{ ...style, pointerEvents: 'auto' }}\n              height={height}\n              width={width}\n              rx={rx}\n              ry={ry}\n              initial={{\n                opacity: 1\n              }}\n              animate={{\n                opacity: 1,\n                transition: !animated ? { type: false, duration: 0 } : {}\n              }}\n            />\n            {children && <Fragment>{typeof children === 'function' ? (children as NodeChildrenAsFunction)(nodeChildProps) : children}</Fragment>}\n            {icon && properties.icon && <CloneElement<IconProps> element={icon} {...properties.icon} />}\n            {label && labels?.length > 0 && labels.map((l, index) => <CloneElement<LabelProps> element={label} key={index} {...(l as LabelProps)} />)}\n            {port && ports?.length > 0 && ports.map((p) => <CloneElement<PortProps> element={port} key={p.id} active={!isMultiPort && dragging} disabled={isDisabled || !linkable} offsetX={newX} offsetY={newY} onDragStart={onDragStartCallback} onDrag={onDragCallback} onDragEnd={onDragEndCallback} {...(p as PortProps)} id={`${id}-port-${p.id}`} />)}\n            {!isDisabled && isActive && !readonly && remove && removable && (\n              <CloneElement<RemoveProps>\n                element={remove}\n                y={height / 2}\n                x={width}\n                onClick={(event: React.MouseEvent<SVGGElement, MouseEvent>) => {\n                  event.preventDefault();\n                  event.stopPropagation();\n                  onRemove?.(event, properties);\n                  setDeleteHovered(false);\n                }}\n                onEnter={() => setDeleteHovered(true)}\n                onLeave={() => setDeleteHovered(false)}\n              />\n            )}\n            <g>\n              {edges?.length > 0 &&\n                edges.map((e: any) => {\n                  const element = typeof childEdge === 'function' ? childEdge(e) : childEdge;\n                  return (\n                    <CloneElement<EdgeProps>\n                      key={e.id}\n                      element={element}\n                      id={`${id}-edge-${e.id}`}\n                      disabled={isDisabled}\n                      {...e}\n                      properties={{\n                        ...e.properties,\n                        ...(e.data ? { data: e.data } : {})\n                      }}\n                    />\n                  );\n                })}\n              {nodes?.length > 0 &&\n                nodes.map(({ children, ...n }: any) => {\n                  const element = typeof childNode === 'function' ? childNode(n) : childNode;\n                  const elementDisabled = element.props?.disabled != null ? element.props.disabled : disabled;\n                  const elementAnimated = element.props?.animated != null ? element.props.animated : animated;\n                  const elementDraggable = element.props?.draggable != null ? element.props.draggable : draggable;\n                  const elementLinkable = element.props?.linkable != null ? element.props.linkable : linkable;\n                  const elementSelectable = element.props?.selectable != null ? element.props.selectable : selectable;\n                  const elementRemovable = element.props?.removable != null ? element.props.removable : removable;\n                  return <CloneElement<NodeProps> key={n.id} element={element} id={`${id}-node-${n.id}`} disabled={elementDisabled} nodes={children} offsetX={newX} offsetY={newY} animated={elementAnimated} children={element.props.children} childNode={childNode} dragCursor={dragCursor} dragType={dragType} childEdge={childEdge} draggable={elementDraggable} linkable={elementLinkable} selectable={elementSelectable} removable={elementRemovable} onDragStart={onDragStart} onDrag={onDrag} onDragEnd={onDragEnd} onClick={onClick} onEnter={onEnter} onLeave={onLeave} onKeyDown={onKeyDown} onRemove={onRemove} {...n} />;\n                })}\n            </g>\n          </svg>\n        </Tooltip>\n      </foreignObject>\n    </motion.g>\n  );\n};\n","import React, { FC } from 'react';\nimport classNames from 'classnames';\nimport css from './Arrow.module.css';\n\nexport interface ArrowProps {\n  size?: number;\n  x?: number;\n  y?: number;\n  angle?: number;\n  className?: string;\n  style?: any;\n}\n\nexport const Arrow: FC<ArrowProps> = ({\n  size = 8,\n  y = 0,\n  x = 0,\n  angle = 0,\n  className,\n  style\n}) => (\n  <path\n    style={style}\n    transform={`translate(${x}, ${y}) rotate(${angle})`}\n    className={classNames(css.arrow, className)}\n    d={`M0,-${size / 2}L${size},0L0,${size / 2}`}\n  />\n);\n","import React, { FC } from 'react';\nimport { Arrow } from './Arrow';\n\nexport interface MarkerArrowProps {\n  size?: number;\n  style?: any;\n  className?: string;\n}\n\nexport const MarkerArrow: FC<Partial<MarkerArrowProps>> = ({\n  size = 8,\n  className,\n  style\n}) => (\n  <marker\n    id=\"end-arrow\"\n    key=\"end-arrow\"\n    viewBox={`0 -${size / 2} ${size} ${size}`}\n    refX={`${size}`}\n    markerWidth={`${size}`}\n    markerHeight={`${size}`}\n    orient=\"auto\"\n  >\n    <Arrow size={size} style={style} className={className} />\n  </marker>\n);\n","import React, { FC, ReactElement, Ref, useImperativeHandle, forwardRef, useLayoutEffect, useRef, Fragment, useMemo, useState, useCallback, useEffect } from 'react';\nimport { useId, CloneElement } from 'reablocks';\nimport { useGesture } from 'react-use-gesture';\nimport { Node, NodeDragType, NodeProps } from './symbols/Node';\nimport { Edge, EdgeProps } from './symbols/Edge';\nimport { ElkRoot, CanvasDirection, LayoutResult, ElkCanvasLayoutOptions } from './layout';\nimport { MarkerArrow, MarkerArrowProps } from './symbols/Arrow';\nimport { CanvasPosition, EdgeData, NodeData, PortData } from './types';\nimport classNames from 'classnames';\nimport { CanvasProvider, useCanvas } from './utils/CanvasProvider';\nimport { getDragNodeData } from './utils/helpers';\nimport { motion } from 'motion/react';\nimport { ZoomResult } from './utils/useZoom';\nimport css from './Canvas.module.css';\n\nexport interface CanvasContainerProps extends CanvasProps {\n  /**\n   * Nodes to render on the canvas.\n   */\n  nodes?: NodeData[];\n\n  /**\n   * Edges to render on the canvas.\n   */\n  edges?: EdgeData[];\n\n  /**\n   * Key of node/edge ids for selection.\n   */\n  selections?: string[];\n\n  /**\n   * Direction of the canvas layout.\n   */\n  direction?: CanvasDirection;\n\n  /**\n   * Whether the canvas is pannable or not.\n   */\n  pannable?: boolean;\n\n  /**\n   * Type of interaction to use for panning.\n   */\n  panType?: 'scroll' | 'drag';\n\n  /**\n   * Whether the canvas is zoomable or not.\n   */\n  zoomable?: boolean;\n\n  /**\n   * Where to position the canvas on load (if at all)\n   */\n  defaultPosition?: CanvasPosition;\n\n  /**\n   * Fit the canvas on load.\n   */\n  fit?: boolean;\n\n  /**\n   * Max height of the canvas scrollable area.\n   */\n  maxHeight?: number;\n\n  /**\n   * Max width of the canvas scrollable area.\n   */\n  maxWidth?: number;\n\n  /**\n   * Zoom factor.\n   */\n  zoom?: number;\n\n  /**\n   * Min zoom factor.\n   */\n  minZoom?: number;\n\n  /**\n   * Max zoom factor.\n   */\n  maxZoom?: number;\n\n  /**\n   * ELKJS Layout Options\n   */\n  layoutOptions?: ElkCanvasLayoutOptions;\n\n  /**\n   * Callback when a node is linked.\n   */\n  onNodeLink?: (event: any, fromNode: NodeData, toNode: NodeData, fromPort?: PortData) => void;\n\n  /**\n   * Callback to check if a node is linkable or not.\n   */\n  onNodeLinkCheck?: (event: any, fromNode: NodeData, toNode: NodeData, fromPort?: PortData) => undefined | boolean;\n\n  /**\n   * When the zoom changes.\n   */\n  onZoomChange?: (zoom: number) => void;\n\n  /**\n   * When the layout changes.\n   */\n  onLayoutChange?: (layout: ElkRoot) => void;\n}\n\nexport interface CanvasProps {\n  /**\n   * CSS classname for the container.\n   */\n  className?: string;\n\n  /**\n   * Disable all events or not.\n   */\n  disabled?: boolean;\n\n  /**\n   * Whether the nodes / edges are animated or not.\n   */\n  animated?: boolean;\n\n  /**\n   * Static height of the canvas.\n   */\n  height?: number;\n\n  /**\n   * Static width of the canvas.\n   */\n  width?: number;\n\n  /**\n   * Whether you can drag connections or not.\n   */\n  readonly?: boolean;\n\n  /**\n   * Element of the drag edge.\n   */\n  dragEdge?: ReactElement<EdgeProps, typeof Edge> | ((edge: EdgeProps) => ReactElement<EdgeProps, typeof Edge>) | null;\n\n  /**\n   * Element of the drag node.\n   */\n  dragNode?: ReactElement<NodeProps, typeof Node> | ((node: NodeProps) => ReactElement<NodeProps, typeof Node>) | null;\n\n  /**\n   * Arrow shown on the edges.\n   */\n  arrow?: ReactElement<MarkerArrowProps, typeof MarkerArrow> | null;\n\n  /**\n   * Node or node callback to return element.\n   */\n  node?: ReactElement<NodeProps, typeof Node> | ((node: NodeProps) => ReactElement<NodeProps, typeof Node>);\n\n  /**\n   * Edge or edge callback to return element.\n   */\n  edge?: ReactElement<EdgeProps, typeof Edge> | ((edge: EdgeProps) => ReactElement<NodeProps, typeof Edge>);\n\n  /**\n   * When the canvas had a mouse enter.\n   */\n  onMouseEnter?: (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;\n\n  /**\n   * When the canvas had a mouse leave.\n   */\n  onMouseLeave?: (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;\n\n  /**\n   * When the canvas was clicked.\n   */\n  onCanvasClick?: (event: React.MouseEvent<SVGGElement, MouseEvent>) => void;\n}\n\nexport type CanvasRef = LayoutResult & ZoomResult;\n\nconst InternalCanvas: FC<CanvasProps & { ref?: Ref<CanvasRef> }> = forwardRef(({ className, height = '100%', width = '100%', readonly, disabled = false, animated = true, arrow = <MarkerArrow />, node = <Node />, edge = <Edge />, dragNode = <Node />, dragEdge = <Edge />, onMouseEnter = () => undefined, onMouseLeave = () => undefined, onCanvasClick = () => undefined }, ref: Ref<CanvasRef>) => {\n  const id = useId();\n  const { pannable, dragCoords, dragNode: canvasDragNode, layout, containerRef, svgRef, canvasHeight, canvasWidth, xy, zoom, setZoom, observe, zoomIn, zoomOut, positionCanvas, fitCanvas, setScrollXY, panType, ...rest } = useCanvas();\n  const [dragType, setDragType] = useState<null | NodeDragType>(null);\n\n  useImperativeHandle(ref, () => ({\n    ...rest,\n    observe,\n    zoom,\n    xy,\n    layout,\n    canvasHeight,\n    containerRef,\n    canvasWidth,\n    svgRef,\n    positionCanvas,\n    setZoom,\n    zoomIn,\n    zoomOut,\n    fitCanvas,\n    setScrollXY\n  }));\n\n  const mount = useRef<boolean>(false);\n  const panStartScrollPosition = useRef<{ x: number; y: number }>({ x: 0, y: 0 });\n\n  const dragNodeData = useMemo(() => getDragNodeData(canvasDragNode, layout?.children), [canvasDragNode, layout?.children]);\n  const [dragNodeDataWithChildren, setDragNodeDataWithChildren] = useState<{\n    [key: string]: any;\n  }>(dragNodeData);\n  const dragNodeElement = useMemo(() => (typeof dragNode === 'function' ? dragNode(dragNodeData as NodeProps) : dragNode), [dragNode, dragNodeData]);\n  useLayoutEffect(() => {\n    if (!mount.current && layout !== null && xy[0] > 0 && xy[1] > 0) {\n      mount.current = true;\n    }\n  }, [layout, xy]);\n\n  useGesture(\n    {\n      onDrag: ({ movement: [mx, my] }) => {\n        // Update container scroll position during drag\n        if (containerRef.current && !canvasDragNode) {\n          containerRef.current.scrollLeft = panStartScrollPosition.current.x - mx;\n          containerRef.current.scrollTop = panStartScrollPosition.current.y - my;\n        }\n      },\n      onDragStart: () => {\n        // Store the initial scroll position of the container when drag starts\n        panStartScrollPosition.current = {\n          x: containerRef.current?.scrollLeft || 0,\n          y: containerRef.current?.scrollTop || 0\n        };\n      },\n      onWheel: ({ event, delta, last }) => {\n        !last && event.preventDefault();\n\n        const zoomFactor = delta[1] * -0.02;\n\n        if (delta[1] > 0) {\n          zoomOut(zoomFactor);\n        } else {\n          zoomIn(zoomFactor);\n        }\n      }\n    },\n    {\n      enabled: pannable && panType === 'drag',\n      eventOptions: { passive: false },\n      domTarget: containerRef\n    }\n  );\n\n  const onDragStart = useCallback((event) => {\n    setDragType(event.dragType);\n  }, []);\n\n  const createDragNodeChildren = useCallback(\n    (children: any) => {\n      if (!children || !Array.isArray(children)) {\n        return [];\n      }\n\n      return children.map(({ children, ...n }) => {\n        const element = typeof dragNode === 'function' ? dragNode(n as NodeProps) : dragNode;\n        return <CloneElement<NodeProps> key={`${id}-node-${n.id}-node-drag`} element={element} disabled children={element.props.children} animated={animated} nodes={children} childEdge={dragEdge} childNode={dragNode} {...n} onDragStart={onDragStart} id={`${id}-node-${n.id}-node-drag`} />;\n      });\n    },\n    // Passing in dragEdge (JSX) will cause the function to be recalculated constantly,\n    // triggering the below useEffect. Since dragEdge and dragNode are passed in props\n    // on Canvas, they are unlikely to change and can be ignored\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n    [animated, id]\n  );\n\n  useEffect(() => {\n    if (dragNodeData && Object.keys(dragNodeData).length > 0) {\n      const nodeCopy = { ...dragNodeData };\n      // Node children is expecting a list of React Elements, need to create a list of elements\n      nodeCopy.children = createDragNodeChildren(nodeCopy.children);\n      setDragNodeDataWithChildren(nodeCopy);\n    }\n  }, [createDragNodeChildren, dragNodeData, layout?.children]);\n\n  return (\n    <div\n      style={{ height, width }}\n      className={classNames(css.container, className, {\n        [css.pannable]: pannable,\n        [css.draggable]: panType === 'drag'\n      })}\n      ref={(el) => {\n        // Really not a fan of this API change...\n        // https://github.com/wellyshen/react-cool-dimensions#how-to-share-a-ref\n        observe(el);\n\n        // @ts-ignore\n        containerRef.current = el;\n      }}\n      onMouseEnter={onMouseEnter}\n      onMouseLeave={onMouseLeave}\n    >\n      <svg xmlns=\"http://www.w3.org/2000/svg\" id={id} ref={svgRef} height={canvasHeight} width={canvasWidth} onClick={onCanvasClick}>\n        {arrow !== null && (\n          <defs>\n            <CloneElement<MarkerArrowProps> element={arrow} {...(arrow as MarkerArrowProps)} />\n          </defs>\n        )}\n        <motion.g\n          initial={{\n            opacity: 0,\n            scale: 0,\n            transition: {\n              translateX: false,\n              translateY: false\n            }\n          }}\n          animate={{\n            opacity: 1,\n            translateX: xy[0],\n            translateY: xy[1],\n            scale: zoom,\n            transition: animated\n              ? {\n                velocity: 100,\n                translateX: { duration: mount.current ? 0.3 : 0 },\n                translateY: { duration: mount.current ? 0.3 : 0 },\n                opacity: { duration: 0.8 },\n                when: 'beforeChildren'\n              }\n              : {\n                type: false,\n                duration: 0,\n                when: 'beforeChildren'\n              }\n          }}\n        >\n          {layout?.children?.map(({ children, ...n }) => {\n            const element = typeof node === 'function' ? node(n) : node;\n            return <CloneElement<NodeProps> key={n.id} element={element} disabled={disabled} children={element.props.children} animated={animated} nodes={children} childEdge={edge} childNode={node} {...n} onDragStart={onDragStart} id={`${id}-node-${n.id}`} />;\n          })}\n          {layout?.edges?.map((e) => {\n            const element = typeof edge === 'function' ? edge(e) : edge;\n            return (\n              <CloneElement<EdgeProps>\n                key={e.id}\n                element={element}\n                disabled={disabled}\n                children={element.props.children}\n                {...e}\n                properties={{\n                  ...e.properties,\n                  ...(e.data ? { data: e.data } : {})\n                }}\n                id={`${id}-edge-${e.id}`}\n              />\n            );\n          })}\n          {dragCoords !== null && dragEdge && dragType === 'port' && !readonly && <CloneElement<EdgeProps> element={dragEdge} id={`${id}-edge-drag`} disabled sections={dragCoords} />}\n          {layout?.children?.map(({ children, ports, ...n }) => (\n            <Fragment key={n.id}>\n              {ports?.length > 0 && (\n                <motion.g\n                  key={n.id}\n                  initial={{\n                    translateX: n.x,\n                    translateY: n.y\n                  }}\n                  animate={{\n                    translateX: n.x,\n                    translateY: n.y\n                  }}\n                  transition={{ duration: 0 }}\n                >\n                  {ports.map((port, index) => (\n                    <use key={index} xlinkHref={`#${id}-node-${n.id}-port-${port.id}`} style={{ pointerEvents: 'none' }} />\n                  ))}\n                </motion.g>\n              )}\n            </Fragment>\n          ))}\n          {dragCoords !== null && dragNodeDataWithChildren && dragType === 'node' && !readonly && <CloneElement<NodeProps> {...dragNodeDataWithChildren} element={dragNodeElement} height={dragNodeDataWithChildren?.props?.height || dragNodeDataWithChildren?.height} width={dragNodeDataWithChildren?.props?.width || dragNodeDataWithChildren?.width} id={`${id}-node-drag`} animated={animated} className={css.dragNode} disabled x={dragCoords[0].endPoint.x} y={dragCoords[0].endPoint.y} />}\n        </motion.g>\n      </svg>\n    </div>\n  );\n});\n\nexport const Canvas: FC<CanvasContainerProps & { ref?: Ref<CanvasRef> }> = forwardRef(({ selections = [], readonly = false, fit = false, nodes = [], edges = [], maxHeight = 2000, maxWidth = 2000, direction = 'DOWN', pannable = true, panType = 'scroll', zoom = 1, defaultPosition = CanvasPosition.CENTER, zoomable = true, minZoom = -0.5, maxZoom = 1, onNodeLink = () => undefined, onNodeLinkCheck = () => undefined, onLayoutChange = () => undefined, onZoomChange = () => undefined, layoutOptions, ...rest }, ref: Ref<CanvasRef>) => (\n  <CanvasProvider layoutOptions={layoutOptions} nodes={nodes} edges={edges} zoom={zoom} defaultPosition={defaultPosition} minZoom={minZoom} maxZoom={maxZoom} fit={fit} maxHeight={maxHeight} maxWidth={maxWidth} direction={direction} pannable={pannable} panType={panType} zoomable={zoomable} readonly={readonly} onLayoutChange={onLayoutChange} selections={selections} onZoomChange={onZoomChange} onNodeLink={onNodeLink} onNodeLinkCheck={onNodeLinkCheck}>\n    <InternalCanvas ref={ref} {...rest} />\n  </CanvasProvider>\n));\n","import React, { FC } from 'react';\nimport classNames from 'classnames';\nimport css from './Icon.module.css';\n\nexport interface IconProps {\n  x: number;\n  y: number;\n  url: string;\n  height: number;\n  width: number;\n  style?: any;\n  className?: string;\n}\n\nexport const Icon: FC<Partial<IconProps>> = ({\n  x,\n  y,\n  url,\n  style,\n  className,\n  height = 40,\n  width = 40\n}) => (\n  <g\n    className={classNames(css.icon, className)}\n    transform={`translate(${x - width / 2}, ${y - height / 2})`}\n  >\n    <image style={style} xlinkHref={url} width={width} height={height} />\n  </g>\n);\n","import { EdgeData, NodeData, PortData } from '../types';\n\n/**\n * Helper function for upserting a node in a edge.\n */\nexport function upsertNode(\n  nodes: NodeData[],\n  edges: EdgeData[],\n  edge: EdgeData,\n  newNode: NodeData\n) {\n  const oldEdgeIndex = edges.findIndex((e) => e.id === edge.id);\n  const edgeBeforeNewNode = {\n    ...edge,\n    id: `${edge.from}-${newNode.id}`,\n    to: newNode.id\n  };\n  const edgeAfterNewNode = {\n    ...edge,\n    id: `${newNode.id}-${edge.to}`,\n    from: newNode.id\n  };\n\n  if (edge.fromPort && edge.toPort) {\n    edgeBeforeNewNode.fromPort = edge.fromPort;\n    edgeBeforeNewNode.toPort = `${newNode.id}-to`;\n\n    edgeAfterNewNode.fromPort = `${newNode.id}-from`;\n    edgeAfterNewNode.toPort = edge.toPort;\n  }\n\n  edges.splice(oldEdgeIndex, 1, edgeBeforeNewNode, edgeAfterNewNode);\n\n  return {\n    nodes: [...nodes, newNode],\n    edges: [...edges]\n  };\n}\n\n/**\n * Helper function for removing a node between edges and\n * linking the children.\n */\nexport function removeAndUpsertNodes(\n  nodes: NodeData[],\n  edges: EdgeData[],\n  removeNodes: NodeData | NodeData[],\n  onNodeLinkCheck?: (\n    newNodes: NodeData[],\n    newEdges: EdgeData[],\n    from: NodeData,\n    to: NodeData,\n    port?: PortData\n  ) => undefined | boolean\n) {\n  if (!Array.isArray(removeNodes)) {\n    removeNodes = [removeNodes];\n  }\n\n  const nodeIds = removeNodes.map((n) => n.id);\n  const newNodes = nodes.filter((n) => !nodeIds.includes(n.id));\n  const newEdges = edges.filter(\n    (e) => !nodeIds.includes(e.from) && !nodeIds.includes(e.to)\n  );\n\n  for (const nodeId of nodeIds) {\n    const sourceEdges = edges.filter((e) => e.to === nodeId);\n    const targetEdges = edges.filter((e) => e.from === nodeId);\n\n    for (const sourceEdge of sourceEdges) {\n      for (const targetEdge of targetEdges) {\n        const sourceNode = nodes.find((n) => n.id === sourceEdge.from);\n        const targetNode = nodes.find((n) => n.id === targetEdge.to);\n        if (sourceNode && targetNode) {\n          const canLink = onNodeLinkCheck?.(\n            newNodes,\n            newEdges,\n            sourceNode,\n            targetNode\n          );\n          if (canLink === undefined || canLink) {\n            newEdges.push({\n              id: `${sourceNode.id}-${targetNode.id}`,\n              from: sourceNode.id,\n              to: targetNode.id,\n              parent: sourceNode?.parent\n            });\n          }\n        }\n      }\n    }\n  }\n\n  return {\n    edges: newEdges,\n    nodes: newNodes\n  };\n}\n\n/**\n * Helper function to remove a node and its related edges.\n */\nexport function removeNode(\n  nodes: NodeData[],\n  edges: EdgeData[],\n  removeNodes: string | string[]\n) {\n  if (!Array.isArray(removeNodes)) {\n    removeNodes = [removeNodes];\n  }\n\n  const newNodes = [];\n  const newEdges = [];\n\n  for (const node of nodes) {\n    const has = removeNodes.some((n) => n === node.id);\n    if (!has) {\n      newNodes.push(node);\n    }\n  }\n\n  for (const edge of edges) {\n    const has = removeNodes.some((n) => n === edge.from || n === edge.to);\n    if (!has) {\n      newEdges.push(edge);\n    }\n  }\n\n  return {\n    nodes: newNodes,\n    edges: newEdges\n  };\n}\n\n/**\n * Helper function to remove a node's related edges.\n */\nexport function removeEdgesFromNode(nodeId: string, edges: EdgeData[]) {\n  return edges.filter((edge) => !(edge.to === nodeId || edge.from === nodeId));\n}\n\n/**\n * Remove edge(s)\n */\nexport function removeEdge(edges: EdgeData[], edge: EdgeData | EdgeData[]) {\n  const deletions: EdgeData[] = !Array.isArray(edge) ? [edge] : edge;\n  const edgeIds = deletions.map((e) => e.id);\n  return edges.filter((e) => !edgeIds.includes(e.id));\n}\n\n/**\n * Create an edge given 2 nodes.\n */\nexport function createEdgeFromNodes(fromNode: NodeData, toNode: NodeData) {\n  return {\n    id: `${fromNode.id}-${toNode.id}`,\n    from: fromNode.id,\n    to: toNode.id,\n    parent: toNode.parent\n  };\n}\n\n/**\n * Add a node and optional edge.\n */\nexport function addNodeAndEdge(\n  nodes: NodeData[],\n  edges: EdgeData[],\n  node: NodeData,\n  toNode?: NodeData\n) {\n  return {\n    nodes: [...nodes, node],\n    edges: [...edges, ...(toNode ? [createEdgeFromNodes(toNode, node)] : [])]\n  };\n}\n","import React, { useState } from 'react';\nimport { useHotkeys } from 'reakeys';\nimport { EdgeData, NodeData } from '../types';\nimport { removeNode } from './crudHelpers';\n\nexport type HotkeyTypes = 'selectAll' | 'deselect' | 'delete';\n\nexport interface SelectionProps {\n  /**\n   * Current selections.\n   *\n   * Contains both nodes and edges ids.\n   */\n  selections?: string[];\n\n  /**\n   * Node datas.\n   */\n  nodes?: NodeData[];\n\n  /**\n   * Edge datas.\n   */\n  edges?: EdgeData[];\n\n  /**\n   * Disabled or not.\n   */\n  disabled?: boolean;\n\n  /**\n   * Hotkey types\n   */\n  hotkeys?: HotkeyTypes[];\n\n  /**\n   * On selection change.\n   */\n  onSelection?: (newSelectedIds: string[]) => void;\n\n  /**\n   * On data change.\n   */\n  onDataChange?: (nodes: NodeData[], edges: EdgeData[]) => void;\n}\n\nexport interface SelectionResult {\n  /**\n   * Selections id array (of nodes and edges).\n   */\n  selections: string[];\n\n  /**\n   * Clear selections method.\n   */\n  clearSelections: (value?: string[]) => void;\n\n  /**\n   * A selection method.\n   */\n  addSelection: (value: string) => void;\n\n  /**\n   * Remove selection method.\n   */\n  removeSelection: (value: string) => void;\n\n  /**\n   * Toggle existing selection on/off method.\n   */\n  toggleSelection: (value: string) => void;\n\n  /**\n   * Set internal selections.\n   */\n  setSelections: (value: string[]) => void;\n\n  /**\n   * On click event pass through.\n   */\n  onClick?: (\n    event: React.MouseEvent<SVGGElement, MouseEvent>,\n    data: any\n  ) => void;\n\n  /**\n   * On canvas click event pass through.\n   */\n  onCanvasClick?: (event?: React.MouseEvent<SVGGElement, MouseEvent>) => void;\n\n  /**\n   * On keydown event pass through.\n   */\n  onKeyDown?: (event: React.KeyboardEvent<SVGGElement>) => void;\n}\n\nexport const useSelection = ({\n  selections = [],\n  nodes = [],\n  edges = [],\n  hotkeys = ['selectAll', 'deselect', 'delete'],\n  disabled,\n  onSelection,\n  onDataChange\n}: SelectionProps): SelectionResult => {\n  const [internalSelections, setInternalSelections] =\n    useState<string[]>(selections);\n  const [metaKeyDown, setMetaKeyDown] = useState<boolean>(false);\n\n  const addSelection = (item: string) => {\n    if (!disabled) {\n      const has = internalSelections.includes(item);\n      if (!has) {\n        const next = [...internalSelections, item];\n        onSelection?.(next);\n        setInternalSelections(next);\n      }\n    }\n  };\n\n  const removeSelection = (item: string) => {\n    if (!disabled) {\n      const has = internalSelections.includes(item);\n      if (has) {\n        const next = internalSelections.filter((i) => i !== item);\n        onSelection?.(next);\n        setInternalSelections(next);\n      }\n    }\n  };\n\n  const toggleSelection = (item: string) => {\n    const has = internalSelections.includes(item);\n    if (has) {\n      removeSelection(item);\n    } else {\n      addSelection(item);\n    }\n  };\n\n  const clearSelections = (next = []) => {\n    if (!disabled) {\n      setInternalSelections(next);\n      onSelection?.(next);\n    }\n  };\n\n  const onClick = (event, data) => {\n    event.preventDefault();\n    event.stopPropagation();\n\n    if (!metaKeyDown) {\n      clearSelections([data.id]);\n    } else {\n      toggleSelection(data.id);\n    }\n\n    setMetaKeyDown(false);\n  };\n\n  const onKeyDown = (event) => {\n    event.preventDefault();\n    setMetaKeyDown(event.metaKey || event.ctrlKey);\n  };\n\n  const onCanvasClick = () => {\n    clearSelections();\n    setMetaKeyDown(false);\n  };\n\n  useHotkeys([\n    {\n      name: 'Select All',\n      keys: 'mod+a',\n      disabled: !hotkeys.includes('selectAll'),\n      category: 'Canvas',\n      description: 'Select all nodes and edges',\n      callback: (event) => {\n        event.preventDefault();\n\n        if (!disabled) {\n          const next = nodes.map((n) => n.id);\n          onDataChange?.(nodes, edges);\n          onSelection?.(next);\n          setInternalSelections(next);\n        }\n      }\n    },\n    {\n      name: 'Delete Selections',\n      category: 'Canvas',\n      disabled: !hotkeys.includes('delete'),\n      description: 'Delete selected nodes and edges',\n      keys: 'backspace',\n      callback: (event) => {\n        if (!disabled) {\n          event.preventDefault();\n          const result = removeNode(nodes, edges, internalSelections);\n          onDataChange?.(result.nodes, result.edges);\n          onSelection?.([]);\n          setInternalSelections([]);\n        }\n      }\n    },\n    {\n      name: 'Deselect Selections',\n      category: 'Canvas',\n      disabled: !hotkeys.includes('deselect'),\n      description: 'Deselect selected nodes and edges',\n      keys: 'escape',\n      callback: (event) => {\n        if (!disabled) {\n          event.preventDefault();\n          onSelection?.([]);\n          setInternalSelections([]);\n        }\n      }\n    }\n  ]);\n\n  return {\n    onClick,\n    onKeyDown,\n    onCanvasClick,\n    selections: internalSelections,\n    clearSelections,\n    addSelection,\n    removeSelection,\n    toggleSelection,\n    setSelections: setInternalSelections\n  };\n};\n","import { useCallback, useEffect, useRef, useState } from 'react';\nimport { useHotkeys } from 'reakeys';\nimport { EdgeData, NodeData } from '../types';\nimport Undoo from 'undoo';\n\nexport interface UndoRedoEvent {\n  /**\n   * Updated node datas.\n   */\n  nodes?: NodeData[];\n\n  /**\n   * Updated edge datas.\n   */\n  edges?: EdgeData[];\n\n  /**\n   * Type of change.\n   */\n  type: 'undo' | 'redo' | 'clear';\n\n  /**\n   * Whether you can undo now.\n   */\n  canUndo: boolean;\n\n  /**\n   * Whether you can redo now.\n   */\n  canRedo: boolean;\n}\n\nexport interface UndoProps {\n  /**\n   * Current node datas.\n   */\n  nodes: NodeData[];\n\n  /**\n   * Current edge datas.\n   */\n  edges: EdgeData[];\n\n  /**\n   * Max history count.\n   *\n   * @default 20\n   */\n  maxHistory?: number;\n\n  /**\n   * Disabled or not.\n   *\n   * @default false\n   */\n  disabled?: boolean;\n\n  /**\n   * On undo/redo event handler.\n   */\n  onUndoRedo: (state: UndoRedoEvent) => void;\n}\n\nexport interface UndoResult {\n  /**\n   * Can undo or not.\n   */\n  canUndo: boolean;\n\n  /**\n   * Can redo or not.\n   */\n  canRedo: boolean;\n\n  /**\n   * Count of existing changes.\n   */\n  count: () => number;\n\n  /**\n   * Clear state.\n   */\n  clear: (nodes: NodeData[], edges: EdgeData[]) => void;\n\n  /**\n   * Get history of state.\n   */\n  history: () => { nodes: NodeData[]; edges: EdgeData[] }[];\n\n  /**\n   * Perform an redo.\n   */\n  redo: () => void;\n\n  /**\n   * Perform a undo.\n   */\n  undo: () => void;\n}\n\nexport const useUndo = ({\n  nodes,\n  edges,\n  disabled,\n  maxHistory = 20,\n  onUndoRedo\n}: UndoProps): UndoResult => {\n  const [canUndo, setCanUndo] = useState<boolean>(false);\n  const [canRedo, setCanRedo] = useState<boolean>(false);\n\n  const manager = useRef<Undoo>(\n    new Undoo({\n      maxLength: maxHistory\n    })\n  );\n\n  // Reference: https://reactjs.org/docs/hooks-faq.html#how-to-read-an-often-changing-value-from-usecallback\n  const callbackRef = useRef(onUndoRedo);\n  useEffect(() => {\n    callbackRef.current = onUndoRedo;\n  }, [onUndoRedo]);\n\n  useEffect(() => {\n    manager.current.save({\n      nodes,\n      edges\n    });\n\n    setCanUndo(manager.current.canUndo());\n    setCanRedo(manager.current.canRedo());\n  }, [nodes, edges]);\n\n  const undo = useCallback(() => {\n    manager.current.undo((state) => {\n      const nextUndo = manager.current.canUndo();\n      const nextRedo = manager.current.canRedo();\n      setCanUndo(nextUndo);\n      setCanRedo(nextRedo);\n\n      callbackRef.current({\n        ...state,\n        type: 'undo',\n        canUndo: nextUndo,\n        canRedo: nextRedo\n      });\n    });\n  }, []);\n\n  const redo = useCallback(() => {\n    manager.current.redo((state) => {\n      const nextUndo = manager.current.canUndo();\n      const nextRedo = manager.current.canRedo();\n      setCanUndo(nextUndo);\n      setCanRedo(nextRedo);\n\n      callbackRef.current({\n        ...state,\n        type: 'redo',\n        canUndo: nextUndo,\n        canRedo: nextRedo\n      });\n    });\n  }, []);\n\n  const clear = useCallback((nodes: NodeData[], edges: EdgeData[]) => {\n    manager.current.clear();\n    setCanUndo(false);\n    setCanRedo(false);\n\n    callbackRef.current({\n      type: 'clear',\n      canUndo: false,\n      canRedo: false\n    });\n\n    manager.current.save({\n      nodes,\n      edges\n    });\n  }, []);\n\n  useHotkeys([\n    {\n      name: 'Undo',\n      keys: 'mod+z',\n      category: 'Canvas',\n      description: 'Undo changes',\n      callback: (event) => {\n        event.preventDefault();\n        if (!disabled && canUndo) {\n          undo();\n        }\n      }\n    },\n    {\n      name: 'Redo',\n      keys: 'mod+shift+z',\n      category: 'Canvas',\n      description: 'Redo changes',\n      callback: (event) => {\n        event.preventDefault();\n        if (!disabled && canRedo) {\n          redo();\n        }\n      }\n    }\n  ]);\n\n  return {\n    canUndo,\n    canRedo,\n    count: () => manager.current.count(),\n    history: () => manager.current.history(),\n    clear,\n    redo,\n    undo\n  } as UndoResult;\n};\n","import { RefObject, useCallback, useEffect, useRef, useState } from 'react';\nimport { CanvasRef } from '../Canvas';\nimport { getCoords } from '../utils/helpers';\nimport { Matrix2D, Point2D } from 'kld-affine';\nimport { IntersectionQuery } from 'kld-intersections';\nimport { LayoutNodeData } from '../types';\n\nexport interface ProximityProps {\n  /**\n   * Disable proximity or not.\n   */\n  disabled?: boolean;\n\n  /**\n   * Min distance required before match is made.\n   *\n   * @default 40\n   */\n  minDistance?: number;\n\n  /**\n   * Ref pointer to the canvas.\n   */\n  canvasRef?: RefObject<CanvasRef>;\n\n  /**\n   * Distance from the match.\n   */\n  onDistanceChange?: (distance: number | null) => void;\n\n  /**\n   * When a match state has changed.\n   */\n  onMatchChange?: (matche: string | null, distance: number | null) => void;\n\n  /**\n   * When the pointer intersects a node.\n   */\n  onIntersects?: (matche: string | null) => void;\n}\n\nexport interface ProximityResult {\n  /**\n   * The matched id of the node.\n   */\n  match: string | null;\n\n  /**\n   * Event for drag started.\n   */\n  onDragStart: (event: PointerEvent) => void;\n\n  /**\n   * Event for active dragging.\n   */\n  onDrag: (event: PointerEvent) => void;\n\n  /**\n   * Event for drag ended.\n   */\n  onDragEnd: (event: PointerEvent) => void;\n}\n\ninterface PointNode {\n  points: Point2D[];\n  node: LayoutNodeData;\n}\n\nconst buildPoints = (nodes: LayoutNodeData[], parent?: LayoutNodeData) => {\n  const results: PointNode[] = [];\n\n  if (nodes?.length) {\n    for (const node of nodes) {\n      let x = node.x;\n      let y = node.y;\n\n      // NOTE: If we have a parent, let's update the points\n      // to account for the parent's position\n      if (parent) {\n        x = parent.x + x;\n        y = parent.y + y;\n      }\n\n      const points = [\n        // top-left\n        new Point2D(x, y),\n        // bottom-right\n        new Point2D(x + node.width, y + node.height)\n      ];\n\n      results.push({\n        points,\n        node\n      });\n\n      if (node.children?.length) {\n        results.push(...buildPoints(node.children, node));\n      }\n    }\n  }\n\n  return results;\n};\n\nconst distanceFromNode = (mousePoint: Point2D, node: PointNode) => {\n  const [tl, br] = node.points;\n  let dx = 0;\n  let dy = 0;\n\n  // Compute distance to elem in X\n  if (mousePoint.x < tl.x) {\n    dx = tl.x - mousePoint.x;\n  } else if (mousePoint.x > br.x) {\n    dx = br.x - mousePoint.x;\n  }\n\n  // Compute distance to elem in Y\n  if (mousePoint.y < tl.y) {\n    dy = tl.y - mousePoint.y;\n  } else if (mousePoint.y > br.y) {\n    dy = br.y - mousePoint.y;\n  }\n\n  return Math.floor(Math.sqrt(dx * dx + dy * dy));\n};\n\nconst findNodeIntersection = (\n  event: PointerEvent,\n  matrix: Matrix2D,\n  points: PointNode[],\n  minDistance: number\n) => {\n  const cubes = [];\n  const mousePoint = new Point2D(event.x, event.y).transform(matrix);\n\n  for (const point of points) {\n    // TODO: Make this support other shape types...\n    const intersects = IntersectionQuery.pointInRectangle(\n      mousePoint,\n      point.points[0],\n      point.points[1]\n    );\n\n    // Calc the distances\n    // https://github.com/thelonious/kld-affine/issues/24\n    const minDist = distanceFromNode(mousePoint, point);\n\n    cubes.push({\n      node: point.node,\n      minDist,\n      intersects\n    });\n  }\n\n  let foundDist = minDistance;\n  let intersectedNodeId = null;\n  let foundNodeId = null;\n  for (const cube of cubes) {\n    if (cube.minDist < foundDist && !cube.intersects) {\n      foundNodeId = cube.node.id;\n      foundDist = cube.minDist;\n    }\n\n    if (cube.intersects) {\n      intersectedNodeId = cube.node.id;\n    }\n  }\n\n  if (intersectedNodeId) {\n    // We are are just inside a node already\n    // and there is no closer children ( nested case )\n    if (!foundNodeId || foundNodeId === intersectedNodeId) {\n      // If we are inside the intersected node and its the\n      // closest node, let's reset the distance to 0\n      foundNodeId = intersectedNodeId;\n      foundDist = 0;\n    }\n  }\n\n  return {\n    intersectedNodeId,\n    foundNodeId,\n    foundDist\n  };\n};\n\nexport const useProximity = ({\n  canvasRef,\n  disabled,\n  minDistance = 40,\n  ...rest\n}: ProximityProps) => {\n  const lastIntersectRef = useRef<string | null>(null);\n  const lastMatchRef = useRef<string | null>(null);\n  const lastDistance = useRef<number | null>(null);\n  const frame = useRef<number>(0);\n\n  // Reference: https://reactjs.org/docs/hooks-faq.html#how-to-read-an-often-changing-value-from-usecallback\n  const eventRefs = useRef(rest);\n  useEffect(() => {\n    eventRefs.current = rest;\n  }, [rest]);\n\n  const [match, setMatch] = useState<string | null>(null);\n  const [matrix, setMatrix] = useState<Matrix2D | null>(null);\n  const [points, setPoints] = useState<PointNode[] | null>(null);\n\n  const onDragStart = useCallback(() => {\n    if (disabled) {\n      return;\n    }\n\n    const ref = canvasRef.current;\n\n    // @ts-ignore\n    setMatrix(\n      getCoords({\n        containerRef: ref.containerRef,\n        zoom: ref.zoom,\n        layoutXY: ref.xy\n      })\n    );\n    setPoints(buildPoints(ref.layout.children));\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [disabled]);\n\n  const onDrag = useCallback(\n    (event: PointerEvent) => {\n      if (!matrix || disabled) {\n        return;\n      }\n\n      const { onMatchChange, onIntersects, onDistanceChange } =\n        eventRefs.current;\n\n      const { intersectedNodeId, foundNodeId, foundDist } =\n        findNodeIntersection(event, matrix, points, minDistance);\n      const nextDist = foundDist !== minDistance ? foundDist : null;\n\n      if (foundNodeId !== lastMatchRef.current) {\n        onMatchChange?.(foundNodeId, foundDist);\n      }\n\n      if (intersectedNodeId !== lastIntersectRef.current) {\n        onIntersects?.(intersectedNodeId);\n      }\n\n      if (onDistanceChange && nextDist !== lastDistance.current) {\n        cancelAnimationFrame(frame.current);\n        frame.current = requestAnimationFrame(() => {\n          onDistanceChange(nextDist);\n        });\n      }\n\n      // Hold these in refs for race cases\n      lastIntersectRef.current = intersectedNodeId;\n      lastMatchRef.current = foundNodeId;\n      lastDistance.current = nextDist;\n\n      setMatch(foundNodeId);\n    },\n    [matrix, disabled, minDistance, points]\n  );\n\n  useEffect(() => {\n    return () => cancelAnimationFrame(frame.current);\n  });\n\n  const onDragEnd = useCallback(() => {\n    if (!disabled) {\n      setMatch(null);\n      setMatrix(null);\n      setPoints(null);\n    }\n  }, [disabled]);\n\n  return {\n    match,\n    onDragStart,\n    onDrag,\n    onDragEnd\n  } as ProximityResult;\n};\n","import { EdgeData, NodeData } from '../types';\n\n/**\n * Helper function to determine if edge already has a link.\n */\nexport function hasLink(edges: EdgeData[], from: NodeData, to: NodeData) {\n  return edges.some((e) => e.from === from.id && e.to === to.id);\n}\n\n/**\n * Get sources pointing to a node.\n */\nfunction getSourceNodesForTargetId(\n  nodes: NodeData[],\n  edges: EdgeData[],\n  nodeId: string\n) {\n  const sourceNodeIds = edges.reduce((acc, edge) => {\n    if (edge.to === nodeId) {\n      acc.push(edge.from);\n    }\n    return acc;\n  }, []);\n\n  const node = nodes.find((n) => n.id === nodeId);\n\n  if (node?.parent) {\n    sourceNodeIds.push(node.parent);\n  }\n\n  return nodes.filter((n) => sourceNodeIds.includes(n.id));\n}\n\n/**\n * Detect if there is a circular reference from the from to the source node.\n */\nexport function detectCircular(\n  nodes: NodeData[],\n  edges: EdgeData[],\n  fromNode: NodeData,\n  toNode: NodeData\n) {\n  let found = false;\n\n  const traverse = (nodeId: string) => {\n    const sourceNodes = getSourceNodesForTargetId(nodes, edges, nodeId);\n    for (const node of sourceNodes) {\n      if (node.id !== toNode.id) {\n        traverse(node.id);\n      } else {\n        found = true;\n        break;\n      }\n    }\n  };\n\n  traverse(fromNode.id);\n\n  return found;\n}\n\n/**\n * Given a node id, get all the parent nodes recursively.\n */\nexport const getParentsForNodeId = (\n  nodes: NodeData[],\n  edges: EdgeData[],\n  startId: string\n) => {\n  const result = [];\n\n  const traverse = (nodeId: string) => {\n    const sourceNodes = getSourceNodesForTargetId(nodes, edges, nodeId);\n    for (const node of sourceNodes) {\n      const has = result.find((n) => n.id === node.id);\n      if (!has) {\n        result.push(node);\n        traverse(node.id);\n      }\n    }\n  };\n\n  traverse(startId);\n\n  return result;\n};\n\n/**\n * Get edge data given a node.\n */\nexport function getEdgesByNode(edges: EdgeData[], node: NodeData) {\n  const to = [];\n  const from = [];\n\n  for (const edge of edges) {\n    if (edge.to === node.id) {\n      to.push(edge);\n    }\n    if (edge.from === node.id) {\n      from.push(edge);\n    }\n  }\n\n  return {\n    to,\n    from,\n    all: [...to, ...from]\n  };\n}\n"],"names":["CanvasPosition","text","children","port","edge","pannable","useRef","useState","xy","useEffect","useCallback","nodes","useLayoutEffect","dragNode","Point2D","disabled","useGesture","createContext","jsx","useContext","Matrix2D","useDrag","forwardRef","active","jsxs","css","motion","Fragment","path","deleteHovered","useMemo","line","d","curveBundle","CloneElement","icon","draggable","useAnimation","dragging","dragType","arrow","useId","useImperativeHandle","_a","_b","useHotkeys","edges","IntersectionQuery"],"mappings":";;;;AAEY,MAAA,mCAAAA,oBAAL;AACLA,oBAAA,QAAS,IAAA;AACTA,oBAAA,KAAM,IAAA;AACNA,oBAAA,MAAO,IAAA;AACPA,oBAAA,OAAQ,IAAA;AACRA,oBAAA,QAAS,IAAA;AALCA,WAAAA;AAAAA,EAAA,GAAA,kBAAA,CAAA,CAAA;ACEZ,QAAM,iBAAiB;AACvB,QAAM,iBAAiB;AACvB,QAAM,sBAAsB;AAC5B,QAAM,eAAe;AACrB,QAAM,eAAe;AAEd,WAAS,YAAYC,OAAc;AACxC,QAAI,SAAS,EAAE,QAAQ,GAAG,OAAO,EAAE;AAEnC,QAAIA,OAAM;AAGR,YAAM,KAAK,OAAO,kBAAkB,aAAa,gBAAgB,cAAc;AAC/E,eAAS,GAAGA,OAAM;AAAA,QAChB,MAAM;AAAA,QACN,UAAU;AAAA,MAAA,CACX;AAAA,IACH;AAEO,WAAA;AAAA,EACT;AAEO,WAAS,aAAa,SAAkC;AAC7D,QAAI,MAAM;AACV,QAAI,QAAQ;AACZ,QAAI,SAAS;AACb,QAAI,OAAO;AAEP,QAAA,MAAM,QAAQ,OAAO,GAAG;AACtB,UAAA,QAAQ,WAAW,GAAG;AACxB,cAAM,QAAQ,CAAC;AACf,iBAAS,QAAQ,CAAC;AAClB,eAAO,QAAQ,CAAC;AAChB,gBAAQ,QAAQ,CAAC;AAAA,MAAA,WACR,QAAQ,WAAW,GAAG;AAC/B,cAAM,QAAQ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