import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
import { append, $ as $$1 } from '../../../../base/browser/dom.js';
import { Button } from '../../../../base/browser/ui/button/button.js';
import { MarkdownString } from '../../../../base/common/htmlContent.js';
import { Disposable } from '../../../../base/common/lifecycle.js';
import { localizeWithPath } from '../../../../nls.js';
import { IChatAgentService } from '../common/chatAgents.service.js';
import { chatAgentLeader, chatSubcommandLeader } from '../common/chatParserTypes.js';
const _moduleId = "vs/workbench/contrib/chat/browser/chatFollowups";
const $ = $$1;
let ChatFollowups = class ChatFollowups extends Disposable {
    constructor(container, followups, location, options, clickHandler, chatAgentService) {
        super();
        this.location = location;
        this.options = options;
        this.clickHandler = clickHandler;
        this.chatAgentService = chatAgentService;
        const followupsContainer = append(container, $('.interactive-session-followups'));
        followups.forEach(followup => this.renderFollowup(followupsContainer, followup));
    }
    renderFollowup(container, followup) {
        if (!this.chatAgentService.getDefaultAgent(this.location)) {
            return;
        }
        let tooltipPrefix = '';
        if ('agentId' in followup && followup.agentId && followup.agentId !== this.chatAgentService.getDefaultAgent(this.location)?.id) {
            const agent = this.chatAgentService.getAgent(followup.agentId);
            if (!agent) {
                return;
            }
            tooltipPrefix += `${chatAgentLeader}${agent.name} `;
            if ('subCommand' in followup && followup.subCommand) {
                tooltipPrefix += `${chatSubcommandLeader}${followup.subCommand} `;
            }
        }
        const baseTitle = followup.kind === 'reply' ?
            (followup.title || followup.message)
            : followup.title;
        const message = followup.kind === 'reply' ? followup.message : followup.title;
        const tooltip = (tooltipPrefix +
            ('tooltip' in followup && followup.tooltip || message)).trim();
        const button = this._register(( (new Button(container, { ...this.options, title: tooltip }))));
        if (followup.kind === 'reply') {
            button.element.classList.add('interactive-followup-reply');
        }
        else if (followup.kind === 'command') {
            button.element.classList.add('interactive-followup-command');
        }
        button.element.ariaLabel = ( localizeWithPath(_moduleId, 0, "Follow up question: {0}", baseTitle));
        button.label = ( (new MarkdownString(baseTitle)));
        this._register(button.onDidClick(() => this.clickHandler(followup)));
    }
};
ChatFollowups = ( (__decorate([
    ( (__param(5, IChatAgentService)))
], ChatFollowups)));
export { ChatFollowups };
