import { _objectWithoutProperties } from "../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectWithoutProperties.js";
import { stringify } from "../Table/utils.js";
import Table_default from "../Table/index.js";
import Gallery_default from "../Gallery/index.js";
import React, { useMemo } from "react";
import { Form } from "antd";
import { useDebounce, useMemoizedFn } from "ahooks";
//#region src/components/table/View/index.tsx
const _excluded = [
	"dataSource",
	"columns",
	"dispatch",
	"style",
	"filter",
	"sort",
	"buttons",
	"actionButtons",
	"title",
	"summary",
	"onValuesChange",
	"columnSetting",
	"dataSourceGroup",
	"view",
	"gallery",
	"setTableSetting",
	"onDataSourceChange"
];
const View = (props) => {
	const { dataSource, columns, dispatch, style, filter, sort, buttons, actionButtons, title, summary, onValuesChange, columnSetting, dataSourceGroup, view, gallery, setTableSetting, onDataSourceChange } = props, other = _objectWithoutProperties(props, _excluded);
	const form = Form.useFormInstance();
	const viewMode = Form.useWatch("view_mode", {
		form,
		preserve: true
	});
	const debouncedFilter = useDebounce(filter, { wait: 200 });
	const memoOnDataSourceChange = useMemoizedFn((v) => onDataSourceChange === null || onDataSourceChange === void 0 ? void 0 : onDataSourceChange(v));
	return useMemo(() => {
		return /* @__PURE__ */ React.createElement(React.Fragment, null, viewMode === "grid" && /* @__PURE__ */ React.createElement(Table_default, {
			tableProps: other,
			filter,
			setTableSetting,
			onDataSourceChange: memoOnDataSourceChange
		}), viewMode === "gallery" && /* @__PURE__ */ React.createElement(Gallery_default, {
			loading: other === null || other === void 0 ? void 0 : other.loading,
			gallery,
			pagination: other.pagination,
			filter,
			rowKey: other.rowKey,
			onDataSourceChange: memoOnDataSourceChange
		}));
	}, [
		viewMode,
		stringify(other),
		debouncedFilter,
		memoOnDataSourceChange,
		gallery
	]);
};
//#endregion
export { View as default };
