The list type discriminator
The type of leaf item values
The default list type for the root level
Flat sequence of depth-annotated items, where each item has:
depth: the 0-based nesting levelltype: the list type for grouping (e.g., "bullet" vs "number")value: the actual item contentEquality comparator for list types (defaults to ===)
Array of finished trees, each with an ltype and a list of nested items.
Multiple trees are returned when the list type changes at depth 0.
Process a flat list of depth-annotated items into nested tree structures.
This is the main entry point for the depth module. It takes a sequence of items, each annotated with a nesting depth and a list type, and produces one or more nested trees. Multiple trees are produced when the list type changes at the root level (depth 0).
The algorithm iterates through items sequentially, using a stack to track open nesting levels. When depth increases, new levels are pushed; when depth decreases, levels are popped and collapsed into their parent. When the list type changes at the same depth, the current list is finalized and a new one begins.