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/saleDetail/components/Client/ClientDetailCard.tsx
var ClientDetailCard_exports = {};
__export(ClientDetailCard_exports, {
  ClientDetailCard: () => ClientDetailCard
});
module.exports = __toCommonJS(ClientDetailCard_exports);
var import_classnames = __toESM(require("classnames"));
var import_react = __toESM(require("react"));
var import_antd = require("antd");
var import_materials = require("@pisell/materials");
var import_utils = require("@pisell/utils");
var import_responsive = require("../../../../responsive");
var import_useEngineContext = __toESM(require("../../../../hooks/useEngineContext"));
var import_utils2 = require("../../utils");
var import_useClientSelectorProps = require("./hooks/useClientSelectorProps");
var import_utils3 = require("./utils");
var import_ClientDetailCard = require("./ClientDetailCard.less");
var PREFIX = "pisell-sale-detail-client-detail-card";
var EMPTY_TEXT = "-";
function getAvatarText(name) {
  const text = name.split(/\s+/).filter(Boolean).map((item) => item[0]).join("").slice(0, 2).toUpperCase();
  return text || "U";
}
function ClientDetailCardBase({
  className,
  context,
  variant
}) {
  var _a, _b;
  const currentVariant = variant || "desktop";
  const engineContext = (0, import_useEngineContext.default)();
  const translationOriginal = (_b = (_a = engineContext.appHelper) == null ? void 0 : _a.utils) == null ? void 0 : _b.translationOriginal;
  const { selectedCustomer } = (0, import_useClientSelectorProps.useClientSelectorProps)({
    context,
    readOnly: true,
    variant
  });
  const clientName = (0, import_react.useMemo)(
    () => (0, import_utils3.getClientDisplayName)(selectedCustomer) || EMPTY_TEXT,
    [selectedCustomer]
  );
  const phone = (0, import_react.useMemo)(
    () => (0, import_utils3.getClientPhone)(selectedCustomer) || EMPTY_TEXT,
    [selectedCustomer]
  );
  const email = (0, import_react.useMemo)(
    () => (0, import_utils3.getClientEmail)(selectedCustomer) || EMPTY_TEXT,
    [selectedCustomer]
  );
  const memberTag = (0, import_react.useMemo)(() => {
    var _a2, _b2;
    const walletName = (_b2 = (_a2 = selectedCustomer == null ? void 0 : selectedCustomer.latest_wallet_detail) == null ? void 0 : _a2.wallet) == null ? void 0 : _b2.name;
    return walletName ? (translationOriginal == null ? void 0 : translationOriginal(walletName)) || walletName : EMPTY_TEXT;
  }, [selectedCustomer, translationOriginal]);
  const note = (0, import_react.useMemo)(
    () => String((selectedCustomer == null ? void 0 : selectedCustomer.note) || "").trim() || EMPTY_TEXT,
    [selectedCustomer]
  );
  const createdAt = (0, import_react.useMemo)(
    () => (0, import_utils2.formatLocalizedDateTime)(selectedCustomer == null ? void 0 : selectedCustomer.created_at, EMPTY_TEXT),
    [selectedCustomer]
  );
  const avatarSrc = (selectedCustomer == null ? void 0 : selectedCustomer.avatar) || (selectedCustomer == null ? void 0 : selectedCustomer.cover);
  const handleDetailClick = (0, import_react.useCallback)(() => {
  }, []);
  return /* @__PURE__ */ import_react.default.createElement(
    "section",
    {
      className: (0, import_classnames.default)(PREFIX, `${PREFIX}--${currentVariant}`, className)
    },
    /* @__PURE__ */ import_react.default.createElement("div", { className: `${PREFIX}__profile` }, /* @__PURE__ */ import_react.default.createElement(
      import_materials.PisellAvatar,
      {
        className: `${PREFIX}__avatar`,
        src: avatarSrc,
        size: "lg",
        shape: "square",
        borderRadius: 10,
        useTextAvatar: true
      },
      getAvatarText(clientName)
    ), /* @__PURE__ */ import_react.default.createElement("div", { className: `${PREFIX}__identity` }, /* @__PURE__ */ import_react.default.createElement("div", { className: `${PREFIX}__name` }, clientName), /* @__PURE__ */ import_react.default.createElement("div", { className: `${PREFIX}__meta` }, /* @__PURE__ */ import_react.default.createElement("span", null, phone), /* @__PURE__ */ import_react.default.createElement("span", null, email)))),
    /* @__PURE__ */ import_react.default.createElement("dl", { className: `${PREFIX}__details` }, /* @__PURE__ */ import_react.default.createElement("div", { className: `${PREFIX}__field` }, /* @__PURE__ */ import_react.default.createElement("dt", null, import_utils.locales.getText("pisell2.sale-detail.member-tag")), /* @__PURE__ */ import_react.default.createElement("dd", null, memberTag === EMPTY_TEXT ? EMPTY_TEXT : import_react.default.createElement(
      import_antd.Tag,
      {
        className: `${PREFIX}__member-tag`,
        color: "gold"
      },
      memberTag
    ))), /* @__PURE__ */ import_react.default.createElement("div", { className: `${PREFIX}__field` }, /* @__PURE__ */ import_react.default.createElement("dt", null, import_utils.locales.getText("pisell2.sale-detail.created-at")), /* @__PURE__ */ import_react.default.createElement("dd", null, createdAt)))
  );
}
ClientDetailCardBase.displayName = "ClientDetailCard";
var ClientDetailCard = (0, import_responsive.withResponsive)(ClientDetailCardBase);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  ClientDetailCard
});
