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/plus/selectHolder/components/HolderItem/index.tsx
var HolderItem_exports = {};
__export(HolderItem_exports, {
  PREFIX: () => PREFIX,
  default: () => HolderItem_default
});
module.exports = __toCommonJS(HolderItem_exports);
var import_react = __toESM(require("react"));
var import_materials = require("@pisell/materials");
var import_utils = require("../../utils");
var import_index = require("./index.less");
var PREFIX = "pisell-lowcode-holder-item";
var HolderItem = ({
  item,
  displayConfig,
  value,
  isAddItem
}) => {
  const {
    showAvatar = true,
    showTitle = true,
    showSubtitle = false,
    selectType = "single",
    direction = "vertical",
    showExtraFields = false,
    extraFields = []
  } = displayConfig || {};
  const isSelected = (0, import_react.useMemo)(() => {
    if (!(value == null ? void 0 : value.length) || !(item == null ? void 0 : item.value)) return false;
    return value.includes(item.value);
  }, [value, item == null ? void 0 : item.value]);
  const extraFieldsCom = (0, import_react.useMemo)(() => {
    if (!showExtraFields || !(extraFields == null ? void 0 : extraFields.length)) return null;
    return extraFields.map((field) => {
      return /* @__PURE__ */ import_react.default.createElement("div", { className: `${PREFIX}-extra-field` }, (field == null ? void 0 : field.isShowLabel) && /* @__PURE__ */ import_react.default.createElement("span", { className: `${PREFIX}-extra-field-label` }, field.label, ":"), (field == null ? void 0 : field.isShowValue) && (field == null ? void 0 : field.value) && /* @__PURE__ */ import_react.default.createElement("span", { className: `${PREFIX}-extra-field-value` }, item == null ? void 0 : item[field.value]));
    });
  }, [showExtraFields, extraFields, item]);
  return /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: `${PREFIX}-wrap ${isSelected ? `${PREFIX}-wrap-selected` : ""}`
    },
    /* @__PURE__ */ import_react.default.createElement(import_materials.PisellCard, { padding: 20, selected: isSelected }, /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        className: `${PREFIX}-card ${direction === "horizontal" ? `${PREFIX}-card-horizontal` : ""}`
      },
      showAvatar ? /* @__PURE__ */ import_react.default.createElement(
        import_materials.PisellAvatar,
        {
          src: item == null ? void 0 : item.avatar,
          useTextAvatar: !(item == null ? void 0 : item.avatar) && !isAddItem,
          className: `${isAddItem ? `${PREFIX}-add-avatar` : ""}`,
          size: "xxl"
        },
        (0, import_utils.getAvatarText)(item.label)
      ) : null,
      (showTitle || showSubtitle) && /* @__PURE__ */ import_react.default.createElement("div", { className: `${PREFIX}-info` }, showTitle && /* @__PURE__ */ import_react.default.createElement("span", { className: `${PREFIX}-name` }, item.label), showSubtitle && item.subtitle && /* @__PURE__ */ import_react.default.createElement("span", { className: `${PREFIX}-subtitle` }, item.subtitle), extraFieldsCom),
      selectType === "multiple" && /* @__PURE__ */ import_react.default.createElement(
        "div",
        {
          className: `${PREFIX}-check-icon ${isSelected ? `${PREFIX}-check-icon-selected` : ""}`
        },
        /* @__PURE__ */ import_react.default.createElement(import_materials.Icon, { type: "CheckCircleFilled" })
      )
    ))
  );
};
var HolderItem_default = HolderItem;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  PREFIX
});
