import type { APIEndpoints } from '@riverbankcms/api';
import type { PreviewCustomizeAction } from '../blocks/previewCustomizeActions';
import { type PreviewCustomizeHistoryEntry, type PreviewCustomizeHistoryState } from './previewCustomizeHistory';
type ApiPageDesignEditorStateResponse = NonNullable<APIEndpoints['getPageDesignEditorState']['response']>;
type LoadedPageDesignEditorState = Extract<ApiPageDesignEditorStateResponse, Readonly<{
    kind: 'loaded';
}>>;
type NonLoadedPageDesignEditorState = Exclude<ApiPageDesignEditorStateResponse, Readonly<{
    kind: 'loaded';
}>>;
type ApplyPageDesignEditorActionResponse = NonNullable<APIEndpoints['applyPageDesignEditorAction']['response']>;
export type PreviewPageDesignEditorState = Readonly<{
    kind: 'unsupported';
}> | Readonly<{
    kind: 'loading';
}> | Readonly<{
    kind: 'failed';
    message: string;
}> | ApiPageDesignEditorStateResponse;
export type PreviewPageDesignEditorApplyOutcome = Readonly<{
    kind: 'saved';
    response: ApplyPageDesignEditorActionResponse;
}> | Readonly<{
    kind: 'skipped';
    reason: PreviewCustomizeSkipReason;
    message: string;
}> | Readonly<{
    kind: 'stale';
    message: string;
}> | Readonly<{
    kind: 'invalid';
    message: string;
}> | Readonly<{
    kind: 'failed';
    message: string;
}>;
export type PreviewCustomizeSkipReason = 'disabled' | 'missing-page' | 'not-loaded' | 'mutation-pending' | 'stale' | 'no-history-entry' | 'cannot-undo' | 'cannot-redo';
export type PreviewCustomizeMutationState = Readonly<{
    kind: 'idle';
}> | Readonly<{
    kind: 'applying';
    action: PreviewCustomizeAction;
    historyEntry: PreviewCustomizeHistoryEntry | null;
}> | Readonly<{
    kind: 'undoing';
    action: PreviewCustomizeAction;
    entry: PreviewCustomizeHistoryEntry;
}> | Readonly<{
    kind: 'redoing';
    action: PreviewCustomizeAction;
    entry: PreviewCustomizeHistoryEntry;
}> | Readonly<{
    kind: 'stale';
    message: string;
}> | Readonly<{
    kind: 'failed';
    message: string;
}>;
export type PreviewCustomizeWorkflowState = Readonly<{
    kind: 'unsupported';
}> | Readonly<{
    kind: 'loading';
}> | Readonly<{
    kind: 'failed';
    message: string;
}> | Readonly<{
    kind: 'ready';
    pageState: NonLoadedPageDesignEditorState;
}> | Readonly<{
    kind: 'loaded';
    pageState: LoadedPageDesignEditorState;
    history: PreviewCustomizeHistoryState;
    mutation: PreviewCustomizeMutationState;
}>;
export type PreviewCustomizeBeginResult = Readonly<{
    kind: 'started';
    state: PreviewCustomizeWorkflowState;
    action: PreviewCustomizeAction;
}> | Readonly<{
    kind: 'skipped';
    reason: PreviewCustomizeSkipReason;
    message: string;
}>;
export declare function unsupportedPreviewCustomizeWorkflowState(): PreviewCustomizeWorkflowState;
export declare function loadingPreviewCustomizeWorkflowState(): PreviewCustomizeWorkflowState;
export declare function failedPreviewCustomizeWorkflowState(message: string): PreviewCustomizeWorkflowState;
export declare function previewCustomizeLoadSucceeded(pageState: ApiPageDesignEditorStateResponse): PreviewCustomizeWorkflowState;
export declare function previewCustomizeWorkflowPageState(workflow: PreviewCustomizeWorkflowState): PreviewPageDesignEditorState;
export declare function beginPreviewCustomizeApply(workflow: PreviewCustomizeWorkflowState, action: PreviewCustomizeAction): PreviewCustomizeBeginResult;
export declare function beginPreviewCustomizeUndo(workflow: PreviewCustomizeWorkflowState): PreviewCustomizeBeginResult;
export declare function beginPreviewCustomizeRedo(workflow: PreviewCustomizeWorkflowState): PreviewCustomizeBeginResult;
export declare function confirmPreviewCustomizeMutation(workflow: PreviewCustomizeWorkflowState, response: ApplyPageDesignEditorActionResponse): PreviewCustomizeWorkflowState;
export declare function rejectPreviewCustomizeMutation(previousWorkflow: PreviewCustomizeWorkflowState, outcome: Exclude<PreviewPageDesignEditorApplyOutcome, {
    kind: 'saved' | 'skipped';
}>): PreviewCustomizeWorkflowState;
export declare function previewCustomizeCanUndo(workflow: PreviewCustomizeWorkflowState): boolean;
export declare function previewCustomizeCanRedo(workflow: PreviewCustomizeWorkflowState): boolean;
export declare function previewCustomizeCanApply(workflow: PreviewCustomizeWorkflowState): boolean;
export declare function previewCustomizeIsMutationPending(workflow: PreviewCustomizeWorkflowState): boolean;
export declare function previewCustomizeIsStale(workflow: PreviewCustomizeWorkflowState): boolean;
export declare function previewCustomizeFailureMessage(workflow: PreviewCustomizeWorkflowState): string | null;
export declare function applyPreviewCustomizeActionToState(state: PreviewPageDesignEditorState, action: PreviewCustomizeAction): PreviewPageDesignEditorState;
export declare function skippedPreviewCustomizeOutcome(reason: PreviewCustomizeSkipReason): Extract<PreviewPageDesignEditorApplyOutcome, {
    kind: 'skipped';
}>;
export {};
