/**
 * #gamesdrawerbadge_msg.ts
 *
 * Code generated by ts-proto. DO NOT EDIT.
 * @packageDocumentation
 */
/* eslint-disable */
import _m0 from "protobufjs/minimal.js";
import { Duration } from "../../../google/protobuf/duration.js";
import { Timestamp } from "../../../google/protobuf/timestamp.js";
import { messageTypeRegistry } from "../../../typeRegistry.js";
function createBaseShowGamesDrawerBadgeRequest() {
    return { post: "", expiresIn: undefined, expiresAt: undefined };
}
export const ShowGamesDrawerBadgeRequest = {
    $type: "devvit.plugin.notifications.ShowGamesDrawerBadgeRequest",
    encode(message, writer = _m0.Writer.create()) {
        if (message.post !== "") {
            writer.uint32(10).string(message.post);
        }
        if (message.expiresIn !== undefined) {
            Duration.encode(message.expiresIn, writer.uint32(18).fork()).ldelim();
        }
        if (message.expiresAt !== undefined) {
            Timestamp.encode(toTimestamp(message.expiresAt), writer.uint32(26).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseShowGamesDrawerBadgeRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.post = reader.string();
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.expiresIn = Duration.decode(reader, reader.uint32());
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.expiresAt = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            post: isSet(object.post) ? globalThis.String(object.post) : "",
            expiresIn: isSet(object.expiresIn) ? Duration.fromJSON(object.expiresIn) : undefined,
            expiresAt: isSet(object.expiresAt) ? fromJsonTimestamp(object.expiresAt) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.post !== "") {
            obj.post = message.post;
        }
        if (message.expiresIn !== undefined) {
            obj.expiresIn = Duration.toJSON(message.expiresIn);
        }
        if (message.expiresAt !== undefined) {
            obj.expiresAt = message.expiresAt.toISOString();
        }
        return obj;
    },
    create(base) {
        return ShowGamesDrawerBadgeRequest.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseShowGamesDrawerBadgeRequest();
        message.post = object.post ?? "";
        message.expiresIn = (object.expiresIn !== undefined && object.expiresIn !== null)
            ? Duration.fromPartial(object.expiresIn)
            : undefined;
        message.expiresAt = object.expiresAt ?? undefined;
        return message;
    },
};
messageTypeRegistry.set(ShowGamesDrawerBadgeRequest.$type, ShowGamesDrawerBadgeRequest);
function createBaseShowGamesDrawerBadgeResponse() {
    return { success: false, message: undefined };
}
export const ShowGamesDrawerBadgeResponse = {
    $type: "devvit.plugin.notifications.ShowGamesDrawerBadgeResponse",
    encode(message, writer = _m0.Writer.create()) {
        if (message.success !== false) {
            writer.uint32(8).bool(message.success);
        }
        if (message.message !== undefined) {
            writer.uint32(18).string(message.message);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseShowGamesDrawerBadgeResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 8) {
                        break;
                    }
                    message.success = reader.bool();
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.message = reader.string();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            success: isSet(object.success) ? globalThis.Boolean(object.success) : false,
            message: isSet(object.message) ? globalThis.String(object.message) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.success !== false) {
            obj.success = message.success;
        }
        if (message.message !== undefined) {
            obj.message = message.message;
        }
        return obj;
    },
    create(base) {
        return ShowGamesDrawerBadgeResponse.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseShowGamesDrawerBadgeResponse();
        message.success = object.success ?? false;
        message.message = object.message ?? undefined;
        return message;
    },
};
messageTypeRegistry.set(ShowGamesDrawerBadgeResponse.$type, ShowGamesDrawerBadgeResponse);
function createBaseDismissGamesDrawerBadgeRequest() {
    return {};
}
export const DismissGamesDrawerBadgeRequest = {
    $type: "devvit.plugin.notifications.DismissGamesDrawerBadgeRequest",
    encode(_, writer = _m0.Writer.create()) {
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseDismissGamesDrawerBadgeRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(_) {
        return {};
    },
    toJSON(_) {
        const obj = {};
        return obj;
    },
    create(base) {
        return DismissGamesDrawerBadgeRequest.fromPartial(base ?? {});
    },
    fromPartial(_) {
        const message = createBaseDismissGamesDrawerBadgeRequest();
        return message;
    },
};
messageTypeRegistry.set(DismissGamesDrawerBadgeRequest.$type, DismissGamesDrawerBadgeRequest);
function createBaseDismissGamesDrawerBadgeResponse() {
    return { success: false };
}
export const DismissGamesDrawerBadgeResponse = {
    $type: "devvit.plugin.notifications.DismissGamesDrawerBadgeResponse",
    encode(message, writer = _m0.Writer.create()) {
        if (message.success !== false) {
            writer.uint32(8).bool(message.success);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseDismissGamesDrawerBadgeResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 8) {
                        break;
                    }
                    message.success = reader.bool();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return { success: isSet(object.success) ? globalThis.Boolean(object.success) : false };
    },
    toJSON(message) {
        const obj = {};
        if (message.success !== false) {
            obj.success = message.success;
        }
        return obj;
    },
    create(base) {
        return DismissGamesDrawerBadgeResponse.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseDismissGamesDrawerBadgeResponse();
        message.success = object.success ?? false;
        return message;
    },
};
messageTypeRegistry.set(DismissGamesDrawerBadgeResponse.$type, DismissGamesDrawerBadgeResponse);
function createBaseGetGamesDrawerBadgeStatusRequest() {
    return {};
}
export const GetGamesDrawerBadgeStatusRequest = {
    $type: "devvit.plugin.notifications.GetGamesDrawerBadgeStatusRequest",
    encode(_, writer = _m0.Writer.create()) {
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseGetGamesDrawerBadgeStatusRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(_) {
        return {};
    },
    toJSON(_) {
        const obj = {};
        return obj;
    },
    create(base) {
        return GetGamesDrawerBadgeStatusRequest.fromPartial(base ?? {});
    },
    fromPartial(_) {
        const message = createBaseGetGamesDrawerBadgeStatusRequest();
        return message;
    },
};
messageTypeRegistry.set(GetGamesDrawerBadgeStatusRequest.$type, GetGamesDrawerBadgeStatusRequest);
function createBaseGetGamesDrawerBadgeStatusResponse() {
    return { hasActiveBadge: false, expiresAt: undefined };
}
export const GetGamesDrawerBadgeStatusResponse = {
    $type: "devvit.plugin.notifications.GetGamesDrawerBadgeStatusResponse",
    encode(message, writer = _m0.Writer.create()) {
        if (message.hasActiveBadge !== false) {
            writer.uint32(8).bool(message.hasActiveBadge);
        }
        if (message.expiresAt !== undefined) {
            Timestamp.encode(toTimestamp(message.expiresAt), writer.uint32(18).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseGetGamesDrawerBadgeStatusResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 8) {
                        break;
                    }
                    message.hasActiveBadge = reader.bool();
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.expiresAt = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            hasActiveBadge: isSet(object.hasActiveBadge) ? globalThis.Boolean(object.hasActiveBadge) : false,
            expiresAt: isSet(object.expiresAt) ? fromJsonTimestamp(object.expiresAt) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.hasActiveBadge !== false) {
            obj.hasActiveBadge = message.hasActiveBadge;
        }
        if (message.expiresAt !== undefined) {
            obj.expiresAt = message.expiresAt.toISOString();
        }
        return obj;
    },
    create(base) {
        return GetGamesDrawerBadgeStatusResponse.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseGetGamesDrawerBadgeStatusResponse();
        message.hasActiveBadge = object.hasActiveBadge ?? false;
        message.expiresAt = object.expiresAt ?? undefined;
        return message;
    },
};
messageTypeRegistry.set(GetGamesDrawerBadgeStatusResponse.$type, GetGamesDrawerBadgeStatusResponse);
function toTimestamp(date) {
    const seconds = Math.trunc(date.getTime() / 1000);
    const nanos = (date.getTime() % 1000) * 1000000;
    return { seconds, nanos };
}
function fromTimestamp(t) {
    let millis = (t.seconds || 0) * 1000;
    millis += (t.nanos || 0) / 1000000;
    return new globalThis.Date(millis);
}
function fromJsonTimestamp(o) {
    if (o instanceof globalThis.Date) {
        return o;
    }
    else if (typeof o === "string") {
        return new globalThis.Date(o);
    }
    else {
        return fromTimestamp(Timestamp.fromJSON(o));
    }
}
function isSet(value) {
    return value !== null && value !== undefined;
}
