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");
const require_index$1 = require("../../../../DragSortList/index.js");
const require_utils = require("./utils.js");
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
let _ant_design_icons = require("@ant-design/icons");
let classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
let _pisell_icon_es_DotsSix = require("@pisell/icon/es/DotsSix");
_pisell_icon_es_DotsSix = require_runtime.__toESM(_pisell_icon_es_DotsSix);
let _pisell_icon_es_Lock01 = require("@pisell/icon/es/Lock01");
_pisell_icon_es_Lock01 = require_runtime.__toESM(_pisell_icon_es_Lock01);
require("./PopoverContent.less");
//#region src/components/table/Actions/component/ColumnsSetting/PopoverContent.tsx
const prefix = "pisell-lowcode-";
const DragItem = react.default.forwardRef((props, ref) => {
	const { attributes, listeners, setActivatorNodeRef, style, isLock } = props;
	return /* @__PURE__ */ react.default.createElement("div", require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({ ref }, attributes), {}, {
		style,
		className: `${prefix}table-action-column-drag-item`
	}), isLock ? /* @__PURE__ */ react.default.createElement(antd.Tooltip, { title: require_index.getText("table-column-group-lock-tip") }, /* @__PURE__ */ react.default.createElement(_pisell_icon_es_Lock01.default, { className: `${prefix}table-action-column-drag-bar` })) : /* @__PURE__ */ react.default.createElement(_pisell_icon_es_DotsSix.default, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({ ref: setActivatorNodeRef }, listeners), {}, {
		style: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, listeners.style || {}), {}, { touchAction: "none" }),
		className: `${prefix}table-action-column-drag-bar`
	})), props.children);
});
const defaultValue = [];
const PopoverContent = (props) => {
	const { value = defaultValue, onChange, isShowTitle = true, headerContent } = props;
	const handleChange = (index, isShow) => {
		value[index] = require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, value[index]), {}, { isShow });
		onChange === null || onChange === void 0 || onChange([...value]);
	};
	return /* @__PURE__ */ react.default.createElement("div", { className: `${prefix}table-action-column-popover-content-wrap` }, /* @__PURE__ */ react.default.createElement("div", { className: `${prefix}table-action-column-header` }, isShowTitle && /* @__PURE__ */ react.default.createElement("span", { className: `${prefix}table-action-column-header-title` }, require_index.getText("table-action-column-title")), headerContent && headerContent), /* @__PURE__ */ react.default.createElement("div", { className: `${prefix}table-action-column-content` }, /* @__PURE__ */ react.default.createElement(require_index$1.default, {
		list: value,
		rowKey: (item) => {
			var _item$dataIndex;
			return `${item.key}-${(_item$dataIndex = item.dataIndex) === null || _item$dataIndex === void 0 ? void 0 : _item$dataIndex.toString()}`;
		},
		onChange: (list) => {
			if (!require_utils.isFixedOrderValid(list)) return;
			onChange === null || onChange === void 0 || onChange(list.map((item, index) => require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item), {}, { sortIndex: index })));
		}
	}, ({ item, index, style, props, attributes, setActivatorNodeRef, listeners }) => {
		return /* @__PURE__ */ react.default.createElement(DragItem, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, props), {}, {
			isLock: item.fixed,
			index,
			attributes,
			setActivatorNodeRef,
			listeners,
			style
		}), /* @__PURE__ */ react.default.createElement("div", { className: `${prefix}table-action-column-drag-item-right` }, /* @__PURE__ */ react.default.createElement("span", { className: (0, classnames.default)(`${prefix}table-action-column-drag-item-right-text`, { [`${prefix}table-action-column-drag-item-right-text-hidden`]: !item.isShow }) }, item.titleString || item.title), /* @__PURE__ */ react.default.createElement("div", null, /* @__PURE__ */ react.default.createElement("span", {
			className: `${prefix}table-action-column-drag-item-right-icon-wrap`,
			onClick: () => {
				handleChange(index, !item.isShow);
			}
		}, item.isShow ? /* @__PURE__ */ react.default.createElement(_ant_design_icons.EyeOutlined, null) : /* @__PURE__ */ react.default.createElement(_ant_design_icons.EyeInvisibleOutlined, null)))));
	})));
};
//#endregion
exports.default = PopoverContent;
