// This program has been developed by students from the bachelor Computer Science at Utrecht
// University within the Software Project course.
// © Copyright Utrecht University (Department of Information and Computing Sciences)
import {type Edge, type Node } from "@xyflow/react";

export type SavedProject = {
  name: string;
  savedASavedProject: string; // ISO timestamp
  nodes: Node[];
  edges: Edge[];
};

// Creates a JSON Blob containing the current visual program (nodes + edges)
export function makeProjectBlob(name: string, nodes: Node[], edges: Edge[]): Blob {
  const payload = {
    name,
    savedAt: new Date().toISOString(),
    nodes,
    edges,
  };
  return new Blob([JSON.stringify(payload, null, 2)], { type: "application/json" });
}