import React from 'react';
import { Typography } from 'antd';
import classNames from 'classnames';
import "./ReadPretty.less";
var Link = Typography.Link;

// 格式化 url 确保包含协议前缀
export var formatUrl = function formatUrl(url) {
  if (!url) return '';

  // 如果已经包含协议前缀，直接返回
  if (url.startsWith('http://') || url.startsWith('https://')) {
    return url;
  }

  // 默认添加 https:// 前缀
  return "https://".concat(url);
};
var UrlReadPretty = function UrlReadPretty(props) {
  var value = props.value,
    renderMode = props.renderMode;
  var formattedUrl = formatUrl(value);
  return /*#__PURE__*/React.createElement(Link, {
    className: classNames('pisell-url-read-pretty', {
      'pisell-url-read-pretty-table-view': renderMode === 'tableView'
    }),
    href: formattedUrl,
    target: "_blank"
  }, value);
};
export default UrlReadPretty;