import { _objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
import Button$1 from "../button/index.js";
import React, { forwardRef, memo, useMemo } from "react";
import { Dropdown, Flex, Space } from "antd";
import { MoreOutlined } from "@ant-design/icons";
//#region src/components/buttonGroupPreview/index.tsx
/**
*
* @param param0 { buttonConfig, buttonGroupList }
* @returns 整合按钮配置 返回最新的组件数据
*/
const updateSourceData = ({ buttonConfig, buttonGroupList }) => {
	if (Object.keys(buttonConfig).length !== 0) return buttonGroupList.map((subArray) => {
		return subArray.map((item) => {
			if (buttonConfig.hasOwnProperty(item.id)) return buttonConfig[item.id];
			return item;
		});
	});
	return buttonGroupList;
};
var buttonGroupPreview_default = memo(forwardRef((props, ref) => {
	const { buttonConfig = {}, buttonGroupList = [] } = props;
	const sourceDatas = useMemo(() => {
		return updateSourceData({
			buttonConfig,
			buttonGroupList
		});
	}, [buttonGroupList, buttonConfig]);
	return /* @__PURE__ */ React.createElement(Flex, {
		wrap: true,
		vertical: true,
		style: { marginBottom: 10 }
	}, sourceDatas.map((item, index) => /* @__PURE__ */ React.createElement(Space, { key: index }, item.map((items, index) => {
		const { isMore = false, id = "", menuData = [], buttonProps } = items;
		const btnProps = _objectSpread2(_objectSpread2({}, buttonProps), props.updateButtonProps);
		return isMore ? /* @__PURE__ */ React.createElement(Dropdown, { menu: { items: menuData } }, /* @__PURE__ */ React.createElement(Button$1, null, /* @__PURE__ */ React.createElement(MoreOutlined, null))) : /* @__PURE__ */ React.createElement(Button$1, _objectSpread2({ key: id }, btnProps));
	}))));
}));
//#endregion
export { buttonGroupPreview_default as default };
