import _extends from "@babel/runtime/helpers/extends";
import { uuid } from "../../../../_utils/utils";
import { FlowEvent } from "../type";
import { getActionRequestMenus, getComMenus, getDeleteMenus as _getDeleteMenus, getInterposition, isEffectivePluginId } from "../utils";
import { BehaviorType } from "../../../../../src/utils/CLowCodeService/type";
import { t } from "../../../../../src/locale";
import { cloneDeep, isArray } from 'lodash';
export var FlowEventService = /*#__PURE__*/function () {
  function FlowEventService() {}
  var _proto = FlowEventService.prototype;
  _proto.loadFlowNode = function loadFlowNode(node) {
    var _this = this;
    // 由于保存时删除了menus，故这里要补充进入
    this.addInitNodeMenus(node);
    if (node.children && node.children.length) {
      node.children.forEach(function (item) {
        _this.loadFlowNode(item);
      });
    }
    return node;
  }

  /**
   * 保存节点，去除所有的menus数据内容
   */;
  _proto.getSaveFlowNode = function getSaveFlowNode(nodes) {
    var result;
    result = this.handleSaveFlowNode(nodes);
    return result;
  }

  /**
   * 获取事件流打开动作里面的存储行为
   * @returns 
   */;
  _proto.getSaveDataBehaviorByAction = function getSaveDataBehaviorByAction(nodes) {
    var result = [];
    result = this._getSaveDataBehaviorByAction([nodes]);
    return result;
  };
  _proto._getSaveDataBehaviorByAction = function _getSaveDataBehaviorByAction(flowEventConfig) {
    var _this2 = this;
    var result = [];
    flowEventConfig.forEach(function (item) {
      var _item$config, _item$children;
      if (item.type === FlowEvent.action && ((_item$config = item.config) === null || _item$config === void 0 ? void 0 : _item$config.type) === BehaviorType.storageDataBehavior) {
        result.push(item.config.data);
      }
      if ((_item$children = item.children) !== null && _item$children !== void 0 && _item$children.length) {
        result = result.concat(_this2._getSaveDataBehaviorByAction(item.children));
      }
    });
    return result;
  }

  /**
   * 创建节点
   * @param curModel 
   * @param key 
   * @returns 
   */;
  _proto.createFlowNode = function createFlowNode(curModel, key) {
    var _curModel$current$men;
    var result;
    var newKey = this.getNewKey(key);
    var menu = (_curModel$current$men = curModel.current.menus) === null || _curModel$current$men === void 0 ? void 0 : _curModel$current$men.find(function (o) {
      return o.key === newKey;
    });
    var type = menu.nodeType;
    var name = menu.nodeName;
    var menus = getComMenus();

    // 等于规则特殊处理
    if (type === FlowEvent.rule) {
      var list = getComMenus();
      menus = list.filter(function (item) {
        return item.key !== FlowEvent.rule;
      });
      var rulePreObj = this.getOneFlowNode({
        type: FlowEvent.rulePre,
        label: t('setter.flowRulePre'),
        menus: menus
      });
      var ruleBeforeObj = this.getOneFlowNode({
        type: FlowEvent.ruleBefore,
        label: t('setter.flowRuleBefore'),
        menus: menus
      });
      var ruleAfterObj = this.getOneFlowNode({
        type: FlowEvent.ruleAfter,
        label: t('setter.flowRuleAfter'),
        menus: menus
      });
      result = this.getOneFlowNode({
        type: FlowEvent.rule,
        label: name,
        menus: [],
        key: FlowEvent.rule,
        children: [rulePreObj, ruleBeforeObj, ruleAfterObj]
      });
    } else {
      if (type === FlowEvent.action) {
        menus = [];
      }
      result = this.getOneFlowNode({
        type: type,
        label: name,
        menus: menus,
        key: type === FlowEvent.event ? key : type
      });
    }
    return result;
  }

  /**
   * 处理插入节点,对规则节点的处理逻辑有问题
   * @param curModel 
   * @param newNode 
   */;
  _proto.InterpositionFlowNode = function InterpositionFlowNode(curModel, newNode) {
    var _this3 = this;
    var curModelDep = cloneDeep(curModel);
    var index = curModel.depth + 1;
    var type = newNode.key;

    // 规则是自带children的
    if (newNode.children && newNode.children.length) {
      newNode.children = newNode.children.map(function (item) {
        var typeList = [type, item.type];
        item.children = _this3.createUUid(cloneDeep(curModelDep.children), typeList, index);
        return item;
      });
    } else {
      newNode.children = this.createUUid(curModelDep.children, type, index);
    }
    return newNode;
  };
  _proto.createUUid = function createUUid(children, type, index) {
    var _this4 = this;
    return children.map(function (item) {
      item.id = uuid();
      if (item.children) {
        item.children = _this4.createUUid(item.children, type, index);
      }
      return item;
    });
  };
  _proto.updatedParentConfig = function updatedParentConfig(parentConfig, type, index) {
    var result = parentConfig;
    if (result.parentKeys && result.parentKeys.length) {
      var list = isArray(type) ? type : [type];
      list.forEach(function (key, i) {
        var number = i + index;
        result.parentKeys.splice(number, 0, key);
      });
    }
    return result;
  }

  /**
   * 菜单配置
   * 1，模块下子模块都是条件/或者缺省条件 的情况下，是可以添加多个条件的，否则只能有一条线路
   * 2, 请求动作，成功，失败和成功或失败是互斥的
   * 3, 除条件以为的子模块不允许子啊添加动作
   * @param node 
   * @returns 
   */;
  _proto.getMenusByNode = function getMenusByNode(node, FlowCtx) {
    var result = node.menus;
    var children = node.children,
      parentConfig = node.parentConfig;
    if (children !== null && children !== void 0 && children.length) {
      var _node$config;
      var newMenus = [];
      // 特殊请求节点直接是不允许插入的
      if (((_node$config = node.config) === null || _node$config === void 0 ? void 0 : _node$config.type) === BehaviorType.requestBehavior) {
        return this.handleActionRequestMenus(node);
      } else if (this.isHaveConditionAndElseInChildren(children)) {
        // 判断所有的子节点都是条件或者缺省条件
        newMenus = this.handleConditionMenus(node);
      }
      // 统一处理公共插入菜单
      result = newMenus.concat(this.addInterpositionMenus(node, FlowCtx));
    } else {
      // 非插件类需要过滤掉规则，或者父级已经存在规则了
      if (!isEffectivePluginId(FlowCtx.pluginId) || this.isHaveRuleInParentKeys(parentConfig === null || parentConfig === void 0 ? void 0 : parentConfig.parentKeys)) {
        result = result.filter(function (item) {
          return item.key !== FlowEvent.rule;
        });
      }
    }
    return result;
  };
  _proto.getMenusPosition = function getMenusPosition(item, target, graph, refContainer) {
    var _refContainer$current;
    // 获取当前节点的位置
    var itemBox = item.getBBox();
    // 获取当前节点的子节点位置
    var bbox = target.getBBox();
    // 获取当前节点在画布上的位置
    var newBox = graph.getCanvasByPoint(bbox.x + itemBox.x + itemBox.width / 2 + 20, bbox.y + itemBox.y + itemBox.height / 2 + 6);
    var _ref = (refContainer === null || refContainer === void 0 ? void 0 : (_refContainer$current = refContainer.current) === null || _refContainer$current === void 0 ? void 0 : _refContainer$current.getBoundingClientRect()) || {},
      left = _ref.left,
      top = _ref.top;
    return {
      top: newBox.y + top,
      left: newBox.x + left
    };
  };
  _proto.getDeleteMenus = function getDeleteMenus(model, graph) {
    var result = _getDeleteMenus();
    if (model.type === FlowEvent.rule || this.isHaveMultiCondition(model, graph)) {
      result = result.filter(function (item) {
        return item.key !== FlowEvent.deleteContent;
      });
    } else if (model.type === FlowEvent.end) {
      result = result.filter(function (item) {
        return item.key !== FlowEvent.deleteAfter;
      });
    }
    return result;
  }

  /**
   * 判断节点是否是条件节点，并且有多个条件的情况下，应该过滤掉删除当前节点的方法
   * @param model 
   * @param graph 
   * @returns 
   */;
  _proto.isHaveMultiCondition = function isHaveMultiCondition(model, graph) {
    var result = false;
    if (model.type === FlowEvent.condition || model.type === FlowEvent.conditionElse) {
      var _graph$findById;
      var parentId = model.parentConfig.parentId;
      var parentModel = (_graph$findById = graph.findById(parentId)) === null || _graph$findById === void 0 ? void 0 : _graph$findById.getModel();
      result = parentModel && parentModel.children.length > 1;
    }
    return result;
  };
  _proto.updatedParentConfigs = function updatedParentConfigs(data) {
    var result = data;
    if (data) {
      result = this._updateParentConfig(data, [], null);
    }
    return result;
  }

  /**
   * 除了判断是否是插入节点
   * 这里除了明确指出来的插入节点以外还需要注意类似
   * 动作突然修改成接口，添加节点的内容插入
   * @param key 
   * @returns 
   */;
  _proto.isInsertNode = function isInsertNode(key, current) {
    var result = false;
    if (key.endsWith('Insert')) {
      result = true;
    } else if (current && current.type === FlowEvent.action && this.isNoHaveActionRequestData(current)) {
      result = true;
    }
    return result;
  }

  /**
   * 校验所有的节点是否正确,不断扩充，暂时只校验请求接口
   * 1，请求动作节点后面必须是成功，失败，穿透
   * 2，规则节点必须绑定instanceId
   * 3，规则节点前置，后置，预制等必须有结束节点
   * 4, 只要存在一个结束节点或者异常结束节点就行
   */;
  _proto.checkAllNode = function checkAllNode(newData) {
    var result = {
      code: 200,
      msg: ''
    };
    result = this.checkAllRequestNodeData([newData]);
    if (result.code !== 200) {
      return result;
    }
    result = this.checkAllRuleNodeData([newData]);
    if (result.code !== 200) {
      return result;
    }
    var res = this.checkAllEndNodeData(newData);
    if (!res) {
      result = {
        code: 201,
        msg: t("setter.flowTipEnd")
      };
    }
    return result;
  }
  /**
   * 检测至少含义一个结束节点
   * 1，结束节点
   * 2，公共事件流节点
   * 3，异常节点
   * @param node 
   * @returns 
   */;
  _proto.checkAllEndNodeData = function checkAllEndNodeData(node) {
    var result = false;
    if (node.children) {
      var endRes = this.checkChildrenNode(node.children, FlowEvent.end);
      var eventRes = this.checkChildrenNode(node.children, FlowEvent.eventFlowNode);
      var abnormalRes = this.checkChildrenNode(node.children, FlowEvent.abnormal);
      return endRes || eventRes || abnormalRes;
    }
    return result;
  }

  /**
   * 递归遍历修改树图数据
   * 1，规则节点和结束节点只要存在一个就行
   * 以遇到结束节点作为执行完成的标准
   * @param root 当前跟节点
   * @param option 更新类型： 删除节点  删除一整个子树 添加节点
   * @param targetId 要删除的节点 || 在那个节点下新增
   * @param newNode 新增节点
   * @param isInsertNode 判断是否插入节点
   * @returns 
   */;
  _proto.getNewTreeGraphData = function getNewTreeGraphData(root, option, targetId, newNode, isInsertNode) {
    var _root$children,
      _root$children2,
      _this5 = this,
      _root$children3;
    if (newNode === void 0) {
      newNode = null;
    }
    if (isInsertNode === void 0) {
      isInsertNode = false;
    }
    switch (option) {
      case FlowEvent.deleteAfter:
        root.children = (_root$children = root.children) === null || _root$children === void 0 ? void 0 : _root$children.filter(function (child) {
          return child.id !== targetId;
        });
        (_root$children2 = root.children) === null || _root$children2 === void 0 ? void 0 : _root$children2.forEach(function (child) {
          _this5.getNewTreeGraphData(child, option, targetId);
        });
        break;
      case FlowEvent.deleteContent:
        (_root$children3 = root.children) === null || _root$children3 === void 0 ? void 0 : _root$children3.forEach(function (child, index) {
          if (child.id === targetId) {
            var _root$children4;
            var children = child.children || [];
            (_root$children4 = root.children) === null || _root$children4 === void 0 ? void 0 : _root$children4.splice.apply(_root$children4, [index, 1].concat(children));
          } else {
            _this5.getNewTreeGraphData(child, option, targetId);
          }
        });
        break;
      case FlowEvent.insert:
        var addNode = cloneDeep(newNode);
        root.children = root.children || [];
        if (root.id === targetId) {
          if (isInsertNode) {
            addNode = this.InterpositionFlowNode(root, newNode);
            root.children = [];
          }
          if (root.children === undefined) {
            root.children = [];
          }
          root.children.push(addNode);
        } else {
          var _root$children5;
          (_root$children5 = root.children) === null || _root$children5 === void 0 ? void 0 : _root$children5.forEach(function (child) {
            _this5.getNewTreeGraphData(child, option, targetId, newNode, isInsertNode);
          });
        }
        break;
      default:
        break;
    }
    return root;
  }

  /**
   * 补充menus
   * @param node 
   */;
  _proto.addInitNodeMenus = function addInitNodeMenus(node) {
    var _node$config2;
    if (node.type === FlowEvent.action && ((_node$config2 = node.config) === null || _node$config2 === void 0 ? void 0 : _node$config2.type) === BehaviorType.requestBehavior) {
      node.menus = getActionRequestMenus();
    } else {
      node.menus = getComMenus();
    }
  }

  /**
   * 1，请求动作节点后面必须是成功，失败，穿透
   * @param nodeList 
   * @returns 
   */;
  _proto.checkAllRequestNodeData = function checkAllRequestNodeData(nodeList) {
    var result = {
      code: 200,
      msg: ''
    };
    for (var i = 0; i < nodeList.length; i++) {
      var _item$config2;
      var item = nodeList[i];

      // 校验请求接口
      if ((item === null || item === void 0 ? void 0 : item.type) === FlowEvent.action && ((_item$config2 = item.config) === null || _item$config2 === void 0 ? void 0 : _item$config2.type) === BehaviorType.requestBehavior) {
        result = this.checkActionRequestData(item);
        if (result.code !== 200) {
          break;
        }
      }
      if (item.children) {
        result = this.checkAllRequestNodeData(item.children);
        if (result.code !== 200) {
          break;
        }
      }
    }
    return result;
  }

  /**
   * 2，规则节点必须绑定instanceId
   * 3，规则节点前置，后置，预制等必须有结束节点
   * @param nodeList 
   */;
  _proto.checkAllRuleNodeData = function checkAllRuleNodeData(nodeList) {
    var result = {
      code: 200,
      msg: ''
    };
    for (var i = 0; i < nodeList.length; i++) {
      var item = nodeList[i];
      if ((item === null || item === void 0 ? void 0 : item.type) === FlowEvent.rule) {
        var _result = this.checkRuleNodeData(item);
        if (_result.code !== 200) {
          return _result;
        }
      } else if (item.children) {
        result = this.checkAllRuleNodeData(item.children);
        if (result.code !== 200) {
          return result;
        }
      }
    }
    return result;
  }

  /**
   * 补充插入菜单,
   * 暂时只支持条件，动作，插入其他节点
   */;
  _proto.addInterpositionMenus = function addInterpositionMenus(node, FlowCtx) {
    var result = [];
    // 支持节点
    var comSupportKeyList = [FlowEvent.start, FlowEvent.action, FlowEvent.condition, FlowEvent.conditionElse, FlowEvent.success, FlowEvent.error, FlowEvent["finally"], FlowEvent.ruleBefore, FlowEvent.rulePre, FlowEvent.ruleAfter];
    // 支持菜单
    var comEnumsList = [];
    var nodeKey = node.key ? node.key : node.type;
    if (comSupportKeyList.includes(nodeKey)) {
      var comMenus = getInterposition();

      // 允许添加规则，并且子模块中并没有规则的情况下可以补充规则菜单
      if (isEffectivePluginId(FlowCtx.pluginId) && !this.isHaveRuleInChildren([node])) {
        comEnumsList.push(FlowEvent.ruleInsert);
      }
      comEnumsList = comEnumsList.concat([FlowEvent.actionInsert, FlowEvent.conditionInsert]);
      result = comMenus.filter(function (item) {
        return comEnumsList.includes(item.key);
      });
    }
    return result;
  }

  /**
   * 可能是插入节点，应该转换成对应的节点内容
   * 用于去生成新的节点
   * @param key 
   * @returns 
   */;
  _proto.getNewKey = function getNewKey(key) {
    var result = key;
    if (this.isInsertNode(key)) {
      result = key.replace('Insert', '');
    }
    return result;
  };
  _proto.handleSaveFlowNode = function handleSaveFlowNode(node) {
    var _this6 = this;
    var result = node;
    if (node.menus && node.menus.length) {
      node.menus.length = 0;
    }
    if (node.children && node.children.length) {
      node.children.forEach(function (item) {
        _this6.handleSaveFlowNode(item);
      });
    }
    return result;
  }

  /**
   * 处理多条件节点，即某个节点下面可以有多个条件和一个缺省条件
   * @param node 
   * @returns 
   */;
  _proto.handleConditionMenus = function handleConditionMenus(node) {
    var result = [];
    var menus = node.menus;
    if (this.isHaveConditionElseChildren(node.children)) {
      result = menus.filter(function (item) {
        return item.key === FlowEvent.condition;
      });
    } else if (this.isHaveConditionInChildren(node.children)) {
      result = menus.filter(function (item) {
        return item.key === FlowEvent.condition || item.key === FlowEvent.conditionElse;
      });
    }
    return result;
  }

  /**
   * 处理动作节点下的请求动作
   * @param node 
   * @param FlowCtx 
   * @returns 
   */;
  _proto.handleActionRequestMenus = function handleActionRequestMenus(node) {
    var result = node.menus || [];
    var children = node.children,
      menus = node.menus;
    // 请求动作 ，成功，失败和成功或失败是互斥的
    if (children) {
      // 有穿透则不能再添加任何模块,或者有了成功，失败则不能再添加
      if (this.isHaveFinallyNode(children) || this.isSuccessAndErrorNode(children)) {
        result = [];
      } else {
        var key = this.isSuccessOrErrorNode(children);
        if (key) {
          var menusKey = key === FlowEvent.success ? FlowEvent.error : FlowEvent.success;
          result = menus.filter(function (item) {
            return item.key === menusKey;
          });
        }
      }
    }
    return result;
  };
  _proto.isHaveFinallyNode = function isHaveFinallyNode(children) {
    return children.some(function (item) {
      return item.key === FlowEvent["finally"];
    });
  };
  _proto.isSuccessOrErrorNode = function isSuccessOrErrorNode(children) {
    var key;
    for (var i = 0; i < children.length; i++) {
      var item = children[i];
      if (item.key === FlowEvent.success || item.key === FlowEvent.error) {
        key = item.key;
        break;
      }
    }
    return key;
  };
  _proto.isSuccessAndErrorNode = function isSuccessAndErrorNode(children) {
    var cLen = children.filter(function (item) {
      return item.key === FlowEvent.success || item.key === FlowEvent.error;
    });
    return cLen.length === 2;
  }

  /**
   * 暂时只针对menus中含有rule里面的menus，目的是保证整条链路只有一个规则
   * 
   * @param menus 
   * @param parentKeys 
   */;
  _proto.handleParentKeysMenus = function handleParentKeysMenus(menus, parentKeys) {
    if (parentKeys === void 0) {
      parentKeys = [];
    }
    var result = [];
    var isRule = menus.find(function (item) {
      return item.key === FlowEvent.rule;
    });
    if (isRule && this.isHaveRuleInParentKeys(parentKeys)) {
      result = menus.filter(function (item) {
        return item.key !== FlowEvent.rule;
      });
    }
    return result;
  };
  _proto.isHaveRuleInParentKeys = function isHaveRuleInParentKeys(parentKeys) {
    if (parentKeys === void 0) {
      parentKeys = [];
    }
    return parentKeys.includes(FlowEvent.rule);
  };
  _proto.isHaveRuleInChildren = function isHaveRuleInChildren(children) {
    var result = false;
    for (var i = 0; i < children.length; i++) {
      var _item$parentConfig;
      var item = children[i];
      if (this.isHaveRuleInParentKeys((_item$parentConfig = item.parentConfig) === null || _item$parentConfig === void 0 ? void 0 : _item$parentConfig.parentKeys)) {
        result = true;
        break;
      }
      if (item.children) {
        result = this.isHaveRuleInChildren(item.children);
      }
    }
    return result;
  }

  /**
   * 判断是否有除请求以外的任何数据
   * 主要是action节点之前不是请求，后来改成请求后要插入成功，失败或穿透的子模块
   * @param children 
   */;
  _proto.isNoHaveActionRequestData = function isNoHaveActionRequestData(node) {
    // 只有请求才做这个逻辑处理
    if (node.config.type !== BehaviorType.requestBehavior) {
      return false;
    }
    var children = node.children;
    if (!children) {
      return false;
    }
    return this._checkRequestChildren(children);
  };
  _proto._checkRequestChildren = function _checkRequestChildren(children) {
    var requestList = [FlowEvent.success, FlowEvent.error, FlowEvent["finally"]];
    var res = children.filter(function (item) {
      return !requestList.includes(item.key);
    });
    return res.length > 0;
  }

  /**
   * 校验请求动作
   * @param node
   */;
  _proto.checkActionRequestData = function checkActionRequestData(node) {
    var result = {
      code: 200,
      msg: ''
    };
    if (!node.children || node.children.length === 0) {
      return {
        code: 201,
        msg: t('setter.checkReqTip1')
      };
    }
    if (this._checkRequestChildren(node.children)) {
      return {
        code: 201,
        msg: t('setter.checkReqTip2')
      };
    }
    return result;
  };
  _proto.checkRuleNodeData = function checkRuleNodeData(node) {
    var _node$config3, _node$children;
    var result = {
      code: 200,
      msg: ''
    };
    if (!((_node$config3 = node.config) !== null && _node$config3 !== void 0 && _node$config3.ruleId)) {
      return {
        code: 201,
        msg: t('setter.checkRuleTip1')
      };
    }
    if ((_node$children = node.children) !== null && _node$children !== void 0 && _node$children.length) {
      for (var i = 0; i < node.children.length; i++) {
        var ruleItem = node.children[i];
        if (ruleItem.children) {
          var res = this.checkAllEndNodeData(ruleItem);
          if (!res) {
            return {
              code: 201,
              msg: t('setter.checkRuleTip2')
            };
          }
        }
      }
    }
    return result;
  };
  _proto.checkChildrenNode = function checkChildrenNode(list, checkType) {
    var result = false;
    for (var i = 0; i < list.length; i++) {
      var _item$children2;
      var item = list[i];
      if (item.type === checkType) {
        result = true;
        break;
      }
      if ((_item$children2 = item.children) !== null && _item$children2 !== void 0 && _item$children2.length) {
        result = this.checkChildrenNode(item.children, checkType);
        if (result) {
          break;
        }
      }
    }
    return result;
  };
  _proto.getOneFlowNode = function getOneFlowNode(config) {
    var children = config.children,
      key = config.key;
    return _extends({}, config, {
      id: uuid(),
      key: key,
      children: children || []
    });
  }

  /**
   * 判断子节点只能是条件或者缺省条件
   * @param children 
   * @returns 
   */;
  _proto.isHaveConditionAndElseInChildren = function isHaveConditionAndElseInChildren(children) {
    if (!children) return false;
    return children.every(function (item) {
      return item.type === FlowEvent.condition || item.type === FlowEvent.conditionElse;
    });
  }
  /**
   * 节点存在条件
   * @param children 
   * @returns 
   */;
  _proto.isHaveConditionInChildren = function isHaveConditionInChildren(children) {
    if (!children) return false;
    return children.some(function (item) {
      return item.type === FlowEvent.condition;
    });
  }

  /**
   * 节点存在缺省条件
   * @param children 
   * @returns 
   */;
  _proto.isHaveConditionElseChildren = function isHaveConditionElseChildren(children) {
    if (!children) return false;
    return children.some(function (item) {
      return item.type === FlowEvent.conditionElse;
    });
  };
  _proto._updateParentConfig = function _updateParentConfig(data, parentKeys, parentId) {
    var _this7 = this;
    var result = data;
    if (result.parentConfig === undefined) {
      result.parentConfig = {
        parentKeys: [],
        parentId: ''
      };
    }
    result.parentConfig.parentKeys = parentKeys.concat([result.type]);
    result.parentConfig.parentId = parentId;
    if (result.children) {
      var _result$parentConfig;
      var _parentKeys = ((_result$parentConfig = result.parentConfig) === null || _result$parentConfig === void 0 ? void 0 : _result$parentConfig.parentKeys) || [];
      var _parentId = result.id;
      result.children = result.children.map(function (item) {
        return _this7._updateParentConfig(item, _parentKeys, _parentId);
      });
    }
    return result;
  };
  return FlowEventService;
}();