import { TreeSelectFieldNode, TreeSelectFieldValue, TreeSelectFieldValueConsistsOf } from '../types';
import { CheckState } from '../../../../types';
export type { CheckState };
/**
 * Computes the visual check state for every node in the tree.
 *
 * In "linked" mode parents reflect the aggregate state of their children:
 * - checked — all non-disabled children are checked
 * - indeterminate — some but not all non-disabled children are checked
 * - unchecked — no children are checked
 *
 * In "independent" / "single" mode (and for BRANCH_ONLY) each node is checked
 * only when its id appears in the value array; no cascade is applied. A node's
 * own selection lives in `value` regardless of what is loaded, so these modes
 * are unaffected by lazy/filtered loading.
 *
 * ## Under-represented branches (lazy / filtered)
 *
 * In linked mode a branch's aggregate state is derived from its children. But
 * the tree passed in is only ever what is currently *loaded* — during search it
 * is the filtered subset, and lazy branches (`children === null`) or partially
 * loaded branches don't expose their full child set. A branch is
 * "under-represented" when its loaded children are known to be fewer than its
 * real children (`children === null`, or `loadedCount < childCount`). For these
 * we infer rather than aggregate:
 * - the branch's own id is checked → `checked`
 * - any *loaded* descendant is checked/indeterminate → `indeterminate`
 *   (it can't be fully checked because unknown children exist)
 * - otherwise, if the branch is a known ancestor of an "orphan" selection (a
 *   checked id that isn't in the currently-loaded tree — e.g. a descendant of a
 *   collapsed lazy branch), via `orphanAncestorIds` → `indeterminate`
 * - otherwise → `unchecked`
 *
 * Orphan attribution is *path-scoped*: only branches on the resolved ancestor
 * path of an orphaned selection are marked, so unrelated collapsed siblings stay
 * `unchecked`. The caller resolves those ancestors (from a value's `path` or the
 * loader's ancestry map) and passes them in `orphanAncestorIds`. An orphan whose
 * ancestry is unknown contributes nothing (its branch shows `unchecked` until
 * its parent loads, then self-corrects).
 *
 * One limitation remains: accurate filtered-branch state requires
 * server-/consumer-provided `childCount` — a partially-loaded branch without a
 * `childCount` falls back to aggregating only its visible children.
 *
 * @param nodes - The currently loaded (possibly filtered) tree.
 * @param value - The current value array.
 * @param selectionMode - "single", "independent", or "linked".
 * @param valueConsistsOf - Strategy used when computing check states.
 * @param orphanAncestorIds - Branch ids that lie on the resolved ancestor path
 *   of an orphaned selection. Such under-represented branches render
 *   `indeterminate`. Defaults to empty (no orphan inference).
 * @returns A Map from node id to CheckState.
 */
export declare function computeCheckStates(nodes: TreeSelectFieldNode[], value: TreeSelectFieldValue[], selectionMode: "single" | "independent" | "linked", valueConsistsOf: TreeSelectFieldValueConsistsOf, orphanAncestorIds?: Set<string | number>): Map<string | number, CheckState>;
/**
 * Given a set of checked node IDs and a value strategy, returns the value
 * array according to the strategy.
 *
 * - "ALL" — every checked node
 * - "BRANCH_PRIORITY" — branch replaces its leaves when all non-disabled
 *     children are checked; otherwise individual leaves
 * - "LEAF_PRIORITY" — leaves only, unless the node is a branch with an empty
 *     or null children list (leaf-less branch)
 * - "LEAF_ONLY" — strictly leaves; branches are never included
 *
 * @param nodes - The full tree.
 * @param checkedIds - Set of IDs that are checked.
 * @param valueConsistsOf - Strategy to apply.
 * @returns The value array.
 */
export declare function computeValue(nodes: TreeSelectFieldNode[], checkedIds: Set<string | number>, valueConsistsOf: TreeSelectFieldValueConsistsOf): TreeSelectFieldValue[];
/**
 * Toggles a node's selection and returns the new value array.
 *
 * In "single" mode:
 * - Replaces the entire selection with the clicked node (or empties if already selected).
 *
 * In "independent" mode:
 * - Only the clicked node is toggled; no cascade.
 *
 * In "linked" mode:
 * - Selecting a branch selects all non-disabled descendants recursively.
 * - Deselecting a branch deselects all non-disabled descendants recursively.
 * - Disabled nodes are never modified.
 *
 * @param nodes - The full tree.
 * @param currentValue - The current value array.
 * @param nodeId - The id of the node to toggle.
 * @param selectionMode - "single", "independent", or "linked".
 * @param valueConsistsOf - Strategy to apply when computing the returned value.
 * @returns The new value array.
 */
export declare function toggleNodeSelection(nodes: TreeSelectFieldNode[], currentValue: TreeSelectFieldValue[], nodeId: string | number, selectionMode: "single" | "independent" | "linked", valueConsistsOf: TreeSelectFieldValueConsistsOf): TreeSelectFieldValue[];
