@pixerate/editor-svelte 0.5.3 → 0.5.5

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.
@@ -1100,32 +1100,46 @@ function createCanvasExplosion(graph, options = {}) {
1100
1100
  const currentStyle = (edge.style || "").replace(/opacity:\s*[^;]+;?/g, "").trim();
1101
1101
  edge.style = `${currentStyle ? currentStyle + "; " : ""}opacity: ${childOpacity};`;
1102
1102
  });
1103
- graph.setEdges(graph.edges.map((e) => childIdSet.has(e.target) ? { ...e } : e));
1103
+ graph.setEdges([...graph.edges]);
1104
1104
  }
1105
1105
  }
1106
- graph.setNodes(graph.nodes.map((node) => {
1107
- const isTransitioning = transitions.some((t) => t.node.id === node.id);
1108
- return isTransitioning ? { ...node, data: { ...node.data } } : node;
1109
- }));
1106
+ transitions.forEach((t) => {
1107
+ const graphNode = graph.nodes.find((n) => n.id === t.node.id);
1108
+ if (graphNode && graphNode !== t.node) {
1109
+ graphNode.position = { ...t.node.position };
1110
+ graphNode.style = t.node.style;
1111
+ if (t.node.data) {
1112
+ graphNode.data = { ...graphNode.data, ...t.node.data };
1113
+ }
1114
+ }
1115
+ });
1116
+ graph.setNodes([...graph.nodes]);
1110
1117
  },
1111
1118
  onComplete: () => {
1112
- childNodes.forEach((child) => {
1119
+ childNodes.forEach((child, i) => {
1113
1120
  const node = graph.nodes.find((n) => n.id === child.id);
1114
1121
  if (node) {
1122
+ node.position = { ...targetPositions[i] };
1115
1123
  node.style = (node.style || "").replace(/opacity:\s*[^;]+;?/g, "").trim() || void 0;
1116
1124
  if (node.data) {
1117
1125
  node.data.opacity = 1;
1118
1126
  }
1119
1127
  }
1120
1128
  });
1129
+ displacementMap.forEach((targetPos, nodeId) => {
1130
+ const graphNode = graph.nodes.find((n) => n.id === nodeId);
1131
+ if (graphNode) {
1132
+ graphNode.position = { ...targetPos };
1133
+ }
1134
+ });
1121
1135
  edgesToAdd.forEach((edge) => {
1122
1136
  const graphEdge = graph.edges.find((e) => e.id === edge.id);
1123
1137
  if (graphEdge) {
1124
1138
  graphEdge.style = (graphEdge.style || "").replace(/opacity:\s*[^;]+;?/g, "").trim() || void 0;
1125
1139
  }
1126
1140
  });
1127
- graph.setNodes(graph.nodes.map((node) => ({ ...node, data: { ...node.data } })));
1128
- graph.setEdges(graph.edges.map((edge) => ({ ...edge })));
1141
+ graph.setNodes([...graph.nodes]);
1142
+ graph.setEdges([...graph.edges]);
1129
1143
  $5.set(explodedNodeIds, [...$5.get(explodedNodeIds), parentId], true);
1130
1144
  activeAnimationCancel = null;
1131
1145
  options.onSave?.();
@@ -1205,12 +1219,19 @@ function createCanvasExplosion(graph, options = {}) {
1205
1219
  const currentStyle = (edge.style || "").replace(/opacity:\s*[^;]+;?/g, "").trim();
1206
1220
  edge.style = `${currentStyle ? currentStyle + "; " : ""}opacity: ${childOpacity};`;
1207
1221
  });
1208
- graph.setEdges(graph.edges.map((e) => edgeIdSet.has(e.id) ? { ...e } : e));
1222
+ graph.setEdges([...graph.edges]);
1209
1223
  }
1210
- graph.setNodes(graph.nodes.map((node) => {
1211
- const isTransitioning = transitions.some((t) => t.node.id === node.id);
1212
- return isTransitioning ? { ...node, data: { ...node.data } } : node;
1213
- }));
1224
+ transitions.forEach((t) => {
1225
+ const graphNode = graph.nodes.find((n) => n.id === t.node.id);
1226
+ if (graphNode && graphNode !== t.node) {
1227
+ graphNode.position = { ...t.node.position };
1228
+ graphNode.style = t.node.style;
1229
+ if (t.node.data) {
1230
+ graphNode.data = { ...graphNode.data, ...t.node.data };
1231
+ }
1232
+ }
1233
+ });
1234
+ graph.setNodes([...graph.nodes]);
1214
1235
  },
