import { BinaryWriter } from "../binary";
import { isSet } from "../helpers";
function createBaseDao() {
  return {
    creator: "",
    id: BigInt(0),
    address: "",
    name: "",
    avatarUrl: "",
    followers: [],
    following: [],
    teams: [],
    location: "",
    website: "",
    verified: false,
    description: "",
    createdAt: BigInt(0),
    updatedAt: BigInt(0),
    pinnedRepos: []
  };
}
export const Dao = {
  typeUrl: "/gitopia.gitopia.gitopia.Dao",
  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.address !== "") {
      writer.uint32(26).string(message.address);
    }
    if (message.name !== "") {
      writer.uint32(34).string(message.name);
    }
    if (message.avatarUrl !== "") {
      writer.uint32(42).string(message.avatarUrl);
    }
    for (const v of message.followers) {
      writer.uint32(50).string(v);
    }
    for (const v of message.following) {
      writer.uint32(58).string(v);
    }
    writer.uint32(66).fork();
    for (const v of message.teams) {
      writer.uint64(v);
    }
    writer.ldelim();
    if (message.location !== "") {
      writer.uint32(74).string(message.location);
    }
    if (message.website !== "") {
      writer.uint32(82).string(message.website);
    }
    if (message.verified === true) {
      writer.uint32(88).bool(message.verified);
    }
    if (message.description !== "") {
      writer.uint32(98).string(message.description);
    }
    if (message.createdAt !== BigInt(0)) {
      writer.uint32(104).int64(message.createdAt);
    }
    if (message.updatedAt !== BigInt(0)) {
      writer.uint32(112).int64(message.updatedAt);
    }
    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),
      address: isSet(object.address) ? String(object.address) : "",
      name: isSet(object.name) ? String(object.name) : "",
      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)) : [],
      teams: Array.isArray(object === null || object === void 0 ? void 0 : object.teams) ? object.teams.map(e => BigInt(e.toString())) : [],
      location: isSet(object.location) ? String(object.location) : "",
      website: isSet(object.website) ? String(object.website) : "",
      verified: isSet(object.verified) ? Boolean(object.verified) : false,
      description: isSet(object.description) ? String(object.description) : "",
      createdAt: isSet(object.createdAt) ? BigInt(object.createdAt.toString()) : BigInt(0),
      updatedAt: isSet(object.updatedAt) ? BigInt(object.updatedAt.toString()) : BigInt(0),
      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$address, _object$name, _object$avatarUrl, _object$followers, _object$following, _object$teams, _object$location, _object$website, _object$verified, _object$description, _object$pinnedRepos;
    const message = createBaseDao();
    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.address = (_object$address = object.address) !== null && _object$address !== void 0 ? _object$address : "";
    message.name = (_object$name = object.name) !== null && _object$name !== void 0 ? _object$name : "";
    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.teams = ((_object$teams = object.teams) === null || _object$teams === void 0 ? void 0 : _object$teams.map(e => BigInt(e.toString()))) || [];
    message.location = (_object$location = object.location) !== null && _object$location !== void 0 ? _object$location : "";
    message.website = (_object$website = object.website) !== null && _object$website !== void 0 ? _object$website : "";
    message.verified = (_object$verified = object.verified) !== null && _object$verified !== void 0 ? _object$verified : false;
    message.description = (_object$description = object.description) !== null && _object$description !== void 0 ? _object$description : "";
    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.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$teams2, _object$pinned_repos;
    const message = createBaseDao();
    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.address !== undefined && object.address !== null) {
      message.address = object.address;
    }
    if (object.name !== undefined && object.name !== null) {
      message.name = object.name;
    }
    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.teams = ((_object$teams2 = object.teams) === null || _object$teams2 === void 0 ? void 0 : _object$teams2.map(e => BigInt(e))) || [];
    if (object.location !== undefined && object.location !== null) {
      message.location = object.location;
    }
    if (object.website !== undefined && object.website !== null) {
      message.website = object.website;
    }
    if (object.verified !== undefined && object.verified !== null) {
      message.verified = object.verified;
    }
    if (object.description !== undefined && object.description !== null) {
      message.description = object.description;
    }
    if (object.createdAt !== undefined && object.createdAt !== null) {
      message.createdAt = BigInt(object.createdAt);
    }
    if (object.updatedAt !== undefined && object.updatedAt !== null) {
      message.updatedAt = BigInt(object.updatedAt);
    }
    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.address = message.address === "" ? undefined : message.address;
    obj.name = message.name === "" ? undefined : message.name;
    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.teams) {
      obj.teams = message.teams.map(e => e.toString());
    } else {
      obj.teams = message.teams;
    }
    obj.location = message.location === "" ? undefined : message.location;
    obj.website = message.website === "" ? undefined : message.website;
    obj.verified = message.verified === false ? undefined : message.verified;
    obj.description = message.description === "" ? undefined : message.description;
    obj.createdAt = message.createdAt !== BigInt(0) ? message.createdAt.toString() : undefined;
    obj.updatedAt = message.updatedAt !== BigInt(0) ? message.updatedAt.toString() : undefined;
    if (message.pinnedRepos) {
      obj.pinned_repos = message.pinnedRepos.map(e => e.toString());
    } else {
      obj.pinned_repos = message.pinnedRepos;
    }
    return obj;
  },
  fromAminoMsg(object) {
    return Dao.fromAmino(object.value);
  },
  fromProtoMsg(message) {
    return Dao.decode(message.value);
  },
  toProto(message) {
    return Dao.encode(message).finish();
  },
  toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.gitopia.Dao",
      value: Dao.encode(message).finish()
    };
  }
};