import { ImageRun } from "docx";
import type { CheerioAPI } from "cheerio";
import type { Element } from "domhandler";
type ImageType = "png" | "jpg" | "gif" | "bmp";
/** Raw image bytes a caller's {@link ImageResolver} returns for a non-`data:` `src`. */
export interface ResolvedImage {
/** Encoded image bytes (not base64 — the raw file contents). */
readonly data: Uint8Array | ArrayBuffer;
readonly type: ImageType;
/** Optional intrinsic size (px); used only when the `
` omits width/height. */
readonly width?: number;
readonly height?: number;
}
/**
* Caller-supplied hook to resolve non-`data:` `
` (e.g. `http(s):` / `file:`).
* The library never fetches on its own — the caller owns the network/filesystem access
* and its security policy (host allowlist, SSRF/private-IP blocking, auth, size caps).
* Return `null` to skip an image (it falls back to alt text).
*/
export type ImageResolver = (src: string) => Promise | ResolvedImage | null;
/** Encode a resolved image as a `data:` URL so the sync conversion path handles it uniformly. */
export declare function resolvedImageToDataUrl(resolved: ResolvedImage): string;
/** True for an `
` whose `src` is set but is not (yet) an inline `data:` URL. */
export declare function hasUnresolvedSrc(el: Element): boolean;
/**
* Pre-resolution pass (run before the synchronous tree walk): for every `
` whose
* `src` is not already a `data:` URL, ask the caller's resolver for bytes and, if given,
* rewrite `src` to an inline `data:` URL. Unresolved images keep their `src` and fall
* back to alt text. Resolver errors are swallowed per-image (never abort the conversion).
*/
export declare function applyImageResolver($: CheerioAPI, resolver: ImageResolver): Promise;
export declare function resetImageDocPrIds(): void;
/**
* Build a docx `ImageRun` from an `
` element. Supports base64 `data:` raster
* URLs (png/jpg/gif/bmp). Display size comes from `width`/`height` attributes,
* falling back to the image's natural size (aspect-preserved if only one is given).
* Returns null for unsupported sources (e.g. remote URLs) — caller drops to alt text.
*/
export declare function imageRunFromElement(element: Element): ImageRun | null;
export {};
//# sourceMappingURL=image.d.ts.map