// Renderer-side autostart adapter. Replaces the Tauri version, which
// imported from `@tauri-apps/plugin-autostart`. We route through the
// Electron preload bridge to `app.setLoginItemSettings()` in the main
// process — the OS-native login-items mechanism (Windows registry Run
// key, macOS LaunchAgent, Linux .desktop entry).

import { isTauriRuntime } from './globalShortcut';

export async function isAutoStartEnabled(): Promise<boolean> {
  if (!isTauriRuntime()) return false;
  try {
    return await window.electronAPI.isAutoStartEnabled();
  } catch {
    return false;
  }
}

export async function setAutoStart(enabled: boolean): Promise<void> {
  if (!isTauriRuntime()) return;
  await window.electronAPI.setAutoStart(enabled);
}
