import { Jexl } from '@pawel-up/jexl';
import { Property } from '../../models/Property.js';
export interface EvaluateOptions {
    /**
     * The execution context to use instead of creating the context
     */
    context?: Record<string, string>;
    /**
     * The list of properties to evaluate. If not set then it scans for all keys in the object.
     * This is used when evaluating objects.
     */
    names?: string[];
}
export declare function valueHasVariable(value: string): boolean;
export declare const functionRegex: RegExp;
export declare const varValueRe: RegExp;
export declare const varExprRe: RegExp;
export declare const varStrictExprRe: RegExp;
export declare class VariablesProcessor {
    jexl: Jexl;
    /**
     * A helper function to map properties to the context object.
     *
     * The arguments are the lists of `Property`. It starts reading the variables from the right to left,
     * meaning, variables on the left override variables already defined on the left.
     *
     * ```javascript
     * const result = VariablesProcessor.createContextFromProperties(
     *   [Property.String('test1', 'value1')],
     *   [Property.String('test1', 'value2')]
     * );
     * ```
     * The result has only one variable `test1` with value `value1` because this value if left most in the arguments list.
     *
     * When a property with the same name is repeated in the same group then the last value wins.
     *
     * Note, variables without a name, not enabled, or which `value` is undefined are ignored.
     */
    static createContextFromProperties(...input: Property[][]): Record<string, string>;
    /**
     * Processes the context itself. This way the context can also contain variables.
     *
     * @return Promise resolved to the context to be passed to Jexl.
     */
    buildContext(unprocessedContext: Record<string, string>): Promise<Record<string, string>>;
    /**
     * Processes variables in the context recursively.
     *
     * @param result A result to where to put the values.
     * @param variables The map of current variables
     * @param runCount Current run count in the recursive function. It stops executing after second run.
     */
    _processContextVariables(result: Record<string, string>, variables: Record<string, string>, runCount?: number): Promise<Record<string, string>>;
    /**
     * Clears cached groups.
     */
    clearCache(): void;
    /**
     * Evaluates a value against the passed variables.
     *
     * Use this method when the context is not evaluated against itself. You can manually
     * build context with `buildContext()` and call `evaluateWithContext()` for additional
     * performance improvement.
     *
     * @param value A value to evaluate
     * @param unprocessedContext The context (or variables) to use when evaluating the value.
     * @return Promise that resolves to the evaluated value.
     */
    evaluateVariable(value: string, unprocessedContext: Record<string, string>): Promise<string>;
    /**
     * Evaluates the object against the passed variables.
     *
     * Note, it only performs a shallow evaluation. Deep objects are not evaluated.
     *
     * Use this method when the context is not evaluated against itself. You can manually
     * build context with `buildContext()` and call `evaluateVariablesWithContext()` for additional
     * performance improvement.
     *
     * @param obj The object to evaluate.
     * @param unprocessedContext The context (or variables) to use when evaluating the value.
     * @return Copy of the passed object with the evaluated values.
     */
    evaluateVariables<T>(obj: T, unprocessedContext: Record<string, string>, names?: string[]): Promise<T>;
    /**
     * Evaluates the object against the passed variables.
     *
     * Note, it only performs a shallow evaluation. Deep objects are not evaluated.
     *
     * This method is to be used when the passed context is already evaluated against itself.
     *
     * @param obj The object to evaluate.
     * @param context The evaluated context. use `buildContext()` to prepare the values.
     * @param names The list of names of variables to evaluate. Note, this function changes this array.
     * @returns Copy of the passed object with the evaluated values.
     */
    evaluateVariablesWithContext<T>(obj: T, context: Record<string, string>, names?: string[]): Promise<T>;
    /**
     * Evaluates a value with context passed to Jexl.
     *
     * @param context Jexl's context
     * @param value Value to evaluate
     */
    evaluateWithContext(context: Record<string, string>, value: string): Promise<string>;
    _parse(value: string, context: Record<string, string>): Promise<string>;
    /**
     * Upgrades old syntax of magic variables to new one.
     * It replaces `${now}` and `${random}` to function calls: `now()` and
     * `random()`. It also keeps grouping.
     *
     * @param value Currently evaluated value
     * @return Parsed value without old syntax.
     */
    _upgradeLegacy(value: string): string;
    /**
     * Evaluates functions.
     *
     * @param value A value to evaluate
     * @returns Evaluated value with removed functions.
     * @throws Error if a function is not supported.
     */
    _evalFunctions(value: string, context: Record<string, string>): string;
    /**
     * Calls one of the predefined functions and returns its value.
     *
     * @param fnName A function name to call.
     * @param args Arguments find in the expression.
     * @return Result of calling a function. Always a string.
     */
    _callFn(context: Record<string, string>, fnName: string, args?: string[]): string | number;
    /**
     * Calls JavaScript native function.
     * Currently only `Math`, 'JSON', and `String` namespaces are supported.
     *
     * @param namespace The namespace of the function to call
     * @param fn Name of the function to call
     * @param args A list of arguments to call
     * @returns Processed value.
     */
    _callNamespaceFunction(context: Record<string, string>, namespace: string, fn: string, args?: string[]): string | number;
    /**
     * Prepares variables to be evaluated where a value is a multiline value.
     * @param lines Lines in the expression
     * @returns Processed lines
     */
    _prepareMultilineValue(lines: string[]): string[];
    _applyArgumentsContext(arg: any, context: Record<string, string>): any;
    /**
     * Replaces strings with quoted string and variables notation into
     * variables that Jexl understands.
     *
     * @param value Value to evaluate
     * @return Proper syntax for Jexl
     */
    _prepareValue(value: string): string;
    /**
     * Wraps a passed value with `'{'` and `'}'` to be properly processed by Jexl.
     * @param value The value to wrap.
     * @param isJson Whether the passed string originally was a JSON string.
     * @return Valid for Jexl JSON string.
     */
    _wrapJsonValue(value: string, isJson: boolean): string;
    /**
     * Checks whether passed value is a valid variable name.
     * @param name Variable name
     * @return true if the passed name can be used as variable value.
     */
    isValidName(name: string): boolean;
}
//# sourceMappingURL=VariablesProcessor.d.ts.map