/**
 * This file is part of the NocoBase (R) project.
 * Copyright (c) 2020-2024 NocoBase Co., Ltd.
 * Authors: NocoBase Team.
 *
 * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
 * For more information, please refer to: https://www.nocobase.com/agreement.
 */
import { type MetaTreeNode, type VariableHybridInputConverters } from '@nocobase/flow-engine';
import React from 'react';
/**
 * The flow-engine defaults emit `{{ ctx.$X.Y }}` and only parse the same
 * shape back into a path — but NocoBase server templates (and v1 stored
 * values) use the bare `{{$X.Y}}` form without the `ctx.` prefix. These
 * converters keep the picker's output stable against v1 and let already-
 * stored values round-trip to a labelled pill instead of falling back to a
 * raw `{{…}}` literal.
 */
/**
 * Variable delimiters: opening + closing tokens. Default `['{{', '}}']`
 * matches NocoBase server template convention (Handlebars HTML-escaped
 * output). Pass `['{{{', '}}}']` to switch to Handlebars' raw/unescaped
 * form — required for fields whose content is rendered as HTML (e.g.
 * in-app message body) so the variable expansion bypasses HTML escaping.
 *
 * Restrict to literal-token pairs, since the regex builder escapes them
 * verbatim.
 */
export type VariableDelimiters = readonly [string, string];
/**
 * Factory: returns a `parseValueToPath` bound to the given delimiters.
 * Anchored (`^…$`) — only treats the whole input as a single variable
 * reference, matching the v1 single-line picker behaviour.
 */
export declare function makeParseVariablePath(delimiters?: VariableDelimiters): (value?: string) => string[] | undefined;
/**
 * Factory: returns a `formatPathToValue` bound to the given delimiters.
 * No inner spaces — matches the v1 storage shape exactly so round-trips
 * through the API stay byte-stable.
 */
export declare function makeFormatVariablePath(delimiters?: VariableDelimiters): (meta?: MetaTreeNode) => string | undefined;
/**
 * Factory: returns a global regex matching every occurrence of the
 * variable token within a longer string. Used by `VariableHybridInput`
 * to render embedded variables as pills.
 */
export declare function makeVariableRegExp(delimiters?: VariableDelimiters): RegExp;
export declare const parseVariablePath: (value?: string) => string[] | undefined;
export declare const formatVariablePath: (meta?: MetaTreeNode) => string | undefined;
/**
 * Resolve the meta tree the variable picker should expose. Filters the global
 * meta tree by `namespaces` (top-level property names like `'$env'`,
 * `'$user'`), appends `extraNodes`, and eagerly resolves any lazy `children`
 * thunks so labels render on first paint.
 *
 * Returns `[]` while loading or when no nodes survive the filter, mirroring
 * the existing EnvVariableInput behavior so the picker still opens but offers
 * nothing.
 */
export declare function useFilteredMetaTree(options: {
    namespaces?: string[];
    extraNodes?: MetaTreeNode[];
}): MetaTreeNode[];
export interface VariableInputProps {
    value?: string;
    onChange?: (value: string) => void;
    disabled?: boolean;
    placeholder?: string;
    addonBefore?: React.ReactNode;
    /**
     * Restrict the picker to specific top-level meta tree namespaces (e.g.
     * `['$env', '$user']`). When omitted, every registered top-level property is
     * exposed. Filter happens at the picker level — the underlying regex used
     * for pill rendering still matches any `{{ ... }}` expression so pre-existing
     * out-of-scope values stay legible.
     */
    namespaces?: string[];
    /**
     * Static leaves appended to the picker, after the namespace-filtered nodes.
     * Use for ad-hoc local-only variables (e.g. `$resetLink`) that are not part
     * of the global FlowContext registry.
     */
    extraNodes?: MetaTreeNode[];
    /**
     * Override the converters used by the underlying `VariableHybridInput`.
     * Mostly useful when the caller wants to constrain `formatPathToValue` to a
     * specific namespace (see `EnvVariableInput` for that pattern).
     *
     * Takes precedence over `delimiters` when both are set on the same field
     * (an explicit converter wins over the delimiter-derived one).
     */
    converters?: VariableHybridInputConverters;
    /**
     * Token pair wrapping variable references in the stored string. Defaults
     * to `['{{', '}}']` — the standard NocoBase server-template form,
     * HTML-escaped by Handlebars. Pass `['{{{', '}}}']` for fields rendered
     * as HTML where escaping would corrupt the variable value (e.g. the
     * in-app message body).
     *
     * Ignored when `converters` is also supplied — caller-provided converters
     * win.
     */
    delimiters?: VariableDelimiters;
    className?: string;
    style?: React.CSSProperties;
}
/**
 * Inline (single-line) variable input. Renders the literal text and any
 * `{{ ... }}` references as styled pills via `VariableHybridInput`. Use for
 * fields like form input titles, email subject lines, or any place a single
 * line of mixed literal+variable content is appropriate.
 */
export declare function VariableInput(props: VariableInputProps): React.JSX.Element;
export interface VariableTextAreaProps extends Omit<VariableInputProps, 'converters' | 'addonBefore'> {
    rows?: number;
    maxRows?: number;
}
/**
 * Multi-line variable input. Variables are inserted as raw `{{ ... }}` text at
 * the caret rather than rendered as pills — use for email body templates and
 * other free-form long-form text where literal display of variable expressions
 * is desirable (the server expands them at render time).
 */
export declare function VariableTextArea(props: VariableTextAreaProps): React.JSX.Element;
