const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
const require_useIsMobileTable = require("../hooks/useIsMobileTable.js");
const require_index = require("../../filter/index.js");
const require_index$1 = require("../../sort/index.js");
const require_index$2 = require("../Header/Buttons/index.js");
const require_index$3 = require("./component/ColumnsSetting/index.js");
const require_index$4 = require("./component/ExportImport/index.js");
const require_index$5 = require("./component/GallerySetting/index.js");
const require_index$6 = require("./component/Group/index.js");
const require_index$7 = require("./component/ViewMode/index.js");
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
require("./index.less");
//#region src/components/table/Actions/index.tsx
const Actions = ({ filter, sort, columnSetting, dataSourceGroup, tableId, localPagination, buttons, view, gallery, exportImport }) => {
	const form = antd.Form.useFormInstance();
	const isMobileBool = require_useIsMobileTable.default();
	const viewMode = antd.Form.useWatch("view_mode", {
		form,
		preserve: true
	});
	const showActions = (0, react.useMemo)(() => {
		if (react.default.isValidElement(filter) || react.default.isValidElement(filter === null || filter === void 0 ? void 0 : filter.dom)) return true;
		return (filter === null || filter === void 0 ? void 0 : filter.show) || (sort === null || sort === void 0 ? void 0 : sort.show) || (columnSetting === null || columnSetting === void 0 ? void 0 : columnSetting.show) || (dataSourceGroup === null || dataSourceGroup === void 0 ? void 0 : dataSourceGroup.show) || view.multiple || (exportImport === null || exportImport === void 0 ? void 0 : exportImport.show);
	}, [
		filter === null || filter === void 0 ? void 0 : filter.show,
		sort === null || sort === void 0 ? void 0 : sort.show,
		columnSetting === null || columnSetting === void 0 ? void 0 : columnSetting.show,
		dataSourceGroup === null || dataSourceGroup === void 0 ? void 0 : dataSourceGroup.show,
		view.multiple,
		exportImport === null || exportImport === void 0 ? void 0 : exportImport.show
	]);
	const filterRender = (0, react.useMemo)(() => {
		if (react.default.isValidElement(filter)) return filter;
		if (react.default.isValidElement(filter === null || filter === void 0 ? void 0 : filter.dom)) return filter.dom;
		return /* @__PURE__ */ react.default.createElement(require_index.default, {
			filter,
			isRenderFormContent: false,
			tableId,
			viewMode,
			isMobile: isMobileBool
		});
	}, [
		filter,
		tableId,
		viewMode,
		isMobileBool
	]);
	return showActions ? /* @__PURE__ */ react.default.createElement("div", { className: "materials-grid-actions" }, /* @__PURE__ */ react.default.createElement("div", { className: "left-wrap" }, filterRender), /* @__PURE__ */ react.default.createElement("div", {
		className: "right-wrap",
		style: { columnGap: isMobileBool ? 0 : 12 }
	}, view.multiple && /* @__PURE__ */ react.default.createElement(antd.Form.Item, {
		name: "view_mode",
		noStyle: true
	}, /* @__PURE__ */ react.default.createElement(require_index$7.default, { view })), (exportImport === null || exportImport === void 0 ? void 0 : exportImport.show) ? /* @__PURE__ */ react.default.createElement(require_index$4.default, { exportImport }) : null, (dataSourceGroup === null || dataSourceGroup === void 0 ? void 0 : dataSourceGroup.show) && viewMode === "grid" && /* @__PURE__ */ react.default.createElement(antd.Form.Item, {
		name: "group_by",
		noStyle: true
	}, /* @__PURE__ */ react.default.createElement(require_index$6.default, { setting: dataSourceGroup })), (columnSetting === null || columnSetting === void 0 ? void 0 : columnSetting.show) && viewMode === "grid" && /* @__PURE__ */ react.default.createElement(antd.Form.Item, {
		name: ["column_setting"],
		noStyle: true
	}, /* @__PURE__ */ react.default.createElement(require_index$3.default, null)), (columnSetting === null || columnSetting === void 0 ? void 0 : columnSetting.show) && viewMode === "gallery" && /* @__PURE__ */ react.default.createElement(require_index$5.default, {
		setting: gallery,
		currentViewMode: viewMode
	}), (sort === null || sort === void 0 ? void 0 : sort.show) ? /* @__PURE__ */ react.default.createElement(antd.Form.Item, {
		name: "order_by",
		noStyle: true
	}, /* @__PURE__ */ react.default.createElement(require_index$1.default, {
		list: (sort === null || sort === void 0 ? void 0 : sort.list) || [],
		localPagination
	})) : null, !!(buttons === null || buttons === void 0 ? void 0 : buttons.length) && /* @__PURE__ */ react.default.createElement(require_index$2.default, {
		list: buttons,
		style: isMobileBool ? { marginLeft: 8 } : {}
	}))) : null;
};
//#endregion
exports.default = Actions;
