import { NicePresentationDocument, PresentationSlide, SlideElement, PresentationTheme, PresentationMetadata } from '../types/presentationTypes';

export interface YDoc {
    getMap<T>(name: string): YMap<T>;
    getArray<T>(name: string): YArray<T>;
    getText(name: string): YText;
    on(event: 'update' | 'destroy', callback: (update: Uint8Array, origin: unknown) => void): void;
    off(event: 'update' | 'destroy', callback: (update: Uint8Array, origin: unknown) => void): void;
    transact(fn: () => void, origin?: unknown): void;
    destroy(): void;
    guid: string;
    clientID: number;
}
export interface YMap<T> {
    get(key: string): T | undefined;
    set(key: string, value: T): void;
    delete(key: string): void;
    has(key: string): boolean;
    keys(): IterableIterator<string>;
    values(): IterableIterator<T>;
    entries(): IterableIterator<[string, T]>;
    forEach(fn: (value: T, key: string, map: YMap<T>) => void): void;
    toJSON(): Record<string, T>;
    observe(fn: (event: YMapEvent<T>) => void): void;
    unobserve(fn: (event: YMapEvent<T>) => void): void;
    size: number;
}
export interface YArray<T> {
    get(index: number): T | undefined;
    insert(index: number, content: T[]): void;
    delete(index: number, length: number): void;
    push(content: T[]): void;
    unshift(content: T[]): void;
    slice(start?: number, end?: number): T[];
    toArray(): T[];
    toJSON(): T[];
    length: number;
    observe(fn: (event: YArrayEvent<T>) => void): void;
    unobserve(fn: (event: YArrayEvent<T>) => void): void;
    forEach(fn: (item: T, index: number, array: YArray<T>) => void): void;
}
export interface YText {
    insert(index: number, content: string): void;
    delete(index: number, length: number): void;
    toString(): string;
    length: number;
    observe(fn: (event: YTextEvent) => void): void;
    unobserve(fn: (event: YTextEvent) => void): void;
}
export interface YMapEvent<T> {
    target: YMap<T>;
    keysChanged: Set<string>;
    changes: {
        keys: Map<string, {
            action: 'add' | 'update' | 'delete';
            oldValue?: T;
        }>;
    };
}
export interface YArrayEvent<T> {
    target: YArray<T>;
    delta: Array<{
        insert?: T[];
        delete?: number;
        retain?: number;
    }>;
}
export interface YTextEvent {
    target: YText;
    delta: Array<{
        insert?: string;
        delete?: number;
        retain?: number;
    }>;
}
export interface PresentationAwarenessState {
    user: CollaboratorInfo;
    /** Slide the user is currently viewing/editing */
    currentSlideId?: string;
    /** Element being edited (null = no active edit) */
    editingElementId?: string;
    /** Cursor position on canvas */
    cursor?: {
        x: number;
        y: number;
        timestamp: number;
    };
    /** Current selection (element IDs) */
    selection?: string[];
}
export interface CollaboratorInfo {
    id: string;
    name: string;
    color: string;
    avatar?: string;
}
export interface Awareness {
    clientID: number;
    getLocalState(): PresentationAwarenessState | null;
    setLocalState(state: Partial<PresentationAwarenessState>): void;
    setLocalStateField(field: string, value: unknown): void;
    getStates(): Map<number, PresentationAwarenessState>;
    on(event: 'change' | 'update', callback: (changes: AwarenessChanges) => void): void;
    off(event: 'change' | 'update', callback: (changes: AwarenessChanges) => void): void;
    destroy(): void;
}
export interface AwarenessChanges {
    added: number[];
    updated: number[];
    removed: number[];
}
export interface WebsocketProviderLike {
    awareness: Awareness;
    on(event: 'sync' | 'connection-error' | 'connection-close', callback: (synced: boolean) => void): void;
    off(event: 'sync' | 'connection-error' | 'connection-close', callback: (synced: boolean) => void): void;
    connect(): void;
    disconnect(): void;
    destroy(): void;
    connected: boolean;
}
export interface CollaborationProviderConfig {
    type: 'websocket' | 'webrtc' | 'indexed-db';
    url?: string;
    room: string;
    password?: string;
}
export interface UndoManagerLike {
    undo(): void;
    redo(): void;
    canUndo(): boolean;
    canRedo(): boolean;
    on(event: 'stack-item-added' | 'stack-item-popped', fn: (event: unknown) => void): void;
    stopCapturing(): void;
    clear(): void;
}
export interface CollaborativePresentationState {
    document: NicePresentationDocument | null;
    collaborators: CollaboratorInfo[];
    /** Which slide each collaborator is on */
    collaboratorSlides: Map<string, string>;
    /** Which elements each collaborator is editing */
    collaboratorEditing: Map<string, string | null>;
    /** Cursors per collaborator */
    cursors: Map<string, {
        x: number;
        y: number;
    }>;
    /** Selections per collaborator */
    selections: Map<string, string[]>;
    isConnected: boolean;
    isSynced: boolean;
    localUser: CollaboratorInfo | null;
    undoManager: UndoManagerLike | null;
}
export interface CollaborativePresentationActions {
    addSlide: (slide: PresentationSlide, index?: number) => void;
    updateSlide: (slideId: string, updates: Partial<PresentationSlide>) => void;
    deleteSlide: (slideId: string) => void;
    reorderSlides: (slideIds: string[]) => void;
    addElement: (slideId: string, element: SlideElement) => void;
    updateElement: (slideId: string, elementId: string, updates: Partial<SlideElement>) => void;
    deleteElement: (slideId: string, elementId: string) => void;
    updateTheme: (theme: Partial<PresentationTheme>) => void;
    updateMetadata: (metadata: Partial<PresentationMetadata>) => void;
    setTitle: (title: string) => void;
    setCurrentSlide: (slideId: string) => void;
    setEditingElement: (elementId: string | null) => void;
    setCursor: (position: {
        x: number;
        y: number;
    } | null) => void;
    setSelection: (elementIds: string[]) => void;
    undo: () => void;
    redo: () => void;
    connect: () => void;
    disconnect: () => void;
    setDocument: (doc: NicePresentationDocument) => void;
    getDocument: () => NicePresentationDocument | null;
}
export interface CollaborativePresentationContextValue {
    state: CollaborativePresentationState;
    actions: CollaborativePresentationActions;
}
/**
 * Reconstruct a NicePresentationDocument from Yjs shared types.
 */
