const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
const require_index = require("../../../locales/index.js");
const require_objectSpread2 = require("../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
let _pisell_icon_es_FilterFunnel01 = require("@pisell/icon/es/FilterFunnel01");
_pisell_icon_es_FilterFunnel01 = require_runtime.__toESM(_pisell_icon_es_FilterFunnel01);
let _pisell_icon_es_FilterFunnel01Fill = require("@pisell/icon/es/FilterFunnel01Fill");
_pisell_icon_es_FilterFunnel01Fill = require_runtime.__toESM(_pisell_icon_es_FilterFunnel01Fill);
require("./index.less");
//#region src/components/table/TableFilter/selectFilter.tsx
const FilterDropdown = (props) => {
	const { setSelectedKeys, selectedKeys, confirm, clearFilters, filters } = props;
	const [value, setValue] = (0, react.useState)((selectedKeys === null || selectedKeys === void 0 ? void 0 : selectedKeys[0]) || []);
	(0, react.useEffect)(() => {
		setValue((selectedKeys === null || selectedKeys === void 0 ? void 0 : selectedKeys[0]) || []);
	}, [selectedKeys === null || selectedKeys === void 0 ? void 0 : selectedKeys[0]]);
	const items = (0, react.useMemo)(() => {
		return filters.map((item) => ({
			label: /* @__PURE__ */ react.default.createElement("span", { onClick: (e) => {
				e.preventDefault();
			} }, /* @__PURE__ */ react.default.createElement(antd.Checkbox, { checked: value.includes(item.value) }, item.text)),
			key: item.value
		}));
	}, [filters, value]);
	const handleClick = ({ key }) => {
		setValue((v) => {
			if (v.includes(key)) return v.filter((item) => item !== key);
			return [...v, key];
		});
	};
	(0, react.useEffect)(() => {
		setSelectedKeys((value === null || value === void 0 ? void 0 : value.length) ? [value] : []);
	}, [value]);
	return /* @__PURE__ */ react.default.createElement("div", {
		onKeyDown: (e) => e.stopPropagation(),
		className: "pisell-table-filter-dropdown"
	}, /* @__PURE__ */ react.default.createElement("div", {
		className: "pisell-table-filter-dropdown-top",
		style: { padding: 0 }
	}, /* @__PURE__ */ react.default.createElement(antd.Menu, {
		onClick: handleClick,
		items,
		selectedKeys: [],
		style: { width: 272 }
	})), /* @__PURE__ */ react.default.createElement(antd.Space, {
		className: "pisell-table-filter-dropdown-bottom",
		styles: { item: { flex: 1 } }
	}, /* @__PURE__ */ react.default.createElement(antd.Button, {
		onClick: () => {
			clearFilters && clearFilters();
			confirm();
		},
		block: true,
		style: { flex: 1 }
	}, require_index.getText("table-filter-clear")), /* @__PURE__ */ react.default.createElement(antd.Button, {
		type: "primary",
		onClick: () => confirm(),
		block: true,
		style: { flex: 1 }
	}, require_index.getText("table-filter-filter"))));
};
const getColumnSelectProps = ({ dataIndex, filters }) => ({
	filterDropdown: (props) => /* @__PURE__ */ react.default.createElement(FilterDropdown, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, props), {}, { filters })),
	filterIcon: (filtered) => filtered ? /* @__PURE__ */ react.default.createElement(_pisell_icon_es_FilterFunnel01Fill.default, { style: {
		color: "#7f56d9",
		fontSize: 14
	} }) : /* @__PURE__ */ react.default.createElement(_pisell_icon_es_FilterFunnel01.default, { style: {
		color: "#98A2B3",
		fontSize: 14
	} })
});
//#endregion
exports.default = getColumnSelectProps;
