import React from 'react';
import { parsePhoneNumberFromString as parsePhoneNumber } from 'libphonenumber-js';
import classNames from 'classnames';
import "./ReadPretty.less";
var ReadPretty = function ReadPretty(_ref) {
  var value = _ref.value,
    renderMode = _ref.renderMode;
  if (!value) return null;
  var className = classNames('pisell-phone-read-pretty', {
    'pisell-phone-read-pretty-table-view': renderMode === 'tableView'
  });
  try {
    var phoneNumber = parsePhoneNumber(value);
    if (!phoneNumber) return /*#__PURE__*/React.createElement("span", {
      className: className
    }, value);
    var formattedValue = "(".concat(phoneNumber.formatInternational().split(' ')[0], ") ").concat(phoneNumber.formatNational());
    return /*#__PURE__*/React.createElement("span", {
      className: className
    }, formattedValue);
  } catch (error) {
    // 如果解析失败，直接显示原始值
    return /*#__PURE__*/React.createElement("span", {
      className: className
    }, value);
  }
};
export default ReadPretty;