import { useCallback, useMemo, useState } from "react";
//#region src/components/pisellHierarchicalSummaryList/hooks/useExpandedKeys.ts
/**
* 展开态管理（兼容受控/非受控）。
*/
function useExpandedKeys(options) {
	const { expandedKeys, defaultExpandedKeys, onExpandedKeysChange } = options;
	const [inner, setInner] = useState(defaultExpandedKeys !== null && defaultExpandedKeys !== void 0 ? defaultExpandedKeys : []);
	const merged = expandedKeys !== null && expandedKeys !== void 0 ? expandedKeys : inner;
	const setExpandedKeys = useCallback((next) => {
		onExpandedKeysChange === null || onExpandedKeysChange === void 0 || onExpandedKeysChange(next);
		if (expandedKeys === void 0) setInner(next);
	}, [expandedKeys, onExpandedKeysChange]);
	return {
		expandedKeys: merged,
		expandedKeySet: useMemo(() => new Set(merged), [merged]),
		setExpandedKeys
	};
}
//#endregion
export { useExpandedKeys };
