"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_UriMatcher = exports.Condition_HostMatcher = exports.Condition_StringMatcher = exports.Condition = exports.SecurityRule = exports.CaptchaSecretKey = exports.OverrideVariant = exports.Captcha = exports.captchaChallengeTypeToJSON = exports.captchaChallengeTypeFromJSON = exports.CaptchaChallengeType = exports.captchaPreCheckTypeToJSON = exports.captchaPreCheckTypeFromJSON = exports.CaptchaPreCheckType = exports.captchaComplexityToJSON = exports.captchaComplexityFromJSON = exports.CaptchaComplexity = 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.smartcaptcha.v1';
/** Captcha's complexity. */
var CaptchaComplexity;
(function (CaptchaComplexity) {
    CaptchaComplexity[CaptchaComplexity["CAPTCHA_COMPLEXITY_UNSPECIFIED"] = 0] = "CAPTCHA_COMPLEXITY_UNSPECIFIED";
    /** EASY - High chance to pass pre-check and easy advanced challenge. */
    CaptchaComplexity[CaptchaComplexity["EASY"] = 1] = "EASY";
    /** MEDIUM - Medium chance to pass pre-check and normal advanced challenge. */
    CaptchaComplexity[CaptchaComplexity["MEDIUM"] = 2] = "MEDIUM";
    /** HARD - Little chance to pass pre-check and hard advanced challenge. */
    CaptchaComplexity[CaptchaComplexity["HARD"] = 3] = "HARD";
    /** FORCE_HARD - Impossible to pass pre-check and hard advanced challenge. */
    CaptchaComplexity[CaptchaComplexity["FORCE_HARD"] = 4] = "FORCE_HARD";
    CaptchaComplexity[CaptchaComplexity["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(CaptchaComplexity = exports.CaptchaComplexity || (exports.CaptchaComplexity = {}));
function captchaComplexityFromJSON(object) {
    switch (object) {
        case 0:
        case 'CAPTCHA_COMPLEXITY_UNSPECIFIED':
            return CaptchaComplexity.CAPTCHA_COMPLEXITY_UNSPECIFIED;
        case 1:
        case 'EASY':
            return CaptchaComplexity.EASY;
        case 2:
        case 'MEDIUM':
            return CaptchaComplexity.MEDIUM;
        case 3:
        case 'HARD':
            return CaptchaComplexity.HARD;
        case 4:
        case 'FORCE_HARD':
            return CaptchaComplexity.FORCE_HARD;
        case -1:
        case 'UNRECOGNIZED':
        default:
            return CaptchaComplexity.UNRECOGNIZED;
    }
}
exports.captchaComplexityFromJSON = captchaComplexityFromJSON;
function captchaComplexityToJSON(object) {
    switch (object) {
        case CaptchaComplexity.CAPTCHA_COMPLEXITY_UNSPECIFIED:
            return 'CAPTCHA_COMPLEXITY_UNSPECIFIED';
        case CaptchaComplexity.EASY:
            return 'EASY';
        case CaptchaComplexity.MEDIUM:
            return 'MEDIUM';
        case CaptchaComplexity.HARD:
            return 'HARD';
        case CaptchaComplexity.FORCE_HARD:
            return 'FORCE_HARD';
        default:
            return 'UNKNOWN';
    }
}
exports.captchaComplexityToJSON = captchaComplexityToJSON;
/** Captcha's basic check type, see [Task types / Main task](/docs/smartcaptcha/concepts/tasks#main-task). */
var CaptchaPreCheckType;
(function (CaptchaPreCheckType) {
    CaptchaPreCheckType[CaptchaPreCheckType["CAPTCHA_PRE_CHECK_TYPE_UNSPECIFIED"] = 0] = "CAPTCHA_PRE_CHECK_TYPE_UNSPECIFIED";
    /** CHECKBOX - User must click the "I am not a robot" button. */
    CaptchaPreCheckType[CaptchaPreCheckType["CHECKBOX"] = 1] = "CHECKBOX";
    /** SLIDER - User must move the slider from left to right. */
    CaptchaPreCheckType[CaptchaPreCheckType["SLIDER"] = 2] = "SLIDER";
    CaptchaPreCheckType[CaptchaPreCheckType["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(CaptchaPreCheckType = exports.CaptchaPreCheckType || (exports.CaptchaPreCheckType = {}));
function captchaPreCheckTypeFromJSON(object) {
    switch (object) {
        case 0:
        case 'CAPTCHA_PRE_CHECK_TYPE_UNSPECIFIED':
            return CaptchaPreCheckType.CAPTCHA_PRE_CHECK_TYPE_UNSPECIFIED;
        case 1:
        case 'CHECKBOX':
            return CaptchaPreCheckType.CHECKBOX;
        case 2:
        case 'SLIDER':
            return CaptchaPreCheckType.SLIDER;
        case -1:
        case 'UNRECOGNIZED':
        default:
            return CaptchaPreCheckType.UNRECOGNIZED;
    }
}
exports.captchaPreCheckTypeFromJSON = captchaPreCheckTypeFromJSON;
function captchaPreCheckTypeToJSON(object) {
    switch (object) {
        case CaptchaPreCheckType.CAPTCHA_PRE_CHECK_TYPE_UNSPECIFIED:
            return 'CAPTCHA_PRE_CHECK_TYPE_UNSPECIFIED';
        case CaptchaPreCheckType.CHECKBOX:
            return 'CHECKBOX';
        case CaptchaPreCheckType.SLIDER:
            return 'SLIDER';
        default:
            return 'UNKNOWN';
    }
}
exports.captchaPreCheckTypeToJSON = captchaPreCheckTypeToJSON;
/** Additional task, see [Task types / Additional task](/docs/smartcaptcha/concepts/tasks#additional-task). */
var CaptchaChallengeType;
(function (CaptchaChallengeType) {
    CaptchaChallengeType[CaptchaChallengeType["CAPTCHA_CHALLENGE_TYPE_UNSPECIFIED"] = 0] = "CAPTCHA_CHALLENGE_TYPE_UNSPECIFIED";
    /** IMAGE_TEXT - Text recognition: The user has to type a distorted text from the picture into a special field. */
    CaptchaChallengeType[CaptchaChallengeType["IMAGE_TEXT"] = 1] = "IMAGE_TEXT";
    /** SILHOUETTES - Silhouettes: The user has to mark several icons from the picture in a particular order. */
    CaptchaChallengeType[CaptchaChallengeType["SILHOUETTES"] = 2] = "SILHOUETTES";
    /** KALEIDOSCOPE - Kaleidoscope: The user has to build a picture from individual parts by shuffling them using a slider. */
    CaptchaChallengeType[CaptchaChallengeType["KALEIDOSCOPE"] = 3] = "KALEIDOSCOPE";
    CaptchaChallengeType[CaptchaChallengeType["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(CaptchaChallengeType = exports.CaptchaChallengeType || (exports.CaptchaChallengeType = {}));
function captchaChallengeTypeFromJSON(object) {
    switch (object) {
        case 0:
        case 'CAPTCHA_CHALLENGE_TYPE_UNSPECIFIED':
            return CaptchaChallengeType.CAPTCHA_CHALLENGE_TYPE_UNSPECIFIED;
        case 1:
        case 'IMAGE_TEXT':
            return CaptchaChallengeType.IMAGE_TEXT;
        case 2:
        case 'SILHOUETTES':
            return CaptchaChallengeType.SILHOUETTES;
        case 3:
        case 'KALEIDOSCOPE':
            return CaptchaChallengeType.KALEIDOSCOPE;
        case -1:
        case 'UNRECOGNIZED':
        default:
            return CaptchaChallengeType.UNRECOGNIZED;
    }
}
exports.captchaChallengeTypeFromJSON = captchaChallengeTypeFromJSON;
function captchaChallengeTypeToJSON(object) {
    switch (object) {
        case CaptchaChallengeType.CAPTCHA_CHALLENGE_TYPE_UNSPECIFIED:
            return 'CAPTCHA_CHALLENGE_TYPE_UNSPECIFIED';
        case CaptchaChallengeType.IMAGE_TEXT:
            return 'IMAGE_TEXT';
        case CaptchaChallengeType.SILHOUETTES:
            return 'SILHOUETTES';
        case CaptchaChallengeType.KALEIDOSCOPE:
            return 'KALEIDOSCOPE';
        default:
            return 'UNKNOWN';
    }
}
exports.captchaChallengeTypeToJSON = captchaChallengeTypeToJSON;
const baseCaptcha = {
    id: '',
    folderId: '',
    cloudId: '',
    clientKey: '',
    name: '',
    allowedSites: '',
    complexity: 0,
    styleJson: '',
    suspend: false,
    turnOffHostnameCheck: false,
    preCheckType: 0,
    challengeType: 0,
    deletionProtection: false,
};
exports.Captcha = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.id !== '') {
            writer.uint32(170).string(message.id);
        }
        if (message.folderId !== '') {
            writer.uint32(18).string(message.folderId);
        }
        if (message.cloudId !== '') {
            writer.uint32(98).string(message.cloudId);
        }
        if (message.clientKey !== '') {
            writer.uint32(26).string(message.clientKey);
        }
        if (message.createdAt !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.createdAt), writer.uint32(42).fork()).ldelim();
        }
        if (message.name !== '') {
            writer.uint32(58).string(message.name);
        }
        for (const v of message.allowedSites) {
            writer.uint32(66).string(v);
        }
        if (message.complexity !== 0) {
            writer.uint32(72).int32(message.complexity);
        }
        if (message.styleJson !== '') {
            writer.uint32(82).string(message.styleJson);
        }
        if (message.suspend === true) {
            writer.uint32(104).bool(message.suspend);
        }
        if (message.turnOffHostnameCheck === true) {
            writer.uint32(112).bool(message.turnOffHostnameCheck);
        }
        if (message.preCheckType !== 0) {
            writer.uint32(128).int32(message.preCheckType);
        }
        if (message.challengeType !== 0) {
            writer.uint32(136).int32(message.challengeType);
        }
        for (const v of message.securityRules) {
            exports.SecurityRule.encode(v, writer.uint32(154).fork()).ldelim();
        }
        if (message.deletionProtection === true) {
            writer.uint32(176).bool(message.deletionProtection);
        }
        for (const v of message.overrideVariants) {
            exports.OverrideVariant.encode(v, writer.uint32(186).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({}, baseCaptcha);
        message.allowedSites = [];
        message.securityRules = [];
        message.overrideVariants = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 21:
                    message.id = reader.string();
                    break;
                case 2:
                    message.folderId = reader.string();
                    break;
                case 12:
                    message.cloudId = reader.string();
                    break;
                case 3:
                    message.clientKey = reader.string();
                    break;
                case 5:
                    message.createdAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    break;
                case 7:
                    message.name = reader.string();
                    break;
                case 8:
                    message.allowedSites.push(reader.string());
                    break;
                case 9:
                    message.complexity = reader.int32();
                    break;
                case 10:
                    message.styleJson = reader.string();
                    break;
                case 13:
                    message.suspend = reader.bool();
                    break;
                case 14:
                    message.turnOffHostnameCheck = reader.bool();
                    break;
                case 16:
                    message.preCheckType = reader.int32();
                    break;
                case 17:
                    message.challengeType = reader.int32();
                    break;
                case 19:
                    message.securityRules.push(exports.SecurityRule.decode(reader, reader.uint32()));
                    break;
                case 22:
                    message.deletionProtection = reader.bool();
                    break;
                case 23:
                    message.overrideVariants.push(exports.OverrideVariant.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a, _b, _c;
        const message = Object.assign({}, baseCaptcha);
        message.id = object.id !== undefined && object.id !== null ? String(object.id) : '';
        message.folderId =
            object.folderId !== undefined && object.folderId !== null
                ? String(object.folderId)
                : '';
        message.cloudId =
            object.cloudId !== undefined && object.cloudId !== null ? String(object.cloudId) : '';
        message.clientKey =
            object.clientKey !== undefined && object.clientKey !== null
                ? String(object.clientKey)
                : '';
        message.createdAt =
            object.createdAt !== undefined && object.createdAt !== null
                ? fromJsonTimestamp(object.createdAt)
                : undefined;
        message.name = object.name !== undefined && object.name !== null ? String(object.name) : '';
        message.allowedSites = ((_a = object.allowedSites) !== null && _a !== void 0 ? _a : []).map((e) => String(e));
        message.complexity =
            object.complexity !== undefined && object.complexity !== null
                ? captchaComplexityFromJSON(object.complexity)
                : 0;
        message.styleJson =
            object.styleJson !== undefined && object.styleJson !== null
                ? String(object.styleJson)
                : '';
        message.suspend =
            object.suspend !== undefined && object.suspend !== null
                ? Boolean(object.suspend)
                : false;
        message.turnOffHostnameCheck =
            object.turnOffHostnameCheck !== undefined && object.turnOffHostnameCheck !== null
                ? Boolean(object.turnOffHostnameCheck)
                : false;
        message.preCheckType =
            object.preCheckType !== undefined && object.preCheckType !== null
                ? captchaPreCheckTypeFromJSON(object.preCheckType)
                : 0;
        message.challengeType =
            object.challengeType !== undefined && object.challengeType !== null
                ? captchaChallengeTypeFromJSON(object.challengeType)
                : 0;
        message.securityRules = ((_b = object.securityRules) !== null && _b !== void 0 ? _b : []).map((e) => exports.SecurityRule.fromJSON(e));
        message.deletionProtection =
            object.deletionProtection !== undefined && object.deletionProtection !== null
                ? Boolean(object.deletionProtection)
                : false;
        message.overrideVariants = ((_c = object.overrideVariants) !== null && _c !== void 0 ? _c : []).map((e) => exports.OverrideVariant.fromJSON(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.id !== undefined && (obj.id = message.id);
        message.folderId !== undefined && (obj.folderId = message.folderId);
        message.cloudId !== undefined && (obj.cloudId = message.cloudId);
        message.clientKey !== undefined && (obj.clientKey = message.clientKey);
        message.createdAt !== undefined && (obj.createdAt = message.createdAt.toISOString());
        message.name !== undefined && (obj.name = message.name);
        if (message.allowedSites) {
            obj.allowedSites = message.allowedSites.map((e) => e);
        }
        else {
            obj.allowedSites = [];
        }
        message.complexity !== undefined &&
            (obj.complexity = captchaComplexityToJSON(message.complexity));
        message.styleJson !== undefined && (obj.styleJson = message.styleJson);
        message.suspend !== undefined && (obj.suspend = message.suspend);
        message.turnOffHostnameCheck !== undefined &&
            (obj.turnOffHostnameCheck = message.turnOffHostnameCheck);
        message.preCheckType !== undefined &&
            (obj.preCheckType = captchaPreCheckTypeToJSON(message.preCheckType));
        message.challengeType !== undefined &&
            (obj.challengeType = captchaChallengeTypeToJSON(message.challengeType));
        if (message.securityRules) {
            obj.securityRules = message.securityRules.map((e) => e ? exports.SecurityRule.toJSON(e) : undefined);
        }
        else {
            obj.securityRules = [];
        }
        message.deletionProtection !== undefined &&
            (obj.deletionProtection = message.deletionProtection);
        if (message.overrideVariants) {
            obj.overrideVariants = message.overrideVariants.map((e) => e ? exports.OverrideVariant.toJSON(e) : undefined);
        }
        else {
            obj.overrideVariants = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
        const message = Object.assign({}, baseCaptcha);
        message.id = (_a = object.id) !== null && _a !== void 0 ? _a : '';
        message.folderId = (_b = object.folderId) !== null && _b !== void 0 ? _b : '';
        message.cloudId = (_c = object.cloudId) !== null && _c !== void 0 ? _c : '';
        message.clientKey = (_d = object.clientKey) !== null && _d !== void 0 ? _d : '';
        message.createdAt = (_e = object.createdAt) !== null && _e !== void 0 ? _e : undefined;
        message.name = (_f = object.name) !== null && _f !== void 0 ? _f : '';
        message.allowedSites = ((_g = object.allowedSites) === null || _g === void 0 ? void 0 : _g.map((e) => e)) || [];
        message.complexity = (_h = object.complexity) !== null && _h !== void 0 ? _h : 0;
        message.styleJson = (_j = object.styleJson) !== null && _j !== void 0 ? _j : '';
        message.suspend = (_k = object.suspend) !== null && _k !== void 0 ? _k : false;
        message.turnOffHostnameCheck = (_l = object.turnOffHostnameCheck) !== null && _l !== void 0 ? _l : false;
        message.preCheckType = (_m = object.preCheckType) !== null && _m !== void 0 ? _m : 0;
        message.challengeType = (_o = object.challengeType) !== null && _o !== void 0 ? _o : 0;
        message.securityRules = ((_p = object.securityRules) === null || _p === void 0 ? void 0 : _p.map((e) => exports.SecurityRule.fromPartial(e))) || [];
        message.deletionProtection = (_q = object.deletionProtection) !== null && _q !== void 0 ? _q : false;
        message.overrideVariants =
            ((_r = object.overrideVariants) === null || _r === void 0 ? void 0 : _r.map((e) => exports.OverrideVariant.fromPartial(e))) || [];
        return message;
    },
};
const baseOverrideVariant = {
    uuid: '',
    description: '',
    complexity: 0,
    preCheckType: 0,
    challengeType: 0,
};
exports.OverrideVariant = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.uuid !== '') {
            writer.uint32(10).string(message.uuid);
        }
        if (message.description !== '') {
            writer.uint32(18).string(message.description);
        }
        if (message.complexity !== 0) {
            writer.uint32(24).int32(message.complexity);
        }
        if (message.preCheckType !== 0) {
            writer.uint32(32).int32(message.preCheckType);
        }
        if (message.challengeType !== 0) {
            writer.uint32(40).int32(message.challengeType);
        }
        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({}, baseOverrideVariant);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.uuid = reader.string();
                    break;
                case 2:
                    message.description = reader.string();
                    break;
                case 3:
                    message.complexity = reader.int32();
                    break;
                case 4:
                    message.preCheckType = reader.int32();
                    break;
                case 5:
                    message.challengeType = reader.int32();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseOverrideVariant);
        message.uuid = object.uuid !== undefined && object.uuid !== null ? String(object.uuid) : '';
        message.description =
            object.description !== undefined && object.description !== null
                ? String(object.description)
                : '';
        message.complexity =
            object.complexity !== undefined && object.complexity !== null
                ? captchaComplexityFromJSON(object.complexity)
                : 0;
        message.preCheckType =
            object.preCheckType !== undefined && object.preCheckType !== null
                ? captchaPreCheckTypeFromJSON(object.preCheckType)
                : 0;
        message.challengeType =
            object.challengeType !== undefined && object.challengeType !== null
                ? captchaChallengeTypeFromJSON(object.challengeType)
                : 0;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.uuid !== undefined && (obj.uuid = message.uuid);
        message.description !== undefined && (obj.description = message.description);
        message.complexity !== undefined &&
            (obj.complexity = captchaComplexityToJSON(message.complexity));
        message.preCheckType !== undefined &&
            (obj.preCheckType = captchaPreCheckTypeToJSON(message.preCheckType));
        message.challengeType !== undefined &&
            (obj.challengeType = captchaChallengeTypeToJSON(message.challengeType));
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d, _e;
        const message = Object.assign({}, baseOverrideVariant);
        message.uuid = (_a = object.uuid) !== null && _a !== void 0 ? _a : '';
        message.description = (_b = object.description) !== null && _b !== void 0 ? _b : '';
        message.complexity = (_c = object.complexity) !== null && _c !== void 0 ? _c : 0;
        message.preCheckType = (_d = object.preCheckType) !== null && _d !== void 0 ? _d : 0;
        message.challengeType = (_e = object.challengeType) !== null && _e !== void 0 ? _e : 0;
        return message;
    },
};
const baseCaptchaSecretKey = { serverKey: '' };
exports.CaptchaSecretKey = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.serverKey !== '') {
            writer.uint32(10).string(message.serverKey);
        }
        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({}, baseCaptchaSecretKey);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.serverKey = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseCaptchaSecretKey);
        message.serverKey =
            object.serverKey !== undefined && object.serverKey !== null
                ? String(object.serverKey)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.serverKey !== undefined && (obj.serverKey = message.serverKey);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseCaptchaSecretKey);
        message.serverKey = (_a = object.serverKey) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseSecurityRule = {
    name: '',
    priority: 0,
    description: '',
    overrideVariantUuid: '',
};
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.description !== '') {
            writer.uint32(26).string(message.description);
        }
        if (message.condition !== undefined) {
            exports.Condition.encode(message.condition, writer.uint32(34).fork()).ldelim();
        }
        if (message.overrideVariantUuid !== '') {
            writer.uint32(50).string(message.overrideVariantUuid);
        }
        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.description = reader.string();
                    break;
                case 4:
                    message.condition = exports.Condition.decode(reader, reader.uint32());
                    break;
                case 6:
                    message.overrideVariantUuid = 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.description =
            object.description !== undefined && object.description !== null
                ? String(object.description)
                : '';
        message.condition =
            object.condition !== undefined && object.condition !== null
                ? exports.Condition.fromJSON(object.condition)
                : undefined;
        message.overrideVariantUuid =
            object.overrideVariantUuid !== undefined && object.overrideVariantUuid !== null
                ? String(object.overrideVariantUuid)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.name !== undefined && (obj.name = message.name);
        message.priority !== undefined && (obj.priority = Math.round(message.priority));
        message.description !== undefined && (obj.description = message.description);
        message.condition !== undefined &&
            (obj.condition = message.condition ? exports.Condition.toJSON(message.condition) : undefined);
        message.overrideVariantUuid !== undefined &&
            (obj.overrideVariantUuid = message.overrideVariantUuid);
        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.description = (_c = object.description) !== null && _c !== void 0 ? _c : '';
        message.condition =
            object.condition !== undefined && object.condition !== null
                ? exports.Condition.fromPartial(object.condition)
                : undefined;
        message.overrideVariantUuid = (_d = object.overrideVariantUuid) !== null && _d !== void 0 ? _d : '';
        return message;
    },
};
const baseCondition = {};
exports.Condition = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.host !== undefined) {
            exports.Condition_HostMatcher.encode(message.host, writer.uint32(10).fork()).ldelim();
        }
        if (message.uri !== undefined) {
            exports.Condition_UriMatcher.encode(message.uri, writer.uint32(18).fork()).ldelim();
        }
        for (const v of message.headers) {
            exports.Condition_HeaderMatcher.encode(v, writer.uint32(26).fork()).ldelim();
        }
        if (message.sourceIp !== undefined) {
            exports.Condition_IpMatcher.encode(message.sourceIp, 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);
        message.headers = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.host = exports.Condition_HostMatcher.decode(reader, reader.uint32());
                    break;
                case 2:
                    message.uri = exports.Condition_UriMatcher.decode(reader, reader.uint32());
                    break;
                case 3:
                    message.headers.push(exports.Condition_HeaderMatcher.decode(reader, reader.uint32()));
                    break;
                case 4:
                    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.host =
            object.host !== undefined && object.host !== null
                ? exports.Condition_HostMatcher.fromJSON(object.host)
                : undefined;
        message.uri =
            object.uri !== undefined && object.uri !== null
                ? exports.Condition_UriMatcher.fromJSON(object.uri)
                : 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.host !== undefined &&
            (obj.host = message.host ? exports.Condition_HostMatcher.toJSON(message.host) : undefined);
        message.uri !== undefined &&
            (obj.uri = message.uri ? exports.Condition_UriMatcher.toJSON(message.uri) : 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.host =
            object.host !== undefined && object.host !== null
                ? exports.Condition_HostMatcher.fromPartial(object.host)
                : undefined;
        message.uri =
            object.uri !== undefined && object.uri !== null
                ? exports.Condition_UriMatcher.fromPartial(object.uri)
                : 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_HostMatcher = {};
exports.Condition_HostMatcher = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        for (const v of message.hosts) {
            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_HostMatcher);
        message.hosts = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.hosts.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_HostMatcher);
        message.hosts = ((_a = object.hosts) !== null && _a !== void 0 ? _a : []).map((e) => exports.Condition_StringMatcher.fromJSON(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        if (message.hosts) {
            obj.hosts = message.hosts.map((e) => e ? exports.Condition_StringMatcher.toJSON(e) : undefined);
        }
        else {
            obj.hosts = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseCondition_HostMatcher);
        message.hosts = ((_a = object.hosts) === null || _a === void 0 ? void 0 : _a.map((e) => exports.Condition_StringMatcher.fromPartial(e))) || [];
        return message;
    },
};
const baseCondition_UriMatcher = {};
exports.Condition_UriMatcher = {
    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_UriMatcher);
        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_UriMatcher);
        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_UriMatcher);
        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();
}
