import { resolve } from 'node:path';
const projectConfigCache = new Map();
const projectConfigTraceCache = new Map();
const resolvedValueCache = new Map();
function normalizeProjectDir(projectDir) {
    return resolve(projectDir);
}
function resolvedValueKey(projectDir, key) {
    return `${normalizeProjectDir(projectDir)}::${key}`;
}
export function getCachedProjectConfig(projectDir) {
    return projectConfigCache.get(normalizeProjectDir(projectDir));
}
export function setCachedProjectConfig(projectDir, config) {
    projectConfigCache.set(normalizeProjectDir(projectDir), config);
}
export function getCachedProjectConfigTrace(projectDir) {
    return projectConfigTraceCache.get(normalizeProjectDir(projectDir));
}
export function setCachedProjectConfigTrace(projectDir, trace) {
    projectConfigTraceCache.set(normalizeProjectDir(projectDir), trace);
}
export function hasCachedResolvedValue(projectDir, key) {
    return resolvedValueCache.has(resolvedValueKey(projectDir, key));
}
export function getCachedResolvedValue(projectDir, key) {
    return resolvedValueCache.get(resolvedValueKey(projectDir, key));
}
export function setCachedResolvedValue(projectDir, key, value) {
    resolvedValueCache.set(resolvedValueKey(projectDir, key), value);
}
export function invalidateResolvedConfigCache(projectDir) {
    const normalizedProjectDir = normalizeProjectDir(projectDir);
    projectConfigCache.delete(normalizedProjectDir);
    projectConfigTraceCache.delete(normalizedProjectDir);
    const prefix = `${normalizedProjectDir}::`;
    for (const key of resolvedValueCache.keys()) {
        if (key.startsWith(prefix)) {
            resolvedValueCache.delete(key);
        }
    }
}
export function invalidateAllResolvedConfigCache() {
    projectConfigCache.clear();
    projectConfigTraceCache.clear();
    resolvedValueCache.clear();
}
//# sourceMappingURL=resolutionCache.js.map