const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
let _pisell_utils = require("@pisell/utils");
let _pisell_icon_es_PlusCircle = require("@pisell/icon/es/PlusCircle");
_pisell_icon_es_PlusCircle = require_runtime.__toESM(_pisell_icon_es_PlusCircle);
let classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
let _pisell_icon_es_XCircle = require("@pisell/icon/es/XCircle");
_pisell_icon_es_XCircle = require_runtime.__toESM(_pisell_icon_es_XCircle);
require("./index.less");
//#region src/components/pisellSelectCustomerModal/CustomerCard/index.tsx
const CustomerCard = ({ onClickItem, customer, showIcon = true, customIcon, onRemove, className }) => {
	const username = (0, 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, 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__ */ react.default.createElement("div", {
		className: (0, classnames.default)("pisell-lowcode__customer_card", className),
		onClick: () => {
			onClickItem(customer);
		}
	}, /* @__PURE__ */ react.default.createElement(antd.Avatar, {
		className: "pisell-lowcode__customer_card-avatar",
		src: (customer === null || customer === void 0 ? void 0 : customer.cover) ? _pisell_utils.image.ali(customer === null || customer === void 0 ? void 0 : customer.cover, 100) : void 0
	}, getAvatarName), /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode__customer_card-info" }, /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode__customer_card-info-left" }, /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode__customer_card-info-name" }, username), !customer ? /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode__customer_card-info-desc" }, _pisell_utils.locales.getText("pisell2.text.leave-empty-for-walk-in")) : /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, (customer === null || customer === void 0 ? void 0 : customer.email) ? /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode__customer_card-info-email" }, customer === null || customer === void 0 ? void 0 : customer.email) : null, (customer === null || customer === void 0 ? void 0 : customer.phone) ? /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode__customer_card-info-phone" }, customer === null || customer === void 0 ? void 0 : customer.phone) : null)), showIcon ? /* @__PURE__ */ react.default.createElement("div", {
		className: "pisell-lowcode__customer_card-info-right",
		onClick: (e) => {
			if (!customer) return;
			e.preventDefault();
			e.stopPropagation();
			onRemove === null || onRemove === void 0 || onRemove();
		}
	}, customIcon ? customIcon : customer ? /* @__PURE__ */ react.default.createElement(_pisell_icon_es_XCircle.default, { className: "pisell-lowcode__customer_card-add-icon" }) : /* @__PURE__ */ react.default.createElement(_pisell_icon_es_PlusCircle.default, { className: "pisell-lowcode__customer_card-add-icon" })) : null));
};
//#endregion
exports.default = CustomerCard;
