import { type ContentEntrySnapshot, type ContentTypeSchema, type ToolbarState } from "@riverbankcms/content-model";
import type { EditorBlockId } from "@riverbankcms/core";
import type { BlockItem } from "@riverbankcms/editor-blocks";
import { type ReactNode } from "react";
import { type PublishOptions } from "../hooks/useEntryActions";
import { type ApiClient } from "../services";
import type { DraftWorkflowStatus } from "../types";
import { type EditorUiState } from "../ui/editorUiStore";
export type EntryControllerBlocksSlice = {
    list: BlockItem[];
    status: "idle" | "loading" | "error";
    actions: {
        setList: (next: BlockItem[]) => void;
    };
};
export type EntryControllerUiSlice = EditorUiState;
export type EntryControllerAutosaveState = {
    status: DraftWorkflowStatus;
    hasFailedSaves: boolean;
};
export type EntryDraftBlockPatch = {
    blockId: EditorBlockId;
    path?: string | null;
    value: unknown;
};
export type EntryDraftCompositePatch = {
    metadata?: Record<string, unknown>;
    content?: Record<string, unknown> | null;
    blocks?: EntryDraftBlockPatch[];
};
export type EntryDraftsActions = {
    setMetadata: (partial: Record<string, unknown>) => void;
    setBlockValue: (blockId: EditorBlockId, path: string | null | undefined, value: unknown) => void;
    setContent: (next: Record<string, unknown> | null) => void;
    setContentValue: (path: string, value: unknown) => void;
    applyCompositePatch: (patch: EntryDraftCompositePatch | null | undefined) => void;
};
export type EntryDraftsSlice = {
    actions: EntryDraftsActions;
};
export type EntryRecoveryConflictState = Readonly<{
    affectedBlockIds: readonly EditorBlockId[];
    count: number;
    reviewRequestId: number | null;
    reviewAffectedBlocks: () => void;
    discardRecoveredChanges: () => void;
}>;
/** Actions returned by useEntryActions */
export type EntryActions = {
    saveDraft: () => Promise<void>;
    publish: (options?: PublishOptions) => Promise<void>;
    discardDraft: () => Promise<void>;
    deleteEntry: () => Promise<void>;
};
export type EntryControllerContextValue = {
    entry: ContentEntrySnapshot;
    baseline: Record<string, unknown>;
    errorMessage: string | null;
    recoveryConflict: EntryRecoveryConflictState | null;
    setErrorMessage: (msg: string | null) => void;
    actions: EntryActions;
    blocks: EntryControllerBlocksSlice;
    drafts: EntryDraftsSlice;
    toolbar: ToolbarState<Record<string, unknown>>;
};
type BaseInternalProps = {
    children: ReactNode;
    apiClient: ApiClient;
    siteId: string;
    entryId: string;
    routeId?: string;
    type: string;
    schema: ContentTypeSchema;
    entityLabel?: string | null;
    initialEntry?: ContentEntrySnapshot | null;
    /** Autosave mode (default: auto). Manual disables background autosave triggers. */
    saveMode?: "auto" | "manual";
    /** Initial content values for content entries - used to hydrate content store */
    initialContent?: Record<string, unknown> | null;
    /** Published content values for content entries - used to detect unpublished changes */
    initialPublishedContent?: Record<string, unknown> | null;
    onEntryUpdated?: (response: unknown) => void;
    historyShortcutsEnabled?: boolean;
};
type PageInternalProps = BaseInternalProps & {
    kind: "page";
    initialStatus?: "draft" | "scheduled" | "published";
} & {
    initialBlocks?: BlockItem[];
};
type ContentInternalProps = BaseInternalProps & {
    kind: "content";
    initialBlocks?: BlockItem[];
};
type EntryControllerProviderProps = PageInternalProps | ContentInternalProps;
/**
 * Entry Controller Provider
 *
 * Main provider for content/page editing functionality. Orchestrates:
 * - Entry state management and syncing
 * - Metadata form with validation and autosave
 * - Block list management and autosave (pages only)
 * - Draft state tracking via EditorUiStore
 * - Publish/discard/delete mutations
 * - Toolbar state (combined metadata + block changes)
 *
 * Consumers should use:
 * - `useEntryEditorController()` - Access entry, form, actions, toolbar
 * - `useEditorUiStore()` - Subscribe to draft/autosave/focus state with selectors
 */
export declare function EntryControllerProvider(props: EntryControllerProviderProps): import("react/jsx-runtime").JSX.Element;
export declare function useEntryEditorController(): EntryControllerContextValue;
export declare function useEntryController(): EntryControllerContextValue;
/**
 * Hook to access autosave status from the uiStore.
 *
 * @deprecated Use useEditorUiStore with selectors instead for better performance:
 * ```tsx
 * const metadataStatus = useEditorUiStore(state => state.autosave.metadata.status)
 * const blocksStatus = useEditorUiStore(state => state.autosave.blocks.status)
 * ```
 *
 * This hook exists for backward compatibility and subscribes to the entire
 * autosave state, causing re-renders when any autosave status changes.
 */
export declare function useAutosave(): {
    autosave: import("../ui/editorUiStore").AutosaveStatus;
    blockAutosave: import("../ui/editorUiStore").AutosaveStatus;
};
/**
 * @deprecated Use useEditorUiStore hook directly from '../ui/editorUiStore'
 * This provides granular selector support for better performance.
 *
 * Example:
 * ```tsx
 * // Old (re-renders on any state change):
 * const uiStore = useEntryUiStore()
 *
 * // New (only re-renders when metadata status changes):
 * const metadataStatus = useEditorUiStore(state => state.metadata.getSnapshot().syncState.kind)
 * ```
 */
export declare function useEntryUiStore(): import("zustand").StoreApi<EditorUiState>;
export {};
