import "core-js/modules/es6.number.constructor";
import _Object$assign from "@babel/runtime-corejs2/core-js/object/assign";
import _inheritsLoose from "../../../inheritsLoose";
import _defineProperty from "@babel/runtime-corejs2/helpers/defineProperty";
import { DLayout } from './layout';
import mx from '../mxgraph';
var mxRadialTreeLayout = mx.mxRadialTreeLayout;
export var DRadialLayout =
/*#__PURE__*/
function (_DLayout) {
  _inheritsLoose(DRadialLayout, _DLayout);

  function DRadialLayout() {
    return _DLayout.apply(this, arguments) || this;
  }

  var _proto = DRadialLayout.prototype;

  _proto.defaults = function defaults() {
    return _Object$assign({}, _DLayout.prototype.defaults.call(this), {
      levelDistance: 60,
      nodeDistance: 16,
      rootx: 0,
      rooty: 0
    });
  };

  _proto._getLayout = function _getLayout(graph) {
    var _this$get = this.get(),
        type = _this$get.type,
        levelDistance = _this$get.levelDistance,
        nodeDistance = _this$get.nodeDistance;

    var layout = new mxRadialTreeLayout(graph);
    layout.autoRadius = true;
    layout.nodeDistance = +nodeDistance;
    layout.levelDistance = +levelDistance; // layout.useBoundingBox = false;

    layout.edgeRouting = false;
    return layout;
  };

  _proto._execute = function _execute(layout, cells, parent, graph) {
    if (!cells.length) return;
    var roots = graph.findTreeRoots(parent.cell);
    var tmp = cells[0];

    if (roots && roots.length) {
      tmp = roots[0];
    }

    var _this$get2 = this.get(),
        rootx = _this$get2.rootx,
        rooty = _this$get2.rooty;

    var geo = tmp.getGeometry().clone();
    if (rootx != null) geo.x = +rootx;
    if (rooty != null) geo.y = +rooty;
    graph.model.setGeometry(tmp, geo);
    layout.execute(parent.cell, tmp);
  };

  return DRadialLayout;
}(DLayout);

_defineProperty(DRadialLayout, "displayName", 'DRadialLayout');

_defineProperty(DRadialLayout, "propTypes", _Object$assign({}, DLayout.propTypes, {
  levelDistance: [Number, String],
  nodeDistance: [Number, String],
  rootx: [Number, String],
  rooty: [Number, String]
}));