type Subscriber<T> = (newValue: T) => void;
type Middleware<T> = (value: T) => T | undefined;
interface Chunk<T> {
    /** Get the current value of the chunk. */
    get: () => T;
    /** Peek at the current value without tracking dependencies. */
    peek: () => T;
    /** Set a new value for the chunk & Update existing value efficiently. */
    set: (newValueOrUpdater: T | ((currentValue: T) => T)) => void;
    /** Subscribe to changes in the chunk. Returns an unsubscribe function. */
    subscribe: (callback: Subscriber<T>) => () => void;
    /** Create a derived chunk based on this chunk's value. */
    derive: <D>(fn: (value: T) => D) => ReadOnlyChunk<D>;
    /** Reset the chunk to its initial value. */
    reset: () => void;
    /** Destroy the chunk and all its subscribers. */
    destroy: () => void;
}
interface ReadOnlyChunk<T> extends Omit<Chunk<T>, 'set' | 'reset'> {
    derive: <D>(fn: (value: T) => D) => ReadOnlyChunk<D>;
}

export type { Chunk as C, Middleware as M, ReadOnlyChunk as R };
