"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LagAllocationSettings = exports.LagAllocationSettingsRequest = exports.protobufPackage = void 0;
/* eslint-disable */
const long_1 = __importDefault(require("long"));
const minimal_1 = __importDefault(require("protobufjs/minimal"));
const lag_info_1 = require("../../../../../yandex/cloud/cic/v1/common/lag_info");
exports.protobufPackage = 'yandex.cloud.cic.v1.common';
const baseLagAllocationSettingsRequest = {};
exports.LagAllocationSettingsRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.lagSize !== undefined) {
            writer.uint32(104).int64(message.lagSize);
        }
        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({}, baseLagAllocationSettingsRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 13:
                    message.lagSize = longToNumber(reader.int64());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseLagAllocationSettingsRequest);
        message.lagSize =
            object.lagSize !== undefined && object.lagSize !== null
                ? Number(object.lagSize)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.lagSize !== undefined && (obj.lagSize = Math.round(message.lagSize));
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseLagAllocationSettingsRequest);
        message.lagSize = (_a = object.lagSize) !== null && _a !== void 0 ? _a : undefined;
        return message;
    },
};
const baseLagAllocationSettings = {};
exports.LagAllocationSettings = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.lagInfo !== undefined) {
            lag_info_1.LagInfo.encode(message.lagInfo, writer.uint32(114).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({}, baseLagAllocationSettings);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 14:
                    message.lagInfo = lag_info_1.LagInfo.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseLagAllocationSettings);
        message.lagInfo =
            object.lagInfo !== undefined && object.lagInfo !== null
                ? lag_info_1.LagInfo.fromJSON(object.lagInfo)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.lagInfo !== undefined &&
            (obj.lagInfo = message.lagInfo ? lag_info_1.LagInfo.toJSON(message.lagInfo) : undefined);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseLagAllocationSettings);
        message.lagInfo =
            object.lagInfo !== undefined && object.lagInfo !== null
                ? lag_info_1.LagInfo.fromPartial(object.lagInfo)
                : undefined;
        return message;
    },
};
var globalThis = (() => {
    if (typeof globalThis !== 'undefined')
        return globalThis;
    if (typeof self !== 'undefined')
        return self;
    if (typeof window !== 'undefined')
        return window;
    if (typeof global !== 'undefined')
        return global;
    throw 'Unable to locate global object';
})();
function longToNumber(long) {
    if (long.gt(Number.MAX_SAFE_INTEGER)) {
        throw new globalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER');
    }
    return long.toNumber();
}
if (minimal_1.default.util.Long !== long_1.default) {
    minimal_1.default.util.Long = long_1.default;
    minimal_1.default.configure();
}
