import { TreeSelectFieldNode } from '../types';
/**
 * Options for the useTreeLoader hook.
 * @property loadOptions - Async function to load tree nodes. Called with searchValue and optional parentNode.
 * @property cache - Cache configuration. Enabled by default with maxSize of 15.
 * @property initialLoad - Controls when the initial load occurs. "auto" and "immediate" load on mount, "open" loads on first onOpen() call.
 * @property debounceMs - Debounce delay in milliseconds for search calls. Defaults to 200.
 */
export type UseTreeLoaderOptions = {
    loadOptions: (searchValue: string, parentNode?: TreeSelectFieldNode) => TreeSelectFieldNode[] | Promise<TreeSelectFieldNode[]>;
    cache?: {
        enabled?: boolean;
        maxSize?: number;
    };
    initialLoad?: "auto" | "immediate" | "open";
    debounceMs?: number;
};
/**
 * Return value from the useTreeLoader hook.
 * @property nodes - The currently loaded tree nodes.
 * @property ancestry - Durable childId → parentId map accumulated from lazy
 *   children loads; survives tree resets so off-screen selections can be
 *   attributed to their ancestors.
 * @property isLoading - Whether a root/search load is in progress.
 * @property isLoadingChildren - Set of node IDs whose children are currently loading.
 * @property loadChildren - Loads children for the given branch node (lazy expansion).
 * @property search - Triggers a search load with the given search value (debounced).
 * @property clearCache - Clears both the search and children caches.
 * @property invalidate - Clears both caches and triggers a fresh load.
 * @property onOpen - Triggers the initial load when initialLoad="open". No-op otherwise or after first open.
 */
export type UseTreeLoaderReturn = {
    nodes: TreeSelectFieldNode[];
    ancestry: Map<string | number, string | number>;
    isLoading: boolean;
    isLoadingChildren: Set<string | number>;
    loadChildren: (parentNode: TreeSelectFieldNode) => Promise<TreeSelectFieldNode[]>;
    search: (searchValue: string) => void;
    clearCache: () => void;
    invalidate: () => void;
    onOpen: () => void;
};
/**
 * Hook that manages async loading and caching for tree data.
 *
 * Features:
 * - Handles root/search loading and lazy branch expansion via a single loadOptions callback
 * - Two separate LRU caches: one for search results, one for lazy-loaded children
 * - Configurable cache size and opt-out support
 * - Debounced search to reduce unnecessary loadOptions calls
 * - initialLoad modes: "immediate"/"auto" load on mount, "open" defers until onOpen() is called
 * - Children are merged into the node tree after loading, updating children: null to the loaded array
 * - invalidate() clears caches and triggers a fresh load of the current view
 *
 * @param options - Configuration options for the tree loader.
 * @returns Current nodes, loading states, and loader control functions.
 */
export declare function useTreeLoader(options: UseTreeLoaderOptions): UseTreeLoaderReturn;
