import { BinaryWriter } from "../binary";
import { isSet } from "../helpers";
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: []
  };
}
export const User = {
  typeUrl: "/gitopia.gitopia.gitopia.User",
  encode(message, writer = 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);
    }
    for (const v of message.followers) {
      writer.uint32(58).string(v);
    }
    for (const v of message.following) {
      writer.uint32(66).string(v);
    }
    writer.uint32(74).fork();
    for (const v of message.starredRepos) {
      writer.uint64(v);
    }
    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();
    for (const v of message.pinnedRepos) {
      writer.uint64(v);
    }
    writer.ldelim();
    return writer;
  },
  fromJSON(object) {
    return {
      creator: isSet(object.creator) ? String(object.creator) : "",
      id: isSet(object.id) ? BigInt(object.id.toString()) : BigInt(0),
      name: isSet(object.name) ? String(object.name) : "",
      username: isSet(object.username) ? String(object.username) : "",
      usernameGithub: isSet(object.usernameGithub) ? String(object.usernameGithub) : "",
      avatarUrl: isSet(object.avatarUrl) ? String(object.avatarUrl) : "",
      followers: Array.isArray(object === null || object === void 0 ? void 0 : object.followers) ? object.followers.map(e => String(e)) : [],
      following: Array.isArray(object === null || object === void 0 ? void 0 : object.following) ? object.following.map(e => String(e)) : [],
      starredRepos: Array.isArray(object === null || object === void 0 ? void 0 : object.starredRepos) ? object.starredRepos.map(e => BigInt(e.toString())) : [],
      subscriptions: isSet(object.subscriptions) ? String(object.subscriptions) : "",
      bio: isSet(object.bio) ? String(object.bio) : "",
      createdAt: isSet(object.createdAt) ? BigInt(object.createdAt.toString()) : BigInt(0),
      updatedAt: isSet(object.updatedAt) ? BigInt(object.updatedAt.toString()) : BigInt(0),
      verified: isSet(object.verified) ? Boolean(object.verified) : false,
      pinnedRepos: Array.isArray(object === null || object === void 0 ? void 0 : object.pinnedRepos) ? object.pinnedRepos.map(e => BigInt(e.toString())) : []
    };
  },
  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;
    const 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(e => e)) || [];
    message.following = ((_object$following = object.following) === null || _object$following === void 0 ? void 0 : _object$following.map(e => e)) || [];
    message.starredRepos = ((_object$starredRepos = object.starredRepos) === null || _object$starredRepos === void 0 ? void 0 : _object$starredRepos.map(e => 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(e => BigInt(e.toString()))) || [];
    return message;
  },
  fromAmino(object) {
    var _object$followers2, _object$following2, _object$starred_repos, _object$pinned_repos;
    const 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(e => e)) || [];
    message.following = ((_object$following2 = object.following) === null || _object$following2 === void 0 ? void 0 : _object$following2.map(e => e)) || [];
    message.starredRepos = ((_object$starred_repos = object.starred_repos) === null || _object$starred_repos === void 0 ? void 0 : _object$starred_repos.map(e => 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(e => BigInt(e))) || [];
    return message;
  },
  toAmino(message) {
    const 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(e => e);
    } else {
      obj.followers = message.followers;
    }
    if (message.following) {
      obj.following = message.following.map(e => e);
    } else {
      obj.following = message.following;
    }
    if (message.starredRepos) {
      obj.starred_repos = message.starredRepos.map(e => 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(e => e.toString());
    } else {
      obj.pinned_repos = message.pinnedRepos;
    }
    return obj;
  },
  fromAminoMsg(object) {
    return User.fromAmino(object.value);
  },
  fromProtoMsg(message) {
    return User.decode(message.value);
  },
  toProto(message) {
    return User.encode(message).finish();
  },
  toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.gitopia.User",
      value: User.encode(message).finish()
    };
  }
};
function createBaseUserDao() {
  return {
    userAddress: "",
    daoAddress: ""
  };
}
export const UserDao = {
  typeUrl: "/gitopia.gitopia.gitopia.UserDao",
  encode(message, writer = BinaryWriter.create()) {
    if (message.userAddress !== "") {
      writer.uint32(10).string(message.userAddress);
    }
    if (message.daoAddress !== "") {
      writer.uint32(18).string(message.daoAddress);
    }
    return writer;
  },
  fromJSON(object) {
    return {
      userAddress: isSet(object.userAddress) ? String(object.userAddress) : "",
      daoAddress: isSet(object.daoAddress) ? String(object.daoAddress) : ""
    };
  },
  fromPartial(object) {
    var _object$userAddress, _object$daoAddress;
    const 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(object) {
    const 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(message) {
    const obj = {};
    obj.userAddress = message.userAddress === "" ? undefined : message.userAddress;
    obj.daoAddress = message.daoAddress === "" ? undefined : message.daoAddress;
    return obj;
  },
  fromAminoMsg(object) {
    return UserDao.fromAmino(object.value);
  },
  fromProtoMsg(message) {
    return UserDao.decode(message.value);
  },
  toProto(message) {
    return UserDao.encode(message).finish();
  },
  toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.gitopia.UserDao",
      value: UserDao.encode(message).finish()
    };
  }
};