"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.UserDao = exports.User = void 0;
var _binary = require("../binary");
var _helpers = require("../helpers");
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, 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 normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function createBaseUser() {
  return {
    creator: "",
    id: BigInt(0),
    name: "",
    username: "",
    usernameGithub: "",
    avatarUrl: "",
    followers: [],
    following: [],
    starredRepos: [],
    subscriptions: "",
    bio: "",
    createdAt: BigInt(0),
    updatedAt: BigInt(0),
    verified: false,
    pinnedRepos: []
  };
}
var User = exports.User = {
  typeUrl: "/gitopia.gitopia.gitopia.User",
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _binary.BinaryWriter.create();
    if (message.creator !== "") {
      writer.uint32(10).string(message.creator);
    }
    if (message.id !== BigInt(0)) {
      writer.uint32(16).uint64(message.id);
    }
    if (message.name !== "") {
      writer.uint32(26).string(message.name);
    }
    if (message.username !== "") {
      writer.uint32(34).string(message.username);
    }
    if (message.usernameGithub !== "") {
      writer.uint32(42).string(message.usernameGithub);
    }
    if (message.avatarUrl !== "") {
      writer.uint32(50).string(message.avatarUrl);
    }
    var _iterator = _createForOfIteratorHelper(message.followers),
      _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();
    }
    var _iterator2 = _createForOfIteratorHelper(message.following),
      _step2;
    try {
      for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
        var _v = _step2.value;
        writer.uint32(66).string(_v);
      }
    } catch (err) {
      _iterator2.e(err);
    } finally {
      _iterator2.f();
    }
    writer.uint32(74).fork();
    var _iterator3 = _createForOfIteratorHelper(message.starredRepos),
      _step3;
    try {
      for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
        var _v2 = _step3.value;
        writer.uint64(_v2);
      }
    } catch (err) {
      _iterator3.e(err);
    } finally {
      _iterator3.f();
    }
    writer.ldelim();
    if (message.subscriptions !== "") {
      writer.uint32(82).string(message.subscriptions);
    }
    if (message.bio !== "") {
      writer.uint32(90).string(message.bio);
    }
    if (message.createdAt !== BigInt(0)) {
      writer.uint32(96).int64(message.createdAt);
    }
    if (message.updatedAt !== BigInt(0)) {
      writer.uint32(104).int64(message.updatedAt);
    }
    if (message.verified === true) {
      writer.uint32(112).bool(message.verified);
    }
    writer.uint32(122).fork();
    var _iterator4 = _createForOfIteratorHelper(message.pinnedRepos),
      _step4;
    try {
      for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
        var _v3 = _step4.value;
        writer.uint64(_v3);
      }
    } catch (err) {
      _iterator4.e(err);
    } finally {
      _iterator4.f();
    }
    writer.ldelim();
    return writer;
  },
  fromJSON: function fromJSON(object) {
    return {
      creator: (0, _helpers.isSet)(object.creator) ? String(object.creator) : "",
      id: (0, _helpers.isSet)(object.id) ? BigInt(object.id.toString()) : BigInt(0),
      name: (0, _helpers.isSet)(object.name) ? String(object.name) : "",
      username: (0, _helpers.isSet)(object.username) ? String(object.username) : "",
      usernameGithub: (0, _helpers.isSet)(object.usernameGithub) ? String(object.usernameGithub) : "",
      avatarUrl: (0, _helpers.isSet)(object.avatarUrl) ? String(object.avatarUrl) : "",
      followers: Array.isArray(object === null || object === void 0 ? void 0 : object.followers) ? object.followers.map(function (e) {
        return String(e);
      }) : [],
      following: Array.isArray(object === null || object === void 0 ? void 0 : object.following) ? object.following.map(function (e) {
        return String(e);
      }) : [],
      starredRepos: Array.isArray(object === null || object === void 0 ? void 0 : object.starredRepos) ? object.starredRepos.map(function (e) {
        return BigInt(e.toString());
      }) : [],
      subscriptions: (0, _helpers.isSet)(object.subscriptions) ? String(object.subscriptions) : "",
      bio: (0, _helpers.isSet)(object.bio) ? String(object.bio) : "",
      createdAt: (0, _helpers.isSet)(object.createdAt) ? BigInt(object.createdAt.toString()) : BigInt(0),
      updatedAt: (0, _helpers.isSet)(object.updatedAt) ? BigInt(object.updatedAt.toString()) : BigInt(0),
      verified: (0, _helpers.isSet)(object.verified) ? Boolean(object.verified) : false,
      pinnedRepos: Array.isArray(object === null || object === void 0 ? void 0 : object.pinnedRepos) ? object.pinnedRepos.map(function (e) {
        return BigInt(e.toString());
      }) : []
    };
  },
  fromPartial: function fromPartial(object) {
    var _object$creator, _object$name, _object$username, _object$usernameGithu, _object$avatarUrl, _object$followers, _object$following, _object$starredRepos, _object$subscriptions, _object$bio, _object$verified, _object$pinnedRepos;
    var message = createBaseUser();
    message.creator = (_object$creator = object.creator) !== null && _object$creator !== void 0 ? _object$creator : "";
    message.id = object.id !== undefined && object.id !== null ? BigInt(object.id.toString()) : BigInt(0);
    message.name = (_object$name = object.name) !== null && _object$name !== void 0 ? _object$name : "";
    message.username = (_object$username = object.username) !== null && _object$username !== void 0 ? _object$username : "";
    message.usernameGithub = (_object$usernameGithu = object.usernameGithub) !== null && _object$usernameGithu !== void 0 ? _object$usernameGithu : "";
    message.avatarUrl = (_object$avatarUrl = object.avatarUrl) !== null && _object$avatarUrl !== void 0 ? _object$avatarUrl : "";
    message.followers = ((_object$followers = object.followers) === null || _object$followers === void 0 ? void 0 : _object$followers.map(function (e) {
      return e;
    })) || [];
    message.following = ((_object$following = object.following) === null || _object$following === void 0 ? void 0 : _object$following.map(function (e) {
      return e;
    })) || [];
    message.starredRepos = ((_object$starredRepos = object.starredRepos) === null || _object$starredRepos === void 0 ? void 0 : _object$starredRepos.map(function (e) {
      return BigInt(e.toString());
    })) || [];
    message.subscriptions = (_object$subscriptions = object.subscriptions) !== null && _object$subscriptions !== void 0 ? _object$subscriptions : "";
    message.bio = (_object$bio = object.bio) !== null && _object$bio !== void 0 ? _object$bio : "";
    message.createdAt = object.createdAt !== undefined && object.createdAt !== null ? BigInt(object.createdAt.toString()) : BigInt(0);
    message.updatedAt = object.updatedAt !== undefined && object.updatedAt !== null ? BigInt(object.updatedAt.toString()) : BigInt(0);
    message.verified = (_object$verified = object.verified) !== null && _object$verified !== void 0 ? _object$verified : false;
    message.pinnedRepos = ((_object$pinnedRepos = object.pinnedRepos) === null || _object$pinnedRepos === void 0 ? void 0 : _object$pinnedRepos.map(function (e) {
      return BigInt(e.toString());
    })) || [];
    return message;
  },
  fromAmino: function fromAmino(object) {
    var _object$followers2, _object$following2, _object$starred_repos, _object$pinned_repos;
    var message = createBaseUser();
    if (object.creator !== undefined && object.creator !== null) {
      message.creator = object.creator;
    }
    if (object.id !== undefined && object.id !== null) {
      message.id = BigInt(object.id);
    }
    if (object.name !== undefined && object.name !== null) {
      message.name = object.name;
    }
    if (object.username !== undefined && object.username !== null) {
      message.username = object.username;
    }
    if (object.usernameGithub !== undefined && object.usernameGithub !== null) {
      message.usernameGithub = object.usernameGithub;
    }
    if (object.avatarUrl !== undefined && object.avatarUrl !== null) {
      message.avatarUrl = object.avatarUrl;
    }
    message.followers = ((_object$followers2 = object.followers) === null || _object$followers2 === void 0 ? void 0 : _object$followers2.map(function (e) {
      return e;
    })) || [];
    message.following = ((_object$following2 = object.following) === null || _object$following2 === void 0 ? void 0 : _object$following2.map(function (e) {
      return e;
    })) || [];
    message.starredRepos = ((_object$starred_repos = object.starred_repos) === null || _object$starred_repos === void 0 ? void 0 : _object$starred_repos.map(function (e) {
      return BigInt(e);
    })) || [];
    if (object.subscriptions !== undefined && object.subscriptions !== null) {
      message.subscriptions = object.subscriptions;
    }
    if (object.bio !== undefined && object.bio !== null) {
      message.bio = object.bio;
    }
    if (object.createdAt !== undefined && object.createdAt !== null) {
      message.createdAt = BigInt(object.createdAt);
    }
    if (object.updatedAt !== undefined && object.updatedAt !== null) {
      message.updatedAt = BigInt(object.updatedAt);
    }
    if (object.verified !== undefined && object.verified !== null) {
      message.verified = object.verified;
    }
    message.pinnedRepos = ((_object$pinned_repos = object.pinned_repos) === null || _object$pinned_repos === void 0 ? void 0 : _object$pinned_repos.map(function (e) {
      return BigInt(e);
    })) || [];
    return message;
  },
  toAmino: function toAmino(message) {
    var obj = {};
    obj.creator = message.creator === "" ? undefined : message.creator;
    obj.id = message.id !== BigInt(0) ? message.id.toString() : undefined;
    obj.name = message.name === "" ? undefined : message.name;
    obj.username = message.username === "" ? undefined : message.username;
    obj.usernameGithub = message.usernameGithub === "" ? undefined : message.usernameGithub;
    obj.avatarUrl = message.avatarUrl === "" ? undefined : message.avatarUrl;
    if (message.followers) {
      obj.followers = message.followers.map(function (e) {
        return e;
      });
    } else {
      obj.followers = message.followers;
    }
    if (message.following) {
      obj.following = message.following.map(function (e) {
        return e;
      });
    } else {
      obj.following = message.following;
    }
    if (message.starredRepos) {
      obj.starred_repos = message.starredRepos.map(function (e) {
        return e.toString();
      });
    } else {
      obj.starred_repos = message.starredRepos;
    }
    obj.subscriptions = message.subscriptions === "" ? undefined : message.subscriptions;
    obj.bio = message.bio === "" ? undefined : message.bio;
    obj.createdAt = message.createdAt !== BigInt(0) ? message.createdAt.toString() : undefined;
    obj.updatedAt = message.updatedAt !== BigInt(0) ? message.updatedAt.toString() : undefined;
    obj.verified = message.verified === false ? undefined : message.verified;
    if (message.pinnedRepos) {
      obj.pinned_repos = message.pinnedRepos.map(function (e) {
        return e.toString();
      });
    } else {
      obj.pinned_repos = message.pinnedRepos;
    }
    return obj;
  },
  fromAminoMsg: function fromAminoMsg(object) {
    return User.fromAmino(object.value);
  },
  fromProtoMsg: function fromProtoMsg(message) {
    return User.decode(message.value);
  },
  toProto: function toProto(message) {
    return User.encode(message).finish();
  },
  toProtoMsg: function toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.gitopia.User",
      value: User.encode(message).finish()
    };
  }
};
function createBaseUserDao() {
  return {
    userAddress: "",
    daoAddress: ""
  };
}
var UserDao = exports.UserDao = {
  typeUrl: "/gitopia.gitopia.gitopia.UserDao",
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _binary.BinaryWriter.create();
    if (message.userAddress !== "") {
      writer.uint32(10).string(message.userAddress);
    }
    if (message.daoAddress !== "") {
      writer.uint32(18).string(message.daoAddress);
    }
    return writer;
  },
  fromJSON: function fromJSON(object) {
    return {
      userAddress: (0, _helpers.isSet)(object.userAddress) ? String(object.userAddress) : "",
      daoAddress: (0, _helpers.isSet)(object.daoAddress) ? String(object.daoAddress) : ""
    };
  },
  fromPartial: function fromPartial(object) {
    var _object$userAddress, _object$daoAddress;
    var message = createBaseUserDao();
    message.userAddress = (_object$userAddress = object.userAddress) !== null && _object$userAddress !== void 0 ? _object$userAddress : "";
    message.daoAddress = (_object$daoAddress = object.daoAddress) !== null && _object$daoAddress !== void 0 ? _object$daoAddress : "";
    return message;
  },
  fromAmino: function fromAmino(object) {
    var message = createBaseUserDao();
    if (object.userAddress !== undefined && object.userAddress !== null) {
      message.userAddress = object.userAddress;
    }
    if (object.daoAddress !== undefined && object.daoAddress !== null) {
      message.daoAddress = object.daoAddress;
    }
    return message;
  },
  toAmino: function toAmino(message) {
    var obj = {};
    obj.userAddress = message.userAddress === "" ? undefined : message.userAddress;
    obj.daoAddress = message.daoAddress === "" ? undefined : message.daoAddress;
    return obj;
  },
  fromAminoMsg: function fromAminoMsg(object) {
    return UserDao.fromAmino(object.value);
  },
  fromProtoMsg: function fromProtoMsg(message) {
    return UserDao.decode(message.value);
  },
  toProto: function toProto(message) {
    return UserDao.encode(message).finish();
  },
  toProtoMsg: function toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.gitopia.UserDao",
      value: UserDao.encode(message).finish()
    };
  }
};