1215
1236
  onComplete: () => {
1216
1237
  graph.removeNodes(activeChildNodes, false);
@@ -1219,6 +1240,13 @@ function createCanvasExplosion(graph, options = {}) {
1219
1240
  if (edgesToRemove.length > 0) {
1220
1241
  graph.removeEdges(edgesToRemove, false);
1221
1242
  }
1243
+ snapshot.displacedNodes.forEach(({ id, originalPosition }) => {
1244
+ const graphNode = graph.nodes.find((n) => n.id === id);
1245
+ if (graphNode) {
1246
+ graphNode.position = { ...originalPosition };
1247
+ }
1248
+ });
1249
+ graph.setNodes([...graph.nodes]);
1222
1250
  snapshots.delete(parentId);
1223
1251
  $5.set(explodedNodeIds, $5.get(explodedNodeIds).filter((id) => id !== parentId), true);
1224
1252
  activeAnimationCancel = null;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/canvas/createCanvasGraph.svelte.ts","../../src/canvas/createCanvasLayout.ts","../../src/canvas/createCanvasClipboard.svelte.ts","../../src/canvas/createCanvasDocking.svelte.ts","../../src/canvas/createCanvasShortcuts.ts","../../src/canvas/createCanvasInteractions.svelte.ts","../../src/canvas/createCanvasTrajectory.ts","../../src/canvas/createCanvasDisplacement.ts","../../src/canvas/createCanvasExplosion.svelte.ts"],"sourcesContent":["import { cubicOut } from \"svelte/easing\";\nexport function calculateGraphDifferences(currentState, baselineState) {\n const currentNodes = currentState.nodes ?? [];\n const currentEdges = currentState.edges ?? [];\n const baselineNodes = baselineState.nodes ?? [];\n const baselineEdges = baselineState.edges ?? [];\n const baselineNodeMap = new Map(baselineNodes.map((n) => [n.id, n]));\n const baselineEdgeMap = new Map(baselineEdges.map((e) => [e.id, e]));\n const currentNodeMap = new Map(currentNodes.map((n) => [n.id, n]));\n const currentEdgeMap = new Map(currentEdges.map((e) => [e.id, e]));\n const removedNodes = baselineNodes.filter((oldNode) => !currentNodeMap.has(oldNode.id));\n const removedEdges = baselineEdges.filter((oldEdge) => !currentEdgeMap.has(oldEdge.id));\n const changedNodes = currentNodes.filter((newNode) => {\n const oldNode = baselineNodeMap.get(newNode.id);\n if (!oldNode) return true;\n return JSON.stringify(newNode) !== JSON.stringify(oldNode);\n });\n const changedEdges = currentEdges.filter((newEdge) => {\n const oldEdge = baselineEdgeMap.get(newEdge.id);\n if (!oldEdge) return true;\n return JSON.stringify(newEdge) !== JSON.stringify(oldEdge);\n });\n return { changedNodes, changedEdges, removedNodes, removedEdges };\n}\nexport function replaceNodeInGraph(nodes, edges, oldNode, newNode, keepEdges = false) {\n const updatedNodes = nodes.map((n) => n.id === oldNode.id ? newNode : n);\n if (!keepEdges) {\n return { nodes: updatedNodes, edges };\n }\n const updatedEdges = edges.map((edge) => {\n if (edge.source === oldNode.id || edge.target === oldNode.id) {\n return {\n ...edge,\n id: crypto.randomUUID(),\n source: edge.source === oldNode.id ? newNode.id : edge.source,\n target: edge.target === oldNode.id ? newNode.id : edge.target\n };\n }\n return edge;\n });\n return {\n nodes: updatedNodes,\n edges: updatedEdges\n };\n}\nexport function createCanvasGraph(options = {}) {\n let nodes = $state.raw(options.initialNodes ?? []);\n let edges = $state.raw(options.initialEdges ?? []);\n function setNodes(newNodes, triggerCallback = true) {\n nodes = newNodes;\n if (triggerCallback) {\n options.onNodesChange?.(nodes);\n }\n }\n function setEdges(newEdges, triggerCallback = true) {\n edges = newEdges;\n if (triggerCallback) {\n options.onEdgesChange?.(edges);\n }\n }\n function animateNodePosition(node, targetPosition, duration = 400, easing = cubicOut) {\n const delay = node.data?.animationDelay ?? 0;\n const startPosition = { ...node.position };\n const startTime = Date.now() + delay;\n function step() {\n const currentTime = Date.now();\n if (currentTime < startTime) {\n if (typeof requestAnimationFrame !== \"undefined\") {\n requestAnimationFrame(step);\n }\n return;\n }\n const progress = Math.min((currentTime - startTime) / duration, 1);\n const eased = easing(progress);\n const currentPos = {\n x: startPosition.x + (targetPosition.x - startPosition.x) * eased,\n y: startPosition.y + (targetPosition.y - startPosition.y) * eased\n };\n const targetNode = nodes.find((n) => n.id === node.id);\n if (targetNode) {\n targetNode.position = currentPos;\n }\n if (progress < 1) {\n if (typeof requestAnimationFrame !== \"undefined\") {\n requestAnimationFrame(step);\n }\n } else {\n setNodes([...nodes]);\n }\n }\n step();\n }\n function addNodeOrNodes(nodeOrNodesToAdd, animateFromPosition, save = true) {\n const toAdd = Array.isArray(nodeOrNodesToAdd) ? nodeOrNodesToAdd : [nodeOrNodesToAdd];\n const existingMap = new Map(nodes.map((n) => [n.id, n]));\n toAdd.forEach((node) => {\n if (!existingMap.has(node.id)) {\n existingMap.set(node.id, node);\n }\n });\n setNodes(Array.from(existingMap.values()));\n if (animateFromPosition) {\n toAdd.forEach((node) => {\n const target = { ...node.position };\n node.position = { ...animateFromPosition };\n animateNodePosition(node, target);\n });\n }\n if (save) options.onSave?.();\n }\n function addEdge(edgeToAdd, save = true) {\n setEdges([...edges, edgeToAdd]);\n if (save) options.onSave?.();\n }\n function addEdges(edgesToAdd, save = true) {\n setEdges([...edges, ...edgesToAdd]);\n if (save) options.onSave?.();\n }\n function removeNodes(nodesToRemove, save = true) {\n const idsToRemove = new Set(nodesToRemove.map((n) => n.id));\n setNodes(nodes.filter((n) => !idsToRemove.has(n.id)));\n if (save) options.onSave?.();\n }\n function removeEdges(edgesToRemove, save = true) {\n const idsToRemove = new Set(edgesToRemove.map((e) => e.id));\n setEdges(edges.filter((e) => !idsToRemove.has(e.id)));\n if (save) options.onSave?.();\n }\n function replaceNode(oldNode, newNode, save = true, keepEdges = false) {\n const result = replaceNodeInGraph(nodes, edges, oldNode, newNode, keepEdges);\n setNodes(result.nodes);\n if (result.edges !== edges) {\n setEdges(result.edges);\n }\n if (save) options.onSave?.();\n }\n function addConnectedNodes(params) {\n const {\n nodesToAdd,\n inboundNodes = [],\n outboundNodes = [],\n animatedEdges = false,\n animateFromPosition,\n inboundEdgeData = {},\n outboundEdgeData = {},\n getEdgeLabel\n } = params;\n const defaultCreateEdge = (sourceId, targetId, opt) => {\n if (options.createEdge) {\n return options.createEdge(sourceId, targetId, opt);\n }\n return {\n id: crypto.randomUUID(),\n type: \"default\",\n source: sourceId,\n target: targetId,\n label: opt?.label ?? \"\",\n animated: opt?.animated ?? false,\n data: opt?.data ?? {}\n };\n };\n nodesToAdd.forEach((addedNode) => {\n addNodeOrNodes(addedNode, animateFromPosition, false);\n inboundNodes.forEach((sourceNode) => {\n const label = getEdgeLabel ? getEdgeLabel(sourceNode, addedNode) : \"\";\n addEdge(\n defaultCreateEdge(sourceNode.id, addedNode.id, {\n label,\n animated: animatedEdges,\n data: inboundEdgeData\n }),\n false\n );\n });\n outboundNodes.forEach((targetNode) => {\n const label = getEdgeLabel ? getEdgeLabel(addedNode, targetNode) : \"\";\n addEdge(\n defaultCreateEdge(addedNode.id, targetNode.id, {\n label,\n animated: animatedEdges,\n data: outboundEdgeData\n }),\n false\n );\n });\n });\n options.onSave?.();\n }\n function getDifferences(baseline) {\n return calculateGraphDifferences({ nodes, edges }, baseline);\n }\n return {\n get nodes() {\n return nodes;\n },\n set nodes(val) {\n setNodes(val);\n },\n get edges() {\n return edges;\n },\n set edges(val) {\n setEdges(val);\n },\n setNodes,\n setEdges,\n addNodeOrNodes,\n addEdge,\n addEdges,\n removeNodes,\n removeEdges,\n replaceNode,\n addConnectedNodes,\n animateNodePosition,\n getDifferences\n };\n}\n","import dagre from '@dagrejs/dagre';\nimport { Position, type XYPosition, type Rect } from '@xyflow/svelte';\nimport type { CanvasNode, CanvasEdge, CanvasLayoutOptions } from './types.js';\n\n/**\n * Calculates upper-left flow coordinate for an element to be centered in the viewport.\n */\nexport function getCenteredNodePosition(\n\twidth = 0,\n\theight = 0,\n\tscreenToFlowPosition: (position: XYPosition) => XYPosition,\n\tscreenDimensions?: { width: number; height: number }\n): XYPosition {\n\tconst rect = screenDimensions ?? (typeof document !== 'undefined'\n\t\t? { width: document.documentElement.clientWidth, height: document.documentElement.clientHeight }\n\t\t: { width: 1920, height: 1080 });\n\n\tconst flowPos = screenToFlowPosition({ x: rect.width / 2, y: rect.height / 2 });\n\treturn {\n\t\tx: flowPos.x - width / 2,\n\t\ty: flowPos.y - height / 2\n\t};\n}\n\n/**\n * Updates positions of nodes so their collective bounding box is centered in the current viewport.\n */\nexport function centerNodes<TNode extends CanvasNode = CanvasNode>(\n\tnodes: TNode[],\n\tscreenToFlowPosition: (position: XYPosition) => XYPosition,\n\tgetNodesBounds: (nodes: TNode[]) => Rect,\n\tscreenDimensions?: { width: number; height: number }\n): TNode[] {\n\tif (nodes.length === 0) {\n\t\treturn [];\n\t}\n\n\tconst bounds = getNodesBounds(nodes);\n\tconst boundingBoxOrigin = { x: bounds.x, y: bounds.y };\n\n\tconst centeredPosition = getCenteredNodePosition(\n\t\tbounds.width,\n\t\tbounds.height,\n\t\tscreenToFlowPosition,\n\t\tscreenDimensions\n\t);\n\n\tconst deltaX = centeredPosition.x - boundingBoxOrigin.x;\n\tconst deltaY = centeredPosition.y - boundingBoxOrigin.y;\n\n\treturn nodes.map((node) => ({\n\t\t...node,\n\t\tposition: {\n\t\t\tx: node.position.x + deltaX,\n\t\t\ty: node.position.y + deltaY\n\t\t}\n\t}));\n}\n\n/**\n * Automatically calculates directed hierarchical layout of nodes and edges using Dagre.\n */\nexport function getLayoutedNodes<\n\tTNode extends CanvasNode = CanvasNode,\n\tTEdge extends CanvasEdge = CanvasEdge\n>(\n\tnodes: TNode[],\n\tedges: TEdge[],\n\tgetNodesBounds: (nodes: TNode[]) => Rect,\n\toptions: CanvasLayoutOptions = {}\n): TNode[] {\n\tif (nodes.length === 0) return [];\n\n\tconst {\n\t\tdirection = 'LR',\n\t\tranksep = 100,\n\t\tnodesep = 25,\n\t\tdefaultNodeWidth = 200,\n\t\tdefaultNodeHeight = 200\n\t} = options;\n\n\tconst isHorizontal = direction === 'LR' || direction === 'RL';\n\tconst bounds = getNodesBounds(nodes);\n\n\tconst dagreGraph = new dagre.graphlib.Graph();\n\tdagreGraph.setDefaultEdgeLabel(() => ({}));\n\tdagreGraph.setGraph({ rankdir: direction, ranksep, nodesep });\n\n\tconst nodeIds = new Set(nodes.map((node) => node.id));\n\n\tnodes.forEach((node) => {\n\t\tconst nodeWidth = node.measured?.width ?? (node as any).width ?? defaultNodeWidth;\n\t\tconst nodeHeight = node.measured?.height ?? (node as any).height ?? defaultNodeHeight;\n\t\tdagreGraph.setNode(node.id, { width: nodeWidth, height: nodeHeight });\n\t});\n\n\tedges.forEach((edge) => {\n\t\tif (nodeIds.has(edge.source) && nodeIds.has(edge.target)) {\n\t\t\tdagreGraph.setEdge(edge.source, edge.target);\n\t\t}\n\t});\n\n\tdagre.layout(dagreGraph);\n\n\treturn nodes.map((node) => {\n\t\tconst nodeWithPosition = dagreGraph.node(node.id);\n\t\tconst nodeWidth = node.measured?.width ?? (node as any).width ?? defaultNodeWidth;\n\t\tconst nodeHeight = node.measured?.height ?? (node as any).height ?? defaultNodeHeight;\n\n\t\treturn {\n\t\t\t...node,\n\t\t\ttargetPosition: isHorizontal ? Position.Left : Position.Top,\n\t\t\tsourcePosition: isHorizontal ? Position.Right : Position.Bottom,\n\t\t\tposition: {\n\t\t\t\tx: bounds.x + (nodeWithPosition?.x ?? 0) - nodeWidth / 2,\n\t\t\t\ty: bounds.y + (nodeWithPosition?.y ?? 0) - nodeHeight / 2\n\t\t\t}\n\t\t};\n\t});\n}\n","import { tick } from \"svelte\";\nexport function isEventFromTextInput(event) {\n const target = event.target;\n if (!target) return false;\n if (target.tagName === \"INPUT\" || target.tagName === \"TEXTAREA\" || target.tagName === \"SELECT\" || target.isContentEditable || target.closest?.('[contenteditable=\"true\"]') || target.closest?.(\".ProseMirror\")) {\n return true;\n }\n return false;\n}\nexport function isValidCanvasNode(obj) {\n return typeof obj === \"object\" && obj !== null && \"id\" in obj && typeof obj.id === \"string\" && \"position\" in obj && typeof obj.position === \"object\" && obj.position !== null && \"x\" in obj.position && \"y\" in obj.position;\n}\nexport function isValidUrl(url) {\n try {\n const parsed = new URL(url);\n return parsed.protocol === \"http:\" || parsed.protocol === \"https:\";\n } catch {\n return false;\n }\n}\nexport function createCanvasClipboard(options = {}) {\n function copySelectedNodes(selectedNodes, connectedEdges, event) {\n if (event && isEventFromTextInput(event)) {\n return false;\n }\n if (selectedNodes.length === 0) return false;\n const payload = {\n version: 1,\n nodes: selectedNodes,\n edges: connectedEdges\n };\n const serialized = JSON.stringify(payload);\n if (event?.clipboardData) {\n event.clipboardData.setData(\"application/json\", serialized);\n event.clipboardData.setData(\"text/plain\", serialized);\n event.preventDefault();\n } else if (typeof navigator !== \"undefined\" && navigator.clipboard) {\n navigator.clipboard.writeText(serialized).catch(() => {\n });\n }\n return true;\n }\n function cutSelectedNodes(selectedNodes, connectedEdges, onRemove, event) {\n if (event && isEventFromTextInput(event)) {\n return false;\n }\n const copied = copySelectedNodes(selectedNodes, connectedEdges, event);\n if (copied && onRemove) {\n onRemove(selectedNodes);\n }\n return copied;\n }\n async function handlePasteEvent(event) {\n if (isEventFromTextInput(event)) {\n return false;\n }\n const clipboardData = event.clipboardData;\n if (!clipboardData) return false;\n const files = clipboardData.files;\n if (files && files.length > 0) {\n const imageFile = Array.from(files).find((f) => f.type.startsWith(\"image/\"));\n if (imageFile && options.onPasteImage) {\n event.preventDefault();\n await options.onPasteImage(imageFile);\n return true;\n }\n }\n const rawJson = clipboardData.getData(\"application/json\") || clipboardData.getData(\"text/plain\");\n if (rawJson) {\n try {\n const parsed = JSON.parse(rawJson);\n let rawNodes;\n let rawEdges;\n if (Array.isArray(parsed) && parsed.every(isValidCanvasNode)) {\n rawNodes = parsed;\n } else if (typeof parsed === \"object\" && parsed !== null && Array.isArray(parsed.nodes) && parsed.nodes.every(isValidCanvasNode)) {\n rawNodes = parsed.nodes;\n rawEdges = parsed.edges;\n }\n if (rawNodes && rawNodes.length > 0) {\n event.preventDefault();\n const idMap = /* @__PURE__ */ new Map();\n const newNodes = rawNodes.map((node) => {\n const newId = crypto.randomUUID();\n idMap.set(node.id, newId);\n return {\n ...node,\n id: newId,\n selected: true,\n position: {\n x: node.position.x + 40,\n y: node.position.y + 40\n }\n };\n });\n const newEdges = rawEdges?.map((edge) => ({\n ...edge,\n id: crypto.randomUUID(),\n source: idMap.get(edge.source) ?? edge.source,\n target: idMap.get(edge.target) ?? edge.target\n }));\n if (options.onPasteNodes) {\n await options.onPasteNodes(newNodes, newEdges);\n await tick();\n }\n return true;\n }\n } catch {\n }\n }\n const text = clipboardData.getData(\"text/plain\")?.trim();\n if (text) {\n if (isValidUrl(text) && options.onPasteUrl) {\n event.preventDefault();\n options.onPasteUrl(text);\n return true;\n } else if (options.onPasteText) {\n event.preventDefault();\n options.onPasteText(text);\n return true;\n }\n }\n return false;\n }\n return {\n copySelectedNodes,\n cutSelectedNodes,\n handlePasteEvent\n };\n}\n","export function createCanvasDocking(options = {}) {\n let draggedNode = $state.raw(null);\n let draggedInitialPosition = $state.raw(null);\n let connectingHandle = $state.raw(\"\");\n let connectingNode = $state.raw(null);\n let currentHoverTargets = $state.raw(/* @__PURE__ */ new Set());\n const isDockTarget = options.isDockTarget ?? ((target) => target.type === \"boardNode\");\n function handleNodeDragStart(params) {\n draggedNode = params.targetNode;\n draggedInitialPosition = params.targetNode?.position ? { ...params.targetNode.position } : null;\n currentHoverTargets = /* @__PURE__ */ new Set();\n }\n function handleNodeDrag(params, getIntersectingNodes) {\n draggedNode = params.targetNode;\n if (!draggedNode) return;\n const intersecting = getIntersectingNodes(draggedNode);\n const currentDockTargets = intersecting.filter(isDockTarget);\n const newHoverSet = new Set(currentDockTargets.map((t) => t.id));\n currentHoverTargets.forEach((targetId) => {\n if (!newHoverSet.has(targetId)) {\n const leftNode = intersecting.find((n) => n.id === targetId) ?? { id: targetId };\n options.onDockLeave?.(leftNode, draggedNode);\n }\n });\n currentDockTargets.forEach((target) => {\n if (!currentHoverTargets.has(target.id)) {\n options.onDockHover?.(target, draggedNode);\n }\n });\n currentHoverTargets = newHoverSet;\n }\n function handleNodeDragStop(params, getIntersectingNodes, updateNodePosition) {\n draggedNode = params.targetNode;\n if (draggedNode) {\n const intersecting = getIntersectingNodes(draggedNode);\n const dockTarget = intersecting.find(isDockTarget);\n if (dockTarget) {\n options.onDockDrop?.(dockTarget, draggedNode);\n if (options.restorePositionOnDock !== false && draggedInitialPosition && updateNodePosition) {\n updateNodePosition(draggedNode.id, draggedInitialPosition);\n }\n }\n }\n draggedNode = null;\n draggedInitialPosition = null;\n currentHoverTargets = /* @__PURE__ */ new Set();\n options.onSave?.();\n }\n function handleConnectStart(params, getNode) {\n connectingHandle = params.handleType ?? \"\";\n connectingNode = params.nodeId ? getNode(params.nodeId) ?? null : null;\n }\n function handleConnectEnd() {\n connectingHandle = \"\";\n connectingNode = null;\n }\n function reset() {\n draggedNode = null;\n draggedInitialPosition = null;\n connectingHandle = \"\";\n connectingNode = null;\n currentHoverTargets = /* @__PURE__ */ new Set();\n }\n return {\n get draggedNode() {\n return draggedNode;\n },\n get draggedInitialPosition() {\n return draggedInitialPosition;\n },\n get connectingHandle() {\n return connectingHandle;\n },\n get connectingNode() {\n return connectingNode;\n },\n get isDragging() {\n return draggedNode !== null;\n },\n handleNodeDragStart,\n handleNodeDrag,\n handleNodeDragStop,\n handleConnectStart,\n handleConnectEnd,\n reset\n };\n}\n","import { isEventFromTextInput } from './createCanvasClipboard.svelte.js';\nimport type { CanvasNode, CanvasShortcutsOptions } from './types.js';\n\n/**\n * Attaches keyboard shortcut handlers for canvas interaction.\n * Automatically ignores shortcuts when the user is typing into text inputs, textareas, or rich editors.\n *\n * @returns A cleanup function to remove event listeners.\n */\nexport function createCanvasShortcuts<TNode extends CanvasNode = CanvasNode>(\n\toptions: CanvasShortcutsOptions<TNode>\n): () => void {\n\tconst target = options.targetElement ?? (typeof window !== 'undefined' ? window : null);\n\tif (!target) return () => {};\n\n\tfunction handleKeyDown(event: Event) {\n\t\tconst keyboardEvent = event as KeyboardEvent;\n\t\tif (isEventFromTextInput(keyboardEvent)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst isMod = keyboardEvent.metaKey || keyboardEvent.ctrlKey;\n\t\tconst isShift = keyboardEvent.shiftKey;\n\t\tconst key = keyboardEvent.key;\n\n\t\tconst selectedNodes = options.getSelectedNodes ? options.getSelectedNodes() : [];\n\n\t\tif (key === 'Backspace' || key === 'Delete') {\n\t\t\tif (options.onDelete && selectedNodes.length > 0) {\n\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\toptions.onDelete(selectedNodes);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (isMod) {\n\t\t\tconst lowerKey = key.toLowerCase();\n\n\t\t\tif (lowerKey === 'c' && !isShift) {\n\t\t\t\tif (options.onCopy) {\n\t\t\t\t\t// We let the native copy event fire or call onCopy\n\t\t\t\t\toptions.onCopy();\n\t\t\t\t}\n\t\t\t} else if (lowerKey === 'x' && !isShift) {\n\t\t\t\tif (options.onCut) {\n\t\t\t\t\toptions.onCut();\n\t\t\t\t}\n\t\t\t} else if (lowerKey === 'd' && !isShift) {\n\t\t\t\tif (options.onDuplicate && selectedNodes.length > 0) {\n\t\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\t\toptions.onDuplicate(selectedNodes);\n\t\t\t\t}\n\t\t\t} else if (lowerKey === 'a' && !isShift) {\n\t\t\t\tif (options.onSelectAll) {\n\t\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\t\toptions.onSelectAll();\n\t\t\t\t}\n\t\t\t} else if (lowerKey === 'g') {\n\t\t\t\tif (isShift) {\n\t\t\t\t\tif (options.onUngroup && selectedNodes.length > 0) {\n\t\t\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\t\t\toptions.onUngroup(selectedNodes);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (options.onGroup && selectedNodes.length > 0) {\n\t\t\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\t\t\toptions.onGroup(selectedNodes);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (key === '=' || key === '+') {\n\t\t\t\tif (options.onZoomIn) {\n\t\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\t\toptions.onZoomIn();\n\t\t\t\t}\n\t\t\t} else if (key === '-') {\n\t\t\t\tif (options.onZoomOut) {\n\t\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\t\toptions.onZoomOut();\n\t\t\t\t}\n\t\t\t} else if (key === '0') {\n\t\t\t\tif (options.onFitView) {\n\t\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\t\toptions.onFitView();\n\t\t\t\t}\n\t\t\t} else if (lowerKey === 'f') {\n\t\t\t\tif (options.onSearch) {\n\t\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\t\toptions.onSearch();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\ttarget.addEventListener('keydown', handleKeyDown as EventListener);\n\n\treturn () => {\n\t\ttarget.removeEventListener('keydown', handleKeyDown as EventListener);\n\t};\n}\n","import { isEventFromTextInput } from \"./createCanvasClipboard.svelte.js\";\nexport function createCanvasInteractions(options = {}) {\n let isSpacebarPanning = $state.raw(false);\n let trackpadDetected = $state.raw(false);\n let toggledPanMode = false;\n function handleKeyDown(event) {\n if (event.key === \" \" || event.code === \"Space\") {\n if (isSpacebarPanning || isEventFromTextInput(event)) return;\n isSpacebarPanning = true;\n toggledPanMode = true;\n options.onPanModeChange?.(true);\n if (typeof document !== \"undefined\") {\n document.body.classList.add(\"cursor-grab\");\n }\n }\n }\n function handleKeyUp(event) {\n if (event.key === \" \" || event.code === \"Space\") {\n if (!isSpacebarPanning && !toggledPanMode) return;\n isSpacebarPanning = false;\n toggledPanMode = false;\n options.onPanModeChange?.(false);\n if (typeof document !== \"undefined\") {\n document.body.classList.remove(\"cursor-grab\");\n }\n }\n }\n function handleWheel(event) {\n if (event.ctrlKey && !trackpadDetected) {\n trackpadDetected = true;\n options.onTrackpadDetected?.();\n }\n }\n function attachListeners(target) {\n const el = target ?? options.targetElement ?? (typeof window !== \"undefined\" ? window : null);\n if (!el) return () => {\n };\n el.addEventListener(\"keydown\", handleKeyDown);\n el.addEventListener(\"keyup\", handleKeyUp);\n el.addEventListener(\"wheel\", handleWheel, { passive: true });\n return () => {\n el.removeEventListener(\"keydown\", handleKeyDown);\n el.removeEventListener(\"keyup\", handleKeyUp);\n el.removeEventListener(\"wheel\", handleWheel);\n if (typeof document !== \"undefined\") {\n document.body.classList.remove(\"cursor-grab\");\n }\n };\n }\n return {\n get isSpacebarPanning() {\n return isSpacebarPanning;\n },\n get trackpadDetected() {\n return trackpadDetected;\n },\n attachListeners,\n destroy: attachListeners()\n };\n}\nexport const defaultSvelteFlowPreset = {\n snapGrid: [25, 25],\n panOnDrag: [0, 1, 2, 3, 4],\n panOnScroll: false,\n selectionOnDrag: false,\n colorMode: \"system\",\n multiSelectionKey: [\"Shift\", \"Meta\"]\n};\nexport const miroCompatiblePreset = {\n ...defaultSvelteFlowPreset,\n panOnDrag: [1, 2],\n selectionOnDrag: true\n};\nexport function restorePanelPointerEvents(panelSelector = \".svelte-flow__panel\") {\n if (typeof document === \"undefined\") return;\n const panels = document.querySelectorAll(panelSelector);\n panels.forEach((panel) => {\n panel.style.pointerEvents = \"auto\";\n });\n}\n","import { cubicOut } from 'svelte/easing';\nimport type { XYPosition } from '@xyflow/svelte';\nimport type {\n\tCanvasNode,\n\tFanOutTrajectoryOptions,\n\tNodeTransition,\n\tTrajectoryFunction,\n\tTrajectoryPoint\n} from './types.js';\n\n/**\n * Standard linear trajectory: straight line interpolation with linear scale & opacity progression.\n */\nexport const linearTrajectory: TrajectoryFunction = (\n\torigin: XYPosition,\n\ttarget: XYPosition,\n\tprogress: number\n): TrajectoryPoint => {\n\treturn {\n\t\tposition: {\n\t\t\tx: origin.x + (target.x - origin.x) * progress,\n\t\t\ty: origin.y + (target.y - origin.y) * progress\n\t\t},\n\t\tscale: progress,\n\t\topacity: Math.min(1, progress * 1.5)\n\t};\n};\n\n/**\n * Linear position trajectory: pure position interpolation without altering scale or opacity.\n * Used for displaced sibling nodes to ensure their visibility remains unaltered.\n */\nexport const linearPositionTrajectory: TrajectoryFunction = (\n\torigin: XYPosition,\n\ttarget: XYPosition,\n\tprogress: number\n): TrajectoryPoint => {\n\treturn {\n\t\tposition: {\n\t\t\tx: origin.x + (target.x - origin.x) * progress,\n\t\t\ty: origin.y + (target.y - origin.y) * progress\n\t\t}\n\t};\n};\n\n/**\n * Creates a fan-out trajectory where nodes arc outward from origin to target.\n * Matches the curved distribution shown in multi-node branching diagrams.\n */\nexport function createFanOutTrajectory(options: FanOutTrajectoryOptions = {}): TrajectoryFunction {\n\tconst {\n\t\tcurvature = 0.4,\n\t\tstartScale = 0,\n\t\tendScale = 1,\n\t\tstartOpacity = 0,\n\t\tendOpacity = 1\n\t} = options;\n\n\treturn (\n\t\torigin: XYPosition,\n\t\ttarget: XYPosition,\n\t\tprogress: number,\n\t\tindex: number,\n\t\ttotal: number\n\t): TrajectoryPoint => {\n\t\tconst dx = target.x - origin.x;\n\t\tconst dy = target.y - origin.y;\n\n\t\t// Normalized index from -1 (top) to +1 (bottom)\n\t\tconst normIndex = total > 1 ? (index - (total - 1) / 2) / ((total - 1) / 2) : 0;\n\n\t\t// Perpendicular control point offset to create smooth fan arc\n\t\tconst midX = origin.x + dx * 0.4;\n\t\tconst midY = origin.y + dy * 0.1 - normIndex * Math.abs(dx) * 0.15 * curvature;\n\n\t\t// Quadratic Bezier interpolation: B(t) = (1-t)^2 * P0 + 2(1-t)t * P1 + t^2 * P2\n\t\tconst t = progress;\n\t\tconst oneMinusT = 1 - t;\n\n\t\tconst x = oneMinusT * oneMinusT * origin.x + 2 * oneMinusT * t * midX + t * t * target.x;\n\t\tconst y = oneMinusT * oneMinusT * origin.y + 2 * oneMinusT * t * midY + t * t * target.y;\n\n\t\tconst scale = startScale + (endScale - startScale) * progress;\n\t\tconst opacity = startOpacity + (endOpacity - startOpacity) * progress;\n\n\t\treturn {\n\t\t\tposition: { x, y },\n\t\t\tscale,\n\t\t\topacity\n\t\t};\n\t};\n}\n\n/**\n * Creates a custom quadratic Bezier trajectory with a specified or dynamically calculated control point.\n */\nexport function createBezierTrajectory(\n\tgetControlPoint: (origin: XYPosition, target: XYPosition) => XYPosition\n): TrajectoryFunction {\n\treturn (origin: XYPosition, target: XYPosition, progress: number): TrajectoryPoint => {\n\t\tconst cp = getControlPoint(origin, target);\n\t\tconst t = progress;\n\t\tconst oneMinusT = 1 - t;\n\n\t\tconst x = oneMinusT * oneMinusT * origin.x + 2 * oneMinusT * t * cp.x + t * t * target.x;\n\t\tconst y = oneMinusT * oneMinusT * origin.y + 2 * oneMinusT * t * cp.y + t * t * target.y;\n\n\t\treturn {\n\t\t\tposition: { x, y },\n\t\t\tscale: progress,\n\t\t\topacity: progress\n\t\t};\n\t};\n}\n\n/**\n * Coordinates and animates multiple node transitions simultaneously with zero per-frame array allocations.\n * Directly mutates node positions and data (scale, opacity) in-place during the animation loop.\n */\nexport function runMultiNodeTransition<TNode extends CanvasNode = CanvasNode>(\n\ttransitions: NodeTransition<TNode>[],\n\toptions: {\n\t\tdefaultDuration?: number;\n\t\tdefaultEasing?: (t: number) => number;\n\t\tonUpdate?: () => void;\n\t\tonComplete?: () => void;\n\t} = {}\n): () => void {\n\tif (transitions.length === 0) {\n\t\toptions.onComplete?.();\n\t\treturn () => {};\n\t}\n\n\tconst { defaultDuration = 400, defaultEasing = cubicOut, onUpdate, onComplete } = options;\n\n\tlet isCancelled = false;\n\tconst startTime = Date.now();\n\n\tconst items = transitions.map((tr, i) => ({\n\t\t...tr,\n\t\tindex: tr.index ?? i,\n\t\ttotal: tr.total ?? transitions.length,\n\t\tduration: tr.duration ?? defaultDuration,\n\t\teasing: tr.easing ?? defaultEasing,\n\t\tdelay: tr.delay ?? 0,\n\t\ttrajectory: tr.trajectory ?? linearTrajectory\n\t}));\n\n\tfunction frame() {\n\t\tif (isCancelled) return;\n\n\t\tconst now = Date.now();\n\t\tlet allCompleted = true;\n\n\t\tfor (let i = 0; i < items.length; i++) {\n\t\t\tconst item = items[i];\n\t\t\tconst elapsed = now - (startTime + item.delay);\n\n\t\t\tif (elapsed < 0) {\n\t\t\t\tallCompleted = false;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst rawProgress = item.duration <= 0 ? 1 : Math.min(elapsed / item.duration, 1);\n\t\t\tconst progress = item.duration <= 0 ? 1 : item.easing(rawProgress);\n\n\t\t\tconst point = item.trajectory(item.from, item.to, progress, item.index, item.total);\n\n\t\t\t// Direct in-place mutation avoids array reconstruction during RAF\n\t\t\titem.node.position = { ...point.position };\n\n\t\t\tif (point.scale !== undefined || point.opacity !== undefined) {\n\t\t\t\tif (!item.node.data) {\n\t\t\t\t\titem.node.data = {} as any;\n\t\t\t\t}\n\t\t\t\tif (point.scale !== undefined) {\n\t\t\t\t\t(item.node.data as any).scale = point.scale;\n\t\t\t\t}\n\t\t\t\tif (point.opacity !== undefined) {\n\t\t\t\t\t(item.node.data as any).opacity = point.opacity;\n\t\t\t\t\tconst currentStyle = (item.node.style || '').replace(/opacity:\\s*[^;]+;?/g, '').trim();\n\t\t\t\t\titem.node.style = `${currentStyle ? currentStyle + '; ' : ''}opacity: ${point.opacity};`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (rawProgress < 1) {\n\t\t\t\tallCompleted = false;\n\t\t\t}\n\t\t}\n\n\t\tonUpdate?.();\n\n\t\tif (!allCompleted) {\n\t\t\tif (typeof requestAnimationFrame !== 'undefined') {\n\t\t\t\trequestAnimationFrame(frame);\n\t\t\t}\n\t\t} else {\n\t\t\tonComplete?.();\n\t\t}\n\t}\n\n\tframe();\n\n\treturn () => {\n\t\tisCancelled = true;\n\t};\n}\n","import dagre from '@dagrejs/dagre';\nimport type { Rect, XYPosition } from '@xyflow/svelte';\nimport type {\n\tCanvasEdge,\n\tCanvasLayoutOptions,\n\tCanvasNode,\n\tDirectionalDisplacementOptions\n} from './types.js';\n\n/**\n * Calculates a bounding rectangle for a set of nodes if not provided by getNodesBounds.\n */\nexport function computeNodesBoundingBox<TNode extends CanvasNode = CanvasNode>(\n\tnodes: TNode[],\n\tdefaultWidth = 200,\n\tdefaultHeight = 60\n): Rect {\n\tif (nodes.length === 0) {\n\t\treturn { x: 0, y: 0, width: 0, height: 0 };\n\t}\n\n\tlet minX = Infinity;\n\tlet minY = Infinity;\n\tlet maxX = -Infinity;\n\tlet maxY = -Infinity;\n\n\tfor (const node of nodes) {\n\t\tconst width = node.measured?.width ?? (node as any).width ?? defaultWidth;\n\t\tconst height = node.measured?.height ?? (node as any).height ?? defaultHeight;\n\n\t\tminX = Math.min(minX, node.position.x);\n\t\tminY = Math.min(minY, node.position.y);\n\t\tmaxX = Math.max(maxX, node.position.x + width);\n\t\tmaxY = Math.max(maxY, node.position.y + height);\n\t}\n\n\treturn {\n\t\tx: minX,\n\t\ty: minY,\n\t\twidth: maxX - minX,\n\t\theight: maxY - minY\n\t};\n}\n\n/**\n * Pure directional displacement calculation.\n * Shifts downstream or surrounding nodes along an axis to clear space for newly inserted child nodes.\n */\nexport function calculateDirectionalDisplacement<TNode extends CanvasNode = CanvasNode>(params: {\n\texistingNodes: TNode[];\n\toriginNode: TNode;\n\tchildNodes: TNode[];\n\tgetNodesBounds?: (nodes: TNode[]) => Rect;\n\toptions?: DirectionalDisplacementOptions;\n}): Map<string, XYPosition> {\n\tconst {\n\t\texistingNodes,\n\t\toriginNode,\n\t\tchildNodes,\n\t\tgetNodesBounds,\n\t\toptions = {}\n\t} = params;\n\n\tconst {\n\t\tdirection = 'right',\n\t\tgap = 40,\n\t\tspreadSiblingLanes = false,\n\t\tsiblingTolerance = 50,\n\t\tminY\n\t} = options;\n\n\tconst displacedMap = new Map<string, XYPosition>();\n\tif (childNodes.length === 0 || existingNodes.length === 0) {\n\t\treturn displacedMap;\n\t}\n\n\tconst childBounds = getNodesBounds\n\t\t? getNodesBounds(childNodes)\n\t\t: computeNodesBoundingBox(childNodes);\n\n\tconst originWidth = originNode.measured?.width ?? (originNode as any).width ?? 200;\n\tconst originHeight = originNode.measured?.height ?? (originNode as any).height ?? 60;\n\n\t// The delta space required along primary axis\n\tconst deltaPrimary = (direction === 'right' || direction === 'left')\n\t\t? childBounds.width + gap\n\t\t: childBounds.height + gap;\n\n\t// Vertical displacement parameters: upward and downward row clearance\n\tconst deltaUp = Math.max(0, originNode.position.y - childBounds.y + gap);\n\tconst deltaDown = Math.max(\n\t\t0,\n\t\tchildBounds.y + childBounds.height - (originNode.position.y + originHeight) + gap\n\t);\n\n\t// Both above and below displace equally so the row expands symmetrically\n\tconst equalDelta = Math.max(deltaUp, deltaDown);\n\n\tfor (const node of existingNodes) {\n\t\tif (node.id === originNode.id) continue;\n\n\t\tlet newX = node.position.x;\n\t\tlet newY = node.position.y;\n\t\tlet moved = false;\n\n\t\tif (direction === 'right') {\n\t\t\t// Downstream nodes strictly to the right of the origin\n\t\t\tif (node.position.x >= originNode.position.x + originWidth * 0.5) {\n\t\t\t\tnewX += deltaPrimary;\n\t\t\t\tmoved = true;\n\t\t\t} else if (spreadSiblingLanes) {\n\t\t\t\t// Sibling nodes occupying the same vertical space as the exploded cluster\n\t\t\t\tconst isVerticallyOverlapping =\n\t\t\t\t\tnode.position.y + ((node as any).height ?? 60) >= childBounds.y - gap &&\n\t\t\t\t\tnode.position.y <= childBounds.y + childBounds.height + gap;\n\n\t\t\t\tif (isVerticallyOverlapping && Math.abs(node.position.x - originNode.position.x) <= siblingTolerance) {\n\t\t\t\t\tconst pushDirection = node.position.y >= originNode.position.y ? 1 : -1;\n\t\t\t\t\tnewY += pushDirection * (childBounds.height * 0.5 + gap);\n\t\t\t\t\tmoved = true;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (direction === 'left') {\n\t\t\tif (node.position.x <= originNode.position.x) {\n\t\t\t\tnewX -= deltaPrimary;\n\t\t\t\tmoved = true;\n\t\t\t}\n\t\t} else if (direction === 'down') {\n\t\t\tif (node.position.y >= originNode.position.y + originHeight * 0.5) {\n\t\t\t\tnewY += deltaPrimary;\n\t\t\t\tmoved = true;\n\t\t\t}\n\t\t} else if (direction === 'up') {\n\t\t\tif (node.position.y <= originNode.position.y) {\n\t\t\t\tnewY -= deltaPrimary;\n\t\t\t\tmoved = true;\n\t\t\t}\n\t\t} else if (direction === 'vertical') {\n\t\t\t// Row grows vertically:\n\t\t\t// Nodes strictly above the origin node move up by equalDelta\n\t\t\t// Nodes strictly below the origin node move down by equalDelta\n\t\t\t// Both above and below displace equally; horizontal position (x) is strictly preserved\n\t\t\tif (node.position.y < originNode.position.y) {\n\t\t\t\tif (equalDelta > 0) {\n\t\t\t\t\tnewY -= equalDelta;\n\t\t\t\t\tmoved = true;\n\t\t\t\t}\n\t\t\t} else if (node.position.y >= originNode.position.y + originHeight * 0.5) {\n\t\t\t\tif (equalDelta > 0) {\n\t\t\t\t\tnewY += equalDelta;\n\t\t\t\t\tmoved = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (moved) {\n\t\t\tdisplacedMap.set(node.id, { x: newX, y: newY });\n\t\t}\n\t}\n\n\treturn displacedMap;\n}\n\n/**\n * Pure hierarchical Dagre reflow displacement calculation.\n * Calculates new coordinates for surrounding nodes using Dagre hierarchical layout,\n * anchoring the origin node at its current position to eliminate layout jumping.\n */\nexport function calculateReflowDisplacement<\n\tTNode extends CanvasNode = CanvasNode,\n\tTEdge extends CanvasEdge = CanvasEdge\n>(params: {\n\texistingNodes: TNode[];\n\texistingEdges: TEdge[];\n\toriginNode: TNode;\n\tchildNodes: TNode[];\n\tchildEdges?: TEdge[];\n\tgetNodesBounds?: (nodes: TNode[]) => Rect;\n\toptions?: CanvasLayoutOptions;\n}): Map<string, XYPosition> {\n\tconst {\n\t\texistingNodes,\n\t\texistingEdges,\n\t\toriginNode,\n\t\tchildNodes,\n\t\tchildEdges = [],\n\t\toptions = {}\n\t} = params;\n\n\tconst {\n\t\tdirection = 'LR',\n\t\tranksep = 80,\n\t\tnodesep = 30,\n\t\tdefaultNodeWidth = 200,\n\t\tdefaultNodeHeight = 60\n\t} = options;\n\n\tconst displacedMap = new Map<string, XYPosition>();\n\tif (existingNodes.length === 0) return displacedMap;\n\n\tconst allNodes = [...existingNodes, ...childNodes];\n\tconst allEdges = [...existingEdges, ...childEdges];\n\n\tconst dagreGraph = new dagre.graphlib.Graph();\n\tdagreGraph.setDefaultEdgeLabel(() => ({}));\n\tdagreGraph.setGraph({ rankdir: direction, ranksep, nodesep });\n\n\tconst allNodeIds = new Set(allNodes.map((n) => n.id));\n\n\tallNodes.forEach((node) => {\n\t\tconst nodeWidth = node.measured?.width ?? (node as any).width ?? defaultNodeWidth;\n\t\tconst nodeHeight = node.measured?.height ?? (node as any).height ?? defaultNodeHeight;\n\t\tdagreGraph.setNode(node.id, { width: nodeWidth, height: nodeHeight });\n\t});\n\n\tallEdges.forEach((edge) => {\n\t\tif (allNodeIds.has(edge.source) && allNodeIds.has(edge.target)) {\n\t\t\tdagreGraph.setEdge(edge.source, edge.target);\n\t\t}\n\t});\n\n\tdagre.layout(dagreGraph);\n\n\tconst dagreOrigin = dagreGraph.node(originNode.id);\n\tif (!dagreOrigin) return displacedMap;\n\n\tconst originWidth = originNode.measured?.width ?? (originNode as any).width ?? defaultNodeWidth;\n\tconst originHeight = originNode.measured?.height ?? (originNode as any).height ?? defaultNodeHeight;\n\n\t// Calculate offset so origin node remains anchored at its exact initial coordinates\n\tconst anchorOffsetX = originNode.position.x - (dagreOrigin.x - originWidth / 2);\n\tconst anchorOffsetY = originNode.position.y - (dagreOrigin.y - originHeight / 2);\n\n\texistingNodes.forEach((node) => {\n\t\tif (node.id === originNode.id) return;\n\n\t\tconst dagreNode = dagreGraph.node(node.id);\n\t\tif (!dagreNode) return;\n\n\t\tconst nodeWidth = node.measured?.width ?? (node as any).width ?? defaultNodeWidth;\n\t\tconst nodeHeight = node.measured?.height ?? (node as any).height ?? defaultNodeHeight;\n\n\t\tconst targetX = dagreNode.x - nodeWidth / 2 + anchorOffsetX;\n\t\tconst targetY = dagreNode.y - nodeHeight / 2 + anchorOffsetY;\n\n\t\t// Only include if position actually shifted\n\t\tif (Math.abs(targetX - node.position.x) > 0.5 || Math.abs(targetY - node.position.y) > 0.5) {\n\t\t\tdisplacedMap.set(node.id, { x: targetX, y: targetY });\n\t\t}\n\t});\n\n\treturn displacedMap;\n}\n","import { cubicOut } from \"svelte/easing\";\nimport {\n calculateDirectionalDisplacement,\n calculateReflowDisplacement\n} from \"./createCanvasDisplacement.js\";\nimport {\n createFanOutTrajectory,\n linearPositionTrajectory,\n runMultiNodeTransition\n} from \"./createCanvasTrajectory.js\";\nexport function createCanvasExplosion(graph, options = {}) {\n let explodedNodeIds = $state([]);\n const snapshots = /* @__PURE__ */ new Map();\n let activeAnimationCancel = null;\n function isExploded(nodeId) {\n return explodedNodeIds.includes(nodeId);\n }\n function explodeNode(parentId, explodeOptions) {\n if (isExploded(parentId)) {\n return false;\n }\n const parentNode = graph.nodes.find((n) => n.id === parentId);\n if (!parentNode) {\n return false;\n }\n const {\n childNodes,\n childEdges = [],\n connectParentToChildren = \"all\",\n displacementStrategy = \"directional\",\n directionalOptions = {},\n reflowOptions = {},\n trajectory,\n duration = 500,\n staggerDelay = 20,\n easing = cubicOut,\n onComplete\n } = explodeOptions;\n if (childNodes.length === 0) {\n return false;\n }\n let displacementMap;\n if (displacementStrategy === \"dagre\") {\n displacementMap = calculateReflowDisplacement({\n existingNodes: graph.nodes,\n existingEdges: graph.edges,\n originNode: parentNode,\n childNodes,\n childEdges,\n getNodesBounds: options.getNodesBounds,\n options: {\n ...reflowOptions,\n direction: reflowOptions.direction ?? \"LR\"\n }\n });\n } else if (displacementStrategy === \"none\") {\n displacementMap = /* @__PURE__ */ new Map();\n } else {\n displacementMap = calculateDirectionalDisplacement({\n existingNodes: graph.nodes,\n originNode: parentNode,\n childNodes,\n getNodesBounds: options.getNodesBounds,\n options: directionalOptions\n });\n }\n const displacedNodesSnapshot = Array.from(displacementMap.entries()).map(([id]) => {\n const node = graph.nodes.find((n) => n.id === id);\n return {\n id,\n originalPosition: { ...node?.position ?? { x: 0, y: 0 } }\n };\n });\n const edgesToAdd = [...childEdges];\n const defaultCreateEdge = (sourceId, targetId) => {\n if (graph.createEdge) {\n return graph.createEdge(sourceId, targetId);\n }\n return {\n id: crypto.randomUUID(),\n type: \"default\",\n source: sourceId,\n target: targetId\n };\n };\n if (connectParentToChildren === \"all\" || connectParentToChildren === true) {\n childNodes.forEach((child) => {\n const exists = edgesToAdd.some((e) => e.source === parentId && e.target === child.id);\n if (!exists) {\n edgesToAdd.push(defaultCreateEdge(parentId, child.id));\n }\n });\n } else if (connectParentToChildren === \"first\" && childNodes.length > 0) {\n const firstChild = childNodes[0];\n const exists = edgesToAdd.some((e) => e.source === parentId && e.target === firstChild.id);\n if (!exists) {\n edgesToAdd.push(defaultCreateEdge(parentId, firstChild.id));\n }\n }\n const snapshot = {\n parentId,\n childNodeIds: childNodes.map((n) => n.id),\n childEdgeIds: edgesToAdd.map((e) => e.id),\n displacedNodes: displacedNodesSnapshot,\n timestamp: Date.now()\n };\n snapshots.set(parentId, snapshot);\n const originPos = { ...parentNode.position };\n const targetPositions = childNodes.map((child) => ({ ...child.position }));\n childNodes.forEach((child) => {\n child.position = { ...originPos };\n if (!child.data) child.data = {};\n child.data.scale = 0;\n child.data.opacity = 0;\n const currentStyle = (child.style || \"\").replace(/opacity:\\s*[^;]+;?/g, \"\").trim();\n child.style = `${currentStyle ? currentStyle + \"; \" : \"\"}opacity: 0;`;\n });\n edgesToAdd.forEach((edge) => {\n const currentStyle = (edge.style || \"\").replace(/opacity:\\s*[^;]+;?/g, \"\").trim();\n edge.style = `${currentStyle ? currentStyle + \"; \" : \"\"}opacity: 0;`;\n });\n graph.addNodeOrNodes(childNodes, void 0, false);\n if (edgesToAdd.length > 0) {\n graph.addEdges(edgesToAdd, false);\n }\n const chosenTrajectory = trajectory ?? createFanOutTrajectory({ curvature: 0.35 });\n const transitions = [];\n const effectiveStagger = duration === 0 ? 0 : staggerDelay;\n childNodes.forEach((child, i) => {\n transitions.push({\n node: child,\n from: originPos,\n to: targetPositions[i],\n trajectory: chosenTrajectory,\n delay: i * effectiveStagger,\n duration,\n easing,\n index: i,\n total: childNodes.length\n });\n });\n displacementMap.forEach((targetPos, nodeId) => {\n const node = graph.nodes.find((n) => n.id === nodeId);\n if (node) {\n transitions.push({\n node,\n from: { ...node.position },\n to: targetPos,\n trajectory: linearPositionTrajectory,\n duration,\n easing\n });\n }\n });\n if (activeAnimationCancel) {\n activeAnimationCancel();\n }\n activeAnimationCancel = runMultiNodeTransition(transitions, {\n defaultDuration: duration,\n defaultEasing: easing,\n onUpdate: () => {\n if (edgesToAdd.length > 0) {\n const childIdSet = new Set(childNodes.map((c) => c.id));\n const childEdgesInGraph = graph.edges.filter((e) => childIdSet.has(e.target));\n if (childEdgesInGraph.length > 0) {\n childEdgesInGraph.forEach((edge) => {\n const child = childNodes.find((c) => c.id === edge.target);\n const childOpacity = child?.data?.opacity ?? 1;\n const currentStyle = (edge.style || \"\").replace(/opacity:\\s*[^;]+;?/g, \"\").trim();\n edge.style = `${currentStyle ? currentStyle + \"; \" : \"\"}opacity: ${childOpacity};`;\n });\n graph.setEdges(\n graph.edges.map((e) => childIdSet.has(e.target) ? { ...e } : e)\n );\n }\n }\n graph.setNodes(\n graph.nodes.map((node) => {\n const isTransitioning = transitions.some((t) => t.node.id === node.id);\n return isTransitioning ? { ...node, data: { ...node.data } } : node;\n })\n );\n },\n onComplete: () => {\n childNodes.forEach((child) => {\n const node = graph.nodes.find((n) => n.id === child.id);\n if (node) {\n node.style = (node.style || \"\").replace(/opacity:\\s*[^;]+;?/g, \"\").trim() || void 0;\n if (node.data) {\n node.data.opacity = 1;\n }\n }\n });\n edgesToAdd.forEach((edge) => {\n const graphEdge = graph.edges.find((e) => e.id === edge.id);\n if (graphEdge) {\n graphEdge.style = (graphEdge.style || \"\").replace(/opacity:\\s*[^;]+;?/g, \"\").trim() || void 0;\n }\n });\n graph.setNodes(graph.nodes.map((node) => ({ ...node, data: { ...node.data } })));\n graph.setEdges(graph.edges.map((edge) => ({ ...edge })));\n explodedNodeIds = [...explodedNodeIds, parentId];\n activeAnimationCancel = null;\n options.onSave?.();\n graph.onSave?.();\n onComplete?.();\n }\n });\n return true;\n }\n function collapseNode(parentId, collapseOptions = {}) {\n const snapshot = snapshots.get(parentId);\n if (!snapshot) {\n return false;\n }\n const parentNode = graph.nodes.find((n) => n.id === parentId);\n if (!parentNode) {\n return false;\n }\n const {\n duration = 400,\n staggerDelay = 15,\n easing = cubicOut,\n trajectory,\n onComplete\n } = collapseOptions;\n const childIdSet = new Set(snapshot.childNodeIds);\n const activeChildNodes = graph.nodes.filter((n) => childIdSet.has(n.id));\n const originPos = { ...parentNode.position };\n const reverseTrajectory = trajectory ?? createFanOutTrajectory({\n curvature: 0.2,\n startScale: 1,\n endScale: 0,\n startOpacity: 1,\n endOpacity: 0\n });\n const transitions = [];\n const effectiveStagger = duration === 0 ? 0 : staggerDelay;\n activeChildNodes.forEach((child, i) => {\n transitions.push({\n node: child,\n from: { ...child.position },\n to: originPos,\n trajectory: reverseTrajectory,\n delay: (activeChildNodes.length - 1 - i) * effectiveStagger,\n duration,\n easing,\n index: i,\n total: activeChildNodes.length\n });\n });\n snapshot.displacedNodes.forEach(({ id, originalPosition }) => {\n const node = graph.nodes.find((n) => n.id === id);\n if (node) {\n transitions.push({\n node,\n from: { ...node.position },\n to: originalPosition,\n trajectory: linearPositionTrajectory,\n duration,\n easing\n });\n }\n });\n if (activeAnimationCancel) {\n activeAnimationCancel();\n }\n activeAnimationCancel = runMultiNodeTransition(transitions, {\n defaultDuration: duration,\n defaultEasing: easing,\n onUpdate: () => {\n const edgeIdSet = new Set(snapshot.childEdgeIds);\n const childEdgesInGraph = graph.edges.filter((e) => edgeIdSet.has(e.id));\n if (childEdgesInGraph.length > 0) {\n childEdgesInGraph.forEach((edge) => {\n const child = activeChildNodes.find((c) => c.id === edge.target);\n const childOpacity = child?.data?.opacity ?? 0;\n const currentStyle = (edge.style || \"\").replace(/opacity:\\s*[^;]+;?/g, \"\").trim();\n edge.style = `${currentStyle ? currentStyle + \"; \" : \"\"}opacity: ${childOpacity};`;\n });\n graph.setEdges(\n graph.edges.map((e) => edgeIdSet.has(e.id) ? { ...e } : e)\n );\n }\n graph.setNodes(\n graph.nodes.map((node) => {\n const isTransitioning = transitions.some((t) => t.node.id === node.id);\n return isTransitioning ? { ...node, data: { ...node.data } } : node;\n })\n );\n },\n onComplete: () => {\n graph.removeNodes(activeChildNodes, false);\n const edgeIdSet = new Set(snapshot.childEdgeIds);\n const edgesToRemove = graph.edges.filter((e) => edgeIdSet.has(e.id));\n if (edgesToRemove.length > 0) {\n graph.removeEdges(edgesToRemove, false);\n }\n snapshots.delete(parentId);\n explodedNodeIds = explodedNodeIds.filter((id) => id !== parentId);\n activeAnimationCancel = null;\n options.onSave?.();\n graph.onSave?.();\n onComplete?.();\n }\n });\n return true;\n }\n function toggleExplode(parentId, explodeOptions, collapseOptions) {\n if (isExploded(parentId)) {\n return collapseNode(parentId, collapseOptions);\n }\n return explodeNode(parentId, explodeOptions);\n }\n function getSnapshot(parentId) {\n return snapshots.get(parentId);\n }\n return {\n get explodedNodeIds() {\n return explodedNodeIds;\n },\n isExploded,\n explodeNode,\n collapseNode,\n toggleExplode,\n getSnapshot\n };\n}\n"],"mappings":";;AAAA,SAAS,gBAAgB;AAClB,SAAS,0BAA0B,cAAc,eAAe;AACrE,QAAM,eAAe,aAAa,SAAK,CAAA;AACvC,QAAM,eAAe,aAAa,SAAK,CAAA;AACvC,QAAM,gBAAgB,cAAc,SAAK,CAAA;AACzC,QAAM,gBAAgB,cAAc,SAAK,CAAA;AACzC,QAAM,kBAAkB,IAAI,IAAI,cAAc,IAAG,CAAE,MAAC,CAAM,EAAE,IAAI,CAAC,CAAA,CAAA;AACjE,QAAM,kBAAkB,IAAI,IAAI,cAAc,IAAG,CAAE,MAAC,CAAM,EAAE,IAAI,CAAC,CAAA,CAAA;AACjE,QAAM,iBAAiB,IAAI,IAAI,aAAa,IAAG,CAAE,MAAC,CAAM,EAAE,IAAI,CAAC,CAAA,CAAA;AAC/D,QAAM,iBAAiB,IAAI,IAAI,aAAa,IAAG,CAAE,MAAC,CAAM,EAAE,IAAI,CAAC,CAAA,CAAA;AAC/D,QAAM,eAAe,cAAc,OAAM,CAAE,YAAO,CAAM,eAAe,IAAI,QAAQ,EAAE,CAAA;AACrF,QAAM,eAAe,cAAc,OAAM,CAAE,YAAO,CAAM,eAAe,IAAI,QAAQ,EAAE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AO,KAAK,EAAE;AACrE,iBAAO,kBAAe,EAAA,GAAQ,MAAM,MAAI,EAAA,GAAO,KAAK,KAAI,EAAA,IAAO;QACjE,CAAC,CAAA;MAEL;MACA,YAAU,MAAQ;AAChB,cAAM,YAAY,kBAAkB,KAAK;AACzC,cAAM,YAAY,IAAI,IAAI,SAAS,YAAY;AAC/C,cAAM,gBAAgB,MAAM,MAAM,OAAM,CAAE,MAAM,UAAU,IAAI,EAAE,EAAE,CAAA;AAClE,YAAI,cAAc,SAAS,GAAG;AAC5B,gBAAM,YAAY,eAAe,KAAK;QACxC;AACA,kBAAU,OAAO,QAAQ;eACzB,iBAAe,OAAG,eAAe,EAAC,OAAM,CAAE,OAAO,OAAO,QAAQ,GAAA,IAAA;AAChE,gCAAwB;AACxB,gBAAQ,SAAM;AACd,cAAM,SAAM;AACZ,qBAAU;MACZ;;AAEF,WAAO;EACT;AACA,WAAS,cAAc,UAAU,gBAAgB,iBAAiB;AAChE,QAAI,WAAW,QAAQ,GAAG;AACxB,aAAO,aAAa,UAAU,eAAe;IAC/C;AACA,WAAO,YAAY,UAAU,cAAc;EAC7C;AACA,WAAS,YAAY,UAAU;AAC7B,WAAO,UAAU,IAAI,QAAQ;EAC/B;AACA,SAAM;IACJ,IAAI,kBAAkB;AACpB,aAAM,OAAC,eAAe;IACxB;IACA;IACA;IACA;IACA;IACA;;AAEJ;","names":["cubicOut","dagre","cubicOut","cubicOut"]}
