"use strict";

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

var _propTypes = _interopRequireDefault(require("prop-types"));

var _core = require("@emotion/core");

var _shortid = _interopRequireDefault(require("shortid"));

var _index = require("../_Themes/index");

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

function _templateObject3() {
  var data = _taggedTemplateLiteral(["\n                margin-left: 5px;\n              "]);

  _templateObject3 = function _templateObject3() {
    return data;
  };

  return data;
}

function _templateObject2() {
  var data = _taggedTemplateLiteral(["\n              margin-left: 10px;\n            "]);

  _templateObject2 = function _templateObject2() {
    return data;
  };

  return data;
}

function _templateObject() {
  var data = _taggedTemplateLiteral(["\n    font-family: \"Roboto Condensed\", \"Helvetica Neue\", Helvetica, sans-serif;\n    font-size: 14px;\n    font-weight: bold;\n    text-align: center;\n    margin: 10px 0 0 0;\n\n    @media (max-width: 640px) {\n      text-align: left;\n    }\n  "]);

  _templateObject = function _templateObject() {
    return data;
  };

  return data;
}

function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }

var SimpleLegend = function SimpleLegend(_ref) {
  var colorScale = _ref.colorScale,
      legendData = _ref.legendData,
      theme = _ref.theme;
  var legendStyle = (0, _core.css)(_templateObject());
  var colorMap = colorScale || theme.group.colorScale;

  if (legendData.length) {
    return (0, _core.jsx)("div", {
      css: legendStyle
    }, legendData.map(function (group, idx) {
      return (0, _core.jsx)("span", {
        key: _shortid["default"].generate(),
        css: (0, _core.css)(_templateObject2())
      }, (0, _core.jsx)("svg", {
        viewBox: "0 0 10 10",
        width: "10px"
      }, (0, _core.jsx)("circle", {
        cx: "5",
        cy: "5",
        r: "5",
        fill: colorMap[idx]
      })), (0, _core.jsx)("span", {
        css: (0, _core.css)(_templateObject3())
      }, group.name));
    }));
  }

  return null;
};

SimpleLegend.propTypes = {
  colorScale: _propTypes["default"].arrayOf(_propTypes["default"].string),
  legendData: _propTypes["default"].arrayOf(_propTypes["default"].shape({
    name: _propTypes["default"].string
  })),
  theme: _propTypes["default"].shape({})
};
SimpleLegend.defaultProps = {
  colorScale: null,
  legendData: null,
  theme: _index.VictoryTheme
};
var _default = SimpleLegend;
exports["default"] = _default;