import { State, Store as Store$1, StoreState } from "@ariakit/store";
import { AnyFunction, PickByValue, SetState } from "@ariakit/utils";
//#region src/index.d.ts
interface UseState<S> {
  /**
   * Re-renders the component when state changes and returns the current state.
   * @deprecated Use
   * [`useStoreState`](https://ariakit.com/reference/use-store-state) instead.
   * @example
   * const state = store.useState();
   */
  (): S;
  /**
   * Re-renders the component when the state changes and returns the current
   * state given the passed key. Changes on other keys will not trigger a
   * re-render.
   * @param key The state key.
   * @deprecated Use
   * [`useStoreState`](https://ariakit.com/reference/use-store-state) instead.
   * @example
   * const foo = store.useState("foo");
   */
  <K extends keyof S>(key: K): S[K];
  /**
   * Re-renders the component when the state changes given the return value of
   * the selector function. The selector should return a stable value that will
   * be compared to the previous value. Returns the value returned by the
   * selector function.
   * @param selector The selector function.
   * @deprecated Use
   * [`useStoreState`](https://ariakit.com/reference/use-store-state) instead.
   * @example
   * const foo = store.useState((state) => state.foo);
   */
  <V>(selector: (state: S) => V): V;
}
type StateStore<T = Store$1<any>> = T | null | undefined;
type StateKey<T = Store$1<any>> = keyof StoreState<T>;
type SelectorStateKey<T> = T extends Store$1 ? StateKey<T> : never;
type SelectorState<T, K extends PropertyKey> = T extends Store$1 ? Pick<StoreState<T>, Extract<K, StateKey<T>>> : never;
/**
 * Receives an Ariakit store object (which can be `null` or `undefined`) and
 * returns the current state. If a key is provided as the second argument, it
 * returns the value of that key. If a selector function is provided, the state
 * is passed to it, and its return value is used. Selector calls can pass the
 * state keys they read as the second argument to skip unrelated store updates.
 * This list must include every store key the selector reads, or the returned
 * snapshot may stay stale. An empty list means store updates will never notify
 * the selector.
 *
 * The component using this hook will re-render when the returned value changes.
 * @example
 * Accessing the whole combobox state:
 * ```js
 * const combobox = Ariakit.useComboboxStore();
 * const state = Ariakit.useStoreState(combobox);
 * ```
 * @example
 * Accessing a specific value from the combobox state:
 * ```js
 * const combobox = Ariakit.useComboboxStore();
 * const value = Ariakit.useStoreState(combobox, "value");
 * ```
 * @example
 * Accessing a value using a selector function:
 * ```js
 * const combobox = Ariakit.useComboboxStore();
 * const value = Ariakit.useStoreState(combobox, (state) => state.value);
 * ```
 * @example
 * Subscribing only to the state keys read by a selector:
 * ```js
 * const tab = Ariakit.useTabStore();
 * const selected = Ariakit.useStoreState(
 *   tab,
 *   ["selectedId"],
 *   (state) => state.selectedId === "details",
 * );
 * ```
 * @example
 * Accessing the state of a store that may be `null` or `undefined` (for
 * example, using a context):
 * ```js
 * const combobox = Ariakit.useComboboxContext();
 * const value = Ariakit.useStoreState(combobox, "value");
 * ```
 */
