import type { DomainTemplate } from './types.js'
import {
  getAllTemplates,
  getTemplate,
  getTemplatesByTag,
  getTemplatesByCategory,
  searchTemplates,
  getTemplateStats,
} from './meta/index.js'

/**
 * Registry of all available domain templates with their metadata.
 * This provides a central location for UI components to discover and present templates.
 *
 * The templates are pre-processed at build time using the generate-template-metadata.js script
 * to avoid loading and processing all templates on the client side.
 */
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
export class TemplateRegistry {
  /**
   * Gets all available templates
   */
  static getAllTemplates(): DomainTemplate[] {
    return getAllTemplates()
  }

  /**
   * Gets a template by its ID
   */
  static getTemplate(id: string): DomainTemplate | undefined {
    return getTemplate(id)
  }

  /**
   * Gets templates filtered by tags
   */
  static getTemplatesByTag(tag: string): DomainTemplate[] {
    return getTemplatesByTag(tag)
  }

  /**
   * Gets templates filtered by category (based on tags)
   */
  static getTemplatesByCategory(category: 'business' | 'content' | 'social' | 'technical'): DomainTemplate[] {
    return getTemplatesByCategory(category)
  }

  /**
   * Searches templates by name or description
   */
  static searchTemplates(query: string): DomainTemplate[] {
    return searchTemplates(query)
  }

  /**
   * Gets template statistics for analytics
   */
  static getTemplateStats(): {
    totalTemplates: number
    totalEntities: number
    totalProperties: number
    totalAssociations: number
    categoryCounts: Record<string, number>
  } {
    return getTemplateStats()
  }
}
