"use strict";

var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Params = exports.EntityMetadata = exports.EntityAccount = exports.Entity = void 0;
var _timestamp = require("../../../google/protobuf/timestamp");
var _helpers = require("../../../helpers");
var _m0 = _interopRequireWildcard(require("protobufjs/minimal"));
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
/** EntityMetadata defines metadata associated to a entity */

/** EntityMetadata defines metadata associated to a entity */

function createBaseParams() {
  return {
    nftContractAddress: "",
    nftContractMinter: "",
    createSequence: _helpers.Long.UZERO
  };
}
var Params = exports.Params = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.nftContractAddress !== "") {
      writer.uint32(10).string(message.nftContractAddress);
    }
    if (message.nftContractMinter !== "") {
      writer.uint32(18).string(message.nftContractMinter);
    }
    if (!message.createSequence.isZero()) {
      writer.uint32(24).uint64(message.createSequence);
    }
    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 = createBaseParams();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.nftContractAddress = reader.string();
          break;
        case 2:
          message.nftContractMinter = reader.string();
          break;
        case 3:
          message.createSequence = reader.uint64();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      nftContractAddress: (0, _helpers.isSet)(object.nftContractAddress) ? String(object.nftContractAddress) : "",
      nftContractMinter: (0, _helpers.isSet)(object.nftContractMinter) ? String(object.nftContractMinter) : "",
      createSequence: (0, _helpers.isSet)(object.createSequence) ? _helpers.Long.fromValue(object.createSequence) : _helpers.Long.UZERO
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message.nftContractAddress !== undefined && (obj.nftContractAddress = message.nftContractAddress);
    message.nftContractMinter !== undefined && (obj.nftContractMinter = message.nftContractMinter);
    message.createSequence !== undefined && (obj.createSequence = (message.createSequence || _helpers.Long.UZERO).toString());
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var _object$nftContractAd, _object$nftContractMi;
    var message = createBaseParams();
    message.nftContractAddress = (_object$nftContractAd = object.nftContractAddress) !== null && _object$nftContractAd !== void 0 ? _object$nftContractAd : "";
    message.nftContractMinter = (_object$nftContractMi = object.nftContractMinter) !== null && _object$nftContractMi !== void 0 ? _object$nftContractMi : "";
    message.createSequence = object.createSequence !== undefined && object.createSequence !== null ? _helpers.Long.fromValue(object.createSequence) : _helpers.Long.UZERO;
    return message;
  }
};
function createBaseEntity() {
  return {
    id: "",
    type: "",
    startDate: undefined,
    endDate: undefined,
    status: 0,
    relayerNode: "",
    credentials: [],
    entityVerified: false,
    metadata: undefined,
    accounts: []
  };
}
var Entity = exports.Entity = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.id !== "") {
      writer.uint32(10).string(message.id);
    }
    if (message.type !== "") {
      writer.uint32(18).string(message.type);
    }
    if (message.startDate !== undefined) {
      _timestamp.Timestamp.encode(message.startDate, writer.uint32(26).fork()).ldelim();
    }
    if (message.endDate !== undefined) {
      _timestamp.Timestamp.encode(message.endDate, writer.uint32(34).fork()).ldelim();
    }
    if (message.status !== 0) {
      writer.uint32(40).int32(message.status);
    }
    if (message.relayerNode !== "") {
      writer.uint32(50).string(message.relayerNode);
    }
    var _iterator = _createForOfIteratorHelper(message.credentials),
      _step;
    try {
      for (_iterator.s(); !(_step = _iterator.n()).done;) {
        var v = _step.value;
        writer.uint32(58).string(v);
      }
    } catch (err) {
      _iterator.e(err);
    } finally {
      _iterator.f();
    }
    if (message.entityVerified === true) {
      writer.uint32(64).bool(message.entityVerified);
    }
    if (message.metadata !== undefined) {
      EntityMetadata.encode(message.metadata, writer.uint32(74).fork()).ldelim();
    }
    var _iterator2 = _createForOfIteratorHelper(message.accounts),
      _step2;
    try {
      for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
        var _v = _step2.value;
        EntityAccount.encode(_v, writer.uint32(82).fork()).ldelim();
      }
    } catch (err) {
      _iterator2.e(err);
    } finally {
      _iterator2.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 = createBaseEntity();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.id = reader.string();
          break;
        case 2:
          message.type = reader.string();
          break;
        case 3:
          message.startDate = _timestamp.Timestamp.decode(reader, reader.uint32());
          break;
        case 4:
          message.endDate = _timestamp.Timestamp.decode(reader, reader.uint32());
          break;
        case 5:
          message.status = reader.int32();
          break;
        case 6:
          message.relayerNode = reader.string();
          break;
        case 7:
          message.credentials.push(reader.string());
          break;
        case 8:
          message.entityVerified = reader.bool();
          break;
        case 9:
          message.metadata = EntityMetadata.decode(reader, reader.uint32());
          break;
        case 10:
          message.accounts.push(EntityAccount.decode(reader, reader.uint32()));
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      id: (0, _helpers.isSet)(object.id) ? String(object.id) : "",
      type: (0, _helpers.isSet)(object.type) ? String(object.type) : "",
      startDate: (0, _helpers.isSet)(object.startDate) ? (0, _helpers.fromJsonTimestamp)(object.startDate) : undefined,
      endDate: (0, _helpers.isSet)(object.endDate) ? (0, _helpers.fromJsonTimestamp)(object.endDate) : undefined,
      status: (0, _helpers.isSet)(object.status) ? Number(object.status) : 0,
      relayerNode: (0, _helpers.isSet)(object.relayerNode) ? String(object.relayerNode) : "",
      credentials: Array.isArray(object === null || object === void 0 ? void 0 : object.credentials) ? object.credentials.map(function (e) {
        return String(e);
      }) : [],
      entityVerified: (0, _helpers.isSet)(object.entityVerified) ? Boolean(object.entityVerified) : false,
      metadata: (0, _helpers.isSet)(object.metadata) ? EntityMetadata.fromJSON(object.metadata) : undefined,
      accounts: Array.isArray(object === null || object === void 0 ? void 0 : object.accounts) ? object.accounts.map(function (e) {
        return EntityAccount.fromJSON(e);
      }) : []
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message.id !== undefined && (obj.id = message.id);
    message.type !== undefined && (obj.type = message.type);
    message.startDate !== undefined && (obj.startDate = (0, _helpers.fromTimestamp)(message.startDate).toISOString());
    message.endDate !== undefined && (obj.endDate = (0, _helpers.fromTimestamp)(message.endDate).toISOString());
    message.status !== undefined && (obj.status = Math.round(message.status));
    message.relayerNode !== undefined && (obj.relayerNode = message.relayerNode);
    if (message.credentials) {
      obj.credentials = message.credentials.map(function (e) {
        return e;
      });
    } else {
      obj.credentials = [];
    }
    message.entityVerified !== undefined && (obj.entityVerified = message.entityVerified);
    message.metadata !== undefined && (obj.metadata = message.metadata ? EntityMetadata.toJSON(message.metadata) : undefined);
    if (message.accounts) {
      obj.accounts = message.accounts.map(function (e) {
        return e ? EntityAccount.toJSON(e) : undefined;
      });
    } else {
      obj.accounts = [];
    }
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var _object$id, _object$type, _object$status, _object$relayerNode, _object$credentials, _object$entityVerifie, _object$accounts;
    var message = createBaseEntity();
    message.id = (_object$id = object.id) !== null && _object$id !== void 0 ? _object$id : "";
    message.type = (_object$type = object.type) !== null && _object$type !== void 0 ? _object$type : "";
    message.startDate = object.startDate !== undefined && object.startDate !== null ? _timestamp.Timestamp.fromPartial(object.startDate) : undefined;
    message.endDate = object.endDate !== undefined && object.endDate !== null ? _timestamp.Timestamp.fromPartial(object.endDate) : undefined;
    message.status = (_object$status = object.status) !== null && _object$status !== void 0 ? _object$status : 0;
    message.relayerNode = (_object$relayerNode = object.relayerNode) !== null && _object$relayerNode !== void 0 ? _object$relayerNode : "";
    message.credentials = ((_object$credentials = object.credentials) === null || _object$credentials === void 0 ? void 0 : _object$credentials.map(function (e) {
      return e;
    })) || [];
    message.entityVerified = (_object$entityVerifie = object.entityVerified) !== null && _object$entityVerifie !== void 0 ? _object$entityVerifie : false;
    message.metadata = object.metadata !== undefined && object.metadata !== null ? EntityMetadata.fromPartial(object.metadata) : undefined;
    message.accounts = ((_object$accounts = object.accounts) === null || _object$accounts === void 0 ? void 0 : _object$accounts.map(function (e) {
      return EntityAccount.fromPartial(e);
    })) || [];
    return message;
  }
};
function createBaseEntityAccount() {
  return {
    name: "",
    address: ""
  };
}
var EntityAccount = exports.EntityAccount = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.name !== "") {
      writer.uint32(10).string(message.name);
    }
    if (message.address !== "") {
      writer.uint32(18).string(message.address);
    }
    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 = createBaseEntityAccount();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.name = reader.string();
          break;
        case 2:
          message.address = reader.string();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      name: (0, _helpers.isSet)(object.name) ? String(object.name) : "",
      address: (0, _helpers.isSet)(object.address) ? String(object.address) : ""
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message.name !== undefined && (obj.name = message.name);
    message.address !== undefined && (obj.address = message.address);
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var _object$name, _object$address;
    var message = createBaseEntityAccount();
    message.name = (_object$name = object.name) !== null && _object$name !== void 0 ? _object$name : "";
    message.address = (_object$address = object.address) !== null && _object$address !== void 0 ? _object$address : "";
    return message;
  }
};
function createBaseEntityMetadata() {
  return {
    versionId: "",
    created: undefined,
    updated: undefined
  };
}
var EntityMetadata = exports.EntityMetadata = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.versionId !== "") {
      writer.uint32(10).string(message.versionId);
    }
    if (message.created !== undefined) {
      _timestamp.Timestamp.encode(message.created, writer.uint32(18).fork()).ldelim();
    }
    if (message.updated !== undefined) {
      _timestamp.Timestamp.encode(message.updated, writer.uint32(26).fork()).ldelim();
    }
    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 = createBaseEntityMetadata();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.versionId = reader.string();
          break;
        case 2:
          message.created = _timestamp.Timestamp.decode(reader, reader.uint32());
          break;
        case 3:
          message.updated = _timestamp.Timestamp.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      versionId: (0, _helpers.isSet)(object.versionId) ? String(object.versionId) : "",
      created: (0, _helpers.isSet)(object.created) ? (0, _helpers.fromJsonTimestamp)(object.created) : undefined,
      updated: (0, _helpers.isSet)(object.updated) ? (0, _helpers.fromJsonTimestamp)(object.updated) : undefined
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message.versionId !== undefined && (obj.versionId = message.versionId);
    message.created !== undefined && (obj.created = (0, _helpers.fromTimestamp)(message.created).toISOString());
    message.updated !== undefined && (obj.updated = (0, _helpers.fromTimestamp)(message.updated).toISOString());
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var _object$versionId;
    var message = createBaseEntityMetadata();
    message.versionId = (_object$versionId = object.versionId) !== null && _object$versionId !== void 0 ? _object$versionId : "";
    message.created = object.created !== undefined && object.created !== null ? _timestamp.Timestamp.fromPartial(object.created) : undefined;
    message.updated = object.updated !== undefined && object.updated !== null ? _timestamp.Timestamp.fromPartial(object.updated) : undefined;
    return message;
  }
};