/**
 * Copyright 2023-present DreamNum Co., Ltd.
 *
 * 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 { Nullable } from '@univerjs/core';
import type { IDirtyUnitDefinedNameMap, IExprTreeNode, ISuperTable } from '../../basics/common';
import type { IFunctionNames } from '../../basics/function';
import type { IDefinedNamesServiceParam } from '../../services/defined-names.service';
import type { ISequenceArray, ISequenceNode } from '../utils/sequence';
import { AbsoluteRefType, Disposable } from '@univerjs/core';
import { FormulaAstLRU } from '../../basics/cache-lru';
import { ErrorType } from '../../basics/error-type';
import { LexerNode } from './lexer-node';
export declare const FormulaLexerNodeCache: FormulaAstLRU<LexerNode>;
export declare const FormulaSequenceNodeCache: FormulaAstLRU<(string | ISequenceNode)[]>;
interface IInjectDefinedNameParam {
    unitId: Nullable<string>;
    sheetId?: Nullable<string>;
    refOffsetX: number;
    refOffsetY: number;
    hasFunction(functionToken: IFunctionNames): boolean;
    getValueByName(unitId: string, name: string, sheetId?: Nullable<string>): Nullable<IDefinedNamesServiceParam>;
    getDirtyDefinedNameMap(): IDirtyUnitDefinedNameMap;
    getSheetName: (unitId: string, sheetId: string) => string;
}
export declare class LexerTreeBuilder extends Disposable {
    private _currentLexerNode;
    private _upLevel;
    private _segment;
    private _bracketState;
    private _openBracketNormalIndexStack;
    private _squareBracketState;
    private _bracesState;
    private _singleQuotationState;
    private _doubleQuotationState;
    private _lambdaState;
    private _colonState;
    private _formulaErrorCount;
    private _tableBracketState;
    private _hasNewExcelFunction;
    private _lambdaFunctionParameterSet;
    private _xlpmPrefix;
    private _xlfnPrefix;
    private _resetPrefix;
    private _clearPrefix;
    dispose(): void;
    getUpLevel(): number;
    isColonClose(): boolean;
    isColonOpen(): boolean;
    isDoubleQuotationClose(): boolean;
    isLambdaOpen(): boolean;
    isLambdaClose(): boolean;
    isSingleQuotationClose(): boolean;
    isBracesClose(): boolean;
    isBracketClose(): boolean;
    isSquareBracketClose(): boolean;
    getCurrentLexerNode(): LexerNode;
    getFunctionAndParameter(formulaString: string, strIndex: number): {
        functionName: string;
        paramIndex: number;
    } | undefined;
    /**
     * Estimate the number of right brackets that need to be automatically added to the end of the formula.
     * @param formulaString
     */
    checkIfAddBracket(formulaString: string): number;
    sequenceNodesBuilder(formulaString: string): (string | ISequenceNode)[] | undefined;
    convertRefersToAbsolute(formulaString: string, startAbsoluteRefType: AbsoluteRefType, endAbsoluteRefType: AbsoluteRefType, currentSheetName?: string): string;
    moveFormulaRefOffset(formulaString: string, refOffsetX: number, refOffsetY: number, ignoreAbsolute?: boolean): string;
    /**
     * univer-pro/issues/1684
     * =sum({}{})
     */
    private _formulaSpellCheck;
    /**
     * ={0,1,2,3,4,5,6} + {0;1;2;3;4;5;6}*7
     */
    private _passArrayOperator;
    getSequenceNode(sequenceArray: ISequenceArray[]): (string | ISequenceNode)[];
    private _processPushSequenceNode;
    private _getCurrentParamIndex;
    private _isLastMergeString;
    /**
     * Merge array and handle ref operations
     *
     */
    private _mergeSequenceNodeReference;
    /**
     * =-A1  Separate the negative sign from the ref string.
     */
    private _minusSplitSequenceNode;
    private _pushSequenceNode;
    nodeMakerTest(formulaString: string): ErrorType.VALUE | (string | LexerNode)[] | undefined;
    treeBuilder(formulaString: string, transformSuffix?: boolean, injectDefinedNameParam?: IInjectDefinedNameParam): ErrorType.VALUE | LexerNode | (string | LexerNode)[] | undefined;
    private _handleDefinedName;
    private _moveDefinedNameRefOffset;
    private _getHasSheetNameDefinedName;
    private _handleNestedDefinedName;
    private _simpleCheckDefinedName;
    private _checkDefinedNameDirty;
    private _suffixExpressionHandler;
    private _processSuffixExpressionRemain;
    private _processSuffixExpressionCloseBracket;
    private _checkCloseBracket;
    private _checkOpenBracket;
    private _checkOperator;
    private _deletePlusForPreNode;
    private _resetCurrentLexerNode;
    private _resetSegment;
    private _openBracket;
    private _closeBracket;
    private _openBracketNormalIndex;
    private _getNodesByCurrentBracketNormalIndex;
    private _openSquareBracket;
    private _closeSquareBracket;
    private _getCurrentBracket;
    private _changeCurrentBracket;
    private _openBraces;
    private _closeBraces;
    private _openSingleQuotation;
    private _closeSingleQuotation;
    private _openDoubleQuotation;
    private _closeDoubleQuotation;
    private _openLambda;
    private _closeLambda;
    private _openColon;
    private _closeColon;
    private _isTableBracket;
    private _openTableBracket;
    private _closeTableBracket;
    private _formalErrorOccurred;
    private _hasFormalError;
    private _getLastChildCurrentLexerNode;
    private _getLastChildCurrent;
    private _setParentCurrentLexerNode;
    private _setAncestorCurrentLexerNode;
    private _segmentCount;
    private _pushSegment;
    private _pushNodeToChildren;
    private _setCurrentLexerNode;
    private _newAndPushCurrentLexerNode;
    private _getTopNode;
    private _removeLastChild;
    /**
     * fix univer-pro/issues/2447
     * =1/3+
     * =+
     * =sum(A1+)
     */
    private _formulaErrorLastTokenCheck;
    private _findPreviousToken;
    private _findSecondLastNonSpaceToken;
    private _findNextToken;
    private _unexpectedEndingTokenExcludeOperator;
    private _unexpectedEndingToken;
    private _isOperatorToken;
    private _getSequenceArray;
    private _resetTemp;
    private _checkErrorState;
    private _checkSimilarErrorToken;
    private _checkIfErrorObject;
    private _findErrorObject;
    private _nodeMaker;
    private _isScientificNotation;
    private _addSequenceArray;
    getNewFormulaWithPrefix(formulaString: string, hasFunction: (functionToken: IFunctionNames) => boolean): string | null;
    private _generateNewFunctionString;
    private _handleNewFunctionChild;
    private _clearFunctionString;
    private _checkAddBracketForMinus;
    private _currentUnitId;
    getFormulaExprTree(formulaString: string, unitId: string, hasFunction: (functionToken: IFunctionNames) => boolean, getDefinedNameName: (unitId: string, name: string) => Nullable<IDefinedNamesServiceParam>, getTable: (unitId: string, tableName: string) => Nullable<ISuperTable>): IExprTreeNode | null;
    private _generateExprTree;
    private _handleChildrenForExprTree;
    private _checkColonNodeForExprTree;
    private _handleTextNodeForExprTree;
    private _getTableNameFromStructuredRef;
    private _handleLambdaForExprTree;
    private _getCurNodeTypeForExprTree;
}
export {};
