/**
 * UDocViewer - Document viewer component.
 *
 * Binds to a loaded document and optionally provides UI.
 * Created via `client.createViewer()`.
 */
import type { WorkerClient, PageInfo, FontUsageEntry } from "./worker/index.js";
import type { ViewerOptions } from "./UDocClient.js";
import type { PrintDialogResult } from "./ui/viewer/components/PrintDialog.js";
import type { Destination, OutlineItem, ScrollAlignment } from "./ui/viewer/navigation.js";
import { type Annotation } from "./ui/viewer/annotation/index.js";
export type { Annotation } from "./ui/viewer/annotation/index.js";
export type { SearchMatch } from "./ui/viewer/state.js";
import type { LayoutPage } from "./worker/index.js";
import { type ViewMode, type PanelTab, type ScrollMode, type LayoutMode, type ZoomMode, type PageRotation, type SpacingMode, type ThemeMode, type SearchMatch } from "./ui/viewer/state.js";
import { type IPerformanceCounter } from "./performance/index.js";
/**
 * Options for rendering a page.
 */
export interface RenderOptions {
    /**
     * Scale factor for rendering.
     * 1 = 72 DPI (1 point = 1 pixel)
     * 2 = 144 DPI (retina)
     * @default 1
     */
    scale?: number;
    /**
     * Output format.
     * @default 'image-data'
     */
    format?: "image-data" | "image-bitmap" | "blob" | "data-url";
    /**
     * Image type when format is 'blob' or 'data-url'.
     * @default 'image/png'
     */
    imageType?: "image/png" | "image/jpeg";
    /**
     * JPEG quality (0-1) when imageType is 'image/jpeg'.
     * @default 0.92
     */
    quality?: number;
    /**
     * Include annotations in render.
     * @default true
     */
    annotations?: boolean;
    /**
     * Skip all cache and queue, call worker directly.
     * Useful for one-off renders that shouldn't affect the render queue.
     * @default false
     */
    force?: boolean;
    /**
     * Boost render priority by calling boostRenderPage before rendering.
     * This prioritizes this page and nearby pages in the render queue.
     * @default false
     */
    boost?: boolean;
}
/**
 * Rendered page result.
 */
export type RenderedPage = ImageData | ImageBitmap | Blob | string;
/**
 * Document metadata.
 */
export interface DocumentMetadata {
    title?: string;
    author?: string;
    subject?: string;
    keywords?: string;
    creator?: string;
    producer?: string;
    creationDate?: Date;
    modificationDate?: Date;
}
/**
 * Re-export navigation types for public API.
 */
export type { Destination, DestinationDisplay, OutlineItem, ScrollAlignment } from "./ui/viewer/navigation.js";
/**
 * Download progress information.
 */
export interface DownloadProgress {
    /** Bytes loaded so far. */
    loaded: number;
    /** Total bytes (may be 0 if Content-Length not available). */
    total: number;
    /** Progress percentage 0-100 (null if total unknown). */
    percent: number | null;
}
/**
 * UI component identifier for visibility events.
 */
export type UIComponent = "toolbar" | "floatingToolbar" | "leftPanel" | "rightPanel" | "fullscreen" | "download" | "print" | PanelTab;
/**
 * Event map for viewer events.
 */
export interface ViewerEventMap {
    "document:load": {
        pageCount: number;
    };
    "document:close": Record<string, never>;
    "download:progress": DownloadProgress;
    error: {
        error: Error;
        phase: "fetch" | "parse" | "render";
    };
    "page:change": {
        page: number;
        previousPage: number;
    };
    "ui:visibilityChange": {
        component: UIComponent;
        visible: boolean;
    };
    "panel:change": {
        panel: PanelTab | null;
        previousPanel: PanelTab | null;
    };
    "font:usageChange": {
        entries: FontUsageEntry[];
    };
    "search:change": {
        matches: SearchMatch[];
        activeIndex: number;
    };
}
type EventHandler<K extends keyof ViewerEventMap> = (payload: ViewerEventMap[K]) => void;
/**
 * Document viewer component.
 *
 * Supports both UI mode (with container) and headless mode (without container).
 * Use `client.createViewer()` to create instances.
 */
