const require_runtime = require("../../../../_virtual/_rolldown/runtime.js");
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_utils = require("@pisell/utils");
let classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
require("./index.less");
//#region src/plus/saleDetail/components/Contact/index.tsx
const PREFIX = "pisell-sale-detail-contact";
function normalizeContactInfo(value) {
	if (!value || Array.isArray(value) || typeof value !== "object") return null;
	if (!Object.keys(value).length) return null;
	return value;
}
function Contact({ dataSource, className }) {
	var _contact$phone;
	const contact = (0, react.useMemo)(() => normalizeContactInfo(dataSource), [dataSource]);
	if (!contact) return null;
	const displayName = contact.display_name || [contact.first_name, contact.last_name].filter(Boolean).join(" ");
	const phone = ((_contact$phone = contact.phone) === null || _contact$phone === void 0 ? void 0 : _contact$phone.phone) ? `${contact.phone.country_calling_code || ""} ${contact.phone.phone}`.trim() : "";
	const isEmpty = !displayName && !phone && !contact.email;
	return /* @__PURE__ */ react.default.createElement("section", { className: (0, classnames.default)("pisell-sale-detail-contact", className) }, /* @__PURE__ */ react.default.createElement("div", { className: `${PREFIX}__title` }, _pisell_utils.locales.getText("pisell2.sale-detail.contact-info")), /* @__PURE__ */ react.default.createElement("div", { className: `${PREFIX}__card` }, /* @__PURE__ */ react.default.createElement("div", { className: `${PREFIX}__row` }, /* @__PURE__ */ react.default.createElement("div", { className: `${PREFIX}__content-main` }, /* @__PURE__ */ react.default.createElement("div", { className: `${PREFIX}__content` }, isEmpty ? /* @__PURE__ */ react.default.createElement("div", { className: `${PREFIX}__empty-description` }, _pisell_utils.locales.getText("pisell2.sale-detail.add-contact-info")) : /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement("div", { className: `${PREFIX}__name-line` }, displayName ? /* @__PURE__ */ react.default.createElement("span", { className: `${PREFIX}__name` }, displayName) : null, phone ? /* @__PURE__ */ react.default.createElement("span", { className: `${PREFIX}__phone` }, "(", phone, ")") : null), contact.email ? /* @__PURE__ */ react.default.createElement("div", { className: `${PREFIX}__text` }, contact.email) : null))))));
}
//#endregion
exports.Contact = Contact;
