"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) {
    const rootModulesDir = await utils_1.realNodeModulesDir(lockfileDirectory);
    const modules = await modules_yaml_1.read(rootModulesDir);
    return {
        currentHoistPattern: modules && modules.hoistPattern || undefined,
        hoist: !modules ? undefined : Boolean(modules.hoistPattern),
        hoistedAliases: modules && modules.hoistedAliases || {},
        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);
            return {
                ...importer,
                bin: importer.bin || path.join(importer.prefix, 'node_modules', '.bin'),
                id: importerId,
                modulesDir,
            };
        })),
        include: modules && modules.included || { dependencies: true, devDependencies: true, optionalDependencies: true },
        independentLeaves: modules && modules.independentLeaves || undefined,
        modules,
        pendingBuilds: modules && modules.pendingBuilds || [],
        registries: modules && modules.registries && utils_1.normalizeRegistries(modules.registries),
        rootModulesDir,
        shamefullyHoist: modules && modules.shamefullyHoist || undefined,
        skipped: new Set(modules && modules.skipped || []),
    };
}
exports.default = default_1;
