import type { TreeCheckedState } from '../tree/types.cjs'; import type { TreeSelectCheckStrategy, TreeSelectNode, TreeSelectValueStrategy } from './types.cjs'; /** Pure functions for cascading check state, value projection and filtering; no React/DOM, works on collapsed branches. */ /** @internal Everything derived once per collection about a single node. */ export interface TreeSelectIndexEntry { node: TreeSelectNode; /** Parent's value, or `null` for a root node. */ parent: string | null; /** 1-based depth, which is exactly `aria-level`. */ depth: number; /** Immediate children's values, in collection order. */ childValues: string[]; /** Every descendant's value, in pre-order. */ descendants: string[]; /** Enabled leaf descendants this node's tri-state derives from, excluding disabled leaves so one doesn't stick a branch at 'mixed'. */ leaves: string[]; /** Own `disabled`, or any ancestor's — disabling a branch disables its subtree. */ disabled: boolean; } /** @internal Value → entry, built once per `collection` identity. */ export type TreeSelectIndex = ReadonlyMap; /** @internal One row of the visible, expanded tree, in the order the arrow keys walk it. */ export interface TreeSelectFlatNode { value: string; parent: string | null; depth: number; disabled: boolean; /** Whether it has a visible child or declares itself a branch via `hasChildren`; decides `aria-expanded`. */ hasChildren: boolean; expanded: boolean; /** 1-based position among its visible siblings — `aria-posinset`. */ posinset: number; /** Number of visible siblings including itself — `aria-setsize`. */ setsize: number; } /** @internal Flattens a collection into a value-keyed index plus its pre-order value list. */ export declare function indexCollection(collection: readonly TreeSelectNode[]): { index: Map; order: string[]; }; /** @internal A node's ancestors, nearest first. */ export declare function ancestorsOf(value: string, index: TreeSelectIndex): string[]; /** @internal The value strategy that can round-trip under `strategy`, falling back to `'all'` when the matching propagation direction is missing. */ export declare function effectiveValueStrategy(strategy: TreeSelectCheckStrategy, valueStrategy: TreeSelectValueStrategy): TreeSelectValueStrategy; /** @internal A node's tri-state value: plain membership under `'independent'`, else derived from its enabled leaves. */ export declare function checkStateOf(value: string, checked: ReadonlySet, index: TreeSelectIndex, strategy: TreeSelectCheckStrategy): TreeCheckedState; /** @internal Expands an emitted `value` back into the full checked set; the inverse of {@link projectValue}, and the pair must round-trip. */ export declare function normalizeChecked(values: readonly string[], index: TreeSelectIndex, order: readonly string[], strategy: TreeSelectCheckStrategy): Set; /** @internal Reduces the full checked set to the values a consumer actually receives. */ export declare function projectValue(checked: ReadonlySet, index: TreeSelectIndex, order: readonly string[], strategy: TreeSelectValueStrategy): string[]; /** @internal The checked set after activating one node. */ export declare function toggleChecked(value: string, checked: ReadonlySet, index: TreeSelectIndex, strategy: TreeSelectCheckStrategy, multiple: boolean): Set; /** @internal Which nodes survive the filter and which branches must open to reveal them; a match drags its ancestor chain and subtree into visibility. */ export declare function computeFilter(index: TreeSelectIndex, order: readonly string[], matches: (node: TreeSelectNode) => boolean): { visible: Set; autoExpanded: Set; matchCount: number; }; /** @internal Walks the visible collection in navigation order, descending only into expanded branches. */ export declare function flattenVisible(collection: readonly TreeSelectNode[], index: TreeSelectIndex, visible: ReadonlySet | null, expanded: ReadonlySet): TreeSelectFlatNode[];