"use strict";
Object.defineProperty(exports, "__esModule", {
  value: !0
}), exports.getEleNode = exports.addTrigerAndAction = exports.addTrigerEleAndConn = exports.commonAddNodeAndConn = exports.commonAddNode = void 0;
var _amosJsplumb = require("amos-jsplumb"),
  _stageConf = require("./modelConf/stageConf");

function ownKeys(o, e) {
  var t, r = Object.keys(o);
  return Object.getOwnPropertySymbols && (t = Object.getOwnPropertySymbols(o), e && (t = t.filter(function(e) {
    return Object.getOwnPropertyDescriptor(o, e).enumerable
  })), r.push.apply(r, t)), r
}

function _objectSpread(o) {
  for (var e = 1; e < arguments.length; e++) {
    var t = null != arguments[e] ? arguments[e] : {};
    e % 2 ? ownKeys(Object(t), !0).forEach(function(e) {
      _defineProperty(o, e, t[e])
    }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(o, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(e) {
      Object.defineProperty(o, e, Object.getOwnPropertyDescriptor(t, e))
    })
  }
  return o
}

function _defineProperty(e, o, t) {
  return o in e ? Object.defineProperty(e, o, {
    value: t,
    enumerable: !0,
    configurable: !0,
    writable: !0
  }) : e[o] = t, e
}
var commonAddNode = function(e) {
  var o = e.eleType,
    t = e.labelValue,
    r = e.position,
    e = e.ruleNodeId;
  return {
    config: {
      label: t,
      nodeType: o,
      type: (0, _stageConf.typeValue)(o),
      ruleNodeId: e,
      style: _objectSpread({}, r)
    },
    id: _amosJsplumb.tools.uuid()
  }
};
exports.commonAddNode = commonAddNode;
var commonAddNodeAndConn = function(e) {
  var o = e.eleType,
    t = e.labelValue,
    r = e.position,
    n = e.sourceId,
    e = _amosJsplumb.tools.uuid();
  return {
    node: {
      config: {
        label: t,
        nodeType: o,
        type: (0, _stageConf.typeValue)(o),
        style: _objectSpread({}, r)
      },
      id: e
    },
    conn: {
      sourceId: n,
      targetId: e
    }
  }
};
exports.commonAddNodeAndConn = commonAddNodeAndConn;
var addTrigerEleAndConn = function(e) {
  var o = e.labelValue,
    t = e.position,
    r = e.statusId,
    e = _amosJsplumb.tools.uuid();
  return {
    node: {
      config: {
        label: o,
        type: "trigger",
        nodeType: "trigger",
        style: _objectSpread({}, t)
      },
      id: e
    },
    conn: {
      sourceId: r,
      targetId: e
    }
  }
};
exports.addTrigerEleAndConn = addTrigerEleAndConn;
var addTrigerAndAction = function(e) {
  var o = e.labelValue,
    t = e.position,
    r = e.statusId,
    n = _amosJsplumb.tools.uuid(),
    d = _amosJsplumb.tools.uuid(),
    e = {
      left: t.left + _stageConf.stagePosition.spaceX * _stageConf.stagePosition.ratio_3,
      top: t.top
    };
  return {
    node: [{
      id: n,
      config: {
        label: o,
        nodeType: "trigger",
        type: "both",
        style: _objectSpread({}, t)
      }
    }, {
      id: d,
      config: {
        label: "动作",
        nodeType: "flowAction",
        type: "both",
        style: _objectSpread({}, e)
      }
    }],
    conn: [{
      sourceId: r,
      targetId: n
    }, {
      sourceId: n,
      targetId: d
    }]
  }
};
exports.addTrigerAndAction = addTrigerAndAction;
var getEleNode = function e(o) {
  if (o) return -1 < (o.className || "").indexOf("ele") ? o : e(o.parentNode)
};
exports.getEleNode = getEleNode;
