import { createContext, useContext } from 'react';
import { Asset, Storyboard, CanvasMetadata } from '@/types';

export interface CanvasContextType {
    initialAssetId?: string;
    initialStoryboardId?: string;
    onClose?: () => void;
    onUpdateAsset?: (id: string, updates: Partial<Asset>) => void;
    onUpdateStoryboard?: (id: string, updates: Partial<Storyboard>) => void;
    
    // Canvas Switching & Persistence
    activeCanvasId?: string | null;
    activeCanvasType?: 'main' | 'asset' | 'storyboard';
    switchCanvas?: (id: string | null, type: 'main' | 'asset' | 'storyboard') => Promise<void>;
    isCanvasLoaded?: boolean;
    currentCanvasMetadata?: CanvasMetadata | null;
}

export const CanvasContext = createContext<CanvasContextType>({});

export const useCanvasContext = () => useContext(CanvasContext);

export interface CanvasActionContextType {
    addHistoryItem: (item: any) => void;
}
export const CanvasActionContext = createContext<CanvasActionContextType>({ addHistoryItem: () => {} });
export const useCanvasActionContext = () => useContext(CanvasActionContext);
