import { EventEmitter } from 'eventemitter3';
import { App, MachineEvents, MiddlewareFunction, Reader, Recorder, Snapshot, WrappedType, Writer } from './types.js';
declare const _snapshot: unique symbol;
export interface MachineOptions {
    emitAppEvents: boolean;
}
/**
 * The core engine for running applications that interface with blockchain-driven architectures.
 * Provides mechanisms for reading from and writing to the blockchain, as well as invoking app-specific methods.
 *
 * @category Machine
 */
export declare class Machine<T extends App, R extends Reader, W extends Writer> extends EventEmitter {
    private instance;
    private reader;
    private writer;
    private recorder?;
    private options;
    private [_snapshot];
    private queue;
    /**
     * @param appClass - The class that represents the application's logic and state.
     * @param driver - The reader driver to read blockchain events.
     * @param writer - The writer to persist data to the blockchain.
     */
    constructor(appClass: {
        new (): T;
    }, reader: R, writer: W, recorder?: Recorder, options?: MachineOptions);
    on(event: MachineEvents<T>, listener: (...args: any[]) => void): this;
    on(event: string | symbol, listener: (...args: any[]) => void): this;
    /**
     * Instructs the reader to begin dispatching events.
     * Calls the reader's start function with the latest action id if present
     *
     * @param snapshot - Resume from a snapshot. Informs the reader of the latest snapshot so that the reader can skip any actions prior to this.
     */
    start(): void;
    /**
     * Instructs the reader to stop dispatching actions.
     */
    stop(): void;
    /**
     * Instructs the reader to fetch the latest events.
     * This is different from start(), which opens a realtime websocket that drives your App continuously.
     * Do not mix the usage of start() and fetch()
     */
    fetch(): Promise<void>;
    /**
     * Creates a snapshot.
     * This function will create a snapshot after an action has been fully completed.
     */
    createSnapshot(): Promise<Snapshot>;
    /**
     * Loads a snapshot into the state of the App instance.
     * After calling this function, getInstance().state will equal that of the loaded snapshot
     * @param id - The Action.id of the snapshot to load
     */
    loadSnapshot(id?: string): Promise<void>;
    /**
     * Gets a proxied version of the app instance where methods are wrapped
     * to automatically write actions to the action storage.
     *
     * Access to instance.state is readonly via a cloned copy
     *
     * @returns The wrapped application instance.
     */
    getInstance(): WrappedType<T>;
    /**
     * Gets a proxied version of the app instance where methods are wrapped
     * to automatically write events to the blockchain when invoked.
     *
     * @returns The wrapped application instance.
     */
    useMiddleware(methodName: keyof T, middlewareFn: MiddlewareFunction): void;
    /**
     * Dispatches an action to the appropriate method on the app instance.
     * Passed to a reader via the Reader.initialize function.
     * Called by a reader to dispatch actions.
     *
     * @param action - The action data.
     * @param additionalContext - Additional context data that will be accessible from ctx.reader inside methods.
     */
    private dispatchAction;
}
export {};
