@next-bricks/diagram 0.68.6 → 0.68.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/bricks.json +1 -1
  2. package/dist/chunks/{3171.77fcc3d5.js → 3171.3bd2c8f0.js} +2 -2
  3. package/dist/chunks/{5552.a03dc5df.js.map → 3171.3bd2c8f0.js.map} +1 -1
  4. package/dist/chunks/3654.59bd8992.js +3 -0
  5. package/dist/chunks/{3654.485b2ee1.js.map → 3654.59bd8992.js.map} +1 -1
  6. package/dist/chunks/3746.591c50d8.js +2 -0
  7. package/dist/chunks/{3746.f01acf89.js.map → 3746.591c50d8.js.map} +1 -1
  8. package/dist/chunks/{7470.28763ed7.js → 4667.53203ccd.js} +2 -2
  9. package/dist/chunks/{7470.28763ed7.js.map → 4667.53203ccd.js.map} +1 -1
  10. package/dist/chunks/4765.0ab66eb8.js +2 -0
  11. package/dist/chunks/{4765.09fa27a9.js.map → 4765.0ab66eb8.js.map} +1 -1
  12. package/dist/chunks/{4837.23693f19.js → 4837.32dece7c.js} +2 -2
  13. package/dist/chunks/{7218.ae373a36.js.map → 4837.32dece7c.js.map} +1 -1
  14. package/dist/chunks/{5552.a03dc5df.js → 5552.e3e728b7.js} +2 -2
  15. package/dist/chunks/{3171.77fcc3d5.js.map → 5552.e3e728b7.js.map} +1 -1
  16. package/dist/chunks/577.c9c65352.js +2 -0
  17. package/dist/chunks/{577.8a00080d.js.map → 577.c9c65352.js.map} +1 -1
  18. package/dist/chunks/7146.564428f1.js +2 -0
  19. package/dist/chunks/{7146.a40fefdc.js.map → 7146.564428f1.js.map} +1 -1
  20. package/dist/chunks/{7218.ae373a36.js → 7218.e0bf22af.js} +2 -2
  21. package/dist/chunks/{4837.23693f19.js.map → 7218.e0bf22af.js.map} +1 -1
  22. package/dist/chunks/7920.df65d810.js +3 -0
  23. package/dist/chunks/7920.df65d810.js.map +1 -0
  24. package/dist/chunks/948.83e23068.js +3 -0
  25. package/dist/chunks/948.83e23068.js.map +1 -0
  26. package/dist/chunks/eo-draw-canvas.e01342d6.js +2 -0
  27. package/dist/chunks/{eo-draw-canvas.80ff662d.js.map → eo-draw-canvas.e01342d6.js.map} +1 -1
  28. package/dist/chunks/main.57e2b94a.js +2 -0
  29. package/dist/chunks/{main.16deb8ab.js.map → main.57e2b94a.js.map} +1 -1
  30. package/dist/index.cfc9b630.js +2 -0
  31. package/dist/index.cfc9b630.js.map +1 -0
  32. package/dist/types.json +74 -74
  33. package/package.json +5 -3
  34. package/dist/chunks/3654.485b2ee1.js +0 -3
  35. package/dist/chunks/3746.f01acf89.js +0 -2
  36. package/dist/chunks/4765.09fa27a9.js +0 -2
  37. package/dist/chunks/577.8a00080d.js +0 -2
  38. package/dist/chunks/7146.a40fefdc.js +0 -2
  39. package/dist/chunks/7920.367555e2.js +0 -3
  40. package/dist/chunks/7920.367555e2.js.map +0 -1
  41. package/dist/chunks/948.48c4319a.js +0 -3
  42. package/dist/chunks/948.48c4319a.js.map +0 -1
  43. package/dist/chunks/eo-draw-canvas.80ff662d.js +0 -2
  44. package/dist/chunks/main.16deb8ab.js +0 -2
  45. package/dist/index.e2b7a362.js +0 -2
  46. package/dist/index.e2b7a362.js.map +0 -1
  47. /package/dist/chunks/{3654.485b2ee1.js.LICENSE.txt → 3654.59bd8992.js.LICENSE.txt} +0 -0
  48. /package/dist/chunks/{7920.367555e2.js.LICENSE.txt → 7920.df65d810.js.LICENSE.txt} +0 -0
  49. /package/dist/chunks/{948.48c4319a.js.LICENSE.txt → 948.83e23068.js.LICENSE.txt} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"chunks/3746.f01acf89.js","mappings":"kMAGO,SAASA,EAAmBC,EAAgBC,GACjD,MAAO,CACLC,EAAGF,EAAKE,EAAIF,EAAKG,MAAQ,EACzBC,EAAGJ,EAAKI,EAAIJ,EAAKK,OAAS,EAC1BF,MAAOH,EAAKG,MAAQF,EACpBI,OAAQL,EAAKK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AKpD7Z,EAJFkzB,EACN,GACC6S,EAAkB9lC,EAAS4Z,GAAS,EAAI6rB,EAAa5zB,EAAM+H,EAEjD2J,EAAG3J,EACpB,C","sources":["webpack:///./src/shared/canvas/processors/nodeViewToNodeRect.ts","webpack:///./src/shared/canvas/processors/getSmartLinePoints.ts","webpack:///./src/draw-canvas/processors/getUnrelatedCells.ts","webpack:///./src/shared/canvas/useActiveTarget.ts","webpack:///./src/draw-canvas/processors/sameTarget.ts","webpack:///./src/draw-canvas/reducers/cells.ts","webpack:///./src/draw-canvas/reducers/index.ts","webpack:///./src/draw-canvas/reducers/layoutKey.ts","webpack:///./src/draw-canvas/LineLabelComponent.tsx","webpack:///./src/draw-canvas/EdgeComponent.tsx","webpack:///./src/draw-canvas/processors/getLabelMaskAndOffset.ts","webpack:///./src/draw-canvas/LockIcon.tsx","webpack:///./src/draw-canvas/NodeComponent.tsx","webpack:///./src/draw-canvas/processors/getSnapPositions.ts","webpack:///./src/draw-canvas/processors/handleMouseDown.ts","webpack:///./src/draw-canvas/processors/normalizeSnapOptions.ts","webpack:///./src/draw-canvas/processors/getContentEditable.ts","webpack:///./src/draw-canvas/decorators/DecoratorText.tsx","webpack:///./src/draw-canvas/decorators/index.tsx","webpack:///./src/draw-canvas/decorators/DecoratorGroup.tsx","webpack:///./src/draw-canvas/decorators/DecoratorContainer.tsx","webpack:///./src/draw-canvas/decorators/DecoratorArea.tsx","webpack:///./src/draw-canvas/decorators/DecoratorRect.tsx","webpack:///./src/draw-canvas/decorators/DecoratorLine.tsx","webpack:///./src/draw-canvas/processors/getLineLockIconPosition.ts","webpack:///./src/draw-canvas/CellComponent.tsx","webpack:///./src/draw-canvas/SmartConnectLineComponent.tsx","webpack:///./src/shared/canvas/processors/getConnectLinePoints.ts","webpack:///./src/draw-canvas/processors/handleKeyboard.ts","webpack:///./src/shared/canvas/useLineMarkers.ts","webpack:///./src/shared/canvas/processors/getEditingLinePoints.ts","webpack:///./src/draw-canvas/EditingLineComponent.tsx","webpack:///./src/draw-canvas/processors/initializeCells.ts","webpack:///./src/draw-canvas/processors/normalizeAlignOrigin.ts","webpack:///./src/shared/canvas/useLayout.ts","webpack:///./src/shared/canvas/useAutoCenter.ts","webpack:///./src/draw-canvas/processors/toggleLock.ts","webpack:///./src/shared/canvas/useReady.ts","webpack:///./src/draw-canvas/processors/isLocked.ts","webpack:///./src/shared/canvas/styles.shadow.css","webpack:///./src/draw-canvas/LineConnectorComponent.tsx","webpack:///./src/draw-canvas/constants.ts","webpack:///./src/shared/canvas/processors/getCellsRect.ts","webpack:///../../src/mergeRects.ts","webpack:///./src/draw-canvas/processors/handleNodeContainedChange.ts","webpack:///./src/draw-canvas/HoverStateContext.ts","webpack:///./src/draw-canvas/processors/asserts.ts","webpack:///./src/draw-canvas/processors/findNodeOrAreaDecorator.ts","webpack:///./src/shared/canvas/collectLineJumpsFactory.ts","webpack:///./src/shared/canvas/useEditableLineMap.ts","webpack:///./src/draw-canvas/LineEditorComponent.tsx","webpack:///./src/draw-canvas/processors/targetIsActive.ts","webpack:///./src/draw-canvas/processors/staggeredLayout.ts","webpack:///./src/draw-canvas/processors/computeBoundingBox.ts","webpack:///./src/draw-canvas/processors/generateNewPointsWithLayout.ts","webpack:///./src/draw-canvas/processors/updateCells.ts","webpack:///./src/draw-canvas/processors/transformToCenter.ts","webpack:///./src/draw-canvas/ConnectLineComponent.tsx","webpack:///./src/shared/canvas/ZoomBarComponent.shadow.css","webpack:///./src/shared/canvas/icons/center.svg","webpack:///./src/shared/canvas/icons/zoom-in.svg","webpack:///./src/shared/canvas/icons/zoom-out.svg","webpack:///./src/shared/canvas/ZoomBarComponent.tsx","webpack:///./src/draw-canvas/processors/cellToTarget.ts","webpack:///./src/draw-canvas/processors/handleLasso.ts","webpack:///./src/shared/canvas/forceLayout.ts","webpack:///./src/shared/canvas/useZoom.ts","webpack:///./src/shared/canvas/dagreLayout.ts","webpack:///./src/draw-canvas/processors/initialGroupLayout.ts","webpack:///./src/draw-canvas/processors/initialContainerLayout.ts","webpack:///./src/shared/canvas/shapes/Rectangle.ts","webpack:///./src/shared/canvas/processors/getTransformToCenter.ts"],"sourcesContent":["import type { NodeRect } from \"../../../diagram/interfaces\";\nimport type { NodeView } from \"../../../draw-canvas/interfaces\";\n\nexport function nodeViewToNodeRect(view: NodeView, padding: number): NodeRect {\n return {\n x: view.x + view.width / 2,\n y: view.y + view.height / 2,\n width: view.width + padding,\n height: view.height + padding,\n };\n}\n","import { pull } from \"lodash\";\nimport type { NodePosition } from \"../../../diagram/interfaces\";\nimport { getConnectPointsOfRectangleWithDirection } from \"../shapes/Rectangle\";\nimport type {\n BiDirection,\n EditableLineView,\n NodeView,\n} from \"../../../draw-canvas/interfaces\";\nimport { getPolyLinePoints } from \"../../../diagram/lines/getPolyLinePoints\";\nimport { nodeViewToNodeRect } from \"./nodeViewToNodeRect\";\nimport {\n DEFAULT_NODE_PADDING_FOR_LINES,\n DEFAULT_NODE_PADDING_FOR_SMART_LINES,\n} from \"../../../draw-canvas/constants\";\nimport { getDirectLinePoints } from \"../../../diagram/lines/getDirectLinePoints\";\nimport { isStraightType } from \"../../../draw-canvas/processors/asserts\";\n\nconst DEFAULT_DIRECTIONS = [\"right\", \"top\", \"left\", \"bottom\"] as const;\n\nexport function getSmartLinePoints(\n sourceView: NodeView,\n targetView: NodeView,\n lineView: EditableLineView | undefined,\n parallelGap?: number,\n /** @default \"edge\" */\n cellType?: \"edge\" | \"decorator\"\n): NodePosition[] | null {\n const {\n type,\n vertices,\n exitPosition: originalExit,\n entryPosition: originalEntry,\n } = lineView ?? {};\n\n if (isStraightType(type)) {\n if (cellType === \"decorator\") {\n return [\n { x: sourceView.x, y: sourceView.y },\n ...(vertices ?? []),\n { x: targetView.x, y: targetView.y },\n ];\n }\n\n return getDirectLinePoints(\n nodeViewToNodeRect(\n sourceView,\n originalExit\n ? DEFAULT_NODE_PADDING_FOR_SMART_LINES\n : DEFAULT_NODE_PADDING_FOR_LINES\n ),\n nodeViewToNodeRect(\n targetView,\n originalEntry\n ? DEFAULT_NODE_PADDING_FOR_SMART_LINES\n : DEFAULT_NODE_PADDING_FOR_LINES\n ),\n parallelGap,\n lineView\n );\n }\n\n if (vertices?.length) {\n const firstVertex = vertices[0];\n const lastVertex = vertices[vertices.length - 1];\n\n let exitPoint: NodePosition;\n let entryPoint: NodePosition;\n let exitDirection: BiDirection | undefined;\n let entryDirection: BiDirection | undefined;\n\n // Auto decide the exit and entry position.\n if (originalExit) {\n exitPoint = getAbsolutePosition(sourceView, originalExit);\n } else {\n let possibleFirstNextPoint: NodePosition | undefined;\n if (vertices.length > 1) {\n // Decide exit point by the first two vertices.\n possibleFirstNextPoint = vertices[1];\n } else if (originalEntry) {\n // Decide exit point by the entry position.\n possibleFirstNextPoint = getAbsolutePosition(targetView, originalEntry);\n }\n if (possibleFirstNextPoint) {\n exitPoint = getDefaultAbsolutePosition(\n firstVertex,\n sourceView,\n firstVertex.y === possibleFirstNextPoint.y\n );\n } else {\n // No other vertices nor the entry position, decide exit point by the\n // relative position between the last vertex and the target node.\n const prefer =\n lastVertex.y < targetView.y ||\n lastVertex.y > targetView.y + targetView.height\n ? \"ns\"\n : \"ew\";\n ({ point: exitPoint, direction: exitDirection } =\n fitEndpointAndDirection(sourceView, targetView, vertices, prefer));\n }\n }\n\n if (originalEntry) {\n entryPoint = getAbsolutePosition(targetView, originalEntry);\n } else {\n let possibleLastPreviousPoint: NodePosition | undefined;\n if (vertices.length > 1) {\n // Decide entry point by the last two vertices.\n possibleLastPreviousPoint = vertices[vertices.length - 2];\n } else if (originalExit) {\n // Decide entry point by the exit position.\n possibleLastPreviousPoint = getAbsolutePosition(\n sourceView,\n originalExit\n );\n }\n if (possibleLastPreviousPoint) {\n entryPoint = getDefaultAbsolutePosition(\n lastVertex,\n targetView,\n lastVertex.y === possibleLastPreviousPoint.y\n );\n } else {\n // No other vertices nor the exit position, decide entry point by the\n // relative position between the first vertex and the source node.\n const prefer =\n firstVertex.x < sourceView.x ||\n firstVertex.x > sourceView.x + sourceView.width\n ? \"ew\"\n : \"ns\";\n ({ point: entryPoint, direction: entryDirection } =\n fitEndpointAndDirection(\n targetView,\n sourceView,\n vertices.slice().reverse(),\n prefer\n ));\n }\n }\n\n const { x: sourceX, y: sourceY } = exitPoint;\n const { x: targetX, y: targetY } = entryPoint;\n\n const newLinePoints = [exitPoint, ...vertices, entryPoint];\n\n const newVertices = [...vertices];\n\n // If the first vertex is not on any axis of the source exit point,\n // add a vertex to connect them.\n if (firstVertex && firstVertex.x !== sourceX && firstVertex.y !== sourceY) {\n newVertices.unshift(\n exitDirection === \"ns\"\n ? { x: sourceX, y: firstVertex.y }\n : exitDirection === \"ew\"\n ? { x: firstVertex.x, y: sourceY }\n : firstVertex.x === newLinePoints[2].x\n ? { x: sourceX, y: firstVertex.y }\n : { x: firstVertex.x, y: sourceY }\n );\n }\n\n // If the last vertex is not on any axis of the target entry point,\n // add a vertex to connect them.\n if (lastVertex && lastVertex.x !== targetX && lastVertex.y !== targetY) {\n newVertices.push(\n entryDirection === \"ns\"\n ? { x: targetX, y: lastVertex.y }\n : entryDirection === \"ew\"\n ? { x: lastVertex.x, y: targetY }\n : lastVertex.x === newLinePoints[newLinePoints.length - 3].x\n ? { x: targetX, y: lastVertex.y }\n : { x: lastVertex.x, y: targetY }\n );\n }\n\n return [\n exitPoint,\n ...simplifyVertices(exitPoint, newVertices, entryPoint),\n entryPoint,\n ];\n }\n\n const exitPosition =\n originalExit ?? getDefaultPosition(targetView, sourceView);\n const entryPosition =\n originalEntry ?? getDefaultPosition(sourceView, targetView);\n\n const { x: sourceX, y: sourceY } = getAbsolutePosition(\n sourceView,\n exitPosition\n );\n const { x: targetX, y: targetY } = getAbsolutePosition(\n targetView,\n entryPosition\n );\n\n const connectPoints = getConnectPointsOfRectangleWithDirection();\n const originalSourceDirections =\n connectPoints.find((p) => p.x === exitPosition.x && p.y === exitPosition.y)\n ?.d ?? DEFAULT_DIRECTIONS;\n const originalTargetDirections =\n connectPoints.find(\n (p) => p.x === entryPosition.x && p.y === entryPosition.y\n )?.d ?? DEFAULT_DIRECTIONS;\n const sourceDirections = [...originalSourceDirections];\n const targetDirections = [...originalTargetDirections];\n\n if (sourceX < targetX) {\n pull(sourceDirections, \"left\");\n pull(targetDirections, \"right\");\n } else {\n pull(sourceDirections, \"right\");\n pull(targetDirections, \"left\");\n }\n\n if (sourceY < targetY) {\n pull(sourceDirections, \"top\");\n pull(targetDirections, \"bottom\");\n } else {\n pull(sourceDirections, \"bottom\");\n pull(targetDirections, \"top\");\n }\n\n const sourceDirection = sourceDirections[0] ?? originalSourceDirections[0];\n const targetDirection = targetDirections[0] ?? originalTargetDirections[0];\n\n const sourcePosition =\n sourceDirection === \"left\" || sourceDirection === \"right\"\n ? exitPosition.y\n : exitPosition.x;\n const targetPosition =\n targetDirection === \"left\" || targetDirection === \"right\"\n ? entryPosition.y\n : entryPosition.x;\n\n return getPolyLinePoints(\n nodeViewToNodeRect(sourceView, DEFAULT_NODE_PADDING_FOR_SMART_LINES),\n nodeViewToNodeRect(targetView, DEFAULT_NODE_PADDING_FOR_SMART_LINES),\n sourceDirection,\n targetDirection,\n sourcePosition,\n targetPosition\n );\n}\n\nexport function simplifyVertices(\n exitPoint: NodePosition,\n vertices: NodePosition[],\n entryPoint: NodePosition\n): NodePosition[] {\n // Simplify the vertices, ignore all vertices that its previous and next points are on the same axis\n // E.g, ignore two vertices of index 1 and index 3 for the following line.\n // 0---1---2\n // |\n // 3\n // |\n // 4\n const simplifiedVertices: NodePosition[] = [];\n let prev = exitPoint;\n let prevDirection: \"ns\" | \"ew\" | undefined;\n let index = 0;\n while (index < vertices.length) {\n const vertex = vertices[index];\n const isHorizontal = vertex.x !== prev.x;\n const isVertical = vertex.y !== prev.y;\n if (isHorizontal || isVertical) {\n const direction = isHorizontal ? \"ew\" : \"ns\";\n if (direction !== prevDirection) {\n const next =\n index === vertices.length - 1 ? entryPoint : vertices[index + 1];\n const isHorizontalNext = next.x !== vertex.x;\n const isVerticalNext = next.y !== vertex.y;\n if (isHorizontalNext || isVerticalNext) {\n const nextDirection = isHorizontalNext ? \"ew\" : \"ns\";\n if (direction !== nextDirection) {\n prevDirection = direction;\n simplifiedVertices.push(vertex);\n prev = vertex;\n }\n }\n }\n }\n index++;\n }\n\n return simplifiedVertices;\n}\n\nfunction getDefaultPosition(\n sourceView: NodeView,\n targetView: NodeView\n): NodePosition {\n if (targetView.y + targetView.height < sourceView.y) {\n return { x: 0.5, y: 1 };\n }\n if (targetView.y > sourceView.y + sourceView.height) {\n return { x: 0.5, y: 0 };\n }\n return targetView.x < sourceView.x ? { x: 1, y: 0.5 } : { x: 0, y: 0.5 };\n}\n\nfunction getAbsolutePosition(view: NodeView, position: NodePosition) {\n const halfPadding = DEFAULT_NODE_PADDING_FOR_SMART_LINES / 2;\n return {\n x:\n view.x -\n halfPadding +\n position.x * (view.width + DEFAULT_NODE_PADDING_FOR_SMART_LINES),\n y:\n view.y -\n halfPadding +\n position.y * (view.height + DEFAULT_NODE_PADDING_FOR_SMART_LINES),\n };\n}\n\nfunction getDefaultAbsolutePosition(\n sourceView: NodePosition,\n targetView: NodeView,\n flip?: boolean\n): NodePosition {\n let xAxis: \"x\" | \"y\";\n let yAxis: \"x\" | \"y\";\n let xSize: \"width\" | \"height\";\n let ySize: \"width\" | \"height\";\n if (flip) {\n xAxis = \"y\";\n yAxis = \"x\";\n xSize = \"height\";\n ySize = \"width\";\n } else {\n xAxis = \"x\";\n yAxis = \"y\";\n xSize = \"width\";\n ySize = \"height\";\n }\n let position: NodePosition | undefined;\n if (targetView[yAxis] + targetView[ySize] < sourceView[yAxis]) {\n position = { [xAxis]: 0.5, [yAxis]: 1 } as unknown as NodePosition;\n }\n if (targetView[yAxis] > sourceView[yAxis]) {\n position = { [xAxis]: 0.5, [yAxis]: 0 } as unknown as NodePosition;\n }\n if (position) {\n return getAbsolutePosition(targetView, position);\n }\n\n const xPosition = targetView[xAxis] < sourceView[xAxis] ? 1 : 0;\n\n return {\n [xAxis]:\n targetView[xAxis] -\n DEFAULT_NODE_PADDING_FOR_SMART_LINES / 2 +\n xPosition * (targetView[xSize] + DEFAULT_NODE_PADDING_FOR_SMART_LINES),\n [yAxis]: sourceView[yAxis],\n } as unknown as NodePosition;\n}\n\nfunction fitEndpointAndDirection(\n view: NodeView,\n oppositeView: NodeView,\n vertices: NodePosition[],\n prefer: BiDirection\n): { point: NodePosition; direction: BiDirection } {\n let point: NodePosition;\n let direction: BiDirection;\n\n let xAxis: \"x\" | \"y\";\n let yAxis: \"x\" | \"y\";\n let xSize: \"width\" | \"height\";\n let ySize: \"width\" | \"height\";\n let nsDirection: BiDirection;\n let ewDirection: BiDirection;\n if (prefer === \"ns\") {\n xAxis = \"x\";\n yAxis = \"y\";\n xSize = \"width\";\n ySize = \"height\";\n nsDirection = \"ns\";\n ewDirection = \"ew\";\n } else {\n xAxis = \"y\";\n yAxis = \"x\";\n xSize = \"height\";\n ySize = \"width\";\n nsDirection = \"ew\";\n ewDirection = \"ns\";\n }\n const vertex = vertices[0];\n\n if (\n vertex[xAxis] >= view[xAxis] &&\n vertex[xAxis] <= view[xAxis] + view[xSize]\n ) {\n if (vertex[yAxis] > view[yAxis] + view[ySize]) {\n point = {\n [xAxis]: vertex[xAxis],\n [yAxis]: view[yAxis] + view[ySize],\n } as unknown as NodePosition;\n direction = nsDirection;\n } else if (vertex[yAxis] < view[yAxis]) {\n point = {\n [xAxis]: vertex[xAxis],\n [yAxis]: view[yAxis],\n } as unknown as NodePosition;\n direction = nsDirection;\n } else {\n const nextVertex = vertices[1] ?? oppositeView;\n point = {\n [xAxis]: vertex[xAxis],\n [yAxis]:\n nextVertex[yAxis] < vertex[yAxis]\n ? vertex[yAxis]\n : view[yAxis] + view[ySize],\n } as unknown as NodePosition;\n direction = nsDirection;\n }\n } else {\n if (vertex[yAxis] < view[yAxis]) {\n point = {\n [xAxis]: view[xAxis] + view[xSize] / 2,\n [yAxis]: view[yAxis],\n } as unknown as NodePosition;\n direction = nsDirection;\n } else if (vertex[yAxis] > view[yAxis] + view[ySize]) {\n point = {\n [xAxis]: view[xAxis] + view[xSize] / 2,\n [yAxis]: view[yAxis] + view[ySize],\n } as unknown as NodePosition;\n direction = nsDirection;\n } else if (vertex[xAxis] < view[xAxis]) {\n point = {\n [xAxis]: view[xAxis],\n [yAxis]: vertex[yAxis],\n } as unknown as NodePosition;\n direction = ewDirection;\n } else {\n point = {\n [xAxis]: view[xAxis] + view[xSize],\n [yAxis]: vertex[yAxis],\n } as unknown as NodePosition;\n direction = ewDirection;\n }\n }\n return { point, direction: direction };\n}\n","import type { ActiveTarget, Cell, ConnectLineState } from \"../interfaces\";\nimport { targetIsActive } from \"./targetIsActive\";\n\nexport function getUnrelatedCells(\n cells: Cell[],\n connectLineState: ConnectLineState | null,\n activeTarget: ActiveTarget | null,\n allowEdgeToArea?: boolean\n): Cell[] {\n const unrelated: Cell[] = [];\n if (connectLineState) {\n const existedTargets = new Set<string>();\n for (const cell of cells) {\n if (cell.type === \"edge\" && cell.source === connectLineState.source.id) {\n existedTargets.add(cell.target);\n }\n }\n for (const cell of cells) {\n switch (cell.type) {\n case \"node\":\n if (existedTargets.has(cell.id)) {\n unrelated.push(cell);\n }\n break;\n case \"decorator\":\n if (\n !allowEdgeToArea ||\n cell.decorator == \"text\" ||\n existedTargets.has(cell.id)\n ) {\n unrelated.push(cell);\n }\n break;\n default:\n unrelated.push(cell);\n }\n }\n } else {\n switch (activeTarget?.type) {\n case \"multi\": {\n const nodesMap = new Map<string, Cell>();\n const activeNodeIds = new Set<string>();\n const relatedNodeIds = new Set<string>();\n for (const active of activeTarget.targets) {\n if (active.type === \"node\") {\n activeNodeIds.add(active.id);\n relatedNodeIds.add(active.id);\n }\n }\n for (const cell of cells) {\n if (cell.type === \"node\") {\n nodesMap.set(cell.id, cell);\n } else if (cell.type === \"edge\") {\n if (activeNodeIds.has(cell.source)) {\n relatedNodeIds.add(cell.target);\n } else if (activeNodeIds.has(cell.target)) {\n relatedNodeIds.add(cell.source);\n } else if (!targetIsActive(cell, activeTarget)) {\n unrelated.push(cell);\n }\n } else if (!targetIsActive(cell, activeTarget)) {\n unrelated.push(cell);\n }\n }\n for (const [id, cell] of nodesMap) {\n if (!relatedNodeIds.has(id)) {\n unrelated.push(cell);\n }\n }\n break;\n }\n\n case \"node\": {\n const nodesMap = new Map<string, Cell>();\n const relatedNodeIds = new Set<string>([activeTarget.id]);\n for (const cell of cells) {\n if (cell.type === \"node\") {\n nodesMap.set(cell.id, cell);\n } else if (cell.type === \"edge\") {\n if (cell.source === activeTarget.id) {\n relatedNodeIds.add(cell.target);\n } else if (cell.target === activeTarget.id) {\n relatedNodeIds.add(cell.source);\n } else {\n unrelated.push(cell);\n }\n } else {\n unrelated.push(cell);\n }\n }\n for (const [id, cell] of nodesMap) {\n if (!relatedNodeIds.has(id)) {\n unrelated.push(cell);\n }\n }\n break;\n }\n\n case \"edge\":\n for (const cell of cells) {\n if (\n !(cell.type === \"edge\"\n ? targetIsActive(cell, activeTarget)\n : cell.type === \"node\" &&\n (cell.id === activeTarget.source ||\n cell.id === activeTarget.target))\n ) {\n unrelated.push(cell);\n }\n }\n break;\n }\n }\n\n return unrelated;\n}\n","import React, { useEffect, useRef, useState } from \"react\";\nimport type { ActiveTarget } from \"../../draw-canvas/interfaces\";\nimport { sameTarget } from \"../../draw-canvas/processors/sameTarget\";\n\nexport interface UseActiveTargetOptions {\n rootRef: React.RefObject<SVGGElement>;\n activeTarget?: ActiveTarget | null;\n doNotResetActiveTargetForSelector?: string;\n doNotResetActiveTargetOutsideCanvas?: boolean;\n onActiveTargetChange(target: ActiveTarget | null): void;\n}\n\nexport type UseActiveTargetResult = ActiveTarget | null;\n\nexport function useActiveTarget({\n rootRef,\n activeTarget: _activeTarget,\n doNotResetActiveTargetForSelector,\n doNotResetActiveTargetOutsideCanvas,\n onActiveTargetChange,\n}: UseActiveTargetOptions): UseActiveTargetResult {\n const newActiveTarget = _activeTarget ?? null;\n const [activeTarget, setActiveTarget] = useState<ActiveTarget | null>(\n newActiveTarget\n );\n\n useEffect(() => {\n setActiveTarget((previous) =>\n sameTarget(previous, newActiveTarget) ? previous : newActiveTarget\n );\n }, [newActiveTarget]);\n\n const activeTargetChangeInitialized = useRef(false);\n useEffect(() => {\n if (!activeTargetChangeInitialized.current) {\n activeTargetChangeInitialized.current = true;\n return;\n }\n onActiveTargetChange(activeTarget);\n }, [activeTarget, onActiveTargetChange]);\n\n useEffect(() => {\n if (!activeTarget) {\n return;\n }\n const resetActiveTarget = (e: MouseEvent) => {\n const path = e.composedPath();\n const rootIndex = path.indexOf(rootRef.current!);\n // Reset active target to null when clicking outside of the cells container,\n // Or inside the cells container but not on any cell.\n if (\n doNotResetActiveTargetOutsideCanvas\n ? rootIndex === 0\n : rootIndex <= 0 &&\n !(\n doNotResetActiveTargetForSelector &&\n path.some(\n (el) =>\n el instanceof Element &&\n el.matches(doNotResetActiveTargetForSelector)\n )\n )\n ) {\n setActiveTarget(null);\n }\n };\n document.addEventListener(\"click\", resetActiveTarget);\n return () => {\n document.removeEventListener(\"click\", resetActiveTarget);\n };\n }, [\n activeTarget,\n doNotResetActiveTargetOutsideCanvas,\n doNotResetActiveTargetForSelector,\n rootRef,\n ]);\n\n return activeTarget;\n}\n","import type {\n ActiveTarget,\n ActiveTargetOfEdge,\n ActiveTargetOfMulti,\n ActiveTargetOfNode,\n} from \"../interfaces\";\n\nexport function sameTarget(\n a: ActiveTarget | null | undefined,\n b: ActiveTarget | null | undefined\n): boolean {\n return a\n ? !!b &&\n a.type === b.type &&\n (a.type === \"multi\"\n ? a.targets.length === (b as ActiveTargetOfMulti).targets.length &&\n a.targets.every((targetA) =>\n (b as ActiveTargetOfMulti).targets.some((targetB) =>\n sameTarget(targetA, targetB)\n )\n )\n : a.type === \"node\" || a.type === \"decorator\"\n ? a.id === (b as ActiveTargetOfNode).id\n : a.source === (b as ActiveTargetOfEdge).source &&\n a.target === (b as ActiveTargetOfEdge).target)\n : !b;\n}\n","import type { Reducer } from \"react\";\nimport { pick } from \"lodash\";\nimport type { DrawCanvasAction } from \"./interfaces\";\nimport type {\n Cell,\n DecoratorCell,\n DecoratorType,\n EdgeCell,\n NodeCell,\n} from \"../interfaces\";\nimport { isNodeCell } from \"../processors/asserts\";\nimport { SYMBOL_FOR_SIZE_INITIALIZED } from \"../constants\";\n\ntype CellOrder = CellOrderOfDecorator | CellOrderOfOthers;\n\ninterface CellOrderOfDecorator {\n type: \"decorator\";\n decorators: DecoratorType[];\n}\n\ninterface CellOrderOfOthers {\n type: \"node\" | \"edge\";\n}\n\n// NOTE: keep the cells in the following order by default, when adding new cells:\n// 1. decorators other than text\n// 2. edges\n// 3. nodes\n// 4. decorators of text\nconst DEFAULT_CELL_ORDERS: CellOrder[] = [\n {\n type: \"decorator\",\n decorators: [\"line\", \"area\", \"container\", \"rect\"],\n },\n { type: \"edge\" },\n { type: \"node\" },\n { type: \"decorator\", decorators: [\"text\"] },\n];\n\nexport const cells: Reducer<Cell[], DrawCanvasAction> = (state, action) => {\n switch (action.type) {\n case \"drop-node\":\n case \"drop-decorator\":\n return insertCell(state, action.payload);\n case \"add-nodes\":\n return insertCells(state, action.payload);\n case \"add-edge\": {\n // If the new edge between the source and target already exists, override the old one.\n const existedEdgeIndex = state.findIndex(\n (cell) =>\n cell.type === \"edge\" &&\n cell.source === action.payload.source &&\n cell.target === action.payload.target\n );\n if (existedEdgeIndex === -1) {\n // Add the edge to just next to the previous last edge or area decorator.\n // If not found, append to the start.\n return insertCell(state, action.payload);\n }\n return [\n ...state.slice(0, existedEdgeIndex),\n action.payload,\n ...state.slice(existedEdgeIndex + 1),\n ];\n }\n case \"change-edge-view\": {\n const existedEdgeIndex = state.findIndex(\n (cell) =>\n cell.type === \"edge\" &&\n cell.source === action.payload.source &&\n cell.target === action.payload.target\n );\n return existedEdgeIndex === -1\n ? state\n : [\n ...state.slice(0, existedEdgeIndex),\n {\n ...(state[existedEdgeIndex] as EdgeCell),\n view: action.payload.view,\n },\n ...state.slice(existedEdgeIndex + 1),\n ];\n }\n case \"change-decorator-view\": {\n const existedDecoratorIndex = state.findIndex(\n (cell) => cell.type === \"decorator\" && cell.id === action.payload.id\n );\n return existedDecoratorIndex === -1\n ? state\n : [\n ...state.slice(0, existedDecoratorIndex),\n {\n ...(state[existedDecoratorIndex] as EdgeCell),\n view: action.payload.view,\n },\n ...state.slice(existedDecoratorIndex + 1),\n ];\n }\n case \"move-cells\": {\n let matched = false;\n const newState = state.map((cell) => {\n const newCell = action.payload.find(\n (move) => cell.type === move.type && cell.id === move.id\n );\n if (newCell) {\n matched = true;\n return {\n ...(cell as NodeCell),\n view: {\n ...(cell as NodeCell).view,\n x: newCell.x,\n y: newCell.y,\n ...pick(newCell, \"source\", \"target\", \"vertices\"),\n },\n };\n }\n return cell;\n });\n return matched ? newState : state;\n }\n case \"resize-cell\": {\n const { type, id, width, height } = action.payload;\n const index = state.findIndex(\n (cell) => cell.type === type && cell.id === id\n );\n if (index !== -1) {\n const node = state[index] as NodeCell;\n return [\n ...state.slice(0, index),\n { ...node, view: { ...node.view, width, height } },\n ...state.slice(index + 1),\n ];\n }\n return state;\n }\n case \"update-cells\":\n return action.payload;\n case \"update-node-size\":\n return state.map((cell) =>\n isNodeCell(cell) && cell.id === action.payload.id\n ? {\n ...cell,\n [SYMBOL_FOR_SIZE_INITIALIZED]: true,\n view: action.payload.size\n ? {\n ...cell.view,\n width: action.payload.size[0],\n height: action.payload.size[1],\n }\n : cell.view,\n }\n : cell\n );\n }\n return state;\n};\n\nfunction insertCell(cells: Cell[], newCell: Cell): Cell[] {\n return insertCells(cells, [newCell]);\n}\n\n/**\n * Insert new cells (with same types and some decorators) to the cells.\n */\nfunction insertCells(cells: Cell[], newCells: Cell[]): Cell[] {\n if (newCells.length === 0) {\n return cells;\n }\n const index = DEFAULT_CELL_ORDERS.findIndex((order) =>\n matchCellOrder(newCells[0], order)\n );\n\n // istanbul ignore next\n if (index === -1) {\n // eslint-disable-next-line no-console\n console.warn(\n \"Default order index unhandled for the cell: %o.\\n%s\",\n newCells[0],\n \"This is a bug of diagram-NB, please report it.\"\n );\n }\n\n const lastIndex = cells.findLastIndex(\n (cell) =>\n DEFAULT_CELL_ORDERS.findIndex((order) => matchCellOrder(cell, order)) <=\n index\n );\n const targetIndex = lastIndex + 1;\n return [\n ...cells.slice(0, targetIndex),\n ...newCells,\n ...cells.slice(targetIndex),\n ];\n}\n\nfunction matchCellOrder(cell: Cell, order: CellOrder) {\n return (\n cell.type === order.type &&\n (order.type !== \"decorator\" ||\n order.decorators.includes((cell as DecoratorCell).decorator))\n );\n}\n","import { Reducer } from \"react\";\nimport type { DrawCanvasAction, DrawCanvasState } from \"./interfaces\";\nimport { cells } from \"./cells\";\nimport { layoutKey } from \"./layoutKey\";\n\ntype ReducersMapObject<S, A> = {\n [K in keyof S]: Reducer<S[K], A>;\n};\n\nfunction combineReducers<S, A>(\n reducers: ReducersMapObject<S, A>\n): Reducer<S, A> {\n return ((state, action) =>\n Object.fromEntries(\n Object.entries<Reducer<any, A>>(reducers).map(([key, value]) => [\n key,\n value(state[key as keyof S], action),\n ])\n )) as Reducer<S, A>;\n}\n\nexport const rootReducer = combineReducers<DrawCanvasState, DrawCanvasAction>({\n cells,\n layoutKey,\n});\n","import type { Reducer } from \"react\";\nimport type { DrawCanvasAction } from \"./interfaces\";\n\nexport const layoutKey: Reducer<number, DrawCanvasAction> = (state, action) => {\n switch (action.type) {\n case \"update-node-size\":\n return action.layoutKey;\n default:\n return state;\n }\n};\n","import React, { useCallback, useEffect, useMemo } from \"react\";\nimport { checkIfOfComputed } from \"@next-core/runtime\";\nimport { ReactUseBrick } from \"@next-core/react-runtime\";\nimport classNames from \"classnames\";\nimport type {\n LineLabelConf,\n PositionTuple,\n TextOptions,\n} from \"../diagram/interfaces\";\nimport type { EdgeCell, PositionAndAngle } from \"./interfaces\";\n\nexport interface LineLabelComponentProps {\n edge: EdgeCell;\n position?: PositionAndAngle | null;\n offset?: PositionTuple | null;\n label?: LineLabelConf;\n text?: TextOptions;\n onRendered?: (element: HTMLElement | null) => void;\n onClick?: () => void;\n}\n\nexport function LineLabelComponent({\n edge,\n position,\n offset,\n label,\n text,\n onRendered,\n onClick,\n}: LineLabelComponentProps): JSX.Element | null {\n if (!label && !text) {\n return null;\n }\n const ready = !!(position && offset);\n return (\n <foreignObject\n className={classNames(\"line-label-container\", { ready })}\n x={ready ? position[0] + offset[0] : 0}\n y={ready ? position[1] + offset[1] : 0}\n onClick={onClick}\n >\n {label ? (\n <div className=\"line-label label\">\n <LineLabelUseBrickComponent\n edge={edge}\n label={label}\n onRendered={onRendered}\n />\n </div>\n ) : (\n <LineLabelTextComponent text={text!} onRendered={onRendered} />\n )}\n </foreignObject>\n );\n}\n\ninterface LineLabelTextComponentProps {\n text: TextOptions;\n onRendered?: (element: HTMLElement | null) => void;\n}\n\nfunction LineLabelTextComponent({\n text,\n onRendered,\n}: LineLabelTextComponentProps): JSX.Element {\n const refCallback = useCallback(\n (element: HTMLDivElement) => {\n onRendered?.(element);\n },\n [onRendered]\n );\n\n return (\n <div className=\"line-label text\" ref={refCallback} style={text.style}>\n {text.content}\n </div>\n );\n}\n\ninterface LineLabelUseBrickComponentProps {\n edge: EdgeCell;\n label: LineLabelConf;\n onRendered?: (element: HTMLElement | null) => void;\n}\n\n// istanbul ignore next\nfunction LineLabelUseBrickComponent({\n edge,\n label,\n onRendered,\n}: LineLabelUseBrickComponentProps): JSX.Element | null {\n const useBrick = useMemo(\n () => (checkIfOfComputed(label) ? label.useBrick : null),\n [label]\n );\n\n const memoizedData = useMemo(() => ({ edge }), [edge]);\n\n useEffect(() => {\n if (!useBrick) {\n // Keep the same time delay for reporting rendered.\n setTimeout(() => {\n onRendered?.(null);\n });\n }\n }, [onRendered, useBrick]);\n\n useEffect(\n () => {\n return () => {\n onRendered?.(null);\n };\n },\n // Only unmount once\n // eslint-disable-next-line react-hooks/exhaustive-deps\n []\n );\n\n const refCallback = useCallback(\n (element: HTMLElement | null) => {\n if (element) {\n // Todo: correctly wait for `useBrick` in v3 to be rendered (after layout)\n // Wait a macro task to let `useBrick` to be rendered.\n setTimeout(() => {\n // await Promise.resolve();\n onRendered?.(element.parentElement);\n });\n }\n },\n [onRendered]\n );\n\n const ignoredCallback = useCallback(() => {\n setTimeout(() => {\n onRendered?.(null);\n });\n }, [onRendered]);\n\n if (!useBrick) {\n return null;\n }\n\n return (\n <ReactUseBrick\n refCallback={refCallback}\n ignoredCallback={ignoredCallback}\n useBrick={useBrick}\n data={memoizedData}\n />\n );\n}\n","import React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport classNames from \"classnames\";\nimport { uniqueId } from \"lodash\";\nimport ResizeObserver from \"resize-observer-polyfill\";\nimport type {\n ActiveTarget,\n ComputedEdgeLineConf,\n Direction,\n EdgeCell,\n EdgeLineMotion,\n EditableLine,\n EditableLineCell,\n PositionAndAngle,\n} from \"./interfaces\";\nimport {\n DEFAULT_LINE_INTERACT_ANIMATE_DURATION,\n DEFAULT_MOTION_SPEED,\n} from \"./constants\";\nimport { curveLine } from \"../diagram/lines/curveLine\";\nimport { getMarkers } from \"../shared/canvas/useLineMarkers\";\nimport type {\n LineMarkerConf,\n NodePosition,\n SizeTuple,\n} from \"../diagram/interfaces\";\nimport { LineLabelComponent } from \"./LineLabelComponent\";\nimport { cellToTarget } from \"./processors/cellToTarget\";\nimport { getLabelMaskAndOffset } from \"./processors/getLabelMaskAndOffset\";\n\nexport interface EdgeComponentProps {\n edge: EdgeCell;\n lineConfMap: WeakMap<EditableLineCell, ComputedEdgeLineConf>;\n editableLineMap: WeakMap<EditableLineCell, EditableLine>;\n readOnly?: boolean;\n active?: boolean;\n activeRelated?: boolean;\n onSwitchActiveTarget?(activeTarget: ActiveTarget | null): void;\n}\n\nexport function EdgeComponent({\n edge,\n lineConfMap,\n editableLineMap,\n readOnly,\n active,\n activeRelated,\n onSwitchActiveTarget,\n}: EdgeComponentProps): JSX.Element | null {\n const pathRef = useRef<SVGPathElement | null>(null);\n const lineConf = lineConfMap.get(edge)!;\n const { points: linePoints, jumpsMap } = editableLineMap.get(edge) ?? {};\n\n const line = useMemo(() => {\n return curveLine(\n linePoints,\n lineConf.type === \"curve\" ? lineConf.curveType : \"curveLinear\",\n 0,\n 1,\n jumpsMap\n );\n }, [lineConf, linePoints, jumpsMap]);\n\n const lineClipPathPrefix = useMemo(() => uniqueId(\"line-mask-\"), []);\n\n const [labelPosition, setLabelPosition] = useState<PositionAndAngle | null>(\n null\n );\n const [labelSize, setLabelSize] = useState<SizeTuple | null>(null);\n const [lineRect, setLineRect] = useState<Pick<\n SVGRect,\n \"x\" | \"y\" | \"width\" | \"height\"\n > | null>(null);\n\n const updateLabelPosition = useCallback(() => {\n const path = pathRef.current;\n const { label, text } = lineConf;\n // istanbul ignore next\n if (path && linePoints && (label || text)) {\n if (process.env.NODE_ENV === \"test\") {\n setLabelPosition([30, 40, \"center\", 0, 0]);\n setLineRect({ x: 10, y: 20, width: 300, height: 400 });\n return;\n }\n const placement = (label ? label.placement : text.placement) ?? \"center\";\n const offset = (label ? label.offset : text.offset) ?? 0;\n const pathLength = path.getTotalLength();\n const halfPathLength = pathLength / 2;\n const pathPoint = path.getPointAtLength(\n placement === \"start\"\n ? 0\n : placement === \"end\"\n ? pathLength\n : halfPathLength + offset\n );\n\n let direction: Direction | \"center\" = \"center\";\n let angle = 0;\n if (placement === \"start\" || placement === \"end\") {\n let p0: NodePosition;\n let p1: NodePosition;\n if (placement === \"start\") {\n p0 = linePoints[0];\n p1 = linePoints[1];\n } else {\n p0 = linePoints[linePoints.length - 1];\n p1 = linePoints[linePoints.length - 2];\n }\n angle = Math.atan2(p1.y - p0.y, p1.x - p0.x);\n direction =\n Math.abs(p0.x - p1.x) > Math.abs(p0.y - p1.y)\n ? p0.x > p1.x\n ? \"left\"\n : \"right\"\n : p0.y > p1.y\n ? \"top\"\n : \"bottom\";\n }\n\n setLabelPosition([pathPoint.x, pathPoint.y, direction, angle, offset]);\n const rect = path.getBBox();\n setLineRect({\n x: rect.x - 1000,\n y: rect.y - 1000,\n width: rect.width + 2000,\n height: rect.height + 2000,\n });\n }\n }, [lineConf, linePoints]);\n\n const [pathLength, setPathLength] = useState<number | null>(null);\n\n const pathRefCallback = useCallback(\n (element: SVGPathElement | null) => {\n pathRef.current = element;\n if (element) {\n // Jest does not support `SVGPathElement::getTotalLength`\n setPathLength(element.getTotalLength?.() ?? 100);\n const rect = element.getBBox?.();\n edge.view = {\n ...edge.view,\n x: rect?.x,\n y: rect?.y,\n width: rect?.width,\n height: rect?.height,\n };\n }\n updateLabelPosition();\n },\n [updateLabelPosition, edge]\n );\n\n const [labelElement, setLabelElement] = useState<HTMLElement | null>(null);\n\n useEffect(() => {\n if (!labelElement) {\n setLabelSize(null);\n return;\n }\n const observerCallback = () => {\n const { offsetWidth, offsetHeight } = labelElement;\n // Do not mask out when the label takes no space.\n // istanbul ignore next\n if (\n process.env.NODE_ENV !== \"test\" &&\n (offsetWidth === 0 || offsetHeight === 0)\n ) {\n setLabelSize(null);\n return;\n }\n setLabelSize([offsetWidth, offsetHeight]);\n };\n const resizeObserver = new ResizeObserver(observerCallback);\n resizeObserver.observe(labelElement);\n\n // `ResizeObserver` will not call the callback in test environment.\n // istanbul ignore next\n if (process.env.NODE_ENV === \"test\") {\n observerCallback();\n }\n return () => {\n resizeObserver.disconnect();\n };\n }, [labelElement]);\n\n const handleLabelRendered = useCallback((element: HTMLElement | null) => {\n setLabelElement(element);\n }, []);\n\n useEffect(\n () => {\n updateLabelPosition();\n },\n // Update label position when line points changed\n [updateLabelPosition, linePoints]\n );\n\n const onLabelClick = useCallback(() => {\n onSwitchActiveTarget?.(cellToTarget(edge));\n }, [edge, onSwitchActiveTarget]);\n\n const onDoubleClick = useCallback(\n (e: React.MouseEvent) => {\n if (readOnly || !lineConf.callLabelOnDoubleClick) {\n return;\n }\n e.preventDefault();\n e.stopPropagation();\n (\n labelElement?.firstElementChild as unknown as Record<string, () => void>\n )?.[lineConf.callLabelOnDoubleClick]?.();\n },\n [labelElement, lineConf, readOnly]\n );\n\n const [mask, labelOffset] = useMemo(\n () => getLabelMaskAndOffset(labelPosition, labelSize),\n [labelPosition, labelSize]\n );\n\n const clipPathPoints = useMemo(() => {\n if (!mask || !lineRect) {\n return null;\n }\n const right = lineRect.x + lineRect.width;\n const bottom = lineRect.y + lineRect.height;\n const maskRight = mask.left + mask.width;\n const maskBottom = mask.top + mask.height;\n return [\n [mask.left, maskBottom],\n [maskRight, maskBottom],\n [maskRight, mask.top],\n [mask.left, mask.top],\n [mask.left, lineRect.y],\n [right, lineRect.y],\n [right, bottom],\n [lineRect.x, bottom],\n [lineRect.x, lineRect.y],\n [mask.left, lineRect.y],\n ]\n .map((points) => points.join(\",\"))\n .join(\" \");\n }, [lineRect, mask]);\n\n if (!line) {\n // This happens when source or target is not found,\n // or when source or target has not been positioned yet.\n return null;\n }\n\n let markerStart: string | undefined;\n let markerEnd: string | undefined;\n let strokeColor: string | undefined;\n let strokeWidth: number | undefined;\n let motion: EdgeLineMotion | undefined;\n const lineMarkers: LineMarkerConf[] = getMarkers(lineConf);\n if (active) {\n const overrides = lineConf.overrides?.active;\n strokeColor = overrides?.strokeColor ?? lineConf.strokeColor;\n strokeWidth = overrides?.strokeWidth ?? lineConf.strokeWidth;\n motion = overrides?.motion;\n for (const marker of lineMarkers) {\n if (marker.placement === \"start\") {\n markerStart =\n lineConf.$activeMarkerStartUrl ?? lineConf.$markerStartUrl;\n } else {\n markerEnd = lineConf.$activeMarkerEndUrl ?? lineConf.$markerEndUrl;\n }\n }\n } else if (activeRelated) {\n const overrides = lineConf.overrides?.activeRelated;\n strokeColor = overrides?.strokeColor ?? lineConf.strokeColor;\n strokeWidth = overrides?.strokeWidth ?? lineConf.strokeWidth;\n motion = overrides?.motion;\n for (const marker of lineMarkers) {\n if (marker.placement === \"start\") {\n markerStart =\n lineConf.$activeRelatedMarkerStartUrl ?? lineConf.$markerStartUrl;\n } else {\n markerEnd =\n lineConf.$activeRelatedMarkerEndUrl ?? lineConf.$markerEndUrl;\n }\n }\n } else {\n strokeColor = lineConf.strokeColor;\n strokeWidth = lineConf.strokeWidth;\n for (const marker of lineMarkers) {\n if (marker.placement === \"start\") {\n markerStart = lineConf.$markerStartUrl;\n } else {\n markerEnd = lineConf.$markerEndUrl;\n }\n }\n }\n\n let motionPath: string | undefined;\n if (motion?.shape === \"dot\") {\n const radius = motion.size == null ? strokeWidth * 2 : motion.size / 2;\n motionPath = `M 0,${-radius} A ${radius},${radius} 0,1,1 0,${radius} A ${radius},${radius} 0,1,1 0,${-radius} z`;\n } else if (motion?.shape === \"triangle\") {\n const radius = motion.size == null ? strokeWidth * 2 : motion.size / 2;\n const offset = radius / Math.sqrt(3);\n motionPath = `M ${-offset},${radius} v ${-radius * 2} L ${offset * 2},0 z`;\n }\n let motionDuration: string | undefined;\n if (pathLength) {\n motionDuration = `${pathLength / (motion?.speed ?? DEFAULT_MOTION_SPEED)}s`;\n }\n\n const hasMotion = [\n lineConf.overrides?.active?.motion?.shape,\n lineConf.overrides?.activeRelated?.motion?.shape,\n ].some((item) => item === \"dot\" || item === \"triangle\");\n\n const clipPathUrl = clipPathPoints\n ? `url(#${lineClipPathPrefix})`\n : undefined;\n\n return (\n <>\n {clipPathPoints && (\n <defs>\n <clipPath id={lineClipPathPrefix}>\n <polygon points={clipPathPoints} />\n </clipPath>\n </defs>\n )}\n <g className=\"line-group\" onDoubleClick={onDoubleClick}>\n <path\n // This `path` is made for expanding interaction area of graph lines.\n d={line}\n fill=\"none\"\n stroke=\"transparent\"\n strokeWidth={lineConf.interactStrokeWidth}\n clipPath={clipPathUrl}\n />\n <path\n ref={pathRefCallback}\n className={classNames(\"line\", {\n dashed: lineConf.dashed,\n dotted: lineConf.dotted,\n [`${lineConf.dashed ? \"dashed\" : lineConf.dotted ? \"dotted\" : \"solid\"}-animation`]:\n lineConf.animate.useAnimate,\n })}\n clipPath={clipPathUrl}\n style={\n {\n \"--time\": `${lineConf.animate.duration ?? DEFAULT_LINE_INTERACT_ANIMATE_DURATION}s`,\n \"--solid-length\": pathLength,\n } as React.CSSProperties\n }\n d={line}\n fill=\"none\"\n stroke={strokeColor}\n strokeWidth={strokeWidth}\n markerStart={markerStart}\n markerEnd={markerEnd}\n />\n {!lineConf.overrides?.active && (\n <path\n className=\"line-active-bg\"\n d={line}\n fill=\"none\"\n clipPath={clipPathUrl}\n />\n )}\n {\n // No dur in old browsers will cause animation not working.\n // So always set a dur.\n hasMotion && motionDuration && (\n <path\n className={classNames(\"motion\", { visible: !!motionPath })}\n d={motionPath}\n fill={strokeColor}\n >\n <animateMotion\n dur={motionDuration}\n repeatCount={\"indefinite\"}\n rotate={\"auto\"}\n path={line}\n />\n </path>\n )\n }\n </g>\n <LineLabelComponent\n edge={edge}\n position={labelPosition}\n offset={labelOffset}\n label={lineConf.label}\n text={lineConf.text}\n onClick={onLabelClick}\n onRendered={handleLabelRendered}\n />\n </>\n );\n}\n","import type {\n PositionTuple,\n SimpleRect,\n SizeTuple,\n} from \"../../diagram/interfaces\";\nimport type { PositionAndAngle } from \"../interfaces\";\n\nexport function getLabelMaskAndOffset(\n labelPosition: PositionAndAngle | null,\n labelSize: SizeTuple | null\n): [labelMask: SimpleRect | null, labelOffset: PositionTuple | null] {\n if (!labelPosition || !labelSize) {\n return [null, null];\n }\n const padding = 3;\n const [x, y, direction, angle, offset] = labelPosition;\n const [width, height] = labelSize;\n\n const left = x - width / 2 - padding;\n const top = y - height / 2 - padding;\n let offsetX = 0;\n let offsetY = 0;\n const halfWidth = width / 2 + padding;\n const halfHeight = height / 2 + padding;\n switch (direction) {\n case \"top\":\n offsetX = offset * Math.cos(angle) - halfHeight / Math.tan(angle);\n offsetY = offset * Math.sin(angle) - halfHeight;\n break;\n case \"bottom\":\n offsetX = offset * Math.cos(angle) + halfHeight / Math.tan(angle);\n offsetY = offset * Math.sin(angle) + halfHeight;\n break;\n case \"left\":\n offsetX = offset * Math.cos(angle) - halfWidth;\n offsetY = offset * Math.sin(angle) - halfWidth * Math.tan(angle);\n break;\n case \"right\":\n offsetX = offset * Math.cos(angle) + halfWidth;\n offsetY = offset * Math.sin(angle) + halfWidth * Math.tan(angle);\n break;\n }\n\n return [\n {\n left: left + offsetX,\n top: top + offsetY,\n width: width + padding * 2,\n height: height + padding * 2,\n },\n [offsetX, offsetY],\n ];\n}\n","import React from \"react\";\n\nexport interface LockIconProps {\n x: number;\n y: number;\n}\n\nexport function LockIcon({ x, y }: LockIconProps) {\n // 12 / 512 = 0.0234375\n return (\n <g\n transform={`translate(${x}, ${y}) scale(0.0234375)`}\n className=\"lock-icon\"\n >\n <path\n d=\"M144 144l0 48 160 0 0-48c0-44.2-35.8-80-80-80s-80 35.8-80 80zM80 192l0-48C80 64.5 144.5 0 224 0s144 64.5 144 144l0 48 16 0c35.3 0 64 28.7 64 64l0 192c0 35.3-28.7 64-64 64L64 512c-35.3 0-64-28.7-64-64L0 256c0-35.3 28.7-64 64-64l16 0z\"\n fill=\"var(--color-secondary-text)\"\n stroke=\"none\"\n />\n </g>\n );\n}\n","import React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { ReactUseBrick } from \"@next-core/react-runtime\";\nimport { __secret_internals, checkIfByTransform } from \"@next-core/runtime\";\nimport { isEqual } from \"lodash\";\nimport ResizeObserver from \"resize-observer-polyfill\";\nimport type {\n NodeBrickCell,\n NodeBrickConf,\n NodeCell,\n NodeComponentCell,\n} from \"./interfaces\";\nimport type { SizeTuple } from \"../diagram/interfaces\";\nimport { LockIcon } from \"./LockIcon\";\n\nexport interface NodeComponentProps {\n node: NodeCell;\n x?: number;\n y?: number;\n degraded: boolean;\n degradedNodeLabel?: string;\n defaultNodeBricks?: NodeBrickConf[];\n locked?: boolean;\n containerLocked?: boolean;\n groupLocked?: boolean;\n onResize(id: string, size: SizeTuple | null): void;\n}\n\nexport function NodeComponent({\n node,\n x,\n y,\n degraded,\n degradedNodeLabel,\n defaultNodeBricks,\n locked,\n containerLocked,\n groupLocked,\n onResize,\n}: NodeComponentProps): JSX.Element | null {\n const memoizedData = useDeepMemo({\n node: { id: node.id, data: node.data, locked: !!locked },\n });\n const specifiedUseBrick = (node as NodeBrickCell).useBrick;\n const specifiedComponent = (node as NodeComponentCell).component;\n const observerRef = useRef<ResizeObserver | null>(null);\n\n const { useBrick, component: Component } =\n useMemo<\n Pick<NodeBrickConf, \"useBrick\" | \"component\"> | null | undefined\n >(() => {\n return degraded\n ? null\n : specifiedUseBrick\n ? {\n useBrick: specifiedUseBrick,\n }\n : specifiedComponent\n ? {\n component: specifiedComponent,\n }\n : defaultNodeBricks?.find((item) =>\n checkIfByTransform(item, memoizedData)\n );\n }, [\n defaultNodeBricks,\n degraded,\n memoizedData,\n specifiedComponent,\n specifiedUseBrick,\n ]) ?? {};\n\n const label = useMemo<string>(\n () =>\n degraded\n ? String(\n __secret_internals.legacyDoTransform(\n memoizedData,\n degradedNodeLabel ?? \"<% DATA.node.id %>\"\n )\n )\n : \"\",\n [degraded, degradedNodeLabel, memoizedData]\n );\n\n const brickRef = useRef<HTMLElement | null>(null);\n const xRef = useRef<number | undefined>(x);\n const yRef = useRef<number | undefined>(y);\n\n const refCallback = useCallback(\n (element: HTMLElement | null) => {\n brickRef.current = element;\n const prevObserver = observerRef.current;\n if (prevObserver) {\n prevObserver.disconnect();\n observerRef.current = null;\n }\n if (element) {\n if (xRef.current != null && yRef.current != null) {\n element.style.left = `${xRef.current}px`;\n element.style.top = `${yRef.current}px`;\n }\n // Todo: correctly wait for `useBrick` in v3 to be rendered (after layout)\n // Wait a macro task to let `useBrick` to be rendered.\n setTimeout(() => {\n const observer = new ResizeObserver(() => {\n onResize(node.id, [element.offsetWidth, element.offsetHeight]);\n });\n observer.observe(element);\n observerRef.current = observer;\n });\n } else {\n onResize(node.id, null);\n }\n },\n [node.id, onResize]\n );\n\n // Use position instead of transform, for clients\n // that hardware acceleration (GPU) is not available.\n useEffect(() => {\n xRef.current = x;\n yRef.current = y;\n const element = brickRef.current;\n if (element && x != null && y != null) {\n element.style.top = `${y}px`;\n element.style.left = `${x}px`;\n }\n }, [x, y]);\n\n const degradedRefCallBack = useCallback(\n (g: SVGGElement | null) => {\n if (g) {\n // istanbul ignore next\n const size =\n process.env.NODE_ENV === \"test\"\n ? { width: 60, height: 60 }\n : g.getBBox();\n onResize(node.id, [size.width, size.height]);\n } else {\n onResize(node.id, null);\n }\n },\n [node.id, onResize]\n );\n\n const foreignObjectRef = useRef<SVGForeignObjectElement | null>(null);\n\n // Workaround for Firefox bug:\n // https://bugzilla.mozilla.org/show_bug.cgi?id=1644680\n // istanbul ignore next\n useEffect(() => {\n const fo = foreignObjectRef.current;\n if (!fo || !/firefox/i.test(navigator.userAgent)) {\n return;\n }\n fo.style.overflow = \"hidden\";\n // 延时 500ms 是经验值,实际测试如果机器性能较差,可能需要更长的时间。\n // MacBook Air M1 >= 100ms 可以工作,<= 50ms 则不行。\n const timeoutId = setTimeout(() => {\n fo.style.overflow = \"visible\";\n }, 500);\n return () => clearTimeout(timeoutId);\n }, []);\n\n return (\n <>\n {useBrick || Component ? (\n <foreignObject\n // Make a large size to avoid the brick inside to be clipped by the foreignObject.\n width={9999}\n height={9999}\n className=\"node\"\n ref={foreignObjectRef}\n >\n {Component ? (\n <Component {...memoizedData} refCallback={refCallback} />\n ) : (\n <ReactUseBrick\n useBrick={useBrick!}\n data={memoizedData}\n refCallback={refCallback}\n />\n )}\n </foreignObject>\n ) : degraded ? (\n <g className=\"degraded\" ref={degradedRefCallBack}>\n <circle cx={8} cy={8} r={8} />\n <text x={8} y={32}>\n {label}\n </text>\n </g>\n ) : null}\n {locked &&\n ![containerLocked, groupLocked].some(Boolean) &&\n x != null &&\n y != null && (\n <LockIcon x={x + node.view.width + 4} y={y + node.view.height - 12} />\n )}\n </>\n );\n}\n\nfunction useDeepMemo<T>(value: T): T {\n const [memoizedValue, setMemoizedValue] = useState(value);\n\n useEffect(() => {\n setMemoizedValue((prev) => (isEqual(prev, value) ? prev : value));\n }, [value]);\n\n return memoizedValue;\n}\n","import type { PositionTuple } from \"../../diagram/interfaces\";\nimport type { NodeView, SnapToObjectPosition } from \"../interfaces\";\n\nconst DEFAULT_ALL_POSITIONS = [\"center\", \"top\", \"bottom\", \"left\", \"right\"];\n\nexport type SnapPositions = Partial<\n Record<SnapToObjectPosition, PositionTuple>\n>;\n\nexport function getSnapPositions(\n view: NodeView,\n positions: string | undefined\n) {\n const snapPositions: SnapPositions = {};\n for (const position of positions\n ?.split(/\\s+/g)\n ?.flatMap((pos) => (pos === \"all\" ? DEFAULT_ALL_POSITIONS : pos)) ?? []) {\n let tuple: PositionTuple;\n const cx = view.x + view.width / 2;\n const cy = view.y + view.height / 2;\n switch (position) {\n case \"center\":\n tuple = [cx, cy];\n break;\n case \"top\":\n tuple = [cx, view.y];\n break;\n case \"right\":\n tuple = [view.x + view.width, cy];\n break;\n case \"bottom\":\n tuple = [cx, view.y + view.height];\n break;\n case \"left\":\n tuple = [view.x, cy];\n break;\n default:\n throw new Error(`Unknown snap position: \"${position}\"`);\n }\n snapPositions[position] = tuple;\n }\n return snapPositions;\n}\n","import { map } from \"lodash\";\nimport type { PositionTuple } from \"../../diagram/interfaces\";\nimport type {\n ActiveTarget,\n Cell,\n LayoutOptions,\n DecoratorCell,\n LayoutType,\n NodeCell,\n SnapToObjectPosition,\n ActiveTargetOfSingular,\n EditableLineCell,\n} from \"../interfaces\";\nimport type {\n MoveCellPayload,\n ResizeCellPayload,\n} from \"../reducers/interfaces\";\nimport {\n isContainerDecoratorCell,\n isDecoratorCell,\n isEdgeCell,\n isGroupDecoratorCell,\n isLineDecoratorCell,\n isNodeCell,\n} from \"./asserts\";\nimport { cellToTarget } from \"./cellToTarget\";\nimport { getSnapPositions, type SnapPositions } from \"./getSnapPositions\";\nimport { getLockedContainerIds, isLocked } from \"./isLocked\";\nimport { normalizeSnapOptions } from \"./normalizeSnapOptions\";\nimport { sameTarget } from \"./sameTarget\";\nimport { targetIsActive } from \"./targetIsActive\";\n\nconst HORIZONTAL_POSITIONS = [\"left\", \"center\", \"right\"];\nconst VERTICAL_POSITIONS = [\"top\", \"center\", \"bottom\"];\n\nexport function handleMouseDown(\n event: MouseEvent,\n {\n action,\n cell,\n scale,\n layout,\n layoutOptions,\n activeTarget,\n cells,\n onCellsMoving,\n onCellsMoved,\n onCellResizing,\n onCellResized,\n onSwitchActiveTarget,\n updateCurActiveEditableLine,\n }: {\n action: \"move\" | \"resize\";\n cell: Cell;\n scale: number;\n layout?: LayoutType;\n layoutOptions?: LayoutOptions;\n activeTarget: ActiveTarget | null | undefined;\n cells: Cell[];\n onCellsMoving?(info: MoveCellPayload[]): void;\n onCellsMoved?(info: MoveCellPayload[]): void;\n onCellResizing?(info: ResizeCellPayload): void;\n onCellResized?(info: ResizeCellPayload): void;\n onSwitchActiveTarget?(activeTarget: ActiveTarget | null): void;\n updateCurActiveEditableLine?: (\n activeEditableLine: EditableLineCell | null\n ) => void;\n }\n) {\n event.stopPropagation();\n\n // Ignore contextmenu click\n if (event.button === 2 || (event.button === 0 && event.ctrlKey)) {\n return;\n }\n\n // Drag node\n const preActive = targetIsActive(cell, activeTarget);\n const lockedContainerIds = getLockedContainerIds(cells);\n let canUpdateActiveEditableLine = false;\n if (event.shiftKey) {\n const activeTargets = activeTarget\n ? activeTarget?.type === \"multi\"\n ? activeTarget.targets\n : [activeTarget]\n : [];\n let targets: ActiveTargetOfSingular[] = [];\n if (preActive) {\n targets = activeTargets.filter((target) => !sameTarget(target, cell));\n } else {\n targets = [...activeTargets, cell];\n canUpdateActiveEditableLine = true;\n }\n onSwitchActiveTarget?.(\n targets.length > 0 ? { type: \"multi\", targets } : null\n );\n } else {\n if (action === \"resize\" || !preActive) {\n onSwitchActiveTarget?.(cellToTarget(cell));\n canUpdateActiveEditableLine = true;\n }\n }\n\n if (isLocked(cell, lockedContainerIds)) {\n return;\n }\n\n if (\n canUpdateActiveEditableLine &&\n (isEdgeCell(cell) || isLineDecoratorCell(cell))\n ) {\n updateCurActiveEditableLine?.(cell);\n }\n\n if (isEdgeCell(cell)) {\n return;\n }\n\n const activeCells: Cell[] = [];\n const actives =\n activeTarget?.type === \"multi\" && action === \"move\"\n ? cells.filter((c) => targetIsActive(c, activeTarget))\n : [cell];\n actives.forEach((a) => {\n activeCells.push(a);\n if (action === \"move\") {\n if (isContainerDecoratorCell(a)) {\n const groupIds = map(\n cells.filter(\n (c) => isGroupDecoratorCell(c) && c.containerId === a.id\n ),\n \"id\"\n );\n const nodeCells = cells.filter(\n (c) =>\n ((isNodeCell(c) || isGroupDecoratorCell(c)) &&\n c.containerId === a.id &&\n !actives.includes(c)) ||\n (isNodeCell(c) && groupIds.includes(c?.groupId))\n );\n activeCells.push(...nodeCells);\n }\n if (isGroupDecoratorCell(a)) {\n activeCells.push(\n ...cells.filter(\n (c) => isNodeCell(c) && c.groupId === a.id && !actives.includes(c)\n )\n );\n }\n }\n });\n const isAutoLayout = layout === \"force\" || layout === \"dagre\";\n const movableActiveCells = activeCells.filter(\n (c) =>\n !isLocked(c, lockedContainerIds) &&\n ((isNodeCell(c) && !isAutoLayout) || isDecoratorCell(c))\n ) as (NodeCell | DecoratorCell)[];\n\n if (movableActiveCells.length === 0) {\n return;\n }\n\n const snap = normalizeSnapOptions(layoutOptions?.snap);\n const snapToObjectPositions = snap.object?.positions;\n\n const from: PositionTuple = [event.clientX, event.clientY];\n const originals = movableActiveCells.map<{\n cell: NodeCell | DecoratorCell;\n position: PositionTuple;\n snapPositions: SnapPositions | null;\n }>((c) => ({\n cell: c,\n position:\n action === \"move\" ? [c.view.x, c.view.y] : [c.view.width, c.view.height],\n snapPositions:\n action === \"move\" && !isEdgeCell(c)\n ? getSnapPositions(c.view, snapToObjectPositions)\n : null,\n }));\n const firstOriginalPosition = originals[0].position;\n // let previousPositions = originals.map(({ position }) => position);\n\n // Get the positions of the objects (cells that are not active) to snap to\n let snapToObjectTargets: {\n cell: NodeCell | DecoratorCell;\n snapPositions: SnapPositions;\n }[] = [];\n if (action === \"move\" && snap.object) {\n const objectCells = cells.filter(\n // Edge and line cells are not snap targets\n (c) =>\n !isEdgeCell(c) && !isLineDecoratorCell(c) && !activeCells.includes(c)\n ) as (NodeCell | DecoratorCell)[];\n snapToObjectTargets = objectCells.map((c) => ({\n cell: c,\n snapPositions: getSnapPositions(c.view, snapToObjectPositions),\n }));\n }\n\n function getMovement(e: MouseEvent): PositionTuple {\n return [(e.clientX - from[0]) / scale, (e.clientY - from[1]) / scale];\n }\n let moved = false;\n\n const handleMove = (e: MouseEvent, finished?: boolean) => {\n // Respect the scale\n const movement = getMovement(e);\n const snapMovement: PositionTuple = [...movement];\n let newPositions: PositionTuple[];\n let xAlign: [PositionTuple, PositionTuple] | undefined;\n let yAlign: [PositionTuple, PositionTuple] | undefined;\n let xAlignCell: Cell | undefined;\n let yAlignCell: Cell | undefined;\n\n if (!moved) {\n moved = movement[0] ** 2 + movement[1] ** 2 >= 9;\n }\n\n // Use alt key (or option key ⌥ on Mac) to disable snap\n if ((!snap.grid && !snap.object) || e.altKey) {\n // No snap\n newPositions = originals.map(({ position }) => [\n position[0] + movement[0],\n position[1] + movement[1],\n ]);\n } else {\n // Snap\n let diffX = Infinity;\n let diffY = Infinity;\n\n if (snap.object) {\n const snapToObjectDistance = snap.object.distance;\n let xAlignFrom: PositionTuple | undefined;\n let yAlignFrom: PositionTuple | undefined;\n let xAlignTarget: NodeCell | DecoratorCell | undefined;\n let yAlignTarget: NodeCell | DecoratorCell | undefined;\n let xAlignToY = 0;\n let yAlignToX = 0;\n for (const {\n cell: target,\n snapPositions: targetPositions,\n // center: [x, y],\n } of snapToObjectTargets) {\n for (const {\n cell: c,\n snapPositions: originalPositions,\n } of originals) {\n for (const [position, originalPoint] of Object.entries(\n originalPositions!\n )) {\n const horizontal = HORIZONTAL_POSITIONS.includes(position);\n const vertical = VERTICAL_POSITIONS.includes(position);\n const [x, y] = targetPositions[position as SnapToObjectPosition]!;\n const [cx, cy] = originalPoint!;\n if (horizontal) {\n const dX = Math.abs(cx + movement[0] - x);\n const xSnapped = dX < snapToObjectDistance && dX < diffX;\n if (xSnapped) {\n diffX = dX;\n snapMovement[0] = x - cx;\n xAlignCell = c;\n xAlignTarget = target;\n xAlignFrom = [x, y];\n xAlignToY = cy;\n }\n }\n if (vertical) {\n const dY = Math.abs(cy + movement[1] - y);\n const ySnapped = dY < snapToObjectDistance && dY < diffY;\n if (ySnapped) {\n diffY = dY;\n snapMovement[1] = y - cy;\n yAlignCell = c;\n yAlignTarget = target;\n yAlignFrom = [x, y];\n yAlignToX = cx;\n }\n }\n }\n }\n }\n\n if (xAlignTarget && xAlignTarget === yAlignTarget) {\n // Handle special case when both x and y are snapped to the same target.\n const halfHeight = xAlignTarget.view.height / 2;\n const halfWidth = xAlignTarget.view.width / 2;\n xAlign = [\n [xAlignFrom![0], xAlignFrom![1] - halfHeight],\n [xAlignFrom![0], xAlignFrom![1] + halfHeight],\n ];\n yAlign = [\n [yAlignFrom![0] - halfWidth, yAlignFrom![1]],\n [yAlignFrom![0] + halfWidth, yAlignFrom![1]],\n ];\n } else {\n if (xAlignFrom) {\n xAlign = [xAlignFrom, [xAlignFrom[0], xAlignToY + snapMovement[1]]];\n }\n if (yAlignFrom) {\n yAlign = [yAlignFrom, [yAlignToX + snapMovement[0], yAlignFrom[1]]];\n }\n }\n }\n\n if (snap.grid) {\n const snapToGridSize = snap.grid.size;\n // Use the first cell to decide the snap to grid position\n const firstNewPosition: PositionTuple = [\n Math.round(\n (firstOriginalPosition[0] + movement[0]) / snapToGridSize\n ) * snapToGridSize,\n Math.round(\n (firstOriginalPosition[1] + movement[1]) / snapToGridSize\n ) * snapToGridSize,\n ];\n const snapToGridMovement: PositionTuple = [\n firstNewPosition[0] - firstOriginalPosition[0],\n firstNewPosition[1] - firstOriginalPosition[1],\n ];\n const snapToGridDiffX = Math.abs(snapToGridMovement[0] - movement[0]);\n const snapToGridDiffY = Math.abs(snapToGridMovement[1] - movement[1]);\n if (snapToGridDiffX < diffX) {\n diffX = snapToGridDiffX;\n snapMovement[0] = snapToGridMovement[0];\n xAlign = undefined;\n xAlignCell = undefined;\n }\n if (snapToGridDiffY < diffY) {\n diffY = snapToGridDiffY;\n snapMovement[1] = snapToGridMovement[1];\n yAlign = undefined;\n yAlignCell = undefined;\n }\n }\n\n newPositions = originals.map(({ position }) => [\n position[0] + snapMovement[0],\n position[1] + snapMovement[1],\n ]);\n }\n\n if (moved) {\n if (action === \"move\") {\n const payloads = originals.map(({ cell: c }, index) => ({\n type: c.type,\n id: c.id,\n x: newPositions[index][0],\n y: newPositions[index][1],\n groupId: c.groupId,\n containerId: c.containerId,\n width: c.view.width,\n height: c.view.height,\n decorator: isDecoratorCell(c) ? c.decorator : undefined,\n guideLines: finished\n ? undefined\n : [\n ...(xAlignCell === c ? [xAlign!] : []),\n ...(yAlignCell === c ? [yAlign!] : []),\n ],\n ...(isLineDecoratorCell(c)\n ? {\n source: {\n x: c.view.source.x + snapMovement[0],\n y: c.view.source.y + snapMovement[1],\n },\n target: {\n x: c.view.target.x + snapMovement[0],\n y: c.view.target.y + snapMovement[1],\n },\n vertices: c.view.vertices?.map((v) => ({\n x: v.x + snapMovement[0],\n y: v.y + snapMovement[1],\n })),\n }\n : null),\n }));\n (finished ? onCellsMoved : onCellsMoving)?.(payloads);\n } else {\n (finished ? onCellResized : onCellResizing)?.({\n type: cell.type,\n id: cell.id,\n width: newPositions[0][0],\n height: newPositions[0][1],\n });\n }\n }\n };\n\n const onMouseMove = (e: MouseEvent) => {\n handleMove(e);\n };\n const onMouseUp = (e: MouseEvent) => {\n handleMove(e, true);\n moved = false;\n document.removeEventListener(\"mousemove\", onMouseMove);\n document.removeEventListener(\"mouseup\", onMouseUp);\n };\n document.addEventListener(\"mousemove\", onMouseMove);\n document.addEventListener(\"mouseup\", onMouseUp);\n}\n","import {\n DEFAULT_SNAP_GRID_SIZE,\n DEFAULT_SNAP_OBJECT_DISTANCE,\n DEFAULT_SNAP_OBJECT_POSITIONS,\n} from \"../constants\";\nimport type {\n SnapOptions,\n SnapToGridOptions,\n SnapToObjectOptions,\n} from \"../interfaces\";\n\nexport interface NormalizedSnapOptions {\n grid: Required<SnapToGridOptions> | null;\n object: Required<SnapToObjectOptions> | null;\n}\n\nexport function normalizeSnapOptions(\n snap: boolean | SnapOptions | undefined\n): NormalizedSnapOptions {\n const intermediateSnap = snap\n ? snap === true\n ? { grid: true, object: true }\n : snap\n : null;\n const snapToGrid = intermediateSnap?.grid\n ? intermediateSnap.grid === true\n ? {}\n : intermediateSnap.grid\n : null;\n const snapToObject = intermediateSnap?.object\n ? intermediateSnap.object === true\n ? {}\n : intermediateSnap.object\n : null;\n return {\n grid: snapToGrid\n ? { size: snapToGrid.size ?? DEFAULT_SNAP_GRID_SIZE }\n : null,\n object: snapToObject\n ? {\n distance: snapToObject.distance ?? DEFAULT_SNAP_OBJECT_DISTANCE,\n positions: snapToObject.positions ?? DEFAULT_SNAP_OBJECT_POSITIONS,\n }\n : null,\n };\n}\n","// istanbul ignore file: compatibility workaround\nimport type { HTMLAttributes } from \"react\";\n\nlet _supports: boolean | undefined;\n\nfunction supportsContentEditablePlaintextOnly(): boolean {\n if (typeof _supports !== \"boolean\") {\n const div = document.createElement(\"div\");\n div.setAttribute(\"contenteditable\", \"PLAINTEXT-ONLY\");\n _supports = div.contentEditable === \"plaintext-only\";\n }\n return _supports;\n}\n\nexport function getContentEditable(\n editable: boolean\n): HTMLAttributes<HTMLDivElement>[\"contentEditable\"] {\n return editable\n ? supportsContentEditablePlaintextOnly()\n ? \"plaintext-only\"\n : \"true\"\n : \"false\";\n}\n","import React, { useCallback, useEffect, useRef, useState } from \"react\";\nimport type { BasicDecoratorProps } from \"../interfaces\";\nimport classNames from \"classnames\";\nimport { LockIcon } from \"../LockIcon\";\nimport { getContentEditable } from \"../processors/getContentEditable\";\n\nexport type DecoratorTextProps = Pick<\n BasicDecoratorProps,\n | \"cell\"\n | \"readOnly\"\n | \"locked\"\n | \"onDecoratorTextEditing\"\n | \"onDecoratorTextChange\"\n>;\n\nexport function DecoratorText({\n cell,\n readOnly,\n locked,\n onDecoratorTextEditing,\n onDecoratorTextChange,\n}: DecoratorTextProps): JSX.Element {\n const label = cell.view.text ?? \"\";\n const [currentLabel, setCurrentLabel] = useState<string>(label);\n const [editingLabel, setEditingLabel] = useState(false);\n const editingLabelInitialized = useRef(false);\n const [shouldEmitLabelChange, setShouldEmitLabelChange] = useState(false);\n const ref = useRef<HTMLDivElement>(null);\n\n const handleEnableEdit = useCallback(\n (e: React.MouseEvent) => {\n if (readOnly || locked) {\n return;\n }\n e.preventDefault();\n e.stopPropagation();\n setEditingLabel(true);\n },\n [readOnly, locked]\n );\n\n useEffect(() => {\n const element = ref.current;\n if (element && element.textContent !== currentLabel) {\n element.textContent = currentLabel;\n }\n }, [currentLabel]);\n useEffect(() => {\n const parentElement = ref.current?.parentElement;\n if (parentElement) {\n cell.view.width = parentElement.clientWidth;\n cell.view.height = parentElement.clientHeight;\n }\n }, [currentLabel, cell.id]);\n\n useEffect(() => {\n if (editingLabel && ref.current) {\n ref.current.focus();\n selectAllText(ref.current);\n }\n onDecoratorTextEditing?.({ id: cell.id, editing: editingLabel });\n }, [cell.id, editingLabel, onDecoratorTextEditing]);\n\n useEffect(() => {\n if (editingLabelInitialized.current) {\n onDecoratorTextEditing?.({ id: cell.id, editing: editingLabel });\n } else {\n editingLabelInitialized.current = true;\n }\n }, [cell.id, editingLabel, onDecoratorTextEditing]);\n\n const handleInput = useCallback(\n (event: React.FormEvent<HTMLDivElement>) => {\n if (readOnly) {\n return;\n }\n setCurrentLabel((event.target as HTMLDivElement).textContent!);\n },\n [readOnly]\n );\n\n const handleBlur = useCallback(() => {\n if (readOnly) {\n return;\n }\n setEditingLabel(false);\n setShouldEmitLabelChange(true);\n }, [readOnly]);\n\n useEffect(() => {\n if (shouldEmitLabelChange) {\n onDecoratorTextChange?.({\n id: cell.id,\n view: { ...cell.view, text: currentLabel },\n });\n setShouldEmitLabelChange(false);\n }\n }, [cell, currentLabel, onDecoratorTextChange, shouldEmitLabelChange]);\n\n return (\n <>\n <foreignObject className=\"decorator-text\" width=\"9999\" height=\"9999\">\n <div\n className={classNames(\"text-container\", { editing: editingLabel })}\n onDoubleClick={handleEnableEdit}\n style={cell.view.style}\n >\n <div\n className=\"text\"\n contentEditable={getContentEditable(editingLabel)}\n ref={ref}\n onInput={handleInput}\n onBlur={handleBlur}\n />\n </div>\n </foreignObject>\n {locked && (\n <LockIcon x={cell.view.width} y={(cell.view.height - 12) / 2} />\n )}\n </>\n );\n}\n\nexport function selectAllText(element: HTMLElement) {\n const range = document.createRange();\n range.selectNodeContents(element);\n const selection = window.getSelection()!;\n selection.removeAllRanges();\n selection.addRange(range);\n}\n","import React from \"react\";\nimport type { BasicDecoratorProps, DecoratorType } from \"../interfaces\";\nimport { DecoratorArea } from \"./DecoratorArea\";\nimport { DecoratorText } from \"./DecoratorText\";\nimport { DecoratorContainer } from \"./DecoratorContainer\";\nimport { DecoratorRect } from \"./DecoratorRect\";\nimport { DecoratorLine } from \"./DecoratorLine\";\nimport { DecoratorGroup } from \"./DecoratorGroup\";\n\nconst decoratorComponents = new Map<\n DecoratorType,\n React.ComponentType<BasicDecoratorProps>\n>([\n [\"group\", DecoratorGroup],\n [\"container\", DecoratorContainer],\n [\"area\", DecoratorArea],\n [\"text\", DecoratorText],\n [\"rect\", DecoratorRect],\n [\"line\", DecoratorLine],\n]);\n\nexport function DecoratorComponent({\n cell,\n view,\n transform,\n readOnly,\n layout,\n layoutOptions,\n active,\n activeTarget,\n cells,\n lineConfMap,\n editableLineMap,\n locked,\n onCellResizing,\n onCellResized,\n onSwitchActiveTarget,\n onDecoratorTextEditing,\n onDecoratorTextChange,\n onDecoratorGroupPlusClick,\n}: BasicDecoratorProps): JSX.Element | null {\n const SpecifiedComponent = decoratorComponents.get(cell.decorator);\n\n if (!SpecifiedComponent) {\n // eslint-disable-next-line no-console\n console.error(`Unknown decorator: ${cell.decorator}`);\n return null;\n }\n\n return (\n <SpecifiedComponent\n cell={cell}\n view={view}\n transform={transform}\n readOnly={readOnly}\n layout={layout}\n layoutOptions={layoutOptions}\n active={active}\n activeTarget={activeTarget}\n cells={cells}\n lineConfMap={lineConfMap}\n editableLineMap={editableLineMap}\n locked={locked}\n onCellResizing={onCellResizing}\n onCellResized={onCellResized}\n onSwitchActiveTarget={onSwitchActiveTarget}\n onDecoratorTextEditing={onDecoratorTextEditing}\n onDecoratorTextChange={onDecoratorTextChange}\n onDecoratorGroupPlusClick={onDecoratorGroupPlusClick}\n />\n );\n}\n","import React, { useMemo } from \"react\";\nimport type { BasicDecoratorProps } from \"../interfaces\";\nimport { LockIcon } from \"../LockIcon\";\nimport classNames from \"classnames\";\nimport { PlusOutlined } from \"@ant-design/icons\";\nimport { highlightGroupCell } from \"../processors/initialGroupLayout\";\n\nexport type DecoratorRectProps = Omit<\n BasicDecoratorProps,\n \"lineConfMap\" | \"editableLineMap\"\n>;\n\nexport function DecoratorGroup({\n cell,\n view,\n activeTarget,\n cells,\n locked,\n onDecoratorGroupPlusClick,\n}: DecoratorRectProps): JSX.Element {\n const active = useMemo(\n () => highlightGroupCell(cell, activeTarget, cells),\n [activeTarget, cell, cells]\n );\n\n return (\n <g\n className={classNames(\"decorator-group\", {\n [\"active-group\"]: active,\n })}\n >\n <foreignObject\n className=\"group-wrapper\"\n width={cell.view.width + 10}\n height={cell.view.height + 10}\n >\n <div\n className=\"group\"\n style={{\n ...cell.view?.style,\n width: cell.view.width,\n height: cell.view.height,\n }}\n >\n {view.usePlus && (\n <PlusOutlined\n className=\"plus-icon\"\n onClick={() => onDecoratorGroupPlusClick?.(cell)}\n />\n )}\n </div>\n </foreignObject>\n {locked && (\n <LockIcon x={cell.view.width! - 16} y={cell.view.height! - 16} />\n )}\n </g>\n );\n}\n","import React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { BasicDecoratorProps, NodeCell } from \"../interfaces\";\nimport { handleMouseDown } from \"../processors/handleMouseDown\";\nimport classNames from \"classnames\";\nimport { get } from \"lodash\";\nimport { selectAllText } from \"./DecoratorText\";\nimport { isNoManualLayout } from \"../processors/asserts\";\nimport { uuidV4 } from \"..\";\nimport { LockIcon } from \"../LockIcon\";\nimport { getContentEditable } from \"../processors/getContentEditable\";\n\nexport function DecoratorContainer({\n cell,\n transform,\n readOnly,\n layout,\n view,\n activeTarget,\n cells,\n locked,\n onCellResizing,\n onCellResized,\n onSwitchActiveTarget,\n onDecoratorTextEditing,\n onDecoratorTextChange,\n}: BasicDecoratorProps): JSX.Element {\n const label = get(cell.view, \"text\", \"\");\n const direction = get(cell.view, \"direction\", \"top\");\n const textRef = useRef<HTMLDivElement>(null);\n const resizeHandleRef = React.useRef<SVGGElement>(null);\n const [editingLabel, setEditingLabel] = useState(false);\n const [currentLabel, setCurrentLabel] = useState<string>(label);\n const [shouldEmitLabelChange, setShouldEmitLabelChange] = useState(false);\n const [recomputation, setRecomputation] = useState<string>();\n const [titleForeignRect, setTitleForeignRect] = useState({\n x: 0,\n y: 0,\n width: cell.view.width,\n height: cell.view.height,\n });\n // istanbul ignore next\n const shouldHighlight = useMemo(() => {\n let activeTargetCells = [],\n active = false;\n if (activeTarget?.type === \"multi\") {\n activeTargetCells = activeTarget.targets;\n } else if (activeTarget?.type === \"node\") {\n activeTargetCells.push(activeTarget);\n }\n const containerLeft = cell.view.x;\n const containerRight = cell.view.x + cell.view.width;\n const containerTop = cell.view.y;\n const containerBottom = cell.view.y + cell.view.height;\n active = activeTargetCells.some((item) => {\n if (item?.type === \"node\" || item.type === \"decorator\") {\n const targetCell = cells.find(\n (c) =>\n (c?.type === \"node\" || c.type === \"decorator\") && c.id === item.id\n ) as NodeCell;\n if (targetCell) {\n const left = targetCell.view.x;\n const right = targetCell.view.x + targetCell.view.width;\n const top = targetCell.view.y;\n const bottom = targetCell.view.y + targetCell.view.height;\n return (\n left >= containerLeft &&\n right <= containerRight &&\n top >= containerTop &&\n bottom <= containerBottom\n );\n }\n }\n });\n return active;\n }, [activeTarget, cell, cells]);\n const handleEnableEdit = useCallback(\n (e: React.MouseEvent) => {\n if (readOnly || locked) {\n return;\n }\n e.preventDefault();\n e.stopPropagation();\n setEditingLabel(true);\n },\n [readOnly, locked]\n );\n const handleInput = useCallback(\n (event: React.FormEvent<HTMLDivElement>) => {\n if (readOnly) {\n return;\n }\n setCurrentLabel((event.target as HTMLDivElement).textContent!);\n },\n [readOnly]\n );\n\n const handleBlur = useCallback(() => {\n if (readOnly) {\n return;\n }\n setEditingLabel(false);\n setShouldEmitLabelChange(true);\n setRecomputation(uuidV4());\n }, [readOnly]);\n\n useEffect(() => {\n setCurrentLabel(label);\n }, [label]);\n\n useEffect(() => {\n const element = textRef.current;\n if (element && element.textContent !== currentLabel) {\n element.textContent = currentLabel;\n }\n }, [currentLabel]);\n\n useEffect(() => {\n const element = textRef.current?.parentElement;\n if (!element) return;\n\n const resizeObserver = new ResizeObserver(() => {\n const { clientWidth, clientHeight } = element;\n if ([\"left\", \"right\"].includes(direction)) {\n setTitleForeignRect({\n width: clientWidth,\n height: view.height,\n x: direction === \"left\" ? -clientWidth : view.width,\n y: 0,\n });\n } else {\n setTitleForeignRect({\n width: view.width,\n height: clientHeight,\n x: 0,\n y: direction === \"top\" ? -clientHeight : view.height,\n });\n }\n });\n\n resizeObserver.observe(element);\n return () => resizeObserver.disconnect();\n }, [view, currentLabel, direction, recomputation]);\n\n useEffect(() => {\n if (editingLabel && textRef.current) {\n textRef.current.focus();\n selectAllText(textRef.current);\n }\n onDecoratorTextEditing?.({ id: cell.id, editing: editingLabel });\n }, [cell.id, editingLabel, onDecoratorTextEditing]);\n\n useEffect(() => {\n if (shouldEmitLabelChange) {\n onDecoratorTextChange?.({\n id: cell.id,\n view: { ...view, text: currentLabel },\n });\n setShouldEmitLabelChange(false);\n }\n }, [cell, view, currentLabel, onDecoratorTextChange, shouldEmitLabelChange]);\n\n useEffect(() => {\n const resizeHandle = resizeHandleRef.current;\n if (!resizeHandle || readOnly) {\n return;\n }\n const onMouseDown = (event: MouseEvent) => {\n handleMouseDown(event, {\n action: \"resize\",\n cell,\n scale: transform.k,\n activeTarget,\n cells,\n onCellResizing,\n onCellResized,\n onSwitchActiveTarget,\n });\n };\n resizeHandle.addEventListener(\"mousedown\", onMouseDown);\n return () => {\n resizeHandle.removeEventListener(\"mousedown\", onMouseDown);\n };\n }, [\n activeTarget,\n cell,\n cells,\n onCellResized,\n onCellResizing,\n onSwitchActiveTarget,\n readOnly,\n transform.k,\n ]);\n\n return (\n <g className=\"decorator-container\">\n <foreignObject {...titleForeignRect}>\n <div\n className={classNames(\"text-container\", {\n editing: editingLabel,\n [[\"left\", \"right\"].includes(direction) ? \"vertical\" : \"horizontal\"]:\n true,\n })}\n onDoubleClick={handleEnableEdit}\n style={cell.view.titleStyle}\n >\n <div\n className=\"text\"\n contentEditable={getContentEditable(editingLabel)}\n ref={textRef}\n onInput={handleInput}\n onBlur={handleBlur}\n />\n </div>\n </foreignObject>\n <foreignObject\n x={0}\n y={0}\n width={view.width}\n height={view.height}\n className=\"container-wrapper\"\n >\n <div\n className={classNames(\"container\", {\n [\"active-container\"]: shouldHighlight,\n })}\n style={{\n ...cell.view.style,\n width: view.width,\n height: view.height,\n }}\n />\n </foreignObject>\n {!readOnly && !locked && !isNoManualLayout(layout) && (\n <g\n ref={resizeHandleRef}\n className=\"resize-handle\"\n transform={`translate(${view.width - 20} ${view.height - 20})`}\n >\n <rect width={20} height={20} />\n <path d=\"M10 18L18 10 M15 18L18 15\" />\n </g>\n )}\n {locked && (\n <LockIcon x={cell.view.width - 16} y={cell.view.height - 16} />\n )}\n </g>\n );\n}\n","import React, { useEffect } from \"react\";\nimport type { BasicDecoratorProps } from \"../interfaces\";\nimport { handleMouseDown } from \"../processors/handleMouseDown\";\nimport { LockIcon } from \"../LockIcon\";\n\nexport function DecoratorArea({\n cell,\n transform,\n readOnly,\n layoutOptions,\n activeTarget,\n cells,\n locked,\n onCellResizing,\n onCellResized,\n onSwitchActiveTarget,\n}: BasicDecoratorProps): JSX.Element {\n const resizeHandleRef = React.useRef<SVGGElement>(null);\n\n useEffect(() => {\n const resizeHandle = resizeHandleRef.current;\n if (!resizeHandle || readOnly) {\n return;\n }\n const onMouseDown = (event: MouseEvent) => {\n handleMouseDown(event, {\n action: \"resize\",\n cell,\n scale: transform.k,\n layoutOptions,\n activeTarget,\n cells,\n onCellResizing,\n onCellResized,\n onSwitchActiveTarget,\n });\n };\n resizeHandle.addEventListener(\"mousedown\", onMouseDown);\n return () => {\n resizeHandle.removeEventListener(\"mousedown\", onMouseDown);\n };\n }, [\n activeTarget,\n cell,\n cells,\n layoutOptions,\n onCellResized,\n onCellResizing,\n onSwitchActiveTarget,\n readOnly,\n transform.k,\n ]);\n\n return (\n <g className=\"decorator-area-container\">\n <foreignObject className=\"decorator-area\" width=\"9999\" height=\"9999\">\n <div\n className=\"area\"\n style={{\n ...cell.view.style,\n width: cell.view.width,\n height: cell.view.height,\n }}\n />\n </foreignObject>\n {!readOnly && !locked && (\n <g\n ref={resizeHandleRef}\n className=\"resize-handle\"\n transform={`translate(${cell.view.width - 20} ${cell.view.height - 20})`}\n >\n <rect width={20} height={20} />\n <path d=\"M10 18L18 10 M15 18L18 15\" />\n </g>\n )}\n {locked && (\n <LockIcon x={cell.view.width - 16} y={cell.view.height - 16} />\n )}\n </g>\n );\n}\n","import React, { useEffect } from \"react\";\nimport type { BasicDecoratorProps } from \"../interfaces\";\nimport { handleMouseDown } from \"../processors/handleMouseDown\";\nimport { isNoManualLayout } from \"../processors/asserts\";\nimport { LockIcon } from \"../LockIcon\";\n\nexport type DecoratorRectProps = Omit<\n BasicDecoratorProps,\n \"lineConfMap\" | \"editableLineMap\"\n>;\n\nexport function DecoratorRect({\n cell,\n transform,\n readOnly,\n layout,\n view,\n activeTarget,\n cells,\n locked,\n onCellResizing,\n onCellResized,\n onSwitchActiveTarget,\n}: DecoratorRectProps): JSX.Element {\n const resizeHandleRef = React.useRef<SVGGElement>(null);\n\n useEffect(() => {\n const resizeHandle = resizeHandleRef.current;\n if (!resizeHandle || readOnly) {\n return;\n }\n const onMouseDown = (event: MouseEvent) => {\n handleMouseDown(event, {\n action: \"resize\",\n cell,\n scale: transform.k,\n layout,\n activeTarget,\n cells,\n onCellResizing,\n onCellResized,\n onSwitchActiveTarget,\n });\n };\n resizeHandle.addEventListener(\"mousedown\", onMouseDown);\n return () => {\n resizeHandle.removeEventListener(\"mousedown\", onMouseDown);\n };\n }, [\n activeTarget,\n cell,\n cells,\n onCellResized,\n onCellResizing,\n onSwitchActiveTarget,\n readOnly,\n transform.k,\n layout,\n ]);\n\n return (\n <g className=\"decorator-rect-container\">\n <foreignObject className=\"decorator-rect\" width=\"9999\" height=\"9999\">\n <div\n className=\"rect-container\"\n style={{\n ...cell.view.style,\n width: view.width,\n height: view.height,\n }}\n />\n </foreignObject>\n {!readOnly && !locked && !isNoManualLayout(layout) && (\n <g\n ref={resizeHandleRef}\n className=\"resize-handle\"\n transform={`translate(${view.width - 20} ${view.height - 20})`}\n >\n <rect width={20} height={20} />\n <path d=\"M10 18L18 10 M15 18L18 15\" />\n </g>\n )}\n {locked && (\n <LockIcon x={cell.view.width - 16} y={cell.view.height - 16} />\n )}\n </g>\n );\n}\n","import React, { useCallback, useMemo, useRef } from \"react\";\nimport classNames from \"classnames\";\nimport type { BasicDecoratorProps } from \"../interfaces\";\nimport { getMarkers } from \"../../shared/canvas/useLineMarkers\";\nimport type { LineMarkerConf } from \"../../diagram/interfaces\";\nimport { curveLine } from \"../../diagram/lines/curveLine\";\nimport { LockIcon } from \"../LockIcon\";\nimport { getLineLockIconPosition } from \"../processors/getLineLockIconPosition\";\n\nexport type DecoratorLineProps = Pick<\n BasicDecoratorProps,\n \"cell\" | \"active\" | \"locked\" | \"lineConfMap\" | \"editableLineMap\"\n>;\n\nexport function DecoratorLine({\n cell,\n active,\n lineConfMap,\n editableLineMap,\n locked,\n}: DecoratorLineProps): JSX.Element | null {\n const lineConf = lineConfMap.get(cell);\n const { points: linePoints, jumpsMap } = editableLineMap.get(cell) ?? {};\n\n const line = useMemo(() => {\n // istanbul ignore next: defensive check\n if (!lineConf) {\n return null;\n }\n return curveLine(\n linePoints,\n lineConf.type === \"curve\" ? lineConf.curveType : \"curveLinear\",\n 0,\n 1,\n jumpsMap\n );\n }, [lineConf, linePoints, jumpsMap]);\n\n const pathRef = useRef<SVGPathElement | null>(null);\n const pathRefCallback = useCallback(\n (element: SVGPathElement | null) => {\n pathRef.current = element;\n // istanbul ignore next: Jest does not support `SVGPathElement::getBBox`\n if (element && process.env.NODE_ENV !== \"test\") {\n const rect = element.getBBox();\n cell.view = {\n ...cell.view,\n x: rect.x,\n y: rect.y,\n width: rect.width,\n height: rect.height,\n };\n }\n },\n [cell]\n );\n\n const lockedPosition = useMemo(\n () => (locked && linePoints ? getLineLockIconPosition(linePoints) : null),\n [locked, linePoints]\n );\n\n if (!line || !lineConf) {\n return null;\n }\n\n let markerStart: string | undefined;\n let markerEnd: string | undefined;\n let strokeColor: string | undefined;\n let strokeWidth: number | undefined;\n const lineMarkers: LineMarkerConf[] = getMarkers(lineConf);\n if (active) {\n const overrides = lineConf.overrides?.active;\n strokeColor = overrides?.strokeColor ?? lineConf.strokeColor;\n strokeWidth = overrides?.strokeWidth ?? lineConf.strokeWidth;\n // motion = overrides?.motion;\n for (const marker of lineMarkers) {\n if (marker.placement === \"start\") {\n markerStart =\n lineConf.$activeMarkerStartUrl ?? lineConf.$markerStartUrl;\n } else {\n markerEnd = lineConf.$activeMarkerEndUrl ?? lineConf.$markerEndUrl;\n }\n }\n } else {\n strokeColor = lineConf.strokeColor;\n strokeWidth = lineConf.strokeWidth;\n for (const marker of lineMarkers) {\n if (marker.placement === \"start\") {\n markerStart = lineConf.$markerStartUrl;\n } else {\n markerEnd = lineConf.$markerEndUrl;\n }\n }\n }\n\n return (\n <g className=\"decorator-line\">\n <path\n // This `path` is made for expanding interaction area of graph lines.\n d={line}\n fill=\"none\"\n stroke=\"transparent\"\n strokeWidth={lineConf.interactStrokeWidth}\n />\n <path\n className={classNames(\"line\", {\n dashed: lineConf.dashed,\n dotted: lineConf.dotted,\n })}\n ref={pathRefCallback}\n d={line}\n fill=\"none\"\n stroke={strokeColor}\n strokeWidth={strokeWidth}\n markerStart={markerStart}\n markerEnd={markerEnd}\n />\n {locked && <LockIcon x={lockedPosition!.x} y={lockedPosition!.y} />}\n </g>\n );\n}\n","import type { NodePosition } from \"../../diagram/interfaces\";\n\nexport function getLineLockIconPosition(\n linePoints: NodePosition[]\n): NodePosition {\n const lastPoint = linePoints[linePoints.length - 1];\n if (linePoints.length < 2) {\n return {\n x: lastPoint.x + 16,\n y: lastPoint.y - 6,\n };\n }\n\n const firstPoint = linePoints[0];\n const dy = lastPoint.y - firstPoint.y;\n const dx = lastPoint.x - firstPoint.x;\n\n let useEndPoint: boolean;\n if (Math.abs(dy) > Math.abs(dx)) {\n useEndPoint = dy > 0;\n } else {\n useEndPoint = dx > 0;\n }\n\n const point1 = useEndPoint\n ? linePoints[linePoints.length - 2]\n : linePoints[1];\n const point2 = useEndPoint ? lastPoint : firstPoint;\n\n const angle = Math.atan2(point2.y - point1.y, point2.x - point1.x);\n const twistedAngle = angle - (Math.PI * 3) / 4;\n const distance = 16;\n return {\n x: point2.x + Math.cos(twistedAngle) * distance - 6,\n y: point2.y + Math.sin(twistedAngle) * distance - 6,\n };\n}\n","import React, { useCallback, useEffect, useMemo, useRef } from \"react\";\nimport classNames from \"classnames\";\nimport type {\n ActiveTarget,\n Cell,\n CellContextMenuDetail,\n ComputedEdgeLineConf,\n DecoratorTextChangeDetail,\n DecoratorView,\n LayoutOptions,\n LayoutType,\n NodeBrickConf,\n NodeCell,\n EditableLine,\n EditableLineCell,\n EditableEdgeLine,\n CellClickDetail,\n DecoratorCell,\n BaseNodeCell,\n} from \"./interfaces\";\nimport {\n isContainerDecoratorCell,\n isDecoratorCell,\n isEdgeCell,\n isEdgeSide,\n isGroupDecoratorCell,\n isLineDecoratorCell,\n isNoManualLayout,\n isNodeCell,\n} from \"./processors/asserts\";\nimport { EdgeComponent } from \"./EdgeComponent\";\nimport { NodeComponent } from \"./NodeComponent\";\nimport { handleMouseDown } from \"./processors/handleMouseDown\";\nimport type { MoveCellPayload, ResizeCellPayload } from \"./reducers/interfaces\";\nimport { DecoratorComponent } from \"./decorators\";\nimport { cellToTarget } from \"./processors/cellToTarget\";\nimport type { SizeTuple, TransformLiteral } from \"../diagram/interfaces\";\nimport { sameTarget } from \"./processors/sameTarget\";\nimport { targetIsActive } from \"./processors/targetIsActive\";\nimport { computeBoundingBox } from \"./processors/computeBoundingBox\";\nimport { get } from \"lodash\";\nimport { useHoverStateContext } from \"./HoverStateContext\";\nimport {\n GROUPPADDING,\n highlightGroupCell,\n} from \"./processors/initialGroupLayout\";\nexport interface CellComponentProps {\n layout: LayoutType;\n layoutOptions?: LayoutOptions;\n cell: Cell;\n cells: Cell[];\n degraded: boolean;\n degradedNodeLabel?: string;\n defaultNodeBricks?: NodeBrickConf[];\n transform: TransformLiteral;\n lineConfMap: WeakMap<EditableLineCell, ComputedEdgeLineConf>;\n editableLineMap: WeakMap<EditableLineCell, EditableLine>;\n activeTarget: ActiveTarget | null | undefined;\n readOnly?: boolean;\n hoverCell?: Cell | null | undefined;\n unrelatedCells: Cell[];\n dragoverContainer?: boolean;\n allowEdgeToArea?: boolean;\n curActiveEditableLine?: EditableLineCell | null;\n locked?: boolean;\n containerLocked?: boolean;\n groupLocked?: boolean;\n updateCurActiveEditableLine?: (\n activeEditableLine: EditableLineCell | null\n ) => void;\n onCellsMoving?(info: MoveCellPayload[]): void;\n onCellsMoved?(info: MoveCellPayload[]): void;\n onCellResizing?(info: ResizeCellPayload): void;\n onCellResized?(info: ResizeCellPayload): void;\n onSwitchActiveTarget(target: ActiveTarget | null): void;\n onCellContextMenu(detail: CellContextMenuDetail): void;\n onCellClick?(detail: CellClickDetail): void;\n onDecoratorTextEditing?(detail: { id: string; editing: boolean }): void;\n onDecoratorTextChange?(detail: DecoratorTextChangeDetail): void;\n onDecoratorGroupPlusClick?(detail: DecoratorCell): void;\n onNodeBrickResize(id: string, size: SizeTuple | null): void;\n onCellMouseEnter?(cell: Cell): void;\n onCellMouseLeave?(cell: Cell): void;\n}\n\nexport function CellComponent({\n layout,\n layoutOptions,\n cell,\n cells,\n degraded,\n degradedNodeLabel,\n defaultNodeBricks,\n lineConfMap,\n editableLineMap,\n activeTarget,\n dragoverContainer,\n readOnly,\n transform,\n hoverCell,\n unrelatedCells,\n allowEdgeToArea,\n curActiveEditableLine,\n locked,\n containerLocked,\n groupLocked,\n updateCurActiveEditableLine,\n onCellsMoving,\n onCellsMoved,\n onCellResizing,\n onCellResized,\n onSwitchActiveTarget,\n onCellContextMenu,\n onCellClick,\n onDecoratorTextEditing,\n onDecoratorTextChange,\n onDecoratorGroupPlusClick,\n onNodeBrickResize,\n onCellMouseEnter,\n onCellMouseLeave,\n}: CellComponentProps): JSX.Element | null {\n const {\n lineEditorState,\n smartConnectLineState,\n setSmartConnectLineState,\n onConnect,\n setLineEditorState,\n onChangeEdgeView,\n } = useHoverStateContext();\n const gRef = useRef<SVGGElement>(null);\n const unrelated = useMemo(\n () => unrelatedCells.some((item) => sameTarget(item, cell)),\n [cell, unrelatedCells]\n );\n\n const containerRect = useMemo((): DecoratorView | undefined => {\n if (isContainerDecoratorCell(cell) && isNoManualLayout(layout)) {\n const containCells = cells.filter(\n (c): c is NodeCell => isNodeCell(c) && c.containerId === cell.id\n );\n const view = {\n ...cell.view,\n ...computeBoundingBox(containCells),\n };\n cell.view = view; //Update the rect container to make sure Lasso gets the correct size\n return view;\n }\n if (\n isGroupDecoratorCell(cell) &&\n highlightGroupCell(cell, activeTarget, cells)\n ) {\n const nodeViews = cells.filter(\n (c) => c.type === \"node\" && c.groupId === cell.id\n );\n const view = {\n ...cell.view,\n ...computeBoundingBox(nodeViews as BaseNodeCell[], {\n padding: GROUPPADDING,\n }),\n };\n cell.view = view;\n return view;\n }\n return isEdgeCell(cell) || isLineDecoratorCell(cell)\n ? undefined\n : get(cell, \"view\", { x: 0, y: 0, width: 0, height: 0 });\n }, [layout, cell, cells, activeTarget]);\n\n useEffect(() => {\n const g = gRef.current;\n if (!g) {\n return;\n }\n const onMouseDown = (event: MouseEvent) => {\n if (\n readOnly ||\n ([isContainerDecoratorCell(cell), isGroupDecoratorCell(cell)].some(\n Boolean\n ) &&\n isNoManualLayout(layout))\n ) {\n event.stopPropagation();\n } else {\n handleMouseDown(event, {\n layout,\n layoutOptions,\n action: \"move\",\n cell,\n scale: transform.k,\n activeTarget,\n cells,\n onCellsMoving,\n onCellsMoved,\n onSwitchActiveTarget,\n updateCurActiveEditableLine,\n });\n }\n };\n g.addEventListener(\"mousedown\", onMouseDown);\n return () => {\n g.removeEventListener(\"mousedown\", onMouseDown);\n };\n }, [\n layout,\n layoutOptions,\n cell,\n activeTarget,\n cells,\n onCellsMoved,\n onCellsMoving,\n onSwitchActiveTarget,\n updateCurActiveEditableLine,\n readOnly,\n transform.k,\n ]);\n\n // istanbul ignore next: experimental\n useEffect(() => {\n const g = gRef.current;\n if (\n !g ||\n !isEdgeSide(cell, allowEdgeToArea) ||\n !(\n smartConnectLineState ||\n (lineEditorState && lineEditorState.type !== \"control\")\n )\n ) {\n return;\n }\n const onMouseUp = (e: MouseEvent) => {\n if (\n curActiveEditableLine &&\n lineEditorState &&\n curActiveEditableLine.type === \"decorator\"\n ) {\n return;\n }\n e.preventDefault();\n e.stopPropagation();\n if (smartConnectLineState) {\n if (smartConnectLineState.source !== cell) {\n onConnect?.(\n smartConnectLineState.source,\n cell,\n smartConnectLineState.exitPosition,\n undefined\n );\n }\n setSmartConnectLineState(null);\n } else if (curActiveEditableLine && lineEditorState) {\n const { type } = lineEditorState;\n const { source, target } = editableLineMap.get(\n curActiveEditableLine\n ) as EditableEdgeLine;\n const { view } = curActiveEditableLine;\n\n const isEntry = type === \"entry\";\n if ((isEntry ? target : source) === cell) {\n if (isEntry) {\n onChangeEdgeView?.(source!, target!, {\n ...view,\n entryPosition: null,\n // ...(!view?.exitPosition ? { vertices: null } : {}),\n });\n } else {\n onChangeEdgeView?.(source!, target!, {\n ...view,\n exitPosition: null,\n // ...(!view?.entryPosition ? { vertices: null } : {}),\n });\n }\n }\n setLineEditorState(null);\n }\n };\n g.addEventListener(\"mouseup\", onMouseUp);\n return () => {\n g.removeEventListener(\"mouseup\", onMouseUp);\n };\n }, [\n curActiveEditableLine,\n editableLineMap,\n allowEdgeToArea,\n cell,\n lineEditorState,\n onChangeEdgeView,\n onConnect,\n setLineEditorState,\n setSmartConnectLineState,\n smartConnectLineState,\n updateCurActiveEditableLine,\n ]);\n\n const handleContextMenu = useCallback(\n (event: React.MouseEvent<SVGGElement>) => {\n if (readOnly && cell.type === \"decorator\") {\n return;\n }\n event.preventDefault();\n event.stopPropagation();\n let target = activeTarget;\n // When right-click a cell,\n // - if it's already active, use previous active target (including multiple targets)\n // - if it's inactive, use the cell as the new only target (excluding previous active target)\n if (!targetIsActive(cell, activeTarget)) {\n target = cellToTarget(cell);\n onSwitchActiveTarget(target);\n }\n onCellContextMenu({\n cell,\n clientX: event.clientX,\n clientY: event.clientY,\n locked,\n target: target!,\n });\n },\n [\n readOnly,\n cell,\n activeTarget,\n onCellContextMenu,\n locked,\n onSwitchActiveTarget,\n ]\n );\n\n const handleCellClick = useCallback(\n (event: React.MouseEvent<SVGGElement>) => {\n if (!onCellClick || cell.type === \"decorator\") {\n return;\n }\n onCellClick({\n cell,\n clientX: event.clientX,\n clientY: event.clientY,\n locked,\n });\n },\n [cell, onCellClick, locked]\n );\n\n const handleMouseEnter = useCallback(() => {\n onCellMouseEnter?.(cell);\n }, [cell, onCellMouseEnter]);\n\n const handleMouseLeave = useCallback(() => {\n onCellMouseLeave?.(cell);\n }, [cell, onCellMouseLeave]);\n\n const active = targetIsActive(cell, activeTarget);\n return (\n <g\n className={classNames(\"cell\", {\n active,\n faded: unrelated,\n \"read-only\": readOnly,\n \"container-dragover\": dragoverContainer,\n })}\n ref={gRef}\n transform={\n (isNodeCell(cell) && !degraded) ||\n isEdgeCell(cell) ||\n isLineDecoratorCell(cell) ||\n cell.view?.x == null ||\n cell.view?.y == null\n ? undefined\n : `translate(${containerRect!.x},${containerRect!.y})`\n }\n onContextMenu={handleContextMenu}\n onClick={handleCellClick}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n >\n {isNodeCell(cell) ? (\n <NodeComponent\n node={cell}\n x={containerRect?.x}\n y={containerRect?.y}\n degraded={degraded}\n degradedNodeLabel={degradedNodeLabel}\n defaultNodeBricks={defaultNodeBricks}\n locked={locked}\n containerLocked={containerLocked}\n groupLocked={groupLocked}\n onResize={onNodeBrickResize}\n />\n ) : isEdgeCell(cell) ? (\n <EdgeComponent\n edge={cell}\n active={readOnly ? hoverCell === cell : active}\n activeRelated={!!(readOnly ? hoverCell : activeTarget) && !unrelated}\n lineConfMap={lineConfMap}\n editableLineMap={editableLineMap}\n readOnly={readOnly}\n onSwitchActiveTarget={onSwitchActiveTarget}\n />\n ) : isDecoratorCell(cell) ? (\n <DecoratorComponent\n cell={cell}\n view={containerRect!}\n transform={transform}\n readOnly={readOnly}\n layout={layout}\n layoutOptions={layoutOptions}\n active={active}\n activeTarget={activeTarget}\n cells={cells}\n lineConfMap={lineConfMap}\n editableLineMap={editableLineMap}\n locked={locked}\n onCellResizing={onCellResizing}\n onCellResized={onCellResized}\n onSwitchActiveTarget={onSwitchActiveTarget}\n onDecoratorTextEditing={onDecoratorTextEditing}\n onDecoratorTextChange={onDecoratorTextChange}\n onDecoratorGroupPlusClick={onDecoratorGroupPlusClick}\n />\n ) : null}\n </g>\n );\n}\n","// istanbul ignore file: experimental\nimport React, { useEffect, useMemo, useState } from \"react\";\nimport classNames from \"classnames\";\nimport type { ComputedLineConnecterConf, LineSettings } from \"./interfaces\";\nimport type {\n LineMarkerConf,\n PositionTuple,\n TransformLiteral,\n} from \"../diagram/interfaces\";\nimport { curveLine } from \"../diagram/lines/curveLine\";\nimport { useHoverStateContext } from \"./HoverStateContext\";\nimport { getConnectLinePoints } from \"../shared/canvas/processors/getConnectLinePoints\";\nimport { getMarkers } from \"../shared/canvas/useLineMarkers\";\n\nexport interface SmartConnectLineComponentProps {\n transform: TransformLiteral;\n lineSettings?: LineSettings;\n options: ComputedLineConnecterConf;\n}\n\nexport function SmartConnectLineComponent({\n transform,\n lineSettings,\n options,\n}: SmartConnectLineComponentProps): JSX.Element {\n const [connectLineTo, setConnectLineTo] = useState<PositionTuple | null>(\n null\n );\n const { hoverState, smartConnectLineState, setSmartConnectLineState } =\n useHoverStateContext();\n\n useEffect(() => {\n if (!smartConnectLineState) {\n return;\n }\n function onMouseMove(e: MouseEvent) {\n // Set connect line to based on the mouse position and the transform\n setConnectLineTo([\n (e.clientX - transform.x - smartConnectLineState!.offset[0]) /\n transform.k,\n (e.clientY - transform.y - smartConnectLineState!.offset[1]) /\n transform.k,\n ]);\n }\n function onMouseUp(e: MouseEvent) {\n e.preventDefault();\n reset();\n }\n function reset() {\n document.removeEventListener(\"mousemove\", onMouseMove);\n document.removeEventListener(\"mouseup\", onMouseUp);\n setConnectLineTo(null);\n setSmartConnectLineState(null);\n }\n document.addEventListener(\"mousemove\", onMouseMove);\n document.addEventListener(\"mouseup\", onMouseUp);\n\n return reset;\n }, [setSmartConnectLineState, smartConnectLineState, transform]);\n\n const line = useMemo(() => {\n const points = getConnectLinePoints(\n smartConnectLineState,\n connectLineTo,\n hoverState,\n lineSettings\n );\n return curveLine(\n points,\n lineSettings?.type === \"curve\" ? lineSettings.curveType : \"curveLinear\",\n 0,\n 1\n );\n }, [connectLineTo, hoverState, smartConnectLineState, lineSettings]);\n\n let markerStart: string | undefined;\n let markerEnd: string | undefined;\n const lineMarkers: LineMarkerConf[] = getMarkers(options);\n for (const marker of lineMarkers) {\n if (marker.placement === \"start\") {\n markerStart = options.$markerStartUrl;\n } else {\n markerEnd = options.$markerEndUrl;\n }\n }\n\n return (\n <path\n className={classNames(\"connect-line\", {\n connecting: !!(smartConnectLineState && connectLineTo),\n })}\n d={line}\n fill=\"none\"\n stroke={options.strokeColor}\n strokeWidth={options.strokeWidth}\n markerStart={markerStart}\n markerEnd={markerEnd}\n />\n );\n}\n","import type { NodePosition, PositionTuple } from \"../../../diagram/interfaces\";\nimport type { HoverState } from \"../../../draw-canvas/HoverStateContext\";\nimport type {\n LineSettings,\n SmartConnectLineState,\n} from \"../../../draw-canvas/interfaces\";\nimport { getSmartLinePoints } from \"./getSmartLinePoints\";\n\nexport function getConnectLinePoints(\n smartConnectLineState: SmartConnectLineState | null,\n connectLineTo: PositionTuple | null,\n hoverState: HoverState | null,\n lineSettings?: LineSettings\n): NodePosition[] | null {\n if (\n !smartConnectLineState ||\n !(connectLineTo || hoverState?.activePointIndex !== undefined)\n ) {\n return null;\n }\n\n const sourceView = smartConnectLineState.source.view;\n if (hoverState?.activePointIndex !== undefined) {\n return getSmartLinePoints(sourceView, hoverState.cell.view, {\n ...lineSettings,\n exitPosition: smartConnectLineState.exitPosition,\n entryPosition: hoverState.relativePoints[hoverState.activePointIndex],\n });\n }\n\n const [x1, y1] = connectLineTo!;\n\n return getSmartLinePoints(\n sourceView,\n { x: x1, y: y1, width: 0, height: 0 },\n {\n ...lineSettings,\n exitPosition: smartConnectLineState.exitPosition,\n }\n );\n}\n","import type { ActiveTarget, Cell } from \"../interfaces\";\nimport { isLocked } from \"./isLocked\";\nimport { targetIsActive } from \"./targetIsActive\";\n\nexport type KeyboardAction = KeyboardActionDeleteCells;\n\nexport interface KeyboardActionDeleteCells {\n action: \"delete-cells\";\n cells: Cell[];\n}\n\nexport function handleKeyboard(\n event: KeyboardEvent,\n {\n cells,\n activeTarget,\n lockedIds,\n }: {\n cells: Cell[];\n activeTarget: ActiveTarget | null | undefined;\n lockedIds?: string[];\n }\n): KeyboardAction | undefined {\n const activeCells = cells.filter(\n (cell) => targetIsActive(cell, activeTarget) && !isLocked(cell, lockedIds)\n );\n\n if (activeCells.length === 0) {\n return;\n }\n\n const key =\n event.key ||\n /* istanbul ignore next: compatibility */ event.keyCode ||\n /* istanbul ignore next: compatibility */ event.which;\n\n switch (key) {\n case \"Backspace\":\n case 8:\n case \"Delete\":\n case 46: {\n event.preventDefault();\n event.stopPropagation();\n return {\n action: \"delete-cells\",\n cells: activeCells,\n };\n }\n }\n}\n","import { useMemo, useRef } from \"react\";\nimport {\n __secret_internals,\n checkIfByTransform,\n checkIfOfComputed,\n} from \"@next-core/runtime\";\nimport { findIndex, isUndefined, omitBy } from \"lodash\";\nimport type {\n Cell,\n ComputedEdgeLineConf,\n ComputedLineConnecterConf,\n EdgeCell,\n EdgeLineConf,\n EditableLineCell,\n LineConnecterConf,\n LineMarker,\n} from \"../../draw-canvas/interfaces\";\nimport {\n isEdgeCell,\n isLineDecoratorCell,\n} from \"../../draw-canvas/processors/asserts\";\nimport {\n DEFAULT_LINE_STROKE_COLOR,\n DEFAULT_LINE_STROKE_WIDTH,\n DEFAULT_LINE_INTERACT_STROKE_WIDTH,\n DEFAULT_LINE_INTERACT_SHOW_START_ARROW,\n DEFAULT_LINE_INTERACT_SHOW_END_ARROW,\n DEFAULT_LINE_INTERACT_ANIMATE_DURATION,\n DEFAULT_DECORATOR_LINE_STROKE_COLOR,\n} from \"../../draw-canvas/constants\";\nimport { LineMarkerConf } from \"../../diagram/interfaces\";\n\nexport interface UseLineMarkersOptions {\n cells: Cell[];\n defaultEdgeLines: EdgeLineConf[] | undefined;\n markerPrefix: string;\n lineConnector?: LineConnecterConf | boolean;\n /** Use memoized result when moving and resizing cells */\n useMemoizedResult?: boolean;\n}\n\nexport interface UseLineMarkersResult {\n lineConfMap: WeakMap<EditableLineCell, ComputedEdgeLineConf>;\n lineConnectorConf: ComputedLineConnecterConf | null;\n markers: LineMarker[];\n}\n\nexport function useLineMarkers({\n cells,\n defaultEdgeLines,\n markerPrefix,\n lineConnector,\n useMemoizedResult,\n}: UseLineMarkersOptions): UseLineMarkersResult {\n const memoizedResult = useRef<UseLineMarkersResult | null>(null);\n\n return useMemo<UseLineMarkersResult>(() => {\n if (useMemoizedResult && memoizedResult.current) {\n // If cells are moving or resizing, we can use the previous memoized result.\n return memoizedResult.current;\n }\n\n // Always put the default stroke marker at the first position,\n // since the connecting line will use it.\n const markers: LineMarker[] = [\n {\n strokeColor: DEFAULT_LINE_STROKE_COLOR,\n markerType: \"arrow\",\n },\n ];\n\n let lineConnectorConf: ComputedLineConnecterConf | null = null;\n if (lineConnector) {\n lineConnectorConf = {\n ...getDefaultLineConf(),\n editingStrokeColor: \"var(--palette-blue-5)\",\n ...omitBy(lineConnector === true ? {} : lineConnector, isUndefined),\n } as ComputedLineConnecterConf;\n const lineMarkers: LineMarkerConf[] = getMarkers(lineConnectorConf);\n for (const marker of lineMarkers) {\n const { placement, type: _type } = marker;\n const type = _type ?? \"arrow\";\n const markerIndex = addMarker(\n {\n strokeColor: lineConnectorConf.strokeColor,\n markerType: type,\n },\n markers\n );\n const editingMarkerIndex = addMarker(\n {\n strokeColor: lineConnectorConf.editingStrokeColor,\n markerType: type,\n },\n markers\n );\n if (placement === \"start\") {\n lineConnectorConf.$markerStartUrl = `url(#${markerPrefix}${markerIndex})`;\n lineConnectorConf.$editingStartMarkerUrl = `url(#${markerPrefix}${editingMarkerIndex})`;\n } else {\n lineConnectorConf.$markerEndUrl = `url(#${markerPrefix}${markerIndex})`;\n lineConnectorConf.$editingEndMarkerUrl = `url(#${markerPrefix}${editingMarkerIndex})`;\n }\n }\n }\n\n const map = new WeakMap<EditableLineCell, ComputedEdgeLineConf>();\n for (const cell of cells) {\n const isEdge = isEdgeCell(cell);\n const isLineDecorator = isLineDecoratorCell(cell);\n\n let lineConf: ComputedEdgeLineConf;\n if (isEdge) {\n const computedLineConf =\n (Array.isArray(defaultEdgeLines)\n ? transformLineConf(\n defaultEdgeLines.find((item) =>\n checkIfByTransform(item, { edge: cell })\n ),\n cell\n )\n : (\n __secret_internals.legacyDoTransform(\n { edge: cell },\n defaultEdgeLines\n ) as EdgeLineConf[]\n )?.find((item) => checkIfOfComputed(item))) ?? {};\n lineConf = {\n ...getDefaultLineConf(),\n ...omitBy(computedLineConf, isUndefined),\n ...omitBy(cell.view, isUndefined),\n } as ComputedEdgeLineConf;\n if (lineConf.parallelGap === undefined) {\n lineConf.parallelGap = lineConf.interactStrokeWidth;\n }\n } else {\n lineConf = {\n ...getDefaultLineConf(),\n showEndArrow: false,\n strokeColor: DEFAULT_DECORATOR_LINE_STROKE_COLOR,\n ...omitBy(cell.view, isUndefined),\n } as ComputedEdgeLineConf;\n }\n\n if (isEdge || isLineDecorator) {\n const lineMarkers: LineMarkerConf[] = getMarkers(lineConf);\n\n for (const marker of lineMarkers) {\n const { placement, type: _type } = marker;\n const type = _type ?? \"arrow\";\n const markerIndex = addMarker(\n {\n strokeColor: lineConf.strokeColor,\n markerType: type,\n },\n markers\n );\n if (placement === \"start\") {\n lineConf.$markerStartUrl = `url(#${markerPrefix}${markerIndex})`;\n } else {\n lineConf.$markerEndUrl = `url(#${markerPrefix}${markerIndex})`;\n }\n\n const activeStrokeColor = lineConf.overrides?.active?.strokeColor;\n if (activeStrokeColor && activeStrokeColor !== lineConf.strokeColor) {\n const activeMarkerIndex = addMarker(\n {\n strokeColor: activeStrokeColor,\n markerType: type,\n },\n markers\n );\n if (placement === \"start\") {\n lineConf.$activeMarkerStartUrl = `url(#${markerPrefix}${activeMarkerIndex})`;\n } else {\n lineConf.$activeMarkerEndUrl = `url(#${markerPrefix}${activeMarkerIndex})`;\n }\n }\n\n if (isEdge) {\n const activeRelatedStrokeColor =\n lineConf.overrides?.activeRelated?.strokeColor;\n if (\n activeRelatedStrokeColor &&\n activeRelatedStrokeColor !== lineConf.strokeColor\n ) {\n const activeRelatedMarkerIndex = addMarker(\n {\n strokeColor: activeRelatedStrokeColor,\n markerType: type,\n },\n markers\n );\n if (placement === \"start\") {\n lineConf.$activeRelatedMarkerStartUrl = `url(#${markerPrefix}${activeRelatedMarkerIndex})`;\n } else {\n lineConf.$activeRelatedMarkerEndUrl = `url(#${markerPrefix}${activeRelatedMarkerIndex})`;\n }\n }\n }\n }\n map.set(cell, lineConf);\n }\n }\n return (memoizedResult.current = {\n lineConfMap: map,\n lineConnectorConf,\n markers,\n });\n }, [cells, defaultEdgeLines, lineConnector, markerPrefix, useMemoizedResult]);\n}\n\nfunction transformLineConf(\n lineConf: EdgeLineConf | undefined,\n edge: EdgeCell\n): EdgeLineConf {\n // Do not transform useBrick\n if (lineConf?.label?.useBrick) {\n const {\n label: { useBrick, ...restLabel },\n ...restConf\n } = lineConf;\n const computedRestConf = __secret_internals.legacyDoTransform(\n { edge },\n {\n ...restConf,\n label: restLabel,\n }\n ) as EdgeLineConf;\n return {\n ...computedRestConf,\n label: {\n ...computedRestConf.label,\n useBrick,\n },\n } as EdgeLineConf;\n }\n return __secret_internals.legacyDoTransform(\n { edge },\n lineConf\n ) as EdgeLineConf;\n}\n\nexport function getMarkers(lineConf: ComputedEdgeLineConf): LineMarkerConf[] {\n let lineMarkers: LineMarkerConf[] = [];\n if (lineConf.markers) {\n lineMarkers = lineConf.markers;\n } else {\n if (lineConf.showStartArrow) {\n lineMarkers.push({\n type: \"arrow\",\n placement: \"start\",\n });\n }\n if (lineConf.showEndArrow) {\n lineMarkers.push({\n type: \"arrow\",\n placement: \"end\",\n });\n }\n }\n return lineMarkers;\n}\nfunction addMarker(marker: LineMarker, markers: LineMarker[]): number {\n let markerIndex = findIndex(markers, marker);\n if (markerIndex === -1) {\n markerIndex = markers.push(marker) - 1;\n }\n return markerIndex;\n}\n\nfunction getDefaultLineConf(): EdgeLineConf {\n return {\n type: \"straight\",\n dashed: false,\n strokeColor: DEFAULT_LINE_STROKE_COLOR,\n strokeWidth: DEFAULT_LINE_STROKE_WIDTH,\n interactStrokeWidth: DEFAULT_LINE_INTERACT_STROKE_WIDTH,\n showStartArrow: DEFAULT_LINE_INTERACT_SHOW_START_ARROW,\n showEndArrow: DEFAULT_LINE_INTERACT_SHOW_END_ARROW,\n animate: {\n useAnimate: false,\n duration: DEFAULT_LINE_INTERACT_ANIMATE_DURATION,\n },\n jumps: false,\n };\n}\n","import { pick } from \"lodash\";\nimport type { NodePosition, PositionTuple } from \"../../../diagram/interfaces\";\nimport type { HoverState } from \"../../../draw-canvas/HoverStateContext\";\nimport type {\n LineEditorState,\n LineEditorStateOfControl,\n EditableLine,\n EditableLineCell,\n EditableLineView,\n DecoratorLineView,\n NodeView,\n} from \"../../../draw-canvas/interfaces\";\nimport { getSmartLinePoints, simplifyVertices } from \"./getSmartLinePoints\";\nimport { isEditableEdgeLine } from \"../../../draw-canvas/processors/asserts\";\n\nexport function getEditingLinePoints(\n activeEditableLine: EditableLineCell | null,\n lineEditorState: LineEditorState | null,\n editableLineMap: WeakMap<EditableLineCell, EditableLine>,\n connectLineTo: PositionTuple | null,\n hoverState: HoverState | null\n): NodePosition[] | null {\n if (\n !activeEditableLine ||\n !lineEditorState ||\n !(\n connectLineTo ||\n (lineEditorState.type !== \"control\" &&\n hoverState?.activePointIndex !== undefined)\n )\n ) {\n return null;\n }\n\n const editableLine = editableLineMap.get(activeEditableLine);\n if (!editableLine) {\n return null;\n }\n\n const { type } = lineEditorState;\n let sourceView: NodeView;\n let targetView: NodeView;\n\n const cellType = activeEditableLine.type;\n if (isEditableEdgeLine(editableLine)) {\n sourceView = editableLine.source.view;\n targetView = editableLine.target.view;\n } else {\n const view = editableLine.decorator.view as DecoratorLineView;\n sourceView = { ...view.source, width: 0, height: 0 };\n targetView = { ...view.target, width: 0, height: 0 };\n }\n const view = activeEditableLine.view as EditableLineView;\n const { exitPosition, entryPosition, vertices } = view ?? {};\n const lineSettings = pick(view, [\"type\", \"curveType\"]);\n\n if (type === \"control\") {\n const newVertices = getNewLineVertices(\n activeEditableLine,\n lineEditorState,\n editableLineMap,\n connectLineTo!\n );\n\n return getSmartLinePoints(\n sourceView,\n targetView,\n {\n ...lineSettings,\n exitPosition,\n entryPosition,\n vertices: newVertices,\n },\n 0,\n cellType\n );\n }\n\n if (type === \"corner\") {\n const newVertices = [...vertices!];\n newVertices.splice(lineEditorState.control.index, 1, {\n x: connectLineTo![0],\n y: connectLineTo![1],\n });\n\n return getSmartLinePoints(\n sourceView,\n targetView,\n {\n ...lineSettings,\n exitPosition,\n entryPosition,\n vertices: newVertices,\n },\n 0,\n cellType\n );\n }\n\n if (type === \"break\") {\n const newVertices = [...(vertices ?? [])];\n newVertices.splice(lineEditorState.control.index, 0, {\n x: connectLineTo![0],\n y: connectLineTo![1],\n });\n\n return getSmartLinePoints(\n sourceView,\n targetView,\n {\n ...lineSettings,\n exitPosition,\n entryPosition,\n vertices: newVertices,\n },\n 0,\n cellType\n );\n }\n\n if (cellType === \"edge\" && hoverState?.activePointIndex !== undefined) {\n const position = hoverState.relativePoints[hoverState.activePointIndex];\n // Assert `hoverState.cell` is `target`\n return getSmartLinePoints(\n sourceView,\n targetView,\n {\n ...lineSettings,\n ...(type === \"entry\"\n ? {\n exitPosition,\n entryPosition: position,\n }\n : {\n exitPosition: position,\n entryPosition,\n }),\n vertices,\n },\n 0,\n cellType\n );\n }\n\n const [x1, y1] = connectLineTo!;\n\n if (type === \"entry\") {\n return getSmartLinePoints(\n sourceView,\n { x: x1, y: y1, width: 0, height: 0 },\n { ...lineSettings, exitPosition, vertices },\n 0,\n cellType\n );\n }\n\n return getSmartLinePoints(\n { x: x1, y: y1, width: 0, height: 0 },\n targetView,\n { ...lineSettings, entryPosition, vertices },\n 0,\n cellType\n );\n}\n\nexport function getNewLineVertices(\n activeEditableLine: EditableLineCell,\n lineEditorState: LineEditorStateOfControl,\n editableLineMap: WeakMap<EditableLineCell, EditableLine>,\n connectLineTo: PositionTuple\n) {\n const { control } = lineEditorState;\n const { points: linePoints } = editableLineMap.get(activeEditableLine)!;\n const newVertices: NodePosition[] = [];\n const [x1, y1] = connectLineTo!;\n const exitPoint = linePoints[0];\n const entryPoint = linePoints[linePoints.length - 1];\n\n // If moving the first control, prepend a vertex to connect the control to the source\n if (control.index === 0) {\n newVertices.push(\n control.direction === \"ns\"\n ? { x: exitPoint.x, y: y1 }\n : { x: x1, y: exitPoint.y }\n );\n }\n\n // Adjust the related two controls, and leave other controls unchanged\n for (let i = 1; i < linePoints.length - 1; i++) {\n const vertex = linePoints[i];\n newVertices.push(\n i === control.index || i === control.index + 1\n ? control.direction === \"ns\"\n ? { x: vertex.x, y: y1 }\n : { x: x1, y: vertex.y }\n : vertex\n );\n }\n\n // If moving the last control, append a vertex to connect the control to the target\n if (control.index === linePoints.length - 2) {\n newVertices.push(\n control.direction === \"ns\"\n ? { x: entryPoint.x, y: y1 }\n : { x: x1, y: entryPoint.y }\n );\n }\n\n return simplifyVertices(exitPoint, newVertices, entryPoint);\n}\n","// istanbul ignore file: experimental\nimport React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport classNames from \"classnames\";\nimport type {\n Cell,\n ComputedLineConnecterConf,\n EditableEdgeLine,\n EditableLine,\n EditableLineCell,\n EditableLineView,\n LineEditorState,\n LineEditorStateOfControl,\n} from \"./interfaces\";\nimport type {\n LineMarkerConf,\n NodePosition,\n PositionTuple,\n TransformLiteral,\n} from \"../diagram/interfaces\";\nimport { curveLine } from \"../diagram/lines/curveLine\";\nimport { useHoverStateContext } from \"./HoverStateContext\";\nimport {\n getEditingLinePoints,\n getNewLineVertices,\n} from \"../shared/canvas/processors/getEditingLinePoints\";\nimport { getMarkers } from \"../shared/canvas/useLineMarkers\";\nimport { isEdgeCell, isLineDecoratorCell } from \"./processors/asserts\";\n\nconst LOOSE_CONTROL_TYPES = [\n \"control\",\n \"corner\",\n \"break\",\n] as LineEditorState[\"type\"][];\n\nexport interface EditingLineComponentProps {\n cells: Cell[];\n editableLineMap: WeakMap<EditableLineCell, EditableLine>;\n transform: TransformLiteral;\n options: ComputedLineConnecterConf;\n activeEditableLine: EditableLineCell | null;\n}\n\nexport function EditingLineComponent({\n cells,\n editableLineMap,\n transform,\n options,\n activeEditableLine,\n}: EditingLineComponentProps): JSX.Element {\n const [connectLineTo, setConnectLineTo] = useState<PositionTuple | null>(\n null\n );\n const {\n hoverState,\n lineEditorState,\n setLineEditorState,\n onChangeEdgeView,\n onChangeDecoratorView,\n } = useHoverStateContext();\n const movedRef = useRef(false);\n\n useEffect(() => {\n if (!lineEditorState) {\n setTimeout(() => {\n movedRef.current = false;\n }, 0);\n }\n }, [lineEditorState]);\n\n useEffect(() => {\n if (!activeEditableLine || !lineEditorState) {\n return;\n }\n movedRef.current = false;\n const { type, offset, from } = lineEditorState;\n // Set connect line to based on the mouse position and the transform\n const getConnectTo = (e: MouseEvent): PositionTuple => {\n const position: NodePosition = {\n x: (e.clientX - transform.x - offset[0]) / transform.k,\n y: (e.clientY - transform.y - offset[1]) / transform.k,\n };\n const linePoints = editableLineMap.get(activeEditableLine)!.points;\n const snapDistance = 5;\n const diff: NodePosition = { x: Infinity, y: Infinity };\n let otherPoints: NodePosition[];\n let axises: (\"x\" | \"y\")[];\n\n const getFinalPosition = (): PositionTuple => {\n if (!movedRef.current) {\n const movementX = (e.clientX - from[0]) / transform.k;\n const movementY = (e.clientY - from[1]) / transform.k;\n movedRef.current = movementX ** 2 + movementY ** 2 >= 9;\n }\n\n return [position.x, position.y];\n };\n\n if (LOOSE_CONTROL_TYPES.includes(type) && !e.altKey) {\n // Snap to other points\n const control = (lineEditorState as LineEditorStateOfControl).control;\n axises =\n type === \"control\"\n ? [control.direction === \"ns\" ? \"y\" : \"x\"]\n : [\"x\", \"y\"];\n otherPoints = linePoints.filter(\n (_, i) =>\n i === 0 ||\n i === linePoints.length - 1 ||\n (type === \"control\"\n ? i !== control.index && i !== control.index + 1\n : type !== \"corner\" || i !== control.index + 1)\n );\n } else if (\n isLineDecoratorCell(activeEditableLine) &&\n (type === \"exit\" || type === \"entry\") &&\n !e.altKey\n ) {\n const endpoint =\n type === \"exit\" ? linePoints[0] : linePoints[linePoints.length - 1];\n otherPoints = linePoints.filter((p) => p !== endpoint);\n axises = [\"x\", \"y\"];\n } else {\n return getFinalPosition();\n }\n\n // Snap to control points of other lines\n for (const cell of cells) {\n if (\n !(isEdgeCell(cell) || isLineDecoratorCell(cell)) ||\n cell === activeEditableLine\n ) {\n continue;\n }\n const editableLine = editableLineMap.get(cell);\n if (editableLine) {\n otherPoints.push(...editableLine.points.slice(1, -1));\n }\n }\n\n for (const point of otherPoints) {\n for (const axis of axises) {\n const newDiff = Math.abs(point[axis] - position[axis]);\n if (newDiff <= snapDistance && newDiff < diff[axis]) {\n position[axis] = point[axis];\n diff[axis] = newDiff;\n }\n }\n }\n\n return getFinalPosition();\n };\n const onMouseMove = (e: MouseEvent) => {\n const newConnectTo = getConnectTo(e);\n if (movedRef.current) {\n setConnectLineTo(newConnectTo);\n }\n };\n function onMouseUp(e: MouseEvent) {\n e.preventDefault();\n reset();\n\n if (!movedRef.current) {\n return;\n }\n\n const newConnectTo = getConnectTo(e);\n const isEdge = isEdgeCell(activeEditableLine!);\n\n if (lineEditorState?.type === \"control\") {\n if (isEdge) {\n const editableLine = editableLineMap.get(\n activeEditableLine!\n ) as EditableEdgeLine;\n const { source, target } = editableLine;\n onChangeEdgeView?.(source, target, {\n ...activeEditableLine!.view,\n vertices: getNewLineVertices(\n activeEditableLine!,\n lineEditorState,\n editableLineMap,\n newConnectTo\n ),\n });\n } else {\n onChangeDecoratorView?.(activeEditableLine!, {\n ...activeEditableLine!.view,\n vertices: getNewLineVertices(\n activeEditableLine!,\n lineEditorState,\n editableLineMap,\n newConnectTo\n ),\n });\n }\n return;\n }\n\n if (isEdge) {\n return;\n }\n\n switch (lineEditorState?.type) {\n case \"entry\":\n case \"exit\":\n onChangeDecoratorView?.(activeEditableLine!, {\n ...activeEditableLine!.view,\n [lineEditorState.type === \"entry\" ? \"target\" : \"source\"]: {\n x: newConnectTo[0],\n y: newConnectTo[1],\n },\n });\n break;\n case \"corner\":\n onChangeDecoratorView?.(activeEditableLine!, {\n ...activeEditableLine!.view,\n vertices: activeEditableLine!.view.vertices!.map((point, i) =>\n i === lineEditorState.control.index\n ? { x: newConnectTo[0], y: newConnectTo[1] }\n : point\n ),\n });\n break;\n case \"break\": {\n const newVertices = [...(activeEditableLine!.view.vertices ?? [])];\n newVertices.splice(lineEditorState.control.index, 0, {\n x: newConnectTo[0],\n y: newConnectTo[1],\n });\n onChangeDecoratorView?.(activeEditableLine!, {\n ...activeEditableLine!.view,\n vertices: newVertices,\n });\n break;\n }\n }\n }\n function reset() {\n document.removeEventListener(\"mousemove\", onMouseMove);\n document.removeEventListener(\"mouseup\", onMouseUp);\n setConnectLineTo(null);\n setLineEditorState(null);\n }\n document.addEventListener(\"mousemove\", onMouseMove);\n document.addEventListener(\"mouseup\", onMouseUp);\n\n return reset;\n }, [\n activeEditableLine,\n editableLineMap,\n lineEditorState,\n transform,\n setLineEditorState,\n onChangeEdgeView,\n cells,\n onChangeDecoratorView,\n ]);\n\n useEffect(() => {\n if (!activeEditableLine) {\n return;\n }\n const handleBodyClick = (e: MouseEvent) => {\n if (movedRef.current) {\n e.stopPropagation();\n e.preventDefault();\n }\n };\n document.body.addEventListener(\"click\", handleBodyClick);\n return () => {\n document.body.removeEventListener(\"click\", handleBodyClick);\n };\n }, [activeEditableLine]);\n\n const line = useMemo(() => {\n const points = getEditingLinePoints(\n activeEditableLine,\n lineEditorState,\n editableLineMap,\n connectLineTo,\n hoverState\n );\n const view = activeEditableLine?.view as EditableLineView | undefined;\n return curveLine(\n points,\n view?.type === \"curve\" ? view.curveType : \"curveLinear\",\n 0,\n 1\n );\n }, [\n connectLineTo,\n hoverState,\n activeEditableLine,\n lineEditorState,\n editableLineMap,\n ]);\n let markerStart: string | undefined;\n let markerEnd: string | undefined;\n const lineMarkers: LineMarkerConf[] = getMarkers(options);\n for (const marker of lineMarkers) {\n if (marker.placement === \"start\") {\n markerStart = options.$editingStartMarkerUrl;\n } else {\n markerEnd = options.$editingEndMarkerUrl;\n }\n }\n\n return (\n <path\n className={classNames(\"editing-line\", {\n editing: !!(lineEditorState && connectLineTo),\n })}\n d={line}\n fill=\"none\"\n stroke={options.editingStrokeColor}\n markerStart={markerStart}\n markerEnd={markerEnd}\n />\n );\n}\n","import { get } from \"lodash\";\nimport type { SizeTuple } from \"../../diagram/interfaces\";\nimport type { Cell, InitialCell, LayoutOptions, NodeCell } from \"../interfaces\";\nimport { isInitialNodeCell } from \"./asserts\";\nimport { initialContainerLayout } from \"./initialContainerLayout\";\n\ninterface initializeConfig {\n defaultNodeSize: SizeTuple;\n layoutOptions?: LayoutOptions;\n isInitialize?: boolean;\n}\n\nexport function initializeCells(\n initialCells: InitialCell[] | undefined,\n { defaultNodeSize, layoutOptions, isInitialize }: initializeConfig\n): Cell[] {\n const originalCells = initialCells ?? [];\n if (isInitialize) {\n if (get(layoutOptions, \"initialLayout\") === \"layered-architecture\") {\n initialContainerLayout(originalCells, { nodeLayout: \"dagre\" });\n } else if (get(layoutOptions, \"initialLayout\") === \"layered-staggered\") {\n initialContainerLayout(originalCells, { nodeLayout: \"staggered\" });\n }\n }\n const finalCells: Cell[] = originalCells.map<Cell>((cell) => {\n if (\n !isInitialNodeCell(cell) ||\n (cell.view?.width !== undefined && cell.view?.height !== undefined)\n ) {\n return cell as NodeCell;\n }\n return {\n ...cell,\n view: {\n width: defaultNodeSize[0],\n height: defaultNodeSize[1],\n ...cell.view,\n },\n } as NodeCell;\n });\n return finalCells;\n}\n","import type { AlignOrigin, NormalizedAlignOrigin } from \"../interfaces\";\n\nconst KeywordMap = new Map([\n [\"center\", 0.5],\n [\"left\", 0],\n [\"right\", 1],\n [\"top\", 0],\n [\"bottom\", 1],\n]);\n\nexport function normalizeAlignOrigin(\n alignOrigin: AlignOrigin | undefined\n): NormalizedAlignOrigin {\n const origin = alignOrigin ?? [0.5, 0.5];\n return [\n normalizeAlignAxis(origin[0], \"x\"),\n normalizeAlignAxis(origin[1], \"y\"),\n ];\n}\n\nfunction normalizeAlignAxis(value: string | number, axis: \"x\" | \"y\"): number {\n if (typeof value === \"string\") {\n const newX = KeywordMap.get(value);\n if (newX !== undefined) {\n return newX;\n }\n const matches = value.match(/^(-?\\d+(?:\\.\\d+)?)%$/);\n if (matches) {\n return Number(matches[1]) / 100;\n }\n // eslint-disable-next-line no-console\n console.error(\"Unexpected align origin %s:\", axis, value);\n } else if (typeof value === \"number\") {\n return value;\n } else {\n // eslint-disable-next-line no-console\n console.error(\n \"Unexpected align origin %s, expected %s, received %s:\",\n axis,\n \"string | number\",\n typeof value,\n value\n );\n }\n\n return 0.5;\n}\n","import { useCallback, useEffect, useRef, useState } from \"react\";\nimport type { ZoomBehavior } from \"d3-zoom\";\nimport type {\n Cell,\n LayoutOptions,\n LayoutOptionsForce,\n LayoutOptionsDagre,\n LayoutType,\n NodeId,\n NodeView,\n AutoSize,\n} from \"../../draw-canvas/interfaces\";\nimport type { FullRectTuple, RangeTuple } from \"../../diagram/interfaces\";\nimport { useAutoCenter } from \"./useAutoCenter\";\nimport {\n isNodeCell,\n isNodeOrAreaDecoratorCell,\n isNodeOrEdgeCell,\n} from \"../../draw-canvas/processors/asserts\";\nimport {\n SYMBOL_FOR_LAYOUT_INITIALIZED,\n SYMBOL_FOR_SIZE_INITIALIZED,\n} from \"../../draw-canvas/constants\";\nimport type { DrawCanvasAction } from \"../../draw-canvas/reducers/interfaces\";\nimport { forceLayout } from \"./forceLayout\";\nimport { dagreLayout } from \"./dagreLayout\";\nimport { normalizeAlignOrigin } from \"../../draw-canvas/processors/normalizeAlignOrigin\";\n\nexport interface UseLayoutOptions {\n layout: LayoutType;\n layoutOptions?: LayoutOptions;\n autoSize?: AutoSize;\n rootRef: React.RefObject<SVGSVGElement>;\n cells: Cell[];\n zoomable?: boolean;\n zoomer: ZoomBehavior<SVGSVGElement, unknown>;\n scaleRange: RangeTuple;\n layoutKey: number;\n allowEdgeToArea?: boolean;\n autoCenterWhenCellsChange?: boolean;\n dispatch: (value: DrawCanvasAction) => void;\n}\n\nexport function useLayout({\n layout,\n layoutOptions,\n autoSize,\n rootRef,\n cells,\n zoomable,\n zoomer,\n scaleRange,\n layoutKey,\n allowEdgeToArea,\n autoCenterWhenCellsChange,\n dispatch,\n}: UseLayoutOptions) {\n const [layoutInitialized, setLayoutInitialized] = useState(\n layout !== \"force\" && layout !== \"dagre\"\n );\n\n const layoutKeyRef = useRef(layoutKey);\n\n const getNextLayoutKey = useCallback(() => {\n return ++layoutKeyRef.current;\n }, []);\n\n const [centered, setCentered] = useAutoCenter({\n rootRef,\n layoutInitialized,\n cells,\n zoomable,\n zoomer,\n scaleRange,\n autoCenterWhenCellsChange,\n autoSize,\n padding: layoutOptions?.padding,\n });\n\n const previousLayoutRef = useRef<Cell[] | null>(null);\n\n useEffect(() => {\n // Wait for all nodes to be size-initialized before layout.\n if (\n cells.some(\n (cell) => isNodeCell(cell) && !cell[SYMBOL_FOR_SIZE_INITIALIZED]\n ) ||\n // Skip layout if no cells.\n cells.length === 0\n ) {\n return;\n }\n\n if (layout !== \"force\" && layout !== \"dagre\") {\n setLayoutInitialized(true);\n return;\n }\n\n // DO NOT re-layout if layout key mismatched.\n // DO NOT re-layout if nodes and edges not changed.\n if (\n layoutKeyRef.current !== layoutKey ||\n isSameArray(previousLayoutRef.current, cells.filter(isNodeOrEdgeCell))\n ) {\n // Layout key mismatch happens when this effect is performed after\n // update-node-size dispatched but not yet applied.\n // If didn't ignore mismatched layout, it will cause the update-cells\n // action overwrites those update-node-size actions.\n return;\n }\n\n let getNodeView: (id: NodeId) => NodeView;\n let nodePaddings: FullRectTuple;\n\n if (layout === \"force\") {\n ({ getNodeView, nodePaddings } = forceLayout({\n cells,\n layoutOptions: layoutOptions as LayoutOptionsForce,\n allowEdgeToArea,\n }));\n } else {\n ({ getNodeView, nodePaddings } = dagreLayout({\n cells,\n layoutOptions: layoutOptions as LayoutOptionsDagre,\n allowEdgeToArea,\n }));\n }\n\n const alignOrigin = normalizeAlignOrigin(\n (layoutOptions as LayoutOptionsForce | LayoutOptionsDagre)?.alignOrigin\n );\n\n const newCells: Cell[] = cells.map((cell) => {\n if (\n (allowEdgeToArea && isNodeOrAreaDecoratorCell(cell)) ||\n isNodeCell(cell)\n ) {\n const nodeView = getNodeView(cell.id);\n return {\n ...cell,\n view: {\n ...cell.view,\n x: nodeView.x! - nodeView.width * alignOrigin[0] + nodePaddings[3],\n y: nodeView.y! - nodeView.height * alignOrigin[1] + nodePaddings[0],\n },\n [SYMBOL_FOR_LAYOUT_INITIALIZED]: true,\n };\n }\n return cell;\n });\n previousLayoutRef.current = newCells.filter(isNodeOrEdgeCell);\n\n dispatch({ type: \"update-cells\", payload: newCells });\n // setCentered(false);\n setLayoutInitialized(true);\n }, [\n cells,\n dispatch,\n layout,\n layoutKey,\n layoutOptions,\n allowEdgeToArea /* , setCentered */,\n ]);\n\n return { centered, setCentered, getNextLayoutKey };\n}\n\nfunction isSameArray<T = unknown>(a: T[] | null, b: T[]): boolean {\n return a?.length === b.length && a.every((v, i) => v === b[i]);\n}\n","import React, { useEffect, useState } from \"react\";\nimport { select } from \"d3-selection\";\nimport { ZoomTransform, type ZoomBehavior } from \"d3-zoom\";\nimport type { PartialRectTuple, RangeTuple } from \"../../diagram/interfaces\";\nimport {\n DEFAULT_CANVAS_PADDING,\n SYMBOL_FOR_SIZE_INITIALIZED,\n} from \"../../draw-canvas/constants\";\nimport type { AutoSize, Cell } from \"../../draw-canvas/interfaces\";\nimport {\n isDecoratorCell,\n isNodeCell,\n} from \"../../draw-canvas/processors/asserts\";\nimport { getCellsRect } from \"./processors/getCellsRect\";\nimport { extractPartialRectTuple } from \"../../diagram/processors/extractPartialRectTuple\";\nimport { getTransformToCenter } from \"./processors/getTransformToCenter\";\n\nexport interface UseAutoCenterOptions {\n rootRef: React.RefObject<SVGSVGElement>;\n cells: Cell[];\n layoutInitialized: boolean;\n zoomable?: boolean;\n zoomer: ZoomBehavior<SVGSVGElement, unknown>;\n scaleRange: RangeTuple;\n autoCenterWhenCellsChange?: boolean;\n autoSize?: AutoSize;\n padding?: PartialRectTuple;\n}\n\nexport type UseAutoCenterResult = [\n centered: boolean,\n setCentered: React.Dispatch<React.SetStateAction<boolean>>,\n];\n\nexport function useAutoCenter({\n rootRef,\n cells,\n layoutInitialized,\n zoomable,\n zoomer,\n scaleRange,\n autoCenterWhenCellsChange,\n autoSize,\n padding,\n}: UseAutoCenterOptions): UseAutoCenterResult {\n const [centered, setCentered] = useState(false);\n\n useEffect(() => {\n // Reset auto centering when nodes and decorators are all removed,\n // or when cells change and autoCenterWhenCellsChange is enabled.\n if (\n !cells.some((cell) => isNodeCell(cell) || isDecoratorCell(cell)) ||\n autoCenterWhenCellsChange\n ) {\n setCentered(false);\n }\n }, [cells, autoCenterWhenCellsChange]);\n\n useEffect(() => {\n const root = rootRef.current;\n if (\n !root ||\n !layoutInitialized ||\n centered ||\n !cells.some((cell) => isNodeCell(cell) || isDecoratorCell(cell)) ||\n cells.some(\n (cell) => isNodeCell(cell) && !cell[SYMBOL_FOR_SIZE_INITIALIZED]\n )\n ) {\n return;\n }\n\n const rect = getCellsRect(cells);\n let width = root.clientWidth;\n let height = root.clientHeight;\n const fitWidth = !!autoSize?.width;\n const fitHeight = !!autoSize?.height;\n const fullPadding = extractPartialRectTuple(\n padding ?? DEFAULT_CANVAS_PADDING\n );\n\n // Todo: handle ratio\n if (fitWidth) {\n width = Math.min(\n Math.max(\n rect.width + fullPadding![1] + fullPadding![3],\n autoSize.minWidth ?? 0\n ),\n autoSize.maxWidth ?? Infinity\n );\n root.style.minWidth = `${width}px`;\n }\n if (fitHeight) {\n height = Math.min(\n Math.max(\n rect.height + fullPadding![0] + fullPadding![2],\n autoSize.minHeight ?? 0\n ),\n autoSize.maxHeight ?? Infinity\n );\n root.style.minHeight = `${height}px`;\n }\n\n const { k, x, y } = getTransformToCenter(rect, {\n canvasWidth: width,\n canvasHeight: height,\n canvasPadding: fullPadding,\n scaleRange: zoomable ? scaleRange : undefined,\n });\n // istanbul ignore next\n if (process.env.NODE_ENV !== \"test\") {\n // jsdom doesn't support svg baseVal yet.\n // https://github.com/jsdom/jsdom/issues/2531\n zoomer.transform(select(root), new ZoomTransform(k, x, y));\n }\n setCentered(true);\n }, [\n cells,\n centered,\n layoutInitialized,\n rootRef,\n scaleRange,\n zoomable,\n zoomer,\n autoSize,\n padding,\n ]);\n\n return [centered, setCentered];\n}\n","import type { ActiveTarget, Cell } from \"../interfaces\";\nimport { isNodeCell } from \"./asserts\";\nimport { targetIsActive } from \"./targetIsActive\";\n\nexport function toggleLock(\n target: ActiveTarget,\n type: \"toggle\" | \"lock\" | \"unlock\",\n cells: Cell[],\n lockedContainerIds: string[]\n): { newCells: Cell[] | null; updates: Cell[] } {\n const previousLocked: Cell[] = [];\n const previousUnlocked: Cell[] = [];\n for (const cell of cells) {\n if (targetIsActive(cell, target)) {\n // 如果容器已锁定,禁止其子节点的锁定状态改变\n if (\n isNodeCell(cell) &&\n cell.containerId &&\n lockedContainerIds.includes(cell.containerId)\n ) {\n continue;\n }\n (cell.view?.locked ? previousLocked : previousUnlocked).push(cell);\n }\n }\n\n let newCells: Cell[] | null = null;\n const updates: Cell[] = [];\n\n if (type !== \"unlock\" && previousUnlocked.length > 0) {\n // Lock all unlocked targets\n newCells = cells.map((cell) => {\n if (previousUnlocked.includes(cell)) {\n const update = {\n ...cell,\n view: { ...cell.view, locked: true },\n } as Cell;\n updates.push(update);\n return update;\n }\n return cell;\n });\n } else if (type !== \"lock\" && previousLocked.length > 0) {\n // Unlock all locked targets\n newCells = cells.map((cell) => {\n if (previousLocked.includes(cell)) {\n const update = {\n ...cell,\n view: { ...cell.view, locked: false },\n } as Cell;\n updates.push(update);\n return update;\n }\n return cell;\n });\n }\n\n return { newCells, updates };\n}\n","import { useMemo } from \"react\";\nimport type { Cell, LayoutType } from \"../../draw-canvas/interfaces\";\nimport { isNodeCell } from \"../../draw-canvas/processors/asserts\";\nimport {\n SYMBOL_FOR_LAYOUT_INITIALIZED,\n SYMBOL_FOR_SIZE_INITIALIZED,\n} from \"../../draw-canvas/constants\";\n\nexport interface UseReadyOptions {\n cells: Cell[];\n layout: LayoutType;\n centered: boolean;\n}\n\nexport function useReady({ cells, layout, centered }: UseReadyOptions) {\n const ready = useMemo(\n () =>\n centered &&\n cells.every(\n (cell) =>\n !isNodeCell(cell) ||\n (cell[SYMBOL_FOR_SIZE_INITIALIZED] &&\n ((layout !== \"force\" && layout !== \"dagre\") ||\n cell[SYMBOL_FOR_LAYOUT_INITIALIZED]))\n ),\n [cells, centered, layout]\n );\n return ready;\n}\n","import type { Cell, DecoratorCell } from \"../interfaces\";\nimport {\n isContainerDecoratorCell,\n isGroupDecoratorCell,\n isNodeCell,\n} from \"./asserts\";\n\nexport function getLockedContainerIds(cells: Cell[]): string[] {\n const lockeds = cells.filter(\n (cell) =>\n (cell.view?.locked && isContainerDecoratorCell(cell)) ||\n (cell.view?.locked && isGroupDecoratorCell(cell))\n ) as DecoratorCell[];\n return lockeds.map((cell) => cell.id);\n}\n\nexport function isLocked(cell: Cell, lockeds: string[] | undefined): boolean {\n return (\n cell.view?.locked ||\n !!(\n (isNodeCell(cell) || isGroupDecoratorCell(cell)) &&\n cell.containerId &&\n lockeds?.includes(cell.containerId)\n ) ||\n !!(isNodeCell(cell) && cell.groupId && lockeds?.includes(cell.groupId))\n );\n}\n","// Imports\nimport ___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___ from \"../../../../../node_modules/css-loader/dist/runtime/noSourceMaps.js\";\nimport ___CSS_LOADER_API_IMPORT___ from \"../../../../../node_modules/css-loader/dist/runtime/api.js\";\nvar ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___);\n// Module\n___CSS_LOADER_EXPORT___.push([module.id, `*{box-sizing:border-box}:host{display:block;position:relative;overflow:hidden;--animation-dasharray:48;--stroke-dashedoffset:96;--stroke-dottedoffset:24;--dasharray:4;--dotted:1;--area-bg-color:rgba(119,141,195,0.1)}:host,\n.root{width:100%;height:100%}:host([hidden]){display:none}.root{opacity:0}.root.ready{opacity:1}.root:focus{outline:none}@keyframes solidAnimation{to{stroke-dashoffset:0}}@keyframes dashedAnimation{0%{stroke-dashoffset:var(--stroke-dashedoffset)}to{stroke-dashoffset:0}}@keyframes dottedAnimation{0%{stroke-dashoffset:var(--stroke-dottedoffset)}to{stroke-dashoffset:0}}.solid-animation{stroke-dasharray:var(--solid-length);stroke-dashoffset:var(--solid-length);animation:solidAnimation var(--time) linear infinite}.dashed-animation{animation:dashedAnimation var(--time) linear infinite}.dotted-animation{animation:dottedAnimation var(--time) linear infinite}.decorator-area .area,\n.container-wrapper .container{background-color:var(--area-bg-color);border:1px solid transparent}.decorator-text .text-container{border:1px solid transparent}.decorator-rect-container .rect-container{border:1px solid rgba(73,126,255,0.7)}.decorator-group .lock-icon,.decorator-group .plus-wrapper,.decorator-group .plus-icon{opacity:0}.decorator-group .group{position:relative}.decorator-group .group .plus-icon{position:absolute;left:50%;bottom:0;transform:translate(-50%,50%);padding:2px;background:var(--color-fill-bg-base-1);border-radius:2px;cursor:pointer}.decorator-group .group .plus-icon:hover{color:rgba(33,212,243,1)}.decorator-group.active-group:not(.does-not-exist) .group,.cell.active .decorator-group .group{border:1px dashed rgba(33,212,243,1)}.decorator-group.active-group:not(.does-not-exist) .resize-handle,.cell.active .decorator-group .resize-handle,.decorator-group.active-group:not(.does-not-exist) .lock-icon,.cell.active .decorator-group .lock-icon,.decorator-group.active-group:not(.does-not-exist) .plus-wrapper,.cell.active .decorator-group .plus-wrapper,.decorator-group.active-group:not(.does-not-exist) .plus-icon,.cell.active .decorator-group .plus-icon{opacity:1}.cell:has(.decorator-group.active-group),\n.cell:has(.container.active-container){opacity:1}.cell.active .decorator-area .area,\n.cell.active .decorator-rect-container .rect-container,\n.cell.active .decorator-text .text-container,\n.cell.active .container-wrapper .container,\n.cell.active .group-wrapper .group,\n.container-dragover .decorator-container .container,\n.active-container.container{border-style:dashed;border-color:rgba(73,126,255,0.7)}.node,\n.container-wrapper{overflow:visible}.decorator-text,\n.decorator-rect,\n.decorator-area{overflow:visible;pointer-events:none}.lock-icon,\n.decorator-text > *,\n.decorator-rect > *,\n.decorator-area > *{pointer-events:auto}.cell.active .line-active-bg{stroke:var(--palette-blue-5);stroke-dasharray:var(--dasharray);stroke-width:1}.cell:not(.read-only){-webkit-user-select:none;user-select:none}.resize-handle{cursor:nwse-resize;opacity:0}.resize-handle rect{fill:transparent;stroke:none}.resize-handle path{fill:none;stroke:var(--palette-gray-5);stroke-width:1.5}.decorator-area-container:hover .resize-handle,\n.decorator-rect-container:hover .resize-handle,\n.decorator-container:hover .resize-handle{opacity:1}.connect-line{pointer-events:none}.connect-line:not(.connecting){display:none}.editing-line{pointer-events:none;stroke-dasharray:var(--dasharray);stroke-width:1}.editing-line:not(.editing){display:none}.line.dashed{stroke-dasharray:var(--dasharray)}.line.dotted{stroke-dasharray:var(--dotted)}.decorator-text .text-container{width:max-content;padding:0.5em;white-space:pre}.cell:not(.read-only) .decorator-text .text-container:hover{color:#497eff}.decorator-text .text:focus{outline:none}.cell.faded{opacity:0.3}.cell.container-dragover{opacity:1}.cell .node{pointer-events:none}.cell .node > *{position:fixed;pointer-events:auto}.degraded{pointer-events:bounding-box}.degraded circle{fill:rgb(119,141,195)}.degraded text{text-anchor:middle;fill:var(--antd-text-color)}.cell.active .degraded circle,\n.cell.active .degraded text,\n.degraded:hover circle,\n.degraded:hover text{fill:var(--color-brand)}.decorator-container{--defaultSize:24px}.decorator-container .text-container{display:flex;align-items:center;justify-content:center;padding:0.5em;text-align:center;font-size:16px;color:#262626;background-color:rgba(119,141,195,0.25);overflow:hidden}.decorator-container .horizontal{height:max-content;width:100%}.decorator-container .horizontal .text{min-height:var(--defaultSize)}.decorator-container .vertical{width:max-content;height:100%;writing-mode:vertical-lr;-webkit-text-orientation:upright;text-orientation:upright;letter-spacing:4px}.decorator-container .vertical .text{min-width:var(--defaultSize)}.line-label-container{overflow:visible;opacity:0}.line-label-container.ready{opacity:1}.line-label{position:absolute;display:block;transform:translate(-50%,-50%);white-space:pre-line;width:max-content;text-align:center}.line-label.text{font-size:11px;color:var(--color-secondary-text);font-weight:400;line-height:1.63636364}.motion:not(.visible){opacity:0}`, \"\"]);\n// Exports\nexport default ___CSS_LOADER_EXPORT___.toString();\n","// istanbul ignore file: experimental\nimport React, { useCallback, useEffect, useRef } from \"react\";\nimport { useHoverStateContext } from \"./HoverStateContext\";\nimport type {\n ActiveTarget,\n Cell,\n EditableEdgeLine,\n EditableLine,\n EditableLineCell,\n NodeCell,\n} from \"./interfaces\";\nimport { targetIsActive } from \"./processors/targetIsActive\";\nimport type { NodePosition } from \"../diagram/interfaces\";\nimport { DEFAULT_NODE_PADDING_FOR_SMART_LINES } from \"./constants\";\nimport { isEditableEdgeLine } from \"./processors/asserts\";\n\nconst HELPER_IMAGE =\n \"data:image/svg+xml;base64,PCFET0NUWVBFIHN2ZyBQVUJMSUMgIi0vL1czQy8vRFREIFNWRyAxLjEvL0VOIiAiaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkIj48c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHdpZHRoPSI1cHgiIGhlaWdodD0iNXB4IiB2ZXJzaW9uPSIxLjEiPjxwYXRoIGQ9Im0gMCAwIEwgNSA1IE0gMCA1IEwgNSAwIiBzdHJva2Utd2lkdGg9IjIiIHN0eWxlPSJzdHJva2Utb3BhY2l0eTowLjQiIHN0cm9rZT0iI2ZmZmZmZiIvPjxwYXRoIGQ9Im0gMCAwIEwgNSA1IE0gMCA1IEwgNSAwIiBzdHJva2U9IiMyOWI2ZjIiLz48L3N2Zz4=\";\nconst HELPER_RADIUS = 5;\nconst HELPER_BG_RADIUS = 8;\nconst HALF_HELPER_RADIUS = HELPER_RADIUS / 2;\n\nexport interface LineConnectorComponentProps {\n activeTarget: ActiveTarget | null;\n editableLineMap: WeakMap<EditableLineCell, EditableLine>;\n scale: number;\n activeEditableLine: EditableLineCell | null;\n disabled?: boolean;\n}\n\nexport function LineConnectorComponent({\n activeTarget,\n editableLineMap,\n scale,\n activeEditableLine,\n disabled,\n}: LineConnectorComponentProps): JSX.Element | null {\n const {\n unsetHoverStateTimeoutRef,\n hoverState,\n setHoverState,\n smartConnectLineState,\n lineEditorState,\n } = useHoverStateContext();\n\n const unsetTimeout = useCallback(() => {\n if (unsetHoverStateTimeoutRef.current !== null) {\n clearTimeout(unsetHoverStateTimeoutRef.current);\n unsetHoverStateTimeoutRef.current = null;\n }\n }, [unsetHoverStateTimeoutRef]);\n\n const unsetActivePointIndex = useCallback(() => {\n unsetTimeout();\n setHoverState((prev) =>\n prev?.activePointIndex === undefined\n ? prev\n : { ...hoverState!, activePointIndex: undefined }\n );\n }, [hoverState, setHoverState, unsetTimeout]);\n\n const unsetHoverState = useCallback(() => {\n unsetHoverStateTimeoutRef.current = setTimeout(() => {\n setHoverState(null);\n }) as unknown as number;\n }, [setHoverState, unsetHoverStateTimeoutRef]);\n\n let source: Cell | undefined;\n let target: Cell | undefined;\n let editableLine: EditableLine | undefined;\n\n const available =\n !disabled &&\n hoverState &&\n (!!smartConnectLineState ||\n (activeEditableLine && lineEditorState\n ? (editableLine = editableLineMap.get(activeEditableLine)) &&\n (isEditableEdgeLine(editableLine)\n ? (({ source, target } = editableLine),\n lineEditorState.type === \"entry\")\n ? hoverState.cell === target\n : lineEditorState.type === \"exit\" && hoverState.cell === source\n : // TODO(steve): decorator line\n false)\n : !targetIsActive(hoverState.cell, activeTarget) &&\n !hasActiveEdge(activeTarget)));\n\n const padding = DEFAULT_NODE_PADDING_FOR_SMART_LINES;\n const halfPadding = padding / 2;\n\n return (\n <g onMouseEnter={unsetActivePointIndex} onMouseLeave={unsetHoverState}>\n {available && (\n <>\n <rect\n x={hoverState.cell.view.x - halfPadding}\n y={hoverState.cell.view.y - halfPadding}\n width={hoverState.cell.view.width + padding}\n height={hoverState.cell.view.height + padding}\n fill=\"none\"\n stroke=\"transparent\"\n strokeWidth={(HELPER_BG_RADIUS * 2) / scale}\n pointerEvents=\"stroke\"\n />\n {hoverState.activePointIndex !== undefined && (\n <circle\n cx={hoverState.points[hoverState.activePointIndex].x}\n cy={hoverState.points[hoverState.activePointIndex].y}\n r={HELPER_BG_RADIUS / scale}\n fill=\"lightgreen\"\n fillOpacity={0.5}\n pointerEvents=\"none\"\n />\n )}\n {hoverState.points.map((point, index) => (\n <ConnectPointComponent\n key={index}\n editableLineMap={editableLineMap}\n index={index}\n point={point}\n scale={scale}\n activeEditableLine={activeEditableLine}\n unsetActivePointIndex={unsetActivePointIndex}\n unsetTimeout={unsetTimeout}\n />\n ))}\n </>\n )}\n </g>\n );\n}\n\ninterface ConnectPointComponentProps {\n editableLineMap: WeakMap<EditableLineCell, EditableLine>;\n index: number;\n point: NodePosition;\n scale: number;\n activeEditableLine: EditableLineCell | null;\n unsetTimeout: () => void;\n unsetActivePointIndex: () => void;\n}\n\nfunction ConnectPointComponent({\n editableLineMap,\n index,\n point,\n scale,\n activeEditableLine,\n unsetTimeout,\n unsetActivePointIndex,\n}: ConnectPointComponentProps): JSX.Element {\n const {\n rootRef,\n smartConnectLineState,\n hoverState,\n setHoverState,\n setSmartConnectLineState,\n onConnect,\n lineEditorState,\n setLineEditorState,\n onChangeEdgeView,\n } = useHoverStateContext();\n const ref = useRef<SVGGElement>(null);\n\n useEffect(() => {\n const g = ref.current;\n const handleMouseEnter = (e: MouseEvent) => {\n // There is a chance that mouseenter will not be triggered when the element is shown aync.\n // So we also listen to the mousemove event, but only once.\n if (e.type === \"mousemove\") {\n g?.removeEventListener(e.type, handleMouseEnter);\n }\n unsetTimeout();\n setHoverState((prev) =>\n prev && prev.activePointIndex !== index\n ? { ...hoverState!, activePointIndex: index }\n : prev\n );\n };\n g?.addEventListener(\"mouseenter\", handleMouseEnter);\n g?.addEventListener(\"mousemove\", handleMouseEnter);\n return () => {\n g?.removeEventListener(\"mouseenter\", handleMouseEnter);\n g?.removeEventListener(\"mousemove\", handleMouseEnter);\n };\n }, [hoverState, index, setHoverState, unsetTimeout]);\n\n useEffect(() => {\n if (lineEditorState) {\n return;\n }\n const handleMouseDown = (e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n const rect = rootRef.current!.getBoundingClientRect();\n const originalPoint = hoverState!.points[index];\n setSmartConnectLineState({\n source: hoverState!.cell as NodeCell,\n from: [originalPoint.x, originalPoint.y],\n offset: [rect.left, rect.top],\n exitPosition: hoverState!.relativePoints[index],\n });\n };\n const g = ref.current;\n g?.addEventListener(\"mousedown\", handleMouseDown);\n return () => {\n g?.removeEventListener(\"mousedown\", handleMouseDown);\n };\n }, [hoverState, index, lineEditorState, rootRef, setSmartConnectLineState]);\n\n useEffect(() => {\n const handleMouseUp = (e: MouseEvent) => {\n if (\n activeEditableLine &&\n lineEditorState &&\n activeEditableLine.type === \"decorator\"\n ) {\n return;\n }\n e.preventDefault();\n e.stopPropagation();\n if (smartConnectLineState) {\n if (smartConnectLineState.source !== hoverState?.cell) {\n onConnect?.(\n smartConnectLineState.source,\n hoverState!.cell,\n smartConnectLineState.exitPosition,\n hoverState!.relativePoints[hoverState!.activePointIndex!]\n );\n }\n setSmartConnectLineState(null);\n } else if (activeEditableLine && lineEditorState) {\n const position =\n hoverState!.relativePoints[hoverState!.activePointIndex!];\n const { type } = lineEditorState;\n const { source, target } = editableLineMap.get(\n activeEditableLine!\n ) as EditableEdgeLine;\n const { view } = activeEditableLine!;\n if (type === \"entry\") {\n onChangeEdgeView?.(source, target, {\n ...view,\n entryPosition: position,\n });\n } else {\n onChangeEdgeView?.(source, target, {\n ...view,\n exitPosition: position,\n });\n }\n setLineEditorState(null);\n }\n };\n const g = ref.current;\n g?.addEventListener(\"mouseup\", handleMouseUp);\n return () => {\n g?.removeEventListener(\"mouseup\", handleMouseUp);\n };\n }, [\n smartConnectLineState,\n hoverState,\n onConnect,\n setSmartConnectLineState,\n activeEditableLine,\n lineEditorState,\n editableLineMap,\n onChangeEdgeView,\n setLineEditorState,\n ]);\n\n return (\n <g ref={ref} onMouseLeave={unsetActivePointIndex}>\n <circle\n cx={point.x}\n cy={point.y}\n r={HELPER_BG_RADIUS}\n fill=\"transparent\"\n />\n <image\n x={point.x - HALF_HELPER_RADIUS / scale}\n y={point.y - HALF_HELPER_RADIUS / scale}\n width={HELPER_RADIUS / scale}\n height={HELPER_RADIUS / scale}\n xlinkHref={HELPER_IMAGE}\n preserveAspectRatio=\"none\"\n />\n </g>\n );\n}\n\nfunction hasActiveEdge(activeTarget: ActiveTarget | null) {\n return (\n activeTarget &&\n (activeTarget.type === \"edge\" ||\n (activeTarget.type === \"multi\" &&\n activeTarget.targets.some((target) => target.type === \"edge\")))\n );\n}\n","export const SYMBOL_FOR_SIZE_INITIALIZED = Symbol.for(\"size-initialized\");\nexport const SYMBOL_FOR_LAYOUT_INITIALIZED = Symbol.for(\"layout-initialized\");\nexport const DEFAULT_NODE_SIZE = 20;\nexport const DEFAULT_NODE_GAP_H = 36;\nexport const DEFAULT_NODE_GAP_V = 50;\nexport const DEFAULT_AREA_WIDTH = 180;\nexport const DEFAULT_AREA_HEIGHT = 120;\nexport const DEFAULT_SCALE_RANGE_MIN = 0.5;\nexport const DEFAULT_SCALE_RANGE_MAX = 2;\nexport const DEFAULT_LINE_STROKE_COLOR = \"gray\";\nexport const DEFAULT_LINE_STROKE_WIDTH = 1;\nexport const DEFAULT_DECORATOR_LINE_STROKE_COLOR = \"rgba(73, 126, 255, 0.7)\";\nexport const DEFAULT_LINE_INTERACT_STROKE_WIDTH = 15;\nexport const DEFAULT_LINE_INTERACT_SHOW_START_ARROW = false;\nexport const DEFAULT_LINE_INTERACT_SHOW_END_ARROW = true;\nexport const DEFAULT_LINE_INTERACT_ANIMATE_DURATION = 1;\nexport const DEFAULT_DEGRADED_THRESHOLD = 500;\nexport const DEFAULT_SNAP_GRID_SIZE = 10;\nexport const DEFAULT_SNAP_OBJECT_DISTANCE = 5;\nexport const DEFAULT_SNAP_OBJECT_POSITIONS = \"all\";\n/** Padding left + padding right, as well as top + bottom */\nexport const DEFAULT_NODE_PADDING_FOR_LINES = 5;\n/** Padding left + padding right, as well as top + bottom */\nexport const DEFAULT_NODE_PADDING_FOR_SMART_LINES = 0;\nexport const DEFAULT_CANVAS_PADDING = 0;\n\nexport const POINT_HELPER_RADIUS = 5;\nexport const DEFAULT_MOTION_SPEED = 50;\nexport const CONTAINERGAP = 40;\nexport const MAXPERROW = 12;\n","import { mergeRects, type Rect } from \"@next-shared/diagram\";\nimport type { Cell, CellsRect } from \"../../../draw-canvas/interfaces\";\nimport { isEdgeCell } from \"../../../draw-canvas/processors/asserts\";\n\nexport function getCellsRect(cells: Cell[]): CellsRect {\n const rects: Rect[] = [];\n let empty = true;\n for (const cell of cells) {\n if (!isEdgeCell(cell)) {\n empty = false;\n rects.push(cell.view);\n }\n }\n const { x: left, y: top, width, height } = mergeRects(rects);\n return { left, top, width, height, empty };\n}\n","export interface Rect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/**\n * Merges multiple rectangles into a single bounding rectangle.\n */\nexport function mergeRects(rects: Rect[]): Rect {\n let left = Infinity;\n let top = Infinity;\n let right = -Infinity;\n let bottom = -Infinity;\n for (const rect of rects) {\n const r = rect.x + rect.width;\n const b = rect.y + rect.height;\n if (rect.x < left) {\n left = rect.x;\n }\n if (r > right) {\n right = r;\n }\n if (rect.y < top) {\n top = rect.y;\n }\n if (b > bottom) {\n bottom = b;\n }\n }\n\n const width = right - left;\n const height = bottom - top;\n\n return { x: left, y: top, width, height };\n}\n","import { Cell, DecoratorCell, NodeCell } from \"../interfaces\";\nimport { MoveCellPayload } from \"../reducers/interfaces\";\nimport {\n isContainerDecoratorCell,\n isGroupDecoratorCell,\n isNodeCell,\n} from \"./asserts\";\n\nexport function handleNodeContainedChange(\n payloads: MoveCellPayload[],\n cells: Cell[],\n onContainerContainerChange?: (detail: MoveCellPayload[]) => void\n) {\n const nodeAndGroupCells = cells.filter(\n (c): c is NodeCell => isNodeCell(c) || isGroupDecoratorCell(c)\n );\n const containerIds = payloads\n .filter((p) => isContainerDecoratorCell(p))\n .map((v) => v.id);\n const cellPayloads = payloads.filter((p) => {\n const cell = nodeAndGroupCells.find((v) => v.id === p.id)!;\n const includeNodeFlag =\n cell?.containerId && containerIds.includes(cell.containerId);\n return (\n ((isNodeCell(p) && !p.groupId) || isGroupDecoratorCell(p)) &&\n !includeNodeFlag\n );\n });\n const containerDecoratorCells = cells.filter(\n (cell): cell is DecoratorCell =>\n isContainerDecoratorCell(cell) && !cell.view?.locked\n );\n cellPayloads.forEach((payload) => {\n const left = payload.x;\n const right = payload.x + payload.width!;\n const top = payload.y;\n const bottom = payload.y + payload!.height!;\n\n for (const containerCell of containerDecoratorCells) {\n const containerLeft = containerCell.view.x;\n const containerRight = containerCell.view.x + containerCell.view.width;\n const containerTop = containerCell.view.y;\n const containerBottom = containerCell.view.y + containerCell.view.height;\n if (\n left >= containerLeft &&\n right <= containerRight &&\n top >= containerTop &&\n bottom <= containerBottom\n ) {\n payload.containerCell = containerCell;\n break; //A node can be associated with only one container\n }\n }\n });\n let containedChanges = [];\n containedChanges = cellPayloads.filter((payload) => {\n const cell = nodeAndGroupCells.find((c) => c.id === payload.id);\n const containerId = cell?.containerId;\n const containerCellId = payload.containerCell?.id;\n //过滤掉一直没有关系或者关系没有改变的\n return containerId !== containerCellId;\n });\n if (containedChanges.length > 0) {\n onContainerContainerChange?.(containedChanges);\n }\n return containedChanges;\n}\n","// istanbul ignore file: nothing logical to test\nimport React from \"react\";\nimport type {\n DecoratorCell,\n DecoratorLineView,\n DecoratorView,\n EdgeView,\n EditableLineCell,\n LineEditorState,\n NodeCell,\n SmartConnectLineState,\n} from \"./interfaces\";\nimport type { NodePosition } from \"../diagram/interfaces\";\n\nexport interface HoverState {\n // Currently only support node cell\n cell: NodeCell | DecoratorCell;\n relativePoints: ReadonlyArray<NodePosition>;\n points: ReadonlyArray<NodePosition>;\n activePointIndex?: number;\n}\n\nexport const HoverStateContext = React.createContext<{\n rootRef: React.RefObject<SVGSVGElement>;\n smartConnectLineState: SmartConnectLineState | null;\n unsetHoverStateTimeoutRef: React.MutableRefObject<number | null>;\n hoverState: HoverState | null;\n activeEditableLines: EditableLineCell[];\n lineEditorState: LineEditorState | null;\n movingCells?: boolean;\n setLineEditorState: React.Dispatch<\n React.SetStateAction<LineEditorState | null>\n >;\n setHoverState: React.Dispatch<React.SetStateAction<HoverState | null>>;\n setSmartConnectLineState: React.Dispatch<\n React.SetStateAction<SmartConnectLineState | null>\n >;\n onConnect?: (\n source: NodeCell | DecoratorCell,\n target: NodeCell | DecoratorCell,\n exitPosition: NodePosition,\n entryPosition: NodePosition | undefined\n ) => void;\n onChangeEdgeView?: (\n source: NodeCell | DecoratorCell,\n target: NodeCell | DecoratorCell,\n view: EdgeView\n ) => void;\n onChangeDecoratorView?: (\n cell: DecoratorCell,\n view: DecoratorView | DecoratorLineView\n ) => void;\n}>({\n rootRef: { current: null },\n smartConnectLineState: null,\n unsetHoverStateTimeoutRef: { current: null },\n hoverState: null,\n activeEditableLines: [],\n lineEditorState: null,\n setLineEditorState: () => {},\n setHoverState: () => {},\n setSmartConnectLineState: () => {},\n});\n\nexport function useHoverStateContext() {\n return React.useContext(HoverStateContext);\n}\n","import { isNil } from \"lodash\";\nimport type {\n Cell,\n DecoratorCell,\n EdgeCell,\n EditableEdgeLine,\n EditableLine,\n InitialCell,\n InitialNodeCell,\n InitialNodeView,\n LayoutType,\n LineDecoratorCell,\n LineType,\n NodeCell,\n} from \"../interfaces\";\nimport { MoveCellPayload } from \"../reducers/interfaces\";\n\nexport function isNodeCell(cell: Cell | MoveCellPayload): cell is NodeCell {\n return cell.type === \"node\";\n}\n\nexport function isDecoratorCell(\n cell: Cell | InitialCell\n): cell is DecoratorCell {\n return cell.type === \"decorator\";\n}\n\nexport function isInitialNodeCell(cell: InitialCell): cell is InitialNodeCell {\n return cell.type === \"node\";\n}\n\nexport function isEdgeCell(cell: InitialCell): cell is EdgeCell {\n return cell.type === \"edge\";\n}\n\nexport function isNodeOrEdgeCell(cell: Cell): cell is NodeCell | EdgeCell {\n return cell.type === \"node\" || cell.type === \"edge\";\n}\n\nexport function isNodeOrAreaDecoratorCell(\n cell: Cell\n): cell is NodeCell | DecoratorCell {\n return (\n cell.type === \"node\" ||\n (cell.type === \"decorator\" && cell.decorator === \"area\")\n );\n}\n\nexport function isEdgeSide(\n cell: Cell,\n allowEdgeToArea: boolean | undefined\n): cell is NodeCell | DecoratorCell {\n return (\n cell.type === \"node\" ||\n (!!allowEdgeToArea &&\n cell.type === \"decorator\" &&\n cell.decorator === \"area\")\n );\n}\n\nexport function isNodeOrTextDecoratorCell(\n cell: Cell | MoveCellPayload\n): cell is NodeCell | DecoratorCell {\n return (\n cell.type === \"node\" ||\n (cell.type === \"decorator\" && cell.decorator === \"text\")\n );\n}\n\nexport function isTextDecoratorCell(cell: Cell): cell is DecoratorCell {\n return cell.type === \"decorator\" && cell.decorator === \"text\";\n}\nexport function isContainerDecoratorCell(\n cell: InitialCell | MoveCellPayload\n): cell is DecoratorCell {\n return cell.type === \"decorator\" && cell.decorator === \"container\";\n}\n\nexport function isGroupDecoratorCell(\n cell: InitialCell | MoveCellPayload\n): cell is DecoratorCell {\n return cell.type === \"decorator\" && cell.decorator === \"group\";\n}\n\nexport function isLineDecoratorCell(\n cell: Cell | LineDecoratorCell | MoveCellPayload\n): cell is LineDecoratorCell {\n return cell.type === \"decorator\" && cell.decorator === \"line\";\n}\n\nexport function isNoManualLayout(layout: LayoutType) {\n return ![\"manual\", undefined].includes(layout!);\n}\n\nexport function isNoSize(view: InitialNodeView) {\n return !(view?.width && view?.height);\n}\n\nexport function isNoPoint(view: InitialNodeView) {\n return isNil(view?.x) || isNil(view?.y);\n}\n\nexport function isStraightType(type: LineType | undefined) {\n return !(type === \"polyline\" || type === \"curve\");\n}\n\nexport function isEditableEdgeLine(\n line: EditableLine\n): line is EditableEdgeLine {\n return !!(line as EditableEdgeLine).edge;\n}\n","import type { Cell, NodeCell, DecoratorCell, NodeId } from \"../interfaces\";\nimport { isNodeOrAreaDecoratorCell } from \"./asserts\";\n\nexport function findNodeOrAreaDecorator(\n cells: Cell[],\n id: NodeId\n): NodeCell | DecoratorCell | undefined {\n return cells.find(\n (cell) => isNodeOrAreaDecoratorCell(cell) && cell.id === id\n ) as NodeCell | DecoratorCell | undefined;\n}\n","import { sortBy } from \"lodash\";\nimport type {\n ComputedEdgeLineConf,\n LineSegmentJumps,\n} from \"../../draw-canvas/interfaces\";\nimport type { NodePosition } from \"../../diagram/interfaces\";\nimport { intersect } from \"../../diagram/lines/intersect\";\n\ninterface LineSegment {\n start: NodePosition;\n end: NodePosition;\n}\n\nconst LINE_JUMP_BASE_SIZE = 6;\n\nexport function collectLineJumpsFactory() {\n const allJumps: LineSegmentJumps[] = [];\n const allLineSegments: LineSegment[] = [];\n\n return function collectLineJumps(\n points: NodePosition[],\n lineConf: ComputedEdgeLineConf\n ): Map<number, LineSegmentJumps> | null {\n const lineJumps: LineSegmentJumps[] = [];\n const lineSegments: LineSegment[] = [];\n\n // Line jumps for curved lines are not supported.\n if (lineConf.type !== \"curve\" || lineConf.curveType === \"curveLinear\") {\n for (let i = 0; i < points.length - 1; i++) {\n const start = points[i];\n const end = points[i + 1];\n const jumpPoints: NodePosition[] = [];\n const radius = LINE_JUMP_BASE_SIZE / 2 + lineConf.strokeWidth - 1;\n if (lineConf.jumps) {\n jumpLoop: for (const item of allLineSegments) {\n const point = lineJumpIntersect(\n start,\n end,\n item.start,\n item.end,\n radius\n );\n if (point) {\n for (const jump of allJumps) {\n for (const p of jump.jumpPoints) {\n const distance = Math.sqrt(\n Math.pow(point.x - p.x, 2) + Math.pow(point.y - p.y, 2)\n );\n if (distance < radius + jump.radius) {\n // Ignore this jump point if it's too close to an existing one\n continue jumpLoop;\n }\n }\n }\n\n jumpPoints.push(point);\n }\n }\n }\n\n if (jumpPoints.length > 0) {\n // 将交叉点按其在连线上的顺序排列\n const sortedJumpPoints = sortBy(\n jumpPoints,\n (p) => (p.x - points[0].x) ** 2 + (p.y - points[0].y) ** 2\n );\n\n const segJumps: LineSegmentJumps = {\n jumpPoints: sortedJumpPoints,\n index: i,\n radius,\n };\n allJumps.push(segJumps);\n lineJumps.push(segJumps);\n }\n\n lineSegments.push({ start, end });\n }\n\n // 同一连线上的不同线段交叉时,不产生跨线\n allLineSegments.push(...lineSegments);\n }\n\n return lineJumps.length > 0\n ? new Map(lineJumps.map((j) => [j.index, j]))\n : null;\n };\n}\n\nfunction lineJumpIntersect(\n p1: NodePosition,\n p2: NodePosition,\n p3: NodePosition,\n p4: NodePosition,\n radius: number\n): NodePosition | null {\n const point = intersect(\n [p1.x, p1.y],\n [p2.x, p2.y],\n [p3.x, p3.y],\n [p4.x, p4.y]\n );\n if (point) {\n // Check if the intersection point is too close to the line ends\n const r2 = radius * radius;\n for (const p of [p1, p2, p3, p4]) {\n const dx = point[0] - p.x;\n const dy = point[1] - p.y;\n if (dx * dx + dy * dy < r2) {\n return null;\n }\n }\n return { x: point[0], y: point[1] };\n }\n return null;\n}\n","import { useMemo } from \"react\";\nimport type {\n Cell,\n ComputedEdgeLineConf,\n DecoratorCell,\n DecoratorLineView,\n EdgeCell,\n EditableLine,\n} from \"../../draw-canvas/interfaces\";\nimport {\n isEdgeCell,\n isLineDecoratorCell,\n isStraightType,\n} from \"../../draw-canvas/processors/asserts\";\nimport { findNodeOrAreaDecorator } from \"../../draw-canvas/processors/findNodeOrAreaDecorator\";\nimport { getSmartLinePoints } from \"./processors/getSmartLinePoints\";\nimport { collectLineJumpsFactory } from \"./collectLineJumpsFactory\";\n\nexport function useEditableLineMap({\n cells,\n lineConfMap,\n}: {\n cells: Cell[];\n lineConfMap: WeakMap<EdgeCell | DecoratorCell, ComputedEdgeLineConf>;\n}): WeakMap<EdgeCell | DecoratorCell, EditableLine> {\n return useMemo(() => {\n const map = new WeakMap<EdgeCell | DecoratorCell, EditableLine>();\n\n const collectLineJumps = collectLineJumpsFactory();\n\n for (const cell of cells) {\n if (isEdgeCell(cell)) {\n const lineConf = lineConfMap.get(cell);\n // istanbul ignore next: defensive check\n if (!lineConf) {\n continue;\n }\n\n const sourceNode = findNodeOrAreaDecorator(cells, cell.source);\n const targetNode = findNodeOrAreaDecorator(cells, cell.target);\n\n const hasOppositeEdge =\n isStraightType(cell.view?.type) &&\n cells.some(\n (c) =>\n isEdgeCell(c) &&\n cell.source === c.target &&\n cell.target === c.source &&\n isStraightType(c.view?.type)\n );\n const parallelGap = hasOppositeEdge ? lineConf.parallelGap : 0;\n\n const points =\n sourceNode &&\n targetNode &&\n sourceNode.view.x != null &&\n targetNode.view.x != null\n ? getSmartLinePoints(\n sourceNode.view,\n targetNode.view,\n cell.view,\n parallelGap,\n cell.type\n )\n : null;\n\n if (points) {\n const jumpsMap = collectLineJumps(points, lineConf);\n\n map.set(cell, {\n edge: cell,\n points,\n source: sourceNode!,\n target: targetNode!,\n parallelGap,\n jumpsMap,\n });\n }\n } else if (isLineDecoratorCell(cell)) {\n const lineConf = lineConfMap.get(cell);\n // istanbul ignore next: defensive check\n if (!lineConf) {\n continue;\n }\n\n const { source, target } = cell.view as DecoratorLineView;\n\n const points =\n source && target\n ? getSmartLinePoints(\n { ...source, width: 0, height: 0 },\n { ...target, width: 0, height: 0 },\n cell.view,\n 0,\n cell.type\n )\n : null;\n\n if (points) {\n const jumpsMap = collectLineJumps(points, lineConf);\n\n map.set(cell, {\n decorator: cell,\n points,\n parallelGap: 0,\n jumpsMap,\n });\n }\n }\n }\n return map;\n }, [cells, lineConfMap]);\n}\n","// istanbul ignore file: experimental\nimport React, { useEffect, useMemo, useRef } from \"react\";\nimport type { NodePosition } from \"../diagram/interfaces\";\nimport { useHoverStateContext } from \"./HoverStateContext\";\nimport type {\n ControlPoint,\n EditableLine,\n EditableLineCell,\n EditableLineView,\n} from \"./interfaces\";\nimport { isLineDecoratorCell, isStraightType } from \"./processors/asserts\";\n\nconst POINT_HELPER_IMAGE =\n \"data:image/svg+xml;base64,PCFET0NUWVBFIHN2ZyBQVUJMSUMgIi0vL1czQy8vRFREIFNWRyA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EQvc3ZnMTEuZHRkIj48c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHdpZHRoPSIyMnB4IiBoZWlnaHQ9IjIycHgiIHZlcnNpb249IjEuMSI+PGNpcmNsZSBjeD0iMTEiIGN5PSIxMSIgcj0iNyIgc3Ryb2tlPSIjZmZmIiBmaWxsPSIjMDFiZDIyIi8+PHBhdGggZD0ibSA4IDggTCAxNCAxNE0gOCAxNCBMIDE0IDgiIHN0cm9rZT0iI2ZmZiIvPjwvc3ZnPg==\";\nconst VERTEX_HELPER_IMAGE =\n \"data:image/svg+xml;base64,PCFET0NUWVBFIHN2ZyBQVUJMSUMgIi0vL1czQy8vRFREIFNWRyAxLjEvL0VOIiAiaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkIj48c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHdpZHRoPSIxOHB4IiBoZWlnaHQ9IjE4cHgiIHZlcnNpb249IjEuMSI+PGNpcmNsZSBjeD0iOSIgY3k9IjkiIHI9IjUiIHN0cm9rZT0iI2ZmZiIgZmlsbD0iIzI5YjZmMiIvPjwvc3ZnPg==\";\nconst POINT_HELPER_BG_SIZE = 22;\n\nexport interface LineEditorComponentProps {\n scale: number;\n editableLineMap: WeakMap<EditableLineCell, EditableLine>;\n activeEditableLine: EditableLineCell;\n updateCurActiveEditableLine?: (\n activeEditableLine: EditableLineCell | null\n ) => void;\n}\n\nexport function LineEditorComponent({\n scale,\n editableLineMap,\n activeEditableLine,\n updateCurActiveEditableLine,\n}: LineEditorComponentProps): JSX.Element | null {\n const { rootRef, movingCells, lineEditorState, setLineEditorState } =\n useHoverStateContext();\n const exitRef = useRef<SVGImageElement>(null);\n const entryRef = useRef<SVGImageElement>(null);\n const controlPointsRef = useRef<(SVGImageElement | null)[]>([]);\n const isLineDecorator = isLineDecoratorCell(activeEditableLine);\n\n useEffect(() => {\n const exit = exitRef.current;\n const entry = entryRef.current;\n if (!exit || !entry || !activeEditableLine) {\n return;\n }\n const handleMouseDownFactory = (type: \"exit\" | \"entry\") => {\n return (e: MouseEvent) => {\n e.stopPropagation();\n e.preventDefault();\n const rect = rootRef.current!.getBoundingClientRect();\n setLineEditorState({\n offset: [rect.left, rect.top],\n from: [e.clientX, e.clientY],\n type,\n });\n updateCurActiveEditableLine?.(activeEditableLine);\n };\n };\n const handleStartMouseDown = handleMouseDownFactory(\"exit\");\n const handleEndMouseDown = handleMouseDownFactory(\"entry\");\n exit.addEventListener(\"mousedown\", handleStartMouseDown);\n entry.addEventListener(\"mousedown\", handleEndMouseDown);\n return () => {\n exit.removeEventListener(\"mousedown\", handleStartMouseDown);\n entry.removeEventListener(\"mousedown\", handleEndMouseDown);\n };\n }, [\n activeEditableLine,\n rootRef,\n setLineEditorState,\n updateCurActiveEditableLine,\n ]);\n\n const controlPoints = useMemo(() => {\n if (!activeEditableLine) {\n return [];\n }\n\n const points = editableLineMap.get(activeEditableLine)!.points!;\n\n if (isStraightType((activeEditableLine.view as EditableLineView)?.type)) {\n return isLineDecorator ? getStraightControlPoints(points) : [];\n }\n\n return getControlPoints(points);\n }, [activeEditableLine, editableLineMap, isLineDecorator]);\n\n useEffect(() => {\n if (!activeEditableLine) {\n return;\n }\n const controlElements = controlPointsRef.current;\n const handleMouseDownFactory = (control: ControlPoint) => {\n return (e: MouseEvent) => {\n e.stopPropagation();\n e.preventDefault();\n updateCurActiveEditableLine?.(activeEditableLine);\n const rect = rootRef.current!.getBoundingClientRect();\n setLineEditorState({\n offset: [rect.left, rect.top],\n from: [e.clientX, e.clientY],\n type: control.type,\n control,\n });\n };\n };\n const handlers = controlPoints.map((control) =>\n handleMouseDownFactory(control)\n );\n controlElements.forEach((el, i) => {\n el?.addEventListener(\"mousedown\", handlers[i]);\n });\n return () => {\n controlElements.forEach((el, i) => {\n el?.removeEventListener(\"mousedown\", handlers[i]);\n });\n };\n }, [\n activeEditableLine,\n controlPoints,\n rootRef,\n setLineEditorState,\n updateCurActiveEditableLine,\n ]);\n\n const gRef = useRef<SVGGElement>(null);\n useEffect(() => {\n const g = gRef.current;\n const onClick = (e: MouseEvent) => {\n e.stopPropagation();\n e.preventDefault();\n };\n g?.addEventListener(\"click\", onClick);\n return () => {\n g?.removeEventListener(\"click\", onClick);\n };\n }, []);\n\n if (movingCells) {\n return null;\n }\n\n const view = activeEditableLine.view as EditableLineView;\n const linePoints = editableLineMap.get(activeEditableLine)!.points!;\n const { exitPosition, entryPosition } = view ?? {};\n\n const commonProps: React.SVGAttributes<SVGImageElement> = {\n width: POINT_HELPER_BG_SIZE / scale,\n height: POINT_HELPER_BG_SIZE / scale,\n preserveAspectRatio: \"none\",\n cursor: \"pointer\",\n pointerEvents: \"fill\",\n };\n const exitPoint = linePoints[0];\n const entryPoint = linePoints[linePoints.length - 1];\n const offset = POINT_HELPER_BG_SIZE / scale / 2;\n\n return (\n <g ref={gRef}>\n <image\n ref={exitRef}\n {...commonProps}\n x={exitPoint.x - offset}\n y={exitPoint.y - offset}\n xlinkHref={\n isLineDecorator\n ? VERTEX_HELPER_IMAGE\n : exitPosition\n ? ANCHORED_POINT_HELPER_IMAGE\n : POINT_HELPER_IMAGE\n }\n />\n {controlPoints.map((point, i) => (\n <image\n key={i}\n ref={(el) => {\n controlPointsRef.current[i] = el;\n }}\n {...commonProps}\n x={point.x - offset}\n y={point.y - offset}\n opacity={\n point.type === \"break\" &&\n !(\n lineEditorState?.type === \"break\" &&\n lineEditorState.control === point\n )\n ? 0.4\n : 1\n }\n xlinkHref={VERTEX_HELPER_IMAGE}\n cursor={\n isLineDecorator\n ? \"crosshair\"\n : point.direction === \"ns\"\n ? \"row-resize\"\n : \"col-resize\"\n }\n />\n ))}\n <image\n ref={entryRef}\n {...commonProps}\n x={entryPoint.x - offset}\n y={entryPoint.y - offset}\n xlinkHref={\n isLineDecorator\n ? END_POINT_HELPER_IMAGE\n : entryPosition\n ? ANCHORED_POINT_HELPER_IMAGE\n : POINT_HELPER_IMAGE\n }\n />\n </g>\n );\n}\n\nfunction getControlPoints(linePoints: NodePosition[]): ControlPoint[] {\n const controlPoints: ControlPoint[] = [];\n let prev = linePoints[0];\n let cursor = 1;\n while (cursor < linePoints.length) {\n const next = linePoints[cursor];\n const ns = prev.y === next.y;\n const ew = prev.x === next.x;\n if (!(ns && ew)) {\n const direction = ns ? \"ns\" : \"ew\";\n controlPoints.push({\n type: \"control\",\n direction,\n index: cursor - 1,\n x: (prev.x + next.x) / 2,\n y: (prev.y + next.y) / 2,\n });\n }\n prev = next;\n cursor++;\n }\n\n return controlPoints;\n}\n\nfunction getStraightControlPoints(linePoints: NodePosition[]): ControlPoint[] {\n const controlPoints: ControlPoint[] = [];\n let prev = linePoints[0];\n let cursor = 1;\n while (cursor < linePoints.length) {\n const next = linePoints[cursor];\n controlPoints.push({\n type: \"break\",\n index: cursor - 1,\n x: (prev.x + next.x) / 2,\n y: (prev.y + next.y) / 2,\n });\n if (cursor < linePoints.length - 1) {\n controlPoints.push({\n ...next,\n type: \"corner\",\n index: cursor - 1,\n });\n }\n prev = next;\n cursor++;\n }\n\n return controlPoints;\n}\n","import type { ActiveTarget, ActiveTargetOfSingular } from \"../interfaces\";\nimport { sameTarget } from \"./sameTarget\";\n\nexport function targetIsActive(\n target: ActiveTargetOfSingular,\n activeTarget: ActiveTarget | null | undefined\n): boolean {\n return (\n !!activeTarget &&\n (activeTarget.type === \"multi\"\n ? activeTarget.targets\n : [activeTarget]\n ).some((active) => sameTarget(active, target))\n );\n}\n","import { get } from \"lodash\";\nimport { CONTAINERGAP, DEFAULT_NODE_SIZE, MAXPERROW } from \"../constants\";\nimport { DecoratorCell, NodeCell } from \"../interfaces\";\nimport { isGroupDecoratorCell, isNoPoint } from \"./asserts\";\n\n/**\n * 交错排列的网格布局\n * [●][●][●][●]\n * [●][●][●]\n * [●][●][●][●]\n * @param nodes\n * @param options\n * @returns\n */\nexport function staggeredLayout(\n nodes: (NodeCell | DecoratorCell)[],\n options: {\n gapX?: number;\n gapY?: number;\n offsetY?: number;\n maxPerRow?: number;\n } = {}\n): (NodeCell | DecoratorCell)[] {\n const {\n gapX = 50,\n gapY = 50,\n offsetY = CONTAINERGAP,\n maxPerRow = MAXPERROW,\n } = options;\n /**\n * 满行数量(例如4个)\n * 短行数量(例如3个)\n */\n const fullRowCount = maxPerRow;\n const shortRowCount = maxPerRow - 1;\n const layoutedNodes = [];\n let index = 0,\n row = 0,\n preRowOffsetY = offsetY;\n\n while (index < nodes.length) {\n const isOddRow = row % 2 === 1;\n const nodesInRow = isOddRow ? shortRowCount : fullRowCount;\n let nodeX = isOddRow ? CONTAINERGAP : 0,\n maxNodeHeight = 0;\n for (let i = 0; i < nodesInRow && index < nodes.length; i++, index++) {\n const node = nodes[index];\n const nodeWidth = get(node, \"view.width\", DEFAULT_NODE_SIZE);\n const nodeHeight = get(node, \"view.height\", DEFAULT_NODE_SIZE);\n const x = nodeX;\n const y = preRowOffsetY;\n if (isNoPoint(nodes[index].view) || isGroupDecoratorCell(nodes[index])) {\n nodes[index].view = {\n ...nodes[index].view,\n x,\n y,\n width: nodeWidth,\n height: nodeHeight,\n };\n }\n nodeX = x + (nodeWidth + gapX);\n maxNodeHeight = Math.max(maxNodeHeight, nodeHeight);\n layoutedNodes.push(nodes[index]);\n }\n preRowOffsetY = preRowOffsetY + maxNodeHeight + gapY;\n row++;\n }\n return layoutedNodes;\n}\n","import { get } from \"lodash\";\nimport { BaseNodeCell } from \"../interfaces\";\nimport { CONTAINERGAP } from \"../constants\";\n\nexport function computeBoundingBox(\n cells: BaseNodeCell[],\n options?: { padding: number }\n) {\n let minX = Infinity,\n minY = Infinity;\n let maxX = -Infinity,\n maxY = -Infinity;\n cells.forEach((cell) => {\n const { x, y, width, height } = cell.view;\n if (x < minX) minX = x;\n if (y < minY) minY = y;\n if (x + width > maxX) maxX = x + width;\n if (y + height > maxY) maxY = y + height;\n });\n if (![minX, maxX, minY, maxY].some((n) => isFinite(n))) return {};\n const padding = get(options, \"padding\", CONTAINERGAP);\n const width = maxX - minX + padding * 2;\n const height = maxY - minY + padding * 2;\n return {\n x: minX - padding,\n y: minY - padding,\n width: width,\n height: height,\n };\n}\n","import { forEach, groupBy, isNil } from \"lodash\";\nimport { DecoratorCell, InitialCell, NodeCell, NodeView } from \"../interfaces\";\nimport {\n isContainerDecoratorCell,\n isGroupDecoratorCell,\n isNoPoint,\n} from \"./asserts\";\nimport { SizeTuple } from \"../../diagram/interfaces\";\nimport { CONTAINERGAP } from \"../constants\";\nimport { computeBoundingBox } from \"./computeBoundingBox\";\nimport { GROUPPADDING } from \"./initialGroupLayout\";\ninterface Point {\n x: number;\n y: number;\n}\n\n/**\n * 在容器内新加节点时,计算新节点的点按位置\n * 按网格排布避免重叠\n * @param cells\n * @param defaultNodeSize 默认节点大小\n * @returns void\n */\nexport function generateNewPointsWithLayout(\n cells: InitialCell[],\n { defaultNodeSize }: { defaultNodeSize: SizeTuple }\n) {\n const newContainerChildCells = cells.filter(\n (c) => c.type === \"node\" && isNoPoint(c.view!) && !isNil(c.containerId)\n ) as NodeCell[];\n const newGroupChildCells = cells.filter(\n (c) => c.type === \"node\" && isNoPoint(c.view!) && !isNil(c.groupId)\n ) as NodeCell[];\n if (newGroupChildCells.length) {\n const groupMap: Record<string, NodeCell[]> = {};\n forEach(\n groupBy(newGroupChildCells, \"groupId\"),\n (groupedNodes, containerId) => {\n groupMap[containerId] = groupedNodes;\n }\n );\n\n const groupCells = cells.filter(\n (c) => isGroupDecoratorCell(c) && groupMap[c.id]\n ) as DecoratorCell[];\n groupCells.forEach((group) => {\n const groupId = group.id;\n const newNodes = groupMap[groupId];\n const groupView = !isNoPoint(group.view)\n ? group.view\n : (computeBoundingBox(\n cells.filter(\n (c) => c.type === \"node\" && c.groupId === groupId\n ) as NodeCell[],\n {\n padding: GROUPPADDING,\n }\n ) as NodeView);\n const existingPoints = cells\n .filter(\n (c) =>\n (c as NodeCell)?.groupId === groupId &&\n !isNoPoint((c as NodeCell).view)\n )\n .map((node) => ({ x: node.view!.x, y: node.view!.y })) as Point[];\n newNodes.forEach((node) => {\n const nodeWidth = node.view?.width || defaultNodeSize[0];\n const nodeHeight = node.view?.height || defaultNodeSize[1];\n const gap = 10; // 间距\n const padding = CONTAINERGAP; // 内边距\n\n const newPoint = computeNodePoints(\n groupView,\n existingPoints,\n nodeWidth,\n nodeHeight,\n gap,\n padding\n );\n if (newPoint) {\n node.view = {\n ...node.view,\n x: newPoint.x,\n y: newPoint.y,\n };\n existingPoints.push(newPoint);\n }\n });\n });\n }\n if (newContainerChildCells.length) {\n const containerGroup: Record<string, NodeCell[]> = {};\n forEach(\n groupBy(newContainerChildCells, \"containerId\"),\n (groupedNodes, containerId) => {\n containerGroup[containerId] = groupedNodes;\n }\n );\n\n const containerCells = cells.filter(\n (c) => isContainerDecoratorCell(c) && containerGroup[c.id]\n ) as DecoratorCell[];\n containerCells.forEach((container) => {\n const containerId = container.id;\n const containerView = container.view;\n\n const existingPoints = cells\n .filter(\n (c) =>\n (c as NodeCell)?.containerId === containerId &&\n !isNoPoint((c as NodeCell).view)\n )\n .map((node) => ({ x: node.view!.x, y: node.view!.y })) as Point[];\n const newNodes = containerGroup[containerId];\n newNodes.forEach((node) => {\n const nodeWidth = node.view?.width || defaultNodeSize[0];\n const nodeHeight = node.view?.height || defaultNodeSize[1];\n const gap = 10; // 间距\n const padding = CONTAINERGAP; // 内边距\n\n const newPoint = computeNodePoints(\n containerView,\n existingPoints,\n nodeWidth,\n nodeHeight,\n gap,\n padding\n );\n if (newPoint) {\n node.view = {\n ...node.view,\n x: newPoint.x,\n y: newPoint.y,\n };\n existingPoints.push(newPoint);\n }\n });\n });\n }\n}\n\nfunction computeNodePoints(\n containerView: NodeView,\n existingPoints: Point[],\n nodeWidth: number,\n nodeHeight: number,\n gap = 0,\n padding = 0\n) {\n const { x: left, y: top, width } = containerView;\n const stepX = nodeWidth + gap;\n const stepY = nodeHeight + gap;\n const cols = Math.max(Math.floor((width - padding * 2) / stepX), 1);\n let row = 0;\n\n while (true) {\n for (let col = 0; col < cols; col++) {\n const x = left + padding + col * stepX;\n const y = top + padding + row * stepY;\n\n const overlapping = existingPoints.some((p) =>\n isOverlapping(\n x,\n y,\n nodeWidth,\n nodeHeight,\n p.x,\n p.y,\n nodeWidth,\n nodeHeight\n )\n );\n\n if (!overlapping) {\n return { x, y };\n }\n }\n row++;\n }\n}\n/**\n * 判断两个矩形中心点是否重叠(简单矩形碰撞判断)\n */\nfunction isOverlapping(\n x1: number,\n y1: number,\n w1: number,\n h1: number,\n x2: number,\n y2: number,\n w2: number,\n h2: number\n) {\n const cx1 = x1 + w1 / 2;\n const cy1 = y1 + h1 / 2;\n const cx2 = x2 + w2 / 2;\n const cy2 = y2 + h2 / 2;\n\n const minDistX = (w1 + w2) / 2;\n const minDistY = (h1 + h2) / 2;\n\n return Math.abs(cx1 - cx2) < minDistX && Math.abs(cy1 - cy2) < minDistY;\n}\n","import { get, without } from \"lodash\";\nimport type {\n RangeTuple,\n SizeTuple,\n TransformLiteral,\n} from \"../../diagram/interfaces\";\nimport {\n DEFAULT_NODE_GAP_H,\n DEFAULT_NODE_GAP_V,\n SYMBOL_FOR_SIZE_INITIALIZED,\n} from \"../constants\";\nimport type {\n Cell,\n DecoratorCell,\n InitialCell,\n LayoutOptions,\n LayoutType,\n NodeCell,\n NodeId,\n NodeView,\n} from \"../interfaces\";\nimport {\n isContainerDecoratorCell,\n isDecoratorCell,\n isEdgeCell,\n isGroupDecoratorCell,\n isNodeCell,\n isNoPoint,\n isNoSize,\n} from \"./asserts\";\nimport { initializeCells } from \"./initializeCells\";\nimport { transformToCenter } from \"./transformToCenter\";\nimport { forceLayout } from \"../../shared/canvas/forceLayout\";\nimport { dagreLayout } from \"../../shared/canvas/dagreLayout\";\nimport { sameTarget } from \"./sameTarget\";\nimport { generateNewPointsWithLayout } from \"./generateNewPointsWithLayout\";\nimport { initialContainerLayout } from \"./initialContainerLayout\";\n\nexport function updateCells({\n cells,\n layout,\n previousCells,\n defaultNodeSize,\n canvasWidth,\n canvasHeight,\n scaleRange,\n transform,\n reason,\n parent,\n parentNode,\n allowEdgeToArea,\n layoutOptions,\n}: {\n cells: InitialCell[] | undefined;\n layout?: LayoutType;\n previousCells: Cell[];\n defaultNodeSize: SizeTuple;\n canvasWidth: number;\n canvasHeight: number;\n scaleRange: RangeTuple;\n transform: TransformLiteral;\n reason?: \"add-related-nodes\";\n parent?: NodeId;\n parentNode?: NodeCell;\n allowEdgeToArea?: boolean;\n layoutOptions?: LayoutOptions;\n}): {\n cells: Cell[];\n updated: Cell[];\n shouldReCenter: boolean;\n} {\n const isManualLayout = layout !== \"force\" && layout !== \"dagre\";\n\n // --- Step 1: 初始化 ---\n const newCells = initializeCells(cells, {\n defaultNodeSize,\n layoutOptions,\n isInitialize: false,\n });\n const updateCandidates: (NodeCell | DecoratorCell)[] = [];\n let shouldReCenter = false;\n\n // 记录已存在的节点尺寸,避免丢失\n const prevSizeNodes = new Map<string, NodeCell>();\n let prevShouldCentered = false;\n for (const c of previousCells) {\n if (isDecoratorCell(c) || isNodeCell(c)) {\n prevShouldCentered = true;\n if (isNodeCell(c) && c[SYMBOL_FOR_SIZE_INITIALIZED]) {\n prevSizeNodes.set(c.id, c);\n }\n }\n }\n\n // 构建 id -> node 映射,复用尺寸\n const nodesMap = new Map<string, NodeCell>();\n for (const c of newCells) {\n if (isNodeCell(c)) {\n nodesMap.set(c.id, c);\n const prevNode = prevSizeNodes.get(c.id);\n if (prevNode) {\n Object.assign(c.view, {\n width: prevNode.view.width,\n height: prevNode.view.height,\n });\n c[SYMBOL_FOR_SIZE_INITIALIZED] = true;\n }\n }\n }\n\n // --- Step 2: 特殊场景 - add-related-nodes ---\n let handled = false;\n if (reason === \"add-related-nodes\") {\n handled = layoutRelatedNodes({\n newCells,\n nodesMap,\n parent,\n parentNode,\n isManualLayout,\n updateCandidates,\n handled,\n });\n }\n\n // --- Step 3: 常规布局 ---\n if (!handled) {\n const positioned: NodeCell[] = [];\n let hasDecorators = false;\n\n for (const c of newCells) {\n if (isNodeCell(c)) {\n if (isNoPoint(c.view)) updateCandidates.push(c);\n else positioned.push(c);\n } else if (isDecoratorCell(c)) {\n hasDecorators = true;\n }\n }\n\n if (isManualLayout) {\n // 没有居中过,执行一次居中变换\n if (!prevShouldCentered) {\n transform = transformToCenter(without(newCells, ...updateCandidates), {\n canvasWidth,\n canvasHeight,\n scaleRange,\n });\n }\n\n let getNodeView: (id: NodeId) => NodeView;\n if (\n positioned.length === 0 ||\n (positioned.length === 1 &&\n !hasDecorators &&\n updateCandidates.length > 0)\n ) {\n // 使用 dagre 初始布局\n updateCandidates.push(...positioned);\n ({ getNodeView } = dagreLayout({ cells: newCells, allowEdgeToArea }));\n shouldReCenter =\n previousCells.length === 0 ||\n (previousCells.length === newCells.length &&\n previousCells.every((cell, i) => sameTarget(cell, newCells[i])));\n } else {\n // 使用 force layout 固定已存在位置\n ({ getNodeView } = forceLayout({\n cells: newCells,\n fixedPosition: true,\n allowEdgeToArea,\n center: [\n (canvasWidth / 2 - transform.x) / transform.k,\n (canvasHeight / 2 - transform.y) / transform.k,\n ],\n }));\n }\n\n // --- Step 4: 容器、分组布局 ---\n const containerCells = newCells.filter(\n (cell) => isContainerDecoratorCell(cell) && isNoSize(cell.view)\n ) as DecoratorCell[];\n const groupCells = newCells.filter(\n (cell) => isGroupDecoratorCell(cell) && isNoSize(cell.view)\n ) as DecoratorCell[];\n\n const containerAndGroupCells = [...containerCells, ...groupCells];\n const nodeLayout =\n get(layoutOptions, \"initialLayout\") === \"layered-staggered\"\n ? \"staggered\"\n : \"dagre\";\n if (containerAndGroupCells.length > 0) {\n initialContainerLayout(newCells, { nodeLayout });\n updateCandidates.push(...containerAndGroupCells);\n } else {\n generateNewPointsWithLayout(newCells, { defaultNodeSize });\n }\n\n // --- Step 5: 更新未定位节点 ---\n for (const c of newCells) {\n if (isNodeCell(c) && isNoPoint(c.view)) {\n const v = getNodeView(c.id);\n c.view.x = v.x;\n c.view.y = v.y;\n }\n }\n }\n }\n\n return { cells: newCells, updated: updateCandidates, shouldReCenter };\n}\n\n/**\n * 布局 add-related-nodes 的子节点\n */\nfunction layoutRelatedNodes({\n newCells,\n nodesMap,\n parent,\n parentNode,\n isManualLayout,\n updateCandidates,\n handled,\n}: {\n newCells: Cell[];\n nodesMap: Map<string, NodeCell>;\n parent?: NodeId;\n parentNode?: NodeCell;\n isManualLayout: boolean;\n updateCandidates: (NodeCell | DecoratorCell)[];\n handled: boolean;\n}): boolean {\n const parentNodeCell = parent ? nodesMap.get(parent) : parentNode;\n\n if (!parentNodeCell || isNoPoint(parentNodeCell.view)) return handled;\n\n // 构建父->子[]\n const adjacency = new Map<string, string[]>();\n const queue: { id: string; parentId: string }[] = [];\n\n for (const c of newCells) {\n if (isEdgeCell(c) && c.source && c.target) {\n if (!adjacency.has(c.source)) adjacency.set(c.source, []);\n adjacency.get(c.source)!.push(c.target);\n queue.push({ id: c.target, parentId: c.source });\n }\n }\n\n while (queue.length > 0) {\n const { id, parentId } = queue.shift()!;\n const node = nodesMap.get(id);\n const parent = nodesMap.get(parentId);\n if (!node || !parent) continue;\n\n if (isNoPoint(node.view)) {\n if (isManualLayout) {\n const siblings = adjacency.get(parentId)!;\n const index = siblings.indexOf(id);\n const baseX =\n parent.view.x + parent.view.width / 2 - node.view.width / 2;\n const baseY = parent.view.y + parent.view.height + DEFAULT_NODE_GAP_V;\n\n let offsetX = 0;\n if (index > 0) {\n const step = Math.ceil(index / 2);\n const dir = 1 - 2 * (index % 2);\n offsetX = dir * step * (node.view.width + DEFAULT_NODE_GAP_H);\n }\n\n node.view.x = baseX + offsetX;\n node.view.y = baseY;\n }\n\n updateCandidates.push(node);\n }\n\n (adjacency.get(id) || []).forEach((cid) =>\n queue.push({ id: cid, parentId: id })\n );\n }\n\n return !newCells.some((c) => c.type === \"decorator\" && isNoPoint(c.view));\n}\n","import type { TransformLiteral } from \"../../diagram/interfaces\";\nimport { getCellsRect } from \"../../shared/canvas/processors/getCellsRect\";\nimport {\n getTransformToCenter,\n type TransformToCenterOptions,\n} from \"../../shared/canvas/processors/getTransformToCenter\";\nimport type { Cell } from \"../interfaces\";\n\nexport function transformToCenter(\n cells: Cell[],\n options: TransformToCenterOptions\n): TransformLiteral {\n const rect = getCellsRect(cells);\n return getTransformToCenter(rect, options);\n}\n","import React, { useEffect, useState } from \"react\";\nimport classNames from \"classnames\";\nimport type { ConnectLineState } from \"./interfaces\";\nimport type { PositionTuple, TransformLiteral } from \"../diagram/interfaces\";\n\nexport interface ConnectLineComponentProps {\n connectLineState: ConnectLineState | null;\n transform: TransformLiteral;\n markerEnd: string;\n onConnect(state: ConnectLineState, to: PositionTuple): void;\n}\n\nexport function ConnectLineComponent({\n connectLineState,\n transform,\n markerEnd,\n onConnect,\n}: ConnectLineComponentProps): JSX.Element {\n const [connectLineTo, setConnectLineTo] = useState<PositionTuple | null>(\n null\n );\n\n useEffect(() => {\n if (connectLineState) {\n setConnectLineTo(connectLineState.from);\n }\n }, [connectLineState]);\n\n useEffect(() => {\n if (connectLineState) {\n const getConnectTo = (e: MouseEvent): PositionTuple => [\n (e.clientX - transform.x - connectLineState.offset[0]) / transform.k,\n (e.clientY - transform.y - connectLineState.offset[1]) / transform.k,\n ];\n const onMouseMove = (e: MouseEvent) => {\n // Set connect line to based on the mouse position and the transform\n setConnectLineTo(getConnectTo(e));\n };\n const onMouseDown = (e: MouseEvent) => {\n e.stopPropagation();\n };\n const onClick = (e: MouseEvent) => {\n e.stopPropagation();\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n reset();\n onConnect(connectLineState, getConnectTo(e));\n };\n const reset = () => {\n document.removeEventListener(\"mousemove\", onMouseMove);\n document.removeEventListener(\"mousedown\", onMouseDown, {\n capture: true,\n });\n document.removeEventListener(\"click\", onClick, { capture: true });\n setConnectLineTo(null);\n };\n document.addEventListener(\"mousemove\", onMouseMove);\n document.addEventListener(\"mousedown\", onMouseDown, { capture: true });\n document.addEventListener(\"click\", onClick, { capture: true });\n\n return reset;\n }\n }, [connectLineState, onConnect, transform]);\n\n return (\n <path\n className={classNames(\"connect-line\", {\n connecting:\n !!connectLineState &&\n connectLineTo &&\n // Do not show when the distance of mouse move is less than 5px\n (connectLineTo[0] - connectLineState.from[0]) ** 2 +\n (connectLineTo[1] - connectLineState.from[1]) ** 2 >\n 25,\n })}\n d={\n connectLineState && connectLineTo\n ? `M${connectLineState.from.join(\" \")}L${connectLineTo.join(\" \")}`\n : \"\"\n }\n fill=\"none\"\n stroke=\"gray\"\n strokeWidth={1}\n markerEnd={`url(#${markerEnd})`}\n />\n );\n}\n","// Imports\nimport ___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___ from \"../../../../../node_modules/css-loader/dist/runtime/noSourceMaps.js\";\nimport ___CSS_LOADER_API_IMPORT___ from \"../../../../../node_modules/css-loader/dist/runtime/api.js\";\nvar ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___);\n// Module\n___CSS_LOADER_EXPORT___.push([module.id, `.zoom-bar{position:absolute;bottom:20px;right:20px;width:40px;scale:0.8}.zoom-slider,\n.center-button{width:100%;display:flex;align-items:center;border:1px solid var(--antd-background-color-base);border-radius:var(--larger-border-radius);box-shadow:var(--connected-overlay-shadow);background-color:var(--color-fill-bg-container-4)}.zoom-slider{height:140px;padding:8px 0;flex-direction:column}[role=\"button\"]{cursor:pointer}.center-button{justify-content:center;margin-bottom:8px;height:40px}.center-button:hover{border-color:var(--antd-btn-default-hover-border-color)}.center-button path{fill:var(--antd-link-hover-color)}.center-button:hover path{fill:var(--palette-blue-7)}.zoom-button{font-size:16px;line-height:0}.zoom-button svg{width:1em;height:1em;fill:var(--antd-link-hover-color)}.zoom-slider .ant-slider-vertical{padding-left:5px;padding-right:5px}.zoom-slider .ant-slider-vertical .ant-slider-rail{width:2px}.zoom-slider .ant-slider-vertical .ant-slider-handle{width:6px;height:6px;left:3px}.zoom-slider .ant-slider .ant-slider-handle:hover::before,\n.zoom-slider .ant-slider .ant-slider-handle:focus::before,\n.zoom-slider .ant-slider .ant-slider-handle::before{width:10px;height:10px;left:-2px}.zoom-slider .ant-slider .ant-slider-handle:hover::after,\n.zoom-slider .ant-slider .ant-slider-handle:focus::after,\n.zoom-slider .ant-slider .ant-slider-handle::after{width:6px;height:6px;top:0;left:0}`, \"\"]);\n// Exports\nexport default ___CSS_LOADER_EXPORT___.toString();\n","import * as React from \"react\";\nconst SvgCenter = props => <svg xmlns=\"http://www.w3.org/2000/svg\" width={24} height={24} viewBox=\"0 0 24 24\" {...props}><path d=\"M12 0a.5.5 0 0 1 .5.5v2.013a9.5 9.5 0 0 1 8.987 8.988L23.5 11.5a.5.5 0 0 1 0 1h-2.013a9.5 9.5 0 0 1-8.987 8.987V23.5a.5.5 0 0 1-1 0v-2.013A9.5 9.5 0 0 1 2.514 12.5H.5a.5.5 0 0 1 0-1h2.013A9.5 9.5 0 0 1 11.5 2.514V.5A.5.5 0 0 1 12 0M3.514 11.5H7.5a.5.5 0 0 1 0 1H3.514a8.5 8.5 0 0 0 7.987 7.986L11.5 16.5a.5.5 0 0 1 1 0v3.986a8.5 8.5 0 0 0 7.986-7.986H16.5a.5.5 0 0 1 0-1h3.986A8.5 8.5 0 0 0 12.5 3.515V7.5a.5.5 0 0 1-1 0V3.514a8.5 8.5 0 0 0-7.986 7.987zm8.486-1a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3\" /></svg>;\nexport default SvgCenter;","import * as React from \"react\";\nconst SvgZoomIn = props => <svg xmlns=\"http://www.w3.org/2000/svg\" width={128} height={128} className=\"icon\" viewBox=\"0 0 1024 1024\" {...props}><path d=\"M512 76.8A435.2 435.2 0 1 0 947.2 512 435.71 435.71 0 0 0 512 76.8m0 819.2a384 384 0 1 1 384-384 384 384 0 0 1-384 384\" /><path d=\"M744.448 486.4h-204.8V281.6a25.6 25.6 0 1 0-51.2 0v204.8h-204.8a25.6 25.6 0 0 0 0 51.2h204.8v204.8a25.6 25.6 0 0 0 51.2 0V537.6h204.8a25.6 25.6 0 0 0 0-51.2\" /></svg>;\nexport default SvgZoomIn;","import * as React from \"react\";\nconst SvgZoomOut = props => <svg xmlns=\"http://www.w3.org/2000/svg\" width={128} height={128} className=\"icon\" viewBox=\"0 0 1024 1024\" {...props}><path d=\"M512 76.8A435.2 435.2 0 1 0 947.2 512 435.71 435.71 0 0 0 512 76.8m0 819.2a384 384 0 1 1 384-384 384 384 0 0 1-384 384\" /><path d=\"M744.448 486.4H280.064a25.6 25.6 0 1 0 0 51.2h464.384a25.6 25.6 0 0 0 0-51.2\" /></svg>;\nexport default SvgZoomOut;","import React, { useCallback, useMemo, useRef } from \"react\";\nimport { ConfigProvider, Slider, theme } from \"antd\";\nimport { StyleProvider, createCache } from \"@ant-design/cssinjs\";\nimport { useCurrentTheme } from \"@next-core/react-runtime\";\nimport type { RangeTuple } from \"../../diagram/interfaces\";\nimport CenterSVG from \"./icons/center.svg\";\nimport ZoomInSVG from \"./icons/zoom-in.svg\";\nimport ZoomOutSVG from \"./icons/zoom-out.svg\";\n\nexport interface ZoomBarComponentProps {\n shadowRoot: ShadowRoot;\n scale: number;\n scaleRange: RangeTuple;\n onZoomChange(value: number): void;\n onReCenter(): void;\n}\n\nexport function ZoomBarComponent({\n shadowRoot,\n scale,\n scaleRange,\n onZoomChange,\n onReCenter,\n}: ZoomBarComponentProps): JSX.Element | null {\n const currentTheme = useCurrentTheme();\n const cache = useMemo(() => createCache(), []);\n const zoomBarRef = useRef<HTMLDivElement | null>(null);\n const min = scaleRange[0] * 100;\n const max = scaleRange[1] * 100;\n const value = scale * 100;\n const step = 5;\n\n const tooltip = useMemo(() => {\n return {\n formatter: (value: number | undefined) => `${value}%`,\n placement: \"left\" as const,\n getPopupContainer: () => zoomBarRef.current!,\n };\n }, []);\n\n const onZoomIn = useCallback(() => {\n onZoomChange(Math.min(value + step, max));\n }, [max, onZoomChange, value]);\n\n const onZoomOut = useCallback(() => {\n onZoomChange(Math.max(value - step, min));\n }, [min, onZoomChange, value]);\n\n return (\n <ConfigProvider\n theme={{\n algorithm:\n currentTheme === \"dark-v2\"\n ? theme.darkAlgorithm\n : theme.defaultAlgorithm,\n }}\n >\n <StyleProvider\n container={shadowRoot}\n // Auto clear injected styles after unmount\n autoClear\n cache={cache}\n // Set hashPriority to \"high\" to disable `:where()` usage for compatibility\n hashPriority=\"high\"\n >\n <div className=\"zoom-bar\" ref={zoomBarRef}>\n <div className=\"center-button\" onClick={onReCenter} role=\"button\">\n <CenterSVG />\n </div>\n <div className=\"zoom-slider\">\n <div className=\"zoom-button\" role=\"button\" onClick={onZoomIn}>\n <ZoomInSVG />\n </div>\n <Slider\n min={min}\n max={max}\n value={value}\n step={step}\n vertical\n included={false}\n tooltip={tooltip}\n onChange={onZoomChange}\n />\n <div className=\"zoom-button\" role=\"button\" onClick={onZoomOut}>\n <ZoomOutSVG />\n </div>\n </div>\n </div>\n </StyleProvider>\n </ConfigProvider>\n );\n}\n","import { pick } from \"lodash\";\nimport type { ActiveTargetOfSingular, Cell } from \"../interfaces\";\n\nexport function cellToTarget(cell: Cell): ActiveTargetOfSingular {\n return cell.type === \"edge\"\n ? pick(cell, [\"type\", \"source\", \"target\", \"data\"])\n : pick(cell, [\"type\", \"id\", \"data\"]);\n}\n","import type { PositionTuple, TransformLiteral } from \"../../diagram/interfaces\";\nimport type { NodeView } from \"../interfaces\";\n\nexport interface HandleLassoOptions {\n transform: TransformLiteral;\n offset: PositionTuple;\n onLassoing(rect: NodeView): void;\n onLassoed(rect: NodeView): void;\n}\n\nexport function handleLasso(\n event: MouseEvent,\n { transform, offset, onLassoing, onLassoed }: HandleLassoOptions\n) {\n if (event.ctrlKey || event.button) {\n return;\n }\n\n event.stopPropagation();\n\n const from: PositionTuple = [event.clientX, event.clientY];\n const x0 = (event.clientX - offset[0] - transform.x) / transform.k;\n const y0 = (event.clientY - offset[1] - transform.y) / transform.k;\n\n function getMovement(e: MouseEvent): PositionTuple {\n return [\n (e.clientX - from[0]) / transform.k,\n (e.clientY - from[1]) / transform.k,\n ];\n }\n\n let moved = false;\n\n const handleMove = (e: MouseEvent, finished?: boolean) => {\n // Respect the scale\n const movement = getMovement(e);\n if (!moved) {\n moved = movement[0] ** 2 + movement[1] ** 2 >= 9;\n }\n if (moved) {\n let [width, height] = movement;\n let x = x0;\n let y = y0;\n if (width < 0) {\n x = x0 + width;\n width = -width;\n }\n if (height < 0) {\n y = y0 + height;\n height = -height;\n }\n (finished ? onLassoed : onLassoing)({\n x,\n y,\n width,\n height,\n });\n }\n };\n\n const onMouseMove = (e: MouseEvent) => {\n handleMove(e);\n };\n const onMouseUp = (e: MouseEvent) => {\n handleMove(e, true);\n moved = false;\n document.removeEventListener(\"mousemove\", onMouseMove);\n document.removeEventListener(\"mouseup\", onMouseUp);\n };\n document.addEventListener(\"mousemove\", onMouseMove);\n document.addEventListener(\"mouseup\", onMouseUp);\n}\n","import { pick } from \"lodash\";\nimport {\n forceCollide,\n forceLink,\n forceManyBody,\n forceSimulation,\n forceX,\n forceY,\n type Simulation,\n} from \"d3-force\";\nimport type {\n Cell,\n ForceCollideOptions,\n ForceLink,\n ForceNode,\n LayoutOptionsForce,\n NodeId,\n NodeView,\n} from \"../../draw-canvas/interfaces\";\nimport {\n isEdgeCell,\n isNodeCell,\n isNodeOrAreaDecoratorCell,\n} from \"../../draw-canvas/processors/asserts\";\nimport { extractPartialRectTuple } from \"../../diagram/processors/extractPartialRectTuple\";\nimport type { FullRectTuple, PositionTuple } from \"../../diagram/interfaces\";\n\nexport interface ForceLayoutOptions {\n cells: Cell[];\n layoutOptions?: LayoutOptionsForce;\n center?: PositionTuple;\n fixedPosition?: boolean;\n allowEdgeToArea?: boolean;\n}\n\nexport function forceLayout({\n cells,\n layoutOptions,\n center,\n fixedPosition,\n allowEdgeToArea,\n}: ForceLayoutOptions): {\n getNodeView: (id: NodeId) => NodeView;\n nodePaddings: FullRectTuple;\n} {\n const { nodePadding, collide } = {\n nodePadding: 0,\n ...pick(layoutOptions, [\"nodePadding\"]),\n collide:\n layoutOptions?.collide !== false\n ? ({\n radiusDiff: 18,\n strength: 1,\n iterations: 1,\n ...(layoutOptions?.collide === true\n ? null\n : (layoutOptions?.collide as ForceCollideOptions)),\n } as Required<ForceCollideOptions>)\n : (false as const),\n };\n const nodePaddings = extractPartialRectTuple(nodePadding);\n const forceNodes: ForceNode[] = [];\n const forceLinks: ForceLink[] = [];\n const nodesMap = new Map<NodeId, ForceNode>();\n for (const cell of cells) {\n if (\n (allowEdgeToArea && isNodeOrAreaDecoratorCell(cell)) ||\n isNodeCell(cell)\n ) {\n const node: ForceNode = {\n id: cell.id,\n width: cell.view.width + nodePaddings[1] + nodePaddings[3],\n height: cell.view.height + nodePaddings[0] + nodePaddings[2],\n ...(fixedPosition ? { fx: cell.view.x, fy: cell.view.y } : null),\n };\n forceNodes.push(node);\n nodesMap.set(node.id, node);\n } else if (isEdgeCell(cell)) {\n forceLinks.push({ source: cell.source, target: cell.target });\n }\n }\n\n const linkSimulation = forceLink<ForceNode, ForceLink>(forceLinks).id(\n (d) => d.id\n );\n const simulation = forceSimulation<ForceNode, ForceLink>(forceNodes)\n .force(\"link\", linkSimulation)\n .force(\"x\", forceX(center?.[0]))\n .force(\"y\", forceY(center?.[1]))\n .force(\"charge\", forceManyBody());\n\n if (collide) {\n simulation.force(\n \"collide\",\n forceCollide<ForceNode>()\n .radius(\n (d) =>\n Math.sqrt(d.width ** 2 + d.height ** 2) / 2 + collide.radiusDiff\n )\n .strength(collide.strength)\n .iterations(collide.iterations)\n );\n }\n\n simulation.stop();\n manuallyTickToTheEnd(simulation);\n\n return {\n getNodeView: (id: NodeId) => nodesMap.get(id) as NodeView,\n nodePaddings,\n };\n}\n\nfunction manuallyTickToTheEnd(\n simulation: Simulation<ForceNode, ForceLink>\n): void {\n // Manually tick to the end.\n simulation.tick(\n Math.ceil(\n Math.log(simulation.alphaMin()) / Math.log(1 - simulation.alphaDecay())\n )\n );\n}\n","import React, { useEffect, useMemo, useState } from \"react\";\nimport { select } from \"d3-selection\";\nimport { zoom, type ZoomBehavior } from \"d3-zoom\";\nimport type { RangeTuple, TransformLiteral } from \"../../diagram/interfaces\";\nimport {\n DEFAULT_SCALE_RANGE_MIN,\n DEFAULT_SCALE_RANGE_MAX,\n} from \"../../draw-canvas/constants\";\nimport type { ActiveTarget } from \"../../draw-canvas/interfaces\";\n\nexport interface UseZoomOptions {\n rootRef: React.RefObject<SVGSVGElement>;\n zoomable?: boolean;\n scrollable?: boolean;\n pannable?: boolean;\n draggable?: boolean;\n ctrlDraggable?: boolean;\n scaleRange?: RangeTuple;\n onSwitchActiveTarget?(target: ActiveTarget | null): void;\n}\n\nexport interface UseZoomResult {\n grabbing: boolean;\n transform: TransformLiteral;\n scaleRange: RangeTuple;\n zoomer: ZoomBehavior<SVGSVGElement, unknown>;\n}\n\n// istanbul ignore next\nconst isMac = /mac/i.test(\n (\n navigator as Navigator & {\n userAgentData?: {\n platform: string;\n };\n }\n ).userAgentData?.platform ??\n navigator.platform ??\n navigator.userAgent\n);\n\n// istanbul ignore next\nfunction wheelData(event: WheelEvent) {\n // On Windows with normal mouse, deltaY is too big when scroll with ctrlKey pressed,\n // which cause the zooming too fast.\n // While on mac OS, we need to keep default behavior of d3-zoom.\n return (\n -event.deltaY *\n (event.deltaMode === 1 ? 0.05 : event.deltaMode ? 1 : 0.002) *\n (event.ctrlKey && isMac ? 10 : 1)\n );\n}\n\nexport function useZoom({\n rootRef,\n zoomable,\n scrollable,\n pannable,\n draggable,\n ctrlDraggable,\n scaleRange: _scaleRange,\n onSwitchActiveTarget,\n}: UseZoomOptions): UseZoomResult {\n const [grabbing, setGrabbing] = useState(false);\n const [transform, setTransform] = useState<TransformLiteral>({\n k: 1,\n x: 0,\n y: 0,\n });\n\n const scaleRange = useMemo(\n () =>\n _scaleRange ??\n ([DEFAULT_SCALE_RANGE_MIN, DEFAULT_SCALE_RANGE_MAX] as RangeTuple),\n [_scaleRange]\n );\n\n const zoomer = useMemo(\n () => zoom<SVGSVGElement, unknown>().wheelDelta(wheelData),\n []\n );\n\n // istanbul ignore next: d3-zoom currently hard to test\n useEffect(() => {\n let moved = false;\n zoomer\n .scaleExtent(zoomable ? scaleRange : [1, 1])\n .on(\"start\", () => {\n moved = false;\n setGrabbing(true);\n })\n .on(\"zoom\", (e: { transform: TransformLiteral }) => {\n moved = true;\n setTransform(e.transform);\n })\n .on(\"end\", () => {\n setGrabbing(false);\n if (!moved) {\n onSwitchActiveTarget?.(null);\n }\n })\n .filter(\n (event) =>\n // For wheel event, ignore d3 default behavior, because we control it manually.\n // Except for the trackpad pinch event on Mac OS (with ctrlKey).\n (event.type === \"wheel\"\n ? event.ctrlKey\n : ctrlDraggable\n ? draggable || event.ctrlKey\n : !event.ctrlKey) && !event.button\n );\n }, [\n onSwitchActiveTarget,\n scaleRange,\n zoomable,\n zoomer,\n ctrlDraggable,\n draggable,\n ]);\n\n useEffect(() => {\n if (ctrlDraggable) {\n const onContextMenu = (e: MouseEvent) => {\n if (e.ctrlKey) {\n e.preventDefault();\n }\n };\n document.addEventListener(\"contextmenu\", onContextMenu, true);\n return () => {\n document.removeEventListener(\"contextmenu\", onContextMenu, true);\n };\n }\n }, [ctrlDraggable]);\n\n // istanbul ignore next: d3-zoom currently hard to test\n useEffect(() => {\n const root = rootRef.current;\n if (!root) {\n return;\n }\n\n const rootSelection = select(root);\n\n const unsetZoom = () => {\n rootSelection\n .on(\".zoom\", null)\n .on(\".zoom.custom\", null)\n .on(\"wheel\", null);\n };\n\n if (!(zoomable || scrollable || pannable)) {\n unsetZoom();\n return;\n }\n\n if (zoomable || scrollable) {\n // Do not override default d3 zoom handler.\n // Only handles *panning*\n rootSelection.on(\n \"wheel.zoom.custom\",\n (e: WheelEvent & { wheelDeltaX: number; wheelDeltaY: number }) => {\n // Mac OS trackpad pinch event is emitted as a wheel.zoom and d3.event.ctrlKey set to true\n if (!e.ctrlKey && scrollable) {\n e.preventDefault();\n zoomer.translateBy(\n rootSelection,\n e.wheelDeltaX / 5,\n e.wheelDeltaY / 5\n );\n }\n // zoomer.scaleBy(rootSelection, Math.pow(2, defaultWheelDelta(e)))\n }\n );\n }\n\n rootSelection\n .call(zoomer)\n .on(\"wheel\", (e: WheelEvent) => {\n if (scrollable || (zoomable && e.ctrlKey)) {\n e.preventDefault();\n }\n })\n .on(\"dblclick.zoom\", null);\n\n if ((!draggable && !ctrlDraggable) || !pannable) {\n rootSelection.on(\"mousedown.zoom\", null);\n }\n\n if (!pannable) {\n rootSelection\n .on(\"touchstart.zoom\", null)\n .on(\"touchmove.zoom\", null)\n .on(\"touchend.zoom\", null);\n }\n\n return unsetZoom;\n }, [\n ctrlDraggable,\n draggable,\n pannable,\n rootRef,\n scrollable,\n zoomable,\n zoomer,\n ]);\n\n return { grabbing, transform, zoomer, scaleRange };\n}\n","import { get, pick } from \"lodash\";\nimport dagre from \"@dagrejs/dagre\";\nimport { extractPartialRectTuple } from \"../../diagram/processors/extractPartialRectTuple\";\nimport type {\n Cell,\n ForceNode,\n LayoutOptionsDagre,\n NodeId,\n NodeView,\n} from \"../../draw-canvas/interfaces\";\nimport {\n isEdgeCell,\n isGroupDecoratorCell,\n isNodeCell,\n isNodeOrAreaDecoratorCell,\n} from \"../../draw-canvas/processors/asserts\";\nimport type { FullRectTuple } from \"../../diagram/interfaces\";\n\nexport interface DagreLayoutOptions {\n cells: Cell[];\n layoutOptions?: LayoutOptionsDagre;\n allowEdgeToArea?: boolean;\n}\n\nexport function dagreLayout({\n cells,\n layoutOptions,\n allowEdgeToArea,\n}: DagreLayoutOptions): {\n getNodeView: (id: NodeId) => NodeView;\n nodePaddings: FullRectTuple;\n} {\n const { nodePadding, ...dagreGraphOptions } = {\n nodePadding: 0,\n rankdir: \"TB\",\n ranksep: 50,\n edgesep: 10,\n nodesep: 50,\n // align: undefined,\n ...pick(layoutOptions, [\n \"nodePadding\",\n \"rankdir\",\n \"ranksep\",\n \"edgesep\",\n \"nodesep\",\n \"align\",\n ]),\n };\n const nodePaddings = extractPartialRectTuple(nodePadding);\n\n if (!cells.some(isNodeCell)) {\n // Dagre cannot render empty nodes\n return {\n getNodeView: () => null!,\n nodePaddings,\n };\n }\n\n const graph = new dagre.graphlib.Graph<ForceNode>();\n graph.setGraph(dagreGraphOptions);\n // Default to assigning a new object as a label for each new edge.\n graph.setDefaultEdgeLabel(function () {\n return {};\n });\n for (const cell of cells) {\n if (\n (allowEdgeToArea && isNodeOrAreaDecoratorCell(cell)) ||\n isNodeCell(cell) ||\n isGroupDecoratorCell(cell)\n ) {\n graph.setNode(cell.id, {\n id: cell.id,\n width: get(cell, \"view.width\", 0) + nodePaddings[1] + nodePaddings[3],\n height: get(cell, \"view.height\", 0) + nodePaddings[0] + nodePaddings[2],\n });\n } else if (isEdgeCell(cell)) {\n graph.setEdge(cell.source, cell.target);\n }\n }\n dagre.layout(graph);\n\n return {\n getNodeView: (id: NodeId) => graph.node(id),\n nodePaddings,\n };\n}\n","import { get, orderBy } from \"lodash\";\nimport {\n ActiveTarget,\n BaseNodeCell,\n Cell,\n DecoratorCell,\n InitialCell,\n NodeCell,\n} from \"../interfaces\";\nimport { LayoutOptions } from \"./initialContainerLayout\";\nimport {\n isEdgeCell,\n isGroupDecoratorCell,\n isNodeCell,\n isNoPoint,\n isNoSize,\n} from \"./asserts\";\nimport { dagreLayout } from \"../../shared/canvas/dagreLayout\";\nimport { staggeredLayout } from \"./staggeredLayout\";\nimport { computeBoundingBox } from \"./computeBoundingBox\";\nimport { CONTAINERGAP } from \"../constants\";\nexport const GROUPPADDING = 12;\n\nexport function initialGroupLayout(\n cells: InitialCell[],\n options: LayoutOptions = {}\n) {\n const groupMap: Record<string, Omit<Cell, \"DecoratorCell\">[]> = {};\n const decoratorCells = cells.filter(\n (c) => isGroupDecoratorCell(c) && isNoPoint(c.view)\n ) as DecoratorCell[];\n\n if (!decoratorCells.length) return { groupMap };\n const { nodeLayout = \"dagre\" } = options;\n const nodeCells = cells.filter((c) => c.type === \"node\") as NodeCell[];\n const edgeCells = cells.filter(isEdgeCell);\n\n // 预处理 decoratorCells,以便后续查找更高效\n const containerCellMap = new Map<string, DecoratorCell>();\n decoratorCells.forEach((cell) => {\n containerCellMap.set(cell.id, cell);\n });\n\n const groupNameMap: Record<string, Set<string>> = {};\n\n // 分组节点并构建 groupNameMap\n nodeCells.forEach((node) => {\n const { groupId } = node;\n if (groupId) {\n if (!groupMap[groupId]) {\n groupMap[groupId] = [];\n groupNameMap[groupId] = new Set();\n }\n groupMap[groupId].push(node);\n groupNameMap[groupId].add(node.id);\n }\n });\n\n // 把边加入所属组\n edgeCells.forEach((edge) => {\n for (const [groupId, idSet] of Object.entries(groupNameMap)) {\n if (idSet.has(edge.source) && idSet.has(edge.target)) {\n groupMap[groupId].push(edge);\n break;\n }\n }\n });\n\n const containerGap = 0;\n // 排序组层级,level越大越后面;没有大小都排后面\n const sortedGroupIds = orderBy(\n decoratorCells.filter((cell) => groupMap[cell.id]),\n [(o) => (isNoSize(o.view) ? 1 : 0), (o) => get(o, \"view.level\", 1)],\n [\"asc\", \"asc\"]\n ).map((cell) => cell.id);\n processSortedGroups(\n sortedGroupIds,\n groupMap,\n containerCellMap,\n nodeLayout,\n containerGap\n );\n return { groupMap };\n}\n\nfunction processSortedGroups(\n sortedGroupIds: string[],\n containerGroup: Record<string, Omit<Cell, \"DecoratorCell\">[]>,\n containerCellMap: Map<string, DecoratorCell>,\n nodeLayout: string,\n containerGap: number\n) {\n let currentContainerGap = containerGap;\n sortedGroupIds.forEach((groupId) => {\n const groupCell = containerCellMap.get(groupId)!;\n const groupedCells = containerGroup[groupId] as Cell[];\n const nodeCells = groupedCells.filter(\n (cell) => cell.type === \"node\"\n ) as NodeCell[];\n\n currentContainerGap += +(GROUPPADDING + CONTAINERGAP * 2); //加上容器的间距,分组间距后面会在initialContainerLayout调整减掉一个GROUPPADDING\n\n let nodeViews: (NodeCell | DecoratorCell)[] = [];\n if (nodeLayout === \"dagre\") {\n const { getNodeView } = dagreLayout({ cells: nodeCells });\n nodeViews = nodeCells.map((node: NodeCell) => {\n if (isNoPoint(node.view)) {\n const view = getNodeView(node.id);\n node.view = {\n ...node.view,\n x: view.x,\n y: view.y + currentContainerGap,\n width: view.width,\n height: view.height,\n };\n }\n return node;\n });\n } else if (nodeLayout === \"staggered\") {\n nodeViews = staggeredLayout(nodeCells, {\n offsetY: currentContainerGap,\n });\n }\n\n const containerRect = computeBoundingBox(nodeViews as BaseNodeCell[], {\n padding: GROUPPADDING,\n });\n groupCell.view = { ...groupCell.view, ...containerRect };\n currentContainerGap += get(containerRect, \"height\", 0) + CONTAINERGAP;\n });\n return {\n updatedGap: currentContainerGap,\n };\n}\n\nexport function highlightGroupCell(\n cell: DecoratorCell,\n activeTarget: ActiveTarget | null | undefined,\n cells: Cell[]\n) {\n let activeTargetCells = [],\n active = false;\n // istanbul ignore next\n if (activeTarget?.type === \"multi\") {\n activeTargetCells = activeTarget.targets;\n } else if (activeTarget?.type === \"node\") {\n activeTargetCells.push(activeTarget);\n } else if (activeTarget?.type === \"decorator\") {\n active = activeTarget.id === cell.id;\n return active;\n }\n active = activeTargetCells.some(\n (item) =>\n item?.type === \"node\" &&\n (cells.find((c) => isNodeCell(c) && c.id === item.id) as NodeCell)\n ?.groupId === cell.id\n );\n return active;\n}\n","import { forEach, get, groupBy, isNil, orderBy } from \"lodash\";\nimport type {\n BaseNodeCell,\n Cell,\n DecoratorCell,\n InitialCell,\n NodeCell,\n} from \"../interfaces\";\nimport {\n isContainerDecoratorCell,\n isEdgeCell,\n isGroupDecoratorCell,\n isNoPoint,\n isNoSize,\n} from \"./asserts\";\nimport { dagreLayout } from \"../../shared/canvas/dagreLayout\";\nimport { computeBoundingBox } from \"./computeBoundingBox\";\nimport {\n CONTAINERGAP,\n DEFAULT_AREA_HEIGHT,\n DEFAULT_AREA_WIDTH,\n} from \"../constants\";\nimport { staggeredLayout } from \"./staggeredLayout\";\nimport { GROUPPADDING, initialGroupLayout } from \"./initialGroupLayout\";\nexport interface LayoutOptions {\n nodeLayout?: \"staggered\" | \"dagre\";\n}\n\n/**\n * 初始化容器内节点层次布局以及同步容器大小位置\n * @param cells\n */\nexport function initialContainerLayout(\n cells: InitialCell[],\n options: LayoutOptions = {}\n) {\n const { groupMap } = initialGroupLayout(cells, options);\n const nodeCells = cells.filter(\n (c) => c.type === \"node\" && !isNil(c.containerId)\n ) as NodeCell[];\n const groupCells = cells.filter(\n (c) =>\n c.type === \"decorator\" && c.decorator === \"group\" && !isNil(c.containerId)\n ) as DecoratorCell[];\n if (!nodeCells.length && !groupCells.length) return;\n\n const { nodeLayout = \"dagre\" } = options;\n\n const edgeCells = cells.filter(isEdgeCell);\n const containerCells = cells.filter((c) =>\n isContainerDecoratorCell(c)\n ) as DecoratorCell[];\n\n // 预处理 decoratorCells,以便后续查找更高效\n const containerCellMap = new Map<string, DecoratorCell>();\n let containerGap = 0,\n maxContainerWidth = 0;\n\n containerCells.forEach((cell) => {\n containerCellMap.set(cell.id, cell);\n });\n\n const containerGroup: Record<string, Omit<Cell, \"DecoratorCell\">[]> = {};\n const groupNameMap: Record<string, Set<string>> = {};\n\n forEach(\n groupBy([...nodeCells, ...groupCells], \"containerId\"),\n (groupedNodes, containerId) => {\n containerGroup[containerId] = groupedNodes;\n groupNameMap[containerId] = new Set(groupedNodes.map((node) => node.id));\n }\n );\n\n // 把边加入所属容器组\n edgeCells.forEach((edge) => {\n for (const [groupId, idSet] of Object.entries(groupNameMap)) {\n if (idSet.has(edge.source) && idSet.has(edge.target)) {\n containerGroup[groupId].push(edge);\n break;\n }\n }\n });\n\n const uniformWidthContainers: DecoratorCell[] = [];\n\n // 排序容器层级,level越大越后面;没有大小都排后面\n const sortedContainerIds = orderBy(\n containerCells.filter((cell) => containerGroup[cell.id]),\n [(o) => (isNoSize(o.view) ? 1 : 0), (o) => get(o, \"view.level\", 1)],\n [\"asc\", \"asc\"]\n ).map((cell) => cell.id);\n const { updatedGap, updatedMaxWidth } = processSortedContainers(\n sortedContainerIds,\n containerGroup,\n containerCellMap,\n nodeLayout,\n containerGap,\n uniformWidthContainers,\n maxContainerWidth,\n {\n groupCells,\n groupMap,\n }\n );\n\n containerGap = updatedGap;\n maxContainerWidth = updatedMaxWidth;\n\n // 统一容器宽度\n uniformWidthContainers.forEach((container) => {\n container.view.width = Math.max(DEFAULT_AREA_WIDTH, maxContainerWidth);\n });\n}\n\nfunction processSortedContainers(\n sortedContainerIds: string[],\n containerGroup: Record<string, Omit<Cell, \"DecoratorCell\">[]>,\n containerCellMap: Map<string, DecoratorCell>,\n nodeLayout: string,\n containerGap: number,\n uniformWidthContainers: DecoratorCell[],\n maxContainerWidth: number,\n decoratorGroup: {\n groupCells: DecoratorCell[];\n groupMap: Record<string, Omit<Cell, \"DecoratorCell\">[]>;\n }\n) {\n let currentContainerGap = containerGap;\n let currentMaxContainerWidth = maxContainerWidth;\n\n sortedContainerIds.forEach((groupId) => {\n const containerCell = containerCellMap.get(groupId)!;\n const groupedNodes = containerGroup[groupId] as Cell[];\n\n const isVertical = [\"top\", \"bottom\"].includes(\n get(containerCell, \"view.direction\", \"top\")\n );\n if (isVertical) currentContainerGap += CONTAINERGAP;\n const nodeCells = groupedNodes.filter(\n (cell) => cell.type === \"node\"\n ) as NodeCell[];\n const decoratorGroups = get(decoratorGroup, \"groupCells\", []).filter(\n (g) => g.containerId === groupId\n ) as DecoratorCell[];\n\n let nodeViews: (NodeCell | DecoratorCell)[] = [];\n if (nodeLayout === \"dagre\") {\n const { getNodeView } = dagreLayout({\n cells: [...groupedNodes, ...decoratorGroups],\n });\n nodeViews = [...nodeCells, ...decoratorGroups].map((cell) => {\n if (isNoPoint(cell.view) || isGroupDecoratorCell(cell)) {\n const view = getNodeView(cell.id);\n cell.view = {\n ...cell.view,\n x: view.x,\n y: view.y + currentContainerGap,\n width: view.width,\n height: view.height,\n };\n }\n return cell;\n });\n } else if (nodeLayout === \"staggered\") {\n nodeViews = staggeredLayout([...nodeCells, ...decoratorGroups], {\n offsetY: currentContainerGap,\n });\n }\n let containerHeight = 0,\n containerWidth = 0;\n if (isNoSize(containerCell.view)) {\n const containerRect = computeBoundingBox(nodeViews as BaseNodeCell[]);\n containerHeight = get(containerRect, \"height\", DEFAULT_AREA_HEIGHT);\n containerWidth = get(containerRect, \"width\", DEFAULT_AREA_WIDTH);\n containerCell.view = { ...containerCell.view, ...containerRect };\n uniformWidthContainers.push(containerCell);\n } else {\n containerHeight = get(containerCell, \"view.height\");\n containerWidth = get(containerCell, \"view.width\");\n }\n\n /**\n * 计算好容器位置在重新设置组内节点x,y\n */\n if (decoratorGroups.length > 0) {\n const groupMap = get(decoratorGroup, \"groupMap\", {});\n decoratorGroups.forEach((group) => {\n const groupId = group.id;\n const { x: groupX, y: groupY } = group.view;\n const nodeCells: NodeCell[] = get(groupMap, groupId, []);\n\n if (!nodeCells.length) return;\n\n // 记录第一个节点的基准坐标\n const baseX = nodeCells[0].view.x;\n const baseY = nodeCells[0].view.y;\n\n nodeCells.forEach((node: NodeCell) => {\n node.view = {\n ...node.view,\n x: groupX + (node.view?.x - baseX),\n y: groupY + (node.view?.y - baseY),\n };\n });\n\n group.view = {\n ...group.view,\n x: groupX - GROUPPADDING,\n y: groupY - GROUPPADDING,\n };\n });\n }\n\n currentMaxContainerWidth = Math.max(\n containerWidth,\n currentMaxContainerWidth\n );\n currentContainerGap += containerHeight + CONTAINERGAP;\n });\n\n return {\n updatedGap: currentContainerGap,\n updatedMaxWidth: currentMaxContainerWidth,\n };\n}\n","import type { NodePosition } from \"../../../diagram/interfaces\";\nimport type { NodeConnectPoint } from \"../../../draw-canvas/interfaces\";\n\n// *--*--*--*--*\n// | |\n// * *\n// | |\n// * Rect *\n// | |\n// * *\n// | |\n// *--*--*--*--*\nconst RectangleRelativeConnectPointsWithDirection: ReadonlyArray<NodeConnectPoint> =\n [\n {\n x: 0,\n y: 0,\n d: [\"top\", \"left\"],\n },\n { x: 0.5, y: 0, d: [\"top\"] },\n {\n x: 1,\n y: 0,\n d: [\"top\", \"right\"],\n },\n { x: 0, y: 0.5, d: [\"left\"] },\n { x: 1, y: 0.5, d: [\"right\"] },\n {\n x: 0,\n y: 1,\n d: [\"bottom\", \"left\"],\n },\n { x: 0.5, y: 1, d: [\"bottom\"] },\n {\n x: 1,\n y: 1,\n d: [\"bottom\", \"right\"],\n },\n ];\n\nconst RectangleRelativeConnectPoints: ReadonlyArray<NodePosition> =\n RectangleRelativeConnectPointsWithDirection.map((p) => ({ x: p.x, y: p.y }));\n\nexport function getConnectPointsOfRectangleWithDirection() {\n return RectangleRelativeConnectPointsWithDirection;\n}\n\nexport function getConnectPointsOfRectangle() {\n return RectangleRelativeConnectPoints;\n}\n","import type {\n FullRectTuple,\n TransformLiteral,\n} from \"../../../diagram/interfaces\";\nimport type { CellsRect } from \"../../../draw-canvas/interfaces\";\n\nexport interface TransformToCenterOptions {\n canvasWidth: number;\n canvasHeight: number;\n canvasPadding?: FullRectTuple | null;\n scaleRange?: [min: number, max: number];\n}\n\nexport function getTransformToCenter(\n rect: CellsRect,\n {\n canvasWidth,\n canvasHeight,\n canvasPadding,\n scaleRange,\n }: TransformToCenterOptions\n): TransformLiteral {\n const { left, top, width, height, empty } = rect;\n\n // Apply padding to available canvas dimensions\n const [paddingTop, paddingRight, paddingBottom, paddingLeft] =\n canvasPadding ?? [0, 0, 0, 0];\n const availableWidth = canvasWidth - paddingLeft - paddingRight;\n const availableHeight = canvasHeight - paddingTop - paddingBottom;\n\n const scale =\n scaleRange && !empty && (width > availableWidth || height > availableHeight)\n ? Math.max(\n Math.min(\n availableWidth / width,\n availableHeight / height,\n scaleRange[1]\n ),\n scaleRange[0]\n )\n : 1;\n\n // Adjust center calculation to account for padding\n const x = empty\n ? 0\n : (availableWidth - width * scale) / 2 + paddingLeft - left * scale;\n const y = empty\n ? 0\n : (availableHeight - height * scale) / 2 + paddingTop - top * scale;\n\n return { x, y, k: scale };\n}\n"],"names":["nodeViewToNodeRect","view","padding","x","width","y","height","DEFAULT_DIRECTIONS","getSmartLinePoints","sourceView","targetView","lineView","parallelGap","cellType","_connectPoints$find$d","_connectPoints$find","_connectPoints$find$d2","_connectPoints$find2","_sourceDirections$","_targetDirections$","type","vertices","exitPosition","originalExit","entryPosition","originalEntry","isStraightType","getDirectLinePoints","DEFAULT_NODE_PADDING_FOR_SMART_LINES","DEFAULT_NODE_PADDING_FOR_LINES","length","firstVertex","lastVertex","exitPoint","entryPoint","exitDirection","entryDirection","getAbsolutePosition","possibleFirstNextPoint","getDefaultAbsolutePosition","prefer","point","direction","fitEndpointAndDirection","possibleLastPreviousPoint","slice","reverse","sourceX","sourceY","targetX","targetY","newLinePoints","newVertices","unshift","push","simplifyVertices","getDefaultPosition","connectPoints","getConnectPointsOfRectangleWithDirection","originalSourceDirections","find","p","d","originalTargetDirections","sourceDirections","targetDirections","pull","sourceDirection","targetDirection","sourcePosition","targetPosition","getPolyLinePoints","simplifiedVertices","prevDirection","prev","index","vertex","isHorizontal","isVertical","next","isHorizontalNext","isVerticalNext","position","halfPadding","flip","xAxis","yAxis","xSize","ySize","xPosition","oppositeView","nsDirection","ewDirection","_vertices$","nextVertex","getUnrelatedCells","cells","connectLineState","activeTarget","allowEdgeToArea","unrelated","existedTargets","Set","cell","source","id","add","target","has","decorator","nodesMap","Map","activeNodeIds","relatedNodeIds","active","targets","set","targetIsActive","useActiveTarget","_ref","rootRef","_activeTarget","doNotResetActiveTargetForSelector","doNotResetActiveTargetOutsideCanvas","onActiveTargetChange","newActiveTarget","setActiveTarget","useState","useEffect","previous","sameTarget","activeTargetChangeInitialized","useRef","current","resetActiveTarget","e","path","composedPath","rootIndex","indexOf","some","el","Element","matches","document","addEventListener","removeEventListener","a","b","every","targetA","targetB","DEFAULT_CELL_ORDERS","decorators","insertCell","newCell","insertCells","newCells","findIndex","order","matchCellOrder","console","warn","targetIndex","findLastIndex","includes","rootReducer","reducers","state","action","payload","existedEdgeIndex","existedDecoratorIndex","matched","newState","map","move","pick","node","isNodeCell","SYMBOL_FOR_SIZE_INITIALIZED","size","layoutKey","Object","fromEntries","entries","key","value","LineLabelComponent","edge","offset","label","text","onRendered","onClick","ready","React","className","classNames","LineLabelUseBrickComponent","LineLabelTextComponent","_ref2","refCallback","useCallback","element","ref","style","content","_ref3","useBrick","useMemo","checkIfOfComputed","memoizedData","setTimeout","parentElement","ignoredCallback","ReactUseBrick","data","EdgeComponent","_editableLineMap$get","_motion","_motion2","_lineConf$overrides3","_lineConf$overrides4","_lineConf$animate$dur","_lineConf$overrides5","lineConfMap","editableLineMap","readOnly","activeRelated","onSwitchActiveTarget","pathRef","lineConf","get","points","linePoints","jumpsMap","line","curveLine","curveType","lineClipPathPrefix","uniqueId","labelPosition","setLabelPosition","labelSize","setLabelSize","lineRect","setLineRect","updateLabelPosition","placement","pathLength","getTotalLength","halfPathLength","pathPoint","getPointAtLength","angle","p0","p1","Math","atan2","abs","rect","getBBox","setPathLength","pathRefCallback","_element$getTotalLeng","_element$getTotalLeng2","_element$getBBox","call","labelElement","setLabelElement","resizeObserver","ResizeObserver","observerCallback","offsetWidth","offsetHeight","observe","disconnect","handleLabelRendered","onLabelClick","cellToTarget","onDoubleClick","_labelElement$firstEl","_labelElement$firstEl2","callLabelOnDoubleClick","preventDefault","stopPropagation","firstElementChild","mask","labelOffset","left","top","offsetX","offsetY","halfWidth","halfHeight","cos","tan","sin","getLabelMaskAndOffset","clipPathPoints","right","bottom","maskRight","maskBottom","join","markerStart","markerEnd","strokeColor","strokeWidth","motion","lineMarkers","getMarkers","_lineConf$overrides","_overrides$strokeColo","_overrides$strokeWidt","overrides","marker","_lineConf$$activeMark","_lineConf$$activeMark2","$activeMarkerStartUrl","$markerStartUrl","$activeMarkerEndUrl","$markerEndUrl","_lineConf$overrides2","_overrides$strokeColo2","_overrides$strokeWidt2","_lineConf$$activeRela","_lineConf$$activeRela2","$activeRelatedMarkerStartUrl","$activeRelatedMarkerEndUrl","motionPath","motionDuration","shape","radius","sqrt","_motion$speed","_motion3","speed","DEFAULT_MOTION_SPEED","hasMotion","item","clipPathUrl","undefined","fill","stroke","interactStrokeWidth","clipPath","dashed","dotted","animate","useAnimate","duration","DEFAULT_LINE_INTERACT_ANIMATE_DURATION","visible","dur","repeatCount","rotate","LockIcon","transform","NodeComponent","_useMemo","degraded","degradedNodeLabel","defaultNodeBricks","locked","containerLocked","groupLocked","onResize","memoizedValue","setMemoizedValue","isEqual","useDeepMemo","specifiedUseBrick","specifiedComponent","component","observerRef","Component","checkIfByTransform","String","__secret_internals","legacyDoTransform","brickRef","xRef","yRef","prevObserver","observer","degradedRefCallBack","g","foreignObjectRef","fo","test","navigator","userAgent","overflow","timeoutId","clearTimeout","_extends","cx","cy","r","Boolean","DEFAULT_ALL_POSITIONS","getSnapPositions","positions","snapPositions","_positions$split$flat","_positions$split","split","flatMap","pos","tuple","Error","HORIZONTAL_POSITIONS","VERTICAL_POSITIONS","handleMouseDown","event","_snap$object","scale","layout","layoutOptions","onCellsMoving","onCellsMoved","onCellResizing","onCellResized","updateCurActiveEditableLine","button","ctrlKey","preActive","lockedContainerIds","getLockedContainerIds","canUpdateActiveEditableLine","shiftKey","activeTargets","filter","isLocked","isEdgeCell","isLineDecoratorCell","activeCells","actives","c","forEach","isContainerDecoratorCell","groupIds","isGroupDecoratorCell","containerId","nodeCells","groupId","isAutoLayout","movableActiveCells","isDecoratorCell","snap","_snapToGrid$size","_snapToObject$distanc","_snapToObject$positio","intermediateSnap","grid","object","snapToGrid","snapToObject","DEFAULT_SNAP_GRID_SIZE","distance","DEFAULT_SNAP_OBJECT_DISTANCE","DEFAULT_SNAP_OBJECT_POSITIONS","normalizeSnapOptions","snapToObjectPositions","from","clientX","clientY","originals","firstOriginalPosition","snapToObjectTargets","objectCells","moved","handleMove","finished","movement","getMovement","snapMovement","newPositions","xAlign","yAlign","xAlignCell","yAlignCell","altKey","diffX","Infinity","diffY","snapToObjectDistance","xAlignFrom","yAlignFrom","xAlignTarget","yAlignTarget","xAlignToY","yAlignToX","targetPositions","originalPositions","originalPoint","horizontal","vertical","dX","dY","snapToGridSize","firstNewPosition","round","snapToGridMovement","snapToGridDiffX","snapToGridDiffY","_ref5","payloads","_ref4","_c$view$vertices","guideLines","v","_ref6","onMouseMove","onMouseUp","_supports","getContentEditable","editable","div","createElement","setAttribute","contentEditable","supportsContentEditablePlaintextOnly","selectAllText","range","createRange","selectNodeContents","selection","window","getSelection","removeAllRanges","addRange","decoratorComponents","_cell$view","onDecoratorGroupPlusClick","highlightGroupCell","usePlus","PlusOutlined","onDecoratorTextEditing","onDecoratorTextChange","textRef","resizeHandleRef","editingLabel","setEditingLabel","currentLabel","setCurrentLabel","shouldEmitLabelChange","setShouldEmitLabelChange","recomputation","setRecomputation","titleForeignRect","setTitleForeignRect","shouldHighlight","activeTargetCells","containerLeft","containerRight","containerTop","containerBottom","targetCell","handleEnableEdit","handleInput","textContent","handleBlur","uuidV4","_textRef$current","clientWidth","clientHeight","focus","editing","resizeHandle","onMouseDown","k","titleStyle","onInput","onBlur","isNoManualLayout","_cell$view$text","editingLabelInitialized","_ref$current","lockedPosition","lastPoint","firstPoint","dy","dx","useEndPoint","point1","point2","twistedAngle","PI","getLineLockIconPosition","DecoratorComponent","SpecifiedComponent","error","CellComponent","_cell$view2","dragoverContainer","hoverCell","unrelatedCells","curActiveEditableLine","onCellContextMenu","onCellClick","onNodeBrickResize","onCellMouseEnter","onCellMouseLeave","lineEditorState","smartConnectLineState","setSmartConnectLineState","onConnect","setLineEditorState","onChangeEdgeView","useHoverStateContext","gRef","containerRect","containCells","computeBoundingBox","nodeViews","GROUPPADDING","isEdgeSide","isEntry","handleContextMenu","handleCellClick","handleMouseEnter","handleMouseLeave","faded","onContextMenu","onMouseEnter","onMouseLeave","SmartConnectLineComponent","lineSettings","options","connectLineTo","setConnectLineTo","hoverState","reset","activePointIndex","relativePoints","x1","y1","getConnectLinePoints","connecting","handleKeyboard","lockedIds","keyCode","which","useLineMarkers","defaultEdgeLines","markerPrefix","lineConnector","useMemoizedResult","memoizedResult","markers","DEFAULT_LINE_STROKE_COLOR","markerType","lineConnectorConf","getDefaultLineConf","editingStrokeColor","omitBy","isUndefined","_type","markerIndex","addMarker","editingMarkerIndex","$editingStartMarkerUrl","$editingEndMarkerUrl","WeakMap","isEdge","isLineDecorator","_secret_internals$le","computedLineConf","Array","isArray","transformLineConf","showEndArrow","DEFAULT_DECORATOR_LINE_STROKE_COLOR","activeStrokeColor","activeMarkerIndex","activeRelatedStrokeColor","activeRelatedMarkerIndex","_lineConf$label","restLabel","restConf","computedRestConf","showStartArrow","DEFAULT_LINE_STROKE_WIDTH","DEFAULT_LINE_INTERACT_STROKE_WIDTH","DEFAULT_LINE_INTERACT_SHOW_START_ARROW","DEFAULT_LINE_INTERACT_SHOW_END_ARROW","jumps","getNewLineVertices","activeEditableLine","control","i","LOOSE_CONTROL_TYPES","EditingLineComponent","onChangeDecoratorView","movedRef","getConnectTo","diff","otherPoints","axises","getFinalPosition","movementX","movementY","_","endpoint","editableLine","axis","newDiff","newConnectTo","_view$vertices","splice","handleBodyClick","body","isEditableEdgeLine","getEditingLinePoints","initializeCells","initialCells","defaultNodeSize","isInitialize","originalCells","initialContainerLayout","nodeLayout","isInitialNodeCell","KeywordMap","normalizeAlignAxis","newX","match","Number","useLayout","autoSize","zoomable","zoomer","scaleRange","autoCenterWhenCellsChange","dispatch","layoutInitialized","setLayoutInitialized","layoutKeyRef","getNextLayoutKey","centered","setCentered","root","getCellsRect","fitWidth","fitHeight","fullPadding","extractPartialRectTuple","DEFAULT_CANVAS_PADDING","_autoSize$minWidth","_autoSize$maxWidth","_autoSize$minHeight","_autoSize$maxHeight","min","max","minWidth","maxWidth","minHeight","maxHeight","getTransformToCenter","canvasWidth","canvasHeight","canvasPadding","select","ZoomTransform","useAutoCenter","previousLayoutRef","isNodeOrEdgeCell","getNodeView","nodePaddings","forceLayout","dagreLayout","alignOrigin","origin","normalizeAlignOrigin","isNodeOrAreaDecoratorCell","nodeView","SYMBOL_FOR_LAYOUT_INITIALIZED","toggleLock","previousLocked","previousUnlocked","updates","update","useReady","lockeds","_cell$view3","___CSS_LOADER_EXPORT___","module","toString","HELPER_IMAGE","HELPER_RADIUS","HELPER_BG_RADIUS","HALF_HELPER_RADIUS","LineConnectorComponent","disabled","unsetHoverStateTimeoutRef","setHoverState","unsetTimeout","unsetActivePointIndex","unsetHoverState","available","hasActiveEdge","pointerEvents","fillOpacity","ConnectPointComponent","getBoundingClientRect","handleMouseUp","xlinkHref","preserveAspectRatio","Symbol","for","DEFAULT_NODE_SIZE","DEFAULT_NODE_GAP_H","DEFAULT_NODE_GAP_V","DEFAULT_AREA_WIDTH","DEFAULT_AREA_HEIGHT","DEFAULT_SCALE_RANGE_MIN","DEFAULT_SCALE_RANGE_MAX","DEFAULT_DEGRADED_THRESHOLD","CONTAINERGAP","MAXPERROW","rects","empty","mergeRects","handleNodeContainedChange","onContainerContainerChange","nodeAndGroupCells","containerIds","cellPayloads","includeNodeFlag","containerDecoratorCells","containerCell","containedChanges","_payload$containerCel","HoverStateContext","activeEditableLines","isNoSize","isNoPoint","isNil","findNodeOrAreaDecorator","LINE_JUMP_BASE_SIZE","lineJumpIntersect","p2","p3","p4","intersect","r2","useEditableLineMap","collectLineJumps","allJumps","allLineSegments","lineJumps","lineSegments","start","end","jumpPoints","jumpLoop","jump","pow","segJumps","sortBy","j","collectLineJumpsFactory","sourceNode","targetNode","_c$view","POINT_HELPER_IMAGE","END_POINT_HELPER_IMAGE","ANCHORED_POINT_HELPER_IMAGE","VERTEX_HELPER_IMAGE","POINT_HELPER_BG_SIZE","LineEditorComponent","movingCells","exitRef","entryRef","controlPointsRef","exit","entry","handleMouseDownFactory","handleStartMouseDown","handleEndMouseDown","controlPoints","_activeEditableLine$v","cursor","getStraightControlPoints","ns","ew","getControlPoints","controlElements","handlers","commonProps","opacity","staggeredLayout","nodes","arguments","gapX","gapY","maxPerRow","fullRowCount","shortRowCount","layoutedNodes","row","preRowOffsetY","isOddRow","nodesInRow","nodeX","maxNodeHeight","nodeWidth","nodeHeight","minX","minY","maxX","maxY","n","isFinite","computeNodePoints","containerView","existingPoints","gap","stepX","stepY","cols","floor","col","isOverlapping","w1","h1","x2","y2","w2","h2","cx1","cy1","cx2","cy2","minDistX","minDistY","updateCells","previousCells","reason","parent","parentNode","isManualLayout","updateCandidates","shouldReCenter","prevSizeNodes","prevShouldCentered","prevNode","assign","handled","parentNodeCell","adjacency","queue","parentId","shift","baseX","baseY","ceil","cid","layoutRelatedNodes","positioned","hasDecorators","transformToCenter","without","fixedPosition","center","containerAndGroupCells","newContainerChildCells","newGroupChildCells","groupMap","groupBy","groupedNodes","group","newNodes","groupView","_node$view","_node$view2","newPoint","containerGroup","container","_node$view3","_node$view4","generateNewPointsWithLayout","updated","ConnectLineComponent","capture","props","xmlns","viewBox","ZoomBarComponent","shadowRoot","onZoomChange","onReCenter","currentTheme","useCurrentTheme","cache","createCache","zoomBarRef","tooltip","formatter","getPopupContainer","onZoomIn","onZoomOut","ConfigProvider","theme","algorithm","darkAlgorithm","defaultAlgorithm","StyleProvider","autoClear","hashPriority","role","CenterSVG","ZoomInSVG","Slider","step","included","onChange","ZoomOutSVG","handleLasso","onLassoing","onLassoed","x0","y0","nodePadding","collide","radiusDiff","strength","iterations","forceNodes","forceLinks","fx","fy","linkSimulation","forceLink","simulation","forceSimulation","force","forceX","forceY","forceManyBody","forceCollide","stop","tick","log","alphaMin","alphaDecay","manuallyTickToTheEnd","isMac","_userAgentData$platfo","_userAgentData","userAgentData","platform","wheelData","deltaY","deltaMode","useZoom","scrollable","pannable","draggable","ctrlDraggable","_scaleRange","grabbing","setGrabbing","setTransform","zoom","wheelDelta","scaleExtent","on","rootSelection","unsetZoom","translateBy","wheelDeltaX","wheelDeltaY","dagreGraphOptions","rankdir","ranksep","edgesep","nodesep","graph","dagre","Graph","setGraph","setDefaultEdgeLabel","setNode","setEdge","initialGroupLayout","decoratorCells","edgeCells","containerCellMap","groupNameMap","idSet","sortedGroupIds","currentContainerGap","groupCell","processSortedGroups","orderBy","o","_cells$find","groupCells","containerCells","containerGap","maxContainerWidth","uniformWidthContainers","sortedContainerIds","updatedGap","updatedMaxWidth","decoratorGroup","currentMaxContainerWidth","decoratorGroups","containerHeight","containerWidth","groupX","groupY","processSortedContainers","RectangleRelativeConnectPointsWithDirection","RectangleRelativeConnectPoints","getConnectPointsOfRectangle","paddingTop","paddingRight","paddingBottom","paddingLeft","availableWidth","availableHeight"],"sourceRoot":""}
1
+ {"version":3,"file":"chunks/3746.591c50d8.js","mappings":"kMAGO,SAASA,EAAmBC,EAAgBC,GACjD,MAAO,CACLC,EAAGF,EAAKE,EAAIF,EAAKG,MAAQ,EACzBC,EAAGJ,EAAKI,EAAIJ,EAAKK,OAAS,EAC1BF,MAAOH,EAAKG,MAAQF,EACpBI,OAAQL,EAAKK,OAASJ,EAE1B,C,iCCOA,MAAMK,EAAqB,CAAC,QAAS,MAAO,OAAQ,UAE7C,SAASC,EACdC,EACAC,EACAC,EACAC,EAEAC,GACuB,IAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EACvB,MAAM,KACJC,EAAI,SACJC,EACAC,aAAcC,EACdC,cAAeC,GACbd,QAAAA,EAAY,CAAC,EAEjB,IAAIe,EAAAA,EAAAA,IAAeN,GACjB,MAAiB,cAAbP,EACK,CACL,CAAEV,EAAGM,EAAWN,EAAGE,EAAGI,EAAWJ,MAC7BgB,QAAAA,EAAY,GAChB,CAAElB,EAAGO,EAAWP,EAAGE,EAAGK,EAAWL,KAI9BsB,EAAAA,EAAAA,GACL3B,EACES,EACAc,EACIK,EAAAA,GACAC,EAAAA,IAEN7B,EACEU,EACAe,EACIG,EAAAA,GACAC,EAAAA,IAENjB,EACAD,GAIJ,GAAIU,SAAAA,EAAUS,OAAQ,CACpB,MAAMC,EAA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AASE,IACd,OAAOD,CACT,C,iBCpCO,SAASrW,EACdnf,EAAe9I,GAOG,IANlB,YACEkoB,EAAW,aACXC,EAAY,cACZC,EAAa,WACb7B,GACyBvmB,EAE3B,MAAM,KAAE2K,EAAI,IAAEC,EAAG,MAAE/R,EAAK,OAAEE,EAAM,MAAEizB,GAAUljB,GAGrC01B,EAAYC,EAAcC,EAAeC,GAC9CvW,QAAAA,EAAiB,CAAC,EAAG,EAAG,EAAG,GACvBwW,EAAiB1W,EAAcyW,EAAcF,EAC7CI,EAAkB1W,EAAeqW,EAAaE,EAE9C/rB,EACJ4T,IAAeyF,IAAUnzB,EAAQ+lC,GAAkB7lC,EAAS8lC,GACxDl2B,KAAKif,IACHjf,KAAKgf,IACHiX,EAAiB/lC,EACjBgmC,EAAkB9lC,EAClBwtB,EAAW,IAEbA,EAAW,IAEb,EAUN,MAAO,CAAE3tB,EAPCozB,EACN,GACC4S,EAAiB/lC,EAAQ8Z,GAAS,EAAIgsB,EAAch0B,EAAOgI,EAKpD7Z,EAJFkzB,EACN,GACC6S,EAAkB9lC,EAAS4Z,GAAS,EAAI6rB,EAAa5zB,EAAM+H,EAEjD2J,EAAG3J,EACpB,C","sources":["webpack:///./src/shared/canvas/processors/nodeViewToNodeRect.ts","webpack:///./src/shared/canvas/processors/getSmartLinePoints.ts","webpack:///./src/draw-canvas/processors/getUnrelatedCells.ts","webpack:///./src/shared/canvas/useActiveTarget.ts","webpack:///./src/draw-canvas/processors/sameTarget.ts","webpack:///./src/draw-canvas/reducers/cells.ts","webpack:///./src/draw-canvas/reducers/index.ts","webpack:///./src/draw-canvas/reducers/layoutKey.ts","webpack:///./src/draw-canvas/LineLabelComponent.tsx","webpack:///./src/draw-canvas/EdgeComponent.tsx","webpack:///./src/draw-canvas/processors/getLabelMaskAndOffset.ts","webpack:///./src/draw-canvas/LockIcon.tsx","webpack:///./src/draw-canvas/NodeComponent.tsx","webpack:///./src/draw-canvas/processors/getSnapPositions.ts","webpack:///./src/draw-canvas/processors/handleMouseDown.ts","webpack:///./src/draw-canvas/processors/normalizeSnapOptions.ts","webpack:///./src/draw-canvas/processors/getContentEditable.ts","webpack:///./src/draw-canvas/decorators/DecoratorText.tsx","webpack:///./src/draw-canvas/decorators/index.tsx","webpack:///./src/draw-canvas/decorators/DecoratorGroup.tsx","webpack:///./src/draw-canvas/decorators/DecoratorContainer.tsx","webpack:///./src/draw-canvas/decorators/DecoratorArea.tsx","webpack:///./src/draw-canvas/decorators/DecoratorRect.tsx","webpack:///./src/draw-canvas/decorators/DecoratorLine.tsx","webpack:///./src/draw-canvas/processors/getLineLockIconPosition.ts","webpack:///./src/draw-canvas/CellComponent.tsx","webpack:///./src/draw-canvas/SmartConnectLineComponent.tsx","webpack:///./src/shared/canvas/processors/getConnectLinePoints.ts","webpack:///./src/draw-canvas/processors/handleKeyboard.ts","webpack:///./src/shared/canvas/useLineMarkers.ts","webpack:///./src/shared/canvas/processors/getEditingLinePoints.ts","webpack:///./src/draw-canvas/EditingLineComponent.tsx","webpack:///./src/draw-canvas/processors/initializeCells.ts","webpack:///./src/draw-canvas/processors/normalizeAlignOrigin.ts","webpack:///./src/shared/canvas/useLayout.ts","webpack:///./src/shared/canvas/useAutoCenter.ts","webpack:///./src/draw-canvas/processors/toggleLock.ts","webpack:///./src/shared/canvas/useReady.ts","webpack:///./src/draw-canvas/processors/isLocked.ts","webpack:///./src/shared/canvas/styles.shadow.css","webpack:///./src/draw-canvas/LineConnectorComponent.tsx","webpack:///./src/draw-canvas/constants.ts","webpack:///./src/shared/canvas/processors/getCellsRect.ts","webpack:///../../src/mergeRects.ts","webpack:///./src/draw-canvas/processors/handleNodeContainedChange.ts","webpack:///./src/draw-canvas/HoverStateContext.ts","webpack:///./src/draw-canvas/processors/asserts.ts","webpack:///./src/draw-canvas/processors/findNodeOrAreaDecorator.ts","webpack:///./src/shared/canvas/collectLineJumpsFactory.ts","webpack:///./src/shared/canvas/useEditableLineMap.ts","webpack:///./src/draw-canvas/LineEditorComponent.tsx","webpack:///./src/draw-canvas/processors/targetIsActive.ts","webpack:///./src/draw-canvas/processors/staggeredLayout.ts","webpack:///./src/draw-canvas/processors/computeBoundingBox.ts","webpack:///./src/draw-canvas/processors/generateNewPointsWithLayout.ts","webpack:///./src/draw-canvas/processors/updateCells.ts","webpack:///./src/draw-canvas/processors/transformToCenter.ts","webpack:///./src/draw-canvas/ConnectLineComponent.tsx","webpack:///./src/shared/canvas/ZoomBarComponent.shadow.css","webpack:///./src/shared/canvas/icons/center.svg","webpack:///./src/shared/canvas/icons/zoom-in.svg","webpack:///./src/shared/canvas/icons/zoom-out.svg","webpack:///./src/shared/canvas/ZoomBarComponent.tsx","webpack:///./src/draw-canvas/processors/cellToTarget.ts","webpack:///./src/draw-canvas/processors/handleLasso.ts","webpack:///./src/shared/canvas/forceLayout.ts","webpack:///./src/shared/canvas/useZoom.ts","webpack:///./src/shared/canvas/dagreLayout.ts","webpack:///./src/draw-canvas/processors/initialGroupLayout.ts","webpack:///./src/draw-canvas/processors/initialContainerLayout.ts","webpack:///./src/shared/canvas/shapes/Rectangle.ts","webpack:///./src/shared/canvas/processors/getTransformToCenter.ts"],"sourcesContent":["import type { NodeRect } from \"../../../diagram/interfaces\";\nimport type { NodeView } from \"../../../draw-canvas/interfaces\";\n\nexport function nodeViewToNodeRect(view: NodeView, padding: number): NodeRect {\n return {\n x: view.x + view.width / 2,\n y: view.y + view.height / 2,\n width: view.width + padding,\n height: view.height + padding,\n };\n}\n","import { pull } from \"lodash\";\nimport type { NodePosition } from \"../../../diagram/interfaces\";\nimport { getConnectPointsOfRectangleWithDirection } from \"../shapes/Rectangle\";\nimport type {\n BiDirection,\n EditableLineView,\n NodeView,\n} from \"../../../draw-canvas/interfaces\";\nimport { getPolyLinePoints } from \"../../../diagram/lines/getPolyLinePoints\";\nimport { nodeViewToNodeRect } from \"./nodeViewToNodeRect\";\nimport {\n DEFAULT_NODE_PADDING_FOR_LINES,\n DEFAULT_NODE_PADDING_FOR_SMART_LINES,\n} from \"../../../draw-canvas/constants\";\nimport { getDirectLinePoints } from \"../../../diagram/lines/getDirectLinePoints\";\nimport { isStraightType } from \"../../../draw-canvas/processors/asserts\";\n\nconst DEFAULT_DIRECTIONS = [\"right\", \"top\", \"left\", \"bottom\"] as const;\n\nexport function getSmartLinePoints(\n sourceView: NodeView,\n targetView: NodeView,\n lineView: EditableLineView | undefined,\n parallelGap?: number,\n /** @default \"edge\" */\n cellType?: \"edge\" | \"decorator\"\n): NodePosition[] | null {\n const {\n type,\n vertices,\n exitPosition: originalExit,\n entryPosition: originalEntry,\n } = lineView ?? {};\n\n if (isStraightType(type)) {\n if (cellType === \"decorator\") {\n return [\n { x: sourceView.x, y: sourceView.y },\n ...(vertices ?? []),\n { x: targetView.x, y: targetView.y },\n ];\n }\n\n return getDirectLinePoints(\n nodeViewToNodeRect(\n sourceView,\n originalExit\n ? DEFAULT_NODE_PADDING_FOR_SMART_LINES\n : DEFAULT_NODE_PADDING_FOR_LINES\n ),\n nodeViewToNodeRect(\n targetView,\n originalEntry\n ? DEFAULT_NODE_PADDING_FOR_SMART_LINES\n : DEFAULT_NODE_PADDING_FOR_LINES\n ),\n parallelGap,\n lineView\n );\n }\n\n if (vertices?.length) {\n const firstVertex = vertices[0];\n const lastVertex = vertices[vertices.length - 1];\n\n let exitPoint: NodePosition;\n let entryPoint: NodePosition;\n let exitDirection: BiDirection | undefined;\n let entryDirection: BiDirection | undefined;\n\n // Auto decide the exit and entry position.\n if (originalExit) {\n exitPoint = getAbsolutePosition(sourceView, originalExit);\n } else {\n let possibleFirstNextPoint: NodePosition | undefined;\n if (vertices.length > 1) {\n // Decide exit point by the first two vertices.\n possibleFirstNextPoint = vertices[1];\n } else if (originalEntry) {\n // Decide exit point by the entry position.\n possibleFirstNextPoint = getAbsolutePosition(targetView, originalEntry);\n }\n if (possibleFirstNextPoint) {\n exitPoint = getDefaultAbsolutePosition(\n firstVertex,\n sourceView,\n firstVertex.y === possibleFirstNextPoint.y\n );\n } else {\n // No other vertices nor the entry position, decide exit point by the\n // relative position between the last vertex and the target node.\n const prefer =\n lastVertex.y < targetView.y ||\n lastVertex.y > targetView.y + targetView.height\n ? \"ns\"\n : \"ew\";\n ({ point: exitPoint, direction: exitDirection } =\n fitEndpointAndDirection(sourceView, targetView, vertices, prefer));\n }\n }\n\n if (originalEntry) {\n entryPoint = getAbsolutePosition(targetView, originalEntry);\n } else {\n let possibleLastPreviousPoint: NodePosition | undefined;\n if (vertices.length > 1) {\n // Decide entry point by the last two vertices.\n possibleLastPreviousPoint = vertices[vertices.length - 2];\n } else if (originalExit) {\n // Decide entry point by the exit position.\n possibleLastPreviousPoint = getAbsolutePosition(\n sourceView,\n originalExit\n );\n }\n if (possibleLastPreviousPoint) {\n entryPoint = getDefaultAbsolutePosition(\n lastVertex,\n targetView,\n lastVertex.y === possibleLastPreviousPoint.y\n );\n } else {\n // No other vertices nor the exit position, decide entry point by the\n // relative position between the first vertex and the source node.\n const prefer =\n firstVertex.x < sourceView.x ||\n firstVertex.x > sourceView.x + sourceView.width\n ? \"ew\"\n : \"ns\";\n ({ point: entryPoint, direction: entryDirection } =\n fitEndpointAndDirection(\n targetView,\n sourceView,\n vertices.slice().reverse(),\n prefer\n ));\n }\n }\n\n const { x: sourceX, y: sourceY } = exitPoint;\n const { x: targetX, y: targetY } = entryPoint;\n\n const newLinePoints = [exitPoint, ...vertices, entryPoint];\n\n const newVertices = [...vertices];\n\n // If the first vertex is not on any axis of the source exit point,\n // add a vertex to connect them.\n if (firstVertex && firstVertex.x !== sourceX && firstVertex.y !== sourceY) {\n newVertices.unshift(\n exitDirection === \"ns\"\n ? { x: sourceX, y: firstVertex.y }\n : exitDirection === \"ew\"\n ? { x: firstVertex.x, y: sourceY }\n : firstVertex.x === newLinePoints[2].x\n ? { x: sourceX, y: firstVertex.y }\n : { x: firstVertex.x, y: sourceY }\n );\n }\n\n // If the last vertex is not on any axis of the target entry point,\n // add a vertex to connect them.\n if (lastVertex && lastVertex.x !== targetX && lastVertex.y !== targetY) {\n newVertices.push(\n entryDirection === \"ns\"\n ? { x: targetX, y: lastVertex.y }\n : entryDirection === \"ew\"\n ? { x: lastVertex.x, y: targetY }\n : lastVertex.x === newLinePoints[newLinePoints.length - 3].x\n ? { x: targetX, y: lastVertex.y }\n : { x: lastVertex.x, y: targetY }\n );\n }\n\n return [\n exitPoint,\n ...simplifyVertices(exitPoint, newVertices, entryPoint),\n entryPoint,\n ];\n }\n\n const exitPosition =\n originalExit ?? getDefaultPosition(targetView, sourceView);\n const entryPosition =\n originalEntry ?? getDefaultPosition(sourceView, targetView);\n\n const { x: sourceX, y: sourceY } = getAbsolutePosition(\n sourceView,\n exitPosition\n );\n const { x: targetX, y: targetY } = getAbsolutePosition(\n targetView,\n entryPosition\n );\n\n const connectPoints = getConnectPointsOfRectangleWithDirection();\n const originalSourceDirections =\n connectPoints.find((p) => p.x === exitPosition.x && p.y === exitPosition.y)\n ?.d ?? DEFAULT_DIRECTIONS;\n const originalTargetDirections =\n connectPoints.find(\n (p) => p.x === entryPosition.x && p.y === entryPosition.y\n )?.d ?? DEFAULT_DIRECTIONS;\n const sourceDirections = [...originalSourceDirections];\n const targetDirections = [...originalTargetDirections];\n\n if (sourceX < targetX) {\n pull(sourceDirections, \"left\");\n pull(targetDirections, \"right\");\n } else {\n pull(sourceDirections, \"right\");\n pull(targetDirections, \"left\");\n }\n\n if (sourceY < targetY) {\n pull(sourceDirections, \"top\");\n pull(targetDirections, \"bottom\");\n } else {\n pull(sourceDirections, \"bottom\");\n pull(targetDirections, \"top\");\n }\n\n const sourceDirection = sourceDirections[0] ?? originalSourceDirections[0];\n const targetDirection = targetDirections[0] ?? originalTargetDirections[0];\n\n const sourcePosition =\n sourceDirection === \"left\" || sourceDirection === \"right\"\n ? exitPosition.y\n : exitPosition.x;\n const targetPosition =\n targetDirection === \"left\" || targetDirection === \"right\"\n ? entryPosition.y\n : entryPosition.x;\n\n return getPolyLinePoints(\n nodeViewToNodeRect(sourceView, DEFAULT_NODE_PADDING_FOR_SMART_LINES),\n nodeViewToNodeRect(targetView, DEFAULT_NODE_PADDING_FOR_SMART_LINES),\n sourceDirection,\n targetDirection,\n sourcePosition,\n targetPosition\n );\n}\n\nexport function simplifyVertices(\n exitPoint: NodePosition,\n vertices: NodePosition[],\n entryPoint: NodePosition\n): NodePosition[] {\n // Simplify the vertices, ignore all vertices that its previous and next points are on the same axis\n // E.g, ignore two vertices of index 1 and index 3 for the following line.\n // 0---1---2\n // |\n // 3\n // |\n // 4\n const simplifiedVertices: NodePosition[] = [];\n let prev = exitPoint;\n let prevDirection: \"ns\" | \"ew\" | undefined;\n let index = 0;\n while (index < vertices.length) {\n const vertex = vertices[index];\n const isHorizontal = vertex.x !== prev.x;\n const isVertical = vertex.y !== prev.y;\n if (isHorizontal || isVertical) {\n const direction = isHorizontal ? \"ew\" : \"ns\";\n if (direction !== prevDirection) {\n const next =\n index === vertices.length - 1 ? entryPoint : vertices[index + 1];\n const isHorizontalNext = next.x !== vertex.x;\n const isVerticalNext = next.y !== vertex.y;\n if (isHorizontalNext || isVerticalNext) {\n const nextDirection = isHorizontalNext ? \"ew\" : \"ns\";\n if (direction !== nextDirection) {\n prevDirection = direction;\n simplifiedVertices.push(vertex);\n prev = vertex;\n }\n }\n }\n }\n index++;\n }\n\n return simplifiedVertices;\n}\n\nfunction getDefaultPosition(\n sourceView: NodeView,\n targetView: NodeView\n): NodePosition {\n if (targetView.y + targetView.height < sourceView.y) {\n return { x: 0.5, y: 1 };\n }\n if (targetView.y > sourceView.y + sourceView.height) {\n return { x: 0.5, y: 0 };\n }\n return targetView.x < sourceView.x ? { x: 1, y: 0.5 } : { x: 0, y: 0.5 };\n}\n\nfunction getAbsolutePosition(view: NodeView, position: NodePosition) {\n const halfPadding = DEFAULT_NODE_PADDING_FOR_SMART_LINES / 2;\n return {\n x:\n view.x -\n halfPadding +\n position.x * (view.width + DEFAULT_NODE_PADDING_FOR_SMART_LINES),\n y:\n view.y -\n halfPadding +\n position.y * (view.height + DEFAULT_NODE_PADDING_FOR_SMART_LINES),\n };\n}\n\nfunction getDefaultAbsolutePosition(\n sourceView: NodePosition,\n targetView: NodeView,\n flip?: boolean\n): NodePosition {\n let xAxis: \"x\" | \"y\";\n let yAxis: \"x\" | \"y\";\n let xSize: \"width\" | \"height\";\n let ySize: \"width\" | \"height\";\n if (flip) {\n xAxis = \"y\";\n yAxis = \"x\";\n xSize = \"height\";\n ySize = \"width\";\n } else {\n xAxis = \"x\";\n yAxis = \"y\";\n xSize = \"width\";\n ySize = \"height\";\n }\n let position: NodePosition | undefined;\n if (targetView[yAxis] + targetView[ySize] < sourceView[yAxis]) {\n position = { [xAxis]: 0.5, [yAxis]: 1 } as unknown as NodePosition;\n }\n if (targetView[yAxis] > sourceView[yAxis]) {\n position = { [xAxis]: 0.5, [yAxis]: 0 } as unknown as NodePosition;\n }\n if (position) {\n return getAbsolutePosition(targetView, position);\n }\n\n const xPosition = targetView[xAxis] < sourceView[xAxis] ? 1 : 0;\n\n return {\n [xAxis]:\n targetView[xAxis] -\n DEFAULT_NODE_PADDING_FOR_SMART_LINES / 2 +\n xPosition * (targetView[xSize] + DEFAULT_NODE_PADDING_FOR_SMART_LINES),\n [yAxis]: sourceView[yAxis],\n } as unknown as NodePosition;\n}\n\nfunction fitEndpointAndDirection(\n view: NodeView,\n oppositeView: NodeView,\n vertices: NodePosition[],\n prefer: BiDirection\n): { point: NodePosition; direction: BiDirection } {\n let point: NodePosition;\n let direction: BiDirection;\n\n let xAxis: \"x\" | \"y\";\n let yAxis: \"x\" | \"y\";\n let xSize: \"width\" | \"height\";\n let ySize: \"width\" | \"height\";\n let nsDirection: BiDirection;\n let ewDirection: BiDirection;\n if (prefer === \"ns\") {\n xAxis = \"x\";\n yAxis = \"y\";\n xSize = \"width\";\n ySize = \"height\";\n nsDirection = \"ns\";\n ewDirection = \"ew\";\n } else {\n xAxis = \"y\";\n yAxis = \"x\";\n xSize = \"height\";\n ySize = \"width\";\n nsDirection = \"ew\";\n ewDirection = \"ns\";\n }\n const vertex = vertices[0];\n\n if (\n vertex[xAxis] >= view[xAxis] &&\n vertex[xAxis] <= view[xAxis] + view[xSize]\n ) {\n if (vertex[yAxis] > view[yAxis] + view[ySize]) {\n point = {\n [xAxis]: vertex[xAxis],\n [yAxis]: view[yAxis] + view[ySize],\n } as unknown as NodePosition;\n direction = nsDirection;\n } else if (vertex[yAxis] < view[yAxis]) {\n point = {\n [xAxis]: vertex[xAxis],\n [yAxis]: view[yAxis],\n } as unknown as NodePosition;\n direction = nsDirection;\n } else {\n const nextVertex = vertices[1] ?? oppositeView;\n point = {\n [xAxis]: vertex[xAxis],\n [yAxis]:\n nextVertex[yAxis] < vertex[yAxis]\n ? vertex[yAxis]\n : view[yAxis] + view[ySize],\n } as unknown as NodePosition;\n direction = nsDirection;\n }\n } else {\n if (vertex[yAxis] < view[yAxis]) {\n point = {\n [xAxis]: view[xAxis] + view[xSize] / 2,\n [yAxis]: view[yAxis],\n } as unknown as NodePosition;\n direction = nsDirection;\n } else if (vertex[yAxis] > view[yAxis] + view[ySize]) {\n point = {\n [xAxis]: view[xAxis] + view[xSize] / 2,\n [yAxis]: view[yAxis] + view[ySize],\n } as unknown as NodePosition;\n direction = nsDirection;\n } else if (vertex[xAxis] < view[xAxis]) {\n point = {\n [xAxis]: view[xAxis],\n [yAxis]: vertex[yAxis],\n } as unknown as NodePosition;\n direction = ewDirection;\n } else {\n point = {\n [xAxis]: view[xAxis] + view[xSize],\n [yAxis]: vertex[yAxis],\n } as unknown as NodePosition;\n direction = ewDirection;\n }\n }\n return { point, direction: direction };\n}\n","import type { ActiveTarget, Cell, ConnectLineState } from \"../interfaces\";\nimport { targetIsActive } from \"./targetIsActive\";\n\nexport function getUnrelatedCells(\n cells: Cell[],\n connectLineState: ConnectLineState | null,\n activeTarget: ActiveTarget | null,\n allowEdgeToArea?: boolean\n): Cell[] {\n const unrelated: Cell[] = [];\n if (connectLineState) {\n const existedTargets = new Set<string>();\n for (const cell of cells) {\n if (cell.type === \"edge\" && cell.source === connectLineState.source.id) {\n existedTargets.add(cell.target);\n }\n }\n for (const cell of cells) {\n switch (cell.type) {\n case \"node\":\n if (existedTargets.has(cell.id)) {\n unrelated.push(cell);\n }\n break;\n case \"decorator\":\n if (\n !allowEdgeToArea ||\n cell.decorator == \"text\" ||\n existedTargets.has(cell.id)\n ) {\n unrelated.push(cell);\n }\n break;\n default:\n unrelated.push(cell);\n }\n }\n } else {\n switch (activeTarget?.type) {\n case \"multi\": {\n const nodesMap = new Map<string, Cell>();\n const activeNodeIds = new Set<string>();\n const relatedNodeIds = new Set<string>();\n for (const active of activeTarget.targets) {\n if (active.type === \"node\") {\n activeNodeIds.add(active.id);\n relatedNodeIds.add(active.id);\n }\n }\n for (const cell of cells) {\n if (cell.type === \"node\") {\n nodesMap.set(cell.id, cell);\n } else if (cell.type === \"edge\") {\n if (activeNodeIds.has(cell.source)) {\n relatedNodeIds.add(cell.target);\n } else if (activeNodeIds.has(cell.target)) {\n relatedNodeIds.add(cell.source);\n } else if (!targetIsActive(cell, activeTarget)) {\n unrelated.push(cell);\n }\n } else if (!targetIsActive(cell, activeTarget)) {\n unrelated.push(cell);\n }\n }\n for (const [id, cell] of nodesMap) {\n if (!relatedNodeIds.has(id)) {\n unrelated.push(cell);\n }\n }\n break;\n }\n\n case \"node\": {\n const nodesMap = new Map<string, Cell>();\n const relatedNodeIds = new Set<string>([activeTarget.id]);\n for (const cell of cells) {\n if (cell.type === \"node\") {\n nodesMap.set(cell.id, cell);\n } else if (cell.type === \"edge\") {\n if (cell.source === activeTarget.id) {\n relatedNodeIds.add(cell.target);\n } else if (cell.target === activeTarget.id) {\n relatedNodeIds.add(cell.source);\n } else {\n unrelated.push(cell);\n }\n } else {\n unrelated.push(cell);\n }\n }\n for (const [id, cell] of nodesMap) {\n if (!relatedNodeIds.has(id)) {\n unrelated.push(cell);\n }\n }\n break;\n }\n\n case \"edge\":\n for (const cell of cells) {\n if (\n !(cell.type === \"edge\"\n ? targetIsActive(cell, activeTarget)\n : cell.type === \"node\" &&\n (cell.id === activeTarget.source ||\n cell.id === activeTarget.target))\n ) {\n unrelated.push(cell);\n }\n }\n break;\n }\n }\n\n return unrelated;\n}\n","import React, { useEffect, useRef, useState } from \"react\";\nimport type { ActiveTarget } from \"../../draw-canvas/interfaces\";\nimport { sameTarget } from \"../../draw-canvas/processors/sameTarget\";\n\nexport interface UseActiveTargetOptions {\n rootRef: React.RefObject<SVGGElement>;\n activeTarget?: ActiveTarget | null;\n doNotResetActiveTargetForSelector?: string;\n doNotResetActiveTargetOutsideCanvas?: boolean;\n onActiveTargetChange(target: ActiveTarget | null): void;\n}\n\nexport type UseActiveTargetResult = ActiveTarget | null;\n\nexport function useActiveTarget({\n rootRef,\n activeTarget: _activeTarget,\n doNotResetActiveTargetForSelector,\n doNotResetActiveTargetOutsideCanvas,\n onActiveTargetChange,\n}: UseActiveTargetOptions): UseActiveTargetResult {\n const newActiveTarget = _activeTarget ?? null;\n const [activeTarget, setActiveTarget] = useState<ActiveTarget | null>(\n newActiveTarget\n );\n\n useEffect(() => {\n setActiveTarget((previous) =>\n sameTarget(previous, newActiveTarget) ? previous : newActiveTarget\n );\n }, [newActiveTarget]);\n\n const activeTargetChangeInitialized = useRef(false);\n useEffect(() => {\n if (!activeTargetChangeInitialized.current) {\n activeTargetChangeInitialized.current = true;\n return;\n }\n onActiveTargetChange(activeTarget);\n }, [activeTarget, onActiveTargetChange]);\n\n useEffect(() => {\n if (!activeTarget) {\n return;\n }\n const resetActiveTarget = (e: MouseEvent) => {\n const path = e.composedPath();\n const rootIndex = path.indexOf(rootRef.current!);\n // Reset active target to null when clicking outside of the cells container,\n // Or inside the cells container but not on any cell.\n if (\n doNotResetActiveTargetOutsideCanvas\n ? rootIndex === 0\n : rootIndex <= 0 &&\n !(\n doNotResetActiveTargetForSelector &&\n path.some(\n (el) =>\n el instanceof Element &&\n el.matches(doNotResetActiveTargetForSelector)\n )\n )\n ) {\n setActiveTarget(null);\n }\n };\n document.addEventListener(\"click\", resetActiveTarget);\n return () => {\n document.removeEventListener(\"click\", resetActiveTarget);\n };\n }, [\n activeTarget,\n doNotResetActiveTargetOutsideCanvas,\n doNotResetActiveTargetForSelector,\n rootRef,\n ]);\n\n return activeTarget;\n}\n","import type {\n ActiveTarget,\n ActiveTargetOfEdge,\n ActiveTargetOfMulti,\n ActiveTargetOfNode,\n} from \"../interfaces\";\n\nexport function sameTarget(\n a: ActiveTarget | null | undefined,\n b: ActiveTarget | null | undefined\n): boolean {\n return a\n ? !!b &&\n a.type === b.type &&\n (a.type === \"multi\"\n ? a.targets.length === (b as ActiveTargetOfMulti).targets.length &&\n a.targets.every((targetA) =>\n (b as ActiveTargetOfMulti).targets.some((targetB) =>\n sameTarget(targetA, targetB)\n )\n )\n : a.type === \"node\" || a.type === \"decorator\"\n ? a.id === (b as ActiveTargetOfNode).id\n : a.source === (b as ActiveTargetOfEdge).source &&\n a.target === (b as ActiveTargetOfEdge).target)\n : !b;\n}\n","import type { Reducer } from \"react\";\nimport { pick } from \"lodash\";\nimport type { DrawCanvasAction } from \"./interfaces\";\nimport type {\n Cell,\n DecoratorCell,\n DecoratorType,\n EdgeCell,\n NodeCell,\n} from \"../interfaces\";\nimport { isNodeCell } from \"../processors/asserts\";\nimport { SYMBOL_FOR_SIZE_INITIALIZED } from \"../constants\";\n\ntype CellOrder = CellOrderOfDecorator | CellOrderOfOthers;\n\ninterface CellOrderOfDecorator {\n type: \"decorator\";\n decorators: DecoratorType[];\n}\n\ninterface CellOrderOfOthers {\n type: \"node\" | \"edge\";\n}\n\n// NOTE: keep the cells in the following order by default, when adding new cells:\n// 1. decorators other than text\n// 2. edges\n// 3. nodes\n// 4. decorators of text\nconst DEFAULT_CELL_ORDERS: CellOrder[] = [\n {\n type: \"decorator\",\n decorators: [\"line\", \"area\", \"container\", \"rect\"],\n },\n { type: \"edge\" },\n { type: \"node\" },\n { type: \"decorator\", decorators: [\"text\"] },\n];\n\nexport const cells: Reducer<Cell[], DrawCanvasAction> = (state, action) => {\n switch (action.type) {\n case \"drop-node\":\n case \"drop-decorator\":\n return insertCell(state, action.payload);\n case \"add-nodes\":\n return insertCells(state, action.payload);\n case \"add-edge\": {\n // If the new edge between the source and target already exists, override the old one.\n const existedEdgeIndex = state.findIndex(\n (cell) =>\n cell.type === \"edge\" &&\n cell.source === action.payload.source &&\n cell.target === action.payload.target\n );\n if (existedEdgeIndex === -1) {\n // Add the edge to just next to the previous last edge or area decorator.\n // If not found, append to the start.\n return insertCell(state, action.payload);\n }\n return [\n ...state.slice(0, existedEdgeIndex),\n action.payload,\n ...state.slice(existedEdgeIndex + 1),\n ];\n }\n case \"change-edge-view\": {\n const existedEdgeIndex = state.findIndex(\n (cell) =>\n cell.type === \"edge\" &&\n cell.source === action.payload.source &&\n cell.target === action.payload.target\n );\n return existedEdgeIndex === -1\n ? state\n : [\n ...state.slice(0, existedEdgeIndex),\n {\n ...(state[existedEdgeIndex] as EdgeCell),\n view: action.payload.view,\n },\n ...state.slice(existedEdgeIndex + 1),\n ];\n }\n case \"change-decorator-view\": {\n const existedDecoratorIndex = state.findIndex(\n (cell) => cell.type === \"decorator\" && cell.id === action.payload.id\n );\n return existedDecoratorIndex === -1\n ? state\n : [\n ...state.slice(0, existedDecoratorIndex),\n {\n ...(state[existedDecoratorIndex] as EdgeCell),\n view: action.payload.view,\n },\n ...state.slice(existedDecoratorIndex + 1),\n ];\n }\n case \"move-cells\": {\n let matched = false;\n const newState = state.map((cell) => {\n const newCell = action.payload.find(\n (move) => cell.type === move.type && cell.id === move.id\n );\n if (newCell) {\n matched = true;\n return {\n ...(cell as NodeCell),\n view: {\n ...(cell as NodeCell).view,\n x: newCell.x,\n y: newCell.y,\n ...pick(newCell, \"source\", \"target\", \"vertices\"),\n },\n };\n }\n return cell;\n });\n return matched ? newState : state;\n }\n case \"resize-cell\": {\n const { type, id, width, height } = action.payload;\n const index = state.findIndex(\n (cell) => cell.type === type && cell.id === id\n );\n if (index !== -1) {\n const node = state[index] as NodeCell;\n return [\n ...state.slice(0, index),\n { ...node, view: { ...node.view, width, height } },\n ...state.slice(index + 1),\n ];\n }\n return state;\n }\n case \"update-cells\":\n return action.payload;\n case \"update-node-size\":\n return state.map((cell) =>\n isNodeCell(cell) && cell.id === action.payload.id\n ? {\n ...cell,\n [SYMBOL_FOR_SIZE_INITIALIZED]: true,\n view: action.payload.size\n ? {\n ...cell.view,\n width: action.payload.size[0],\n height: action.payload.size[1],\n }\n : cell.view,\n }\n : cell\n );\n }\n return state;\n};\n\nfunction insertCell(cells: Cell[], newCell: Cell): Cell[] {\n return insertCells(cells, [newCell]);\n}\n\n/**\n * Insert new cells (with same types and some decorators) to the cells.\n */\nfunction insertCells(cells: Cell[], newCells: Cell[]): Cell[] {\n if (newCells.length === 0) {\n return cells;\n }\n const index = DEFAULT_CELL_ORDERS.findIndex((order) =>\n matchCellOrder(newCells[0], order)\n );\n\n // istanbul ignore next\n if (index === -1) {\n // eslint-disable-next-line no-console\n console.warn(\n \"Default order index unhandled for the cell: %o.\\n%s\",\n newCells[0],\n \"This is a bug of diagram-NB, please report it.\"\n );\n }\n\n const lastIndex = cells.findLastIndex(\n (cell) =>\n DEFAULT_CELL_ORDERS.findIndex((order) => matchCellOrder(cell, order)) <=\n index\n );\n const targetIndex = lastIndex + 1;\n return [\n ...cells.slice(0, targetIndex),\n ...newCells,\n ...cells.slice(targetIndex),\n ];\n}\n\nfunction matchCellOrder(cell: Cell, order: CellOrder) {\n return (\n cell.type === order.type &&\n (order.type !== \"decorator\" ||\n order.decorators.includes((cell as DecoratorCell).decorator))\n );\n}\n","import { Reducer } from \"react\";\nimport type { DrawCanvasAction, DrawCanvasState } from \"./interfaces\";\nimport { cells } from \"./cells\";\nimport { layoutKey } from \"./layoutKey\";\n\ntype ReducersMapObject<S, A> = {\n [K in keyof S]: Reducer<S[K], A>;\n};\n\nfunction combineReducers<S, A>(\n reducers: ReducersMapObject<S, A>\n): Reducer<S, A> {\n return ((state, action) =>\n Object.fromEntries(\n Object.entries<Reducer<any, A>>(reducers).map(([key, value]) => [\n key,\n value(state[key as keyof S], action),\n ])\n )) as Reducer<S, A>;\n}\n\nexport const rootReducer = combineReducers<DrawCanvasState, DrawCanvasAction>({\n cells,\n layoutKey,\n});\n","import type { Reducer } from \"react\";\nimport type { DrawCanvasAction } from \"./interfaces\";\n\nexport const layoutKey: Reducer<number, DrawCanvasAction> = (state, action) => {\n switch (action.type) {\n case \"update-node-size\":\n return action.layoutKey;\n default:\n return state;\n }\n};\n","import React, { useCallback, useEffect, useMemo } from \"react\";\nimport { checkIfOfComputed } from \"@next-core/runtime\";\nimport { ReactUseBrick } from \"@next-core/react-runtime\";\nimport classNames from \"classnames\";\nimport type {\n LineLabelConf,\n PositionTuple,\n TextOptions,\n} from \"../diagram/interfaces\";\nimport type { EdgeCell, PositionAndAngle } from \"./interfaces\";\n\nexport interface LineLabelComponentProps {\n edge: EdgeCell;\n position?: PositionAndAngle | null;\n offset?: PositionTuple | null;\n label?: LineLabelConf;\n text?: TextOptions;\n onRendered?: (element: HTMLElement | null) => void;\n onClick?: () => void;\n}\n\nexport function LineLabelComponent({\n edge,\n position,\n offset,\n label,\n text,\n onRendered,\n onClick,\n}: LineLabelComponentProps): JSX.Element | null {\n if (!label && !text) {\n return null;\n }\n const ready = !!(position && offset);\n return (\n <foreignObject\n className={classNames(\"line-label-container\", { ready })}\n x={ready ? position[0] + offset[0] : 0}\n y={ready ? position[1] + offset[1] : 0}\n onClick={onClick}\n >\n {label ? (\n <div className=\"line-label label\">\n <LineLabelUseBrickComponent\n edge={edge}\n label={label}\n onRendered={onRendered}\n />\n </div>\n ) : (\n <LineLabelTextComponent text={text!} onRendered={onRendered} />\n )}\n </foreignObject>\n );\n}\n\ninterface LineLabelTextComponentProps {\n text: TextOptions;\n onRendered?: (element: HTMLElement | null) => void;\n}\n\nfunction LineLabelTextComponent({\n text,\n onRendered,\n}: LineLabelTextComponentProps): JSX.Element {\n const refCallback = useCallback(\n (element: HTMLDivElement) => {\n onRendered?.(element);\n },\n [onRendered]\n );\n\n return (\n <div className=\"line-label text\" ref={refCallback} style={text.style}>\n {text.content}\n </div>\n );\n}\n\ninterface LineLabelUseBrickComponentProps {\n edge: EdgeCell;\n label: LineLabelConf;\n onRendered?: (element: HTMLElement | null) => void;\n}\n\n// istanbul ignore next\nfunction LineLabelUseBrickComponent({\n edge,\n label,\n onRendered,\n}: LineLabelUseBrickComponentProps): JSX.Element | null {\n const useBrick = useMemo(\n () => (checkIfOfComputed(label) ? label.useBrick : null),\n [label]\n );\n\n const memoizedData = useMemo(() => ({ edge }), [edge]);\n\n useEffect(() => {\n if (!useBrick) {\n // Keep the same time delay for reporting rendered.\n setTimeout(() => {\n onRendered?.(null);\n });\n }\n }, [onRendered, useBrick]);\n\n useEffect(\n () => {\n return () => {\n onRendered?.(null);\n };\n },\n // Only unmount once\n // eslint-disable-next-line react-hooks/exhaustive-deps\n []\n );\n\n const refCallback = useCallback(\n (element: HTMLElement | null) => {\n if (element) {\n // Todo: correctly wait for `useBrick` in v3 to be rendered (after layout)\n // Wait a macro task to let `useBrick` to be rendered.\n setTimeout(() => {\n // await Promise.resolve();\n onRendered?.(element.parentElement);\n });\n }\n },\n [onRendered]\n );\n\n const ignoredCallback = useCallback(() => {\n setTimeout(() => {\n onRendered?.(null);\n });\n }, [onRendered]);\n\n if (!useBrick) {\n return null;\n }\n\n return (\n <ReactUseBrick\n refCallback={refCallback}\n ignoredCallback={ignoredCallback}\n useBrick={useBrick}\n data={memoizedData}\n />\n );\n}\n","import React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport classNames from \"classnames\";\nimport { uniqueId } from \"lodash\";\nimport ResizeObserver from \"resize-observer-polyfill\";\nimport type {\n ActiveTarget,\n ComputedEdgeLineConf,\n Direction,\n EdgeCell,\n EdgeLineMotion,\n EditableLine,\n EditableLineCell,\n PositionAndAngle,\n} from \"./interfaces\";\nimport {\n DEFAULT_LINE_INTERACT_ANIMATE_DURATION,\n DEFAULT_MOTION_SPEED,\n} from \"./constants\";\nimport { curveLine } from \"../diagram/lines/curveLine\";\nimport { getMarkers } from \"../shared/canvas/useLineMarkers\";\nimport type {\n LineMarkerConf,\n NodePosition,\n SizeTuple,\n} from \"../diagram/interfaces\";\nimport { LineLabelComponent } from \"./LineLabelComponent\";\nimport { cellToTarget } from \"./processors/cellToTarget\";\nimport { getLabelMaskAndOffset } from \"./processors/getLabelMaskAndOffset\";\n\nexport interface EdgeComponentProps {\n edge: EdgeCell;\n lineConfMap: WeakMap<EditableLineCell, ComputedEdgeLineConf>;\n editableLineMap: WeakMap<EditableLineCell, EditableLine>;\n readOnly?: boolean;\n active?: boolean;\n activeRelated?: boolean;\n onSwitchActiveTarget?(activeTarget: ActiveTarget | null): void;\n}\n\nexport function EdgeComponent({\n edge,\n lineConfMap,\n editableLineMap,\n readOnly,\n active,\n activeRelated,\n onSwitchActiveTarget,\n}: EdgeComponentProps): JSX.Element | null {\n const pathRef = useRef<SVGPathElement | null>(null);\n const lineConf = lineConfMap.get(edge)!;\n const { points: linePoints, jumpsMap } = editableLineMap.get(edge) ?? {};\n\n const line = useMemo(() => {\n return curveLine(\n linePoints,\n lineConf.type === \"curve\" ? lineConf.curveType : \"curveLinear\",\n 0,\n 1,\n jumpsMap\n );\n }, [lineConf, linePoints, jumpsMap]);\n\n const lineClipPathPrefix = useMemo(() => uniqueId(\"line-mask-\"), []);\n\n const [labelPosition, setLabelPosition] = useState<PositionAndAngle | null>(\n null\n );\n const [labelSize, setLabelSize] = useState<SizeTuple | null>(null);\n const [lineRect, setLineRect] = useState<Pick<\n SVGRect,\n \"x\" | \"y\" | \"width\" | \"height\"\n > | null>(null);\n\n const updateLabelPosition = useCallback(() => {\n const path = pathRef.current;\n const { label, text } = lineConf;\n // istanbul ignore next\n if (path && linePoints && (label || text)) {\n if (process.env.NODE_ENV === \"test\") {\n setLabelPosition([30, 40, \"center\", 0, 0]);\n setLineRect({ x: 10, y: 20, width: 300, height: 400 });\n return;\n }\n const placement = (label ? label.placement : text.placement) ?? \"center\";\n const offset = (label ? label.offset : text.offset) ?? 0;\n const pathLength = path.getTotalLength();\n const halfPathLength = pathLength / 2;\n const pathPoint = path.getPointAtLength(\n placement === \"start\"\n ? 0\n : placement === \"end\"\n ? pathLength\n : halfPathLength + offset\n );\n\n let direction: Direction | \"center\" = \"center\";\n let angle = 0;\n if (placement === \"start\" || placement === \"end\") {\n let p0: NodePosition;\n let p1: NodePosition;\n if (placement === \"start\") {\n p0 = linePoints[0];\n p1 = linePoints[1];\n } else {\n p0 = linePoints[linePoints.length - 1];\n p1 = linePoints[linePoints.length - 2];\n }\n angle = Math.atan2(p1.y - p0.y, p1.x - p0.x);\n direction =\n Math.abs(p0.x - p1.x) > Math.abs(p0.y - p1.y)\n ? p0.x > p1.x\n ? \"left\"\n : \"right\"\n : p0.y > p1.y\n ? \"top\"\n : \"bottom\";\n }\n\n setLabelPosition([pathPoint.x, pathPoint.y, direction, angle, offset]);\n const rect = path.getBBox();\n setLineRect({\n x: rect.x - 1000,\n y: rect.y - 1000,\n width: rect.width + 2000,\n height: rect.height + 2000,\n });\n }\n }, [lineConf, linePoints]);\n\n const [pathLength, setPathLength] = useState<number | null>(null);\n\n const pathRefCallback = useCallback(\n (element: SVGPathElement | null) => {\n pathRef.current = element;\n if (element) {\n // Jest does not support `SVGPathElement::getTotalLength`\n setPathLength(element.getTotalLength?.() ?? 100);\n const rect = element.getBBox?.();\n edge.view = {\n ...edge.view,\n x: rect?.x,\n y: rect?.y,\n width: rect?.width,\n height: rect?.height,\n };\n }\n updateLabelPosition();\n },\n [updateLabelPosition, edge]\n );\n\n const [labelElement, setLabelElement] = useState<HTMLElement | null>(null);\n\n useEffect(() => {\n if (!labelElement) {\n setLabelSize(null);\n return;\n }\n const observerCallback = () => {\n const { offsetWidth, offsetHeight } = labelElement;\n // Do not mask out when the label takes no space.\n // istanbul ignore next\n if (\n process.env.NODE_ENV !== \"test\" &&\n (offsetWidth === 0 || offsetHeight === 0)\n ) {\n setLabelSize(null);\n return;\n }\n setLabelSize([offsetWidth, offsetHeight]);\n };\n const resizeObserver = new ResizeObserver(observerCallback);\n resizeObserver.observe(labelElement);\n\n // `ResizeObserver` will not call the callback in test environment.\n // istanbul ignore next\n if (process.env.NODE_ENV === \"test\") {\n observerCallback();\n }\n return () => {\n resizeObserver.disconnect();\n };\n }, [labelElement]);\n\n const handleLabelRendered = useCallback((element: HTMLElement | null) => {\n setLabelElement(element);\n }, []);\n\n useEffect(\n () => {\n updateLabelPosition();\n },\n // Update label position when line points changed\n [updateLabelPosition, linePoints]\n );\n\n const onLabelClick = useCallback(() => {\n onSwitchActiveTarget?.(cellToTarget(edge));\n }, [edge, onSwitchActiveTarget]);\n\n const onDoubleClick = useCallback(\n (e: React.MouseEvent) => {\n if (readOnly || !lineConf.callLabelOnDoubleClick) {\n return;\n }\n e.preventDefault();\n e.stopPropagation();\n (\n labelElement?.firstElementChild as unknown as Record<string, () => void>\n )?.[lineConf.callLabelOnDoubleClick]?.();\n },\n [labelElement, lineConf, readOnly]\n );\n\n const [mask, labelOffset] = useMemo(\n () => getLabelMaskAndOffset(labelPosition, labelSize),\n [labelPosition, labelSize]\n );\n\n const clipPathPoints = useMemo(() => {\n if (!mask || !lineRect) {\n return null;\n }\n const right = lineRect.x + lineRect.width;\n const bottom = lineRect.y + lineRect.height;\n const maskRight = mask.left + mask.width;\n const maskBottom = mask.top + mask.height;\n return [\n [mask.left, maskBottom],\n [maskRight, maskBottom],\n [maskRight, mask.top],\n [mask.left, mask.top],\n [mask.left, lineRect.y],\n [right, lineRect.y],\n [right, bottom],\n [lineRect.x, bottom],\n [lineRect.x, lineRect.y],\n [mask.left, lineRect.y],\n ]\n .map((points) => points.join(\",\"))\n .join(\" \");\n }, [lineRect, mask]);\n\n if (!line) {\n // This happens when source or target is not found,\n // or when source or target has not been positioned yet.\n return null;\n }\n\n let markerStart: string | undefined;\n let markerEnd: string | undefined;\n let strokeColor: string | undefined;\n let strokeWidth: number | undefined;\n let motion: EdgeLineMotion | undefined;\n const lineMarkers: LineMarkerConf[] = getMarkers(lineConf);\n if (active) {\n const overrides = lineConf.overrides?.active;\n strokeColor = overrides?.strokeColor ?? lineConf.strokeColor;\n strokeWidth = overrides?.strokeWidth ?? lineConf.strokeWidth;\n motion = overrides?.motion;\n for (const marker of lineMarkers) {\n if (marker.placement === \"start\") {\n markerStart =\n lineConf.$activeMarkerStartUrl ?? lineConf.$markerStartUrl;\n } else {\n markerEnd = lineConf.$activeMarkerEndUrl ?? lineConf.$markerEndUrl;\n }\n }\n } else if (activeRelated) {\n const overrides = lineConf.overrides?.activeRelated;\n strokeColor = overrides?.strokeColor ?? lineConf.strokeColor;\n strokeWidth = overrides?.strokeWidth ?? lineConf.strokeWidth;\n motion = overrides?.motion;\n for (const marker of lineMarkers) {\n if (marker.placement === \"start\") {\n markerStart =\n lineConf.$activeRelatedMarkerStartUrl ?? lineConf.$markerStartUrl;\n } else {\n markerEnd =\n lineConf.$activeRelatedMarkerEndUrl ?? lineConf.$markerEndUrl;\n }\n }\n } else {\n strokeColor = lineConf.strokeColor;\n strokeWidth = lineConf.strokeWidth;\n for (const marker of lineMarkers) {\n if (marker.placement === \"start\") {\n markerStart = lineConf.$markerStartUrl;\n } else {\n markerEnd = lineConf.$markerEndUrl;\n }\n }\n }\n\n let motionPath: string | undefined;\n if (motion?.shape === \"dot\") {\n const radius = motion.size == null ? strokeWidth * 2 : motion.size / 2;\n motionPath = `M 0,${-radius} A ${radius},${radius} 0,1,1 0,${radius} A ${radius},${radius} 0,1,1 0,${-radius} z`;\n } else if (motion?.shape === \"triangle\") {\n const radius = motion.size == null ? strokeWidth * 2 : motion.size / 2;\n const offset = radius / Math.sqrt(3);\n motionPath = `M ${-offset},${radius} v ${-radius * 2} L ${offset * 2},0 z`;\n }\n let motionDuration: string | undefined;\n if (pathLength) {\n motionDuration = `${pathLength / (motion?.speed ?? DEFAULT_MOTION_SPEED)}s`;\n }\n\n const hasMotion = [\n lineConf.overrides?.active?.motion?.shape,\n lineConf.overrides?.activeRelated?.motion?.shape,\n ].some((item) => item === \"dot\" || item === \"triangle\");\n\n const clipPathUrl = clipPathPoints\n ? `url(#${lineClipPathPrefix})`\n : undefined;\n\n return (\n <>\n {clipPathPoints && (\n <defs>\n <clipPath id={lineClipPathPrefix}>\n <polygon points={clipPathPoints} />\n </clipPath>\n </defs>\n )}\n <g className=\"line-group\" onDoubleClick={onDoubleClick}>\n <path\n // This `path` is made for expanding interaction area of graph lines.\n d={line}\n fill=\"none\"\n stroke=\"transparent\"\n strokeWidth={lineConf.interactStrokeWidth}\n clipPath={clipPathUrl}\n />\n <path\n ref={pathRefCallback}\n className={classNames(\"line\", {\n dashed: lineConf.dashed,\n dotted: lineConf.dotted,\n [`${lineConf.dashed ? \"dashed\" : lineConf.dotted ? \"dotted\" : \"solid\"}-animation`]:\n lineConf.animate.useAnimate,\n })}\n clipPath={clipPathUrl}\n style={\n {\n \"--time\": `${lineConf.animate.duration ?? DEFAULT_LINE_INTERACT_ANIMATE_DURATION}s`,\n \"--solid-length\": pathLength,\n } as React.CSSProperties\n }\n d={line}\n fill=\"none\"\n stroke={strokeColor}\n strokeWidth={strokeWidth}\n markerStart={markerStart}\n markerEnd={markerEnd}\n />\n {!lineConf.overrides?.active && (\n <path\n className=\"line-active-bg\"\n d={line}\n fill=\"none\"\n clipPath={clipPathUrl}\n />\n )}\n {\n // No dur in old browsers will cause animation not working.\n // So always set a dur.\n hasMotion && motionDuration && (\n <path\n className={classNames(\"motion\", { visible: !!motionPath })}\n d={motionPath}\n fill={strokeColor}\n >\n <animateMotion\n dur={motionDuration}\n repeatCount={\"indefinite\"}\n rotate={\"auto\"}\n path={line}\n />\n </path>\n )\n }\n </g>\n <LineLabelComponent\n edge={edge}\n position={labelPosition}\n offset={labelOffset}\n label={lineConf.label}\n text={lineConf.text}\n onClick={onLabelClick}\n onRendered={handleLabelRendered}\n />\n </>\n );\n}\n","import type {\n PositionTuple,\n SimpleRect,\n SizeTuple,\n} from \"../../diagram/interfaces\";\nimport type { PositionAndAngle } from \"../interfaces\";\n\nexport function getLabelMaskAndOffset(\n labelPosition: PositionAndAngle | null,\n labelSize: SizeTuple | null\n): [labelMask: SimpleRect | null, labelOffset: PositionTuple | null] {\n if (!labelPosition || !labelSize) {\n return [null, null];\n }\n const padding = 3;\n const [x, y, direction, angle, offset] = labelPosition;\n const [width, height] = labelSize;\n\n const left = x - width / 2 - padding;\n const top = y - height / 2 - padding;\n let offsetX = 0;\n let offsetY = 0;\n const halfWidth = width / 2 + padding;\n const halfHeight = height / 2 + padding;\n switch (direction) {\n case \"top\":\n offsetX = offset * Math.cos(angle) - halfHeight / Math.tan(angle);\n offsetY = offset * Math.sin(angle) - halfHeight;\n break;\n case \"bottom\":\n offsetX = offset * Math.cos(angle) + halfHeight / Math.tan(angle);\n offsetY = offset * Math.sin(angle) + halfHeight;\n break;\n case \"left\":\n offsetX = offset * Math.cos(angle) - halfWidth;\n offsetY = offset * Math.sin(angle) - halfWidth * Math.tan(angle);\n break;\n case \"right\":\n offsetX = offset * Math.cos(angle) + halfWidth;\n offsetY = offset * Math.sin(angle) + halfWidth * Math.tan(angle);\n break;\n }\n\n return [\n {\n left: left + offsetX,\n top: top + offsetY,\n width: width + padding * 2,\n height: height + padding * 2,\n },\n [offsetX, offsetY],\n ];\n}\n","import React from \"react\";\n\nexport interface LockIconProps {\n x: number;\n y: number;\n}\n\nexport function LockIcon({ x, y }: LockIconProps) {\n // 12 / 512 = 0.0234375\n return (\n <g\n transform={`translate(${x}, ${y}) scale(0.0234375)`}\n className=\"lock-icon\"\n >\n <path\n d=\"M144 144l0 48 160 0 0-48c0-44.2-35.8-80-80-80s-80 35.8-80 80zM80 192l0-48C80 64.5 144.5 0 224 0s144 64.5 144 144l0 48 16 0c35.3 0 64 28.7 64 64l0 192c0 35.3-28.7 64-64 64L64 512c-35.3 0-64-28.7-64-64L0 256c0-35.3 28.7-64 64-64l16 0z\"\n fill=\"var(--color-secondary-text)\"\n stroke=\"none\"\n />\n </g>\n );\n}\n","import React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { ReactUseBrick } from \"@next-core/react-runtime\";\nimport { __secret_internals, checkIfByTransform } from \"@next-core/runtime\";\nimport { isEqual } from \"lodash\";\nimport ResizeObserver from \"resize-observer-polyfill\";\nimport type {\n NodeBrickCell,\n NodeBrickConf,\n NodeCell,\n NodeComponentCell,\n} from \"./interfaces\";\nimport type { SizeTuple } from \"../diagram/interfaces\";\nimport { LockIcon } from \"./LockIcon\";\n\nexport interface NodeComponentProps {\n node: NodeCell;\n x?: number;\n y?: number;\n degraded: boolean;\n degradedNodeLabel?: string;\n defaultNodeBricks?: NodeBrickConf[];\n locked?: boolean;\n containerLocked?: boolean;\n groupLocked?: boolean;\n onResize(id: string, size: SizeTuple | null): void;\n}\n\nexport function NodeComponent({\n node,\n x,\n y,\n degraded,\n degradedNodeLabel,\n defaultNodeBricks,\n locked,\n containerLocked,\n groupLocked,\n onResize,\n}: NodeComponentProps): JSX.Element | null {\n const memoizedData = useDeepMemo({\n node: { id: node.id, data: node.data, locked: !!locked },\n });\n const specifiedUseBrick = (node as NodeBrickCell).useBrick;\n const specifiedComponent = (node as NodeComponentCell).component;\n const observerRef = useRef<ResizeObserver | null>(null);\n\n const { useBrick, component: Component } =\n useMemo<\n Pick<NodeBrickConf, \"useBrick\" | \"component\"> | null | undefined\n >(() => {\n return degraded\n ? null\n : specifiedUseBrick\n ? {\n useBrick: specifiedUseBrick,\n }\n : specifiedComponent\n ? {\n component: specifiedComponent,\n }\n : defaultNodeBricks?.find((item) =>\n checkIfByTransform(item, memoizedData)\n );\n }, [\n defaultNodeBricks,\n degraded,\n memoizedData,\n specifiedComponent,\n specifiedUseBrick,\n ]) ?? {};\n\n const label = useMemo<string>(\n () =>\n degraded\n ? String(\n __secret_internals.legacyDoTransform(\n memoizedData,\n degradedNodeLabel ?? \"<% DATA.node.id %>\"\n )\n )\n : \"\",\n [degraded, degradedNodeLabel, memoizedData]\n );\n\n const brickRef = useRef<HTMLElement | null>(null);\n const xRef = useRef<number | undefined>(x);\n const yRef = useRef<number | undefined>(y);\n\n const refCallback = useCallback(\n (element: HTMLElement | null) => {\n brickRef.current = element;\n const prevObserver = observerRef.current;\n if (prevObserver) {\n prevObserver.disconnect();\n observerRef.current = null;\n }\n if (element) {\n if (xRef.current != null && yRef.current != null) {\n element.style.left = `${xRef.current}px`;\n element.style.top = `${yRef.current}px`;\n }\n // Todo: correctly wait for `useBrick` in v3 to be rendered (after layout)\n // Wait a macro task to let `useBrick` to be rendered.\n setTimeout(() => {\n const observer = new ResizeObserver(() => {\n onResize(node.id, [element.offsetWidth, element.offsetHeight]);\n });\n observer.observe(element);\n observerRef.current = observer;\n });\n } else {\n onResize(node.id, null);\n }\n },\n [node.id, onResize]\n );\n\n // Use position instead of transform, for clients\n // that hardware acceleration (GPU) is not available.\n useEffect(() => {\n xRef.current = x;\n yRef.current = y;\n const element = brickRef.current;\n if (element && x != null && y != null) {\n element.style.top = `${y}px`;\n element.style.left = `${x}px`;\n }\n }, [x, y]);\n\n const degradedRefCallBack = useCallback(\n (g: SVGGElement | null) => {\n if (g) {\n // istanbul ignore next\n const size =\n process.env.NODE_ENV === \"test\"\n ? { width: 60, height: 60 }\n : g.getBBox();\n onResize(node.id, [size.width, size.height]);\n } else {\n onResize(node.id, null);\n }\n },\n [node.id, onResize]\n );\n\n const foreignObjectRef = useRef<SVGForeignObjectElement | null>(null);\n\n // Workaround for Firefox bug:\n // https://bugzilla.mozilla.org/show_bug.cgi?id=1644680\n // istanbul ignore next\n useEffect(() => {\n const fo = foreignObjectRef.current;\n if (!fo || !/firefox/i.test(navigator.userAgent)) {\n return;\n }\n fo.style.overflow = \"hidden\";\n // 延时 500ms 是经验值,实际测试如果机器性能较差,可能需要更长的时间。\n // MacBook Air M1 >= 100ms 可以工作,<= 50ms 则不行。\n const timeoutId = setTimeout(() => {\n fo.style.overflow = \"visible\";\n }, 500);\n return () => clearTimeout(timeoutId);\n }, []);\n\n return (\n <>\n {useBrick || Component ? (\n <foreignObject\n // Make a large size to avoid the brick inside to be clipped by the foreignObject.\n width={9999}\n height={9999}\n className=\"node\"\n ref={foreignObjectRef}\n >\n {Component ? (\n <Component {...memoizedData} refCallback={refCallback} />\n ) : (\n <ReactUseBrick\n useBrick={useBrick!}\n data={memoizedData}\n refCallback={refCallback}\n />\n )}\n </foreignObject>\n ) : degraded ? (\n <g className=\"degraded\" ref={degradedRefCallBack}>\n <circle cx={8} cy={8} r={8} />\n <text x={8} y={32}>\n {label}\n </text>\n </g>\n ) : null}\n {locked &&\n ![containerLocked, groupLocked].some(Boolean) &&\n x != null &&\n y != null && (\n <LockIcon x={x + node.view.width + 4} y={y + node.view.height - 12} />\n )}\n </>\n );\n}\n\nfunction useDeepMemo<T>(value: T): T {\n const [memoizedValue, setMemoizedValue] = useState(value);\n\n useEffect(() => {\n setMemoizedValue((prev) => (isEqual(prev, value) ? prev : value));\n }, [value]);\n\n return memoizedValue;\n}\n","import type { PositionTuple } from \"../../diagram/interfaces\";\nimport type { NodeView, SnapToObjectPosition } from \"../interfaces\";\n\nconst DEFAULT_ALL_POSITIONS = [\"center\", \"top\", \"bottom\", \"left\", \"right\"];\n\nexport type SnapPositions = Partial<\n Record<SnapToObjectPosition, PositionTuple>\n>;\n\nexport function getSnapPositions(\n view: NodeView,\n positions: string | undefined\n) {\n const snapPositions: SnapPositions = {};\n for (const position of positions\n ?.split(/\\s+/g)\n ?.flatMap((pos) => (pos === \"all\" ? DEFAULT_ALL_POSITIONS : pos)) ?? []) {\n let tuple: PositionTuple;\n const cx = view.x + view.width / 2;\n const cy = view.y + view.height / 2;\n switch (position) {\n case \"center\":\n tuple = [cx, cy];\n break;\n case \"top\":\n tuple = [cx, view.y];\n break;\n case \"right\":\n tuple = [view.x + view.width, cy];\n break;\n case \"bottom\":\n tuple = [cx, view.y + view.height];\n break;\n case \"left\":\n tuple = [view.x, cy];\n break;\n default:\n throw new Error(`Unknown snap position: \"${position}\"`);\n }\n snapPositions[position] = tuple;\n }\n return snapPositions;\n}\n","import { map } from \"lodash\";\nimport type { PositionTuple } from \"../../diagram/interfaces\";\nimport type {\n ActiveTarget,\n Cell,\n LayoutOptions,\n DecoratorCell,\n LayoutType,\n NodeCell,\n SnapToObjectPosition,\n ActiveTargetOfSingular,\n EditableLineCell,\n} from \"../interfaces\";\nimport type {\n MoveCellPayload,\n ResizeCellPayload,\n} from \"../reducers/interfaces\";\nimport {\n isContainerDecoratorCell,\n isDecoratorCell,\n isEdgeCell,\n isGroupDecoratorCell,\n isLineDecoratorCell,\n isNodeCell,\n} from \"./asserts\";\nimport { cellToTarget } from \"./cellToTarget\";\nimport { getSnapPositions, type SnapPositions } from \"./getSnapPositions\";\nimport { getLockedContainerIds, isLocked } from \"./isLocked\";\nimport { normalizeSnapOptions } from \"./normalizeSnapOptions\";\nimport { sameTarget } from \"./sameTarget\";\nimport { targetIsActive } from \"./targetIsActive\";\n\nconst HORIZONTAL_POSITIONS = [\"left\", \"center\", \"right\"];\nconst VERTICAL_POSITIONS = [\"top\", \"center\", \"bottom\"];\n\nexport function handleMouseDown(\n event: MouseEvent,\n {\n action,\n cell,\n scale,\n layout,\n layoutOptions,\n activeTarget,\n cells,\n onCellsMoving,\n onCellsMoved,\n onCellResizing,\n onCellResized,\n onSwitchActiveTarget,\n updateCurActiveEditableLine,\n }: {\n action: \"move\" | \"resize\";\n cell: Cell;\n scale: number;\n layout?: LayoutType;\n layoutOptions?: LayoutOptions;\n activeTarget: ActiveTarget | null | undefined;\n cells: Cell[];\n onCellsMoving?(info: MoveCellPayload[]): void;\n onCellsMoved?(info: MoveCellPayload[]): void;\n onCellResizing?(info: ResizeCellPayload): void;\n onCellResized?(info: ResizeCellPayload): void;\n onSwitchActiveTarget?(activeTarget: ActiveTarget | null): void;\n updateCurActiveEditableLine?: (\n activeEditableLine: EditableLineCell | null\n ) => void;\n }\n) {\n event.stopPropagation();\n\n // Ignore contextmenu click\n if (event.button === 2 || (event.button === 0 && event.ctrlKey)) {\n return;\n }\n\n // Drag node\n const preActive = targetIsActive(cell, activeTarget);\n const lockedContainerIds = getLockedContainerIds(cells);\n let canUpdateActiveEditableLine = false;\n if (event.shiftKey) {\n const activeTargets = activeTarget\n ? activeTarget?.type === \"multi\"\n ? activeTarget.targets\n : [activeTarget]\n : [];\n let targets: ActiveTargetOfSingular[] = [];\n if (preActive) {\n targets = activeTargets.filter((target) => !sameTarget(target, cell));\n } else {\n targets = [...activeTargets, cell];\n canUpdateActiveEditableLine = true;\n }\n onSwitchActiveTarget?.(\n targets.length > 0 ? { type: \"multi\", targets } : null\n );\n } else {\n if (action === \"resize\" || !preActive) {\n onSwitchActiveTarget?.(cellToTarget(cell));\n canUpdateActiveEditableLine = true;\n }\n }\n\n if (isLocked(cell, lockedContainerIds)) {\n return;\n }\n\n if (\n canUpdateActiveEditableLine &&\n (isEdgeCell(cell) || isLineDecoratorCell(cell))\n ) {\n updateCurActiveEditableLine?.(cell);\n }\n\n if (isEdgeCell(cell)) {\n return;\n }\n\n const activeCells: Cell[] = [];\n const actives =\n activeTarget?.type === \"multi\" && action === \"move\"\n ? cells.filter((c) => targetIsActive(c, activeTarget))\n : [cell];\n actives.forEach((a) => {\n activeCells.push(a);\n if (action === \"move\") {\n if (isContainerDecoratorCell(a)) {\n const groupIds = map(\n cells.filter(\n (c) => isGroupDecoratorCell(c) && c.containerId === a.id\n ),\n \"id\"\n );\n const nodeCells = cells.filter(\n (c) =>\n ((isNodeCell(c) || isGroupDecoratorCell(c)) &&\n c.containerId === a.id &&\n !actives.includes(c)) ||\n (isNodeCell(c) && groupIds.includes(c?.groupId))\n );\n activeCells.push(...nodeCells);\n }\n if (isGroupDecoratorCell(a)) {\n activeCells.push(\n ...cells.filter(\n (c) => isNodeCell(c) && c.groupId === a.id && !actives.includes(c)\n )\n );\n }\n }\n });\n const isAutoLayout = layout === \"force\" || layout === \"dagre\";\n const movableActiveCells = activeCells.filter(\n (c) =>\n !isLocked(c, lockedContainerIds) &&\n ((isNodeCell(c) && !isAutoLayout) || isDecoratorCell(c))\n ) as (NodeCell | DecoratorCell)[];\n\n if (movableActiveCells.length === 0) {\n return;\n }\n\n const snap = normalizeSnapOptions(layoutOptions?.snap);\n const snapToObjectPositions = snap.object?.positions;\n\n const from: PositionTuple = [event.clientX, event.clientY];\n const originals = movableActiveCells.map<{\n cell: NodeCell | DecoratorCell;\n position: PositionTuple;\n snapPositions: SnapPositions | null;\n }>((c) => ({\n cell: c,\n position:\n action === \"move\" ? [c.view.x, c.view.y] : [c.view.width, c.view.height],\n snapPositions:\n action === \"move\" && !isEdgeCell(c)\n ? getSnapPositions(c.view, snapToObjectPositions)\n : null,\n }));\n const firstOriginalPosition = originals[0].position;\n // let previousPositions = originals.map(({ position }) => position);\n\n // Get the positions of the objects (cells that are not active) to snap to\n let snapToObjectTargets: {\n cell: NodeCell | DecoratorCell;\n snapPositions: SnapPositions;\n }[] = [];\n if (action === \"move\" && snap.object) {\n const objectCells = cells.filter(\n // Edge and line cells are not snap targets\n (c) =>\n !isEdgeCell(c) && !isLineDecoratorCell(c) && !activeCells.includes(c)\n ) as (NodeCell | DecoratorCell)[];\n snapToObjectTargets = objectCells.map((c) => ({\n cell: c,\n snapPositions: getSnapPositions(c.view, snapToObjectPositions),\n }));\n }\n\n function getMovement(e: MouseEvent): PositionTuple {\n return [(e.clientX - from[0]) / scale, (e.clientY - from[1]) / scale];\n }\n let moved = false;\n\n const handleMove = (e: MouseEvent, finished?: boolean) => {\n // Respect the scale\n const movement = getMovement(e);\n const snapMovement: PositionTuple = [...movement];\n let newPositions: PositionTuple[];\n let xAlign: [PositionTuple, PositionTuple] | undefined;\n let yAlign: [PositionTuple, PositionTuple] | undefined;\n let xAlignCell: Cell | undefined;\n let yAlignCell: Cell | undefined;\n\n if (!moved) {\n moved = movement[0] ** 2 + movement[1] ** 2 >= 9;\n }\n\n // Use alt key (or option key ⌥ on Mac) to disable snap\n if ((!snap.grid && !snap.object) || e.altKey) {\n // No snap\n newPositions = originals.map(({ position }) => [\n position[0] + movement[0],\n position[1] + movement[1],\n ]);\n } else {\n // Snap\n let diffX = Infinity;\n let diffY = Infinity;\n\n if (snap.object) {\n const snapToObjectDistance = snap.object.distance;\n let xAlignFrom: PositionTuple | undefined;\n let yAlignFrom: PositionTuple | undefined;\n let xAlignTarget: NodeCell | DecoratorCell | undefined;\n let yAlignTarget: NodeCell | DecoratorCell | undefined;\n let xAlignToY = 0;\n let yAlignToX = 0;\n for (const {\n cell: target,\n snapPositions: targetPositions,\n // center: [x, y],\n } of snapToObjectTargets) {\n for (const {\n cell: c,\n snapPositions: originalPositions,\n } of originals) {\n for (const [position, originalPoint] of Object.entries(\n originalPositions!\n )) {\n const horizontal = HORIZONTAL_POSITIONS.includes(position);\n const vertical = VERTICAL_POSITIONS.includes(position);\n const [x, y] = targetPositions[position as SnapToObjectPosition]!;\n const [cx, cy] = originalPoint!;\n if (horizontal) {\n const dX = Math.abs(cx + movement[0] - x);\n const xSnapped = dX < snapToObjectDistance && dX < diffX;\n if (xSnapped) {\n diffX = dX;\n snapMovement[0] = x - cx;\n xAlignCell = c;\n xAlignTarget = target;\n xAlignFrom = [x, y];\n xAlignToY = cy;\n }\n }\n if (vertical) {\n const dY = Math.abs(cy + movement[1] - y);\n const ySnapped = dY < snapToObjectDistance && dY < diffY;\n if (ySnapped) {\n diffY = dY;\n snapMovement[1] = y - cy;\n yAlignCell = c;\n yAlignTarget = target;\n yAlignFrom = [x, y];\n yAlignToX = cx;\n }\n }\n }\n }\n }\n\n if (xAlignTarget && xAlignTarget === yAlignTarget) {\n // Handle special case when both x and y are snapped to the same target.\n const halfHeight = xAlignTarget.view.height / 2;\n const halfWidth = xAlignTarget.view.width / 2;\n xAlign = [\n [xAlignFrom![0], xAlignFrom![1] - halfHeight],\n [xAlignFrom![0], xAlignFrom![1] + halfHeight],\n ];\n yAlign = [\n [yAlignFrom![0] - halfWidth, yAlignFrom![1]],\n [yAlignFrom![0] + halfWidth, yAlignFrom![1]],\n ];\n } else {\n if (xAlignFrom) {\n xAlign = [xAlignFrom, [xAlignFrom[0], xAlignToY + snapMovement[1]]];\n }\n if (yAlignFrom) {\n yAlign = [yAlignFrom, [yAlignToX + snapMovement[0], yAlignFrom[1]]];\n }\n }\n }\n\n if (snap.grid) {\n const snapToGridSize = snap.grid.size;\n // Use the first cell to decide the snap to grid position\n const firstNewPosition: PositionTuple = [\n Math.round(\n (firstOriginalPosition[0] + movement[0]) / snapToGridSize\n ) * snapToGridSize,\n Math.round(\n (firstOriginalPosition[1] + movement[1]) / snapToGridSize\n ) * snapToGridSize,\n ];\n const snapToGridMovement: PositionTuple = [\n firstNewPosition[0] - firstOriginalPosition[0],\n firstNewPosition[1] - firstOriginalPosition[1],\n ];\n const snapToGridDiffX = Math.abs(snapToGridMovement[0] - movement[0]);\n const snapToGridDiffY = Math.abs(snapToGridMovement[1] - movement[1]);\n if (snapToGridDiffX < diffX) {\n diffX = snapToGridDiffX;\n snapMovement[0] = snapToGridMovement[0];\n xAlign = undefined;\n xAlignCell = undefined;\n }\n if (snapToGridDiffY < diffY) {\n diffY = snapToGridDiffY;\n snapMovement[1] = snapToGridMovement[1];\n yAlign = undefined;\n yAlignCell = undefined;\n }\n }\n\n newPositions = originals.map(({ position }) => [\n position[0] + snapMovement[0],\n position[1] + snapMovement[1],\n ]);\n }\n\n if (moved) {\n if (action === \"move\") {\n const payloads = originals.map(({ cell: c }, index) => ({\n type: c.type,\n id: c.id,\n x: newPositions[index][0],\n y: newPositions[index][1],\n groupId: c.groupId,\n containerId: c.containerId,\n width: c.view.width,\n height: c.view.height,\n decorator: isDecoratorCell(c) ? c.decorator : undefined,\n guideLines: finished\n ? undefined\n : [\n ...(xAlignCell === c ? [xAlign!] : []),\n ...(yAlignCell === c ? [yAlign!] : []),\n ],\n ...(isLineDecoratorCell(c)\n ? {\n source: {\n x: c.view.source.x + snapMovement[0],\n y: c.view.source.y + snapMovement[1],\n },\n target: {\n x: c.view.target.x + snapMovement[0],\n y: c.view.target.y + snapMovement[1],\n },\n vertices: c.view.vertices?.map((v) => ({\n x: v.x + snapMovement[0],\n y: v.y + snapMovement[1],\n })),\n }\n : null),\n }));\n (finished ? onCellsMoved : onCellsMoving)?.(payloads);\n } else {\n (finished ? onCellResized : onCellResizing)?.({\n type: cell.type,\n id: cell.id,\n width: newPositions[0][0],\n height: newPositions[0][1],\n });\n }\n }\n };\n\n const onMouseMove = (e: MouseEvent) => {\n handleMove(e);\n };\n const onMouseUp = (e: MouseEvent) => {\n handleMove(e, true);\n moved = false;\n document.removeEventListener(\"mousemove\", onMouseMove);\n document.removeEventListener(\"mouseup\", onMouseUp);\n };\n document.addEventListener(\"mousemove\", onMouseMove);\n document.addEventListener(\"mouseup\", onMouseUp);\n}\n","import {\n DEFAULT_SNAP_GRID_SIZE,\n DEFAULT_SNAP_OBJECT_DISTANCE,\n DEFAULT_SNAP_OBJECT_POSITIONS,\n} from \"../constants\";\nimport type {\n SnapOptions,\n SnapToGridOptions,\n SnapToObjectOptions,\n} from \"../interfaces\";\n\nexport interface NormalizedSnapOptions {\n grid: Required<SnapToGridOptions> | null;\n object: Required<SnapToObjectOptions> | null;\n}\n\nexport function normalizeSnapOptions(\n snap: boolean | SnapOptions | undefined\n): NormalizedSnapOptions {\n const intermediateSnap = snap\n ? snap === true\n ? { grid: true, object: true }\n : snap\n : null;\n const snapToGrid = intermediateSnap?.grid\n ? intermediateSnap.grid === true\n ? {}\n : intermediateSnap.grid\n : null;\n const snapToObject = intermediateSnap?.object\n ? intermediateSnap.object === true\n ? {}\n : intermediateSnap.object\n : null;\n return {\n grid: snapToGrid\n ? { size: snapToGrid.size ?? DEFAULT_SNAP_GRID_SIZE }\n : null,\n object: snapToObject\n ? {\n distance: snapToObject.distance ?? DEFAULT_SNAP_OBJECT_DISTANCE,\n positions: snapToObject.positions ?? DEFAULT_SNAP_OBJECT_POSITIONS,\n }\n : null,\n };\n}\n","// istanbul ignore file: compatibility workaround\nimport type { HTMLAttributes } from \"react\";\n\nlet _supports: boolean | undefined;\n\nfunction supportsContentEditablePlaintextOnly(): boolean {\n if (typeof _supports !== \"boolean\") {\n const div = document.createElement(\"div\");\n div.setAttribute(\"contenteditable\", \"PLAINTEXT-ONLY\");\n _supports = div.contentEditable === \"plaintext-only\";\n }\n return _supports;\n}\n\nexport function getContentEditable(\n editable: boolean\n): HTMLAttributes<HTMLDivElement>[\"contentEditable\"] {\n return editable\n ? supportsContentEditablePlaintextOnly()\n ? \"plaintext-only\"\n : \"true\"\n : \"false\";\n}\n","import React, { useCallback, useEffect, useRef, useState } from \"react\";\nimport type { BasicDecoratorProps } from \"../interfaces\";\nimport classNames from \"classnames\";\nimport { LockIcon } from \"../LockIcon\";\nimport { getContentEditable } from \"../processors/getContentEditable\";\n\nexport type DecoratorTextProps = Pick<\n BasicDecoratorProps,\n | \"cell\"\n | \"readOnly\"\n | \"locked\"\n | \"onDecoratorTextEditing\"\n | \"onDecoratorTextChange\"\n>;\n\nexport function DecoratorText({\n cell,\n readOnly,\n locked,\n onDecoratorTextEditing,\n onDecoratorTextChange,\n}: DecoratorTextProps): JSX.Element {\n const label = cell.view.text ?? \"\";\n const [currentLabel, setCurrentLabel] = useState<string>(label);\n const [editingLabel, setEditingLabel] = useState(false);\n const editingLabelInitialized = useRef(false);\n const [shouldEmitLabelChange, setShouldEmitLabelChange] = useState(false);\n const ref = useRef<HTMLDivElement>(null);\n\n const handleEnableEdit = useCallback(\n (e: React.MouseEvent) => {\n if (readOnly || locked) {\n return;\n }\n e.preventDefault();\n e.stopPropagation();\n setEditingLabel(true);\n },\n [readOnly, locked]\n );\n\n useEffect(() => {\n const element = ref.current;\n if (element && element.textContent !== currentLabel) {\n element.textContent = currentLabel;\n }\n }, [currentLabel]);\n useEffect(() => {\n const parentElement = ref.current?.parentElement;\n if (parentElement) {\n cell.view.width = parentElement.clientWidth;\n cell.view.height = parentElement.clientHeight;\n }\n }, [currentLabel, cell.id]);\n\n useEffect(() => {\n if (editingLabel && ref.current) {\n ref.current.focus();\n selectAllText(ref.current);\n }\n onDecoratorTextEditing?.({ id: cell.id, editing: editingLabel });\n }, [cell.id, editingLabel, onDecoratorTextEditing]);\n\n useEffect(() => {\n if (editingLabelInitialized.current) {\n onDecoratorTextEditing?.({ id: cell.id, editing: editingLabel });\n } else {\n editingLabelInitialized.current = true;\n }\n }, [cell.id, editingLabel, onDecoratorTextEditing]);\n\n const handleInput = useCallback(\n (event: React.FormEvent<HTMLDivElement>) => {\n if (readOnly) {\n return;\n }\n setCurrentLabel((event.target as HTMLDivElement).textContent!);\n },\n [readOnly]\n );\n\n const handleBlur = useCallback(() => {\n if (readOnly) {\n return;\n }\n setEditingLabel(false);\n setShouldEmitLabelChange(true);\n }, [readOnly]);\n\n useEffect(() => {\n if (shouldEmitLabelChange) {\n onDecoratorTextChange?.({\n id: cell.id,\n view: { ...cell.view, text: currentLabel },\n });\n setShouldEmitLabelChange(false);\n }\n }, [cell, currentLabel, onDecoratorTextChange, shouldEmitLabelChange]);\n\n return (\n <>\n <foreignObject className=\"decorator-text\" width=\"9999\" height=\"9999\">\n <div\n className={classNames(\"text-container\", { editing: editingLabel })}\n onDoubleClick={handleEnableEdit}\n style={cell.view.style}\n >\n <div\n className=\"text\"\n contentEditable={getContentEditable(editingLabel)}\n ref={ref}\n onInput={handleInput}\n onBlur={handleBlur}\n />\n </div>\n </foreignObject>\n {locked && (\n <LockIcon x={cell.view.width} y={(cell.view.height - 12) / 2} />\n )}\n </>\n );\n}\n\nexport function selectAllText(element: HTMLElement) {\n const range = document.createRange();\n range.selectNodeContents(element);\n const selection = window.getSelection()!;\n selection.removeAllRanges();\n selection.addRange(range);\n}\n","import React from \"react\";\nimport type { BasicDecoratorProps, DecoratorType } from \"../interfaces\";\nimport { DecoratorArea } from \"./DecoratorArea\";\nimport { DecoratorText } from \"./DecoratorText\";\nimport { DecoratorContainer } from \"./DecoratorContainer\";\nimport { DecoratorRect } from \"./DecoratorRect\";\nimport { DecoratorLine } from \"./DecoratorLine\";\nimport { DecoratorGroup } from \"./DecoratorGroup\";\n\nconst decoratorComponents = new Map<\n DecoratorType,\n React.ComponentType<BasicDecoratorProps>\n>([\n [\"group\", DecoratorGroup],\n [\"container\", DecoratorContainer],\n [\"area\", DecoratorArea],\n [\"text\", DecoratorText],\n [\"rect\", DecoratorRect],\n [\"line\", DecoratorLine],\n]);\n\nexport function DecoratorComponent({\n cell,\n view,\n transform,\n readOnly,\n layout,\n layoutOptions,\n active,\n activeTarget,\n cells,\n lineConfMap,\n editableLineMap,\n locked,\n onCellResizing,\n onCellResized,\n onSwitchActiveTarget,\n onDecoratorTextEditing,\n onDecoratorTextChange,\n onDecoratorGroupPlusClick,\n}: BasicDecoratorProps): JSX.Element | null {\n const SpecifiedComponent = decoratorComponents.get(cell.decorator);\n\n if (!SpecifiedComponent) {\n // eslint-disable-next-line no-console\n console.error(`Unknown decorator: ${cell.decorator}`);\n return null;\n }\n\n return (\n <SpecifiedComponent\n cell={cell}\n view={view}\n transform={transform}\n readOnly={readOnly}\n layout={layout}\n layoutOptions={layoutOptions}\n active={active}\n activeTarget={activeTarget}\n cells={cells}\n lineConfMap={lineConfMap}\n editableLineMap={editableLineMap}\n locked={locked}\n onCellResizing={onCellResizing}\n onCellResized={onCellResized}\n onSwitchActiveTarget={onSwitchActiveTarget}\n onDecoratorTextEditing={onDecoratorTextEditing}\n onDecoratorTextChange={onDecoratorTextChange}\n onDecoratorGroupPlusClick={onDecoratorGroupPlusClick}\n />\n );\n}\n","import React, { useMemo } from \"react\";\nimport type { BasicDecoratorProps } from \"../interfaces\";\nimport { LockIcon } from \"../LockIcon\";\nimport classNames from \"classnames\";\nimport { PlusOutlined } from \"@ant-design/icons\";\nimport { highlightGroupCell } from \"../processors/initialGroupLayout\";\n\nexport type DecoratorRectProps = Omit<\n BasicDecoratorProps,\n \"lineConfMap\" | \"editableLineMap\"\n>;\n\nexport function DecoratorGroup({\n cell,\n view,\n activeTarget,\n cells,\n locked,\n onDecoratorGroupPlusClick,\n}: DecoratorRectProps): JSX.Element {\n const active = useMemo(\n () => highlightGroupCell(cell, activeTarget, cells),\n [activeTarget, cell, cells]\n );\n\n return (\n <g\n className={classNames(\"decorator-group\", {\n [\"active-group\"]: active,\n })}\n >\n <foreignObject\n className=\"group-wrapper\"\n width={cell.view.width + 10}\n height={cell.view.height + 10}\n >\n <div\n className=\"group\"\n style={{\n ...cell.view?.style,\n width: cell.view.width,\n height: cell.view.height,\n }}\n >\n {view.usePlus && (\n <PlusOutlined\n className=\"plus-icon\"\n onClick={() => onDecoratorGroupPlusClick?.(cell)}\n />\n )}\n </div>\n </foreignObject>\n {locked && (\n <LockIcon x={cell.view.width! - 16} y={cell.view.height! - 16} />\n )}\n </g>\n );\n}\n","import React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { BasicDecoratorProps, NodeCell } from \"../interfaces\";\nimport { handleMouseDown } from \"../processors/handleMouseDown\";\nimport classNames from \"classnames\";\nimport { get } from \"lodash\";\nimport { selectAllText } from \"./DecoratorText\";\nimport { isNoManualLayout } from \"../processors/asserts\";\nimport { uuidV4 } from \"..\";\nimport { LockIcon } from \"../LockIcon\";\nimport { getContentEditable } from \"../processors/getContentEditable\";\n\nexport function DecoratorContainer({\n cell,\n transform,\n readOnly,\n layout,\n view,\n activeTarget,\n cells,\n locked,\n onCellResizing,\n onCellResized,\n onSwitchActiveTarget,\n onDecoratorTextEditing,\n onDecoratorTextChange,\n}: BasicDecoratorProps): JSX.Element {\n const label = get(cell.view, \"text\", \"\");\n const direction = get(cell.view, \"direction\", \"top\");\n const textRef = useRef<HTMLDivElement>(null);\n const resizeHandleRef = React.useRef<SVGGElement>(null);\n const [editingLabel, setEditingLabel] = useState(false);\n const [currentLabel, setCurrentLabel] = useState<string>(label);\n const [shouldEmitLabelChange, setShouldEmitLabelChange] = useState(false);\n const [recomputation, setRecomputation] = useState<string>();\n const [titleForeignRect, setTitleForeignRect] = useState({\n x: 0,\n y: 0,\n width: cell.view.width,\n height: cell.view.height,\n });\n // istanbul ignore next\n const shouldHighlight = useMemo(() => {\n let activeTargetCells = [],\n active = false;\n if (activeTarget?.type === \"multi\") {\n activeTargetCells = activeTarget.targets;\n } else if (activeTarget?.type === \"node\") {\n activeTargetCells.push(activeTarget);\n }\n const containerLeft = cell.view.x;\n const containerRight = cell.view.x + cell.view.width;\n const containerTop = cell.view.y;\n const containerBottom = cell.view.y + cell.view.height;\n active = activeTargetCells.some((item) => {\n if (item?.type === \"node\" || item.type === \"decorator\") {\n const targetCell = cells.find(\n (c) =>\n (c?.type === \"node\" || c.type === \"decorator\") && c.id === item.id\n ) as NodeCell;\n if (targetCell) {\n const left = targetCell.view.x;\n const right = targetCell.view.x + targetCell.view.width;\n const top = targetCell.view.y;\n const bottom = targetCell.view.y + targetCell.view.height;\n return (\n left >= containerLeft &&\n right <= containerRight &&\n top >= containerTop &&\n bottom <= containerBottom\n );\n }\n }\n });\n return active;\n }, [activeTarget, cell, cells]);\n const handleEnableEdit = useCallback(\n (e: React.MouseEvent) => {\n if (readOnly || locked) {\n return;\n }\n e.preventDefault();\n e.stopPropagation();\n setEditingLabel(true);\n },\n [readOnly, locked]\n );\n const handleInput = useCallback(\n (event: React.FormEvent<HTMLDivElement>) => {\n if (readOnly) {\n return;\n }\n setCurrentLabel((event.target as HTMLDivElement).textContent!);\n },\n [readOnly]\n );\n\n const handleBlur = useCallback(() => {\n if (readOnly) {\n return;\n }\n setEditingLabel(false);\n setShouldEmitLabelChange(true);\n setRecomputation(uuidV4());\n }, [readOnly]);\n\n useEffect(() => {\n setCurrentLabel(label);\n }, [label]);\n\n useEffect(() => {\n const element = textRef.current;\n if (element && element.textContent !== currentLabel) {\n element.textContent = currentLabel;\n }\n }, [currentLabel]);\n\n useEffect(() => {\n const element = textRef.current?.parentElement;\n if (!element) return;\n\n const resizeObserver = new ResizeObserver(() => {\n const { clientWidth, clientHeight } = element;\n if ([\"left\", \"right\"].includes(direction)) {\n setTitleForeignRect({\n width: clientWidth,\n height: view.height,\n x: direction === \"left\" ? -clientWidth : view.width,\n y: 0,\n });\n } else {\n setTitleForeignRect({\n width: view.width,\n height: clientHeight,\n x: 0,\n y: direction === \"top\" ? -clientHeight : view.height,\n });\n }\n });\n\n resizeObserver.observe(element);\n return () => resizeObserver.disconnect();\n }, [view, currentLabel, direction, recomputation]);\n\n useEffect(() => {\n if (editingLabel && textRef.current) {\n textRef.current.focus();\n selectAllText(textRef.current);\n }\n onDecoratorTextEditing?.({ id: cell.id, editing: editingLabel });\n }, [cell.id, editingLabel, onDecoratorTextEditing]);\n\n useEffect(() => {\n if (shouldEmitLabelChange) {\n onDecoratorTextChange?.({\n id: cell.id,\n view: { ...view, text: currentLabel },\n });\n setShouldEmitLabelChange(false);\n }\n }, [cell, view, currentLabel, onDecoratorTextChange, shouldEmitLabelChange]);\n\n useEffect(() => {\n const resizeHandle = resizeHandleRef.current;\n if (!resizeHandle || readOnly) {\n return;\n }\n const onMouseDown = (event: MouseEvent) => {\n handleMouseDown(event, {\n action: \"resize\",\n cell,\n scale: transform.k,\n activeTarget,\n cells,\n onCellResizing,\n onCellResized,\n onSwitchActiveTarget,\n });\n };\n resizeHandle.addEventListener(\"mousedown\", onMouseDown);\n return () => {\n resizeHandle.removeEventListener(\"mousedown\", onMouseDown);\n };\n }, [\n activeTarget,\n cell,\n cells,\n onCellResized,\n onCellResizing,\n onSwitchActiveTarget,\n readOnly,\n transform.k,\n ]);\n\n return (\n <g className=\"decorator-container\">\n <foreignObject {...titleForeignRect}>\n <div\n className={classNames(\"text-container\", {\n editing: editingLabel,\n [[\"left\", \"right\"].includes(direction) ? \"vertical\" : \"horizontal\"]:\n true,\n })}\n onDoubleClick={handleEnableEdit}\n style={cell.view.titleStyle}\n >\n <div\n className=\"text\"\n contentEditable={getContentEditable(editingLabel)}\n ref={textRef}\n onInput={handleInput}\n onBlur={handleBlur}\n />\n </div>\n </foreignObject>\n <foreignObject\n x={0}\n y={0}\n width={view.width}\n height={view.height}\n className=\"container-wrapper\"\n >\n <div\n className={classNames(\"container\", {\n [\"active-container\"]: shouldHighlight,\n })}\n style={{\n ...cell.view.style,\n width: view.width,\n height: view.height,\n }}\n />\n </foreignObject>\n {!readOnly && !locked && !isNoManualLayout(layout) && (\n <g\n ref={resizeHandleRef}\n className=\"resize-handle\"\n transform={`translate(${view.width - 20} ${view.height - 20})`}\n >\n <rect width={20} height={20} />\n <path d=\"M10 18L18 10 M15 18L18 15\" />\n </g>\n )}\n {locked && (\n <LockIcon x={cell.view.width - 16} y={cell.view.height - 16} />\n )}\n </g>\n );\n}\n","import React, { useEffect } from \"react\";\nimport type { BasicDecoratorProps } from \"../interfaces\";\nimport { handleMouseDown } from \"../processors/handleMouseDown\";\nimport { LockIcon } from \"../LockIcon\";\n\nexport function DecoratorArea({\n cell,\n transform,\n readOnly,\n layoutOptions,\n activeTarget,\n cells,\n locked,\n onCellResizing,\n onCellResized,\n onSwitchActiveTarget,\n}: BasicDecoratorProps): JSX.Element {\n const resizeHandleRef = React.useRef<SVGGElement>(null);\n\n useEffect(() => {\n const resizeHandle = resizeHandleRef.current;\n if (!resizeHandle || readOnly) {\n return;\n }\n const onMouseDown = (event: MouseEvent) => {\n handleMouseDown(event, {\n action: \"resize\",\n cell,\n scale: transform.k,\n layoutOptions,\n activeTarget,\n cells,\n onCellResizing,\n onCellResized,\n onSwitchActiveTarget,\n });\n };\n resizeHandle.addEventListener(\"mousedown\", onMouseDown);\n return () => {\n resizeHandle.removeEventListener(\"mousedown\", onMouseDown);\n };\n }, [\n activeTarget,\n cell,\n cells,\n layoutOptions,\n onCellResized,\n onCellResizing,\n onSwitchActiveTarget,\n readOnly,\n transform.k,\n ]);\n\n return (\n <g className=\"decorator-area-container\">\n <foreignObject className=\"decorator-area\" width=\"9999\" height=\"9999\">\n <div\n className=\"area\"\n style={{\n ...cell.view.style,\n width: cell.view.width,\n height: cell.view.height,\n }}\n />\n </foreignObject>\n {!readOnly && !locked && (\n <g\n ref={resizeHandleRef}\n className=\"resize-handle\"\n transform={`translate(${cell.view.width - 20} ${cell.view.height - 20})`}\n >\n <rect width={20} height={20} />\n <path d=\"M10 18L18 10 M15 18L18 15\" />\n </g>\n )}\n {locked && (\n <LockIcon x={cell.view.width - 16} y={cell.view.height - 16} />\n )}\n </g>\n );\n}\n","import React, { useEffect } from \"react\";\nimport type { BasicDecoratorProps } from \"../interfaces\";\nimport { handleMouseDown } from \"../processors/handleMouseDown\";\nimport { isNoManualLayout } from \"../processors/asserts\";\nimport { LockIcon } from \"../LockIcon\";\n\nexport type DecoratorRectProps = Omit<\n BasicDecoratorProps,\n \"lineConfMap\" | \"editableLineMap\"\n>;\n\nexport function DecoratorRect({\n cell,\n transform,\n readOnly,\n layout,\n view,\n activeTarget,\n cells,\n locked,\n onCellResizing,\n onCellResized,\n onSwitchActiveTarget,\n}: DecoratorRectProps): JSX.Element {\n const resizeHandleRef = React.useRef<SVGGElement>(null);\n\n useEffect(() => {\n const resizeHandle = resizeHandleRef.current;\n if (!resizeHandle || readOnly) {\n return;\n }\n const onMouseDown = (event: MouseEvent) => {\n handleMouseDown(event, {\n action: \"resize\",\n cell,\n scale: transform.k,\n layout,\n activeTarget,\n cells,\n onCellResizing,\n onCellResized,\n onSwitchActiveTarget,\n });\n };\n resizeHandle.addEventListener(\"mousedown\", onMouseDown);\n return () => {\n resizeHandle.removeEventListener(\"mousedown\", onMouseDown);\n };\n }, [\n activeTarget,\n cell,\n cells,\n onCellResized,\n onCellResizing,\n onSwitchActiveTarget,\n readOnly,\n transform.k,\n layout,\n ]);\n\n return (\n <g className=\"decorator-rect-container\">\n <foreignObject className=\"decorator-rect\" width=\"9999\" height=\"9999\">\n <div\n className=\"rect-container\"\n style={{\n ...cell.view.style,\n width: view.width,\n height: view.height,\n }}\n />\n </foreignObject>\n {!readOnly && !locked && !isNoManualLayout(layout) && (\n <g\n ref={resizeHandleRef}\n className=\"resize-handle\"\n transform={`translate(${view.width - 20} ${view.height - 20})`}\n >\n <rect width={20} height={20} />\n <path d=\"M10 18L18 10 M15 18L18 15\" />\n </g>\n )}\n {locked && (\n <LockIcon x={cell.view.width - 16} y={cell.view.height - 16} />\n )}\n </g>\n );\n}\n","import React, { useCallback, useMemo, useRef } from \"react\";\nimport classNames from \"classnames\";\nimport type { BasicDecoratorProps } from \"../interfaces\";\nimport { getMarkers } from \"../../shared/canvas/useLineMarkers\";\nimport type { LineMarkerConf } from \"../../diagram/interfaces\";\nimport { curveLine } from \"../../diagram/lines/curveLine\";\nimport { LockIcon } from \"../LockIcon\";\nimport { getLineLockIconPosition } from \"../processors/getLineLockIconPosition\";\n\nexport type DecoratorLineProps = Pick<\n BasicDecoratorProps,\n \"cell\" | \"active\" | \"locked\" | \"lineConfMap\" | \"editableLineMap\"\n>;\n\nexport function DecoratorLine({\n cell,\n active,\n lineConfMap,\n editableLineMap,\n locked,\n}: DecoratorLineProps): JSX.Element | null {\n const lineConf = lineConfMap.get(cell);\n const { points: linePoints, jumpsMap } = editableLineMap.get(cell) ?? {};\n\n const line = useMemo(() => {\n // istanbul ignore next: defensive check\n if (!lineConf) {\n return null;\n }\n return curveLine(\n linePoints,\n lineConf.type === \"curve\" ? lineConf.curveType : \"curveLinear\",\n 0,\n 1,\n jumpsMap\n );\n }, [lineConf, linePoints, jumpsMap]);\n\n const pathRef = useRef<SVGPathElement | null>(null);\n const pathRefCallback = useCallback(\n (element: SVGPathElement | null) => {\n pathRef.current = element;\n // istanbul ignore next: Jest does not support `SVGPathElement::getBBox`\n if (element && process.env.NODE_ENV !== \"test\") {\n const rect = element.getBBox();\n cell.view = {\n ...cell.view,\n x: rect.x,\n y: rect.y,\n width: rect.width,\n height: rect.height,\n };\n }\n },\n [cell]\n );\n\n const lockedPosition = useMemo(\n () => (locked && linePoints ? getLineLockIconPosition(linePoints) : null),\n [locked, linePoints]\n );\n\n if (!line || !lineConf) {\n return null;\n }\n\n let markerStart: string | undefined;\n let markerEnd: string | undefined;\n let strokeColor: string | undefined;\n let strokeWidth: number | undefined;\n const lineMarkers: LineMarkerConf[] = getMarkers(lineConf);\n if (active) {\n const overrides = lineConf.overrides?.active;\n strokeColor = overrides?.strokeColor ?? lineConf.strokeColor;\n strokeWidth = overrides?.strokeWidth ?? lineConf.strokeWidth;\n // motion = overrides?.motion;\n for (const marker of lineMarkers) {\n if (marker.placement === \"start\") {\n markerStart =\n lineConf.$activeMarkerStartUrl ?? lineConf.$markerStartUrl;\n } else {\n markerEnd = lineConf.$activeMarkerEndUrl ?? lineConf.$markerEndUrl;\n }\n }\n } else {\n strokeColor = lineConf.strokeColor;\n strokeWidth = lineConf.strokeWidth;\n for (const marker of lineMarkers) {\n if (marker.placement === \"start\") {\n markerStart = lineConf.$markerStartUrl;\n } else {\n markerEnd = lineConf.$markerEndUrl;\n }\n }\n }\n\n return (\n <g className=\"decorator-line\">\n <path\n // This `path` is made for expanding interaction area of graph lines.\n d={line}\n fill=\"none\"\n stroke=\"transparent\"\n strokeWidth={lineConf.interactStrokeWidth}\n />\n <path\n className={classNames(\"line\", {\n dashed: lineConf.dashed,\n dotted: lineConf.dotted,\n })}\n ref={pathRefCallback}\n d={line}\n fill=\"none\"\n stroke={strokeColor}\n strokeWidth={strokeWidth}\n markerStart={markerStart}\n markerEnd={markerEnd}\n />\n {locked && <LockIcon x={lockedPosition!.x} y={lockedPosition!.y} />}\n </g>\n );\n}\n","import type { NodePosition } from \"../../diagram/interfaces\";\n\nexport function getLineLockIconPosition(\n linePoints: NodePosition[]\n): NodePosition {\n const lastPoint = linePoints[linePoints.length - 1];\n if (linePoints.length < 2) {\n return {\n x: lastPoint.x + 16,\n y: lastPoint.y - 6,\n };\n }\n\n const firstPoint = linePoints[0];\n const dy = lastPoint.y - firstPoint.y;\n const dx = lastPoint.x - firstPoint.x;\n\n let useEndPoint: boolean;\n if (Math.abs(dy) > Math.abs(dx)) {\n useEndPoint = dy > 0;\n } else {\n useEndPoint = dx > 0;\n }\n\n const point1 = useEndPoint\n ? linePoints[linePoints.length - 2]\n : linePoints[1];\n const point2 = useEndPoint ? lastPoint : firstPoint;\n\n const angle = Math.atan2(point2.y - point1.y, point2.x - point1.x);\n const twistedAngle = angle - (Math.PI * 3) / 4;\n const distance = 16;\n return {\n x: point2.x + Math.cos(twistedAngle) * distance - 6,\n y: point2.y + Math.sin(twistedAngle) * distance - 6,\n };\n}\n","import React, { useCallback, useEffect, useMemo, useRef } from \"react\";\nimport classNames from \"classnames\";\nimport type {\n ActiveTarget,\n Cell,\n CellContextMenuDetail,\n ComputedEdgeLineConf,\n DecoratorTextChangeDetail,\n DecoratorView,\n LayoutOptions,\n LayoutType,\n NodeBrickConf,\n NodeCell,\n EditableLine,\n EditableLineCell,\n EditableEdgeLine,\n CellClickDetail,\n DecoratorCell,\n BaseNodeCell,\n} from \"./interfaces\";\nimport {\n isContainerDecoratorCell,\n isDecoratorCell,\n isEdgeCell,\n isEdgeSide,\n isGroupDecoratorCell,\n isLineDecoratorCell,\n isNoManualLayout,\n isNodeCell,\n} from \"./processors/asserts\";\nimport { EdgeComponent } from \"./EdgeComponent\";\nimport { NodeComponent } from \"./NodeComponent\";\nimport { handleMouseDown } from \"./processors/handleMouseDown\";\nimport type { MoveCellPayload, ResizeCellPayload } from \"./reducers/interfaces\";\nimport { DecoratorComponent } from \"./decorators\";\nimport { cellToTarget } from \"./processors/cellToTarget\";\nimport type { SizeTuple, TransformLiteral } from \"../diagram/interfaces\";\nimport { sameTarget } from \"./processors/sameTarget\";\nimport { targetIsActive } from \"./processors/targetIsActive\";\nimport { computeBoundingBox } from \"./processors/computeBoundingBox\";\nimport { get } from \"lodash\";\nimport { useHoverStateContext } from \"./HoverStateContext\";\nimport {\n GROUPPADDING,\n highlightGroupCell,\n} from \"./processors/initialGroupLayout\";\nexport interface CellComponentProps {\n layout: LayoutType;\n layoutOptions?: LayoutOptions;\n cell: Cell;\n cells: Cell[];\n degraded: boolean;\n degradedNodeLabel?: string;\n defaultNodeBricks?: NodeBrickConf[];\n transform: TransformLiteral;\n lineConfMap: WeakMap<EditableLineCell, ComputedEdgeLineConf>;\n editableLineMap: WeakMap<EditableLineCell, EditableLine>;\n activeTarget: ActiveTarget | null | undefined;\n readOnly?: boolean;\n hoverCell?: Cell | null | undefined;\n unrelatedCells: Cell[];\n dragoverContainer?: boolean;\n allowEdgeToArea?: boolean;\n curActiveEditableLine?: EditableLineCell | null;\n locked?: boolean;\n containerLocked?: boolean;\n groupLocked?: boolean;\n updateCurActiveEditableLine?: (\n activeEditableLine: EditableLineCell | null\n ) => void;\n onCellsMoving?(info: MoveCellPayload[]): void;\n onCellsMoved?(info: MoveCellPayload[]): void;\n onCellResizing?(info: ResizeCellPayload): void;\n onCellResized?(info: ResizeCellPayload): void;\n onSwitchActiveTarget(target: ActiveTarget | null): void;\n onCellContextMenu(detail: CellContextMenuDetail): void;\n onCellClick?(detail: CellClickDetail): void;\n onDecoratorTextEditing?(detail: { id: string; editing: boolean }): void;\n onDecoratorTextChange?(detail: DecoratorTextChangeDetail): void;\n onDecoratorGroupPlusClick?(detail: DecoratorCell): void;\n onNodeBrickResize(id: string, size: SizeTuple | null): void;\n onCellMouseEnter?(cell: Cell): void;\n onCellMouseLeave?(cell: Cell): void;\n}\n\nexport function CellComponent({\n layout,\n layoutOptions,\n cell,\n cells,\n degraded,\n degradedNodeLabel,\n defaultNodeBricks,\n lineConfMap,\n editableLineMap,\n activeTarget,\n dragoverContainer,\n readOnly,\n transform,\n hoverCell,\n unrelatedCells,\n allowEdgeToArea,\n curActiveEditableLine,\n locked,\n containerLocked,\n groupLocked,\n updateCurActiveEditableLine,\n onCellsMoving,\n onCellsMoved,\n onCellResizing,\n onCellResized,\n onSwitchActiveTarget,\n onCellContextMenu,\n onCellClick,\n onDecoratorTextEditing,\n onDecoratorTextChange,\n onDecoratorGroupPlusClick,\n onNodeBrickResize,\n onCellMouseEnter,\n onCellMouseLeave,\n}: CellComponentProps): JSX.Element | null {\n const {\n lineEditorState,\n smartConnectLineState,\n setSmartConnectLineState,\n onConnect,\n setLineEditorState,\n onChangeEdgeView,\n } = useHoverStateContext();\n const gRef = useRef<SVGGElement>(null);\n const unrelated = useMemo(\n () => unrelatedCells.some((item) => sameTarget(item, cell)),\n [cell, unrelatedCells]\n );\n\n const containerRect = useMemo((): DecoratorView | undefined => {\n if (isContainerDecoratorCell(cell) && isNoManualLayout(layout)) {\n const containCells = cells.filter(\n (c): c is NodeCell => isNodeCell(c) && c.containerId === cell.id\n );\n const view = {\n ...cell.view,\n ...computeBoundingBox(containCells),\n };\n cell.view = view; //Update the rect container to make sure Lasso gets the correct size\n return view;\n }\n if (\n isGroupDecoratorCell(cell) &&\n highlightGroupCell(cell, activeTarget, cells)\n ) {\n const nodeViews = cells.filter(\n (c) => c.type === \"node\" && c.groupId === cell.id\n );\n const view = {\n ...cell.view,\n ...computeBoundingBox(nodeViews as BaseNodeCell[], {\n padding: GROUPPADDING,\n }),\n };\n cell.view = view;\n return view;\n }\n return isEdgeCell(cell) || isLineDecoratorCell(cell)\n ? undefined\n : get(cell, \"view\", { x: 0, y: 0, width: 0, height: 0 });\n }, [layout, cell, cells, activeTarget]);\n\n useEffect(() => {\n const g = gRef.current;\n if (!g) {\n return;\n }\n const onMouseDown = (event: MouseEvent) => {\n if (\n readOnly ||\n ([isContainerDecoratorCell(cell), isGroupDecoratorCell(cell)].some(\n Boolean\n ) &&\n isNoManualLayout(layout))\n ) {\n event.stopPropagation();\n } else {\n handleMouseDown(event, {\n layout,\n layoutOptions,\n action: \"move\",\n cell,\n scale: transform.k,\n activeTarget,\n cells,\n onCellsMoving,\n onCellsMoved,\n onSwitchActiveTarget,\n updateCurActiveEditableLine,\n });\n }\n };\n g.addEventListener(\"mousedown\", onMouseDown);\n return () => {\n g.removeEventListener(\"mousedown\", onMouseDown);\n };\n }, [\n layout,\n layoutOptions,\n cell,\n activeTarget,\n cells,\n onCellsMoved,\n onCellsMoving,\n onSwitchActiveTarget,\n updateCurActiveEditableLine,\n readOnly,\n transform.k,\n ]);\n\n // istanbul ignore next: experimental\n useEffect(() => {\n const g = gRef.current;\n if (\n !g ||\n !isEdgeSide(cell, allowEdgeToArea) ||\n !(\n smartConnectLineState ||\n (lineEditorState && lineEditorState.type !== \"control\")\n )\n ) {\n return;\n }\n const onMouseUp = (e: MouseEvent) => {\n if (\n curActiveEditableLine &&\n lineEditorState &&\n curActiveEditableLine.type === \"decorator\"\n ) {\n return;\n }\n e.preventDefault();\n e.stopPropagation();\n if (smartConnectLineState) {\n if (smartConnectLineState.source !== cell) {\n onConnect?.(\n smartConnectLineState.source,\n cell,\n smartConnectLineState.exitPosition,\n undefined\n );\n }\n setSmartConnectLineState(null);\n } else if (curActiveEditableLine && lineEditorState) {\n const { type } = lineEditorState;\n const { source, target } = editableLineMap.get(\n curActiveEditableLine\n ) as EditableEdgeLine;\n const { view } = curActiveEditableLine;\n\n const isEntry = type === \"entry\";\n if ((isEntry ? target : source) === cell) {\n if (isEntry) {\n onChangeEdgeView?.(source!, target!, {\n ...view,\n entryPosition: null,\n // ...(!view?.exitPosition ? { vertices: null } : {}),\n });\n } else {\n onChangeEdgeView?.(source!, target!, {\n ...view,\n exitPosition: null,\n // ...(!view?.entryPosition ? { vertices: null } : {}),\n });\n }\n }\n setLineEditorState(null);\n }\n };\n g.addEventListener(\"mouseup\", onMouseUp);\n return () => {\n g.removeEventListener(\"mouseup\", onMouseUp);\n };\n }, [\n curActiveEditableLine,\n editableLineMap,\n allowEdgeToArea,\n cell,\n lineEditorState,\n onChangeEdgeView,\n onConnect,\n setLineEditorState,\n setSmartConnectLineState,\n smartConnectLineState,\n updateCurActiveEditableLine,\n ]);\n\n const handleContextMenu = useCallback(\n (event: React.MouseEvent<SVGGElement>) => {\n if (readOnly && cell.type === \"decorator\") {\n return;\n }\n event.preventDefault();\n event.stopPropagation();\n let target = activeTarget;\n // When right-click a cell,\n // - if it's already active, use previous active target (including multiple targets)\n // - if it's inactive, use the cell as the new only target (excluding previous active target)\n if (!targetIsActive(cell, activeTarget)) {\n target = cellToTarget(cell);\n onSwitchActiveTarget(target);\n }\n onCellContextMenu({\n cell,\n clientX: event.clientX,\n clientY: event.clientY,\n locked,\n target: target!,\n });\n },\n [\n readOnly,\n cell,\n activeTarget,\n onCellContextMenu,\n locked,\n onSwitchActiveTarget,\n ]\n );\n\n const handleCellClick = useCallback(\n (event: React.MouseEvent<SVGGElement>) => {\n if (!onCellClick || cell.type === \"decorator\") {\n return;\n }\n onCellClick({\n cell,\n clientX: event.clientX,\n clientY: event.clientY,\n locked,\n });\n },\n [cell, onCellClick, locked]\n );\n\n const handleMouseEnter = useCallback(() => {\n onCellMouseEnter?.(cell);\n }, [cell, onCellMouseEnter]);\n\n const handleMouseLeave = useCallback(() => {\n onCellMouseLeave?.(cell);\n }, [cell, onCellMouseLeave]);\n\n const active = targetIsActive(cell, activeTarget);\n return (\n <g\n className={classNames(\"cell\", {\n active,\n faded: unrelated,\n \"read-only\": readOnly,\n \"container-dragover\": dragoverContainer,\n })}\n ref={gRef}\n transform={\n (isNodeCell(cell) && !degraded) ||\n isEdgeCell(cell) ||\n isLineDecoratorCell(cell) ||\n cell.view?.x == null ||\n cell.view?.y == null\n ? undefined\n : `translate(${containerRect!.x},${containerRect!.y})`\n }\n onContextMenu={handleContextMenu}\n onClick={handleCellClick}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n >\n {isNodeCell(cell) ? (\n <NodeComponent\n node={cell}\n x={containerRect?.x}\n y={containerRect?.y}\n degraded={degraded}\n degradedNodeLabel={degradedNodeLabel}\n defaultNodeBricks={defaultNodeBricks}\n locked={locked}\n containerLocked={containerLocked}\n groupLocked={groupLocked}\n onResize={onNodeBrickResize}\n />\n ) : isEdgeCell(cell) ? (\n <EdgeComponent\n edge={cell}\n active={readOnly ? hoverCell === cell : active}\n activeRelated={!!(readOnly ? hoverCell : activeTarget) && !unrelated}\n lineConfMap={lineConfMap}\n editableLineMap={editableLineMap}\n readOnly={readOnly}\n onSwitchActiveTarget={onSwitchActiveTarget}\n />\n ) : isDecoratorCell(cell) ? (\n <DecoratorComponent\n cell={cell}\n view={containerRect!}\n transform={transform}\n readOnly={readOnly}\n layout={layout}\n layoutOptions={layoutOptions}\n active={active}\n activeTarget={activeTarget}\n cells={cells}\n lineConfMap={lineConfMap}\n editableLineMap={editableLineMap}\n locked={locked}\n onCellResizing={onCellResizing}\n onCellResized={onCellResized}\n onSwitchActiveTarget={onSwitchActiveTarget}\n onDecoratorTextEditing={onDecoratorTextEditing}\n onDecoratorTextChange={onDecoratorTextChange}\n onDecoratorGroupPlusClick={onDecoratorGroupPlusClick}\n />\n ) : null}\n </g>\n );\n}\n","// istanbul ignore file: experimental\nimport React, { useEffect, useMemo, useState } from \"react\";\nimport classNames from \"classnames\";\nimport type { ComputedLineConnecterConf, LineSettings } from \"./interfaces\";\nimport type {\n LineMarkerConf,\n PositionTuple,\n TransformLiteral,\n} from \"../diagram/interfaces\";\nimport { curveLine } from \"../diagram/lines/curveLine\";\nimport { useHoverStateContext } from \"./HoverStateContext\";\nimport { getConnectLinePoints } from \"../shared/canvas/processors/getConnectLinePoints\";\nimport { getMarkers } from \"../shared/canvas/useLineMarkers\";\n\nexport interface SmartConnectLineComponentProps {\n transform: TransformLiteral;\n lineSettings?: LineSettings;\n options: ComputedLineConnecterConf;\n}\n\nexport function SmartConnectLineComponent({\n transform,\n lineSettings,\n options,\n}: SmartConnectLineComponentProps): JSX.Element {\n const [connectLineTo, setConnectLineTo] = useState<PositionTuple | null>(\n null\n );\n const { hoverState, smartConnectLineState, setSmartConnectLineState } =\n useHoverStateContext();\n\n useEffect(() => {\n if (!smartConnectLineState) {\n return;\n }\n function onMouseMove(e: MouseEvent) {\n // Set connect line to based on the mouse position and the transform\n setConnectLineTo([\n (e.clientX - transform.x - smartConnectLineState!.offset[0]) /\n transform.k,\n (e.clientY - transform.y - smartConnectLineState!.offset[1]) /\n transform.k,\n ]);\n }\n function onMouseUp(e: MouseEvent) {\n e.preventDefault();\n reset();\n }\n function reset() {\n document.removeEventListener(\"mousemove\", onMouseMove);\n document.removeEventListener(\"mouseup\", onMouseUp);\n setConnectLineTo(null);\n setSmartConnectLineState(null);\n }\n document.addEventListener(\"mousemove\", onMouseMove);\n document.addEventListener(\"mouseup\", onMouseUp);\n\n return reset;\n }, [setSmartConnectLineState, smartConnectLineState, transform]);\n\n const line = useMemo(() => {\n const points = getConnectLinePoints(\n smartConnectLineState,\n connectLineTo,\n hoverState,\n lineSettings\n );\n return curveLine(\n points,\n lineSettings?.type === \"curve\" ? lineSettings.curveType : \"curveLinear\",\n 0,\n 1\n );\n }, [connectLineTo, hoverState, smartConnectLineState, lineSettings]);\n\n let markerStart: string | undefined;\n let markerEnd: string | undefined;\n const lineMarkers: LineMarkerConf[] = getMarkers(options);\n for (const marker of lineMarkers) {\n if (marker.placement === \"start\") {\n markerStart = options.$markerStartUrl;\n } else {\n markerEnd = options.$markerEndUrl;\n }\n }\n\n return (\n <path\n className={classNames(\"connect-line\", {\n connecting: !!(smartConnectLineState && connectLineTo),\n })}\n d={line}\n fill=\"none\"\n stroke={options.strokeColor}\n strokeWidth={options.strokeWidth}\n markerStart={markerStart}\n markerEnd={markerEnd}\n />\n );\n}\n","import type { NodePosition, PositionTuple } from \"../../../diagram/interfaces\";\nimport type { HoverState } from \"../../../draw-canvas/HoverStateContext\";\nimport type {\n LineSettings,\n SmartConnectLineState,\n} from \"../../../draw-canvas/interfaces\";\nimport { getSmartLinePoints } from \"./getSmartLinePoints\";\n\nexport function getConnectLinePoints(\n smartConnectLineState: SmartConnectLineState | null,\n connectLineTo: PositionTuple | null,\n hoverState: HoverState | null,\n lineSettings?: LineSettings\n): NodePosition[] | null {\n if (\n !smartConnectLineState ||\n !(connectLineTo || hoverState?.activePointIndex !== undefined)\n ) {\n return null;\n }\n\n const sourceView = smartConnectLineState.source.view;\n if (hoverState?.activePointIndex !== undefined) {\n return getSmartLinePoints(sourceView, hoverState.cell.view, {\n ...lineSettings,\n exitPosition: smartConnectLineState.exitPosition,\n entryPosition: hoverState.relativePoints[hoverState.activePointIndex],\n });\n }\n\n const [x1, y1] = connectLineTo!;\n\n return getSmartLinePoints(\n sourceView,\n { x: x1, y: y1, width: 0, height: 0 },\n {\n ...lineSettings,\n exitPosition: smartConnectLineState.exitPosition,\n }\n );\n}\n","import type { ActiveTarget, Cell } from \"../interfaces\";\nimport { isLocked } from \"./isLocked\";\nimport { targetIsActive } from \"./targetIsActive\";\n\nexport type KeyboardAction = KeyboardActionDeleteCells;\n\nexport interface KeyboardActionDeleteCells {\n action: \"delete-cells\";\n cells: Cell[];\n}\n\nexport function handleKeyboard(\n event: KeyboardEvent,\n {\n cells,\n activeTarget,\n lockedIds,\n }: {\n cells: Cell[];\n activeTarget: ActiveTarget | null | undefined;\n lockedIds?: string[];\n }\n): KeyboardAction | undefined {\n const activeCells = cells.filter(\n (cell) => targetIsActive(cell, activeTarget) && !isLocked(cell, lockedIds)\n );\n\n if (activeCells.length === 0) {\n return;\n }\n\n const key =\n event.key ||\n /* istanbul ignore next: compatibility */ event.keyCode ||\n /* istanbul ignore next: compatibility */ event.which;\n\n switch (key) {\n case \"Backspace\":\n case 8:\n case \"Delete\":\n case 46: {\n event.preventDefault();\n event.stopPropagation();\n return {\n action: \"delete-cells\",\n cells: activeCells,\n };\n }\n }\n}\n","import { useMemo, useRef } from \"react\";\nimport {\n __secret_internals,\n checkIfByTransform,\n checkIfOfComputed,\n} from \"@next-core/runtime\";\nimport { findIndex, isUndefined, omitBy } from \"lodash\";\nimport type {\n Cell,\n ComputedEdgeLineConf,\n ComputedLineConnecterConf,\n EdgeCell,\n EdgeLineConf,\n EditableLineCell,\n LineConnecterConf,\n LineMarker,\n} from \"../../draw-canvas/interfaces\";\nimport {\n isEdgeCell,\n isLineDecoratorCell,\n} from \"../../draw-canvas/processors/asserts\";\nimport {\n DEFAULT_LINE_STROKE_COLOR,\n DEFAULT_LINE_STROKE_WIDTH,\n DEFAULT_LINE_INTERACT_STROKE_WIDTH,\n DEFAULT_LINE_INTERACT_SHOW_START_ARROW,\n DEFAULT_LINE_INTERACT_SHOW_END_ARROW,\n DEFAULT_LINE_INTERACT_ANIMATE_DURATION,\n DEFAULT_DECORATOR_LINE_STROKE_COLOR,\n} from \"../../draw-canvas/constants\";\nimport { LineMarkerConf } from \"../../diagram/interfaces\";\n\nexport interface UseLineMarkersOptions {\n cells: Cell[];\n defaultEdgeLines: EdgeLineConf[] | undefined;\n markerPrefix: string;\n lineConnector?: LineConnecterConf | boolean;\n /** Use memoized result when moving and resizing cells */\n useMemoizedResult?: boolean;\n}\n\nexport interface UseLineMarkersResult {\n lineConfMap: WeakMap<EditableLineCell, ComputedEdgeLineConf>;\n lineConnectorConf: ComputedLineConnecterConf | null;\n markers: LineMarker[];\n}\n\nexport function useLineMarkers({\n cells,\n defaultEdgeLines,\n markerPrefix,\n lineConnector,\n useMemoizedResult,\n}: UseLineMarkersOptions): UseLineMarkersResult {\n const memoizedResult = useRef<UseLineMarkersResult | null>(null);\n\n return useMemo<UseLineMarkersResult>(() => {\n if (useMemoizedResult && memoizedResult.current) {\n // If cells are moving or resizing, we can use the previous memoized result.\n return memoizedResult.current;\n }\n\n // Always put the default stroke marker at the first position,\n // since the connecting line will use it.\n const markers: LineMarker[] = [\n {\n strokeColor: DEFAULT_LINE_STROKE_COLOR,\n markerType: \"arrow\",\n },\n ];\n\n let lineConnectorConf: ComputedLineConnecterConf | null = null;\n if (lineConnector) {\n lineConnectorConf = {\n ...getDefaultLineConf(),\n editingStrokeColor: \"var(--palette-blue-5)\",\n ...omitBy(lineConnector === true ? {} : lineConnector, isUndefined),\n } as ComputedLineConnecterConf;\n const lineMarkers: LineMarkerConf[] = getMarkers(lineConnectorConf);\n for (const marker of lineMarkers) {\n const { placement, type: _type } = marker;\n const type = _type ?? \"arrow\";\n const markerIndex = addMarker(\n {\n strokeColor: lineConnectorConf.strokeColor,\n markerType: type,\n },\n markers\n );\n const editingMarkerIndex = addMarker(\n {\n strokeColor: lineConnectorConf.editingStrokeColor,\n markerType: type,\n },\n markers\n );\n if (placement === \"start\") {\n lineConnectorConf.$markerStartUrl = `url(#${markerPrefix}${markerIndex})`;\n lineConnectorConf.$editingStartMarkerUrl = `url(#${markerPrefix}${editingMarkerIndex})`;\n } else {\n lineConnectorConf.$markerEndUrl = `url(#${markerPrefix}${markerIndex})`;\n lineConnectorConf.$editingEndMarkerUrl = `url(#${markerPrefix}${editingMarkerIndex})`;\n }\n }\n }\n\n const map = new WeakMap<EditableLineCell, ComputedEdgeLineConf>();\n for (const cell of cells) {\n const isEdge = isEdgeCell(cell);\n const isLineDecorator = isLineDecoratorCell(cell);\n\n let lineConf: ComputedEdgeLineConf;\n if (isEdge) {\n const computedLineConf =\n (Array.isArray(defaultEdgeLines)\n ? transformLineConf(\n defaultEdgeLines.find((item) =>\n checkIfByTransform(item, { edge: cell })\n ),\n cell\n )\n : (\n __secret_internals.legacyDoTransform(\n { edge: cell },\n defaultEdgeLines\n ) as EdgeLineConf[]\n )?.find((item) => checkIfOfComputed(item))) ?? {};\n lineConf = {\n ...getDefaultLineConf(),\n ...omitBy(computedLineConf, isUndefined),\n ...omitBy(cell.view, isUndefined),\n } as ComputedEdgeLineConf;\n if (lineConf.parallelGap === undefined) {\n lineConf.parallelGap = lineConf.interactStrokeWidth;\n }\n } else {\n lineConf = {\n ...getDefaultLineConf(),\n showEndArrow: false,\n strokeColor: DEFAULT_DECORATOR_LINE_STROKE_COLOR,\n ...omitBy(cell.view, isUndefined),\n } as ComputedEdgeLineConf;\n }\n\n if (isEdge || isLineDecorator) {\n const lineMarkers: LineMarkerConf[] = getMarkers(lineConf);\n\n for (const marker of lineMarkers) {\n const { placement, type: _type } = marker;\n const type = _type ?? \"arrow\";\n const markerIndex = addMarker(\n {\n strokeColor: lineConf.strokeColor,\n markerType: type,\n },\n markers\n );\n if (placement === \"start\") {\n lineConf.$markerStartUrl = `url(#${markerPrefix}${markerIndex})`;\n } else {\n lineConf.$markerEndUrl = `url(#${markerPrefix}${markerIndex})`;\n }\n\n const activeStrokeColor = lineConf.overrides?.active?.strokeColor;\n if (activeStrokeColor && activeStrokeColor !== lineConf.strokeColor) {\n const activeMarkerIndex = addMarker(\n {\n strokeColor: activeStrokeColor,\n markerType: type,\n },\n markers\n );\n if (placement === \"start\") {\n lineConf.$activeMarkerStartUrl = `url(#${markerPrefix}${activeMarkerIndex})`;\n } else {\n lineConf.$activeMarkerEndUrl = `url(#${markerPrefix}${activeMarkerIndex})`;\n }\n }\n\n if (isEdge) {\n const activeRelatedStrokeColor =\n lineConf.overrides?.activeRelated?.strokeColor;\n if (\n activeRelatedStrokeColor &&\n activeRelatedStrokeColor !== lineConf.strokeColor\n ) {\n const activeRelatedMarkerIndex = addMarker(\n {\n strokeColor: activeRelatedStrokeColor,\n markerType: type,\n },\n markers\n );\n if (placement === \"start\") {\n lineConf.$activeRelatedMarkerStartUrl = `url(#${markerPrefix}${activeRelatedMarkerIndex})`;\n } else {\n lineConf.$activeRelatedMarkerEndUrl = `url(#${markerPrefix}${activeRelatedMarkerIndex})`;\n }\n }\n }\n }\n map.set(cell, lineConf);\n }\n }\n return (memoizedResult.current = {\n lineConfMap: map,\n lineConnectorConf,\n markers,\n });\n }, [cells, defaultEdgeLines, lineConnector, markerPrefix, useMemoizedResult]);\n}\n\nfunction transformLineConf(\n lineConf: EdgeLineConf | undefined,\n edge: EdgeCell\n): EdgeLineConf {\n // Do not transform useBrick\n if (lineConf?.label?.useBrick) {\n const {\n label: { useBrick, ...restLabel },\n ...restConf\n } = lineConf;\n const computedRestConf = __secret_internals.legacyDoTransform(\n { edge },\n {\n ...restConf,\n label: restLabel,\n }\n ) as EdgeLineConf;\n return {\n ...computedRestConf,\n label: {\n ...computedRestConf.label,\n useBrick,\n },\n } as EdgeLineConf;\n }\n return __secret_internals.legacyDoTransform(\n { edge },\n lineConf\n ) as EdgeLineConf;\n}\n\nexport function getMarkers(lineConf: ComputedEdgeLineConf): LineMarkerConf[] {\n let lineMarkers: LineMarkerConf[] = [];\n if (lineConf.markers) {\n lineMarkers = lineConf.markers;\n } else {\n if (lineConf.showStartArrow) {\n lineMarkers.push({\n type: \"arrow\",\n placement: \"start\",\n });\n }\n if (lineConf.showEndArrow) {\n lineMarkers.push({\n type: \"arrow\",\n placement: \"end\",\n });\n }\n }\n return lineMarkers;\n}\nfunction addMarker(marker: LineMarker, markers: LineMarker[]): number {\n let markerIndex = findIndex(markers, marker);\n if (markerIndex === -1) {\n markerIndex = markers.push(marker) - 1;\n }\n return markerIndex;\n}\n\nfunction getDefaultLineConf(): EdgeLineConf {\n return {\n type: \"straight\",\n dashed: false,\n strokeColor: DEFAULT_LINE_STROKE_COLOR,\n strokeWidth: DEFAULT_LINE_STROKE_WIDTH,\n interactStrokeWidth: DEFAULT_LINE_INTERACT_STROKE_WIDTH,\n showStartArrow: DEFAULT_LINE_INTERACT_SHOW_START_ARROW,\n showEndArrow: DEFAULT_LINE_INTERACT_SHOW_END_ARROW,\n animate: {\n useAnimate: false,\n duration: DEFAULT_LINE_INTERACT_ANIMATE_DURATION,\n },\n jumps: false,\n };\n}\n","import { pick } from \"lodash\";\nimport type { NodePosition, PositionTuple } from \"../../../diagram/interfaces\";\nimport type { HoverState } from \"../../../draw-canvas/HoverStateContext\";\nimport type {\n LineEditorState,\n LineEditorStateOfControl,\n EditableLine,\n EditableLineCell,\n EditableLineView,\n DecoratorLineView,\n NodeView,\n} from \"../../../draw-canvas/interfaces\";\nimport { getSmartLinePoints, simplifyVertices } from \"./getSmartLinePoints\";\nimport { isEditableEdgeLine } from \"../../../draw-canvas/processors/asserts\";\n\nexport function getEditingLinePoints(\n activeEditableLine: EditableLineCell | null,\n lineEditorState: LineEditorState | null,\n editableLineMap: WeakMap<EditableLineCell, EditableLine>,\n connectLineTo: PositionTuple | null,\n hoverState: HoverState | null\n): NodePosition[] | null {\n if (\n !activeEditableLine ||\n !lineEditorState ||\n !(\n connectLineTo ||\n (lineEditorState.type !== \"control\" &&\n hoverState?.activePointIndex !== undefined)\n )\n ) {\n return null;\n }\n\n const editableLine = editableLineMap.get(activeEditableLine);\n if (!editableLine) {\n return null;\n }\n\n const { type } = lineEditorState;\n let sourceView: NodeView;\n let targetView: NodeView;\n\n const cellType = activeEditableLine.type;\n if (isEditableEdgeLine(editableLine)) {\n sourceView = editableLine.source.view;\n targetView = editableLine.target.view;\n } else {\n const view = editableLine.decorator.view as DecoratorLineView;\n sourceView = { ...view.source, width: 0, height: 0 };\n targetView = { ...view.target, width: 0, height: 0 };\n }\n const view = activeEditableLine.view as EditableLineView;\n const { exitPosition, entryPosition, vertices } = view ?? {};\n const lineSettings = pick(view, [\"type\", \"curveType\"]);\n\n if (type === \"control\") {\n const newVertices = getNewLineVertices(\n activeEditableLine,\n lineEditorState,\n editableLineMap,\n connectLineTo!\n );\n\n return getSmartLinePoints(\n sourceView,\n targetView,\n {\n ...lineSettings,\n exitPosition,\n entryPosition,\n vertices: newVertices,\n },\n 0,\n cellType\n );\n }\n\n if (type === \"corner\") {\n const newVertices = [...vertices!];\n newVertices.splice(lineEditorState.control.index, 1, {\n x: connectLineTo![0],\n y: connectLineTo![1],\n });\n\n return getSmartLinePoints(\n sourceView,\n targetView,\n {\n ...lineSettings,\n exitPosition,\n entryPosition,\n vertices: newVertices,\n },\n 0,\n cellType\n );\n }\n\n if (type === \"break\") {\n const newVertices = [...(vertices ?? [])];\n newVertices.splice(lineEditorState.control.index, 0, {\n x: connectLineTo![0],\n y: connectLineTo![1],\n });\n\n return getSmartLinePoints(\n sourceView,\n targetView,\n {\n ...lineSettings,\n exitPosition,\n entryPosition,\n vertices: newVertices,\n },\n 0,\n cellType\n );\n }\n\n if (cellType === \"edge\" && hoverState?.activePointIndex !== undefined) {\n const position = hoverState.relativePoints[hoverState.activePointIndex];\n // Assert `hoverState.cell` is `target`\n return getSmartLinePoints(\n sourceView,\n targetView,\n {\n ...lineSettings,\n ...(type === \"entry\"\n ? {\n exitPosition,\n entryPosition: position,\n }\n : {\n exitPosition: position,\n entryPosition,\n }),\n vertices,\n },\n 0,\n cellType\n );\n }\n\n const [x1, y1] = connectLineTo!;\n\n if (type === \"entry\") {\n return getSmartLinePoints(\n sourceView,\n { x: x1, y: y1, width: 0, height: 0 },\n { ...lineSettings, exitPosition, vertices },\n 0,\n cellType\n );\n }\n\n return getSmartLinePoints(\n { x: x1, y: y1, width: 0, height: 0 },\n targetView,\n { ...lineSettings, entryPosition, vertices },\n 0,\n cellType\n );\n}\n\nexport function getNewLineVertices(\n activeEditableLine: EditableLineCell,\n lineEditorState: LineEditorStateOfControl,\n editableLineMap: WeakMap<EditableLineCell, EditableLine>,\n connectLineTo: PositionTuple\n) {\n const { control } = lineEditorState;\n const { points: linePoints } = editableLineMap.get(activeEditableLine)!;\n const newVertices: NodePosition[] = [];\n const [x1, y1] = connectLineTo!;\n const exitPoint = linePoints[0];\n const entryPoint = linePoints[linePoints.length - 1];\n\n // If moving the first control, prepend a vertex to connect the control to the source\n if (control.index === 0) {\n newVertices.push(\n control.direction === \"ns\"\n ? { x: exitPoint.x, y: y1 }\n : { x: x1, y: exitPoint.y }\n );\n }\n\n // Adjust the related two controls, and leave other controls unchanged\n for (let i = 1; i < linePoints.length - 1; i++) {\n const vertex = linePoints[i];\n newVertices.push(\n i === control.index || i === control.index + 1\n ? control.direction === \"ns\"\n ? { x: vertex.x, y: y1 }\n : { x: x1, y: vertex.y }\n : vertex\n );\n }\n\n // If moving the last control, append a vertex to connect the control to the target\n if (control.index === linePoints.length - 2) {\n newVertices.push(\n control.direction === \"ns\"\n ? { x: entryPoint.x, y: y1 }\n : { x: x1, y: entryPoint.y }\n );\n }\n\n return simplifyVertices(exitPoint, newVertices, entryPoint);\n}\n","// istanbul ignore file: experimental\nimport React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport classNames from \"classnames\";\nimport type {\n Cell,\n ComputedLineConnecterConf,\n EditableEdgeLine,\n EditableLine,\n EditableLineCell,\n EditableLineView,\n LineEditorState,\n LineEditorStateOfControl,\n} from \"./interfaces\";\nimport type {\n LineMarkerConf,\n NodePosition,\n PositionTuple,\n TransformLiteral,\n} from \"../diagram/interfaces\";\nimport { curveLine } from \"../diagram/lines/curveLine\";\nimport { useHoverStateContext } from \"./HoverStateContext\";\nimport {\n getEditingLinePoints,\n getNewLineVertices,\n} from \"../shared/canvas/processors/getEditingLinePoints\";\nimport { getMarkers } from \"../shared/canvas/useLineMarkers\";\nimport { isEdgeCell, isLineDecoratorCell } from \"./processors/asserts\";\n\nconst LOOSE_CONTROL_TYPES = [\n \"control\",\n \"corner\",\n \"break\",\n] as LineEditorState[\"type\"][];\n\nexport interface EditingLineComponentProps {\n cells: Cell[];\n editableLineMap: WeakMap<EditableLineCell, EditableLine>;\n transform: TransformLiteral;\n options: ComputedLineConnecterConf;\n activeEditableLine: EditableLineCell | null;\n}\n\nexport function EditingLineComponent({\n cells,\n editableLineMap,\n transform,\n options,\n activeEditableLine,\n}: EditingLineComponentProps): JSX.Element {\n const [connectLineTo, setConnectLineTo] = useState<PositionTuple | null>(\n null\n );\n const {\n hoverState,\n lineEditorState,\n setLineEditorState,\n onChangeEdgeView,\n onChangeDecoratorView,\n } = useHoverStateContext();\n const movedRef = useRef(false);\n\n useEffect(() => {\n if (!lineEditorState) {\n setTimeout(() => {\n movedRef.current = false;\n }, 0);\n }\n }, [lineEditorState]);\n\n useEffect(() => {\n if (!activeEditableLine || !lineEditorState) {\n return;\n }\n movedRef.current = false;\n const { type, offset, from } = lineEditorState;\n // Set connect line to based on the mouse position and the transform\n const getConnectTo = (e: MouseEvent): PositionTuple => {\n const position: NodePosition = {\n x: (e.clientX - transform.x - offset[0]) / transform.k,\n y: (e.clientY - transform.y - offset[1]) / transform.k,\n };\n const linePoints = editableLineMap.get(activeEditableLine)!.points;\n const snapDistance = 5;\n const diff: NodePosition = { x: Infinity, y: Infinity };\n let otherPoints: NodePosition[];\n let axises: (\"x\" | \"y\")[];\n\n const getFinalPosition = (): PositionTuple => {\n if (!movedRef.current) {\n const movementX = (e.clientX - from[0]) / transform.k;\n const movementY = (e.clientY - from[1]) / transform.k;\n movedRef.current = movementX ** 2 + movementY ** 2 >= 9;\n }\n\n return [position.x, position.y];\n };\n\n if (LOOSE_CONTROL_TYPES.includes(type) && !e.altKey) {\n // Snap to other points\n const control = (lineEditorState as LineEditorStateOfControl).control;\n axises =\n type === \"control\"\n ? [control.direction === \"ns\" ? \"y\" : \"x\"]\n : [\"x\", \"y\"];\n otherPoints = linePoints.filter(\n (_, i) =>\n i === 0 ||\n i === linePoints.length - 1 ||\n (type === \"control\"\n ? i !== control.index && i !== control.index + 1\n : type !== \"corner\" || i !== control.index + 1)\n );\n } else if (\n isLineDecoratorCell(activeEditableLine) &&\n (type === \"exit\" || type === \"entry\") &&\n !e.altKey\n ) {\n const endpoint =\n type === \"exit\" ? linePoints[0] : linePoints[linePoints.length - 1];\n otherPoints = linePoints.filter((p) => p !== endpoint);\n axises = [\"x\", \"y\"];\n } else {\n return getFinalPosition();\n }\n\n // Snap to control points of other lines\n for (const cell of cells) {\n if (\n !(isEdgeCell(cell) || isLineDecoratorCell(cell)) ||\n cell === activeEditableLine\n ) {\n continue;\n }\n const editableLine = editableLineMap.get(cell);\n if (editableLine) {\n otherPoints.push(...editableLine.points.slice(1, -1));\n }\n }\n\n for (const point of otherPoints) {\n for (const axis of axises) {\n const newDiff = Math.abs(point[axis] - position[axis]);\n if (newDiff <= snapDistance && newDiff < diff[axis]) {\n position[axis] = point[axis];\n diff[axis] = newDiff;\n }\n }\n }\n\n return getFinalPosition();\n };\n const onMouseMove = (e: MouseEvent) => {\n const newConnectTo = getConnectTo(e);\n if (movedRef.current) {\n setConnectLineTo(newConnectTo);\n }\n };\n function onMouseUp(e: MouseEvent) {\n e.preventDefault();\n reset();\n\n if (!movedRef.current) {\n return;\n }\n\n const newConnectTo = getConnectTo(e);\n const isEdge = isEdgeCell(activeEditableLine!);\n\n if (lineEditorState?.type === \"control\") {\n if (isEdge) {\n const editableLine = editableLineMap.get(\n activeEditableLine!\n ) as EditableEdgeLine;\n const { source, target } = editableLine;\n onChangeEdgeView?.(source, target, {\n ...activeEditableLine!.view,\n vertices: getNewLineVertices(\n activeEditableLine!,\n lineEditorState,\n editableLineMap,\n newConnectTo\n ),\n });\n } else {\n onChangeDecoratorView?.(activeEditableLine!, {\n ...activeEditableLine!.view,\n vertices: getNewLineVertices(\n activeEditableLine!,\n lineEditorState,\n editableLineMap,\n newConnectTo\n ),\n });\n }\n return;\n }\n\n if (isEdge) {\n return;\n }\n\n switch (lineEditorState?.type) {\n case \"entry\":\n case \"exit\":\n onChangeDecoratorView?.(activeEditableLine!, {\n ...activeEditableLine!.view,\n [lineEditorState.type === \"entry\" ? \"target\" : \"source\"]: {\n x: newConnectTo[0],\n y: newConnectTo[1],\n },\n });\n break;\n case \"corner\":\n onChangeDecoratorView?.(activeEditableLine!, {\n ...activeEditableLine!.view,\n vertices: activeEditableLine!.view.vertices!.map((point, i) =>\n i === lineEditorState.control.index\n ? { x: newConnectTo[0], y: newConnectTo[1] }\n : point\n ),\n });\n break;\n case \"break\": {\n const newVertices = [...(activeEditableLine!.view.vertices ?? [])];\n newVertices.splice(lineEditorState.control.index, 0, {\n x: newConnectTo[0],\n y: newConnectTo[1],\n });\n onChangeDecoratorView?.(activeEditableLine!, {\n ...activeEditableLine!.view,\n vertices: newVertices,\n });\n break;\n }\n }\n }\n function reset() {\n document.removeEventListener(\"mousemove\", onMouseMove);\n document.removeEventListener(\"mouseup\", onMouseUp);\n setConnectLineTo(null);\n setLineEditorState(null);\n }\n document.addEventListener(\"mousemove\", onMouseMove);\n document.addEventListener(\"mouseup\", onMouseUp);\n\n return reset;\n }, [\n activeEditableLine,\n editableLineMap,\n lineEditorState,\n transform,\n setLineEditorState,\n onChangeEdgeView,\n cells,\n onChangeDecoratorView,\n ]);\n\n useEffect(() => {\n if (!activeEditableLine) {\n return;\n }\n const handleBodyClick = (e: MouseEvent) => {\n if (movedRef.current) {\n e.stopPropagation();\n e.preventDefault();\n }\n };\n document.body.addEventListener(\"click\", handleBodyClick);\n return () => {\n document.body.removeEventListener(\"click\", handleBodyClick);\n };\n }, [activeEditableLine]);\n\n const line = useMemo(() => {\n const points = getEditingLinePoints(\n activeEditableLine,\n lineEditorState,\n editableLineMap,\n connectLineTo,\n hoverState\n );\n const view = activeEditableLine?.view as EditableLineView | undefined;\n return curveLine(\n points,\n view?.type === \"curve\" ? view.curveType : \"curveLinear\",\n 0,\n 1\n );\n }, [\n connectLineTo,\n hoverState,\n activeEditableLine,\n lineEditorState,\n editableLineMap,\n ]);\n let markerStart: string | undefined;\n let markerEnd: string | undefined;\n const lineMarkers: LineMarkerConf[] = getMarkers(options);\n for (const marker of lineMarkers) {\n if (marker.placement === \"start\") {\n markerStart = options.$editingStartMarkerUrl;\n } else {\n markerEnd = options.$editingEndMarkerUrl;\n }\n }\n\n return (\n <path\n className={classNames(\"editing-line\", {\n editing: !!(lineEditorState && connectLineTo),\n })}\n d={line}\n fill=\"none\"\n stroke={options.editingStrokeColor}\n markerStart={markerStart}\n markerEnd={markerEnd}\n />\n );\n}\n","import { get } from \"lodash\";\nimport type { SizeTuple } from \"../../diagram/interfaces\";\nimport type { Cell, InitialCell, LayoutOptions, NodeCell } from \"../interfaces\";\nimport { isInitialNodeCell } from \"./asserts\";\nimport { initialContainerLayout } from \"./initialContainerLayout\";\n\ninterface initializeConfig {\n defaultNodeSize: SizeTuple;\n layoutOptions?: LayoutOptions;\n isInitialize?: boolean;\n}\n\nexport function initializeCells(\n initialCells: InitialCell[] | undefined,\n { defaultNodeSize, layoutOptions, isInitialize }: initializeConfig\n): Cell[] {\n const originalCells = initialCells ?? [];\n if (isInitialize) {\n if (get(layoutOptions, \"initialLayout\") === \"layered-architecture\") {\n initialContainerLayout(originalCells, { nodeLayout: \"dagre\" });\n } else if (get(layoutOptions, \"initialLayout\") === \"layered-staggered\") {\n initialContainerLayout(originalCells, { nodeLayout: \"staggered\" });\n }\n }\n const finalCells: Cell[] = originalCells.map<Cell>((cell) => {\n if (\n !isInitialNodeCell(cell) ||\n (cell.view?.width !== undefined && cell.view?.height !== undefined)\n ) {\n return cell as NodeCell;\n }\n return {\n ...cell,\n view: {\n width: defaultNodeSize[0],\n height: defaultNodeSize[1],\n ...cell.view,\n },\n } as NodeCell;\n });\n return finalCells;\n}\n","import type { AlignOrigin, NormalizedAlignOrigin } from \"../interfaces\";\n\nconst KeywordMap = new Map([\n [\"center\", 0.5],\n [\"left\", 0],\n [\"right\", 1],\n [\"top\", 0],\n [\"bottom\", 1],\n]);\n\nexport function normalizeAlignOrigin(\n alignOrigin: AlignOrigin | undefined\n): NormalizedAlignOrigin {\n const origin = alignOrigin ?? [0.5, 0.5];\n return [\n normalizeAlignAxis(origin[0], \"x\"),\n normalizeAlignAxis(origin[1], \"y\"),\n ];\n}\n\nfunction normalizeAlignAxis(value: string | number, axis: \"x\" | \"y\"): number {\n if (typeof value === \"string\") {\n const newX = KeywordMap.get(value);\n if (newX !== undefined) {\n return newX;\n }\n const matches = value.match(/^(-?\\d+(?:\\.\\d+)?)%$/);\n if (matches) {\n return Number(matches[1]) / 100;\n }\n // eslint-disable-next-line no-console\n console.error(\"Unexpected align origin %s:\", axis, value);\n } else if (typeof value === \"number\") {\n return value;\n } else {\n // eslint-disable-next-line no-console\n console.error(\n \"Unexpected align origin %s, expected %s, received %s:\",\n axis,\n \"string | number\",\n typeof value,\n value\n );\n }\n\n return 0.5;\n}\n","import { useCallback, useEffect, useRef, useState } from \"react\";\nimport type { ZoomBehavior } from \"d3-zoom\";\nimport type {\n Cell,\n LayoutOptions,\n LayoutOptionsForce,\n LayoutOptionsDagre,\n LayoutType,\n NodeId,\n NodeView,\n AutoSize,\n} from \"../../draw-canvas/interfaces\";\nimport type { FullRectTuple, RangeTuple } from \"../../diagram/interfaces\";\nimport { useAutoCenter } from \"./useAutoCenter\";\nimport {\n isNodeCell,\n isNodeOrAreaDecoratorCell,\n isNodeOrEdgeCell,\n} from \"../../draw-canvas/processors/asserts\";\nimport {\n SYMBOL_FOR_LAYOUT_INITIALIZED,\n SYMBOL_FOR_SIZE_INITIALIZED,\n} from \"../../draw-canvas/constants\";\nimport type { DrawCanvasAction } from \"../../draw-canvas/reducers/interfaces\";\nimport { forceLayout } from \"./forceLayout\";\nimport { dagreLayout } from \"./dagreLayout\";\nimport { normalizeAlignOrigin } from \"../../draw-canvas/processors/normalizeAlignOrigin\";\n\nexport interface UseLayoutOptions {\n layout: LayoutType;\n layoutOptions?: LayoutOptions;\n autoSize?: AutoSize;\n rootRef: React.RefObject<SVGSVGElement>;\n cells: Cell[];\n zoomable?: boolean;\n zoomer: ZoomBehavior<SVGSVGElement, unknown>;\n scaleRange: RangeTuple;\n layoutKey: number;\n allowEdgeToArea?: boolean;\n autoCenterWhenCellsChange?: boolean;\n dispatch: (value: DrawCanvasAction) => void;\n}\n\nexport function useLayout({\n layout,\n layoutOptions,\n autoSize,\n rootRef,\n cells,\n zoomable,\n zoomer,\n scaleRange,\n layoutKey,\n allowEdgeToArea,\n autoCenterWhenCellsChange,\n dispatch,\n}: UseLayoutOptions) {\n const [layoutInitialized, setLayoutInitialized] = useState(\n layout !== \"force\" && layout !== \"dagre\"\n );\n\n const layoutKeyRef = useRef(layoutKey);\n\n const getNextLayoutKey = useCallback(() => {\n return ++layoutKeyRef.current;\n }, []);\n\n const [centered, setCentered] = useAutoCenter({\n rootRef,\n layoutInitialized,\n cells,\n zoomable,\n zoomer,\n scaleRange,\n autoCenterWhenCellsChange,\n autoSize,\n padding: layoutOptions?.padding,\n });\n\n const previousLayoutRef = useRef<Cell[] | null>(null);\n\n useEffect(() => {\n // Wait for all nodes to be size-initialized before layout.\n if (\n cells.some(\n (cell) => isNodeCell(cell) && !cell[SYMBOL_FOR_SIZE_INITIALIZED]\n ) ||\n // Skip layout if no cells.\n cells.length === 0\n ) {\n return;\n }\n\n if (layout !== \"force\" && layout !== \"dagre\") {\n setLayoutInitialized(true);\n return;\n }\n\n // DO NOT re-layout if layout key mismatched.\n // DO NOT re-layout if nodes and edges not changed.\n if (\n layoutKeyRef.current !== layoutKey ||\n isSameArray(previousLayoutRef.current, cells.filter(isNodeOrEdgeCell))\n ) {\n // Layout key mismatch happens when this effect is performed after\n // update-node-size dispatched but not yet applied.\n // If didn't ignore mismatched layout, it will cause the update-cells\n // action overwrites those update-node-size actions.\n return;\n }\n\n let getNodeView: (id: NodeId) => NodeView;\n let nodePaddings: FullRectTuple;\n\n if (layout === \"force\") {\n ({ getNodeView, nodePaddings } = forceLayout({\n cells,\n layoutOptions: layoutOptions as LayoutOptionsForce,\n allowEdgeToArea,\n }));\n } else {\n ({ getNodeView, nodePaddings } = dagreLayout({\n cells,\n layoutOptions: layoutOptions as LayoutOptionsDagre,\n allowEdgeToArea,\n }));\n }\n\n const alignOrigin = normalizeAlignOrigin(\n (layoutOptions as LayoutOptionsForce | LayoutOptionsDagre)?.alignOrigin\n );\n\n const newCells: Cell[] = cells.map((cell) => {\n if (\n (allowEdgeToArea && isNodeOrAreaDecoratorCell(cell)) ||\n isNodeCell(cell)\n ) {\n const nodeView = getNodeView(cell.id);\n return {\n ...cell,\n view: {\n ...cell.view,\n x: nodeView.x! - nodeView.width * alignOrigin[0] + nodePaddings[3],\n y: nodeView.y! - nodeView.height * alignOrigin[1] + nodePaddings[0],\n },\n [SYMBOL_FOR_LAYOUT_INITIALIZED]: true,\n };\n }\n return cell;\n });\n previousLayoutRef.current = newCells.filter(isNodeOrEdgeCell);\n\n dispatch({ type: \"update-cells\", payload: newCells });\n // setCentered(false);\n setLayoutInitialized(true);\n }, [\n cells,\n dispatch,\n layout,\n layoutKey,\n layoutOptions,\n allowEdgeToArea /* , setCentered */,\n ]);\n\n return { centered, setCentered, getNextLayoutKey };\n}\n\nfunction isSameArray<T = unknown>(a: T[] | null, b: T[]): boolean {\n return a?.length === b.length && a.every((v, i) => v === b[i]);\n}\n","import React, { useEffect, useState } from \"react\";\nimport { select } from \"d3-selection\";\nimport { ZoomTransform, type ZoomBehavior } from \"d3-zoom\";\nimport type { PartialRectTuple, RangeTuple } from \"../../diagram/interfaces\";\nimport {\n DEFAULT_CANVAS_PADDING,\n SYMBOL_FOR_SIZE_INITIALIZED,\n} from \"../../draw-canvas/constants\";\nimport type { AutoSize, Cell } from \"../../draw-canvas/interfaces\";\nimport {\n isDecoratorCell,\n isNodeCell,\n} from \"../../draw-canvas/processors/asserts\";\nimport { getCellsRect } from \"./processors/getCellsRect\";\nimport { extractPartialRectTuple } from \"../../diagram/processors/extractPartialRectTuple\";\nimport { getTransformToCenter } from \"./processors/getTransformToCenter\";\n\nexport interface UseAutoCenterOptions {\n rootRef: React.RefObject<SVGSVGElement>;\n cells: Cell[];\n layoutInitialized: boolean;\n zoomable?: boolean;\n zoomer: ZoomBehavior<SVGSVGElement, unknown>;\n scaleRange: RangeTuple;\n autoCenterWhenCellsChange?: boolean;\n autoSize?: AutoSize;\n padding?: PartialRectTuple;\n}\n\nexport type UseAutoCenterResult = [\n centered: boolean,\n setCentered: React.Dispatch<React.SetStateAction<boolean>>,\n];\n\nexport function useAutoCenter({\n rootRef,\n cells,\n layoutInitialized,\n zoomable,\n zoomer,\n scaleRange,\n autoCenterWhenCellsChange,\n autoSize,\n padding,\n}: UseAutoCenterOptions): UseAutoCenterResult {\n const [centered, setCentered] = useState(false);\n\n useEffect(() => {\n // Reset auto centering when nodes and decorators are all removed,\n // or when cells change and autoCenterWhenCellsChange is enabled.\n if (\n !cells.some((cell) => isNodeCell(cell) || isDecoratorCell(cell)) ||\n autoCenterWhenCellsChange\n ) {\n setCentered(false);\n }\n }, [cells, autoCenterWhenCellsChange]);\n\n useEffect(() => {\n const root = rootRef.current;\n if (\n !root ||\n !layoutInitialized ||\n centered ||\n !cells.some((cell) => isNodeCell(cell) || isDecoratorCell(cell)) ||\n cells.some(\n (cell) => isNodeCell(cell) && !cell[SYMBOL_FOR_SIZE_INITIALIZED]\n )\n ) {\n return;\n }\n\n const rect = getCellsRect(cells);\n let width = root.clientWidth;\n let height = root.clientHeight;\n const fitWidth = !!autoSize?.width;\n const fitHeight = !!autoSize?.height;\n const fullPadding = extractPartialRectTuple(\n padding ?? DEFAULT_CANVAS_PADDING\n );\n\n // Todo: handle ratio\n if (fitWidth) {\n width = Math.min(\n Math.max(\n rect.width + fullPadding![1] + fullPadding![3],\n autoSize.minWidth ?? 0\n ),\n autoSize.maxWidth ?? Infinity\n );\n root.style.minWidth = `${width}px`;\n }\n if (fitHeight) {\n height = Math.min(\n Math.max(\n rect.height + fullPadding![0] + fullPadding![2],\n autoSize.minHeight ?? 0\n ),\n autoSize.maxHeight ?? Infinity\n );\n root.style.minHeight = `${height}px`;\n }\n\n const { k, x, y } = getTransformToCenter(rect, {\n canvasWidth: width,\n canvasHeight: height,\n canvasPadding: fullPadding,\n scaleRange: zoomable ? scaleRange : undefined,\n });\n // istanbul ignore next\n if (process.env.NODE_ENV !== \"test\") {\n // jsdom doesn't support svg baseVal yet.\n // https://github.com/jsdom/jsdom/issues/2531\n zoomer.transform(select(root), new ZoomTransform(k, x, y));\n }\n setCentered(true);\n }, [\n cells,\n centered,\n layoutInitialized,\n rootRef,\n scaleRange,\n zoomable,\n zoomer,\n autoSize,\n padding,\n ]);\n\n return [centered, setCentered];\n}\n","import type { ActiveTarget, Cell } from \"../interfaces\";\nimport { isNodeCell } from \"./asserts\";\nimport { targetIsActive } from \"./targetIsActive\";\n\nexport function toggleLock(\n target: ActiveTarget,\n type: \"toggle\" | \"lock\" | \"unlock\",\n cells: Cell[],\n lockedContainerIds: string[]\n): { newCells: Cell[] | null; updates: Cell[] } {\n const previousLocked: Cell[] = [];\n const previousUnlocked: Cell[] = [];\n for (const cell of cells) {\n if (targetIsActive(cell, target)) {\n // 如果容器已锁定,禁止其子节点的锁定状态改变\n if (\n isNodeCell(cell) &&\n cell.containerId &&\n lockedContainerIds.includes(cell.containerId)\n ) {\n continue;\n }\n (cell.view?.locked ? previousLocked : previousUnlocked).push(cell);\n }\n }\n\n let newCells: Cell[] | null = null;\n const updates: Cell[] = [];\n\n if (type !== \"unlock\" && previousUnlocked.length > 0) {\n // Lock all unlocked targets\n newCells = cells.map((cell) => {\n if (previousUnlocked.includes(cell)) {\n const update = {\n ...cell,\n view: { ...cell.view, locked: true },\n } as Cell;\n updates.push(update);\n return update;\n }\n return cell;\n });\n } else if (type !== \"lock\" && previousLocked.length > 0) {\n // Unlock all locked targets\n newCells = cells.map((cell) => {\n if (previousLocked.includes(cell)) {\n const update = {\n ...cell,\n view: { ...cell.view, locked: false },\n } as Cell;\n updates.push(update);\n return update;\n }\n return cell;\n });\n }\n\n return { newCells, updates };\n}\n","import { useMemo } from \"react\";\nimport type { Cell, LayoutType } from \"../../draw-canvas/interfaces\";\nimport { isNodeCell } from \"../../draw-canvas/processors/asserts\";\nimport {\n SYMBOL_FOR_LAYOUT_INITIALIZED,\n SYMBOL_FOR_SIZE_INITIALIZED,\n} from \"../../draw-canvas/constants\";\n\nexport interface UseReadyOptions {\n cells: Cell[];\n layout: LayoutType;\n centered: boolean;\n}\n\nexport function useReady({ cells, layout, centered }: UseReadyOptions) {\n const ready = useMemo(\n () =>\n centered &&\n cells.every(\n (cell) =>\n !isNodeCell(cell) ||\n (cell[SYMBOL_FOR_SIZE_INITIALIZED] &&\n ((layout !== \"force\" && layout !== \"dagre\") ||\n cell[SYMBOL_FOR_LAYOUT_INITIALIZED]))\n ),\n [cells, centered, layout]\n );\n return ready;\n}\n","import type { Cell, DecoratorCell } from \"../interfaces\";\nimport {\n isContainerDecoratorCell,\n isGroupDecoratorCell,\n isNodeCell,\n} from \"./asserts\";\n\nexport function getLockedContainerIds(cells: Cell[]): string[] {\n const lockeds = cells.filter(\n (cell) =>\n (cell.view?.locked && isContainerDecoratorCell(cell)) ||\n (cell.view?.locked && isGroupDecoratorCell(cell))\n ) as DecoratorCell[];\n return lockeds.map((cell) => cell.id);\n}\n\nexport function isLocked(cell: Cell, lockeds: string[] | undefined): boolean {\n return (\n cell.view?.locked ||\n !!(\n (isNodeCell(cell) || isGroupDecoratorCell(cell)) &&\n cell.containerId &&\n lockeds?.includes(cell.containerId)\n ) ||\n !!(isNodeCell(cell) && cell.groupId && lockeds?.includes(cell.groupId))\n );\n}\n","// Imports\nimport ___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___ from \"../../../../../node_modules/css-loader/dist/runtime/noSourceMaps.js\";\nimport ___CSS_LOADER_API_IMPORT___ from \"../../../../../node_modules/css-loader/dist/runtime/api.js\";\nvar ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___);\n// Module\n___CSS_LOADER_EXPORT___.push([module.id, `*{box-sizing:border-box}:host{display:block;position:relative;overflow:hidden;--animation-dasharray:48;--stroke-dashedoffset:96;--stroke-dottedoffset:24;--dasharray:4;--dotted:1;--area-bg-color:rgba(119,141,195,0.1)}:host,\n.root{width:100%;height:100%}:host([hidden]){display:none}.root{opacity:0}.root.ready{opacity:1}.root:focus{outline:none}@keyframes solidAnimation{to{stroke-dashoffset:0}}@keyframes dashedAnimation{0%{stroke-dashoffset:var(--stroke-dashedoffset)}to{stroke-dashoffset:0}}@keyframes dottedAnimation{0%{stroke-dashoffset:var(--stroke-dottedoffset)}to{stroke-dashoffset:0}}.solid-animation{stroke-dasharray:var(--solid-length);stroke-dashoffset:var(--solid-length);animation:solidAnimation var(--time) linear infinite}.dashed-animation{animation:dashedAnimation var(--time) linear infinite}.dotted-animation{animation:dottedAnimation var(--time) linear infinite}.decorator-area .area,\n.container-wrapper .container{background-color:var(--area-bg-color);border:1px solid transparent}.decorator-text .text-container{border:1px solid transparent}.decorator-rect-container .rect-container{border:1px solid rgba(73,126,255,0.7)}.decorator-group .lock-icon,.decorator-group .plus-wrapper,.decorator-group .plus-icon{opacity:0}.decorator-group .group{position:relative}.decorator-group .group .plus-icon{position:absolute;left:50%;bottom:0;transform:translate(-50%,50%);padding:2px;background:var(--color-fill-bg-base-1);border-radius:2px;cursor:pointer}.decorator-group .group .plus-icon:hover{color:rgba(33,212,243,1)}.decorator-group.active-group:not(.does-not-exist) .group,.cell.active .decorator-group .group{border:1px dashed rgba(33,212,243,1)}.decorator-group.active-group:not(.does-not-exist) .resize-handle,.cell.active .decorator-group .resize-handle,.decorator-group.active-group:not(.does-not-exist) .lock-icon,.cell.active .decorator-group .lock-icon,.decorator-group.active-group:not(.does-not-exist) .plus-wrapper,.cell.active .decorator-group .plus-wrapper,.decorator-group.active-group:not(.does-not-exist) .plus-icon,.cell.active .decorator-group .plus-icon{opacity:1}.cell:has(.decorator-group.active-group),\n.cell:has(.container.active-container){opacity:1}.cell.active .decorator-area .area,\n.cell.active .decorator-rect-container .rect-container,\n.cell.active .decorator-text .text-container,\n.cell.active .container-wrapper .container,\n.cell.active .group-wrapper .group,\n.container-dragover .decorator-container .container,\n.active-container.container{border-style:dashed;border-color:rgba(73,126,255,0.7)}.node,\n.container-wrapper{overflow:visible}.decorator-text,\n.decorator-rect,\n.decorator-area{overflow:visible;pointer-events:none}.lock-icon,\n.decorator-text > *,\n.decorator-rect > *,\n.decorator-area > *{pointer-events:auto}.cell.active .line-active-bg{stroke:var(--palette-blue-5);stroke-dasharray:var(--dasharray);stroke-width:1}.cell:not(.read-only){-webkit-user-select:none;user-select:none}.resize-handle{cursor:nwse-resize;opacity:0}.resize-handle rect{fill:transparent;stroke:none}.resize-handle path{fill:none;stroke:var(--palette-gray-5);stroke-width:1.5}.decorator-area-container:hover .resize-handle,\n.decorator-rect-container:hover .resize-handle,\n.decorator-container:hover .resize-handle{opacity:1}.connect-line{pointer-events:none}.connect-line:not(.connecting){display:none}.editing-line{pointer-events:none;stroke-dasharray:var(--dasharray);stroke-width:1}.editing-line:not(.editing){display:none}.line.dashed{stroke-dasharray:var(--dasharray)}.line.dotted{stroke-dasharray:var(--dotted)}.decorator-text .text-container{width:max-content;padding:0.5em;white-space:pre}.cell:not(.read-only) .decorator-text .text-container:hover{color:#497eff}.decorator-text .text:focus{outline:none}.cell.faded{opacity:0.3}.cell.container-dragover{opacity:1}.cell .node{pointer-events:none}.cell .node > *{position:fixed;pointer-events:auto}.degraded{pointer-events:bounding-box}.degraded circle{fill:rgb(119,141,195)}.degraded text{text-anchor:middle;fill:var(--antd-text-color)}.cell.active .degraded circle,\n.cell.active .degraded text,\n.degraded:hover circle,\n.degraded:hover text{fill:var(--color-brand)}.decorator-container{--defaultSize:24px}.decorator-container .text-container{display:flex;align-items:center;justify-content:center;padding:0.5em;text-align:center;font-size:16px;color:#262626;background-color:rgba(119,141,195,0.25);overflow:hidden}.decorator-container .horizontal{height:max-content;width:100%}.decorator-container .horizontal .text{min-height:var(--defaultSize)}.decorator-container .vertical{width:max-content;height:100%;writing-mode:vertical-lr;-webkit-text-orientation:upright;text-orientation:upright;letter-spacing:4px}.decorator-container .vertical .text{min-width:var(--defaultSize)}.line-label-container{overflow:visible;opacity:0}.line-label-container.ready{opacity:1}.line-label{position:absolute;display:block;transform:translate(-50%,-50%);white-space:pre-line;width:max-content;text-align:center}.line-label.text{font-size:11px;color:var(--color-secondary-text);font-weight:400;line-height:1.63636364}.motion:not(.visible){opacity:0}`, \"\"]);\n// Exports\nexport default ___CSS_LOADER_EXPORT___.toString();\n","// istanbul ignore file: experimental\nimport React, { useCallback, useEffect, useRef } from \"react\";\nimport { useHoverStateContext } from \"./HoverStateContext\";\nimport type {\n ActiveTarget,\n Cell,\n EditableEdgeLine,\n EditableLine,\n EditableLineCell,\n NodeCell,\n} from \"./interfaces\";\nimport { targetIsActive } from \"./processors/targetIsActive\";\nimport type { NodePosition } from \"../diagram/interfaces\";\nimport { DEFAULT_NODE_PADDING_FOR_SMART_LINES } from \"./constants\";\nimport { isEditableEdgeLine } from \"./processors/asserts\";\n\nconst HELPER_IMAGE =\n \"data:image/svg+xml;base64,PCFET0NUWVBFIHN2ZyBQVUJMSUMgIi0vL1czQy8vRFREIFNWRyAxLjEvL0VOIiAiaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkIj48c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHdpZHRoPSI1cHgiIGhlaWdodD0iNXB4IiB2ZXJzaW9uPSIxLjEiPjxwYXRoIGQ9Im0gMCAwIEwgNSA1IE0gMCA1IEwgNSAwIiBzdHJva2Utd2lkdGg9IjIiIHN0eWxlPSJzdHJva2Utb3BhY2l0eTowLjQiIHN0cm9rZT0iI2ZmZmZmZiIvPjxwYXRoIGQ9Im0gMCAwIEwgNSA1IE0gMCA1IEwgNSAwIiBzdHJva2U9IiMyOWI2ZjIiLz48L3N2Zz4=\";\nconst HELPER_RADIUS = 5;\nconst HELPER_BG_RADIUS = 8;\nconst HALF_HELPER_RADIUS = HELPER_RADIUS / 2;\n\nexport interface LineConnectorComponentProps {\n activeTarget: ActiveTarget | null;\n editableLineMap: WeakMap<EditableLineCell, EditableLine>;\n scale: number;\n activeEditableLine: EditableLineCell | null;\n disabled?: boolean;\n}\n\nexport function LineConnectorComponent({\n activeTarget,\n editableLineMap,\n scale,\n activeEditableLine,\n disabled,\n}: LineConnectorComponentProps): JSX.Element | null {\n const {\n unsetHoverStateTimeoutRef,\n hoverState,\n setHoverState,\n smartConnectLineState,\n lineEditorState,\n } = useHoverStateContext();\n\n const unsetTimeout = useCallback(() => {\n if (unsetHoverStateTimeoutRef.current !== null) {\n clearTimeout(unsetHoverStateTimeoutRef.current);\n unsetHoverStateTimeoutRef.current = null;\n }\n }, [unsetHoverStateTimeoutRef]);\n\n const unsetActivePointIndex = useCallback(() => {\n unsetTimeout();\n setHoverState((prev) =>\n prev?.activePointIndex === undefined\n ? prev\n : { ...hoverState!, activePointIndex: undefined }\n );\n }, [hoverState, setHoverState, unsetTimeout]);\n\n const unsetHoverState = useCallback(() => {\n unsetHoverStateTimeoutRef.current = setTimeout(() => {\n setHoverState(null);\n }) as unknown as number;\n }, [setHoverState, unsetHoverStateTimeoutRef]);\n\n let source: Cell | undefined;\n let target: Cell | undefined;\n let editableLine: EditableLine | undefined;\n\n const available =\n !disabled &&\n hoverState &&\n (!!smartConnectLineState ||\n (activeEditableLine && lineEditorState\n ? (editableLine = editableLineMap.get(activeEditableLine)) &&\n (isEditableEdgeLine(editableLine)\n ? (({ source, target } = editableLine),\n lineEditorState.type === \"entry\")\n ? hoverState.cell === target\n : lineEditorState.type === \"exit\" && hoverState.cell === source\n : // TODO(steve): decorator line\n false)\n : !targetIsActive(hoverState.cell, activeTarget) &&\n !hasActiveEdge(activeTarget)));\n\n const padding = DEFAULT_NODE_PADDING_FOR_SMART_LINES;\n const halfPadding = padding / 2;\n\n return (\n <g onMouseEnter={unsetActivePointIndex} onMouseLeave={unsetHoverState}>\n {available && (\n <>\n <rect\n x={hoverState.cell.view.x - halfPadding}\n y={hoverState.cell.view.y - halfPadding}\n width={hoverState.cell.view.width + padding}\n height={hoverState.cell.view.height + padding}\n fill=\"none\"\n stroke=\"transparent\"\n strokeWidth={(HELPER_BG_RADIUS * 2) / scale}\n pointerEvents=\"stroke\"\n />\n {hoverState.activePointIndex !== undefined && (\n <circle\n cx={hoverState.points[hoverState.activePointIndex].x}\n cy={hoverState.points[hoverState.activePointIndex].y}\n r={HELPER_BG_RADIUS / scale}\n fill=\"lightgreen\"\n fillOpacity={0.5}\n pointerEvents=\"none\"\n />\n )}\n {hoverState.points.map((point, index) => (\n <ConnectPointComponent\n key={index}\n editableLineMap={editableLineMap}\n index={index}\n point={point}\n scale={scale}\n activeEditableLine={activeEditableLine}\n unsetActivePointIndex={unsetActivePointIndex}\n unsetTimeout={unsetTimeout}\n />\n ))}\n </>\n )}\n </g>\n );\n}\n\ninterface ConnectPointComponentProps {\n editableLineMap: WeakMap<EditableLineCell, EditableLine>;\n index: number;\n point: NodePosition;\n scale: number;\n activeEditableLine: EditableLineCell | null;\n unsetTimeout: () => void;\n unsetActivePointIndex: () => void;\n}\n\nfunction ConnectPointComponent({\n editableLineMap,\n index,\n point,\n scale,\n activeEditableLine,\n unsetTimeout,\n unsetActivePointIndex,\n}: ConnectPointComponentProps): JSX.Element {\n const {\n rootRef,\n smartConnectLineState,\n hoverState,\n setHoverState,\n setSmartConnectLineState,\n onConnect,\n lineEditorState,\n setLineEditorState,\n onChangeEdgeView,\n } = useHoverStateContext();\n const ref = useRef<SVGGElement>(null);\n\n useEffect(() => {\n const g = ref.current;\n const handleMouseEnter = (e: MouseEvent) => {\n // There is a chance that mouseenter will not be triggered when the element is shown aync.\n // So we also listen to the mousemove event, but only once.\n if (e.type === \"mousemove\") {\n g?.removeEventListener(e.type, handleMouseEnter);\n }\n unsetTimeout();\n setHoverState((prev) =>\n prev && prev.activePointIndex !== index\n ? { ...hoverState!, activePointIndex: index }\n : prev\n );\n };\n g?.addEventListener(\"mouseenter\", handleMouseEnter);\n g?.addEventListener(\"mousemove\", handleMouseEnter);\n return () => {\n g?.removeEventListener(\"mouseenter\", handleMouseEnter);\n g?.removeEventListener(\"mousemove\", handleMouseEnter);\n };\n }, [hoverState, index, setHoverState, unsetTimeout]);\n\n useEffect(() => {\n if (lineEditorState) {\n return;\n }\n const handleMouseDown = (e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n const rect = rootRef.current!.getBoundingClientRect();\n const originalPoint = hoverState!.points[index];\n setSmartConnectLineState({\n source: hoverState!.cell as NodeCell,\n from: [originalPoint.x, originalPoint.y],\n offset: [rect.left, rect.top],\n exitPosition: hoverState!.relativePoints[index],\n });\n };\n const g = ref.current;\n g?.addEventListener(\"mousedown\", handleMouseDown);\n return () => {\n g?.removeEventListener(\"mousedown\", handleMouseDown);\n };\n }, [hoverState, index, lineEditorState, rootRef, setSmartConnectLineState]);\n\n useEffect(() => {\n const handleMouseUp = (e: MouseEvent) => {\n if (\n activeEditableLine &&\n lineEditorState &&\n activeEditableLine.type === \"decorator\"\n ) {\n return;\n }\n e.preventDefault();\n e.stopPropagation();\n if (smartConnectLineState) {\n if (smartConnectLineState.source !== hoverState?.cell) {\n onConnect?.(\n smartConnectLineState.source,\n hoverState!.cell,\n smartConnectLineState.exitPosition,\n hoverState!.relativePoints[hoverState!.activePointIndex!]\n );\n }\n setSmartConnectLineState(null);\n } else if (activeEditableLine && lineEditorState) {\n const position =\n hoverState!.relativePoints[hoverState!.activePointIndex!];\n const { type } = lineEditorState;\n const { source, target } = editableLineMap.get(\n activeEditableLine!\n ) as EditableEdgeLine;\n const { view } = activeEditableLine!;\n if (type === \"entry\") {\n onChangeEdgeView?.(source, target, {\n ...view,\n entryPosition: position,\n });\n } else {\n onChangeEdgeView?.(source, target, {\n ...view,\n exitPosition: position,\n });\n }\n setLineEditorState(null);\n }\n };\n const g = ref.current;\n g?.addEventListener(\"mouseup\", handleMouseUp);\n return () => {\n g?.removeEventListener(\"mouseup\", handleMouseUp);\n };\n }, [\n smartConnectLineState,\n hoverState,\n onConnect,\n setSmartConnectLineState,\n activeEditableLine,\n lineEditorState,\n editableLineMap,\n onChangeEdgeView,\n setLineEditorState,\n ]);\n\n return (\n <g ref={ref} onMouseLeave={unsetActivePointIndex}>\n <circle\n cx={point.x}\n cy={point.y}\n r={HELPER_BG_RADIUS}\n fill=\"transparent\"\n />\n <image\n x={point.x - HALF_HELPER_RADIUS / scale}\n y={point.y - HALF_HELPER_RADIUS / scale}\n width={HELPER_RADIUS / scale}\n height={HELPER_RADIUS / scale}\n xlinkHref={HELPER_IMAGE}\n preserveAspectRatio=\"none\"\n />\n </g>\n );\n}\n\nfunction hasActiveEdge(activeTarget: ActiveTarget | null) {\n return (\n activeTarget &&\n (activeTarget.type === \"edge\" ||\n (activeTarget.type === \"multi\" &&\n activeTarget.targets.some((target) => target.type === \"edge\")))\n );\n}\n","export const SYMBOL_FOR_SIZE_INITIALIZED = Symbol.for(\"size-initialized\");\nexport const SYMBOL_FOR_LAYOUT_INITIALIZED = Symbol.for(\"layout-initialized\");\nexport const DEFAULT_NODE_SIZE = 20;\nexport const DEFAULT_NODE_GAP_H = 36;\nexport const DEFAULT_NODE_GAP_V = 50;\nexport const DEFAULT_AREA_WIDTH = 180;\nexport const DEFAULT_AREA_HEIGHT = 120;\nexport const DEFAULT_SCALE_RANGE_MIN = 0.5;\nexport const DEFAULT_SCALE_RANGE_MAX = 2;\nexport const DEFAULT_LINE_STROKE_COLOR = \"gray\";\nexport const DEFAULT_LINE_STROKE_WIDTH = 1;\nexport const DEFAULT_DECORATOR_LINE_STROKE_COLOR = \"rgba(73, 126, 255, 0.7)\";\nexport const DEFAULT_LINE_INTERACT_STROKE_WIDTH = 15;\nexport const DEFAULT_LINE_INTERACT_SHOW_START_ARROW = false;\nexport const DEFAULT_LINE_INTERACT_SHOW_END_ARROW = true;\nexport const DEFAULT_LINE_INTERACT_ANIMATE_DURATION = 1;\nexport const DEFAULT_DEGRADED_THRESHOLD = 500;\nexport const DEFAULT_SNAP_GRID_SIZE = 10;\nexport const DEFAULT_SNAP_OBJECT_DISTANCE = 5;\nexport const DEFAULT_SNAP_OBJECT_POSITIONS = \"all\";\n/** Padding left + padding right, as well as top + bottom */\nexport const DEFAULT_NODE_PADDING_FOR_LINES = 5;\n/** Padding left + padding right, as well as top + bottom */\nexport const DEFAULT_NODE_PADDING_FOR_SMART_LINES = 0;\nexport const DEFAULT_CANVAS_PADDING = 0;\n\nexport const POINT_HELPER_RADIUS = 5;\nexport const DEFAULT_MOTION_SPEED = 50;\nexport const CONTAINERGAP = 40;\nexport const MAXPERROW = 12;\n","import { mergeRects, type Rect } from \"@next-shared/diagram\";\nimport type { Cell, CellsRect } from \"../../../draw-canvas/interfaces\";\nimport { isEdgeCell } from \"../../../draw-canvas/processors/asserts\";\n\nexport function getCellsRect(cells: Cell[]): CellsRect {\n const rects: Rect[] = [];\n let empty = true;\n for (const cell of cells) {\n if (!isEdgeCell(cell)) {\n empty = false;\n rects.push(cell.view);\n }\n }\n const { x: left, y: top, width, height } = mergeRects(rects);\n return { left, top, width, height, empty };\n}\n","export interface Rect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/**\n * Merges multiple rectangles into a single bounding rectangle.\n */\nexport function mergeRects(rects: Rect[]): Rect {\n let left = Infinity;\n let top = Infinity;\n let right = -Infinity;\n let bottom = -Infinity;\n for (const rect of rects) {\n const r = rect.x + rect.width;\n const b = rect.y + rect.height;\n if (rect.x < left) {\n left = rect.x;\n }\n if (r > right) {\n right = r;\n }\n if (rect.y < top) {\n top = rect.y;\n }\n if (b > bottom) {\n bottom = b;\n }\n }\n\n const width = right - left;\n const height = bottom - top;\n\n return { x: left, y: top, width, height };\n}\n","import { Cell, DecoratorCell, NodeCell } from \"../interfaces\";\nimport { MoveCellPayload } from \"../reducers/interfaces\";\nimport {\n isContainerDecoratorCell,\n isGroupDecoratorCell,\n isNodeCell,\n} from \"./asserts\";\n\nexport function handleNodeContainedChange(\n payloads: MoveCellPayload[],\n cells: Cell[],\n onContainerContainerChange?: (detail: MoveCellPayload[]) => void\n) {\n const nodeAndGroupCells = cells.filter(\n (c): c is NodeCell => isNodeCell(c) || isGroupDecoratorCell(c)\n );\n const containerIds = payloads\n .filter((p) => isContainerDecoratorCell(p))\n .map((v) => v.id);\n const cellPayloads = payloads.filter((p) => {\n const cell = nodeAndGroupCells.find((v) => v.id === p.id)!;\n const includeNodeFlag =\n cell?.containerId && containerIds.includes(cell.containerId);\n return (\n ((isNodeCell(p) && !p.groupId) || isGroupDecoratorCell(p)) &&\n !includeNodeFlag\n );\n });\n const containerDecoratorCells = cells.filter(\n (cell): cell is DecoratorCell =>\n isContainerDecoratorCell(cell) && !cell.view?.locked\n );\n cellPayloads.forEach((payload) => {\n const left = payload.x;\n const right = payload.x + payload.width!;\n const top = payload.y;\n const bottom = payload.y + payload!.height!;\n\n for (const containerCell of containerDecoratorCells) {\n const containerLeft = containerCell.view.x;\n const containerRight = containerCell.view.x + containerCell.view.width;\n const containerTop = containerCell.view.y;\n const containerBottom = containerCell.view.y + containerCell.view.height;\n if (\n left >= containerLeft &&\n right <= containerRight &&\n top >= containerTop &&\n bottom <= containerBottom\n ) {\n payload.containerCell = containerCell;\n break; //A node can be associated with only one container\n }\n }\n });\n let containedChanges = [];\n containedChanges = cellPayloads.filter((payload) => {\n const cell = nodeAndGroupCells.find((c) => c.id === payload.id);\n const containerId = cell?.containerId;\n const containerCellId = payload.containerCell?.id;\n //过滤掉一直没有关系或者关系没有改变的\n return containerId !== containerCellId;\n });\n if (containedChanges.length > 0) {\n onContainerContainerChange?.(containedChanges);\n }\n return containedChanges;\n}\n","// istanbul ignore file: nothing logical to test\nimport React from \"react\";\nimport type {\n DecoratorCell,\n DecoratorLineView,\n DecoratorView,\n EdgeView,\n EditableLineCell,\n LineEditorState,\n NodeCell,\n SmartConnectLineState,\n} from \"./interfaces\";\nimport type { NodePosition } from \"../diagram/interfaces\";\n\nexport interface HoverState {\n // Currently only support node cell\n cell: NodeCell | DecoratorCell;\n relativePoints: ReadonlyArray<NodePosition>;\n points: ReadonlyArray<NodePosition>;\n activePointIndex?: number;\n}\n\nexport const HoverStateContext = React.createContext<{\n rootRef: React.RefObject<SVGSVGElement>;\n smartConnectLineState: SmartConnectLineState | null;\n unsetHoverStateTimeoutRef: React.MutableRefObject<number | null>;\n hoverState: HoverState | null;\n activeEditableLines: EditableLineCell[];\n lineEditorState: LineEditorState | null;\n movingCells?: boolean;\n setLineEditorState: React.Dispatch<\n React.SetStateAction<LineEditorState | null>\n >;\n setHoverState: React.Dispatch<React.SetStateAction<HoverState | null>>;\n setSmartConnectLineState: React.Dispatch<\n React.SetStateAction<SmartConnectLineState | null>\n >;\n onConnect?: (\n source: NodeCell | DecoratorCell,\n target: NodeCell | DecoratorCell,\n exitPosition: NodePosition,\n entryPosition: NodePosition | undefined\n ) => void;\n onChangeEdgeView?: (\n source: NodeCell | DecoratorCell,\n target: NodeCell | DecoratorCell,\n view: EdgeView\n ) => void;\n onChangeDecoratorView?: (\n cell: DecoratorCell,\n view: DecoratorView | DecoratorLineView\n ) => void;\n}>({\n rootRef: { current: null },\n smartConnectLineState: null,\n unsetHoverStateTimeoutRef: { current: null },\n hoverState: null,\n activeEditableLines: [],\n lineEditorState: null,\n setLineEditorState: () => {},\n setHoverState: () => {},\n setSmartConnectLineState: () => {},\n});\n\nexport function useHoverStateContext() {\n return React.useContext(HoverStateContext);\n}\n","import { isNil } from \"lodash\";\nimport type {\n Cell,\n DecoratorCell,\n EdgeCell,\n EditableEdgeLine,\n EditableLine,\n InitialCell,\n InitialNodeCell,\n InitialNodeView,\n LayoutType,\n LineDecoratorCell,\n LineType,\n NodeCell,\n} from \"../interfaces\";\nimport { MoveCellPayload } from \"../reducers/interfaces\";\n\nexport function isNodeCell(cell: Cell | MoveCellPayload): cell is NodeCell {\n return cell.type === \"node\";\n}\n\nexport function isDecoratorCell(\n cell: Cell | InitialCell\n): cell is DecoratorCell {\n return cell.type === \"decorator\";\n}\n\nexport function isInitialNodeCell(cell: InitialCell): cell is InitialNodeCell {\n return cell.type === \"node\";\n}\n\nexport function isEdgeCell(cell: InitialCell): cell is EdgeCell {\n return cell.type === \"edge\";\n}\n\nexport function isNodeOrEdgeCell(cell: Cell): cell is NodeCell | EdgeCell {\n return cell.type === \"node\" || cell.type === \"edge\";\n}\n\nexport function isNodeOrAreaDecoratorCell(\n cell: Cell\n): cell is NodeCell | DecoratorCell {\n return (\n cell.type === \"node\" ||\n (cell.type === \"decorator\" && cell.decorator === \"area\")\n );\n}\n\nexport function isEdgeSide(\n cell: Cell,\n allowEdgeToArea: boolean | undefined\n): cell is NodeCell | DecoratorCell {\n return (\n cell.type === \"node\" ||\n (!!allowEdgeToArea &&\n cell.type === \"decorator\" &&\n cell.decorator === \"area\")\n );\n}\n\nexport function isNodeOrTextDecoratorCell(\n cell: Cell | MoveCellPayload\n): cell is NodeCell | DecoratorCell {\n return (\n cell.type === \"node\" ||\n (cell.type === \"decorator\" && cell.decorator === \"text\")\n );\n}\n\nexport function isTextDecoratorCell(cell: Cell): cell is DecoratorCell {\n return cell.type === \"decorator\" && cell.decorator === \"text\";\n}\nexport function isContainerDecoratorCell(\n cell: InitialCell | MoveCellPayload\n): cell is DecoratorCell {\n return cell.type === \"decorator\" && cell.decorator === \"container\";\n}\n\nexport function isGroupDecoratorCell(\n cell: InitialCell | MoveCellPayload\n): cell is DecoratorCell {\n return cell.type === \"decorator\" && cell.decorator === \"group\";\n}\n\nexport function isLineDecoratorCell(\n cell: Cell | LineDecoratorCell | MoveCellPayload\n): cell is LineDecoratorCell {\n return cell.type === \"decorator\" && cell.decorator === \"line\";\n}\n\nexport function isNoManualLayout(layout: LayoutType) {\n return ![\"manual\", undefined].includes(layout!);\n}\n\nexport function isNoSize(view: InitialNodeView) {\n return !(view?.width && view?.height);\n}\n\nexport function isNoPoint(view: InitialNodeView) {\n return isNil(view?.x) || isNil(view?.y);\n}\n\nexport function isStraightType(type: LineType | undefined) {\n return !(type === \"polyline\" || type === \"curve\");\n}\n\nexport function isEditableEdgeLine(\n line: EditableLine\n): line is EditableEdgeLine {\n return !!(line as EditableEdgeLine).edge;\n}\n","import type { Cell, NodeCell, DecoratorCell, NodeId } from \"../interfaces\";\nimport { isNodeOrAreaDecoratorCell } from \"./asserts\";\n\nexport function findNodeOrAreaDecorator(\n cells: Cell[],\n id: NodeId\n): NodeCell | DecoratorCell | undefined {\n return cells.find(\n (cell) => isNodeOrAreaDecoratorCell(cell) && cell.id === id\n ) as NodeCell | DecoratorCell | undefined;\n}\n","import { sortBy } from \"lodash\";\nimport type {\n ComputedEdgeLineConf,\n LineSegmentJumps,\n} from \"../../draw-canvas/interfaces\";\nimport type { NodePosition } from \"../../diagram/interfaces\";\nimport { intersect } from \"../../diagram/lines/intersect\";\n\ninterface LineSegment {\n start: NodePosition;\n end: NodePosition;\n}\n\nconst LINE_JUMP_BASE_SIZE = 6;\n\nexport function collectLineJumpsFactory() {\n const allJumps: LineSegmentJumps[] = [];\n const allLineSegments: LineSegment[] = [];\n\n return function collectLineJumps(\n points: NodePosition[],\n lineConf: ComputedEdgeLineConf\n ): Map<number, LineSegmentJumps> | null {\n const lineJumps: LineSegmentJumps[] = [];\n const lineSegments: LineSegment[] = [];\n\n // Line jumps for curved lines are not supported.\n if (lineConf.type !== \"curve\" || lineConf.curveType === \"curveLinear\") {\n for (let i = 0; i < points.length - 1; i++) {\n const start = points[i];\n const end = points[i + 1];\n const jumpPoints: NodePosition[] = [];\n const radius = LINE_JUMP_BASE_SIZE / 2 + lineConf.strokeWidth - 1;\n if (lineConf.jumps) {\n jumpLoop: for (const item of allLineSegments) {\n const point = lineJumpIntersect(\n start,\n end,\n item.start,\n item.end,\n radius\n );\n if (point) {\n for (const jump of allJumps) {\n for (const p of jump.jumpPoints) {\n const distance = Math.sqrt(\n Math.pow(point.x - p.x, 2) + Math.pow(point.y - p.y, 2)\n );\n if (distance < radius + jump.radius) {\n // Ignore this jump point if it's too close to an existing one\n continue jumpLoop;\n }\n }\n }\n\n jumpPoints.push(point);\n }\n }\n }\n\n if (jumpPoints.length > 0) {\n // 将交叉点按其在连线上的顺序排列\n const sortedJumpPoints = sortBy(\n jumpPoints,\n (p) => (p.x - points[0].x) ** 2 + (p.y - points[0].y) ** 2\n );\n\n const segJumps: LineSegmentJumps = {\n jumpPoints: sortedJumpPoints,\n index: i,\n radius,\n };\n allJumps.push(segJumps);\n lineJumps.push(segJumps);\n }\n\n lineSegments.push({ start, end });\n }\n\n // 同一连线上的不同线段交叉时,不产生跨线\n allLineSegments.push(...lineSegments);\n }\n\n return lineJumps.length > 0\n ? new Map(lineJumps.map((j) => [j.index, j]))\n : null;\n };\n}\n\nfunction lineJumpIntersect(\n p1: NodePosition,\n p2: NodePosition,\n p3: NodePosition,\n p4: NodePosition,\n radius: number\n): NodePosition | null {\n const point = intersect(\n [p1.x, p1.y],\n [p2.x, p2.y],\n [p3.x, p3.y],\n [p4.x, p4.y]\n );\n if (point) {\n // Check if the intersection point is too close to the line ends\n const r2 = radius * radius;\n for (const p of [p1, p2, p3, p4]) {\n const dx = point[0] - p.x;\n const dy = point[1] - p.y;\n if (dx * dx + dy * dy < r2) {\n return null;\n }\n }\n return { x: point[0], y: point[1] };\n }\n return null;\n}\n","import { useMemo } from \"react\";\nimport type {\n Cell,\n ComputedEdgeLineConf,\n DecoratorCell,\n DecoratorLineView,\n EdgeCell,\n EditableLine,\n} from \"../../draw-canvas/interfaces\";\nimport {\n isEdgeCell,\n isLineDecoratorCell,\n isStraightType,\n} from \"../../draw-canvas/processors/asserts\";\nimport { findNodeOrAreaDecorator } from \"../../draw-canvas/processors/findNodeOrAreaDecorator\";\nimport { getSmartLinePoints } from \"./processors/getSmartLinePoints\";\nimport { collectLineJumpsFactory } from \"./collectLineJumpsFactory\";\n\nexport function useEditableLineMap({\n cells,\n lineConfMap,\n}: {\n cells: Cell[];\n lineConfMap: WeakMap<EdgeCell | DecoratorCell, ComputedEdgeLineConf>;\n}): WeakMap<EdgeCell | DecoratorCell, EditableLine> {\n return useMemo(() => {\n const map = new WeakMap<EdgeCell | DecoratorCell, EditableLine>();\n\n const collectLineJumps = collectLineJumpsFactory();\n\n for (const cell of cells) {\n if (isEdgeCell(cell)) {\n const lineConf = lineConfMap.get(cell);\n // istanbul ignore next: defensive check\n if (!lineConf) {\n continue;\n }\n\n const sourceNode = findNodeOrAreaDecorator(cells, cell.source);\n const targetNode = findNodeOrAreaDecorator(cells, cell.target);\n\n const hasOppositeEdge =\n isStraightType(cell.view?.type) &&\n cells.some(\n (c) =>\n isEdgeCell(c) &&\n cell.source === c.target &&\n cell.target === c.source &&\n isStraightType(c.view?.type)\n );\n const parallelGap = hasOppositeEdge ? lineConf.parallelGap : 0;\n\n const points =\n sourceNode &&\n targetNode &&\n sourceNode.view.x != null &&\n targetNode.view.x != null\n ? getSmartLinePoints(\n sourceNode.view,\n targetNode.view,\n cell.view,\n parallelGap,\n cell.type\n )\n : null;\n\n if (points) {\n const jumpsMap = collectLineJumps(points, lineConf);\n\n map.set(cell, {\n edge: cell,\n points,\n source: sourceNode!,\n target: targetNode!,\n parallelGap,\n jumpsMap,\n });\n }\n } else if (isLineDecoratorCell(cell)) {\n const lineConf = lineConfMap.get(cell);\n // istanbul ignore next: defensive check\n if (!lineConf) {\n continue;\n }\n\n const { source, target } = cell.view as DecoratorLineView;\n\n const points =\n source && target\n ? getSmartLinePoints(\n { ...source, width: 0, height: 0 },\n { ...target, width: 0, height: 0 },\n cell.view,\n 0,\n cell.type\n )\n : null;\n\n if (points) {\n const jumpsMap = collectLineJumps(points, lineConf);\n\n map.set(cell, {\n decorator: cell,\n points,\n parallelGap: 0,\n jumpsMap,\n });\n }\n }\n }\n return map;\n }, [cells, lineConfMap]);\n}\n","// istanbul ignore file: experimental\nimport React, { useEffect, useMemo, useRef } from \"react\";\nimport type { NodePosition } from \"../diagram/interfaces\";\nimport { useHoverStateContext } from \"./HoverStateContext\";\nimport type {\n ControlPoint,\n EditableLine,\n EditableLineCell,\n EditableLineView,\n} from \"./interfaces\";\nimport { isLineDecoratorCell, isStraightType } from \"./processors/asserts\";\n\nconst POINT_HELPER_IMAGE =\n \"data:image/svg+xml;base64,PCFET0NUWVBFIHN2ZyBQVUJMSUMgIi0vL1czQy8vRFREIFNWRyAxLjEvL0VOIiAiaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkIj48c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHdpZHRoPSIyMnB4IiBoZWlnaHQ9IjIycHgiIHZlcnNpb249IjEuMSI+PGNpcmNsZSBjeD0iMTEiIGN5PSIxMSIgcj0iNyIgc3Ryb2tlPSIjZmZmIiBmaWxsPSIjMjliNmYyIi8+PGNpcmNsZSBjeD0iMTEiIGN5PSIxMSIgcj0iMyIgc3Ryb2tlPSIjZmZmIiBmaWxsPSJ0cmFuc3BhcmVudCIvPjwvc3ZnPg==\";\nconst END_POINT_HELPER_IMAGE =\n \"data:image/svg+xml;base64,PCFET0NUWVBFIHN2ZyBQVUJMSUMgIi0vL1czQy8vRFREIFNWRyA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j48c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHdpZHRoPSIxOHB4IiBoZWlnaHQ9IjE4cHgiIHZlcnNpb249IjEuMSI+PGNpcmNsZSBjeD0iOSIgY3k9IjkiIHI9IjUiIHN0cm9rZT0iI2ZmZiIgZmlsbD0iIzI5YjZmMiIvPjwvc3ZnPg==\";\nconst POINT_HELPER_BG_SIZE = 22;\n\nexport interface LineEditorComponentProps {\n scale: number;\n editableLineMap: WeakMap<EditableLineCell, EditableLine>;\n activeEditableLine: EditableLineCell;\n updateCurActiveEditableLine?: (\n activeEditableLine: EditableLineCell | null\n ) => void;\n}\n\nexport function LineEditorComponent({\n scale,\n editableLineMap,\n activeEditableLine,\n updateCurActiveEditableLine,\n}: LineEditorComponentProps): JSX.Element | null {\n const { rootRef, movingCells, lineEditorState, setLineEditorState } =\n useHoverStateContext();\n const exitRef = useRef<SVGImageElement>(null);\n const entryRef = useRef<SVGImageElement>(null);\n const controlPointsRef = useRef<(SVGImageElement | null)[]>([]);\n const isLineDecorator = isLineDecoratorCell(activeEditableLine);\n\n useEffect(() => {\n const exit = exitRef.current;\n const entry = entryRef.current;\n if (!exit || !entry || !activeEditableLine) {\n return;\n }\n const handleMouseDownFactory = (type: \"exit\" | \"entry\") => {\n return (e: MouseEvent) => {\n e.stopPropagation();\n e.preventDefault();\n const rect = rootRef.current!.getBoundingClientRect();\n setLineEditorState({\n offset: [rect.left, rect.top],\n from: [e.clientX, e.clientY],\n type,\n });\n updateCurActiveEditableLine?.(activeEditableLine);\n };\n };\n const handleStartMouseDown = handleMouseDownFactory(\"exit\");\n const handleEndMouseDown = handleMouseDownFactory(\"entry\");\n exit.addEventListener(\"mousedown\", handleStartMouseDown);\n entry.addEventListener(\"mousedown\", handleEndMouseDown);\n return () => {\n exit.removeEventListener(\"mousedown\", handleStartMouseDown);\n entry.removeEventListener(\"mousedown\", handleEndMouseDown);\n };\n }, [\n activeEditableLine,\n rootRef,\n setLineEditorState,\n updateCurActiveEditableLine,\n ]);\n\n const controlPoints = useMemo(() => {\n if (!activeEditableLine) {\n return [];\n }\n\n const points = editableLineMap.get(activeEditableLine)!.points!;\n\n if (isStraightType((activeEditableLine.view as EditableLineView)?.type)) {\n return isLineDecorator ? getStraightControlPoints(points) : [];\n }\n\n return getControlPoints(points);\n }, [activeEditableLine, editableLineMap, isLineDecorator]);\n\n useEffect(() => {\n if (!activeEditableLine) {\n return;\n }\n const controlElements = controlPointsRef.current;\n const handleMouseDownFactory = (control: ControlPoint) => {\n return (e: MouseEvent) => {\n e.stopPropagation();\n e.preventDefault();\n updateCurActiveEditableLine?.(activeEditableLine);\n const rect = rootRef.current!.getBoundingClientRect();\n setLineEditorState({\n offset: [rect.left, rect.top],\n from: [e.clientX, e.clientY],\n type: control.type,\n control,\n });\n };\n };\n const handlers = controlPoints.map((control) =>\n handleMouseDownFactory(control)\n );\n controlElements.forEach((el, i) => {\n el?.addEventListener(\"mousedown\", handlers[i]);\n });\n return () => {\n controlElements.forEach((el, i) => {\n el?.removeEventListener(\"mousedown\", handlers[i]);\n });\n };\n }, [\n activeEditableLine,\n controlPoints,\n rootRef,\n setLineEditorState,\n updateCurActiveEditableLine,\n ]);\n\n const gRef = useRef<SVGGElement>(null);\n useEffect(() => {\n const g = gRef.current;\n const onClick = (e: MouseEvent) => {\n e.stopPropagation();\n e.preventDefault();\n };\n g?.addEventListener(\"click\", onClick);\n return () => {\n g?.removeEventListener(\"click\", onClick);\n };\n }, []);\n\n if (movingCells) {\n return null;\n }\n\n const view = activeEditableLine.view as EditableLineView;\n const linePoints = editableLineMap.get(activeEditableLine)!.points!;\n const { exitPosition, entryPosition } = view ?? {};\n\n const commonProps: React.SVGAttributes<SVGImageElement> = {\n width: POINT_HELPER_BG_SIZE / scale,\n height: POINT_HELPER_BG_SIZE / scale,\n preserveAspectRatio: \"none\",\n cursor: \"pointer\",\n pointerEvents: \"fill\",\n };\n const exitPoint = linePoints[0];\n const entryPoint = linePoints[linePoints.length - 1];\n const offset = POINT_HELPER_BG_SIZE / scale / 2;\n\n return (\n <g ref={gRef}>\n <image\n ref={exitRef}\n {...commonProps}\n x={exitPoint.x - offset}\n y={exitPoint.y - offset}\n xlinkHref={\n isLineDecorator\n ? VERTEX_HELPER_IMAGE\n : exitPosition\n ? ANCHORED_POINT_HELPER_IMAGE\n : POINT_HELPER_IMAGE\n }\n />\n {controlPoints.map((point, i) => (\n <image\n key={i}\n ref={(el) => {\n controlPointsRef.current[i] = el;\n }}\n {...commonProps}\n x={point.x - offset}\n y={point.y - offset}\n opacity={\n point.type === \"break\" &&\n !(\n lineEditorState?.type === \"break\" &&\n lineEditorState.control === point\n )\n ? 0.4\n : 1\n }\n xlinkHref={VERTEX_HELPER_IMAGE}\n cursor={\n isLineDecorator\n ? \"crosshair\"\n : point.direction === \"ns\"\n ? \"row-resize\"\n : \"col-resize\"\n }\n />\n ))}\n <image\n ref={entryRef}\n {...commonProps}\n x={entryPoint.x - offset}\n y={entryPoint.y - offset}\n xlinkHref={\n isLineDecorator\n ? END_POINT_HELPER_IMAGE\n : entryPosition\n ? ANCHORED_POINT_HELPER_IMAGE\n : POINT_HELPER_IMAGE\n }\n />\n </g>\n );\n}\n\nfunction getControlPoints(linePoints: NodePosition[]): ControlPoint[] {\n const controlPoints: ControlPoint[] = [];\n let prev = linePoints[0];\n let cursor = 1;\n while (cursor < linePoints.length) {\n const next = linePoints[cursor];\n const ns = prev.y === next.y;\n const ew = prev.x === next.x;\n if (!(ns && ew)) {\n const direction = ns ? \"ns\" : \"ew\";\n controlPoints.push({\n type: \"control\",\n direction,\n index: cursor - 1,\n x: (prev.x + next.x) / 2,\n y: (prev.y + next.y) / 2,\n });\n }\n prev = next;\n cursor++;\n }\n\n return controlPoints;\n}\n\nfunction getStraightControlPoints(linePoints: NodePosition[]): ControlPoint[] {\n const controlPoints: ControlPoint[] = [];\n let prev = linePoints[0];\n let cursor = 1;\n while (cursor < linePoints.length) {\n const next = linePoints[cursor];\n controlPoints.push({\n type: \"break\",\n index: cursor - 1,\n x: (prev.x + next.x) / 2,\n y: (prev.y + next.y) / 2,\n });\n if (cursor < linePoints.length - 1) {\n controlPoints.push({\n ...next,\n type: \"corner\",\n index: cursor - 1,\n });\n }\n prev = next;\n cursor++;\n }\n\n return controlPoints;\n}\n","import type { ActiveTarget, ActiveTargetOfSingular } from \"../interfaces\";\nimport { sameTarget } from \"./sameTarget\";\n\nexport function targetIsActive(\n target: ActiveTargetOfSingular,\n activeTarget: ActiveTarget | null | undefined\n): boolean {\n return (\n !!activeTarget &&\n (activeTarget.type === \"multi\"\n ? activeTarget.targets\n : [activeTarget]\n ).some((active) => sameTarget(active, target))\n );\n}\n","import { get } from \"lodash\";\nimport { CONTAINERGAP, DEFAULT_NODE_SIZE, MAXPERROW } from \"../constants\";\nimport { DecoratorCell, NodeCell } from \"../interfaces\";\nimport { isGroupDecoratorCell, isNoPoint } from \"./asserts\";\n\n/**\n * 交错排列的网格布局\n * [●][●][●][●]\n * [●][●][●]\n * [●][●][●][●]\n * @param nodes\n * @param options\n * @returns\n */\nexport function staggeredLayout(\n nodes: (NodeCell | DecoratorCell)[],\n options: {\n gapX?: number;\n gapY?: number;\n offsetY?: number;\n maxPerRow?: number;\n } = {}\n): (NodeCell | DecoratorCell)[] {\n const {\n gapX = 50,\n gapY = 50,\n offsetY = CONTAINERGAP,\n maxPerRow = MAXPERROW,\n } = options;\n /**\n * 满行数量(例如4个)\n * 短行数量(例如3个)\n */\n const fullRowCount = maxPerRow;\n const shortRowCount = maxPerRow - 1;\n const layoutedNodes = [];\n let index = 0,\n row = 0,\n preRowOffsetY = offsetY;\n\n while (index < nodes.length) {\n const isOddRow = row % 2 === 1;\n const nodesInRow = isOddRow ? shortRowCount : fullRowCount;\n let nodeX = isOddRow ? CONTAINERGAP : 0,\n maxNodeHeight = 0;\n for (let i = 0; i < nodesInRow && index < nodes.length; i++, index++) {\n const node = nodes[index];\n const nodeWidth = get(node, \"view.width\", DEFAULT_NODE_SIZE);\n const nodeHeight = get(node, \"view.height\", DEFAULT_NODE_SIZE);\n const x = nodeX;\n const y = preRowOffsetY;\n if (isNoPoint(nodes[index].view) || isGroupDecoratorCell(nodes[index])) {\n nodes[index].view = {\n ...nodes[index].view,\n x,\n y,\n width: nodeWidth,\n height: nodeHeight,\n };\n }\n nodeX = x + (nodeWidth + gapX);\n maxNodeHeight = Math.max(maxNodeHeight, nodeHeight);\n layoutedNodes.push(nodes[index]);\n }\n preRowOffsetY = preRowOffsetY + maxNodeHeight + gapY;\n row++;\n }\n return layoutedNodes;\n}\n","import { get } from \"lodash\";\nimport { BaseNodeCell } from \"../interfaces\";\nimport { CONTAINERGAP } from \"../constants\";\n\nexport function computeBoundingBox(\n cells: BaseNodeCell[],\n options?: { padding: number }\n) {\n let minX = Infinity,\n minY = Infinity;\n let maxX = -Infinity,\n maxY = -Infinity;\n cells.forEach((cell) => {\n const { x, y, width, height } = cell.view;\n if (x < minX) minX = x;\n if (y < minY) minY = y;\n if (x + width > maxX) maxX = x + width;\n if (y + height > maxY) maxY = y + height;\n });\n if (![minX, maxX, minY, maxY].some((n) => isFinite(n))) return {};\n const padding = get(options, \"padding\", CONTAINERGAP);\n const width = maxX - minX + padding * 2;\n const height = maxY - minY + padding * 2;\n return {\n x: minX - padding,\n y: minY - padding,\n width: width,\n height: height,\n };\n}\n","import { forEach, groupBy, isNil } from \"lodash\";\nimport { DecoratorCell, InitialCell, NodeCell, NodeView } from \"../interfaces\";\nimport {\n isContainerDecoratorCell,\n isGroupDecoratorCell,\n isNoPoint,\n} from \"./asserts\";\nimport { SizeTuple } from \"../../diagram/interfaces\";\nimport { CONTAINERGAP } from \"../constants\";\nimport { computeBoundingBox } from \"./computeBoundingBox\";\nimport { GROUPPADDING } from \"./initialGroupLayout\";\ninterface Point {\n x: number;\n y: number;\n}\n\n/**\n * 在容器内新加节点时,计算新节点的点按位置\n * 按网格排布避免重叠\n * @param cells\n * @param defaultNodeSize 默认节点大小\n * @returns void\n */\nexport function generateNewPointsWithLayout(\n cells: InitialCell[],\n { defaultNodeSize }: { defaultNodeSize: SizeTuple }\n) {\n const newContainerChildCells = cells.filter(\n (c) => c.type === \"node\" && isNoPoint(c.view!) && !isNil(c.containerId)\n ) as NodeCell[];\n const newGroupChildCells = cells.filter(\n (c) => c.type === \"node\" && isNoPoint(c.view!) && !isNil(c.groupId)\n ) as NodeCell[];\n if (newGroupChildCells.length) {\n const groupMap: Record<string, NodeCell[]> = {};\n forEach(\n groupBy(newGroupChildCells, \"groupId\"),\n (groupedNodes, containerId) => {\n groupMap[containerId] = groupedNodes;\n }\n );\n\n const groupCells = cells.filter(\n (c) => isGroupDecoratorCell(c) && groupMap[c.id]\n ) as DecoratorCell[];\n groupCells.forEach((group) => {\n const groupId = group.id;\n const newNodes = groupMap[groupId];\n const groupView = !isNoPoint(group.view)\n ? group.view\n : (computeBoundingBox(\n cells.filter(\n (c) => c.type === \"node\" && c.groupId === groupId\n ) as NodeCell[],\n {\n padding: GROUPPADDING,\n }\n ) as NodeView);\n const existingPoints = cells\n .filter(\n (c) =>\n (c as NodeCell)?.groupId === groupId &&\n !isNoPoint((c as NodeCell).view)\n )\n .map((node) => ({ x: node.view!.x, y: node.view!.y })) as Point[];\n newNodes.forEach((node) => {\n const nodeWidth = node.view?.width || defaultNodeSize[0];\n const nodeHeight = node.view?.height || defaultNodeSize[1];\n const gap = 10; // 间距\n const padding = CONTAINERGAP; // 内边距\n\n const newPoint = computeNodePoints(\n groupView,\n existingPoints,\n nodeWidth,\n nodeHeight,\n gap,\n padding\n );\n if (newPoint) {\n node.view = {\n ...node.view,\n x: newPoint.x,\n y: newPoint.y,\n };\n existingPoints.push(newPoint);\n }\n });\n });\n }\n if (newContainerChildCells.length) {\n const containerGroup: Record<string, NodeCell[]> = {};\n forEach(\n groupBy(newContainerChildCells, \"containerId\"),\n (groupedNodes, containerId) => {\n containerGroup[containerId] = groupedNodes;\n }\n );\n\n const containerCells = cells.filter(\n (c) => isContainerDecoratorCell(c) && containerGroup[c.id]\n ) as DecoratorCell[];\n containerCells.forEach((container) => {\n const containerId = container.id;\n const containerView = container.view;\n\n const existingPoints = cells\n .filter(\n (c) =>\n (c as NodeCell)?.containerId === containerId &&\n !isNoPoint((c as NodeCell).view)\n )\n .map((node) => ({ x: node.view!.x, y: node.view!.y })) as Point[];\n const newNodes = containerGroup[containerId];\n newNodes.forEach((node) => {\n const nodeWidth = node.view?.width || defaultNodeSize[0];\n const nodeHeight = node.view?.height || defaultNodeSize[1];\n const gap = 10; // 间距\n const padding = CONTAINERGAP; // 内边距\n\n const newPoint = computeNodePoints(\n containerView,\n existingPoints,\n nodeWidth,\n nodeHeight,\n gap,\n padding\n );\n if (newPoint) {\n node.view = {\n ...node.view,\n x: newPoint.x,\n y: newPoint.y,\n };\n existingPoints.push(newPoint);\n }\n });\n });\n }\n}\n\nfunction computeNodePoints(\n containerView: NodeView,\n existingPoints: Point[],\n nodeWidth: number,\n nodeHeight: number,\n gap = 0,\n padding = 0\n) {\n const { x: left, y: top, width } = containerView;\n const stepX = nodeWidth + gap;\n const stepY = nodeHeight + gap;\n const cols = Math.max(Math.floor((width - padding * 2) / stepX), 1);\n let row = 0;\n\n while (true) {\n for (let col = 0; col < cols; col++) {\n const x = left + padding + col * stepX;\n const y = top + padding + row * stepY;\n\n const overlapping = existingPoints.some((p) =>\n isOverlapping(\n x,\n y,\n nodeWidth,\n nodeHeight,\n p.x,\n p.y,\n nodeWidth,\n nodeHeight\n )\n );\n\n if (!overlapping) {\n return { x, y };\n }\n }\n row++;\n }\n}\n/**\n * 判断两个矩形中心点是否重叠(简单矩形碰撞判断)\n */\nfunction isOverlapping(\n x1: number,\n y1: number,\n w1: number,\n h1: number,\n x2: number,\n y2: number,\n w2: number,\n h2: number\n) {\n const cx1 = x1 + w1 / 2;\n const cy1 = y1 + h1 / 2;\n const cx2 = x2 + w2 / 2;\n const cy2 = y2 + h2 / 2;\n\n const minDistX = (w1 + w2) / 2;\n const minDistY = (h1 + h2) / 2;\n\n return Math.abs(cx1 - cx2) < minDistX && Math.abs(cy1 - cy2) < minDistY;\n}\n","import { get, without } from \"lodash\";\nimport type {\n RangeTuple,\n SizeTuple,\n TransformLiteral,\n} from \"../../diagram/interfaces\";\nimport {\n DEFAULT_NODE_GAP_H,\n DEFAULT_NODE_GAP_V,\n SYMBOL_FOR_SIZE_INITIALIZED,\n} from \"../constants\";\nimport type {\n Cell,\n DecoratorCell,\n InitialCell,\n LayoutOptions,\n LayoutType,\n NodeCell,\n NodeId,\n NodeView,\n} from \"../interfaces\";\nimport {\n isContainerDecoratorCell,\n isDecoratorCell,\n isEdgeCell,\n isGroupDecoratorCell,\n isNodeCell,\n isNoPoint,\n isNoSize,\n} from \"./asserts\";\nimport { initializeCells } from \"./initializeCells\";\nimport { transformToCenter } from \"./transformToCenter\";\nimport { forceLayout } from \"../../shared/canvas/forceLayout\";\nimport { dagreLayout } from \"../../shared/canvas/dagreLayout\";\nimport { sameTarget } from \"./sameTarget\";\nimport { generateNewPointsWithLayout } from \"./generateNewPointsWithLayout\";\nimport { initialContainerLayout } from \"./initialContainerLayout\";\n\nexport function updateCells({\n cells,\n layout,\n previousCells,\n defaultNodeSize,\n canvasWidth,\n canvasHeight,\n scaleRange,\n transform,\n reason,\n parent,\n parentNode,\n allowEdgeToArea,\n layoutOptions,\n}: {\n cells: InitialCell[] | undefined;\n layout?: LayoutType;\n previousCells: Cell[];\n defaultNodeSize: SizeTuple;\n canvasWidth: number;\n canvasHeight: number;\n scaleRange: RangeTuple;\n transform: TransformLiteral;\n reason?: \"add-related-nodes\";\n parent?: NodeId;\n parentNode?: NodeCell;\n allowEdgeToArea?: boolean;\n layoutOptions?: LayoutOptions;\n}): {\n cells: Cell[];\n updated: Cell[];\n shouldReCenter: boolean;\n} {\n const isManualLayout = layout !== \"force\" && layout !== \"dagre\";\n\n // --- Step 1: 初始化 ---\n const newCells = initializeCells(cells, {\n defaultNodeSize,\n layoutOptions,\n isInitialize: false,\n });\n const updateCandidates: (NodeCell | DecoratorCell)[] = [];\n let shouldReCenter = false;\n\n // 记录已存在的节点尺寸,避免丢失\n const prevSizeNodes = new Map<string, NodeCell>();\n let prevShouldCentered = false;\n for (const c of previousCells) {\n if (isDecoratorCell(c) || isNodeCell(c)) {\n prevShouldCentered = true;\n if (isNodeCell(c) && c[SYMBOL_FOR_SIZE_INITIALIZED]) {\n prevSizeNodes.set(c.id, c);\n }\n }\n }\n\n // 构建 id -> node 映射,复用尺寸\n const nodesMap = new Map<string, NodeCell>();\n for (const c of newCells) {\n if (isNodeCell(c)) {\n nodesMap.set(c.id, c);\n const prevNode = prevSizeNodes.get(c.id);\n if (prevNode) {\n Object.assign(c.view, {\n width: prevNode.view.width,\n height: prevNode.view.height,\n });\n c[SYMBOL_FOR_SIZE_INITIALIZED] = true;\n }\n }\n }\n\n // --- Step 2: 特殊场景 - add-related-nodes ---\n let handled = false;\n if (reason === \"add-related-nodes\") {\n handled = layoutRelatedNodes({\n newCells,\n nodesMap,\n parent,\n parentNode,\n isManualLayout,\n updateCandidates,\n handled,\n });\n }\n\n // --- Step 3: 常规布局 ---\n if (!handled) {\n const positioned: NodeCell[] = [];\n let hasDecorators = false;\n\n for (const c of newCells) {\n if (isNodeCell(c)) {\n if (isNoPoint(c.view)) updateCandidates.push(c);\n else positioned.push(c);\n } else if (isDecoratorCell(c)) {\n hasDecorators = true;\n }\n }\n\n if (isManualLayout) {\n // 没有居中过,执行一次居中变换\n if (!prevShouldCentered) {\n transform = transformToCenter(without(newCells, ...updateCandidates), {\n canvasWidth,\n canvasHeight,\n scaleRange,\n });\n }\n\n let getNodeView: (id: NodeId) => NodeView;\n if (\n positioned.length === 0 ||\n (positioned.length === 1 &&\n !hasDecorators &&\n updateCandidates.length > 0)\n ) {\n // 使用 dagre 初始布局\n updateCandidates.push(...positioned);\n ({ getNodeView } = dagreLayout({ cells: newCells, allowEdgeToArea }));\n shouldReCenter =\n previousCells.length === 0 ||\n (previousCells.length === newCells.length &&\n previousCells.every((cell, i) => sameTarget(cell, newCells[i])));\n } else {\n // 使用 force layout 固定已存在位置\n ({ getNodeView } = forceLayout({\n cells: newCells,\n fixedPosition: true,\n allowEdgeToArea,\n center: [\n (canvasWidth / 2 - transform.x) / transform.k,\n (canvasHeight / 2 - transform.y) / transform.k,\n ],\n }));\n }\n\n // --- Step 4: 容器、分组布局 ---\n const containerCells = newCells.filter(\n (cell) => isContainerDecoratorCell(cell) && isNoSize(cell.view)\n ) as DecoratorCell[];\n const groupCells = newCells.filter(\n (cell) => isGroupDecoratorCell(cell) && isNoSize(cell.view)\n ) as DecoratorCell[];\n\n const containerAndGroupCells = [...containerCells, ...groupCells];\n const nodeLayout =\n get(layoutOptions, \"initialLayout\") === \"layered-staggered\"\n ? \"staggered\"\n : \"dagre\";\n if (containerAndGroupCells.length > 0) {\n initialContainerLayout(newCells, { nodeLayout });\n updateCandidates.push(...containerAndGroupCells);\n } else {\n generateNewPointsWithLayout(newCells, { defaultNodeSize });\n }\n\n // --- Step 5: 更新未定位节点 ---\n for (const c of newCells) {\n if (isNodeCell(c) && isNoPoint(c.view)) {\n const v = getNodeView(c.id);\n c.view.x = v.x;\n c.view.y = v.y;\n }\n }\n }\n }\n\n return { cells: newCells, updated: updateCandidates, shouldReCenter };\n}\n\n/**\n * 布局 add-related-nodes 的子节点\n */\nfunction layoutRelatedNodes({\n newCells,\n nodesMap,\n parent,\n parentNode,\n isManualLayout,\n updateCandidates,\n handled,\n}: {\n newCells: Cell[];\n nodesMap: Map<string, NodeCell>;\n parent?: NodeId;\n parentNode?: NodeCell;\n isManualLayout: boolean;\n updateCandidates: (NodeCell | DecoratorCell)[];\n handled: boolean;\n}): boolean {\n const parentNodeCell = parent ? nodesMap.get(parent) : parentNode;\n\n if (!parentNodeCell || isNoPoint(parentNodeCell.view)) return handled;\n\n // 构建父->子[]\n const adjacency = new Map<string, string[]>();\n const queue: { id: string; parentId: string }[] = [];\n\n for (const c of newCells) {\n if (isEdgeCell(c) && c.source && c.target) {\n if (!adjacency.has(c.source)) adjacency.set(c.source, []);\n adjacency.get(c.source)!.push(c.target);\n queue.push({ id: c.target, parentId: c.source });\n }\n }\n\n while (queue.length > 0) {\n const { id, parentId } = queue.shift()!;\n const node = nodesMap.get(id);\n const parent = nodesMap.get(parentId);\n if (!node || !parent) continue;\n\n if (isNoPoint(node.view)) {\n if (isManualLayout) {\n const siblings = adjacency.get(parentId)!;\n const index = siblings.indexOf(id);\n const baseX =\n parent.view.x + parent.view.width / 2 - node.view.width / 2;\n const baseY = parent.view.y + parent.view.height + DEFAULT_NODE_GAP_V;\n\n let offsetX = 0;\n if (index > 0) {\n const step = Math.ceil(index / 2);\n const dir = 1 - 2 * (index % 2);\n offsetX = dir * step * (node.view.width + DEFAULT_NODE_GAP_H);\n }\n\n node.view.x = baseX + offsetX;\n node.view.y = baseY;\n }\n\n updateCandidates.push(node);\n }\n\n (adjacency.get(id) || []).forEach((cid) =>\n queue.push({ id: cid, parentId: id })\n );\n }\n\n return !newCells.some((c) => c.type === \"decorator\" && isNoPoint(c.view));\n}\n","import type { TransformLiteral } from \"../../diagram/interfaces\";\nimport { getCellsRect } from \"../../shared/canvas/processors/getCellsRect\";\nimport {\n getTransformToCenter,\n type TransformToCenterOptions,\n} from \"../../shared/canvas/processors/getTransformToCenter\";\nimport type { Cell } from \"../interfaces\";\n\nexport function transformToCenter(\n cells: Cell[],\n options: TransformToCenterOptions\n): TransformLiteral {\n const rect = getCellsRect(cells);\n return getTransformToCenter(rect, options);\n}\n","import React, { useEffect, useState } from \"react\";\nimport classNames from \"classnames\";\nimport type { ConnectLineState } from \"./interfaces\";\nimport type { PositionTuple, TransformLiteral } from \"../diagram/interfaces\";\n\nexport interface ConnectLineComponentProps {\n connectLineState: ConnectLineState | null;\n transform: TransformLiteral;\n markerEnd: string;\n onConnect(state: ConnectLineState, to: PositionTuple): void;\n}\n\nexport function ConnectLineComponent({\n connectLineState,\n transform,\n markerEnd,\n onConnect,\n}: ConnectLineComponentProps): JSX.Element {\n const [connectLineTo, setConnectLineTo] = useState<PositionTuple | null>(\n null\n );\n\n useEffect(() => {\n if (connectLineState) {\n setConnectLineTo(connectLineState.from);\n }\n }, [connectLineState]);\n\n useEffect(() => {\n if (connectLineState) {\n const getConnectTo = (e: MouseEvent): PositionTuple => [\n (e.clientX - transform.x - connectLineState.offset[0]) / transform.k,\n (e.clientY - transform.y - connectLineState.offset[1]) / transform.k,\n ];\n const onMouseMove = (e: MouseEvent) => {\n // Set connect line to based on the mouse position and the transform\n setConnectLineTo(getConnectTo(e));\n };\n const onMouseDown = (e: MouseEvent) => {\n e.stopPropagation();\n };\n const onClick = (e: MouseEvent) => {\n e.stopPropagation();\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n reset();\n onConnect(connectLineState, getConnectTo(e));\n };\n const reset = () => {\n document.removeEventListener(\"mousemove\", onMouseMove);\n document.removeEventListener(\"mousedown\", onMouseDown, {\n capture: true,\n });\n document.removeEventListener(\"click\", onClick, { capture: true });\n setConnectLineTo(null);\n };\n document.addEventListener(\"mousemove\", onMouseMove);\n document.addEventListener(\"mousedown\", onMouseDown, { capture: true });\n document.addEventListener(\"click\", onClick, { capture: true });\n\n return reset;\n }\n }, [connectLineState, onConnect, transform]);\n\n return (\n <path\n className={classNames(\"connect-line\", {\n connecting:\n !!connectLineState &&\n connectLineTo &&\n // Do not show when the distance of mouse move is less than 5px\n (connectLineTo[0] - connectLineState.from[0]) ** 2 +\n (connectLineTo[1] - connectLineState.from[1]) ** 2 >\n 25,\n })}\n d={\n connectLineState && connectLineTo\n ? `M${connectLineState.from.join(\" \")}L${connectLineTo.join(\" \")}`\n : \"\"\n }\n fill=\"none\"\n stroke=\"gray\"\n strokeWidth={1}\n markerEnd={`url(#${markerEnd})`}\n />\n );\n}\n","// Imports\nimport ___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___ from \"../../../../../node_modules/css-loader/dist/runtime/noSourceMaps.js\";\nimport ___CSS_LOADER_API_IMPORT___ from \"../../../../../node_modules/css-loader/dist/runtime/api.js\";\nvar ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___);\n// Module\n___CSS_LOADER_EXPORT___.push([module.id, `.zoom-bar{position:absolute;bottom:20px;right:20px;width:40px;scale:0.8}.zoom-slider,\n.center-button{width:100%;display:flex;align-items:center;border:1px solid var(--antd-background-color-base);border-radius:var(--larger-border-radius);box-shadow:var(--connected-overlay-shadow);background-color:var(--color-fill-bg-container-4)}.zoom-slider{height:140px;padding:8px 0;flex-direction:column}[role=\"button\"]{cursor:pointer}.center-button{justify-content:center;margin-bottom:8px;height:40px}.center-button:hover{border-color:var(--antd-btn-default-hover-border-color)}.center-button path{fill:var(--antd-link-hover-color)}.center-button:hover path{fill:var(--palette-blue-7)}.zoom-button{font-size:16px;line-height:0}.zoom-button svg{width:1em;height:1em;fill:var(--antd-link-hover-color)}.zoom-slider .ant-slider-vertical{padding-left:5px;padding-right:5px}.zoom-slider .ant-slider-vertical .ant-slider-rail{width:2px}.zoom-slider .ant-slider-vertical .ant-slider-handle{width:6px;height:6px;left:3px}.zoom-slider .ant-slider .ant-slider-handle:hover::before,\n.zoom-slider .ant-slider .ant-slider-handle:focus::before,\n.zoom-slider .ant-slider .ant-slider-handle::before{width:10px;height:10px;left:-2px}.zoom-slider .ant-slider .ant-slider-handle:hover::after,\n.zoom-slider .ant-slider .ant-slider-handle:focus::after,\n.zoom-slider .ant-slider .ant-slider-handle::after{width:6px;height:6px;top:0;left:0}`, \"\"]);\n// Exports\nexport default ___CSS_LOADER_EXPORT___.toString();\n","import * as React from \"react\";\nconst SvgCenter = props => <svg xmlns=\"http://www.w3.org/2000/svg\" width={24} height={24} viewBox=\"0 0 24 24\" {...props}><path d=\"M12 0a.5.5 0 0 1 .5.5v2.013a9.5 9.5 0 0 1 8.987 8.988L23.5 11.5a.5.5 0 0 1 0 1h-2.013a9.5 9.5 0 0 1-8.987 8.987V23.5a.5.5 0 0 1-1 0v-2.013A9.5 9.5 0 0 1 2.514 12.5H.5a.5.5 0 0 1 0-1h2.013A9.5 9.5 0 0 1 11.5 2.514V.5A.5.5 0 0 1 12 0M3.514 11.5H7.5a.5.5 0 0 1 0 1H3.514a8.5 8.5 0 0 0 7.987 7.986L11.5 16.5a.5.5 0 0 1 1 0v3.986a8.5 8.5 0 0 0 7.986-7.986H16.5a.5.5 0 0 1 0-1h3.986A8.5 8.5 0 0 0 12.5 3.515V7.5a.5.5 0 0 1-1 0V3.514a8.5 8.5 0 0 0-7.986 7.987zm8.486-1a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3\" /></svg>;\nexport default SvgCenter;","import * as React from \"react\";\nconst SvgZoomIn = props => <svg xmlns=\"http://www.w3.org/2000/svg\" width={128} height={128} className=\"icon\" viewBox=\"0 0 1024 1024\" {...props}><path d=\"M512 76.8A435.2 435.2 0 1 0 947.2 512 435.71 435.71 0 0 0 512 76.8m0 819.2a384 384 0 1 1 384-384 384 384 0 0 1-384 384\" /><path d=\"M744.448 486.4h-204.8V281.6a25.6 25.6 0 1 0-51.2 0v204.8h-204.8a25.6 25.6 0 0 0 0 51.2h204.8v204.8a25.6 25.6 0 0 0 51.2 0V537.6h204.8a25.6 25.6 0 0 0 0-51.2\" /></svg>;\nexport default SvgZoomIn;","import * as React from \"react\";\nconst SvgZoomOut = props => <svg xmlns=\"http://www.w3.org/2000/svg\" width={128} height={128} className=\"icon\" viewBox=\"0 0 1024 1024\" {...props}><path d=\"M512 76.8A435.2 435.2 0 1 0 947.2 512 435.71 435.71 0 0 0 512 76.8m0 819.2a384 384 0 1 1 384-384 384 384 0 0 1-384 384\" /><path d=\"M744.448 486.4H280.064a25.6 25.6 0 1 0 0 51.2h464.384a25.6 25.6 0 0 0 0-51.2\" /></svg>;\nexport default SvgZoomOut;","import React, { useCallback, useMemo, useRef } from \"react\";\nimport { ConfigProvider, Slider, theme } from \"antd\";\nimport { StyleProvider, createCache } from \"@ant-design/cssinjs\";\nimport { useCurrentTheme } from \"@next-core/react-runtime\";\nimport type { RangeTuple } from \"../../diagram/interfaces\";\nimport CenterSVG from \"./icons/center.svg\";\nimport ZoomInSVG from \"./icons/zoom-in.svg\";\nimport ZoomOutSVG from \"./icons/zoom-out.svg\";\n\nexport interface ZoomBarComponentProps {\n shadowRoot: ShadowRoot;\n scale: number;\n scaleRange: RangeTuple;\n onZoomChange(value: number): void;\n onReCenter(): void;\n}\n\nexport function ZoomBarComponent({\n shadowRoot,\n scale,\n scaleRange,\n onZoomChange,\n onReCenter,\n}: ZoomBarComponentProps): JSX.Element | null {\n const currentTheme = useCurrentTheme();\n const cache = useMemo(() => createCache(), []);\n const zoomBarRef = useRef<HTMLDivElement | null>(null);\n const min = scaleRange[0] * 100;\n const max = scaleRange[1] * 100;\n const value = scale * 100;\n const step = 5;\n\n const tooltip = useMemo(() => {\n return {\n formatter: (value: number | undefined) => `${value}%`,\n placement: \"left\" as const,\n getPopupContainer: () => zoomBarRef.current!,\n };\n }, []);\n\n const onZoomIn = useCallback(() => {\n onZoomChange(Math.min(value + step, max));\n }, [max, onZoomChange, value]);\n\n const onZoomOut = useCallback(() => {\n onZoomChange(Math.max(value - step, min));\n }, [min, onZoomChange, value]);\n\n return (\n <ConfigProvider\n theme={{\n algorithm:\n currentTheme === \"dark-v2\"\n ? theme.darkAlgorithm\n : theme.defaultAlgorithm,\n }}\n >\n <StyleProvider\n container={shadowRoot}\n // Auto clear injected styles after unmount\n autoClear\n cache={cache}\n // Set hashPriority to \"high\" to disable `:where()` usage for compatibility\n hashPriority=\"high\"\n >\n <div className=\"zoom-bar\" ref={zoomBarRef}>\n <div className=\"center-button\" onClick={onReCenter} role=\"button\">\n <CenterSVG />\n </div>\n <div className=\"zoom-slider\">\n <div className=\"zoom-button\" role=\"button\" onClick={onZoomIn}>\n <ZoomInSVG />\n </div>\n <Slider\n min={min}\n max={max}\n value={value}\n step={step}\n vertical\n included={false}\n tooltip={tooltip}\n onChange={onZoomChange}\n />\n <div className=\"zoom-button\" role=\"button\" onClick={onZoomOut}>\n <ZoomOutSVG />\n </div>\n </div>\n </div>\n </StyleProvider>\n </ConfigProvider>\n );\n}\n","import { pick } from \"lodash\";\nimport type { ActiveTargetOfSingular, Cell } from \"../interfaces\";\n\nexport function cellToTarget(cell: Cell): ActiveTargetOfSingular {\n return cell.type === \"edge\"\n ? pick(cell, [\"type\", \"source\", \"target\", \"data\"])\n : pick(cell, [\"type\", \"id\", \"data\"]);\n}\n","import type { PositionTuple, TransformLiteral } from \"../../diagram/interfaces\";\nimport type { NodeView } from \"../interfaces\";\n\nexport interface HandleLassoOptions {\n transform: TransformLiteral;\n offset: PositionTuple;\n onLassoing(rect: NodeView): void;\n onLassoed(rect: NodeView): void;\n}\n\nexport function handleLasso(\n event: MouseEvent,\n { transform, offset, onLassoing, onLassoed }: HandleLassoOptions\n) {\n if (event.ctrlKey || event.button) {\n return;\n }\n\n event.stopPropagation();\n\n const from: PositionTuple = [event.clientX, event.clientY];\n const x0 = (event.clientX - offset[0] - transform.x) / transform.k;\n const y0 = (event.clientY - offset[1] - transform.y) / transform.k;\n\n function getMovement(e: MouseEvent): PositionTuple {\n return [\n (e.clientX - from[0]) / transform.k,\n (e.clientY - from[1]) / transform.k,\n ];\n }\n\n let moved = false;\n\n const handleMove = (e: MouseEvent, finished?: boolean) => {\n // Respect the scale\n const movement = getMovement(e);\n if (!moved) {\n moved = movement[0] ** 2 + movement[1] ** 2 >= 9;\n }\n if (moved) {\n let [width, height] = movement;\n let x = x0;\n let y = y0;\n if (width < 0) {\n x = x0 + width;\n width = -width;\n }\n if (height < 0) {\n y = y0 + height;\n height = -height;\n }\n (finished ? onLassoed : onLassoing)({\n x,\n y,\n width,\n height,\n });\n }\n };\n\n const onMouseMove = (e: MouseEvent) => {\n handleMove(e);\n };\n const onMouseUp = (e: MouseEvent) => {\n handleMove(e, true);\n moved = false;\n document.removeEventListener(\"mousemove\", onMouseMove);\n document.removeEventListener(\"mouseup\", onMouseUp);\n };\n document.addEventListener(\"mousemove\", onMouseMove);\n document.addEventListener(\"mouseup\", onMouseUp);\n}\n","import { pick } from \"lodash\";\nimport {\n forceCollide,\n forceLink,\n forceManyBody,\n forceSimulation,\n forceX,\n forceY,\n type Simulation,\n} from \"d3-force\";\nimport type {\n Cell,\n ForceCollideOptions,\n ForceLink,\n ForceNode,\n LayoutOptionsForce,\n NodeId,\n NodeView,\n} from \"../../draw-canvas/interfaces\";\nimport {\n isEdgeCell,\n isNodeCell,\n isNodeOrAreaDecoratorCell,\n} from \"../../draw-canvas/processors/asserts\";\nimport { extractPartialRectTuple } from \"../../diagram/processors/extractPartialRectTuple\";\nimport type { FullRectTuple, PositionTuple } from \"../../diagram/interfaces\";\n\nexport interface ForceLayoutOptions {\n cells: Cell[];\n layoutOptions?: LayoutOptionsForce;\n center?: PositionTuple;\n fixedPosition?: boolean;\n allowEdgeToArea?: boolean;\n}\n\nexport function forceLayout({\n cells,\n layoutOptions,\n center,\n fixedPosition,\n allowEdgeToArea,\n}: ForceLayoutOptions): {\n getNodeView: (id: NodeId) => NodeView;\n nodePaddings: FullRectTuple;\n} {\n const { nodePadding, collide } = {\n nodePadding: 0,\n ...pick(layoutOptions, [\"nodePadding\"]),\n collide:\n layoutOptions?.collide !== false\n ? ({\n radiusDiff: 18,\n strength: 1,\n iterations: 1,\n ...(layoutOptions?.collide === true\n ? null\n : (layoutOptions?.collide as ForceCollideOptions)),\n } as Required<ForceCollideOptions>)\n : (false as const),\n };\n const nodePaddings = extractPartialRectTuple(nodePadding);\n const forceNodes: ForceNode[] = [];\n const forceLinks: ForceLink[] = [];\n const nodesMap = new Map<NodeId, ForceNode>();\n for (const cell of cells) {\n if (\n (allowEdgeToArea && isNodeOrAreaDecoratorCell(cell)) ||\n isNodeCell(cell)\n ) {\n const node: ForceNode = {\n id: cell.id,\n width: cell.view.width + nodePaddings[1] + nodePaddings[3],\n height: cell.view.height + nodePaddings[0] + nodePaddings[2],\n ...(fixedPosition ? { fx: cell.view.x, fy: cell.view.y } : null),\n };\n forceNodes.push(node);\n nodesMap.set(node.id, node);\n } else if (isEdgeCell(cell)) {\n forceLinks.push({ source: cell.source, target: cell.target });\n }\n }\n\n const linkSimulation = forceLink<ForceNode, ForceLink>(forceLinks).id(\n (d) => d.id\n );\n const simulation = forceSimulation<ForceNode, ForceLink>(forceNodes)\n .force(\"link\", linkSimulation)\n .force(\"x\", forceX(center?.[0]))\n .force(\"y\", forceY(center?.[1]))\n .force(\"charge\", forceManyBody());\n\n if (collide) {\n simulation.force(\n \"collide\",\n forceCollide<ForceNode>()\n .radius(\n (d) =>\n Math.sqrt(d.width ** 2 + d.height ** 2) / 2 + collide.radiusDiff\n )\n .strength(collide.strength)\n .iterations(collide.iterations)\n );\n }\n\n simulation.stop();\n manuallyTickToTheEnd(simulation);\n\n return {\n getNodeView: (id: NodeId) => nodesMap.get(id) as NodeView,\n nodePaddings,\n };\n}\n\nfunction manuallyTickToTheEnd(\n simulation: Simulation<ForceNode, ForceLink>\n): void {\n // Manually tick to the end.\n simulation.tick(\n Math.ceil(\n Math.log(simulation.alphaMin()) / Math.log(1 - simulation.alphaDecay())\n )\n );\n}\n","import React, { useEffect, useMemo, useState } from \"react\";\nimport { select } from \"d3-selection\";\nimport { zoom, type ZoomBehavior } from \"d3-zoom\";\nimport type { RangeTuple, TransformLiteral } from \"../../diagram/interfaces\";\nimport {\n DEFAULT_SCALE_RANGE_MIN,\n DEFAULT_SCALE_RANGE_MAX,\n} from \"../../draw-canvas/constants\";\nimport type { ActiveTarget } from \"../../draw-canvas/interfaces\";\n\nexport interface UseZoomOptions {\n rootRef: React.RefObject<SVGSVGElement>;\n zoomable?: boolean;\n scrollable?: boolean;\n pannable?: boolean;\n draggable?: boolean;\n ctrlDraggable?: boolean;\n scaleRange?: RangeTuple;\n onSwitchActiveTarget?(target: ActiveTarget | null): void;\n}\n\nexport interface UseZoomResult {\n grabbing: boolean;\n transform: TransformLiteral;\n scaleRange: RangeTuple;\n zoomer: ZoomBehavior<SVGSVGElement, unknown>;\n}\n\n// istanbul ignore next\nconst isMac = /mac/i.test(\n (\n navigator as Navigator & {\n userAgentData?: {\n platform: string;\n };\n }\n ).userAgentData?.platform ??\n navigator.platform ??\n navigator.userAgent\n);\n\n// istanbul ignore next\nfunction wheelData(event: WheelEvent) {\n // On Windows with normal mouse, deltaY is too big when scroll with ctrlKey pressed,\n // which cause the zooming too fast.\n // While on mac OS, we need to keep default behavior of d3-zoom.\n return (\n -event.deltaY *\n (event.deltaMode === 1 ? 0.05 : event.deltaMode ? 1 : 0.002) *\n (event.ctrlKey && isMac ? 10 : 1)\n );\n}\n\nexport function useZoom({\n rootRef,\n zoomable,\n scrollable,\n pannable,\n draggable,\n ctrlDraggable,\n scaleRange: _scaleRange,\n onSwitchActiveTarget,\n}: UseZoomOptions): UseZoomResult {\n const [grabbing, setGrabbing] = useState(false);\n const [transform, setTransform] = useState<TransformLiteral>({\n k: 1,\n x: 0,\n y: 0,\n });\n\n const scaleRange = useMemo(\n () =>\n _scaleRange ??\n ([DEFAULT_SCALE_RANGE_MIN, DEFAULT_SCALE_RANGE_MAX] as RangeTuple),\n [_scaleRange]\n );\n\n const zoomer = useMemo(\n () => zoom<SVGSVGElement, unknown>().wheelDelta(wheelData),\n []\n );\n\n // istanbul ignore next: d3-zoom currently hard to test\n useEffect(() => {\n let moved = false;\n zoomer\n .scaleExtent(zoomable ? scaleRange : [1, 1])\n .on(\"start\", () => {\n moved = false;\n setGrabbing(true);\n })\n .on(\"zoom\", (e: { transform: TransformLiteral }) => {\n moved = true;\n setTransform(e.transform);\n })\n .on(\"end\", () => {\n setGrabbing(false);\n if (!moved) {\n onSwitchActiveTarget?.(null);\n }\n })\n .filter(\n (event) =>\n // For wheel event, ignore d3 default behavior, because we control it manually.\n // Except for the trackpad pinch event on Mac OS (with ctrlKey).\n (event.type === \"wheel\"\n ? event.ctrlKey\n : ctrlDraggable\n ? draggable || event.ctrlKey\n : !event.ctrlKey) && !event.button\n );\n }, [\n onSwitchActiveTarget,\n scaleRange,\n zoomable,\n zoomer,\n ctrlDraggable,\n draggable,\n ]);\n\n useEffect(() => {\n if (ctrlDraggable) {\n const onContextMenu = (e: MouseEvent) => {\n if (e.ctrlKey) {\n e.preventDefault();\n }\n };\n document.addEventListener(\"contextmenu\", onContextMenu, true);\n return () => {\n document.removeEventListener(\"contextmenu\", onContextMenu, true);\n };\n }\n }, [ctrlDraggable]);\n\n // istanbul ignore next: d3-zoom currently hard to test\n useEffect(() => {\n const root = rootRef.current;\n if (!root) {\n return;\n }\n\n const rootSelection = select(root);\n\n const unsetZoom = () => {\n rootSelection\n .on(\".zoom\", null)\n .on(\".zoom.custom\", null)\n .on(\"wheel\", null);\n };\n\n if (!(zoomable || scrollable || pannable)) {\n unsetZoom();\n return;\n }\n\n if (zoomable || scrollable) {\n // Do not override default d3 zoom handler.\n // Only handles *panning*\n rootSelection.on(\n \"wheel.zoom.custom\",\n (e: WheelEvent & { wheelDeltaX: number; wheelDeltaY: number }) => {\n // Mac OS trackpad pinch event is emitted as a wheel.zoom and d3.event.ctrlKey set to true\n if (!e.ctrlKey && scrollable) {\n e.preventDefault();\n zoomer.translateBy(\n rootSelection,\n e.wheelDeltaX / 5,\n e.wheelDeltaY / 5\n );\n }\n // zoomer.scaleBy(rootSelection, Math.pow(2, defaultWheelDelta(e)))\n }\n );\n }\n\n rootSelection\n .call(zoomer)\n .on(\"wheel\", (e: WheelEvent) => {\n if (scrollable || (zoomable && e.ctrlKey)) {\n e.preventDefault();\n }\n })\n .on(\"dblclick.zoom\", null);\n\n if ((!draggable && !ctrlDraggable) || !pannable) {\n rootSelection.on(\"mousedown.zoom\", null);\n }\n\n if (!pannable) {\n rootSelection\n .on(\"touchstart.zoom\", null)\n .on(\"touchmove.zoom\", null)\n .on(\"touchend.zoom\", null);\n }\n\n return unsetZoom;\n }, [\n ctrlDraggable,\n draggable,\n pannable,\n rootRef,\n scrollable,\n zoomable,\n zoomer,\n ]);\n\n return { grabbing, transform, zoomer, scaleRange };\n}\n","import { get, pick } from \"lodash\";\nimport dagre from \"@dagrejs/dagre\";\nimport { extractPartialRectTuple } from \"../../diagram/processors/extractPartialRectTuple\";\nimport type {\n Cell,\n ForceNode,\n LayoutOptionsDagre,\n NodeId,\n NodeView,\n} from \"../../draw-canvas/interfaces\";\nimport {\n isEdgeCell,\n isGroupDecoratorCell,\n isNodeCell,\n isNodeOrAreaDecoratorCell,\n} from \"../../draw-canvas/processors/asserts\";\nimport type { FullRectTuple } from \"../../diagram/interfaces\";\n\nexport interface DagreLayoutOptions {\n cells: Cell[];\n layoutOptions?: LayoutOptionsDagre;\n allowEdgeToArea?: boolean;\n}\n\nexport function dagreLayout({\n cells,\n layoutOptions,\n allowEdgeToArea,\n}: DagreLayoutOptions): {\n getNodeView: (id: NodeId) => NodeView;\n nodePaddings: FullRectTuple;\n} {\n const { nodePadding, ...dagreGraphOptions } = {\n nodePadding: 0,\n rankdir: \"TB\",\n ranksep: 50,\n edgesep: 10,\n nodesep: 50,\n // align: undefined,\n ...pick(layoutOptions, [\n \"nodePadding\",\n \"rankdir\",\n \"ranksep\",\n \"edgesep\",\n \"nodesep\",\n \"align\",\n ]),\n };\n const nodePaddings = extractPartialRectTuple(nodePadding);\n\n if (!cells.some(isNodeCell)) {\n // Dagre cannot render empty nodes\n return {\n getNodeView: () => null!,\n nodePaddings,\n };\n }\n\n const graph = new dagre.graphlib.Graph<ForceNode>();\n graph.setGraph(dagreGraphOptions);\n // Default to assigning a new object as a label for each new edge.\n graph.setDefaultEdgeLabel(function () {\n return {};\n });\n for (const cell of cells) {\n if (\n (allowEdgeToArea && isNodeOrAreaDecoratorCell(cell)) ||\n isNodeCell(cell) ||\n isGroupDecoratorCell(cell)\n ) {\n graph.setNode(cell.id, {\n id: cell.id,\n width: get(cell, \"view.width\", 0) + nodePaddings[1] + nodePaddings[3],\n height: get(cell, \"view.height\", 0) + nodePaddings[0] + nodePaddings[2],\n });\n } else if (isEdgeCell(cell)) {\n graph.setEdge(cell.source, cell.target);\n }\n }\n dagre.layout(graph);\n\n return {\n getNodeView: (id: NodeId) => graph.node(id),\n nodePaddings,\n };\n}\n","import { get, orderBy } from \"lodash\";\nimport {\n ActiveTarget,\n BaseNodeCell,\n Cell,\n DecoratorCell,\n InitialCell,\n NodeCell,\n} from \"../interfaces\";\nimport { LayoutOptions } from \"./initialContainerLayout\";\nimport {\n isEdgeCell,\n isGroupDecoratorCell,\n isNodeCell,\n isNoPoint,\n isNoSize,\n} from \"./asserts\";\nimport { dagreLayout } from \"../../shared/canvas/dagreLayout\";\nimport { staggeredLayout } from \"./staggeredLayout\";\nimport { computeBoundingBox } from \"./computeBoundingBox\";\nimport { CONTAINERGAP } from \"../constants\";\nexport const GROUPPADDING = 12;\n\nexport function initialGroupLayout(\n cells: InitialCell[],\n options: LayoutOptions = {}\n) {\n const groupMap: Record<string, Omit<Cell, \"DecoratorCell\">[]> = {};\n const decoratorCells = cells.filter(\n (c) => isGroupDecoratorCell(c) && isNoPoint(c.view)\n ) as DecoratorCell[];\n\n if (!decoratorCells.length) return { groupMap };\n const { nodeLayout = \"dagre\" } = options;\n const nodeCells = cells.filter((c) => c.type === \"node\") as NodeCell[];\n const edgeCells = cells.filter(isEdgeCell);\n\n // 预处理 decoratorCells,以便后续查找更高效\n const containerCellMap = new Map<string, DecoratorCell>();\n decoratorCells.forEach((cell) => {\n containerCellMap.set(cell.id, cell);\n });\n\n const groupNameMap: Record<string, Set<string>> = {};\n\n // 分组节点并构建 groupNameMap\n nodeCells.forEach((node) => {\n const { groupId } = node;\n if (groupId) {\n if (!groupMap[groupId]) {\n groupMap[groupId] = [];\n groupNameMap[groupId] = new Set();\n }\n groupMap[groupId].push(node);\n groupNameMap[groupId].add(node.id);\n }\n });\n\n // 把边加入所属组\n edgeCells.forEach((edge) => {\n for (const [groupId, idSet] of Object.entries(groupNameMap)) {\n if (idSet.has(edge.source) && idSet.has(edge.target)) {\n groupMap[groupId].push(edge);\n break;\n }\n }\n });\n\n const containerGap = 0;\n // 排序组层级,level越大越后面;没有大小都排后面\n const sortedGroupIds = orderBy(\n decoratorCells.filter((cell) => groupMap[cell.id]),\n [(o) => (isNoSize(o.view) ? 1 : 0), (o) => get(o, \"view.level\", 1)],\n [\"asc\", \"asc\"]\n ).map((cell) => cell.id);\n processSortedGroups(\n sortedGroupIds,\n groupMap,\n containerCellMap,\n nodeLayout,\n containerGap\n );\n return { groupMap };\n}\n\nfunction processSortedGroups(\n sortedGroupIds: string[],\n containerGroup: Record<string, Omit<Cell, \"DecoratorCell\">[]>,\n containerCellMap: Map<string, DecoratorCell>,\n nodeLayout: string,\n containerGap: number\n) {\n let currentContainerGap = containerGap;\n sortedGroupIds.forEach((groupId) => {\n const groupCell = containerCellMap.get(groupId)!;\n const groupedCells = containerGroup[groupId] as Cell[];\n const nodeCells = groupedCells.filter(\n (cell) => cell.type === \"node\"\n ) as NodeCell[];\n\n currentContainerGap += +(GROUPPADDING + CONTAINERGAP * 2); //加上容器的间距,分组间距后面会在initialContainerLayout调整减掉一个GROUPPADDING\n\n let nodeViews: (NodeCell | DecoratorCell)[] = [];\n if (nodeLayout === \"dagre\") {\n const { getNodeView } = dagreLayout({ cells: nodeCells });\n nodeViews = nodeCells.map((node: NodeCell) => {\n if (isNoPoint(node.view)) {\n const view = getNodeView(node.id);\n node.view = {\n ...node.view,\n x: view.x,\n y: view.y + currentContainerGap,\n width: view.width,\n height: view.height,\n };\n }\n return node;\n });\n } else if (nodeLayout === \"staggered\") {\n nodeViews = staggeredLayout(nodeCells, {\n offsetY: currentContainerGap,\n });\n }\n\n const containerRect = computeBoundingBox(nodeViews as BaseNodeCell[], {\n padding: GROUPPADDING,\n });\n groupCell.view = { ...groupCell.view, ...containerRect };\n currentContainerGap += get(containerRect, \"height\", 0) + CONTAINERGAP;\n });\n return {\n updatedGap: currentContainerGap,\n };\n}\n\nexport function highlightGroupCell(\n cell: DecoratorCell,\n activeTarget: ActiveTarget | null | undefined,\n cells: Cell[]\n) {\n let activeTargetCells = [],\n active = false;\n // istanbul ignore next\n if (activeTarget?.type === \"multi\") {\n activeTargetCells = activeTarget.targets;\n } else if (activeTarget?.type === \"node\") {\n activeTargetCells.push(activeTarget);\n } else if (activeTarget?.type === \"decorator\") {\n active = activeTarget.id === cell.id;\n return active;\n }\n active = activeTargetCells.some(\n (item) =>\n item?.type === \"node\" &&\n (cells.find((c) => isNodeCell(c) && c.id === item.id) as NodeCell)\n ?.groupId === cell.id\n );\n return active;\n}\n","import { forEach, get, groupBy, isNil, orderBy } from \"lodash\";\nimport type {\n BaseNodeCell,\n Cell,\n DecoratorCell,\n InitialCell,\n NodeCell,\n} from \"../interfaces\";\nimport {\n isContainerDecoratorCell,\n isEdgeCell,\n isGroupDecoratorCell,\n isNoPoint,\n isNoSize,\n} from \"./asserts\";\nimport { dagreLayout } from \"../../shared/canvas/dagreLayout\";\nimport { computeBoundingBox } from \"./computeBoundingBox\";\nimport {\n CONTAINERGAP,\n DEFAULT_AREA_HEIGHT,\n DEFAULT_AREA_WIDTH,\n} from \"../constants\";\nimport { staggeredLayout } from \"./staggeredLayout\";\nimport { GROUPPADDING, initialGroupLayout } from \"./initialGroupLayout\";\nexport interface LayoutOptions {\n nodeLayout?: \"staggered\" | \"dagre\";\n}\n\n/**\n * 初始化容器内节点层次布局以及同步容器大小位置\n * @param cells\n */\nexport function initialContainerLayout(\n cells: InitialCell[],\n options: LayoutOptions = {}\n) {\n const { groupMap } = initialGroupLayout(cells, options);\n const nodeCells = cells.filter(\n (c) => c.type === \"node\" && !isNil(c.containerId)\n ) as NodeCell[];\n const groupCells = cells.filter(\n (c) =>\n c.type === \"decorator\" && c.decorator === \"group\" && !isNil(c.containerId)\n ) as DecoratorCell[];\n if (!nodeCells.length && !groupCells.length) return;\n\n const { nodeLayout = \"dagre\" } = options;\n\n const edgeCells = cells.filter(isEdgeCell);\n const containerCells = cells.filter((c) =>\n isContainerDecoratorCell(c)\n ) as DecoratorCell[];\n\n // 预处理 decoratorCells,以便后续查找更高效\n const containerCellMap = new Map<string, DecoratorCell>();\n let containerGap = 0,\n maxContainerWidth = 0;\n\n containerCells.forEach((cell) => {\n containerCellMap.set(cell.id, cell);\n });\n\n const containerGroup: Record<string, Omit<Cell, \"DecoratorCell\">[]> = {};\n const groupNameMap: Record<string, Set<string>> = {};\n\n forEach(\n groupBy([...nodeCells, ...groupCells], \"containerId\"),\n (groupedNodes, containerId) => {\n containerGroup[containerId] = groupedNodes;\n groupNameMap[containerId] = new Set(groupedNodes.map((node) => node.id));\n }\n );\n\n // 把边加入所属容器组\n edgeCells.forEach((edge) => {\n for (const [groupId, idSet] of Object.entries(groupNameMap)) {\n if (idSet.has(edge.source) && idSet.has(edge.target)) {\n containerGroup[groupId].push(edge);\n break;\n }\n }\n });\n\n const uniformWidthContainers: DecoratorCell[] = [];\n\n // 排序容器层级,level越大越后面;没有大小都排后面\n const sortedContainerIds = orderBy(\n containerCells.filter((cell) => containerGroup[cell.id]),\n [(o) => (isNoSize(o.view) ? 1 : 0), (o) => get(o, \"view.level\", 1)],\n [\"asc\", \"asc\"]\n ).map((cell) => cell.id);\n const { updatedGap, updatedMaxWidth } = processSortedContainers(\n sortedContainerIds,\n containerGroup,\n containerCellMap,\n nodeLayout,\n containerGap,\n uniformWidthContainers,\n maxContainerWidth,\n {\n groupCells,\n groupMap,\n }\n );\n\n containerGap = updatedGap;\n maxContainerWidth = updatedMaxWidth;\n\n // 统一容器宽度\n uniformWidthContainers.forEach((container) => {\n container.view.width = Math.max(DEFAULT_AREA_WIDTH, maxContainerWidth);\n });\n}\n\nfunction processSortedContainers(\n sortedContainerIds: string[],\n containerGroup: Record<string, Omit<Cell, \"DecoratorCell\">[]>,\n containerCellMap: Map<string, DecoratorCell>,\n nodeLayout: string,\n containerGap: number,\n uniformWidthContainers: DecoratorCell[],\n maxContainerWidth: number,\n decoratorGroup: {\n groupCells: DecoratorCell[];\n groupMap: Record<string, Omit<Cell, \"DecoratorCell\">[]>;\n }\n) {\n let currentContainerGap = containerGap;\n let currentMaxContainerWidth = maxContainerWidth;\n\n sortedContainerIds.forEach((groupId) => {\n const containerCell = containerCellMap.get(groupId)!;\n const groupedNodes = containerGroup[groupId] as Cell[];\n\n const isVertical = [\"top\", \"bottom\"].includes(\n get(containerCell, \"view.direction\", \"top\")\n );\n if (isVertical) currentContainerGap += CONTAINERGAP;\n const nodeCells = groupedNodes.filter(\n (cell) => cell.type === \"node\"\n ) as NodeCell[];\n const decoratorGroups = get(decoratorGroup, \"groupCells\", []).filter(\n (g) => g.containerId === groupId\n ) as DecoratorCell[];\n\n let nodeViews: (NodeCell | DecoratorCell)[] = [];\n if (nodeLayout === \"dagre\") {\n const { getNodeView } = dagreLayout({\n cells: [...groupedNodes, ...decoratorGroups],\n });\n nodeViews = [...nodeCells, ...decoratorGroups].map((cell) => {\n if (isNoPoint(cell.view) || isGroupDecoratorCell(cell)) {\n const view = getNodeView(cell.id);\n cell.view = {\n ...cell.view,\n x: view.x,\n y: view.y + currentContainerGap,\n width: view.width,\n height: view.height,\n };\n }\n return cell;\n });\n } else if (nodeLayout === \"staggered\") {\n nodeViews = staggeredLayout([...nodeCells, ...decoratorGroups], {\n offsetY: currentContainerGap,\n });\n }\n let containerHeight = 0,\n containerWidth = 0;\n if (isNoSize(containerCell.view)) {\n const containerRect = computeBoundingBox(nodeViews as BaseNodeCell[]);\n containerHeight = get(containerRect, \"height\", DEFAULT_AREA_HEIGHT);\n containerWidth = get(containerRect, \"width\", DEFAULT_AREA_WIDTH);\n containerCell.view = { ...containerCell.view, ...containerRect };\n uniformWidthContainers.push(containerCell);\n } else {\n containerHeight = get(containerCell, \"view.height\");\n containerWidth = get(containerCell, \"view.width\");\n }\n\n /**\n * 计算好容器位置在重新设置组内节点x,y\n */\n if (decoratorGroups.length > 0) {\n const groupMap = get(decoratorGroup, \"groupMap\", {});\n decoratorGroups.forEach((group) => {\n const groupId = group.id;\n const { x: groupX, y: groupY } = group.view;\n const nodeCells: NodeCell[] = get(groupMap, groupId, []);\n\n if (!nodeCells.length) return;\n\n // 记录第一个节点的基准坐标\n const baseX = nodeCells[0].view.x;\n const baseY = nodeCells[0].view.y;\n\n nodeCells.forEach((node: NodeCell) => {\n node.view = {\n ...node.view,\n x: groupX + (node.view?.x - baseX),\n y: groupY + (node.view?.y - baseY),\n };\n });\n\n group.view = {\n ...group.view,\n x: groupX - GROUPPADDING,\n y: groupY - GROUPPADDING,\n };\n });\n }\n\n currentMaxContainerWidth = Math.max(\n containerWidth,\n currentMaxContainerWidth\n );\n currentContainerGap += containerHeight + CONTAINERGAP;\n });\n\n return {\n updatedGap: currentContainerGap,\n updatedMaxWidth: currentMaxContainerWidth,\n };\n}\n","import type { NodePosition } from \"../../../diagram/interfaces\";\nimport type { NodeConnectPoint } from \"../../../draw-canvas/interfaces\";\n\n// *--*--*--*--*\n// | |\n// * *\n// | |\n// * Rect *\n// | |\n// * *\n// | |\n// *--*--*--*--*\nconst RectangleRelativeConnectPointsWithDirection: ReadonlyArray<NodeConnectPoint> =\n [\n {\n x: 0,\n y: 0,\n d: [\"top\", \"left\"],\n },\n { x: 0.5, y: 0, d: [\"top\"] },\n {\n x: 1,\n y: 0,\n d: [\"top\", \"right\"],\n },\n { x: 0, y: 0.5, d: [\"left\"] },\n { x: 1, y: 0.5, d: [\"right\"] },\n {\n x: 0,\n y: 1,\n d: [\"bottom\", \"left\"],\n },\n { x: 0.5, y: 1, d: [\"bottom\"] },\n {\n x: 1,\n y: 1,\n d: [\"bottom\", \"right\"],\n },\n ];\n\nconst RectangleRelativeConnectPoints: ReadonlyArray<NodePosition> =\n RectangleRelativeConnectPointsWithDirection.map((p) => ({ x: p.x, y: p.y }));\n\nexport function getConnectPointsOfRectangleWithDirection() {\n return RectangleRelativeConnectPointsWithDirection;\n}\n\nexport function getConnectPointsOfRectangle() {\n return RectangleRelativeConnectPoints;\n}\n","import type {\n FullRectTuple,\n TransformLiteral,\n} from \"../../../diagram/interfaces\";\nimport type { CellsRect } from \"../../../draw-canvas/interfaces\";\n\nexport interface TransformToCenterOptions {\n canvasWidth: number;\n canvasHeight: number;\n canvasPadding?: FullRectTuple | null;\n scaleRange?: [min: number, max: number];\n}\n\nexport function getTransformToCenter(\n rect: CellsRect,\n {\n canvasWidth,\n canvasHeight,\n canvasPadding,\n scaleRange,\n }: TransformToCenterOptions\n): TransformLiteral {\n const { left, top, width, height, empty } = rect;\n\n // Apply padding to available canvas dimensions\n const [paddingTop, paddingRight, paddingBottom, paddingLeft] =\n canvasPadding ?? [0, 0, 0, 0];\n const availableWidth = canvasWidth - paddingLeft - paddingRight;\n const availableHeight = canvasHeight - paddingTop - paddingBottom;\n\n const scale =\n scaleRange && !empty && (width > availableWidth || height > availableHeight)\n ? Math.max(\n Math.min(\n availableWidth / width,\n availableHeight / height,\n scaleRange[1]\n ),\n scaleRange[0]\n )\n : 1;\n\n // Adjust center calculation to account for padding\n const x = empty\n ? 0\n : (availableWidth - width * scale) / 2 + paddingLeft - left * scale;\n const y = empty\n ? 0\n : (availableHeight - height * scale) / 2 + paddingTop - top * scale;\n\n return { x, y, k: scale };\n}\n"],"names":["nodeViewToNodeRect","view","padding","x","width","y","height","DEFAULT_DIRECTIONS","getSmartLinePoints","sourceView","targetView","lineView","parallelGap","cellType","_connectPoints$find$d","_connectPoints$find","_connectPoints$find$d2","_connectPoints$find2","_sourceDirections$","_targetDirections$","type","vertices","exitPosition","originalExit","entryPosition","originalEntry","isStraightType","getDirectLinePoints","DEFAULT_NODE_PADDING_FOR_SMART_LINES","DEFAULT_NODE_PADDING_FOR_LINES","length","firstVertex","lastVertex","exitPoint","entryPoint","exitDirection","entryDirection","getAbsolutePosition","possibleFirstNextPoint","getDefaultAbsolutePosition","prefer","point","direction","fitEndpointAndDirection","possibleLastPreviousPoint","slice","reverse","sourceX","sourceY","targetX","targetY","newLinePoints","newVertices","unshift","push","simplifyVertices","getDefaultPosition","connectPoints","getConnectPointsOfRectangleWithDirection","originalSourceDirections","find","p","d","originalTargetDirections","sourceDirections","targetDirections","pull","sourceDirection","targetDirection","sourcePosition","targetPosition","getPolyLinePoints","simplifiedVertices","prevDirection","prev","index","vertex","isHorizontal","isVertical","next","isHorizontalNext","isVerticalNext","position","halfPadding","flip","xAxis","yAxis","xSize","ySize","xPosition","oppositeView","nsDirection","ewDirection","_vertices$","nextVertex","getUnrelatedCells","cells","connectLineState","activeTarget","allowEdgeToArea","unrelated","existedTargets","Set","cell","source","id","add","target","has","decorator","nodesMap","Map","activeNodeIds","relatedNodeIds","active","targets","set","targetIsActive","useActiveTarget","_ref","rootRef","_activeTarget","doNotResetActiveTargetForSelector","doNotResetActiveTargetOutsideCanvas","onActiveTargetChange","newActiveTarget","setActiveTarget","useState","useEffect","previous","sameTarget","activeTargetChangeInitialized","useRef","current","resetActiveTarget","e","path","composedPath","rootIndex","indexOf","some","el","Element","matches","document","addEventListener","removeEventListener","a","b","every","targetA","targetB","DEFAULT_CELL_ORDERS","decorators","insertCell","newCell","insertCells","newCells","findIndex","order","matchCellOrder","console","warn","targetIndex","findLastIndex","includes","rootReducer","reducers","state","action","payload","existedEdgeIndex","existedDecoratorIndex","matched","newState","map","move","pick","node","isNodeCell","SYMBOL_FOR_SIZE_INITIALIZED","size","layoutKey","Object","fromEntries","entries","key","value","LineLabelComponent","edge","offset","label","text","onRendered","onClick","ready","React","className","classNames","LineLabelUseBrickComponent","LineLabelTextComponent","_ref2","refCallback","useCallback","element","ref","style","content","_ref3","useBrick","useMemo","checkIfOfComputed","memoizedData","setTimeout","parentElement","ignoredCallback","ReactUseBrick","data","EdgeComponent","_editableLineMap$get","_motion","_motion2","_lineConf$overrides3","_lineConf$overrides4","_lineConf$animate$dur","_lineConf$overrides5","lineConfMap","editableLineMap","readOnly","activeRelated","onSwitchActiveTarget","pathRef","lineConf","get","points","linePoints","jumpsMap","line","curveLine","curveType","lineClipPathPrefix","uniqueId","labelPosition","setLabelPosition","labelSize","setLabelSize","lineRect","setLineRect","updateLabelPosition","placement","pathLength","getTotalLength","halfPathLength","pathPoint","getPointAtLength","angle","p0","p1","Math","atan2","abs","rect","getBBox","setPathLength","pathRefCallback","_element$getTotalLeng","_element$getTotalLeng2","_element$getBBox","call","labelElement","setLabelElement","resizeObserver","ResizeObserver","observerCallback","offsetWidth","offsetHeight","observe","disconnect","handleLabelRendered","onLabelClick","cellToTarget","onDoubleClick","_labelElement$firstEl","_labelElement$firstEl2","callLabelOnDoubleClick","preventDefault","stopPropagation","firstElementChild","mask","labelOffset","left","top","offsetX","offsetY","halfWidth","halfHeight","cos","tan","sin","getLabelMaskAndOffset","clipPathPoints","right","bottom","maskRight","maskBottom","join","markerStart","markerEnd","strokeColor","strokeWidth","motion","lineMarkers","getMarkers","_lineConf$overrides","_overrides$strokeColo","_overrides$strokeWidt","overrides","marker","_lineConf$$activeMark","_lineConf$$activeMark2","$activeMarkerStartUrl","$markerStartUrl","$activeMarkerEndUrl","$markerEndUrl","_lineConf$overrides2","_overrides$strokeColo2","_overrides$strokeWidt2","_lineConf$$activeRela","_lineConf$$activeRela2","$activeRelatedMarkerStartUrl","$activeRelatedMarkerEndUrl","motionPath","motionDuration","shape","radius","sqrt","_motion$speed","_motion3","speed","DEFAULT_MOTION_SPEED","hasMotion","item","clipPathUrl","undefined","fill","stroke","interactStrokeWidth","clipPath","dashed","dotted","animate","useAnimate","duration","DEFAULT_LINE_INTERACT_ANIMATE_DURATION","visible","dur","repeatCount","rotate","LockIcon","transform","NodeComponent","_useMemo","degraded","degradedNodeLabel","defaultNodeBricks","locked","containerLocked","groupLocked","onResize","memoizedValue","setMemoizedValue","isEqual","useDeepMemo","specifiedUseBrick","specifiedComponent","component","observerRef","Component","checkIfByTransform","String","__secret_internals","legacyDoTransform","brickRef","xRef","yRef","prevObserver","observer","degradedRefCallBack","g","foreignObjectRef","fo","test","navigator","userAgent","overflow","timeoutId","clearTimeout","_extends","cx","cy","r","Boolean","DEFAULT_ALL_POSITIONS","getSnapPositions","positions","snapPositions","_positions$split$flat","_positions$split","split","flatMap","pos","tuple","Error","HORIZONTAL_POSITIONS","VERTICAL_POSITIONS","handleMouseDown","event","_snap$object","scale","layout","layoutOptions","onCellsMoving","onCellsMoved","onCellResizing","onCellResized","updateCurActiveEditableLine","button","ctrlKey","preActive","lockedContainerIds","getLockedContainerIds","canUpdateActiveEditableLine","shiftKey","activeTargets","filter","isLocked","isEdgeCell","isLineDecoratorCell","activeCells","actives","c","forEach","isContainerDecoratorCell","groupIds","isGroupDecoratorCell","containerId","nodeCells","groupId","isAutoLayout","movableActiveCells","isDecoratorCell","snap","_snapToGrid$size","_snapToObject$distanc","_snapToObject$positio","intermediateSnap","grid","object","snapToGrid","snapToObject","DEFAULT_SNAP_GRID_SIZE","distance","DEFAULT_SNAP_OBJECT_DISTANCE","DEFAULT_SNAP_OBJECT_POSITIONS","normalizeSnapOptions","snapToObjectPositions","from","clientX","clientY","originals","firstOriginalPosition","snapToObjectTargets","objectCells","moved","handleMove","finished","movement","getMovement","snapMovement","newPositions","xAlign","yAlign","xAlignCell","yAlignCell","altKey","diffX","Infinity","diffY","snapToObjectDistance","xAlignFrom","yAlignFrom","xAlignTarget","yAlignTarget","xAlignToY","yAlignToX","targetPositions","originalPositions","originalPoint","horizontal","vertical","dX","dY","snapToGridSize","firstNewPosition","round","snapToGridMovement","snapToGridDiffX","snapToGridDiffY","_ref5","payloads","_ref4","_c$view$vertices","guideLines","v","_ref6","onMouseMove","onMouseUp","_supports","getContentEditable","editable","div","createElement","setAttribute","contentEditable","supportsContentEditablePlaintextOnly","selectAllText","range","createRange","selectNodeContents","selection","window","getSelection","removeAllRanges","addRange","decoratorComponents","_cell$view","onDecoratorGroupPlusClick","highlightGroupCell","usePlus","PlusOutlined","onDecoratorTextEditing","onDecoratorTextChange","textRef","resizeHandleRef","editingLabel","setEditingLabel","currentLabel","setCurrentLabel","shouldEmitLabelChange","setShouldEmitLabelChange","recomputation","setRecomputation","titleForeignRect","setTitleForeignRect","shouldHighlight","activeTargetCells","containerLeft","containerRight","containerTop","containerBottom","targetCell","handleEnableEdit","handleInput","textContent","handleBlur","uuidV4","_textRef$current","clientWidth","clientHeight","focus","editing","resizeHandle","onMouseDown","k","titleStyle","onInput","onBlur","isNoManualLayout","_cell$view$text","editingLabelInitialized","_ref$current","lockedPosition","lastPoint","firstPoint","dy","dx","useEndPoint","point1","point2","twistedAngle","PI","getLineLockIconPosition","DecoratorComponent","SpecifiedComponent","error","CellComponent","_cell$view2","dragoverContainer","hoverCell","unrelatedCells","curActiveEditableLine","onCellContextMenu","onCellClick","onNodeBrickResize","onCellMouseEnter","onCellMouseLeave","lineEditorState","smartConnectLineState","setSmartConnectLineState","onConnect","setLineEditorState","onChangeEdgeView","useHoverStateContext","gRef","containerRect","containCells","computeBoundingBox","nodeViews","GROUPPADDING","isEdgeSide","isEntry","handleContextMenu","handleCellClick","handleMouseEnter","handleMouseLeave","faded","onContextMenu","onMouseEnter","onMouseLeave","SmartConnectLineComponent","lineSettings","options","connectLineTo","setConnectLineTo","hoverState","reset","activePointIndex","relativePoints","x1","y1","getConnectLinePoints","connecting","handleKeyboard","lockedIds","keyCode","which","useLineMarkers","defaultEdgeLines","markerPrefix","lineConnector","useMemoizedResult","memoizedResult","markers","DEFAULT_LINE_STROKE_COLOR","markerType","lineConnectorConf","getDefaultLineConf","editingStrokeColor","omitBy","isUndefined","_type","markerIndex","addMarker","editingMarkerIndex","$editingStartMarkerUrl","$editingEndMarkerUrl","WeakMap","isEdge","isLineDecorator","_secret_internals$le","computedLineConf","Array","isArray","transformLineConf","showEndArrow","DEFAULT_DECORATOR_LINE_STROKE_COLOR","activeStrokeColor","activeMarkerIndex","activeRelatedStrokeColor","activeRelatedMarkerIndex","_lineConf$label","restLabel","restConf","computedRestConf","showStartArrow","DEFAULT_LINE_STROKE_WIDTH","DEFAULT_LINE_INTERACT_STROKE_WIDTH","DEFAULT_LINE_INTERACT_SHOW_START_ARROW","DEFAULT_LINE_INTERACT_SHOW_END_ARROW","jumps","getNewLineVertices","activeEditableLine","control","i","LOOSE_CONTROL_TYPES","EditingLineComponent","onChangeDecoratorView","movedRef","getConnectTo","diff","otherPoints","axises","getFinalPosition","movementX","movementY","_","endpoint","editableLine","axis","newDiff","newConnectTo","_view$vertices","splice","handleBodyClick","body","isEditableEdgeLine","getEditingLinePoints","initializeCells","initialCells","defaultNodeSize","isInitialize","originalCells","initialContainerLayout","nodeLayout","isInitialNodeCell","KeywordMap","normalizeAlignAxis","newX","match","Number","useLayout","autoSize","zoomable","zoomer","scaleRange","autoCenterWhenCellsChange","dispatch","layoutInitialized","setLayoutInitialized","layoutKeyRef","getNextLayoutKey","centered","setCentered","root","getCellsRect","fitWidth","fitHeight","fullPadding","extractPartialRectTuple","DEFAULT_CANVAS_PADDING","_autoSize$minWidth","_autoSize$maxWidth","_autoSize$minHeight","_autoSize$maxHeight","min","max","minWidth","maxWidth","minHeight","maxHeight","getTransformToCenter","canvasWidth","canvasHeight","canvasPadding","select","ZoomTransform","useAutoCenter","previousLayoutRef","isNodeOrEdgeCell","getNodeView","nodePaddings","forceLayout","dagreLayout","alignOrigin","origin","normalizeAlignOrigin","isNodeOrAreaDecoratorCell","nodeView","SYMBOL_FOR_LAYOUT_INITIALIZED","toggleLock","previousLocked","previousUnlocked","updates","update","useReady","lockeds","_cell$view3","___CSS_LOADER_EXPORT___","module","toString","HELPER_IMAGE","HELPER_RADIUS","HELPER_BG_RADIUS","HALF_HELPER_RADIUS","LineConnectorComponent","disabled","unsetHoverStateTimeoutRef","setHoverState","unsetTimeout","unsetActivePointIndex","unsetHoverState","available","hasActiveEdge","pointerEvents","fillOpacity","ConnectPointComponent","getBoundingClientRect","handleMouseUp","xlinkHref","preserveAspectRatio","Symbol","for","DEFAULT_NODE_SIZE","DEFAULT_NODE_GAP_H","DEFAULT_NODE_GAP_V","DEFAULT_AREA_WIDTH","DEFAULT_AREA_HEIGHT","DEFAULT_SCALE_RANGE_MIN","DEFAULT_SCALE_RANGE_MAX","DEFAULT_DEGRADED_THRESHOLD","CONTAINERGAP","MAXPERROW","rects","empty","mergeRects","handleNodeContainedChange","onContainerContainerChange","nodeAndGroupCells","containerIds","cellPayloads","includeNodeFlag","containerDecoratorCells","containerCell","containedChanges","_payload$containerCel","HoverStateContext","activeEditableLines","isNoSize","isNoPoint","isNil","findNodeOrAreaDecorator","LINE_JUMP_BASE_SIZE","lineJumpIntersect","p2","p3","p4","intersect","r2","useEditableLineMap","collectLineJumps","allJumps","allLineSegments","lineJumps","lineSegments","start","end","jumpPoints","jumpLoop","jump","pow","segJumps","sortBy","j","collectLineJumpsFactory","sourceNode","targetNode","_c$view","POINT_HELPER_IMAGE","END_POINT_HELPER_IMAGE","ANCHORED_POINT_HELPER_IMAGE","VERTEX_HELPER_IMAGE","POINT_HELPER_BG_SIZE","LineEditorComponent","movingCells","exitRef","entryRef","controlPointsRef","exit","entry","handleMouseDownFactory","handleStartMouseDown","handleEndMouseDown","controlPoints","_activeEditableLine$v","cursor","getStraightControlPoints","ns","ew","getControlPoints","controlElements","handlers","commonProps","opacity","staggeredLayout","nodes","arguments","gapX","gapY","maxPerRow","fullRowCount","shortRowCount","layoutedNodes","row","preRowOffsetY","isOddRow","nodesInRow","nodeX","maxNodeHeight","nodeWidth","nodeHeight","minX","minY","maxX","maxY","n","isFinite","computeNodePoints","containerView","existingPoints","gap","stepX","stepY","cols","floor","col","isOverlapping","w1","h1","x2","y2","w2","h2","cx1","cy1","cx2","cy2","minDistX","minDistY","updateCells","previousCells","reason","parent","parentNode","isManualLayout","updateCandidates","shouldReCenter","prevSizeNodes","prevShouldCentered","prevNode","assign","handled","parentNodeCell","adjacency","queue","parentId","shift","baseX","baseY","ceil","cid","layoutRelatedNodes","positioned","hasDecorators","transformToCenter","without","fixedPosition","center","containerAndGroupCells","newContainerChildCells","newGroupChildCells","groupMap","groupBy","groupedNodes","group","newNodes","groupView","_node$view","_node$view2","newPoint","containerGroup","container","_node$view3","_node$view4","generateNewPointsWithLayout","updated","ConnectLineComponent","capture","props","xmlns","viewBox","ZoomBarComponent","shadowRoot","onZoomChange","onReCenter","currentTheme","useCurrentTheme","cache","createCache","zoomBarRef","tooltip","formatter","getPopupContainer","onZoomIn","onZoomOut","ConfigProvider","theme","algorithm","darkAlgorithm","defaultAlgorithm","StyleProvider","autoClear","hashPriority","role","CenterSVG","ZoomInSVG","Slider","step","included","onChange","ZoomOutSVG","handleLasso","onLassoing","onLassoed","x0","y0","nodePadding","collide","radiusDiff","strength","iterations","forceNodes","forceLinks","fx","fy","linkSimulation","forceLink","simulation","forceSimulation","force","forceX","forceY","forceManyBody","forceCollide","stop","tick","log","alphaMin","alphaDecay","manuallyTickToTheEnd","isMac","_userAgentData$platfo","_userAgentData","userAgentData","platform","wheelData","deltaY","deltaMode","useZoom","scrollable","pannable","draggable","ctrlDraggable","_scaleRange","grabbing","setGrabbing","setTransform","zoom","wheelDelta","scaleExtent","on","rootSelection","unsetZoom","translateBy","wheelDeltaX","wheelDeltaY","dagreGraphOptions","rankdir","ranksep","edgesep","nodesep","graph","dagre","Graph","setGraph","setDefaultEdgeLabel","setNode","setEdge","initialGroupLayout","decoratorCells","edgeCells","containerCellMap","groupNameMap","idSet","sortedGroupIds","currentContainerGap","groupCell","processSortedGroups","orderBy","o","_cells$find","groupCells","containerCells","containerGap","maxContainerWidth","uniformWidthContainers","sortedContainerIds","updatedGap","updatedMaxWidth","decoratorGroup","currentMaxContainerWidth","decoratorGroups","containerHeight","containerWidth","groupX","groupY","processSortedContainers","RectangleRelativeConnectPointsWithDirection","RectangleRelativeConnectPoints","getConnectPointsOfRectangle","paddingTop","paddingRight","paddingBottom","paddingLeft","availableWidth","availableHeight"],"sourceRoot":""}