import { ASSISTANT_RESPONSE_MARKDOWN } from "./models";
import { ASSISTANT_NAME } from "./models";
const PROCESSING_PLACEHOLDER = "{{ASSISTANT_NAME}}";
const sendChatMessages = (chatRef) => () => {
    chatRef.waitingResponse = true;
    chatRef.addNewMessage({
        id: `${new Date().getTime()}`,
        role: "assistant",
        content: "Analyzing",
        status: "waiting",
        metadata: {
            agentName: ASSISTANT_NAME,
            time: "14:25"
        }
    });
    setTimeout(() => {
        chatRef.updateLastMessage({
            role: "assistant",
            content: "Processing with Chat with LLMs",
            status: "waiting",
            metadata: {
                agentName: ASSISTANT_NAME,
                time: "14:25"
            }
        }, "replace");
        setTimeout(() => {
            dummyStreaming(chatRef, 20, ASSISTANT_RESPONSE_MARKDOWN, "replace");
        }, 2000);
    }, 2000);
};
const stopResponseAnswer = () => {
    console.log("stop generating answer");
    return new Promise(resolve => {
        // Lógica asincrónica aquí si es necesario
        resolve();
    });
};
export const chatCallbacksWithChatRef = (chChatRef) => {
    return {
        sendChatMessages: sendChatMessages(chChatRef),
        uploadFile: (file) => new Promise(() => {
            console.log("file", file);
            return Promise.resolve({
                url: "Error",
                mimeType: "application/javascript"
            });
        }),
        stopResponse: stopResponseAnswer
    };
};
function dummyStreaming(chatRef, counter, stringToDisplay, mode) {
    setTimeout(() => {
        const streamingCompleted = counter >= stringToDisplay.length;
        chatRef.updateLastMessage({
            role: "assistant",
            content: stringToDisplay.substring(counter - 20, counter),
            // {
            //   message: stringToDisplay.substring(counter - 20, counter),
            //   files: streamingCompleted
            //     ? [
            //         {
            //           url: "https://next.genexus.ai",
            //           caption: "Mars Exploration Contract"
            //         },
            //         {
            //           url: "https://gx-chameleon.netlify.app",
            //           caption: "Venus Exploration Contract"
            //         }
            //       ]
            //     : undefined
            // },
            status: streamingCompleted ? "complete" : "streaming",
            metadata: {
                agentName: ASSISTANT_NAME,
                time: "14:25"
            }
        }, mode);
        if (!streamingCompleted) {
            dummyStreaming(chatRef, counter + 20, stringToDisplay, "concat");
        }
        else {
            chatRef.waitingResponse = false;
        }
    }, counter % 200 === 0 ? 50 : 40);
}
export const chatTranslations = {
    accessibleName: {
        clearChat: "Clear chat",
        copyMessageContent: "Copy message",
        downloadCodeButton: "Download code",
        sendButton: "Send",
        sendInput: "Message",
        stopResponseButton: "Stop generating answer"
    },
    placeholder: {
        sendInput: "Ask me a question..."
    },
    text: {
        copyCodeButton: "Copy code",
        copyMessageContent: "Copy message content",
        downloadCodeButton: "Download code",
        processing: `Processing with ${PROCESSING_PLACEHOLDER}`,
        sourceFiles: "Source files:",
        stopResponseButton: ""
    }
};
//# sourceMappingURL=callbacks.js.map
