import { homedir, platform } from "node:os";
import { join } from "node:path";
/**
 * Returns the OS-specific config directory for PocketCoder.
 *
 * Can be overridden with POCKETCODER_CONFIG_DIR environment variable (for testing).
 *
 * macOS:   ~/Library/Application Support/pocketcoder
 * Linux:   ~/.config/pocketcoder
 * Windows: %APPDATA%/pocketcoder
 */
export function getConfigDir() {
    // Allow override for testing
    if (process.env.POCKETCODER_CONFIG_DIR) {
        return process.env.POCKETCODER_CONFIG_DIR;
    }
    const os = platform();
    switch (os) {
        case "darwin":
            return join(homedir(), "Library", "Application Support", "pocketcoder");
        case "win32":
            return join(process.env.APPDATA ?? join(homedir(), "AppData", "Roaming"), "pocketcoder");
        default:
            // Linux and other Unix-like systems
            return join(process.env.XDG_CONFIG_HOME ?? join(homedir(), ".config"), "pocketcoder");
    }
}
/** Returns path to auth.json within the config directory. */
export function getAuthPath() {
    return join(getConfigDir(), "auth.json");
}
/** Returns path to daemon.db within the config directory. */
export function getDbPath() {
    return join(getConfigDir(), "daemon.db");
}
/** Returns path to logs directory. */
export function getLogDir() {
    // Use config dir if overridden (for testing), otherwise use ~/.pocketcoder/logs
    if (process.env.POCKETCODER_CONFIG_DIR) {
        return join(process.env.POCKETCODER_CONFIG_DIR, "logs");
    }
    return join(homedir(), ".pocketcoder", "logs");
}
/** Returns path to daemon.pid file. */
export function getPidPath() {
    // Use config dir if overridden (for testing), otherwise use ~/.pocketcoder/
    if (process.env.POCKETCODER_CONFIG_DIR) {
        return join(process.env.POCKETCODER_CONFIG_DIR, "daemon.pid");
    }
    return join(homedir(), ".pocketcoder", "daemon.pid");
}
//# sourceMappingURL=paths.js.map