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/eventBooking/components/selectHolder/index.tsx
var selectHolder_exports = {};
__export(selectHolder_exports, {
  default: () => selectHolder_default
});
module.exports = __toCommonJS(selectHolder_exports);
var import_react = __toESM(require("react"));
var import_materials = require("@pisell/materials");
var import_utils = require("@pisell/utils");
var import_ErrorTip = __toESM(require("../ErrorTip"));
var import_mock = require("../../mock");
var import_index = require("./index.less");
var PisellSelectHolder = ({
  open = false,
  onCancel,
  onOk,
  onClick,
  onAdd,
  options = import_mock.mock.holder || [],
  value,
  title,
  okText,
  showCancel,
  disabled,
  errorTipText
}) => {
  const [errorTip, setErrorTip] = (0, import_react.useState)();
  (0, import_react.useEffect)(() => {
    if (open && !disabled) {
      setErrorTip("");
    }
  }, [open, disabled]);
  const renderCard = (item) => {
    return /* @__PURE__ */ import_react.default.createElement(import_materials.PisellCard, { key: item.id, padding: 20, selected: value == item.id }, /* @__PURE__ */ import_react.default.createElement("div", { className: "select-holder-card" }, /* @__PURE__ */ import_react.default.createElement(import_materials.PisellAvatar, { src: item.avatar, size: "xxl" }), /* @__PURE__ */ import_react.default.createElement("span", { className: "select-holder-name" }, item.name)));
  };
  const renderAddItem = () => {
    return /* @__PURE__ */ import_react.default.createElement(import_materials.PisellCard, { padding: 20 }, /* @__PURE__ */ import_react.default.createElement("div", { className: `select-holder-card select-holder-add-card` }, /* @__PURE__ */ import_react.default.createElement(import_materials.PisellAvatar, { size: "xxl", className: "select-holder-card-avatar" }), /* @__PURE__ */ import_react.default.createElement("span", { className: "select-holder-name" }, import_utils.locales.getText("pisell2.event.create"))));
  };
  return /* @__PURE__ */ import_react.default.createElement(
    import_materials.PisellModal,
    {
      open,
      title: (0, import_utils.isMobile)() ? "" : title,
      platform: (0, import_utils.isMobile)() ? "h5" : "pc",
      okText,
      cancelVisible: false,
      closable: showCancel,
      onCancel,
      onOk: (e) => {
        if (disabled) {
          return setErrorTip(errorTipText);
        }
        onOk && onOk(e);
      },
      bodyStyle: { padding: (0, import_utils.isMobile)() ? "0 16px 16px" : 20 },
      mobileModalHeight: "auto",
      destroyOnClose: true,
      className: `select-holder-modal ${(0, import_utils.isMobile)() ? "select-holder-modal-mobile" : ""}`,
      headerDivider: false
    },
    (0, import_utils.isMobile)() ? /* @__PURE__ */ import_react.default.createElement("div", { className: "select-holder-modal-title" }, title) : null,
    errorTip ? /* @__PURE__ */ import_react.default.createElement(import_ErrorTip.default, { text: errorTip }) : null,
    /* @__PURE__ */ import_react.default.createElement(
      import_materials.PisellCustomCheckboxGroup,
      {
        dataSource: options,
        renderItem: renderCard,
        renderAddItem,
        columns: (0, import_utils.isMobile)() ? 2 : 3,
        horizontalGap: 16,
        verticalGap: 16,
        allowAdd: true,
        onClick: (e) => onClick && onClick(e)
      }
    )
  );
};
var selectHolder_default = PisellSelectHolder;
