// src/cli/paths.ts
import { homedir, platform } from "os";
import { join } from "path";
import { mkdir, access } from "fs/promises";
function getGlobalConfigDir(mode) {
  if (mode === "test") {
    return join(process.cwd(), "e2e", ".openfox-test");
  }
  const suffix = mode === "development" ? "-dev" : "";
  const home = homedir();
  switch (platform()) {
    case "darwin":
      return join(home, "Library", "Application Support", `openfox${suffix}`);
    case "win32":
      return join(process.env["APPDATA"] ?? join(home, "AppData", "Roaming"), `openfox${suffix}`);
    default:
      return join(process.env["XDG_CONFIG_HOME"] ?? join(home, ".config"), `openfox${suffix}`);
  }
}
function getGlobalConfigPath(mode) {
  return join(getGlobalConfigDir(mode), "config.json");
}
function getAuthConfigPath(mode) {
  return join(getGlobalConfigDir(mode), "auth.json");
}
function getAuthKeyPath(mode) {
  return join(getGlobalConfigDir(mode), "auth.key");
}
function getGlobalDataDir(mode) {
  const suffix = mode === "development" ? "-dev" : "";
  const home = homedir();
  switch (platform()) {
    case "darwin":
      return join(home, "Library", "Application Support", `openfox${suffix}`);
    case "win32":
      return join(process.env["LOCALAPPDATA"] ?? join(home, "AppData", "Local"), `openfox${suffix}`);
    default:
      return join(process.env["XDG_DATA_HOME"] ?? join(home, ".local", "share"), `openfox${suffix}`);
  }
}
function getDatabasePath(mode) {
  return join(getGlobalDataDir(mode), "sessions.db");
}
function getSkillsDir(mode) {
  return join(getGlobalConfigDir(mode), "skills");
}
async function ensureDataDirExists(mode) {
  const dataDir = getGlobalDataDir(mode);
  try {
    await access(dataDir);
  } catch {
    await mkdir(dataDir, { recursive: true });
  }
}

export {
  getGlobalConfigDir,
  getGlobalConfigPath,
  getAuthConfigPath,
  getAuthKeyPath,
  getGlobalDataDir,
  getDatabasePath,
  getSkillsDir,
  ensureDataDirExists
};
//# sourceMappingURL=chunk-CQGTEGKL.js.map