import { type FlowColorValues } from './partPalette.js'; import type { ColorPaletteEntry, ColorValue, DocumentMetadata, Resource, ResolvedCalloutDesignConfig, ResolvedDesignSlot, ResolvedChipStyleConfig, ResolvedHeadingLevelConfig, TextAlign } from '../types.js'; import { type ContentWarning, type VDTDocument, type VDTDesignSlot, type VDTDesignBlock, type VDTDesignSlotKind, type VDTChip, type VDTFrame } from '../vdt.js'; import { type JoinedLine } from './placeholders.js'; import type { PageRole } from '../types.js'; import { type DesignFrames, type ResolvedPrimitive } from '../design/layout.js'; import { type DesignPlaceholderContext, type HeadingPlaceholderInfo } from '../design/placeholders.js'; /** A laid-out design primitive as the VDT block the renderers paint (also * used by the comics lettering, which lays out balloon text as design * text). */ export declare function primitiveToBlock(prim: ResolvedPrimitive): VDTDesignBlock; /** * The page boxes a heading's design paints, laid out against `container` * — the band the placed heading takes, as `buildHeadersAndFooters` lays it * out — in absolute page px. Only the elements that reserve room: those * with `reserve: false` are decoration the text and the floats may cover. * The placement pass keeps the float-only side column clear of them * (EF-78): a chapter numeral set in the margin column is no room for a * marginal figure. */ export declare function headingDesignBoxes(level: ResolvedHeadingLevelConfig, heading: HeadingPlaceholderInfo, container: { x: number; y: number; width: number; height: number; }, dpi: number, metadata: DocumentMetadata, pageIndex: number, frames?: DesignFrames, resourceById?: ReadonlyMap): Array<{ x: number; y: number; width: number; height: number; }>; /** Measure the natural bottom of a heading's advanced-design slot when laid * out against a container of the given `width` with unbounded height. * Returns 0 if the level has no advanced design or the slot is empty. Used * during body layout to enlarge a heading block's reserved height so * subsequent blocks sit below the actual bottom of the design content * rather than below the natural text bottom. Applies to both in-column * headings (overlay in block bbox) and page-spanning openers (width is the * full content area; passed in by the caller). * * Two kinds of element never count: those flagged `reserve: false` * (decoration that may overlap the text), and those whose position or * height follows the container's height — anchored to its middle or its * foot, `'fill'` tall, or chained to such an element. The container at * paint time is the band this height reserves, so they are laid out * against the result and cannot set it. They are found by laying the slot * out against two container heights and keeping only the primitives that * did not move. */ export declare function measureHeadingAdvancedDesignHeight(level: ResolvedHeadingLevelConfig, heading: HeadingPlaceholderInfo, width: number, dpi: number, metadata: DocumentMetadata, pageIndex: number, /** Page/bleed frames in absolute page px, for `anchor.to: 'page' | * 'bleed'` elements. Translated into the stub coordinate system (the * heading container's top-left at `origin`) so a band anchored above the * heading does not grow the reserved height, while anything extending * below the heading's top does. */ frames?: DesignFrames, /** Absolute page position of the heading container's top-left. Defaults * to the frames' page origin when omitted. */ origin?: { x: number; y: number; }, /** Resources by id, for `kind: 'image'` elements — the pictures painted * with the design count like its other elements (EF-90). Without it an * image element cannot be sized and counts nothing. */ resourceById?: ReadonlyMap): number; /** What a heading's advanced design needs of the band it is laid out in * (see {@link measureHeadingDesign}). */ export interface HeadingDesignMeasure { /** The height the design reserves below the heading's top (see * {@link measureHeadingAdvancedDesignHeight}), `minHeight` included. */ height: number; /** The least height the band needs at paint time for every text that * rides on it to start at or below the heading's top; 0 when none * does. */ textFloor: number; /** What sets `height`, for a host that explains a heading which claims * its column (#997): the id of the element that reaches lowest, unless * the design's own `minHeight` is taller than every element * (`byMinHeight`). Both absent for a design that reserves nothing. */ claimedBy?: string; byMinHeight?: true; } /** {@link measureHeadingAdvancedDesignHeight}, with the floor that texts * riding on the band set (`textFloor`). A text anchored to the foot or * the middle of the band (a title set on the last line of a tall opener) * does not set the reserved height, but the band has to be tall enough to * hold it: the caller keeps the band it paints at least `textFloor` tall, * so such a title never rises above the heading's top into the text over * it (EF-176; up to postext 1.4 it did when it was taller than the * heading's own lines). Boxes, rules and pictures that ride on the band * set no floor: a panel may reach above the heading on purpose. */ export declare function measureHeadingDesign(level: ResolvedHeadingLevelConfig, heading: HeadingPlaceholderInfo, width: number, dpi: number, metadata: DocumentMetadata, pageIndex: number, frames?: DesignFrames, origin?: { x: number; y: number; }, resourceById?: ReadonlyMap): HeadingDesignMeasure; /** The band a box style's design (#1014) takes `width` wide: as tall as * its elements reach, or its `minHeight` (see {@link measureHeadingDesign}; * a text riding on the band's foot keeps it as tall as it needs). `info` * is the box's title and the fence's attributes. */ export declare function measureBoxDesign(design: ResolvedCalloutDesignConfig, info: { titleText: string; attrs: Readonly>; boxText: readonly string[]; }, width: number, dpi: number, metadata: DocumentMetadata, resourceById?: ReadonlyMap): number; /** A box style's design (#1014) laid out against its band, in the box's * coordinates: `{titleText}` is the box title, `{attr.}` the fence's * attributes. Its texts are cut to fit as a heading design's are, flagged * as a box's (`slot: 'box'`). */ export declare function layoutBoxDesign(design: ResolvedCalloutDesignConfig, info: { titleText: string; attrs: Readonly>; boxText: readonly string[]; }, band: { x: number; y: number; width: number; height: number; }, dpi: number, metadata: DocumentMetadata, extras: Pick): VDTDesignBlock[]; /** Optional page-level inputs for `layoutSlotToVdt`. */ export interface SlotLayoutExtras { frames?: DesignFrames; /** The document's base direction and whether the slot is painted in the * flow of a mirrored page (see `LayoutContext`). */ direction?: 'ltr' | 'rtl'; mirrored?: boolean; /** Start and end edges read the start on the right (`LayoutContext`). */ startRight?: boolean; /** See `LayoutContext.arabicNumbers` (#665). */ arabicNumbers?: boolean; pageRole?: PageRole; /** Resources by id, for `kind: 'image'` elements. */ resourceById?: ReadonlyMap; /** Source range of the text `{titleText}` renders; stamped on the text * blocks whose element content mentions the placeholder. */ titleSource?: { start: number; end: number; text?: string; sourceMap?: number[]; }; /** Source ranges of heading attribute values; a text element whose * content is exactly `{attr.}` maps back to that value. */ attrSources?: Record; attrs?: Record; /** Source range of the heading line itself: what `{number}`, * `{chapterNumber}` or `{chapterTitle}` elements map back to. */ headingSource?: { start: number; end: number; }; /** Source ranges of the frontmatter field values (`{title}`, `{author}`, * `{subtitle}`, `{publishDate}`) and the values themselves. */ metadataSources?: Record; metadata?: Record; /** Where the slot is painted: a text block cut to fit is flagged with it * (`VDTDesignTextBlock.truncated`, #628). Absent: nothing is flagged. */ slot?: VDTDesignSlotKind; /** JSON pointer of the slot in the configuration (`/footer`, * `/pageTemplates/0/decoration`): every block is stamped with its * element's id and, with this, the element's pointer (`…/elements/`, * or the one `elementPaths` gives) (#857). */ configPath?: string; /** The config pointer of each element by id, where the slot's elements * are not one array of the configuration (a template's decoration * merged over the templates it extends). */ elementPaths?: ReadonlyMap; /** Filled with the ends connectors left out (#1056): the connector's id * and the box it named. */ connectorDropped?: { elementId: string; targetId: string; }[]; /** Filled with the ends connectors set at an anchor no picture of their * frame has (#1057). */ connectorAnchorUnknown?: { elementId: string; targetId: string; anchor: string; resourceId?: string; known: string[]; }[]; /** The attributes some elements read before `attrs`, with their source * ranges, by element id (#1189): a module's elements read its * `:::module` fence. */ elementAttrs?: ReadonlyMap; attrSources: Record; }>; /** Text elements painted over the frames of a composed page (#1189): * their blocks are marked `over`. */ overTexts?: ReadonlySet; } export declare function layoutSlotToVdt(slot: ResolvedDesignSlot, container: { x: number; y: number; width: number; height: number; }, pageIndex: number, placeholders: DesignPlaceholderContext, dpi: number, extras?: SlotLayoutExtras): VDTDesignSlot | undefined; /** The title the default opener of a page-span heading prints, read from * the heading's laid-out lines. */ export interface DefaultOpenerTitle { /** The plain title, as `{titleText}` resolves it: the lines joined back * into the text they were broken from (see `lineJoin`: a space where the * break took one, a no-break space where it parted a glued group, * nothing after a hard hyphen or inside a divided word, whose added * hyphen goes), the number prefix dropped, a forced break * (`\\`) as a newline. */ titleText: string; /** The same title written as inline Markdown, when the heading sets bold, * italic, superscript or subscript runs (EF-122): the opener then paints * the runs the heading was measured with. Left out when the heading has * none, or when its runs cannot be written back exactly (a small-capitals * run, a link, a marker character next to a run); the opener then prints * the title plain, and its band still holds every line it paints. */ marked?: string; /** Set when {@link marked} holds the heading's chips (`:chip[…]`, #1162), * which a design text sets with the document's chip styles. A heading * with chips has a marked title even without other runs. */ chips?: true; } /** A heading line as the title readers need it: its segments, and how it * was broken from the next one. */ export type TitleLine = JoinedLine & { segments?: readonly { text: string; bold?: boolean; italic?: boolean; script?: 'sup' | 'sub'; chip?: VDTChip; }[]; }; /** `{titleText}` of a heading, from the lines it was laid out in: the * plain title of {@link defaultOpenerTitle}. */ export declare function headingTitleText(lines: readonly TitleLine[], numberPrefix: string, titleBreaks: readonly number[] | undefined, titleLength: number, numberSeparator?: string): string; /** The title a page-span heading's default opener prints, from the lines the * heading was measured into (see {@link DefaultOpenerTitle}). The same * reading serves the band's measure (`build.ts`) and its paint, so the * two lay out one text. */ export declare function defaultOpenerTitle(lines: readonly TitleLine[], numberPrefix: string, titleBreaks: readonly number[] | undefined, titleLength: number, /** What joins the number to the title in the lines * (`HeadingLevelConfig.numberSeparator`). */ numberSeparator?: string): DefaultOpenerTitle; /** The marked title of a heading placeholder (`titleMarked`), with the * document's chip styles when it holds the heading's chips (#1162). A * title with chips and no styles to set them in is left plain. */ export declare function markedTitleFields(title: DefaultOpenerTitle, chipStyles: readonly ResolvedChipStyleConfig[] | undefined): Pick; /** The height of the title a page-span heading's default opener paints * across `width`, with the opener's own painter (a greedy wrap at natural * widths, a justified heading set flush left). The band reserved for the * heading is at least this tall, so it holds every line the opener paints * even where the heading's own measure fits more on a line: a justified * line whose spaces shrink, a forced break, a run the opener sets plain * (EF-100). */ export declare function measureDefaultOpenerHeight(level: ResolvedHeadingLevelConfig, textAlign: TextAlign, title: DefaultOpenerTitle, numberPrefix: string, width: number, dpi: number, metadata: DocumentMetadata, pageIndex: number, /** The document's chip styles, for a title with chips (#1162). */ chipStyles?: readonly ResolvedChipStyleConfig[]): number; /** What the header/footer pass needs from the content beyond the laid-out * document. */ export interface HeaderFooterInputs { /** For a paragraph content block inside a `:::paragraphs{style=…}` * container: the style id and the paragraph's leading bold text, which * `{firstMark.