"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Whois = exports.OwnerTypeSDKType = exports.OwnerTypeAmino = exports.OwnerType = void 0;
exports.ownerTypeFromJSON = ownerTypeFromJSON;
exports.ownerTypeToJSON = ownerTypeToJSON;
var _binary = require("../binary");
var _helpers = require("../helpers");
var OwnerType = exports.OwnerType = /*#__PURE__*/function (OwnerType) {
  OwnerType[OwnerType["USER"] = 0] = "USER";
  OwnerType[OwnerType["DAO"] = 1] = "DAO";
  OwnerType[OwnerType["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
  return OwnerType;
}({});
var OwnerTypeSDKType = exports.OwnerTypeSDKType = OwnerType;
var OwnerTypeAmino = exports.OwnerTypeAmino = OwnerType;
function ownerTypeFromJSON(object) {
  switch (object) {
    case 0:
    case "USER":
      return OwnerType.USER;
    case 1:
    case "DAO":
      return OwnerType.DAO;
    case -1:
    case "UNRECOGNIZED":
    default:
      return OwnerType.UNRECOGNIZED;
  }
}
function ownerTypeToJSON(object) {
  switch (object) {
    case OwnerType.USER:
      return "USER";
    case OwnerType.DAO:
      return "DAO";
    case OwnerType.UNRECOGNIZED:
    default:
      return "UNRECOGNIZED";
  }
}
function createBaseWhois() {
  return {
    creator: "",
    id: BigInt(0),
    name: "",
    address: "",
    ownerType: 0
  };
}
var Whois = exports.Whois = {
  typeUrl: "/gitopia.gitopia.gitopia.Whois",
  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.address !== "") {
      writer.uint32(34).string(message.address);
    }
    if (message.ownerType !== 0) {
      writer.uint32(40).int32(message.ownerType);
    }
    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) : "",
      address: (0, _helpers.isSet)(object.address) ? String(object.address) : "",
      ownerType: (0, _helpers.isSet)(object.ownerType) ? ownerTypeFromJSON(object.ownerType) : -1
    };
  },
  fromPartial: function fromPartial(object) {
    var _object$creator, _object$name, _object$address, _object$ownerType;
    var message = createBaseWhois();
    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.address = (_object$address = object.address) !== null && _object$address !== void 0 ? _object$address : "";
    message.ownerType = (_object$ownerType = object.ownerType) !== null && _object$ownerType !== void 0 ? _object$ownerType : 0;
    return message;
  },
  fromAmino: function fromAmino(object) {
    var message = createBaseWhois();
    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.address !== undefined && object.address !== null) {
      message.address = object.address;
    }
    if (object.ownerType !== undefined && object.ownerType !== null) {
      message.ownerType = object.ownerType;
    }
    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.address = message.address === "" ? undefined : message.address;
    obj.ownerType = message.ownerType === 0 ? undefined : message.ownerType;
    return obj;
  },
  fromAminoMsg: function fromAminoMsg(object) {
    return Whois.fromAmino(object.value);
  },
  fromProtoMsg: function fromProtoMsg(message) {
    return Whois.decode(message.value);
  },
  toProto: function toProto(message) {
    return Whois.encode(message).finish();
  },
  toProtoMsg: function toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.gitopia.Whois",
      value: Whois.encode(message).finish()
    };
  }
};