import type { TransformValue } from './transform.js'; export type TreeOrientation = 'left' | 'right' | 'top' | 'bottom'; export interface TreeNodeContext { readonly id: string; readonly parentId: string | null; readonly name: string; readonly data: TDatum | null; readonly depth: number; readonly height: number; readonly internal: boolean; readonly external: boolean; readonly source: readonly TDatum[]; readonly sourceIndexes: readonly number[]; } export type TreeNodeComparator = (left: TreeNodeContext, right: TreeNodeContext) => number; export type TreeNodeSeparation = (left: TreeNodeContext, right: TreeNodeContext) => number; interface TreeLayoutSharedOptions { /** Root anchor and growth direction. Defaults to `left`. */ readonly orientation?: TreeOrientation; /** D3 tidy-tree spacing as `[breadth, depth]`. Defaults to `[1, 1]`. */ readonly nodeSize?: readonly [number, number]; readonly sort?: TreeNodeComparator; readonly separation?: TreeNodeSeparation; } export type TreeLayoutPathOptions = TreeLayoutSharedOptions & { readonly path: TransformValue; readonly delimiter?: string; readonly id?: never; readonly parentId?: never; }; export type TreeLayoutParentOptions = TreeLayoutSharedOptions & { readonly id: TransformValue; readonly parentId: TransformValue; readonly path?: never; readonly delimiter?: never; }; export type TreeLayoutOptions = TreeLayoutPathOptions | TreeLayoutParentOptions; export interface TreeLayoutNode extends TreeNodeContext { readonly x: number; readonly y: number; } export interface TreeLayoutLink { /** A tree node has at most one incoming link, so its target id is the link id. */ readonly id: string; readonly source: string; readonly target: string; readonly data: TDatum | null; readonly sourceNode: TreeLayoutNode; readonly targetNode: TreeLayoutNode; readonly sourceIndex: number | null; readonly targetIndex: number | null; /** The link represents its target node and carries that node's raw-row lineage. */ readonly sourceRows: readonly TDatum[]; readonly sourceIndexes: readonly number[]; readonly x1: number; readonly y1: number; readonly x2: number; readonly y2: number; } export interface TreeLayoutResult { readonly nodes: readonly TreeLayoutNode[]; readonly links: readonly TreeLayoutLink[]; } /** Computes a deterministic tidy-tree layout in semantic data-space units. */ export declare function treeLayout>(source: Iterable, options: TreeLayoutSharedOptions & { readonly path: TPath; readonly delimiter?: string; readonly id?: never; readonly parentId?: never; }): TreeLayoutResult; export declare function treeLayout, const TParentId extends TransformValue>(source: Iterable, options: TreeLayoutSharedOptions & { readonly id: TId; readonly parentId: TParentId; readonly path?: never; readonly delimiter?: never; }): TreeLayoutResult; export {};