"use strict";

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

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

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

var _lodash = require("lodash");

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

var _window = _interopRequireDefault(require("global/window"));

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

function _templateObject() {
  var data = _taggedTemplateLiteral(["\n  font-family: Helvetica, Arial, sans-serif;\n  font-size: 14px;\n  position: absolute;\n  padding: 4px;\n  margin: 8px;\n  background: rgba(0, 0, 0, 0.75);\n  color: #ffffff;\n  max-width: 250px;\n  z-index: 9;\n  pointer-events: none;\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 tooltip = (0, _core.css)(_templateObject());

var MapTooltip = function MapTooltip(props) {
  var tooltipData = props.tooltipData;
  var x = tooltipData.x;
  var y = tooltipData.y;
  var xPosition = x < (0, _lodash.get)(_window["default"], "innerWidth", 1000) * 0.66 ? x : x - (0, _lodash.get)(_window["default"], "innerWidth", 1000) * 0.1;
  var yPostition = y < 375 ? y : y - 50;
  var tooltipContent = tooltipData.content.map(function (obj) {
    var value = obj.value ? obj.value : "No Data Available";
    return (0, _core.jsx)("div", {
      key: _shortid["default"].generate()
    }, "".concat(obj.name, ": ").concat(value.toLocaleString()));
  });
  return (0, _core.jsx)("div", {
    css: tooltip,
    style: {
      left: xPosition,
      top: yPostition
    }
  }, tooltipContent);
};

MapTooltip.propTypes = {
  tooltipData: (0, _propTypes.shape)({
    x: _propTypes.number,
    y: _propTypes.number,
    content: (0, _propTypes.arrayOf)((0, _propTypes.shape)({
      name: _propTypes.string,
      value: (0, _propTypes.oneOfType)([_propTypes.number, _propTypes.string])
    }))
  })
};
var _default = MapTooltip;
exports["default"] = _default;