import { S as SetNameAction, U as UndoAction, a as RedoAction, P as PruneAction, E as ExtendedState, L as LoadStateAction, A as Action, D as Document$1, c as BaseAction, d as ImmutableStateReducer, R as Reducer, e as Attachment, B as BaseDocument, b as DocumentFile, f as DocumentHeader, F as FileRegistry, g as ImmutableReducer, I as InputDocumentFile, O as Operation, h as applyMixins } from './object-581171b5.js';
import { F as FileInput, c as createZip, g as getLocalFile, a as getRemoteFile, h as hashAttachment, l as loadFromFile, b as loadFromInput, s as saveToFile, d as saveToFileHandle } from './file-05817129.js';

/**
 * Changes the name of the document.
 *
 * @param name - The name to be set in the document.
 * @category Actions
 */
declare const setName: (name: string) => SetNameAction;
/**
 * Cancels the last `count` operations.
 *
 * @param count - Number of operations to cancel
 * @category Actions
 */
declare const undo: (count?: number) => UndoAction;
/**
 * Cancels the last `count` {@link undo | UNDO} operations.
 *
 * @param count - Number of UNDO operations to cancel
 * @category Actions
 */
declare const redo: (count?: number) => RedoAction;
/**
 * Joins multiple operations into a single {@link loadState | LOAD_STATE} operation.
 *
 * @remarks
 * Useful to keep operations history smaller. Operations to prune are selected by index,
 * similar to the {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice | slice} method in Arrays.
 *
 * @param start - Index of the first operation to prune
 * @param end - Index of the last operation to prune
 * @category Actions
 */
declare const prune: (start?: number | undefined, end?: number | undefined) => PruneAction;
/**
 * Replaces the state of the document.
 *
 * @remarks
 * This action shouldn't be used directly. It is dispatched by the {@link prune} action.
 *
 * @param state - State to be set in the document.
 * @param operations - Number of operations that were removed from the previous state.
 * @category Actions
 */
declare const loadState: (state: Pick<ExtendedState, 'state' | 'name'>, operations: number) => LoadStateAction;

declare const creators_loadState: typeof loadState;
declare const creators_prune: typeof prune;
declare const creators_redo: typeof redo;
declare const creators_setName: typeof setName;
declare const creators_undo: typeof undo;
declare namespace creators {
  export {
    creators_loadState as loadState,
    creators_prune as prune,
    creators_redo as redo,
    creators_setName as setName,
    creators_undo as undo,
  };
}

/**
 * Base document reducer that wraps a custom document reducer and handles
 * document-level actions such as undo, redo, prune, and set name.
 *
 * @template T - The type of the state of the custom reducer.
 * @template A - The type of the actions of the custom reducer.
 * @param state - The current state of the document.
 * @param action - The action object to apply to the state.
 * @param customReducer - The custom reducer that implements the application logic
 * specific to the document's state.
 * @returns The new state of the document.
 */
declare function baseReducer<T, A extends Action>(document: Document$1<T, A>, action: A | BaseAction, customReducer: ImmutableStateReducer<T, A>): Document$1<T, A>;

/**
 * Helper function to be used by action creators.
 *
 * @remarks
 * Creates an action with the given type and input properties. The input
 * properties default to an empty object.
 *
 * @typeParam A - Type of the action to be returned.
 *
 * @param type - The type of the action.
 * @param input - The input properties of the action.
 *
 * @throws Error if the type is empty or not a string.
 *
 * @returns The new action.
 */
declare function createAction<A extends Action>(type: A['type'], input?: A['input'], attachments?: Action['attachments'], validator?: () => {
    parse(v: unknown): A;
}): A;
/**
 * Helper function to create a document model reducer.
 *
 * @remarks
 * This function creates a new reducer that wraps the provided `reducer` with
 * `documentReducer`, adding support for document actions:
 *   - `SET_NAME`
 *   - `UNDO`
 *   - `REDO`
 *   - `PRUNE`
 *
 * It also updates the document-related attributes on every operation.
 *
 * @param reducer - The custom reducer to wrap.
 * @param documentReducer - The document reducer to use.
 *
 * @returns The new reducer.
 */
