// Settings store — thin accessor over BackendAdapter for settings persistence.
// Replaces the old settings-bridge.ts (which imported Tauri invoke directly).
// All consumers should import from here instead of settings-bridge.

import { getBackend } from '../backend/backend';

/**
 * Get a setting value by key. Returns null if not found.
 */
export async function getSetting(key: string): Promise<string | null> {
  return getBackend().getSetting(key);
}

/**
 * Set a setting value by key.
 */
export async function setSetting(key: string, value: string): Promise<void> {
  return getBackend().setSetting(key, value);
}

/**
 * Get all settings as a key-value map.
 * Note: returns Record<string, string> (SettingsMap), not [string, string][].
 * Callers that used listSettings() should adapt to the map format.
 */
export async function getAllSettings(): Promise<Record<string, string>> {
  return getBackend().getAllSettings();
}

// Re-export for backward compat with code that imported listSettings
export { getAllSettings as listSettings };
