import {
  NAMESPACE_CONFIG
} from "@nextsparkjs/registries/namespace-registry";
class NamespaceService {
  /**
   * Get core namespaces (excluding entity namespaces)
   *
   * @returns Array of core namespace names
   *
   * @example
   * ```typescript
   * const namespaces = NamespaceService.getCoreNamespaces()
   * // ['common', 'dashboard', 'settings', 'auth', 'public', 'validation', 'admin']
   * ```
   */
  static getCoreNamespaces() {
    return [...NAMESPACE_CONFIG.core];
  }
  /**
   * Get entity namespaces
   *
   * @returns Array of entity namespace names
   *
   * @example
   * ```typescript
   * const namespaces = NamespaceService.getEntityNamespaces()
   * // [] (empty if no entity namespaces configured)
   * ```
   */
  static getEntityNamespaces() {
    return [...NAMESPACE_CONFIG.entities];
  }
  /**
   * Get optimized namespaces based on route strategy
   *
   * Returns the namespace configuration for a specific route strategy.
   * Falls back to UNKNOWN_FALLBACK if strategy is not found.
   *
   * @param strategy - The route strategy name
   * @returns Namespace configuration for the strategy
   *
   * @example
   * ```typescript
   * const config = NamespaceService.getOptimizedNamespaces('DASHBOARD_AUTHENTICATED')
   * // { core: ['common', 'dashboard', ...], entities: [], strategy: 'DASHBOARD_AUTHENTICATED' }
   * ```
   */
  static getOptimizedNamespaces(strategy) {
    return NAMESPACE_CONFIG.routes[strategy] || NAMESPACE_CONFIG.routes["UNKNOWN_FALLBACK"];
  }
  /**
   * Detect route strategy based on pathname
   *
   * Analyzes the pathname to determine which route strategy should be used.
   * This affects which namespaces are loaded for i18n optimization.
   *
   * @param pathname - The URL pathname to analyze
   * @returns The detected route strategy
   *
   * @example
   * ```typescript
   * NamespaceService.detectRouteStrategy('/dashboard') // 'DASHBOARD_AUTHENTICATED'
   * NamespaceService.detectRouteStrategy('/login') // 'AUTH_ONLY'
   * NamespaceService.detectRouteStrategy('/pricing') // 'PUBLIC_INITIAL'
   * NamespaceService.detectRouteStrategy('/superadmin') // 'SUPERADMIN'
   * NamespaceService.detectRouteStrategy('/unknown') // 'UNKNOWN_FALLBACK'
   * ```
   */
  static detectRouteStrategy(pathname) {
    if (pathname.startsWith("/dashboard")) {
      return "DASHBOARD_AUTHENTICATED";
    }
    if (pathname.startsWith("/auth") || pathname === "/login" || pathname === "/signup" || pathname === "/forgot-password" || pathname === "/reset-password" || pathname === "/verify-email") {
      return "AUTH_ONLY";
    }
    const isPublicWithEntity = pathname === "/" || pathname.startsWith("/pricing") || pathname.startsWith("/docs") || pathname.startsWith("/support") || pathname.startsWith("/features") || NAMESPACE_CONFIG.entityPaths.some((path) => pathname.startsWith(path));
    if (isPublicWithEntity) {
      return "PUBLIC_INITIAL";
    }
    if (pathname.startsWith("/superadmin")) {
      return "SUPERADMIN";
    }
    return "UNKNOWN_FALLBACK";
  }
  /**
   * Get entity paths for namespace route detection
   *
   * @returns Array of entity paths used in route detection
   *
   * @example
   * ```typescript
   * const paths = NamespaceService.getEntityPaths()
   * // [] (empty if no entity paths configured)
   * ```
   */
  static getEntityPaths() {
    return [...NAMESPACE_CONFIG.entityPaths];
  }
  /**
   * Get all available route strategies
   *
   * @returns Array of all route strategy names
   *
   * @example
   * ```typescript
   * const strategies = NamespaceService.getStrategies()
   * // ['DASHBOARD_AUTHENTICATED', 'AUTH_ONLY', 'PUBLIC_INITIAL', 'SUPERADMIN', 'UNKNOWN_FALLBACK']
   * ```
   */
  static getStrategies() {
    return Object.keys(NAMESPACE_CONFIG.routes);
  }
  /**
   * Check if a route strategy exists
   *
   * @param strategy - The strategy name to check
   * @returns True if the strategy exists
   *
   * @example
   * ```typescript
   * NamespaceService.hasStrategy('DASHBOARD_AUTHENTICATED') // true
   * NamespaceService.hasStrategy('INVALID') // false
   * ```
   */
  static hasStrategy(strategy) {
    return strategy in NAMESPACE_CONFIG.routes;
  }
  /**
   * Get the full namespace configuration
   *
   * @returns The complete namespace configuration object
   *
   * @example
   * ```typescript
   * const config = NamespaceService.getConfig()
   * // { core: [...], entities: [...], routes: {...}, entityPaths: [...] }
   * ```
   */
  static getConfig() {
    return NAMESPACE_CONFIG;
  }
}
const getCoreNamespaces = NamespaceService.getCoreNamespaces;
const getEntityNamespaces = NamespaceService.getEntityNamespaces;
const getOptimizedNamespaces = NamespaceService.getOptimizedNamespaces;
const detectRouteStrategy = NamespaceService.detectRouteStrategy;
const getEntityNamespacePaths = NamespaceService.getEntityPaths;
export {
  NamespaceService,
  detectRouteStrategy,
  getCoreNamespaces,
  getEntityNamespacePaths,
  getEntityNamespaces,
  getOptimizedNamespaces
};
