"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AppOptionsResponse = exports.AppOptionsResponse_ModuleOptionsEntry = exports.AppOptionsRequest = void 0;
const options_1 = require("./options");
const binary_1 = require("../../../binary");
const helpers_1 = require("../../../helpers");
const registry_1 = require("../../../registry");
function createBaseAppOptionsRequest() {
    return {};
}
/**
 * AppOptionsRequest is the RemoteInfoService/AppOptions request type.
 * @name AppOptionsRequest
 * @package cosmos.autocli.v1
 * @see proto type: cosmos.autocli.v1.AppOptionsRequest
 */
exports.AppOptionsRequest = {
    typeUrl: "/cosmos.autocli.v1.AppOptionsRequest",
    aminoType: "cosmos-sdk/AppOptionsRequest",
    is(o) {
        return o && o.$typeUrl === exports.AppOptionsRequest.typeUrl;
    },
    isAmino(o) {
        return o && o.$typeUrl === exports.AppOptionsRequest.typeUrl;
    },
    encode(_, writer = binary_1.BinaryWriter.create()) {
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof binary_1.BinaryReader ? input : new binary_1.BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseAppOptionsRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(_) {
        const message = createBaseAppOptionsRequest();
        return message;
    },
    fromAmino(_) {
        const message = createBaseAppOptionsRequest();
        return message;
    },
    toAmino(_) {
        const obj = {};
        return obj;
    },
    fromAminoMsg(object) {
        return exports.AppOptionsRequest.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/AppOptionsRequest",
            value: exports.AppOptionsRequest.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.AppOptionsRequest.decode(message.value);
    },
    toProto(message) {
        return exports.AppOptionsRequest.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmos.autocli.v1.AppOptionsRequest",
            value: exports.AppOptionsRequest.encode(message).finish()
        };
    },
    registerTypeUrl() { }
};
function createBaseAppOptionsResponse_ModuleOptionsEntry() {
    return {
        key: "",
        value: undefined
    };
}
/**
 * @name AppOptionsResponse_ModuleOptionsEntry
 * @package cosmos.autocli.v1
 * @see proto type: cosmos.autocli.v1.undefined
 */
exports.AppOptionsResponse_ModuleOptionsEntry = {
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.key !== "") {
            writer.uint32(10).string(message.key);
        }
        if (message.value !== undefined) {
            options_1.ModuleOptions.encode(message.value, writer.uint32(18).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof binary_1.BinaryReader ? input : new binary_1.BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseAppOptionsResponse_ModuleOptionsEntry();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.key = reader.string();
                    break;
                case 2:
                    message.value = options_1.ModuleOptions.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseAppOptionsResponse_ModuleOptionsEntry();
        message.key = object.key ?? "";
        message.value = object.value !== undefined && object.value !== null ? options_1.ModuleOptions.fromPartial(object.value) : undefined;
        return message;
    },
    fromAmino(object) {
        const message = createBaseAppOptionsResponse_ModuleOptionsEntry();
        if (object.key !== undefined && object.key !== null) {
            message.key = object.key;
        }
        if (object.value !== undefined && object.value !== null) {
            message.value = options_1.ModuleOptions.fromAmino(object.value);
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.key = message.key === "" ? undefined : message.key;
        obj.value = message.value ? options_1.ModuleOptions.toAmino(message.value) : undefined;
        return obj;
    },
    fromAminoMsg(object) {
        return exports.AppOptionsResponse_ModuleOptionsEntry.fromAmino(object.value);
    },
    fromProtoMsg(message) {
        return exports.AppOptionsResponse_ModuleOptionsEntry.decode(message.value);
    },
    toProto(message) {
        return exports.AppOptionsResponse_ModuleOptionsEntry.encode(message).finish();
    },
    registerTypeUrl() {
        options_1.ModuleOptions.registerTypeUrl();
    }
};
function createBaseAppOptionsResponse() {
    return {
        moduleOptions: {}
    };
}
/**
 * AppOptionsResponse is the RemoteInfoService/AppOptions response type.
 * @name AppOptionsResponse
 * @package cosmos.autocli.v1
 * @see proto type: cosmos.autocli.v1.AppOptionsResponse
 */
exports.AppOptionsResponse = {
    typeUrl: "/cosmos.autocli.v1.AppOptionsResponse",
    aminoType: "cosmos-sdk/AppOptionsResponse",
    is(o) {
        return o && (o.$typeUrl === exports.AppOptionsResponse.typeUrl || (0, helpers_1.isSet)(o.moduleOptions));
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.AppOptionsResponse.typeUrl || (0, helpers_1.isSet)(o.module_options));
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        Object.entries(message.moduleOptions).forEach(([key, value]) => {
            exports.AppOptionsResponse_ModuleOptionsEntry.encode({
                key: key,
                value
            }, writer.uint32(10).fork()).ldelim();
        });
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof binary_1.BinaryReader ? input : new binary_1.BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseAppOptionsResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    const entry1 = exports.AppOptionsResponse_ModuleOptionsEntry.decode(reader, reader.uint32());
                    if (entry1.value !== undefined) {
                        message.moduleOptions[entry1.key] = entry1.value;
                    }
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseAppOptionsResponse();
        message.moduleOptions = Object.entries(object.moduleOptions ?? {}).reduce((acc, [key, value]) => {
            if (value !== undefined) {
                acc[key] = options_1.ModuleOptions.fromPartial(value);
            }
            return acc;
        }, {});
        return message;
    },
    fromAmino(object) {
        const message = createBaseAppOptionsResponse();
        message.moduleOptions = Object.entries(object.module_options ?? {}).reduce((acc, [key, value]) => {
            if (value !== undefined) {
                acc[key] = options_1.ModuleOptions.fromAmino(value);
            }
            return acc;
        }, {});
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.module_options = {};
        if (message.moduleOptions) {
            Object.entries(message.moduleOptions).forEach(([k, v]) => {
                obj.module_options[k] = options_1.ModuleOptions.toAmino(v);
            });
        }
        return obj;
    },
    fromAminoMsg(object) {
        return exports.AppOptionsResponse.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/AppOptionsResponse",
            value: exports.AppOptionsResponse.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.AppOptionsResponse.decode(message.value);
    },
    toProto(message) {
        return exports.AppOptionsResponse.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmos.autocli.v1.AppOptionsResponse",
            value: exports.AppOptionsResponse.encode(message).finish()
        };
    },
    registerTypeUrl() {
        if (!registry_1.GlobalDecoderRegistry.registerExistingTypeUrl(exports.AppOptionsResponse.typeUrl)) {
            return;
        }
        options_1.ModuleOptions.registerTypeUrl();
    }
};
