import { CancellationToken, CancellationTokenSource } from '@opensumi/ide-utils';
import { IAccessibilityInformation, ICompositeTreeNode, ITree, ITreeNode, ITreeNodeOrCompositeTreeNode, ITreeWatcher, IWatcherInfo, TreeNodeType } from '../types';
/**
 * 裁剪数组
 *
 * @param arr 裁剪数组
 * @param start 起始位置
 * @param deleteCount 删除或替换位置
 * @param items 插入的数组
 */
export declare function spliceArray(arr: number[], start: number, deleteCount?: number, items?: number[] | null): number[];
export declare enum BranchOperatorStatus {
    EXPANDED = 1,
    SHRINKED = 2
}
export type TreeNodeOrCompositeTreeNode = TreeNode | CompositeTreeNode;
export interface IGlobalTreeState {
    isExpanding: boolean;
    isLoadingPath: boolean;
    isRefreshing: boolean;
    refreshCancelToken: CancellationTokenSource;
    loadPathCancelToken: CancellationTokenSource;
}
export interface IOptionalGlobalTreeState {
    isExpanding?: boolean;
    isLoadingPath?: boolean;
    isRefreshing?: boolean;
    refreshCancelToken?: CancellationTokenSource;
    loadPathCancelToken?: CancellationTokenSource;
}
export declare class TreeNode implements ITreeNode {
    static nextId: () => number;
    static is(node: any): node is ITreeNode;
    static getTreeNodeById(id: number): ITreeNodeOrCompositeTreeNode | undefined;
    static getTreeNodeByPath(path: string): ITreeNodeOrCompositeTreeNode | undefined;
    static setTreeNode(id: number, path: string, node: TreeNode): void;
    static removeTreeNode(id: number, path: string): void;
    static getIdByPath(path: string): number | undefined;
    static setIdByPath(path: string, id: number): Map<string, number>;
    static getGlobalTreeState(path: string): IGlobalTreeState;
    static setGlobalTreeState(path: string, updateState: IOptionalGlobalTreeState): IGlobalTreeState;
    static idToTreeNode: Map<number, ITreeNodeOrCompositeTreeNode>;
    static pathToTreeNode: Map<string, ITreeNodeOrCompositeTreeNode>;
    static pathToId: Map<string, number>;
    private static pathToGlobalTreeState;
    private _parent;
    private _metadata;
    private _uid;
    private _disposed;
    protected _depth: number;
    protected _watcher: ITreeWatcher;
    protected _tree: ITree;
    protected _visible: boolean;
    protected _path: string;
    protected constructor(tree: ITree, parent?: ICompositeTreeNode, watcher?: ITreeWatcher, optionalMetadata?: {
        [key: string]: any;
    });
    get disposed(): boolean;
    /**
     * 获取基础信息
     */
    get depth(): number;
    get parent(): ICompositeTreeNode | undefined;
    set parent(node: ICompositeTreeNode | undefined);
    get type(): TreeNodeType;
    get id(): number;
    set id(id: number);
    get displayName(): string;
    /**
     * 由于 Tree 对于唯一路径的 path 的依赖
     * 在传入 `name` 值时必须保证其在路径上的唯一性
     * 一般不建议手动管理 `name`，采用默认值即可
     */
    get name(): string;
    set name(name: string);
    get path(): string;
    get accessibilityInformation(): IAccessibilityInformation;
    getMetadata(withKey: string): any;
    addMetadata(withKey: string, value: any): void;
    removeMetadata(withKey: string): void;
    /**
     * 这里的move操作可能为移动，也可能为重命名
     *
     * @param {ICompositeTreeNode} to
     * @param {string} [name=this.name]
     * @returns
     * @memberof TreeNode
     */
    mv(to: ICompositeTreeNode | null, name?: string): void;
    get visible(): boolean;
    setVisible(b: boolean): this;
    dispose(): void;
}
export declare class CompositeTreeNode extends TreeNode implements ICompositeTreeNode {
    private static defaultSortComparator;
    static is(node: any): node is ICompositeTreeNode;
    static isRoot(node: any): boolean;
    private static REFRESH_DELAY;
    protected _children: ITreeNodeOrCompositeTreeNode[] | null;
    private _branchSize;
    private _flattenedBranch;
    private _lock;
    private _root;
    private watchTerminator;
    watchEvents: Map<string, IWatcherInfo>;
    isExpanded: boolean;
    private refreshThrottler;
    private toRefreshPathQueue;
    protected generatorWatcher(): ITreeWatcher;
    constructor(tree: ITree, parent?: ICompositeTreeNode, watcher?: ITreeWatcher, optionalMetadata?: {
        [key: string]: any;
    });
    set name(name: string);
    get name(): string;
    get watcher(): ITreeWatcher;
    get type(): TreeNodeType;
    get children(): ITreeNodeOrCompositeTreeNode[] | null;
    get expanded(): boolean;
    /**
     * 当前可见的分支数量
     *
     * 当节点为展开状态时，其整个分支（递归展平）由上一级的分支（根（位于数据层可见）或处于折叠状态的分支）拥有
     * 当节点为折叠状态时，其整个分支（递归展平）由其上一级父目录展开该节点
     *
     * @readonly
     * @memberof CompositeTreeNode
     */
    get branchSize(): number;
    /**
     * 获取当前节点的分支数，一般为顶层节点，如Root上获取
     *
     * @readonly
     * @memberof CompositeTreeNode
     */
    get flattenedBranch(): number[] | null;
    get lock(): boolean;
    get root(): ICompositeTreeNode | null;
    private getRoot;
    /**
     * 确保此“目录”的子级已加载（不影响“展开”状态）
     * 如果子级已经加载，则返回的Promise将立即解决
     * 否则，将发出重新加载请求并返回Promise
     * 一旦返回的Promise.resolve，“CompositeTreeNode＃children” 便可以访问到对于节点
     */
    ensureLoaded(token?: CancellationToken): Promise<boolean | undefined>;
    setExpanded(ensureVisible?: boolean, quiet?: boolean, isOwner?: boolean, token?: CancellationToken): Promise<void>;
    private getAllExpandedNodePath;
    private getAllCollapsedNodePath;
    /**
     * 处理节点数据，让节点重新加载子节点及初始化 flattenedBranch
     * @param token CancellationToken
     */
    private resolveChildrens;
    private updateTreeNodeCache;
    /**
     * 静默刷新子节点, 即不触发分支更新事件
     * @param toExpandPaths 待展开的路径
     * @param token CancellationToken
     * @param origin 当 this === origin 时，说明此节点为调用的源头节点
     */
    private refreshTreeNodeByPaths;
    expandedAll(collapsedPaths?: string[]): Promise<void>;
    collapsedAll(expandedPaths?: string[]): Promise<void>;
    setCollapsed(quiet?: boolean): void;
    mv(to: ICompositeTreeNode, name?: string): void;
    /**
     * 在节点中插入新的节点
     *
     * 直接调用此方法将不会触发onWillHandleWatchEvent和onDidHandleWatchEvent事件
     */
    insertItem(item: ITreeNodeOrCompositeTreeNode): ITreeNode | undefined;
    /**
     * 从父节点中移除节点
     *
     * 直接调用此方法将不会触发onWillHandleWatchEvent和onDidHandleWatchEvent事件
     */
    unlinkItem(item: ITreeNodeOrCompositeTreeNode, reparenting?: boolean): void;
    /**
     * 转换节点路径
     */
    private transferItem;
    dispose(): void;
    /**
     * 设置扁平化的分支信息
     */
    protected setFlattenedBranch(leaves: number[] | null, withoutNotify?: boolean): void;
    /**
     * 展开分支节点
     * @param branch 分支节点
     */
    protected expandBranch(branch: CompositeTreeNode, withoutNotify?: boolean): void;
    /**
     * 清理分支节点
     * @param branch 分支节点
     */
    protected shrinkBranch(branch: CompositeTreeNode, withoutNotify?: boolean): void;
    /**
     * 加载子节点信息
     * 当返回值为 true 时，正常加载完子节点并同步到数据结构中
     * 返回值为 false 时，加载节点的过程被中断
     *
     * @memberof CompositeTreeNode
     */
    hardReloadChildren(token?: CancellationToken): Promise<boolean>;
    moveNode(oldPath: string, newPath: string): ITreeNode | undefined;
    addNode(node: TreeNode): ITreeNode | undefined;
    removeNode(path: string): void;
    /**
     * 处理 Watch 事件，同时可通过外部手动调 g用节点更新函数进行节点替换，这里为通用的事件管理
     * 如： transferItem，insertItem, unlinkItem等
     * @private
     * @memberof CompositeTreeNode
     */
    private handleWatchEvent;
    refresh(tokenSource?: CancellationTokenSource, target?: CompositeTreeNode): any;
    private doRefresh;
    private getRefreshNode;
    private isItemVisibleAtRootSurface;
    /**
     * 检查节点是否可见，而不是被隐藏在节点中
     *
     * 这里的可见并不表示节点在当前视图中可见，而是在用户滚动到特定位置便可看见
     *
     * 隐藏在节点中可能的原因为其父节点中有一个以上处于折叠状态
     */
    isItemVisibleAtSurface(item: ITreeNodeOrCompositeTreeNode): boolean;
    private transformToRelativePath;
    /**
     * 根据路径展开节点树
     * @memberof CompositeTreeNode
     */
    loadTreeNodeByPath(path: string, quiet?: boolean): Promise<ITreeNodeOrCompositeTreeNode | undefined>;
    /**
     * 根据节点获取节点ID下标位置
     * @param {number} id
     * @returns
     * @memberof CompositeTreeNode
     */
    getIndexAtTreeNodeId(id: number): number;
    /**
     * 根据节点获取节点下标位置
     * @param {ITreeNodeOrCompositeTreeNode} node
     * @returns
     * @memberof CompositeTreeNode
     */
    getIndexAtTreeNode(node: ITreeNodeOrCompositeTreeNode): number;
    /**
     * 根据下标位置获取节点
     * @param {number} index
     * @returns
     * @memberof CompositeTreeNode
     */
    getTreeNodeAtIndex(index: number): ITreeNode | undefined;
    /**
     * 根据节点ID获取节点
     * @param {number} id
     * @returns
     * @memberof CompositeTreeNode
     */
    getTreeNodeById(id: number): ITreeNodeOrCompositeTreeNode | undefined;
    /**
     * 根据节点路径获取节点
     * @param {string} path
     * @returns
     * @memberof CompositeTreeNode
     */
    getTreeNodeByPath(path: string): ITreeNodeOrCompositeTreeNode | undefined;
}
//# sourceMappingURL=TreeNode.d.ts.map