export declare class UDocViewer {
    private workerClient;
    private container;
    private uiShell;
    private documentId;
    private _pageCount;
    private _pageInfo;
    private destroyed;
    private eventHandlers;
    private _performanceCounter;
    private viewOverrides;
    private currentFormat;
    private sourceFilename;
    private storeUnsub;
    private fontUsageUnsub;
    private sdkVersion;
    /**
     * @internal
     * Use `client.createViewer()` instead.
     */
    constructor(workerClient: WorkerClient, options?: ViewerOptions, showAttribution?: boolean, showLoadingOverlay?: boolean, sdkVersion?: string);
    /**
     * Performance counter for tracking operation timings.
     * Only records data when `enablePerformanceCounter` is true.
     */
    get performanceCounter(): IPerformanceCounter;
    private buildStateOverrides;
    private buildViewModeOverrides;
    private computeViewDefaults;
    /**
     * Load a document.
     *
     * @param source - URL string, File object, or raw bytes
     */
    load(source: string | File | Uint8Array): Promise<void>;
    /**
     * Close the current document.
     * Viewer returns to empty state.
     */
    close(): void;
    /**
     * Whether a document is currently loaded.
     */
    get isLoaded(): boolean;
    /**
     * Check if the loaded document requires a password to open.
     * @returns True if the document needs authentication before pages can be accessed.
     */
    needsPassword(): Promise<boolean>;
    /**
     * Authenticate with a password to unlock an encrypted document.
     *
     * After successful authentication, page info is reloaded and the document
     * becomes fully accessible.
     *
     * @param password - The password to try
     * @returns True if authentication succeeded, false if the password was incorrect.
     */
    authenticate(password: string): Promise<boolean>;
    /**
     * Handle password submission from the UI dialog.
     * @internal
     */
    private handlePasswordSubmit;
    /**
     * Total number of pages.
     * Returns 0 if no document is loaded.
     */
    get pageCount(): number;
    /**
     * Document metadata (title, author, etc.).
     * Returns null if no document is loaded.
     */
    get metadata(): DocumentMetadata | null;
    /**
     * Get document outline (table of contents / bookmarks).
     */
    getOutline(): Promise<OutlineItem[]>;
    /**
     * Get font usage information for the loaded document.
     *
     * Returns how each font spec in the document was resolved,
     * including primary resolution and any glyph-fallback fonts.
     * This information is populated during rendering — call after
     * at least one page has been rendered for results.
     */
    getFontUsage(): Promise<FontUsageEntry[]>;
    /**
     * Get page dimensions in points (1 point = 1/72 inch).
     * @param page - Page index (0-based)
     */
    getPageInfo(page: number): Promise<PageInfo>;
    /**
     * Get annotations on a specific page.
     * @param page - Page index (0-based)
     */
    getPageAnnotations(page: number): Promise<Annotation[]>;
    /**
     * Get the layout structure for a specific page.
     * Returns frames, parcels, lines, runs, glyphs, tables, and grids
     * without building the full display list.
     * All coordinates are in points (1/72 inch).
     * @param page - Page index (0-based)
     */
    getLayoutPage(page: number): Promise<LayoutPage>;
    /**
     * Get the current page number (1-based).
     */
    get currentPage(): number;
    /**
     * Navigate to a specific page.
     * @param page - Page number (1-based)
     */
    goToPage(page: number): void;
    /**
     * Navigate to a destination (page + position + zoom).
     * @param destination - Full destination object with page index and display mode
     * @param options - Optional navigation options
     * @param options.scrollAlignment - How to align the target in the viewport:
     *   "top" (default), "center", "bottom", or "nearest" (minimal scroll to fit in view)
     */
    goToDestination(destination: Destination, options?: {
        scrollAlignment?: ScrollAlignment;
    }): void;
    /**
     * Navigate to the next page.
     */
    nextPage(): void;
    /**
     * Navigate to the previous page.
     */
    previousPage(): void;
    /**
     * Current zoom level (1 = 100%).
     */
    get zoom(): number;
    /**
     * Current zoom mode.
     */
    get zoomMode(): ZoomMode;
    /**
     * Zoom in to the next zoom step.
     */
    zoomIn(): void;
    /**
     * Zoom out to the previous zoom step.
     */
    zoomOut(): void;
    /**
     * Set zoom to a specific level (1 = 100%). Switches to custom zoom mode.
     */
    setZoom(zoom: number): void;
    /**
     * Set zoom mode.
     */
    setZoomMode(mode: ZoomMode): void;
    /** Current scroll mode. */
    get scrollMode(): ScrollMode;
    /** Current layout mode. */
    get layoutMode(): LayoutMode;
    /** Current page rotation in degrees. */
    get pageRotation(): PageRotation;
    /** Current spacing mode. */
    get spacingMode(): SpacingMode;
    /** Whether the viewer is in fullscreen mode. */
    get isFullscreen(): boolean;
    /** Current view mode. */
    get viewMode(): ViewMode;
    /**
     * Set view mode (paged or continuous).
     */
    setViewMode(mode: ViewMode): void;
    /**
     * Get the current view mode.
     */
    getViewMode(): ViewMode;
    /**
     * Set scroll mode.
     */
    setScrollMode(mode: ScrollMode): void;
    /** Default scroll alignment for navigation (outline, links, goToDestination). */
    get navigationScrollAlignment(): ScrollAlignment;
    /** Default scroll alignment for search result navigation. */
    get searchScrollAlignment(): ScrollAlignment;
    /**
     * Set the default scroll alignment for navigation (outline, links, goToDestination).
     */
    setNavigationScrollAlignment(alignment: ScrollAlignment): void;
    /**
     * Set the default scroll alignment for search result navigation.
     */
    setSearchScrollAlignment(alignment: ScrollAlignment): void;
    /**
     * Set page layout mode.
     */
    setLayoutMode(mode: LayoutMode): void;
    /**
     * Set page rotation.
     */
    setPageRotation(rotation: PageRotation): void;
    /**
     * Set spacing mode.
     */
    setSpacingMode(mode: SpacingMode): void;
    /**
     * Enter or exit fullscreen mode.
     */
    setFullscreen(fullscreen: boolean): void;
    /**
     * Show or hide the top toolbar.
     */
    setToolbarVisible(visible: boolean): void;
    /**
     * Show or hide the floating toolbar (page navigation, zoom, view mode controls).
     */
    setFloatingToolbarVisible(visible: boolean): void;
    /**
     * Enable or disable the fullscreen button.
     */
    setFullscreenEnabled(enabled: boolean): void;
    /**
     * Enable or disable the download button.
     */
    setDownloadEnabled(enabled: boolean): void;
    /**
     * Enable or disable the print button.
     */
    setPrintEnabled(enabled: boolean): void;
    /** Current theme mode. */
    get theme(): ThemeMode;
    /**
     * Set the viewer color theme.
     * @param theme - 'light', 'dark', or 'system'
     */
    setTheme(theme: ThemeMode): void;
    /**
     * Enable or disable the theme toggle button in the toolbar.
     */
    setThemeSwitchingEnabled(enabled: boolean): void;
    /**
     * Enable or disable text selection in the viewer.
     */
    setTextSelectionEnabled(enabled: boolean): void;
    /**
     * Set the minimum zoom level.
     */
    setMinZoom(zoom: number): void;
    /**
     * Set the maximum zoom level.
     */
    setMaxZoom(zoom: number): void;
    /**
     * Enable or disable the entire left panel area.
     * When disabled, the left panel is hidden and all left panel tabs are inaccessible.
     */
    setLeftPanelEnabled(enabled: boolean): void;
    /**
     * Enable or disable the entire right panel area.
     * When disabled, the right panel is hidden and all right panel tabs are inaccessible.
     */
    setRightPanelEnabled(enabled: boolean): void;
    /**
     * Enable or disable a specific panel tab.
     * Disabled panels are removed from the UI and cannot be opened.
     * If the panel is currently open and being disabled, it will be closed.
     */
    setPanelEnabled(panel: PanelTab, enabled: boolean): void;
    /**
     * Open a specific panel.
     * Has no effect if the panel is disabled via `setPanelEnabled()` or a `disable*` option.
     */
    openPanel(panel: PanelTab): void;
    /**
     * Close the currently open panel.
     */
    closePanel(): void;
    /**
     * Search for text in the document.
     * Returns a promise that resolves with the final search matches once all page text
     * has been loaded and the search completes. Highlight overlays are rendered automatically.
     *
     * Results are also available via the `search:change` event (fires for intermediate
     * results as pages load) and the `searchMatches` getter.
     *
     * @param query - The text to search for
     * @param options - Search options
     * @returns Promise resolving with the search matches
     */
    search(query: string, options?: {
        caseSensitive?: boolean;
    }): Promise<SearchMatch[]>;
    /**
     * Navigate to the next search match.
     * @param options - Optional overrides for this navigation
     * @param options.scrollAlignment - Override scroll alignment for this call only
     */
    searchNext(options?: {
        scrollAlignment?: ScrollAlignment;
    }): void;
    /**
     * Navigate to the previous search match.
     * @param options - Optional overrides for this navigation
     * @param options.scrollAlignment - Override scroll alignment for this call only
     */
    searchPrev(options?: {
        scrollAlignment?: ScrollAlignment;
    }): void;
    /**
     * Clear the current search query and results.
     */
    clearSearch(): void;
    /**
     * Get the current search matches.
     */
    get searchMatches(): SearchMatch[];
    /**
     * Get the index of the currently active search match (-1 if none).
     */
    get searchActiveIndex(): number;
    /**
     * Set the active search match by index. Navigates the viewport to the match.
     *
     * @param index - 0-based index into `searchMatches`
     * @param options - Optional overrides for this navigation
     * @param options.scrollAlignment - Override scroll alignment for this call only
     */
    setSearchActiveIndex(index: number, options?: {
        scrollAlignment?: ScrollAlignment;
    }): void;
    /**
     * Render a page to an image.
     *
     * @param page - Page index (0-based)
     * @param options - Render options (scale, format, etc.)
     */
    renderPage(page: number, options?: RenderOptions): Promise<RenderedPage>;
    /**
     * Render a thumbnail of a page.
     *
     * Similar to renderPage but uses lower priority in the render queue,
     * making it suitable for generating thumbnails without blocking main page renders.
     *
     * @param page - Page index (0-based)
     * @param options - Render options (scale, format, etc.)
     */
    renderThumbnail(page: number, options?: RenderOptions): Promise<RenderedPage>;
    /**
     * Internal method to render a page with a specific render type.
     */
    private renderWithType;
    /**
     * Convert an ImageBitmap to the requested output format.
     */
    private convertBitmapToFormat;
    /**
     * Export document as bytes.
     * If annotations have been edited, saves them into the PDF before returning.
     */
    toBytes(): Promise<Uint8Array>;
    /**
     * Download document to user's device.
     * @param filename - Filename for download (defaults to original source filename)
     */
    download(filename?: string): Promise<void>;
    /**
     * Print the document.
     * Shows the print dialog when called without options (from public API).
     * When called with options (from the dialog), renders selected pages and opens the browser print dialog.
     */
    print(options?: PrintDialogResult): Promise<void>;
    /**
     * Resolve a PrintPageRange into an array of 0-based page indices.
     * @internal
     */
    private resolvePageIndices;
    /**
     * Print PDF by loading original bytes into an iframe — vector quality, no rendering needed.
     * @internal
     */
    private printPdfNative;
    /** Map quality preset to DPI scale factor. */
    private static qualityToDpiScale;
    /**
     * Print by rendering selected pages to images.
     * @internal
     */
    private printRendered;
    /** Returns the MIME type for the current document format. */
    private getMimeType;
    /** Returns a default filename based on the source or format. */
    private getDefaultFilename;
    /**
     * Subscribe to an event.
     * @returns Unsubscribe function
     */
    on<K extends keyof ViewerEventMap>(event: K, handler: EventHandler<K>): () => void;
    /**
     * Unsubscribe from an event.
     */
    off<K extends keyof ViewerEventMap>(event: K, handler: EventHandler<K>): void;
    /**
     * Destroy the viewer and release resources.
     */
    destroy(): void;
    /**
     * Get the document ID (for internal use).
     * @internal
     */
    getDocumentId(): string | null;
    /**
     * Initialize the viewer with an already-loaded document ID.
     * Used by UDocClient.compose() to create viewers for composed documents.
     * @internal
     */
    initializeFromDocId(docId: string): Promise<void>;
    private resolveContainer;
    private resolveSourceWithFilename;
    private fetchWithProgress;
    private emit;
    private createEngineAdapter;
    private ensureNotDestroyed;
    private ensureLoaded;
    private ensureUiMode;
}
//# sourceMappingURL=UDocViewer.d.ts.map