import { handleEmailClick, hideEmailDomain, maskEmailDomain } from "../utils/emailHelper.js";
import React from "react";
import { Button, Space, Typography } from "antd";
import { MailOutlined } from "@ant-design/icons";
//#region src/components/pisellEmail/components/ReadOnlyView.tsx
/**
* PisellEmail 只读态视图组件
* 
* 职责：
* - 渲染只读态邮箱地址展示
* - 支持点击唤起邮件客户端（mailto）
* - 支持域名隐藏/脱敏（partial/full 模式）
* - 支持邮件图标按钮
* 
* @param props 组件 Props
*/
const ReadOnlyView = (props) => {
	const { value = "", displayAsLink = true, enableMailto = true, showEmailIcon = false, hideDomain = false, maskPattern = "partial", mailtoOptions, fontSize = 16, fontWeight = 500, color = "#101828", linkColor = "#7F56DA", onMailto } = props;
	const displayEmail = hideDomain ? maskPattern === "full" ? maskEmailDomain(value) : hideEmailDomain(value) : value;
	const handleMailto = () => {
		if (enableMailto && value) {
			onMailto === null || onMailto === void 0 || onMailto(value);
			handleEmailClick(value, mailtoOptions);
		}
	};
	const canMailto = enableMailto && !!value;
	const showAsLink = displayAsLink && canMailto;
	return /* @__PURE__ */ React.createElement("div", { className: "pisell-email-read" }, /* @__PURE__ */ React.createElement(Space, { size: "small" }, showAsLink ? /* @__PURE__ */ React.createElement(Typography.Link, {
		onClick: handleMailto,
		style: {
			fontSize,
			fontWeight,
			color: linkColor
		},
		"aria-label": props["aria-label"],
		"aria-describedby": props["aria-describedby"]
	}, displayEmail) : /* @__PURE__ */ React.createElement(Typography.Text, {
		style: {
			fontSize,
			fontWeight,
			color
		},
		"aria-label": props["aria-label"],
		"aria-describedby": props["aria-describedby"]
	}, displayEmail), showEmailIcon && canMailto && /* @__PURE__ */ React.createElement(Button, {
		type: "link",
		size: "small",
		icon: /* @__PURE__ */ React.createElement(MailOutlined, null),
		onClick: handleMailto,
		"aria-label": "发送邮件"
	})));
};
//#endregion
export { ReadOnlyView as default };
