import type { FnWithParams, Format } from './types.js'; export type RichChunks = (string | T)[]; export type RichTag = (chunks: RichChunks, index: number) => T; export type RichTags = Record>; export type RichPreformat = Format>; /** * Creates a rich-text formatter. * @param tags - Tag handlers used to map rich-text tags to output chunks. * @returns Formatter that returns mapped chunks or `undefined`. */ export declare function rich(tags: RichTags): Format | undefined>; /** * Creates a rich-text formatter with a fallback message. * @param fallback - Message used when the input is `undefined` or `null`. * @param tags - Tag handlers used to map rich-text tags to output chunks. * @returns Formatter that returns mapped chunks. */ export declare function rich(fallback: string, tags: RichTags): Format>; /** * Creates a rich-text formatter that fills values into the message through a preformat. * The preformat gets the whole message, so it can be `params`, `plural`, `match` or a composition of them. * Only the tags of the message are mapped: values filled in by the preformat are never parsed as tags. * @param tags - Tag handlers used to map rich-text tags to output chunks. * @param preformat - Formatter of the message, like `params`, `plural` or `match`. * @returns Formatter that returns a message function of the preformat parameters. */ export declare function rich(tags: RichTags, preformat: RichPreformat): Format RichChunks | undefined>; /** * Creates a rich-text formatter with a fallback message that fills values into the message through a preformat. * The preformat gets the whole message, so it can be `params`, `plural`, `match` or a composition of them. * Only the tags of the message are mapped: values filled in by the preformat are never parsed as tags. * @param fallback - Message used when the input is `undefined` or `null`. * @param tags - Tag handlers used to map rich-text tags to output chunks. * @param preformat - Formatter of the message, like `params`, `plural` or `match`. * @returns Formatter that returns a message function of the preformat parameters. */ export declare function rich(fallback: string, tags: RichTags, preformat: RichPreformat): Format RichChunks>; /** * Creates a rich-text formatter. * @param fallbackOrTags - Fallback message or tag handlers. * @param tagsOrPreformat - Tag handlers used when fallback is provided, or the preformat. * @param maybePreformat - Formatter of the message used when fallback is provided. * @returns Formatter that returns mapped chunks, a message function of them or `undefined`. */ export declare function rich(fallbackOrTags: string | RichTags | undefined, tagsOrPreformat?: RichTags | RichPreformat, maybePreformat?: RichPreformat): Format | ((params: P) => RichChunks | undefined) | undefined>; /** * Maps rich-text tags in a string to chunks using provided tag handlers. * Each handler call receives an unique index, usable as a key for framework nodes. * Self-closing tags are mapped with empty chunks. * Unknown or malformed tags are ignored as markup and only their text content is kept. * @param input - Rich-text input string. * @param tags - Tag handlers used to map known tags. * @param formatText - Formatter of each text piece between the tags, applied before the tag handlers get it. * @returns Mapped chunks. */ export declare function mapTags(input: string, tags: RichTags, formatText?: (text: string) => string): RichChunks; //# sourceMappingURL=rich.d.ts.map