import { useStep } from "../../../../Sales/Step/index.js";
import CartItem from "../Cart/Item/index.js";
import Resource from "../Resource/index.js";
import Event from "../Event/index.js";
import Information from "../Information/index.js";
import React, { useEffect, useMemo } from "react";
import { isMobile } from "@pisell/utils";
import "./index.less";
//#region src/components/eventBooking/components/Provider/Content/index.tsx
const Layout = () => {
	const { currentStepData, isFirstStep } = useStep();
	useEffect(() => {
		window.scrollTo({
			top: 0,
			behavior: "smooth"
		});
	}, [currentStepData === null || currentStepData === void 0 ? void 0 : currentStepData.key]);
	const Com = useMemo(() => {
		const key = currentStepData === null || currentStepData === void 0 ? void 0 : currentStepData.key;
		if (!key) return null;
		let Com = {
			"select-category": Resource,
			"select-event": Event,
			"confirm-information": Information
		}[key];
		return /* @__PURE__ */ React.createElement(Com, null);
	}, [currentStepData === null || currentStepData === void 0 ? void 0 : currentStepData.key]);
	/**
	* @title: 动态计算中间内容区域的高度
	* @description:
	* @return {*}
	* @Author: WangHan
	* @Date: 2025-02-18 15:36
	*/
	useEffect(() => {
		if (isMobile()) {
			var _header$getBoundingCl, _footer$getBoundingCl;
			const header = document.querySelector(".event-progress-bar");
			const footer = document.querySelector(".pisell-section-footers-wrapper");
			const content = document.querySelector(".event-content-mobile-wrap");
			const headerHeight = (header === null || header === void 0 || (_header$getBoundingCl = header.getBoundingClientRect()) === null || _header$getBoundingCl === void 0 ? void 0 : _header$getBoundingCl.height) || 0;
			const footerHeight = (footer === null || footer === void 0 || (_footer$getBoundingCl = footer.getBoundingClientRect()) === null || _footer$getBoundingCl === void 0 ? void 0 : _footer$getBoundingCl.height) || 0;
			const contentHeight = window.innerHeight - headerHeight - footerHeight;
			if (content && (content === null || content === void 0 ? void 0 : content.style)) {
				content.style.height = `${contentHeight}px`;
				content.style.overflowY = "auto";
			}
		}
	}, [currentStepData === null || currentStepData === void 0 ? void 0 : currentStepData.key]);
	return /* @__PURE__ */ React.createElement("div", { className: `event-content-wrap ${isMobile() ? "event-content-mobile-wrap" : ""}` }, /* @__PURE__ */ React.createElement("div", { className: "event-content-left" }, Com), !isMobile() && !isFirstStep ? /* @__PURE__ */ React.createElement("div", { className: "event-content-right" }, /* @__PURE__ */ React.createElement(CartItem, null)) : null);
};
//#endregion
export { Layout as default };
