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    max-width: ", ";\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 MapTooltip = function MapTooltip(props) {
  var x = props.x,
      y = props.y,
      formatPrimaryField = props.formatPrimaryField,
      formatSecondaryField = props.formatSecondaryField,
      isHex = props.isHex,
      primaryName = props.primaryName,
      primaryField = props.primaryField,
      secondaryName = props.secondaryName,
      secondaryField = props.secondaryField,
      tooltipDataArray = props.tooltipDataArray,
      tooltipInfo = props.tooltipInfo,
      wide = props.wide;
  var tooltip = css(_templateObject(), wide ? "400px" : "250px");
  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, jsx("strong", null, "".concat(primaryName, ": ")), getProperty(tooltipInfo.properties[primaryField], formatPrimaryField)), secondaryName && jsx("div", null, jsx("strong", null, "".concat(secondaryName, ": ")), getProperty(tooltipInfo.properties[secondaryField], formatSecondaryField)), tooltipDataArray.map(function (el) {
    return jsx("div", {
      key: el.name
    }, jsx("strong", null, "".concat(el.name, ": ")), getProperty(tooltipInfo.properties[el.field], el.formatField));
  }), 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,
  tooltipDataArray: PropTypes.arrayOf(PropTypes.shape({
    name: PropTypes.string.isRequired,
    field: PropTypes.string.isRequired,
    formatField: PropTypes.func
  })),
  isHex: PropTypes.bool,
  wide: PropTypes.bool
};
MapTooltip.defaultProps = {
  formatPrimaryField: null,
  formatSecondaryField: null,
  tooltipDataArray: [],
  wide: false
};
export default MapTooltip;