import { FunctionlessNode } from "../node";
import { States, CommonFields, Task, State, Pass, Condition } from "./states";
import { ASL } from "./synth";
/**
 * ASL Graph is an intermediate API used to represent a nested and dynamic ASL State Machine Graph.
 *
 * Unlike ASL, the ASL graph supports nested nodes, can associate nodes to {@link FunctionlessNode}s, and contains a representation of the output of a state.
 *
 * ASL Graph is completely stateless.
 */
export declare namespace ASLGraph {
    /**
     * Used by integrations as a placeholder for the "Next" property of a task.
     *
     * When task.Next is ASLGraph.DeferNext, Functionless will replace the Next with the appropriate value.
     * It may also add End or ResultPath based on the scenario.
     */
    const DeferNext: string;
    function isSubState(state: ASLGraph.NodeState | ASLGraph.SubState | ASLGraph.NodeResults): state is ASLGraph.SubState;
    /**
     * A Sub-State is a collection of possible return values.
     * A start state is the first state in the result. It will take on the name of the parent statement node.
     * States are zero to many named states or sub-stages that will take on the name of the parent statement node.
     */
    interface SubState {
        startState: string;
        node?: FunctionlessNode;
        states: {
            [stateName: string]: ASLGraph.NodeState | ASLGraph.SubState;
        };
    }
    const isStateOrSubState: (a: any) => a is State | SubState;
    /**
     * An {@link ASLGraph} interface which adds an optional {@link FunctionlessNode} to a state.
     *
     * The node is used to name the state.
     */
    type NodeState<S extends State = State> = S & {
        node?: FunctionlessNode;
    };
    /**
     * The possible outputs of evaluating an {@link Expr}.
     *
     * State - A state with an {@link ASLGraph.Output} and optional {@link FunctionlessNode}
     * SubStates - A sub-state graph with an {@link ASLGraph.Output} and optional {@link FunctionlessNode}
     * JsonPath - a JSON Path Variable Reference, the consumer should use where json path is valid, ignore, or fail.
     * Value - a Value of type number, string, boolean, object, or null. Consumers should use where values can be used or turn into JsonPath using a {@link Pass} state.
     */
    type NodeResults = ASLGraph.OutputState | ASLGraph.OutputSubState | ASLGraph.Output;
    /**
     * A compound state is a state node that may contain a simple Constant or Variable output instead of
     * built states or sub-states.
     *
     * Compound states are designed to be incorporated into existing states or turned into
     * states before they are returned up.
     *
     * Compound states cannot be nested in sub-states.
     */
    interface OutputSubState extends ASLGraph.SubState {
        output: ASLGraph.Output;
    }
    /**
     * An {@link ASLGraph} interface which adds an {@link ASLGraph.Output} a state.
     *
     * The node is used to name the state.
     */
    type OutputState = NodeState & {
        output: ASLGraph.Output;
    };
    function isOutputStateOrSubState(state: any): state is ASLGraph.OutputSubState | ASLGraph.OutputState;
    /**
     * A literal value of type string, number, boolean, object, or null.
     *
     * If this is an Object, the object may contain nested JsonPaths as denoted by `containsJsonPath`.
     */
    interface LiteralValue {
        /**
         * Whether there is json path in the constant.
         *
         * Helps determine where this constant can go for validation and
         * when false use Result in a Pass State instead of Parameters
         */
        containsJsonPath: boolean;
        value: string | number | null | boolean | Record<string, any> | any[];
    }
    /**
     * A json path based state values reference.
     */
    interface JsonPath {
        jsonPath: string;
    }
    interface ConditionOutput {
        condition: Condition;
    }
    type Output = ASLGraph.LiteralValue | ASLGraph.JsonPath | ASLGraph.ConditionOutput;
    function isLiteralValue(state: any): state is ASLGraph.LiteralValue;
    function isJsonPath(state: any): state is ASLGraph.JsonPath;
    function isConditionOutput(state: any): state is ASLGraph.ConditionOutput;
    const isAslGraphOutput: (a: any) => a is LiteralValue | JsonPath | ConditionOutput;
    /**
     * Wires together an array of {@link State} or {@link ASLGraph.SubState} nodes in the order given.
     * Any state which is missing Next/End will be given a Next value of the next state with the final state
     * either being left as is.
     */
    function joinSubStates(node?: FunctionlessNode, ...subStates: (ASLGraph.NodeState | ASLGraph.SubState | ASLGraph.NodeResults | undefined)[]): ASLGraph.SubState | ASLGraph.NodeState | undefined;
    /**
     * Used to lazily provide the next step to a provided state or nested set of states.
     *
     * Recursively traverse sub-states down to regular states, replacing any
     * nodes with `Next: ASLGraph.DeferNext` or `Next: undefined` with the given props.
     *
     * Note: States without `Next` are ignored and {@link Map} states replace Default and `Choices[].Next` instead.
     */
    function updateDeferredNextStates<T extends State | ASLGraph.SubState>(props: {
        End: true;
    } | {
        Next: string;
    }, state: T): T;
    /**
     * Helper which can update a Asl state to a new output.
     * Sometimes the output can be updated in places like when accessing a constant or variable.
     *
     * If the state is a compound state, only the output needs to change, not the states it contains.
     *
     * ```ts
     * const obj = { a: { b: 1 } };
     * return obj.a.b;
     * ```
     *
     * output of obj.a
     * { startState: ..., states: {...}, output: { jsonPath: "$.obj.a" } }
     *
     * output of obj.a.b
     * { startState: ..., states: {...}, output: { jsonPath: "$.obj.a.b" } }
     *
     * Only the jsonPath has been mutated because no one used use intermediate output.
     */
    function updateAslStateOutput(state: ASLGraph.NodeResults, newOutput: ASLGraph.Output): LiteralValue | JsonPath | ConditionOutput | {
        output: Output;
        Type: "Choice";
        Choices: import("./states").Branch[];
        Default?: string | undefined;
        Comment?: string | undefined;
        InputPath?: string | undefined;
        OutputPath?: string | undefined;
        node?: FunctionlessNode | undefined;
    } | {
        output: Output;
        Type: "Fail";
        Error?: string | undefined;
        Cause?: string | undefined;
        Comment?: string | undefined;
        node?: FunctionlessNode | undefined;
    } | {
        output: Output;
        Comment?: string | undefined;
        InputPath?: string | undefined;
        OutputPath?: string | undefined;
        Next: string;
        End?: undefined;
        Parameters?: import("./states").Parameters | undefined;
        ResultSelector?: import("./states").Parameters | undefined;
        ResultPath?: string | null | undefined;
        Retry?: import("./states").Retry[] | undefined;
        Catch?: import("./states").Catch[] | undefined;
        Type: "Map";
        Iterator: import("./states").StateMachine<States>;
        ItemsPath?: string | undefined;
        MaxConcurrency?: number | undefined;
        node?: FunctionlessNode | undefined;
    } | {
        output: Output;
        Comment?: string | undefined;
        InputPath?: string | undefined;
        OutputPath?: string | undefined;
        End: true;
        Next?: undefined;
        Parameters?: import("./states").Parameters | undefined;
        ResultSelector?: import("./states").Parameters | undefined;
        ResultPath?: string | null | undefined;
        Retry?: import("./states").Retry[] | undefined;
        Catch?: import("./states").Catch[] | undefined;
        Type: "Map";
        Iterator: import("./states").StateMachine<States>;
        ItemsPath?: string | undefined;
        MaxConcurrency?: number | undefined;
        node?: FunctionlessNode | undefined;
    } | {
        output: Output;
        Comment?: string | undefined;
        InputPath?: string | undefined;
        OutputPath?: string | undefined;
        Next: string;
        End?: undefined;
        Parameters?: import("./states").Parameters | undefined;
        ResultSelector?: import("./states").Parameters | undefined;
        ResultPath?: string | null | undefined;
        Retry?: import("./states").Retry[] | undefined;
        Catch?: import("./states").Catch[] | undefined;
        Type: "Parallel";
        Branches: import("./states").StateMachine<States>[];
        node?: FunctionlessNode | undefined;
    } | {
        output: Output;
        Comment?: string | undefined;
        InputPath?: string | undefined;
        OutputPath?: string | undefined;
        End: true;
        Next?: undefined;
        Parameters?: import("./states").Parameters | undefined;
        ResultSelector?: import("./states").Parameters | undefined;
        ResultPath?: string | null | undefined;
        Retry?: import("./states").Retry[] | undefined;
        Catch?: import("./states").Catch[] | undefined;
        Type: "Parallel";
        Branches: import("./states").StateMachine<States>[];
        node?: FunctionlessNode | undefined;
    } | {
        output: Output;
        Comment?: string | undefined;
        InputPath?: string | undefined;
        OutputPath?: string | undefined;
        Next: string;
        End?: undefined;
        Type: "Pass";
        Result?: any;
        ResultPath?: string | null | undefined;
        Parameters?: import("./states").Parameters | undefined;
        node?: FunctionlessNode | undefined;
    } | {
        output: Output;
        Comment?: string | undefined;
        InputPath?: string | undefined;
        OutputPath?: string | undefined;
        End: true;
        Next?: undefined;
        Type: "Pass";
        Result?: any;
        ResultPath?: string | null | undefined;
        Parameters?: import("./states").Parameters | undefined;
        node?: FunctionlessNode | undefined;
    } | {
        output: Output;
        Type: "Succeed";
        Comment?: string | undefined;
        InputPath?: string | undefined;
        OutputPath?: string | undefined;
        node?: FunctionlessNode | undefined;
    } | {
        output: Output;
        Comment?: string | undefined;
        InputPath?: string | undefined;
        OutputPath?: string | undefined;
        Next: string;
        End?: undefined;
        Parameters?: import("./states").Parameters | undefined;
        ResultSelector?: import("./states").Parameters | undefined;
        ResultPath?: string | null | undefined;
        Retry?: import("./states").Retry[] | undefined;
        Catch?: import("./states").Catch[] | undefined;
        Type: "Task";
        Resource: string;
        node?: FunctionlessNode | undefined;
    } | {
        output: Output;
        Comment?: string | undefined;
        InputPath?: string | undefined;
        OutputPath?: string | undefined;
        End: true;
        Next?: undefined;
        Parameters?: import("./states").Parameters | undefined;
        ResultSelector?: import("./states").Parameters | undefined;
        ResultPath?: string | null | undefined;
        Retry?: import("./states").Retry[] | undefined;
        Catch?: import("./states").Catch[] | undefined;
        Type: "Task";
        Resource: string;
        node?: FunctionlessNode | undefined;
    } | {
        output: Output;
        Comment?: string | undefined;
        InputPath?: string | undefined;
        OutputPath?: string | undefined;
        Next: string;
        End?: undefined;
        Type: "Wait";
        Seconds?: number | undefined;
        Timestamp?: string | undefined;
        SecondsPath?: string | undefined;
        TimestampPath?: string | undefined;
        node?: FunctionlessNode | undefined;
    } | {
        output: Output;
        Comment?: string | undefined;
        InputPath?: string | undefined;
        OutputPath?: string | undefined;
        End: true;
        Next?: undefined;
        Type: "Wait";
        Seconds?: number | undefined;
        Timestamp?: string | undefined;
        SecondsPath?: string | undefined;
        TimestampPath?: string | undefined;
        node?: FunctionlessNode | undefined;
    } | {
        output: Output;
        startState: string;
        node?: FunctionlessNode | undefined;
        states: {
            [stateName: string]: NodeState<State> | SubState;
        };
    };
    /**
     * Transforms an {@link ASLGraph.AslState} or {@link ASLGraph.SubState} into a ASL {@link States} collection of flat states.
     *
     * Uses the parent name as a starting point. All state nodes of sub-states will be given the name of their parent.
     *
     * Sub-States with local or relative state references will be rewritten to the updated parent state name.
     *
     * Removes unreachable states from the graph. Unreachable states will cause step functions to fail.
     *
     * sub state
     * ```ts
     * {
     *    startState: "default",
     *    states: {
     *      default: { Next: 'b' },
     *      b: { Next: 'c' },
     *      c: { Next: 'externalState' }
     *    }
     * }
     * ```
     *
     * Parent state name: parentState
     *
     * rewrite
     * ```ts
     * {
     *    parentState: { Next: 'b__parentState' },
     *    b__parentState: { Next: 'c__parentState' },
     *    c__parentState: { Next: 'externalState' }
     * }
     * ```
     *
     * Local State Names
     *
     * In the below example, default, b, and c are all local state names.
     *
     * ```ts
     * {
     *    startState: "default",
     *    states: {
     *      default: { Next: 'b' },
     *      b: { Next: 'c' },
     *      c: { Next: 'externalState' }
     *    }
     * }
     * ```
     *
     * Relative state names
     *
     * Path structures can be used to denote relative paths. ex: `../stateName`.
     *
     * ```ts
     * {
     *    startState: "default",
     *    states: {
     *      default: { Next: 'b' },
     *      b: {
     *         startState: "start",
     *         states: {
     *            start: {
     *               Next: "../c"
     *            }
     *         }
     *      },
     *      c: { Next: 'externalState' }
     *    }
     * }
     * ```
     *
     * In the above example, b/start's next state is c in it's parent state.
     *
     * Currently referencing child states (ex: `./b/start`) is not supported.
     *
     * All state names not found in local or parent sub-states will be assumed to be top level state names and will not be re-written.
     */
    function toStates(startState: string, states: ASLGraph.NodeState | ASLGraph.SubState | ASLGraph.OutputState | ASLGraph.OutputSubState, getStateNames: (parentName: string, states: ASLGraph.SubState) => Record<string, string>): States;
    /**
     * Normalized an ASL state to just the output (constant or variable).
     */
    function getAslStateOutput(state: ASLGraph.NodeResults): ASLGraph.Output;
    /**
     * Applies an {@link ASLGraph.Output} to a partial {@link Pass}.
     *
     * {@link ASLGraph.ConditionOutput} must be first turned into a {@link ASLGraph.JsonPath}.
     */
    function passWithInput(pass: Omit<NodeState<Pass>, "Parameters" | "InputPath" | "Result"> & CommonFields, value: Exclude<ASLGraph.Output, ASLGraph.ConditionOutput>): Pass;
    /**
     * Applies an {@link ASLGraph.Output} to a partial {@link Task}
     *
     * {@link ASLGraph.ConditionOutput} must be first turned into a {@link ASLGraph.JsonPath}.
     */
    function taskWithInput(task: Omit<Task, "Parameters" | "InputPath"> & CommonFields, value: Exclude<ASLGraph.Output, ASLGraph.ConditionOutput>): Task;
    /**
     * Compare any two {@link ASLGraph.Output} values.
     */
    function compareOutputs(leftOutput: ASLGraph.Output, rightOutput: ASLGraph.Output, operator: ASL.ValueComparisonOperators): Condition;
    /**
     * Compare a computed variable or unresolved conditional (left) to any other value (right).
     *
     * Comparing two literals is done with {@link ASLGraph.compareOutputs}.
     *
     * TODO: Implement abstract equality algorithm for `==` and `!=`
     *       https://github.com/functionless/functionless/issues/445
     *       Current `==` and `===` are treated the same.
     */
    function compare(left: ASLGraph.JsonPath | ASLGraph.ConditionOutput, right: ASLGraph.Output, operator: ASL.ValueComparisonOperators | "!=" | "!=="): Condition;
    /**
     * Provide comparison logic when right may be a string for any left value.
     *
     * if right is string literal or json path
     *   typeof left === "string" && left === right
     * else
     *    undefined
     */
    function stringCompare(left: ASLGraph.JsonPath, right: ASLGraph.Output, operator: ASL.ValueComparisonOperators): Condition | undefined;
    /**
     * Provide comparison logic when right may be a number for any left value.
     *
     * if right is number literal or json path
     *   typeof left === "number" && left === right
     * else
     *    undefined
     */
    function numberCompare(left: ASLGraph.JsonPath, right: ASLGraph.Output, operator: ASL.ValueComparisonOperators): Condition | undefined;
    /**
     * Provide comparison logic when right may be a boolean for any left value.
     *
     * If ==/===
     *   if left is a conditional
     *      if right is a conditional
     *         (!left && !right) || (left && right)
     *      if right is boolean literal
     *         right ? left : !left
     *      if right is jsonPath
     *         (!left && right === false) || (left && right === true)
     *   if right is conditional
     *      (!right && left === false) || (right && left === true)
     *   if right is boolean literal or json path
     *      typeof left === "boolean" && left === right
     * else
     *   undefined
     */
    function booleanCompare(left: ASLGraph.JsonPath | ASLGraph.ConditionOutput, right: ASLGraph.Output, operator: ASL.ValueComparisonOperators): Condition | undefined;
    /**
     * Provide comparison logic when right may be null for any left value.
     *
     * If ==/===
     *   if right is a variable - check for isNull(left) && isNull(right)
     *   if right is null - check for isNull(left)
     *   else
     *     undefined
     * else
     *   undefined
     */
    function nullCompare(left: ASLGraph.JsonPath, right: ASLGraph.Output, operator: ASL.ValueComparisonOperators): Condition | undefined;
    /**
     * Provide comparison logic when right may be undefined for any left value.
     *
     * If ==/===
     *   if right is a variable - check for isNotPresent(left) && isNotPresent(right)
     *   if right is undefined - check for isNotPresent(left)
     *   else
     *     undefined
     * else
     *   undefined
     */
    function undefinedCompare(left: ASLGraph.JsonPath, right: ASLGraph.Output, operator: ASL.ValueComparisonOperators): Condition | undefined;
    /**
     * Returns a object with the key formatted based on the contents of the value.
     * in ASL, object keys that reference json path values must have a suffix of ".$"
     * { "input.$": "$.value" }
     */
    function jsonAssignment(key: string, output: Exclude<ASLGraph.Output, ASLGraph.ConditionOutput>): Record<string, any>;
    function isTruthyOutput(v: ASLGraph.Output): Condition;
    function elementIn(element: string | number, targetJsonPath: ASLGraph.JsonPath): Condition;
    /**
     * @param element - when true (or field is a number) the output json path will prefer to use the square bracket format.
     *                  `$.obj[field]`. When false will prefer the dot format `$.obj.field`.
     */
    function accessConstant(value: ASLGraph.Output, field: string | number, element: boolean): ASLGraph.JsonPath | ASLGraph.LiteralValue;
}
export declare const deploymentOnlyModule = true;
//# sourceMappingURL=asl-graph.d.ts.map