import { SelectionChange, SelectionModel } from '@angular/cdk/collections';
import { FlatTreeControl } from '@angular/cdk/tree';
import { InjectionToken, OnInit } from '@angular/core';
import { BaseDataSource, BaseDataSourceMetadata, BaseDataSourceViewer } from '@rxap/data-source';
import { EventOptions, ExpandNodeFunction, Node, NodeGetIconFunction, NodeGetStyleFunction, NodeGetTypeFunction, NodeHasDetailsFunction, NodeToDisplayFunction } from '@rxap/data-structure-tree';
import { Method } from '@rxap/pattern';
import { ToggleSubject } from '@rxap/rxjs';
import { WithChildren, WithIdentifier } from '@rxap/utilities';
import { BehaviorSubject, Observable } from 'rxjs';
import { ISearchForm, SearchForm } from './search.form';
import * as i0 from "@angular/core";
export declare function isSelectionChange<T>(obj: any): obj is SelectionChange<T>;
export interface TreeDataSourceMetadata extends BaseDataSourceMetadata {
    selectMultiple?: boolean;
    expandMultiple?: boolean;
    scopeTypes?: string[];
    /**
     * If true the tree will be refreshed with caching disbabled after the first load
     */
    autoRefreshWithoutCache?: boolean;
}
export declare const RXAP_TREE_DATA_SOURCE_ROOT_REMOTE_METHOD: InjectionToken<unknown>;
export declare const RXAP_TREE_DATA_SOURCE_CHILDREN_REMOTE_METHOD: InjectionToken<unknown>;
export declare const RXAP_TREE_DATA_SOURCE_APPLY_FILTER_METHOD: InjectionToken<unknown>;
export declare function flatTree<Data extends WithIdentifier & WithChildren = any>(tree: Node<Data> | Array<Node<Data>>, all?: boolean): Array<Node<Data>>;
export interface TreeApplyFilterParameter<Form extends ISearchForm = ISearchForm, Data extends WithIdentifier & WithChildren = any> {
    tree: Array<Node<Data>>;
    filter: Form;
    scopeTypes?: string[];
}
export declare class DefaultTreeApplyFilterMethod<Data extends WithIdentifier & WithChildren = any> implements Method<Array<Node<Data>>, TreeApplyFilterParameter> {
    protected lastFilter: ISearchForm | null;
    call({ tree, filter, scopeTypes }: TreeApplyFilterParameter): Array<Node<Data>> | Promise<Array<Node<Data>>>;
    protected isEqualToLastFilter(filter: ISearchForm): boolean;
    static ɵfac: i0.ɵɵFactoryDeclaration<DefaultTreeApplyFilterMethod<any>, never>;
    static ɵprov: i0.ɵɵInjectableDeclaration<DefaultTreeApplyFilterMethod<any>>;
}
export declare class TreeDataSource<Data extends WithIdentifier & WithChildren = any, RootParameters = any, NodeParameters = any> extends BaseDataSource<Array<Node<Data>>, TreeDataSourceMetadata> implements OnInit {
    readonly rootRemoteMethod: Method<Data | Data[], RootParameters>;
    readonly childrenRemoteMethod: Method<Data[], Node<Data>> | null;
    tree$: BehaviorSubject<Node<Data, any>[]>;
    treeControl: FlatTreeControl<Node<Data>>;
    selected: SelectionModel<Node<Data>>;
    expanded: SelectionModel<string>;
    loading$: ToggleSubject;
    searchForm: SearchForm | null;
    protected _data$: BehaviorSubject<Node<Data, any>[]>;
    private _expandedLocalStorageSubscription;
    private _selectedLocalStorageSubscription;
    private _preSelected;
    private _refreshMatchFilter;
    private readonly applyFilterMethod;
    constructor(rootRemoteMethod: Method<Data | Data[], RootParameters>, childrenRemoteMethod?: Method<Data[], Node<Data>> | null, applyFilterMethod?: Method<Array<Node<Data>>, TreeApplyFilterParameter> | null, metadata?: TreeDataSourceMetadata | null);
    private _nodeParameters;
    get nodeParameters(): NodeParameters | null;
    set nodeParameters(nodeParameters: NodeParameters | null);
    ngOnInit(): void;
    toDisplay: NodeToDisplayFunction<Data>;
    getIcon: NodeGetIconFunction<Data>;
    getType: NodeGetTypeFunction<Data>;
    getStyle: NodeGetStyleFunction<Data>;
    hasDetails: NodeHasDetailsFunction<Data>;
    matchFilter: (node: Node<Data>) => boolean;
    getTreeRoot(options?: {
        cache?: boolean;
    }): Promise<Array<Node<Data>>>;
    selectNode(node: Node<Data>): Promise<void>;
    setTreeControl(treeControl: FlatTreeControl<Node<Data>>): void;
    setMatchFilter(matchFilter: (node: Node<Data>) => boolean): void;
    setToDisplay(toDisplay?: NodeToDisplayFunction<Data>): void;
    setGetIcon(getIcon?: NodeGetIconFunction<Data>): void;
    setHasDetails(hasDetails?: NodeHasDetailsFunction<Data>): void;
    deselectNode(node: Node<Data>): Promise<void>;
    expandNode(node: Node<Data>, options?: EventOptions): Promise<void>;
    getChildren(node: Node<Data>): Promise<Data[]>;
    getRoot(options?: {
        cache?: boolean;
    }): Promise<Data | Data[]>;
    getRootParameters(options?: {
        cache?: boolean;
    }): Promise<RootParameters>;
    getNodeById(id: string): Node<Data> | null;
    toNode(parent: Node<Data> | null, item: Data, depth?: number, onExpand?: ExpandNodeFunction<Data>, onCollapse?: ExpandNodeFunction<Data>, onSelect?: ExpandNodeFunction<Data>, onDeselect?: ExpandNodeFunction<Data>): Promise<Node<Data>>;
    collapseNode(node: Node<Data>, options?: EventOptions): Promise<void>;
    /**
     * Converts the tree structure into a list.
     *
     * @param tree
     * @param all true - include nodes children that are not expanded
     */
    flatTree(tree: Node<Data>, all?: boolean): Array<Node<Data>>;
    destroy(): void;
    refreshMatchFilter(): void;
    refresh(): Promise<any>;
    reset(): any;
    setGetStyle(getStyle?: NodeGetStyleFunction<any>): void;
    setGetType(getType?: NodeGetTypeFunction<any>): void;
    /**
     * recall the getStyle, getIcon and toDisplay methods
     * and update the node objects
     */
    updateNodes(): void;
    protected _connect(collectionViewer: Required<BaseDataSourceViewer>): Observable<Array<Node<Data>>>;
    private initSelected;
    private initExpanded;
    static ɵfac: i0.ɵɵFactoryDeclaration<TreeDataSource<any, any, any>, [null, { optional: true; }, { optional: true; }, { optional: true; }]>;
    static ɵprov: i0.ɵɵInjectableDeclaration<TreeDataSource<any, any, any>>;
}
