'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var _getClassName2 = require('babel-plugin-react-css-modules/dist/browser/getClassName');

var _getClassName3 = _interopRequireDefault(_getClassName2);

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _classnames = require('classnames');

var _classnames2 = _interopRequireDefault(_classnames);

var _warning = require('warning');

var _warning2 = _interopRequireDefault(_warning);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

var _styleModuleImportMap = {
  './background.scss': {
    'background-color-none': 'flive_background_background-color-none',
    'background-color-white': 'flive_background_background-color-white',
    'background-color-xx-light-grey': 'flive_background_background-color-xx-light-grey',
    'background-color-x-light-grey': 'flive_background_background-color-x-light-grey',
    'background-color-light-grey': 'flive_background_background-color-light-grey',
    'background-color-medium-light-grey': 'flive_background_background-color-medium-light-grey',
    'background-color-grey': 'flive_background_background-color-grey',
    'background-color-medium-dark-grey': 'flive_background_background-color-medium-dark-grey',
    'background-color-dark-grey': 'flive_background_background-color-dark-grey',
    'background-color-black-grey': 'flive_background_background-color-black-grey',
    'background-color-night-blue': 'flive_background_background-color-night-blue',
    'background-color-blue': 'flive_background_background-color-blue',
    'box-shadow': 'flive_background_box-shadow',
    'border-color-white': 'flive_background_border-color-white',
    'border-color-xx-light-grey': 'flive_background_border-color-xx-light-grey',
    'border-color-x-light-grey': 'flive_background_border-color-x-light-grey',
    'border-color-light-grey': 'flive_background_border-color-light-grey',
    'border-color-medium-light-grey': 'flive_background_border-color-medium-light-grey',
    'border-color-grey': 'flive_background_border-color-grey',
    'border-color-medium-dark-grey': 'flive_background_border-color-medium-dark-grey',
    'border-color-dark-grey': 'flive_background_border-color-dark-grey',
    'border-color-black-grey': 'flive_background_border-color-black-grey',
    'border-color-night-blue': 'flive_background_border-color-night-blue',
    'border-color-blue': 'flive_background_border-color-blue',
    'color-white': 'flive_background_color-white',
    'color-xx-light-grey': 'flive_background_color-xx-light-grey',
    'color-x-light-grey': 'flive_background_color-x-light-grey',
    'color-light-grey': 'flive_background_color-light-grey',
    'color-medium-light-grey': 'flive_background_color-medium-light-grey',
    'color-grey': 'flive_background_color-grey',
    'color-medium-dark-grey': 'flive_background_color-medium-dark-grey',
    'color-dark-grey': 'flive_background_color-dark-grey',
    'color-black-grey': 'flive_background_color-black-grey',
    'color-night-blue': 'flive_background_color-night-blue',
    'color-blue': 'flive_background_color-blue',
    'old-background-none': 'flive_background_old-background-none',
    'old-background-white': 'flive_background_old-background-white',
    'old-background-grey-medium': 'flive_background_old-background-grey-medium',
    'old-background-grey-light': 'flive_background_old-background-grey-light',
    'old-background-night-blue': 'flive_background_old-background-night-blue',
    'old-background-blue': 'flive_background_old-background-blue',
    'old-border-grey': 'flive_background_old-border-grey',
    'old-border-grey-light': 'flive_background_old-border-grey-light',
    'old-border-night-blue': 'flive_background_old-border-night-blue',
    'old-border-blue': 'flive_background_old-border-blue'
  }
};

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }

var colors = ['none', 'white', 'xx-light-grey', 'x-light-grey', 'light-grey', 'medium-light-grey', 'grey', 'medium-dark-grey', 'dark-grey', 'black-grey'];

var propTypes = {
  /** @ignore */
  className: _propTypes2.default.string,
  /** @deprecated use backgroundColor instead */
  background: _propTypes2.default.oneOf(['none', 'white', 'grey-medium', 'grey-light']),
  backgroundColor: _propTypes2.default.oneOf(colors),
  /** @deprecated use borderColor instead */
  border: _propTypes2.default.oneOf(['grey', 'grey-light', 'night-blue']),
  borderColor: _propTypes2.default.oneOf(colors),
  color: _propTypes2.default.oneOf(colors),
  /** A component, h1, h2, h3, a, react router Link, etc... */
  component: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.object, _propTypes2.default.func]),
  boxShadow: _propTypes2.default.bool
};

var defaultProps = {
  className: undefined,
  background: null,
  backgroundColor: 'none',
  border: null,
  borderColor: null,
  color: null,
  component: 'div',
  boxShadow: false
};

var Background = function Background(_ref) {
  var _classNames;

  var className = _ref.className,
      MyComponent = _ref.component,
      boxShadow = _ref.boxShadow,
      background = _ref.background,
      backgroundColor = _ref.backgroundColor,
      border = _ref.border,
      borderColor = _ref.borderColor,
      color = _ref.color,
      props = _objectWithoutProperties(_ref, ['className', 'component', 'boxShadow', 'background', 'backgroundColor', 'border', 'borderColor', 'color']);

  if (background || border) {
    (0, _warning2.default)(false, 'Border and background props deprecated');
  }
  return _react2.default.createElement(MyComponent, _extends({}, props, {
    className: (className ? className + ' ' : '') + (0, _getClassName3.default)((0, _classnames2.default)((_classNames = {}, _defineProperty(_classNames, 'old-background-' + background, background), _defineProperty(_classNames, 'old-border-' + border, border), _defineProperty(_classNames, 'background-color-' + backgroundColor, backgroundColor), _defineProperty(_classNames, 'border-color-' + borderColor, borderColor), _defineProperty(_classNames, 'color-' + color, color), _defineProperty(_classNames, 'box-shadow', boxShadow), _classNames)), _styleModuleImportMap)
  }));
};

Background.propTypes = propTypes;
Background.defaultProps = defaultProps;

exports.default = Background;
module.exports = exports['default'];