import { BinaryWriter } from "../binary";
import { isSet } from "../helpers";
export let MemberRole = /*#__PURE__*/function (MemberRole) {
  MemberRole[MemberRole["MEMBER"] = 0] = "MEMBER";
  MemberRole[MemberRole["OWNER"] = 1] = "OWNER";
  MemberRole[MemberRole["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
  return MemberRole;
}({});
export const MemberRoleSDKType = MemberRole;
export const MemberRoleAmino = MemberRole;
export function memberRoleFromJSON(object) {
  switch (object) {
    case 0:
    case "MEMBER":
      return MemberRole.MEMBER;
    case 1:
    case "OWNER":
      return MemberRole.OWNER;
    case -1:
    case "UNRECOGNIZED":
    default:
      return MemberRole.UNRECOGNIZED;
  }
}
export function memberRoleToJSON(object) {
  switch (object) {
    case MemberRole.MEMBER:
      return "MEMBER";
    case MemberRole.OWNER:
      return "OWNER";
    case MemberRole.UNRECOGNIZED:
    default:
      return "UNRECOGNIZED";
  }
}
function createBaseMember() {
  return {
    id: BigInt(0),
    address: "",
    daoAddress: "",
    role: 0
  };
}
export const Member = {
  typeUrl: "/gitopia.gitopia.gitopia.Member",
  encode(message, writer = BinaryWriter.create()) {
    if (message.id !== BigInt(0)) {
      writer.uint32(8).uint64(message.id);
    }
    if (message.address !== "") {
      writer.uint32(18).string(message.address);
    }
    if (message.daoAddress !== "") {
      writer.uint32(26).string(message.daoAddress);
    }
    if (message.role !== 0) {
      writer.uint32(32).int32(message.role);
    }
    return writer;
  },
  fromJSON(object) {
    return {
      id: isSet(object.id) ? BigInt(object.id.toString()) : BigInt(0),
      address: isSet(object.address) ? String(object.address) : "",
      daoAddress: isSet(object.daoAddress) ? String(object.daoAddress) : "",
      role: isSet(object.role) ? memberRoleFromJSON(object.role) : -1
    };
  },
  fromPartial(object) {
    var _object$address, _object$daoAddress, _object$role;
    const message = createBaseMember();
    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.daoAddress = (_object$daoAddress = object.daoAddress) !== null && _object$daoAddress !== void 0 ? _object$daoAddress : "";
    message.role = (_object$role = object.role) !== null && _object$role !== void 0 ? _object$role : 0;
    return message;
  },
  fromAmino(object) {
    const message = createBaseMember();
    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.daoAddress !== undefined && object.daoAddress !== null) {
      message.daoAddress = object.daoAddress;
    }
    if (object.role !== undefined && object.role !== null) {
      message.role = object.role;
    }
    return message;
  },
  toAmino(message) {
    const obj = {};
    obj.id = message.id !== BigInt(0) ? message.id.toString() : undefined;
    obj.address = message.address === "" ? undefined : message.address;
    obj.daoAddress = message.daoAddress === "" ? undefined : message.daoAddress;
    obj.role = message.role === 0 ? undefined : message.role;
    return obj;
  },
  fromAminoMsg(object) {
    return Member.fromAmino(object.value);
  },
  fromProtoMsg(message) {
    return Member.decode(message.value);
  },
  toProto(message) {
    return Member.encode(message).finish();
  },
  toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.gitopia.Member",
      value: Member.encode(message).finish()
    };
  }
};