"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _default = function _default(color) {
  var n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  // 16进制颜色值的正则
  var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
  // 把颜色值变成小写
  var newColor = color.toLowerCase();
  if (reg.test(newColor)) {
    // 如果只有三位的值，需变成六位，如：#fff => #ffffff
    if (newColor.length === 4) {
      var colorNew = '#';
      for (var i = 1; i < 4; i += 1) {
        colorNew += newColor.slice(i, i + 1).concat(newColor.slice(i, i + 1));
      }
      newColor = colorNew;
    }
    // 处理六位的颜色值，转为RGB
    var colorChange = [];
    for (var _i = 1; _i < 7; _i += 2) {
      colorChange.push(parseInt("0x".concat(newColor.slice(_i, _i + 2))));
    }
    var _rgb = "rgba(".concat(colorChange.join(','), ",").concat(n, ")");
    return _rgb;
  } else {
    return newColor;
  }
};
exports["default"] = _default;
//# sourceMappingURL=transformRgb.js.map
