"use strict";

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

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

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")), _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")), _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")), _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")), _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")), _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")), _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")), _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")), _react = _interopRequireWildcard(require("react")), _propTypes = _interopRequireDefault(require("prop-types")), _amosJsplumb = require("amos-jsplumb"), _nodeConf = require("./../modelConf/nodeConf"), _ele = _interopRequireDefault(require("./../ele")), _excluded = [ "nodes", "connections", "onPlumbChange", "onSceneCreated", "onPlumbClick", "eventListeners" ];

function _getRequireWildcardCache(e) {
  if ("function" != typeof WeakMap) return null;
  var t = new WeakMap, r = new WeakMap;
  return (_getRequireWildcardCache = function(e) {
    return e ? r : t;
  })(e);
}

function _interopRequireWildcard(e, t) {
  if (!t && e && e.__esModule) return e;
  if (null === e || "object" !== _typeof(e) && "function" != typeof e) return {
    default: e
  };
  var r = _getRequireWildcardCache(t);
  if (r && r.has(e)) return r.get(e);
  var n = {}, o = Object.defineProperty && Object.getOwnPropertyDescriptor;
  for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) {
    var l = o ? Object.getOwnPropertyDescriptor(e, u) : null;
    l && (l.get || l.set) ? Object.defineProperty(n, u, l) : n[u] = e[u];
  }
  return n.default = e, r && r.set(e, n), n;
}

function _createSuper(e) {
  var t = _isNativeReflectConstruct();
  return function() {
    var r, n = (0, _getPrototypeOf2.default)(e);
    if (t) {
      var o = (0, _getPrototypeOf2.default)(this).constructor;
      r = Reflect.construct(n, arguments, o);
    } else r = n.apply(this, arguments);
    return (0, _possibleConstructorReturn2.default)(this, r);
  };
}

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

var dottedConnectionStyle = _amosJsplumb.setting.dottedConnectionStyle, selectedConnectionStyle = _amosJsplumb.setting.selectedConnectionStyle, registerTypes = {
  connections: {
    dotted: dottedConnectionStyle,
    selected: selectedConnectionStyle
  },
  endpoints: {}
}, TopoStagePlumb = function(e) {
  (0, _inherits2.default)(r, e);
  var t = _createSuper(r);
  function r() {
    return (0, _classCallCheck2.default)(this, r), t.apply(this, arguments);
  }
  return (0, _createClass2.default)(r, [ {
    key: "render",
    value: function() {
      var e = this, t = this.props, r = t.nodes, n = t.connections, o = t.onPlumbChange, u = t.onSceneCreated, l = t.onPlumbClick, i = t.eventListeners, a = (0, 
      _objectWithoutProperties2.default)(t, _excluded);
      return _react.default.createElement(_amosJsplumb.AmosPlumb, (0, _extends2.default)({
        className: "amos-plumb-container",
        key: "amos-plumb",
        onCreated: u,
        connections: n,
        nodes: r,
        jsPlumbSettings: _nodeConf.jsPlumbOptions,
        eventListeners: i,
        registerTypes: registerTypes,
        onChange: o,
        onPlumbClick: l
      }, a, {
        getNodeContent: _ele.default
      }), r.map((function(t, r) {
        var n = (0, _ele.default)(t.config.nodeType), o = "nodes-".concat(r);
        return _react.default.createElement(n, {
          key: o,
          id: t.id,
          equipmentId: t.equipmentId,
          showProperty: e.showProperty,
          deleteNode: e.deleteNode
        });
      })));
    }
  } ]), r;
}(_react.Component);

(0, _defineProperty2.default)(TopoStagePlumb, "propTypes", {
  nodes: _propTypes.default.array,
  connections: _propTypes.default.array,
  handleDrop: _propTypes.default.func,
  onPlumbChange: _propTypes.default.func,
  onSceneCreated: _propTypes.default.func,
  onPlumbClick: _propTypes.default.func,
  destroy: _propTypes.default.bool,
  eventListeners: _propTypes.default.object
}), TopoStagePlumb.displayName = "TopoStagePlumb";

var _default = TopoStagePlumb;

exports.default = _default;