"use strict";
Object.defineProperty(exports, "__esModule", {
  value: !0
}), exports.default = _default;
var 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 _interopRequireDefault(e) {
  return e && e.__esModule ? e : {
    default: e
  }
}

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

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

function _typeof(e) {
  return (_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
    return typeof e
  } : function(e) {
    return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e
  })(e)
}

function _classCallCheck(e, t) {
  if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
}

function _defineProperties(e, t) {
  for (var r = 0; r < t.length; r++) {
    var n = t[r];
    n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(e, n.key, n)
  }
}

function _createClass(e, t, r) {
  return t && _defineProperties(e.prototype, t), r && _defineProperties(e, r), e
}

function _inherits(e, t) {
  if ("function" != typeof t && null !== t) throw new TypeError("Super expression must either be null or a function");
  e.prototype = Object.create(t && t.prototype, {
    constructor: {
      value: e,
      writable: !0,
      configurable: !0
    }
  }), t && _setPrototypeOf(e, t)
}

function _setPrototypeOf(e, t) {
  return (_setPrototypeOf = Object.setPrototypeOf || function(e, t) {
    return e.__proto__ = t, e
  })(e, t)
}

function _createSuper(r) {
  var n = _isNativeReflectConstruct();
  return function() {
    var e, t = _getPrototypeOf(r);
    return _possibleConstructorReturn(this, n ? (e = _getPrototypeOf(this).constructor, Reflect.construct(t, arguments, e)) : t.apply(this, arguments))
  }
}

function _possibleConstructorReturn(e, t) {
  return !t || "object" !== _typeof(t) && "function" != typeof t ? _assertThisInitialized(e) : t
}

function _assertThisInitialized(e) {
  if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  return e
}

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

function _getPrototypeOf(e) {
  return (_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function(e) {
    return e.__proto__ || Object.getPrototypeOf(e)
  })(e)
}

function _defineProperty(e, t, r) {
  return t in e ? Object.defineProperty(e, t, {
    value: r,
    enumerable: !0,
    configurable: !0,
    writable: !0
  }) : e[t] = r, e
}
var DefaultNode = _amosJsplumb.PlumbEleNode.DefaultNode,
  Anchors = _amosJsplumb.placement.Anchors;

function _default(e) {
  var n = e.type,
    c = e.nodeIcon,
    l = (0, _stageConf.completeItemTypeIcon)(c);
  return (0, _amosJsplumb.plumbNodeConnect)({
    className: "alarm-node-ele-inner",
    targetParams: {
      allowLoopback: !1,
      anchor: Anchors.LeftMiddle,
      dropOptions: {
        hoverClass: "drag-hover"
      },
      isTarget: !0
    },
    sourceParams: {
      filter: ".ele-source-bar",
      allowLoopback: !1,
      anchor: Anchors.Right,
      dropOptions: {
        hoverClass: "drag-hover"
      }
    },
    endPointParams: [{
      params: _plumbOptions.sourceEndPoint,
      referenceParams: {
        anchor: Anchors.RightMiddle
      }
    }, {
      params: _plumbOptions.targetEndpoint,
      referenceParams: {
        anchor: Anchors.LeftMiddle
      }
    }]
  })(e = function() {
    _inherits(r, React.Component);
    var t = _createSuper(r);

    function r(e) {
      return _classCallCheck(this, r), _defineProperty(_assertThisInitialized(e = t.call(this, e)), "dbClickTrigger", function(e) {
        var t = e.id,
          r = e.config,
          e = e.parentConfig;
        _rayEventpool.PubSub.publish(_stageConf.eleTypeTopic.stage, {
          id: t,
          config: r,
          parentConfig: e,
          type: n
        })
      }), _defineProperty(_assertThisInitialized(e), "clickTrigger", function() {}), _defineProperty(_assertThisInitialized(e), "remove", function(e, t) {
        t = t.id;
        _rayEventpool.PubSub.publish(_stageConf.ELE_DEL_TOPIC.trigger, {
          eleId: t
        })
      }), e.state = {
        active: !1
      }, e
    }
    return _createClass(r, [{
      key: "componentDidMount",
      value: function() {}
    }, {
      key: "render",
      value: function() {
        var t = this,
          e = this.state.active,
          r = this.props,
          n = r.id,
          o = r.config,
          i = r.parentConfig,
          a = (o.style, o.label),
          r = (0, _classnames.default)({
            "node-content-wrapper": !0,
            "node-wrapper-active": e
          }),
          e = (0, _classnames.default)("alarm-node-ele", c);
        return React.createElement("div", {
          className: e,
          onClick: this.clickTrigger,
          onDoubleClick: function() {
            return t.dbClickTrigger({
              id: n,
              config: o,
              parentConfig: i
            })
          }
        }, React.createElement("div", {
          className: r
        }, React.createElement("div", {
          className: "ele-node-icon"
        }, React.createElement("img", {
          src: l,
          alt: ""
        })), React.createElement("div", {
          className: "ele-node-content"
        }, React.createElement(_ElementEditor.default, {
          label: a,
          eleId: n
        })), React.createElement("div", {
          className: "ele-node-action"
        }, React.createElement(_ActionItem.default, {
          icon: "delete",
          onClick: function(e) {
            return t.remove(e, {
              id: n
            })
          },
          tip: "点击删除元素节点"
        }))))
      }
    }]), r
  }()) || e
}
module.exports = exports.default;
