import { useCallback, useState } from 'react';
function useControllableState({ value, defaultValue, onChange }) {
    const [internal, setInternal] = useState(defaultValue);
    const isControlled = value !== undefined;
    const handleChange = useCallback((event) => {
        if (!isControlled)
            setInternal(event.target.value);
        onChange?.(event);
    }, [isControlled, onChange]);
    return [isControlled ? value : internal, handleChange];
}
export default useControllableState;
//# sourceMappingURL=use-controllable-state.js.map