const require_runtime = require("../../../../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_index = require("../utils/index.js");
let react = require("react");
react = require_runtime.__toESM(react);
let classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
//#region src/components/PisellCards/components/MultilevelCard/components/PanelWrapper.tsx
/**
* PanelWrapper 组件
* 次级面板包装器，负责展开/收起动画和样式处理
*/
const PanelWrapper = (props) => {
	const { children, visible, widthMode = "full", width, animation = true, animationDuration = 300, onMount, onUnmount, onMouseEnter, onMouseLeave, style, className } = props;
	const panelRef = (0, react.useRef)(null);
	const isMountedRef = (0, react.useRef)(false);
	(0, react.useEffect)(() => {
		if (visible && !isMountedRef.current) {
			isMountedRef.current = true;
			onMount === null || onMount === void 0 || onMount();
		} else if (!visible && isMountedRef.current) {
			const timer = setTimeout(() => {
				isMountedRef.current = false;
				onUnmount === null || onUnmount === void 0 || onUnmount();
			}, animation ? animationDuration : 0);
			return () => clearTimeout(timer);
		}
	}, [
		visible,
		animation,
		animationDuration,
		onMount,
		onUnmount
	]);
	if (!children) return null;
	const getWidthStyle = () => {
		switch (widthMode) {
			case "auto": return { width: "auto" };
			case "fixed": return { width: require_index.formatWidth(width) };
			case "full": return { width: "100%" };
			default: return {};
		}
	};
	const getAnimationStyle = () => {
		if (!animation) return {};
		return { transition: `max-height ${animationDuration}ms ease, opacity ${animationDuration}ms ease` };
	};
	const panelStyle = require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, getWidthStyle()), getAnimationStyle()), style);
	const panelClassName = (0, classnames.default)("multilevel-card-panel", {
		"multilevel-card-panel--visible": visible,
		"multilevel-card-panel--hidden": !visible
	}, className);
	return visible ? /* @__PURE__ */ react.default.createElement("div", {
		ref: panelRef,
		className: panelClassName,
		style: panelStyle,
		onMouseEnter,
		onMouseLeave
	}, children) : null;
};
//#endregion
exports.PanelWrapper = PanelWrapper;
