"use strict";

var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.GenesisState = void 0;
var _claims = require("./claims");
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
/** GenesisState defines the claims module's genesis state. */

/** GenesisState defines the claims module's genesis state. */

function createBaseGenesisState() {
  return {
    params: undefined,
    collections: [],
    claims: [],
    disputes: [],
    intents: []
  };
}
var GenesisState = exports.GenesisState = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.params !== undefined) {
      _claims.Params.encode(message.params, writer.uint32(10).fork()).ldelim();
    }
    var _iterator = _createForOfIteratorHelper(message.collections),
      _step;
    try {
      for (_iterator.s(); !(_step = _iterator.n()).done;) {
        var v = _step.value;
        _claims.Collection.encode(v, writer.uint32(18).fork()).ldelim();
      }
    } catch (err) {
      _iterator.e(err);
    } finally {
      _iterator.f();
    }
    var _iterator2 = _createForOfIteratorHelper(message.claims),
      _step2;
    try {
      for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
        var _v = _step2.value;
        _claims.Claim.encode(_v, writer.uint32(26).fork()).ldelim();
      }
    } catch (err) {
      _iterator2.e(err);
    } finally {
      _iterator2.f();
    }
    var _iterator3 = _createForOfIteratorHelper(message.disputes),
      _step3;
    try {
      for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
        var _v2 = _step3.value;
        _claims.Dispute.encode(_v2, writer.uint32(34).fork()).ldelim();
      }
    } catch (err) {
      _iterator3.e(err);
    } finally {
      _iterator3.f();
    }
    var _iterator4 = _createForOfIteratorHelper(message.intents),
      _step4;
    try {
      for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
        var _v3 = _step4.value;
        _claims.Intent.encode(_v3, writer.uint32(42).fork()).ldelim();
      }
    } catch (err) {
      _iterator4.e(err);
    } finally {
      _iterator4.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 = createBaseGenesisState();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.params = _claims.Params.decode(reader, reader.uint32());
          break;
        case 2:
          message.collections.push(_claims.Collection.decode(reader, reader.uint32()));
          break;
        case 3:
          message.claims.push(_claims.Claim.decode(reader, reader.uint32()));
          break;
        case 4:
          message.disputes.push(_claims.Dispute.decode(reader, reader.uint32()));
          break;
        case 5:
          message.intents.push(_claims.Intent.decode(reader, reader.uint32()));
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      params: (0, _helpers.isSet)(object.params) ? _claims.Params.fromJSON(object.params) : undefined,
      collections: Array.isArray(object === null || object === void 0 ? void 0 : object.collections) ? object.collections.map(function (e) {
        return _claims.Collection.fromJSON(e);
      }) : [],
      claims: Array.isArray(object === null || object === void 0 ? void 0 : object.claims) ? object.claims.map(function (e) {
        return _claims.Claim.fromJSON(e);
      }) : [],
      disputes: Array.isArray(object === null || object === void 0 ? void 0 : object.disputes) ? object.disputes.map(function (e) {
        return _claims.Dispute.fromJSON(e);
      }) : [],
      intents: Array.isArray(object === null || object === void 0 ? void 0 : object.intents) ? object.intents.map(function (e) {
        return _claims.Intent.fromJSON(e);
      }) : []
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message.params !== undefined && (obj.params = message.params ? _claims.Params.toJSON(message.params) : undefined);
    if (message.collections) {
      obj.collections = message.collections.map(function (e) {
        return e ? _claims.Collection.toJSON(e) : undefined;
      });
    } else {
      obj.collections = [];
    }
    if (message.claims) {
      obj.claims = message.claims.map(function (e) {
        return e ? _claims.Claim.toJSON(e) : undefined;
      });
    } else {
      obj.claims = [];
    }
    if (message.disputes) {
      obj.disputes = message.disputes.map(function (e) {
        return e ? _claims.Dispute.toJSON(e) : undefined;
      });
    } else {
      obj.disputes = [];
    }
    if (message.intents) {
      obj.intents = message.intents.map(function (e) {
        return e ? _claims.Intent.toJSON(e) : undefined;
      });
    } else {
      obj.intents = [];
    }
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var _object$collections, _object$claims, _object$disputes, _object$intents;
    var message = createBaseGenesisState();
    message.params = object.params !== undefined && object.params !== null ? _claims.Params.fromPartial(object.params) : undefined;
    message.collections = ((_object$collections = object.collections) === null || _object$collections === void 0 ? void 0 : _object$collections.map(function (e) {
      return _claims.Collection.fromPartial(e);
    })) || [];
    message.claims = ((_object$claims = object.claims) === null || _object$claims === void 0 ? void 0 : _object$claims.map(function (e) {
      return _claims.Claim.fromPartial(e);
    })) || [];
    message.disputes = ((_object$disputes = object.disputes) === null || _object$disputes === void 0 ? void 0 : _object$disputes.map(function (e) {
      return _claims.Dispute.fromPartial(e);
    })) || [];
    message.intents = ((_object$intents = object.intents) === null || _object$intents === void 0 ? void 0 : _object$intents.map(function (e) {
      return _claims.Intent.fromPartial(e);
    })) || [];
    return message;
  }
};