"use strict";

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

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

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

var _deck = _interopRequireWildcard(require("deck.gl"));

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }

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

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

var ScatterPlotMap = function ScatterPlotMap(props) {
  var stroked = props.stroked,
      getLineWidth = props.getLineWidth,
      getFillColor = props.getFillColor,
      getLineColor = props.getLineColor,
      viewport = props.viewport,
      data = props.data,
      getPosition = props.getPosition,
      opacity = props.opacity,
      getRadius = props.getRadius,
      radiusScale = props.radiusScale,
      autoHighlight = props.autoHighlight,
      highlightColor = props.highlightColor,
      onLayerClick = props.onLayerClick,
      visible = props.visible,
      tooltipInfo = props.tooltipInfo,
      x = props.x,
      y = props.y,
      onHover = props.onHover,
      children = props.children;

  var tooltip = _react["default"].Children.map(children, function (child) {
    return _react["default"].cloneElement(child, {
      tooltipInfo: tooltipInfo,
      x: x,
      y: y
    });
  });

  var tooltipRender = tooltipInfo && x && y ? tooltip : null;
  return _react["default"].createElement("div", null, _react["default"].createElement(_deck["default"], _extends({
    className: "DeckGL"
  }, viewport, {
    getCursor: function getCursor() {
      return "crosshair";
    }
  }), _react["default"].createElement(_deck.ScatterplotLayer, {
    className: "ScatterPlotMap",
    id: "scatterplot-layer",
    pickable: true,
    data: data,
    getPosition: getPosition,
    opacity: opacity,
    getRadius: getRadius,
    radiusScale: radiusScale,
    radiusMinPixels: 1,
    autoHighlight: autoHighlight,
    highlightColor: highlightColor,
    onClick: onLayerClick,
    parameters: {
      depthTest: false
    },
    visible: visible,
    onHover: onHover,
    stroked: stroked,
    getLineColor: getLineColor,
    getLineWidth: getLineWidth,
    getFillColor: getFillColor,
    updateTriggers: {
      getRadius: getRadius
    }
  })), tooltipRender);
};

ScatterPlotMap.propTypes = {
  viewport: _propTypes["default"].shape({}),
  data: _propTypes["default"].arrayOf(_propTypes["default"].shape({})).isRequired,
  getPosition: _propTypes["default"].func,
  opacity: _propTypes["default"].number,
  getRadius: _propTypes["default"].func,
  radiusScale: _propTypes["default"].number,
  autoHighlight: _propTypes["default"].bool,
  highlightColor: _propTypes["default"].arrayOf(_propTypes["default"].number),
  onLayerClick: _propTypes["default"].func,
  visible: _propTypes["default"].bool,
  tooltipInfo: _propTypes["default"].shape({}),
  x: _propTypes["default"].number,
  y: _propTypes["default"].number,
  onHover: _propTypes["default"].func,
  children: _propTypes["default"].node,
  stroked: _propTypes["default"].bool,
  getLineColor: _propTypes["default"].oneOfType([_propTypes["default"].func, _propTypes["default"].array]),
  getLineWidth: _propTypes["default"].oneOfType([_propTypes["default"].func, _propTypes["default"].number]),
  getFillColor: _propTypes["default"].oneOfType([_propTypes["default"].func, _propTypes["default"].array])
};
ScatterPlotMap.defaultProps = {
  getPosition: function getPosition(d) {
    return d.geometry.coordinates;
  },
  opacity: 0.8,
  getRadius: function getRadius() {
    return 50;
  },
  radiusScale: 1,
  visible: true,
  highlightColor: [0, 255, 0, 255],
  stroked: false,
  getLineColor: function getLineColor() {
    return [0, 0, 0];
  },
  getLineWidth: function getLineWidth() {
    return 1;
  },
  getFillColor: function getFillColor() {
    return [0, 0, 0];
  }
};
var _default = ScatterPlotMap;
exports["default"] = _default;