import '../../../../../node_modules/preact/compat/dist/compat.module.mjs';
import { debounce } from '../../utils/index.mjs';
import { useState as h, useMemo as F, useCallback as T } from '../../../../../node_modules/preact/hooks/dist/hooks.module.mjs';

const useDebouncedState = (initialValue, delay)=>{
    const [debouncedValue, setDebouncedValue] = h(initialValue);
    const [pendingValue, setPendingValue] = h(initialValue);
    const debouncedSetValue = F(()=>debounce(setDebouncedValue, delay), [
        delay
    ]);
    const setValue = T((newValue)=>{
        setPendingValue(newValue);
        debouncedSetValue(newValue);
    }, [
        debouncedSetValue
    ]);
    return [
        debouncedValue,
        setValue,
        pendingValue
    ];
};

export { useDebouncedState };
//# sourceMappingURL=useDebouncedState.mjs.map
