"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.toMynahIcon = toMynahIcon;
exports.toMynahButtons = toMynahButtons;
exports.toMynahHeader = toMynahHeader;
exports.toMynahFileList = toMynahFileList;
exports.toDetailsWithoutIcon = toDetailsWithoutIcon;
exports.toMynahContextCommand = toMynahContextCommand;
const mynah_ui_1 = require("@aws/mynah-ui");
function toMynahIcon(icon) {
    return icon && Object.values(mynah_ui_1.MynahIcons).includes(icon) ? icon : undefined;
}
function toMynahButtons(buttons) {
    return buttons?.map(button => ({ ...button, icon: toMynahIcon(button.icon) }));
}
function toMynahHeader(header) {
    if (!header)
        return undefined;
    return {
        ...header,
        icon: toMynahIcon(header.icon),
        buttons: toMynahButtons(header.buttons),
        status: header.status ? { ...header.status, icon: toMynahIcon(header.status.icon) } : undefined,
    };
}
function toMynahFileList(fileList) {
    if (!fileList)
        return undefined;
    const fileListTree = {
        fileTreeTitle: '',
        filePaths: fileList.filePaths?.map(file => file),
        rootFolderTitle: fileList.rootFolderTitle ?? 'Context',
        flatList: true,
        hideFileCount: true,
        collapsed: true,
        details: Object.fromEntries(Object.entries(fileList.details || {}).map(([filePath, fileDetails]) => [
            filePath,
            {
                label: fileDetails.lineRanges
                    ?.map(range => range.first === -1 || range.second === -1 ? '' : `line ${range.first} - ${range.second}`)
                    .join(', ') || '',
                description: fileDetails.description,
                clickable: true,
                data: {
                    fullPath: fileDetails.fullPath || '',
                },
            },
        ])),
    };
    return fileListTree;
}
function toDetailsWithoutIcon(details) {
    return Object.fromEntries(Object.entries(details || {}).map(([filePath, fileDetails]) => [filePath, { ...fileDetails, icon: null }]));
}
function toMynahContextCommand(feature) {
    if (!feature || !feature.value.stringValue) {
        return {};
    }
    return {
        command: feature.value.stringValue,
        description: feature.variation,
    };
}
//# sourceMappingURL=utils.js.map