"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RuleSetDescriptor_RuleDescription = exports.RuleSetDescriptor = exports.protobufPackage = void 0;
/* eslint-disable */
const long_1 = __importDefault(require("long"));
const minimal_1 = __importDefault(require("protobufjs/minimal"));
exports.protobufPackage = 'yandex.cloud.smartwebsecurity.v1.waf';
const baseRuleSetDescriptor = { name: '', version: '', id: '' };
exports.RuleSetDescriptor = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.name !== '') {
            writer.uint32(10).string(message.name);
        }
        if (message.version !== '') {
            writer.uint32(18).string(message.version);
        }
        if (message.id !== '') {
            writer.uint32(26).string(message.id);
        }
        for (const v of message.rules) {
            exports.RuleSetDescriptor_RuleDescription.encode(v, writer.uint32(34).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({}, baseRuleSetDescriptor);
        message.rules = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.name = reader.string();
                    break;
                case 2:
                    message.version = reader.string();
                    break;
                case 3:
                    message.id = reader.string();
                    break;
                case 4:
                    message.rules.push(exports.RuleSetDescriptor_RuleDescription.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseRuleSetDescriptor);
        message.name = object.name !== undefined && object.name !== null ? String(object.name) : '';
        message.version =
            object.version !== undefined && object.version !== null ? String(object.version) : '';
        message.id = object.id !== undefined && object.id !== null ? String(object.id) : '';
        message.rules = ((_a = object.rules) !== null && _a !== void 0 ? _a : []).map((e) => exports.RuleSetDescriptor_RuleDescription.fromJSON(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.name !== undefined && (obj.name = message.name);
        message.version !== undefined && (obj.version = message.version);
        message.id !== undefined && (obj.id = message.id);
        if (message.rules) {
            obj.rules = message.rules.map((e) => e ? exports.RuleSetDescriptor_RuleDescription.toJSON(e) : undefined);
        }
        else {
            obj.rules = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d;
        const message = Object.assign({}, baseRuleSetDescriptor);
        message.name = (_a = object.name) !== null && _a !== void 0 ? _a : '';
        message.version = (_b = object.version) !== null && _b !== void 0 ? _b : '';
        message.id = (_c = object.id) !== null && _c !== void 0 ? _c : '';
        message.rules =
            ((_d = object.rules) === null || _d === void 0 ? void 0 : _d.map((e) => exports.RuleSetDescriptor_RuleDescription.fromPartial(e))) || [];
        return message;
    },
};
const baseRuleSetDescriptor_RuleDescription = { id: '', anomalyScore: 0, paranoiaLevel: 0 };
exports.RuleSetDescriptor_RuleDescription = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.id !== '') {
            writer.uint32(10).string(message.id);
        }
        if (message.anomalyScore !== 0) {
            writer.uint32(64).int64(message.anomalyScore);
        }
        if (message.paranoiaLevel !== 0) {
            writer.uint32(72).int64(message.paranoiaLevel);
        }
        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({}, baseRuleSetDescriptor_RuleDescription);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.id = reader.string();
                    break;
                case 8:
                    message.anomalyScore = longToNumber(reader.int64());
                    break;
                case 9:
                    message.paranoiaLevel = longToNumber(reader.int64());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseRuleSetDescriptor_RuleDescription);
        message.id = object.id !== undefined && object.id !== null ? String(object.id) : '';
        message.anomalyScore =
            object.anomalyScore !== undefined && object.anomalyScore !== null
                ? Number(object.anomalyScore)
                : 0;
        message.paranoiaLevel =
            object.paranoiaLevel !== undefined && object.paranoiaLevel !== null
                ? Number(object.paranoiaLevel)
                : 0;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.id !== undefined && (obj.id = message.id);
        message.anomalyScore !== undefined && (obj.anomalyScore = Math.round(message.anomalyScore));
        message.paranoiaLevel !== undefined &&
            (obj.paranoiaLevel = Math.round(message.paranoiaLevel));
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c;
        const message = Object.assign({}, baseRuleSetDescriptor_RuleDescription);
        message.id = (_a = object.id) !== null && _a !== void 0 ? _a : '';
        message.anomalyScore = (_b = object.anomalyScore) !== null && _b !== void 0 ? _b : 0;
        message.paranoiaLevel = (_c = object.paranoiaLevel) !== null && _c !== void 0 ? _c : 0;
        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();
}
