import { execFileSync } from "child_process";
import { LaunchdBackend } from "./launchd.js";
import { SystemdBackend } from "./systemd.js";
import { CrontabBackend } from "./crontab.js";
import { GithubBackend } from "./github.js";
export function detectBackend() {
    if (process.platform === "darwin")
        return "launchd";
    try {
        // execFileSync throws if `which` exits non-zero (systemctl not found) or ENOENT
        execFileSync("which", ["systemctl"], { stdio: "pipe" });
        return "systemd";
    }
    catch {
        return "crontab";
    }
}
export function getBackend(type) {
    switch (type) {
        case "launchd":
            return new LaunchdBackend();
        case "systemd":
            return new SystemdBackend();
        case "crontab":
            return new CrontabBackend();
        case "github":
            return new GithubBackend();
    }
}
export { LaunchdBackend } from "./launchd.js";
export { SystemdBackend } from "./systemd.js";
export { CrontabBackend } from "./crontab.js";
export { GithubBackend } from "./github.js";
