import { _objectSpread2 } from "../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
import { useCallback, useState } from "react";
//#region src/components/PisellTabbar2/hooks/useExpand.ts
/**
* Tabbar 展开状态管理 Hook
* 用于管理多层级的展开/收起状态
* 
* @param props - Hook 配置参数
* @returns 展开状态和操作方法
* 
* @example
* ```tsx
* const { expand, toggleExpand, getExpand } = useExpand({
*   initialExpand: { level1: false }
* });
* 
* <button onClick={() => toggleExpand('level1')}>
*   {getExpand('level1') ? '收起' : '展开'}
* </button>
* ```
*/
const useExpand = (props = {}) => {
	const { initialExpand = {} } = props;
	const [expand, setExpand] = useState(_objectSpread2({
		level1: false,
		level2: false,
		level3: false
	}, initialExpand));
	return {
		expand,
		setExpand,
		toggleExpand: useCallback((level) => {
			setExpand((prev) => _objectSpread2(_objectSpread2({}, prev), {}, { [level]: !prev[level] }));
		}, []),
		getExpand: useCallback((level) => {
			return expand[level];
		}, [expand])
	};
};
//#endregion
export { useExpand as default };
