"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.HybridSearchIndex = exports.VectorSearchIndex = exports.TextSearchIndex = exports.SearchIndex_LabelsEntry = exports.SearchIndex = exports.protobufPackage = void 0;
/* eslint-disable */
const long_1 = __importDefault(require("long"));
const minimal_1 = __importDefault(require("protobufjs/minimal"));
const common_1 = require("../../../../../../yandex/cloud/ai/common/common");
const common_2 = require("../../../../../../yandex/cloud/ai/assistants/v1/searchindex/common");
const timestamp_1 = require("../../../../../../google/protobuf/timestamp");
exports.protobufPackage = 'yandex.cloud.ai.assistants.v1.searchindex';
const baseSearchIndex = {
    id: '',
    folderId: '',
    name: '',
    description: '',
    createdBy: '',
    updatedBy: '',
};
exports.SearchIndex = {
    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);
        }
        if (message.name !== '') {
            writer.uint32(26).string(message.name);
        }
        if (message.description !== '') {
            writer.uint32(34).string(message.description);
        }
        if (message.createdBy !== '') {
            writer.uint32(42).string(message.createdBy);
        }
        if (message.createdAt !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.createdAt), writer.uint32(50).fork()).ldelim();
        }
        if (message.updatedBy !== '') {
            writer.uint32(58).string(message.updatedBy);
        }
        if (message.updatedAt !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.updatedAt), writer.uint32(66).fork()).ldelim();
        }
        if (message.expirationConfig !== undefined) {
            common_1.ExpirationConfig.encode(message.expirationConfig, writer.uint32(74).fork()).ldelim();
        }
        if (message.expiresAt !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.expiresAt), writer.uint32(82).fork()).ldelim();
        }
        Object.entries(message.labels).forEach(([key, value]) => {
            exports.SearchIndex_LabelsEntry.encode({ key: key, value }, writer.uint32(90).fork()).ldelim();
        });
        if (message.textSearchIndex !== undefined) {
            exports.TextSearchIndex.encode(message.textSearchIndex, writer.uint32(98).fork()).ldelim();
        }
        if (message.vectorSearchIndex !== undefined) {
            exports.VectorSearchIndex.encode(message.vectorSearchIndex, writer.uint32(106).fork()).ldelim();
        }
        if (message.hybridSearchIndex !== undefined) {
            exports.HybridSearchIndex.encode(message.hybridSearchIndex, writer.uint32(114).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseSearchIndex);
        message.labels = {};
        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:
                    message.name = reader.string();
                    break;
                case 4:
                    message.description = reader.string();
                    break;
                case 5:
                    message.createdBy = reader.string();
                    break;
                case 6:
                    message.createdAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    break;
                case 7:
                    message.updatedBy = reader.string();
                    break;
                case 8:
                    message.updatedAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    break;
                case 9:
                    message.expirationConfig = common_1.ExpirationConfig.decode(reader, reader.uint32());
                    break;
                case 10:
                    message.expiresAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    break;
                case 11:
                    const entry11 = exports.SearchIndex_LabelsEntry.decode(reader, reader.uint32());
                    if (entry11.value !== undefined) {
                        message.labels[entry11.key] = entry11.value;
                    }
                    break;
                case 12:
                    message.textSearchIndex = exports.TextSearchIndex.decode(reader, reader.uint32());
                    break;
                case 13:
                    message.vectorSearchIndex = exports.VectorSearchIndex.decode(reader, reader.uint32());
                    break;
                case 14:
                    message.hybridSearchIndex = exports.HybridSearchIndex.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseSearchIndex);
        message.id = object.id !== undefined && object.id !== null ? String(object.id) : '';
        message.folderId =
            object.folderId !== undefined && object.folderId !== null
                ? String(object.folderId)
                : '';
        message.name = object.name !== undefined && object.name !== null ? String(object.name) : '';
        message.description =
            object.description !== undefined && object.description !== null
                ? String(object.description)
                : '';
        message.createdBy =
            object.createdBy !== undefined && object.createdBy !== null
                ? String(object.createdBy)
                : '';
        message.createdAt =
            object.createdAt !== undefined && object.createdAt !== null
                ? fromJsonTimestamp(object.createdAt)
                : undefined;
        message.updatedBy =
            object.updatedBy !== undefined && object.updatedBy !== null
                ? String(object.updatedBy)
                : '';
        message.updatedAt =
            object.updatedAt !== undefined && object.updatedAt !== null
                ? fromJsonTimestamp(object.updatedAt)
                : undefined;
        message.expirationConfig =
            object.expirationConfig !== undefined && object.expirationConfig !== null
                ? common_1.ExpirationConfig.fromJSON(object.expirationConfig)
                : undefined;
        message.expiresAt =
            object.expiresAt !== undefined && object.expiresAt !== null
                ? fromJsonTimestamp(object.expiresAt)
                : undefined;
        message.labels = Object.entries((_a = object.labels) !== null && _a !== void 0 ? _a : {}).reduce((acc, [key, value]) => {
            acc[key] = String(value);
            return acc;
        }, {});
        message.textSearchIndex =
            object.textSearchIndex !== undefined && object.textSearchIndex !== null
                ? exports.TextSearchIndex.fromJSON(object.textSearchIndex)
                : undefined;
        message.vectorSearchIndex =
            object.vectorSearchIndex !== undefined && object.vectorSearchIndex !== null
                ? exports.VectorSearchIndex.fromJSON(object.vectorSearchIndex)
                : undefined;
        message.hybridSearchIndex =
            object.hybridSearchIndex !== undefined && object.hybridSearchIndex !== null
                ? exports.HybridSearchIndex.fromJSON(object.hybridSearchIndex)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.id !== undefined && (obj.id = message.id);
        message.folderId !== undefined && (obj.folderId = message.folderId);
        message.name !== undefined && (obj.name = message.name);
        message.description !== undefined && (obj.description = message.description);
        message.createdBy !== undefined && (obj.createdBy = message.createdBy);
        message.createdAt !== undefined && (obj.createdAt = message.createdAt.toISOString());
        message.updatedBy !== undefined && (obj.updatedBy = message.updatedBy);
        message.updatedAt !== undefined && (obj.updatedAt = message.updatedAt.toISOString());
        message.expirationConfig !== undefined &&
            (obj.expirationConfig = message.expirationConfig
                ? common_1.ExpirationConfig.toJSON(message.expirationConfig)
                : undefined);
        message.expiresAt !== undefined && (obj.expiresAt = message.expiresAt.toISOString());
        obj.labels = {};
        if (message.labels) {
            Object.entries(message.labels).forEach(([k, v]) => {
                obj.labels[k] = v;
            });
        }
        message.textSearchIndex !== undefined &&
            (obj.textSearchIndex = message.textSearchIndex
                ? exports.TextSearchIndex.toJSON(message.textSearchIndex)
                : undefined);
        message.vectorSearchIndex !== undefined &&
            (obj.vectorSearchIndex = message.vectorSearchIndex
                ? exports.VectorSearchIndex.toJSON(message.vectorSearchIndex)
                : undefined);
        message.hybridSearchIndex !== undefined &&
            (obj.hybridSearchIndex = message.hybridSearchIndex
                ? exports.HybridSearchIndex.toJSON(message.hybridSearchIndex)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
        const message = Object.assign({}, baseSearchIndex);
        message.id = (_a = object.id) !== null && _a !== void 0 ? _a : '';
        message.folderId = (_b = object.folderId) !== null && _b !== void 0 ? _b : '';
        message.name = (_c = object.name) !== null && _c !== void 0 ? _c : '';
        message.description = (_d = object.description) !== null && _d !== void 0 ? _d : '';
        message.createdBy = (_e = object.createdBy) !== null && _e !== void 0 ? _e : '';
        message.createdAt = (_f = object.createdAt) !== null && _f !== void 0 ? _f : undefined;
        message.updatedBy = (_g = object.updatedBy) !== null && _g !== void 0 ? _g : '';
        message.updatedAt = (_h = object.updatedAt) !== null && _h !== void 0 ? _h : undefined;
        message.expirationConfig =
            object.expirationConfig !== undefined && object.expirationConfig !== null
                ? common_1.ExpirationConfig.fromPartial(object.expirationConfig)
                : undefined;
        message.expiresAt = (_j = object.expiresAt) !== null && _j !== void 0 ? _j : undefined;
        message.labels = Object.entries((_k = object.labels) !== null && _k !== void 0 ? _k : {}).reduce((acc, [key, value]) => {
            if (value !== undefined) {
                acc[key] = String(value);
            }
            return acc;
        }, {});
        message.textSearchIndex =
            object.textSearchIndex !== undefined && object.textSearchIndex !== null
                ? exports.TextSearchIndex.fromPartial(object.textSearchIndex)
                : undefined;
        message.vectorSearchIndex =
            object.vectorSearchIndex !== undefined && object.vectorSearchIndex !== null
                ? exports.VectorSearchIndex.fromPartial(object.vectorSearchIndex)
                : undefined;
        message.hybridSearchIndex =
            object.hybridSearchIndex !== undefined && object.hybridSearchIndex !== null
                ? exports.HybridSearchIndex.fromPartial(object.hybridSearchIndex)
                : undefined;
        return message;
    },
};
const baseSearchIndex_LabelsEntry = { key: '', value: '' };
exports.SearchIndex_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({}, baseSearchIndex_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({}, baseSearchIndex_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({}, baseSearchIndex_LabelsEntry);
        message.key = (_a = object.key) !== null && _a !== void 0 ? _a : '';
        message.value = (_b = object.value) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const baseTextSearchIndex = {};
exports.TextSearchIndex = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.chunkingStrategy !== undefined) {
            common_2.ChunkingStrategy.encode(message.chunkingStrategy, writer.uint32(10).fork()).ldelim();
        }
        if (message.ngramTokenizer !== undefined) {
            common_2.NgramTokenizer.encode(message.ngramTokenizer, 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({}, baseTextSearchIndex);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.chunkingStrategy = common_2.ChunkingStrategy.decode(reader, reader.uint32());
                    break;
                case 2:
                    message.ngramTokenizer = common_2.NgramTokenizer.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseTextSearchIndex);
        message.chunkingStrategy =
            object.chunkingStrategy !== undefined && object.chunkingStrategy !== null
                ? common_2.ChunkingStrategy.fromJSON(object.chunkingStrategy)
                : undefined;
        message.ngramTokenizer =
            object.ngramTokenizer !== undefined && object.ngramTokenizer !== null
                ? common_2.NgramTokenizer.fromJSON(object.ngramTokenizer)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.chunkingStrategy !== undefined &&
            (obj.chunkingStrategy = message.chunkingStrategy
                ? common_2.ChunkingStrategy.toJSON(message.chunkingStrategy)
                : undefined);
        message.ngramTokenizer !== undefined &&
            (obj.ngramTokenizer = message.ngramTokenizer
                ? common_2.NgramTokenizer.toJSON(message.ngramTokenizer)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseTextSearchIndex);
        message.chunkingStrategy =
            object.chunkingStrategy !== undefined && object.chunkingStrategy !== null
                ? common_2.ChunkingStrategy.fromPartial(object.chunkingStrategy)
                : undefined;
        message.ngramTokenizer =
            object.ngramTokenizer !== undefined && object.ngramTokenizer !== null
                ? common_2.NgramTokenizer.fromPartial(object.ngramTokenizer)
                : undefined;
        return message;
    },
};
const baseVectorSearchIndex = { docEmbedderUri: '', queryEmbedderUri: '' };
exports.VectorSearchIndex = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.docEmbedderUri !== '') {
            writer.uint32(10).string(message.docEmbedderUri);
        }
        if (message.queryEmbedderUri !== '') {
            writer.uint32(18).string(message.queryEmbedderUri);
        }
        if (message.chunkingStrategy !== undefined) {
            common_2.ChunkingStrategy.encode(message.chunkingStrategy, writer.uint32(26).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({}, baseVectorSearchIndex);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.docEmbedderUri = reader.string();
                    break;
                case 2:
                    message.queryEmbedderUri = reader.string();
                    break;
                case 3:
                    message.chunkingStrategy = common_2.ChunkingStrategy.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseVectorSearchIndex);
        message.docEmbedderUri =
            object.docEmbedderUri !== undefined && object.docEmbedderUri !== null
                ? String(object.docEmbedderUri)
                : '';
        message.queryEmbedderUri =
            object.queryEmbedderUri !== undefined && object.queryEmbedderUri !== null
                ? String(object.queryEmbedderUri)
                : '';
        message.chunkingStrategy =
            object.chunkingStrategy !== undefined && object.chunkingStrategy !== null
                ? common_2.ChunkingStrategy.fromJSON(object.chunkingStrategy)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.docEmbedderUri !== undefined && (obj.docEmbedderUri = message.docEmbedderUri);
        message.queryEmbedderUri !== undefined && (obj.queryEmbedderUri = message.queryEmbedderUri);
        message.chunkingStrategy !== undefined &&
            (obj.chunkingStrategy = message.chunkingStrategy
                ? common_2.ChunkingStrategy.toJSON(message.chunkingStrategy)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseVectorSearchIndex);
        message.docEmbedderUri = (_a = object.docEmbedderUri) !== null && _a !== void 0 ? _a : '';
        message.queryEmbedderUri = (_b = object.queryEmbedderUri) !== null && _b !== void 0 ? _b : '';
        message.chunkingStrategy =
            object.chunkingStrategy !== undefined && object.chunkingStrategy !== null
                ? common_2.ChunkingStrategy.fromPartial(object.chunkingStrategy)
                : undefined;
        return message;
    },
};
const baseHybridSearchIndex = { normalizationStrategy: 0 };
exports.HybridSearchIndex = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.textSearchIndex !== undefined) {
            exports.TextSearchIndex.encode(message.textSearchIndex, writer.uint32(10).fork()).ldelim();
        }
        if (message.vectorSearchIndex !== undefined) {
            exports.VectorSearchIndex.encode(message.vectorSearchIndex, writer.uint32(18).fork()).ldelim();
        }
        if (message.chunkingStrategy !== undefined) {
            common_2.ChunkingStrategy.encode(message.chunkingStrategy, writer.uint32(26).fork()).ldelim();
        }
        if (message.normalizationStrategy !== 0) {
            writer.uint32(32).int32(message.normalizationStrategy);
        }
        if (message.combinationStrategy !== undefined) {
            common_2.CombinationStrategy.encode(message.combinationStrategy, 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({}, baseHybridSearchIndex);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.textSearchIndex = exports.TextSearchIndex.decode(reader, reader.uint32());
                    break;
                case 2:
                    message.vectorSearchIndex = exports.VectorSearchIndex.decode(reader, reader.uint32());
                    break;
                case 3:
                    message.chunkingStrategy = common_2.ChunkingStrategy.decode(reader, reader.uint32());
                    break;
                case 4:
                    message.normalizationStrategy = reader.int32();
                    break;
                case 5:
                    message.combinationStrategy = common_2.CombinationStrategy.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseHybridSearchIndex);
        message.textSearchIndex =
            object.textSearchIndex !== undefined && object.textSearchIndex !== null
                ? exports.TextSearchIndex.fromJSON(object.textSearchIndex)
                : undefined;
        message.vectorSearchIndex =
            object.vectorSearchIndex !== undefined && object.vectorSearchIndex !== null
                ? exports.VectorSearchIndex.fromJSON(object.vectorSearchIndex)
                : undefined;
        message.chunkingStrategy =
            object.chunkingStrategy !== undefined && object.chunkingStrategy !== null
                ? common_2.ChunkingStrategy.fromJSON(object.chunkingStrategy)
                : undefined;
        message.normalizationStrategy =
            object.normalizationStrategy !== undefined && object.normalizationStrategy !== null
                ? (0, common_2.normalizationStrategyFromJSON)(object.normalizationStrategy)
                : 0;
        message.combinationStrategy =
            object.combinationStrategy !== undefined && object.combinationStrategy !== null
                ? common_2.CombinationStrategy.fromJSON(object.combinationStrategy)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.textSearchIndex !== undefined &&
            (obj.textSearchIndex = message.textSearchIndex
                ? exports.TextSearchIndex.toJSON(message.textSearchIndex)
                : undefined);
        message.vectorSearchIndex !== undefined &&
            (obj.vectorSearchIndex = message.vectorSearchIndex
                ? exports.VectorSearchIndex.toJSON(message.vectorSearchIndex)
                : undefined);
        message.chunkingStrategy !== undefined &&
            (obj.chunkingStrategy = message.chunkingStrategy
                ? common_2.ChunkingStrategy.toJSON(message.chunkingStrategy)
                : undefined);
        message.normalizationStrategy !== undefined &&
            (obj.normalizationStrategy = (0, common_2.normalizationStrategyToJSON)(message.normalizationStrategy));
        message.combinationStrategy !== undefined &&
            (obj.combinationStrategy = message.combinationStrategy
                ? common_2.CombinationStrategy.toJSON(message.combinationStrategy)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseHybridSearchIndex);
        message.textSearchIndex =
            object.textSearchIndex !== undefined && object.textSearchIndex !== null
                ? exports.TextSearchIndex.fromPartial(object.textSearchIndex)
                : undefined;
        message.vectorSearchIndex =
            object.vectorSearchIndex !== undefined && object.vectorSearchIndex !== null
                ? exports.VectorSearchIndex.fromPartial(object.vectorSearchIndex)
                : undefined;
        message.chunkingStrategy =
            object.chunkingStrategy !== undefined && object.chunkingStrategy !== null
                ? common_2.ChunkingStrategy.fromPartial(object.chunkingStrategy)
                : undefined;
        message.normalizationStrategy = (_a = object.normalizationStrategy) !== null && _a !== void 0 ? _a : 0;
        message.combinationStrategy =
            object.combinationStrategy !== undefined && object.combinationStrategy !== null
                ? common_2.CombinationStrategy.fromPartial(object.combinationStrategy)
                : undefined;
        return message;
    },
};
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));
    }
}
if (minimal_1.default.util.Long !== long_1.default) {
    minimal_1.default.util.Long = long_1.default;
    minimal_1.default.configure();
}
