import type { AnchorEdge, Dimension, ElementPlacement } from '../types.js'; import type { FrameSize, ResolvedFrame, ResolvedFrameGroup, ResolvedPageTemplate } from './types.js'; export interface Rect { x: number; y: number; width: number; height: number; } /** The rectangles a template's anchors refer to on one page. */ export interface FrameAreas { /** The template's `area` (the content area, the trim or the bleed). */ area: Rect; /** The trim box (`anchor.to: 'page'`) and the bleed box. */ page: Rect; bleed: Rect; } export interface FrameGeometryContext { areas: FrameAreas; dpi: number; /** Ems of the page's body text, for `em` lengths. */ emPx: number; } type Pin = 'start' | 'middle' | 'end'; /** The anchor point and the side of the box pinned to it. */ interface Anchor { x: number; y: number; pinX: Pin; pinY: Pin; } /** The anchor of `edge` on `ref`: the nine-point grid of a container, or an * element-to-element edge when `element` (an anchor to `'#name'`). An * element edge on a container, or a container edge on an element, reads * as `top-left` / `align-top`, as design slots do. */ export declare function anchorOn(given: AnchorEdge, ref: Rect, element: boolean): Anchor; /** `v` held between `min` and `max` (min wins). */ export declare function clampSize(v: number, min: number | undefined, max: number | undefined): number; /** The rectangle of cell `cell` of the template grid in `area`. */ export declare function gridCellRect(template: Pick, cell: Required<{ col: number; row: number; cols: number; rows: number; }>, area: Rect, ctx: FrameGeometryContext): Rect; /** What the geometry needs to know of a box it places: a frame's * placement and sizes, or a group's. */ interface Placeable { placement?: ElementPlacement; grid?: Required<{ col: number; row: number; cols: number; rows: number; }>; width: FrameSize; height: FrameSize; /** The height was written (a grid cell keeps its own otherwise). */ heightSet: boolean; minWidth?: Dimension; maxWidth?: Dimension; minHeight?: Dimension; maxHeight?: Dimension; } /** * The box of a frame (or group): `resolveRef` gives the box of a `'#name'` * anchor (undefined when it has none yet: the anchor then reads as the * area's); `natural(width)` the content's height at a width, for an * `'auto'` height. */ export declare function placeBox(item: Placeable, template: Pick, ctx: FrameGeometryContext, resolveRef: (name: string) => Rect | undefined, natural: (width: number) => number, /** For an `'auto'` width (#982): the width the content needs when it may * take up to `room` px, as wide as its longest line. Left out, an * `'auto'` width reads as `'fill'`. */ naturalWidth?: (room: number) => number): Rect; /** A frame as {@link placeBox} reads it. */ export declare function framePlaceable(frame: ResolvedFrame): Placeable; /** A group's own box as {@link placeBox} reads it, or undefined when it has * none (its box is then the union of its frames'). */ export declare function groupPlaceable(group: ResolvedFrameGroup): Placeable | undefined; /** The frame of the same page a frame's content goes on in: its `next`, * else an `overflow.continueIn` of the form `'#frame'` (the same thing). */ export declare function nextFrameOf(frame: Pick): string | undefined; /** The smallest rectangle holding `rects` (undefined for none). */ export declare function unionRect(rects: readonly Rect[]): Rect | undefined; /** * The order frames are placed and typeset in: a frame after what it * anchors to (a group's frames, or the group's own anchor), after the frame * of its chain before it (`next`); frames that push text first; otherwise * template order. Anchor cycles (rejected by validation, settled by the * resolver) are broken where they close. */ export declare function frameOrder(template: Pick): ResolvedFrame[]; /** * Where every frame of `template` stands on a page before any content is * poured (#863: the Sandbox's template thumbnails and editor): the frames * placed in {@link frameOrder}, a group without a box of its own taking the * union of its frames. An `'auto'` height takes `natural(frame, width)`; * left out, a fifth of the area's height. */ export declare function templateFrameRects(template: Pick, ctx: FrameGeometryContext, natural?: (frame: ResolvedFrame, width: number) => number): Map; export {}; //# sourceMappingURL=geometry.d.ts.map