"use strict";

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

var _interpreter = _interopRequireDefault(require("../utils/interpreter"));

var _decisionTreeContainer = _interopRequireDefault(require("./decisionTreeContainer"));

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

var _tree = _interopRequireDefault(require("./tree"));

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

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

var DecisionTree = function DecisionTree(_ref) {
  var data = _ref.data,
      edgeType = _ref.edgeType,
      position = _ref.position,
      scale = _ref.scale,
      selectedNode = _ref.selectedNode,
      updateFoldedNodes = _ref.updateFoldedNodes,
      updateSelectedNode = _ref.updateSelectedNode,
      updatePositionAndZoom = _ref.updatePositionAndZoom,
      foldedNodes = _ref.foldedNodes,
      style = _ref.style;
  var interpreter = (0, _react.useMemo)(function () {
    return (0, _interpreter.default)(data, Object.keys(data.trees)[0]);
  }, [data]);
  return _react.default.createElement(_decisionTreeContainer.default, {
    style: style
  }, function (_ref2) {
    var height = _ref2.height,
        width = _ref2.width;
    return _react.default.createElement(_tree.default, {
      interpreter: interpreter,
      updateSelectedNode: updateSelectedNode,
      updateFoldedNodes: updateFoldedNodes,
      height: height,
      width: width,
      position: position,
      scale: scale,
      updatePositionAndZoom: updatePositionAndZoom,
      configuration: data.configuration,
      dt: interpreter.dt,
      edgeType: edgeType,
      selectedNode: selectedNode,
      foldedNodes: foldedNodes
    });
  });
};

DecisionTree.defaultProps = {
  position: [0, 0],
  scale: -1,
  updatePositionAndZoom: null,
  auto: false,
  updateSelectedNode: undefined,
  updateFoldedNodes: undefined,
  edgeType: 'constant',
  selectedNode: ''
};
DecisionTree.propTypes = {
  scale: _propTypes.default.number,
  position: _propTypes.default.array,
  updateSelectedNode: _propTypes.default.func,
  updateFoldedNodes: _propTypes.default.func,
  data: _propTypes.default.object.isRequired,
  updatePositionAndZoom: _propTypes.default.func,
  edgeType: _propTypes.default.string,
  selectedNode: _propTypes.default.string,
  foldedNodes: _propTypes.default.arrayOf(_propTypes.default.string),
  style: _propTypes.default.object
};
var _default = DecisionTree;
exports.default = _default;