import {
  graphEdgeKey
} from "./chunk-Y4Z4I6WK.js";

// src/graph-dashboard-diff.ts
function diffGraphSnapshots(previous, next) {
  const prevNodeSet = new Set(previous.nodes.map((node) => node.id));
  const nextNodeSet = new Set(next.nodes.map((node) => node.id));
  const prevEdges = new Map(previous.edges.map((edge) => [graphEdgeKey(edge), edge]));
  const nextEdges = new Map(next.edges.map((edge) => [graphEdgeKey(edge), edge]));
  const addedNodes = [...nextNodeSet].filter((id) => !prevNodeSet.has(id)).sort((a, b) => a.localeCompare(b));
  const removedNodes = [...prevNodeSet].filter((id) => !nextNodeSet.has(id)).sort((a, b) => a.localeCompare(b));
  const addedEdges = [...nextEdges.entries()].filter(([key]) => !prevEdges.has(key)).map(([, edge]) => edge).sort((a, b) => a.type.localeCompare(b.type) || a.from.localeCompare(b.from) || a.to.localeCompare(b.to));
  const removedEdges = [...prevEdges.entries()].filter(([key]) => !nextEdges.has(key)).map(([, edge]) => edge).sort((a, b) => a.type.localeCompare(b.type) || a.from.localeCompare(b.from) || a.to.localeCompare(b.to));
  return {
    addedNodes,
    removedNodes,
    addedEdges,
    removedEdges
  };
}

export {
  diffGraphSnapshots
};
//# sourceMappingURL=chunk-3SLRNYNG.js.map