import * as pino from 'pino';
import { t as AnyActorDefinition, f as ActorDefinition, c as EventSchemaConfig, Q as QueueSchemaConfig, ad as RunContext, b9 as QueueFilterName, ba as QueueNextOptions, bb as QueueResultMessageForName, bc as InferSchemaMap, a5 as Registry, C as Client, bd as InferDatabaseClient, be as InferEventArgs } from './config-BFqid9Gr.js';
import { WorkflowContextInterface, LoopResult, LoopConfig, BranchConfig, BranchOutput, EntryKindType } from '@rivetkit/workflow-engine';
import { A as AnyDatabaseProvider } from './config-BiNoIHRs.js';

type WorkflowActorQueueNextOptions<TName extends string, TCompletable extends boolean> = Omit<QueueNextOptions<TName, TCompletable>, "signal" | "count">;
type WorkflowActorQueueNextOptionsFallback<TCompletable extends boolean> = Omit<QueueNextOptions<string, TCompletable>, "signal" | "count">;
type WorkflowActorQueueNextBatchOptions<TName extends string, TCompletable extends boolean> = Omit<QueueNextOptions<TName, TCompletable>, "signal">;
type WorkflowActorQueueNextBatchOptionsFallback<TCompletable extends boolean> = Omit<QueueNextOptions<string, TCompletable>, "signal">;
type ActorWorkflowLoopConfig<S, T, TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = Omit<LoopConfig<S, T>, "run"> & {
    run: (ctx: ActorWorkflowContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, state: S) => Promise<LoopResult<S, T> | (S extends undefined ? void : never)>;
};
type ActorWorkflowBranchConfig<TOutput, TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
    run: (ctx: ActorWorkflowContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => Promise<TOutput>;
};
declare class ActorWorkflowContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> implements WorkflowContextInterface {
    #private;
    constructor(inner: WorkflowContextInterface, runCtx: RunContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>);
    get workflowId(): string;
    get abortSignal(): AbortSignal;
    get queue(): {
        next: {
            <const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(name: string, opts?: WorkflowActorQueueNextOptions<TName, TCompletable>): Promise<QueueResultMessageForName<TQueues, TName, TCompletable>>;
            <const TCompletable extends boolean = false>(name: string, opts?: WorkflowActorQueueNextOptionsFallback<TCompletable>): Promise<QueueResultMessageForName<TQueues, QueueFilterName<TQueues>, TCompletable>>;
        };
        nextBatch: {
            <const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(name: string, opts?: WorkflowActorQueueNextBatchOptions<TName, TCompletable>): Promise<Array<QueueResultMessageForName<TQueues, TName, TCompletable>>>;
            <const TCompletable extends boolean = false>(name: string, opts?: WorkflowActorQueueNextBatchOptionsFallback<TCompletable>): Promise<Array<QueueResultMessageForName<TQueues, QueueFilterName<TQueues>, TCompletable>>>;
        };
        send: {
            <K extends keyof TQueues & string>(name: K, body: InferSchemaMap<TQueues>[K]): Promise<void>;
            (name: keyof TQueues extends never ? string : never, body: unknown): Promise<void>;
        };
    };
    step<T>(nameOrConfig: string | Parameters<WorkflowContextInterface["step"]>[0], run?: () => Promise<T>): Promise<T>;
    loop<T>(name: string, run: (ctx: ActorWorkflowContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => Promise<LoopResult<undefined, T> | void>): Promise<T>;
    loop<T>(name: string, run: (ctx: WorkflowContextInterface) => Promise<LoopResult<undefined, T> | void>): Promise<T>;
    loop<S, T>(config: ActorWorkflowLoopConfig<S, T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>): Promise<T>;
    loop<S, T>(config: LoopConfig<S, T>): Promise<T>;
    sleep(name: string, durationMs: number): Promise<void>;
    sleepUntil(name: string, timestampMs: number): Promise<void>;
    rollbackCheckpoint(name: string): Promise<void>;
    join<T extends Record<string, ActorWorkflowBranchConfig<unknown, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>>>(name: string, branches: T): Promise<{
        [K in keyof T]: Awaited<ReturnType<T[K]["run"]>>;
    }>;
    join<T extends Record<string, BranchConfig<unknown>>>(name: string, branches: T): Promise<{
        [K in keyof T]: BranchOutput<T[K]>;
    }>;
    race<T>(name: string, branches: Array<{
        name: string;
        run: (ctx: ActorWorkflowContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => Promise<T>;
    }>): Promise<{
        winner: string;
        value: T;
    }>;
    removed(name: string, originalType: EntryKindType): Promise<void>;
    isEvicted(): boolean;
    get state(): TState extends never ? never : TState;
    get vars(): TVars extends never ? never : TVars;
    client<R extends Registry<any>>(): Client<R>;
    get db(): TDatabase extends never ? never : InferDatabaseClient<TDatabase>;
    get log(): pino.Logger;
    keepAwake<T>(promise: Promise<T>): Promise<T>;
    waitUntil(promise: Promise<void>): void;
    get actorId(): string;
    broadcast<K extends keyof TEvents & string>(name: K, ...args: InferEventArgs<InferSchemaMap<TEvents>[K]>): void;
    broadcast(name: keyof TEvents extends never ? string : never, ...args: Array<unknown>): void;
    consumeGuardViolation(): boolean;
}
type WorkflowContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? ActorWorkflowContext<S, CP, CS, V, I, DB, E, Q> : never;
type WorkflowLoopContextOf<AD extends AnyActorDefinition> = WorkflowContextOf<AD>;
type WorkflowBranchContextOf<AD extends AnyActorDefinition> = WorkflowContextOf<AD>;
type WorkflowStepContextOf<AD extends AnyActorDefinition> = WorkflowContextOf<AD>;

export { ActorWorkflowContext as A, type WorkflowBranchContextOf as W, type WorkflowContextOf as a, type WorkflowLoopContextOf as b, type WorkflowStepContextOf as c };
