"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const lockfile_file_1 = require("@pnpm/lockfile-file");
const modules_yaml_1 = require("@pnpm/modules-yaml");
const utils_1 = require("@pnpm/utils");
const path = require("path");
async function default_1(importers, lockfileDirectory, opts) {
    const virtualStoreDir = await utils_1.realNodeModulesDir(lockfileDirectory);
    const modules = await modules_yaml_1.read(virtualStoreDir);
    return {
        importers: await Promise.all(importers.map(async (importer) => {
            const modulesDir = await utils_1.realNodeModulesDir(importer.prefix);
            const importerId = lockfile_file_1.getLockfileImporterId(lockfileDirectory, importer.prefix);
            const importerModules = modules && modules.importers[importerId];
            return Object.assign({}, importer, { bin: importer.bin || path.join(importer.prefix, 'node_modules', '.bin'), currentShamefullyFlatten: importerModules && importerModules.shamefullyFlatten, hoistedAliases: importerModules && importerModules.hoistedAliases || {}, id: importerId, modulesDir, shamefullyFlatten: Boolean(typeof importer.shamefullyFlatten === 'boolean' ? importer.shamefullyFlatten : opts.shamefullyFlatten) });
        })),
        include: modules && modules.included || { dependencies: true, devDependencies: true, optionalDependencies: true },
        modules,
        pendingBuilds: modules && modules.pendingBuilds || [],
        registries: modules && modules.registries && utils_1.normalizeRegistries(modules.registries),
        skipped: new Set(modules && modules.skipped || []),
        virtualStoreDir,
    };
}
exports.default = default_1;
