"use strict";
/*!
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.Messager = void 0;
const telemetry_1 = require("../contracts/telemetry");
class Messager {
    chatApi;
    constructor(chatApi) {
        this.chatApi = chatApi;
    }
    onTabAdd = (tabId, triggerType, restoredTab) => {
        this.chatApi.tabAdded({ tabId, restoredTab });
        this.chatApi.telemetry({ triggerType: triggerType ?? 'click', tabId, name: telemetry_1.TAB_ADD_TELEMETRY_EVENT });
    };
    onRuleClick = (params) => {
        this.chatApi.onRuleClick(params);
    };
    onTabChange = (tabId) => {
        this.chatApi.tabChanged({ tabId });
    };
    onTabRemove = (tabId) => {
        this.chatApi.tabRemoved({ tabId });
    };
    onUiReady = () => {
        this.chatApi.uiReady();
    };
    onDisclaimerAcknowledged = () => {
        this.chatApi.disclaimerAcknowledged();
    };
    onChatPromptOptionAcknowledged = (messageId) => {
        this.chatApi.chatPromptOptionAcknowledged(messageId);
    };
    onFocusStateChanged = (focusState) => {
        this.chatApi.telemetry({ name: focusState ? telemetry_1.ENTER_FOCUS : telemetry_1.EXIT_FOCUS });
    };
    onSendToPrompt = (params, tabId) => {
        this.chatApi.telemetry({ ...params, tabId, name: telemetry_1.SEND_TO_PROMPT_TELEMETRY_EVENT });
    };
    onChatPrompt = (params, triggerType) => {
        this.chatApi.sendChatPrompt(params);
        // Let the server know about the latest trigger interaction on the tabId
        this.chatApi.telemetry({
            triggerType: triggerType ?? 'click',
            tabId: params.tabId,
            name: telemetry_1.ADD_MESSAGE_TELEMETRY_EVENT,
        });
    };
    onQuickActionCommand = (params) => {
        this.chatApi.sendQuickActionCommand(params);
    };
    onInsertToCursorPosition = (params) => {
        this.chatApi.insertToCursorPosition(params);
        this.chatApi.telemetry({ ...params, name: telemetry_1.INSERT_TO_CURSOR_POSITION_TELEMETRY_EVENT });
    };
    onAuthFollowUpClicked = (params) => {
        this.chatApi.authFollowUpClicked(params);
        this.chatApi.telemetry({ ...params, name: telemetry_1.AUTH_FOLLOW_UP_CLICKED_TELEMETRY_EVENT });
    };
    onFollowUpClicked = (params) => {
        this.chatApi.followUpClicked(params);
    };
    onCopyCodeToClipboard = (params) => {
        this.chatApi.copyToClipboard(params);
        this.chatApi.telemetry({ ...params, name: telemetry_1.COPY_TO_CLIPBOARD_TELEMETRY_EVENT });
    };
    onVote = (params) => {
        this.chatApi.telemetry({ ...params, name: telemetry_1.VOTE_TELEMETRY_EVENT });
    };
    onSendFeedback = (params) => {
        this.chatApi.sendFeedback(params);
    };
    onLinkClick = (params) => {
        this.chatApi.linkClick(params);
        this.chatApi.telemetry({ ...params, name: telemetry_1.LINK_CLICK_TELEMETRY_EVENT });
    };
    onSourceLinkClick = (params) => {
        this.chatApi.sourceLinkClick(params);
        this.chatApi.telemetry({ ...params, name: telemetry_1.SOURCE_LINK_CLICK_TELEMETRY_EVENT });
    };
    onInfoLinkClick = (params) => {
        this.chatApi.infoLinkClick(params);
        this.chatApi.telemetry({ ...params, name: telemetry_1.INFO_LINK_CLICK_TELEMETRY_EVENT });
    };
    onError = (params) => {
        this.chatApi.telemetry({ ...params, name: telemetry_1.ERROR_MESSAGE_TELEMETRY_EVENT });
    };
    onOpenTab = (requestId, result) => {
        this.chatApi.onOpenTab(requestId, result);
    };
    onCreatePrompt = (params) => {
        this.chatApi.createPrompt(params);
    };
    onFileClick = (params) => {
        this.chatApi.fileClick(params);
    };
    onListConversations = (filter, tabButtonClicked) => {
        this.chatApi.listConversations({ filter });
        if (tabButtonClicked) {
            this.chatApi.telemetry({ triggerType: 'click', name: telemetry_1.HISTORY_BUTTON_CLICK_TELEMETRY_EVENT });
        }
    };
    onListRules = (params) => {
        this.chatApi.listRules(params);
    };
    onConversationClick = (conversationId, action) => {
        this.chatApi.conversationClick({ id: conversationId, action });
    };
    onListMcpServers = (filter) => {
        this.chatApi.listMcpServers({ filter });
    };
    onMcpServerClick = (id, title, options) => {
        this.chatApi.mcpServerClick({ id: id, title: title, optionsValues: options });
    };
    onTabBarAction = (params) => {
        this.chatApi.tabBarAction(params);
    };
    onGetSerializedChat = (requestId, result) => {
        this.chatApi.onGetSerializedChat(requestId, result);
    };
    onPromptInputOptionChange = (params) => {
        this.chatApi.promptInputOptionChange(params);
    };
    onPromptInputButtonClick = (params) => {
        this.chatApi.promptInputButtonClick(params);
    };
    onStopChatResponse = (tabId) => {
        this.chatApi.stopChatResponse(tabId);
    };
    onButtonClick = (params) => {
        this.chatApi.sendButtonClickEvent(params);
    };
    onOpenSettings = (settingKey) => {
        this.chatApi.onOpenSettings(settingKey);
    };
    onAddPinnedContext = (params) => {
        this.chatApi.onAddPinnedContext(params);
    };
    onRemovePinnedContext = (params) => {
        this.chatApi.onRemovePinnedContext(params);
    };
}
exports.Messager = Messager;
//# sourceMappingURL=messager.js.map