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 { IAccessibleViewService } from '../../accessibility/browser/accessibleView.js';
import { isRequestVM, isResponseVM, isWelcomeVM } from '../common/chatViewModel.js';
let ChatAccessibilityProvider = class ChatAccessibilityProvider {
    constructor(_accessibleViewService) {
        this._accessibleViewService = _accessibleViewService;
    }
    getWidgetRole() {
        return 'list';
    }
    getRole(element) {
        return 'listitem';
    }
    getWidgetAriaLabel() {
        return ( localizeWithPath(
            'vs/workbench/contrib/chat/browser/chatAccessibilityProvider',
            'chat',
            "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("accessibility.verbosity.panelChat" );
        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(
                    'vs/workbench/contrib/chat/browser/chatAccessibilityProvider',
                    'singleFileTreeHint',
                    "1 file tree"
                ));
                break;
            default:
                fileTreeCountHint = ( localizeWithPath(
                    'vs/workbench/contrib/chat/browser/chatAccessibilityProvider',
                    'multiFileTreeHint',
                    "{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(
                    'vs/workbench/contrib/chat/browser/chatAccessibilityProvider',
                    'noCodeBlocksHint',
                    "{0} {1} {2}",
                    fileTreeCountHint,
                    element.response.asString(),
                    accessibleViewHint
                )) : ( localizeWithPath(
                    'vs/workbench/contrib/chat/browser/chatAccessibilityProvider',
                    'noCodeBlocks',
                    "{0} {1}",
                    fileTreeCountHint,
                    element.response.asString()
                ));
                break;
            case 1:
                label = accessibleViewHint ? ( localizeWithPath(
                    'vs/workbench/contrib/chat/browser/chatAccessibilityProvider',
                    'singleCodeBlockHint',
                    "{0} 1 code block: {1} {2}",
                    fileTreeCountHint,
                    element.response.asString(),
                    accessibleViewHint
                )) : ( localizeWithPath(
                    'vs/workbench/contrib/chat/browser/chatAccessibilityProvider',
                    'singleCodeBlock',
                    "{0} 1 code block: {1}",
                    fileTreeCountHint,
                    element.response.asString()
                ));
                break;
            default:
                label = accessibleViewHint ? ( localizeWithPath(
                    'vs/workbench/contrib/chat/browser/chatAccessibilityProvider',
                    'multiCodeBlockHint',
                    "{0} {1} code blocks: {2}",
                    fileTreeCountHint,
                    codeBlockCount,
                    element.response.asString(),
                    accessibleViewHint
                )) : ( localizeWithPath(
                    'vs/workbench/contrib/chat/browser/chatAccessibilityProvider',
                    'multiCodeBlock',
                    "{0} {1} code blocks",
                    fileTreeCountHint,
                    codeBlockCount,
                    element.response.asString()
                ));
                break;
        }
        return label;
    }
};
ChatAccessibilityProvider = ( __decorate([
    ( __param(0, IAccessibleViewService))
], ChatAccessibilityProvider));
export { ChatAccessibilityProvider };
