"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

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

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));

var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));

var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));

var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));

var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

var _react = _interopRequireDefault(require("react"));

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

var _classnames = _interopRequireDefault(require("classnames"));

var _plot = require("../../../../plot");

var _coordinatesLabel = _interopRequireDefault(require("../../../coordinates-label"));

var _reactDom = _interopRequireDefault(require("react-dom"));

var _utils = require("../../../utils");

var _excluded = ["classes", "className", "coordinatesOnHover", "x", "y", "disabled", "correctness", "graphProps", "labelNode", "style"];

function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }

function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }

var RawBp = /*#__PURE__*/function (_React$Component) {
  (0, _inherits2["default"])(RawBp, _React$Component);

  var _super = _createSuper(RawBp);

  function RawBp(props) {
    var _this;

    (0, _classCallCheck2["default"])(this, RawBp);
    _this = _super.call(this, props);
    _this.state = {
      showCoordinates: false
    };
    return _this;
  }

  (0, _createClass2["default"])(RawBp, [{
    key: "render",
    value: function render() {
      var _this2 = this;

      var _this$props = this.props,
          classes = _this$props.classes,
          className = _this$props.className,
          coordinatesOnHover = _this$props.coordinatesOnHover,
          x = _this$props.x,
          y = _this$props.y,
          disabled = _this$props.disabled,
          correctness = _this$props.correctness,
          graphProps = _this$props.graphProps,
          labelNode = _this$props.labelNode,
          style = _this$props.style,
          rest = (0, _objectWithoutProperties2["default"])(_this$props, _excluded);
      var showCoordinates = this.state.showCoordinates;
      var scale = graphProps.scale;
      var r = (0, _utils.thinnerShapesNeeded)(graphProps) ? 5 : 7;
      return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("circle", (0, _extends2["default"])({
        style: {
          fill: 'transparent',
          cursor: 'pointer',
          pointerEvents: 'all'
        },
        r: r * 3,
        cx: scale.x(x),
        cy: scale.y(y),
        onMouseEnter: function onMouseEnter() {
          return _this2.setState({
            showCoordinates: true
          });
        },
        onMouseLeave: function onMouseLeave() {
          return _this2.setState({
            showCoordinates: false
          });
        }
      }, rest)), /*#__PURE__*/_react["default"].createElement("g", (0, _extends2["default"])({
        className: (0, _classnames["default"])(classes.point, disabled && classes.disabled, classes[correctness], className),
        onMouseEnter: function onMouseEnter() {
          return _this2.setState({
            showCoordinates: true
          });
        },
        onMouseLeave: function onMouseLeave() {
          return _this2.setState({
            showCoordinates: false
          });
        }
      }, rest), /*#__PURE__*/_react["default"].createElement("circle", (0, _extends2["default"])({}, rest, {
        r: r,
        cx: scale.x(x),
        cy: scale.y(y)
      })), labelNode && coordinatesOnHover && showCoordinates && /*#__PURE__*/_reactDom["default"].createPortal( /*#__PURE__*/_react["default"].createElement(_coordinatesLabel["default"], {
        graphProps: graphProps,
        x: x,
        y: y
      }), labelNode)));
    }
  }]);
  return RawBp;
}(_react["default"].Component);

exports.RawBp = RawBp;
(0, _defineProperty2["default"])(RawBp, "propTypes", {
  classes: _propTypes["default"].object,
  className: _propTypes["default"].string,
  coordinatesOnHover: _propTypes["default"].bool,
  correctness: _propTypes["default"].string,
  disabled: _propTypes["default"].bool,
  labelNode: _propTypes["default"].object,
  x: _propTypes["default"].number,
  y: _propTypes["default"].number,
  graphProps: _plot.types.GraphPropsType.isRequired
});
//# sourceMappingURL=base-point.js.map