import { KeyboardEvent } from 'react';
import { TreeSelectFieldNode, TreeSelectFieldValue, TreeSelectFieldValueConsistsOf } from '../types';
import { VisibleNode } from './types';
import { CheckState } from './useTreeCascade';
/**
 * Options for the useTree hook.
 * @property nodes - The full tree data.
 * @property value - Controlled selected values.
 * @property onSelectedOptionsChange - Callback when selection changes.
 * @property selectionMode - "single", "independent", or "linked" (default).
 * @property valueConsistsOf - Controls which nodes are selectable and how the value is shaped.
 * @property defaultExpandLevel - Initial expand depth. 0 = collapsed, Infinity = all.
 * @property expandedIds - Controlled set of expanded node IDs.
 * @property onExpandedIdsChange - Callback when expanded IDs change (controlled mode).
 * @property searchValue - Filter string applied to the tree.
 * @property ancestry - childId → parentId map from the loader, used to attribute
 *   off-screen ("orphan") selections to their ancestor branches.
 * @property loadingChildrenIds - Set of node IDs whose children are currently being fetched.
 */
export type UseTreeOptions = {
    nodes: TreeSelectFieldNode[];
    value: TreeSelectFieldValue[];
    onSelectedOptionsChange: (nodes: TreeSelectFieldValue[]) => void;
    selectionMode?: "single" | "independent" | "linked";
    valueConsistsOf?: TreeSelectFieldValueConsistsOf;
    defaultExpandLevel?: number;
    expandedIds?: Set<string | number>;
    onExpandedIdsChange?: (ids: Set<string | number>) => void;
    searchValue?: string;
    ancestry?: Map<string | number, string | number>;
    loadingChildrenIds?: Set<string | number>;
};
/**
 * ARIA props returned per tree item.
 */
export type TreeItemProps = {
    id: string;
    role: "treeitem";
    "aria-level": number;
    "aria-setsize": number;
    "aria-posinset": number;
    "aria-expanded"?: boolean;
    "aria-selected": boolean;
};
/**
 * ARIA props for the tree container.
 */
export type TreeContainerProps = {
    role: "tree";
    "aria-activedescendant": string | undefined;
    "aria-multiselectable": boolean;
};
/**
 * Return value from the useTree hook.
 * @property visibleNodes - Flat list of currently visible nodes.
 * @property getCheckState - Returns the visual check state for a node ID.
 * @property toggleNode - Toggles selection for the given node ID.
 * @property isExpanded - Returns whether the given node ID is expanded.
 * @property toggleExpand - Expands or collapses the given branch node ID.
 * @property expandAll - Expands all branch nodes.
 * @property collapseAll - Collapses all branch nodes.
 * @property activeDescendantId - The id attribute of the focused treeitem, for aria-activedescendant.
 * @property onKeyDown - Keyboard event handler for the tree container.
 * @property getTreeItemProps - Returns ARIA props for a given node ID.
 * @property treeProps - ARIA props for the tree container element.
 */
export type UseTreeReturn = {
    nodes: TreeSelectFieldNode[];
    visibleNodes: VisibleNode[];
    getCheckState: (id: string | number) => CheckState;
    toggleNode: (id: string | number) => void;
    isExpanded: (id: string | number) => boolean;
    toggleExpand: (id: string | number) => void;
    expandAll: () => void;
    collapseAll: () => void;
    activeDescendantId: string | undefined;
    setActiveNodeId: (id: string | number) => void;
    onKeyDown: (e: KeyboardEvent) => void;
    getTreeItemProps: (id: string | number) => TreeItemProps;
    treeProps: TreeContainerProps;
};
/**
 * Core tree state hook that manages expansion, selection, keyboard navigation,
 * search filtering, and ARIA attributes for a tree widget.
 *
 * Features:
 * - Uncontrolled expansion state by default; fully controlled via expandedIds/onExpandedIdsChange
 * - defaultExpandLevel for initial expansion depth
 * - expandAll / collapseAll helpers
 * - Delegates selection logic to computeCheckStates and toggleNodeSelection from useTreeCascade
 * - valueConsistsOf determines which nodes are selectable
 * - Search filtering that preserves tree structure
 * - Full keyboard navigation (WAI-ARIA tree pattern)
 * - ARIA attribute generation for tree container and tree items
 *
 * @param options - Configuration options for the tree state.
 * @returns Tree state and handlers.
 */
export declare function useTree(options: UseTreeOptions): UseTreeReturn;
