"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(projects, lockfileDir) {
    const rootModulesDir = await utils_1.realNodeModulesDir(lockfileDir);
    const modules = await modules_yaml_1.read(rootModulesDir);
    return {
        currentHoistPattern: (modules === null || modules === void 0 ? void 0 : modules.hoistPattern) || undefined,
        hoist: !modules ? undefined : Boolean(modules.hoistPattern),
        hoistedAliases: (modules === null || modules === void 0 ? void 0 : modules.hoistedAliases) || {},
        include: (modules === null || modules === void 0 ? void 0 : modules.included) || { dependencies: true, devDependencies: true, optionalDependencies: true },
        independentLeaves: (modules === null || modules === void 0 ? void 0 : modules.independentLeaves) || undefined,
        modules,
        pendingBuilds: (modules === null || modules === void 0 ? void 0 : modules.pendingBuilds) || [],
        projects: await Promise.all(projects.map(async (project) => {
            const modulesDir = await utils_1.realNodeModulesDir(project.rootDir);
            const importerId = lockfile_file_1.getLockfileImporterId(lockfileDir, project.rootDir);
            return {
                ...project,
                binsDir: project.binsDir || path.join(project.rootDir, 'node_modules', '.bin'),
                id: importerId,
                modulesDir,
            };
        })),
        registries: (modules === null || modules === void 0 ? void 0 : modules.registries) && utils_1.normalizeRegistries(modules.registries),
        rootModulesDir,
        shamefullyHoist: (modules === null || modules === void 0 ? void 0 : modules.shamefullyHoist) || undefined,
        skipped: new Set((modules === null || modules === void 0 ? void 0 : modules.skipped) || []),
    };
}
exports.default = default_1;
