/**
 * Copyright (c) 2020-present, Goldman Sachs
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import type { TreeNodeData, TreeData } from '@finos/legend-art';
import { type GeneratorFn, ActionState, type Hashable } from '@finos/legend-shared';
import type { QueryBuilderExplorerTreeDragSource, QueryBuilderExplorerTreeRelationColumnDragSource } from '../explorer/QueryBuilderExplorerState.js';
import { QueryBuilderPropertyExpressionState } from '../QueryBuilderPropertyEditorState.js';
import type { QueryBuilderState } from '../QueryBuilderState.js';
import { type ValueSpecification, type VariableExpression, type Type, AbstractPropertyExpression, Multiplicity } from '@finos/legend-graph';
import type { QueryBuilderProjectionColumnDragSource } from '../fetch-structure/tds/projection/QueryBuilderProjectionColumnState.js';
import type { QueryBuilderFilterOperator } from './QueryBuilderFilterOperator.js';
import { QUERY_BUILDER_GROUP_OPERATION } from '../QueryBuilderGroupOperationHelper.js';
import type { QueryBuilderVariableDragSource } from '../../components/shared/BasicValueSpecificationEditor.js';
export declare enum QUERY_BUILDER_FILTER_DND_TYPE {
    GROUP_CONDITION = "QUERY_BUILDER_FILTER_DND_TYPE.GROUP_CONDITION",
    CONDITION = "QUERY_BUILDER_FILTER_DND_TYPE.CONDITION",
    BLANK_CONDITION = "QUERY_BUILDER_FILTER_DND_TYPE.BLANK_CONDITION"
}
export interface QueryBuilderFilterConditionDragSource {
    node: QueryBuilderFilterTreeNodeData;
}
export type QueryBuilderFilterNodeDropTarget = QueryBuilderExplorerTreeDragSource | QueryBuilderExplorerTreeRelationColumnDragSource | QueryBuilderProjectionColumnDragSource | QueryBuilderFilterConditionDragSource;
export type QueryBuilderFilterValueDropTarget = QueryBuilderVariableDragSource | QueryBuilderProjectionColumnDragSource | QueryBuilderExplorerTreeDragSource | QueryBuilderExplorerTreeRelationColumnDragSource;
export type QueryBuilderFilterConditionRearrangeDropTarget = QueryBuilderFilterConditionDragSource;
export declare const isCollectionProperty: (propertyExpression: AbstractPropertyExpression) => boolean;
export declare abstract class FilterConditionValueState implements Hashable {
    conditionState: FilterConditionState;
    constructor(conditionState: FilterConditionState);
    get type(): Type | undefined;
    get isCollection(): boolean;
    get hashCode(): string;
}
export declare class FilterValueSpecConditionValueState extends FilterConditionValueState {
    value?: ValueSpecification | undefined;
    constructor(conditionState: FilterConditionState, value?: ValueSpecification | undefined);
    get type(): Type | undefined;
    setValue(val: ValueSpecification | undefined): ValueSpecification | undefined;
    get isCollection(): boolean;
    get hashCode(): string;
}
export declare class FilterPropertyExpressionStateConditionValueState extends FilterConditionValueState {
    propertyExpressionState: QueryBuilderPropertyExpressionState;
    constructor(conditionState: FilterConditionState, propertyExpressionState: QueryBuilderPropertyExpressionState);
    get type(): Type;
    get isCollection(): boolean;
    changePropertyExpressionState(propertyExpressionState: QueryBuilderPropertyExpressionState): void;
}
export declare class FilterRelationColumnConditionValueState extends FilterConditionValueState {
    columnName: string;
    columnType: Type;
    columnMultiplicity: Multiplicity;
    constructor(conditionState: FilterConditionState, columnName: string, columnType: Type, columnMultiplicity: Multiplicity);
    get type(): Type;
    get isCollection(): boolean;
    changeColumn(columnName: string, columnType: Type, columnMultiplicity: Multiplicity): void;
    get hashCode(): string;
}
/**
 * Abstract base class for the left-hand side (source) of a filter condition.
 * This allows filtering on different source types (class properties, relation columns)
 * without operators needing to know the specifics of the source.
 */
