"use strict";

var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.StoreKeyConfig = exports.Module = void 0;
var _m0 = _interopRequireWildcard(require("protobufjs/minimal"));
var _helpers = require("../../../../helpers");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } //@ts-nocheck
/** Module is the config object for the runtime module. */

/** Module is the config object for the runtime module. */

/**
 * StoreKeyConfig may be supplied to override the default module store key, which
 * is the module name.
 */

/**
 * StoreKeyConfig may be supplied to override the default module store key, which
 * is the module name.
 */

function createBaseModule() {
  return {
    appName: "",
    beginBlockers: [],
    endBlockers: [],
    initGenesis: [],
    exportGenesis: [],
    overrideStoreKeys: [],
    orderMigrations: [],
    precommiters: [],
    prepareCheckStaters: []
  };
}
var Module = exports.Module = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.appName !== "") {
      writer.uint32(10).string(message.appName);
    }
    var _iterator = _createForOfIteratorHelper(message.beginBlockers),
      _step;
    try {
      for (_iterator.s(); !(_step = _iterator.n()).done;) {
        var v = _step.value;
        writer.uint32(18).string(v);
      }
    } catch (err) {
      _iterator.e(err);
    } finally {
      _iterator.f();
    }
    var _iterator2 = _createForOfIteratorHelper(message.endBlockers),
      _step2;
    try {
      for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
        var _v = _step2.value;
        writer.uint32(26).string(_v);
      }
    } catch (err) {
      _iterator2.e(err);
    } finally {
      _iterator2.f();
    }
    var _iterator3 = _createForOfIteratorHelper(message.initGenesis),
      _step3;
    try {
      for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
        var _v2 = _step3.value;
        writer.uint32(34).string(_v2);
      }
    } catch (err) {
      _iterator3.e(err);
    } finally {
      _iterator3.f();
    }
    var _iterator4 = _createForOfIteratorHelper(message.exportGenesis),
      _step4;
    try {
      for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
        var _v3 = _step4.value;
        writer.uint32(42).string(_v3);
      }
    } catch (err) {
      _iterator4.e(err);
    } finally {
      _iterator4.f();
    }
    var _iterator5 = _createForOfIteratorHelper(message.overrideStoreKeys),
      _step5;
    try {
      for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
        var _v4 = _step5.value;
        StoreKeyConfig.encode(_v4, writer.uint32(50).fork()).ldelim();
      }
    } catch (err) {
      _iterator5.e(err);
    } finally {
      _iterator5.f();
    }
    var _iterator6 = _createForOfIteratorHelper(message.orderMigrations),
      _step6;
    try {
      for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
        var _v5 = _step6.value;
        writer.uint32(58).string(_v5);
      }
    } catch (err) {
      _iterator6.e(err);
    } finally {
      _iterator6.f();
    }
    var _iterator7 = _createForOfIteratorHelper(message.precommiters),
      _step7;
    try {
      for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
        var _v6 = _step7.value;
        writer.uint32(66).string(_v6);
      }
    } catch (err) {
      _iterator7.e(err);
    } finally {
      _iterator7.f();
    }
    var _iterator8 = _createForOfIteratorHelper(message.prepareCheckStaters),
      _step8;
    try {
      for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
        var _v7 = _step8.value;
        writer.uint32(74).string(_v7);
      }
    } catch (err) {
      _iterator8.e(err);
    } finally {
      _iterator8.f();
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseModule();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.appName = reader.string();
          break;
        case 2:
          message.beginBlockers.push(reader.string());
          break;
        case 3:
          message.endBlockers.push(reader.string());
          break;
        case 4:
          message.initGenesis.push(reader.string());
          break;
        case 5:
          message.exportGenesis.push(reader.string());
          break;
        case 6:
          message.overrideStoreKeys.push(StoreKeyConfig.decode(reader, reader.uint32()));
          break;
        case 7:
          message.orderMigrations.push(reader.string());
          break;
        case 8:
          message.precommiters.push(reader.string());
          break;
        case 9:
          message.prepareCheckStaters.push(reader.string());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      appName: (0, _helpers.isSet)(object.appName) ? String(object.appName) : "",
      beginBlockers: Array.isArray(object === null || object === void 0 ? void 0 : object.beginBlockers) ? object.beginBlockers.map(function (e) {
        return String(e);
      }) : [],
      endBlockers: Array.isArray(object === null || object === void 0 ? void 0 : object.endBlockers) ? object.endBlockers.map(function (e) {
        return String(e);
      }) : [],
      initGenesis: Array.isArray(object === null || object === void 0 ? void 0 : object.initGenesis) ? object.initGenesis.map(function (e) {
        return String(e);
      }) : [],
      exportGenesis: Array.isArray(object === null || object === void 0 ? void 0 : object.exportGenesis) ? object.exportGenesis.map(function (e) {
        return String(e);
      }) : [],
      overrideStoreKeys: Array.isArray(object === null || object === void 0 ? void 0 : object.overrideStoreKeys) ? object.overrideStoreKeys.map(function (e) {
        return StoreKeyConfig.fromJSON(e);
      }) : [],
      orderMigrations: Array.isArray(object === null || object === void 0 ? void 0 : object.orderMigrations) ? object.orderMigrations.map(function (e) {
        return String(e);
      }) : [],
      precommiters: Array.isArray(object === null || object === void 0 ? void 0 : object.precommiters) ? object.precommiters.map(function (e) {
        return String(e);
      }) : [],
      prepareCheckStaters: Array.isArray(object === null || object === void 0 ? void 0 : object.prepareCheckStaters) ? object.prepareCheckStaters.map(function (e) {
        return String(e);
      }) : []
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message.appName !== undefined && (obj.appName = message.appName);
    if (message.beginBlockers) {
      obj.beginBlockers = message.beginBlockers.map(function (e) {
        return e;
      });
    } else {
      obj.beginBlockers = [];
    }
    if (message.endBlockers) {
      obj.endBlockers = message.endBlockers.map(function (e) {
        return e;
      });
    } else {
      obj.endBlockers = [];
    }
    if (message.initGenesis) {
      obj.initGenesis = message.initGenesis.map(function (e) {
        return e;
      });
    } else {
      obj.initGenesis = [];
    }
    if (message.exportGenesis) {
      obj.exportGenesis = message.exportGenesis.map(function (e) {
        return e;
      });
    } else {
      obj.exportGenesis = [];
    }
    if (message.overrideStoreKeys) {
      obj.overrideStoreKeys = message.overrideStoreKeys.map(function (e) {
        return e ? StoreKeyConfig.toJSON(e) : undefined;
      });
    } else {
      obj.overrideStoreKeys = [];
    }
    if (message.orderMigrations) {
      obj.orderMigrations = message.orderMigrations.map(function (e) {
        return e;
      });
    } else {
      obj.orderMigrations = [];
    }
    if (message.precommiters) {
      obj.precommiters = message.precommiters.map(function (e) {
        return e;
      });
    } else {
      obj.precommiters = [];
    }
    if (message.prepareCheckStaters) {
      obj.prepareCheckStaters = message.prepareCheckStaters.map(function (e) {
        return e;
      });
    } else {
      obj.prepareCheckStaters = [];
    }
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var _object$appName, _object$beginBlockers, _object$endBlockers, _object$initGenesis, _object$exportGenesis, _object$overrideStore, _object$orderMigratio, _object$precommiters, _object$prepareCheckS;
    var message = createBaseModule();
    message.appName = (_object$appName = object.appName) !== null && _object$appName !== void 0 ? _object$appName : "";
    message.beginBlockers = ((_object$beginBlockers = object.beginBlockers) === null || _object$beginBlockers === void 0 ? void 0 : _object$beginBlockers.map(function (e) {
      return e;
    })) || [];
    message.endBlockers = ((_object$endBlockers = object.endBlockers) === null || _object$endBlockers === void 0 ? void 0 : _object$endBlockers.map(function (e) {
      return e;
    })) || [];
    message.initGenesis = ((_object$initGenesis = object.initGenesis) === null || _object$initGenesis === void 0 ? void 0 : _object$initGenesis.map(function (e) {
      return e;
    })) || [];
    message.exportGenesis = ((_object$exportGenesis = object.exportGenesis) === null || _object$exportGenesis === void 0 ? void 0 : _object$exportGenesis.map(function (e) {
      return e;
    })) || [];
    message.overrideStoreKeys = ((_object$overrideStore = object.overrideStoreKeys) === null || _object$overrideStore === void 0 ? void 0 : _object$overrideStore.map(function (e) {
      return StoreKeyConfig.fromPartial(e);
    })) || [];
    message.orderMigrations = ((_object$orderMigratio = object.orderMigrations) === null || _object$orderMigratio === void 0 ? void 0 : _object$orderMigratio.map(function (e) {
      return e;
    })) || [];
    message.precommiters = ((_object$precommiters = object.precommiters) === null || _object$precommiters === void 0 ? void 0 : _object$precommiters.map(function (e) {
      return e;
    })) || [];
    message.prepareCheckStaters = ((_object$prepareCheckS = object.prepareCheckStaters) === null || _object$prepareCheckS === void 0 ? void 0 : _object$prepareCheckS.map(function (e) {
      return e;
    })) || [];
    return message;
  }
};
function createBaseStoreKeyConfig() {
  return {
    moduleName: "",
    kvStoreKey: ""
  };
}
var StoreKeyConfig = exports.StoreKeyConfig = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.moduleName !== "") {
      writer.uint32(10).string(message.moduleName);
    }
    if (message.kvStoreKey !== "") {
      writer.uint32(18).string(message.kvStoreKey);
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseStoreKeyConfig();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.moduleName = reader.string();
          break;
        case 2:
          message.kvStoreKey = reader.string();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      moduleName: (0, _helpers.isSet)(object.moduleName) ? String(object.moduleName) : "",
      kvStoreKey: (0, _helpers.isSet)(object.kvStoreKey) ? String(object.kvStoreKey) : ""
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message.moduleName !== undefined && (obj.moduleName = message.moduleName);
    message.kvStoreKey !== undefined && (obj.kvStoreKey = message.kvStoreKey);
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var _object$moduleName, _object$kvStoreKey;
    var message = createBaseStoreKeyConfig();
    message.moduleName = (_object$moduleName = object.moduleName) !== null && _object$moduleName !== void 0 ? _object$moduleName : "";
    message.kvStoreKey = (_object$kvStoreKey = object.kvStoreKey) !== null && _object$kvStoreKey !== void 0 ? _object$kvStoreKey : "";
    return message;
  }
};