"use strict";

require("core-js/modules/es.object.define-property.js");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.splitName = exports.getNameColor = void 0;
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
require("core-js/modules/es.error.to-string.js");
require("core-js/modules/es.array.join.js");
require("core-js/modules/es.array.slice.js");
require("core-js/modules/es.date.to-string.js");
require("core-js/modules/es.object.to-string.js");
require("core-js/modules/es.parse-int.js");
require("core-js/modules/es.regexp.exec.js");
require("core-js/modules/es.regexp.test.js");
require("core-js/modules/es.regexp.to-string.js");
var _toUpper = _interopRequireDefault(require("lodash/toUpper"));
var nameColorPalette = ['#4262FF', '#0081A7', '#F07167', '#6FCFA3', '#758BFD', '#B388EB', '#ACA885', '#70A9A1'];
var getNameColor = exports.getNameColor = function getNameColor(userName) {
  if (!userName) return nameColorPalette[0];
  var arr = [];
  for (var i = 0; i < userName.length; i++) {
    arr[i] = userName.charCodeAt(i).toString(16).slice(-4);
  }
  var arrSlice = arr.join('').slice(0, 8);
  return nameColorPalette[parseInt(arrSlice, 16) % nameColorPalette.length];
};
var splitName = exports.splitName = function splitName() {
  var userName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  var names = userName.split(' ');
  var _names = (0, _slicedToArray2["default"])(names, 1),
    firstWord = _names[0];
  var lastWord = names[names.length - 1];
  var firstLetter = firstWord.split('')[0];
  var secondLetter = names.length > 1 ? lastWord.split('')[0] : lastWord.length > 1 ? lastWord.split('')[1] : '';
  return filterChineseWord([(0, _toUpper["default"])(firstLetter), (0, _toUpper["default"])(secondLetter)]);
};
var filterChineseWord = function filterChineseWord(word) {
  var reg = /[\u4e00-\u9fa5]/;
  if (reg.test(word[1])) {
    return [word[0], ''];
  }
  return word;
};