import React from 'react';
import { Typography, Button, Space } from 'antd';
import { MailOutlined } from '@ant-design/icons';
import { handleEmailClick, hideEmailDomain, maskEmailDomain } from "../utils";
/**
 * PisellEmail 只读态视图组件
 * 
 * 职责：
 * - 渲染只读态邮箱地址展示
 * - 支持点击唤起邮件客户端（mailto）
 * - 支持域名隐藏/脱敏（partial/full 模式）
 * - 支持邮件图标按钮
 * 
 * @param props 组件 Props
 */
var ReadOnlyView = function ReadOnlyView(props) {
  var _props$value = props.value,
    value = _props$value === void 0 ? '' : _props$value,
    _props$displayAsLink = props.displayAsLink,
    displayAsLink = _props$displayAsLink === void 0 ? true : _props$displayAsLink,
    _props$enableMailto = props.enableMailto,
    enableMailto = _props$enableMailto === void 0 ? true : _props$enableMailto,
    _props$showEmailIcon = props.showEmailIcon,
    showEmailIcon = _props$showEmailIcon === void 0 ? false : _props$showEmailIcon,
    _props$hideDomain = props.hideDomain,
    hideDomain = _props$hideDomain === void 0 ? false : _props$hideDomain,
    _props$maskPattern = props.maskPattern,
    maskPattern = _props$maskPattern === void 0 ? 'partial' : _props$maskPattern,
    mailtoOptions = props.mailtoOptions,
    _props$fontSize = props.fontSize,
    fontSize = _props$fontSize === void 0 ? 16 : _props$fontSize,
    _props$fontWeight = props.fontWeight,
    fontWeight = _props$fontWeight === void 0 ? 500 : _props$fontWeight,
    _props$color = props.color,
    color = _props$color === void 0 ? '#101828' : _props$color,
    _props$linkColor = props.linkColor,
    linkColor = _props$linkColor === void 0 ? '#7F56DA' : _props$linkColor,
    onMailto = props.onMailto;

  // 处理域名隐藏/脱敏
  var displayEmail = hideDomain ? maskPattern === 'full' ? maskEmailDomain(value) : hideEmailDomain(value) : value;

  // 邮件发送处理
  var handleMailto = function handleMailto() {
    if (enableMailto && value) {
      onMailto === null || onMailto === void 0 || onMailto(value);
      handleEmailClick(value, mailtoOptions);
    }
  };
  var canMailto = enableMailto && !!value;
  var 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: fontSize,
      fontWeight: fontWeight,
      color: linkColor
    },
    "aria-label": props['aria-label'],
    "aria-describedby": props['aria-describedby']
  }, displayEmail) : /*#__PURE__*/React.createElement(Typography.Text, {
    style: {
      fontSize: fontSize,
      fontWeight: fontWeight,
      color: 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": "\u53D1\u9001\u90AE\u4EF6"
  })));
};
export default ReadOnlyView;