@pixerate/editor-svelte 0.5.1 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvas/index.js +74 -23
- package/dist/canvas/index.js.map +1 -1
- package/package.json +1 -1
- package/src/canvas/__tests__/canvas-explosion.test.ts +67 -12
- package/src/canvas/createCanvasDisplacement.ts +10 -21
- package/src/canvas/createCanvasExplosion.svelte.ts +69 -5
- package/src/canvas/createCanvasTrajectory.ts +19 -0
- package/src/canvas/index.ts +1 -0
package/dist/canvas/index.js
CHANGED
|
@@ -664,6 +664,14 @@ var linearTrajectory = (origin, target, progress) => {
|
|
|
664
664
|
opacity: Math.min(1, progress * 1.5)
|
|
665
665
|
};
|
|
666
666
|
};
|
|
667
|
+
var linearPositionTrajectory = (origin, target, progress) => {
|
|
668
|
+
return {
|
|
669
|
+
position: {
|
|
670
|
+
x: origin.x + (target.x - origin.x) * progress,
|
|
671
|
+
y: origin.y + (target.y - origin.y) * progress
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
};
|
|
667
675
|
function createFanOutTrajectory(options = {}) {
|
|
668
676
|
const {
|
|
669
677
|
curvature = 0.4,
|
|
@@ -747,6 +755,8 @@ function runMultiNodeTransition(transitions, options = {}) {
|
|
|
747
755
|
}
|
|
748
756
|
if (point.opacity !== void 0) {
|
|
749
757
|
item.node.data.opacity = point.opacity;
|
|
758
|
+
const currentStyle = (item.node.style || "").replace(/opacity:\s*[^;]+;?/g, "").trim();
|
|
759
|
+
item.node.style = `${currentStyle ? currentStyle + "; " : ""}opacity: ${point.opacity};`;
|
|
750
760
|
}
|
|
751
761
|
}
|
|
752
762
|
if (rawProgress < 1) {
|
|
@@ -817,23 +827,11 @@ function calculateDirectionalDisplacement(params) {
|
|
|
817
827
|
const originHeight = originNode.measured?.height ?? originNode.height ?? 60;
|
|
818
828
|
const deltaPrimary = direction === "right" || direction === "left" ? childBounds.width + gap : childBounds.height + gap;
|
|
819
829
|
const deltaUp = Math.max(0, originNode.position.y - childBounds.y + gap);
|
|
820
|
-
|
|
830
|
+
const deltaDown = Math.max(
|
|
821
831
|
0,
|
|
822
832
|
childBounds.y + childBounds.height - (originNode.position.y + originHeight) + gap
|
|
823
833
|
);
|
|
824
|
-
|
|
825
|
-
if (direction === "vertical" && minY !== void 0 && deltaUp > 0) {
|
|
826
|
-
const aboveNodes = existingNodes.filter(
|
|
827
|
-
(n) => n.id !== originNode.id && n.position.y < originNode.position.y
|
|
828
|
-
);
|
|
829
|
-
if (aboveNodes.length > 0) {
|
|
830
|
-
const minAboveY = Math.min(...aboveNodes.map((n) => n.position.y));
|
|
831
|
-
const maxAllowedUp = Math.max(0, minAboveY - minY);
|
|
832
|
-
effectiveDeltaUp = Math.min(deltaUp, maxAllowedUp);
|
|
833
|
-
const unmetUp = deltaUp - effectiveDeltaUp;
|
|
834
|
-
deltaDown += unmetUp;
|
|
835
|
-
}
|
|
836
|
-
}
|
|
834
|
+
const equalDelta = Math.max(deltaUp, deltaDown);
|
|
837
835
|
for (const node of existingNodes) {
|
|
838
836
|
if (node.id === originNode.id) continue;
|
|
839
837
|
let newX = node.position.x;
|
|
@@ -868,13 +866,13 @@ function calculateDirectionalDisplacement(params) {
|
|
|
868
866
|
}
|
|
869
867
|
} else if (direction === "vertical") {
|
|
870
868
|
if (node.position.y < originNode.position.y) {
|
|
871
|
-
if (
|
|
872
|
-
newY -=
|
|
869
|
+
if (equalDelta > 0) {
|
|
870
|
+
newY -= equalDelta;
|
|
873
871
|
moved = true;
|
|
874
872
|
}
|
|
875
873
|
} else if (node.position.y >= originNode.position.y + originHeight * 0.5) {
|
|
876
|
-
if (
|
|
877
|
-
newY +=
|
|
874
|
+
if (equalDelta > 0) {
|
|
875
|
+
newY += equalDelta;
|
|
878
876
|
moved = true;
|
|
879
877
|
}
|
|
880
878
|
}
|
|
@@ -1045,6 +1043,12 @@ function createCanvasExplosion(graph, options = {}) {
|
|
|
1045
1043
|
if (!child.data) child.data = {};
|
|
1046
1044
|
child.data.scale = 0;
|
|
1047
1045
|
child.data.opacity = 0;
|
|
1046
|
+
const currentStyle = (child.style || "").replace(/opacity:\s*[^;]+;?/g, "").trim();
|
|
1047
|
+
child.style = `${currentStyle ? currentStyle + "; " : ""}opacity: 0;`;
|
|
1048
|
+
});
|
|
1049
|
+
edgesToAdd.forEach((edge) => {
|
|
1050
|
+
const currentStyle = (edge.style || "").replace(/opacity:\s*[^;]+;?/g, "").trim();
|
|
1051
|
+
edge.style = `${currentStyle ? currentStyle + "; " : ""}opacity: 0;`;
|
|
1048
1052
|
});
|
|
1049
1053
|
graph.addNodeOrNodes(childNodes, void 0, false);
|
|
1050
1054
|
if (edgesToAdd.length > 0) {
|
|
@@ -1073,7 +1077,7 @@ function createCanvasExplosion(graph, options = {}) {
|
|
|
1073
1077
|
node,
|
|
1074
1078
|
from: { ...node.position },
|
|
1075
1079
|
to: targetPos,
|
|
1076
|
-
trajectory:
|
|
1080
|
+
trajectory: linearPositionTrajectory,
|
|
1077
1081
|
duration,
|
|
1078
1082
|
easing
|
|
1079
1083
|
});
|
|
@@ -1086,10 +1090,42 @@ function createCanvasExplosion(graph, options = {}) {
|
|
|
1086
1090
|
defaultDuration: duration,
|
|
1087
1091
|
defaultEasing: easing,
|
|
1088
1092
|
onUpdate: () => {
|
|
1089
|
-
|
|
1093
|
+
if (edgesToAdd.length > 0) {
|
|
1094
|
+
const childIdSet = new Set(childNodes.map((c) => c.id));
|
|
1095
|
+
const childEdgesInGraph = graph.edges.filter((e) => childIdSet.has(e.target));
|
|
1096
|
+
if (childEdgesInGraph.length > 0) {
|
|
1097
|
+
childEdgesInGraph.forEach((edge) => {
|
|
1098
|
+
const child = childNodes.find((c) => c.id === edge.target);
|
|
1099
|
+
const childOpacity = child?.data?.opacity ?? 1;
|
|
1100
|
+
const currentStyle = (edge.style || "").replace(/opacity:\s*[^;]+;?/g, "").trim();
|
|
1101
|
+
edge.style = `${currentStyle ? currentStyle + "; " : ""}opacity: ${childOpacity};`;
|
|
1102
|
+
});
|
|
1103
|
+
graph.setEdges(graph.edges.map((e) => childIdSet.has(e.target) ? { ...e } : e));
|
|
1104
|
+
}
|
|
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
|
+
}));
|
|
1090
1110
|
},
|
|
1091
1111
|
onComplete: () => {
|
|
1092
|
-
|
|
1112
|
+
childNodes.forEach((child) => {
|
|
1113
|
+
const node = graph.nodes.find((n) => n.id === child.id);
|
|
1114
|
+
if (node) {
|
|
1115
|
+
node.style = (node.style || "").replace(/opacity:\s*[^;]+;?/g, "").trim() || void 0;
|
|
1116
|
+
if (node.data) {
|
|
1117
|
+
node.data.opacity = 1;
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
});
|
|
1121
|
+
edgesToAdd.forEach((edge) => {
|
|
1122
|
+
const graphEdge = graph.edges.find((e) => e.id === edge.id);
|
|
1123
|
+
if (graphEdge) {
|
|
1124
|
+
graphEdge.style = (graphEdge.style || "").replace(/opacity:\s*[^;]+;?/g, "").trim() || void 0;
|
|
1125
|
+
}
|
|
1126
|
+
});
|
|
1127
|
+
graph.setNodes(graph.nodes.map((node) => ({ ...node, data: { ...node.data } })));
|
|
1128
|
+
graph.setEdges(graph.edges.map((edge) => ({ ...edge })));
|
|
1093
1129
|
$5.set(explodedNodeIds, [...$5.get(explodedNodeIds), parentId], true);
|
|
1094
1130
|
activeAnimationCancel = null;
|
|
1095
1131
|
options.onSave?.();
|
|
@@ -1147,7 +1183,7 @@ function createCanvasExplosion(graph, options = {}) {
|
|
|
1147
1183
|
node,
|
|
1148
1184
|
from: { ...node.position },
|
|
1149
1185
|
to: originalPosition,
|
|
1150
|
-
trajectory:
|
|
1186
|
+
trajectory: linearPositionTrajectory,
|
|
1151
1187
|
duration,
|
|
1152
1188
|
easing
|
|
1153
1189
|
});
|
|
@@ -1160,7 +1196,21 @@ function createCanvasExplosion(graph, options = {}) {
|
|
|
1160
1196
|
defaultDuration: duration,
|
|
1161
1197
|
defaultEasing: easing,
|
|
1162
1198
|
onUpdate: () => {
|
|
1163
|
-
|
|
1199
|
+
const edgeIdSet = new Set(snapshot.childEdgeIds);
|
|
1200
|
+
const childEdgesInGraph = graph.edges.filter((e) => edgeIdSet.has(e.id));
|
|
1201
|
+
if (childEdgesInGraph.length > 0) {
|
|
1202
|
+
childEdgesInGraph.forEach((edge) => {
|
|
1203
|
+
const child = activeChildNodes.find((c) => c.id === edge.target);
|
|
1204
|
+
const childOpacity = child?.data?.opacity ?? 0;
|
|
1205
|
+
const currentStyle = (edge.style || "").replace(/opacity:\s*[^;]+;?/g, "").trim();
|
|
1206
|
+
edge.style = `${currentStyle ? currentStyle + "; " : ""}opacity: ${childOpacity};`;
|
|
1207
|
+
});
|
|
1208
|
+
graph.setEdges(graph.edges.map((e) => edgeIdSet.has(e.id) ? { ...e } : e));
|
|
1209
|
+
}
|
|
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
|
+
}));
|
|
1164
1214
|
},
|
|
1165
1215
|
onComplete: () => {
|
|
1166
1216
|
graph.removeNodes(activeChildNodes, false);
|
|
@@ -1219,6 +1269,7 @@ export {
|
|
|
1219
1269
|
isEventFromTextInput,
|
|
1220
1270
|
isValidCanvasNode,
|
|
1221
1271
|
isValidUrl,
|
|
1272
|
+
linearPositionTrajectory,
|
|
1222
1273
|
linearTrajectory,
|
|
1223
1274
|
miroCompatiblePreset,
|
|
1224
1275
|
replaceNodeInGraph,
|
package/dist/canvas/index.js.map
CHANGED
|
@@ -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 * 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}\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\tlet deltaDown = Math.max(\n\t\t0,\n\t\tchildBounds.y + childBounds.height - (originNode.position.y + originHeight) + gap\n\t);\n\n\tlet effectiveDeltaUp = deltaUp;\n\tif (direction === 'vertical' && minY !== undefined && deltaUp > 0) {\n\t\tconst aboveNodes = existingNodes.filter(\n\t\t\t(n) => n.id !== originNode.id && n.position.y < originNode.position.y\n\t\t);\n\t\tif (aboveNodes.length > 0) {\n\t\t\tconst minAboveY = Math.min(...aboveNodes.map((n) => n.position.y));\n\t\t\tconst maxAllowedUp = Math.max(0, minAboveY - minY);\n\t\t\teffectiveDeltaUp = Math.min(deltaUp, maxAllowedUp);\n\t\t\tconst unmetUp = deltaUp - effectiveDeltaUp;\n\t\t\tdeltaDown += unmetUp;\n\t\t}\n\t}\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 to accommodate childBounds above origin\n\t\t\t// Nodes strictly below the origin node move down to accommodate childBounds below origin\n\t\t\t// Horizontal position (x) is strictly preserved\n\t\t\tif (node.position.y < originNode.position.y) {\n\t\t\t\tif (effectiveDeltaUp > 0) {\n\t\t\t\t\tnewY -= effectiveDeltaUp;\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 (deltaDown > 0) {\n\t\t\t\t\tnewY += deltaDown;\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 linearTrajectory,\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 });\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: linearTrajectory,\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 graph.setNodes([...graph.nodes]);\n },\n onComplete: () => {\n graph.setNodes([...graph.nodes]);\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: linearTrajectory,\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 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 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,S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AAe;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(\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,CAAA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AK,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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
2
2
|
import {
|
|
3
3
|
linearTrajectory,
|
|
4
|
+
linearPositionTrajectory,
|
|
4
5
|
createFanOutTrajectory,
|
|
5
6
|
createBezierTrajectory,
|
|
6
7
|
runMultiNodeTransition
|
|
@@ -48,10 +49,35 @@ describe('Canvas Trajectory Math & Transition Runner', () => {
|
|
|
48
49
|
|
|
49
50
|
expect(topPoint.scale).toBeCloseTo(0.6);
|
|
50
51
|
expect(bottomPoint.scale).toBeCloseTo(0.6);
|
|
52
|
+
expect(topPoint.opacity).toBeCloseTo(0.5);
|
|
53
|
+
expect(bottomPoint.opacity).toBeCloseTo(0.5);
|
|
51
54
|
// Trajectory arc deflects top and bottom differently based on normalized index
|
|
52
55
|
expect(topPoint.position.y).not.toBe(bottomPoint.position.y);
|
|
53
56
|
});
|
|
54
57
|
|
|
58
|
+
it('evaluates linearPositionTrajectory without altering scale or opacity', () => {
|
|
59
|
+
const origin = { x: 10, y: 20 };
|
|
60
|
+
const target = { x: 110, y: 120 };
|
|
61
|
+
|
|
62
|
+
const pt = linearPositionTrajectory(origin, target, 0.5, 0, 1);
|
|
63
|
+
expect(pt.position).toEqual({ x: 60, y: 70 });
|
|
64
|
+
expect(pt.scale).toBeUndefined();
|
|
65
|
+
expect(pt.opacity).toBeUndefined();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('creates reverse trajectory fading out opacity from 1 to 0', () => {
|
|
69
|
+
const reverseTrajectory = createFanOutTrajectory({
|
|
70
|
+
startOpacity: 1,
|
|
71
|
+
endOpacity: 0,
|
|
72
|
+
startScale: 1,
|
|
73
|
+
endScale: 0
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const pt = reverseTrajectory({ x: 100, y: 100 }, { x: 0, y: 0 }, 0.5, 0, 1);
|
|
77
|
+
expect(pt.opacity).toBeCloseTo(0.5);
|
|
78
|
+
expect(pt.scale).toBeCloseTo(0.5);
|
|
79
|
+
});
|
|
80
|
+
|
|
55
81
|
it('creates custom bezier trajectory with control point calculator', () => {
|
|
56
82
|
const trajectory = createBezierTrajectory((orig, tgt) => ({
|
|
57
83
|
x: orig.x,
|
|
@@ -90,6 +116,36 @@ describe('Canvas Trajectory Math & Transition Runner', () => {
|
|
|
90
116
|
expect(onComplete).toHaveBeenCalled();
|
|
91
117
|
cancel();
|
|
92
118
|
});
|
|
119
|
+
|
|
120
|
+
it('animates opacity and sets style in runMultiNodeTransition', () => {
|
|
121
|
+
const node: CanvasNode = {
|
|
122
|
+
id: 'n1',
|
|
123
|
+
position: { x: 0, y: 0 },
|
|
124
|
+
data: {}
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const trajectory = createFanOutTrajectory({
|
|
128
|
+
startOpacity: 0,
|
|
129
|
+
endOpacity: 1
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
const cancel = runMultiNodeTransition(
|
|
133
|
+
[
|
|
134
|
+
{
|
|
135
|
+
node,
|
|
136
|
+
from: { x: 0, y: 0 },
|
|
137
|
+
to: { x: 100, y: 100 },
|
|
138
|
+
trajectory,
|
|
139
|
+
duration: 0
|
|
140
|
+
}
|
|
141
|
+
]
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
expect(node.position).toEqual({ x: 100, y: 100 });
|
|
145
|
+
expect((node.data as any).opacity).toBe(1);
|
|
146
|
+
expect(node.style).toContain('opacity: 1');
|
|
147
|
+
cancel();
|
|
148
|
+
});
|
|
93
149
|
});
|
|
94
150
|
|
|
95
151
|
describe('Spatial Displacement Solvers', () => {
|
|
@@ -135,7 +191,7 @@ describe('Spatial Displacement Solvers', () => {
|
|
|
135
191
|
expect(displaced.has('upstream')).toBe(false);
|
|
136
192
|
});
|
|
137
193
|
|
|
138
|
-
it('calculates vertical directional displacement moving above nodes up and below nodes down without shifting x', () => {
|
|
194
|
+
it('calculates vertical directional displacement moving above nodes up and below nodes down equally without shifting x', () => {
|
|
139
195
|
const origin = createNode('origin', 100, 200, 100, 40);
|
|
140
196
|
const above = createNode('above', 100, 100, 100, 40);
|
|
141
197
|
const below = createNode('below', 300, 300, 100, 40);
|
|
@@ -153,36 +209,35 @@ describe('Spatial Displacement Solvers', () => {
|
|
|
153
209
|
options: { direction: 'vertical', gap: 20 }
|
|
154
210
|
});
|
|
155
211
|
|
|
156
|
-
// deltaUp = (200 - 140) + 20 = 80
|
|
157
|
-
|
|
212
|
+
// deltaUp = (200 - 140) + 20 = 80
|
|
213
|
+
// deltaDown = (310 - (200 + 40)) + 20 = 90
|
|
214
|
+
// equalDelta = max(80, 90) = 90 -> BOTH above and below displace equally by 90!
|
|
215
|
+
expect(displaced.get('above')?.y).toBe(100 - 90);
|
|
158
216
|
expect(displaced.get('above')?.x).toBe(100);
|
|
159
217
|
|
|
160
|
-
// deltaDown = (310 - (200 + 40)) + 20 = 90 -> below moves down by 90
|
|
161
218
|
expect(displaced.get('below')?.y).toBe(300 + 90);
|
|
162
|
-
// Crucially: x position is strictly preserved!
|
|
163
219
|
expect(displaced.get('below')?.x).toBe(300);
|
|
164
220
|
});
|
|
165
221
|
|
|
166
|
-
it('
|
|
222
|
+
it('displaces both above and below nodes equally when deltaUp is greater than deltaDown', () => {
|
|
167
223
|
const origin = createNode('origin', 100, 200, 100, 40);
|
|
168
224
|
const above = createNode('above', 100, 100, 100, 40);
|
|
169
225
|
const below = createNode('below', 300, 300, 100, 40);
|
|
170
226
|
|
|
171
227
|
const children = [
|
|
172
|
-
createNode('c1', 250,
|
|
173
|
-
createNode('c2', 250,
|
|
228
|
+
createNode('c1', 250, 100, 100, 30), // top at 100 -> deltaUp = 200 - 100 + 20 = 120
|
|
229
|
+
createNode('c2', 250, 220, 100, 30) // bottom at 250 -> deltaDown = 250 - 240 + 20 = 30
|
|
174
230
|
];
|
|
175
231
|
|
|
176
232
|
const displaced = calculateDirectionalDisplacement({
|
|
177
233
|
existingNodes: [origin, above, below],
|
|
178
234
|
originNode: origin,
|
|
179
235
|
childNodes: children,
|
|
180
|
-
options: { direction: 'vertical', gap: 20
|
|
236
|
+
options: { direction: 'vertical', gap: 20 }
|
|
181
237
|
});
|
|
182
238
|
|
|
183
|
-
//
|
|
184
|
-
expect(displaced.get('above')?.y).toBe(
|
|
185
|
-
// below gets standard 90 + unmet 30 = 120
|
|
239
|
+
// equalDelta = max(120, 30) = 120 -> BOTH displace equally by 120
|
|
240
|
+
expect(displaced.get('above')?.y).toBe(100 - 120);
|
|
186
241
|
expect(displaced.get('below')?.y).toBe(300 + 120);
|
|
187
242
|
expect(displaced.get('below')?.x).toBe(300);
|
|
188
243
|
});
|
|
@@ -88,24 +88,13 @@ export function calculateDirectionalDisplacement<TNode extends CanvasNode = Canv
|
|
|
88
88
|
|
|
89
89
|
// Vertical displacement parameters: upward and downward row clearance
|
|
90
90
|
const deltaUp = Math.max(0, originNode.position.y - childBounds.y + gap);
|
|
91
|
-
|
|
91
|
+
const deltaDown = Math.max(
|
|
92
92
|
0,
|
|
93
93
|
childBounds.y + childBounds.height - (originNode.position.y + originHeight) + gap
|
|
94
94
|
);
|
|
95
95
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const aboveNodes = existingNodes.filter(
|
|
99
|
-
(n) => n.id !== originNode.id && n.position.y < originNode.position.y
|
|
100
|
-
);
|
|
101
|
-
if (aboveNodes.length > 0) {
|
|
102
|
-
const minAboveY = Math.min(...aboveNodes.map((n) => n.position.y));
|
|
103
|
-
const maxAllowedUp = Math.max(0, minAboveY - minY);
|
|
104
|
-
effectiveDeltaUp = Math.min(deltaUp, maxAllowedUp);
|
|
105
|
-
const unmetUp = deltaUp - effectiveDeltaUp;
|
|
106
|
-
deltaDown += unmetUp;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
96
|
+
// Both above and below displace equally so the row expands symmetrically
|
|
97
|
+
const equalDelta = Math.max(deltaUp, deltaDown);
|
|
109
98
|
|
|
110
99
|
for (const node of existingNodes) {
|
|
111
100
|
if (node.id === originNode.id) continue;
|
|
@@ -148,17 +137,17 @@ export function calculateDirectionalDisplacement<TNode extends CanvasNode = Canv
|
|
|
148
137
|
}
|
|
149
138
|
} else if (direction === 'vertical') {
|
|
150
139
|
// Row grows vertically:
|
|
151
|
-
// Nodes strictly above the origin node move up
|
|
152
|
-
// Nodes strictly below the origin node move down
|
|
153
|
-
//
|
|
140
|
+
// Nodes strictly above the origin node move up by equalDelta
|
|
141
|
+
// Nodes strictly below the origin node move down by equalDelta
|
|
142
|
+
// Both above and below displace equally; horizontal position (x) is strictly preserved
|
|
154
143
|
if (node.position.y < originNode.position.y) {
|
|
155
|
-
if (
|
|
156
|
-
newY -=
|
|
144
|
+
if (equalDelta > 0) {
|
|
145
|
+
newY -= equalDelta;
|
|
157
146
|
moved = true;
|
|
158
147
|
}
|
|
159
148
|
} else if (node.position.y >= originNode.position.y + originHeight * 0.5) {
|
|
160
|
-
if (
|
|
161
|
-
newY +=
|
|
149
|
+
if (equalDelta > 0) {
|
|
150
|
+
newY += equalDelta;
|
|
162
151
|
moved = true;
|
|
163
152
|
}
|
|
164
153
|
}
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
} from './createCanvasDisplacement.js';
|
|
15
15
|
import {
|
|
16
16
|
createFanOutTrajectory,
|
|
17
|
+
linearPositionTrajectory,
|
|
17
18
|
linearTrajectory,
|
|
18
19
|
runMultiNodeTransition
|
|
19
20
|
} from './createCanvasTrajectory.js';
|
|
@@ -172,6 +173,13 @@ export function createCanvasExplosion<
|
|
|
172
173
|
if (!child.data) child.data = {} as any;
|
|
173
174
|
(child.data as any).scale = 0;
|
|
174
175
|
(child.data as any).opacity = 0;
|
|
176
|
+
const currentStyle = (child.style || '').replace(/opacity:\s*[^;]+;?/g, '').trim();
|
|
177
|
+
child.style = `${currentStyle ? currentStyle + '; ' : ''}opacity: 0;`;
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
edgesToAdd.forEach((edge) => {
|
|
181
|
+
const currentStyle = (edge.style || '').replace(/opacity:\s*[^;]+;?/g, '').trim();
|
|
182
|
+
edge.style = `${currentStyle ? currentStyle + '; ' : ''}opacity: 0;`;
|
|
175
183
|
});
|
|
176
184
|
|
|
177
185
|
// Add nodes and edges to graph without saving yet
|
|
@@ -208,7 +216,7 @@ export function createCanvasExplosion<
|
|
|
208
216
|
node,
|
|
209
217
|
from: { ...node.position },
|
|
210
218
|
to: targetPos,
|
|
211
|
-
trajectory:
|
|
219
|
+
trajectory: linearPositionTrajectory,
|
|
212
220
|
duration,
|
|
213
221
|
easing
|
|
214
222
|
});
|
|
@@ -224,10 +232,47 @@ export function createCanvasExplosion<
|
|
|
224
232
|
defaultDuration: duration,
|
|
225
233
|
defaultEasing: easing,
|
|
226
234
|
onUpdate: () => {
|
|
227
|
-
|
|
235
|
+
if (edgesToAdd.length > 0) {
|
|
236
|
+
const childIdSet = new Set(childNodes.map((c) => c.id));
|
|
237
|
+
const childEdgesInGraph = graph.edges.filter((e) => childIdSet.has(e.target));
|
|
238
|
+
if (childEdgesInGraph.length > 0) {
|
|
239
|
+
childEdgesInGraph.forEach((edge) => {
|
|
240
|
+
const child = childNodes.find((c) => c.id === edge.target);
|
|
241
|
+
const childOpacity = (child?.data as any)?.opacity ?? 1;
|
|
242
|
+
const currentStyle = (edge.style || '').replace(/opacity:\s*[^;]+;?/g, '').trim();
|
|
243
|
+
edge.style = `${currentStyle ? currentStyle + '; ' : ''}opacity: ${childOpacity};`;
|
|
244
|
+
});
|
|
245
|
+
graph.setEdges(
|
|
246
|
+
graph.edges.map((e) => (childIdSet.has(e.target) ? { ...e } : e))
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
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
|
+
);
|
|
228
257
|
},
|
|
229
258
|
onComplete: () => {
|
|
230
|
-
|
|
259
|
+
childNodes.forEach((child) => {
|
|
260
|
+
const node = graph.nodes.find((n) => n.id === child.id);
|
|
261
|
+
if (node) {
|
|
262
|
+
node.style = (node.style || '').replace(/opacity:\s*[^;]+;?/g, '').trim() || undefined;
|
|
263
|
+
if (node.data) {
|
|
264
|
+
(node.data as any).opacity = 1;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
edgesToAdd.forEach((edge) => {
|
|
269
|
+
const graphEdge = graph.edges.find((e) => e.id === edge.id);
|
|
270
|
+
if (graphEdge) {
|
|
271
|
+
graphEdge.style = (graphEdge.style || '').replace(/opacity:\s*[^;]+;?/g, '').trim() || undefined;
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
graph.setNodes(graph.nodes.map((node) => ({ ...node, data: { ...node.data } })));
|
|
275
|
+
graph.setEdges(graph.edges.map((edge) => ({ ...edge })));
|
|
231
276
|
explodedNodeIds = [...explodedNodeIds, parentId];
|
|
232
277
|
activeAnimationCancel = null;
|
|
233
278
|
options.onSave?.();
|
|
@@ -300,7 +345,7 @@ export function createCanvasExplosion<
|
|
|
300
345
|
node,
|
|
301
346
|
from: { ...node.position },
|
|
302
347
|
to: originalPosition,
|
|
303
|
-
trajectory:
|
|
348
|
+
trajectory: linearPositionTrajectory,
|
|
304
349
|
duration,
|
|
305
350
|
easing
|
|
306
351
|
});
|
|
@@ -315,7 +360,26 @@ export function createCanvasExplosion<
|
|
|
315
360
|
defaultDuration: duration,
|
|
316
361
|
defaultEasing: easing,
|
|
317
362
|
onUpdate: () => {
|
|
318
|
-
|
|
363
|
+
const edgeIdSet = new Set(snapshot.childEdgeIds);
|
|
364
|
+
const childEdgesInGraph = graph.edges.filter((e) => edgeIdSet.has(e.id));
|
|
365
|
+
if (childEdgesInGraph.length > 0) {
|
|
366
|
+
childEdgesInGraph.forEach((edge) => {
|
|
367
|
+
const child = activeChildNodes.find((c) => c.id === edge.target);
|
|
368
|
+
const childOpacity = (child?.data as any)?.opacity ?? 0;
|
|
369
|
+
const currentStyle = (edge.style || '').replace(/opacity:\s*[^;]+;?/g, '').trim();
|
|
370
|
+
edge.style = `${currentStyle ? currentStyle + '; ' : ''}opacity: ${childOpacity};`;
|
|
371
|
+
});
|
|
372
|
+
graph.setEdges(
|
|
373
|
+
graph.edges.map((e) => (edgeIdSet.has(e.id) ? { ...e } : e))
|
|
374
|
+
);
|
|
375
|
+
}
|
|
376
|
+
|
|
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
|
+
);
|
|
319
383
|
},
|
|
320
384
|
onComplete: () => {
|
|
321
385
|
// Animation completed: prune child nodes and edges
|
|
@@ -26,6 +26,23 @@ export const linearTrajectory: TrajectoryFunction = (
|
|
|
26
26
|
};
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Linear position trajectory: pure position interpolation without altering scale or opacity.
|
|
31
|
+
* Used for displaced sibling nodes to ensure their visibility remains unaltered.
|
|
32
|
+
*/
|
|
33
|
+
export const linearPositionTrajectory: TrajectoryFunction = (
|
|
34
|
+
origin: XYPosition,
|
|
35
|
+
target: XYPosition,
|
|
36
|
+
progress: number
|
|
37
|
+
): TrajectoryPoint => {
|
|
38
|
+
return {
|
|
39
|
+
position: {
|
|
40
|
+
x: origin.x + (target.x - origin.x) * progress,
|
|
41
|
+
y: origin.y + (target.y - origin.y) * progress
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
|
|
29
46
|
/**
|
|
30
47
|
* Creates a fan-out trajectory where nodes arc outward from origin to target.
|
|
31
48
|
* Matches the curved distribution shown in multi-node branching diagrams.
|
|
@@ -161,6 +178,8 @@ export function runMultiNodeTransition<TNode extends CanvasNode = CanvasNode>(
|
|
|
161
178
|
}
|
|
162
179
|
if (point.opacity !== undefined) {
|
|
163
180
|
(item.node.data as any).opacity = point.opacity;
|
|
181
|
+
const currentStyle = (item.node.style || '').replace(/opacity:\s*[^;]+;?/g, '').trim();
|
|
182
|
+
item.node.style = `${currentStyle ? currentStyle + '; ' : ''}opacity: ${point.opacity};`;
|
|
164
183
|
}
|
|
165
184
|
}
|
|
166
185
|
|