1
+ {"version":3,"sources":["../../src/canvas/createCanvasGraph.svelte.ts","../../src/canvas/createCanvasLayout.ts","../../src/canvas/createCanvasClipboard.svelte.ts","../../src/canvas/createCanvasDocking.svelte.ts","../../src/canvas/createCanvasShortcuts.ts","../../src/canvas/createCanvasInteractions.svelte.ts","../../src/canvas/createCanvasTrajectory.ts","../../src/canvas/createCanvasDisplacement.ts","../../src/canvas/createCanvasExplosion.svelte.ts"],"sourcesContent":["import { cubicOut } from \"svelte/easing\";\nexport function calculateGraphDifferences(currentState, baselineState) {\n const currentNodes = currentState.nodes ?? [];\n const currentEdges = currentState.edges ?? [];\n const baselineNodes = baselineState.nodes ?? [];\n const baselineEdges = baselineState.edges ?? [];\n const baselineNodeMap = new Map(baselineNodes.map((n) => [n.id, n]));\n const baselineEdgeMap = new Map(baselineEdges.map((e) => [e.id, e]));\n const currentNodeMap = new Map(currentNodes.map((n) => [n.id, n]));\n const currentEdgeMap = new Map(currentEdges.map((e) => [e.id, e]));\n const removedNodes = baselineNodes.filter((oldNode) => !currentNodeMap.has(oldNode.id));\n const removedEdges = baselineEdges.filter((oldEdge) => !currentEdgeMap.has(oldEdge.id));\n const changedNodes = currentNodes.filter((newNode) => {\n const oldNode = baselineNodeMap.get(newNode.id);\n if (!oldNode) return true;\n return JSON.stringify(newNode) !== JSON.stringify(oldNode);\n });\n const changedEdges = currentEdges.filter((newEdge) => {\n const oldEdge = baselineEdgeMap.get(newEdge.id);\n if (!oldEdge) return true;\n return JSON.stringify(newEdge) !== JSON.stringify(oldEdge);\n });\n return { changedNodes, changedEdges, removedNodes, removedEdges };\n}\nexport function replaceNodeInGraph(nodes, edges, oldNode, newNode, keepEdges = false) {\n const updatedNodes = nodes.map((n) => n.id === oldNode.id ? newNode : n);\n if (!keepEdges) {\n return { nodes: updatedNodes, edges };\n }\n const updatedEdges = edges.map((edge) => {\n if (edge.source === oldNode.id || edge.target === oldNode.id) {\n return {\n ...edge,\n id: crypto.randomUUID(),\n source: edge.source === oldNode.id ? newNode.id : edge.source,\n target: edge.target === oldNode.id ? newNode.id : edge.target\n };\n }\n return edge;\n });\n return {\n nodes: updatedNodes,\n edges: updatedEdges\n };\n}\nexport function createCanvasGraph(options = {}) {\n let nodes = $state.raw(options.initialNodes ?? []);\n let edges = $state.raw(options.initialEdges ?? []);\n function setNodes(newNodes, triggerCallback = true) {\n nodes = newNodes;\n if (triggerCallback) {\n options.onNodesChange?.(nodes);\n }\n }\n function setEdges(newEdges, triggerCallback = true) {\n edges = newEdges;\n if (triggerCallback) {\n options.onEdgesChange?.(edges);\n }\n }\n function animateNodePosition(node, targetPosition, duration = 400, easing = cubicOut) {\n const delay = node.data?.animationDelay ?? 0;\n const startPosition = { ...node.position };\n const startTime = Date.now() + delay;\n function step() {\n const currentTime = Date.now();\n if (currentTime < startTime) {\n if (typeof requestAnimationFrame !== \"undefined\") {\n requestAnimationFrame(step);\n }\n return;\n }\n const progress = Math.min((currentTime - startTime) / duration, 1);\n const eased = easing(progress);\n const currentPos = {\n x: startPosition.x + (targetPosition.x - startPosition.x) * eased,\n y: startPosition.y + (targetPosition.y - startPosition.y) * eased\n };\n const targetNode = nodes.find((n) => n.id === node.id);\n if (targetNode) {\n targetNode.position = currentPos;\n }\n if (progress < 1) {\n if (typeof requestAnimationFrame !== \"undefined\") {\n requestAnimationFrame(step);\n }\n } else {\n setNodes([...nodes]);\n }\n }\n step();\n }\n function addNodeOrNodes(nodeOrNodesToAdd, animateFromPosition, save = true) {\n const toAdd = Array.isArray(nodeOrNodesToAdd) ? nodeOrNodesToAdd : [nodeOrNodesToAdd];\n const existingMap = new Map(nodes.map((n) => [n.id, n]));\n toAdd.forEach((node) => {\n if (!existingMap.has(node.id)) {\n existingMap.set(node.id, node);\n }\n });\n setNodes(Array.from(existingMap.values()));\n if (animateFromPosition) {\n toAdd.forEach((node) => {\n const target = { ...node.position };\n node.position = { ...animateFromPosition };\n animateNodePosition(node, target);\n });\n }\n if (save) options.onSave?.();\n }\n function addEdge(edgeToAdd, save = true) {\n setEdges([...edges, edgeToAdd]);\n if (save) options.onSave?.();\n }\n function addEdges(edgesToAdd, save = true) {\n setEdges([...edges, ...edgesToAdd]);\n if (save) options.onSave?.();\n }\n function removeNodes(nodesToRemove, save = true) {\n const idsToRemove = new Set(nodesToRemove.map((n) => n.id));\n setNodes(nodes.filter((n) => !idsToRemove.has(n.id)));\n if (save) options.onSave?.();\n }\n function removeEdges(edgesToRemove, save = true) {\n const idsToRemove = new Set(edgesToRemove.map((e) => e.id));\n setEdges(edges.filter((e) => !idsToRemove.has(e.id)));\n if (save) options.onSave?.();\n }\n function replaceNode(oldNode, newNode, save = true, keepEdges = false) {\n const result = replaceNodeInGraph(nodes, edges, oldNode, newNode, keepEdges);\n setNodes(result.nodes);\n if (result.edges !== edges) {\n setEdges(result.edges);\n }\n if (save) options.onSave?.();\n }\n function addConnectedNodes(params) {\n const {\n nodesToAdd,\n inboundNodes = [],\n outboundNodes = [],\n animatedEdges = false,\n animateFromPosition,\n inboundEdgeData = {},\n outboundEdgeData = {},\n getEdgeLabel\n } = params;\n const defaultCreateEdge = (sourceId, targetId, opt) => {\n if (options.createEdge) {\n return options.createEdge(sourceId, targetId, opt);\n }\n return {\n id: crypto.randomUUID(),\n type: \"default\",\n source: sourceId,\n target: targetId,\n label: opt?.label ?? \"\",\n animated: opt?.animated ?? false,\n data: opt?.data ?? {}\n };\n };\n nodesToAdd.forEach((addedNode) => {\n addNodeOrNodes(addedNode, animateFromPosition, false);\n inboundNodes.forEach((sourceNode) => {\n const label = getEdgeLabel ? getEdgeLabel(sourceNode, addedNode) : \"\";\n addEdge(\n defaultCreateEdge(sourceNode.id, addedNode.id, {\n label,\n animated: animatedEdges,\n data: inboundEdgeData\n }),\n false\n );\n });\n outboundNodes.forEach((targetNode) => {\n const label = getEdgeLabel ? getEdgeLabel(addedNode, targetNode) : \"\";\n addEdge(\n defaultCreateEdge(addedNode.id, targetNode.id, {\n label,\n animated: animatedEdges,\n data: outboundEdgeData\n }),\n false\n );\n });\n });\n options.onSave?.();\n }\n function getDifferences(baseline) {\n return calculateGraphDifferences({ nodes, edges }, baseline);\n }\n return {\n get nodes() {\n return nodes;\n },\n set nodes(val) {\n setNodes(val);\n },\n get edges() {\n return edges;\n },\n set edges(val) {\n setEdges(val);\n },\n setNodes,\n setEdges,\n addNodeOrNodes,\n addEdge,\n addEdges,\n removeNodes,\n removeEdges,\n replaceNode,\n addConnectedNodes,\n animateNodePosition,\n getDifferences\n };\n}\n","import dagre from '@dagrejs/dagre';\nimport { Position, type XYPosition, type Rect } from '@xyflow/svelte';\nimport type { CanvasNode, CanvasEdge, CanvasLayoutOptions } from './types.js';\n\n/**\n * Calculates upper-left flow coordinate for an element to be centered in the viewport.\n */\nexport function getCenteredNodePosition(\n\twidth = 0,\n\theight = 0,\n\tscreenToFlowPosition: (position: XYPosition) => XYPosition,\n\tscreenDimensions?: { width: number; height: number }\n): XYPosition {\n\tconst rect = screenDimensions ?? (typeof document !== 'undefined'\n\t\t? { width: document.documentElement.clientWidth, height: document.documentElement.clientHeight }\n\t\t: { width: 1920, height: 1080 });\n\n\tconst flowPos = screenToFlowPosition({ x: rect.width / 2, y: rect.height / 2 });\n\treturn {\n\t\tx: flowPos.x - width / 2,\n\t\ty: flowPos.y - height / 2\n\t};\n}\n\n/**\n * Updates positions of nodes so their collective bounding box is centered in the current viewport.\n */\nexport function centerNodes<TNode extends CanvasNode = CanvasNode>(\n\tnodes: TNode[],\n\tscreenToFlowPosition: (position: XYPosition) => XYPosition,\n\tgetNodesBounds: (nodes: TNode[]) => Rect,\n\tscreenDimensions?: { width: number; height: number }\n): TNode[] {\n\tif (nodes.length === 0) {\n\t\treturn [];\n\t}\n\n\tconst bounds = getNodesBounds(nodes);\n\tconst boundingBoxOrigin = { x: bounds.x, y: bounds.y };\n\n\tconst centeredPosition = getCenteredNodePosition(\n\t\tbounds.width,\n\t\tbounds.height,\n\t\tscreenToFlowPosition,\n\t\tscreenDimensions\n\t);\n\n\tconst deltaX = centeredPosition.x - boundingBoxOrigin.x;\n\tconst deltaY = centeredPosition.y - boundingBoxOrigin.y;\n\n\treturn nodes.map((node) => ({\n\t\t...node,\n\t\tposition: {\n\t\t\tx: node.position.x + deltaX,\n\t\t\ty: node.position.y + deltaY\n\t\t}\n\t}));\n}\n\n/**\n * Automatically calculates directed hierarchical layout of nodes and edges using Dagre.\n */\nexport function getLayoutedNodes<\n\tTNode extends CanvasNode = CanvasNode,\n\tTEdge extends CanvasEdge = CanvasEdge\n>(\n\tnodes: TNode[],\n\tedges: TEdge[],\n\tgetNodesBounds: (nodes: TNode[]) => Rect,\n\toptions: CanvasLayoutOptions = {}\n): TNode[] {\n\tif (nodes.length === 0) return [];\n\n\tconst {\n\t\tdirection = 'LR',\n\t\tranksep = 100,\n\t\tnodesep = 25,\n\t\tdefaultNodeWidth = 200,\n\t\tdefaultNodeHeight = 200\n\t} = options;\n\n\tconst isHorizontal = direction === 'LR' || direction === 'RL';\n\tconst bounds = getNodesBounds(nodes);\n\n\tconst dagreGraph = new dagre.graphlib.Graph();\n\tdagreGraph.setDefaultEdgeLabel(() => ({}));\n\tdagreGraph.setGraph({ rankdir: direction, ranksep, nodesep });\n\n\tconst nodeIds = new Set(nodes.map((node) => node.id));\n\n\tnodes.forEach((node) => {\n\t\tconst nodeWidth = node.measured?.width ?? (node as any).width ?? defaultNodeWidth;\n\t\tconst nodeHeight = node.measured?.height ?? (node as any).height ?? defaultNodeHeight;\n\t\tdagreGraph.setNode(node.id, { width: nodeWidth, height: nodeHeight });\n\t});\n\n\tedges.forEach((edge) => {\n\t\tif (nodeIds.has(edge.source) && nodeIds.has(edge.target)) {\n\t\t\tdagreGraph.setEdge(edge.source, edge.target);\n\t\t}\n\t});\n\n\tdagre.layout(dagreGraph);\n\n\treturn nodes.map((node) => {\n\t\tconst nodeWithPosition = dagreGraph.node(node.id);\n\t\tconst nodeWidth = node.measured?.width ?? (node as any).width ?? defaultNodeWidth;\n\t\tconst nodeHeight = node.measured?.height ?? (node as any).height ?? defaultNodeHeight;\n\n\t\treturn {\n\t\t\t...node,\n\t\t\ttargetPosition: isHorizontal ? Position.Left : Position.Top,\n\t\t\tsourcePosition: isHorizontal ? Position.Right : Position.Bottom,\n\t\t\tposition: {\n\t\t\t\tx: bounds.x + (nodeWithPosition?.x ?? 0) - nodeWidth / 2,\n\t\t\t\ty: bounds.y + (nodeWithPosition?.y ?? 0) - nodeHeight / 2\n\t\t\t}\n\t\t};\n\t});\n}\n","import { tick } from \"svelte\";\nexport function isEventFromTextInput(event) {\n const target = event.target;\n if (!target) return false;\n if (target.tagName === \"INPUT\" || target.tagName === \"TEXTAREA\" || target.tagName === \"SELECT\" || target.isContentEditable || target.closest?.('[contenteditable=\"true\"]') || target.closest?.(\".ProseMirror\")) {\n return true;\n }\n return false;\n}\nexport function isValidCanvasNode(obj) {\n return typeof obj === \"object\" && obj !== null && \"id\" in obj && typeof obj.id === \"string\" && \"position\" in obj && typeof obj.position === \"object\" && obj.position !== null && \"x\" in obj.position && \"y\" in obj.position;\n}\nexport function isValidUrl(url) {\n try {\n const parsed = new URL(url);\n return parsed.protocol === \"http:\" || parsed.protocol === \"https:\";\n } catch {\n return false;\n }\n}\nexport function createCanvasClipboard(options = {}) {\n function copySelectedNodes(selectedNodes, connectedEdges, event) {\n if (event && isEventFromTextInput(event)) {\n return false;\n }\n if (selectedNodes.length === 0) return false;\n const payload = {\n version: 1,\n nodes: selectedNodes,\n edges: connectedEdges\n };\n const serialized = JSON.stringify(payload);\n if (event?.clipboardData) {\n event.clipboardData.setData(\"application/json\", serialized);\n event.clipboardData.setData(\"text/plain\", serialized);\n event.preventDefault();\n } else if (typeof navigator !== \"undefined\" && navigator.clipboard) {\n navigator.clipboard.writeText(serialized).catch(() => {\n });\n }\n return true;\n }\n function cutSelectedNodes(selectedNodes, connectedEdges, onRemove, event) {\n if (event && isEventFromTextInput(event)) {\n return false;\n }\n const copied = copySelectedNodes(selectedNodes, connectedEdges, event);\n if (copied && onRemove) {\n onRemove(selectedNodes);\n }\n return copied;\n }\n async function handlePasteEvent(event) {\n if (isEventFromTextInput(event)) {\n return false;\n }\n const clipboardData = event.clipboardData;\n if (!clipboardData) return false;\n const files = clipboardData.files;\n if (files && files.length > 0) {\n const imageFile = Array.from(files).find((f) => f.type.startsWith(\"image/\"));\n if (imageFile && options.onPasteImage) {\n event.preventDefault();\n await options.onPasteImage(imageFile);\n return true;\n }\n }\n const rawJson = clipboardData.getData(\"application/json\") || clipboardData.getData(\"text/plain\");\n if (rawJson) {\n try {\n const parsed = JSON.parse(rawJson);\n let rawNodes;\n let rawEdges;\n if (Array.isArray(parsed) && parsed.every(isValidCanvasNode)) {\n rawNodes = parsed;\n } else if (typeof parsed === \"object\" && parsed !== null && Array.isArray(parsed.nodes) && parsed.nodes.every(isValidCanvasNode)) {\n rawNodes = parsed.nodes;\n rawEdges = parsed.edges;\n }\n if (rawNodes && rawNodes.length > 0) {\n event.preventDefault();\n const idMap = /* @__PURE__ */ new Map();\n const newNodes = rawNodes.map((node) => {\n const newId = crypto.randomUUID();\n idMap.set(node.id, newId);\n return {\n ...node,\n id: newId,\n selected: true,\n position: {\n x: node.position.x + 40,\n y: node.position.y + 40\n }\n };\n });\n const newEdges = rawEdges?.map((edge) => ({\n ...edge,\n id: crypto.randomUUID(),\n source: idMap.get(edge.source) ?? edge.source,\n target: idMap.get(edge.target) ?? edge.target\n }));\n if (options.onPasteNodes) {\n await options.onPasteNodes(newNodes, newEdges);\n await tick();\n }\n return true;\n }\n } catch {\n }\n }\n const text = clipboardData.getData(\"text/plain\")?.trim();\n if (text) {\n if (isValidUrl(text) && options.onPasteUrl) {\n event.preventDefault();\n options.onPasteUrl(text);\n return true;\n } else if (options.onPasteText) {\n event.preventDefault();\n options.onPasteText(text);\n return true;\n }\n }\n return false;\n }\n return {\n copySelectedNodes,\n cutSelectedNodes,\n handlePasteEvent\n };\n}\n","export function createCanvasDocking(options = {}) {\n let draggedNode = $state.raw(null);\n let draggedInitialPosition = $state.raw(null);\n let connectingHandle = $state.raw(\"\");\n let connectingNode = $state.raw(null);\n let currentHoverTargets = $state.raw(/* @__PURE__ */ new Set());\n const isDockTarget = options.isDockTarget ?? ((target) => target.type === \"boardNode\");\n function handleNodeDragStart(params) {\n draggedNode = params.targetNode;\n draggedInitialPosition = params.targetNode?.position ? { ...params.targetNode.position } : null;\n currentHoverTargets = /* @__PURE__ */ new Set();\n }\n function handleNodeDrag(params, getIntersectingNodes) {\n draggedNode = params.targetNode;\n if (!draggedNode) return;\n const intersecting = getIntersectingNodes(draggedNode);\n const currentDockTargets = intersecting.filter(isDockTarget);\n const newHoverSet = new Set(currentDockTargets.map((t) => t.id));\n currentHoverTargets.forEach((targetId) => {\n if (!newHoverSet.has(targetId)) {\n const leftNode = intersecting.find((n) => n.id === targetId) ?? { id: targetId };\n options.onDockLeave?.(leftNode, draggedNode);\n }\n });\n currentDockTargets.forEach((target) => {\n if (!currentHoverTargets.has(target.id)) {\n options.onDockHover?.(target, draggedNode);\n }\n });\n currentHoverTargets = newHoverSet;\n }\n function handleNodeDragStop(params, getIntersectingNodes, updateNodePosition) {\n draggedNode = params.targetNode;\n if (draggedNode) {\n const intersecting = getIntersectingNodes(draggedNode);\n const dockTarget = intersecting.find(isDockTarget);\n if (dockTarget) {\n options.onDockDrop?.(dockTarget, draggedNode);\n if (options.restorePositionOnDock !== false && draggedInitialPosition && updateNodePosition) {\n updateNodePosition(draggedNode.id, draggedInitialPosition);\n }\n }\n }\n draggedNode = null;\n draggedInitialPosition = null;\n currentHoverTargets = /* @__PURE__ */ new Set();\n options.onSave?.();\n }\n function handleConnectStart(params, getNode) {\n connectingHandle = params.handleType ?? \"\";\n connectingNode = params.nodeId ? getNode(params.nodeId) ?? null : null;\n }\n function handleConnectEnd() {\n connectingHandle = \"\";\n connectingNode = null;\n }\n function reset() {\n draggedNode = null;\n draggedInitialPosition = null;\n connectingHandle = \"\";\n connectingNode = null;\n currentHoverTargets = /* @__PURE__ */ new Set();\n }\n return {\n get draggedNode() {\n return draggedNode;\n },\n get draggedInitialPosition() {\n return draggedInitialPosition;\n },\n get connectingHandle() {\n return connectingHandle;\n },\n get connectingNode() {\n return connectingNode;\n },\n get isDragging() {\n return draggedNode !== null;\n },\n handleNodeDragStart,\n handleNodeDrag,\n handleNodeDragStop,\n handleConnectStart,\n handleConnectEnd,\n reset\n };\n}\n","import { isEventFromTextInput } from './createCanvasClipboard.svelte.js';\nimport type { CanvasNode, CanvasShortcutsOptions } from './types.js';\n\n/**\n * Attaches keyboard shortcut handlers for canvas interaction.\n * Automatically ignores shortcuts when the user is typing into text inputs, textareas, or rich editors.\n *\n * @returns A cleanup function to remove event listeners.\n */\nexport function createCanvasShortcuts<TNode extends CanvasNode = CanvasNode>(\n\toptions: CanvasShortcutsOptions<TNode>\n): () => void {\n\tconst target = options.targetElement ?? (typeof window !== 'undefined' ? window : null);\n\tif (!target) return () => {};\n\n\tfunction handleKeyDown(event: Event) {\n\t\tconst keyboardEvent = event as KeyboardEvent;\n\t\tif (isEventFromTextInput(keyboardEvent)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst isMod = keyboardEvent.metaKey || keyboardEvent.ctrlKey;\n\t\tconst isShift = keyboardEvent.shiftKey;\n\t\tconst key = keyboardEvent.key;\n\n\t\tconst selectedNodes = options.getSelectedNodes ? options.getSelectedNodes() : [];\n\n\t\tif (key === 'Backspace' || key === 'Delete') {\n\t\t\tif (options.onDelete && selectedNodes.length > 0) {\n\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\toptions.onDelete(selectedNodes);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (isMod) {\n\t\t\tconst lowerKey = key.toLowerCase();\n\n\t\t\tif (lowerKey === 'c' && !isShift) {\n\t\t\t\tif (options.onCopy) {\n\t\t\t\t\t// We let the native copy event fire or call onCopy\n\t\t\t\t\toptions.onCopy();\n\t\t\t\t}\n\t\t\t} else if (lowerKey === 'x' && !isShift) {\n\t\t\t\tif (options.onCut) {\n\t\t\t\t\toptions.onCut();\n\t\t\t\t}\n\t\t\t} else if (lowerKey === 'd' && !isShift) {\n\t\t\t\tif (options.onDuplicate && selectedNodes.length > 0) {\n\t\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\t\toptions.onDuplicate(selectedNodes);\n\t\t\t\t}\n\t\t\t} else if (lowerKey === 'a' && !isShift) {\n\t\t\t\tif (options.onSelectAll) {\n\t\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\t\toptions.onSelectAll();\n\t\t\t\t}\n\t\t\t} else if (lowerKey === 'g') {\n\t\t\t\tif (isShift) {\n\t\t\t\t\tif (options.onUngroup && selectedNodes.length > 0) {\n\t\t\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\t\t\toptions.onUngroup(selectedNodes);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (options.onGroup && selectedNodes.length > 0) {\n\t\t\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\t\t\toptions.onGroup(selectedNodes);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (key === '=' || key === '+') {\n\t\t\t\tif (options.onZoomIn) {\n\t\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\t\toptions.onZoomIn();\n\t\t\t\t}\n\t\t\t} else if (key === '-') {\n\t\t\t\tif (options.onZoomOut) {\n\t\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\t\toptions.onZoomOut();\n\t\t\t\t}\n\t\t\t} else if (key === '0') {\n\t\t\t\tif (options.onFitView) {\n\t\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\t\toptions.onFitView();\n\t\t\t\t}\n\t\t\t} else if (lowerKey === 'f') {\n\t\t\t\tif (options.onSearch) {\n\t\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\t\toptions.onSearch();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\ttarget.addEventListener('keydown', handleKeyDown as EventListener);\n\n\treturn () => {\n\t\ttarget.removeEventListener('keydown', handleKeyDown as EventListener);\n\t};\n}\n","import { isEventFromTextInput } from \"./createCanvasClipboard.svelte.js\";\nexport function createCanvasInteractions(options = {}) {\n let isSpacebarPanning = $state.raw(false);\n let trackpadDetected = $state.raw(false);\n let toggledPanMode = false;\n function handleKeyDown(event) {\n if (event.key === \" \" || event.code === \"Space\") {\n if (isSpacebarPanning || isEventFromTextInput(event)) return;\n isSpacebarPanning = true;\n toggledPanMode = true;\n options.onPanModeChange?.(true);\n if (typeof document !== \"undefined\") {\n document.body.classList.add(\"cursor-grab\");\n }\n }\n }\n function handleKeyUp(event) {\n if (event.key === \" \" || event.code === \"Space\") {\n if (!isSpacebarPanning && !toggledPanMode) return;\n isSpacebarPanning = false;\n toggledPanMode = false;\n options.onPanModeChange?.(false);\n if (typeof document !== \"undefined\") {\n document.body.classList.remove(\"cursor-grab\");\n }\n }\n }\n function handleWheel(event) {\n if (event.ctrlKey && !trackpadDetected) {\n trackpadDetected = true;\n options.onTrackpadDetected?.();\n }\n }\n function attachListeners(target) {\n const el = target ?? options.targetElement ?? (typeof window !== \"undefined\" ? window : null);\n if (!el) return () => {\n };\n el.addEventListener(\"keydown\", handleKeyDown);\n el.addEventListener(\"keyup\", handleKeyUp);\n el.addEventListener(\"wheel\", handleWheel, { passive: true });\n return () => {\n el.removeEventListener(\"keydown\", handleKeyDown);\n el.removeEventListener(\"keyup\", handleKeyUp);\n el.removeEventListener(\"wheel\", handleWheel);\n if (typeof document !== \"undefined\") {\n document.body.classList.remove(\"cursor-grab\");\n }\n };\n }\n return {\n get isSpacebarPanning() {\n return isSpacebarPanning;\n },\n get trackpadDetected() {\n return trackpadDetected;\n },\n attachListeners,\n destroy: attachListeners()\n };\n}\nexport const defaultSvelteFlowPreset = {\n snapGrid: [25, 25],\n panOnDrag: [0, 1, 2, 3, 4],\n panOnScroll: false,\n selectionOnDrag: false,\n colorMode: \"system\",\n multiSelectionKey: [\"Shift\", \"Meta\"]\n};\nexport const miroCompatiblePreset = {\n ...defaultSvelteFlowPreset,\n panOnDrag: [1, 2],\n selectionOnDrag: true\n};\nexport function restorePanelPointerEvents(panelSelector = \".svelte-flow__panel\") {\n if (typeof document === \"undefined\") return;\n const panels = document.querySelectorAll(panelSelector);\n panels.forEach((panel) => {\n panel.style.pointerEvents = \"auto\";\n });\n}\n","import { cubicOut } from 'svelte/easing';\nimport type { XYPosition } from '@xyflow/svelte';\nimport type {\n\tCanvasNode,\n\tFanOutTrajectoryOptions,\n\tNodeTransition,\n\tTrajectoryFunction,\n\tTrajectoryPoint\n} from './types.js';\n\n/**\n * Standard linear trajectory: straight line interpolation with linear scale & opacity progression.\n */\nexport const linearTrajectory: TrajectoryFunction = (\n\torigin: XYPosition,\n\ttarget: XYPosition,\n\tprogress: number\n): TrajectoryPoint => {\n\treturn {\n\t\tposition: {\n\t\t\tx: origin.x + (target.x - origin.x) * progress,\n\t\t\ty: origin.y + (target.y - origin.y) * progress\n\t\t},\n\t\tscale: progress,\n\t\topacity: Math.min(1, progress * 1.5)\n\t};\n};\n\n/**\n * Linear position trajectory: pure position interpolation without altering scale or opacity.\n * Used for displaced sibling nodes to ensure their visibility remains unaltered.\n */\nexport const linearPositionTrajectory: TrajectoryFunction = (\n\torigin: XYPosition,\n\ttarget: XYPosition,\n\tprogress: number\n): TrajectoryPoint => {\n\treturn {\n\t\tposition: {\n\t\t\tx: origin.x + (target.x - origin.x) * progress,\n\t\t\ty: origin.y + (target.y - origin.y) * progress\n\t\t}\n\t};\n};\n\n/**\n * Creates a fan-out trajectory where nodes arc outward from origin to target.\n * Matches the curved distribution shown in multi-node branching diagrams.\n */\nexport function createFanOutTrajectory(options: FanOutTrajectoryOptions = {}): TrajectoryFunction {\n\tconst {\n\t\tcurvature = 0.4,\n\t\tstartScale = 0,\n\t\tendScale = 1,\n\t\tstartOpacity = 0,\n\t\tendOpacity = 1\n\t} = options;\n\n\treturn (\n\t\torigin: XYPosition,\n\t\ttarget: XYPosition,\n\t\tprogress: number,\n\t\tindex: number,\n\t\ttotal: number\n\t): TrajectoryPoint => {\n\t\tconst dx = target.x - origin.x;\n\t\tconst dy = target.y - origin.y;\n\n\t\t// Normalized index from -1 (top) to +1 (bottom)\n\t\tconst normIndex = total > 1 ? (index - (total - 1) / 2) / ((total - 1) / 2) : 0;\n\n\t\t// Perpendicular control point offset to create smooth fan arc\n\t\tconst midX = origin.x + dx * 0.4;\n\t\tconst midY = origin.y + dy * 0.1 - normIndex * Math.abs(dx) * 0.15 * curvature;\n\n\t\t// Quadratic Bezier interpolation: B(t) = (1-t)^2 * P0 + 2(1-t)t * P1 + t^2 * P2\n\t\tconst t = progress;\n\t\tconst oneMinusT = 1 - t;\n\n\t\tconst x = oneMinusT * oneMinusT * origin.x + 2 * oneMinusT * t * midX + t * t * target.x;\n\t\tconst y = oneMinusT * oneMinusT * origin.y + 2 * oneMinusT * t * midY + t * t * target.y;\n\n\t\tconst scale = startScale + (endScale - startScale) * progress;\n\t\tconst opacity = startOpacity + (endOpacity - startOpacity) * progress;\n\n\t\treturn {\n\t\t\tposition: { x, y },\n\t\t\tscale,\n\t\t\topacity\n\t\t};\n\t};\n}\n\n/**\n * Creates a custom quadratic Bezier trajectory with a specified or dynamically calculated control point.\n */\nexport function createBezierTrajectory(\n\tgetControlPoint: (origin: XYPosition, target: XYPosition) => XYPosition\n): TrajectoryFunction {\n\treturn (origin: XYPosition, target: XYPosition, progress: number): TrajectoryPoint => {\n\t\tconst cp = getControlPoint(origin, target);\n\t\tconst t = progress;\n\t\tconst oneMinusT = 1 - t;\n\n\t\tconst x = oneMinusT * oneMinusT * origin.x + 2 * oneMinusT * t * cp.x + t * t * target.x;\n\t\tconst y = oneMinusT * oneMinusT * origin.y + 2 * oneMinusT * t * cp.y + t * t * target.y;\n\n\t\treturn {\n\t\t\tposition: { x, y },\n\t\t\tscale: progress,\n\t\t\topacity: progress\n\t\t};\n\t};\n}\n\n/**\n * Coordinates and animates multiple node transitions simultaneously with zero per-frame array allocations.\n * Directly mutates node positions and data (scale, opacity) in-place during the animation loop.\n */\nexport function runMultiNodeTransition<TNode extends CanvasNode = CanvasNode>(\n\ttransitions: NodeTransition<TNode>[],\n\toptions: {\n\t\tdefaultDuration?: number;\n\t\tdefaultEasing?: (t: number) => number;\n\t\tonUpdate?: () => void;\n\t\tonComplete?: () => void;\n\t} = {}\n): () => void {\n\tif (transitions.length === 0) {\n\t\toptions.onComplete?.();\n\t\treturn () => {};\n\t}\n\n\tconst { defaultDuration = 400, defaultEasing = cubicOut, onUpdate, onComplete } = options;\n\n\tlet isCancelled = false;\n\tconst startTime = Date.now();\n\n\tconst items = transitions.map((tr, i) => ({\n\t\t...tr,\n\t\tindex: tr.index ?? i,\n\t\ttotal: tr.total ?? transitions.length,\n\t\tduration: tr.duration ?? defaultDuration,\n\t\teasing: tr.easing ?? defaultEasing,\n\t\tdelay: tr.delay ?? 0,\n\t\ttrajectory: tr.trajectory ?? linearTrajectory\n\t}));\n\n\tfunction frame() {\n\t\tif (isCancelled) return;\n\n\t\tconst now = Date.now();\n\t\tlet allCompleted = true;\n\n\t\tfor (let i = 0; i < items.length; i++) {\n\t\t\tconst item = items[i];\n\t\t\tconst elapsed = now - (startTime + item.delay);\n\n\t\t\tif (elapsed < 0) {\n\t\t\t\tallCompleted = false;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst rawProgress = item.duration <= 0 ? 1 : Math.min(elapsed / item.duration, 1);\n\t\t\tconst progress = item.duration <= 0 ? 1 : item.easing(rawProgress);\n\n\t\t\tconst point = item.trajectory(item.from, item.to, progress, item.index, item.total);\n\n\t\t\t// Direct in-place mutation avoids array reconstruction during RAF\n\t\t\titem.node.position = { ...point.position };\n\n\t\t\tif (point.scale !== undefined || point.opacity !== undefined) {\n\t\t\t\tif (!item.node.data) {\n\t\t\t\t\titem.node.data = {} as any;\n\t\t\t\t}\n\t\t\t\tif (point.scale !== undefined) {\n\t\t\t\t\t(item.node.data as any).scale = point.scale;\n\t\t\t\t}\n\t\t\t\tif (point.opacity !== undefined) {\n\t\t\t\t\t(item.node.data as any).opacity = point.opacity;\n\t\t\t\t\tconst currentStyle = (item.node.style || '').replace(/opacity:\\s*[^;]+;?/g, '').trim();\n\t\t\t\t\titem.node.style = `${currentStyle ? currentStyle + '; ' : ''}opacity: ${point.opacity};`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (rawProgress < 1) {\n\t\t\t\tallCompleted = false;\n\t\t\t}\n\t\t}\n\n\t\tonUpdate?.();\n\n\t\tif (!allCompleted) {\n\t\t\tif (typeof requestAnimationFrame !== 'undefined') {\n\t\t\t\trequestAnimationFrame(frame);\n\t\t\t}\n\t\t} else {\n\t\t\tonComplete?.();\n\t\t}\n\t}\n\n\tframe();\n\n\treturn () => {\n\t\tisCancelled = true;\n\t};\n}\n","import dagre from '@dagrejs/dagre';\nimport type { Rect, XYPosition } from '@xyflow/svelte';\nimport type {\n\tCanvasEdge,\n\tCanvasLayoutOptions,\n\tCanvasNode,\n\tDirectionalDisplacementOptions\n} from './types.js';\n\n/**\n * Calculates a bounding rectangle for a set of nodes if not provided by getNodesBounds.\n */\nexport function computeNodesBoundingBox<TNode extends CanvasNode = CanvasNode>(\n\tnodes: TNode[],\n\tdefaultWidth = 200,\n\tdefaultHeight = 60\n): Rect {\n\tif (nodes.length === 0) {\n\t\treturn { x: 0, y: 0, width: 0, height: 0 };\n\t}\n\n\tlet minX = Infinity;\n\tlet minY = Infinity;\n\tlet maxX = -Infinity;\n\tlet maxY = -Infinity;\n\n\tfor (const node of nodes) {\n\t\tconst width = node.measured?.width ?? (node as any).width ?? defaultWidth;\n\t\tconst height = node.measured?.height ?? (node as any).height ?? defaultHeight;\n\n\t\tminX = Math.min(minX, node.position.x);\n\t\tminY = Math.min(minY, node.position.y);\n\t\tmaxX = Math.max(maxX, node.position.x + width);\n\t\tmaxY = Math.max(maxY, node.position.y + height);\n\t}\n\n\treturn {\n\t\tx: minX,\n\t\ty: minY,\n\t\twidth: maxX - minX,\n\t\theight: maxY - minY\n\t};\n}\n\n/**\n * Pure directional displacement calculation.\n * Shifts downstream or surrounding nodes along an axis to clear space for newly inserted child nodes.\n */\nexport function calculateDirectionalDisplacement<TNode extends CanvasNode = CanvasNode>(params: {\n\texistingNodes: TNode[];\n\toriginNode: TNode;\n\tchildNodes: TNode[];\n\tgetNodesBounds?: (nodes: TNode[]) => Rect;\n\toptions?: DirectionalDisplacementOptions;\n}): Map<string, XYPosition> {\n\tconst {\n\t\texistingNodes,\n\t\toriginNode,\n\t\tchildNodes,\n\t\tgetNodesBounds,\n\t\toptions = {}\n\t} = params;\n\n\tconst {\n\t\tdirection = 'right',\n\t\tgap = 40,\n\t\tspreadSiblingLanes = false,\n\t\tsiblingTolerance = 50,\n\t\tminY\n\t} = options;\n\n\tconst displacedMap = new Map<string, XYPosition>();\n\tif (childNodes.length === 0 || existingNodes.length === 0) {\n\t\treturn displacedMap;\n\t}\n\n\tconst childBounds = getNodesBounds\n\t\t? getNodesBounds(childNodes)\n\t\t: computeNodesBoundingBox(childNodes);\n\n\tconst originWidth = originNode.measured?.width ?? (originNode as any).width ?? 200;\n\tconst originHeight = originNode.measured?.height ?? (originNode as any).height ?? 60;\n\n\t// The delta space required along primary axis\n\tconst deltaPrimary = (direction === 'right' || direction === 'left')\n\t\t? childBounds.width + gap\n\t\t: childBounds.height + gap;\n\n\t// Vertical displacement parameters: upward and downward row clearance\n\tconst deltaUp = Math.max(0, originNode.position.y - childBounds.y + gap);\n\tconst deltaDown = Math.max(\n\t\t0,\n\t\tchildBounds.y + childBounds.height - (originNode.position.y + originHeight) + gap\n\t);\n\n\t// Both above and below displace equally so the row expands symmetrically\n\tconst equalDelta = Math.max(deltaUp, deltaDown);\n\n\tfor (const node of existingNodes) {\n\t\tif (node.id === originNode.id) continue;\n\n\t\tlet newX = node.position.x;\n\t\tlet newY = node.position.y;\n\t\tlet moved = false;\n\n\t\tif (direction === 'right') {\n\t\t\t// Downstream nodes strictly to the right of the origin\n\t\t\tif (node.position.x >= originNode.position.x + originWidth * 0.5) {\n\t\t\t\tnewX += deltaPrimary;\n\t\t\t\tmoved = true;\n\t\t\t} else if (spreadSiblingLanes) {\n\t\t\t\t// Sibling nodes occupying the same vertical space as the exploded cluster\n\t\t\t\tconst isVerticallyOverlapping =\n\t\t\t\t\tnode.position.y + ((node as any).height ?? 60) >= childBounds.y - gap &&\n\t\t\t\t\tnode.position.y <= childBounds.y + childBounds.height + gap;\n\n\t\t\t\tif (isVerticallyOverlapping && Math.abs(node.position.x - originNode.position.x) <= siblingTolerance) {\n\t\t\t\t\tconst pushDirection = node.position.y >= originNode.position.y ? 1 : -1;\n\t\t\t\t\tnewY += pushDirection * (childBounds.height * 0.5 + gap);\n\t\t\t\t\tmoved = true;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (direction === 'left') {\n\t\t\tif (node.position.x <= originNode.position.x) {\n\t\t\t\tnewX -= deltaPrimary;\n\t\t\t\tmoved = true;\n\t\t\t}\n\t\t} else if (direction === 'down') {\n\t\t\tif (node.position.y >= originNode.position.y + originHeight * 0.5) {\n\t\t\t\tnewY += deltaPrimary;\n\t\t\t\tmoved = true;\n\t\t\t}\n\t\t} else if (direction === 'up') {\n\t\t\tif (node.position.y <= originNode.position.y) {\n\t\t\t\tnewY -= deltaPrimary;\n\t\t\t\tmoved = true;\n\t\t\t}\n\t\t} else if (direction === 'vertical') {\n\t\t\t// Row grows vertically:\n\t\t\t// Nodes strictly above the origin node move up by equalDelta\n\t\t\t// Nodes strictly below the origin node move down by equalDelta\n\t\t\t// Both above and below displace equally; horizontal position (x) is strictly preserved\n\t\t\tif (node.position.y < originNode.position.y) {\n\t\t\t\tif (equalDelta > 0) {\n\t\t\t\t\tnewY -= equalDelta;\n\t\t\t\t\tmoved = true;\n\t\t\t\t}\n\t\t\t} else if (node.position.y >= originNode.position.y + originHeight * 0.5) {\n\t\t\t\tif (equalDelta > 0) {\n\t\t\t\t\tnewY += equalDelta;\n\t\t\t\t\tmoved = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (moved) {\n\t\t\tdisplacedMap.set(node.id, { x: newX, y: newY });\n\t\t}\n\t}\n\n\treturn displacedMap;\n}\n\n/**\n * Pure hierarchical Dagre reflow displacement calculation.\n * Calculates new coordinates for surrounding nodes using Dagre hierarchical layout,\n * anchoring the origin node at its current position to eliminate layout jumping.\n */\nexport function calculateReflowDisplacement<\n\tTNode extends CanvasNode = CanvasNode,\n\tTEdge extends CanvasEdge = CanvasEdge\n>(params: {\n\texistingNodes: TNode[];\n\texistingEdges: TEdge[];\n\toriginNode: TNode;\n\tchildNodes: TNode[];\n\tchildEdges?: TEdge[];\n\tgetNodesBounds?: (nodes: TNode[]) => Rect;\n\toptions?: CanvasLayoutOptions;\n}): Map<string, XYPosition> {\n\tconst {\n\t\texistingNodes,\n\t\texistingEdges,\n\t\toriginNode,\n\t\tchildNodes,\n\t\tchildEdges = [],\n\t\toptions = {}\n\t} = params;\n\n\tconst {\n\t\tdirection = 'LR',\n\t\tranksep = 80,\n\t\tnodesep = 30,\n\t\tdefaultNodeWidth = 200,\n\t\tdefaultNodeHeight = 60\n\t} = options;\n\n\tconst displacedMap = new Map<string, XYPosition>();\n\tif (existingNodes.length === 0) return displacedMap;\n\n\tconst allNodes = [...existingNodes, ...childNodes];\n\tconst allEdges = [...existingEdges, ...childEdges];\n\n\tconst dagreGraph = new dagre.graphlib.Graph();\n\tdagreGraph.setDefaultEdgeLabel(() => ({}));\n\tdagreGraph.setGraph({ rankdir: direction, ranksep, nodesep });\n\n\tconst allNodeIds = new Set(allNodes.map((n) => n.id));\n\n\tallNodes.forEach((node) => {\n\t\tconst nodeWidth = node.measured?.width ?? (node as any).width ?? defaultNodeWidth;\n\t\tconst nodeHeight = node.measured?.height ?? (node as any).height ?? defaultNodeHeight;\n\t\tdagreGraph.setNode(node.id, { width: nodeWidth, height: nodeHeight });\n\t});\n\n\tallEdges.forEach((edge) => {\n\t\tif (allNodeIds.has(edge.source) && allNodeIds.has(edge.target)) {\n\t\t\tdagreGraph.setEdge(edge.source, edge.target);\n\t\t}\n\t});\n\n\tdagre.layout(dagreGraph);\n\n\tconst dagreOrigin = dagreGraph.node(originNode.id);\n\tif (!dagreOrigin) return displacedMap;\n\n\tconst originWidth = originNode.measured?.width ?? (originNode as any).width ?? defaultNodeWidth;\n\tconst originHeight = originNode.measured?.height ?? (originNode as any).height ?? defaultNodeHeight;\n\n\t// Calculate offset so origin node remains anchored at its exact initial coordinates\n\tconst anchorOffsetX = originNode.position.x - (dagreOrigin.x - originWidth / 2);\n\tconst anchorOffsetY = originNode.position.y - (dagreOrigin.y - originHeight / 2);\n\n\texistingNodes.forEach((node) => {\n\t\tif (node.id === originNode.id) return;\n\n\t\tconst dagreNode = dagreGraph.node(node.id);\n\t\tif (!dagreNode) return;\n\n\t\tconst nodeWidth = node.measured?.width ?? (node as any).width ?? defaultNodeWidth;\n\t\tconst nodeHeight = node.measured?.height ?? (node as any).height ?? defaultNodeHeight;\n\n\t\tconst targetX = dagreNode.x - nodeWidth / 2 + anchorOffsetX;\n\t\tconst targetY = dagreNode.y - nodeHeight / 2 + anchorOffsetY;\n\n\t\t// Only include if position actually shifted\n\t\tif (Math.abs(targetX - node.position.x) > 0.5 || Math.abs(targetY - node.position.y) > 0.5) {\n\t\t\tdisplacedMap.set(node.id, { x: targetX, y: targetY });\n\t\t}\n\t});\n\n\treturn displacedMap;\n}\n","import { cubicOut } from \"svelte/easing\";\nimport {\n calculateDirectionalDisplacement,\n calculateReflowDisplacement\n} from \"./createCanvasDisplacement.js\";\nimport {\n createFanOutTrajectory,\n linearPositionTrajectory,\n runMultiNodeTransition\n} from \"./createCanvasTrajectory.js\";\nexport function createCanvasExplosion(graph, options = {}) {\n let explodedNodeIds = $state([]);\n const snapshots = /* @__PURE__ */ new Map();\n let activeAnimationCancel = null;\n function isExploded(nodeId) {\n return explodedNodeIds.includes(nodeId);\n }\n function explodeNode(parentId, explodeOptions) {\n if (isExploded(parentId)) {\n return false;\n }\n const parentNode = graph.nodes.find((n) => n.id === parentId);\n if (!parentNode) {\n return false;\n }\n const {\n childNodes,\n childEdges = [],\n connectParentToChildren = \"all\",\n displacementStrategy = \"directional\",\n directionalOptions = {},\n reflowOptions = {},\n trajectory,\n duration = 500,\n staggerDelay = 20,\n easing = cubicOut,\n onComplete\n } = explodeOptions;\n if (childNodes.length === 0) {\n return false;\n }\n let displacementMap;\n if (displacementStrategy === \"dagre\") {\n displacementMap = calculateReflowDisplacement({\n existingNodes: graph.nodes,\n existingEdges: graph.edges,\n originNode: parentNode,\n childNodes,\n childEdges,\n getNodesBounds: options.getNodesBounds,\n options: {\n ...reflowOptions,\n direction: reflowOptions.direction ?? \"LR\"\n }\n });\n } else if (displacementStrategy === \"none\") {\n displacementMap = /* @__PURE__ */ new Map();\n } else {\n displacementMap = calculateDirectionalDisplacement({\n existingNodes: graph.nodes,\n originNode: parentNode,\n childNodes,\n getNodesBounds: options.getNodesBounds,\n options: directionalOptions\n });\n }\n const displacedNodesSnapshot = Array.from(displacementMap.entries()).map(([id]) => {\n const node = graph.nodes.find((n) => n.id === id);\n return {\n id,\n originalPosition: { ...node?.position ?? { x: 0, y: 0 } }\n };\n });\n const edgesToAdd = [...childEdges];\n const defaultCreateEdge = (sourceId, targetId) => {\n if (graph.createEdge) {\n return graph.createEdge(sourceId, targetId);\n }\n return {\n id: crypto.randomUUID(),\n type: \"default\",\n source: sourceId,\n target: targetId\n };\n };\n if (connectParentToChildren === \"all\" || connectParentToChildren === true) {\n childNodes.forEach((child) => {\n const exists = edgesToAdd.some((e) => e.source === parentId && e.target === child.id);\n if (!exists) {\n edgesToAdd.push(defaultCreateEdge(parentId, child.id));\n }\n });\n } else if (connectParentToChildren === \"first\" && childNodes.length > 0) {\n const firstChild = childNodes[0];\n const exists = edgesToAdd.some((e) => e.source === parentId && e.target === firstChild.id);\n if (!exists) {\n edgesToAdd.push(defaultCreateEdge(parentId, firstChild.id));\n }\n }\n const snapshot = {\n parentId,\n childNodeIds: childNodes.map((n) => n.id),\n childEdgeIds: edgesToAdd.map((e) => e.id),\n displacedNodes: displacedNodesSnapshot,\n timestamp: Date.now()\n };\n snapshots.set(parentId, snapshot);\n const originPos = { ...parentNode.position };\n const targetPositions = childNodes.map((child) => ({ ...child.position }));\n childNodes.forEach((child) => {\n child.position = { ...originPos };\n if (!child.data) child.data = {};\n child.data.scale = 0;\n child.data.opacity = 0;\n const currentStyle = (child.style || \"\").replace(/opacity:\\s*[^;]+;?/g, \"\").trim();\n child.style = `${currentStyle ? currentStyle + \"; \" : \"\"}opacity: 0;`;\n });\n edgesToAdd.forEach((edge) => {\n const currentStyle = (edge.style || \"\").replace(/opacity:\\s*[^;]+;?/g, \"\").trim();\n edge.style = `${currentStyle ? currentStyle + \"; \" : \"\"}opacity: 0;`;\n });\n graph.addNodeOrNodes(childNodes, void 0, false);\n if (edgesToAdd.length > 0) {\n graph.addEdges(edgesToAdd, false);\n }\n const chosenTrajectory = trajectory ?? createFanOutTrajectory({ curvature: 0.35 });\n const transitions = [];\n const effectiveStagger = duration === 0 ? 0 : staggerDelay;\n childNodes.forEach((child, i) => {\n transitions.push({\n node: child,\n from: originPos,\n to: targetPositions[i],\n trajectory: chosenTrajectory,\n delay: i * effectiveStagger,\n duration,\n easing,\n index: i,\n total: childNodes.length\n });\n });\n displacementMap.forEach((targetPos, nodeId) => {\n const node = graph.nodes.find((n) => n.id === nodeId);\n if (node) {\n transitions.push({\n node,\n from: { ...node.position },\n to: targetPos,\n trajectory: linearPositionTrajectory,\n duration,\n easing\n });\n }\n });\n if (activeAnimationCancel) {\n activeAnimationCancel();\n }\n activeAnimationCancel = runMultiNodeTransition(transitions, {\n defaultDuration: duration,\n defaultEasing: easing,\n onUpdate: () => {\n if (edgesToAdd.length > 0) {\n const childIdSet = new Set(childNodes.map((c) => c.id));\n const childEdgesInGraph = graph.edges.filter((e) => childIdSet.has(e.target));\n if (childEdgesInGraph.length > 0) {\n childEdgesInGraph.forEach((edge) => {\n const child = childNodes.find((c) => c.id === edge.target);\n const childOpacity = child?.data?.opacity ?? 1;\n const currentStyle = (edge.style || \"\").replace(/opacity:\\s*[^;]+;?/g, \"\").trim();\n edge.style = `${currentStyle ? currentStyle + \"; \" : \"\"}opacity: ${childOpacity};`;\n });\n graph.setEdges([...graph.edges]);\n }\n }\n transitions.forEach((t) => {\n const graphNode = graph.nodes.find((n) => n.id === t.node.id);\n if (graphNode && graphNode !== t.node) {\n graphNode.position = { ...t.node.position };\n graphNode.style = t.node.style;\n if (t.node.data) {\n graphNode.data = { ...graphNode.data, ...t.node.data };\n }\n }\n });\n graph.setNodes([...graph.nodes]);\n },\n onComplete: () => {\n childNodes.forEach((child, i) => {\n const node = graph.nodes.find((n) => n.id === child.id);\n if (node) {\n node.position = { ...targetPositions[i] };\n node.style = (node.style || \"\").replace(/opacity:\\s*[^;]+;?/g, \"\").trim() || void 0;\n if (node.data) {\n node.data.opacity = 1;\n }\n }\n });\n displacementMap.forEach((targetPos, nodeId) => {\n const graphNode = graph.nodes.find((n) => n.id === nodeId);\n if (graphNode) {\n graphNode.position = { ...targetPos };\n }\n });\n edgesToAdd.forEach((edge) => {\n const graphEdge = graph.edges.find((e) => e.id === edge.id);\n if (graphEdge) {\n graphEdge.style = (graphEdge.style || \"\").replace(/opacity:\\s*[^;]+;?/g, \"\").trim() || void 0;\n }\n });\n graph.setNodes([...graph.nodes]);\n graph.setEdges([...graph.edges]);\n explodedNodeIds = [...explodedNodeIds, parentId];\n activeAnimationCancel = null;\n options.onSave?.();\n graph.onSave?.();\n onComplete?.();\n }\n });\n return true;\n }\n function collapseNode(parentId, collapseOptions = {}) {\n const snapshot = snapshots.get(parentId);\n if (!snapshot) {\n return false;\n }\n const parentNode = graph.nodes.find((n) => n.id === parentId);\n if (!parentNode) {\n return false;\n }\n const {\n duration = 400,\n staggerDelay = 15,\n easing = cubicOut,\n trajectory,\n onComplete\n } = collapseOptions;\n const childIdSet = new Set(snapshot.childNodeIds);\n const activeChildNodes = graph.nodes.filter((n) => childIdSet.has(n.id));\n const originPos = { ...parentNode.position };\n const reverseTrajectory = trajectory ?? createFanOutTrajectory({\n curvature: 0.2,\n startScale: 1,\n endScale: 0,\n startOpacity: 1,\n endOpacity: 0\n });\n const transitions = [];\n const effectiveStagger = duration === 0 ? 0 : staggerDelay;\n activeChildNodes.forEach((child, i) => {\n transitions.push({\n node: child,\n from: { ...child.position },\n to: originPos,\n trajectory: reverseTrajectory,\n delay: (activeChildNodes.length - 1 - i) * effectiveStagger,\n duration,\n easing,\n index: i,\n total: activeChildNodes.length\n });\n });\n snapshot.displacedNodes.forEach(({ id, originalPosition }) => {\n const node = graph.nodes.find((n) => n.id === id);\n if (node) {\n transitions.push({\n node,\n from: { ...node.position },\n to: originalPosition,\n trajectory: linearPositionTrajectory,\n duration,\n easing\n });\n }\n });\n if (activeAnimationCancel) {\n activeAnimationCancel();\n }\n activeAnimationCancel = runMultiNodeTransition(transitions, {\n defaultDuration: duration,\n defaultEasing: easing,\n onUpdate: () => {\n const edgeIdSet = new Set(snapshot.childEdgeIds);\n const childEdgesInGraph = graph.edges.filter((e) => edgeIdSet.has(e.id));\n if (childEdgesInGraph.length > 0) {\n childEdgesInGraph.forEach((edge) => {\n const child = activeChildNodes.find((c) => c.id === edge.target);\n const childOpacity = child?.data?.opacity ?? 0;\n const currentStyle = (edge.style || \"\").replace(/opacity:\\s*[^;]+;?/g, \"\").trim();\n edge.style = `${currentStyle ? currentStyle + \"; \" : \"\"}opacity: ${childOpacity};`;\n });\n graph.setEdges([...graph.edges]);\n }\n transitions.forEach((t) => {\n const graphNode = graph.nodes.find((n) => n.id === t.node.id);\n if (graphNode && graphNode !== t.node) {\n graphNode.position = { ...t.node.position };\n graphNode.style = t.node.style;\n if (t.node.data) {\n graphNode.data = { ...graphNode.data, ...t.node.data };\n }\n }\n });\n graph.setNodes([...graph.nodes]);\n },\n onComplete: () => {\n graph.removeNodes(activeChildNodes, false);\n const edgeIdSet = new Set(snapshot.childEdgeIds);\n const edgesToRemove = graph.edges.filter((e) => edgeIdSet.has(e.id));\n if (edgesToRemove.length > 0) {\n graph.removeEdges(edgesToRemove, false);\n }\n snapshot.displacedNodes.forEach(({ id, originalPosition }) => {\n const graphNode = graph.nodes.find((n) => n.id === id);\n if (graphNode) {\n graphNode.position = { ...originalPosition };\n }\n });\n graph.setNodes([...graph.nodes]);\n snapshots.delete(parentId);\n explodedNodeIds = explodedNodeIds.filter((id) => id !== parentId);\n activeAnimationCancel = null;\n options.onSave?.();\n graph.onSave?.();\n onComplete?.();\n }\n });\n return true;\n }\n function toggleExplode(parentId, explodeOptions, collapseOptions) {\n if (isExploded(parentId)) {\n return collapseNode(parentId, collapseOptions);\n }\n return explodeNode(parentId, explodeOptions);\n }\n function getSnapshot(parentId) {\n return snapshots.get(parentId);\n }\n return {\n get explodedNodeIds() {\n return explodedNodeIds;\n },\n isExploded,\n explodeNode,\n collapseNode,\n toggleExplode,\n getSnapshot\n };\n}\n"],"mappings":";;AAAA,SAAS,gBAAgB;AAClB,SAAS,0BAA0B,cAAc,eAAe;AACrE,QAAM,eAAe,aAAa,SAAK,CAAA;AACvC,QAAM,eAAe,aAAa,SAAK,CAAA;AACvC,QAAM,gBAAgB,cAAc,SAAK,CAAA;AACzC,QAAM,gBAAgB,cAAc,SAAK,CAAA;AACzC,QAAM,kBAAkB,IAAI,IAAI,cAAc,IAAG,CAAE,MAAC,CAAM,EAAE,IAAI,CAAC,CAAA,CAAA;AACjE,QAAM,kBAAkB,IAAI,IAAI,cAAc,IAAG,CAAE,MAAC,CAAM,EAAE,IAAI,CAAC,CAAA,CAAA;AACjE,QAAM,iBAAiB,IAAI,IAAI,aAAa,IAAG,CAAE,MAAC,CAAM,EAAE,IAAI,CAAC,CAAA,CAAA;AAC/D,QAAM,iBAAiB,IAAI,IAAI,aAAa,IAAG,CAAE,MAAC,CAAM,EAAE,IAAI,CAAC,CAAA,CAAA;AAC/D,QAAM,eAAe,cAAc,OAAM,CAAE,YAAO,CAAM,eAAe,IAAI,QAAQ,EAAE,CAAA;AACrF,QAAM,eAAe,cAAc,OAAM,CAAE,YAAO,CAAM,eAAe,IAAI,QAAQ,EAAE,CAAA;AACrF,QAAM,eAAe,aAAa,OAAM,CAAE,YAAY;AACpD,UAAM,UAAU,gBAAgB,IAAI,QAAQ,EAAE;AAC9C,QAAE,CAAG,QAAS,QAAO;AACrB,WAAO,KAAK,UAAU,OAAO,MAAM,KAAK,UAAU,OAAO;EAC3D,CAAC;AACD,QAAM,eAAe,aAAa,OAAM,CAAE,YAAY;AACpD,UAAM,UAAU,gBAAgB,IAAI,QAAQ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ubicOut"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor-svelte",
3
- "version": "0.5.3",
3
+ "version": "0.5.5",
4
4
  "description": "Svelte bindings and prompt/rich-text components for @pixerate/editor",
5
5
  "author": "Pixerate",
6
6
  "license": "MIT",
@@ -353,4 +353,240 @@ describe('createCanvasExplosion Rune Lifecycle & Reversibility', () => {
353
353
  explosion.toggleExplode('origin', { childNodes: [child], duration: 0 }, { duration: 0 });
354
354
  expect(explosion.isExploded('origin')).toBe(false);
355
355
  });
356
+
357
+ it('updates node positions and opacity continuously across multiple animation frames without freezing', () => {
358
+ let currentTime = 1000;
359
+ const originalDateNow = Date.now;
360
+ Date.now = () => currentTime;
361
+
362
+ let rafCallback: (() => void) | null = null;
363
+ const originalRaf = globalThis.requestAnimationFrame;
364
+ globalThis.requestAnimationFrame = ((cb: () => void) => {
365
+ rafCallback = cb;
366
+ return 1;
367
+ }) as any;
368
+
369
+ try {
370
+ const origin = createNode('origin', 0, 0);
371
+ const graph = createCanvasGraph({ initialNodes: [origin] });
372
+ const explosion = createCanvasExplosion(graph);
373
+
374
+ const child = createNode('c1', 100, 100);
375
+
376
+ explosion.explodeNode('origin', {
377
+ childNodes: [child],
378
+ duration: 200,
379
+ easing: (t) => t,
380
+ trajectory: linearPositionTrajectory
381
+ });
382
+
383
+ // Frame 0 ran at t=0 (currentTime = 1000)
384
+ let graphChild = graph.nodes.find((n) => n.id === 'c1')!;
385
+ expect(graphChild).toBeDefined();
386
+
387
+ // Advance time by 100ms (progress = 0.5)
388
+ currentTime = 1100;
389
+ expect(rafCallback).not.toBeNull();
390
+ if (rafCallback) {
391
+ const nextCb = rafCallback;
392
+ rafCallback = null;
393
+ nextCb();
394
+ }
395
+
396
+ graphChild = graph.nodes.find((n) => n.id === 'c1')!;
397
+ expect(graphChild.position.x).toBeCloseTo(50, 0);
398
+ expect(graphChild.position.y).toBeCloseTo(50, 0);
399
+
400
+ // Advance time by another 100ms (progress = 1.0)
401
+ currentTime = 1200;
402
+ expect(rafCallback).not.toBeNull();
403
+ if (rafCallback) {
404
+ const nextCb = rafCallback;
405
+ rafCallback = null;
406
+ nextCb();
407
+ }
408
+
409
+ graphChild = graph.nodes.find((n) => n.id === 'c1')!;
410
+ expect(graphChild.position.x).toBeCloseTo(100, 0);
411
+ expect(graphChild.position.y).toBeCloseTo(100, 0);
412
+
413
+ // Collapse node over 200ms
414
+ explosion.collapseNode('origin', {
415
+ duration: 200,
416
+ easing: (t) => t,
417
+ trajectory: linearPositionTrajectory
418
+ });
419
+
420
+ // Advance time by 100ms into collapse (progress = 0.5)
421
+ currentTime = 1300;
422
+ expect(rafCallback).not.toBeNull();
423
+ if (rafCallback) {
424
+ const nextCb = rafCallback;
425
+ rafCallback = null;
426
+ nextCb();
427
+ }
428
+
429
+ graphChild = graph.nodes.find((n) => n.id === 'c1')!;
430
+ expect(graphChild).toBeDefined();
431
+ expect(graphChild.position.x).toBeCloseTo(50, 0);
432
+ expect(graphChild.position.y).toBeCloseTo(50, 0);
433
+
434
+ // Advance time by another 100ms (collapse completion)
435
+ currentTime = 1400;
436
+ expect(rafCallback).not.toBeNull();
437
+ if (rafCallback) {
438
+ const nextCb = rafCallback;
439
+ rafCallback = null;
440
+ nextCb();
441
+ }
442
+
443
+ expect(graph.nodes.some((n) => n.id === 'c1')).toBe(false);
444
+ expect(explosion.isExploded('origin')).toBe(false);
445
+ } finally {
446
+ Date.now = originalDateNow;
447
+ globalThis.requestAnimationFrame = originalRaf;
448
+ }
449
+ });
450
+
451
+ it('animates opacity for child nodes and connecting edges while preserving full opacity of displaced sibling nodes', () => {
452
+ let currentTime = 1000;
453
+ const originalDateNow = Date.now;
454
+ Date.now = () => currentTime;
455
+
456
+ let rafCallback: (() => void) | null = null;
457
+ const originalRaf = globalThis.requestAnimationFrame;
458
+ globalThis.requestAnimationFrame = ((cb: () => void) => {
459
+ rafCallback = cb;
460
+ return 1;
461
+ }) as any;
462
+
463
+ try {
464
+ const origin = createNode('origin', 200, 200);
465
+ const siblingAbove = createNode('above', 200, 100);
466
+ const siblingBelow = createNode('below', 200, 300);
467
+
468
+ const graph = createCanvasGraph({
469
+ initialNodes: [origin, siblingAbove, siblingBelow]
470
+ });
471
+ const explosion = createCanvasExplosion(graph);
472
+
473
+ const child = createNode('c1', 500, 200);
474
+
475
+ const forwardTrajectory = createFanOutTrajectory({
476
+ startOpacity: 0,
477
+ endOpacity: 1,
478
+ curvature: 0
479
+ });
480
+
481
+ const reverseTrajectory = createFanOutTrajectory({
482
+ startOpacity: 1,
483
+ endOpacity: 0,
484
+ curvature: 0
485
+ });
486
+
487
+ explosion.explodeNode('origin', {
488
+ childNodes: [child],
489
+ duration: 200,
490
+ easing: (t) => t,
491
+ trajectory: forwardTrajectory,
492
+ connectParentToChildren: 'all',
493
+ directionalOptions: { direction: 'vertical', gap: 20 }
494
+ });
495
+
496
+ // Frame 0: child node and edge start with opacity 0
497
+ let graphChild = graph.nodes.find((n) => n.id === 'c1')!;
498
+ let graphEdge = graph.edges.find((e) => e.source === 'origin' && e.target === 'c1')!;
499
+ let graphAbove = graph.nodes.find((n) => n.id === 'above')!;
500
+ let graphBelow = graph.nodes.find((n) => n.id === 'below')!;
501
+
502
+ expect(graphChild.style).toContain('opacity: 0');
503
+ expect(graphEdge.style).toContain('opacity: 0');
504
+ // Displaced siblings should never be faded
505
+ expect(graphAbove.style || '').not.toContain('opacity: 0');
506
+ expect(graphBelow.style || '').not.toContain('opacity: 0');
507
+
508
+ // Advance 100ms (50% progress)
509
+ currentTime = 1100;
510
+ if (rafCallback) {
511
+ const nextCb = rafCallback;
512
+ rafCallback = null;
513
+ nextCb();
514
+ }
515
+
516
+ graphChild = graph.nodes.find((n) => n.id === 'c1')!;
517
+ graphEdge = graph.edges.find((e) => e.source === 'origin' && e.target === 'c1')!;
518
+ graphAbove = graph.nodes.find((n) => n.id === 'above')!;
519
+ graphBelow = graph.nodes.find((n) => n.id === 'below')!;
520
+
521
+ expect(graphChild.position.x).toBeCloseTo(335, 0); // quadratic bezier curve at t=0.5
522
+ expect(graphChild.style).toContain('opacity: 0.5');
523
+ expect(graphEdge.style).toContain('opacity: 0.5');
524
+ // Displaced siblings move vertically without horizontal change and without opacity modification
525
+ expect(graphAbove.position.x).toBe(200);
526
+ expect(graphBelow.position.x).toBe(200);
527
+ expect(graphAbove.style || '').not.toContain('opacity: 0.5');
528
+
529
+ // Advance 100ms (100% progress)
530
+ currentTime = 1200;
531
+ if (rafCallback) {
532
+ const nextCb = rafCallback;
533
+ rafCallback = null;
534
+ nextCb();
535
+ }
536
+
537
+ graphChild = graph.nodes.find((n) => n.id === 'c1')!;
538
+ graphEdge = graph.edges.find((e) => e.source === 'origin' && e.target === 'c1')!;
539
+ graphAbove = graph.nodes.find((n) => n.id === 'above')!;
540
+ graphBelow = graph.nodes.find((n) => n.id === 'below')!;
541
+
542
+ expect(graphChild.position.x).toBe(500);
543
+ expect(graphChild.style || '').not.toContain('opacity: 0');
544
+ expect((graphChild.data as any).opacity).toBe(1);
545
+ expect(graphAbove.position.y).toBeLessThan(100);
546
+ expect(graphBelow.position.y).toBeGreaterThan(300);
547
+
548
+ // Now collapse with reverse trajectory
549
+ explosion.collapseNode('origin', {
550
+ duration: 200,
551
+ easing: (t) => t,
552
+ trajectory: reverseTrajectory
553
+ });
554
+
555
+ // Advance 100ms into collapse (50%)
556
+ currentTime = 1300;
557
+ if (rafCallback) {
558
+ const nextCb = rafCallback;
559
+ rafCallback = null;
560
+ nextCb();
561
+ }
562
+
563
+ graphChild = graph.nodes.find((n) => n.id === 'c1')!;
564
+ graphEdge = graph.edges.find((e) => e.source === 'origin' && e.target === 'c1')!;
565
+ expect(graphChild.position.x).toBeCloseTo(365, 0); // quadratic bezier curve at t=0.5 on collapse
566
+ expect(graphChild.style).toContain('opacity: 0.5');
567
+ expect(graphEdge.style).toContain('opacity: 0.5');
568
+
569
+ // Advance 100ms (collapse completion)
570
+ currentTime = 1400;
571
+ if (rafCallback) {
572
+ const nextCb = rafCallback;
573
+ rafCallback = null;
574
+ nextCb();
575
+ }
576
+
577
+ expect(graph.nodes.some((n) => n.id === 'c1')).toBe(false);
578
+ expect(graph.edges.some((e) => e.source === 'origin' && e.target === 'c1')).toBe(false);
579
+ expect(explosion.isExploded('origin')).toBe(false);
580
+
581
+ graphAbove = graph.nodes.find((n) => n.id === 'above')!;
582
+ graphBelow = graph.nodes.find((n) => n.id === 'below')!;
583
+ expect(graphAbove.position.y).toBe(100);
584
+ expect(graphBelow.position.y).toBe(300);
585
+ expect(graphAbove.position.x).toBe(200);
586
+ expect(graphBelow.position.x).toBe(200);
587
+ } finally {
588
+ Date.now = originalDateNow;
589
+ globalThis.requestAnimationFrame = originalRaf;
590
+ }
591
+ });
356
592
  });
