import { _objectSpread2 } from "../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
import { _objectWithoutProperties } from "../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectWithoutProperties.js";
import Button from "../../../button/index.js";
import icon_default from "../../../icon/index.js";
import React from "react";
import classNames from "classnames";
import DotsSix from "@pisell/icon/es/DotsSix";
import "./index.less";
//#region src/components/pisellDropSort/components/SortableItem/index.tsx
const _excluded = [
	"item",
	"depth",
	"clone",
	"ghost",
	"indicator",
	"disableSelection",
	"disableInteraction",
	"wrapperRef",
	"style",
	"onCollapse",
	"onRemove",
	"childCount",
	"indentationWidth",
	"handleProps",
	"collapsed",
	"isError"
];
const SortableItem = (props) => {
	const { itemProps, render, domRef, allowAddChild, allowDelete, allowDrag, allowIsShow, disabled, onAdd, onDelete, showBorder, spacing, maxLevel, __designMode, isCustomAction, getItemStyle } = props;
	const { item, depth, clone, ghost, indicator, disableSelection, disableInteraction, wrapperRef, style, onCollapse, onRemove, childCount, indentationWidth, handleProps, collapsed, isError } = itemProps, otherProps = _objectWithoutProperties(itemProps, _excluded);
	const mergedStyle = _objectSpread2(_objectSpread2({}, (getItemStyle === null || getItemStyle === void 0 ? void 0 : getItemStyle(itemProps)) || {}), style);
	if (isError) mergedStyle.backgroundColor = "#FECDCA";
	return /* @__PURE__ */ React.createElement("li", _objectSpread2({
		className: classNames("pisell-lowcode-drop-sort-item", clone && "clone", ghost && "ghost", indicator && "indicator", disableSelection && "disableSelection", disableInteraction && "disableInteraction"),
		ref: wrapperRef,
		style: { "--spacing": `${indentationWidth * depth}px` }
	}, otherProps), /* @__PURE__ */ React.createElement("div", {
		className: classNames("pisell-lowcode-drop-sort-item-tree-item", {
			"pisell-lowcode-drop-sort-item-tree-item-border": showBorder,
			disabled
		}),
		ref: domRef,
		style: mergedStyle
	}, allowDrag && !disabled && /* @__PURE__ */ React.createElement(Button, _objectSpread2({
		icon: /* @__PURE__ */ React.createElement(DotsSix, { className: "pisell-lowcode-drop-sort-item-drag-handle-icon" }),
		type: "text",
		className: "pisell-lowcode-drop-sort-item-button"
	}, __designMode === "design" ? {} : _objectSpread2({}, handleProps))), onCollapse && /* @__PURE__ */ React.createElement(Button, {
		icon: /* @__PURE__ */ React.createElement(icon_default, {
			type: "pisell2-chevron-down",
			className: "pisell-lowcode-drop-sort-item-icon"
		}),
		onClick: onCollapse,
		type: "text",
		className: classNames("Collapse", collapsed && "collapsed", "pisell-lowcode-drop-sort-item-button")
	}), /* @__PURE__ */ React.createElement("div", { className: "pisell-lowcode-drop-sort-item-content" }, render && render(itemProps)), !isCustomAction && /* @__PURE__ */ React.createElement(React.Fragment, null, !clone && allowAddChild && !disabled && /* @__PURE__ */ React.createElement(Button, {
		icon: /* @__PURE__ */ React.createElement(icon_default, {
			type: "pisell2-plus",
			className: "pisell-lowcode-drop-sort-item-icon"
		}),
		onClick: () => onAdd === null || onAdd === void 0 ? void 0 : onAdd(itemProps),
		type: "text",
		className: "pisell-lowcode-drop-sort-item-button"
	}), !clone && allowDelete && !disabled && /* @__PURE__ */ React.createElement(Button, {
		icon: /* @__PURE__ */ React.createElement(icon_default, {
			type: "pisell2-trash-01",
			className: "pisell-lowcode-drop-sort-item-icon"
		}),
		onClick: () => onDelete === null || onDelete === void 0 ? void 0 : onDelete(itemProps),
		type: "text",
		className: "pisell-lowcode-drop-sort-item-button"
	})), clone && childCount && childCount > 1 ? /* @__PURE__ */ React.createElement("span", { className: "pisell-lowcode-drop-sort-item-count" }, childCount) : null));
};
//#endregion
export { SortableItem as default };
