import type { AnyObject, SetStateAction } from "./types.js";
/**
 * Creates a store.
 * @param initialState Initial state.
 * @param stores Stores to extend.
 */
export declare function createStore<S extends State>(initialState: S, ...stores: Array<Partial<Store<Partial<S>>> | undefined>): Store<S>;
/**
 * Merges multiple stores into a single store.
 */
export declare function mergeStore<S extends State>(...stores: Array<Partial<Store<S>> | undefined>): Store<S>;
/**
 * Store state type.
 */
export type State = AnyObject;
/**
 * Initial state that can be passed to a store creator function.
 * @template S State type.
 * @template K Key type.
 */
export type StoreOptions<S extends State, K extends keyof S> = Partial<Pick<S, K>>;
/**
 * Props that can be passed to a store creator function.
 * @template S State type.
 */
export type StoreProps<S extends State = State> = {
    store?: Store<Partial<S>>;
};
/**
 * Extracts the state type from a store type.
 * @template T Store type.
 */
export type StoreState<T> = T extends {
    getState(): infer S;
} ? S : never;
/**
 * Store listener type.
 * @template S State type.
 */
export type Listener<S> = (state: S, prevState: S) => void | (() => void);
/**
 * Subscriber function type used by `sync`, `subscribe` and `effect`.
 * @template S State type.
 */
export type Sync<S = State> = {
    /**
     * @param listener The listener function. It's called with the current state
     * and the previous state as arguments and may return a cleanup function.
     * @param keys Optional array of state keys to listen to.
     */
    <K extends keyof S = keyof S>(listener: Listener<Pick<S, K>>, keys?: K[]): () => void;
};
/**
 * Store.
 * @template S State type.
 */
export interface Store<S = State> {
    /**
     * Returns the current store state.
     */
    getState(): S;
    /**
     * Sets a state value.
     */
    setState<K extends keyof S>(key: K, value: SetStateAction<S[K]>): void;
    /**
     * Register a callback function that's called when the store is initialized.
     * @deprecated Experimental. This API may change in minor or patch releases.
     */
    setup: (callback: () => void | (() => void)) => () => void;
    /**
     * Function that should be called when the store is initialized.
     * @deprecated Experimental. This API may change in minor or patch releases.
     */
    init: () => () => void;
    /**
     * Registers a listener function that's called immediately and synchronously
     * whenever the store state changes.
     * @deprecated Experimental. This API may change in minor or patch releases.
     */
    sync: Sync<S>;
    /**
     * Registers a listener function that's called after state changes in the
     * store.
     * @deprecated Experimental. This API may change in minor or patch releases.
     */
    subscribe: Sync<S>;
    /**
     * Registers a listener function that's called immediately and after a batch
     * of state changes in the store.
     * @deprecated Experimental. This API may change in minor or patch releases.
     */
    syncBatch: Sync<S>;
    /**
     * Creates a new store with a subset of the current store state and keeps them
     * in sync.
     * @deprecated Experimental. This API may change in minor or patch releases.
     */
    pick<K extends Array<keyof S>>(...keys: K): Store<Pick<S, K[number]>>;
    /**
     * Creates a new store with a subset of the current store state and keeps them
     * in sync.
     * @deprecated Experimental. This API may change in minor or patch releases.
     */
    omit<K extends Array<keyof S>>(...keys: K): Store<Omit<S, K[number]>>;
}
