"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, i = (0, _getPrototypeOf2.default)(e);
        if (t) {
            var a = (0, _getPrototypeOf2.default)(this).constructor;
            r = Reflect.construct(i, arguments, a);
        } else r = i.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, i = e.nodeIcon, a = (0, _stageConf.completeItemTypeIcon)(i);
    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)(n, e);
        var t = _createSuper(n);
        function n(e) {
            var i;
            return (0, _classCallCheck2.default)(this, n), i = t.call(this, e), (0, _defineProperty2.default)((0, 
            _assertThisInitialized2.default)(i), "dbClickTrigger", (function(e) {
                var t = e.id, a = e.config, n = e.parentConfig;
                a.label = i.currentLabel, _rayEventpool.PubSub.publish(_stageConf.eleTypeTopic.stage, {
                    id: t,
                    config: a,
                    parentConfig: n,
                    type: r
                });
            })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(i), "clickTrigger", (function() {})), 
            (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(i), "remove", (function(e, t) {
                var r = t.id;
                _rayEventpool.PubSub.publish(_stageConf.ELE_DEL_TOPIC.trigger, {
                    eleId: r
                });
            })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(i), "refreshLabel", (function(e) {
                i.currentLabel = e;
            })), i.currentLabel = i.props.config.label, i.state = {
                active: !1
            }, i;
        }
        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, l = r.config, o = r.parentConfig, u = (l.style, 
                l.label), s = (0, _classnames.default)({
                    "node-content-wrapper": !0,
                    "node-wrapper-active": t
                }), c = (0, _classnames.default)("output-node-ele", i);
                return React.createElement("div", {
                    className: c,
                    onClick: this.clickTrigger,
                    onDoubleClick: function() {
                        return e.dbClickTrigger({
                            id: n,
                            config: l,
                            parentConfig: o
                        });
                    }
                }, React.createElement("div", {
                    className: s
                }, 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: n,
                    editCallBack: this.refreshLabel
                })), 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;
}