
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
import { IExtensionService } from '../../../services/extensions/common/extensions.service.js';
import { ProgressLocation } from '../../../../platform/progress/common/progress.js';
import { IProgressService } from '../../../../platform/progress/common/progress.service.js';
import { localize } from '../../../../nls.js';
import { DeferredPromise, timeout } from '../../../../base/common/async.js';
import { ILogService } from '../../../../platform/log/common/log.service.js';
import { CancellationToken } from '../../../../base/common/cancellation.js';

let ExtensionActivationProgress = class ExtensionActivationProgress {
    constructor(extensionService, progressService, logService) {
        const options = {
            location: ProgressLocation.Window,
            title: ( localize(10027, "Activating Extensions..."))
        };
        let deferred;
        let count = 0;
        this._listener = extensionService.onWillActivateByEvent(e => {
            logService.trace("onWillActivateByEvent: ", e.event);
            if (!deferred) {
                deferred = ( new DeferredPromise());
                progressService.withProgress(options, _ => deferred.p);
            }
            count++;
            Promise.race([e.activation, timeout(5000, CancellationToken.None)]).finally(() => {
                if (--count === 0) {
                    deferred.complete(undefined);
                    deferred = undefined;
                }
            });
        });
    }
    dispose() {
        this._listener.dispose();
    }
};
ExtensionActivationProgress = ( __decorate([( __param(0, IExtensionService)), ( __param(1, IProgressService)), ( __param(2, ILogService))], ExtensionActivationProgress));

export { ExtensionActivationProgress };
