import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
import marked_1 from '../../../../../../../external/vscode-marked/lib/marked.esm.js';
import { localizeWithPath } from '../../../../nls.js';
import { AccessibilityVerbositySettingId } from '../../accessibility/browser/accessibilityConfiguration.js';
import { IAccessibleViewService } from '../../../../platform/accessibility/browser/accessibleView.service.js';
import { isRequestVM, isResponseVM, isWelcomeVM } from '../common/chatViewModel.js';
const _moduleId = "vs/workbench/contrib/chat/browser/chatAccessibilityProvider";
let ChatAccessibilityProvider = class ChatAccessibilityProvider {
    constructor(_accessibleViewService) {
        this._accessibleViewService = _accessibleViewService;
    }
    getWidgetRole() {
        return 'list';
    }
    getRole(element) {
        return 'listitem';
    }
    getWidgetAriaLabel() {
        return ( localizeWithPath(_moduleId, 0, "Chat"));
    }
    getAriaLabel(element) {
        if (isRequestVM(element)) {
            return element.messageText;
        }
        if (isResponseVM(element)) {
            return this._getLabelWithCodeBlockCount(element);
        }
        if (isWelcomeVM(element)) {
            return ( (element.content.map(
                c => 'value' in c ? c.value : ( (c.map(followup => followup.message))).join('\n')
            ))).join('\n');
        }
        return '';
    }
    _getLabelWithCodeBlockCount(element) {
        const accessibleViewHint = this._accessibleViewService.getOpenAriaHint(AccessibilityVerbositySettingId.Chat);
        let label = '';
        const fileTreeCount = element.response.value.filter((v) => !('value' in v))?.length ?? 0;
        let fileTreeCountHint = '';
        switch (fileTreeCount) {
            case 0:
                break;
            case 1:
                fileTreeCountHint = ( localizeWithPath(_moduleId, 1, "1 file tree"));
                break;
            default:
                fileTreeCountHint = ( localizeWithPath(_moduleId, 2, "{0} file trees", fileTreeCount));
                break;
        }
        const codeBlockCount = marked_1.lexer(element.response.asString()).filter(token => token.type === 'code')?.length ?? 0;
        switch (codeBlockCount) {
            case 0:
                label = accessibleViewHint ? ( localizeWithPath(
                    _moduleId,
                    3,
                    "{0} {1} {2}",
                    fileTreeCountHint,
                    element.response.asString(),
                    accessibleViewHint
                )) : ( localizeWithPath(_moduleId, 4, "{0} {1}", fileTreeCountHint, element.response.asString()));
                break;
            case 1:
                label = accessibleViewHint ? ( localizeWithPath(
                    _moduleId,
                    5,
                    "{0} 1 code block: {1} {2}",
                    fileTreeCountHint,
                    element.response.asString(),
                    accessibleViewHint
                )) : ( localizeWithPath(
                    _moduleId,
                    6,
                    "{0} 1 code block: {1}",
                    fileTreeCountHint,
                    element.response.asString()
                ));
                break;
            default:
                label = accessibleViewHint ? ( localizeWithPath(
                    _moduleId,
                    7,
                    "{0} {1} code blocks: {2}",
                    fileTreeCountHint,
                    codeBlockCount,
                    element.response.asString(),
                    accessibleViewHint
                )) : ( localizeWithPath(
                    _moduleId,
                    8,
                    "{0} {1} code blocks",
                    fileTreeCountHint,
                    codeBlockCount,
                    element.response.asString()
                ));
                break;
        }
        return label;
    }
};
ChatAccessibilityProvider = ( (__decorate([
    ( (__param(0, IAccessibleViewService)))
], ChatAccessibilityProvider)));
export { ChatAccessibilityProvider };
