import type { TuiMarkdownVisualRow } from "./types.js"; export type TuiMarkdownMathMode = "inline" | "display"; export type TuiMarkdownMathImageCells = Readonly<{ base64: string; widthCells: number; heightCells: number; }>; export type TuiMarkdownMathImageOptions = Readonly<{ cellWidthPx?: number; cellHeightPx?: number; scale?: number; color?: string; maxWidthCells?: number; /** * Vertical position of the text baseline inside a terminal cell, as a * fraction of the cell height (0 = top, 1 = bottom). Inline formula images * are padded so their baseline lands here. Defaults to 0.78. */ baselineRatio?: number; }>; export type TuiMarkdownMathRasterizer = (tex: string, mode: TuiMarkdownMathMode, options: Required) => Promise; type RequiredMathImageOptions = Required; export declare function resolveMarkdownMathColor(fg: unknown): string | undefined; export declare function normalizeMathImageOptions(options?: TuiMarkdownMathImageOptions): RequiredMathImageOptions; /** * Install a custom TeX -> PNG rasterizer (e.g. consumers that already have a * katex/mathjax pipeline). Passing `null` restores the built-in lazy loader. */ export declare function setMarkdownMathRasterizer(rasterizer: TuiMarkdownMathRasterizer | null): void; export declare function subscribeMarkdownMathImage(listener: () => void): () => void; /** * True when a rasterizer is confirmed available (a custom one was installed or * the built-in MathJax+resvg stack finished loading). Components should gate * image production on this so they never spend time rasterizing formulas while * the math engine is still loading or missing. */ export declare function isMarkdownMathImageRendererReady(): boolean; /** * Ensure the math image rasterizer is loaded (or resolved as unavailable). * Resolves `true` once a rasterizer is usable. Safe to call repeatedly; the * underlying load is shared and its outcome is cached. */ export declare function loadMarkdownMathImageRenderer(): Promise; /** Synchronous cache lookup used by the markdown AST/layout phase. */ export declare function getCachedMarkdownMathImage(tex: string, mode: TuiMarkdownMathMode, options?: TuiMarkdownMathImageOptions): TuiMarkdownMathImageCells | null; /** * Drop all cached rasterized formulas (PNG + failed lookups). Useful for long * running processes that change cell metrics, and for tests. */ export declare function clearMarkdownMathImageCache(): void; /** * Resolve a TeX formula to a PNG base64 + cell size. Cached per * (tex, mode, cell metrics, color). In-flight requests are deduped. When a new * image finishes, `subscribeMarkdownMathImage` listeners are notified so * components can rebuild/re-paint with the real size. */ export declare function getMarkdownMathImage(tex: string, mode: TuiMarkdownMathMode, options?: TuiMarkdownMathImageOptions): Promise; /** * Kick off rasterization for every math graphic segment in the given row range * that does not have a cached PNG yet. Safe to call after every row rebuild; * in-flight and cached requests are deduped inside getMarkdownMathImage. Pass a * viewport to avoid rasterizing off-screen formulas (e.g. virtualized views). */ export declare function enqueueMarkdownMathImages(rows: readonly TuiMarkdownVisualRow[], options?: TuiMarkdownMathImageOptions, viewport?: Readonly<{ firstRow: number; lastRow: number; }>): void; export {};