import type { Scene } from "@/lib/studio-types";

export const STUDIO_HISTORY_LIMIT = 50;

export interface StudioHistorySnapshot {
  scenes: Scene[];
  activeSceneId: string;
  selectedLayerId: string | null;
}

export function cloneScenes(scenes: Scene[]): Scene[] {
  return scenes.map((scene) => ({
    ...scene,
    layers: scene.layers.map((layer) => ({
      ...layer,
      props: { ...layer.props },
    })),
  }));
}

export function captureHistorySnapshot(state: {
  scenes: Scene[];
  activeSceneId: string;
  selectedLayerId: string | null;
}): StudioHistorySnapshot {
  return {
    scenes: cloneScenes(state.scenes),
    activeSceneId: state.activeSceneId,
    selectedLayerId: state.selectedLayerId,
  };
}