export declare abstract class FilterConditionSourceState implements Hashable {
    abstract get type(): Type;
    abstract get label(): string;
    abstract get title(): string;
    abstract get isValid(): boolean;
    abstract get requiresExistsHandling(): boolean;
    abstract buildLeftExpression(queryBuilderState: QueryBuilderState, lambdaParameterName: string): ValueSpecification;
    abstract get hashCode(): string;
}
export declare class FilterPropertyExpressionSourceState extends FilterConditionSourceState {
    readonly propertyExpressionState: QueryBuilderPropertyExpressionState;
    constructor(propertyExpressionState: QueryBuilderPropertyExpressionState);
    get type(): Type;
    get label(): string;
    get title(): string;
    get isValid(): boolean;
    get requiresExistsHandling(): boolean;
    buildLeftExpression(queryBuilderState: QueryBuilderState, lambdaParameterName: string): ValueSpecification;
    get hashCode(): string;
}
export declare class FilterRelationColumnSourceState extends FilterConditionSourceState {
    readonly columnName: string;
    readonly columnType: Type;
    readonly columnMultiplicity: Multiplicity;
    constructor(columnName: string, columnType: Type, columnMultiplicity: Multiplicity);
    get multiplicity(): Multiplicity;
    get type(): Type;
    get label(): string;
    get title(): string;
    get isValid(): boolean;
    get requiresExistsHandling(): boolean;
    buildLeftExpression(queryBuilderState: QueryBuilderState, lambdaParameterName: string): ValueSpecification;
    get hashCode(): string;
}
export declare class FilterConditionState implements Hashable {
    readonly filterState: QueryBuilderFilterState;
    sourceState: FilterConditionSourceState;
    operator: QueryBuilderFilterOperator;
    rightConditionValue?: FilterConditionValueState | undefined;
    existsLambdaParamNames: string[];
    typeaheadSearchResults: string[] | undefined;
    typeaheadSearchState: ActionState;
    constructor(filterState: QueryBuilderFilterState, source: AbstractPropertyExpression | FilterConditionSourceState, operator?: QueryBuilderFilterOperator);
    /**
     * Backward-compatible accessor for the property expression state.
     * Only valid when the source is a property expression.
     */
    get propertyExpressionState(): QueryBuilderPropertyExpressionState;
    /**
     * The raw type of the left-hand side of the filter condition.
     */
    get leftConditionType(): Type;
    get operators(): QueryBuilderFilterOperator[];
    handleTypeaheadSearch(searchValue?: ValueSpecification | undefined): GeneratorFn<void>;
    changeOperator(val: QueryBuilderFilterOperator): void;
    setOperator(val: QueryBuilderFilterOperator): void;
    setRightConditionValue(val: FilterConditionValueState | undefined): void;
    addExistsLambdaParamNames(val: string): void;
    buildRightConditionValueFromValueSpec(val: ValueSpecification | undefined): void;
    buildRightConditionValueFromPropertyExpressionState(propertyExpressionState: QueryBuilderPropertyExpressionState): void;
    buildRightConditionValueFromRelationColumn(columnName: string, columnType: Type, columnMultiplicity: Multiplicity): void;
    get hashCode(): string;
}
export declare abstract class QueryBuilderFilterTreeNodeData implements TreeNodeData, Hashable {
    readonly id: string;
    readonly label = "";
    isOpen?: boolean | undefined;
    parentId?: string | undefined;
    constructor(parentId: string | undefined);
    abstract get dragPreviewLabel(): string;
    setIsOpen(val: boolean): void;
    setParentId(val: string | undefined): void;
    abstract get hashCode(): string;
}
export declare abstract class QueryBuilderFilterTreeOperationNodeData extends QueryBuilderFilterTreeNodeData implements Hashable {
    childrenIds: string[];
    lambdaParameterName?: string | undefined;
    constructor(parentId: string | undefined);
    addChildNode(node: QueryBuilderFilterTreeNodeData): void;
    removeChildNode(node: QueryBuilderFilterTreeNodeData): void;
    addChildNodeAt(node: QueryBuilderFilterTreeNodeData, idx: number): void;
}
export declare class QueryBuilderFilterTreeGroupNodeData extends QueryBuilderFilterTreeOperationNodeData implements Hashable {
    groupOperation: QUERY_BUILDER_GROUP_OPERATION;
    constructor(parentId: string | undefined, groupOperation: QUERY_BUILDER_GROUP_OPERATION);
    get dragPreviewLabel(): string;
    setGroupOperation(val: QUERY_BUILDER_GROUP_OPERATION): void;
    get hashCode(): string;
}
export declare class QueryBuilderFilterTreeExistsNodeData extends QueryBuilderFilterTreeOperationNodeData implements Hashable {
    readonly filterState: QueryBuilderFilterState;
    propertyExpressionState: QueryBuilderPropertyExpressionState;
    constructor(filterState: QueryBuilderFilterState, parentId: string | undefined);
    get dragPreviewLabel(): string;
    setPropertyExpression(val: AbstractPropertyExpression): void;
    get hashCode(): string;
}
export declare const isExistsNodeChild: (node: QueryBuilderFilterTreeConditionNodeData) => boolean;
/**
 *
 * @param node the node from which to start searching
 * @returns the furthest away parent node that is an exists node, or
 *          undefined if none exists.
 */
