"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const most = require("most");
const COMMANDS_THAT_REPORT_SCOPE = new Set([
    'install',
    'link',
    'prune',
    'rebuild',
    'uninstall',
    'unlink',
    'update',
    'run',
    'test',
]);
exports.default = (scope$, opts) => {
    if (!opts.isRecursive && !COMMANDS_THAT_REPORT_SCOPE.has(opts.cmd) ||
        opts.isRecursive && (!opts.subCmd || !COMMANDS_THAT_REPORT_SCOPE.has(opts.subCmd))) {
        return most.never();
    }
    return scope$
        .take(1)
        .map((log) => {
        if (log.selected === 1 && typeof log.total !== 'number') {
            if (!log.workspacePrefix)
                return most.never();
            if (!opts.isRecursive)
                return most.of({ msg: 'Scope: current workspace package' });
        }
        let msg = `Scope: `;
        if (log.selected === log.total) {
            msg += `all ${log.total}`;
        }
        else {
            msg += `${log.selected}`;
            if (log.total) {
                msg += ` of ${log.total}`;
            }
        }
        if (log.workspacePrefix) {
            msg += ' workspace packages';
        }
        else {
            msg += ' packages';
        }
        return most.of({ msg });
    });
};
