/**
 * #installation.ts
 *
 * Code generated by ts-proto. DO NOT EDIT.
 * @packageDocumentation
 */
/* eslint-disable */
import _m0 from "protobufjs/minimal.js";
import { Struct } from "../../../google/protobuf/struct.js";
import { Timestamp } from "../../../google/protobuf/timestamp.js";
import { BoolValue, StringValue } from "../../../google/protobuf/wrappers.js";
import { messageTypeRegistry } from "../../../typeRegistry.js";
import { thingTypeFromJSON, thingTypeToJSON } from "../../reddit/thing_type.js";
import { AppInfo } from "../app/info/app_info.js";
import { AppVersionInfo, installationTypeFromJSON, installationTypeToJSON, } from "../app_version/info/app_version_info.js";
export var UpgradeStrategy;
(function (UpgradeStrategy) {
    UpgradeStrategy[UpgradeStrategy["MANUAL"] = 0] = "MANUAL";
    UpgradeStrategy[UpgradeStrategy["AUTOMATIC"] = 1] = "AUTOMATIC";
    UpgradeStrategy[UpgradeStrategy["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(UpgradeStrategy || (UpgradeStrategy = {}));
export function upgradeStrategyFromJSON(object) {
    switch (object) {
        case 0:
        case "MANUAL":
            return UpgradeStrategy.MANUAL;
        case 1:
        case "AUTOMATIC":
            return UpgradeStrategy.AUTOMATIC;
        case -1:
        case "UNRECOGNIZED":
        default:
            return UpgradeStrategy.UNRECOGNIZED;
    }
}
export function upgradeStrategyToJSON(object) {
    switch (object) {
        case UpgradeStrategy.MANUAL:
            return 0;
        case UpgradeStrategy.AUTOMATIC:
            return 1;
        case UpgradeStrategy.UNRECOGNIZED:
        default:
            return -1;
    }
}
/**
 * Permissions that a moderator can grant to the app developer for an installation
 * This enum maps 1-to-1 to its Prisma equivalent in prisma/schema.prisma,
 * so they must be kept in sync
 */
export var DeveloperPermissions;
(function (DeveloperPermissions) {
    /** NONE - No permissions granted */
    DeveloperPermissions[DeveloperPermissions["NONE"] = 0] = "NONE";
    /**
     * READ_INSTALL_LOGS - Developer can stream the installation's logs and see the installation page
     * in portal, but cannot edit the installation's settings
     */
    DeveloperPermissions[DeveloperPermissions["READ_INSTALL_LOGS"] = 1] = "READ_INSTALL_LOGS";
    DeveloperPermissions[DeveloperPermissions["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(DeveloperPermissions || (DeveloperPermissions = {}));
export function developerPermissionsFromJSON(object) {
    switch (object) {
        case 0:
        case "NONE":
            return DeveloperPermissions.NONE;
        case 1:
        case "READ_INSTALL_LOGS":
            return DeveloperPermissions.READ_INSTALL_LOGS;
        case -1:
        case "UNRECOGNIZED":
        default:
            return DeveloperPermissions.UNRECOGNIZED;
    }
}
export function developerPermissionsToJSON(object) {
    switch (object) {
        case DeveloperPermissions.NONE:
            return 0;
        case DeveloperPermissions.READ_INSTALL_LOGS:
            return 1;
        case DeveloperPermissions.UNRECOGNIZED:
        default:
            return -1;
    }
}
export var InstallationHistoryEventName;
(function (InstallationHistoryEventName) {
    InstallationHistoryEventName[InstallationHistoryEventName["INSTALLED"] = 0] = "INSTALLED";
    InstallationHistoryEventName[InstallationHistoryEventName["UNINSTALLED"] = 1] = "UNINSTALLED";
    InstallationHistoryEventName[InstallationHistoryEventName["UPGRADED"] = 2] = "UPGRADED";
    InstallationHistoryEventName[InstallationHistoryEventName["UPDATED"] = 3] = "UPDATED";
    InstallationHistoryEventName[InstallationHistoryEventName["BANNED"] = 4] = "BANNED";
    InstallationHistoryEventName[InstallationHistoryEventName["UNBANNED"] = 5] = "UNBANNED";
    InstallationHistoryEventName[InstallationHistoryEventName["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(InstallationHistoryEventName || (InstallationHistoryEventName = {}));
export function installationHistoryEventNameFromJSON(object) {
    switch (object) {
        case 0:
        case "INSTALLED":
            return InstallationHistoryEventName.INSTALLED;
        case 1:
        case "UNINSTALLED":
            return InstallationHistoryEventName.UNINSTALLED;
        case 2:
        case "UPGRADED":
            return InstallationHistoryEventName.UPGRADED;
        case 3:
        case "UPDATED":
            return InstallationHistoryEventName.UPDATED;
        case 4:
        case "BANNED":
            return InstallationHistoryEventName.BANNED;
        case 5:
        case "UNBANNED":
            return InstallationHistoryEventName.UNBANNED;
        case -1:
        case "UNRECOGNIZED":
        default:
            return InstallationHistoryEventName.UNRECOGNIZED;
    }
}
export function installationHistoryEventNameToJSON(object) {
    switch (object) {
        case InstallationHistoryEventName.INSTALLED:
            return 0;
        case InstallationHistoryEventName.UNINSTALLED:
            return 1;
        case InstallationHistoryEventName.UPGRADED:
            return 2;
        case InstallationHistoryEventName.UPDATED:
            return 3;
        case InstallationHistoryEventName.BANNED:
            return 4;
        case InstallationHistoryEventName.UNBANNED:
            return 5;
        case InstallationHistoryEventName.UNRECOGNIZED:
        default:
            return -1;
    }
}
function createBaseOptionalUpgradeStrategy() {
    return { value: 0 };
}
export const OptionalUpgradeStrategy = {
    $type: "devvit.dev_portal.installation.OptionalUpgradeStrategy",
    encode(message, writer = _m0.Writer.create()) {
        if (message.value !== 0) {
            writer.uint32(8).int32(message.value);
        }
        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 = createBaseOptionalUpgradeStrategy();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 8) {
                        break;
                    }
                    message.value = reader.int32();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return { value: isSet(object.value) ? upgradeStrategyFromJSON(object.value) : 0 };
    },
    toJSON(message) {
        const obj = {};
        if (message.value !== 0) {
            obj.value = upgradeStrategyToJSON(message.value);
        }
        return obj;
    },
    create(base) {
        return OptionalUpgradeStrategy.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseOptionalUpgradeStrategy();
        message.value = object.value ?? 0;
        return message;
    },
};
messageTypeRegistry.set(OptionalUpgradeStrategy.$type, OptionalUpgradeStrategy);
function createBaseInstallationCreationRequest() {
    return {
        appVersionId: "",
        runAs: undefined,
        type: 0,
        location: "",
        upgradeStrategy: 0,
        upgradeStrategyConfig: undefined,
    };
}
export const InstallationCreationRequest = {
    $type: "devvit.dev_portal.installation.InstallationCreationRequest",
    encode(message, writer = _m0.Writer.create()) {
        if (message.appVersionId !== "") {
            writer.uint32(10).string(message.appVersionId);
        }
        if (message.runAs !== undefined) {
            StringValue.encode({ value: message.runAs }, writer.uint32(26).fork()).ldelim();
        }
        if (message.type !== 0) {
            writer.uint32(32).int32(message.type);
        }
        if (message.location !== "") {
            writer.uint32(42).string(message.location);
        }
        if (message.upgradeStrategy !== 0) {
            writer.uint32(48).int32(message.upgradeStrategy);
        }
        if (message.upgradeStrategyConfig !== undefined) {
            Struct.encode(Struct.wrap(message.upgradeStrategyConfig), writer.uint32(58).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 = createBaseInstallationCreationRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.appVersionId = reader.string();
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.runAs = StringValue.decode(reader, reader.uint32()).value;
                    continue;
                case 4:
                    if (tag !== 32) {
                        break;
                    }
                    message.type = reader.int32();
                    continue;
                case 5:
                    if (tag !== 42) {
                        break;
                    }
                    message.location = reader.string();
                    continue;
                case 6:
                    if (tag !== 48) {
                        break;
                    }
                    message.upgradeStrategy = reader.int32();
                    continue;
                case 7:
                    if (tag !== 58) {
                        break;
                    }
                    message.upgradeStrategyConfig = Struct.unwrap(Struct.decode(reader, reader.uint32()));
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            appVersionId: isSet(object.appVersionId) ? globalThis.String(object.appVersionId) : "",
            runAs: isSet(object.runAs) ? String(object.runAs) : undefined,
            type: isSet(object.type) ? installationTypeFromJSON(object.type) : 0,
            location: isSet(object.location) ? globalThis.String(object.location) : "",
            upgradeStrategy: isSet(object.upgradeStrategy) ? upgradeStrategyFromJSON(object.upgradeStrategy) : 0,
            upgradeStrategyConfig: isObject(object.upgradeStrategyConfig) ? object.upgradeStrategyConfig : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.appVersionId !== "") {
            obj.appVersionId = message.appVersionId;
        }
        if (message.runAs !== undefined) {
            obj.runAs = message.runAs;
        }
        if (message.type !== 0) {
            obj.type = installationTypeToJSON(message.type);
        }
        if (message.location !== "") {
            obj.location = message.location;
        }
        if (message.upgradeStrategy !== 0) {
            obj.upgradeStrategy = upgradeStrategyToJSON(message.upgradeStrategy);
        }
        if (message.upgradeStrategyConfig !== undefined) {
            obj.upgradeStrategyConfig = message.upgradeStrategyConfig;
        }
        return obj;
    },
    create(base) {
        return InstallationCreationRequest.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseInstallationCreationRequest();
        message.appVersionId = object.appVersionId ?? "";
        message.runAs = object.runAs ?? undefined;
        message.type = object.type ?? 0;
        message.location = object.location ?? "";
        message.upgradeStrategy = object.upgradeStrategy ?? 0;
        message.upgradeStrategyConfig = object.upgradeStrategyConfig ?? undefined;
        return message;
    },
};
messageTypeRegistry.set(InstallationCreationRequest.$type, InstallationCreationRequest);
function createBaseInstallationUpdateRequest() {
    return {
        id: "",
        runAs: undefined,
        upgradeStrategy: undefined,
        upgradeStrategyConfig: undefined,
        isEnabled: undefined,
        developerPermissions: undefined,
    };
}
export const InstallationUpdateRequest = {
    $type: "devvit.dev_portal.installation.InstallationUpdateRequest",
    encode(message, writer = _m0.Writer.create()) {
        if (message.id !== "") {
            writer.uint32(10).string(message.id);
        }
        if (message.runAs !== undefined) {
            StringValue.encode({ value: message.runAs }, writer.uint32(26).fork()).ldelim();
        }
        if (message.upgradeStrategy !== undefined) {
            OptionalUpgradeStrategy.encode(message.upgradeStrategy, writer.uint32(34).fork()).ldelim();
        }
        if (message.upgradeStrategyConfig !== undefined) {
            Struct.encode(Struct.wrap(message.upgradeStrategyConfig), writer.uint32(42).fork()).ldelim();
        }
        if (message.isEnabled !== undefined) {
            BoolValue.encode({ value: message.isEnabled }, writer.uint32(50).fork()).ldelim();
        }
        if (message.developerPermissions !== undefined) {
            writer.uint32(56).int32(message.developerPermissions);
        }
        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 = createBaseInstallationUpdateRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.id = reader.string();
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.runAs = StringValue.decode(reader, reader.uint32()).value;
                    continue;
                case 4:
                    if (tag !== 34) {
                        break;
                    }
                    message.upgradeStrategy = OptionalUpgradeStrategy.decode(reader, reader.uint32());
                    continue;
                case 5:
                    if (tag !== 42) {
                        break;
                    }
                    message.upgradeStrategyConfig = Struct.unwrap(Struct.decode(reader, reader.uint32()));
                    continue;
                case 6:
                    if (tag !== 50) {
                        break;
                    }
                    message.isEnabled = BoolValue.decode(reader, reader.uint32()).value;
                    continue;
                case 7:
                    if (tag !== 56) {
                        break;
                    }
                    message.developerPermissions = reader.int32();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            id: isSet(object.id) ? globalThis.String(object.id) : "",
            runAs: isSet(object.runAs) ? String(object.runAs) : undefined,
            upgradeStrategy: isSet(object.upgradeStrategy)
                ? OptionalUpgradeStrategy.fromJSON(object.upgradeStrategy)
                : undefined,
            upgradeStrategyConfig: isObject(object.upgradeStrategyConfig) ? object.upgradeStrategyConfig : undefined,
            isEnabled: isSet(object.isEnabled) ? Boolean(object.isEnabled) : undefined,
            developerPermissions: isSet(object.developerPermissions)
                ? developerPermissionsFromJSON(object.developerPermissions)
                : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.id !== "") {
            obj.id = message.id;
        }
        if (message.runAs !== undefined) {
            obj.runAs = message.runAs;
        }
        if (message.upgradeStrategy !== undefined) {
            obj.upgradeStrategy = OptionalUpgradeStrategy.toJSON(message.upgradeStrategy);
        }
        if (message.upgradeStrategyConfig !== undefined) {
            obj.upgradeStrategyConfig = message.upgradeStrategyConfig;
        }
        if (message.isEnabled !== undefined) {
            obj.isEnabled = message.isEnabled;
        }
        if (message.developerPermissions !== undefined) {
            obj.developerPermissions = developerPermissionsToJSON(message.developerPermissions);
        }
        return obj;
    },
    create(base) {
        return InstallationUpdateRequest.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseInstallationUpdateRequest();
        message.id = object.id ?? "";
        message.runAs = object.runAs ?? undefined;
        message.upgradeStrategy = (object.upgradeStrategy !== undefined && object.upgradeStrategy !== null)
            ? OptionalUpgradeStrategy.fromPartial(object.upgradeStrategy)
            : undefined;
        message.upgradeStrategyConfig = object.upgradeStrategyConfig ?? undefined;
        message.isEnabled = object.isEnabled ?? undefined;
        message.developerPermissions = object.developerPermissions ?? undefined;
        return message;
    },
};
messageTypeRegistry.set(InstallationUpdateRequest.$type, InstallationUpdateRequest);
function createBaseInstallationUpgradeRequest() {
    return { id: "", appVersionId: undefined };
}
export const InstallationUpgradeRequest = {
    $type: "devvit.dev_portal.installation.InstallationUpgradeRequest",
    encode(message, writer = _m0.Writer.create()) {
        if (message.id !== "") {
            writer.uint32(10).string(message.id);
        }
        if (message.appVersionId !== undefined) {
            StringValue.encode({ value: message.appVersionId }, 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 = createBaseInstallationUpgradeRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.id = reader.string();
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.appVersionId = StringValue.decode(reader, reader.uint32()).value;
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            id: isSet(object.id) ? globalThis.String(object.id) : "",
            appVersionId: isSet(object.appVersionId) ? String(object.appVersionId) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.id !== "") {
            obj.id = message.id;
        }
        if (message.appVersionId !== undefined) {
            obj.appVersionId = message.appVersionId;
        }
        return obj;
    },
    create(base) {
        return InstallationUpgradeRequest.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseInstallationUpgradeRequest();
        message.id = object.id ?? "";
        message.appVersionId = object.appVersionId ?? undefined;
        return message;
    },
};
messageTypeRegistry.set(InstallationUpgradeRequest.$type, InstallationUpgradeRequest);
function createBaseInstallationUpgradeManyRequest() {
    return { ids: [], appVersionId: "" };
}
export const InstallationUpgradeManyRequest = {
    $type: "devvit.dev_portal.installation.InstallationUpgradeManyRequest",
    encode(message, writer = _m0.Writer.create()) {
        for (const v of message.ids) {
            writer.uint32(10).string(v);
        }
        if (message.appVersionId !== "") {
            writer.uint32(18).string(message.appVersionId);
        }
        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 = createBaseInstallationUpgradeManyRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.ids.push(reader.string());
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.appVersionId = reader.string();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            ids: globalThis.Array.isArray(object?.ids) ? object.ids.map((e) => globalThis.String(e)) : [],
            appVersionId: isSet(object.appVersionId) ? globalThis.String(object.appVersionId) : "",
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.ids?.length) {
            obj.ids = message.ids;
        }
        if (message.appVersionId !== "") {
            obj.appVersionId = message.appVersionId;
        }
        return obj;
    },
    create(base) {
        return InstallationUpgradeManyRequest.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseInstallationUpgradeManyRequest();
        message.ids = object.ids?.map((e) => e) || [];
        message.appVersionId = object.appVersionId ?? "";
        return message;
    },
};
messageTypeRegistry.set(InstallationUpgradeManyRequest.$type, InstallationUpgradeManyRequest);
function createBaseGetByAppNameAndInstallLocationRequest() {
    return { slug: "", type: 0, location: "" };
}
export const GetByAppNameAndInstallLocationRequest = {
    $type: "devvit.dev_portal.installation.GetByAppNameAndInstallLocationRequest",
    encode(message, writer = _m0.Writer.create()) {
        if (message.slug !== "") {
            writer.uint32(10).string(message.slug);
        }
        if (message.type !== 0) {
            writer.uint32(16).int32(message.type);
        }
        if (message.location !== "") {
            writer.uint32(26).string(message.location);
        }
        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 = createBaseGetByAppNameAndInstallLocationRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.slug = reader.string();
                    continue;
                case 2:
                    if (tag !== 16) {
                        break;
                    }
                    message.type = reader.int32();
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.location = reader.string();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            slug: isSet(object.slug) ? globalThis.String(object.slug) : "",
            type: isSet(object.type) ? installationTypeFromJSON(object.type) : 0,
            location: isSet(object.location) ? globalThis.String(object.location) : "",
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.slug !== "") {
            obj.slug = message.slug;
        }
        if (message.type !== 0) {
            obj.type = installationTypeToJSON(message.type);
        }
        if (message.location !== "") {
            obj.location = message.location;
        }
        return obj;
    },
    create(base) {
        return GetByAppNameAndInstallLocationRequest.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseGetByAppNameAndInstallLocationRequest();
        message.slug = object.slug ?? "";
        message.type = object.type ?? 0;
        message.location = object.location ?? "";
        return message;
    },
};
messageTypeRegistry.set(GetByAppNameAndInstallLocationRequest.$type, GetByAppNameAndInstallLocationRequest);
function createBaseGetAllWithInstallLocationRequest() {
    return { type: 0, location: "" };
}
export const GetAllWithInstallLocationRequest = {
    $type: "devvit.dev_portal.installation.GetAllWithInstallLocationRequest",
    encode(message, writer = _m0.Writer.create()) {
        if (message.type !== 0) {
            writer.uint32(8).int32(message.type);
        }
        if (message.location !== "") {
            writer.uint32(18).string(message.location);
        }
        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 = createBaseGetAllWithInstallLocationRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 8) {
                        break;
                    }
                    message.type = reader.int32();
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.location = reader.string();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            type: isSet(object.type) ? installationTypeFromJSON(object.type) : 0,
            location: isSet(object.location) ? globalThis.String(object.location) : "",
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.type !== 0) {
            obj.type = installationTypeToJSON(message.type);
        }
        if (message.location !== "") {
            obj.location = message.location;
        }
        return obj;
    },
    create(base) {
        return GetAllWithInstallLocationRequest.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseGetAllWithInstallLocationRequest();
        message.type = object.type ?? 0;
        message.location = object.location ?? "";
        return message;
    },
};
messageTypeRegistry.set(GetAllWithInstallLocationRequest.$type, GetAllWithInstallLocationRequest);
function createBaseGetAllWithInstallerRequest() {
    return { installedBy: "" };
}
export const GetAllWithInstallerRequest = {
    $type: "devvit.dev_portal.installation.GetAllWithInstallerRequest",
    encode(message, writer = _m0.Writer.create()) {
        if (message.installedBy !== "") {
            writer.uint32(10).string(message.installedBy);
        }
        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 = createBaseGetAllWithInstallerRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.installedBy = reader.string();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return { installedBy: isSet(object.installedBy) ? globalThis.String(object.installedBy) : "" };
    },
    toJSON(message) {
        const obj = {};
        if (message.installedBy !== "") {
            obj.installedBy = message.installedBy;
        }
        return obj;
    },
    create(base) {
        return GetAllWithInstallerRequest.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseGetAllWithInstallerRequest();
        message.installedBy = object.installedBy ?? "";
        return message;
    },
};
messageTypeRegistry.set(GetAllWithInstallerRequest.$type, GetAllWithInstallerRequest);
function createBaseGetAllWithAppRequest() {
    return { id: "", take: undefined, skip: undefined };
}
export const GetAllWithAppRequest = {
    $type: "devvit.dev_portal.installation.GetAllWithAppRequest",
    encode(message, writer = _m0.Writer.create()) {
        if (message.id !== "") {
            writer.uint32(10).string(message.id);
        }
        if (message.take !== undefined) {
            writer.uint32(16).uint32(message.take);
        }
        if (message.skip !== undefined) {
            writer.uint32(24).uint32(message.skip);
        }
        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 = createBaseGetAllWithAppRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.id = reader.string();
                    continue;
                case 2:
                    if (tag !== 16) {
                        break;
                    }
                    message.take = reader.uint32();
                    continue;
                case 3:
                    if (tag !== 24) {
                        break;
                    }
                    message.skip = reader.uint32();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            id: isSet(object.id) ? globalThis.String(object.id) : "",
            take: isSet(object.take) ? globalThis.Number(object.take) : undefined,
            skip: isSet(object.skip) ? globalThis.Number(object.skip) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.id !== "") {
            obj.id = message.id;
        }
        if (message.take !== undefined) {
            obj.take = Math.round(message.take);
        }
        if (message.skip !== undefined) {
            obj.skip = Math.round(message.skip);
        }
        return obj;
    },
    create(base) {
        return GetAllWithAppRequest.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseGetAllWithAppRequest();
        message.id = object.id ?? "";
        message.take = object.take ?? undefined;
        message.skip = object.skip ?? undefined;
        return message;
    },
};
messageTypeRegistry.set(GetAllWithAppRequest.$type, GetAllWithAppRequest);
function createBaseGetInstallationHistoryRequest() {
    return { type: 0, location: "", slug: "", from: undefined, to: undefined, take: undefined, desc: undefined };
}
export const GetInstallationHistoryRequest = {
    $type: "devvit.dev_portal.installation.GetInstallationHistoryRequest",
    encode(message, writer = _m0.Writer.create()) {
        if (message.type !== 0) {
            writer.uint32(8).int32(message.type);
        }
        if (message.location !== "") {
            writer.uint32(18).string(message.location);
        }
        if (message.slug !== "") {
            writer.uint32(26).string(message.slug);
        }
        if (message.from !== undefined) {
            Timestamp.encode(toTimestamp(message.from), writer.uint32(34).fork()).ldelim();
        }
        if (message.to !== undefined) {
            Timestamp.encode(toTimestamp(message.to), writer.uint32(42).fork()).ldelim();
        }
        if (message.take !== undefined) {
            writer.uint32(48).uint32(message.take);
        }
        if (message.desc !== undefined) {
            writer.uint32(56).bool(message.desc);
        }
        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 = createBaseGetInstallationHistoryRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 8) {
                        break;
                    }
                    message.type = reader.int32();
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.location = reader.string();
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.slug = reader.string();
                    continue;
                case 4:
                    if (tag !== 34) {
                        break;
                    }
                    message.from = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
                    continue;
                case 5:
                    if (tag !== 42) {
                        break;
                    }
                    message.to = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
                    continue;
                case 6:
                    if (tag !== 48) {
                        break;
                    }
                    message.take = reader.uint32();
                    continue;
                case 7:
                    if (tag !== 56) {
                        break;
                    }
                    message.desc = reader.bool();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            type: isSet(object.type) ? installationTypeFromJSON(object.type) : 0,
            location: isSet(object.location) ? globalThis.String(object.location) : "",
            slug: isSet(object.slug) ? globalThis.String(object.slug) : "",
            from: isSet(object.from) ? fromJsonTimestamp(object.from) : undefined,
            to: isSet(object.to) ? fromJsonTimestamp(object.to) : undefined,
            take: isSet(object.take) ? globalThis.Number(object.take) : undefined,
            desc: isSet(object.desc) ? globalThis.Boolean(object.desc) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.type !== 0) {
            obj.type = installationTypeToJSON(message.type);
        }
        if (message.location !== "") {
            obj.location = message.location;
        }
        if (message.slug !== "") {
            obj.slug = message.slug;
        }
        if (message.from !== undefined) {
            obj.from = message.from.toISOString();
        }
        if (message.to !== undefined) {
            obj.to = message.to.toISOString();
        }
        if (message.take !== undefined) {
            obj.take = Math.round(message.take);
        }
        if (message.desc !== undefined) {
            obj.desc = message.desc;
        }
        return obj;
    },
    create(base) {
        return GetInstallationHistoryRequest.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseGetInstallationHistoryRequest();
        message.type = object.type ?? 0;
        message.location = object.location ?? "";
        message.slug = object.slug ?? "";
        message.from = object.from ?? undefined;
        message.to = object.to ?? undefined;
        message.take = object.take ?? undefined;
        message.desc = object.desc ?? undefined;
        return message;
    },
};
messageTypeRegistry.set(GetInstallationHistoryRequest.$type, GetInstallationHistoryRequest);
function createBaseInstallationInfo() {
    return {
        id: "",
        upgradeStrategy: 0,
        upgradeStrategyConfig: undefined,
        runAs: undefined,
        type: 0,
        location: undefined,
        isEnabled: false,
        developerPermissions: 0,
    };
}
export const InstallationInfo = {
    $type: "devvit.dev_portal.installation.InstallationInfo",
    encode(message, writer = _m0.Writer.create()) {
        if (message.id !== "") {
            writer.uint32(10).string(message.id);
        }
        if (message.upgradeStrategy !== 0) {
            writer.uint32(24).int32(message.upgradeStrategy);
        }
        if (message.upgradeStrategyConfig !== undefined) {
            Struct.encode(Struct.wrap(message.upgradeStrategyConfig), writer.uint32(34).fork()).ldelim();
        }
        if (message.runAs !== undefined) {
            StringValue.encode({ value: message.runAs }, writer.uint32(50).fork()).ldelim();
        }
        if (message.type !== 0) {
            writer.uint32(56).int32(message.type);
        }
        if (message.location !== undefined) {
            InstallationLocationInfo.encode(message.location, writer.uint32(66).fork()).ldelim();
        }
        if (message.isEnabled !== false) {
            writer.uint32(72).bool(message.isEnabled);
        }
        if (message.developerPermissions !== 0) {
            writer.uint32(80).int32(message.developerPermissions);
        }
        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 = createBaseInstallationInfo();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.id = reader.string();
                    continue;
                case 3:
                    if (tag !== 24) {
                        break;
                    }
                    message.upgradeStrategy = reader.int32();
                    continue;
                case 4:
                    if (tag !== 34) {
                        break;
                    }
                    message.upgradeStrategyConfig = Struct.unwrap(Struct.decode(reader, reader.uint32()));
                    continue;
                case 6:
                    if (tag !== 50) {
                        break;
                    }
                    message.runAs = StringValue.decode(reader, reader.uint32()).value;
                    continue;
                case 7:
                    if (tag !== 56) {
                        break;
                    }
                    message.type = reader.int32();
                    continue;
                case 8:
                    if (tag !== 66) {
                        break;
                    }
                    message.location = InstallationLocationInfo.decode(reader, reader.uint32());
                    continue;
                case 9:
                    if (tag !== 72) {
                        break;
                    }
                    message.isEnabled = reader.bool();
                    continue;
                case 10:
                    if (tag !== 80) {
                        break;
                    }
                    message.developerPermissions = reader.int32();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            id: isSet(object.id) ? globalThis.String(object.id) : "",
            upgradeStrategy: isSet(object.upgradeStrategy) ? upgradeStrategyFromJSON(object.upgradeStrategy) : 0,
            upgradeStrategyConfig: isObject(object.upgradeStrategyConfig) ? object.upgradeStrategyConfig : undefined,
            runAs: isSet(object.runAs) ? String(object.runAs) : undefined,
            type: isSet(object.type) ? installationTypeFromJSON(object.type) : 0,
            location: isSet(object.location) ? InstallationLocationInfo.fromJSON(object.location) : undefined,
            isEnabled: isSet(object.isEnabled) ? globalThis.Boolean(object.isEnabled) : false,
            developerPermissions: isSet(object.developerPermissions)
                ? developerPermissionsFromJSON(object.developerPermissions)
                : 0,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.id !== "") {
            obj.id = message.id;
        }
        if (message.upgradeStrategy !== 0) {
            obj.upgradeStrategy = upgradeStrategyToJSON(message.upgradeStrategy);
        }
        if (message.upgradeStrategyConfig !== undefined) {
            obj.upgradeStrategyConfig = message.upgradeStrategyConfig;
        }
        if (message.runAs !== undefined) {
            obj.runAs = message.runAs;
        }
        if (message.type !== 0) {
            obj.type = installationTypeToJSON(message.type);
        }
        if (message.location !== undefined) {
            obj.location = InstallationLocationInfo.toJSON(message.location);
        }
        if (message.isEnabled !== false) {
            obj.isEnabled = message.isEnabled;
        }
        if (message.developerPermissions !== 0) {
            obj.developerPermissions = developerPermissionsToJSON(message.developerPermissions);
        }
        return obj;
    },
    create(base) {
        return InstallationInfo.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseInstallationInfo();
        message.id = object.id ?? "";
        message.upgradeStrategy = object.upgradeStrategy ?? 0;
        message.upgradeStrategyConfig = object.upgradeStrategyConfig ?? undefined;
        message.runAs = object.runAs ?? undefined;
        message.type = object.type ?? 0;
        message.location = (object.location !== undefined && object.location !== null)
            ? InstallationLocationInfo.fromPartial(object.location)
            : undefined;
        message.isEnabled = object.isEnabled ?? false;
        message.developerPermissions = object.developerPermissions ?? 0;
        return message;
    },
};
messageTypeRegistry.set(InstallationInfo.$type, InstallationInfo);
function createBaseInstallationLocationInfo() {
    return { id: "", name: "", type: 0, icon: undefined, isNsfw: false, isUnavailable: false };
}
export const InstallationLocationInfo = {
    $type: "devvit.dev_portal.installation.InstallationLocationInfo",
    encode(message, writer = _m0.Writer.create()) {
        if (message.id !== "") {
            writer.uint32(10).string(message.id);
        }
        if (message.name !== "") {
            writer.uint32(18).string(message.name);
        }
        if (message.type !== 0) {
            writer.uint32(24).int32(message.type);
        }
        if (message.icon !== undefined) {
            StringValue.encode({ value: message.icon }, writer.uint32(34).fork()).ldelim();
        }
        if (message.isNsfw !== false) {
            writer.uint32(40).bool(message.isNsfw);
        }
        if (message.isUnavailable !== false) {
            writer.uint32(48).bool(message.isUnavailable);
        }
        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 = createBaseInstallationLocationInfo();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.id = reader.string();
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.name = reader.string();
                    continue;
                case 3:
                    if (tag !== 24) {
                        break;
                    }
                    message.type = reader.int32();
                    continue;
                case 4:
                    if (tag !== 34) {
                        break;
                    }
                    message.icon = StringValue.decode(reader, reader.uint32()).value;
                    continue;
                case 5:
                    if (tag !== 40) {
                        break;
                    }
                    message.isNsfw = reader.bool();
                    continue;
                case 6:
                    if (tag !== 48) {
                        break;
                    }
                    message.isUnavailable = reader.bool();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            id: isSet(object.id) ? globalThis.String(object.id) : "",
            name: isSet(object.name) ? globalThis.String(object.name) : "",
            type: isSet(object.type) ? thingTypeFromJSON(object.type) : 0,
            icon: isSet(object.icon) ? String(object.icon) : undefined,
            isNsfw: isSet(object.isNsfw) ? globalThis.Boolean(object.isNsfw) : false,
            isUnavailable: isSet(object.isUnavailable) ? globalThis.Boolean(object.isUnavailable) : false,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.id !== "") {
            obj.id = message.id;
        }
        if (message.name !== "") {
            obj.name = message.name;
        }
        if (message.type !== 0) {
            obj.type = thingTypeToJSON(message.type);
        }
        if (message.icon !== undefined) {
            obj.icon = message.icon;
        }
        if (message.isNsfw !== false) {
            obj.isNsfw = message.isNsfw;
        }
        if (message.isUnavailable !== false) {
            obj.isUnavailable = message.isUnavailable;
        }
        return obj;
    },
    create(base) {
        return InstallationLocationInfo.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseInstallationLocationInfo();
        message.id = object.id ?? "";
        message.name = object.name ?? "";
        message.type = object.type ?? 0;
        message.icon = object.icon ?? undefined;
        message.isNsfw = object.isNsfw ?? false;
        message.isUnavailable = object.isUnavailable ?? false;
        return message;
    },
};
messageTypeRegistry.set(InstallationLocationInfo.$type, InstallationLocationInfo);
function createBaseFullInstallationInfo() {
    return { installation: undefined, appVersion: undefined, app: undefined };
}
export const FullInstallationInfo = {
    $type: "devvit.dev_portal.installation.FullInstallationInfo",
    encode(message, writer = _m0.Writer.create()) {
        if (message.installation !== undefined) {
            InstallationInfo.encode(message.installation, writer.uint32(10).fork()).ldelim();
        }
        if (message.appVersion !== undefined) {
            AppVersionInfo.encode(message.appVersion, writer.uint32(18).fork()).ldelim();
        }
        if (message.app !== undefined) {
            AppInfo.encode(message.app, 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 = createBaseFullInstallationInfo();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.installation = InstallationInfo.decode(reader, reader.uint32());
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.appVersion = AppVersionInfo.decode(reader, reader.uint32());
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.app = AppInfo.decode(reader, reader.uint32());
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            installation: isSet(object.installation) ? InstallationInfo.fromJSON(object.installation) : undefined,
            appVersion: isSet(object.appVersion) ? AppVersionInfo.fromJSON(object.appVersion) : undefined,
            app: isSet(object.app) ? AppInfo.fromJSON(object.app) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.installation !== undefined) {
            obj.installation = InstallationInfo.toJSON(message.installation);
        }
        if (message.appVersion !== undefined) {
            obj.appVersion = AppVersionInfo.toJSON(message.appVersion);
        }
        if (message.app !== undefined) {
            obj.app = AppInfo.toJSON(message.app);
        }
        return obj;
    },
    create(base) {
        return FullInstallationInfo.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseFullInstallationInfo();
        message.installation = (object.installation !== undefined && object.installation !== null)
            ? InstallationInfo.fromPartial(object.installation)
            : undefined;
        message.appVersion = (object.appVersion !== undefined && object.appVersion !== null)
            ? AppVersionInfo.fromPartial(object.appVersion)
            : undefined;
        message.app = (object.app !== undefined && object.app !== null) ? AppInfo.fromPartial(object.app) : undefined;
        return message;
    },
};
messageTypeRegistry.set(FullInstallationInfo.$type, FullInstallationInfo);
function createBaseMultipleInstallationsResponse() {
    return { installations: [] };
}
export const MultipleInstallationsResponse = {
    $type: "devvit.dev_portal.installation.MultipleInstallationsResponse",
    encode(message, writer = _m0.Writer.create()) {
        for (const v of message.installations) {
            InstallationInfo.encode(v, writer.uint32(10).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 = createBaseMultipleInstallationsResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.installations.push(InstallationInfo.decode(reader, reader.uint32()));
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            installations: globalThis.Array.isArray(object?.installations)
                ? object.installations.map((e) => InstallationInfo.fromJSON(e))
                : [],
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.installations?.length) {
            obj.installations = message.installations.map((e) => InstallationInfo.toJSON(e));
        }
        return obj;
    },
    create(base) {
        return MultipleInstallationsResponse.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseMultipleInstallationsResponse();
        message.installations = object.installations?.map((e) => InstallationInfo.fromPartial(e)) || [];
        return message;
    },
};
messageTypeRegistry.set(MultipleInstallationsResponse.$type, MultipleInstallationsResponse);
function createBaseGetAllWithAppResponse() {
    return { installations: [] };
}
export const GetAllWithAppResponse = {
    $type: "devvit.dev_portal.installation.GetAllWithAppResponse",
    encode(message, writer = _m0.Writer.create()) {
        for (const v of message.installations) {
            InstallationWithAppVersion.encode(v, writer.uint32(10).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 = createBaseGetAllWithAppResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.installations.push(InstallationWithAppVersion.decode(reader, reader.uint32()));
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            installations: globalThis.Array.isArray(object?.installations)
                ? object.installations.map((e) => InstallationWithAppVersion.fromJSON(e))
                : [],
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.installations?.length) {
            obj.installations = message.installations.map((e) => InstallationWithAppVersion.toJSON(e));
        }
        return obj;
    },
    create(base) {
        return GetAllWithAppResponse.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseGetAllWithAppResponse();
        message.installations = object.installations?.map((e) => InstallationWithAppVersion.fromPartial(e)) || [];
        return message;
    },
};
messageTypeRegistry.set(GetAllWithAppResponse.$type, GetAllWithAppResponse);
function createBaseInstallationWithAppVersion() {
    return { installation: undefined, appVersion: undefined };
}
export const InstallationWithAppVersion = {
    $type: "devvit.dev_portal.installation.InstallationWithAppVersion",
    encode(message, writer = _m0.Writer.create()) {
        if (message.installation !== undefined) {
            InstallationInfo.encode(message.installation, writer.uint32(10).fork()).ldelim();
        }
        if (message.appVersion !== undefined) {
            AppVersionInfo.encode(message.appVersion, 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 = createBaseInstallationWithAppVersion();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.installation = InstallationInfo.decode(reader, reader.uint32());
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.appVersion = AppVersionInfo.decode(reader, reader.uint32());
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            installation: isSet(object.installation) ? InstallationInfo.fromJSON(object.installation) : undefined,
            appVersion: isSet(object.appVersion) ? AppVersionInfo.fromJSON(object.appVersion) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.installation !== undefined) {
            obj.installation = InstallationInfo.toJSON(message.installation);
        }
        if (message.appVersion !== undefined) {
            obj.appVersion = AppVersionInfo.toJSON(message.appVersion);
        }
        return obj;
    },
    create(base) {
        return InstallationWithAppVersion.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseInstallationWithAppVersion();
        message.installation = (object.installation !== undefined && object.installation !== null)
            ? InstallationInfo.fromPartial(object.installation)
            : undefined;
        message.appVersion = (object.appVersion !== undefined && object.appVersion !== null)
            ? AppVersionInfo.fromPartial(object.appVersion)
            : undefined;
        return message;
    },
};
messageTypeRegistry.set(InstallationWithAppVersion.$type, InstallationWithAppVersion);
function createBaseInstallationUpgradeManyResponse() {
    return { details: [] };
}
export const InstallationUpgradeManyResponse = {
    $type: "devvit.dev_portal.installation.InstallationUpgradeManyResponse",
    encode(message, writer = _m0.Writer.create()) {
        for (const v of message.details) {
            InstallationUpgradeManyResponse_InstallationUpgradeDetails.encode(v, writer.uint32(10).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 = createBaseInstallationUpgradeManyResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.details.push(InstallationUpgradeManyResponse_InstallationUpgradeDetails.decode(reader, reader.uint32()));
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            details: globalThis.Array.isArray(object?.details)
                ? object.details.map((e) => InstallationUpgradeManyResponse_InstallationUpgradeDetails.fromJSON(e))
                : [],
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.details?.length) {
            obj.details = message.details.map((e) => InstallationUpgradeManyResponse_InstallationUpgradeDetails.toJSON(e));
        }
        return obj;
    },
    create(base) {
        return InstallationUpgradeManyResponse.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseInstallationUpgradeManyResponse();
        message.details =
            object.details?.map((e) => InstallationUpgradeManyResponse_InstallationUpgradeDetails.fromPartial(e)) || [];
        return message;
    },
};
messageTypeRegistry.set(InstallationUpgradeManyResponse.$type, InstallationUpgradeManyResponse);
function createBaseInstallationUpgradeManyResponse_InstallationUpgradeDetails() {
    return { id: "", success: false, error: undefined };
}
export const InstallationUpgradeManyResponse_InstallationUpgradeDetails = {
    $type: "devvit.dev_portal.installation.InstallationUpgradeManyResponse.InstallationUpgradeDetails",
    encode(message, writer = _m0.Writer.create()) {
        if (message.id !== "") {
            writer.uint32(10).string(message.id);
        }
        if (message.success !== false) {
            writer.uint32(16).bool(message.success);
        }
        if (message.error !== undefined) {
            writer.uint32(26).string(message.error);
        }
        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 = createBaseInstallationUpgradeManyResponse_InstallationUpgradeDetails();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.id = reader.string();
                    continue;
                case 2:
                    if (tag !== 16) {
                        break;
                    }
                    message.success = reader.bool();
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.error = reader.string();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            id: isSet(object.id) ? globalThis.String(object.id) : "",
            success: isSet(object.success) ? globalThis.Boolean(object.success) : false,
            error: isSet(object.error) ? globalThis.String(object.error) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.id !== "") {
            obj.id = message.id;
        }
        if (message.success !== false) {
            obj.success = message.success;
        }
        if (message.error !== undefined) {
            obj.error = message.error;
        }
        return obj;
    },
    create(base) {
        return InstallationUpgradeManyResponse_InstallationUpgradeDetails.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseInstallationUpgradeManyResponse_InstallationUpgradeDetails();
        message.id = object.id ?? "";
        message.success = object.success ?? false;
        message.error = object.error ?? undefined;
        return message;
    },
};
messageTypeRegistry.set(InstallationUpgradeManyResponse_InstallationUpgradeDetails.$type, InstallationUpgradeManyResponse_InstallationUpgradeDetails);
function createBaseInstallationLocationDetails() {
    return { type: 0, thingId: "", name: "" };
}
export const InstallationLocationDetails = {
    $type: "devvit.dev_portal.installation.InstallationLocationDetails",
    encode(message, writer = _m0.Writer.create()) {
        if (message.type !== 0) {
            writer.uint32(8).int32(message.type);
        }
        if (message.thingId !== "") {
            writer.uint32(18).string(message.thingId);
        }
        if (message.name !== "") {
            writer.uint32(26).string(message.name);
        }
        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 = createBaseInstallationLocationDetails();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 8) {
                        break;
                    }
                    message.type = reader.int32();
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.thingId = reader.string();
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.name = reader.string();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            type: isSet(object.type) ? installationTypeFromJSON(object.type) : 0,
            thingId: isSet(object.thingId) ? globalThis.String(object.thingId) : "",
            name: isSet(object.name) ? globalThis.String(object.name) : "",
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.type !== 0) {
            obj.type = installationTypeToJSON(message.type);
        }
        if (message.thingId !== "") {
            obj.thingId = message.thingId;
        }
        if (message.name !== "") {
            obj.name = message.name;
        }
        return obj;
    },
    create(base) {
        return InstallationLocationDetails.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseInstallationLocationDetails();
        message.type = object.type ?? 0;
        message.thingId = object.thingId ?? "";
        message.name = object.name ?? "";
        return message;
    },
};
messageTypeRegistry.set(InstallationLocationDetails.$type, InstallationLocationDetails);
function createBaseInstallationHistoryEvent() {
    return { userId: "", name: 0, details: {}, createdAt: undefined };
}
export const InstallationHistoryEvent = {
    $type: "devvit.dev_portal.installation.InstallationHistoryEvent",
    encode(message, writer = _m0.Writer.create()) {
        if (message.userId !== "") {
            writer.uint32(10).string(message.userId);
        }
        if (message.name !== 0) {
            writer.uint32(16).int32(message.name);
        }
        Object.entries(message.details).forEach(([key, value]) => {
            InstallationHistoryEvent_DetailsEntry.encode({ key: key, value }, writer.uint32(26).fork()).ldelim();
        });
        if (message.createdAt !== undefined) {
            Timestamp.encode(toTimestamp(message.createdAt), writer.uint32(34).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 = createBaseInstallationHistoryEvent();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.userId = reader.string();
                    continue;
                case 2:
                    if (tag !== 16) {
                        break;
                    }
                    message.name = reader.int32();
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    const entry3 = InstallationHistoryEvent_DetailsEntry.decode(reader, reader.uint32());
                    if (entry3.value !== undefined) {
                        message.details[entry3.key] = entry3.value;
                    }
                    continue;
                case 4:
                    if (tag !== 34) {
                        break;
                    }
                    message.createdAt = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            userId: isSet(object.userId) ? globalThis.String(object.userId) : "",
            name: isSet(object.name) ? installationHistoryEventNameFromJSON(object.name) : 0,
            details: isObject(object.details)
                ? Object.entries(object.details).reduce((acc, [key, value]) => {
                    acc[key] = String(value);
                    return acc;
                }, {})
                : {},
            createdAt: isSet(object.createdAt) ? fromJsonTimestamp(object.createdAt) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.userId !== "") {
            obj.userId = message.userId;
        }
        if (message.name !== 0) {
            obj.name = installationHistoryEventNameToJSON(message.name);
        }
        if (message.details) {
            const entries = Object.entries(message.details);
            if (entries.length > 0) {
                obj.details = {};
                entries.forEach(([k, v]) => {
                    obj.details[k] = v;
                });
            }
        }
        if (message.createdAt !== undefined) {
            obj.createdAt = message.createdAt.toISOString();
        }
        return obj;
    },
    create(base) {
        return InstallationHistoryEvent.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseInstallationHistoryEvent();
        message.userId = object.userId ?? "";
        message.name = object.name ?? 0;
        message.details = Object.entries(object.details ?? {}).reduce((acc, [key, value]) => {
            if (value !== undefined) {
                acc[key] = globalThis.String(value);
            }
            return acc;
        }, {});
        message.createdAt = object.createdAt ?? undefined;
        return message;
    },
};
messageTypeRegistry.set(InstallationHistoryEvent.$type, InstallationHistoryEvent);
function createBaseInstallationHistoryEvent_DetailsEntry() {
    return { key: "", value: "" };
}
export const InstallationHistoryEvent_DetailsEntry = {
    $type: "devvit.dev_portal.installation.InstallationHistoryEvent.DetailsEntry",
    encode(message, writer = _m0.Writer.create()) {
        if (message.key !== "") {
            writer.uint32(10).string(message.key);
        }
        if (message.value !== "") {
            writer.uint32(18).string(message.value);
        }
        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 = createBaseInstallationHistoryEvent_DetailsEntry();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.key = reader.string();
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.value = reader.string();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            key: isSet(object.key) ? globalThis.String(object.key) : "",
            value: isSet(object.value) ? globalThis.String(object.value) : "",
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.key !== "") {
            obj.key = message.key;
        }
        if (message.value !== "") {
            obj.value = message.value;
        }
        return obj;
    },
    create(base) {
        return InstallationHistoryEvent_DetailsEntry.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseInstallationHistoryEvent_DetailsEntry();
        message.key = object.key ?? "";
        message.value = object.value ?? "";
        return message;
    },
};
messageTypeRegistry.set(InstallationHistoryEvent_DetailsEntry.$type, InstallationHistoryEvent_DetailsEntry);
function createBaseGetInstallationHistoryResponse() {
    return { events: [], totalEvents: 0 };
}
export const GetInstallationHistoryResponse = {
    $type: "devvit.dev_portal.installation.GetInstallationHistoryResponse",
    encode(message, writer = _m0.Writer.create()) {
        for (const v of message.events) {
            InstallationHistoryEvent.encode(v, writer.uint32(10).fork()).ldelim();
        }
        if (message.totalEvents !== 0) {
            writer.uint32(64).uint32(message.totalEvents);
        }
        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 = createBaseGetInstallationHistoryResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.events.push(InstallationHistoryEvent.decode(reader, reader.uint32()));
                    continue;
                case 8:
                    if (tag !== 64) {
                        break;
                    }
                    message.totalEvents = reader.uint32();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            events: globalThis.Array.isArray(object?.events)
                ? object.events.map((e) => InstallationHistoryEvent.fromJSON(e))
                : [],
            totalEvents: isSet(object.totalEvents) ? globalThis.Number(object.totalEvents) : 0,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.events?.length) {
            obj.events = message.events.map((e) => InstallationHistoryEvent.toJSON(e));
        }
        if (message.totalEvents !== 0) {
            obj.totalEvents = Math.round(message.totalEvents);
        }
        return obj;
    },
    create(base) {
        return GetInstallationHistoryResponse.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseGetInstallationHistoryResponse();
        message.events = object.events?.map((e) => InstallationHistoryEvent.fromPartial(e)) || [];
        message.totalEvents = object.totalEvents ?? 0;
        return message;
    },
};
messageTypeRegistry.set(GetInstallationHistoryResponse.$type, GetInstallationHistoryResponse);
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 isObject(value) {
    return typeof value === "object" && value !== null;
}
function isSet(value) {
    return value !== null && value !== undefined;
}
