import { join } from 'node:path';
export function requireSurfaceRoot(surfaceRoot, source = 'surfaceRoot') {
    const normalized = surfaceRoot.trim();
    if (!normalized || normalized.includes('/') || normalized.includes('\\') || normalized === '.' || normalized === '..') {
        throw new Error(`${source} must be a single non-empty path segment.`);
    }
    return normalized;
}
export function resolveSurfaceDirectory(baseDirectory, surfaceRoot, ...segments) {
    return join(baseDirectory, '.goodvibes', requireSurfaceRoot(surfaceRoot), ...segments);
}
export function resolveSurfaceSharedFile(baseDirectory, surfaceRoot, extension = 'json') {
    return join(baseDirectory, '.goodvibes', `${requireSurfaceRoot(surfaceRoot)}.${extension}`);
}
export function resolveSharedDirectory(baseDirectory, ...segments) {
    return join(baseDirectory, '.goodvibes', ...segments);
}
export function resolveScopedDirectory(baseDirectory, surfaceRoot, ...segments) {
    return surfaceRoot && surfaceRoot.trim().length > 0
        ? resolveSurfaceDirectory(baseDirectory, surfaceRoot, ...segments)
        : resolveSharedDirectory(baseDirectory, ...segments);
}
