"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Condition_GeoIpMatcher = exports.Condition_IpRangesMatcher = exports.Condition_IpMatcher = exports.Condition_HeaderMatcher = exports.Condition_QueryMatcher = exports.Condition_RequestUriMatcher = exports.Condition_AuthorityMatcher = exports.Condition_HttpMethodMatcher = exports.Condition_StringMatcher = exports.Condition = exports.SecurityRule_Waf = exports.SecurityRule_SmartProtection = exports.SecurityRule_RuleCondition = exports.SecurityRule = exports.SecurityProfile_LabelsEntry = exports.SecurityProfile_AnalyzeRequestBody = exports.SecurityProfile = exports.securityRule_Waf_ModeToJSON = exports.securityRule_Waf_ModeFromJSON = exports.SecurityRule_Waf_Mode = exports.securityRule_SmartProtection_ModeToJSON = exports.securityRule_SmartProtection_ModeFromJSON = exports.SecurityRule_SmartProtection_Mode = exports.securityRule_RuleCondition_ActionToJSON = exports.securityRule_RuleCondition_ActionFromJSON = exports.SecurityRule_RuleCondition_Action = exports.securityProfile_AnalyzeRequestBody_ActionToJSON = exports.securityProfile_AnalyzeRequestBody_ActionFromJSON = exports.SecurityProfile_AnalyzeRequestBody_Action = exports.securityProfile_DefaultActionToJSON = exports.securityProfile_DefaultActionFromJSON = exports.SecurityProfile_DefaultAction = exports.protobufPackage = void 0;
/* eslint-disable */
const long_1 = __importDefault(require("long"));
const minimal_1 = __importDefault(require("protobufjs/minimal"));
const timestamp_1 = require("../../../../google/protobuf/timestamp");
exports.protobufPackage = 'yandex.cloud.smartwebsecurity.v1';
/** Action to perform if none of rules matched. */
var SecurityProfile_DefaultAction;
(function (SecurityProfile_DefaultAction) {
    SecurityProfile_DefaultAction[SecurityProfile_DefaultAction["DEFAULT_ACTION_UNSPECIFIED"] = 0] = "DEFAULT_ACTION_UNSPECIFIED";
    /** ALLOW - Pass request to service. */
    SecurityProfile_DefaultAction[SecurityProfile_DefaultAction["ALLOW"] = 1] = "ALLOW";
    /** DENY - Deny request. */
    SecurityProfile_DefaultAction[SecurityProfile_DefaultAction["DENY"] = 2] = "DENY";
    SecurityProfile_DefaultAction[SecurityProfile_DefaultAction["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(SecurityProfile_DefaultAction = exports.SecurityProfile_DefaultAction || (exports.SecurityProfile_DefaultAction = {}));
function securityProfile_DefaultActionFromJSON(object) {
    switch (object) {
        case 0:
        case 'DEFAULT_ACTION_UNSPECIFIED':
            return SecurityProfile_DefaultAction.DEFAULT_ACTION_UNSPECIFIED;
        case 1:
        case 'ALLOW':
            return SecurityProfile_DefaultAction.ALLOW;
        case 2:
        case 'DENY':
            return SecurityProfile_DefaultAction.DENY;
        case -1:
        case 'UNRECOGNIZED':
        default:
            return SecurityProfile_DefaultAction.UNRECOGNIZED;
    }
}
exports.securityProfile_DefaultActionFromJSON = securityProfile_DefaultActionFromJSON;
function securityProfile_DefaultActionToJSON(object) {
    switch (object) {
        case SecurityProfile_DefaultAction.DEFAULT_ACTION_UNSPECIFIED:
            return 'DEFAULT_ACTION_UNSPECIFIED';
        case SecurityProfile_DefaultAction.ALLOW:
            return 'ALLOW';
        case SecurityProfile_DefaultAction.DENY:
            return 'DENY';
        default:
            return 'UNKNOWN';
    }
}
exports.securityProfile_DefaultActionToJSON = securityProfile_DefaultActionToJSON;
/** Action to perform if maximum size of body exceeded. */
var SecurityProfile_AnalyzeRequestBody_Action;
(function (SecurityProfile_AnalyzeRequestBody_Action) {
    SecurityProfile_AnalyzeRequestBody_Action[SecurityProfile_AnalyzeRequestBody_Action["ACTION_UNSPECIFIED"] = 0] = "ACTION_UNSPECIFIED";
    /** IGNORE - Ignore body. */
    SecurityProfile_AnalyzeRequestBody_Action[SecurityProfile_AnalyzeRequestBody_Action["IGNORE"] = 1] = "IGNORE";
    /** DENY - Deny request. */
    SecurityProfile_AnalyzeRequestBody_Action[SecurityProfile_AnalyzeRequestBody_Action["DENY"] = 2] = "DENY";
    SecurityProfile_AnalyzeRequestBody_Action[SecurityProfile_AnalyzeRequestBody_Action["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(SecurityProfile_AnalyzeRequestBody_Action = exports.SecurityProfile_AnalyzeRequestBody_Action || (exports.SecurityProfile_AnalyzeRequestBody_Action = {}));
function securityProfile_AnalyzeRequestBody_ActionFromJSON(object) {
    switch (object) {
        case 0:
        case 'ACTION_UNSPECIFIED':
            return SecurityProfile_AnalyzeRequestBody_Action.ACTION_UNSPECIFIED;
        case 1:
        case 'IGNORE':
            return SecurityProfile_AnalyzeRequestBody_Action.IGNORE;
        case 2:
        case 'DENY':
            return SecurityProfile_AnalyzeRequestBody_Action.DENY;
        case -1:
        case 'UNRECOGNIZED':
        default:
            return SecurityProfile_AnalyzeRequestBody_Action.UNRECOGNIZED;
    }
}
exports.securityProfile_AnalyzeRequestBody_ActionFromJSON = securityProfile_AnalyzeRequestBody_ActionFromJSON;
function securityProfile_AnalyzeRequestBody_ActionToJSON(object) {
    switch (object) {
        case SecurityProfile_AnalyzeRequestBody_Action.ACTION_UNSPECIFIED:
            return 'ACTION_UNSPECIFIED';
        case SecurityProfile_AnalyzeRequestBody_Action.IGNORE:
            return 'IGNORE';
        case SecurityProfile_AnalyzeRequestBody_Action.DENY:
            return 'DENY';
        default:
            return 'UNKNOWN';
    }
}
exports.securityProfile_AnalyzeRequestBody_ActionToJSON = securityProfile_AnalyzeRequestBody_ActionToJSON;
/** Type of action to perform if this rule matched. */
var SecurityRule_RuleCondition_Action;
(function (SecurityRule_RuleCondition_Action) {
    SecurityRule_RuleCondition_Action[SecurityRule_RuleCondition_Action["ACTION_UNSPECIFIED"] = 0] = "ACTION_UNSPECIFIED";
    /** ALLOW - Pass request to service. */
    SecurityRule_RuleCondition_Action[SecurityRule_RuleCondition_Action["ALLOW"] = 1] = "ALLOW";
    /** DENY - Deny request. */
    SecurityRule_RuleCondition_Action[SecurityRule_RuleCondition_Action["DENY"] = 2] = "DENY";
    SecurityRule_RuleCondition_Action[SecurityRule_RuleCondition_Action["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(SecurityRule_RuleCondition_Action = exports.SecurityRule_RuleCondition_Action || (exports.SecurityRule_RuleCondition_Action = {}));
function securityRule_RuleCondition_ActionFromJSON(object) {
    switch (object) {
        case 0:
        case 'ACTION_UNSPECIFIED':
            return SecurityRule_RuleCondition_Action.ACTION_UNSPECIFIED;
        case 1:
        case 'ALLOW':
            return SecurityRule_RuleCondition_Action.ALLOW;
        case 2:
        case 'DENY':
            return SecurityRule_RuleCondition_Action.DENY;
        case -1:
        case 'UNRECOGNIZED':
        default:
            return SecurityRule_RuleCondition_Action.UNRECOGNIZED;
    }
}
exports.securityRule_RuleCondition_ActionFromJSON = securityRule_RuleCondition_ActionFromJSON;
function securityRule_RuleCondition_ActionToJSON(object) {
    switch (object) {
        case SecurityRule_RuleCondition_Action.ACTION_UNSPECIFIED:
            return 'ACTION_UNSPECIFIED';
        case SecurityRule_RuleCondition_Action.ALLOW:
            return 'ALLOW';
        case SecurityRule_RuleCondition_Action.DENY:
            return 'DENY';
        default:
            return 'UNKNOWN';
    }
}
exports.securityRule_RuleCondition_ActionToJSON = securityRule_RuleCondition_ActionToJSON;
/** Mode of protection. */
var SecurityRule_SmartProtection_Mode;
(function (SecurityRule_SmartProtection_Mode) {
    SecurityRule_SmartProtection_Mode[SecurityRule_SmartProtection_Mode["MODE_UNSPECIFIED"] = 0] = "MODE_UNSPECIFIED";
    /**
     * FULL - Full protection means that the traffic will be checked based on ML models and behavioral analysis,
     * with suspicious requests being sent to SmartCaptcha.
     */
    SecurityRule_SmartProtection_Mode[SecurityRule_SmartProtection_Mode["FULL"] = 1] = "FULL";
    /**
     * API - API protection means checking the traffic based on ML models and behavioral analysis without sending suspicious
     * requests to SmartCaptcha. The suspicious requests will be blocked.
     */
    SecurityRule_SmartProtection_Mode[SecurityRule_SmartProtection_Mode["API"] = 2] = "API";
    SecurityRule_SmartProtection_Mode[SecurityRule_SmartProtection_Mode["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(SecurityRule_SmartProtection_Mode = exports.SecurityRule_SmartProtection_Mode || (exports.SecurityRule_SmartProtection_Mode = {}));
function securityRule_SmartProtection_ModeFromJSON(object) {
    switch (object) {
        case 0:
        case 'MODE_UNSPECIFIED':
            return SecurityRule_SmartProtection_Mode.MODE_UNSPECIFIED;
        case 1:
        case 'FULL':
            return SecurityRule_SmartProtection_Mode.FULL;
        case 2:
        case 'API':
            return SecurityRule_SmartProtection_Mode.API;
        case -1:
        case 'UNRECOGNIZED':
        default:
            return SecurityRule_SmartProtection_Mode.UNRECOGNIZED;
    }
}
exports.securityRule_SmartProtection_ModeFromJSON = securityRule_SmartProtection_ModeFromJSON;
function securityRule_SmartProtection_ModeToJSON(object) {
    switch (object) {
        case SecurityRule_SmartProtection_Mode.MODE_UNSPECIFIED:
            return 'MODE_UNSPECIFIED';
        case SecurityRule_SmartProtection_Mode.FULL:
            return 'FULL';
        case SecurityRule_SmartProtection_Mode.API:
            return 'API';
        default:
            return 'UNKNOWN';
    }
}
exports.securityRule_SmartProtection_ModeToJSON = securityRule_SmartProtection_ModeToJSON;
/** Mode of protection. */
var SecurityRule_Waf_Mode;
(function (SecurityRule_Waf_Mode) {
    SecurityRule_Waf_Mode[SecurityRule_Waf_Mode["MODE_UNSPECIFIED"] = 0] = "MODE_UNSPECIFIED";
    /**
     * FULL - Full protection means that the traffic will be checked based on ML models and behavioral analysis,
     * with suspicious requests being sent to SmartCaptcha.
     */
    SecurityRule_Waf_Mode[SecurityRule_Waf_Mode["FULL"] = 1] = "FULL";
    /**
     * API - API protection means checking the traffic based on ML models and behavioral analysis without sending suspicious
     * requests to SmartCaptcha. The suspicious requests will be blocked.
     */
    SecurityRule_Waf_Mode[SecurityRule_Waf_Mode["API"] = 2] = "API";
    SecurityRule_Waf_Mode[SecurityRule_Waf_Mode["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(SecurityRule_Waf_Mode = exports.SecurityRule_Waf_Mode || (exports.SecurityRule_Waf_Mode = {}));
function securityRule_Waf_ModeFromJSON(object) {
    switch (object) {
        case 0:
        case 'MODE_UNSPECIFIED':
            return SecurityRule_Waf_Mode.MODE_UNSPECIFIED;
        case 1:
        case 'FULL':
            return SecurityRule_Waf_Mode.FULL;
        case 2:
        case 'API':
            return SecurityRule_Waf_Mode.API;
        case -1:
        case 'UNRECOGNIZED':
        default:
            return SecurityRule_Waf_Mode.UNRECOGNIZED;
    }
}
exports.securityRule_Waf_ModeFromJSON = securityRule_Waf_ModeFromJSON;
function securityRule_Waf_ModeToJSON(object) {
    switch (object) {
        case SecurityRule_Waf_Mode.MODE_UNSPECIFIED:
            return 'MODE_UNSPECIFIED';
        case SecurityRule_Waf_Mode.FULL:
            return 'FULL';
        case SecurityRule_Waf_Mode.API:
            return 'API';
        default:
            return 'UNKNOWN';
    }
}
exports.securityRule_Waf_ModeToJSON = securityRule_Waf_ModeToJSON;
const baseSecurityProfile = {
    id: '',
    folderId: '',
    name: '',
    description: '',
    defaultAction: 0,
    cloudId: '',
    captchaId: '',
    advancedRateLimiterProfileId: '',
};
exports.SecurityProfile = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.id !== '') {
            writer.uint32(10).string(message.id);
        }
        if (message.folderId !== '') {
            writer.uint32(18).string(message.folderId);
        }
        Object.entries(message.labels).forEach(([key, value]) => {
            exports.SecurityProfile_LabelsEntry.encode({ key: key, value }, writer.uint32(26).fork()).ldelim();
        });
        if (message.name !== '') {
            writer.uint32(34).string(message.name);
        }
        if (message.description !== '') {
            writer.uint32(42).string(message.description);
        }
        if (message.defaultAction !== 0) {
            writer.uint32(48).int32(message.defaultAction);
        }
        for (const v of message.securityRules) {
            exports.SecurityRule.encode(v, writer.uint32(58).fork()).ldelim();
        }
        if (message.createdAt !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.createdAt), writer.uint32(66).fork()).ldelim();
        }
        if (message.cloudId !== '') {
            writer.uint32(82).string(message.cloudId);
        }
        if (message.captchaId !== '') {
            writer.uint32(90).string(message.captchaId);
        }
        if (message.advancedRateLimiterProfileId !== '') {
            writer.uint32(98).string(message.advancedRateLimiterProfileId);
        }
        if (message.analyzeRequestBody !== undefined) {
            exports.SecurityProfile_AnalyzeRequestBody.encode(message.analyzeRequestBody, writer.uint32(106).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({}, baseSecurityProfile);
        message.labels = {};
        message.securityRules = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.id = reader.string();
                    break;
                case 2:
                    message.folderId = reader.string();
                    break;
                case 3:
                    const entry3 = exports.SecurityProfile_LabelsEntry.decode(reader, reader.uint32());
                    if (entry3.value !== undefined) {
                        message.labels[entry3.key] = entry3.value;
                    }
                    break;
                case 4:
                    message.name = reader.string();
                    break;
                case 5:
                    message.description = reader.string();
                    break;
                case 6:
                    message.defaultAction = reader.int32();
                    break;
                case 7:
                    message.securityRules.push(exports.SecurityRule.decode(reader, reader.uint32()));
                    break;
                case 8:
                    message.createdAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    break;
                case 10:
                    message.cloudId = reader.string();
                    break;
                case 11:
                    message.captchaId = reader.string();
                    break;
                case 12:
                    message.advancedRateLimiterProfileId = reader.string();
                    break;
                case 13:
                    message.analyzeRequestBody = exports.SecurityProfile_AnalyzeRequestBody.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a, _b;
        const message = Object.assign({}, baseSecurityProfile);
        message.id = object.id !== undefined && object.id !== null ? String(object.id) : '';
        message.folderId =
            object.folderId !== undefined && object.folderId !== null
                ? String(object.folderId)
                : '';
        message.labels = Object.entries((_a = object.labels) !== null && _a !== void 0 ? _a : {}).reduce((acc, [key, value]) => {
            acc[key] = String(value);
            return acc;
        }, {});
        message.name = object.name !== undefined && object.name !== null ? String(object.name) : '';
        message.description =
            object.description !== undefined && object.description !== null
                ? String(object.description)
                : '';
        message.defaultAction =
            object.defaultAction !== undefined && object.defaultAction !== null
                ? securityProfile_DefaultActionFromJSON(object.defaultAction)
                : 0;
        message.securityRules = ((_b = object.securityRules) !== null && _b !== void 0 ? _b : []).map((e) => exports.SecurityRule.fromJSON(e));
        message.createdAt =
            object.createdAt !== undefined && object.createdAt !== null
                ? fromJsonTimestamp(object.createdAt)
                : undefined;
        message.cloudId =
            object.cloudId !== undefined && object.cloudId !== null ? String(object.cloudId) : '';
        message.captchaId =
            object.captchaId !== undefined && object.captchaId !== null
                ? String(object.captchaId)
                : '';
        message.advancedRateLimiterProfileId =
            object.advancedRateLimiterProfileId !== undefined &&
                object.advancedRateLimiterProfileId !== null
                ? String(object.advancedRateLimiterProfileId)
                : '';
        message.analyzeRequestBody =
            object.analyzeRequestBody !== undefined && object.analyzeRequestBody !== null
                ? exports.SecurityProfile_AnalyzeRequestBody.fromJSON(object.analyzeRequestBody)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.id !== undefined && (obj.id = message.id);
        message.folderId !== undefined && (obj.folderId = message.folderId);
        obj.labels = {};
        if (message.labels) {
            Object.entries(message.labels).forEach(([k, v]) => {
                obj.labels[k] = v;
            });
        }
        message.name !== undefined && (obj.name = message.name);
        message.description !== undefined && (obj.description = message.description);
        message.defaultAction !== undefined &&
            (obj.defaultAction = securityProfile_DefaultActionToJSON(message.defaultAction));
        if (message.securityRules) {
            obj.securityRules = message.securityRules.map((e) => e ? exports.SecurityRule.toJSON(e) : undefined);
        }
        else {
            obj.securityRules = [];
        }
        message.createdAt !== undefined && (obj.createdAt = message.createdAt.toISOString());
        message.cloudId !== undefined && (obj.cloudId = message.cloudId);
        message.captchaId !== undefined && (obj.captchaId = message.captchaId);
        message.advancedRateLimiterProfileId !== undefined &&
            (obj.advancedRateLimiterProfileId = message.advancedRateLimiterProfileId);
        message.analyzeRequestBody !== undefined &&
            (obj.analyzeRequestBody = message.analyzeRequestBody
                ? exports.SecurityProfile_AnalyzeRequestBody.toJSON(message.analyzeRequestBody)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
        const message = Object.assign({}, baseSecurityProfile);
        message.id = (_a = object.id) !== null && _a !== void 0 ? _a : '';
        message.folderId = (_b = object.folderId) !== null && _b !== void 0 ? _b : '';
        message.labels = Object.entries((_c = object.labels) !== null && _c !== void 0 ? _c : {}).reduce((acc, [key, value]) => {
            if (value !== undefined) {
                acc[key] = String(value);
            }
            return acc;
        }, {});
        message.name = (_d = object.name) !== null && _d !== void 0 ? _d : '';
        message.description = (_e = object.description) !== null && _e !== void 0 ? _e : '';
        message.defaultAction = (_f = object.defaultAction) !== null && _f !== void 0 ? _f : 0;
        message.securityRules = ((_g = object.securityRules) === null || _g === void 0 ? void 0 : _g.map((e) => exports.SecurityRule.fromPartial(e))) || [];
        message.createdAt = (_h = object.createdAt) !== null && _h !== void 0 ? _h : undefined;
        message.cloudId = (_j = object.cloudId) !== null && _j !== void 0 ? _j : '';
        message.captchaId = (_k = object.captchaId) !== null && _k !== void 0 ? _k : '';
        message.advancedRateLimiterProfileId = (_l = object.advancedRateLimiterProfileId) !== null && _l !== void 0 ? _l : '';
        message.analyzeRequestBody =
            object.analyzeRequestBody !== undefined && object.analyzeRequestBody !== null
                ? exports.SecurityProfile_AnalyzeRequestBody.fromPartial(object.analyzeRequestBody)
                : undefined;
        return message;
    },
};
const baseSecurityProfile_AnalyzeRequestBody = { sizeLimit: 0, sizeLimitAction: 0 };
exports.SecurityProfile_AnalyzeRequestBody = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.sizeLimit !== 0) {
            writer.uint32(8).int64(message.sizeLimit);
        }
        if (message.sizeLimitAction !== 0) {
            writer.uint32(16).int32(message.sizeLimitAction);
        }
        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({}, baseSecurityProfile_AnalyzeRequestBody);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.sizeLimit = longToNumber(reader.int64());
                    break;
                case 2:
                    message.sizeLimitAction = reader.int32();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseSecurityProfile_AnalyzeRequestBody);
        message.sizeLimit =
            object.sizeLimit !== undefined && object.sizeLimit !== null
                ? Number(object.sizeLimit)
                : 0;
        message.sizeLimitAction =
            object.sizeLimitAction !== undefined && object.sizeLimitAction !== null
                ? securityProfile_AnalyzeRequestBody_ActionFromJSON(object.sizeLimitAction)
                : 0;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.sizeLimit !== undefined && (obj.sizeLimit = Math.round(message.sizeLimit));
        message.sizeLimitAction !== undefined &&
            (obj.sizeLimitAction = securityProfile_AnalyzeRequestBody_ActionToJSON(message.sizeLimitAction));
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseSecurityProfile_AnalyzeRequestBody);
        message.sizeLimit = (_a = object.sizeLimit) !== null && _a !== void 0 ? _a : 0;
        message.sizeLimitAction = (_b = object.sizeLimitAction) !== null && _b !== void 0 ? _b : 0;
        return message;
    },
};
const baseSecurityProfile_LabelsEntry = { key: '', value: '' };
exports.SecurityProfile_LabelsEntry = {
    encode(message, writer = minimal_1.default.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 minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseSecurityProfile_LabelsEntry);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.key = reader.string();
                    break;
                case 2:
                    message.value = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseSecurityProfile_LabelsEntry);
        message.key = object.key !== undefined && object.key !== null ? String(object.key) : '';
        message.value =
            object.value !== undefined && object.value !== null ? String(object.value) : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.key !== undefined && (obj.key = message.key);
        message.value !== undefined && (obj.value = message.value);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseSecurityProfile_LabelsEntry);
        message.key = (_a = object.key) !== null && _a !== void 0 ? _a : '';
        message.value = (_b = object.value) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const baseSecurityRule = { name: '', priority: 0, dryRun: false, description: '' };
exports.SecurityRule = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.name !== '') {
            writer.uint32(10).string(message.name);
        }
        if (message.priority !== 0) {
            writer.uint32(16).int64(message.priority);
        }
        if (message.dryRun === true) {
            writer.uint32(24).bool(message.dryRun);
        }
        if (message.ruleCondition !== undefined) {
            exports.SecurityRule_RuleCondition.encode(message.ruleCondition, writer.uint32(34).fork()).ldelim();
        }
        if (message.smartProtection !== undefined) {
            exports.SecurityRule_SmartProtection.encode(message.smartProtection, writer.uint32(42).fork()).ldelim();
        }
        if (message.waf !== undefined) {
            exports.SecurityRule_Waf.encode(message.waf, writer.uint32(50).fork()).ldelim();
        }
        if (message.description !== '') {
            writer.uint32(58).string(message.description);
        }
        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({}, baseSecurityRule);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.name = reader.string();
                    break;
                case 2:
                    message.priority = longToNumber(reader.int64());
                    break;
                case 3:
                    message.dryRun = reader.bool();
                    break;
                case 4:
                    message.ruleCondition = exports.SecurityRule_RuleCondition.decode(reader, reader.uint32());
                    break;
                case 5:
                    message.smartProtection = exports.SecurityRule_SmartProtection.decode(reader, reader.uint32());
                    break;
                case 6:
                    message.waf = exports.SecurityRule_Waf.decode(reader, reader.uint32());
                    break;
                case 7:
                    message.description = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseSecurityRule);
        message.name = object.name !== undefined && object.name !== null ? String(object.name) : '';
        message.priority =
            object.priority !== undefined && object.priority !== null ? Number(object.priority) : 0;
        message.dryRun =
            object.dryRun !== undefined && object.dryRun !== null ? Boolean(object.dryRun) : false;
        message.ruleCondition =
            object.ruleCondition !== undefined && object.ruleCondition !== null
                ? exports.SecurityRule_RuleCondition.fromJSON(object.ruleCondition)
                : undefined;
        message.smartProtection =
            object.smartProtection !== undefined && object.smartProtection !== null
                ? exports.SecurityRule_SmartProtection.fromJSON(object.smartProtection)
                : undefined;
        message.waf =
            object.waf !== undefined && object.waf !== null
                ? exports.SecurityRule_Waf.fromJSON(object.waf)
                : undefined;
        message.description =
            object.description !== undefined && object.description !== null
                ? String(object.description)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.name !== undefined && (obj.name = message.name);
        message.priority !== undefined && (obj.priority = Math.round(message.priority));
        message.dryRun !== undefined && (obj.dryRun = message.dryRun);
        message.ruleCondition !== undefined &&
            (obj.ruleCondition = message.ruleCondition
                ? exports.SecurityRule_RuleCondition.toJSON(message.ruleCondition)
                : undefined);
        message.smartProtection !== undefined &&
            (obj.smartProtection = message.smartProtection
                ? exports.SecurityRule_SmartProtection.toJSON(message.smartProtection)
                : undefined);
        message.waf !== undefined &&
            (obj.waf = message.waf ? exports.SecurityRule_Waf.toJSON(message.waf) : undefined);
        message.description !== undefined && (obj.description = message.description);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d;
        const message = Object.assign({}, baseSecurityRule);
        message.name = (_a = object.name) !== null && _a !== void 0 ? _a : '';
        message.priority = (_b = object.priority) !== null && _b !== void 0 ? _b : 0;
        message.dryRun = (_c = object.dryRun) !== null && _c !== void 0 ? _c : false;
        message.ruleCondition =
            object.ruleCondition !== undefined && object.ruleCondition !== null
                ? exports.SecurityRule_RuleCondition.fromPartial(object.ruleCondition)
                : undefined;
        message.smartProtection =
            object.smartProtection !== undefined && object.smartProtection !== null
                ? exports.SecurityRule_SmartProtection.fromPartial(object.smartProtection)
                : undefined;
        message.waf =
            object.waf !== undefined && object.waf !== null
                ? exports.SecurityRule_Waf.fromPartial(object.waf)
                : undefined;
        message.description = (_d = object.description) !== null && _d !== void 0 ? _d : '';
        return message;
    },
};
const baseSecurityRule_RuleCondition = { action: 0 };
exports.SecurityRule_RuleCondition = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.action !== 0) {
            writer.uint32(8).int32(message.action);
        }
        if (message.condition !== undefined) {
            exports.Condition.encode(message.condition, 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({}, baseSecurityRule_RuleCondition);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.action = reader.int32();
                    break;
                case 2:
                    message.condition = exports.Condition.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseSecurityRule_RuleCondition);
        message.action =
            object.action !== undefined && object.action !== null
                ? securityRule_RuleCondition_ActionFromJSON(object.action)
                : 0;
        message.condition =
            object.condition !== undefined && object.condition !== null
                ? exports.Condition.fromJSON(object.condition)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.action !== undefined &&
            (obj.action = securityRule_RuleCondition_ActionToJSON(message.action));
        message.condition !== undefined &&
            (obj.condition = message.condition ? exports.Condition.toJSON(message.condition) : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseSecurityRule_RuleCondition);
        message.action = (_a = object.action) !== null && _a !== void 0 ? _a : 0;
        message.condition =
            object.condition !== undefined && object.condition !== null
                ? exports.Condition.fromPartial(object.condition)
                : undefined;
        return message;
    },
};
const baseSecurityRule_SmartProtection = { mode: 0 };
exports.SecurityRule_SmartProtection = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.mode !== 0) {
            writer.uint32(8).int32(message.mode);
        }
        if (message.condition !== undefined) {
            exports.Condition.encode(message.condition, 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({}, baseSecurityRule_SmartProtection);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.mode = reader.int32();
                    break;
                case 2:
                    message.condition = exports.Condition.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseSecurityRule_SmartProtection);
        message.mode =
            object.mode !== undefined && object.mode !== null
                ? securityRule_SmartProtection_ModeFromJSON(object.mode)
                : 0;
        message.condition =
            object.condition !== undefined && object.condition !== null
                ? exports.Condition.fromJSON(object.condition)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.mode !== undefined &&
            (obj.mode = securityRule_SmartProtection_ModeToJSON(message.mode));
        message.condition !== undefined &&
            (obj.condition = message.condition ? exports.Condition.toJSON(message.condition) : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseSecurityRule_SmartProtection);
        message.mode = (_a = object.mode) !== null && _a !== void 0 ? _a : 0;
        message.condition =
            object.condition !== undefined && object.condition !== null
                ? exports.Condition.fromPartial(object.condition)
                : undefined;
        return message;
    },
};
const baseSecurityRule_Waf = { mode: 0, wafProfileId: '' };
exports.SecurityRule_Waf = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.mode !== 0) {
            writer.uint32(8).int32(message.mode);
        }
        if (message.condition !== undefined) {
            exports.Condition.encode(message.condition, writer.uint32(18).fork()).ldelim();
        }
        if (message.wafProfileId !== '') {
            writer.uint32(26).string(message.wafProfileId);
        }
        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({}, baseSecurityRule_Waf);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.mode = reader.int32();
                    break;
                case 2:
                    message.condition = exports.Condition.decode(reader, reader.uint32());
                    break;
                case 3:
                    message.wafProfileId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseSecurityRule_Waf);
        message.mode =
            object.mode !== undefined && object.mode !== null
                ? securityRule_Waf_ModeFromJSON(object.mode)
                : 0;
        message.condition =
            object.condition !== undefined && object.condition !== null
                ? exports.Condition.fromJSON(object.condition)
                : undefined;
        message.wafProfileId =
            object.wafProfileId !== undefined && object.wafProfileId !== null
                ? String(object.wafProfileId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.mode !== undefined && (obj.mode = securityRule_Waf_ModeToJSON(message.mode));
        message.condition !== undefined &&
            (obj.condition = message.condition ? exports.Condition.toJSON(message.condition) : undefined);
        message.wafProfileId !== undefined && (obj.wafProfileId = message.wafProfileId);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseSecurityRule_Waf);
        message.mode = (_a = object.mode) !== null && _a !== void 0 ? _a : 0;
        message.condition =
            object.condition !== undefined && object.condition !== null
                ? exports.Condition.fromPartial(object.condition)
                : undefined;
        message.wafProfileId = (_b = object.wafProfileId) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const baseCondition = {};
exports.Condition = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.authority !== undefined) {
            exports.Condition_AuthorityMatcher.encode(message.authority, writer.uint32(10).fork()).ldelim();
        }
        if (message.httpMethod !== undefined) {
            exports.Condition_HttpMethodMatcher.encode(message.httpMethod, writer.uint32(18).fork()).ldelim();
        }
        if (message.requestUri !== undefined) {
            exports.Condition_RequestUriMatcher.encode(message.requestUri, writer.uint32(26).fork()).ldelim();
        }
        for (const v of message.headers) {
            exports.Condition_HeaderMatcher.encode(v, writer.uint32(34).fork()).ldelim();
        }
        if (message.sourceIp !== undefined) {
            exports.Condition_IpMatcher.encode(message.sourceIp, writer.uint32(42).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({}, baseCondition);
        message.headers = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.authority = exports.Condition_AuthorityMatcher.decode(reader, reader.uint32());
                    break;
                case 2:
                    message.httpMethod = exports.Condition_HttpMethodMatcher.decode(reader, reader.uint32());
                    break;
                case 3:
                    message.requestUri = exports.Condition_RequestUriMatcher.decode(reader, reader.uint32());
                    break;
                case 4:
                    message.headers.push(exports.Condition_HeaderMatcher.decode(reader, reader.uint32()));
                    break;
                case 5:
                    message.sourceIp = exports.Condition_IpMatcher.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseCondition);
        message.authority =
            object.authority !== undefined && object.authority !== null
                ? exports.Condition_AuthorityMatcher.fromJSON(object.authority)
                : undefined;
        message.httpMethod =
            object.httpMethod !== undefined && object.httpMethod !== null
                ? exports.Condition_HttpMethodMatcher.fromJSON(object.httpMethod)
                : undefined;
        message.requestUri =
            object.requestUri !== undefined && object.requestUri !== null
                ? exports.Condition_RequestUriMatcher.fromJSON(object.requestUri)
                : undefined;
        message.headers = ((_a = object.headers) !== null && _a !== void 0 ? _a : []).map((e) => exports.Condition_HeaderMatcher.fromJSON(e));
        message.sourceIp =
            object.sourceIp !== undefined && object.sourceIp !== null
                ? exports.Condition_IpMatcher.fromJSON(object.sourceIp)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.authority !== undefined &&
            (obj.authority = message.authority
                ? exports.Condition_AuthorityMatcher.toJSON(message.authority)
                : undefined);
        message.httpMethod !== undefined &&
            (obj.httpMethod = message.httpMethod
                ? exports.Condition_HttpMethodMatcher.toJSON(message.httpMethod)
                : undefined);
        message.requestUri !== undefined &&
            (obj.requestUri = message.requestUri
                ? exports.Condition_RequestUriMatcher.toJSON(message.requestUri)
                : undefined);
        if (message.headers) {
            obj.headers = message.headers.map((e) => e ? exports.Condition_HeaderMatcher.toJSON(e) : undefined);
        }
        else {
            obj.headers = [];
        }
        message.sourceIp !== undefined &&
            (obj.sourceIp = message.sourceIp
                ? exports.Condition_IpMatcher.toJSON(message.sourceIp)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseCondition);
        message.authority =
            object.authority !== undefined && object.authority !== null
                ? exports.Condition_AuthorityMatcher.fromPartial(object.authority)
                : undefined;
        message.httpMethod =
            object.httpMethod !== undefined && object.httpMethod !== null
                ? exports.Condition_HttpMethodMatcher.fromPartial(object.httpMethod)
                : undefined;
        message.requestUri =
            object.requestUri !== undefined && object.requestUri !== null
                ? exports.Condition_RequestUriMatcher.fromPartial(object.requestUri)
                : undefined;
        message.headers = ((_a = object.headers) === null || _a === void 0 ? void 0 : _a.map((e) => exports.Condition_HeaderMatcher.fromPartial(e))) || [];
        message.sourceIp =
            object.sourceIp !== undefined && object.sourceIp !== null
                ? exports.Condition_IpMatcher.fromPartial(object.sourceIp)
                : undefined;
        return message;
    },
};
const baseCondition_StringMatcher = {};
exports.Condition_StringMatcher = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.exactMatch !== undefined) {
            writer.uint32(10).string(message.exactMatch);
        }
        if (message.exactNotMatch !== undefined) {
            writer.uint32(18).string(message.exactNotMatch);
        }
        if (message.prefixMatch !== undefined) {
            writer.uint32(26).string(message.prefixMatch);
        }
        if (message.prefixNotMatch !== undefined) {
            writer.uint32(34).string(message.prefixNotMatch);
        }
        if (message.pireRegexMatch !== undefined) {
            writer.uint32(42).string(message.pireRegexMatch);
        }
        if (message.pireRegexNotMatch !== undefined) {
            writer.uint32(50).string(message.pireRegexNotMatch);
        }
        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({}, baseCondition_StringMatcher);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.exactMatch = reader.string();
                    break;
                case 2:
                    message.exactNotMatch = reader.string();
                    break;
                case 3:
                    message.prefixMatch = reader.string();
                    break;
                case 4:
                    message.prefixNotMatch = reader.string();
                    break;
                case 5:
                    message.pireRegexMatch = reader.string();
                    break;
                case 6:
                    message.pireRegexNotMatch = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseCondition_StringMatcher);
        message.exactMatch =
            object.exactMatch !== undefined && object.exactMatch !== null
                ? String(object.exactMatch)
                : undefined;
        message.exactNotMatch =
            object.exactNotMatch !== undefined && object.exactNotMatch !== null
                ? String(object.exactNotMatch)
                : undefined;
        message.prefixMatch =
            object.prefixMatch !== undefined && object.prefixMatch !== null
                ? String(object.prefixMatch)
                : undefined;
        message.prefixNotMatch =
            object.prefixNotMatch !== undefined && object.prefixNotMatch !== null
                ? String(object.prefixNotMatch)
                : undefined;
        message.pireRegexMatch =
            object.pireRegexMatch !== undefined && object.pireRegexMatch !== null
                ? String(object.pireRegexMatch)
                : undefined;
        message.pireRegexNotMatch =
            object.pireRegexNotMatch !== undefined && object.pireRegexNotMatch !== null
                ? String(object.pireRegexNotMatch)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.exactMatch !== undefined && (obj.exactMatch = message.exactMatch);
        message.exactNotMatch !== undefined && (obj.exactNotMatch = message.exactNotMatch);
        message.prefixMatch !== undefined && (obj.prefixMatch = message.prefixMatch);
        message.prefixNotMatch !== undefined && (obj.prefixNotMatch = message.prefixNotMatch);
        message.pireRegexMatch !== undefined && (obj.pireRegexMatch = message.pireRegexMatch);
        message.pireRegexNotMatch !== undefined &&
            (obj.pireRegexNotMatch = message.pireRegexNotMatch);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d, _e, _f;
        const message = Object.assign({}, baseCondition_StringMatcher);
        message.exactMatch = (_a = object.exactMatch) !== null && _a !== void 0 ? _a : undefined;
        message.exactNotMatch = (_b = object.exactNotMatch) !== null && _b !== void 0 ? _b : undefined;
        message.prefixMatch = (_c = object.prefixMatch) !== null && _c !== void 0 ? _c : undefined;
        message.prefixNotMatch = (_d = object.prefixNotMatch) !== null && _d !== void 0 ? _d : undefined;
        message.pireRegexMatch = (_e = object.pireRegexMatch) !== null && _e !== void 0 ? _e : undefined;
        message.pireRegexNotMatch = (_f = object.pireRegexNotMatch) !== null && _f !== void 0 ? _f : undefined;
        return message;
    },
};
const baseCondition_HttpMethodMatcher = {};
exports.Condition_HttpMethodMatcher = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        for (const v of message.httpMethods) {
            exports.Condition_StringMatcher.encode(v, writer.uint32(10).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({}, baseCondition_HttpMethodMatcher);
        message.httpMethods = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.httpMethods.push(exports.Condition_StringMatcher.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseCondition_HttpMethodMatcher);
        message.httpMethods = ((_a = object.httpMethods) !== null && _a !== void 0 ? _a : []).map((e) => exports.Condition_StringMatcher.fromJSON(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        if (message.httpMethods) {
            obj.httpMethods = message.httpMethods.map((e) => e ? exports.Condition_StringMatcher.toJSON(e) : undefined);
        }
        else {
            obj.httpMethods = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseCondition_HttpMethodMatcher);
        message.httpMethods =
            ((_a = object.httpMethods) === null || _a === void 0 ? void 0 : _a.map((e) => exports.Condition_StringMatcher.fromPartial(e))) || [];
        return message;
    },
};
const baseCondition_AuthorityMatcher = {};
exports.Condition_AuthorityMatcher = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        for (const v of message.authorities) {
            exports.Condition_StringMatcher.encode(v, writer.uint32(10).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({}, baseCondition_AuthorityMatcher);
        message.authorities = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.authorities.push(exports.Condition_StringMatcher.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseCondition_AuthorityMatcher);
        message.authorities = ((_a = object.authorities) !== null && _a !== void 0 ? _a : []).map((e) => exports.Condition_StringMatcher.fromJSON(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        if (message.authorities) {
            obj.authorities = message.authorities.map((e) => e ? exports.Condition_StringMatcher.toJSON(e) : undefined);
        }
        else {
            obj.authorities = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseCondition_AuthorityMatcher);
        message.authorities =
            ((_a = object.authorities) === null || _a === void 0 ? void 0 : _a.map((e) => exports.Condition_StringMatcher.fromPartial(e))) || [];
        return message;
    },
};
const baseCondition_RequestUriMatcher = {};
exports.Condition_RequestUriMatcher = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.path !== undefined) {
            exports.Condition_StringMatcher.encode(message.path, writer.uint32(10).fork()).ldelim();
        }
        for (const v of message.queries) {
            exports.Condition_QueryMatcher.encode(v, 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({}, baseCondition_RequestUriMatcher);
        message.queries = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.path = exports.Condition_StringMatcher.decode(reader, reader.uint32());
                    break;
                case 2:
                    message.queries.push(exports.Condition_QueryMatcher.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseCondition_RequestUriMatcher);
        message.path =
            object.path !== undefined && object.path !== null
                ? exports.Condition_StringMatcher.fromJSON(object.path)
                : undefined;
        message.queries = ((_a = object.queries) !== null && _a !== void 0 ? _a : []).map((e) => exports.Condition_QueryMatcher.fromJSON(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.path !== undefined &&
            (obj.path = message.path ? exports.Condition_StringMatcher.toJSON(message.path) : undefined);
        if (message.queries) {
            obj.queries = message.queries.map((e) => e ? exports.Condition_QueryMatcher.toJSON(e) : undefined);
        }
        else {
            obj.queries = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseCondition_RequestUriMatcher);
        message.path =
            object.path !== undefined && object.path !== null
                ? exports.Condition_StringMatcher.fromPartial(object.path)
                : undefined;
        message.queries = ((_a = object.queries) === null || _a === void 0 ? void 0 : _a.map((e) => exports.Condition_QueryMatcher.fromPartial(e))) || [];
        return message;
    },
};
const baseCondition_QueryMatcher = { key: '' };
exports.Condition_QueryMatcher = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.key !== '') {
            writer.uint32(10).string(message.key);
        }
        if (message.value !== undefined) {
            exports.Condition_StringMatcher.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({}, baseCondition_QueryMatcher);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.key = reader.string();
                    break;
                case 2:
                    message.value = exports.Condition_StringMatcher.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseCondition_QueryMatcher);
        message.key = object.key !== undefined && object.key !== null ? String(object.key) : '';
        message.value =
            object.value !== undefined && object.value !== null
                ? exports.Condition_StringMatcher.fromJSON(object.value)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.key !== undefined && (obj.key = message.key);
        message.value !== undefined &&
            (obj.value = message.value ? exports.Condition_StringMatcher.toJSON(message.value) : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseCondition_QueryMatcher);
        message.key = (_a = object.key) !== null && _a !== void 0 ? _a : '';
        message.value =
            object.value !== undefined && object.value !== null
                ? exports.Condition_StringMatcher.fromPartial(object.value)
                : undefined;
        return message;
    },
};
const baseCondition_HeaderMatcher = { name: '' };
exports.Condition_HeaderMatcher = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.name !== '') {
            writer.uint32(10).string(message.name);
        }
        if (message.value !== undefined) {
            exports.Condition_StringMatcher.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({}, baseCondition_HeaderMatcher);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.name = reader.string();
                    break;
                case 2:
                    message.value = exports.Condition_StringMatcher.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseCondition_HeaderMatcher);
        message.name = object.name !== undefined && object.name !== null ? String(object.name) : '';
        message.value =
            object.value !== undefined && object.value !== null
                ? exports.Condition_StringMatcher.fromJSON(object.value)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.name !== undefined && (obj.name = message.name);
        message.value !== undefined &&
            (obj.value = message.value ? exports.Condition_StringMatcher.toJSON(message.value) : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseCondition_HeaderMatcher);
        message.name = (_a = object.name) !== null && _a !== void 0 ? _a : '';
        message.value =
            object.value !== undefined && object.value !== null
                ? exports.Condition_StringMatcher.fromPartial(object.value)
                : undefined;
        return message;
    },
};
const baseCondition_IpMatcher = {};
exports.Condition_IpMatcher = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.ipRangesMatch !== undefined) {
            exports.Condition_IpRangesMatcher.encode(message.ipRangesMatch, writer.uint32(10).fork()).ldelim();
        }
        if (message.ipRangesNotMatch !== undefined) {
            exports.Condition_IpRangesMatcher.encode(message.ipRangesNotMatch, writer.uint32(18).fork()).ldelim();
        }
        if (message.geoIpMatch !== undefined) {
            exports.Condition_GeoIpMatcher.encode(message.geoIpMatch, writer.uint32(26).fork()).ldelim();
        }
        if (message.geoIpNotMatch !== undefined) {
            exports.Condition_GeoIpMatcher.encode(message.geoIpNotMatch, 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({}, baseCondition_IpMatcher);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.ipRangesMatch = exports.Condition_IpRangesMatcher.decode(reader, reader.uint32());
                    break;
                case 2:
                    message.ipRangesNotMatch = exports.Condition_IpRangesMatcher.decode(reader, reader.uint32());
                    break;
                case 3:
                    message.geoIpMatch = exports.Condition_GeoIpMatcher.decode(reader, reader.uint32());
                    break;
                case 4:
                    message.geoIpNotMatch = exports.Condition_GeoIpMatcher.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseCondition_IpMatcher);
        message.ipRangesMatch =
            object.ipRangesMatch !== undefined && object.ipRangesMatch !== null
                ? exports.Condition_IpRangesMatcher.fromJSON(object.ipRangesMatch)
                : undefined;
        message.ipRangesNotMatch =
            object.ipRangesNotMatch !== undefined && object.ipRangesNotMatch !== null
                ? exports.Condition_IpRangesMatcher.fromJSON(object.ipRangesNotMatch)
                : undefined;
        message.geoIpMatch =
            object.geoIpMatch !== undefined && object.geoIpMatch !== null
                ? exports.Condition_GeoIpMatcher.fromJSON(object.geoIpMatch)
                : undefined;
        message.geoIpNotMatch =
            object.geoIpNotMatch !== undefined && object.geoIpNotMatch !== null
                ? exports.Condition_GeoIpMatcher.fromJSON(object.geoIpNotMatch)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.ipRangesMatch !== undefined &&
            (obj.ipRangesMatch = message.ipRangesMatch
                ? exports.Condition_IpRangesMatcher.toJSON(message.ipRangesMatch)
                : undefined);
        message.ipRangesNotMatch !== undefined &&
            (obj.ipRangesNotMatch = message.ipRangesNotMatch
                ? exports.Condition_IpRangesMatcher.toJSON(message.ipRangesNotMatch)
                : undefined);
        message.geoIpMatch !== undefined &&
            (obj.geoIpMatch = message.geoIpMatch
                ? exports.Condition_GeoIpMatcher.toJSON(message.geoIpMatch)
                : undefined);
        message.geoIpNotMatch !== undefined &&
            (obj.geoIpNotMatch = message.geoIpNotMatch
                ? exports.Condition_GeoIpMatcher.toJSON(message.geoIpNotMatch)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseCondition_IpMatcher);
        message.ipRangesMatch =
            object.ipRangesMatch !== undefined && object.ipRangesMatch !== null
                ? exports.Condition_IpRangesMatcher.fromPartial(object.ipRangesMatch)
                : undefined;
        message.ipRangesNotMatch =
            object.ipRangesNotMatch !== undefined && object.ipRangesNotMatch !== null
                ? exports.Condition_IpRangesMatcher.fromPartial(object.ipRangesNotMatch)
                : undefined;
        message.geoIpMatch =
            object.geoIpMatch !== undefined && object.geoIpMatch !== null
                ? exports.Condition_GeoIpMatcher.fromPartial(object.geoIpMatch)
                : undefined;
        message.geoIpNotMatch =
            object.geoIpNotMatch !== undefined && object.geoIpNotMatch !== null
                ? exports.Condition_GeoIpMatcher.fromPartial(object.geoIpNotMatch)
                : undefined;
        return message;
    },
};
const baseCondition_IpRangesMatcher = { ipRanges: '' };
exports.Condition_IpRangesMatcher = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        for (const v of message.ipRanges) {
            writer.uint32(10).string(v);
        }
        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({}, baseCondition_IpRangesMatcher);
        message.ipRanges = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.ipRanges.push(reader.string());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseCondition_IpRangesMatcher);
        message.ipRanges = ((_a = object.ipRanges) !== null && _a !== void 0 ? _a : []).map((e) => String(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        if (message.ipRanges) {
            obj.ipRanges = message.ipRanges.map((e) => e);
        }
        else {
            obj.ipRanges = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseCondition_IpRangesMatcher);
        message.ipRanges = ((_a = object.ipRanges) === null || _a === void 0 ? void 0 : _a.map((e) => e)) || [];
        return message;
    },
};
const baseCondition_GeoIpMatcher = { locations: '' };
exports.Condition_GeoIpMatcher = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        for (const v of message.locations) {
            writer.uint32(10).string(v);
        }
        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({}, baseCondition_GeoIpMatcher);
        message.locations = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.locations.push(reader.string());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseCondition_GeoIpMatcher);
        message.locations = ((_a = object.locations) !== null && _a !== void 0 ? _a : []).map((e) => String(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        if (message.locations) {
            obj.locations = message.locations.map((e) => e);
        }
        else {
            obj.locations = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseCondition_GeoIpMatcher);
        message.locations = ((_a = object.locations) === null || _a === void 0 ? void 0 : _a.map((e) => e)) || [];
        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 toTimestamp(date) {
    const seconds = date.getTime() / 1000;
    const nanos = (date.getTime() % 1000) * 1000000;
    return { seconds, nanos };
}
function fromTimestamp(t) {
    let millis = t.seconds * 1000;
    millis += t.nanos / 1000000;
    return new Date(millis);
}
function fromJsonTimestamp(o) {
    if (o instanceof Date) {
        return o;
    }
    else if (typeof o === 'string') {
        return new Date(o);
    }
    else {
        return fromTimestamp(timestamp_1.Timestamp.fromJSON(o));
    }
}
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();
}
