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) } })); }

import PropTypes from "prop-types";
import { jsx, css } from "@emotion/core";
import { get } from "lodash";
import window from "global/window";
var tooltip = css(_templateObject());

var MapTooltip = function MapTooltip(props) {
  var tooltipInfo = props.tooltipInfo,
      x = props.x,
      y = props.y,
      formatPrimaryField = props.formatPrimaryField,
      formatSecondaryField = props.formatSecondaryField,
      primaryName = props.primaryName,
      primaryField = props.primaryField,
      secondaryName = props.secondaryName,
      secondaryField = props.secondaryField,
      isHex = props.isHex;
  var xPosition = x < get(window, "innerWidth", 1000) * 0.66 ? x : x - get(window, "innerWidth", 1000) * 0.1;
  var yPostition = y < 375 ? y : y - 50;

  var getProperty = function getProperty(property, formatFunction) {
    if (formatFunction) {
      return formatFunction(property);
    }

    return property;
  };

  return jsx("div", {
    css: tooltip,
    style: {
      left: xPosition,
      top: yPostition
    }
  }, primaryName && jsx("div", null, "".concat(primaryName, ": ").concat(getProperty(tooltipInfo.properties[primaryField], formatPrimaryField))), secondaryName && jsx("div", null, "".concat(secondaryName, ": ").concat(getProperty(tooltipInfo.properties[secondaryField], formatSecondaryField))), isHex && jsx("div", null, jsx("div", null, "elevation: ", tooltipInfo.elevationValue), jsx("div", null, "coordinates: ", tooltipInfo.centroid.join(", "))));
};

MapTooltip.propTypes = {
  tooltipInfo: PropTypes.shape({}),
  x: PropTypes.number,
  y: PropTypes.number,
  formatPrimaryField: PropTypes.func,
  formatSecondaryField: PropTypes.func,
  primaryName: PropTypes.string,
  primaryField: PropTypes.string,
  secondaryName: PropTypes.string,
  secondaryField: PropTypes.string,
  isHex: PropTypes.bool
};
MapTooltip.defaultProps = {
  formatPrimaryField: null,
  formatSecondaryField: null
};
export default MapTooltip;