import { _objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
import { _objectWithoutProperties } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectWithoutProperties.js";
import React, { forwardRef, useEffect, useImperativeHandle, useMemo, useState } from "react";
import classNames from "classnames";
import "./index.less";
//#region src/components/actionBar/index.tsx
const _excluded = [
	"headerProps",
	"contentProps",
	"footerProps"
];
const ActionBar = forwardRef((props, ref) => {
	const { headerProps, contentProps, footerProps } = props, restProps = _objectWithoutProperties(props, _excluded);
	const [slot, setSlot] = useState([]);
	const set = (dom) => {
		setSlot((prev) => [...prev, dom]);
	};
	const destroyAll = () => {
		setSlot([]);
	};
	const destroyById = (id) => {
		setSlot((prev) => prev.filter((item) => item.id !== id));
	};
	useEffect(() => {
		document.body.id = "body";
		window.actionBar = {
			set,
			destroyAll,
			destroyById
		};
		return () => {
			window.actionBar = null;
		};
	}, []);
	useImperativeHandle(ref, () => ({
		set,
		destroyAll,
		destroyById
	}));
	const header = useMemo(() => {
		return slot.filter((item) => item.position === "header").sort((a, b) => a.sort - b.sort).map((item) => item.component);
	}, [slot]);
	const content = useMemo(() => {
		return slot.filter((item) => item.position === "content").sort((a, b) => a.sort - b.sort).map((item) => item.component);
	}, [slot]);
	const footer = useMemo(() => {
		return slot.filter((item) => item.position === "footer").sort((a, b) => a.sort - b.sort).map((item) => item.component);
	}, [slot]);
	return /* @__PURE__ */ React.createElement("div", _objectSpread2(_objectSpread2({}, restProps), {}, { className: classNames("pisell-action-bar", restProps.className) }), /* @__PURE__ */ React.createElement("div", _objectSpread2(_objectSpread2({}, headerProps), {}, { className: classNames("pisell-action-bar-header", headerProps === null || headerProps === void 0 ? void 0 : headerProps.className) }), header), /* @__PURE__ */ React.createElement("div", _objectSpread2(_objectSpread2({}, contentProps), {}, { className: classNames("pisell-action-bar-content", contentProps === null || contentProps === void 0 ? void 0 : contentProps.className) }), content), /* @__PURE__ */ React.createElement("div", _objectSpread2(_objectSpread2({}, footerProps), {}, { className: classNames("pisell-action-bar-footer", footerProps === null || footerProps === void 0 ? void 0 : footerProps.className) }), footer));
});
//#endregion
export { ActionBar as default };
