import { BinaryWriter } from "../binary";
import { isSet } from "../helpers";
export let TaskType = /*#__PURE__*/function (TaskType) {
  TaskType[TaskType["TASK_TYPE_FORK_REPOSITORY"] = 0] = "TASK_TYPE_FORK_REPOSITORY";
  TaskType[TaskType["TASK_TYPE_SET_PULL_REQUEST_STATE"] = 1] = "TASK_TYPE_SET_PULL_REQUEST_STATE";
  TaskType[TaskType["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
  return TaskType;
}({});
export const TaskTypeSDKType = TaskType;
export const TaskTypeAmino = TaskType;
export function taskTypeFromJSON(object) {
  switch (object) {
    case 0:
    case "TASK_TYPE_FORK_REPOSITORY":
      return TaskType.TASK_TYPE_FORK_REPOSITORY;
    case 1:
    case "TASK_TYPE_SET_PULL_REQUEST_STATE":
      return TaskType.TASK_TYPE_SET_PULL_REQUEST_STATE;
    case -1:
    case "UNRECOGNIZED":
    default:
      return TaskType.UNRECOGNIZED;
  }
}
export function taskTypeToJSON(object) {
  switch (object) {
    case TaskType.TASK_TYPE_FORK_REPOSITORY:
      return "TASK_TYPE_FORK_REPOSITORY";
    case TaskType.TASK_TYPE_SET_PULL_REQUEST_STATE:
      return "TASK_TYPE_SET_PULL_REQUEST_STATE";
    case TaskType.UNRECOGNIZED:
    default:
      return "UNRECOGNIZED";
  }
}
export let TaskState = /*#__PURE__*/function (TaskState) {
  TaskState[TaskState["TASK_STATE_PENDING"] = 0] = "TASK_STATE_PENDING";
  TaskState[TaskState["TASK_STATE_SUCCESS"] = 1] = "TASK_STATE_SUCCESS";
  TaskState[TaskState["TASK_STATE_FAILURE"] = 2] = "TASK_STATE_FAILURE";
  TaskState[TaskState["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
  return TaskState;
}({});
export const TaskStateSDKType = TaskState;
export const TaskStateAmino = TaskState;
export function taskStateFromJSON(object) {
  switch (object) {
    case 0:
    case "TASK_STATE_PENDING":
      return TaskState.TASK_STATE_PENDING;
    case 1:
    case "TASK_STATE_SUCCESS":
      return TaskState.TASK_STATE_SUCCESS;
    case 2:
    case "TASK_STATE_FAILURE":
      return TaskState.TASK_STATE_FAILURE;
    case -1:
    case "UNRECOGNIZED":
    default:
      return TaskState.UNRECOGNIZED;
  }
}
export function taskStateToJSON(object) {
  switch (object) {
    case TaskState.TASK_STATE_PENDING:
      return "TASK_STATE_PENDING";
    case TaskState.TASK_STATE_SUCCESS:
      return "TASK_STATE_SUCCESS";
    case TaskState.TASK_STATE_FAILURE:
      return "TASK_STATE_FAILURE";
    case TaskState.UNRECOGNIZED:
    default:
      return "UNRECOGNIZED";
  }
}
function createBaseTask() {
  return {
    id: BigInt(0),
    type: 0,
    state: 0,
    message: "",
    creator: "",
    provider: ""
  };
}
export const Task = {
  typeUrl: "/gitopia.gitopia.gitopia.Task",
  encode(message, writer = BinaryWriter.create()) {
    if (message.id !== BigInt(0)) {
      writer.uint32(8).uint64(message.id);
    }
    if (message.type !== 0) {
      writer.uint32(16).int32(message.type);
    }
    if (message.state !== 0) {
      writer.uint32(24).int32(message.state);
    }
    if (message.message !== "") {
      writer.uint32(34).string(message.message);
    }
    if (message.creator !== "") {
      writer.uint32(42).string(message.creator);
    }
    if (message.provider !== "") {
      writer.uint32(50).string(message.provider);
    }
    return writer;
  },
  fromJSON(object) {
    return {
      id: isSet(object.id) ? BigInt(object.id.toString()) : BigInt(0),
      type: isSet(object.type) ? taskTypeFromJSON(object.type) : -1,
      state: isSet(object.state) ? taskStateFromJSON(object.state) : -1,
      message: isSet(object.message) ? String(object.message) : "",
      creator: isSet(object.creator) ? String(object.creator) : "",
      provider: isSet(object.provider) ? String(object.provider) : ""
    };
  },
  fromPartial(object) {
    var _object$type, _object$state, _object$message, _object$creator, _object$provider;
    const message = createBaseTask();
    message.id = object.id !== undefined && object.id !== null ? BigInt(object.id.toString()) : BigInt(0);
    message.type = (_object$type = object.type) !== null && _object$type !== void 0 ? _object$type : 0;
    message.state = (_object$state = object.state) !== null && _object$state !== void 0 ? _object$state : 0;
    message.message = (_object$message = object.message) !== null && _object$message !== void 0 ? _object$message : "";
    message.creator = (_object$creator = object.creator) !== null && _object$creator !== void 0 ? _object$creator : "";
    message.provider = (_object$provider = object.provider) !== null && _object$provider !== void 0 ? _object$provider : "";
    return message;
  },
  fromAmino(object) {
    const message = createBaseTask();
    if (object.id !== undefined && object.id !== null) {
      message.id = BigInt(object.id);
    }
    if (object.type !== undefined && object.type !== null) {
      message.type = object.type;
    }
    if (object.state !== undefined && object.state !== null) {
      message.state = object.state;
    }
    if (object.message !== undefined && object.message !== null) {
      message.message = object.message;
    }
    if (object.creator !== undefined && object.creator !== null) {
      message.creator = object.creator;
    }
    if (object.provider !== undefined && object.provider !== null) {
      message.provider = object.provider;
    }
    return message;
  },
  toAmino(message) {
    const obj = {};
    obj.id = message.id !== BigInt(0) ? message.id.toString() : undefined;
    obj.type = message.type === 0 ? undefined : message.type;
    obj.state = message.state === 0 ? undefined : message.state;
    obj.message = message.message === "" ? undefined : message.message;
    obj.creator = message.creator === "" ? undefined : message.creator;
    obj.provider = message.provider === "" ? undefined : message.provider;
    return obj;
  },
  fromAminoMsg(object) {
    return Task.fromAmino(object.value);
  },
  fromProtoMsg(message) {
    return Task.decode(message.value);
  },
  toProto(message) {
    return Task.encode(message).finish();
  },
  toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.gitopia.Task",
      value: Task.encode(message).finish()
    };
  }
};