"use strict";
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
//   protoc-gen-ts_proto  v2.11.8
//   protoc               v4.25.9
// source: io/restorecommerce/filter.proto
Object.defineProperty(exports, "__esModule", { value: true });
exports.protoMetadata = exports.FilterOp = exports.Filter = exports.FilterOp_Operator = exports.Filter_ValueType = exports.Filter_Operation = exports.protobufPackage = void 0;
exports.filter_OperationFromJSON = filter_OperationFromJSON;
exports.filter_OperationToJSON = filter_OperationToJSON;
exports.filter_OperationToNumber = filter_OperationToNumber;
exports.filter_ValueTypeFromJSON = filter_ValueTypeFromJSON;
exports.filter_ValueTypeToJSON = filter_ValueTypeToJSON;
exports.filter_ValueTypeToNumber = filter_ValueTypeToNumber;
exports.filterOp_OperatorFromJSON = filterOp_OperatorFromJSON;
exports.filterOp_OperatorToJSON = filterOp_OperatorToJSON;
exports.filterOp_OperatorToNumber = filterOp_OperatorToNumber;
/* eslint-disable */
const wire_1 = require("@bufbuild/protobuf/wire");
exports.protobufPackage = "io.restorecommerce.filter";
var Filter_Operation;
(function (Filter_Operation) {
    Filter_Operation["eq"] = "eq";
    Filter_Operation["lt"] = "lt";
    Filter_Operation["lte"] = "lte";
    Filter_Operation["gt"] = "gt";
    Filter_Operation["gte"] = "gte";
    Filter_Operation["isEmpty"] = "isEmpty";
    Filter_Operation["iLike"] = "iLike";
    Filter_Operation["in"] = "in";
    Filter_Operation["neq"] = "neq";
    Filter_Operation["UNRECOGNIZED"] = "UNRECOGNIZED";
})(Filter_Operation || (exports.Filter_Operation = Filter_Operation = {}));
function filter_OperationFromJSON(object) {
    switch (object) {
        case 0:
        case "eq":
            return Filter_Operation.eq;
        case 1:
        case "lt":
            return Filter_Operation.lt;
        case 2:
        case "lte":
            return Filter_Operation.lte;
        case 3:
        case "gt":
            return Filter_Operation.gt;
        case 4:
        case "gte":
            return Filter_Operation.gte;
        case 5:
        case "isEmpty":
            return Filter_Operation.isEmpty;
        case 6:
        case "iLike":
            return Filter_Operation.iLike;
        case 7:
        case "in":
            return Filter_Operation.in;
        case 8:
        case "neq":
            return Filter_Operation.neq;
        case -1:
        case "UNRECOGNIZED":
        default:
            return Filter_Operation.UNRECOGNIZED;
    }
}
function filter_OperationToJSON(object) {
    switch (object) {
        case Filter_Operation.eq:
            return "eq";
        case Filter_Operation.lt:
            return "lt";
        case Filter_Operation.lte:
            return "lte";
        case Filter_Operation.gt:
            return "gt";
        case Filter_Operation.gte:
            return "gte";
        case Filter_Operation.isEmpty:
            return "isEmpty";
        case Filter_Operation.iLike:
            return "iLike";
        case Filter_Operation.in:
            return "in";
        case Filter_Operation.neq:
            return "neq";
        case Filter_Operation.UNRECOGNIZED:
        default:
            return "UNRECOGNIZED";
    }
}
function filter_OperationToNumber(object) {
    switch (object) {
        case Filter_Operation.eq:
            return 0;
        case Filter_Operation.lt:
            return 1;
        case Filter_Operation.lte:
            return 2;
        case Filter_Operation.gt:
            return 3;
        case Filter_Operation.gte:
            return 4;
        case Filter_Operation.isEmpty:
            return 5;
        case Filter_Operation.iLike:
            return 6;
        case Filter_Operation.in:
            return 7;
        case Filter_Operation.neq:
            return 8;
        case Filter_Operation.UNRECOGNIZED:
        default:
            return -1;
    }
}
var Filter_ValueType;
(function (Filter_ValueType) {
    /** STRING - default value type if not specified */
    Filter_ValueType["STRING"] = "STRING";
    Filter_ValueType["NUMBER"] = "NUMBER";
    Filter_ValueType["BOOLEAN"] = "BOOLEAN";
    Filter_ValueType["DATE"] = "DATE";
    Filter_ValueType["ARRAY"] = "ARRAY";
    Filter_ValueType["UNRECOGNIZED"] = "UNRECOGNIZED";
})(Filter_ValueType || (exports.Filter_ValueType = Filter_ValueType = {}));
function filter_ValueTypeFromJSON(object) {
    switch (object) {
        case 0:
        case "STRING":
            return Filter_ValueType.STRING;
        case 1:
        case "NUMBER":
            return Filter_ValueType.NUMBER;
        case 2:
        case "BOOLEAN":
            return Filter_ValueType.BOOLEAN;
        case 3:
        case "DATE":
            return Filter_ValueType.DATE;
        case 4:
        case "ARRAY":
            return Filter_ValueType.ARRAY;
        case -1:
        case "UNRECOGNIZED":
        default:
            return Filter_ValueType.UNRECOGNIZED;
    }
}
function filter_ValueTypeToJSON(object) {
    switch (object) {
        case Filter_ValueType.STRING:
            return "STRING";
        case Filter_ValueType.NUMBER:
            return "NUMBER";
        case Filter_ValueType.BOOLEAN:
            return "BOOLEAN";
        case Filter_ValueType.DATE:
            return "DATE";
        case Filter_ValueType.ARRAY:
            return "ARRAY";
        case Filter_ValueType.UNRECOGNIZED:
        default:
            return "UNRECOGNIZED";
    }
}
function filter_ValueTypeToNumber(object) {
    switch (object) {
        case Filter_ValueType.STRING:
            return 0;
        case Filter_ValueType.NUMBER:
            return 1;
        case Filter_ValueType.BOOLEAN:
            return 2;
        case Filter_ValueType.DATE:
            return 3;
        case Filter_ValueType.ARRAY:
            return 4;
        case Filter_ValueType.UNRECOGNIZED:
        default:
            return -1;
    }
}
var FilterOp_Operator;
(function (FilterOp_Operator) {
    FilterOp_Operator["and"] = "and";
    FilterOp_Operator["or"] = "or";
    FilterOp_Operator["UNRECOGNIZED"] = "UNRECOGNIZED";
})(FilterOp_Operator || (exports.FilterOp_Operator = FilterOp_Operator = {}));
function filterOp_OperatorFromJSON(object) {
    switch (object) {
        case 0:
        case "and":
            return FilterOp_Operator.and;
        case 1:
        case "or":
            return FilterOp_Operator.or;
        case -1:
        case "UNRECOGNIZED":
        default:
            return FilterOp_Operator.UNRECOGNIZED;
    }
}
function filterOp_OperatorToJSON(object) {
    switch (object) {
        case FilterOp_Operator.and:
            return "and";
        case FilterOp_Operator.or:
            return "or";
        case FilterOp_Operator.UNRECOGNIZED:
        default:
            return "UNRECOGNIZED";
    }
}
function filterOp_OperatorToNumber(object) {
    switch (object) {
        case FilterOp_Operator.and:
            return 0;
        case FilterOp_Operator.or:
            return 1;
        case FilterOp_Operator.UNRECOGNIZED:
        default:
            return -1;
    }
}
function createBaseFilter() {
    return {};
}
exports.Filter = {
    encode(message, writer = new wire_1.BinaryWriter()) {
        if (message.field !== undefined) {
            writer.uint32(10).string(message.field);
        }
        if (message.operation !== undefined) {
            writer.uint32(16).int32(filter_OperationToNumber(message.operation));
        }
        if (message.value !== undefined) {
            writer.uint32(26).string(message.value);
        }
        if (message.type !== undefined) {
            writer.uint32(32).int32(filter_ValueTypeToNumber(message.type));
        }
        if (message.filters !== undefined && message.filters.length !== 0) {
            for (const v of message.filters) {
                exports.FilterOp.encode(v, writer.uint32(50).fork()).join();
            }
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
        const end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseFilter();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1: {
                    if (tag !== 10) {
                        break;
                    }
                    message.field = reader.string();
                    continue;
                }
                case 2: {
                    if (tag !== 16) {
                        break;
                    }
                    message.operation = filter_OperationFromJSON(reader.int32());
                    continue;
                }
                case 3: {
                    if (tag !== 26) {
                        break;
                    }
                    message.value = reader.string();
                    continue;
                }
                case 4: {
                    if (tag !== 32) {
                        break;
                    }
                    message.type = filter_ValueTypeFromJSON(reader.int32());
                    continue;
                }
                case 6: {
                    if (tag !== 50) {
                        break;
                    }
                    if (message.filters === undefined) {
                        message.filters = [];
                    }
                    const el = exports.FilterOp.decode(reader, reader.uint32());
                    if (el !== undefined) {
                        message.filters.push(el);
                    }
                    continue;
                }
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skip(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            field: isSet(object.field) ? globalThis.String(object.field) : undefined,
            operation: isSet(object.operation) ? filter_OperationFromJSON(object.operation) : undefined,
            value: isSet(object.value) ? globalThis.String(object.value) : undefined,
            type: isSet(object.type) ? filter_ValueTypeFromJSON(object.type) : undefined,
            filters: globalThis.Array.isArray(object?.filters)
                ? object.filters.map((e) => exports.FilterOp.fromJSON(e))
                : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.field !== undefined) {
            obj.field = message.field;
        }
        if (message.operation !== undefined) {
            obj.operation = filter_OperationToJSON(message.operation);
        }
        if (message.value !== undefined) {
            obj.value = message.value;
        }
        if (message.type !== undefined) {
            obj.type = filter_ValueTypeToJSON(message.type);
        }
        if (message.filters?.length) {
            obj.filters = message.filters.map((e) => exports.FilterOp.toJSON(e));
        }
        return obj;
    },
    create(base) {
        return exports.Filter.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseFilter();
        message.field = object.field ?? undefined;
        message.operation = object.operation ?? undefined;
        message.value = object.value ?? undefined;
        message.type = object.type ?? undefined;
        message.filters = object.filters?.map((e) => exports.FilterOp.fromPartial(e)) || undefined;
        return message;
    },
};
function createBaseFilterOp() {
    return {};
}
exports.FilterOp = {
    encode(message, writer = new wire_1.BinaryWriter()) {
        if (message.filters !== undefined && message.filters.length !== 0) {
            for (const v of message.filters) {
                exports.Filter.encode(v, writer.uint32(10).fork()).join();
            }
        }
        if (message.operator !== undefined) {
            writer.uint32(16).int32(filterOp_OperatorToNumber(message.operator));
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
        const end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseFilterOp();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1: {
                    if (tag !== 10) {
                        break;
                    }
                    if (message.filters === undefined) {
                        message.filters = [];
                    }
                    const el = exports.Filter.decode(reader, reader.uint32());
                    if (el !== undefined) {
                        message.filters.push(el);
                    }
                    continue;
                }
                case 2: {
                    if (tag !== 16) {
                        break;
                    }
                    message.operator = filterOp_OperatorFromJSON(reader.int32());
                    continue;
                }
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skip(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            filters: globalThis.Array.isArray(object?.filters)
                ? object.filters.map((e) => exports.Filter.fromJSON(e))
                : undefined,
            operator: isSet(object.operator) ? filterOp_OperatorFromJSON(object.operator) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.filters?.length) {
            obj.filters = message.filters.map((e) => exports.Filter.toJSON(e));
        }
        if (message.operator !== undefined) {
            obj.operator = filterOp_OperatorToJSON(message.operator);
        }
        return obj;
    },
    create(base) {
        return exports.FilterOp.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseFilterOp();
        message.filters = object.filters?.map((e) => exports.Filter.fromPartial(e)) || undefined;
        message.operator = object.operator ?? undefined;
        return message;
    },
};
exports.protoMetadata = {
    fileDescriptor: {
        "name": "io/restorecommerce/filter.proto",
        "package": "io.restorecommerce.filter",
        "dependency": [],
        "publicDependency": [],
        "weakDependency": [],
        "optionDependency": [],
        "messageType": [{
                "name": "Filter",
                "field": [{
                        "name": "field",
                        "number": 1,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "field",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "operation",
                        "number": 2,
                        "label": 1,
                        "type": 14,
                        "typeName": ".io.restorecommerce.filter.Filter.Operation",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 1,
                        "jsonName": "operation",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "value",
                        "number": 3,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 2,
                        "jsonName": "value",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "type",
                        "number": 4,
                        "label": 1,
                        "type": 14,
                        "typeName": ".io.restorecommerce.filter.Filter.ValueType",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 3,
                        "jsonName": "type",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "filters",
                        "number": 6,
                        "label": 3,
                        "type": 11,
                        "typeName": ".io.restorecommerce.filter.FilterOp",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "filters",
                        "options": undefined,
                        "proto3Optional": false,
                    }],
                "extension": [],
                "nestedType": [],
                "enumType": [{
                        "name": "Operation",
                        "value": [
                            { "name": "eq", "number": 0, "options": undefined },
                            { "name": "lt", "number": 1, "options": undefined },
                            { "name": "lte", "number": 2, "options": undefined },
                            { "name": "gt", "number": 3, "options": undefined },
                            { "name": "gte", "number": 4, "options": undefined },
                            { "name": "isEmpty", "number": 5, "options": undefined },
                            { "name": "iLike", "number": 6, "options": undefined },
                            { "name": "in", "number": 7, "options": undefined },
                            { "name": "neq", "number": 8, "options": undefined },
                        ],
                        "options": undefined,
                        "reservedRange": [],
                        "reservedName": [],
                        "visibility": 0,
                    }, {
                        "name": "ValueType",
                        "value": [
                            { "name": "STRING", "number": 0, "options": undefined },
                            { "name": "NUMBER", "number": 1, "options": undefined },
                            { "name": "BOOLEAN", "number": 2, "options": undefined },
                            { "name": "DATE", "number": 3, "options": undefined },
                            { "name": "ARRAY", "number": 4, "options": undefined },
                        ],
                        "options": undefined,
                        "reservedRange": [],
                        "reservedName": [],
                        "visibility": 0,
                    }],
                "extensionRange": [],
                "oneofDecl": [{ "name": "_field", "options": undefined }, { "name": "_operation", "options": undefined }, {
                        "name": "_value",
                        "options": undefined,
                    }, { "name": "_type", "options": undefined }],
                "options": undefined,
                "reservedRange": [],
                "reservedName": [],
                "visibility": 0,
            }, {
                "name": "FilterOp",
                "field": [{
                        "name": "filters",
                        "number": 1,
                        "label": 3,
                        "type": 11,
                        "typeName": ".io.restorecommerce.filter.Filter",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "filters",
                        "options": undefined,
                        "proto3Optional": false,
                    }, {
                        "name": "operator",
                        "number": 2,
                        "label": 1,
                        "type": 14,
                        "typeName": ".io.restorecommerce.filter.FilterOp.Operator",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "operator",
                        "options": undefined,
                        "proto3Optional": true,
                    }],
                "extension": [],
                "nestedType": [],
                "enumType": [{
                        "name": "Operator",
                        "value": [{ "name": "and", "number": 0, "options": undefined }, {
                                "name": "or",
                                "number": 1,
                                "options": undefined,
                            }],
                        "options": undefined,
                        "reservedRange": [],
                        "reservedName": [],
                        "visibility": 0,
                    }],
                "extensionRange": [],
                "oneofDecl": [{ "name": "_operator", "options": undefined }],
                "options": undefined,
                "reservedRange": [],
                "reservedName": [],
                "visibility": 0,
            }],
        "enumType": [],
        "service": [],
        "extension": [],
        "options": undefined,
        "sourceCodeInfo": {
            "location": [{
                    "path": [4, 0, 4, 1, 2, 0],
                    "span": [20, 4, 15],
                    "leadingComments": "",
                    "trailingComments": " default value type if not specified\n",
                    "leadingDetachedComments": [],
                }],
        },
        "syntax": "proto3",
        "edition": 0,
    },
    references: {
        ".io.restorecommerce.filter.Filter": exports.Filter,
        ".io.restorecommerce.filter.Filter.Operation": Filter_Operation,
        ".io.restorecommerce.filter.Filter.ValueType": Filter_ValueType,
        ".io.restorecommerce.filter.FilterOp": exports.FilterOp,
        ".io.restorecommerce.filter.FilterOp.Operator": FilterOp_Operator,
    },
    dependencies: [],
};
function isSet(value) {
    return value !== null && value !== undefined;
}
//# sourceMappingURL=filter.js.map