/** Bounded past/future snapshot stacks — a serializable undo/redo record for any state `T`. */ export interface HistoryStacks { /** Prior states, oldest first; the last entry is the step an undo restores. */ readonly past: readonly T[]; /** Undone states awaiting redo, oldest first; the last entry is the step a redo restores. */ readonly future: readonly T[]; } /** The snapshot an undo/redo restores plus the advanced stacks. */ export interface HistoryStep { /** State to apply as the new present. */ snapshot: T; /** Stacks after the step. */ stacks: HistoryStacks; } /** Empty history stacks for state `T`. * @internal */ export declare function emptyHistory(): HistoryStacks; /** True when there is a prior state to undo to. * @internal */ export declare function canUndo(stacks: HistoryStacks): boolean; /** True when there is an undone state to redo. * @internal */ export declare function canRedo(stacks: HistoryStacks): boolean; /** * Record `present` as the newest undo step and clear the redo future (a fresh action forks history). * The oldest past entries beyond `limit` are dropped so the stack stays bounded for save/transport. * @internal */ export declare function recordSnapshot(stacks: HistoryStacks, present: T, limit?: number): HistoryStacks; /** * Step back: pop the newest past snapshot to apply as the new present, and push the given `present` * onto the future for a later redo. Returns `null` when there is nothing to undo. * @internal */ export declare function undoSnapshot(stacks: HistoryStacks, present: T): HistoryStep | null; /** * Step forward: pop the newest future snapshot to apply as the new present, and push the given * `present` back onto the past. Returns `null` when there is nothing to redo. * @internal */ export declare function redoSnapshot(stacks: HistoryStacks, present: T): HistoryStep | null; /** Stateful undo/redo handle over {@link HistoryStacks}, holding the stacks in a closure. */ export interface SnapshotHistory { /** Record `present` as a new undo step and clear the redo future. */ record(present: T): void; /** Undo, returning the restored snapshot or `null` if there is nothing to undo. */ undo(present: T): T | null; /** Redo, returning the restored snapshot or `null` if there is nothing to redo. */ redo(present: T): T | null; /** True when an undo is available. */ canUndo(): boolean; /** True when a redo is available. */ canRedo(): boolean; /** Drop all history. */ clear(): void; /** Current immutable stacks (for serialization). */ stacks(): HistoryStacks; } /** * Stateful undo/redo handle wrapping the pure snapshot functions. Call `record(state)` before each * mutation; `undo`/`redo` return the state to apply. `limit` bounds the past stack. * @internal */ export declare function createSnapshotHistory(limit?: number): SnapshotHistory;