import * as React from "react";
//#region src/hooks/use-controllable-state.ts
/**
* Manages state that can be either controlled or uncontrolled.
*
* When `value` is provided, the component is controlled — the caller owns
* the state and `onChange` is called on updates. When omitted, internal
* state is used with `defaultValue` as the initial value.
*/
function useControllableState({ value: controlledValue, defaultValue, onChange }) {
	const [internalValue, setInternalValue] = React.useState(defaultValue);
	const isControlled = controlledValue !== void 0;
	return [isControlled ? controlledValue : internalValue, React.useCallback((newValue) => {
		if (!isControlled) setInternalValue(newValue);
		onChange?.(newValue);
	}, [isControlled, onChange])];
}
//#endregion
export { useControllableState };

//# sourceMappingURL=index11.js.map