
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
import { IExtensionTipsService } from '../../../../platform/extensionManagement/common/extensionManagement.service.js';
import { ExtensionRecommendations } from './extensionRecommendations.js';
import { localize } from '../../../../nls.js';
import { ExtensionRecommendationReason } from '../../../services/extensionRecommendations/common/extensionRecommendations.js';

let ExeBasedRecommendations = class ExeBasedRecommendations extends ExtensionRecommendations {
    get otherRecommendations() {
        return ( this._otherTips.map(tip => this.toExtensionRecommendation(tip)));
    }
    get importantRecommendations() {
        return ( this._importantTips.map(tip => this.toExtensionRecommendation(tip)));
    }
    get recommendations() {
        return [...this.importantRecommendations, ...this.otherRecommendations];
    }
    constructor(extensionTipsService) {
        super();
        this.extensionTipsService = extensionTipsService;
        this._otherTips = [];
        this._importantTips = [];
    }
    getRecommendations(exe) {
        const important = ( this._importantTips.filter(tip => tip.exeName.toLowerCase() === exe.toLowerCase()).map(tip => this.toExtensionRecommendation(tip)));
        const others = ( this._otherTips.filter(tip => tip.exeName.toLowerCase() === exe.toLowerCase()).map(tip => this.toExtensionRecommendation(tip)));
        return {
            important,
            others
        };
    }
    async doActivate() {
        this._otherTips = await this.extensionTipsService.getOtherExecutableBasedTips();
        await this.fetchImportantExeBasedRecommendations();
    }
    async fetchImportantExeBasedRecommendations() {
        if (!this._importantExeBasedRecommendations) {
            this._importantExeBasedRecommendations = this.doFetchImportantExeBasedRecommendations();
        }
        return this._importantExeBasedRecommendations;
    }
    async doFetchImportantExeBasedRecommendations() {
        const importantExeBasedRecommendations = ( new Map());
        this._importantTips = await this.extensionTipsService.getImportantExecutableBasedTips();
        this._importantTips.forEach(
            tip => importantExeBasedRecommendations.set(tip.extensionId.toLowerCase(), tip)
        );
        return importantExeBasedRecommendations;
    }
    toExtensionRecommendation(tip) {
        return {
            extension: tip.extensionId.toLowerCase(),
            reason: {
                reasonId: ExtensionRecommendationReason.Executable,
                reasonText: ( localize(
                    9634,
                    "This extension is recommended because you have {0} installed.",
                    tip.exeFriendlyName
                ))
            }
        };
    }
};
ExeBasedRecommendations = ( __decorate([( __param(0, IExtensionTipsService))], ExeBasedRecommendations));

export { ExeBasedRecommendations };