declare function createReducer<T = unknown, A extends Action = Action>(reducer: ImmutableStateReducer<T, A>, documentReducer?: typeof baseReducer): Reducer<T, A>;
/**
 * Builds the initial document state from the provided data.
 *
 * @typeParam T - The type of the data.
 * @typeParam A - The type of the actions.
 *
 * @param initialState - The initial state of the document. The `data` property
 *   is required, but all other properties are optional.
 *
 * @returns The new document state.
 */
declare const createDocument: <T, A extends Action<string, unknown>>(initialState?: Partial<ExtendedState<T>> | undefined) => Document$1<T, A>;
declare const hashDocument: (document: Document$1) => string;
declare const hashKey: (date?: Date, randomLimit?: number) => string;

declare const index_FileInput: typeof FileInput;
declare const index_createAction: typeof createAction;
declare const index_createDocument: typeof createDocument;
declare const index_createReducer: typeof createReducer;
declare const index_createZip: typeof createZip;
declare const index_getLocalFile: typeof getLocalFile;
declare const index_getRemoteFile: typeof getRemoteFile;
declare const index_hashAttachment: typeof hashAttachment;
declare const index_hashDocument: typeof hashDocument;
declare const index_hashKey: typeof hashKey;
declare const index_loadFromFile: typeof loadFromFile;
declare const index_loadFromInput: typeof loadFromInput;
declare const index_saveToFile: typeof saveToFile;
declare const index_saveToFileHandle: typeof saveToFileHandle;
declare namespace index {
  export {
    index_FileInput as FileInput,
    index_createAction as createAction,
    index_createDocument as createDocument,
    index_createReducer as createReducer,
    index_createZip as createZip,
    index_getLocalFile as getLocalFile,
    index_getRemoteFile as getRemoteFile,
    index_hashAttachment as hashAttachment,
    index_hashDocument as hashDocument,
    index_hashKey as hashKey,
    index_loadFromFile as loadFromFile,
    index_loadFromInput as loadFromInput,
    index_saveToFile as saveToFile,
    index_saveToFileHandle as saveToFileHandle,
  };
}

declare const Document_Action: typeof Action;
declare const Document_Attachment: typeof Attachment;
declare const Document_BaseAction: typeof BaseAction;
declare const Document_BaseDocument: typeof BaseDocument;
declare const Document_DocumentFile: typeof DocumentFile;
declare const Document_DocumentHeader: typeof DocumentHeader;
declare const Document_ExtendedState: typeof ExtendedState;
declare const Document_FileRegistry: typeof FileRegistry;
declare const Document_ImmutableReducer: typeof ImmutableReducer;
declare const Document_ImmutableStateReducer: typeof ImmutableStateReducer;
declare const Document_InputDocumentFile: typeof InputDocumentFile;
declare const Document_Operation: typeof Operation;
declare const Document_Reducer: typeof Reducer;
declare const Document_applyMixins: typeof applyMixins;
declare const Document_baseReducer: typeof baseReducer;
declare namespace Document {
  export {
    Document_Action as Action,
    Document_Attachment as Attachment,
    Document_BaseAction as BaseAction,
    Document_BaseDocument as BaseDocument,
    Document$1 as Document,
    Document_DocumentFile as DocumentFile,
    Document_DocumentHeader as DocumentHeader,
    Document_ExtendedState as ExtendedState,
    Document_FileRegistry as FileRegistry,
    Document_ImmutableReducer as ImmutableReducer,
    Document_ImmutableStateReducer as ImmutableStateReducer,
    Document_InputDocumentFile as InputDocumentFile,
    Document_Operation as Operation,
    Document_Reducer as Reducer,
    creators as actions,
    Document_applyMixins as applyMixins,
    Document_baseReducer as baseReducer,
    index as utils,
  };
}

export { Document as D, baseReducer as b, creators as c, index as i };