export declare const getFurthestExistsNodeParent: (node: QueryBuilderFilterTreeConditionNodeData) => QueryBuilderFilterTreeExistsNodeData | undefined;
export declare class QueryBuilderFilterTreeConditionNodeData extends QueryBuilderFilterTreeNodeData implements Hashable {
    condition: FilterConditionState;
    isNewlyAdded: boolean;
    constructor(parentId: string | undefined, condition: FilterConditionState);
    setIsNewlyAdded(val: boolean): void;
    get dragPreviewLabel(): string;
    get hashCode(): string;
}
export declare class QueryBuilderFilterTreeBlankConditionNodeData extends QueryBuilderFilterTreeNodeData implements Hashable {
    constructor(parentId: string | undefined);
    get dragPreviewLabel(): string;
    get hashCode(): string;
}
export declare class QueryBuilderFilterState implements TreeData<QueryBuilderFilterTreeNodeData>, Hashable {
    queryBuilderState: QueryBuilderState;
    lambdaParameterName: string;
    rootIds: string[];
    nodes: Map<string, QueryBuilderFilterTreeNodeData>;
    selectedNode?: QueryBuilderFilterTreeNodeData | undefined;
    isRearrangingConditions: boolean;
    operators: QueryBuilderFilterOperator[];
    showPanel: boolean;
    constructor(queryBuilderState: QueryBuilderState, operators: QueryBuilderFilterOperator[]);
    get isEmpty(): boolean;
    setLambdaParameterName(val: string): void;
    setShowPanel(val: boolean): void;
    setRearrangingConditions(val: boolean): void;
    setSelectedNode(val: QueryBuilderFilterTreeNodeData | undefined): void;
    getNode(id: string): QueryBuilderFilterTreeNodeData;
    getRootNode(): QueryBuilderFilterTreeNodeData | undefined;
    getParentNode(node: QueryBuilderFilterTreeNodeData): QueryBuilderFilterTreeOperationNodeData | undefined;
    private addRootNode;
    addNodeFromNode(node: QueryBuilderFilterTreeNodeData, fromNode: QueryBuilderFilterTreeNodeData | undefined): void;
    replaceBlankNodeWithNode(node: QueryBuilderFilterTreeNodeData, blankNode: QueryBuilderFilterTreeBlankConditionNodeData): void;
    addGroupConditionNodeFromNode(fromNode: QueryBuilderFilterTreeNodeData | undefined): void;
    /**
     *
     * Function to create group condition from node where either of the
     * child nodes of group condition is `exists` node
     */
    newGroupConditionFromNode(fromNode: QueryBuilderFilterTreeConditionNodeData | QueryBuilderFilterTreeExistsNodeData, node?: QueryBuilderFilterTreeConditionNodeData | QueryBuilderFilterTreeExistsNodeData | undefined, operation?: QUERY_BUILDER_GROUP_OPERATION | undefined): QueryBuilderFilterTreeGroupNodeData;
    newGroupWithConditionFromNode(node: QueryBuilderFilterTreeNodeData | undefined, fromNode: QueryBuilderFilterTreeNodeData | undefined): void;
    private removeNode;
    private pruneChildlessGroupNodes;
    private pruneOrphanNodes;
    /**
     * If group node has fewer than 2 children, flatten it
     */
    private squashGroupNode;
    removeNodeAndPruneBranch(node: QueryBuilderFilterTreeNodeData): void;
    pruneTree(): void;
    /**
     * Cleanup unecessary group nodes (i.e. group node whose group operation is the same as its parent's)
     */
    simplifyTree(): void;
    isValidMove(node: QueryBuilderFilterTreeNodeData, toNode: QueryBuilderFilterTreeNodeData): boolean;
    moveNode(node: QueryBuilderFilterTreeNodeData, toNode: QueryBuilderFilterTreeNodeData): void;
    collapseTree(): void;
    expandTree(): void;
    isVariableUsed(variable: VariableExpression): boolean;
    isInvalidFilterPropertyExpressionState(node: QueryBuilderFilterTreeNodeData): boolean;
    isInvalidValueSpecFilterValue(node: QueryBuilderFilterTreeNodeData): boolean;
    isInvalidPropertyExpressionStateFilterValue(node: QueryBuilderFilterTreeNodeData): boolean;
    get allValidationIssues(): string[];
    get hasInvalidFilterValues(): boolean;
    get hasInvalidDerivedPropertyParameters(): boolean;
    get hashCode(): string;
}
//# sourceMappingURL=QueryBuilderFilterState.d.ts.map