'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

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

var _propTypes2 = _interopRequireDefault(_propTypes);

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

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

var ToolTip = function ToolTip(props) {
  var visibility = 'hidden';
  var transform = '';
  var x = 0;
  var y = 0;
  var width = 150;
  var height = 40;
  var transformArrow = '';
  var transformText = 'translate(' + width / 2 + ', ' + (height / 2 - 5) + ')';

  if (props.tooltip.display === true) {
    var position = props.tooltip.pos;
    x = position.x;
    y = position.y;
    visibility = 'visible';
    if (y < height) {
      transform = 'translate(' + (x - width / 2) + ', ' + (y - height - 20) + ')';
      transformArrow = 'translate(' + (width / 2 - 20) + ', ' + (height - 2) + ')';
    } else if (y < height) {
      transform = 'translate(' + (x - width / 2) + ', ' + (Math.round(y) + 20) + ')';
      transformArrow = 'translate(' + (width / 2 - 20) + ', 0) rotate(180, 20, 0)';
    }
  } else {
    visibility = 'hidden';
  }
  return _react2.default.createElement(
    'g',
    { transform: transform },
    _react2.default.createElement('polygon', {
      className: 'shadow',
      points: '10,0  30,0  20,10',
      transform: transformArrow,
      fill: '#ffffff',
      opacity: '1',
      stroke: '#A676B2',
      strokeWidth: '1px',
      visibility: visibility
    }),
    _react2.default.createElement('rect', {
      className: 'shadow',
      width: width,
      height: height,
      rx: '0',
      ry: '0',
      visibility: visibility,
      fill: '#ffffff',
      stroke: '#A676B2',
      strokeWidth: '1px'
    }),
    _react2.default.createElement(
      'g',
      { visibility: visibility, transform: transformText },
      props.children
    )
  );
};

ToolTip.propTypes = {
  tooltip: _propTypes2.default.object,
  children: _propTypes2.default.node
};

exports.default = ToolTip;
//# sourceMappingURL=ToolTip.js.map