import 'autopilot_theme.dart';
import 'themes/light_theme.dart';
import 'themes/cyan_theme.dart';
import 'themes/wine_theme.dart';
import 'themes/ochre_theme.dart';

/// Central registry of all factory [AutopilotTheme]s.
///
/// Themes are keyed by their [AutopilotTheme.id] string.
///
/// ## Display order
/// `light → cyan → wine → ochre` (shown in the Appearance selector grid).
///
/// ## Custom themes (Sprint 9 / Tier 3)
/// Architecture is ready for integrators to ship custom YAML themes in
/// `/config/themes/*.yaml`. [ThemeRegistry] will merge them with the
/// factory set at startup. Not active until Sprint 9.
abstract final class ThemeRegistry {
  /// Theme id used when no preference is stored (first run).
  static const String defaultId = 'cyan';

  static final Map<String, AutopilotTheme> _registry = {
    lightTheme.id: lightTheme,
    cyanTheme.id: cyanTheme,
    wineTheme.id: wineTheme,
    ochreTheme.id: ochreTheme,
  };

  /// All available themes in UI display order.
  static List<AutopilotTheme> get all => const [
        lightTheme,
        cyanTheme,
        wineTheme,
        ochreTheme,
      ];

  /// Returns the theme for [id].
  /// Falls back to [defaultId] (cyan) if [id] is not registered.
  static AutopilotTheme byId(String id) =>
      _registry[id] ?? _registry[defaultId]!;

  /// Whether [id] belongs to a registered theme.
  static bool contains(String id) => _registry.containsKey(id);
}
