"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Release = void 0;
var _attachment = require("./attachment");
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 createBaseRelease() {
  return {
    creator: "",
    id: BigInt(0),
    repositoryId: BigInt(0),
    tagName: "",
    target: "",
    name: "",
    description: "",
    attachments: [],
    draft: false,
    preRelease: false,
    isTag: false,
    createdAt: BigInt(0),
    updatedAt: BigInt(0),
    publishedAt: BigInt(0)
  };
}
var Release = exports.Release = {
  typeUrl: "/gitopia.gitopia.gitopia.Release",
  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.repositoryId !== BigInt(0)) {
      writer.uint32(24).uint64(message.repositoryId);
    }
    if (message.tagName !== "") {
      writer.uint32(34).string(message.tagName);
    }
    if (message.target !== "") {
      writer.uint32(42).string(message.target);
    }
    if (message.name !== "") {
      writer.uint32(50).string(message.name);
    }
    if (message.description !== "") {
      writer.uint32(58).string(message.description);
    }
    var _iterator = _createForOfIteratorHelper(message.attachments),
      _step;
    try {
      for (_iterator.s(); !(_step = _iterator.n()).done;) {
        var v = _step.value;
        _attachment.Attachment.encode(v, writer.uint32(66).fork()).ldelim();
      }
    } catch (err) {
      _iterator.e(err);
    } finally {
      _iterator.f();
    }
    if (message.draft === true) {
      writer.uint32(72).bool(message.draft);
    }
    if (message.preRelease === true) {
      writer.uint32(80).bool(message.preRelease);
    }
    if (message.isTag === true) {
      writer.uint32(88).bool(message.isTag);
    }
    if (message.createdAt !== BigInt(0)) {
      writer.uint32(96).int64(message.createdAt);
    }
    if (message.updatedAt !== BigInt(0)) {
      writer.uint32(104).int64(message.updatedAt);
    }
    if (message.publishedAt !== BigInt(0)) {
      writer.uint32(112).int64(message.publishedAt);
    }
    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),
      repositoryId: (0, _helpers.isSet)(object.repositoryId) ? BigInt(object.repositoryId.toString()) : BigInt(0),
      tagName: (0, _helpers.isSet)(object.tagName) ? String(object.tagName) : "",
      target: (0, _helpers.isSet)(object.target) ? String(object.target) : "",
      name: (0, _helpers.isSet)(object.name) ? String(object.name) : "",
      description: (0, _helpers.isSet)(object.description) ? String(object.description) : "",
      attachments: Array.isArray(object === null || object === void 0 ? void 0 : object.attachments) ? object.attachments.map(function (e) {
        return _attachment.Attachment.fromJSON(e);
      }) : [],
      draft: (0, _helpers.isSet)(object.draft) ? Boolean(object.draft) : false,
      preRelease: (0, _helpers.isSet)(object.preRelease) ? Boolean(object.preRelease) : false,
      isTag: (0, _helpers.isSet)(object.isTag) ? Boolean(object.isTag) : false,
      createdAt: (0, _helpers.isSet)(object.createdAt) ? BigInt(object.createdAt.toString()) : BigInt(0),
      updatedAt: (0, _helpers.isSet)(object.updatedAt) ? BigInt(object.updatedAt.toString()) : BigInt(0),
      publishedAt: (0, _helpers.isSet)(object.publishedAt) ? BigInt(object.publishedAt.toString()) : BigInt(0)
    };
  },
  fromPartial: function fromPartial(object) {
    var _object$creator, _object$tagName, _object$target, _object$name, _object$description, _object$attachments, _object$draft, _object$preRelease, _object$isTag;
    var message = createBaseRelease();
    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.repositoryId = object.repositoryId !== undefined && object.repositoryId !== null ? BigInt(object.repositoryId.toString()) : BigInt(0);
    message.tagName = (_object$tagName = object.tagName) !== null && _object$tagName !== void 0 ? _object$tagName : "";
    message.target = (_object$target = object.target) !== null && _object$target !== void 0 ? _object$target : "";
    message.name = (_object$name = object.name) !== null && _object$name !== void 0 ? _object$name : "";
    message.description = (_object$description = object.description) !== null && _object$description !== void 0 ? _object$description : "";
    message.attachments = ((_object$attachments = object.attachments) === null || _object$attachments === void 0 ? void 0 : _object$attachments.map(function (e) {
      return _attachment.Attachment.fromPartial(e);
    })) || [];
    message.draft = (_object$draft = object.draft) !== null && _object$draft !== void 0 ? _object$draft : false;
    message.preRelease = (_object$preRelease = object.preRelease) !== null && _object$preRelease !== void 0 ? _object$preRelease : false;
    message.isTag = (_object$isTag = object.isTag) !== null && _object$isTag !== void 0 ? _object$isTag : false;
    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.publishedAt = object.publishedAt !== undefined && object.publishedAt !== null ? BigInt(object.publishedAt.toString()) : BigInt(0);
    return message;
  },
  fromAmino: function fromAmino(object) {
    var _object$attachments2;
    var message = createBaseRelease();
    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.repositoryId !== undefined && object.repositoryId !== null) {
      message.repositoryId = BigInt(object.repositoryId);
    }
    if (object.tagName !== undefined && object.tagName !== null) {
      message.tagName = object.tagName;
    }
    if (object.target !== undefined && object.target !== null) {
      message.target = object.target;
    }
    if (object.name !== undefined && object.name !== null) {
      message.name = object.name;
    }
    if (object.description !== undefined && object.description !== null) {
      message.description = object.description;
    }
    message.attachments = ((_object$attachments2 = object.attachments) === null || _object$attachments2 === void 0 ? void 0 : _object$attachments2.map(function (e) {
      return _attachment.Attachment.fromAmino(e);
    })) || [];
    if (object.draft !== undefined && object.draft !== null) {
      message.draft = object.draft;
    }
    if (object.preRelease !== undefined && object.preRelease !== null) {
      message.preRelease = object.preRelease;
    }
    if (object.isTag !== undefined && object.isTag !== null) {
      message.isTag = object.isTag;
    }
    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.publishedAt !== undefined && object.publishedAt !== null) {
      message.publishedAt = BigInt(object.publishedAt);
    }
    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.repositoryId = message.repositoryId !== BigInt(0) ? message.repositoryId.toString() : undefined;
    obj.tagName = message.tagName === "" ? undefined : message.tagName;
    obj.target = message.target === "" ? undefined : message.target;
    obj.name = message.name === "" ? undefined : message.name;
    obj.description = message.description === "" ? undefined : message.description;
    if (message.attachments) {
      obj.attachments = message.attachments.map(function (e) {
        return e ? _attachment.Attachment.toAmino(e) : undefined;
      });
    } else {
      obj.attachments = message.attachments;
    }
    obj.draft = message.draft === false ? undefined : message.draft;
    obj.preRelease = message.preRelease === false ? undefined : message.preRelease;
    obj.isTag = message.isTag === false ? undefined : message.isTag;
    obj.createdAt = message.createdAt !== BigInt(0) ? message.createdAt.toString() : undefined;
    obj.updatedAt = message.updatedAt !== BigInt(0) ? message.updatedAt.toString() : undefined;
    obj.publishedAt = message.publishedAt !== BigInt(0) ? message.publishedAt.toString() : undefined;
    return obj;
  },
  fromAminoMsg: function fromAminoMsg(object) {
    return Release.fromAmino(object.value);
  },
  fromProtoMsg: function fromProtoMsg(message) {
    return Release.decode(message.value);
  },
  toProto: function toProto(message) {
    return Release.encode(message).finish();
  },
  toProtoMsg: function toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.gitopia.Release",
      value: Release.encode(message).finish()
    };
  }
};