"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));

var _palette = _interopRequireDefault(require("./palette.json"));

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

var color = function color(target) {
  var name = target;
  var hue;

  if (typeof target !== 'string') {
    var _target = (0, _slicedToArray2["default"])(target, 2);

    name = _target[0];
    hue = _target[1];
  }

  var hex = _palette["default"][name];

  if (!hex) {
    var keys = JSON.stringify(Object.keys(_palette["default"]));
    throw new Error("Color \"".concat(name, "\" is not a known color. Try: ").concat(keys));
  }

  if (typeof hex === 'string') {
    return hex;
  }

  return hex[hue];
};

var _default = _objectSpread({}, _palette["default"], {
  color: color
});

exports["default"] = _default;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL2xpYi90aGVtZS9wYWxldHRlLmpzIl0sIm5hbWVzIjpbImNvbG9yIiwidGFyZ2V0IiwibmFtZSIsImh1ZSIsImhleCIsIlBhbGV0dGUiLCJrZXlzIiwiSlNPTiIsInN0cmluZ2lm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