export declare function syncYjsToPresentation(slidesArray: YArray<PresentationSlide>, metaMap: YMap<unknown>): NicePresentationDocument;
/**
 * Push a NicePresentationDocument into Yjs shared types.
 */
export declare function syncPresentationToYjs(document: NicePresentationDocument, slidesArray: YArray<PresentationSlide>, metaMap: YMap<unknown>, ydoc: YDoc): void;
export interface UseCollaborativePresentationOptions {
    provider?: CollaborationProviderConfig;
    user: CollaboratorInfo;
    initialDocument?: NicePresentationDocument;
    onSync?: (document: NicePresentationDocument) => void;
    onUserJoin?: (user: CollaboratorInfo) => void;
    onUserLeave?: (user: CollaboratorInfo) => void;
    onConnectionChange?: (connected: boolean) => void;
    /** Factory to create a Yjs Doc (peer dependency injection) */
    createYDoc?: () => YDoc;
    /** Factory to create a transport provider */
    createProvider?: (ydoc: YDoc, config: CollaborationProviderConfig) => WebsocketProviderLike;
    /** Factory to create an undo manager */
    createUndoManager?: (ydoc: YDoc, trackedTypes: unknown[]) => UndoManagerLike;
}
export declare function useCollaborativePresentation(options: UseCollaborativePresentationOptions): CollaborativePresentationContextValue;
//# sourceMappingURL=collaborativePresentation.d.ts.map