import { ShowToast, ToastConfig } from '../model';
import { ErrorMonitor, ModalLayoutProps, PartialLodash, Translate } from '../services';
import { TypedEmitter } from '../util';
export type EventuallyUpdated = 'submit' | number | Promise<unknown>;
export interface ExecuteParams<A, R> {
    showUndoToast?: boolean;
    showUndoSuccessToast?: boolean;
    submit: (items: A[]) => Promise<R> | undefined;
    eventuallyUpdated?: EventuallyUpdated;
    onEventuallyUpdated?: () => unknown;
    errorToast?: (err: unknown, params: {
        retry: () => void;
    }) => ToastConfig | string;
    onTryAgain?: () => void;
    onError?: (err: unknown) => void;
    onUndo?: () => void;
    successToast?: ToastConfig | string;
    onRollback: () => void;
}
interface ExecutionBaseParams<A, R> {
    successToastState: SuccessToastState;
    submit: (actions: A[]) => Promise<R> | undefined;
    eventuallyUpdated?: EventuallyUpdated;
    onEventuallyUpdated?: () => unknown;
    errorToast?: (err: unknown, params: {
        retry: () => void;
    }) => ToastConfig | string;
    onTryAgain?: () => void;
    onError?: (err: unknown) => void;
    successToast?: ToastConfig | string;
    onRollback: () => void;
}
interface ExecutionParams<A, R> extends ExecutionBaseParams<A, R> {
    actions: A[];
}
interface ScheduleExecutionParams<A, R> extends ExecutionBaseParams<A, R> {
}
interface SuccessToastState {
    undoToast?: UndoToastState;
}
interface UndoToastState {
    timeoutPromises: Promise<{
        status?: 'undone';
    } | undefined>[];
    removeNavigationListener: () => void;
}
export interface CollectionOptimisticExecutorParams {
    readonly showToast: ShowToast;
    readonly translate: Translate;
    readonly errorMonitor: ErrorMonitor;
    readonly batchWait: number;
    readonly lodash: PartialLodash;
    readonly container: {
        events: TypedEmitter<{
            navigation: () => ModalLayoutProps | null | undefined;
        }>;
    };
}
export declare class CollectionOptimisticExecutor<A> {
    readonly showToast: ShowToast;
    readonly translate: Translate;
    readonly errorMonitor: ErrorMonitor;
    readonly lodash: PartialLodash;
    readonly container: {
        events: TypedEmitter<{
            navigation: () => ModalLayoutProps | null | undefined;
        }>;
    };
    removeToast: (() => void) | null;
    _actions: A[];
    scheduleExecution: <R>(params: ScheduleExecutionParams<A, R>) => unknown;
    constructor(params: CollectionOptimisticExecutorParams);
    removeAndShowToast(toastConfig: ToastConfig): void;
    rollback(actions: A[], onRollback: () => void): void;
    getSuccessToast(actions: A[], { onRollback, successToast, showUndoToast, showUndoSuccessToast, onUndo, }: {
        successToast?: ToastConfig | string;
        showUndoToast?: boolean;
        showUndoSuccessToast?: boolean;
        onRollback: () => unknown;
        onUndo?: () => unknown;
    }): SuccessToastState;
    _execute<R>(params: ExecutionParams<A, R>): Promise<{
        status?: "undone" | undefined;
    } | {
        result: Awaited<R> | undefined;
        status: string;
        err?: undefined;
    } | {
        status: string;
        err: unknown;
        result?: undefined;
    }>;
    executePending<R>(params: ScheduleExecutionParams<A, R>): Promise<{
        status?: "undone" | undefined;
    } | {
        result: Awaited<R> | undefined;
        status: string;
        err?: undefined;
    } | {
        status: string;
        err: unknown;
        result?: undefined;
    }>;
    execute<R>(actions: A[], params: ExecuteParams<A, R>): void;
}
export {};
//# sourceMappingURL=CollectionOptimisticExecutor.d.ts.map