dishui 0.0.47 → 0.0.49
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.
- package/dist/components/pro/CodeEditor/editors/MarkdownEditor.js +1 -2
- package/dist/components/pro/CodeEditor/editors/MarkdownEditor.js.map +1 -1
- package/dist/components/pro/CodeEditor/themes.js +0 -25
- package/dist/components/pro/CodeEditor/themes.js.map +1 -1
- package/dist/components/pro/CodeEditor/types.d.ts +1 -1
- package/dist/components/pro/Flow/Flow.js +500 -483
- package/dist/components/pro/Flow/Flow.js.map +1 -1
- package/dist/components/pro/Flow/FlowCanvas.js +526 -524
- package/dist/components/pro/Flow/FlowCanvas.js.map +1 -1
- package/dist/components/pro/Flow/canvas/GridRenderer.d.ts +3 -0
- package/dist/components/pro/Flow/canvas/GridRenderer.js +28 -23
- package/dist/components/pro/Flow/canvas/GridRenderer.js.map +1 -1
- package/dist/components/pro/Flow/canvas/MiniMapRenderer.js +18 -17
- package/dist/components/pro/Flow/canvas/MiniMapRenderer.js.map +1 -1
- package/dist/components/pro/Flow/canvas/PixiApp.d.ts +2 -0
- package/dist/components/pro/Flow/canvas/PixiApp.js +14 -11
- package/dist/components/pro/Flow/canvas/PixiApp.js.map +1 -1
- package/dist/components/pro/Flow/constants.js +7 -7
- package/dist/components/pro/Flow/constants.js.map +1 -1
- package/dist/components/pro/Flow/context/FlowAIContext.d.ts +15 -0
- package/dist/components/pro/Flow/context/FlowAIContext.js +32 -0
- package/dist/components/pro/Flow/context/FlowAIContext.js.map +1 -0
- package/dist/components/pro/Flow/context/FlowUIContext.d.ts +4 -1
- package/dist/components/pro/Flow/context/FlowUIContext.js +58 -55
- package/dist/components/pro/Flow/context/FlowUIContext.js.map +1 -1
- package/dist/components/pro/Flow/edges/EdgeRenderer.js +22 -21
- package/dist/components/pro/Flow/edges/EdgeRenderer.js.map +1 -1
- package/dist/components/pro/Flow/hooks/useFlowImportExport.js +32 -32
- package/dist/components/pro/Flow/hooks/useFlowImportExport.js.map +1 -1
- package/dist/components/pro/Flow/hooks/usePixiApp.d.ts +6 -1
- package/dist/components/pro/Flow/hooks/usePixiApp.js +49 -30
- package/dist/components/pro/Flow/hooks/usePixiApp.js.map +1 -1
- package/dist/components/pro/Flow/index.d.ts +2 -0
- package/dist/components/pro/Flow/lines/FreehandTool.js +21 -20
- package/dist/components/pro/Flow/lines/FreehandTool.js.map +1 -1
- package/dist/components/pro/Flow/lines/GeometricLineTool.js +22 -18
- package/dist/components/pro/Flow/lines/GeometricLineTool.js.map +1 -1
- package/dist/components/pro/Flow/lines/LineRenderer.js +19 -18
- package/dist/components/pro/Flow/lines/LineRenderer.js.map +1 -1
- package/dist/components/pro/Flow/nodes/MediaContent.js +143 -124
- package/dist/components/pro/Flow/nodes/MediaContent.js.map +1 -1
- package/dist/components/pro/Flow/nodes/MediaOverlay.js +22 -17
- package/dist/components/pro/Flow/nodes/MediaOverlay.js.map +1 -1
- package/dist/components/pro/Flow/nodes/NodeRenderer.js +77 -76
- package/dist/components/pro/Flow/nodes/NodeRenderer.js.map +1 -1
- package/dist/components/pro/Flow/nodes/aiClient.d.ts +22 -0
- package/dist/components/pro/Flow/nodes/aiClient.js +107 -54
- package/dist/components/pro/Flow/nodes/aiClient.js.map +1 -1
- package/dist/components/pro/Flow/nodes/svgIcons.js +6 -6
- package/dist/components/pro/Flow/nodes/svgIcons.js.map +1 -1
- package/dist/components/pro/Flow/panels/AIPanel.d.ts +2 -0
- package/dist/components/pro/Flow/panels/AIPanel.js +498 -0
- package/dist/components/pro/Flow/panels/AIPanel.js.map +1 -0
- package/dist/components/pro/Flow/panels/FlowPanelGroup.js +51 -39
- package/dist/components/pro/Flow/panels/FlowPanelGroup.js.map +1 -1
- package/dist/components/pro/Flow/panels/FlowToolbar.js +91 -85
- package/dist/components/pro/Flow/panels/FlowToolbar.js.map +1 -1
- package/dist/components/pro/Flow/panels/InspectorPanel.js +372 -332
- package/dist/components/pro/Flow/panels/InspectorPanel.js.map +1 -1
- package/dist/components/pro/Flow/panels/OutlinePanel.js +28 -27
- package/dist/components/pro/Flow/panels/OutlinePanel.js.map +1 -1
- package/dist/components/pro/Flow/panels/ShapePalette.js +107 -104
- package/dist/components/pro/Flow/panels/ShapePalette.js.map +1 -1
- package/dist/components/pro/Flow/panels/toolbarIcons.d.ts +1 -0
- package/dist/components/pro/Flow/panels/toolbarIcons.js +25 -20
- package/dist/components/pro/Flow/panels/toolbarIcons.js.map +1 -1
- package/dist/components/pro/Flow/types.d.ts +13 -0
- package/dist/components/pro/Flow/types.js.map +1 -1
- package/dist/components/pro/Flow/utils/themeColor.d.ts +87 -0
- package/dist/components/pro/Flow/utils/themeColor.js +212 -0
- package/dist/components/pro/Flow/utils/themeColor.js.map +1 -0
- package/dist/contexts/AppContext.d.ts +1 -1
- package/dist/contexts/AppContext.js +28 -29
- package/dist/contexts/AppContext.js.map +1 -1
- package/dist/dishui.css +1 -1
- package/dist/favicon.svg +10 -0
- package/dist/flow.js +56 -51
- package/dist/styles/themeStyles.js +6 -11
- package/dist/styles/themeStyles.js.map +1 -1
- package/dist/utils/themes.js +3 -23
- package/dist/utils/themes.js.map +1 -1
- package/package.json +17 -18
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlowCanvas.js","names":[],"sources":["../../../../src/components/pro/Flow/FlowCanvas.tsx"],"sourcesContent":["import React, { useRef, useEffect, useCallback, useState } from 'react';\nimport { FederatedPointerEvent, Graphics } from 'pixi.js';\nimport { usePixiApp } from './hooks/usePixiApp';\nimport { useViewport } from './hooks/useViewport';\nimport { useFlowContext } from './context/FlowContext';\nimport { useFlowUI, type FocusOnRectOptions } from './context/FlowUIContext';\nimport { GridRenderer } from './canvas/GridRenderer';\nimport { SelectionOverlay } from './canvas/SelectionOverlay';\nimport { NodeRenderer } from './nodes/NodeRenderer';\nimport { EdgeRenderer } from './edges/EdgeRenderer';\nimport { LineRenderer } from './lines/LineRenderer';\nimport { FreehandTool } from './lines/FreehandTool';\nimport { GeometricLineTool } from './lines/GeometricLineTool';\nimport { isPointInNode, rectsOverlap, distToSegment, generateId } from './nodes/nodeUtils';\nimport { shapeDrawers } from './nodes/shapes';\nimport { findClosestHandle, findClosestHandleWorld, handleWorldPos, getHandlePositions } from './nodes/NodeHandles';\nimport { buildEdgePath, resolveEdgeEndpoints, linearizeSegments } from './edges/edgePaths';\nimport { computeAlignmentSnap, type AlignGuide } from './hooks/useAlignmentGuides';\nimport { AlignmentGuidesRenderer } from './canvas/AlignmentGuides';\nimport { getDocumentSlides, nextAnimIndex } from './nodes/animAnchors';\nimport type { PixiApp } from './canvas/PixiApp';\nimport type { ViewportState, FlowNode, FlowEdge, FlowLine, FlowBezierControl } from './types';\n\nexport interface FlowCanvasProps {\n onPixiReady?: (pixi: PixiApp) => void;\n}\n\ntype ResizeHandle = 'nw' | 'ne' | 'se' | 'sw';\n\nconst RESIZE_CURSORS: Record<ResizeHandle, string> = {\n nw: 'nwse-resize', ne: 'nesw-resize',\n se: 'nwse-resize', sw: 'nesw-resize',\n};\n\nfunction getResizeHandleAt(\n pt: { x: number; y: number }, node: FlowNode, threshold: number,\n): ResizeHandle | null {\n const { x, y } = node.position;\n const w = node.width, h = node.height;\n const defs: Array<[ResizeHandle, number, number]> = [\n ['nw', x, y], ['ne', x + w, y],\n ['se', x + w, y + h], ['sw', x, y + h],\n ];\n let best: ResizeHandle | null = null, bestD = threshold;\n for (const [pos, hx, hy] of defs) {\n const d = Math.hypot(pt.x - hx, pt.y - hy);\n if (d < bestD) { bestD = d; best = pos; }\n }\n return best;\n}\n\ninterface EdgeEndpointHit {\n edgeId: string;\n end: 'source' | 'target';\n worldX: number;\n worldY: number;\n}\n\nfunction findEdgeEndpointNear(\n wx: number, wy: number,\n edges: FlowEdge[],\n nodeMap: Map<string, FlowNode>,\n threshold: number,\n): EdgeEndpointHit | null {\n let best: EdgeEndpointHit | null = null;\n let bestD = threshold;\n for (const edge of edges) {\n const ep = resolveEdgeEndpoints(edge, nodeMap);\n if (!ep) continue;\n const dSrc = Math.hypot(wx - ep.sx, wy - ep.sy);\n if (dSrc < bestD) { bestD = dSrc; best = { edgeId: edge.id, end: 'source', worldX: ep.sx, worldY: ep.sy }; }\n const dTgt = Math.hypot(wx - ep.tx, wy - ep.ty);\n if (dTgt < bestD) { bestD = dTgt; best = { edgeId: edge.id, end: 'target', worldX: ep.tx, worldY: ep.ty }; }\n }\n return best;\n}\n\ninterface WaypointHit {\n edgeId: string;\n waypointIndex: number;\n wx: number;\n wy: number;\n}\n\ninterface BezierControlHit {\n edgeId: string;\n segmentIndex: number;\n controlEnd: 'c1' | 'c2';\n wx: number;\n wy: number;\n}\n\nfunction findWaypointNear(\n wx: number, wy: number,\n edges: FlowEdge[],\n threshold: number,\n): WaypointHit | null {\n let best: WaypointHit | null = null;\n let bestD = threshold;\n for (const edge of edges) {\n const wps = edge.data.waypoints;\n if (!wps) continue;\n for (let i = 0; i < wps.length; i++) {\n const d = Math.hypot(wx - wps[i].x, wy - wps[i].y);\n if (d < bestD) {\n bestD = d;\n best = { edgeId: edge.id, waypointIndex: i, wx: wps[i].x, wy: wps[i].y };\n }\n }\n }\n return best;\n}\n\nfunction findBezierControlNear(\n wx: number, wy: number,\n edges: FlowEdge[],\n nodeMap: Map<string, FlowNode>,\n threshold: number,\n): BezierControlHit | null {\n let best: BezierControlHit | null = null;\n let bestD = threshold;\n for (const edge of edges) {\n if (edge.type !== 'simplebezier') continue;\n const ep = resolveEdgeEndpoints(edge, nodeMap);\n if (!ep) continue;\n const wps = edge.data.waypoints ?? [];\n const allPts = [{ x: ep.sx, y: ep.sy }, ...wps, { x: ep.tx, y: ep.ty }];\n const ctrls = edge.data.bezierControls;\n const lastIdx = allPts.length - 2;\n for (let i = 0; i <= lastIdx; i++) {\n const a = allPts[i], b = allPts[i + 1];\n const ctrl = ctrls?.[i];\n const segDist = Math.hypot(b.x - a.x, b.y - a.y);\n const arm = Math.max(30, segDist * 0.3);\n const c1x = ctrl?.c1x ?? (i === 0 ? a.x + ep.snx * arm : a.x + (b.x - a.x) * 0.4);\n const c1y = ctrl?.c1y ?? (i === 0 ? a.y + ep.sny * arm : a.y);\n const c2x = ctrl?.c2x ?? (i === lastIdx ? b.x + ep.tnx * arm : b.x - (b.x - a.x) * 0.4);\n const c2y = ctrl?.c2y ?? (i === lastIdx ? b.y + ep.tny * arm : b.y);\n const d1 = Math.hypot(wx - c1x, wy - c1y);\n if (d1 < bestD) { bestD = d1; best = { edgeId: edge.id, segmentIndex: i, controlEnd: 'c1', wx: c1x, wy: c1y }; }\n const d2 = Math.hypot(wx - c2x, wy - c2y);\n if (d2 < bestD) { bestD = d2; best = { edgeId: edge.id, segmentIndex: i, controlEnd: 'c2', wx: c2x, wy: c2y }; }\n }\n }\n return best;\n}\n\nfunction findInsertionIndex(\n wx: number, wy: number,\n edge: FlowEdge,\n nodeMap: Map<string, FlowNode>,\n): number {\n const ep = resolveEdgeEndpoints(edge, nodeMap);\n if (!ep) return 0;\n const wps = edge.data.waypoints ?? [];\n const allPts = [{ x: ep.sx, y: ep.sy }, ...wps, { x: ep.tx, y: ep.ty }];\n let bestD = Infinity, bestI = 0;\n for (let i = 0; i < allPts.length - 1; i++) {\n const d = distToSegment(wx, wy, allPts[i].x, allPts[i].y, allPts[i + 1].x, allPts[i + 1].y);\n if (d < bestD) { bestD = d; bestI = i; }\n }\n return bestI;\n}\n\nfunction applyResize(\n start: { x: number; y: number; w: number; h: number },\n handle: ResizeHandle, dx: number, dy: number, minSize = 24,\n): { x: number; y: number; w: number; h: number } {\n let { x, y, w, h } = { ...start };\n const ml = handle === 'nw' || handle === 'sw';\n const mr = handle === 'ne' || handle === 'se';\n const mt = handle === 'nw' || handle === 'ne';\n const mb = handle === 'sw' || handle === 'se';\n if (ml) { x += dx; w -= dx; }\n if (mr) { w += dx; }\n if (mt) { y += dy; h -= dy; }\n if (mb) { h += dy; }\n if (w < minSize) { if (ml) x = start.x + start.w - minSize; w = minSize; }\n if (h < minSize) { if (mt) y = start.y + start.h - minSize; h = minSize; }\n return { x, y, w, h };\n}\n\nfunction isPointNearEdgePath(\n wx: number, wy: number, edge: FlowEdge,\n nodeMap: Map<string, FlowNode>, threshold: number,\n): boolean {\n const ep = resolveEdgeEndpoints(edge, nodeMap);\n if (!ep) return false;\n const segs = buildEdgePath(edge.type, ep, edge.data.waypoints, edge.data.bezierControls);\n const pts = linearizeSegments(segs);\n for (let i = 0; i < pts.length - 1; i++) {\n if (distToSegment(wx, wy, pts[i].x, pts[i].y, pts[i + 1].x, pts[i + 1].y) < threshold) return true;\n }\n return false;\n}\n\nfunction isPointNearLine(\n wx: number, wy: number, line: FlowLine, threshold: number,\n): boolean {\n const pts = line.points;\n for (let i = 0; i < pts.length - 1; i++) {\n if (distToSegment(wx, wy, pts[i].x, pts[i].y, pts[i + 1].x, pts[i + 1].y) < threshold) return true;\n }\n return false;\n}\n\nexport default function FlowCanvas({ onPixiReady }: FlowCanvasProps) {\n const containerRef = useRef<HTMLDivElement>(null);\n const { pixiRef, readyRef } = usePixiApp(containerRef);\n const { setViewportInternal, viewportReqRef, viewport: uiViewport, autoFocus, showGrid, showAnchors, gridSize, toolMode, edgeType, focusOnRect, setFocusOnRect, pendingPlacement, setPendingPlacement, setContextMenu, beginNodeDrag, endNodeDrag, presentation, editingNodeId, setEditingNodeId } = useFlowUI();\n const { currentCanvas, selection, setSelection, setDoc, currentCanvasId, pushCanvas, doc: flowDoc } = useFlowContext();\n\n const gridRef = useRef<GridRenderer | null>(null);\n const selectionRef = useRef<SelectionOverlay | null>(null);\n const nodeRendererRef = useRef<NodeRenderer | null>(null);\n const edgeRendererRef = useRef<EdgeRenderer | null>(null);\n const lineRendererRef = useRef<LineRenderer | null>(null);\n const freehandRef = useRef<FreehandTool | null>(null);\n const geoLineRef = useRef<GeometricLineTool | null>(null);\n const hoveredNodeRef = useRef<string | null>(null);\n const transformGfxRef = useRef<Graphics | null>(null);\n const handleHoverGfxRef = useRef<Graphics | null>(null);\n const alignGuidesRef = useRef<AlignmentGuidesRenderer | null>(null);\n const activeGuidesRef = useRef<AlignGuide[]>([]);\n const hoveredHandleRef = useRef<{ nodeId: string; handleId: string; wx: number; wy: number } | null>(null);\n const hoveredEdgeEndpointRef = useRef<EdgeEndpointHit | null>(null);\n const waypointDragRef = useRef<{\n active: boolean;\n edgeId: string;\n type: 'waypoint' | 'bezierC1' | 'bezierC2';\n index: number;\n } | null>(null);\n const edgeEditGfxRef = useRef<Graphics | null>(null);\n const lastClickRef = useRef<{ time: number; wx: number; wy: number }>({ time: 0, wx: 0, wy: 0 });\n const dblClickRef = useRef<{ time: number; wx: number; wy: number }>({ time: 0, wx: 0, wy: 0 });\n const ghostGfxRef = useRef<Graphics | null>(null);\n const mouseWorldRef = useRef<{ x: number; y: number }>({ x: 0, y: 0 });\n\n const interactiveCanvas = showAnchors || presentation\n ? currentCanvas\n : { ...currentCanvas, nodes: currentCanvas.nodes.filter(node => node.type !== 'animAnchor') };\n const canvasDataRef = useRef(interactiveCanvas);\n canvasDataRef.current = interactiveCanvas;\n const currentCanvasIdRef = useRef(currentCanvasId);\n currentCanvasIdRef.current = currentCanvasId;\n const selectionDataRef = useRef(selection);\n selectionDataRef.current = selection;\n const docRef = useRef(flowDoc);\n docRef.current = flowDoc;\n const toolModeRef = useRef(toolMode);\n toolModeRef.current = toolMode;\n const autoFocusRef = useRef(autoFocus);\n autoFocusRef.current = autoFocus;\n const focusOnRectRef = useRef(focusOnRect);\n focusOnRectRef.current = focusOnRect;\n const edgeTypeRef = useRef(edgeType);\n edgeTypeRef.current = edgeType;\n const showAnchorsRef = useRef(showAnchors);\n showAnchorsRef.current = showAnchors;\n const presentationRef = useRef(presentation);\n presentationRef.current = presentation;\n const pendingPlacementRef = useRef(pendingPlacement);\n pendingPlacementRef.current = pendingPlacement;\n const beginNodeDragRef = useRef(beginNodeDrag);\n beginNodeDragRef.current = beginNodeDrag;\n const endNodeDragRef = useRef(endNodeDrag);\n endNodeDragRef.current = endNodeDrag;\n\n const dragRef = useRef<{\n active: boolean;\n nodeIds: Set<string>;\n lineIds?: Set<string>;\n startWorld: { x: number; y: number };\n nodeStarts: Map<string, { x: number; y: number }>;\n linePointStarts?: Map<string, Array<{ x: number; y: number }>>;\n } | null>(null);\n\n const marqueeRef = useRef<{\n active: boolean;\n startScreen: { x: number; y: number };\n } | null>(null);\n\n const connectRef = useRef<{\n active: boolean;\n sourceNodeId: string;\n sourceHandleId: string;\n } | null>(null);\n const reconnectRef = useRef<{\n active: boolean;\n edgeId: string;\n movingEnd: 'source' | 'target';\n fixedNodeId: string;\n fixedHandleId: string | undefined;\n } | null>(null);\n const connectLineRef = useRef<Graphics | null>(null);\n\n const resizeRef = useRef<{\n active: boolean;\n nodeId: string;\n handle: ResizeHandle;\n startWorld: { x: number; y: number };\n startBounds: { x: number; y: number; w: number; h: number };\n childStarts: Map<string, { x: number; y: number; w: number; h: number }>;\n childLineStarts?: Map<string, Array<{ x: number; y: number }>>;\n } | null>(null);\n\n const lineDragRef = useRef<{\n active: boolean;\n lineIds: Set<string>;\n startWorld: { x: number; y: number };\n pointStarts: Map<string, Array<{ x: number; y: number }>>;\n } | null>(null);\n\n const vmViewportRef = useRef(uiViewport);\n const vpRafRef = useRef(0);\n const handleViewportChange = useCallback((v: ViewportState) => {\n vmViewportRef.current = v;\n if (!vpRafRef.current) {\n vpRafRef.current = requestAnimationFrame(() => {\n vpRafRef.current = 0;\n // VM → React: display-only update. Does NOT request a VM apply, so it\n // can never echo back and cause a feedback loop / jitter.\n setViewportInternal(vmViewportRef.current);\n });\n }\n }, [setViewportInternal]);\n\n const { vmRef, screenToWorld } = useViewport(pixiRef, handleViewportChange);\n const screenToWorldRef = useRef(screenToWorld);\n screenToWorldRef.current = screenToWorld;\n // `editing` holds the target; `editorPos` is the on-screen position (CSS px\n // relative to the canvas container) recomputed each frame so the input\n // tracks pan/zoom.\n const [editing, setEditing] = useState<{ kind: 'node' | 'edge' | 'line'; id: string; value: string } | null>(null);\n const [editorPos, setEditorPos] = useState<{ x: number; y: number } | null>(null);\n const editingRef = useRef(editing);\n editingRef.current = editing;\n\n // Stable trigger used from inside the pixi event handlers.\n const beginEditRef = useRef<(kind: 'node' | 'edge' | 'line', id: string, value: string) => void>(() => {});\n beginEditRef.current = (kind, id, value) => {\n setEditingNodeId(kind === 'node' ? id : null);\n setEditing({ kind, id, value });\n };\n\n const commitEdit = useCallback((value: string) => {\n const target = editingRef.current;\n if (!target) return;\n setDoc(prev => {\n const cid = currentCanvasIdRef.current;\n const canvas = prev.canvases[cid];\n if (!canvas) return prev;\n let next = canvas;\n if (target.kind === 'node') {\n next = { ...canvas, nodes: canvas.nodes.map(n => n.id === target.id ? { ...n, data: { ...n.data, label: value } } : n) };\n } else if (target.kind === 'edge') {\n next = { ...canvas, edges: canvas.edges.map(e => e.id === target.id ? { ...e, data: { ...e.data, labelText: value } } : e) };\n } else {\n // Lines have no label field today; ignore.\n return prev;\n }\n return { ...prev, canvases: { ...prev.canvases, [cid]: next } };\n });\n setEditing(null);\n setEditingNodeId(null);\n setEditorPos(null);\n }, [setDoc, setEditingNodeId]);\n\n const cancelEdit = useCallback(() => {\n setEditing(null);\n setEditingNodeId(null);\n setEditorPos(null);\n }, [setEditingNodeId]);\n\n useEffect(() => {\n if (!editingNodeId || editingRef.current?.id === editingNodeId) return;\n const node = canvasDataRef.current.nodes.find(item => item.id === editingNodeId);\n if (node) beginEditRef.current('node', node.id, node.data.label);\n }, [editingNodeId]);\n\n // Compute the on-screen editor position from the target's world-space center.\n useEffect(() => {\n if (!editing) return;\n const vm = vmRef.current;\n if (!vm) return;\n const canvas = canvasDataRef.current;\n let world: { x: number; y: number } | null = null;\n if (editing.kind === 'node') {\n const n = canvas.nodes.find(nn => nn.id === editing.id);\n if (n) world = { x: n.position.x + n.width / 2, y: n.position.y + n.height / 2 };\n } else if (editing.kind === 'edge') {\n const e = canvas.edges.find(ee => ee.id === editing.id);\n const nodeMap = new Map<string, FlowNode>();\n for (const nn of canvas.nodes) nodeMap.set(nn.id, nn);\n if (e) {\n const ep = resolveEdgeEndpoints(e, nodeMap);\n if (ep) {\n const segs = buildEdgePath(e.type, ep, e.data.waypoints, e.data.bezierControls);\n const pts = linearizeSegments(segs);\n const mid = pts[Math.floor(pts.length / 2)] ?? { x: (ep.sx + ep.tx) / 2, y: (ep.sy + ep.ty) / 2 };\n world = { x: mid.x, y: mid.y };\n }\n }\n }\n if (world) {\n const s = vm.worldToScreen(world.x, world.y);\n setEditorPos({ x: s.x, y: s.y });\n }\n }, [editing, vmRef]);\n\n // Apply EXTERNAL viewport commands (toolbar zoom buttons, minimap, outline\n // panel) → ViewportManager. Only runs when the external request counter\n // changes, so VM→React display updates are never echoed back (no jitter).\n const lastViewportReqRef = useRef(0);\n useEffect(() => {\n if (viewportReqRef.current === lastViewportReqRef.current) return;\n lastViewportReqRef.current = viewportReqRef.current;\n vmViewportRef.current = uiViewport;\n vmRef.current?.setState(uiViewport);\n }, [uiViewport, vmRef, viewportReqRef]);\n\n // Register focusOnRect implementation with ViewportManager\n useEffect(() => {\n setFocusOnRect((wx: number, wy: number, ww: number, wh: number, options?: FocusOnRectOptions) => {\n const vm = vmRef.current;\n const el = containerRef.current;\n if (!vm || !el) return;\n const screenW = el.clientWidth || 800;\n const screenH = el.clientHeight || 600;\n const pad = Math.max(0, options?.padding ?? 60);\n const availableW = Math.max(1, screenW - pad * 2);\n const availableH = Math.max(1, screenH - pad * 2);\n const zoom = options?.preserveZoom\n ? vm.state.zoom\n : Math.min(\n availableW / Math.max(ww, 1),\n availableH / Math.max(wh, 1),\n options?.maxZoom ?? 2,\n );\n const cx = wx + ww / 2;\n const cy = wy + wh / 2;\n const targetX = screenW / 2 - cx * zoom;\n const targetY = screenH / 2 - cy * zoom;\n vm.animateTo({ x: targetX, y: targetY, zoom }, options?.duration ?? 350);\n });\n }, [setFocusOnRect, vmRef]);\n\n const handleLineComplete = useCallback((line: FlowLine) => {\n setDoc(prev => {\n const canvas = prev.canvases[currentCanvasIdRef.current];\n if (!canvas) return prev;\n return {\n ...prev,\n canvases: {\n ...prev.canvases,\n [currentCanvasIdRef.current]: { ...canvas, lines: [...canvas.lines, line] },\n },\n };\n });\n }, [setDoc, currentCanvasId]);\n const handleLineCompleteRef = useRef(handleLineComplete);\n handleLineCompleteRef.current = handleLineComplete;\n\n // Initialize PixiJS subsystems\n useEffect(() => {\n const pixi = pixiRef.current;\n if (!pixi || pixi.destroyed) return;\n\n let cancelled = false;\n const waitForReady = () => {\n if (cancelled) return;\n if (!readyRef.current) { setTimeout(waitForReady, 30); return; }\n\n gridRef.current = new GridRenderer(pixi.app.stage, gridSize, showGrid);\n selectionRef.current = new SelectionOverlay(pixi.app.stage);\n nodeRendererRef.current = new NodeRenderer(pixi.world);\n edgeRendererRef.current = new EdgeRenderer(pixi.world);\n lineRendererRef.current = new LineRenderer(pixi.world);\n\n const connectLine = new Graphics();\n connectLine.label = 'connect-line';\n connectLine.visible = false;\n pixi.world.addChild(connectLine);\n connectLineRef.current = connectLine;\n\n const transformGfx = new Graphics();\n transformGfx.label = 'transform-handles';\n pixi.app.stage.addChild(transformGfx);\n transformGfxRef.current = transformGfx;\n\n const handleHoverGfx = new Graphics();\n handleHoverGfx.label = 'handle-hover';\n pixi.world.addChild(handleHoverGfx);\n handleHoverGfxRef.current = handleHoverGfx;\n\n const edgeEditGfx = new Graphics();\n edgeEditGfx.label = 'edge-edit-handles';\n pixi.world.addChild(edgeEditGfx);\n edgeEditGfxRef.current = edgeEditGfx;\n\n const ghostGfx = new Graphics();\n ghostGfx.label = 'ghost-placement';\n ghostGfx.alpha = 0.5;\n pixi.world.addChild(ghostGfx);\n ghostGfxRef.current = ghostGfx;\n\n alignGuidesRef.current = new AlignmentGuidesRenderer(pixi.world);\n\n freehandRef.current = new FreehandTool(pixi.app.stage, pixi.world, {\n onLineComplete: (line) => handleLineCompleteRef.current(line),\n screenToWorld: (sx, sy) => screenToWorldRef.current(sx, sy),\n });\n geoLineRef.current = new GeometricLineTool(pixi.app.stage, pixi.world, {\n onLineComplete: (line) => handleLineCompleteRef.current(line),\n screenToWorld: (sx, sy) => screenToWorldRef.current(sx, sy),\n });\n\n onPixiReady?.(pixi);\n const stage = pixi.app.stage;\n\n // ─── POINTER DOWN ───────────────────────────────────────\n stage.on('pointerdown', (e: FederatedPointerEvent) => {\n // Pixi interactions do not move DOM focus automatically. Explicitly\n // focus the canvas host so Mindmap Tab/Enter shortcuts are not handled\n // as focus navigation by a previously focused inspector control.\n containerRef.current?.focus({ preventScroll: true });\n if (vmRef.current?.isPanning || vmRef.current?.isSpaceHeld) return;\n if (e.button !== 0) return;\n const mode = toolModeRef.current;\n if (mode === 'pan') {\n vmRef.current?.startPan(e.global.x, e.global.y);\n return;\n }\n if (mode === 'freehand' || mode === 'line' || mode === 'polyline' || mode === 'arrow') return;\n\n const world = screenToWorldRef.current(e.global.x, e.global.y);\n const nodes = canvasDataRef.current.nodes;\n const edges = canvasDataRef.current.edges;\n const lines = canvasDataRef.current.lines;\n const sel = selectionDataRef.current;\n const additive = e.metaKey || e.ctrlKey || e.shiftKey;\n const zoom = vmRef.current?.state.zoom ?? 1;\n\n // Pending placement has the highest priority: clicking over an existing\n // node still places the new object instead of selecting the object below.\n const pp = pendingPlacementRef.current;\n if (pp) {\n const newId = generateId('node');\n const rawX = world.x - pp.width / 2;\n const rawY = world.y - pp.height / 2;\n const virtual: FlowNode = {\n id: '__ghost__', type: pp.type,\n position: { x: rawX, y: rawY },\n width: pp.width, height: pp.height, data: {} as any,\n };\n const snap = computeAlignmentSnap([virtual], nodes);\n const px = rawX + snap.dx;\n const py = rawY + snap.dy;\n setDoc(prev => {\n const canvas = prev.canvases[currentCanvasIdRef.current];\n if (!canvas) return prev;\n const extraData: Record<string, any> = {};\n if (pp.type === 'animAnchor') extraData.animIndex = nextAnimIndex(prev);\n const highestZ = Math.max(\n 0,\n ...canvas.nodes.map(node => node.zIndex ?? 0),\n ...canvas.lines.map(line => line.zIndex ?? 0),\n );\n return {\n ...prev,\n canvases: { ...prev.canvases, [currentCanvasIdRef.current]: {\n ...canvas,\n nodes: [...canvas.nodes, {\n id: newId,\n type: pp.type,\n position: { x: px, y: py },\n width: pp.width,\n height: pp.height,\n zIndex: highestZ + 1,\n data: { ...pp.data, ...extraData },\n }],\n }},\n };\n });\n setSelection({ nodeIds: new Set([newId]), edgeIds: new Set(), lineIds: new Set() });\n if (autoFocusRef.current) {\n window.setTimeout(() => {\n focusOnRectRef.current(px, py, pp.width, pp.height, {\n padding: 80,\n preserveZoom: true,\n duration: 280,\n });\n }, 0);\n }\n return;\n }\n\n const now = Date.now();\n const lc = lastClickRef.current;\n const isDblClick = now - lc.time < 350 && Math.hypot(world.x - lc.wx, world.y - lc.wy) < 8 / zoom;\n lastClickRef.current = { time: now, wx: world.x, wy: world.y };\n\n // 1) Resize handles (corners only, single-node selection, select mode)\n if (sel.nodeIds.size === 1 && !additive && mode === 'select') {\n const selNode = nodes.find(n => n.id === [...sel.nodeIds][0]);\n if (selNode) {\n const rh = getResizeHandleAt(world, selNode, Math.min(10 / zoom, 16));\n if (rh) {\n const childStarts = new Map<string, { x: number; y: number; w: number; h: number }>();\n const childLineStarts = new Map<string, Array<{ x: number; y: number }>>();\n const isGeoGroup = selNode.type === 'geometryGroup';\n const isAnyGroup = isGeoGroup || selNode.type === 'flowGroup' || selNode.data.isGroup;\n const gx = selNode.position.x, gy = selNode.position.y;\n const gw = selNode.width, gh = selNode.height;\n for (const n of nodes) {\n if (n.id === selNode.id) continue;\n if (n.parentId === selNode.id) {\n childStarts.set(n.id, { x: n.position.x, y: n.position.y, w: n.width, h: n.height });\n } else if (isGeoGroup\n && n.position.x >= gx && n.position.y >= gy\n && n.position.x + n.width <= gx + gw\n && n.position.y + n.height <= gy + gh) {\n childStarts.set(n.id, { x: n.position.x, y: n.position.y, w: n.width, h: n.height });\n }\n }\n if (isAnyGroup) {\n for (const l of canvasDataRef.current.lines) {\n if (l.parentId === selNode.id) {\n childLineStarts.set(l.id, l.points.map(p => ({ ...p })));\n } else if (isGeoGroup && l.points.length > 0 && l.points.every(p =>\n p.x >= gx && p.x <= gx + gw && p.y >= gy && p.y <= gy + gh\n )) {\n childLineStarts.set(l.id, l.points.map(p => ({ ...p })));\n }\n }\n }\n resizeRef.current = {\n active: true, nodeId: selNode.id, handle: rh,\n startWorld: world,\n startBounds: { x: selNode.position.x, y: selNode.position.y, w: selNode.width, h: selNode.height },\n childStarts,\n childLineStarts: childLineStarts.size > 0 ? childLineStarts : undefined,\n };\n return;\n }\n }\n }\n\n // Hit test node — if the hit node is inside a group, redirect to the group\n let hitNode: FlowNode | null = null;\n for (let i = nodes.length - 1; i >= 0; i--) {\n if (isPointInNode(world.x, world.y, nodes[i])) { hitNode = nodes[i]; break; }\n }\n if (hitNode?.parentId) {\n const groupNode = nodes.find(n => n.id === hitNode!.parentId);\n if (groupNode) hitNode = groupNode;\n }\n\n // 2) Connection handle detection (works in both select and connect modes)\n if (hitNode && (mode === 'select' || mode === 'connect')) {\n const handles = getHandlePositions(hitNode.width, hitNode.height);\n const closest = findClosestHandleWorld(\n handles, hitNode,\n world.x, world.y, Math.min(14 / zoom, 20),\n );\n if (closest) {\n connectRef.current = { active: true, sourceNodeId: hitNode.id, sourceHandleId: closest.id };\n return;\n }\n }\n\n // 3) Edge endpoint reconnection — only for SELECTED edges\n if ((mode === 'select' || mode === 'connect') && !additive && sel.edgeIds.size > 0) {\n const nodeMap = new Map<string, FlowNode>();\n for (const n of nodes) nodeMap.set(n.id, n);\n const selectedEdges = edges.filter(ed => sel.edgeIds.has(ed.id));\n const epHit = findEdgeEndpointNear(world.x, world.y, selectedEdges, nodeMap, Math.min(14 / zoom, 20));\n if (epHit) {\n const edge = edges.find(ed => ed.id === epHit.edgeId);\n if (edge) {\n const fixedEnd = epHit.end === 'source' ? 'target' : 'source';\n reconnectRef.current = {\n active: true,\n edgeId: edge.id,\n movingEnd: epHit.end,\n fixedNodeId: fixedEnd === 'source' ? edge.source : edge.target,\n fixedHandleId: fixedEnd === 'source' ? edge.sourceHandle : edge.targetHandle,\n };\n return;\n }\n }\n }\n\n // 3.5) Waypoint / bezier control editing on selected edges\n if (mode === 'select' && sel.edgeIds.size > 0 && !hitNode) {\n const wmNodeMap = new Map<string, FlowNode>();\n for (const n of nodes) wmNodeMap.set(n.id, n);\n const selEdges = edges.filter(ed => sel.edgeIds.has(ed.id));\n const wpThreshold = Math.min(10 / zoom, 14);\n\n const bzHit = findBezierControlNear(world.x, world.y, selEdges, wmNodeMap, wpThreshold);\n if (bzHit) {\n waypointDragRef.current = {\n active: true, edgeId: bzHit.edgeId,\n type: bzHit.controlEnd === 'c1' ? 'bezierC1' : 'bezierC2',\n index: bzHit.segmentIndex,\n };\n return;\n }\n\n const wpHit = findWaypointNear(world.x, world.y, selEdges, wpThreshold);\n if (wpHit) {\n if (isDblClick) {\n setDoc(prev => {\n const canvas = prev.canvases[currentCanvasIdRef.current];\n if (!canvas) return prev;\n return {\n ...prev,\n canvases: { ...prev.canvases, [currentCanvasIdRef.current]: {\n ...canvas,\n edges: canvas.edges.map(e => {\n if (e.id !== wpHit.edgeId) return e;\n const wps = [...(e.data.waypoints ?? [])];\n wps.splice(wpHit.waypointIndex, 1);\n const data = { ...e.data, waypoints: wps.length > 0 ? wps : undefined };\n if (e.type === 'simplebezier' && e.data.bezierControls) {\n const ctrls = [...e.data.bezierControls];\n ctrls.splice(wpHit.waypointIndex, 2, null);\n data.bezierControls = ctrls.some(c => c !== null) ? ctrls : undefined;\n }\n return { ...e, data };\n }),\n }},\n };\n });\n return;\n }\n waypointDragRef.current = { active: true, edgeId: wpHit.edgeId, type: 'waypoint', index: wpHit.waypointIndex };\n return;\n }\n\n if (isDblClick) {\n for (const edge of selEdges) {\n if (isPointNearEdgePath(world.x, world.y, edge, wmNodeMap, Math.min(8 / zoom, 12))) {\n const insertIdx = findInsertionIndex(world.x, world.y, edge, wmNodeMap);\n const newWp = { x: world.x, y: world.y };\n setDoc(prev => {\n const canvas = prev.canvases[currentCanvasIdRef.current];\n if (!canvas) return prev;\n return {\n ...prev,\n canvases: { ...prev.canvases, [currentCanvasIdRef.current]: {\n ...canvas,\n edges: canvas.edges.map(e => {\n if (e.id !== edge.id) return e;\n const wps = [...(e.data.waypoints ?? [])];\n wps.splice(insertIdx, 0, newWp);\n const data = { ...e.data, waypoints: wps };\n if (e.type === 'simplebezier' && e.data.bezierControls) {\n const ctrls = [...e.data.bezierControls];\n while (ctrls.length < (e.data.waypoints ?? []).length + 1) ctrls.push(null);\n ctrls.splice(insertIdx, 1, null, null);\n data.bezierControls = ctrls;\n }\n return { ...e, data };\n }),\n }},\n };\n });\n waypointDragRef.current = { active: true, edgeId: edge.id, type: 'waypoint', index: insertIdx };\n return;\n }\n }\n }\n }\n\n // 4) Node body → select + drag\n if (hitNode && (mode === 'select' || mode === 'connect')) {\n if (!additive && !sel.nodeIds.has(hitNode.id)) {\n setSelection({ nodeIds: new Set([hitNode.id]), edgeIds: new Set(), lineIds: new Set() });\n } else if (additive) {\n setSelection(prev => {\n const ids = new Set(prev.nodeIds);\n if (ids.has(hitNode!.id)) ids.delete(hitNode!.id); else ids.add(hitNode!.id);\n return { nodeIds: ids, edgeIds: new Set(), lineIds: new Set() };\n });\n }\n if (autoFocusRef.current) {\n focusOnRectRef.current(\n hitNode.position.x,\n hitNode.position.y,\n hitNode.width,\n hitNode.height,\n { padding: 80, preserveZoom: true, duration: 280 },\n );\n }\n const dragIds = sel.nodeIds.has(hitNode.id)\n ? new Set(sel.nodeIds)\n : new Set([hitNode.id]);\n if (additive && !sel.nodeIds.has(hitNode.id)) dragIds.add(hitNode.id);\n // Include children of group nodes being dragged\n const dragLineIds = new Set<string>();\n for (const gId of [...dragIds]) {\n const gNode = nodes.find(nd => nd.id === gId);\n if (!gNode || (gNode.type !== 'flowGroup' && gNode.type !== 'geometryGroup' && !gNode.data.isGroup)) continue;\n const isGeo = gNode.type === 'geometryGroup';\n const gx = gNode.position.x, gy = gNode.position.y;\n const gw = gNode.width, gh = gNode.height;\n for (const n of nodes) {\n if (dragIds.has(n.id) || n.id === gId) continue;\n if (n.parentId === gId) { dragIds.add(n.id); continue; }\n if (isGeo\n && n.position.x >= gx && n.position.y >= gy\n && n.position.x + n.width <= gx + gw\n && n.position.y + n.height <= gy + gh) {\n dragIds.add(n.id);\n }\n }\n // Include child lines (by parentId)\n for (const l of canvasDataRef.current.lines) {\n if (l.parentId === gId) dragLineIds.add(l.id);\n }\n // Spatial containment for lines in geometryGroup\n if (isGeo) {\n for (const l of canvasDataRef.current.lines) {\n if (dragLineIds.has(l.id)) continue;\n if (l.points.length > 0 && l.points.every(p =>\n p.x >= gx && p.x <= gx + gw && p.y >= gy && p.y <= gy + gh\n )) {\n dragLineIds.add(l.id);\n }\n }\n }\n }\n const nodeStarts = new Map<string, { x: number; y: number }>();\n for (const n of nodes) { if (dragIds.has(n.id)) nodeStarts.set(n.id, { ...n.position }); }\n const linePointStarts = new Map<string, Array<{ x: number; y: number }>>();\n if (dragLineIds.size > 0) {\n for (const l of canvasDataRef.current.lines) {\n if (dragLineIds.has(l.id)) linePointStarts.set(l.id, l.points.map(p => ({ ...p })));\n }\n }\n dragRef.current = { active: true, nodeIds: dragIds, lineIds: dragLineIds.size > 0 ? dragLineIds : undefined, startWorld: world, nodeStarts, linePointStarts: linePointStarts.size > 0 ? linePointStarts : undefined };\n beginNodeDragRef.current();\n return;\n }\n\n // 5) Edge hit test → select edge\n const nodeMap2 = new Map<string, FlowNode>();\n for (const n of nodes) nodeMap2.set(n.id, n);\n const hitThreshold = Math.min(8 / zoom, 12);\n for (const edge of edges) {\n if (isPointNearEdgePath(world.x, world.y, edge, nodeMap2, hitThreshold)) {\n if (additive) {\n setSelection(prev => {\n const ids = new Set(prev.edgeIds);\n if (ids.has(edge.id)) ids.delete(edge.id); else ids.add(edge.id);\n return { ...prev, edgeIds: ids };\n });\n } else {\n setSelection({ nodeIds: new Set(), edgeIds: new Set([edge.id]), lineIds: new Set() });\n }\n if (autoFocusRef.current) {\n const source = nodeMap2.get(edge.source);\n const target = nodeMap2.get(edge.target);\n if (source && target) {\n const minX = Math.min(source.position.x, target.position.x);\n const minY = Math.min(source.position.y, target.position.y);\n const maxX = Math.max(source.position.x + source.width, target.position.x + target.width);\n const maxY = Math.max(source.position.y + source.height, target.position.y + target.height);\n focusOnRectRef.current(minX, minY, maxX - minX, maxY - minY, {\n padding: 80,\n preserveZoom: true,\n duration: 280,\n });\n }\n }\n return;\n }\n }\n\n // 5) Line hit test → select + drag line\n for (const line of lines) {\n if (isPointNearLine(world.x, world.y, line, hitThreshold)) {\n const alreadySelected = sel.lineIds.has(line.id);\n if (additive) {\n setSelection(prev => {\n const ids = new Set(prev.lineIds);\n if (ids.has(line.id)) ids.delete(line.id); else ids.add(line.id);\n return { ...prev, lineIds: ids };\n });\n } else if (!alreadySelected) {\n setSelection({ nodeIds: new Set(), edgeIds: new Set(), lineIds: new Set([line.id]) });\n }\n if (autoFocusRef.current && line.points.length > 0) {\n const xs = line.points.map(point => point.x);\n const ys = line.points.map(point => point.y);\n const minX = Math.min(...xs);\n const minY = Math.min(...ys);\n const maxX = Math.max(...xs);\n const maxY = Math.max(...ys);\n focusOnRectRef.current(minX, minY, Math.max(1, maxX - minX), Math.max(1, maxY - minY), {\n padding: 80,\n preserveZoom: true,\n duration: 280,\n });\n }\n // Start line drag\n const dragLineIds = alreadySelected ? new Set(sel.lineIds) : new Set([line.id]);\n const pointStarts = new Map<string, Array<{ x: number; y: number }>>();\n for (const l of lines) {\n if (dragLineIds.has(l.id)) pointStarts.set(l.id, l.points.map(p => ({ ...p })));\n }\n lineDragRef.current = { active: true, lineIds: dragLineIds, startWorld: world, pointStarts };\n return;\n }\n }\n\n // 6) Empty space → clear selection, start marquee\n if (!additive) {\n setSelection({ nodeIds: new Set(), edgeIds: new Set(), lineIds: new Set() });\n }\n if (mode === 'select') {\n marqueeRef.current = { active: true, startScreen: { x: e.global.x, y: e.global.y } };\n }\n });\n\n // ─── POINTER MOVE ──────────────────────────────────────\n stage.on('globalpointermove', (e: FederatedPointerEvent) => {\n const world = screenToWorldRef.current(e.global.x, e.global.y);\n mouseWorldRef.current = world;\n\n const mode = toolModeRef.current;\n if (mode === 'freehand' || mode === 'line' || mode === 'polyline' || mode === 'arrow') return;\n\n const nodes = canvasDataRef.current.nodes;\n const edges = canvasDataRef.current.edges;\n const zoom = vmRef.current?.state.zoom ?? 1;\n const isIdle = !dragRef.current?.active && !connectRef.current?.active\n && !resizeRef.current?.active && !reconnectRef.current?.active\n && !waypointDragRef.current?.active && !lineDragRef.current?.active;\n\n // Hover tracking — redirect child hovers to parent group\n let hovered: string | null = null;\n for (let i = nodes.length - 1; i >= 0; i--) {\n if (isPointInNode(world.x, world.y, nodes[i])) {\n const n = nodes[i];\n hovered = n.parentId\n ? (nodes.find(g => g.id === n.parentId)?.id ?? n.id)\n : n.id;\n break;\n }\n }\n hoveredNodeRef.current = hovered;\n\n // Hover detection for connection handles and edge endpoints (when idle)\n if (isIdle && (mode === 'select' || mode === 'connect')) {\n const nodeMap = new Map<string, FlowNode>();\n for (const n of nodes) nodeMap.set(n.id, n);\n\n // Check edge endpoint hover — only for selected edges\n const sel = selectionDataRef.current;\n const selectedEdges = sel.edgeIds.size > 0 ? edges.filter(ed => sel.edgeIds.has(ed.id)) : [];\n const epHit = selectedEdges.length > 0\n ? findEdgeEndpointNear(world.x, world.y, selectedEdges, nodeMap, Math.min(12 / zoom, 18))\n : null;\n hoveredEdgeEndpointRef.current = epHit;\n\n // Check connection handle hover on any node\n let foundHandle: typeof hoveredHandleRef.current = null;\n if (hovered) {\n const node = nodes.find(n => n.id === hovered);\n if (node) {\n const handles = getHandlePositions(node.width, node.height);\n const closest = findClosestHandleWorld(handles, node, world.x, world.y, Math.min(14 / zoom, 20));\n if (closest) {\n const wp = handleWorldPos(closest, node);\n foundHandle = { nodeId: node.id, handleId: closest.id, wx: wp.x, wy: wp.y };\n }\n }\n }\n hoveredHandleRef.current = foundHandle;\n }\n\n // Cursor updates\n const el = containerRef.current;\n if (el && isIdle) {\n const sel = selectionDataRef.current;\n let cursor = '';\n if (hoveredEdgeEndpointRef.current) {\n cursor = 'crosshair';\n } else if (hoveredHandleRef.current) {\n cursor = 'crosshair';\n } else if (sel.edgeIds.size > 0 && mode === 'select') {\n const selEdgesForCursor = edges.filter(ed => sel.edgeIds.has(ed.id));\n const cursorNm = new Map<string, FlowNode>();\n for (const n of nodes) cursorNm.set(n.id, n);\n const wpThreshold = Math.min(10 / zoom, 14);\n if (findWaypointNear(world.x, world.y, selEdgesForCursor, wpThreshold)\n || findBezierControlNear(world.x, world.y, selEdgesForCursor, cursorNm, wpThreshold)) {\n cursor = 'grab';\n }\n }\n if (!cursor && sel.nodeIds.size === 1 && mode === 'select') {\n const selNode = nodes.find(n => n.id === [...sel.nodeIds][0]);\n if (selNode) {\n const rh = getResizeHandleAt(world, selNode, Math.min(10 / zoom, 16));\n if (rh) cursor = RESIZE_CURSORS[rh];\n }\n }\n if (!cursor && mode === 'select') {\n const hoverLines = canvasDataRef.current.lines;\n const lineHitT = Math.min(8 / zoom, 12);\n for (const ln of hoverLines) {\n if (isPointNearLine(world.x, world.y, ln, lineHitT)) {\n cursor = 'move';\n break;\n }\n }\n }\n el.style.cursor = cursor;\n }\n\n // Resize with alignment snapping\n if (resizeRef.current?.active) {\n const r = resizeRef.current;\n const dx = world.x - r.startWorld.x;\n const dy = world.y - r.startWorld.y;\n const nb = applyResize(r.startBounds, r.handle, dx, dy);\n const allNodes = canvasDataRef.current.nodes;\n const virtualNode: FlowNode = { id: r.nodeId, type: 'shapeRect', position: { x: nb.x, y: nb.y }, width: nb.w, height: nb.h, data: {} as any };\n const snap = computeAlignmentSnap([virtualNode], allNodes);\n nb.x += snap.dx; nb.y += snap.dy;\n if (r.handle === 'ne' || r.handle === 'se') nb.w += snap.dx;\n if (r.handle === 'se' || r.handle === 'sw') nb.h += snap.dy;\n activeGuidesRef.current = snap.guides;\n\n const ob = r.startBounds;\n const finalW = Math.max(nb.w, 24);\n const finalH = Math.max(nb.h, 24);\n const scaleX = ob.w > 0 ? finalW / ob.w : 1;\n const scaleY = ob.h > 0 ? finalH / ob.h : 1;\n\n setDoc(prev => {\n const canvas = prev.canvases[currentCanvasIdRef.current];\n if (!canvas) return prev;\n return {\n ...prev,\n canvases: {\n ...prev.canvases,\n [currentCanvasIdRef.current]: {\n ...canvas,\n nodes: canvas.nodes.map(n => {\n if (n.id === r.nodeId) {\n return { ...n, position: { x: nb.x, y: nb.y }, width: finalW, height: finalH };\n }\n const cs = r.childStarts.get(n.id);\n if (cs) {\n return {\n ...n,\n position: {\n x: nb.x + (cs.x - ob.x) * scaleX,\n y: nb.y + (cs.y - ob.y) * scaleY,\n },\n width: Math.max(cs.w * scaleX, 24),\n height: Math.max(cs.h * scaleY, 24),\n };\n }\n return n;\n }),\n lines: r.childLineStarts\n ? canvas.lines.map(l => {\n const pts = r.childLineStarts!.get(l.id);\n if (!pts) return l;\n return {\n ...l,\n points: pts.map(p => ({\n x: nb.x + (p.x - ob.x) * scaleX,\n y: nb.y + (p.y - ob.y) * scaleY,\n })),\n };\n })\n : canvas.lines,\n },\n },\n };\n });\n return;\n }\n\n // Waypoint / bezier control drag\n if (waypointDragRef.current?.active) {\n const wpd = waypointDragRef.current;\n const wpNodes = canvasDataRef.current.nodes;\n const wpNm = new Map<string, FlowNode>();\n for (const nd of wpNodes) wpNm.set(nd.id, nd);\n setDoc(prev => {\n const canvas = prev.canvases[currentCanvasIdRef.current];\n if (!canvas) return prev;\n return {\n ...prev,\n canvases: { ...prev.canvases, [currentCanvasIdRef.current]: {\n ...canvas,\n edges: canvas.edges.map(e => {\n if (e.id !== wpd.edgeId) return e;\n if (wpd.type === 'waypoint') {\n const wps = [...(e.data.waypoints ?? [])];\n if (wpd.index < wps.length) wps[wpd.index] = { x: world.x, y: world.y };\n return { ...e, data: { ...e.data, waypoints: wps } };\n }\n const ep = resolveEdgeEndpoints(e, wpNm);\n if (!ep) return e;\n const allWps = e.data.waypoints ?? [];\n const allPts = [{ x: ep.sx, y: ep.sy }, ...allWps, { x: ep.tx, y: ep.ty }];\n const segCount = allPts.length - 1;\n const ctrls: Array<FlowBezierControl | null> = [...(e.data.bezierControls ?? [])];\n while (ctrls.length < segCount) ctrls.push(null);\n const si = wpd.index;\n if (si >= segCount) return e;\n const a = allPts[si], b = allPts[si + 1];\n const existing = ctrls[si];\n const segDist = Math.hypot(b.x - a.x, b.y - a.y);\n const arm = Math.max(30, segDist * 0.3);\n const lastSegIdx = segCount - 1;\n const defC1x = si === 0 ? a.x + ep.snx * arm : a.x + (b.x - a.x) * 0.4;\n const defC1y = si === 0 ? a.y + ep.sny * arm : a.y;\n const defC2x = si === lastSegIdx ? b.x + ep.tnx * arm : b.x - (b.x - a.x) * 0.4;\n const defC2y = si === lastSegIdx ? b.y + ep.tny * arm : b.y;\n if (wpd.type === 'bezierC1') {\n ctrls[si] = {\n c1x: world.x, c1y: world.y,\n c2x: existing?.c2x ?? defC2x, c2y: existing?.c2y ?? defC2y,\n };\n } else {\n ctrls[si] = {\n c1x: existing?.c1x ?? defC1x, c1y: existing?.c1y ?? defC1y,\n c2x: world.x, c2y: world.y,\n };\n }\n return { ...e, data: { ...e.data, bezierControls: ctrls } };\n }),\n }},\n };\n });\n return;\n }\n\n // Line drag\n if (lineDragRef.current?.active) {\n const ld = lineDragRef.current;\n const dx = world.x - ld.startWorld.x;\n const dy = world.y - ld.startWorld.y;\n setDoc(prev => {\n const canvas = prev.canvases[currentCanvasIdRef.current];\n if (!canvas) return prev;\n return {\n ...prev,\n canvases: { ...prev.canvases, [currentCanvasIdRef.current]: {\n ...canvas,\n lines: canvas.lines.map(l => {\n const starts = ld.pointStarts.get(l.id);\n if (!starts) return l;\n return { ...l, points: starts.map(p => ({ x: p.x + dx, y: p.y + dy })) };\n }),\n }},\n };\n });\n return;\n }\n\n // Node drag with alignment snapping\n if (dragRef.current?.active) {\n const drag = dragRef.current;\n const rawDx = world.x - drag.startWorld.x;\n const rawDy = world.y - drag.startWorld.y;\n const allNodes = canvasDataRef.current.nodes;\n const dragNodes = allNodes\n .filter(n => drag.nodeIds.has(n.id))\n .map(n => {\n const start = drag.nodeStarts.get(n.id)!;\n return { ...n, position: { x: start.x + rawDx, y: start.y + rawDy } };\n });\n const snap = computeAlignmentSnap(dragNodes, allNodes);\n const dx = rawDx + snap.dx;\n const dy = rawDy + snap.dy;\n activeGuidesRef.current = snap.guides;\n setDoc(prev => {\n const canvas = prev.canvases[currentCanvasIdRef.current];\n if (!canvas) return prev;\n return {\n ...prev,\n canvases: {\n ...prev.canvases,\n [currentCanvasIdRef.current]: {\n ...canvas,\n nodes: canvas.nodes.map(n => {\n const start = drag.nodeStarts.get(n.id);\n if (!start) return n;\n return { ...n, position: { x: start.x + dx, y: start.y + dy } };\n }),\n lines: drag.linePointStarts\n ? canvas.lines.map(l => {\n const starts = drag.linePointStarts!.get(l.id);\n if (!starts) return l;\n return { ...l, points: starts.map(p => ({ x: p.x + dx, y: p.y + dy })) };\n })\n : canvas.lines,\n },\n },\n };\n });\n return;\n }\n\n // Marquee\n if (marqueeRef.current?.active && selectionRef.current) {\n const mx = Math.min(marqueeRef.current.startScreen.x, e.global.x);\n const my = Math.min(marqueeRef.current.startScreen.y, e.global.y);\n const mw = Math.abs(e.global.x - marqueeRef.current.startScreen.x);\n const mh = Math.abs(e.global.y - marqueeRef.current.startScreen.y);\n selectionRef.current.showMarquee(mx, my, mw, mh);\n }\n\n // Connect line preview — snaps to nearest handle on target node\n if (connectRef.current?.active && connectLineRef.current) {\n const srcNode = canvasDataRef.current.nodes.find(n => n.id === connectRef.current!.sourceNodeId);\n if (srcNode) {\n const handles = getHandlePositions(srcNode.width, srcNode.height);\n const handle = handles.find(h => h.id === connectRef.current!.sourceHandleId);\n if (handle) {\n const swp = handleWorldPos(handle, srcNode);\n const sx = swp.x;\n const sy = swp.y;\n let ex = world.x, ey = world.y;\n\n // Snap endpoint to closest handle if hovering over a different node\n const hovNode = hoveredNodeRef.current;\n if (hovNode && hovNode !== connectRef.current!.sourceNodeId) {\n const tNode = canvasDataRef.current.nodes.find(n => n.id === hovNode);\n if (tNode) {\n const tHandles = getHandlePositions(tNode.width, tNode.height);\n const snap = findClosestHandleWorld(tHandles, tNode, world.x, world.y, Infinity);\n if (snap) { const wp = handleWorldPos(snap, tNode); ex = wp.x; ey = wp.y; }\n }\n }\n\n const g = connectLineRef.current;\n g.clear();\n g.moveTo(sx, sy).lineTo(ex, ey)\n .stroke({ color: 0x3b82f6, width: 2, alpha: 0.6 });\n g.visible = true;\n }\n }\n }\n\n // Reconnect line preview — snaps to nearest handle on target node\n if (reconnectRef.current?.active && connectLineRef.current && !connectLineRef.current.destroyed) {\n const rc = reconnectRef.current;\n const fixedNode = canvasDataRef.current.nodes.find(n => n.id === rc.fixedNodeId);\n if (fixedNode) {\n const handles = getHandlePositions(fixedNode.width, fixedNode.height);\n const fh = handles.find(h => h.id === rc.fixedHandleId);\n const fwp = fh ? handleWorldPos(fh, fixedNode) : { x: fixedNode.position.x + fixedNode.width / 2, y: fixedNode.position.y + fixedNode.height / 2 };\n const fx = fwp.x, fy = fwp.y;\n let ex = world.x, ey = world.y;\n\n const hovNode = hoveredNodeRef.current;\n if (hovNode && hovNode !== rc.fixedNodeId) {\n const tNode = canvasDataRef.current.nodes.find(n => n.id === hovNode);\n if (tNode) {\n const tHandles = getHandlePositions(tNode.width, tNode.height);\n const snap = findClosestHandleWorld(tHandles, tNode, world.x, world.y, Infinity);\n if (snap) { const wp = handleWorldPos(snap, tNode); ex = wp.x; ey = wp.y; }\n }\n }\n\n const g = connectLineRef.current;\n g.clear();\n g.moveTo(fx, fy).lineTo(ex, ey)\n .stroke({ color: 0xf97316, width: 2, alpha: 0.7 });\n g.visible = true;\n }\n }\n });\n\n // ─── POINTER UP ────────────────────────────────────────\n const cleanupDrag = () => {\n activeGuidesRef.current = [];\n try { alignGuidesRef.current?.clear(); } catch { /* destroyed */ }\n try {\n const cl = connectLineRef.current;\n if (cl && !cl.destroyed) { cl.clear(); cl.visible = false; }\n } catch { /* destroyed */ }\n if (containerRef.current) containerRef.current.style.cursor = '';\n };\n\n stage.on('pointerup', (e: FederatedPointerEvent) => {\n cleanupDrag();\n\n if (waypointDragRef.current?.active) {\n waypointDragRef.current = null;\n return;\n }\n\n if (resizeRef.current?.active) {\n resizeRef.current = null;\n return;\n }\n\n if (lineDragRef.current?.active) {\n lineDragRef.current = null;\n return;\n }\n\n if (dragRef.current?.active) {\n dragRef.current = null;\n endNodeDragRef.current();\n }\n\n if (marqueeRef.current?.active) {\n const start = screenToWorldRef.current(marqueeRef.current.startScreen.x, marqueeRef.current.startScreen.y);\n const end = screenToWorldRef.current(e.global.x, e.global.y);\n const mx = Math.min(start.x, end.x), my = Math.min(start.y, end.y);\n const mw = Math.abs(end.x - start.x), mh = Math.abs(end.y - start.y);\n if (mw > 4 && mh > 4) {\n const hit = canvasDataRef.current.nodes.filter(n =>\n rectsOverlap(mx, my, mw, mh, n.position.x, n.position.y, n.width, n.height),\n );\n const hitLines = canvasDataRef.current.lines.filter(l => {\n if (l.points.length === 0) return false;\n return l.points.every(p => p.x >= mx && p.x <= mx + mw && p.y >= my && p.y <= my + mh);\n });\n setSelection({\n nodeIds: new Set(hit.map(n => n.id)),\n edgeIds: new Set(),\n lineIds: new Set(hitLines.map(l => l.id)),\n });\n }\n marqueeRef.current = null;\n selectionRef.current?.hideMarquee();\n }\n\n // Reconnection completion\n if (reconnectRef.current?.active) {\n const rcEdgeId = reconnectRef.current.edgeId;\n const rcMovingEnd = reconnectRef.current.movingEnd;\n const rcFixedNodeId = reconnectRef.current.fixedNodeId;\n reconnectRef.current = null;\n\n const world = screenToWorldRef.current(e.global.x, e.global.y);\n const nodes = canvasDataRef.current.nodes;\n let targetNode: FlowNode | null = null;\n for (let i = nodes.length - 1; i >= 0; i--) {\n if (isPointInNode(world.x, world.y, nodes[i]) && nodes[i].id !== rcFixedNodeId) {\n targetNode = nodes[i]; break;\n }\n }\n if (targetNode) {\n const tgtId = targetNode.id;\n const handles = getHandlePositions(targetNode.width, targetNode.height);\n const closest = findClosestHandleWorld(handles, targetNode, world.x, world.y, Infinity);\n const tgtHandleId = closest?.id;\n setDoc(prev => {\n const canvas = prev.canvases[currentCanvasIdRef.current];\n if (!canvas) return prev;\n return {\n ...prev,\n canvases: {\n ...prev.canvases,\n [currentCanvasIdRef.current]: {\n ...canvas,\n edges: canvas.edges.map(edge => {\n if (edge.id !== rcEdgeId) return edge;\n if (rcMovingEnd === 'source') {\n return { ...edge, source: tgtId, sourceHandle: tgtHandleId };\n } else {\n return { ...edge, target: tgtId, targetHandle: tgtHandleId };\n }\n }),\n },\n },\n };\n });\n }\n return;\n }\n\n // New connection completion\n if (connectRef.current?.active) {\n const srcNodeId = connectRef.current.sourceNodeId;\n const srcHandleId = connectRef.current.sourceHandleId;\n connectRef.current = null;\n\n const world = screenToWorldRef.current(e.global.x, e.global.y);\n const nodes = canvasDataRef.current.nodes;\n let targetNode: FlowNode | null = null;\n for (let i = nodes.length - 1; i >= 0; i--) {\n if (isPointInNode(world.x, world.y, nodes[i]) && nodes[i].id !== srcNodeId) {\n targetNode = nodes[i]; break;\n }\n }\n if (targetNode) {\n const tgtNodeId = targetNode.id;\n const handles = getHandlePositions(targetNode.width, targetNode.height);\n const closest = findClosestHandleWorld(handles, targetNode, world.x, world.y, Infinity);\n const tgtHandleId = closest?.id;\n const id = `edge_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 6)}`;\n const eType = edgeTypeRef.current;\n setDoc(prev => {\n const canvas = prev.canvases[currentCanvasIdRef.current];\n if (!canvas) return prev;\n if (canvas.edges.some(e =>\n e.source === srcNodeId && e.target === tgtNodeId\n && e.sourceHandle === srcHandleId && e.targetHandle === tgtHandleId\n )) return prev;\n return {\n ...prev,\n canvases: {\n ...prev.canvases,\n [currentCanvasIdRef.current]: {\n ...canvas,\n edges: [...canvas.edges, {\n id,\n source: srcNodeId,\n target: tgtNodeId,\n sourceHandle: srcHandleId,\n targetHandle: tgtHandleId,\n type: eType as any,\n data: { strokeColor: '#374151', strokeWidth: 2, lineStyle: 'solid' as const, markerEnd: 'arrowclosed' as const },\n }],\n },\n },\n };\n });\n }\n }\n });\n\n stage.on('pointerupoutside', () => {\n cleanupDrag();\n if (dragRef.current?.active) endNodeDragRef.current();\n dragRef.current = null;\n resizeRef.current = null;\n marqueeRef.current = null;\n reconnectRef.current = null;\n connectRef.current = null;\n waypointDragRef.current = null;\n lineDragRef.current = null;\n selectionRef.current?.hideMarquee();\n });\n\n // ─── RIGHT-CLICK CONTEXT MENU ─────────────────────────\n stage.on('rightclick', (e: FederatedPointerEvent) => {\n e.preventDefault?.();\n // If the right button was used to pan (drawio-style right-drag), don't\n // open the context menu — only a stationary right-click should.\n if (vmRef.current?.didRightPan) return;\n const world = screenToWorldRef.current(e.global.x, e.global.y);\n const nodes = canvasDataRef.current.nodes;\n let hitNodeId: string | null = null;\n for (let i = nodes.length - 1; i >= 0; i--) {\n if (isPointInNode(world.x, world.y, nodes[i])) {\n hitNodeId = nodes[i].id;\n break;\n }\n }\n const native = (e as any).nativeEvent as MouseEvent | undefined;\n const cx = native?.clientX ?? e.global.x;\n const cy = native?.clientY ?? e.global.y;\n setContextMenu({ x: cx, y: cy, nodeId: hitNodeId });\n });\n\n // ─── DOUBLE-CLICK → ENTER SUB-CANVAS / EDIT LABEL ────\n stage.on('pointertap', (e: FederatedPointerEvent) => {\n if (e.button !== 0) return;\n const now = Date.now();\n const world = screenToWorldRef.current(e.global.x, e.global.y);\n const last = dblClickRef.current;\n const dx = world.x - last.wx;\n const dy = world.y - last.wy;\n if (now - last.time < 400 && Math.abs(dx) < 10 && Math.abs(dy) < 10) {\n const nodes = canvasDataRef.current.nodes;\n for (let i = nodes.length - 1; i >= 0; i--) {\n if (isPointInNode(world.x, world.y, nodes[i])) {\n const node = nodes[i];\n const childId = node.data.childCanvasId;\n if (childId) {\n pushCanvas(childId);\n dblClickRef.current = { time: 0, wx: 0, wy: 0 };\n return;\n }\n // Double-click a shape → edit its label in place.\n beginEditRef.current('node', node.id, node.data.label ?? '');\n dblClickRef.current = { time: 0, wx: 0, wy: 0 };\n return;\n }\n }\n\n // Double-click an edge → edit its label.\n const edges = canvasDataRef.current.edges;\n const wmNodeMap = new Map<string, FlowNode>();\n for (const n of nodes) wmNodeMap.set(n.id, n);\n const zoom = vmRef.current?.state.zoom ?? 1;\n for (let i = edges.length - 1; i >= 0; i--) {\n if (isPointNearEdgePath(world.x, world.y, edges[i], wmNodeMap, Math.min(8 / zoom, 12))) {\n beginEditRef.current('edge', edges[i].id, edges[i].data.labelText ?? '');\n dblClickRef.current = { time: 0, wx: 0, wy: 0 };\n return;\n }\n }\n }\n dblClickRef.current = { time: now, wx: world.x, wy: world.y };\n });\n\n // ─── RENDER LOOP ───────────────────────────────────\n let wasPanning = false;\n pixi.app.ticker.add((ticker) => {\n if (pixi.destroyed) return;\n const deltaMs = ticker.deltaMS;\n const screen = pixi.app.screen;\n const vp = vmRef.current?.state ?? { x: 0, y: 0, zoom: 1 };\n gridRef.current?.update(vp, screen.width, screen.height);\n\n // Show a grabbing cursor while panning (right-drag / middle / space).\n const panningNow = vmRef.current?.isPanning ?? false;\n if (panningNow !== wasPanning) {\n wasPanning = panningNow;\n if (containerRef.current) {\n containerRef.current.style.cursor = panningNow ? 'grabbing' : '';\n }\n }\n\n const cData = canvasDataRef.current;\n const sel = selectionDataRef.current;\n\n // Global (document-wide) animation-anchor sequence so sub-canvas badges\n // share one order and the presentation can drill in/out consistently.\n const slides = getDocumentSlides(docRef.current);\n const animSeqMap = new Map<string, number>();\n slides.forEach((s, i) => animSeqMap.set(s.node.id, i + 1));\n\n nodeRendererRef.current?.advanceAnimation(deltaMs);\n const activeSlide = presentationRef.current\n ? slides[presentationRef.current.current]\n : undefined;\n nodeRendererRef.current?.sync(cData.nodes, sel.nodeIds, hoveredNodeRef.current, animSeqMap, {\n showAnchors: showAnchorsRef.current,\n presentation: presentationRef.current !== null,\n presentationAnchorId: activeSlide?.node.id,\n presentationAnchorVisible: presentationRef.current?.showAnchor ?? false,\n });\n\n const nodeMap = new Map<string, FlowNode>();\n for (const n of cData.nodes) nodeMap.set(n.id, n);\n edgeRendererRef.current?.advanceAnimation(deltaMs);\n edgeRendererRef.current?.sync(cData.edges, nodeMap, sel.edgeIds, null, {\n presentation: presentationRef.current !== null,\n });\n\n lineRendererRef.current?.advanceAnimation(deltaMs);\n lineRendererRef.current?.sync(cData.lines, sel.lineIds);\n\n // Draw alignment guides in world space\n alignGuidesRef.current?.update(activeGuidesRef.current, screen.width, screen.height, vp);\n\n // Draw connection handle hover indicator (world space)\n const hhGfx = handleHoverGfxRef.current;\n if (hhGfx) {\n hhGfx.clear();\n const hh = hoveredHandleRef.current;\n if (hh) {\n hhGfx.circle(hh.wx, hh.wy, 10)\n .fill({ color: 0x3b82f6, alpha: 0.12 })\n .stroke({ color: 0x3b82f6, width: 1.5, alpha: 0.5 });\n hhGfx.circle(hh.wx, hh.wy, 4)\n .fill({ color: 0x3b82f6, alpha: 0.9 });\n }\n // Edge endpoint hover indicators\n const epHover = hoveredEdgeEndpointRef.current;\n if (epHover && !hh) {\n hhGfx.circle(epHover.worldX, epHover.worldY, 10)\n .fill({ color: 0xf97316, alpha: 0.12 })\n .stroke({ color: 0xf97316, width: 1.5, alpha: 0.5 });\n hhGfx.circle(epHover.worldX, epHover.worldY, 4)\n .fill({ color: 0xf97316, alpha: 0.9 });\n }\n }\n\n // Ghost placement preview — draw actual shape silhouette, with\n // alignment-guide snapping against existing nodes (same as dragging).\n const gGfx = ghostGfxRef.current;\n if (gGfx) {\n gGfx.clear();\n const pp = pendingPlacementRef.current;\n if (pp) {\n const mw = mouseWorldRef.current;\n const rawX = mw.x - pp.width / 2;\n const rawY = mw.y - pp.height / 2;\n const virtual: FlowNode = {\n id: '__ghost__', type: pp.type,\n position: { x: rawX, y: rawY },\n width: pp.width, height: pp.height, data: {} as any,\n };\n const snap = computeAlignmentSnap([virtual], cData.nodes);\n activeGuidesRef.current = snap.guides;\n gGfx.position.set(rawX + snap.dx, rawY + snap.dy);\n const drawFn = shapeDrawers[pp.type] ?? shapeDrawers.shapeRect;\n drawFn(gGfx, {\n width: pp.width, height: pp.height,\n fill: '#3b82f6', stroke: '#3b82f6',\n strokeWidth: 1.5, borderStyle: pp.data.borderStyle,\n });\n } else {\n gGfx.position.set(0, 0);\n // Only clear guides here if nothing else (drag/resize) owns them.\n if (!dragRef.current?.active && !resizeRef.current?.active) {\n activeGuidesRef.current = [];\n }\n }\n }\n\n // Draw edge edit handles (waypoints + bezier controls) in world space\n const eeGfx = edgeEditGfxRef.current;\n if (eeGfx) {\n eeGfx.clear();\n if (sel.edgeIds.size > 0 && toolModeRef.current === 'select') {\n const iz = 1 / vp.zoom;\n for (const edge of cData.edges) {\n if (!sel.edgeIds.has(edge.id)) continue;\n const wps = edge.data.waypoints;\n if (wps) {\n for (const wp of wps) {\n eeGfx.circle(wp.x, wp.y, 5 * iz)\n .fill({ color: 0xffffff })\n .stroke({ color: 0x3b82f6, width: 1.5 * iz });\n }\n }\n if (edge.type === 'simplebezier') {\n const ep = resolveEdgeEndpoints(edge, nodeMap);\n if (!ep) continue;\n const allWps = wps ?? [];\n const allPts = [{ x: ep.sx, y: ep.sy }, ...allWps, { x: ep.tx, y: ep.ty }];\n const controls = edge.data.bezierControls;\n const lastSegIdx = allPts.length - 2;\n for (let i = 0; i <= lastSegIdx; i++) {\n const a = allPts[i], b = allPts[i + 1];\n const ctrl = controls?.[i];\n const segDist = Math.hypot(b.x - a.x, b.y - a.y);\n const arm = Math.max(30, segDist * 0.3);\n const c1x = ctrl?.c1x ?? (i === 0 ? a.x + ep.snx * arm : a.x + (b.x - a.x) * 0.4);\n const c1y = ctrl?.c1y ?? (i === 0 ? a.y + ep.sny * arm : a.y);\n const c2x = ctrl?.c2x ?? (i === lastSegIdx ? b.x + ep.tnx * arm : b.x - (b.x - a.x) * 0.4);\n const c2y = ctrl?.c2y ?? (i === lastSegIdx ? b.y + ep.tny * arm : b.y);\n eeGfx.moveTo(a.x, a.y).lineTo(c1x, c1y).stroke({ color: 0x9ca3af, width: 1 * iz });\n eeGfx.moveTo(b.x, b.y).lineTo(c2x, c2y).stroke({ color: 0x9ca3af, width: 1 * iz });\n const cr = 4 * iz;\n eeGfx.circle(c1x, c1y, cr).fill({ color: 0xffffff }).stroke({ color: 0x3b82f6, width: 1.5 * iz });\n eeGfx.circle(c2x, c2y, cr).fill({ color: 0xffffff }).stroke({ color: 0x3b82f6, width: 1.5 * iz });\n }\n }\n }\n }\n }\n\n // Draw transform handles in screen space\n const tg = transformGfxRef.current;\n if (tg) {\n tg.clear();\n if (sel.nodeIds.size === 1 && toolModeRef.current === 'select') {\n const nodeId = [...sel.nodeIds][0];\n const node = cData.nodes.find(n => n.id === nodeId);\n if (node) {\n const z = vp.zoom;\n const sx = node.position.x * z + vp.x;\n const sy = node.position.y * z + vp.y;\n const sw = node.width * z;\n const sh = node.height * z;\n\n tg.rect(sx, sy, sw, sh).stroke({ color: 0x3b82f6, width: 1.5 });\n\n // Corner resize handles (squares)\n const hs = 7, h2 = hs / 2;\n const corners: Array<[number, number]> = [\n [sx, sy], [sx + sw, sy],\n [sx + sw, sy + sh], [sx, sy + sh],\n ];\n for (const [cx, cy] of corners) {\n tg.rect(cx - h2, cy - h2, hs, hs)\n .fill({ color: 0xffffff })\n .stroke({ color: 0x3b82f6, width: 1.5 });\n }\n\n // Midpoint connection handles (circles)\n const cr = 4;\n const midpoints: Array<[number, number]> = [\n [sx + sw / 2, sy], [sx + sw, sy + sh / 2],\n [sx + sw / 2, sy + sh], [sx, sy + sh / 2],\n ];\n for (const [cx, cy] of midpoints) {\n tg.circle(cx, cy, cr)\n .fill({ color: 0x3b82f6, alpha: 0.9 });\n }\n }\n }\n }\n });\n };\n\n waitForReady();\n\n return () => {\n cancelled = true;\n // Remove stage event listeners to prevent duplicates on re-mount\n if (pixi && !pixi.destroyed) {\n try { pixi.app.stage.removeAllListeners(); } catch { /* already destroyed */ }\n }\n gridRef.current?.destroy();\n selectionRef.current?.destroy();\n nodeRendererRef.current?.destroy();\n edgeRendererRef.current?.destroy();\n lineRendererRef.current?.destroy();\n freehandRef.current?.destroy();\n geoLineRef.current?.destroy();\n connectLineRef.current?.destroy();\n if (transformGfxRef.current) { transformGfxRef.current.destroy(); transformGfxRef.current = null; }\n if (handleHoverGfxRef.current) { handleHoverGfxRef.current.destroy(); handleHoverGfxRef.current = null; }\n if (edgeEditGfxRef.current) { edgeEditGfxRef.current.destroy(); edgeEditGfxRef.current = null; }\n if (ghostGfxRef.current) { ghostGfxRef.current.destroy(); ghostGfxRef.current = null; }\n alignGuidesRef.current?.destroy();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [pixiRef.current]);\n\n // Activate/deactivate line tools based on toolMode\n useEffect(() => {\n const freehand = freehandRef.current;\n const geo = geoLineRef.current;\n if (!freehand || !geo) return;\n\n freehand.deactivate();\n geo.deactivate();\n\n switch (toolMode) {\n case 'freehand': freehand.activate(); break;\n case 'line': geo.activate('straight'); break;\n case 'polyline': geo.activate('polyline'); break;\n case 'arrow': geo.activate('arrow'); break;\n }\n }, [toolMode]);\n\n useEffect(() => {\n if (gridRef.current) {\n gridRef.current.visible = showGrid;\n gridRef.current.gridSize = gridSize;\n }\n }, [showGrid, gridSize]);\n\n // Native, non-passive wheel listener: zoom the canvas and preventDefault() so\n // the browser's Ctrl/Cmd+wheel page zoom (and trackpad pinch) never fires.\n // Pixi's federated wheel event cannot reliably block that native gesture.\n useEffect(() => {\n const el = containerRef.current;\n if (!el) return;\n const ZOOM_SENSITIVITY = 0.001;\n const onWheel = (e: WheelEvent) => {\n e.preventDefault();\n const vm = vmRef.current;\n if (!vm) return;\n const rect = el.getBoundingClientRect();\n const sx = e.clientX - rect.left;\n const sy = e.clientY - rect.top;\n // ctrlKey is set for pinch-zoom gestures; scale it up for parity.\n const scale = e.ctrlKey ? 3 : 1;\n const delta = -e.deltaY * ZOOM_SENSITIVITY * scale;\n vm.zoomAt(sx, sy, 1 + delta);\n };\n el.addEventListener('wheel', onWheel, { passive: false });\n return () => el.removeEventListener('wheel', onWheel);\n }, [vmRef]);\n\n return (\n <div style={{ position: 'relative', width: '100%', height: '100%' }}>\n <div\n ref={containerRef}\n className=\"flow-canvas-wrapper\"\n tabIndex={-1}\n onContextMenu={(e) => e.preventDefault()}\n />\n {editing && editorPos && (\n <input\n className=\"flow-label-editor\"\n autoFocus\n defaultValue={editing.value}\n style={{ left: editorPos.x, top: editorPos.y }}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n e.preventDefault();\n commitEdit((e.target as HTMLInputElement).value);\n } else if (e.key === 'Escape') {\n e.preventDefault();\n cancelEdit();\n }\n e.stopPropagation();\n }}\n onBlur={(e) => commitEdit(e.target.value)}\n onPointerDown={(e) => e.stopPropagation()}\n />\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA6BA,IAAM,KAA+C;AAAA,EACnD,IAAI;AAAA,EAAe,IAAI;AAAA,EACvB,IAAI;AAAA,EAAe,IAAI;AACzB;AAEA,SAAS,GACP,GAA8B,GAAgB,GACzB;AACrB,QAAM,EAAE,GAAA,GAAG,GAAA,EAAA,IAAM,EAAK,UAChB,IAAI,EAAK,OAAO,IAAI,EAAK,QACzB,IAA8C;AAAA,IAClD;AAAA,MAAC;AAAA,MAAM;AAAA,MAAG;AAAA,IAAC;AAAA,IAAG;AAAA,MAAC;AAAA,MAAM,IAAI;AAAA,MAAG;AAAA,IAAC;AAAA,IAC7B;AAAA,MAAC;AAAA,MAAM,IAAI;AAAA,MAAG,IAAI;AAAA,IAAC;AAAA,IAAG;AAAA,MAAC;AAAA,MAAM;AAAA,MAAG,IAAI;AAAA,IAAC;AAAA,EACvC;AACA,MAAI,IAA4B,MAAM,IAAQ;AAC9C,aAAW,CAAC,GAAK,IAAI,EAAA,KAAO,GAAM;AAChC,UAAM,IAAI,KAAK,MAAM,EAAG,IAAI,IAAI,EAAG,IAAI,EAAE;AACzC,IAAI,IAAI,MAAS,IAAQ,GAAG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AAU,EAAK,MACtB,IAAK,EAAE,UAAU,EAAK,KAEtB,KAAQ,EAAE,UAAU,IAAI,GACxB,KAAQ,CAAC,EAAE,SAAS,IAAmB;AAC7C,MAAA,EAAG,OAAO,GAAI,GAAI,IAAI,EAAK;AAAA,IAC7B;AACA,WAAA,EAAG,iBAAiB,SAAS,GAAS,EAAE,SAAS,GAAM,CAAC,GACxD,MAAa,EAAG,oBAAoB,SAAS,CAAO;AAAA,EACtD,GAAG,CAAC,CAAK,CAAC,GAGR,gBAAA,GAAC,OAAD;AAAA,IAAK,OAAO;AAAA,MAAE,UAAU;AAAA,MAAY,OAAO;AAAA,MAAQ,QAAQ;AAAA,IAAO;AAAA,cAAlE,CACE,gBAAA,GAAC,OAAD;AAAA,MACE,KAAK;AAAA,MACL,WAAU;AAAA,MACV,UAAU;AAAA,MACV,eAAA,CAAgB,MAAM,EAAE,eAAe;AAAA,IACxC,CAAA,GACA,MAAW,MACV,gBAAA,GAAC,SAAD;AAAA,MACE,WAAU;AAAA,MACV,WAAA;AAAA,MACA,cAAc,GAAQ;AAAA,MACtB,OAAO;AAAA,QAAE,MAAM,GAAU;AAAA,QAAG,KAAK,GAAU;AAAA,MAAE;AAAA,MAC7C,WAAA,CAAY,MAAM;AAChB,QAAI,EAAE,QAAQ,WACZ,EAAE,eAAe,GACjB,GAAY,EAAE,OAA4B,KAAK,KACtC,EAAE,QAAQ,aACnB,EAAE,eAAe,GACjB,GAAW,IAEb,EAAE,gBAAgB;AAAA,MACpB;AAAA,MACA,QAAA,CAAS,MAAM,GAAW,EAAE,OAAO,KAAK;AAAA,MACxC,eAAA,CAAgB,MAAM,EAAE,gBAAgB;AAAA,IACzC,CAAA,CAEA;AAAA;AAET"}
|
|
1
|
+
{"version":3,"file":"FlowCanvas.js","names":[],"sources":["../../../../src/components/pro/Flow/FlowCanvas.tsx"],"sourcesContent":["import React, { useRef, useEffect, useCallback, useState } from 'react';\nimport { FederatedPointerEvent, Graphics } from 'pixi.js';\nimport { usePixiApp } from './hooks/usePixiApp';\nimport { useViewport } from './hooks/useViewport';\nimport { useFlowContext } from './context/FlowContext';\nimport { useFlowUI, type FocusOnRectOptions } from './context/FlowUIContext';\nimport { GridRenderer } from './canvas/GridRenderer';\nimport { SelectionOverlay } from './canvas/SelectionOverlay';\nimport { NodeRenderer } from './nodes/NodeRenderer';\nimport { EdgeRenderer } from './edges/EdgeRenderer';\nimport { LineRenderer } from './lines/LineRenderer';\nimport { FreehandTool } from './lines/FreehandTool';\nimport { GeometricLineTool } from './lines/GeometricLineTool';\nimport { isPointInNode, rectsOverlap, distToSegment, generateId } from './nodes/nodeUtils';\nimport { shapeDrawers } from './nodes/shapes';\nimport { findClosestHandle, findClosestHandleWorld, handleWorldPos, getHandlePositions } from './nodes/NodeHandles';\nimport { buildEdgePath, resolveEdgeEndpoints, linearizeSegments } from './edges/edgePaths';\nimport { computeAlignmentSnap, type AlignGuide } from './hooks/useAlignmentGuides';\nimport { AlignmentGuidesRenderer } from './canvas/AlignmentGuides';\nimport { getDocumentSlides, nextAnimIndex } from './nodes/animAnchors';\nimport type { PixiApp } from './canvas/PixiApp';\nimport type { ViewportState, FlowNode, FlowEdge, FlowLine, FlowBezierControl } from './types';\n\nexport interface FlowCanvasProps {\n onPixiReady?: (pixi: PixiApp) => void;\n}\n\ntype ResizeHandle = 'nw' | 'ne' | 'se' | 'sw';\n\nconst RESIZE_CURSORS: Record<ResizeHandle, string> = {\n nw: 'nwse-resize', ne: 'nesw-resize',\n se: 'nwse-resize', sw: 'nesw-resize',\n};\n\nfunction getResizeHandleAt(\n pt: { x: number; y: number }, node: FlowNode, threshold: number,\n): ResizeHandle | null {\n const { x, y } = node.position;\n const w = node.width, h = node.height;\n const defs: Array<[ResizeHandle, number, number]> = [\n ['nw', x, y], ['ne', x + w, y],\n ['se', x + w, y + h], ['sw', x, y + h],\n ];\n let best: ResizeHandle | null = null, bestD = threshold;\n for (const [pos, hx, hy] of defs) {\n const d = Math.hypot(pt.x - hx, pt.y - hy);\n if (d < bestD) { bestD = d; best = pos; }\n }\n return best;\n}\n\ninterface EdgeEndpointHit {\n edgeId: string;\n end: 'source' | 'target';\n worldX: number;\n worldY: number;\n}\n\nfunction findEdgeEndpointNear(\n wx: number, wy: number,\n edges: FlowEdge[],\n nodeMap: Map<string, FlowNode>,\n threshold: number,\n): EdgeEndpointHit | null {\n let best: EdgeEndpointHit | null = null;\n let bestD = threshold;\n for (const edge of edges) {\n const ep = resolveEdgeEndpoints(edge, nodeMap);\n if (!ep) continue;\n const dSrc = Math.hypot(wx - ep.sx, wy - ep.sy);\n if (dSrc < bestD) { bestD = dSrc; best = { edgeId: edge.id, end: 'source', worldX: ep.sx, worldY: ep.sy }; }\n const dTgt = Math.hypot(wx - ep.tx, wy - ep.ty);\n if (dTgt < bestD) { bestD = dTgt; best = { edgeId: edge.id, end: 'target', worldX: ep.tx, worldY: ep.ty }; }\n }\n return best;\n}\n\ninterface WaypointHit {\n edgeId: string;\n waypointIndex: number;\n wx: number;\n wy: number;\n}\n\ninterface BezierControlHit {\n edgeId: string;\n segmentIndex: number;\n controlEnd: 'c1' | 'c2';\n wx: number;\n wy: number;\n}\n\nfunction findWaypointNear(\n wx: number, wy: number,\n edges: FlowEdge[],\n threshold: number,\n): WaypointHit | null {\n let best: WaypointHit | null = null;\n let bestD = threshold;\n for (const edge of edges) {\n const wps = edge.data.waypoints;\n if (!wps) continue;\n for (let i = 0; i < wps.length; i++) {\n const d = Math.hypot(wx - wps[i].x, wy - wps[i].y);\n if (d < bestD) {\n bestD = d;\n best = { edgeId: edge.id, waypointIndex: i, wx: wps[i].x, wy: wps[i].y };\n }\n }\n }\n return best;\n}\n\nfunction findBezierControlNear(\n wx: number, wy: number,\n edges: FlowEdge[],\n nodeMap: Map<string, FlowNode>,\n threshold: number,\n): BezierControlHit | null {\n let best: BezierControlHit | null = null;\n let bestD = threshold;\n for (const edge of edges) {\n if (edge.type !== 'simplebezier') continue;\n const ep = resolveEdgeEndpoints(edge, nodeMap);\n if (!ep) continue;\n const wps = edge.data.waypoints ?? [];\n const allPts = [{ x: ep.sx, y: ep.sy }, ...wps, { x: ep.tx, y: ep.ty }];\n const ctrls = edge.data.bezierControls;\n const lastIdx = allPts.length - 2;\n for (let i = 0; i <= lastIdx; i++) {\n const a = allPts[i], b = allPts[i + 1];\n const ctrl = ctrls?.[i];\n const segDist = Math.hypot(b.x - a.x, b.y - a.y);\n const arm = Math.max(30, segDist * 0.3);\n const c1x = ctrl?.c1x ?? (i === 0 ? a.x + ep.snx * arm : a.x + (b.x - a.x) * 0.4);\n const c1y = ctrl?.c1y ?? (i === 0 ? a.y + ep.sny * arm : a.y);\n const c2x = ctrl?.c2x ?? (i === lastIdx ? b.x + ep.tnx * arm : b.x - (b.x - a.x) * 0.4);\n const c2y = ctrl?.c2y ?? (i === lastIdx ? b.y + ep.tny * arm : b.y);\n const d1 = Math.hypot(wx - c1x, wy - c1y);\n if (d1 < bestD) { bestD = d1; best = { edgeId: edge.id, segmentIndex: i, controlEnd: 'c1', wx: c1x, wy: c1y }; }\n const d2 = Math.hypot(wx - c2x, wy - c2y);\n if (d2 < bestD) { bestD = d2; best = { edgeId: edge.id, segmentIndex: i, controlEnd: 'c2', wx: c2x, wy: c2y }; }\n }\n }\n return best;\n}\n\nfunction findInsertionIndex(\n wx: number, wy: number,\n edge: FlowEdge,\n nodeMap: Map<string, FlowNode>,\n): number {\n const ep = resolveEdgeEndpoints(edge, nodeMap);\n if (!ep) return 0;\n const wps = edge.data.waypoints ?? [];\n const allPts = [{ x: ep.sx, y: ep.sy }, ...wps, { x: ep.tx, y: ep.ty }];\n let bestD = Infinity, bestI = 0;\n for (let i = 0; i < allPts.length - 1; i++) {\n const d = distToSegment(wx, wy, allPts[i].x, allPts[i].y, allPts[i + 1].x, allPts[i + 1].y);\n if (d < bestD) { bestD = d; bestI = i; }\n }\n return bestI;\n}\n\nfunction applyResize(\n start: { x: number; y: number; w: number; h: number },\n handle: ResizeHandle, dx: number, dy: number, minSize = 24,\n): { x: number; y: number; w: number; h: number } {\n let { x, y, w, h } = { ...start };\n const ml = handle === 'nw' || handle === 'sw';\n const mr = handle === 'ne' || handle === 'se';\n const mt = handle === 'nw' || handle === 'ne';\n const mb = handle === 'sw' || handle === 'se';\n if (ml) { x += dx; w -= dx; }\n if (mr) { w += dx; }\n if (mt) { y += dy; h -= dy; }\n if (mb) { h += dy; }\n if (w < minSize) { if (ml) x = start.x + start.w - minSize; w = minSize; }\n if (h < minSize) { if (mt) y = start.y + start.h - minSize; h = minSize; }\n return { x, y, w, h };\n}\n\nfunction isPointNearEdgePath(\n wx: number, wy: number, edge: FlowEdge,\n nodeMap: Map<string, FlowNode>, threshold: number,\n): boolean {\n const ep = resolveEdgeEndpoints(edge, nodeMap);\n if (!ep) return false;\n const segs = buildEdgePath(edge.type, ep, edge.data.waypoints, edge.data.bezierControls);\n const pts = linearizeSegments(segs);\n for (let i = 0; i < pts.length - 1; i++) {\n if (distToSegment(wx, wy, pts[i].x, pts[i].y, pts[i + 1].x, pts[i + 1].y) < threshold) return true;\n }\n return false;\n}\n\nfunction isPointNearLine(\n wx: number, wy: number, line: FlowLine, threshold: number,\n): boolean {\n const pts = line.points;\n for (let i = 0; i < pts.length - 1; i++) {\n if (distToSegment(wx, wy, pts[i].x, pts[i].y, pts[i + 1].x, pts[i + 1].y) < threshold) return true;\n }\n return false;\n}\n\nexport default function FlowCanvas({ onPixiReady }: FlowCanvasProps) {\n const containerRef = useRef<HTMLDivElement>(null);\n const gridRef = useRef<GridRenderer | null>(null);\n // Latest theme-derived grid dot color; applied to the grid renderer whenever\n // it (re)initializes or the DishUI theme changes. Node/edge colors follow the\n // theme via `theme:*` tokens resolved in the render loop.\n const gridDotColorRef = useRef<number>(0xd1d5db);\n const handleThemeColors = useCallback((colors: { background: number; gridDot: number; nodeFill: string; nodeText: string }) => {\n gridDotColorRef.current = colors.gridDot;\n if (gridRef.current) gridRef.current.dotColor = colors.gridDot;\n }, []);\n const { pixiRef, readyRef } = usePixiApp(containerRef, handleThemeColors);\n const { setViewportInternal, viewportReqRef, viewport: uiViewport, autoFocus, showGrid, showAnchors, gridSize, toolMode, edgeType, focusOnRect, setFocusOnRect, pendingPlacement, setPendingPlacement, setContextMenu, beginNodeDrag, endNodeDrag, presentation, editingNodeId, setEditingNodeId } = useFlowUI();\n const { currentCanvas, selection, setSelection, setDoc, currentCanvasId, pushCanvas, doc: flowDoc } = useFlowContext();\n const selectionRef = useRef<SelectionOverlay | null>(null);\n const nodeRendererRef = useRef<NodeRenderer | null>(null);\n const edgeRendererRef = useRef<EdgeRenderer | null>(null);\n const lineRendererRef = useRef<LineRenderer | null>(null);\n const freehandRef = useRef<FreehandTool | null>(null);\n const geoLineRef = useRef<GeometricLineTool | null>(null);\n const hoveredNodeRef = useRef<string | null>(null);\n const transformGfxRef = useRef<Graphics | null>(null);\n const handleHoverGfxRef = useRef<Graphics | null>(null);\n const alignGuidesRef = useRef<AlignmentGuidesRenderer | null>(null);\n const activeGuidesRef = useRef<AlignGuide[]>([]);\n const hoveredHandleRef = useRef<{ nodeId: string; handleId: string; wx: number; wy: number } | null>(null);\n const hoveredEdgeEndpointRef = useRef<EdgeEndpointHit | null>(null);\n const waypointDragRef = useRef<{\n active: boolean;\n edgeId: string;\n type: 'waypoint' | 'bezierC1' | 'bezierC2';\n index: number;\n } | null>(null);\n const edgeEditGfxRef = useRef<Graphics | null>(null);\n const lastClickRef = useRef<{ time: number; wx: number; wy: number }>({ time: 0, wx: 0, wy: 0 });\n const dblClickRef = useRef<{ time: number; wx: number; wy: number }>({ time: 0, wx: 0, wy: 0 });\n const ghostGfxRef = useRef<Graphics | null>(null);\n const mouseWorldRef = useRef<{ x: number; y: number }>({ x: 0, y: 0 });\n\n const interactiveCanvas = showAnchors || presentation\n ? currentCanvas\n : { ...currentCanvas, nodes: currentCanvas.nodes.filter(node => node.type !== 'animAnchor') };\n const canvasDataRef = useRef(interactiveCanvas);\n canvasDataRef.current = interactiveCanvas;\n const currentCanvasIdRef = useRef(currentCanvasId);\n currentCanvasIdRef.current = currentCanvasId;\n const selectionDataRef = useRef(selection);\n selectionDataRef.current = selection;\n const docRef = useRef(flowDoc);\n docRef.current = flowDoc;\n const toolModeRef = useRef(toolMode);\n toolModeRef.current = toolMode;\n const autoFocusRef = useRef(autoFocus);\n autoFocusRef.current = autoFocus;\n const focusOnRectRef = useRef(focusOnRect);\n focusOnRectRef.current = focusOnRect;\n const edgeTypeRef = useRef(edgeType);\n edgeTypeRef.current = edgeType;\n const showAnchorsRef = useRef(showAnchors);\n showAnchorsRef.current = showAnchors;\n const presentationRef = useRef(presentation);\n presentationRef.current = presentation;\n const pendingPlacementRef = useRef(pendingPlacement);\n pendingPlacementRef.current = pendingPlacement;\n const beginNodeDragRef = useRef(beginNodeDrag);\n beginNodeDragRef.current = beginNodeDrag;\n const endNodeDragRef = useRef(endNodeDrag);\n endNodeDragRef.current = endNodeDrag;\n\n const dragRef = useRef<{\n active: boolean;\n nodeIds: Set<string>;\n lineIds?: Set<string>;\n startWorld: { x: number; y: number };\n nodeStarts: Map<string, { x: number; y: number }>;\n linePointStarts?: Map<string, Array<{ x: number; y: number }>>;\n } | null>(null);\n\n const marqueeRef = useRef<{\n active: boolean;\n startScreen: { x: number; y: number };\n } | null>(null);\n\n const connectRef = useRef<{\n active: boolean;\n sourceNodeId: string;\n sourceHandleId: string;\n } | null>(null);\n const reconnectRef = useRef<{\n active: boolean;\n edgeId: string;\n movingEnd: 'source' | 'target';\n fixedNodeId: string;\n fixedHandleId: string | undefined;\n } | null>(null);\n const connectLineRef = useRef<Graphics | null>(null);\n\n const resizeRef = useRef<{\n active: boolean;\n nodeId: string;\n handle: ResizeHandle;\n startWorld: { x: number; y: number };\n startBounds: { x: number; y: number; w: number; h: number };\n childStarts: Map<string, { x: number; y: number; w: number; h: number }>;\n childLineStarts?: Map<string, Array<{ x: number; y: number }>>;\n } | null>(null);\n\n const lineDragRef = useRef<{\n active: boolean;\n lineIds: Set<string>;\n startWorld: { x: number; y: number };\n pointStarts: Map<string, Array<{ x: number; y: number }>>;\n } | null>(null);\n\n const vmViewportRef = useRef(uiViewport);\n const vpRafRef = useRef(0);\n const handleViewportChange = useCallback((v: ViewportState) => {\n vmViewportRef.current = v;\n if (!vpRafRef.current) {\n vpRafRef.current = requestAnimationFrame(() => {\n vpRafRef.current = 0;\n // VM → React: display-only update. Does NOT request a VM apply, so it\n // can never echo back and cause a feedback loop / jitter.\n setViewportInternal(vmViewportRef.current);\n });\n }\n }, [setViewportInternal]);\n\n const { vmRef, screenToWorld } = useViewport(pixiRef, handleViewportChange);\n const screenToWorldRef = useRef(screenToWorld);\n screenToWorldRef.current = screenToWorld;\n // `editing` holds the target; `editorPos` is the on-screen position (CSS px\n // relative to the canvas container) recomputed each frame so the input\n // tracks pan/zoom.\n const [editing, setEditing] = useState<{ kind: 'node' | 'edge' | 'line'; id: string; value: string } | null>(null);\n const [editorPos, setEditorPos] = useState<{ x: number; y: number } | null>(null);\n const editingRef = useRef(editing);\n editingRef.current = editing;\n\n // Stable trigger used from inside the pixi event handlers.\n const beginEditRef = useRef<(kind: 'node' | 'edge' | 'line', id: string, value: string) => void>(() => {});\n beginEditRef.current = (kind, id, value) => {\n setEditingNodeId(kind === 'node' ? id : null);\n setEditing({ kind, id, value });\n };\n\n const commitEdit = useCallback((value: string) => {\n const target = editingRef.current;\n if (!target) return;\n setDoc(prev => {\n const cid = currentCanvasIdRef.current;\n const canvas = prev.canvases[cid];\n if (!canvas) return prev;\n let next = canvas;\n if (target.kind === 'node') {\n next = { ...canvas, nodes: canvas.nodes.map(n => n.id === target.id ? { ...n, data: { ...n.data, label: value } } : n) };\n } else if (target.kind === 'edge') {\n next = { ...canvas, edges: canvas.edges.map(e => e.id === target.id ? { ...e, data: { ...e.data, labelText: value } } : e) };\n } else {\n // Lines have no label field today; ignore.\n return prev;\n }\n return { ...prev, canvases: { ...prev.canvases, [cid]: next } };\n });\n setEditing(null);\n setEditingNodeId(null);\n setEditorPos(null);\n }, [setDoc, setEditingNodeId]);\n\n const cancelEdit = useCallback(() => {\n setEditing(null);\n setEditingNodeId(null);\n setEditorPos(null);\n }, [setEditingNodeId]);\n\n useEffect(() => {\n if (!editingNodeId || editingRef.current?.id === editingNodeId) return;\n const node = canvasDataRef.current.nodes.find(item => item.id === editingNodeId);\n if (node) beginEditRef.current('node', node.id, node.data.label);\n }, [editingNodeId]);\n\n // Compute the on-screen editor position from the target's world-space center.\n useEffect(() => {\n if (!editing) return;\n const vm = vmRef.current;\n if (!vm) return;\n const canvas = canvasDataRef.current;\n let world: { x: number; y: number } | null = null;\n if (editing.kind === 'node') {\n const n = canvas.nodes.find(nn => nn.id === editing.id);\n if (n) world = { x: n.position.x + n.width / 2, y: n.position.y + n.height / 2 };\n } else if (editing.kind === 'edge') {\n const e = canvas.edges.find(ee => ee.id === editing.id);\n const nodeMap = new Map<string, FlowNode>();\n for (const nn of canvas.nodes) nodeMap.set(nn.id, nn);\n if (e) {\n const ep = resolveEdgeEndpoints(e, nodeMap);\n if (ep) {\n const segs = buildEdgePath(e.type, ep, e.data.waypoints, e.data.bezierControls);\n const pts = linearizeSegments(segs);\n const mid = pts[Math.floor(pts.length / 2)] ?? { x: (ep.sx + ep.tx) / 2, y: (ep.sy + ep.ty) / 2 };\n world = { x: mid.x, y: mid.y };\n }\n }\n }\n if (world) {\n const s = vm.worldToScreen(world.x, world.y);\n setEditorPos({ x: s.x, y: s.y });\n }\n }, [editing, vmRef]);\n\n // Apply EXTERNAL viewport commands (toolbar zoom buttons, minimap, outline\n // panel) → ViewportManager. Only runs when the external request counter\n // changes, so VM→React display updates are never echoed back (no jitter).\n const lastViewportReqRef = useRef(0);\n useEffect(() => {\n if (viewportReqRef.current === lastViewportReqRef.current) return;\n lastViewportReqRef.current = viewportReqRef.current;\n vmViewportRef.current = uiViewport;\n vmRef.current?.setState(uiViewport);\n }, [uiViewport, vmRef, viewportReqRef]);\n\n // Register focusOnRect implementation with ViewportManager\n useEffect(() => {\n setFocusOnRect((wx: number, wy: number, ww: number, wh: number, options?: FocusOnRectOptions) => {\n const vm = vmRef.current;\n const el = containerRef.current;\n if (!vm || !el) return;\n const screenW = el.clientWidth || 800;\n const screenH = el.clientHeight || 600;\n const pad = Math.max(0, options?.padding ?? 60);\n const availableW = Math.max(1, screenW - pad * 2);\n const availableH = Math.max(1, screenH - pad * 2);\n const zoom = options?.preserveZoom\n ? vm.state.zoom\n : Math.min(\n availableW / Math.max(ww, 1),\n availableH / Math.max(wh, 1),\n options?.maxZoom ?? 2,\n );\n const cx = wx + ww / 2;\n const cy = wy + wh / 2;\n const targetX = screenW / 2 - cx * zoom;\n const targetY = screenH / 2 - cy * zoom;\n vm.animateTo({ x: targetX, y: targetY, zoom }, options?.duration ?? 350);\n });\n }, [setFocusOnRect, vmRef]);\n\n const handleLineComplete = useCallback((line: FlowLine) => {\n setDoc(prev => {\n const canvas = prev.canvases[currentCanvasIdRef.current];\n if (!canvas) return prev;\n return {\n ...prev,\n canvases: {\n ...prev.canvases,\n [currentCanvasIdRef.current]: { ...canvas, lines: [...canvas.lines, line] },\n },\n };\n });\n }, [setDoc, currentCanvasId]);\n const handleLineCompleteRef = useRef(handleLineComplete);\n handleLineCompleteRef.current = handleLineComplete;\n\n // Initialize PixiJS subsystems\n useEffect(() => {\n const pixi = pixiRef.current;\n if (!pixi || pixi.destroyed) return;\n\n let cancelled = false;\n const waitForReady = () => {\n if (cancelled) return;\n if (!readyRef.current) { setTimeout(waitForReady, 30); return; }\n\n gridRef.current = new GridRenderer(pixi.app.stage, gridSize, showGrid);\n gridRef.current.dotColor = gridDotColorRef.current;\n selectionRef.current = new SelectionOverlay(pixi.app.stage);\n nodeRendererRef.current = new NodeRenderer(pixi.world);\n edgeRendererRef.current = new EdgeRenderer(pixi.world);\n lineRendererRef.current = new LineRenderer(pixi.world);\n\n const connectLine = new Graphics();\n connectLine.label = 'connect-line';\n connectLine.visible = false;\n pixi.world.addChild(connectLine);\n connectLineRef.current = connectLine;\n\n const transformGfx = new Graphics();\n transformGfx.label = 'transform-handles';\n pixi.app.stage.addChild(transformGfx);\n transformGfxRef.current = transformGfx;\n\n const handleHoverGfx = new Graphics();\n handleHoverGfx.label = 'handle-hover';\n pixi.world.addChild(handleHoverGfx);\n handleHoverGfxRef.current = handleHoverGfx;\n\n const edgeEditGfx = new Graphics();\n edgeEditGfx.label = 'edge-edit-handles';\n pixi.world.addChild(edgeEditGfx);\n edgeEditGfxRef.current = edgeEditGfx;\n\n const ghostGfx = new Graphics();\n ghostGfx.label = 'ghost-placement';\n ghostGfx.alpha = 0.5;\n pixi.world.addChild(ghostGfx);\n ghostGfxRef.current = ghostGfx;\n\n alignGuidesRef.current = new AlignmentGuidesRenderer(pixi.world);\n\n freehandRef.current = new FreehandTool(pixi.app.stage, pixi.world, {\n onLineComplete: (line) => handleLineCompleteRef.current(line),\n screenToWorld: (sx, sy) => screenToWorldRef.current(sx, sy),\n });\n geoLineRef.current = new GeometricLineTool(pixi.app.stage, pixi.world, {\n onLineComplete: (line) => handleLineCompleteRef.current(line),\n screenToWorld: (sx, sy) => screenToWorldRef.current(sx, sy),\n });\n\n onPixiReady?.(pixi);\n const stage = pixi.app.stage;\n\n // ─── POINTER DOWN ───────────────────────────────────────\n stage.on('pointerdown', (e: FederatedPointerEvent) => {\n // Pixi interactions do not move DOM focus automatically. Explicitly\n // focus the canvas host so Mindmap Tab/Enter shortcuts are not handled\n // as focus navigation by a previously focused inspector control.\n containerRef.current?.focus({ preventScroll: true });\n if (vmRef.current?.isPanning || vmRef.current?.isSpaceHeld) return;\n if (e.button !== 0) return;\n const mode = toolModeRef.current;\n if (mode === 'pan') {\n vmRef.current?.startPan(e.global.x, e.global.y);\n return;\n }\n if (mode === 'freehand' || mode === 'line' || mode === 'polyline' || mode === 'arrow') return;\n\n const world = screenToWorldRef.current(e.global.x, e.global.y);\n const nodes = canvasDataRef.current.nodes;\n const edges = canvasDataRef.current.edges;\n const lines = canvasDataRef.current.lines;\n const sel = selectionDataRef.current;\n const additive = e.metaKey || e.ctrlKey || e.shiftKey;\n const zoom = vmRef.current?.state.zoom ?? 1;\n\n // Pending placement has the highest priority: clicking over an existing\n // node still places the new object instead of selecting the object below.\n const pp = pendingPlacementRef.current;\n if (pp) {\n const newId = generateId('node');\n const rawX = world.x - pp.width / 2;\n const rawY = world.y - pp.height / 2;\n const virtual: FlowNode = {\n id: '__ghost__', type: pp.type,\n position: { x: rawX, y: rawY },\n width: pp.width, height: pp.height, data: {} as any,\n };\n const snap = computeAlignmentSnap([virtual], nodes);\n const px = rawX + snap.dx;\n const py = rawY + snap.dy;\n setDoc(prev => {\n const canvas = prev.canvases[currentCanvasIdRef.current];\n if (!canvas) return prev;\n const extraData: Record<string, any> = {};\n if (pp.type === 'animAnchor') extraData.animIndex = nextAnimIndex(prev);\n const highestZ = Math.max(\n 0,\n ...canvas.nodes.map(node => node.zIndex ?? 0),\n ...canvas.lines.map(line => line.zIndex ?? 0),\n );\n return {\n ...prev,\n canvases: { ...prev.canvases, [currentCanvasIdRef.current]: {\n ...canvas,\n nodes: [...canvas.nodes, {\n id: newId,\n type: pp.type,\n position: { x: px, y: py },\n width: pp.width,\n height: pp.height,\n zIndex: highestZ + 1,\n data: { ...pp.data, ...extraData },\n }],\n }},\n };\n });\n setSelection({ nodeIds: new Set([newId]), edgeIds: new Set(), lineIds: new Set() });\n if (autoFocusRef.current) {\n window.setTimeout(() => {\n focusOnRectRef.current(px, py, pp.width, pp.height, {\n padding: 80,\n preserveZoom: true,\n duration: 280,\n });\n }, 0);\n }\n return;\n }\n\n const now = Date.now();\n const lc = lastClickRef.current;\n const isDblClick = now - lc.time < 350 && Math.hypot(world.x - lc.wx, world.y - lc.wy) < 8 / zoom;\n lastClickRef.current = { time: now, wx: world.x, wy: world.y };\n\n // 1) Resize handles (corners only, single-node selection, select mode)\n if (sel.nodeIds.size === 1 && !additive && mode === 'select') {\n const selNode = nodes.find(n => n.id === [...sel.nodeIds][0]);\n if (selNode) {\n const rh = getResizeHandleAt(world, selNode, Math.min(10 / zoom, 16));\n if (rh) {\n const childStarts = new Map<string, { x: number; y: number; w: number; h: number }>();\n const childLineStarts = new Map<string, Array<{ x: number; y: number }>>();\n const isGeoGroup = selNode.type === 'geometryGroup';\n const isAnyGroup = isGeoGroup || selNode.type === 'flowGroup' || selNode.data.isGroup;\n const gx = selNode.position.x, gy = selNode.position.y;\n const gw = selNode.width, gh = selNode.height;\n for (const n of nodes) {\n if (n.id === selNode.id) continue;\n if (n.parentId === selNode.id) {\n childStarts.set(n.id, { x: n.position.x, y: n.position.y, w: n.width, h: n.height });\n } else if (isGeoGroup\n && n.position.x >= gx && n.position.y >= gy\n && n.position.x + n.width <= gx + gw\n && n.position.y + n.height <= gy + gh) {\n childStarts.set(n.id, { x: n.position.x, y: n.position.y, w: n.width, h: n.height });\n }\n }\n if (isAnyGroup) {\n for (const l of canvasDataRef.current.lines) {\n if (l.parentId === selNode.id) {\n childLineStarts.set(l.id, l.points.map(p => ({ ...p })));\n } else if (isGeoGroup && l.points.length > 0 && l.points.every(p =>\n p.x >= gx && p.x <= gx + gw && p.y >= gy && p.y <= gy + gh\n )) {\n childLineStarts.set(l.id, l.points.map(p => ({ ...p })));\n }\n }\n }\n resizeRef.current = {\n active: true, nodeId: selNode.id, handle: rh,\n startWorld: world,\n startBounds: { x: selNode.position.x, y: selNode.position.y, w: selNode.width, h: selNode.height },\n childStarts,\n childLineStarts: childLineStarts.size > 0 ? childLineStarts : undefined,\n };\n return;\n }\n }\n }\n\n // Hit test node — if the hit node is inside a group, redirect to the group\n let hitNode: FlowNode | null = null;\n for (let i = nodes.length - 1; i >= 0; i--) {\n if (isPointInNode(world.x, world.y, nodes[i])) { hitNode = nodes[i]; break; }\n }\n if (hitNode?.parentId) {\n const groupNode = nodes.find(n => n.id === hitNode!.parentId);\n if (groupNode) hitNode = groupNode;\n }\n\n // 2) Connection handle detection (works in both select and connect modes)\n if (hitNode && (mode === 'select' || mode === 'connect')) {\n const handles = getHandlePositions(hitNode.width, hitNode.height);\n const closest = findClosestHandleWorld(\n handles, hitNode,\n world.x, world.y, Math.min(14 / zoom, 20),\n );\n if (closest) {\n connectRef.current = { active: true, sourceNodeId: hitNode.id, sourceHandleId: closest.id };\n return;\n }\n }\n\n // 3) Edge endpoint reconnection — only for SELECTED edges\n if ((mode === 'select' || mode === 'connect') && !additive && sel.edgeIds.size > 0) {\n const nodeMap = new Map<string, FlowNode>();\n for (const n of nodes) nodeMap.set(n.id, n);\n const selectedEdges = edges.filter(ed => sel.edgeIds.has(ed.id));\n const epHit = findEdgeEndpointNear(world.x, world.y, selectedEdges, nodeMap, Math.min(14 / zoom, 20));\n if (epHit) {\n const edge = edges.find(ed => ed.id === epHit.edgeId);\n if (edge) {\n const fixedEnd = epHit.end === 'source' ? 'target' : 'source';\n reconnectRef.current = {\n active: true,\n edgeId: edge.id,\n movingEnd: epHit.end,\n fixedNodeId: fixedEnd === 'source' ? edge.source : edge.target,\n fixedHandleId: fixedEnd === 'source' ? edge.sourceHandle : edge.targetHandle,\n };\n return;\n }\n }\n }\n\n // 3.5) Waypoint / bezier control editing on selected edges\n if (mode === 'select' && sel.edgeIds.size > 0 && !hitNode) {\n const wmNodeMap = new Map<string, FlowNode>();\n for (const n of nodes) wmNodeMap.set(n.id, n);\n const selEdges = edges.filter(ed => sel.edgeIds.has(ed.id));\n const wpThreshold = Math.min(10 / zoom, 14);\n\n const bzHit = findBezierControlNear(world.x, world.y, selEdges, wmNodeMap, wpThreshold);\n if (bzHit) {\n waypointDragRef.current = {\n active: true, edgeId: bzHit.edgeId,\n type: bzHit.controlEnd === 'c1' ? 'bezierC1' : 'bezierC2',\n index: bzHit.segmentIndex,\n };\n return;\n }\n\n const wpHit = findWaypointNear(world.x, world.y, selEdges, wpThreshold);\n if (wpHit) {\n if (isDblClick) {\n setDoc(prev => {\n const canvas = prev.canvases[currentCanvasIdRef.current];\n if (!canvas) return prev;\n return {\n ...prev,\n canvases: { ...prev.canvases, [currentCanvasIdRef.current]: {\n ...canvas,\n edges: canvas.edges.map(e => {\n if (e.id !== wpHit.edgeId) return e;\n const wps = [...(e.data.waypoints ?? [])];\n wps.splice(wpHit.waypointIndex, 1);\n const data = { ...e.data, waypoints: wps.length > 0 ? wps : undefined };\n if (e.type === 'simplebezier' && e.data.bezierControls) {\n const ctrls = [...e.data.bezierControls];\n ctrls.splice(wpHit.waypointIndex, 2, null);\n data.bezierControls = ctrls.some(c => c !== null) ? ctrls : undefined;\n }\n return { ...e, data };\n }),\n }},\n };\n });\n return;\n }\n waypointDragRef.current = { active: true, edgeId: wpHit.edgeId, type: 'waypoint', index: wpHit.waypointIndex };\n return;\n }\n\n if (isDblClick) {\n for (const edge of selEdges) {\n if (isPointNearEdgePath(world.x, world.y, edge, wmNodeMap, Math.min(8 / zoom, 12))) {\n const insertIdx = findInsertionIndex(world.x, world.y, edge, wmNodeMap);\n const newWp = { x: world.x, y: world.y };\n setDoc(prev => {\n const canvas = prev.canvases[currentCanvasIdRef.current];\n if (!canvas) return prev;\n return {\n ...prev,\n canvases: { ...prev.canvases, [currentCanvasIdRef.current]: {\n ...canvas,\n edges: canvas.edges.map(e => {\n if (e.id !== edge.id) return e;\n const wps = [...(e.data.waypoints ?? [])];\n wps.splice(insertIdx, 0, newWp);\n const data = { ...e.data, waypoints: wps };\n if (e.type === 'simplebezier' && e.data.bezierControls) {\n const ctrls = [...e.data.bezierControls];\n while (ctrls.length < (e.data.waypoints ?? []).length + 1) ctrls.push(null);\n ctrls.splice(insertIdx, 1, null, null);\n data.bezierControls = ctrls;\n }\n return { ...e, data };\n }),\n }},\n };\n });\n waypointDragRef.current = { active: true, edgeId: edge.id, type: 'waypoint', index: insertIdx };\n return;\n }\n }\n }\n }\n\n // 4) Node body → select + drag\n if (hitNode && (mode === 'select' || mode === 'connect')) {\n if (!additive && !sel.nodeIds.has(hitNode.id)) {\n setSelection({ nodeIds: new Set([hitNode.id]), edgeIds: new Set(), lineIds: new Set() });\n } else if (additive) {\n setSelection(prev => {\n const ids = new Set(prev.nodeIds);\n if (ids.has(hitNode!.id)) ids.delete(hitNode!.id); else ids.add(hitNode!.id);\n return { nodeIds: ids, edgeIds: new Set(), lineIds: new Set() };\n });\n }\n if (autoFocusRef.current) {\n focusOnRectRef.current(\n hitNode.position.x,\n hitNode.position.y,\n hitNode.width,\n hitNode.height,\n { padding: 80, preserveZoom: true, duration: 280 },\n );\n }\n const dragIds = sel.nodeIds.has(hitNode.id)\n ? new Set(sel.nodeIds)\n : new Set([hitNode.id]);\n if (additive && !sel.nodeIds.has(hitNode.id)) dragIds.add(hitNode.id);\n // Include children of group nodes being dragged\n const dragLineIds = new Set<string>();\n for (const gId of [...dragIds]) {\n const gNode = nodes.find(nd => nd.id === gId);\n if (!gNode || (gNode.type !== 'flowGroup' && gNode.type !== 'geometryGroup' && !gNode.data.isGroup)) continue;\n const isGeo = gNode.type === 'geometryGroup';\n const gx = gNode.position.x, gy = gNode.position.y;\n const gw = gNode.width, gh = gNode.height;\n for (const n of nodes) {\n if (dragIds.has(n.id) || n.id === gId) continue;\n if (n.parentId === gId) { dragIds.add(n.id); continue; }\n if (isGeo\n && n.position.x >= gx && n.position.y >= gy\n && n.position.x + n.width <= gx + gw\n && n.position.y + n.height <= gy + gh) {\n dragIds.add(n.id);\n }\n }\n // Include child lines (by parentId)\n for (const l of canvasDataRef.current.lines) {\n if (l.parentId === gId) dragLineIds.add(l.id);\n }\n // Spatial containment for lines in geometryGroup\n if (isGeo) {\n for (const l of canvasDataRef.current.lines) {\n if (dragLineIds.has(l.id)) continue;\n if (l.points.length > 0 && l.points.every(p =>\n p.x >= gx && p.x <= gx + gw && p.y >= gy && p.y <= gy + gh\n )) {\n dragLineIds.add(l.id);\n }\n }\n }\n }\n const nodeStarts = new Map<string, { x: number; y: number }>();\n for (const n of nodes) { if (dragIds.has(n.id)) nodeStarts.set(n.id, { ...n.position }); }\n const linePointStarts = new Map<string, Array<{ x: number; y: number }>>();\n if (dragLineIds.size > 0) {\n for (const l of canvasDataRef.current.lines) {\n if (dragLineIds.has(l.id)) linePointStarts.set(l.id, l.points.map(p => ({ ...p })));\n }\n }\n dragRef.current = { active: true, nodeIds: dragIds, lineIds: dragLineIds.size > 0 ? dragLineIds : undefined, startWorld: world, nodeStarts, linePointStarts: linePointStarts.size > 0 ? linePointStarts : undefined };\n beginNodeDragRef.current();\n return;\n }\n\n // 5) Edge hit test → select edge\n const nodeMap2 = new Map<string, FlowNode>();\n for (const n of nodes) nodeMap2.set(n.id, n);\n const hitThreshold = Math.min(8 / zoom, 12);\n for (const edge of edges) {\n if (isPointNearEdgePath(world.x, world.y, edge, nodeMap2, hitThreshold)) {\n if (additive) {\n setSelection(prev => {\n const ids = new Set(prev.edgeIds);\n if (ids.has(edge.id)) ids.delete(edge.id); else ids.add(edge.id);\n return { ...prev, edgeIds: ids };\n });\n } else {\n setSelection({ nodeIds: new Set(), edgeIds: new Set([edge.id]), lineIds: new Set() });\n }\n if (autoFocusRef.current) {\n const source = nodeMap2.get(edge.source);\n const target = nodeMap2.get(edge.target);\n if (source && target) {\n const minX = Math.min(source.position.x, target.position.x);\n const minY = Math.min(source.position.y, target.position.y);\n const maxX = Math.max(source.position.x + source.width, target.position.x + target.width);\n const maxY = Math.max(source.position.y + source.height, target.position.y + target.height);\n focusOnRectRef.current(minX, minY, maxX - minX, maxY - minY, {\n padding: 80,\n preserveZoom: true,\n duration: 280,\n });\n }\n }\n return;\n }\n }\n\n // 5) Line hit test → select + drag line\n for (const line of lines) {\n if (isPointNearLine(world.x, world.y, line, hitThreshold)) {\n const alreadySelected = sel.lineIds.has(line.id);\n if (additive) {\n setSelection(prev => {\n const ids = new Set(prev.lineIds);\n if (ids.has(line.id)) ids.delete(line.id); else ids.add(line.id);\n return { ...prev, lineIds: ids };\n });\n } else if (!alreadySelected) {\n setSelection({ nodeIds: new Set(), edgeIds: new Set(), lineIds: new Set([line.id]) });\n }\n if (autoFocusRef.current && line.points.length > 0) {\n const xs = line.points.map(point => point.x);\n const ys = line.points.map(point => point.y);\n const minX = Math.min(...xs);\n const minY = Math.min(...ys);\n const maxX = Math.max(...xs);\n const maxY = Math.max(...ys);\n focusOnRectRef.current(minX, minY, Math.max(1, maxX - minX), Math.max(1, maxY - minY), {\n padding: 80,\n preserveZoom: true,\n duration: 280,\n });\n }\n // Start line drag\n const dragLineIds = alreadySelected ? new Set(sel.lineIds) : new Set([line.id]);\n const pointStarts = new Map<string, Array<{ x: number; y: number }>>();\n for (const l of lines) {\n if (dragLineIds.has(l.id)) pointStarts.set(l.id, l.points.map(p => ({ ...p })));\n }\n lineDragRef.current = { active: true, lineIds: dragLineIds, startWorld: world, pointStarts };\n return;\n }\n }\n\n // 6) Empty space → clear selection, start marquee\n if (!additive) {\n setSelection({ nodeIds: new Set(), edgeIds: new Set(), lineIds: new Set() });\n }\n if (mode === 'select') {\n marqueeRef.current = { active: true, startScreen: { x: e.global.x, y: e.global.y } };\n }\n });\n\n // ─── POINTER MOVE ──────────────────────────────────────\n stage.on('globalpointermove', (e: FederatedPointerEvent) => {\n const world = screenToWorldRef.current(e.global.x, e.global.y);\n mouseWorldRef.current = world;\n\n const mode = toolModeRef.current;\n if (mode === 'freehand' || mode === 'line' || mode === 'polyline' || mode === 'arrow') return;\n\n const nodes = canvasDataRef.current.nodes;\n const edges = canvasDataRef.current.edges;\n const zoom = vmRef.current?.state.zoom ?? 1;\n const isIdle = !dragRef.current?.active && !connectRef.current?.active\n && !resizeRef.current?.active && !reconnectRef.current?.active\n && !waypointDragRef.current?.active && !lineDragRef.current?.active;\n\n // Hover tracking — redirect child hovers to parent group\n let hovered: string | null = null;\n for (let i = nodes.length - 1; i >= 0; i--) {\n if (isPointInNode(world.x, world.y, nodes[i])) {\n const n = nodes[i];\n hovered = n.parentId\n ? (nodes.find(g => g.id === n.parentId)?.id ?? n.id)\n : n.id;\n break;\n }\n }\n hoveredNodeRef.current = hovered;\n\n // Hover detection for connection handles and edge endpoints (when idle)\n if (isIdle && (mode === 'select' || mode === 'connect')) {\n const nodeMap = new Map<string, FlowNode>();\n for (const n of nodes) nodeMap.set(n.id, n);\n\n // Check edge endpoint hover — only for selected edges\n const sel = selectionDataRef.current;\n const selectedEdges = sel.edgeIds.size > 0 ? edges.filter(ed => sel.edgeIds.has(ed.id)) : [];\n const epHit = selectedEdges.length > 0\n ? findEdgeEndpointNear(world.x, world.y, selectedEdges, nodeMap, Math.min(12 / zoom, 18))\n : null;\n hoveredEdgeEndpointRef.current = epHit;\n\n // Check connection handle hover on any node\n let foundHandle: typeof hoveredHandleRef.current = null;\n if (hovered) {\n const node = nodes.find(n => n.id === hovered);\n if (node) {\n const handles = getHandlePositions(node.width, node.height);\n const closest = findClosestHandleWorld(handles, node, world.x, world.y, Math.min(14 / zoom, 20));\n if (closest) {\n const wp = handleWorldPos(closest, node);\n foundHandle = { nodeId: node.id, handleId: closest.id, wx: wp.x, wy: wp.y };\n }\n }\n }\n hoveredHandleRef.current = foundHandle;\n }\n\n // Cursor updates\n const el = containerRef.current;\n if (el && isIdle) {\n const sel = selectionDataRef.current;\n let cursor = '';\n if (hoveredEdgeEndpointRef.current) {\n cursor = 'crosshair';\n } else if (hoveredHandleRef.current) {\n cursor = 'crosshair';\n } else if (sel.edgeIds.size > 0 && mode === 'select') {\n const selEdgesForCursor = edges.filter(ed => sel.edgeIds.has(ed.id));\n const cursorNm = new Map<string, FlowNode>();\n for (const n of nodes) cursorNm.set(n.id, n);\n const wpThreshold = Math.min(10 / zoom, 14);\n if (findWaypointNear(world.x, world.y, selEdgesForCursor, wpThreshold)\n || findBezierControlNear(world.x, world.y, selEdgesForCursor, cursorNm, wpThreshold)) {\n cursor = 'grab';\n }\n }\n if (!cursor && sel.nodeIds.size === 1 && mode === 'select') {\n const selNode = nodes.find(n => n.id === [...sel.nodeIds][0]);\n if (selNode) {\n const rh = getResizeHandleAt(world, selNode, Math.min(10 / zoom, 16));\n if (rh) cursor = RESIZE_CURSORS[rh];\n }\n }\n if (!cursor && mode === 'select') {\n const hoverLines = canvasDataRef.current.lines;\n const lineHitT = Math.min(8 / zoom, 12);\n for (const ln of hoverLines) {\n if (isPointNearLine(world.x, world.y, ln, lineHitT)) {\n cursor = 'move';\n break;\n }\n }\n }\n el.style.cursor = cursor;\n }\n\n // Resize with alignment snapping\n if (resizeRef.current?.active) {\n const r = resizeRef.current;\n const dx = world.x - r.startWorld.x;\n const dy = world.y - r.startWorld.y;\n const nb = applyResize(r.startBounds, r.handle, dx, dy);\n const allNodes = canvasDataRef.current.nodes;\n const virtualNode: FlowNode = { id: r.nodeId, type: 'shapeRect', position: { x: nb.x, y: nb.y }, width: nb.w, height: nb.h, data: {} as any };\n const snap = computeAlignmentSnap([virtualNode], allNodes);\n nb.x += snap.dx; nb.y += snap.dy;\n if (r.handle === 'ne' || r.handle === 'se') nb.w += snap.dx;\n if (r.handle === 'se' || r.handle === 'sw') nb.h += snap.dy;\n activeGuidesRef.current = snap.guides;\n\n const ob = r.startBounds;\n const finalW = Math.max(nb.w, 24);\n const finalH = Math.max(nb.h, 24);\n const scaleX = ob.w > 0 ? finalW / ob.w : 1;\n const scaleY = ob.h > 0 ? finalH / ob.h : 1;\n\n setDoc(prev => {\n const canvas = prev.canvases[currentCanvasIdRef.current];\n if (!canvas) return prev;\n return {\n ...prev,\n canvases: {\n ...prev.canvases,\n [currentCanvasIdRef.current]: {\n ...canvas,\n nodes: canvas.nodes.map(n => {\n if (n.id === r.nodeId) {\n return { ...n, position: { x: nb.x, y: nb.y }, width: finalW, height: finalH };\n }\n const cs = r.childStarts.get(n.id);\n if (cs) {\n return {\n ...n,\n position: {\n x: nb.x + (cs.x - ob.x) * scaleX,\n y: nb.y + (cs.y - ob.y) * scaleY,\n },\n width: Math.max(cs.w * scaleX, 24),\n height: Math.max(cs.h * scaleY, 24),\n };\n }\n return n;\n }),\n lines: r.childLineStarts\n ? canvas.lines.map(l => {\n const pts = r.childLineStarts!.get(l.id);\n if (!pts) return l;\n return {\n ...l,\n points: pts.map(p => ({\n x: nb.x + (p.x - ob.x) * scaleX,\n y: nb.y + (p.y - ob.y) * scaleY,\n })),\n };\n })\n : canvas.lines,\n },\n },\n };\n });\n return;\n }\n\n // Waypoint / bezier control drag\n if (waypointDragRef.current?.active) {\n const wpd = waypointDragRef.current;\n const wpNodes = canvasDataRef.current.nodes;\n const wpNm = new Map<string, FlowNode>();\n for (const nd of wpNodes) wpNm.set(nd.id, nd);\n setDoc(prev => {\n const canvas = prev.canvases[currentCanvasIdRef.current];\n if (!canvas) return prev;\n return {\n ...prev,\n canvases: { ...prev.canvases, [currentCanvasIdRef.current]: {\n ...canvas,\n edges: canvas.edges.map(e => {\n if (e.id !== wpd.edgeId) return e;\n if (wpd.type === 'waypoint') {\n const wps = [...(e.data.waypoints ?? [])];\n if (wpd.index < wps.length) wps[wpd.index] = { x: world.x, y: world.y };\n return { ...e, data: { ...e.data, waypoints: wps } };\n }\n const ep = resolveEdgeEndpoints(e, wpNm);\n if (!ep) return e;\n const allWps = e.data.waypoints ?? [];\n const allPts = [{ x: ep.sx, y: ep.sy }, ...allWps, { x: ep.tx, y: ep.ty }];\n const segCount = allPts.length - 1;\n const ctrls: Array<FlowBezierControl | null> = [...(e.data.bezierControls ?? [])];\n while (ctrls.length < segCount) ctrls.push(null);\n const si = wpd.index;\n if (si >= segCount) return e;\n const a = allPts[si], b = allPts[si + 1];\n const existing = ctrls[si];\n const segDist = Math.hypot(b.x - a.x, b.y - a.y);\n const arm = Math.max(30, segDist * 0.3);\n const lastSegIdx = segCount - 1;\n const defC1x = si === 0 ? a.x + ep.snx * arm : a.x + (b.x - a.x) * 0.4;\n const defC1y = si === 0 ? a.y + ep.sny * arm : a.y;\n const defC2x = si === lastSegIdx ? b.x + ep.tnx * arm : b.x - (b.x - a.x) * 0.4;\n const defC2y = si === lastSegIdx ? b.y + ep.tny * arm : b.y;\n if (wpd.type === 'bezierC1') {\n ctrls[si] = {\n c1x: world.x, c1y: world.y,\n c2x: existing?.c2x ?? defC2x, c2y: existing?.c2y ?? defC2y,\n };\n } else {\n ctrls[si] = {\n c1x: existing?.c1x ?? defC1x, c1y: existing?.c1y ?? defC1y,\n c2x: world.x, c2y: world.y,\n };\n }\n return { ...e, data: { ...e.data, bezierControls: ctrls } };\n }),\n }},\n };\n });\n return;\n }\n\n // Line drag\n if (lineDragRef.current?.active) {\n const ld = lineDragRef.current;\n const dx = world.x - ld.startWorld.x;\n const dy = world.y - ld.startWorld.y;\n setDoc(prev => {\n const canvas = prev.canvases[currentCanvasIdRef.current];\n if (!canvas) return prev;\n return {\n ...prev,\n canvases: { ...prev.canvases, [currentCanvasIdRef.current]: {\n ...canvas,\n lines: canvas.lines.map(l => {\n const starts = ld.pointStarts.get(l.id);\n if (!starts) return l;\n return { ...l, points: starts.map(p => ({ x: p.x + dx, y: p.y + dy })) };\n }),\n }},\n };\n });\n return;\n }\n\n // Node drag with alignment snapping\n if (dragRef.current?.active) {\n const drag = dragRef.current;\n const rawDx = world.x - drag.startWorld.x;\n const rawDy = world.y - drag.startWorld.y;\n const allNodes = canvasDataRef.current.nodes;\n const dragNodes = allNodes\n .filter(n => drag.nodeIds.has(n.id))\n .map(n => {\n const start = drag.nodeStarts.get(n.id)!;\n return { ...n, position: { x: start.x + rawDx, y: start.y + rawDy } };\n });\n const snap = computeAlignmentSnap(dragNodes, allNodes);\n const dx = rawDx + snap.dx;\n const dy = rawDy + snap.dy;\n activeGuidesRef.current = snap.guides;\n setDoc(prev => {\n const canvas = prev.canvases[currentCanvasIdRef.current];\n if (!canvas) return prev;\n return {\n ...prev,\n canvases: {\n ...prev.canvases,\n [currentCanvasIdRef.current]: {\n ...canvas,\n nodes: canvas.nodes.map(n => {\n const start = drag.nodeStarts.get(n.id);\n if (!start) return n;\n return { ...n, position: { x: start.x + dx, y: start.y + dy } };\n }),\n lines: drag.linePointStarts\n ? canvas.lines.map(l => {\n const starts = drag.linePointStarts!.get(l.id);\n if (!starts) return l;\n return { ...l, points: starts.map(p => ({ x: p.x + dx, y: p.y + dy })) };\n })\n : canvas.lines,\n },\n },\n };\n });\n return;\n }\n\n // Marquee\n if (marqueeRef.current?.active && selectionRef.current) {\n const mx = Math.min(marqueeRef.current.startScreen.x, e.global.x);\n const my = Math.min(marqueeRef.current.startScreen.y, e.global.y);\n const mw = Math.abs(e.global.x - marqueeRef.current.startScreen.x);\n const mh = Math.abs(e.global.y - marqueeRef.current.startScreen.y);\n selectionRef.current.showMarquee(mx, my, mw, mh);\n }\n\n // Connect line preview — snaps to nearest handle on target node\n if (connectRef.current?.active && connectLineRef.current) {\n const srcNode = canvasDataRef.current.nodes.find(n => n.id === connectRef.current!.sourceNodeId);\n if (srcNode) {\n const handles = getHandlePositions(srcNode.width, srcNode.height);\n const handle = handles.find(h => h.id === connectRef.current!.sourceHandleId);\n if (handle) {\n const swp = handleWorldPos(handle, srcNode);\n const sx = swp.x;\n const sy = swp.y;\n let ex = world.x, ey = world.y;\n\n // Snap endpoint to closest handle if hovering over a different node\n const hovNode = hoveredNodeRef.current;\n if (hovNode && hovNode !== connectRef.current!.sourceNodeId) {\n const tNode = canvasDataRef.current.nodes.find(n => n.id === hovNode);\n if (tNode) {\n const tHandles = getHandlePositions(tNode.width, tNode.height);\n const snap = findClosestHandleWorld(tHandles, tNode, world.x, world.y, Infinity);\n if (snap) { const wp = handleWorldPos(snap, tNode); ex = wp.x; ey = wp.y; }\n }\n }\n\n const g = connectLineRef.current;\n g.clear();\n g.moveTo(sx, sy).lineTo(ex, ey)\n .stroke({ color: 0x3b82f6, width: 2, alpha: 0.6 });\n g.visible = true;\n }\n }\n }\n\n // Reconnect line preview — snaps to nearest handle on target node\n if (reconnectRef.current?.active && connectLineRef.current && !connectLineRef.current.destroyed) {\n const rc = reconnectRef.current;\n const fixedNode = canvasDataRef.current.nodes.find(n => n.id === rc.fixedNodeId);\n if (fixedNode) {\n const handles = getHandlePositions(fixedNode.width, fixedNode.height);\n const fh = handles.find(h => h.id === rc.fixedHandleId);\n const fwp = fh ? handleWorldPos(fh, fixedNode) : { x: fixedNode.position.x + fixedNode.width / 2, y: fixedNode.position.y + fixedNode.height / 2 };\n const fx = fwp.x, fy = fwp.y;\n let ex = world.x, ey = world.y;\n\n const hovNode = hoveredNodeRef.current;\n if (hovNode && hovNode !== rc.fixedNodeId) {\n const tNode = canvasDataRef.current.nodes.find(n => n.id === hovNode);\n if (tNode) {\n const tHandles = getHandlePositions(tNode.width, tNode.height);\n const snap = findClosestHandleWorld(tHandles, tNode, world.x, world.y, Infinity);\n if (snap) { const wp = handleWorldPos(snap, tNode); ex = wp.x; ey = wp.y; }\n }\n }\n\n const g = connectLineRef.current;\n g.clear();\n g.moveTo(fx, fy).lineTo(ex, ey)\n .stroke({ color: 0xf97316, width: 2, alpha: 0.7 });\n g.visible = true;\n }\n }\n });\n\n // ─── POINTER UP ────────────────────────────────────────\n const cleanupDrag = () => {\n activeGuidesRef.current = [];\n try { alignGuidesRef.current?.clear(); } catch { /* destroyed */ }\n try {\n const cl = connectLineRef.current;\n if (cl && !cl.destroyed) { cl.clear(); cl.visible = false; }\n } catch { /* destroyed */ }\n if (containerRef.current) containerRef.current.style.cursor = '';\n };\n\n stage.on('pointerup', (e: FederatedPointerEvent) => {\n cleanupDrag();\n\n if (waypointDragRef.current?.active) {\n waypointDragRef.current = null;\n return;\n }\n\n if (resizeRef.current?.active) {\n resizeRef.current = null;\n return;\n }\n\n if (lineDragRef.current?.active) {\n lineDragRef.current = null;\n return;\n }\n\n if (dragRef.current?.active) {\n dragRef.current = null;\n endNodeDragRef.current();\n }\n\n if (marqueeRef.current?.active) {\n const start = screenToWorldRef.current(marqueeRef.current.startScreen.x, marqueeRef.current.startScreen.y);\n const end = screenToWorldRef.current(e.global.x, e.global.y);\n const mx = Math.min(start.x, end.x), my = Math.min(start.y, end.y);\n const mw = Math.abs(end.x - start.x), mh = Math.abs(end.y - start.y);\n if (mw > 4 && mh > 4) {\n const hit = canvasDataRef.current.nodes.filter(n =>\n rectsOverlap(mx, my, mw, mh, n.position.x, n.position.y, n.width, n.height),\n );\n const hitLines = canvasDataRef.current.lines.filter(l => {\n if (l.points.length === 0) return false;\n return l.points.every(p => p.x >= mx && p.x <= mx + mw && p.y >= my && p.y <= my + mh);\n });\n setSelection({\n nodeIds: new Set(hit.map(n => n.id)),\n edgeIds: new Set(),\n lineIds: new Set(hitLines.map(l => l.id)),\n });\n }\n marqueeRef.current = null;\n selectionRef.current?.hideMarquee();\n }\n\n // Reconnection completion\n if (reconnectRef.current?.active) {\n const rcEdgeId = reconnectRef.current.edgeId;\n const rcMovingEnd = reconnectRef.current.movingEnd;\n const rcFixedNodeId = reconnectRef.current.fixedNodeId;\n reconnectRef.current = null;\n\n const world = screenToWorldRef.current(e.global.x, e.global.y);\n const nodes = canvasDataRef.current.nodes;\n let targetNode: FlowNode | null = null;\n for (let i = nodes.length - 1; i >= 0; i--) {\n if (isPointInNode(world.x, world.y, nodes[i]) && nodes[i].id !== rcFixedNodeId) {\n targetNode = nodes[i]; break;\n }\n }\n if (targetNode) {\n const tgtId = targetNode.id;\n const handles = getHandlePositions(targetNode.width, targetNode.height);\n const closest = findClosestHandleWorld(handles, targetNode, world.x, world.y, Infinity);\n const tgtHandleId = closest?.id;\n setDoc(prev => {\n const canvas = prev.canvases[currentCanvasIdRef.current];\n if (!canvas) return prev;\n return {\n ...prev,\n canvases: {\n ...prev.canvases,\n [currentCanvasIdRef.current]: {\n ...canvas,\n edges: canvas.edges.map(edge => {\n if (edge.id !== rcEdgeId) return edge;\n if (rcMovingEnd === 'source') {\n return { ...edge, source: tgtId, sourceHandle: tgtHandleId };\n } else {\n return { ...edge, target: tgtId, targetHandle: tgtHandleId };\n }\n }),\n },\n },\n };\n });\n }\n return;\n }\n\n // New connection completion\n if (connectRef.current?.active) {\n const srcNodeId = connectRef.current.sourceNodeId;\n const srcHandleId = connectRef.current.sourceHandleId;\n connectRef.current = null;\n\n const world = screenToWorldRef.current(e.global.x, e.global.y);\n const nodes = canvasDataRef.current.nodes;\n let targetNode: FlowNode | null = null;\n for (let i = nodes.length - 1; i >= 0; i--) {\n if (isPointInNode(world.x, world.y, nodes[i]) && nodes[i].id !== srcNodeId) {\n targetNode = nodes[i]; break;\n }\n }\n if (targetNode) {\n const tgtNodeId = targetNode.id;\n const handles = getHandlePositions(targetNode.width, targetNode.height);\n const closest = findClosestHandleWorld(handles, targetNode, world.x, world.y, Infinity);\n const tgtHandleId = closest?.id;\n const id = `edge_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 6)}`;\n const eType = edgeTypeRef.current;\n setDoc(prev => {\n const canvas = prev.canvases[currentCanvasIdRef.current];\n if (!canvas) return prev;\n if (canvas.edges.some(e =>\n e.source === srcNodeId && e.target === tgtNodeId\n && e.sourceHandle === srcHandleId && e.targetHandle === tgtHandleId\n )) return prev;\n return {\n ...prev,\n canvases: {\n ...prev.canvases,\n [currentCanvasIdRef.current]: {\n ...canvas,\n edges: [...canvas.edges, {\n id,\n source: srcNodeId,\n target: tgtNodeId,\n sourceHandle: srcHandleId,\n targetHandle: tgtHandleId,\n type: eType as any,\n data: { strokeColor: 'theme:base-content', strokeWidth: 2, lineStyle: 'solid' as const, markerEnd: 'arrowclosed' as const },\n }],\n },\n },\n };\n });\n }\n }\n });\n\n stage.on('pointerupoutside', () => {\n cleanupDrag();\n if (dragRef.current?.active) endNodeDragRef.current();\n dragRef.current = null;\n resizeRef.current = null;\n marqueeRef.current = null;\n reconnectRef.current = null;\n connectRef.current = null;\n waypointDragRef.current = null;\n lineDragRef.current = null;\n selectionRef.current?.hideMarquee();\n });\n\n // ─── RIGHT-CLICK CONTEXT MENU ─────────────────────────\n stage.on('rightclick', (e: FederatedPointerEvent) => {\n e.preventDefault?.();\n // If the right button was used to pan (drawio-style right-drag), don't\n // open the context menu — only a stationary right-click should.\n if (vmRef.current?.didRightPan) return;\n const world = screenToWorldRef.current(e.global.x, e.global.y);\n const nodes = canvasDataRef.current.nodes;\n let hitNodeId: string | null = null;\n for (let i = nodes.length - 1; i >= 0; i--) {\n if (isPointInNode(world.x, world.y, nodes[i])) {\n hitNodeId = nodes[i].id;\n break;\n }\n }\n const native = (e as any).nativeEvent as MouseEvent | undefined;\n const cx = native?.clientX ?? e.global.x;\n const cy = native?.clientY ?? e.global.y;\n setContextMenu({ x: cx, y: cy, nodeId: hitNodeId });\n });\n\n // ─── DOUBLE-CLICK → ENTER SUB-CANVAS / EDIT LABEL ────\n stage.on('pointertap', (e: FederatedPointerEvent) => {\n if (e.button !== 0) return;\n const now = Date.now();\n const world = screenToWorldRef.current(e.global.x, e.global.y);\n const last = dblClickRef.current;\n const dx = world.x - last.wx;\n const dy = world.y - last.wy;\n if (now - last.time < 400 && Math.abs(dx) < 10 && Math.abs(dy) < 10) {\n const nodes = canvasDataRef.current.nodes;\n for (let i = nodes.length - 1; i >= 0; i--) {\n if (isPointInNode(world.x, world.y, nodes[i])) {\n const node = nodes[i];\n const childId = node.data.childCanvasId;\n if (childId) {\n pushCanvas(childId);\n dblClickRef.current = { time: 0, wx: 0, wy: 0 };\n return;\n }\n // Double-click a shape → edit its label in place.\n beginEditRef.current('node', node.id, node.data.label ?? '');\n dblClickRef.current = { time: 0, wx: 0, wy: 0 };\n return;\n }\n }\n\n // Double-click an edge → edit its label.\n const edges = canvasDataRef.current.edges;\n const wmNodeMap = new Map<string, FlowNode>();\n for (const n of nodes) wmNodeMap.set(n.id, n);\n const zoom = vmRef.current?.state.zoom ?? 1;\n for (let i = edges.length - 1; i >= 0; i--) {\n if (isPointNearEdgePath(world.x, world.y, edges[i], wmNodeMap, Math.min(8 / zoom, 12))) {\n beginEditRef.current('edge', edges[i].id, edges[i].data.labelText ?? '');\n dblClickRef.current = { time: 0, wx: 0, wy: 0 };\n return;\n }\n }\n }\n dblClickRef.current = { time: now, wx: world.x, wy: world.y };\n });\n\n // ─── RENDER LOOP ───────────────────────────────────\n let wasPanning = false;\n pixi.app.ticker.add((ticker) => {\n if (pixi.destroyed) return;\n const deltaMs = ticker.deltaMS;\n const screen = pixi.app.screen;\n const vp = vmRef.current?.state ?? { x: 0, y: 0, zoom: 1 };\n gridRef.current?.update(vp, screen.width, screen.height);\n\n // Show a grabbing cursor while panning (right-drag / middle / space).\n const panningNow = vmRef.current?.isPanning ?? false;\n if (panningNow !== wasPanning) {\n wasPanning = panningNow;\n if (containerRef.current) {\n containerRef.current.style.cursor = panningNow ? 'grabbing' : '';\n }\n }\n\n const cData = canvasDataRef.current;\n const sel = selectionDataRef.current;\n\n // Global (document-wide) animation-anchor sequence so sub-canvas badges\n // share one order and the presentation can drill in/out consistently.\n const slides = getDocumentSlides(docRef.current);\n const animSeqMap = new Map<string, number>();\n slides.forEach((s, i) => animSeqMap.set(s.node.id, i + 1));\n\n nodeRendererRef.current?.advanceAnimation(deltaMs);\n const activeSlide = presentationRef.current\n ? slides[presentationRef.current.current]\n : undefined;\n nodeRendererRef.current?.sync(cData.nodes, sel.nodeIds, hoveredNodeRef.current, animSeqMap, {\n showAnchors: showAnchorsRef.current,\n presentation: presentationRef.current !== null,\n presentationAnchorId: activeSlide?.node.id,\n presentationAnchorVisible: presentationRef.current?.showAnchor ?? false,\n });\n\n const nodeMap = new Map<string, FlowNode>();\n for (const n of cData.nodes) nodeMap.set(n.id, n);\n edgeRendererRef.current?.advanceAnimation(deltaMs);\n edgeRendererRef.current?.sync(cData.edges, nodeMap, sel.edgeIds, null, {\n presentation: presentationRef.current !== null,\n });\n\n lineRendererRef.current?.advanceAnimation(deltaMs);\n lineRendererRef.current?.sync(cData.lines, sel.lineIds);\n\n // Draw alignment guides in world space\n alignGuidesRef.current?.update(activeGuidesRef.current, screen.width, screen.height, vp);\n\n // Draw connection handle hover indicator (world space)\n const hhGfx = handleHoverGfxRef.current;\n if (hhGfx) {\n hhGfx.clear();\n const hh = hoveredHandleRef.current;\n if (hh) {\n hhGfx.circle(hh.wx, hh.wy, 10)\n .fill({ color: 0x3b82f6, alpha: 0.12 })\n .stroke({ color: 0x3b82f6, width: 1.5, alpha: 0.5 });\n hhGfx.circle(hh.wx, hh.wy, 4)\n .fill({ color: 0x3b82f6, alpha: 0.9 });\n }\n // Edge endpoint hover indicators\n const epHover = hoveredEdgeEndpointRef.current;\n if (epHover && !hh) {\n hhGfx.circle(epHover.worldX, epHover.worldY, 10)\n .fill({ color: 0xf97316, alpha: 0.12 })\n .stroke({ color: 0xf97316, width: 1.5, alpha: 0.5 });\n hhGfx.circle(epHover.worldX, epHover.worldY, 4)\n .fill({ color: 0xf97316, alpha: 0.9 });\n }\n }\n\n // Ghost placement preview — draw actual shape silhouette, with\n // alignment-guide snapping against existing nodes (same as dragging).\n const gGfx = ghostGfxRef.current;\n if (gGfx) {\n gGfx.clear();\n const pp = pendingPlacementRef.current;\n if (pp) {\n const mw = mouseWorldRef.current;\n const rawX = mw.x - pp.width / 2;\n const rawY = mw.y - pp.height / 2;\n const virtual: FlowNode = {\n id: '__ghost__', type: pp.type,\n position: { x: rawX, y: rawY },\n width: pp.width, height: pp.height, data: {} as any,\n };\n const snap = computeAlignmentSnap([virtual], cData.nodes);\n activeGuidesRef.current = snap.guides;\n gGfx.position.set(rawX + snap.dx, rawY + snap.dy);\n const drawFn = shapeDrawers[pp.type] ?? shapeDrawers.shapeRect;\n drawFn(gGfx, {\n width: pp.width, height: pp.height,\n fill: '#3b82f6', stroke: '#3b82f6',\n strokeWidth: 1.5, borderStyle: pp.data.borderStyle,\n });\n } else {\n gGfx.position.set(0, 0);\n // Only clear guides here if nothing else (drag/resize) owns them.\n if (!dragRef.current?.active && !resizeRef.current?.active) {\n activeGuidesRef.current = [];\n }\n }\n }\n\n // Draw edge edit handles (waypoints + bezier controls) in world space\n const eeGfx = edgeEditGfxRef.current;\n if (eeGfx) {\n eeGfx.clear();\n if (sel.edgeIds.size > 0 && toolModeRef.current === 'select') {\n const iz = 1 / vp.zoom;\n for (const edge of cData.edges) {\n if (!sel.edgeIds.has(edge.id)) continue;\n const wps = edge.data.waypoints;\n if (wps) {\n for (const wp of wps) {\n eeGfx.circle(wp.x, wp.y, 5 * iz)\n .fill({ color: 0xffffff })\n .stroke({ color: 0x3b82f6, width: 1.5 * iz });\n }\n }\n if (edge.type === 'simplebezier') {\n const ep = resolveEdgeEndpoints(edge, nodeMap);\n if (!ep) continue;\n const allWps = wps ?? [];\n const allPts = [{ x: ep.sx, y: ep.sy }, ...allWps, { x: ep.tx, y: ep.ty }];\n const controls = edge.data.bezierControls;\n const lastSegIdx = allPts.length - 2;\n for (let i = 0; i <= lastSegIdx; i++) {\n const a = allPts[i], b = allPts[i + 1];\n const ctrl = controls?.[i];\n const segDist = Math.hypot(b.x - a.x, b.y - a.y);\n const arm = Math.max(30, segDist * 0.3);\n const c1x = ctrl?.c1x ?? (i === 0 ? a.x + ep.snx * arm : a.x + (b.x - a.x) * 0.4);\n const c1y = ctrl?.c1y ?? (i === 0 ? a.y + ep.sny * arm : a.y);\n const c2x = ctrl?.c2x ?? (i === lastSegIdx ? b.x + ep.tnx * arm : b.x - (b.x - a.x) * 0.4);\n const c2y = ctrl?.c2y ?? (i === lastSegIdx ? b.y + ep.tny * arm : b.y);\n eeGfx.moveTo(a.x, a.y).lineTo(c1x, c1y).stroke({ color: 0x9ca3af, width: 1 * iz });\n eeGfx.moveTo(b.x, b.y).lineTo(c2x, c2y).stroke({ color: 0x9ca3af, width: 1 * iz });\n const cr = 4 * iz;\n eeGfx.circle(c1x, c1y, cr).fill({ color: 0xffffff }).stroke({ color: 0x3b82f6, width: 1.5 * iz });\n eeGfx.circle(c2x, c2y, cr).fill({ color: 0xffffff }).stroke({ color: 0x3b82f6, width: 1.5 * iz });\n }\n }\n }\n }\n }\n\n // Draw transform handles in screen space\n const tg = transformGfxRef.current;\n if (tg) {\n tg.clear();\n if (sel.nodeIds.size === 1 && toolModeRef.current === 'select') {\n const nodeId = [...sel.nodeIds][0];\n const node = cData.nodes.find(n => n.id === nodeId);\n if (node) {\n const z = vp.zoom;\n const sx = node.position.x * z + vp.x;\n const sy = node.position.y * z + vp.y;\n const sw = node.width * z;\n const sh = node.height * z;\n\n tg.rect(sx, sy, sw, sh).stroke({ color: 0x3b82f6, width: 1.5 });\n\n // Corner resize handles (squares)\n const hs = 7, h2 = hs / 2;\n const corners: Array<[number, number]> = [\n [sx, sy], [sx + sw, sy],\n [sx + sw, sy + sh], [sx, sy + sh],\n ];\n for (const [cx, cy] of corners) {\n tg.rect(cx - h2, cy - h2, hs, hs)\n .fill({ color: 0xffffff })\n .stroke({ color: 0x3b82f6, width: 1.5 });\n }\n\n // Midpoint connection handles (circles)\n const cr = 4;\n const midpoints: Array<[number, number]> = [\n [sx + sw / 2, sy], [sx + sw, sy + sh / 2],\n [sx + sw / 2, sy + sh], [sx, sy + sh / 2],\n ];\n for (const [cx, cy] of midpoints) {\n tg.circle(cx, cy, cr)\n .fill({ color: 0x3b82f6, alpha: 0.9 });\n }\n }\n }\n }\n });\n };\n\n waitForReady();\n\n return () => {\n cancelled = true;\n // Remove stage event listeners to prevent duplicates on re-mount\n if (pixi && !pixi.destroyed) {\n try { pixi.app.stage.removeAllListeners(); } catch { /* already destroyed */ }\n }\n gridRef.current?.destroy();\n selectionRef.current?.destroy();\n nodeRendererRef.current?.destroy();\n edgeRendererRef.current?.destroy();\n lineRendererRef.current?.destroy();\n freehandRef.current?.destroy();\n geoLineRef.current?.destroy();\n connectLineRef.current?.destroy();\n if (transformGfxRef.current) { transformGfxRef.current.destroy(); transformGfxRef.current = null; }\n if (handleHoverGfxRef.current) { handleHoverGfxRef.current.destroy(); handleHoverGfxRef.current = null; }\n if (edgeEditGfxRef.current) { edgeEditGfxRef.current.destroy(); edgeEditGfxRef.current = null; }\n if (ghostGfxRef.current) { ghostGfxRef.current.destroy(); ghostGfxRef.current = null; }\n alignGuidesRef.current?.destroy();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [pixiRef.current]);\n\n // Activate/deactivate line tools based on toolMode\n useEffect(() => {\n const freehand = freehandRef.current;\n const geo = geoLineRef.current;\n if (!freehand || !geo) return;\n\n freehand.deactivate();\n geo.deactivate();\n\n switch (toolMode) {\n case 'freehand': freehand.activate(); break;\n case 'line': geo.activate('straight'); break;\n case 'polyline': geo.activate('polyline'); break;\n case 'arrow': geo.activate('arrow'); break;\n }\n }, [toolMode]);\n\n useEffect(() => {\n if (gridRef.current) {\n gridRef.current.visible = showGrid;\n gridRef.current.gridSize = gridSize;\n }\n }, [showGrid, gridSize]);\n\n // Native, non-passive wheel listener: zoom the canvas and preventDefault() so\n // the browser's Ctrl/Cmd+wheel page zoom (and trackpad pinch) never fires.\n // Pixi's federated wheel event cannot reliably block that native gesture.\n useEffect(() => {\n const el = containerRef.current;\n if (!el) return;\n const ZOOM_SENSITIVITY = 0.001;\n const onWheel = (e: WheelEvent) => {\n e.preventDefault();\n const vm = vmRef.current;\n if (!vm) return;\n const rect = el.getBoundingClientRect();\n const sx = e.clientX - rect.left;\n const sy = e.clientY - rect.top;\n // ctrlKey is set for pinch-zoom gestures; scale it up for parity.\n const scale = e.ctrlKey ? 3 : 1;\n const delta = -e.deltaY * ZOOM_SENSITIVITY * scale;\n vm.zoomAt(sx, sy, 1 + delta);\n };\n el.addEventListener('wheel', onWheel, { passive: false });\n return () => el.removeEventListener('wheel', onWheel);\n }, [vmRef]);\n\n return (\n <div style={{ position: 'relative', width: '100%', height: '100%' }}>\n <div\n ref={containerRef}\n className=\"flow-canvas-wrapper\"\n tabIndex={-1}\n onContextMenu={(e) => e.preventDefault()}\n />\n {editing && editorPos && (\n <input\n className=\"flow-label-editor\"\n autoFocus\n defaultValue={editing.value}\n style={{ left: editorPos.x, top: editorPos.y }}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n e.preventDefault();\n commitEdit((e.target as HTMLInputElement).value);\n } else if (e.key === 'Escape') {\n e.preventDefault();\n cancelEdit();\n }\n e.stopPropagation();\n }}\n onBlur={(e) => commitEdit(e.target.value)}\n onPointerDown={(e) => e.stopPropagation()}\n />\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA6BA,IAAM,KAA+C;AAAA,EACnD,IAAI;AAAA,EAAe,IAAI;AAAA,EACvB,IAAI;AAAA,EA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