@@ -242,37 +242,49 @@ export function createCanvasExplosion<
242
242
  const currentStyle = (edge.style || '').replace(/opacity:\s*[^;]+;?/g, '').trim();
243
243
  edge.style = `${currentStyle ? currentStyle + '; ' : ''}opacity: ${childOpacity};`;
244
244
  });
245
- graph.setEdges(
246
- graph.edges.map((e) => (childIdSet.has(e.target) ? { ...e } : e))
247
- );
245
+ graph.setEdges([...graph.edges]);
248
246
  }
249
247
  }
250
248
 
251
- graph.setNodes(
252
- graph.nodes.map((node) => {
253
- const isTransitioning = transitions.some((t) => t.node.id === node.id);
254
- return isTransitioning ? { ...node, data: { ...node.data } } : node;
255
- })
256
- );
249
+ // Sync any mismatched node references in graph.nodes from transitions
250
+ transitions.forEach((t) => {
251
+ const graphNode = graph.nodes.find((n) => n.id === t.node.id);
252
+ if (graphNode && graphNode !== t.node) {
253
+ graphNode.position = { ...t.node.position };
254
+ graphNode.style = t.node.style;
255
+ if (t.node.data) {
256
+ graphNode.data = { ...graphNode.data, ...t.node.data };
257
+ }
258
+ }
259
+ });
260
+
261
+ graph.setNodes([...graph.nodes]);
257
262
  },
