import React, { useMemo } from "react";
import { locales } from "@pisell/utils";
import classNames from "classnames";
import "./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 = 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.createElement("section", { className: classNames("pisell-sale-detail-contact", className) }, /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}__title` }, locales.getText("pisell2.sale-detail.contact-info")), /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}__card` }, /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}__row` }, /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}__content-main` }, /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}__content` }, isEmpty ? /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}__empty-description` }, locales.getText("pisell2.sale-detail.add-contact-info")) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}__name-line` }, displayName ? /* @__PURE__ */ React.createElement("span", { className: `${PREFIX}__name` }, displayName) : null, phone ? /* @__PURE__ */ React.createElement("span", { className: `${PREFIX}__phone` }, "(", phone, ")") : null), contact.email ? /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}__text` }, contact.email) : null))))));
}
//#endregion
export { Contact };
