"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
const default_fetcher_1 = require("@pnpm/default-fetcher");
const default_resolver_1 = require("@pnpm/default-resolver");
const LRU = require("lru-cache");
const package_store_1 = require("package-store");
const path = require("path");
exports.default = (opts) => __awaiter(this, void 0, void 0, function* () {
    const sopts = Object.assign(opts, {
        locks: opts.lock ? path.join(opts.store, '_locks') : undefined,
        registry: opts.registry || 'https://registry.npmjs.org/',
    });
    const resolve = default_resolver_1.default(Object.assign(sopts, {
        fullMetadata: false,
        metaCache: LRU({
            max: 10000,
            maxAge: 120 * 1000,
        }),
    }));
    const fetchers = default_fetcher_1.default(sopts);
    return {
        ctrl: yield package_store_1.default(resolve, fetchers, {
            lockStaleDuration: sopts.lockStaleDuration,
            locks: sopts.locks,
            networkConcurrency: sopts.networkConcurrency,
            packageImportMethod: sopts.packageImportMethod,
            store: sopts.store,
        }),
        path: sopts.store,
    };
});
//# sourceMappingURL=createStore.js.map