import {
  THEME_REGISTRY,
  THEME_METADATA
} from "@nextsparkjs/registries/theme-registry";
class ThemeService {
  /**
   * Get all registered themes
   * @returns Array of ThemeConfig
   * @complexity O(n) where n = number of themes
   */
  static getAll() {
    return Object.values(THEME_REGISTRY).map((entry) => entry.config);
  }
  /**
   * Get theme by name
   * @complexity O(1)
   */
  static getByName(name) {
    var _a;
    return (_a = THEME_REGISTRY[name]) == null ? void 0 : _a.config;
  }
  /**
   * Get full registry entry by name
   * @complexity O(1)
   */
  static getEntry(name) {
    return THEME_REGISTRY[name];
  }
  /**
   * Get dashboard config for a theme
   * @complexity O(1)
   */
  static getDashboardConfig(name) {
    var _a;
    return (_a = THEME_REGISTRY[name]) == null ? void 0 : _a.dashboardConfig;
  }
  /**
   * Get app config for a theme
   * @complexity O(1)
   */
  static getAppConfig(name) {
    var _a;
    return (_a = THEME_REGISTRY[name]) == null ? void 0 : _a.appConfig;
  }
  /**
   * Get dev config for a theme
   * Contains development-only settings like DevKeyring
   * @complexity O(1)
   */
  static getDevConfig(name) {
    var _a;
    return ((_a = THEME_REGISTRY[name]) == null ? void 0 : _a.devConfig) ?? null;
  }
  /**
   * Get themes with entities
   * @complexity O(n)
   */
  static getWithEntities() {
    return Object.values(THEME_REGISTRY).filter(
      (entry) => entry.entities && entry.entities.length > 0
    );
  }
  /**
   * Get themes with API routes
   * @complexity O(n)
   */
  static getWithRoutes() {
    return Object.values(THEME_REGISTRY).filter(
      (entry) => entry.routeFiles && entry.routeFiles.length > 0
    );
  }
  /**
   * Get themes using a specific plugin
   * @complexity O(n)
   */
  static getUsingPlugin(pluginName) {
    return Object.values(THEME_REGISTRY).filter(
      (entry) => entry.plugins && entry.plugins.includes(pluginName)
    );
  }
  /**
   * Get plugin usage across all themes
   * @complexity O(n)
   */
  static getPluginUsage(pluginName) {
    return Object.values(THEME_REGISTRY).filter((entry) => entry.plugins && entry.plugins.includes(pluginName)).map((entry) => {
      var _a, _b;
      return {
        theme: entry.name,
        entities: ((_a = entry.entities) == null ? void 0 : _a.length) || 0,
        routes: ((_b = entry.routeFiles) == null ? void 0 : _b.length) || 0
      };
    });
  }
  /**
   * Check if theme exists
   * @complexity O(1)
   */
  static exists(name) {
    return name in THEME_REGISTRY;
  }
  /**
   * Get theme names
   * @complexity O(1) - uses pre-computed metadata
   */
  static getNames() {
    return THEME_METADATA.themes;
  }
  /**
   * Get total theme count
   * @complexity O(1) - uses pre-computed metadata
   */
  static getCount() {
    return THEME_METADATA.totalThemes;
  }
  /**
   * Get metadata
   * @complexity O(1)
   */
  static getMetadata() {
    return THEME_METADATA;
  }
}
const getRegisteredThemes = ThemeService.getAll;
const getTheme = ThemeService.getByName;
const getThemeDashboardConfig = ThemeService.getDashboardConfig;
const getThemeAppConfig = ThemeService.getAppConfig;
const getThemeDevConfig = ThemeService.getDevConfig;
const getThemesWithEntities = ThemeService.getWithEntities;
const getThemesWithRoutes = ThemeService.getWithRoutes;
const getThemesUsingPlugin = ThemeService.getUsingPlugin;
const getPluginUsage = ThemeService.getPluginUsage;
export {
  ThemeService,
  getPluginUsage,
  getRegisteredThemes,
  getTheme,
  getThemeAppConfig,
  getThemeDashboardConfig,
  getThemeDevConfig,
  getThemesUsingPlugin,
  getThemesWithEntities,
  getThemesWithRoutes
};