258
263
  onComplete: () => {
259
- childNodes.forEach((child) => {
264
+ childNodes.forEach((child, i) => {
260
265
  const node = graph.nodes.find((n) => n.id === child.id);
261
266
  if (node) {
267
+ node.position = { ...targetPositions[i] };
262
268
  node.style = (node.style || '').replace(/opacity:\s*[^;]+;?/g, '').trim() || undefined;
263
269
  if (node.data) {
264
270
  (node.data as any).opacity = 1;
265
271
  }
266
272
  }
267
273
  });
274
+ displacementMap.forEach((targetPos, nodeId) => {
275
+ const graphNode = graph.nodes.find((n) => n.id === nodeId);
276
+ if (graphNode) {
277
+ graphNode.position = { ...targetPos };
278
+ }
279
+ });
268
280
  edgesToAdd.forEach((edge) => {
269
281
  const graphEdge = graph.edges.find((e) => e.id === edge.id);
270
282
  if (graphEdge) {
271
283
  graphEdge.style = (graphEdge.style || '').replace(/opacity:\s*[^;]+;?/g, '').trim() || undefined;
272
284
  }
273
285
  });
274
- graph.setNodes(graph.nodes.map((node) => ({ ...node, data: { ...node.data } })));
275
- graph.setEdges(graph.edges.map((edge) => ({ ...edge })));
286
+ graph.setNodes([...graph.nodes]);
287
+ graph.setEdges([...graph.edges]);
276
288
  explodedNodeIds = [...explodedNodeIds, parentId];
277
289
  activeAnimationCancel = null;
278
290
  options.onSave?.();
@@ -369,17 +381,22 @@ export function createCanvasExplosion<
369
381
  const currentStyle = (edge.style || '').replace(/opacity:\s*[^;]+;?/g, '').trim();
370
382
  edge.style = `${currentStyle ? currentStyle + '; ' : ''}opacity: ${childOpacity};`;
371
383
  });
372
- graph.setEdges(
373
- graph.edges.map((e) => (edgeIdSet.has(e.id) ? { ...e } : e))
374
- );
384
+ graph.setEdges([...graph.edges]);
375
385
  }
