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/clientCard/line/index.tsx
var line_exports = {};
__export(line_exports, {
  default: () => line_default
});
module.exports = __toCommonJS(line_exports);
var import_react = __toESM(require("react"));
var import_classnames = __toESM(require("classnames"));
var import_antd = require("antd");
var import_materials = require("@pisell/materials");
var import_clientName = __toESM(require("../../clientName"));
var import_utils = require("../utils");
var import_index = require("./index.less");
var import_clientCard = require("../../clientCard");
var LineCard = ({
  dataSource,
  isShowName,
  isShowAvatar = true,
  isShowPhone = true,
  isShowEmail = true,
  isShowStatus = false,
  // 样式配置
  style: customStyle = {},
  horizontalGap,
  // 头像配置
  avatar = {},
  status = {},
  // 姓名样式
  nameStyle = {},
  // 标签配置
  tags = [],
  tag = {},
  // 插槽
  slots,
  // 事件回调
  onViewClient
}) => {
  const contactText = (0, import_react.useMemo)(() => {
    if (!dataSource) return "";
    const { phone, email } = dataSource;
    if (isShowPhone && phone) return phone;
    if (isShowEmail && email) return email;
    return "";
  }, [dataSource, isShowPhone, isShowEmail]);
  const renderAvatar = () => {
    if (!isShowAvatar || !dataSource) return null;
    const {
      icon,
      shape = "circle",
      borderRadius = 4,
      size = "sm",
      useTextAvatar = false,
      children
    } = avatar;
    const avatarProps = {
      shape,
      size,
      className: `${import_clientCard.PREFIX}__avatar`
    };
    if (shape === "square") {
      avatarProps.style = { borderRadius };
    }
    const statusIndicator = isShowStatus && /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        className: `${import_clientCard.PREFIX}__status-indicator`,
        style: {
          backgroundColor: status.color || "#17B26A"
        }
      }
    );
    if (useTextAvatar) {
      const text = children || (0, import_utils.getAvatarText)(dataSource.display_name || dataSource.nickname || "");
      return /* @__PURE__ */ import_react.default.createElement("div", { className: `${import_clientCard.PREFIX}__avatar-wrapper` }, /* @__PURE__ */ import_react.default.createElement(import_materials.PisellAvatar, { ...avatarProps }, text), statusIndicator);
    }
    if (icon) {
      return /* @__PURE__ */ import_react.default.createElement("div", { className: `${import_clientCard.PREFIX}__avatar-wrapper` }, /* @__PURE__ */ import_react.default.createElement(import_materials.PisellAvatar, { ...avatarProps, icon }), statusIndicator);
    }
    return /* @__PURE__ */ import_react.default.createElement("div", { className: `${import_clientCard.PREFIX}__avatar-wrapper` }, /* @__PURE__ */ import_react.default.createElement(import_materials.PisellAvatar, { ...avatarProps, src: dataSource.cover }), statusIndicator);
  };
  const renderTags = () => {
    const tagsToShow = tags.length > 0 ? tags : (dataSource == null ? void 0 : dataSource.tags) || [];
    if (!tagsToShow.length) return null;
    const { gap = 6, flexWrap = "nowrap" } = tag;
    return /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        className: `${import_clientCard.PREFIX}__tags ${import_clientCard.PREFIX}__tags--line`,
        style: { gap, flexWrap }
      },
      tagsToShow.map((tagItem, index) => {
        const content = typeof tagItem === "string" ? tagItem : tagItem.children || tagItem.label;
        const tagProps = {
          key: index,
          color: typeof tagItem === "object" ? tagItem.color : void 0,
          className: `${import_clientCard.PREFIX}__tag`
        };
        return /* @__PURE__ */ import_react.default.createElement(import_antd.Tag, { ...tagProps }, content);
      })
    );
  };
  const cardStyle = {
    ...customStyle,
    gap: horizontalGap
  };
  return /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: (0, import_classnames.default)(import_clientCard.PREFIX, `${import_clientCard.PREFIX}--line`),
      style: cardStyle,
      ...{ onClick: () => dataSource && (onViewClient == null ? void 0 : onViewClient(dataSource)) }
    },
    slots == null ? void 0 : slots.top,
    /* @__PURE__ */ import_react.default.createElement("div", { className: `${import_clientCard.PREFIX}__content` }, (slots == null ? void 0 : slots.left) && /* @__PURE__ */ import_react.default.createElement("div", { className: `${import_clientCard.PREFIX}__slot-left` }, slots == null ? void 0 : slots.left), renderAvatar(), isShowName && /* @__PURE__ */ import_react.default.createElement(
      import_clientName.default,
      {
        dataSource,
        style: nameStyle,
        className: "pisell-client-card__name--line"
      }
    ), contactText && /* @__PURE__ */ import_react.default.createElement("div", { className: `${import_clientCard.PREFIX}__contact ${import_clientCard.PREFIX}__contact--line` }, contactText), renderTags(), (slots == null ? void 0 : slots.right) && /* @__PURE__ */ import_react.default.createElement("div", { className: `${import_clientCard.PREFIX}__slot-right` }, slots == null ? void 0 : slots.right)),
    slots == null ? void 0 : slots.bottom
  );
};
var line_default = LineCard;
