// Type definitions for Tauri-specific functionality and bridge communication

declare global {
  interface Window {
    // Tauri IPC bridge
    __TAURI__?: {
      invoke: (cmd: string, args?: any) => Promise<any>;
    };

    // Our custom message bridge
    MessageBridge?: any;
  }

  // Custom brittle protocol types
  interface BrittleProtocol {
    getAnnotations(refId: string): Promise<any[]>;
    createAnnotation(refId: string, page: number, quads: any[], text?: string): Promise<string>;
    updateAnnotation(annotation: any): Promise<void>;
    deleteAnnotation(refId: string, annotationId: string): Promise<void>;
  }

  // Extend the global scope with our custom types
  interface CustomEventMap {
    "brittle:annotations-request": CustomEvent;
    "brittle:annotations-set": CustomEvent;
    "brittle:annotation-create": CustomEvent;
    "brittle:annotation-click": CustomEvent;
  }
}