// Type extensions for DOM APIs used in the PDF viewer

declare global {
  interface OffscreenCanvas {
    transferToImageBitmap(): ImageBitmap;
  }

  // Extend Performance interface for non-standard memory API
  interface Performance {
    memory?: {
      usedJSHeapSize: number;
      jsHeapSizeLimit: number;
      totalJSHeapSize?: number;
      jsHeapSizeLimit?: number;
    };
  }

  interface HTMLCanvasElement {
    transferControlToOffscreen(): OffscreenCanvas;
  }

  interface CanvasRenderingContext2D {
    getImageData(sx: number, sy: number, sw: number, sh: number): ImageData;
    putImageData(imageData: ImageData, dx: number, dy: number): void;
  }

  interface ImageBitmap {
    close(): void;
  }

  // Extend Element for our custom methods
  interface Element {
    scrollIntoView(options?: ScrollIntoViewOptions): void;
  }
}