import { MapComponentProps } from './types';
/** Extra capture info handed to `processCapture` alongside the canvas. An object so future fields can be added without breaking callers. */
export interface MapScreenshotCaptureContext {
    /** Device-pixel ratio the canvas was rendered at — use to scale CSS-pixel offsets (e.g. from `getBoundingClientRect()`) into canvas space. On the vector-Google-Maps path this is `window.devicePixelRatio`, since Google's interleaved canvas is captured 1:1 at native device resolution. */
    dpr: number;
}
/**
 * Serialization extension point: receives the final composited canvas (basemap
 * + deck.gl layers) right before it would be read via `toDataURL()`, on every
 * capture path (MapLibre/CARTO, raster and vector Google Maps). Draw onto it
 * (logos, attribution) and/or return the final result — a data-URL string or a
 * `Blob` — to replace the default `canvas.toDataURL()` serialization. Return
 * nothing to keep the default. If you return a `Blob`, always return one: a
 * mixed `Blob | void` callback falls back to a string at runtime while being
 * typed as `Blob`.
 */
export type MapScreenshotProcessCapture<TResult extends string | Blob = string> = (canvas: HTMLCanvasElement, context: MapScreenshotCaptureContext) => TResult | void | Promise<TResult | void>;
/**
 * Captures screenshots of a map instance, supporting both CARTO and Google Maps basemaps.
 *
 * @param mapId - Identifier of the map to capture.
 * @param pixelRatio - Target device-pixel ratio for the capture (both the maplibre basemap and the deck.gl overlay). Defaults to `Math.max(2, window.devicePixelRatio)` — at least 2× so the map is sharp on Linux/Windows displays where `window.devicePixelRatio` is typically 1, but never below the display's native DPR (e.g. 3 on a high-DPI laptop). When the resolved value already matches `window.devicePixelRatio`, no resize happens. Raster Google Maps basemaps are captured via `html2canvas` at the requested scale and are unaffected by the maplibre resize path. **For vector Google Maps `pixelRatio` is a no-op** — the basemap and overlay share Google's WebGL2 canvas, which is captured 1:1 at Google's native device resolution.
 * @param processCapture - Optional serialization extension point, invoked with `(canvas, { dpr })` — the final composited canvas — right before the default `toDataURL()` read, on **every** capture path (MapLibre/CARTO, raster and vector Google Maps). Draw onto the canvas (e.g. a logo, attribution text) and/or return the final result (a data-URL string or a `Blob`) to replace the default serialization; return nothing to keep it. Exceptions from the callback surface through the hook's `error`. On the vector-Google-Maps path `dpr` is `window.devicePixelRatio` (Google's interleaved canvas is captured 1:1 at native device resolution).
 * @returns An object with `takeScreenshot` to trigger capture, `screenshot` as a data URL string (or whatever `processCapture` returns), `isLoading`, `error`, and `reset`.
 *
 * @remarks
 * Both raster and vector Google Maps rendering modes are supported. Raster captures the DOM basemap tiles via `html2canvas` and composites the deck overlay on top; vector reads Google's interleaved WebGL2 canvas directly (basemap + layers in one canvas). A Google map still reporting `UNINITIALIZED` rendering type is treated as not-ready and retried.
 * If map instances are not ready when `takeScreenshot` is called, the capture is automatically retried until they become available.
 * When resizing for capture, maplibre is bumped first (`setPixelRatio` + `triggerRepaint` + `await once('idle')`) so basemap tiles re-render at the new DPR; then deck is bumped via `setProps({ useDevicePixels })` followed by a forced redraw (luma's `_resizeDrawingBufferIfNeeded` only runs from `getCurrentFramebuffer` — i.e. inside a render pass — so `setProps` alone marks the resize but doesn't apply it). After capture, both are restored fire-and-forget so the screenshot promise resolves as soon as the data URL is ready.
 * Readiness gating differs by basemap. MapLibre/CARTO capture waits for the basemap's `idle` flag (`areMapsIdle`) in addition to `isLoaded` and layer load. Google Maps does **not** wait on `areMapsIdle` — it never reliably settles for gmaps because the deck<->Google camera sync fires a trailing `setViewState` after Google's `idle` event and Google doesn't re-fire idle on a static map; gmaps readiness is instead gated by `isLoaded` (tiles), layer load, and `waitForDeckIdle`. In all cases the capture also waits for `deck.needsRedraw()` to return `false` for two consecutive frames before drawing, avoiding partially-painted frames immediately after viewstate changes (e.g. zoom) where tile streaming or layer interpolation can leave the canvas in a transient cut state.
 *
 * @example
 * ```tsx
 * // Default — at least 2× on every OS, native DPR on higher-density displays.
 * const { takeScreenshot, screenshot } = useMapScreenshot({ mapId: 'main-map' })
 *
 * // Force a specific ratio.
 * const { takeScreenshot, screenshot } = useMapScreenshot({ mapId: 'main-map', pixelRatio: 3 })
 *
 * // Draw an overlay and/or take over serialization.
 * const { takeScreenshot, screenshot } = useMapScreenshot({
 *   mapId: 'main-map',
 *   processCapture: (canvas, { dpr }) => {
 *     const ctx = canvas.getContext('2d')!
 *     ctx.drawImage(logo, 16 * dpr, 16 * dpr)
 *     return canvas.toDataURL('image/jpeg', 0.9) // optional — omit to keep the default PNG
 *   },
 * })
 * ```
 */
export declare function useMapScreenshot<TResult extends string | Blob = string>({ mapId, pixelRatio, processCapture, }: {
    mapId: MapComponentProps['id'];
    pixelRatio?: number;
    processCapture?: MapScreenshotProcessCapture<TResult>;
}): {
    takeScreenshot: () => void;
    screenshot: TResult | undefined;
    isLoading: boolean;
    error: Error | undefined;
    reset: () => void;
};
