import { Ref } from 'vue'; import { RuntimeDocument, SuperDocFitWidthOptions, SuperDocViewportMetrics, SuperDocZoomConfig, SuperDocZoomMode } from '../core/types/index.js'; import { PageMetricsPage, PageMetricsSnapshot } from '../public/ui/page-metrics.js'; export type ResolvedFitWidthOptions = Required; type PageWidthSnapshot = Partial> & { pages?: ReadonlyArray<{ base?: Partial>; } | null | undefined>; }; type EditorPageGeometry = { pageMetrics?: { getSnapshot?: () => PageWidthSnapshot | null | undefined; } | null; getPages?: () => Array<{ size?: { w?: unknown; }; } | null | undefined> | null | undefined; getPageStyles?: () => { pageSize?: { width?: unknown; }; } | null | undefined; }; type ViewportFitEventName = 'editorCreate' | 'pagination-update' | 'pdf:document-ready'; interface ViewportFitSuperDoc { config?: { zoom?: Pick | null; } | null; activeEditor?: EditorPageGeometry | null; emit(event: 'zoomChange', payload: { zoom: number; mode: 'fit-width'; }): unknown; emit(event: 'viewport-change', payload: SuperDocViewportMetrics): unknown; on?(event: ViewportFitEventName, listener: () => void): unknown; off?(event: ViewportFitEventName, listener: () => void): unknown; } interface UseViewportFitOptions { getSuperdoc: () => ViewportFitSuperDoc | null | undefined; superdocContainerWidth: Readonly>; isReady: Readonly>; activeZoom: Ref; zoomMode: Readonly>; viewportMetrics: Ref; showCommentsSidebar?: Readonly>; rightSidebarRef?: Readonly>; superdocRoot: Readonly>; documents?: Readonly>; } export declare const FIT_WIDTH_DEFAULTS: Readonly<{ min: 10; max: 100; padding: 0; }>; export declare const resolveFitWidthOptions: (rawFitConfig: unknown) => ResolvedFitWidthOptions; export declare const computeFitZoom: (availableWidth: number, documentWidth: number) => number | null; export declare const computeAppliedFitZoom: (availableWidth: number, documentWidth: number, options: ResolvedFitWidthOptions) => number | null; export declare const normalizePdfPageMeasurement: (measured: number, scaleFactor: number, zoomFactor: number) => number | null; export declare const resolveEditorPageWidth: (editor: EditorPageGeometry | null | undefined) => number | null; /** * Viewport fit tracking. Maintains pure viewport metrics (available width, * document base width, fit zoom), stores them for `getViewportMetrics()`, * emits `viewport-change` when the fit they imply changes, and applies the * `fit-width` policy while `zoomMode` is `'fit-width'`. * * Metrics are policy-free measurements: `availableWidth` is the container * width minus the comments sidebar when visible; `fitZoom` is the raw * available/document ratio. The fit policy (and only the policy) accounts * for `config.zoom.fitWidth` padding and clamping. * * The base page width is re-resolved on every evaluation (never latched): * DOCX uses the widest laid-out page with page-styles fallback, PDF uses * rendered pages normalized by their actual scale factor, and HTML reflows * so it contributes no fixed width. A zoom-normalized DOM measurement is * the last-resort fallback for a DOCX editor without page geometry. * * The fit application writes the zoom state directly instead of calling * `setZoom()`, which by contract switches the mode to `manual`. * * Must be called inside a component `setup()` (registers watchers and an * unmount hook). */ export declare function useViewportFit({ getSuperdoc, superdocContainerWidth, isReady, activeZoom, zoomMode, viewportMetrics, showCommentsSidebar, rightSidebarRef, superdocRoot, documents, }: UseViewportFitOptions): { evaluateViewport: () => void; }; export {};