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/pisellSelectCustomerModal/CustomerCard/index.tsx
var CustomerCard_exports = {};
__export(CustomerCard_exports, {
  default: () => CustomerCard_default
});
module.exports = __toCommonJS(CustomerCard_exports);
var import_react = __toESM(require("react"));
var import_antd = require("antd");
var import_PlusCircle = __toESM(require("@pisell/icon/es/PlusCircle"));
var import_XCircle = __toESM(require("@pisell/icon/es/XCircle"));
var import_utils = require("@pisell/utils");
var import_index = require("./index.less");
var import_classnames = __toESM(require("classnames"));
var CustomerCard = ({
  onClickItem,
  customer,
  showIcon = true,
  customIcon,
  onRemove,
  className
}) => {
  const username = (0, import_react.useMemo)(() => {
    if (!customer) {
      return "Walk-in";
    }
    const firstLastName = customer.first_name || customer.last_name ? `${customer.first_name} ${customer.last_name}` : "";
    return customer.name || (customer.display_name || "").trim() || (customer.nickname || "").trim() || firstLastName.trim() || "";
  }, [customer]);
  const getAvatarName = (0, import_react.useMemo)(() => {
    if (!username) return "";
    const parts = username.trim().split(/\s+/);
    if (parts.length === 1) {
      return parts[0].charAt(0);
    }
    return parts[0].charAt(0) + parts[1].charAt(0);
  }, [username]);
  return /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: (0, import_classnames.default)("pisell-lowcode__customer_card", className),
      onClick: () => {
        onClickItem(customer);
      }
    },
    /* @__PURE__ */ import_react.default.createElement(
      import_antd.Avatar,
      {
        className: "pisell-lowcode__customer_card-avatar",
        src: (customer == null ? void 0 : customer.cover) ? import_utils.image.ali(customer == null ? void 0 : customer.cover, 100) : void 0
      },
      getAvatarName
    ),
    /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__customer_card-info" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__customer_card-info-left" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__customer_card-info-name" }, username), !customer ? /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__customer_card-info-desc" }, import_utils.locales.getText("pisell2.text.leave-empty-for-walk-in")) : /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, (customer == null ? void 0 : customer.email) ? /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__customer_card-info-email" }, customer == null ? void 0 : customer.email) : null, (customer == null ? void 0 : customer.phone) ? /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__customer_card-info-phone" }, customer == null ? void 0 : customer.phone) : null)), showIcon ? /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        className: "pisell-lowcode__customer_card-info-right",
        onClick: (e) => {
          if (!customer) {
            return;
          }
          e.preventDefault();
          e.stopPropagation();
          onRemove == null ? void 0 : onRemove();
        }
      },
      customIcon ? customIcon : customer ? /* @__PURE__ */ import_react.default.createElement(import_XCircle.default, { className: "pisell-lowcode__customer_card-add-icon" }) : /* @__PURE__ */ import_react.default.createElement(import_PlusCircle.default, { className: "pisell-lowcode__customer_card-add-icon" })
    ) : null)
  );
};
var CustomerCard_default = CustomerCard;