declare function useStoreState<T extends Store$1>(store: T): StoreState<T>;
declare function useStoreState<T extends Store$1>(store: StateStore<T>): StoreState<T> | undefined;
declare function useStoreState<T extends Store$1, K extends StateKey<T>>(store: T, key: K): StoreState<T>[K];
declare function useStoreState<T extends Store$1, K extends StateKey<T>>(store: StateStore<T>, key: K): StoreState<T>[K] | undefined;
declare function useStoreState<T extends Store$1, V>(store: T, selector: (state: StoreState<T>) => V): V;
declare function useStoreState<T extends Store$1, V>(store: StateStore<T>, selector: (state?: StoreState<T>) => V): V;
declare function useStoreState<T extends Store$1, K extends SelectorStateKey<T>, V>(store: T, keys: readonly K[], selector: (state: SelectorState<T, K>) => V): V;
declare function useStoreState<T extends Store$1, K extends SelectorStateKey<T>, V>(store: StateStore<T>, keys: readonly K[], selector: (state?: SelectorState<T, K>) => V): V;
type StoreStateObject<T extends StateStore, S> = Record<string, StateKey<T> | ((state: S) => any)>;
type StoreStateObjectResult<T extends StateStore, S extends StoreState<T> | undefined, O extends Record<string, StateKey<T> | AnyFunction>> = { [K in keyof O]: O[K] extends keyof StoreState<T> ? O[K] extends keyof S ? S[O[K]] : StoreState<T>[O[K]] | undefined : O[K] extends AnyFunction ? ReturnType<O[K]> : never; };
/**
 * Receives an Ariakit store object (which can be `null` or `undefined`) and
 * returns the current state. Unlike `useStoreState`, this hook receives an
 * object with keys that map to store keys or selector functions. Store keys in
 * the object are always subscribed to. When selector dependency keys are
 * passed as the second argument, they must include every store key read by
 * every selector, or the returned snapshot may stay stale. An empty list means
 * only direct store keys in the object will notify the selectors.
 * @example
 * Reading direct and derived values with selector dependencies:
 * ```js
 * const values = useStoreStateObject(
 *   store,
 *   ["value"],
 *   {
 *     value: "value",
 *     valueLength: (state) => state.value.length,
 *   },
 * );
 * ```
 */
declare function useStoreStateObject<T extends Store$1, O extends StoreStateObject<T, StoreState<T>>>(store: T, object: O): StoreStateObjectResult<T, StoreState<T>, O>;
declare function useStoreStateObject<T extends StateStore, O extends StoreStateObject<T, StoreState<T> | undefined>>(store: T, object: O): StoreStateObjectResult<T, StoreState<T> | undefined, O>;
declare function useStoreStateObject<T extends Store$1, K extends SelectorStateKey<T>, O extends StoreStateObject<T, SelectorState<T, K>>>(store: T, keys: readonly K[], object: O): StoreStateObjectResult<T, StoreState<T>, O>;
declare function useStoreStateObject<T extends Store$1, K extends SelectorStateKey<T>, O extends StoreStateObject<T, SelectorState<T, K> | undefined>>(store: StateStore<T>, keys: readonly K[], object: O): StoreStateObjectResult<T, StoreState<T> | undefined, O>;
/**
 * Synchronizes the store with the props, including parent store props.
 * @param store The store to synchronize.
 * @param props The props to synchronize with.
 * @param key The key of the value prop.
 * @param setKey The key of the setValue prop.
 */
declare function useStoreProps<S extends State, P extends Partial<S>, K extends keyof S, SK extends keyof PickByValue<P, SetState<P[K]>>>(store: Store$1<S>, props: P, key: K, setKey?: SK): void;
/**
 * Creates a React store from a core store object and returns a tuple with the
 * store and a function to update the store.
 * @param createStore A function that receives the props and returns a core
 * store object.
 * @param props The props to pass to the createStore function.
 */
declare function useStore<T extends Store$1, P>(createStore: (props: P) => T, props: P): readonly [T & {
  useState: UseState<StoreState<T>>;
}, () => void];
type Store<T extends Store$1 = Store$1> = T & {
  /**
   * Re-renders the component when the state changes and returns the current
   * state.
   * @deprecated Use
   * [`useStoreState`](https://ariakit.com/reference/use-store-state) instead.
   */
  useState: UseState<StoreState<T>>;
};
//#endregion
export { Store, UseState, useStore, useStoreProps, useStoreState, useStoreStateObject };
//# sourceMappingURL=index.d.ts.map