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 mxHierarchicalLayout = mx.mxHierarchicalLayout,
    mxConstants = mx.mxConstants;
export var DFlowLayout =
/*#__PURE__*/
function (_DLayout) {
  _inheritsLoose(DFlowLayout, _DLayout);

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

  var _proto = DFlowLayout.prototype;

  _proto.defaults = function defaults() {
    return _Object$assign({}, _DLayout.prototype.defaults.call(this), {
      type: 'horizontal',
      // The spacing buffer added between cells on the same layer.
      intraCellSpacing: 30,
      // The spacing buffer between unconnected hierarchies.
      interHierarchySpacing: 30,
      // The spacing buffer added between cell on adjacent layers.
      interRankCellSpacing: 50,
      // parallelEdgeSpacing: 10,
      resizeParent: false,
      // The border to be added around the children if the parent is to be resized using resizeParent.
      parentBorder: 0
    });
  };

  _proto._getLayout = function _getLayout(graph) {
    var _this$get = this.get(),
        type = _this$get.type,
        interHierarchySpacing = _this$get.interHierarchySpacing,
        interRankCellSpacing = _this$get.interRankCellSpacing,
        intraCellSpacing = _this$get.intraCellSpacing,
        resizeParent = _this$get.resizeParent,
        parentBorder = _this$get.parentBorder;

    var direction = type === 'horizontal' ? mxConstants.DIRECTION_WEST : mxConstants.DIRECTION_NORTH;
    var layout = new mxHierarchicalLayout(graph, direction);
    layout.intraCellSpacing = +intraCellSpacing;
    layout.interHierarchySpacing = +interHierarchySpacing;
    layout.interRankCellSpacing = +interRankCellSpacing;
    layout.resizeParent = resizeParent;
    layout.parentBorder = +parentBorder;
    layout.disableEdgeStyle = false;
    layout.edgeStyle = 'orthogonalEdgeStyle';
    layout.maintainParentLocation = true;
    return layout;
  };

  return DFlowLayout;
}(DLayout);

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

_defineProperty(DFlowLayout, "propTypes", _Object$assign({}, DLayout.propTypes, {
  type: ['horizontal', 'vertical'],
  interRankCellSpacing: [Number, String],
  interHierarchySpacing: [Number, String],
  resizeParent: Boolean
}));