import { SchemaService } from "../../_utils/schemaService";
var HandlerName = /*#__PURE__*/function (HandlerName) {
  HandlerName["Allocate Random"] = "Allocate Random";
  HandlerName["Allocate Offset Random"] = "Allocate Offset Random";
  return HandlerName;
}(HandlerName || {});
export var DataType = /*#__PURE__*/function (DataType) {
  DataType["dataSource"] = "dataSource";
  DataType["customState"] = "customState";
  return DataType;
}({});
export var RuleSetterService = /*#__PURE__*/function () {
  function RuleSetterService(webGid) {
    this.webGid = void 0;
    this.webGid = webGid;
  }
  var _proto = RuleSetterService.prototype;
  _proto.getDataSourceList = function getDataSourceList() {
    var schemaService = new SchemaService();
    var dataSourceList = schemaService.getDataSourceList(this.webGid);
    var customState = schemaService.getCustomStateList(this.webGid);
    return {
      dataSourceList: dataSourceList,
      customState: customState
    };
  };
  _proto.getOptionsByDataSourceList = function getOptionsByDataSourceList() {
    var dataSourceListRes = [];
    var _this$getDataSourceLi = this.getDataSourceList(),
      dataSourceList = _this$getDataSourceLi.dataSourceList,
      customState = _this$getDataSourceLi.customState;
    dataSourceList.map(function (item) {
      var _item$options, _item$options$dataSou, _item$options2, _item$options2$dataSo;
      if ((item === null || item === void 0 ? void 0 : (_item$options = item.options) === null || _item$options === void 0 ? void 0 : (_item$options$dataSou = _item$options.dataSource) === null || _item$options$dataSou === void 0 ? void 0 : _item$options$dataSou.handlerName) === HandlerName['Allocate Offset Random'] || (item === null || item === void 0 ? void 0 : (_item$options2 = item.options) === null || _item$options2 === void 0 ? void 0 : (_item$options2$dataSo = _item$options2.dataSource) === null || _item$options2$dataSo === void 0 ? void 0 : _item$options2$dataSo.handlerName) === HandlerName['Allocate Random']) {
        var _item$options3, _item$options3$dataSo, _item$options4, _item$options4$dataSo, _item$options4$dataSo2, _item$options4$dataSo3, _item$options4$dataSo4, _item$options5, _item$options5$dataSo;
        dataSourceListRes.push({
          label: item.options.dataSourceName,
          value: item.id,
          ruleId: (item === null || item === void 0 ? void 0 : (_item$options3 = item.options) === null || _item$options3 === void 0 ? void 0 : (_item$options3$dataSo = _item$options3.dataSource) === null || _item$options3$dataSo === void 0 ? void 0 : _item$options3$dataSo.ruleId) || (item === null || item === void 0 ? void 0 : (_item$options4 = item.options) === null || _item$options4 === void 0 ? void 0 : (_item$options4$dataSo = _item$options4.dataSource) === null || _item$options4$dataSo === void 0 ? void 0 : (_item$options4$dataSo2 = _item$options4$dataSo.apiParams) === null || _item$options4$dataSo2 === void 0 ? void 0 : (_item$options4$dataSo3 = _item$options4$dataSo2.filter(function (i) {
            return i.name === 'ruleId';
          })) === null || _item$options4$dataSo3 === void 0 ? void 0 : (_item$options4$dataSo4 = _item$options4$dataSo3[0]) === null || _item$options4$dataSo4 === void 0 ? void 0 : _item$options4$dataSo4.data),
          chainId: item === null || item === void 0 ? void 0 : (_item$options5 = item.options) === null || _item$options5 === void 0 ? void 0 : (_item$options5$dataSo = _item$options5.dataSource) === null || _item$options5$dataSo === void 0 ? void 0 : _item$options5$dataSo.chainId
        });
      }
    });

    //自定义变量
    var customList = [];
    for (var key in customState) {
      customList.push({
        label: key,
        value: key,
        list: customState[key].list
      });
    }
    return {
      dataSourceList: dataSourceListRes,
      customList: customList
    };
  };
  return RuleSetterService;
}();