376
386
 
377
- graph.setNodes(
378
- graph.nodes.map((node) => {
379
- const isTransitioning = transitions.some((t) => t.node.id === node.id);
380
- return isTransitioning ? { ...node, data: { ...node.data } } : node;
381
- })
382
- );
387
+ // Sync any mismatched node references in graph.nodes from transitions
388
+ transitions.forEach((t) => {
389
+ const graphNode = graph.nodes.find((n) => n.id === t.node.id);
390
+ if (graphNode && graphNode !== t.node) {
391
+ graphNode.position = { ...t.node.position };
392
+ graphNode.style = t.node.style;
393
+ if (t.node.data) {
394
+ graphNode.data = { ...graphNode.data, ...t.node.data };
395
+ }
396
+ }
397
+ });
398
+
399
+ graph.setNodes([...graph.nodes]);
383
400
  },
384
401
  onComplete: () => {
385
402
  // Animation completed: prune child nodes and edges
@@ -391,6 +408,14 @@ export function createCanvasExplosion<
391
408
  graph.removeEdges(edgesToRemove, false);
392
409
  }
393
410
 
411
+ snapshot.displacedNodes.forEach(({ id, originalPosition }) => {
412
+ const graphNode = graph.nodes.find((n) => n.id === id);
413
+ if (graphNode) {
414
+ graphNode.position = { ...originalPosition };
415
+ }
416
+ });
417
+ graph.setNodes([...graph.nodes]);
418
+
394
419
  snapshots.delete(parentId);
395
420
  explodedNodeIds = explodedNodeIds.filter((id) => id !== parentId);
396
421
  activeAnimationCancel = null;