{"version":3,"file":"catch-all-routes.mjs","sources":["../../../../src/lib/routing/advanced/catch-all-routes.ts"],"sourcesContent":["/**\n * @file Catch-All Routes Support\n * @description Implements advanced catch-all routing patterns with full type safety.\n * Supports both required and optional catch-all segments with segment parsing.\n *\n * @module @/lib/routing/advanced/catch-all-routes\n *\n * This module provides:\n * - Catch-all route definitions\n * - Segment parsing and extraction\n * - Type-safe catch-all params\n * - Priority ordering for catch-all routes\n * - Fallback handling\n *\n * @example\n * ```typescript\n * import { CatchAllRoute, createCatchAllRoute } from '@/lib/routing/advanced/catch-all-routes';\n *\n * const docsRoute = createCatchAllRoute({\n *   basePath: '/docs',\n *   paramName: 'slug',\n *   optional: false,\n *   component: DocsPage,\n * });\n *\n * const segments = docsRoute.parseSegments('/docs/getting-started/installation');\n * // ['getting-started', 'installation']\n * ```\n */\n\nimport type { ComponentType } from 'react';\n\n// =============================================================================\n// Types\n// =============================================================================\n\n/**\n * Catch-all route configuration\n */\nexport interface CatchAllRouteConfig<TProps = unknown> {\n  /** Base path before the catch-all segment */\n  readonly basePath: string;\n  /** Parameter name for the catch-all segments */\n  readonly paramName: string;\n  /** Whether the catch-all is optional (can match basePath alone) */\n  readonly optional: boolean;\n  /** Component to render */\n  readonly component: ComponentType<TProps & CatchAllRouteProps>;\n  /** Loading component */\n  readonly loading?: ComponentType;\n  /** Error component */\n  readonly error?: ComponentType<{ error: Error }>;\n  /** Not found component (for failed lookups) */\n  readonly notFound?: ComponentType;\n  /** Segment validator */\n  readonly validateSegment?: (segment: string) => boolean;\n  /** Transform segments before passing to component */\n  readonly transformSegments?: (segments: string[]) => string[];\n  /** Maximum allowed segments */\n  readonly maxSegments?: number;\n  /** Minimum required segments (for optional catch-all) */\n  readonly minSegments?: number;\n  /** Allowed segment patterns (regex) */\n  readonly allowedPatterns?: readonly RegExp[];\n  /** Denied segment patterns (regex) */\n  readonly deniedPatterns?: readonly RegExp[];\n  /** Metadata for the route */\n  readonly meta?: CatchAllRouteMeta;\n  /** Feature flag for this route */\n  readonly featureFlag?: string;\n}\n\n/**\n * Props passed to catch-all route component\n */\nexport interface CatchAllRouteProps {\n  /** Array of captured path segments */\n  readonly segments: readonly string[];\n  /** Joined path from segments */\n  readonly joinedPath: string;\n  /** Number of segments */\n  readonly depth: number;\n  /** Whether this is the base path (empty segments) */\n  readonly isBase: boolean;\n  /** Full matched path */\n  readonly fullPath: string;\n  /** Original params object */\n  readonly params: Record<string, string>;\n}\n\n/**\n * Catch-all route metadata\n */\nexport interface CatchAllRouteMeta {\n  /** Route title template */\n  readonly title?: string;\n  /** Route description */\n  readonly description?: string;\n  /** Whether to index in sitemap */\n  readonly indexable?: boolean;\n  /** Custom metadata */\n  readonly custom?: Record<string, unknown>;\n}\n\n/**\n * Catch-all match result\n */\nexport interface CatchAllMatch {\n  /** Whether the path matches */\n  readonly matches: boolean;\n  /** Captured segments */\n  readonly segments: readonly string[];\n  /** Validation errors (if any) */\n  readonly errors: readonly CatchAllError[];\n  /** Match score for priority sorting */\n  readonly score: number;\n  /** Computed props for component */\n  readonly props: CatchAllRouteProps | null;\n}\n\n/**\n * Catch-all validation error\n */\nexport interface CatchAllError {\n  /** Error type */\n  readonly type: 'invalid-segment' | 'too-many-segments' | 'too-few-segments' | 'pattern-violation';\n  /** Error message */\n  readonly message: string;\n  /** Problematic segment (if applicable) */\n  readonly segment?: string;\n  /** Segment index (if applicable) */\n  readonly index?: number;\n}\n\n/**\n * Registered catch-all route\n */\nexport interface RegisteredCatchAllRoute {\n  /** Unique route ID */\n  readonly id: string;\n  /** Route configuration */\n  readonly config: CatchAllRouteConfig;\n  /** Compiled pattern for matching */\n  readonly pattern: CatchAllPattern;\n  /** Registration timestamp */\n  readonly registeredAt: number;\n}\n\n/**\n * Compiled catch-all pattern\n */\nexport interface CatchAllPattern {\n  /** Base path regex */\n  readonly baseRegex: RegExp;\n  /** Full path regex */\n  readonly fullRegex: RegExp;\n  /** Static prefix length */\n  readonly staticPrefixLength: number;\n}\n\n// =============================================================================\n// CatchAllRoute Class\n// =============================================================================\n\n/**\n * Manages a single catch-all route\n *\n * @example\n * ```typescript\n * const route = new CatchAllRoute({\n *   basePath: '/blog',\n *   paramName: 'slug',\n *   optional: true,\n *   component: BlogPage,\n * });\n *\n * if (route.matches('/blog/2024/01/hello-world')) {\n *   const segments = route.parseSegments('/blog/2024/01/hello-world');\n *   // ['2024', '01', 'hello-world']\n * }\n * ```\n */\nexport class CatchAllRoute {\n  private readonly config: CatchAllRouteConfig;\n  private readonly pattern: CatchAllPattern;\n\n  constructor(config: CatchAllRouteConfig) {\n    this.config = {\n      ...config,\n      maxSegments: config.maxSegments ?? 50,\n      minSegments: config.minSegments ?? 0,\n    };\n    this.pattern = this.compilePattern(config);\n  }\n\n  /**\n   * Check if a path matches this catch-all route\n   *\n   * @param path - URL path to check\n   * @returns True if path matches\n   */\n  matches(path: string): boolean {\n    const normalizedPath = path.replace(/\\/$/, '') || '/';\n\n    if (this.config.optional && this.pattern.baseRegex.test(normalizedPath)) {\n      return true;\n    }\n\n    return this.pattern.fullRegex.test(normalizedPath);\n  }\n\n  /**\n   * Parse segments from a matched path\n   *\n   * @param path - URL path to parse\n   * @returns Array of segments\n   */\n  parseSegments(path: string): string[] {\n    const normalizedPath = path.replace(/\\/$/, '') || '/';\n    const basePath = this.config.basePath.replace(/\\/$/, '');\n\n    if (normalizedPath === basePath || normalizedPath === `${basePath  }/`) {\n      return [];\n    }\n\n    const remainder = normalizedPath.slice(basePath.length);\n    const segments = remainder.split('/').filter(Boolean).map(decodeURIComponent);\n\n    // Apply transformation if configured\n    if (this.config.transformSegments) {\n      return this.config.transformSegments(segments);\n    }\n\n    return segments;\n  }\n\n  /**\n   * Match a path and return full match result\n   *\n   * @param path - URL path to match\n   * @returns Match result with segments and validation\n   */\n  match(path: string): CatchAllMatch {\n    const errors: CatchAllError[] = [];\n\n    // Check if path matches pattern\n    if (!this.matches(path)) {\n      return {\n        matches: false,\n        segments: [],\n        errors: [],\n        score: 0,\n        props: null,\n      };\n    }\n\n    // Parse segments\n    const segments = this.parseSegments(path);\n\n    // Validate segment count\n    if (this.config.maxSegments != null && segments.length > this.config.maxSegments) {\n      errors.push({\n        type: 'too-many-segments',\n        message: `Too many segments: ${segments.length} (max: ${this.config.maxSegments})`,\n      });\n    }\n\n    if (this.config.minSegments != null && segments.length < this.config.minSegments) {\n      errors.push({\n        type: 'too-few-segments',\n        message: `Too few segments: ${segments.length} (min: ${this.config.minSegments})`,\n      });\n    }\n\n    // Validate individual segments\n    for (let i = 0; i < segments.length; i++) {\n      const segment = segments[i];\n      if (segment == null) continue;\n\n      // Custom validator\n      if (this.config.validateSegment && !this.config.validateSegment(segment)) {\n        errors.push({\n          type: 'invalid-segment',\n          message: `Invalid segment: \"${segment}\"`,\n          segment,\n          index: i,\n        });\n      }\n\n      // Pattern validation\n      if (this.config.deniedPatterns) {\n        for (const pattern of this.config.deniedPatterns) {\n          if (pattern.test(segment)) {\n            errors.push({\n              type: 'pattern-violation',\n              message: `Segment \"${segment}\" matches denied pattern`,\n              segment,\n              index: i,\n            });\n          }\n        }\n      }\n\n      if (this.config.allowedPatterns && this.config.allowedPatterns.length > 0) {\n        const matchesAllowed = this.config.allowedPatterns.some(p => p.test(segment));\n        if (!matchesAllowed) {\n          errors.push({\n            type: 'pattern-violation',\n            message: `Segment \"${segment}\" does not match any allowed pattern`,\n            segment,\n            index: i,\n          });\n        }\n      }\n    }\n\n    // Build props\n    const joinedPath = segments.join('/');\n    const props: CatchAllRouteProps = {\n      segments: Object.freeze(segments),\n      joinedPath,\n      depth: segments.length,\n      isBase: segments.length === 0,\n      fullPath: path,\n      params: { [this.config.paramName]: joinedPath },\n    };\n\n    // Calculate match score (more static prefix = higher score)\n    const score = this.pattern.staticPrefixLength * 10 + (this.config.optional ? 0 : 5);\n\n    return {\n      matches: errors.length === 0,\n      segments: Object.freeze(segments),\n      errors: Object.freeze(errors),\n      score,\n      props: errors.length === 0 ? props : null,\n    };\n  }\n\n  /**\n   * Get the route pattern string\n   *\n   * @returns Pattern string (e.g., '/docs/*' or '/docs/*?')\n   */\n  getPatternString(): string {\n    const base = this.config.basePath.replace(/\\/$/, '');\n    const suffix = this.config.optional ? '/*?' : '/*';\n    return base + suffix;\n  }\n\n  /**\n   * Get the URL path for given segments\n   *\n   * @param segments - Segments to join\n   * @returns Full URL path\n   */\n  buildPath(segments: readonly string[]): string {\n    const base = this.config.basePath.replace(/\\/$/, '');\n    if (segments.length === 0) {\n      return base || '/';\n    }\n    return `${base}/${segments.map(encodeURIComponent).join('/')}`;\n  }\n\n  /**\n   * Get route configuration\n   */\n  getConfig(): Readonly<CatchAllRouteConfig> {\n    return this.config;\n  }\n\n  /**\n   * Get component for rendering\n   */\n  getComponent(): ComponentType<unknown> {\n    return this.config.component as ComponentType<unknown>;\n  }\n\n  /**\n   * Compile the route pattern into regex\n   */\n  private compilePattern(config: CatchAllRouteConfig): CatchAllPattern {\n    const basePath = config.basePath.replace(/\\/$/, '');\n    const escapedBase = basePath.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n\n    // Base regex matches just the base path\n    const baseRegex = new RegExp(`^${escapedBase}/?$`);\n\n    // Full regex matches base path plus any number of segments\n    const segmentPattern = config.optional ? '(/[^/]+)*' : '(/[^/]+)+';\n    const fullRegex = new RegExp(`^${escapedBase}${segmentPattern}$`);\n\n    return {\n      baseRegex,\n      fullRegex,\n      staticPrefixLength: basePath.split('/').filter(Boolean).length,\n    };\n  }\n}\n\n// =============================================================================\n// CatchAllRouteManager Class\n// =============================================================================\n\n/**\n * Manages multiple catch-all routes with priority ordering\n */\nexport class CatchAllRouteManager {\n  private routes: Map<string, RegisteredCatchAllRoute> = new Map();\n  private idCounter = 0;\n\n  /**\n   * Register a catch-all route\n   *\n   * @param config - Route configuration\n   * @returns Route ID\n   */\n  register(config: CatchAllRouteConfig): string {\n    const id = `catchall_${++this.idCounter}`;\n    new CatchAllRoute(config);\n\n    const registered: RegisteredCatchAllRoute = {\n      id,\n      config,\n      pattern: {\n        baseRegex: new RegExp(`^${config.basePath.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')}/?$`),\n        fullRegex: new RegExp(`^${config.basePath.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')}(/[^/]+)*$`),\n        staticPrefixLength: config.basePath.split('/').filter(Boolean).length,\n      },\n      registeredAt: Date.now(),\n    };\n\n    this.routes.set(id, registered);\n    return id;\n  }\n\n  /**\n   * Unregister a catch-all route\n   *\n   * @param id - Route ID\n   * @returns True if route was found and removed\n   */\n  unregister(id: string): boolean {\n    return this.routes.delete(id);\n  }\n\n  /**\n   * Find the best matching catch-all route for a path\n   *\n   * @param path - URL path\n   * @returns Best match or null\n   */\n  findBestMatch(path: string): {\n    route: RegisteredCatchAllRoute;\n    match: CatchAllMatch;\n  } | null {\n    const matches: Array<{ route: RegisteredCatchAllRoute; match: CatchAllMatch }> = [];\n\n    for (const registered of this.routes.values()) {\n      const route = new CatchAllRoute(registered.config);\n      const match = route.match(path);\n\n      if (match.matches) {\n        matches.push({ route: registered, match });\n      }\n    }\n\n    if (matches.length === 0) {\n      return null;\n    }\n\n    // Sort by score (descending) - higher score = more specific\n    matches.sort((a, b) => b.match.score - a.match.score);\n\n    const [bestMatch] = matches;\n    if (bestMatch == null) {\n      throw new Error('No match found');\n    }\n    return bestMatch;\n  }\n\n  /**\n   * Get all registered routes\n   */\n  getAllRoutes(): readonly RegisteredCatchAllRoute[] {\n    return Array.from(this.routes.values());\n  }\n\n  /**\n   * Get a specific route\n   *\n   * @param id - Route ID\n   */\n  getRoute(id: string): RegisteredCatchAllRoute | undefined {\n    return this.routes.get(id);\n  }\n\n  /**\n   * Clear all routes\n   */\n  clearAll(): void {\n    this.routes.clear();\n  }\n}\n\n// =============================================================================\n// Factory Functions\n// =============================================================================\n\n/**\n * Create a catch-all route configuration\n *\n * @param config - Route configuration\n * @returns CatchAllRoute instance\n */\nexport function createCatchAllRoute(config: CatchAllRouteConfig): CatchAllRoute {\n  return new CatchAllRoute(config);\n}\n\n/**\n * Create a catch-all route for documentation sites\n *\n * @param options - Configuration options\n * @returns Configured CatchAllRoute\n */\nexport function createDocsCatchAll(options: {\n  basePath?: string;\n  component: ComponentType<CatchAllRouteProps>;\n  notFound?: ComponentType;\n  maxDepth?: number;\n}): CatchAllRoute {\n  return new CatchAllRoute({\n    basePath: options.basePath ?? '/docs',\n    paramName: 'slug',\n    optional: true,\n    component: options.component,\n    notFound: options.notFound,\n    maxSegments: options.maxDepth ?? 10,\n    validateSegment: (segment) => /^[a-z0-9-]+$/.test(segment),\n    meta: {\n      indexable: true,\n    },\n  });\n}\n\n/**\n * Create a catch-all route for blog posts\n *\n * @param options - Configuration options\n * @returns Configured CatchAllRoute\n */\nexport function createBlogCatchAll(options: {\n  basePath?: string;\n  component: ComponentType<CatchAllRouteProps>;\n}): CatchAllRoute {\n  return new CatchAllRoute({\n    basePath: options.basePath ?? '/blog',\n    paramName: 'slug',\n    optional: true,\n    component: options.component,\n    minSegments: 0,\n    maxSegments: 5,\n    allowedPatterns: [\n      /^\\d{4}$/,           // Year: 2024\n      /^\\d{2}$/,           // Month: 01\n      /^[a-z0-9-]+$/,      // Slug\n    ],\n    meta: {\n      indexable: true,\n    },\n  });\n}\n\n// =============================================================================\n// Singleton Instance\n// =============================================================================\n\nlet defaultManager: CatchAllRouteManager | null = null;\n\n/**\n * Get the default catch-all route manager\n */\nexport function getCatchAllManager(): CatchAllRouteManager {\n  defaultManager ??= new CatchAllRouteManager();\n  return defaultManager;\n}\n\n/**\n * Reset the default catch-all route manager\n */\nexport function resetCatchAllManager(): void {\n  defaultManager?.clearAll();\n  defaultManager = null;\n}\n\n// =============================================================================\n// Utility Functions\n// =============================================================================\n\n/**\n * Check if a path pattern is a catch-all\n *\n * @param pattern - Route pattern\n * @returns True if pattern is a catch-all\n */\nexport function isCatchAllPattern(pattern: string): boolean {\n  return pattern.includes('*') || pattern.includes('[...]') || pattern.includes('[[...') ;\n}\n\n/**\n * Extract base path from catch-all pattern\n *\n * @param pattern - Route pattern with catch-all\n * @returns Base path without catch-all\n */\nexport function extractBasePath(pattern: string): string {\n  return pattern\n    .replace(/\\/?\\*\\??$/, '')\n    .replace(/\\/?\\[\\.\\.\\.[^\\]]+\\]$/, '')\n    .replace(/\\/?\\[\\[\\.\\.\\.[^\\]]+\\]\\]$/, '')\n    || '/';\n}\n\n/**\n * Check if catch-all is optional\n *\n * @param pattern - Route pattern\n * @returns True if catch-all is optional\n */\nexport function isOptionalCatchAll(pattern: string): boolean {\n  return pattern.includes('*?') || pattern.includes('[[...');\n}\n\n/**\n * Normalize path segments for comparison\n *\n * @param segments - Array of segments\n * @returns Normalized segments\n */\nexport function normalizeSegments(segments: readonly string[]): string[] {\n  return segments\n    .map(s => s.toLowerCase().trim())\n    .filter(Boolean);\n}\n\n/**\n * Join segments into a path\n *\n * @param segments - Array of segments\n * @returns Joined path\n */\nexport function joinSegments(segments: readonly string[]): string {\n  return `/${  segments.join('/')}`;\n}\n\n/**\n * Split a path into segments\n *\n * @param path - URL path\n * @returns Array of segments\n */\nexport function splitPath(path: string): string[] {\n  return path.split('/').filter(Boolean);\n}\n\n// =============================================================================\n// Type Guards\n// =============================================================================\n\n/**\n * Type guard for CatchAllRouteProps\n */\nexport function isCatchAllRouteProps(value: unknown): value is CatchAllRouteProps {\n  return (\n    typeof value === 'object' &&\n    value !== null &&\n    'segments' in value &&\n    'joinedPath' in value &&\n    'depth' in value &&\n    'isBase' in value\n  );\n}\n\n/**\n * Type guard for CatchAllMatch\n */\nexport function isCatchAllMatch(value: unknown): value is CatchAllMatch {\n  return (\n    typeof value === 'object' &&\n    value !== null &&\n    'matches' in value &&\n    'segments' in value &&\n    'score' in value\n  );\n}\n"],"names":["CatchAllRoute","config","path","normalizedPath","basePath","segments","errors","i","segment","pattern","p","joinedPath","props","score","base","suffix","escapedBase","baseRegex","segmentPattern","fullRegex","CatchAllRouteManager","id","registered","matches","match","a","b","bestMatch","createCatchAllRoute","isCatchAllPattern"],"mappings":"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