"use strict";

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

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

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")), _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")), _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")), _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")), _amosJsplumb = require("amos-jsplumb"), _rayEventpool = require("ray-eventpool"), _classnames = _interopRequireDefault(require("classnames")), _ActionItem = _interopRequireDefault(require("./../../extra/ActionItem")), _stageConf = require("./../../modelConf/stageConf"), _plumbOptions = require("./../../modelConf/plumbOptions"), _ElementEditor = _interopRequireDefault(require("./../../ElementEditor"));

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 = {}, a = Object.defineProperty && Object.getOwnPropertyDescriptor;
  for (var i in e) if ("default" !== i && Object.prototype.hasOwnProperty.call(e, i)) {
    var l = a ? Object.getOwnPropertyDescriptor(e, i) : null;
    l && (l.get || l.set) ? Object.defineProperty(n, i, l) : n[i] = e[i];
  }
  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 a = (0, _getPrototypeOf2.default)(this).constructor;
      r = Reflect.construct(n, arguments, a);
    } 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 DefaultNode = _amosJsplumb.PlumbEleNode.DefaultNode, Anchors = _amosJsplumb.placement.Anchors;

function _default(e) {
  var t, r = e.type, n = e.nodeIcon, a = (0, _stageConf.completeItemTypeIcon)(n);
  return (0, _amosJsplumb.plumbNodeConnect)({
    className: "output-node-ele-inner",
    targetParams: {
      allowLoopback: !1,
      anchor: Anchors.LeftMiddle,
      dropOptions: {
        hoverClass: "drag-hover"
      },
      isTarget: !0
    },
    endPointParams: [ {
      params: _plumbOptions.targetEndpoint,
      referenceParams: {
        anchor: Anchors.LeftMiddle
      }
    } ]
  })(t = function(e) {
    (0, _inherits2.default)(i, e);
    var t = _createSuper(i);
    function i(e) {
      var n;
      return (0, _classCallCheck2.default)(this, i), n = t.call(this, e), (0, _defineProperty2.default)((0, 
      _assertThisInitialized2.default)(n), "dbClickTrigger", (function(e) {
        var t = e.id, a = e.config, i = e.parentConfig;
        a.label = n.currentLabel, _rayEventpool.PubSub.publish(_stageConf.eleTypeTopic.stage, {
          id: t,
          config: a,
          parentConfig: i,
          type: r
        });
      })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(n), "clickTrigger", (function() {})), 
      (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(n), "remove", (function(e, t) {
        var r = t.id;
        _rayEventpool.PubSub.publish(_stageConf.ELE_DEL_TOPIC.trigger, {
          eleId: r
        });
      })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(n), "refreshLabel", (function(e) {
        n.currentLabel = e;
      })), n.currentLabel = n.props.config.label, n.state = {
        active: !1
      }, n;
    }
    return (0, _createClass2.default)(i, [ {
      key: "componentDidMount",
      value: function() {}
    }, {
      key: "render",
      value: function() {
        var e = this, t = this.state.active, r = this.props, i = r.id, l = r.config, o = r.parentConfig, u = (l.style, 
        l.label), c = (0, _classnames.default)({
          "node-content-wrapper": !0,
          "node-wrapper-active": t
        }), s = (0, _classnames.default)("output-node-ele", n);
        return React.createElement("div", {
          className: s,
          onClick: this.clickTrigger,
          onDoubleClick: function() {
            return e.dbClickTrigger({
              id: i,
              config: l,
              parentConfig: o
            });
          }
        }, React.createElement("div", {
          className: c
        }, React.createElement("div", {
          className: "ele-node-icon"
        }, React.createElement("img", {
          src: a,
          alt: ""
        })), React.createElement("div", {
          className: "ele-node-content"
        }, React.createElement(_ElementEditor.default, {
          label: u,
          eleId: i,
          editCallBack: this.refreshLabel
        })), React.createElement("div", {
          className: "ele-node-action"
        }, React.createElement(_ActionItem.default, {
          icon: "delete",
          onClick: function(t) {
            return e.remove(t, {
              id: i
            });
          },
          tip: "点击删除元素节点"
        }))));
      }
    } ]), i;
  }(React.Component)) || t;
}