var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/pisellDropSort/PisellDropSort.tsx
var PisellDropSort_exports = {};
__export(PisellDropSort_exports, {
  default: () => PisellDropSort_default
});
module.exports = __toCommonJS(PisellDropSort_exports);
var import_react = __toESM(require("react"));
var import_icons = require("@ant-design/icons");
var import_classnames = __toESM(require("classnames"));
var import_button = __toESM(require("../button"));
var import_SortableItem = __toESM(require("./components/SortableItem"));
var import_pisellDraggable = require("../pisellDraggable");
var import_PisellDropSort = require("./PisellDropSort.less");
var import_locales = require("../../locales");
var PisellDropSort = ({
  value = [],
  allowDrag = true,
  allowDelete = true,
  allowAddChild = true,
  allowAddRoot = true,
  allowIsShow = false,
  disabled = false,
  spacing = 8,
  maxLevel = 3,
  showBorder = true,
  style,
  className,
  onChange,
  onDelete,
  onAdd,
  renderItem: propsRenderItem,
  leftContent,
  rightContent,
  onAddRoot,
  __designMode,
  isCustomAction,
  emptyContent,
  getItemStyle,
  canDrop,
  indentationWidth
}) => {
  const renderItem = (0, import_react.useCallback)(
    (itemProps, ref) => {
      return /* @__PURE__ */ import_react.default.createElement(
        import_SortableItem.default,
        {
          itemProps,
          domRef: ref,
          render: propsRenderItem,
          allowAddChild,
          allowDelete,
          allowDrag,
          allowIsShow,
          disabled,
          onAdd,
          onDelete,
          showBorder,
          spacing,
          maxLevel,
          __designMode,
          isCustomAction,
          getItemStyle
        }
      );
    },
    [
      allowAddChild,
      allowDelete,
      allowDrag,
      value,
      disabled,
      maxLevel,
      onAdd,
      onDelete,
      showBorder,
      spacing,
      isCustomAction
    ]
  );
  const handleChange = (0, import_react.useCallback)(
    (items) => {
      onChange == null ? void 0 : onChange(items);
    },
    [onChange]
  );
  const containerClassName = (0, import_classnames.default)(
    "pisell-lowcode-drop-sort-container",
    className
  );
  return /* @__PURE__ */ import_react.default.createElement("div", { className: containerClassName, style }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode-drop-sort-container-header" }, /* @__PURE__ */ import_react.default.createElement("span", null, leftContent), /* @__PURE__ */ import_react.default.createElement("span", null, rightContent || allowAddRoot && !disabled && /* @__PURE__ */ import_react.default.createElement(
    import_button.default,
    {
      icon: /* @__PURE__ */ import_react.default.createElement(import_icons.PlusOutlined, null),
      type: "primary",
      onClick: () => onAddRoot == null ? void 0 : onAddRoot(),
      size: "large"
    },
    (0, import_locales.getText)("pisell-lowcode-drop-sort-add")
  ))), /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: "pisell-lowcode-drop-sort-container-content",
      style: { gap: spacing ?? 8 }
    },
    value.length === 0 && emptyContent ? emptyContent : /* @__PURE__ */ import_react.default.createElement(
      import_pisellDraggable.SortableTree,
      {
        value,
        collapsible: true,
        indicator: false,
        indentationWidth,
        removable: allowDelete,
        renderItem,
        onChange: handleChange,
        canDrop,
        maxLevel
      }
    )
  ));
};
var PisellDropSort_default = PisellDropSort;
