import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
import type { BivariantCallback } from "../utils/types.js";
type Item = {
    id: string;
    element?: HTMLElement | null;
};
/**
 * Creates a collection store.
 */
export declare function createCollectionStore<T extends Item = Item>(props?: CollectionStoreProps<T>): CollectionStore<T>;
export type CollectionStoreItem = Item;
export interface CollectionStoreState<T extends Item = Item> {
    /**
     * Lists all the items with their meta data. This state is automatically
     * updated when an item is registered or unregistered with the `registerItem`
     * function.
     */
    items: T[];
    /**
     * Lists all the items that are currently rendered. This state is
     * automatically updated when an item is rendered or unrendered with the
     * `renderItem` function. This state is also automatically sorted based on
     * their DOM position.
     */
    renderedItems: T[];
}
export interface CollectionStoreFunctions<T extends Item = Item> {
    /**
     * Registers an item in the collection. This function returns a cleanup
     * function that unregisters the item.
     * @param item The item to register.
     * @example
     * const unregisterItem = store.registerItem({ id: "item-1" });
     * // on cleanup
     * unregisterItem();
     */
    registerItem: BivariantCallback<(item: T) => () => void>;
    /**
     * Renders an item in the collection. This function returns a cleanup function
     * that unrenders the item.
     * @param item The item to render.
     * @example
     * const unrenderItem = store.renderItem({ id: "item-1" });
     * // on cleanup
     * unrenderItem();
     */
    renderItem: BivariantCallback<(item: T) => () => void>;
    /**
     * Gets an item by its id.
     * @param id The id of the item.
     * @example
     * const item = store.item("item-1");
     */
    item: (id: string | null | undefined) => T | null;
}
export interface CollectionStoreOptions<T extends Item = Item> extends StoreOptions<CollectionStoreState<T>, "items"> {
    /**
     * The defaut value for the `items` state.
     * @default []
     */
    defaultItems?: CollectionStoreState<T>["items"];
}
export type CollectionStoreProps<T extends Item = Item> = CollectionStoreOptions<T> & StoreProps<CollectionStoreState<T>>;
export type CollectionStore<T extends Item = Item> = CollectionStoreFunctions<T> & Store<CollectionStoreState<T>>;
export {};
