const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_index = require("../../clientName/index.js");
const require_utils = require("../utils.js");
const require_index$1 = require("../index.js");
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
let _pisell_materials = require("@pisell/materials");
let classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
require("./index.less");
//#region src/plus/clientCard/line/index.tsx
/**
* 客户卡片组件 - 行内布局
* 所有信息在一行展示：头像、客户名、联系方式（电话优先于邮箱）、标签
*/
const LineCard = ({ dataSource, isShowName, isShowAvatar = true, isShowPhone = true, isShowEmail = true, isShowStatus = false, style: customStyle = {}, horizontalGap, avatar = {}, status = {}, nameStyle = {}, tags = [], tag = {}, slots, onViewClient }) => {
	const contactText = (0, 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: `${require_index$1.PREFIX}__avatar`
		};
		if (shape === "square") avatarProps.style = { borderRadius };
		const statusIndicator = isShowStatus && /* @__PURE__ */ react.default.createElement("div", {
			className: `pisell-client-card__status-indicator`,
			style: { backgroundColor: status.color || "#17B26A" }
		});
		if (useTextAvatar) {
			const text = children || require_utils.getAvatarText(dataSource.display_name || dataSource.nickname || "");
			return /* @__PURE__ */ react.default.createElement("div", { className: `${require_index$1.PREFIX}__avatar-wrapper` }, /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellAvatar, avatarProps, text), statusIndicator);
		}
		if (icon) return /* @__PURE__ */ react.default.createElement("div", { className: `${require_index$1.PREFIX}__avatar-wrapper` }, /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellAvatar, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, avatarProps), {}, { icon })), statusIndicator);
		return /* @__PURE__ */ react.default.createElement("div", { className: `${require_index$1.PREFIX}__avatar-wrapper` }, /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellAvatar, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, avatarProps), {}, { src: dataSource.cover })), statusIndicator);
	};
	const renderTags = () => {
		const tagsToShow = tags.length > 0 ? tags : (dataSource === null || dataSource === void 0 ? void 0 : dataSource.tags) || [];
		if (!tagsToShow.length) return null;
		const { gap = 6, flexWrap = "nowrap" } = tag;
		return /* @__PURE__ */ react.default.createElement("div", {
			className: `${require_index$1.PREFIX}__tags ${require_index$1.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: `${require_index$1.PREFIX}__tag`
			};
			return /* @__PURE__ */ react.default.createElement(antd.Tag, tagProps, content);
		}));
	};
	const cardStyle = require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, customStyle), {}, { gap: horizontalGap });
	return /* @__PURE__ */ react.default.createElement("div", require_objectSpread2._objectSpread2({
		className: (0, classnames.default)(require_index$1.PREFIX, `${require_index$1.PREFIX}--line`),
		style: cardStyle
	}, { onClick: () => dataSource && (onViewClient === null || onViewClient === void 0 ? void 0 : onViewClient(dataSource)) }), slots === null || slots === void 0 ? void 0 : slots.top, /* @__PURE__ */ react.default.createElement("div", { className: `${require_index$1.PREFIX}__content` }, (slots === null || slots === void 0 ? void 0 : slots.left) && /* @__PURE__ */ react.default.createElement("div", { className: `pisell-client-card__slot-left` }, slots === null || slots === void 0 ? void 0 : slots.left), renderAvatar(), isShowName && /* @__PURE__ */ react.default.createElement(require_index.default, {
		dataSource,
		style: nameStyle,
		className: "pisell-client-card__name--line"
	}), contactText && /* @__PURE__ */ react.default.createElement("div", { className: `pisell-client-card__contact pisell-client-card__contact--line` }, contactText), renderTags(), (slots === null || slots === void 0 ? void 0 : slots.right) && /* @__PURE__ */ react.default.createElement("div", { className: `pisell-client-card__slot-right` }, slots === null || slots === void 0 ? void 0 : slots.right)), slots === null || slots === void 0 ? void 0 : slots.bottom);
};
//#endregion
exports.default = LineCard;
