"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.initMessageSdk = exports.MessageSdk = void 0;
const message_service_1 = require("../../generated/yandex/cloud/ai/assistants/v1/threads/message_service");
class MessageSdk {
    constructor(session, endpoint = MessageSdk.ENDPOINT) {
        this.messageClient = session.client(message_service_1.MessageServiceClient, endpoint);
    }
    static getMessageContent(...args) {
        return { content: args.map((content) => ({ text: { content } })) };
    }
    static messageContentToString(messageContent) {
        var _a;
        return ((_a = messageContent === null || messageContent === void 0 ? void 0 : messageContent.content.reduce((res, { text }) => {
            if (text === null || text === void 0 ? void 0 : text.content) {
                res += text.content;
            }
            return res;
        }, '')) !== null && _a !== void 0 ? _a : '');
    }
    send(params, args) {
        const p = this.messageClient.create(message_service_1.CreateMessageRequest.fromPartial(params), args);
        return p;
    }
    get(params, args) {
        const p = this.messageClient.get(message_service_1.GetMessageRequest.fromPartial(params), args);
        return p;
    }
    list(params, args) {
        const p = this.messageClient.list(message_service_1.ListMessagesRequest.fromPartial(params), args);
        return p;
    }
}
exports.MessageSdk = MessageSdk;
MessageSdk.ENDPOINT = 'assistant.api.cloud.yandex.net:443';
const initMessageSdk = (session, endpoint = MessageSdk.ENDPOINT) => {
    return new MessageSdk(session, endpoint);
};
exports.initMessageSdk = initMessageSdk;
