'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
var ColorLuminance = function ColorLuminance(hex, lum) {
  if (typeof hex === 'undefined' || !hex) {
    return false;
  }

  // Validate hex string
  hex = String(hex).replace(/[^0-9a-f]/gi, '');
  if (hex.length < 3) {
    return false;
  }
  if (hex.length < 6) {
    hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
  }
  lum = lum || 0;

  var rgb = "#",
      c = void 0,
      i = void 0;

  for (i = 0; i < 3; i++) {
    c = parseInt(hex.substr(i * 2, 2), 16);
    c = Math.round(Math.min(Math.max(0, c + c * lum), 255)).toString(16);
    rgb += ("00" + c).substr(c.length);
  }

  return rgb;
};

exports.default = ColorLuminance;