"use strict";

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"), _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

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 _createSuper(e) {
    var t = _isNativeReflectConstruct();
    return function() {
        var r, a = (0, _getPrototypeOf2.default)(e);
        if (t) {
            var i = (0, _getPrototypeOf2.default)(this).constructor;
            r = Reflect.construct(a, arguments, i);
        } else r = a.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, a = e.nodeIcon, i = (0, _stageConf.completeItemTypeIcon)(a);
    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
            }
        } ]
    })(t = function(e) {
        (0, _inherits2.default)(n, e);
        var t = _createSuper(n);
        function n(e) {
            var a;
            return (0, _classCallCheck2.default)(this, n), a = t.call(this, e), (0, _defineProperty2.default)((0, 
            _assertThisInitialized2.default)(a), "dbClickTrigger", (function(e) {
                var t = e.id, a = e.config, i = e.parentConfig;
                _rayEventpool.PubSub.publish(_stageConf.eleTypeTopic.stage, {
                    id: t,
                    config: a,
                    parentConfig: i,
                    type: r
                });
            })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(a), "clickTrigger", (function() {})), 
            (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(a), "remove", (function(e, t) {
                var r = t.id;
                _rayEventpool.PubSub.publish(_stageConf.ELE_DEL_TOPIC.trigger, {
                    eleId: r
                });
            })), a.state = {
                active: !1
            }, a;
        }
        return (0, _createClass2.default)(n, [ {
            key: "componentDidMount",
            value: function() {}
        }, {
            key: "render",
            value: function() {
                var e = this, t = this.state.active, r = this.props, n = r.id, o = r.config, l = r.parentConfig, s = (o.style, 
                o.label), u = (0, _classnames.default)({
                    "node-content-wrapper": !0,
                    "node-wrapper-active": t
                }), c = (0, _classnames.default)("alarm-node-ele", a);
                return React.createElement("div", {
                    className: c,
                    onClick: this.clickTrigger,
                    onDoubleClick: function() {
                        return e.dbClickTrigger({
                            id: n,
                            config: o,
                            parentConfig: l
                        });
                    }
                }, React.createElement("div", {
                    className: u
                }, React.createElement("div", {
                    className: "ele-node-icon"
                }, React.createElement("img", {
                    src: i,
                    alt: ""
                })), React.createElement("div", {
                    className: "ele-node-content"
                }, React.createElement(_ElementEditor.default, {
                    label: s,
                    eleId: n
                })), React.createElement("div", {
                    className: "ele-node-action"
                }, React.createElement(_ActionItem.default, {
                    icon: "delete",
                    onClick: function(t) {
                        return e.remove(t, {
                            id: n
                        });
                    },
                    tip: "点击删除元素节点"
                }))));
            }
        } ]), n;
    }(React.Component)) || t;
}