import type { BreakStatement, ContinueStatement, ParseResult, ThrowStatement, TryStatement } from "../parse.js";
import { type ErrorSourceSpan } from "../error/shape.js";
import { type Budget } from "./budget.js";
import type { Scope } from "./scope.js";
import { type SandboxObject, type SandboxValue } from "./values.js";
declare const capturedExceptionBrand: unique symbol;
declare const sandboxErrorNames: readonly ["Error", "TypeError", "RangeError", "ReferenceError", "SyntaxError", "AbortError", "AggregateError", "HarnessFailure"];
export type SandboxErrorName = (typeof sandboxErrorNames)[number];
export type CompletionKind = "normal" | "return" | "throw" | "break" | "continue";
export type CompletionResult = {
    kind: CompletionKind;
    hasValue: boolean;
    span?: ErrorSourceSpan;
    stackFrames?: readonly string[];
    value: SandboxValue;
    label?: string;
    node?: BreakStatement | ContinueStatement;
};
export type EvaluationResult<TError> = CompletionResult | {
    kind: "error";
    error: TError;
};
type CapturedException = {
    readonly reason: unknown;
    readonly stackFrames: readonly string[];
    readonly [capturedExceptionBrand]: true;
};
type ExceptionContext = {
    budget: Budget;
    callStack: readonly string[];
    scope: Scope;
};
type EvaluateExceptionNode<TContext, TError> = (node: ParseResult, context: TContext) => Promise<EvaluationResult<TError>>;
export declare function evaluateThrowStatement<TContext extends ExceptionContext, TError>(node: ThrowStatement, context: TContext, evaluateNode: EvaluateExceptionNode<TContext, TError>): Promise<EvaluationResult<TError>>;
export declare function evaluateTryStatement<TContext extends ExceptionContext, TError>(node: TryStatement, context: TContext, evaluateNode: EvaluateExceptionNode<TContext, TError>): Promise<EvaluationResult<TError>>;
export declare function createCapturedException(reason: unknown, stackFrames: readonly string[]): CapturedException;
export declare function isCapturedException(value: unknown): value is CapturedException;
export declare function coerceThrownValue(reason: unknown, budget: Budget, stackFrames: readonly string[], span?: ErrorSourceSpan): SandboxValue;
export declare function surfaceThrownValue(reason: unknown, budget: Budget, stackFrames?: readonly string[], span?: ErrorSourceSpan): SandboxObject;
export declare function createSubsetErrorValue(name: string, message: SandboxValue, stackFrames: readonly string[], budget: Budget, options?: {
    cause?: unknown;
    chargeBudget?: boolean;
    span?: ErrorSourceSpan;
}): SandboxObject;
export declare function isSandboxErrorConstructorInstance(value: SandboxValue, name: SandboxErrorName): boolean;
export {};
