"use strict";
const node_path_1 = require("node:path");
const ENV_1 = require("./ENV");
const WIN32_1 = require("./WIN32");
// Yarn cache directory paths.
// Yarn Classic (v1) and Yarn Berry (v2+) use different cache locations.
//
// Yarn Classic (v1):
// - macOS/Linux: ~/.cache/yarn
// - Windows: %LOCALAPPDATA%/Yarn/Cache
//
// Yarn Berry (v2+):
// - Uses .yarn/cache in the project directory by default
// - Can be configured via yarnPath in .yarnrc.yml
//
// Can be overridden by:
// - YARN_CACHE_FOLDER environment variable (Classic)
// - cacheFolder setting in .yarnrc.yml (Berry)
//
// Documentation:
// - Classic: https://classic.yarnpkg.com/en/docs/cli/cache
// - Berry: https://yarnpkg.com/configuration/yarnrc#cacheFolder
function getYarnCachePaths() {
    const paths = {
        __proto__: null,
        classic: '',
        berry: '.yarn/cache',
    };
    // Check for explicit YARN_CACHE_FOLDER environment variable (Yarn Classic).
    const yarnCacheFolder = process.env['YARN_CACHE_FOLDER'];
    if (yarnCacheFolder) {
        paths.classic = yarnCacheFolder;
        return paths;
    }
    if (WIN32_1) {
        // On Windows, Yarn Classic uses LOCALAPPDATA.
        paths.classic = ENV_1.LOCALAPPDATA
            ? node_path_1.join(ENV_1.LOCALAPPDATA, 'Yarn', 'Cache')
            : '';
    }
    else {
        // On Unix-like systems, Yarn Classic uses ~/.cache/yarn.
        paths.classic = ENV_1.HOME ? node_path_1.join(ENV_1.HOME, '.cache', 'yarn') : '';
    }
    return paths;
}
module.exports = getYarnCachePaths();
