"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SingleAgentConfiguration_FilesEntry = exports.SingleAgentConfiguration = exports.protobufPackage = void 0;
/* eslint-disable */
const long_1 = __importDefault(require("long"));
const minimal_1 = __importDefault(require("protobufjs/minimal"));
const agent_selector_1 = require("../../../../../../yandex/cloud/loadtesting/api/v1/test/agent_selector");
const file_pointer_1 = require("../../../../../../yandex/cloud/loadtesting/api/v1/test/file_pointer");
exports.protobufPackage = 'yandex.cloud.loadtesting.api.v1.test';
const baseSingleAgentConfiguration = { configId: '' };
exports.SingleAgentConfiguration = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.configId !== '') {
            writer.uint32(10).string(message.configId);
        }
        if (message.agentSelector !== undefined) {
            agent_selector_1.AgentSelector.encode(message.agentSelector, writer.uint32(18).fork()).ldelim();
        }
        Object.entries(message.files).forEach(([key, value]) => {
            exports.SingleAgentConfiguration_FilesEntry.encode({ key: key, value }, writer.uint32(26).fork()).ldelim();
        });
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseSingleAgentConfiguration);
        message.files = {};
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.configId = reader.string();
                    break;
                case 2:
                    message.agentSelector = agent_selector_1.AgentSelector.decode(reader, reader.uint32());
                    break;
                case 3:
                    const entry3 = exports.SingleAgentConfiguration_FilesEntry.decode(reader, reader.uint32());
                    if (entry3.value !== undefined) {
                        message.files[entry3.key] = entry3.value;
                    }
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseSingleAgentConfiguration);
        message.configId =
            object.configId !== undefined && object.configId !== null
                ? String(object.configId)
                : '';
        message.agentSelector =
            object.agentSelector !== undefined && object.agentSelector !== null
                ? agent_selector_1.AgentSelector.fromJSON(object.agentSelector)
                : undefined;
        message.files = Object.entries((_a = object.files) !== null && _a !== void 0 ? _a : {}).reduce((acc, [key, value]) => {
            acc[key] = file_pointer_1.FilePointer.fromJSON(value);
            return acc;
        }, {});
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.configId !== undefined && (obj.configId = message.configId);
        message.agentSelector !== undefined &&
            (obj.agentSelector = message.agentSelector
                ? agent_selector_1.AgentSelector.toJSON(message.agentSelector)
                : undefined);
        obj.files = {};
        if (message.files) {
            Object.entries(message.files).forEach(([k, v]) => {
                obj.files[k] = file_pointer_1.FilePointer.toJSON(v);
            });
        }
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseSingleAgentConfiguration);
        message.configId = (_a = object.configId) !== null && _a !== void 0 ? _a : '';
        message.agentSelector =
            object.agentSelector !== undefined && object.agentSelector !== null
                ? agent_selector_1.AgentSelector.fromPartial(object.agentSelector)
                : undefined;
        message.files = Object.entries((_b = object.files) !== null && _b !== void 0 ? _b : {}).reduce((acc, [key, value]) => {
            if (value !== undefined) {
                acc[key] = file_pointer_1.FilePointer.fromPartial(value);
            }
            return acc;
        }, {});
        return message;
    },
};
const baseSingleAgentConfiguration_FilesEntry = { key: '' };
exports.SingleAgentConfiguration_FilesEntry = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.key !== '') {
            writer.uint32(10).string(message.key);
        }
        if (message.value !== undefined) {
            file_pointer_1.FilePointer.encode(message.value, writer.uint32(18).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseSingleAgentConfiguration_FilesEntry);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.key = reader.string();
                    break;
                case 2:
                    message.value = file_pointer_1.FilePointer.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseSingleAgentConfiguration_FilesEntry);
        message.key = object.key !== undefined && object.key !== null ? String(object.key) : '';
        message.value =
            object.value !== undefined && object.value !== null
                ? file_pointer_1.FilePointer.fromJSON(object.value)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.key !== undefined && (obj.key = message.key);
        message.value !== undefined &&
            (obj.value = message.value ? file_pointer_1.FilePointer.toJSON(message.value) : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseSingleAgentConfiguration_FilesEntry);
        message.key = (_a = object.key) !== null && _a !== void 0 ? _a : '';
        message.value =
            object.value !== undefined && object.value !== null
                ? file_pointer_1.FilePointer.fromPartial(object.value)
                : undefined;
        return message;
    },
};
if (minimal_1.default.util.Long !== long_1.default) {
    minimal_1.default.util.Long = long_1.default;
    minimal_1.default.configure();
}
