{"version":3,"file":"router.cjs","sources":["../../src/plugins/Router.js"],"sourcesContent":["\"use strict\";\n\n/**\n * @module eleva/plugins/router\n * @fileoverview Client-side router plugin with hash, history, and query modes,\n * navigation guards, and lifecycle hooks.\n */\n\n// ============================================================================\n// TYPE DEFINITIONS\n// ============================================================================\n\n// -----------------------------------------------------------------------------\n// External Type Imports\n// -----------------------------------------------------------------------------\n\n/**\n * Type imports from the Eleva core library.\n * @typedef {import('eleva').Eleva} Eleva\n * @typedef {import('eleva').ComponentDefinition} ComponentDefinition\n * @typedef {import('eleva').Emitter} Emitter\n * @typedef {import('eleva').MountResult} MountResult\n * @typedef {import('eleva').UnsubscribeFunction} UnsubscribeFunction\n */\n\n/**\n * Generic type import.\n * @template T\n * @typedef {import('eleva').Signal<T>} Signal\n */\n\n// -----------------------------------------------------------------------------\n// Router Events\n// -----------------------------------------------------------------------------\n\n/**\n * Fired when the router initialization completes successfully.\n * @event router:ready\n * @type {Router}\n */\n\n/**\n * Fired when an error occurs during navigation or route handling, including\n * when no matching route is found and no catch-all (`*`) route exists.\n * @event router:error\n * @type {Error}\n */\n\n/**\n * Fired before guards run, allowing plugins to block or redirect navigation.\n * @event router:beforeEach\n * @type {NavigationContext}\n */\n\n/**\n * Fired before component resolution, allowing plugins to modify the resolve context.\n * @event router:beforeResolve\n * @type {ResolveContext}\n */\n\n/**\n * Fired after components are resolved successfully.\n * @event router:afterResolve\n * @type {ResolveContext}\n */\n\n/**\n * Fired after leaving the previous route.\n * @event router:afterLeave\n * @type {{to: RouteLocation, from: RouteLocation}}\n */\n\n/**\n * Fired before DOM rendering begins.\n * @event router:beforeRender\n * @type {RenderContext}\n */\n\n/**\n * Fired after DOM rendering completes.\n * @event router:afterRender\n * @type {RenderContext}\n */\n\n/**\n * Fired after render for scroll behavior handling.\n * @event router:scroll\n * @type {ScrollContext}\n */\n\n/**\n * Fired after entering the new route.\n * @event router:afterEnter\n * @type {{to: RouteLocation, from: RouteLocation | null}}\n */\n\n/**\n * Fired after navigation completes successfully.\n * @event router:afterEach\n * @type {{to: RouteLocation, from: RouteLocation | null}}\n */\n\n/**\n * Fired when a route is dynamically added.\n * @event router:routeAdded\n * @type {RouteDefinition}\n */\n\n/**\n * Fired when a route is dynamically removed.\n * @event router:routeRemoved\n * @type {RouteDefinition}\n */\n\n// -----------------------------------------------------------------------------\n// Router Data Types\n// -----------------------------------------------------------------------------\n\n/**\n * The routing mode determines how the router manages URL state.\n * - `hash`: Uses URL hash (e.g., `/#/path`) - works without server config\n * - `history`: Uses HTML5 History API (e.g., `/path`) - requires server config\n * - `query`: Uses query parameters (e.g., `?view=/path`) - useful for embedded apps\n * @typedef {'hash' | 'history' | 'query'} RouterMode\n */\n\n/**\n * Route parameters extracted from the URL path.\n * @typedef {Record<string, string>} RouteParams\n * @description Key-value pairs extracted from dynamic route segments (e.g., `/users/:id` → `{ id: '123' }`).\n */\n\n/**\n * Query parameters from the URL query string.\n * @typedef {Record<string, string>} QueryParams\n * @description Key-value pairs from the URL query string (e.g., `?page=1&sort=name`).\n */\n\n/**\n * Navigation input parameters supporting multiple value types.\n * @typedef {Record<string, string | number | boolean>} NavigationParams\n * @description Parameters passed to navigation functions, automatically converted to strings in URLs.\n */\n\n/**\n * Function signature for programmatic navigation.\n * @typedef {(location: string | NavigationTarget, params?: NavigationParams) => Promise<boolean>} NavigateFunction\n * @description Returns true if navigation succeeded, false if blocked by a guard.\n */\n\n/**\n * Router configuration options.\n * @typedef {Object} RouterOptions\n * @property {RouterMode} [mode='hash']\n *           The routing mode to use.\n * @property {string} [queryParam='view']\n *           Query parameter name for 'query' mode.\n * @property {string} [viewSelector='view']\n *           Base selector for the view element.\n * @property {string} mount\n *           CSS selector for the mount point element.\n * @property {RouteDefinition[]} routes\n *           Array of route definitions.\n * @property {RouteComponent} [globalLayout]\n *           Default layout for all routes.\n * @property {NavigationGuard} [onBeforeEach]\n *           Global navigation guard.\n * @property {boolean} [autoStart=true]\n *           Whether to start the router automatically.\n * @description Configuration options for the Router plugin.\n */\n\n/**\n * Object describing a navigation target for `router.navigate()`.\n * @typedef {Object} NavigationTarget\n * @property {string} path\n *           The target path (can include params like '/users/:id').\n * @property {NavigationParams} [params]\n *           Route parameters to inject.\n * @property {NavigationParams} [query]\n *           Query parameters to append.\n * @property {boolean} [replace=false]\n *           Whether to replace current history entry.\n * @property {unknown} [state]\n *           History state to pass.\n * @description Object describing a navigation target for `router.navigate()`.\n */\n\n/**\n * Saved scroll position.\n * @typedef {Object} ScrollPosition\n * @property {number} x\n *           Horizontal scroll position.\n * @property {number} y\n *           Vertical scroll position.\n * @description Represents a saved scroll position.\n */\n\n/**\n * Internal representation of a parsed route path segment.\n * @typedef {Object} RouteSegment\n * @property {'static' | 'param'} type\n *           The segment type.\n * @property {string} [value]\n *           The segment value (static segments).\n * @property {string} [name]\n *           The parameter name (param segments).\n * @description Internal representation of a parsed route path segment.\n * @private\n */\n\n/**\n * Result of matching a path against route definitions.\n * @typedef {Object} RouteMatch\n * @property {RouteDefinition} route\n *           The matched route definition.\n * @property {RouteParams} params\n *           The extracted route parameters.\n * @description Result of matching a path against route definitions.\n * @private\n */\n\n/**\n * Arbitrary metadata attached to routes for use in guards and components.\n * @typedef {Record<string, unknown>} RouteMeta\n * @description Common properties include:\n * - `requiresAuth: boolean` - Whether the route requires authentication\n * - `title: string` - Page title for the route\n * - `roles: string[]` - Required user roles\n * @example\n * {\n *   path: '/admin',\n *   component: AdminPage,\n *   meta: { requiresAuth: true, roles: ['admin'], title: 'Admin Dashboard' }\n * }\n */\n\n/**\n * Interface for the router's error handling system.\n * @typedef {Object} RouterErrorHandler\n * @property {(error: Error, context: string, details?: Record<string, unknown>) => void} handle\n *           Throws a formatted error.\n * @property {(message: string, details?: Record<string, unknown>) => void} warn\n *           Logs a warning.\n * @property {(message: string, error: Error, details?: Record<string, unknown>) => void} log\n *           Logs an error without throwing.\n * @description Interface for the router's error handling system.\n */\n\n// -----------------------------------------------------------------------------\n// Event Callback Types\n// -----------------------------------------------------------------------------\n\n/**\n * Callback for `router:beforeEach` event.\n * @callback NavigationContextCallback\n * @param {NavigationContext} context\n *        The navigation context (can be modified to block/redirect).\n * @returns {void | Promise<void>}\n * @description Modify context to control navigation flow.\n */\n\n/**\n * Callback for `router:beforeResolve` and `router:afterResolve` events.\n * @callback ResolveContextCallback\n * @param {ResolveContext} context\n *        The resolve context (can be modified to block/redirect).\n * @returns {void | Promise<void>}\n * @description Callback for `router:beforeResolve` and `router:afterResolve` events.\n */\n\n/**\n * Callback for `router:beforeRender` and `router:afterRender` events.\n * @callback RenderContextCallback\n * @param {RenderContext} context\n *        The render context.\n * @returns {void | Promise<void>}\n * @description Callback for `router:beforeRender` and `router:afterRender` events.\n */\n\n/**\n * Callback for `router:scroll` event.\n * @callback ScrollContextCallback\n * @param {ScrollContext} context\n *        The scroll context with saved position info.\n * @returns {void | Promise<void>}\n * @description Use to implement custom scroll behavior.\n */\n\n/**\n * Callback for `router:afterEnter`, `router:afterLeave`, `router:afterEach` events.\n * @callback RouteChangeCallback\n * @param {RouteLocation} to\n *        The target route location.\n * @param {RouteLocation | null} from\n *        The source route location.\n * @returns {void | Promise<void>}\n * @description Callback for `router:afterEnter`, `router:afterLeave`, `router:afterEach` events.\n */\n\n/**\n * Router context injected into component setup as `ctx.router`.\n * @typedef {Object} RouterContext\n * @property {NavigateFunction} navigate\n *           Programmatic navigation function.\n * @property {Signal<RouteLocation | null>} current\n *           Reactive signal for current route.\n * @property {Signal<RouteLocation | null>} previous\n *           Reactive signal for previous route.\n * @property {RouteParams} params\n *           Current route params (getter).\n * @property {QueryParams} query\n *           Current route query (getter).\n * @property {string} path\n *           Current route path (getter).\n * @property {string} fullUrl\n *           Current routed URL string (getter).\n * @property {RouteMeta} meta\n *           Current route meta (getter).\n * @description Injected into component setup as `ctx.router`.\n */\n\n/**\n * Callback for `router:error` event.\n * @callback RouterErrorCallback\n * @param {Error} error\n *        The error that occurred.\n * @param {RouteLocation} [to]\n *        The target route (if available).\n * @param {RouteLocation | null} [from]\n *        The source route (if available).\n * @returns {void | Promise<void>}\n * @description Callback for `router:error` event.\n */\n\n/**\n * Callback for `router:ready` event.\n * @callback RouterReadyCallback\n * @param {Router} router\n *        The router instance.\n * @returns {void | Promise<void>}\n * @description Callback for `router:ready` event.\n */\n\n/**\n * Callback for `router:routeAdded` event.\n * @callback RouteAddedCallback\n * @param {RouteDefinition} route\n *        The added route definition.\n * @returns {void | Promise<void>}\n * @description Callback for `router:routeAdded` event.\n */\n\n/**\n * Callback for `router:routeRemoved` event.\n * @callback RouteRemovedCallback\n * @param {RouteDefinition} route\n *        The removed route definition.\n * @returns {void | Promise<void>}\n * @description Callback for `router:routeRemoved` event.\n */\n\n// ============================================================================\n// CORE IMPLEMENTATION\n// ============================================================================\n\n/**\n * Simple error handler for the core router.\n * @private\n */\nconst CoreErrorHandler = {\n  /**\n   * Handles router errors with basic formatting.\n   * @param {Error} error - The error to handle.\n   * @param {string} context - The context where the error occurred.\n   * @param {Record<string, unknown>} details - Additional error details.\n   * @throws {Error} The formatted error.\n   */\n  handle(error, context, details = {}) {\n    const message = `[ElevaRouter] ${context}: ${error.message}`;\n    const formattedError = new Error(message);\n\n    // Preserve original error details\n    formattedError.originalError = error;\n    formattedError.context = context;\n    formattedError.details = details;\n\n    console.error(message, { error, context, details });\n    throw formattedError;\n  },\n\n  /**\n   * Logs a warning without throwing an error.\n   * @param {string} message - The warning message.\n   * @param {Record<string, unknown>} details - Additional warning details.\n   */\n  warn(message, details = {}) {\n    console.warn(`[ElevaRouter] ${message}`, details);\n  },\n\n  /**\n   * Logs an error without throwing.\n   * @param {string} message - The error message.\n   * @param {Error} error - The original error.\n   * @param {Record<string, unknown>} details - Additional error details.\n   */\n  log(message, error, details = {}) {\n    console.error(`[ElevaRouter] ${message}`, { error, details });\n  },\n};\n\n/**\n * Represents the current or target location in the router.\n * @typedef {Object} RouteLocation\n * @property {string} path\n *           The path of the route (e.g., '/users/123').\n * @property {QueryParams} query\n *           Query parameters as key-value pairs.\n * @property {string} fullUrl\n *           The routed URL string (path plus query).\n * @property {RouteParams} params\n *           Dynamic route parameters.\n * @property {RouteMeta} meta\n *           Metadata associated with the matched route.\n * @property {string} [name]\n *           The optional name of the matched route.\n * @property {RouteDefinition} matched\n *           The raw route definition that was matched.\n * @description Represents the current or target location in the router.\n */\n\n/**\n * Return value of a navigation guard.\n * - `true` or `undefined/void`: Allow navigation\n * - `false`: Abort navigation\n * - `string`: Redirect to path\n * - `NavigationTarget`: Redirect with options\n * @typedef {boolean | string | NavigationTarget | void} NavigationGuardResult\n */\n\n/**\n * Navigation guard function that controls navigation flow.\n * @callback NavigationGuard\n * @param {RouteLocation} to\n *        The target route location.\n * @param {RouteLocation | null} from\n *        The source route location (null on initial).\n * @returns {NavigationGuardResult | Promise<NavigationGuardResult>}\n * @description A function that controls navigation flow. Runs before navigation is confirmed.\n * @example\n * // Simple auth guard\n * const authGuard = (to, from) => {\n *   if (to.meta.requiresAuth && !isLoggedIn()) {\n *     return '/login'; // Redirect\n *   }\n *   // Allow navigation (implicit return undefined)\n * };\n */\n\n/**\n * Navigation hook for side effects. Does not affect navigation flow.\n * @callback NavigationHook\n * @param {RouteLocation} to\n *        The target route location.\n * @param {RouteLocation | null} from\n *        The source route location.\n * @returns {void | Promise<void>}\n * @description A lifecycle hook for side effects. Does not affect navigation flow.\n * @example\n * // Analytics hook\n * const analyticsHook = (to, from) => {\n *   analytics.trackPageView(to.path);\n * };\n */\n\n/**\n * Interface for router plugins.\n * @typedef {Object} RouterPlugin\n * @property {string} name\n *           Unique plugin identifier.\n * @property {string} [version]\n *           Plugin version (recommended to match router version).\n * @property {(router: Router, options?: Record<string, unknown>) => void} install\n *           Installation function.\n * @property {(router: Router) => void | Promise<void>} [destroy]\n *           Cleanup function called on router.destroy().\n * @description Interface for router plugins. Plugins can extend router functionality.\n * @example\n * const AnalyticsPlugin = {\n *   name: 'analytics',\n *   version: '1.0.0',\n *   install(router, options) {\n *     router.emitter.on('router:afterEach', (to, from) => {\n *       analytics.track(to.path);\n *     });\n *   }\n * };\n */\n\n/**\n * Context object for navigation events that plugins can modify.\n * @typedef {Object} NavigationContext\n * @property {RouteLocation} to\n *           The target route location.\n * @property {RouteLocation | null} from\n *           The source route location.\n * @property {boolean} cancelled\n *           Whether navigation has been cancelled.\n * @property {string | NavigationTarget | null} redirectTo\n *           Redirect target if set.\n * @description Passed to navigation events. Plugins can modify to control navigation flow.\n */\n\n/**\n * Context object for component resolution events.\n * @typedef {Object} ResolveContext\n * @property {RouteLocation} to\n *           The target route location.\n * @property {RouteLocation | null} from\n *           The source route location.\n * @property {RouteDefinition} route\n *           The matched route definition.\n * @property {ComponentDefinition | null} layoutComponent\n *           The resolved layout component (available in afterResolve).\n * @property {ComponentDefinition | null} pageComponent\n *           The resolved page component (available in afterResolve).\n * @property {boolean} cancelled\n *           Whether navigation has been cancelled.\n * @property {string | NavigationTarget | null} redirectTo\n *           Redirect target if set.\n * @description Passed to component resolution events.\n */\n\n/**\n * Context object for render events.\n * @typedef {Object} RenderContext\n * @property {RouteLocation} to\n *           The target route location.\n * @property {RouteLocation | null} from\n *           The source route location.\n * @property {ComponentDefinition | null} layoutComponent\n *           The layout component being rendered.\n * @property {ComponentDefinition} pageComponent\n *           The page component being rendered.\n * @description Passed to render events.\n */\n\n/**\n * Context object for scroll events.\n * @typedef {Object} ScrollContext\n * @property {RouteLocation} to\n *           The target route location.\n * @property {RouteLocation | null} from\n *           The source route location.\n * @property {{x: number, y: number} | null} savedPosition\n *           Saved position (back/forward nav).\n * @description Passed to scroll events for plugins to handle scroll behavior.\n */\n\n/**\n * A component that can be rendered for a route.\n * - `string`: Name of a registered component\n * - `ComponentDefinition`: Inline component definition\n * - `() => ComponentDefinition`: Factory function returning a component\n * - `() => Promise<ComponentDefinition>`: Async factory function\n * - `() => Promise<{default: ComponentDefinition}>`: Lazy-loaded module (e.g., `() => import('./Page.js')`)\n * @typedef {string | ComponentDefinition | (() => ComponentDefinition | Promise<ComponentDefinition | {default: ComponentDefinition}>)} RouteComponent\n */\n\n/**\n * Defines a route in the application.\n * @typedef {Object} RouteDefinition\n * @property {string} path\n *           URL path pattern. Supports:\n *           - Static: '/about'\n *           - Dynamic params: '/users/:id'\n *           - Wildcard: '*' (catch-all, conventionally last)\n * @property {RouteComponent} component\n *           The component to render for this route.\n * @property {RouteComponent} [layout]\n *           Optional layout component to wrap the route component.\n * @property {string} [name]\n *           Optional route name for programmatic navigation.\n * @property {RouteMeta} [meta]\n *           Optional metadata (auth flags, titles, etc.).\n * @property {NavigationGuard} [beforeEnter]\n *           Route-specific guard before entering.\n * @property {NavigationHook} [afterEnter]\n *           Hook after entering and component is mounted.\n * @property {NavigationGuard} [beforeLeave]\n *           Guard before leaving this route.\n * @property {NavigationHook} [afterLeave]\n *           Hook after leaving and component is unmounted.\n * @property {RouteSegment[]} [segments]\n *           Internal: parsed path segments (added by router).\n * @description Defines a route in the application.\n * @note Nested routes are not supported. Use shared layouts with flat routes instead.\n * @example\n * // Static route\n * { path: '/about', component: AboutPage }\n *\n * // Dynamic route with params\n * { path: '/users/:id', component: UserPage, meta: { requiresAuth: true } }\n *\n * // Lazy-loaded route with layout\n * {\n *   path: '/dashboard',\n *   component: () => import('./Dashboard.js'),\n *   layout: DashboardLayout,\n *   beforeEnter: (to, from) => isLoggedIn() || '/login'\n * }\n *\n * // Catch-all 404 route (conventionally last)\n * { path: '*', component: NotFoundPage }\n */\n\n/**\n * @class 🛤️ Router\n * @classdesc A powerful, reactive, and flexible Router Plugin for Eleva.\n * This class manages all routing logic, including state, navigation, and rendering.\n *\n * ## Features\n * - Multiple routing modes (hash, history, query)\n * - Reactive route state via Signals\n * - Navigation guards and lifecycle hooks\n * - Lazy-loaded components\n * - Layout system\n * - Plugin architecture\n * - Scroll position management\n *\n * ## Events Reference\n * | Event | Callback Type | Can Block | Description |\n * |-------|--------------|-----------|-------------|\n * | `router:ready` | {@link RouterReadyCallback} | No | Router initialized |\n * | `router:beforeEach` | {@link NavigationContextCallback} | Yes | Before guards run |\n * | `router:beforeResolve` | {@link ResolveContextCallback} | Yes | Before component loading |\n * | `router:afterResolve` | {@link ResolveContextCallback} | No | After components loaded |\n * | `router:afterLeave` | {@link RouteChangeCallback} | No | After leaving route |\n * | `router:beforeRender` | {@link RenderContextCallback} | No | Before DOM update |\n * | `router:afterRender` | {@link RenderContextCallback} | No | After DOM update |\n * | `router:scroll` | {@link ScrollContextCallback} | No | For scroll behavior |\n * | `router:afterEnter` | {@link RouteChangeCallback} | No | After entering route |\n * | `router:afterEach` | {@link RouteChangeCallback} | No | Navigation complete |\n * | `router:error` | {@link RouterErrorCallback} | No | Navigation error |\n * | `router:routeAdded` | {@link RouteAddedCallback} | No | Dynamic route added |\n * | `router:routeRemoved` | {@link RouteRemovedCallback} | No | Dynamic route removed |\n *\n * ## Reactive Signals\n * - `currentRoute: Signal<RouteLocation | null>` - Current route info\n * - `previousRoute: Signal<RouteLocation | null>` - Previous route info\n * - `currentParams: Signal<RouteParams>` - Current route params\n * - `currentQuery: Signal<QueryParams>` - Current query params\n * - `currentLayout: Signal<MountResult | null>` - Mounted layout instance\n * - `currentView: Signal<MountResult | null>` - Mounted view instance\n * - `isReady: Signal<boolean>` - Router readiness state\n *\n * @note Internal API Access Policy:\n * As a core Eleva plugin, the Router may access internal Eleva APIs (prefixed with _)\n * such as `eleva._components`. This is intentional and these internal APIs are\n * considered stable for official plugins. Third-party plugins should avoid\n * accessing internal APIs as they may change without notice.\n *\n * @example\n * // Basic setup\n * const router = new Router(eleva, {\n *   mode: 'hash',\n *   mount: '#app',\n *   routes: [\n *     { path: '/', component: HomePage },\n *     { path: '/users/:id', component: UserPage },\n *     { path: '*', component: NotFoundPage }\n *   ]\n * });\n *\n * // Start router\n * await router.start();\n *\n * // Navigate programmatically\n * const success = await router.navigate('/users/123');\n *\n * // Watch for route changes\n * router.currentRoute.watch((route) => {\n *   document.title = route?.meta?.title || 'My App';\n * });\n *\n * @private\n */\nclass Router {\n  /**\n   * Creates an instance of the Router.\n   * @param {Eleva} eleva - The Eleva framework instance.\n   * @param {RouterOptions} options - The configuration options for the router.\n   * @throws {Error} If the routing mode is invalid.\n   */\n  constructor(eleva, options = {}) {\n    /** @type {Eleva} The Eleva framework instance. */\n    this.eleva = eleva;\n\n    /** @type {RouterOptions} The merged router options. */\n    this.options = {\n      mode: \"hash\",\n      queryParam: \"view\",\n      viewSelector: \"view\",\n      ...options,\n    };\n\n    /** @private @type {RouteDefinition[]} The processed list of route definitions. */\n    this.routes = this._processRoutes(options.routes || []);\n\n    /** @private @type {Emitter} The shared Eleva event emitter for global hooks. */\n    this.emitter = this.eleva.emitter;\n\n    /** @private @type {boolean} A flag indicating if the router has been started. */\n    this.isStarted = false;\n\n    /** @private @type {boolean} A flag to prevent navigation loops from history events. */\n    this._isNavigating = false;\n\n    /** @private @type {number} Counter for tracking navigation operations to prevent race conditions. */\n    this._navigationId = 0;\n\n    /** @private @type {UnsubscribeFunction[]} A collection of cleanup functions for event listeners. */\n    this.eventListeners = [];\n\n    /** @type {Signal<RouteLocation | null>} A reactive signal holding the current route's information. */\n    this.currentRoute = new this.eleva.signal(null);\n\n    /** @type {Signal<RouteLocation | null>} A reactive signal holding the previous route's information. */\n    this.previousRoute = new this.eleva.signal(null);\n\n    /** @type {Signal<RouteParams>} A reactive signal holding the current route's parameters. */\n    this.currentParams = new this.eleva.signal({});\n\n    /** @type {Signal<QueryParams>} A reactive signal holding the current route's query parameters. */\n    this.currentQuery = new this.eleva.signal({});\n\n    /** @type {Signal<MountResult | null>} A reactive signal for the currently mounted layout instance. */\n    this.currentLayout = new this.eleva.signal(null);\n\n    /** @type {Signal<MountResult | null>} A reactive signal for the currently mounted view (page) instance. */\n    this.currentView = new this.eleva.signal(null);\n\n    /** @type {Signal<boolean>} A reactive signal indicating if the router is ready (started and initial navigation complete). */\n    this.isReady = new this.eleva.signal(false);\n\n    /** @private @type {Map<string, RouterPlugin>} Map of registered plugins by name. */\n    this.plugins = new Map();\n\n    /** @private @type {NavigationGuard[]} Array of global before-each navigation guards. */\n    this._beforeEachGuards = [];\n\n    // If onBeforeEach was provided in options, add it to the guards array\n    if (options.onBeforeEach) {\n      this._beforeEachGuards.push(options.onBeforeEach);\n    }\n\n    /** @type {RouterErrorHandler} The error handler instance. Can be overridden by plugins. */\n    this.errorHandler = CoreErrorHandler;\n\n    /** @private @type {Map<string, {x: number, y: number}>} Saved scroll positions by route path. */\n    this._scrollPositions = new Map();\n\n    this._validateOptions();\n  }\n\n  /**\n   * Validates the provided router options.\n   * @private\n   * @throws {Error} If the routing mode is invalid.\n   */\n  _validateOptions() {\n    if (![\"hash\", \"query\", \"history\"].includes(this.options.mode)) {\n      this.errorHandler.handle(\n        new Error(\n          `Invalid routing mode: ${this.options.mode}. Must be \"hash\", \"query\", or \"history\".`\n        ),\n        \"Configuration validation failed\"\n      );\n    }\n  }\n\n  /**\n   * Pre-processes route definitions to parse their path segments for efficient matching.\n   * @private\n   * @param {RouteDefinition[]} routes - The raw route definitions.\n   * @returns {RouteDefinition[]} The processed routes.\n   */\n  _processRoutes(routes) {\n    const processedRoutes = [];\n    for (const route of routes) {\n      try {\n        processedRoutes.push({\n          ...route,\n          segments: this._parsePathIntoSegments(route.path),\n        });\n      } catch (error) {\n        this.errorHandler.warn(\n          `Invalid path in route definition \"${route.path || \"undefined\"}\": ${error.message}`,\n          { route, error }\n        );\n      }\n    }\n    return processedRoutes;\n  }\n\n  /**\n   * Parses a route path string into an array of static and parameter segments.\n   * @private\n   * @param {string} path - The path pattern to parse.\n   * @returns {{type: 'static' | 'param', value?: string, name?: string}[]} An array of segment objects.\n   * @throws {Error} If the route path is not a valid string.\n   */\n  _parsePathIntoSegments(path) {\n    if (!path || typeof path !== \"string\") {\n      this.errorHandler.handle(\n        new Error(\"Route path must be a non-empty string\"),\n        \"Path parsing failed\",\n        { path }\n      );\n    }\n\n    const normalizedPath = path.replace(/\\/+/g, \"/\").replace(/\\/$/, \"\") || \"/\";\n\n    if (normalizedPath === \"/\") {\n      return [];\n    }\n\n    return normalizedPath\n      .split(\"/\")\n      .filter(Boolean)\n      .map((segment) => {\n        if (segment.startsWith(\":\")) {\n          const paramName = segment.substring(1);\n          if (!paramName) {\n            this.errorHandler.handle(\n              new Error(`Invalid parameter segment: ${segment}`),\n              \"Path parsing failed\",\n              { segment, path }\n            );\n          }\n          return { type: \"param\", name: paramName };\n        }\n        return { type: \"static\", value: segment };\n      });\n  }\n\n  /**\n   * Finds the view element within a container using multiple selector strategies.\n   * @private\n   * @param {HTMLElement} container - The parent element to search within.\n   * @returns {HTMLElement} The found view element or the container itself as a fallback.\n   */\n  _findViewElement(container) {\n    const selector = this.options.viewSelector;\n    return (\n      container.querySelector(`#${selector}`) ||\n      container.querySelector(`.${selector}`) ||\n      container.querySelector(`[data-${selector}]`) ||\n      container.querySelector(selector) ||\n      container\n    );\n  }\n\n  /**\n   * Starts the router, initializes event listeners, and performs the initial navigation.\n   * @returns {Promise<Router>} The router instance for method chaining.\n   * @listens window:hashchange In hash mode, triggers route changes.\n   * @listens window:popstate In history/query mode, triggers route changes.\n   * @emits router:ready When initialization completes successfully.\n   * @see destroy - Stop the router and clean up listeners.\n   * @see navigate - Programmatically navigate to a route.\n   *\n   * @example\n   * // Basic usage\n   * await router.start();\n   *\n   * // Method chaining\n   * await router.start().then(r => r.navigate('/home'));\n   *\n   * // Reactive readiness\n   * router.isReady.watch((ready) => {\n   *   if (ready) console.log('Router is ready!');\n   * });\n   */\n  async start() {\n    if (this.isStarted) {\n      this.errorHandler.warn(\"Router is already started\");\n      return this;\n    }\n    if (typeof window === \"undefined\") {\n      this.errorHandler.warn(\n        \"Router start skipped: `window` object not available (SSR environment)\"\n      );\n      return this;\n    }\n    if (\n      typeof document !== \"undefined\" &&\n      !document.querySelector(this.options.mount)\n    ) {\n      this.errorHandler.warn(\n        `Mount element \"${this.options.mount}\" was not found in the DOM. The router will not start.`,\n        { mountSelector: this.options.mount }\n      );\n      return this;\n    }\n    const handler = () => this._handleRouteChange();\n    if (this.options.mode === \"hash\") {\n      window.addEventListener(\"hashchange\", handler);\n      this.eventListeners.push(() =>\n        window.removeEventListener(\"hashchange\", handler)\n      );\n    } else {\n      window.addEventListener(\"popstate\", handler);\n      this.eventListeners.push(() =>\n        window.removeEventListener(\"popstate\", handler)\n      );\n    }\n    this.isStarted = true;\n    // Initial navigation is not a popstate event\n    await this._handleRouteChange(false);\n    // Set isReady to true after initial navigation completes\n    this.isReady.value = true;\n    await this.emitter.emit(\"router:ready\", this);\n    return this;\n  }\n\n  /**\n   * Stops the router and cleans up event listeners.\n   * Unmounts the current layout instance if present.\n   * @async\n   * @returns {Promise<void>}\n   * @see start - Restart the router after destroying.\n   */\n  async destroy() {\n    if (!this.isStarted) return;\n\n    // Clean up plugins\n    for (const plugin of this.plugins.values()) {\n      if (typeof plugin.destroy === \"function\") {\n        try {\n          await plugin.destroy(this);\n        } catch (error) {\n          this.errorHandler.log(`Plugin ${plugin.name} destroy failed`, error);\n        }\n      }\n    }\n\n    this.eventListeners.forEach((cleanup) => cleanup());\n    this.eventListeners = [];\n    if (this.currentLayout.value) {\n      await this.currentLayout.value.unmount();\n    }\n    this.isStarted = false;\n    this.isReady.value = false;\n  }\n\n  /**\n   * Alias for destroy(). Stops the router and cleans up all resources.\n   * Provided for semantic consistency (start/stop pattern).\n   * @async\n   * @returns {Promise<void>}\n   *\n   * @example\n   * await router.start();\n   * // ... later\n   * await router.stop();\n   */\n  async stop() {\n    return this.destroy();\n  }\n\n  /**\n   * Programmatically navigates to a new route.\n   * @async\n   * @param {string | NavigationTarget} location - The target location as a path string or navigation target object.\n   * @param {NavigationParams} [params] - Route parameters (only used when location is a string).\n   * @returns {Promise<boolean>} True if navigation succeeded, false if blocked by guards or failed.\n   * @emits router:error When navigation fails due to an exception.\n   * @see start - Initialize the router before navigating.\n   * @see currentRoute - Access the current route after navigation.\n   *\n   * @example\n   * // Basic navigation\n   * await router.navigate('/users/123');\n   *\n   * // Check if navigation succeeded\n   * const success = await router.navigate('/protected');\n   * if (!success) {\n   *   console.log('Navigation was blocked by a guard');\n   * }\n   *\n   * // Navigate with options\n   * await router.navigate({\n   *   path: '/users/:id',\n   *   params: { id: '123' },\n   *   query: { tab: 'profile' },\n   *   replace: true\n   * });\n   */\n  async navigate(location, params = {}) {\n    try {\n      const target =\n        typeof location === \"string\" ? { path: location, params } : location;\n      let path = this._buildPath(target.path, target.params || {});\n      const query = target.query || {};\n\n      if (Object.keys(query).length > 0) {\n        const queryString = new URLSearchParams(query).toString();\n        if (queryString) path += `?${queryString}`;\n      }\n\n      if (this._isSameRoute(path, target.params, query)) {\n        return true; // Already at this route, consider it successful\n      }\n\n      const navigationSuccessful = await this._proceedWithNavigation(path);\n\n      if (navigationSuccessful) {\n        // Increment navigation ID and capture it for this navigation\n        const currentNavId = ++this._navigationId;\n        this._isNavigating = true;\n\n        try {\n          const state = target.state || {};\n          const replace = target.replace || false;\n          const historyMethod = replace ? \"replaceState\" : \"pushState\";\n\n          if (this.options.mode === \"hash\") {\n            if (replace) {\n              const newUrl = `${window.location.pathname}${window.location.search}#${path}`;\n              window.history.replaceState(state, \"\", newUrl);\n            } else {\n              window.location.hash = path;\n            }\n          } else {\n            const url =\n              this.options.mode === \"query\" ? this._buildQueryUrl(path) : path;\n            history[historyMethod](state, \"\", url);\n          }\n        } finally {\n          // Always reset the flag via microtask, even if history manipulation throws\n          // Only reset if no newer navigation has started\n          queueMicrotask(() => {\n            if (this._navigationId === currentNavId) {\n              this._isNavigating = false;\n            }\n          });\n        }\n      }\n\n      return navigationSuccessful;\n    } catch (error) {\n      this.errorHandler.log(\"Navigation failed\", error);\n      await this.emitter.emit(\"router:error\", error);\n      return false;\n    }\n  }\n\n  /**\n   * Builds a URL for query mode.\n   * @private\n   * @param {string} path - The path to set as the query parameter.\n   * @returns {string} The full URL with the updated query string.\n   */\n  _buildQueryUrl(path) {\n    const urlParams = new URLSearchParams(window.location.search);\n    urlParams.set(this.options.queryParam, path.split(\"?\")[0]);\n    return `${window.location.pathname}?${urlParams.toString()}`;\n  }\n\n  /**\n   * Checks if the target route is identical to the current route.\n   * @private\n   * @param {string} path - The target path with query string.\n   * @param {object} params - The target params.\n   * @param {object} query - The target query.\n   * @returns {boolean} True if the routes are the same.\n   */\n  _isSameRoute(path, params, query) {\n    const current = this.currentRoute.value;\n    if (!current) return false;\n    const [targetPath, queryString] = path.split(\"?\");\n    const targetQuery = query || this._parseQuery(queryString || \"\");\n    return (\n      current.path === targetPath &&\n      JSON.stringify(current.params) === JSON.stringify(params || {}) &&\n      JSON.stringify(current.query) === JSON.stringify(targetQuery)\n    );\n  }\n\n  /**\n   * Injects dynamic parameters into a path string.\n   * Replaces `:param` placeholders with URL-encoded values from the params object.\n   *\n   * @private\n   * @param {string} path - The path pattern containing `:param` placeholders.\n   * @param {RouteParams} params - Key-value pairs to inject into the path.\n   * @returns {string} The path with all parameters replaced.\n   *\n   * @example\n   * this._buildPath('/users/:id/posts/:postId', { id: '123', postId: '456' });\n   * // Returns: '/users/123/posts/456'\n   */\n  _buildPath(path, params) {\n    let result = path;\n    for (const [key, value] of Object.entries(params)) {\n      // Fix: Handle special characters and ensure proper encoding\n      const encodedValue = encodeURIComponent(String(value));\n      result = result.replace(new RegExp(`:${key}\\\\b`, \"g\"), encodedValue);\n    }\n    return result;\n  }\n\n  /**\n   * The handler for browser-initiated route changes (e.g., back/forward buttons).\n   *\n   * @private\n   * @async\n   * @param {boolean} [isPopState=true] - Whether this is a popstate event (back/forward navigation).\n   * @returns {Promise<void>}\n   * @emits router:error When route change handling fails.\n   */\n  async _handleRouteChange(isPopState = true) {\n    if (this._isNavigating) return;\n\n    try {\n      const from = this.currentRoute.value;\n      const toLocation = this._getCurrentLocation();\n\n      const navigationSuccessful = await this._proceedWithNavigation(\n        toLocation.fullUrl,\n        isPopState\n      );\n\n      // If navigation was blocked by a guard, revert the URL change\n      if (!navigationSuccessful && from) {\n        this.navigate({ path: from.path, query: from.query, replace: true });\n      }\n    } catch (error) {\n      this.errorHandler.log(\"Route change handling failed\", error, {\n        currentUrl: typeof window !== \"undefined\" ? window.location.href : \"\",\n      });\n      await this.emitter.emit(\"router:error\", error);\n    }\n  }\n\n  /**\n   * Manages the core navigation lifecycle. Runs guards before committing changes.\n   *\n   * @private\n   * @async\n   * @param {string} fullPath - The full path (e.g., '/users/123?foo=bar') to navigate to.\n   * @param {boolean} [isPopState=false] - Whether this navigation was triggered by popstate (back/forward).\n   * @returns {Promise<boolean>} `true` if navigation succeeded, `false` if aborted.\n   * @emits router:error When no matching route is found (and no catch-all route exists),\n   * or when an error occurs during navigation.\n   * @emits router:beforeResolve Before component resolution (can block/redirect).\n   * @emits router:afterResolve After components are resolved.\n   * @emits router:afterLeave After leaving the previous route.\n   * @emits router:beforeRender Before DOM rendering.\n   * @emits router:afterRender After DOM rendering completes.\n   * @emits router:scroll After render, for scroll behavior handling.\n   * @emits router:afterEnter After entering the new route.\n   * @emits router:afterEach After navigation completes successfully.\n   * @see _runGuards - Guard execution.\n   * @see _resolveComponents - Component resolution.\n   * @see _render - DOM rendering.\n   */\n  async _proceedWithNavigation(fullPath, isPopState = false) {\n    const from = this.currentRoute.value;\n    const [path, queryString] = (fullPath || \"/\").split(\"?\");\n    const toLocation = {\n      path: path.startsWith(\"/\") ? path : `/${path}`,\n      query: this._parseQuery(queryString),\n      fullUrl: fullPath,\n    };\n\n    let toMatch = this._matchRoute(toLocation.path);\n\n    if (!toMatch) {\n      const notFoundRoute = this.routes.find((route) => route.path === \"*\");\n      if (notFoundRoute) {\n        toMatch = {\n          route: notFoundRoute,\n          params: {\n            pathMatch: decodeURIComponent(toLocation.path.substring(1)),\n          },\n        };\n      } else {\n        await this.emitter.emit(\n          \"router:error\",\n          new Error(`Route not found: ${toLocation.path}`),\n          toLocation,\n          from\n        );\n        return false;\n      }\n    }\n\n    const to = {\n      ...toLocation,\n      params: toMatch.params,\n      meta: toMatch.route.meta || {},\n      name: toMatch.route.name,\n      matched: toMatch.route,\n    };\n\n    try {\n      // 1. Run all *pre-navigation* guards.\n      const canNavigate = await this._runGuards(to, from, toMatch.route);\n      if (!canNavigate) return false;\n\n      // 2. Save current scroll position before navigating away\n      if (from && typeof window !== \"undefined\") {\n        this._scrollPositions.set(from.path, {\n          x: window.scrollX || window.pageXOffset || 0,\n          y: window.scrollY || window.pageYOffset || 0,\n        });\n      }\n\n      // 3. Emit beforeResolve event - plugins can show loading indicators\n      /** @type {ResolveContext} */\n      const resolveContext = {\n        to,\n        from,\n        route: toMatch.route,\n        layoutComponent: null,\n        pageComponent: null,\n        cancelled: false,\n        redirectTo: null,\n      };\n      await this.emitter.emit(\"router:beforeResolve\", resolveContext);\n\n      // Check if resolution was cancelled or redirected\n      if (resolveContext.cancelled) return false;\n      if (resolveContext.redirectTo) {\n        this.navigate(resolveContext.redirectTo);\n        return false;\n      }\n\n      // 4. Resolve async components *before* touching the DOM.\n      const { layoutComponent, pageComponent } = await this._resolveComponents(\n        toMatch.route\n      );\n\n      // 5. Emit afterResolve event - plugins can hide loading indicators\n      resolveContext.layoutComponent = layoutComponent;\n      resolveContext.pageComponent = pageComponent;\n      await this.emitter.emit(\"router:afterResolve\", resolveContext);\n\n      // 6. Unmount the previous view/layout.\n      if (from) {\n        const toLayout = toMatch.route.layout || this.options.globalLayout;\n        const fromLayout = from.matched.layout || this.options.globalLayout;\n\n        const tryUnmount = async (instance) => {\n          if (!instance) return;\n\n          try {\n            await instance.unmount();\n          } catch (error) {\n            this.errorHandler.warn(\"Error during component unmount\", {\n              error,\n              instance,\n            });\n          }\n        };\n\n        if (toLayout !== fromLayout) {\n          await tryUnmount(this.currentLayout.value);\n          this.currentLayout.value = null;\n        } else {\n          await tryUnmount(this.currentView.value);\n          this.currentView.value = null;\n        }\n\n        // Call `afterLeave` hook *after* the old component has been unmounted.\n        if (from.matched.afterLeave) {\n          await from.matched.afterLeave(to, from);\n        }\n        await this.emitter.emit(\"router:afterLeave\", to, from);\n      }\n\n      // 7. Update reactive state.\n      this.previousRoute.value = from;\n      this.currentRoute.value = to;\n      this.currentParams.value = to.params || {};\n      this.currentQuery.value = to.query || {};\n\n      // 8. Emit beforeRender event - plugins can add transitions\n      /** @type {RenderContext} */\n      const renderContext = {\n        to,\n        from,\n        layoutComponent,\n        pageComponent,\n      };\n      await this.emitter.emit(\"router:beforeRender\", renderContext);\n\n      // 9. Render the new components.\n      await this._render(layoutComponent, pageComponent);\n\n      // 10. Emit afterRender event - plugins can trigger animations\n      await this.emitter.emit(\"router:afterRender\", renderContext);\n\n      // 11. Emit scroll event - plugins can handle scroll restoration\n      /** @type {ScrollContext} */\n      const scrollContext = {\n        to,\n        from,\n        savedPosition: isPopState\n          ? this._scrollPositions.get(to.path) || null\n          : null,\n      };\n      await this.emitter.emit(\"router:scroll\", scrollContext);\n\n      // 12. Run post-navigation hooks.\n      if (toMatch.route.afterEnter) {\n        await toMatch.route.afterEnter(to, from);\n      }\n      await this.emitter.emit(\"router:afterEnter\", to, from);\n      await this.emitter.emit(\"router:afterEach\", to, from);\n\n      return true;\n    } catch (error) {\n      this.errorHandler.log(\"Error during navigation\", error, { to, from });\n      await this.emitter.emit(\"router:error\", error, to, from);\n      return false;\n    }\n  }\n\n  /**\n   * Executes all applicable navigation guards for a transition in order.\n   * Guards are executed in the following order:\n   * 1. Global beforeEach event (emitter-based, can block via context)\n   * 2. Global beforeEach guards (registered via onBeforeEach)\n   * 3. Route-specific beforeLeave guard (from the route being left)\n   * 4. Route-specific beforeEnter guard (from the route being entered)\n   *\n   * @private\n   * @param {RouteLocation} to - The target route location.\n   * @param {RouteLocation | null} from - The current route location (null on initial navigation).\n   * @param {RouteDefinition} route - The matched route definition.\n   * @returns {Promise<boolean>} `false` if navigation should be aborted.\n   * @emits router:beforeEach Before guards run (can block/redirect via context).\n   */\n  async _runGuards(to, from, route) {\n    // Create navigation context that plugins can modify to block navigation\n    /** @type {NavigationContext} */\n    const navContext = {\n      to,\n      from,\n      cancelled: false,\n      redirectTo: null,\n    };\n\n    // Emit beforeEach event with context - plugins can block by modifying context\n    await this.emitter.emit(\"router:beforeEach\", navContext);\n\n    // Check if navigation was cancelled or redirected by event listeners\n    if (navContext.cancelled) return false;\n    if (navContext.redirectTo) {\n      this.navigate(navContext.redirectTo);\n      return false;\n    }\n\n    // Collect all guards in execution order\n    const guards = [\n      ...this._beforeEachGuards,\n      ...(from && from.matched.beforeLeave ? [from.matched.beforeLeave] : []),\n      ...(route.beforeEnter ? [route.beforeEnter] : []),\n    ];\n\n    for (const guard of guards) {\n      const result = await guard(to, from);\n      if (result === false) return false;\n      if (typeof result === \"string\" || typeof result === \"object\") {\n        this.navigate(result);\n        return false;\n      }\n    }\n    return true;\n  }\n\n  /**\n   * Resolves a string component definition to a component object.\n   * @private\n   * @param {string} def - The component name to resolve.\n   * @returns {ComponentDefinition} The resolved component.\n   * @throws {Error} If the component is not registered.\n   *\n   * @note Core plugins (Router, Attr, Store) may access eleva._components\n   * directly. This is intentional and stable for official Eleva plugins shipped\n   * with the framework. Third-party plugins should use eleva.component() for\n   * registration and avoid direct access to internal APIs.\n   */\n  _resolveStringComponent(def) {\n    const componentDef = this.eleva._components.get(def);\n    if (!componentDef) {\n      this.errorHandler.handle(\n        new Error(`Component \"${def}\" not registered.`),\n        \"Component resolution failed\",\n        {\n          componentName: def,\n          availableComponents: Array.from(this.eleva._components.keys()),\n        }\n      );\n    }\n    return componentDef;\n  }\n\n  /**\n   * Resolves a function component definition to a component object.\n   * @private\n   * @async\n   * @param {() => ComponentDefinition | Promise<ComponentDefinition | { default: ComponentDefinition }>} def - The function to resolve.\n   * @returns {Promise<ComponentDefinition>} The resolved component.\n   * @throws {Error} If the function fails to load the component.\n   */\n  async _resolveFunctionComponent(def) {\n    try {\n      const funcStr = def.toString();\n      const isAsyncImport =\n        funcStr.includes(\"import(\") || funcStr.startsWith(\"() =>\");\n\n      const result = await def();\n      return isAsyncImport ? result.default || result : result;\n    } catch (error) {\n      this.errorHandler.handle(\n        new Error(`Failed to load async component: ${error.message}`),\n        \"Component resolution failed\",\n        { function: def.toString(), error }\n      );\n    }\n  }\n\n  /**\n   * Validates a component definition object.\n   * @private\n   * @param {unknown} def - The component definition to validate.\n   * @returns {ComponentDefinition} The validated component.\n   * @throws {Error} If the component definition is invalid.\n   */\n  _validateComponentDefinition(def) {\n    if (!def || typeof def !== \"object\") {\n      this.errorHandler.handle(\n        new Error(`Invalid component definition: ${typeof def}`),\n        \"Component validation failed\",\n        { definition: def }\n      );\n    }\n\n    if (\n      typeof def.template !== \"function\" &&\n      typeof def.template !== \"string\"\n    ) {\n      this.errorHandler.handle(\n        new Error(\"Component missing template property\"),\n        \"Component validation failed\",\n        { definition: def }\n      );\n    }\n\n    return def;\n  }\n\n  /**\n   * Resolves a component definition to a component object.\n   * @private\n   * @param {unknown} def - The component definition to resolve.\n   * @returns {Promise<ComponentDefinition | null>} The resolved component or null.\n   */\n  async _resolveComponent(def) {\n    if (def === null || def === undefined) {\n      return null;\n    }\n\n    if (typeof def === \"string\") {\n      return this._resolveStringComponent(def);\n    }\n\n    if (typeof def === \"function\") {\n      return await this._resolveFunctionComponent(def);\n    }\n\n    if (def && typeof def === \"object\") {\n      return this._validateComponentDefinition(def);\n    }\n\n    this.errorHandler.handle(\n      new Error(`Invalid component definition: ${typeof def}`),\n      \"Component resolution failed\",\n      { definition: def }\n    );\n  }\n\n  /**\n   * Asynchronously resolves the layout and page components for a route.\n   * @private\n   * @async\n   * @param {RouteDefinition} route - The route to resolve components for.\n   * @returns {Promise<{layoutComponent: ComponentDefinition | null, pageComponent: ComponentDefinition}>}\n   * @throws {Error} If page component cannot be resolved.\n   */\n  async _resolveComponents(route) {\n    const effectiveLayout = route.layout || this.options.globalLayout;\n\n    try {\n      const [layoutComponent, pageComponent] = await Promise.all([\n        this._resolveComponent(effectiveLayout),\n        this._resolveComponent(route.component),\n      ]);\n\n      if (!pageComponent) {\n        this.errorHandler.handle(\n          new Error(\n            `Page component is null or undefined for route: ${route.path}`\n          ),\n          \"Component resolution failed\",\n          { route: route.path }\n        );\n      }\n\n      return { layoutComponent, pageComponent };\n    } catch (error) {\n      this.errorHandler.log(\n        `Error resolving components for route ${route.path}`,\n        error,\n        { route: route.path }\n      );\n      throw error;\n    }\n  }\n\n  /**\n   * Renders the components for the current route into the DOM.\n   *\n   * Rendering algorithm:\n   * 1. Find the mount element using options.mount selector\n   * 2. If layoutComponent exists:\n   *    a. Mount layout to mount element\n   *    b. Find view element within layout (using viewSelector)\n   *    c. Mount page component to view element\n   * 3. If no layoutComponent:\n   *    a. Mount page component directly to mount element\n   *    b. Set currentLayout to null\n   *\n   * @private\n   * @async\n   * @param {ComponentDefinition | null} layoutComponent - The pre-loaded layout component.\n   * @param {ComponentDefinition} pageComponent - The pre-loaded page component.\n   * @returns {Promise<void>}\n   * @throws {Error} If mount element is not found in the DOM.\n   * @throws {Error} If component mounting fails (propagated from eleva.mount).\n   */\n  async _render(layoutComponent, pageComponent) {\n    const mountEl = document.querySelector(this.options.mount);\n    if (!mountEl) {\n      this.errorHandler.handle(\n        new Error(`Mount element \"${this.options.mount}\" not found.`),\n        { mountSelector: this.options.mount }\n      );\n    }\n\n    if (layoutComponent) {\n      const layoutInstance = await this.eleva.mount(\n        mountEl,\n        this._wrapComponentWithChildren(layoutComponent)\n      );\n      this.currentLayout.value = layoutInstance;\n      const viewEl = this._findViewElement(layoutInstance.container);\n      const viewInstance = await this.eleva.mount(\n        viewEl,\n        this._wrapComponentWithChildren(pageComponent)\n      );\n      this.currentView.value = viewInstance;\n    } else {\n      const viewInstance = await this.eleva.mount(\n        mountEl,\n        this._wrapComponentWithChildren(pageComponent)\n      );\n      this.currentView.value = viewInstance;\n      this.currentLayout.value = null;\n    }\n  }\n\n  /**\n   * Creates a getter function for router context properties.\n   * @private\n   * @param {string} property - The property name to access.\n   * @param {unknown} defaultValue - The default value if property is undefined.\n   * @returns {() => unknown} A getter function.\n   */\n  _createRouteGetter(property, defaultValue) {\n    return () => this.currentRoute.value?.[property] ?? defaultValue;\n  }\n\n  /**\n   * Wraps a component definition to inject router-specific context into its setup function.\n   * @private\n   * @param {ComponentDefinition} component - The component to wrap.\n   * @returns {ComponentDefinition} The wrapped component definition.\n   */\n  _wrapComponent(component) {\n    const originalSetup = component.setup;\n    const self = this;\n\n    return {\n      ...component,\n      async setup(ctx) {\n        /** @type {RouterContext} */\n        ctx.router = {\n          navigate: self.navigate.bind(self),\n          current: self.currentRoute,\n          previous: self.previousRoute,\n\n          // Route property getters\n          get params() {\n            return self._createRouteGetter(\"params\", {})();\n          },\n          get query() {\n            return self._createRouteGetter(\"query\", {})();\n          },\n          get path() {\n            return self._createRouteGetter(\"path\", \"/\")();\n          },\n          get fullUrl() {\n            return self._createRouteGetter(\"fullUrl\", window.location.href)();\n          },\n          get meta() {\n            return self._createRouteGetter(\"meta\", {})();\n          },\n        };\n\n        return originalSetup ? await originalSetup(ctx) : {};\n      },\n    };\n  }\n\n  /**\n   * Recursively wraps all child components to ensure they have access to router context.\n   * String component references are returned as-is (context injected during mount).\n   * Objects are wrapped with router context and their children are recursively wrapped.\n   *\n   * @private\n   * @param {ComponentDefinition | string} component - The component to wrap (can be a definition object or a registered component name).\n   * @returns {ComponentDefinition | string} The wrapped component definition or the original string reference.\n   * @see _wrapComponent - Single component wrapping.\n   */\n  _wrapComponentWithChildren(component) {\n    // If the component is a string (registered component name), return as-is\n    // The router context will be injected when the component is resolved during mounting\n    if (typeof component === \"string\") {\n      return component;\n    }\n\n    // If not a valid component object, return as-is\n    if (!component || typeof component !== \"object\") {\n      return component;\n    }\n\n    const wrappedComponent = this._wrapComponent(component);\n\n    // If the component has children, wrap them too\n    if (\n      wrappedComponent.children &&\n      typeof wrappedComponent.children === \"object\"\n    ) {\n      const wrappedChildren = {};\n      for (const [selector, childComponent] of Object.entries(\n        wrappedComponent.children\n      )) {\n        wrappedChildren[selector] =\n          this._wrapComponentWithChildren(childComponent);\n      }\n      wrappedComponent.children = wrappedChildren;\n    }\n\n    return wrappedComponent;\n  }\n\n  /**\n   * Gets the current location information from the browser's window object.\n   * @private\n   * @returns {Omit<RouteLocation, 'params' | 'meta' | 'name' | 'matched'>}\n   */\n  _getCurrentLocation() {\n    if (typeof window === \"undefined\")\n      return { path: \"/\", query: {}, fullUrl: \"\" };\n    let path, queryString, fullUrl;\n    switch (this.options.mode) {\n      case \"hash\":\n        fullUrl = window.location.hash.slice(1) || \"/\";\n        [path, queryString] = fullUrl.split(\"?\");\n        break;\n      case \"query\":\n        const urlParams = new URLSearchParams(window.location.search);\n        path = urlParams.get(this.options.queryParam) || \"/\";\n        queryString = window.location.search.slice(1);\n        fullUrl = path;\n        break;\n      default: // 'history' mode\n        path = window.location.pathname || \"/\";\n        queryString = window.location.search.slice(1);\n        fullUrl = `${path}${queryString ? \"?\" + queryString : \"\"}`;\n    }\n    return {\n      path: path.startsWith(\"/\") ? path : `/${path}`,\n      query: this._parseQuery(queryString),\n      fullUrl,\n    };\n  }\n\n  /**\n   * Parses a query string into a key-value object.\n   * Uses URLSearchParams for robust parsing of encoded values.\n   *\n   * @private\n   * @param {string} queryString - The query string to parse (without leading '?').\n   * @returns {QueryParams} Key-value pairs from the query string.\n   *\n   * @example\n   * this._parseQuery('foo=bar&baz=qux');\n   * // Returns: { foo: 'bar', baz: 'qux' }\n   */\n  _parseQuery(queryString) {\n    const query = {};\n    if (queryString) {\n      new URLSearchParams(queryString).forEach((value, key) => {\n        query[key] = value;\n      });\n    }\n    return query;\n  }\n\n  /**\n   * Matches a given path against the registered routes.\n   * @private\n   * @param {string} path - The path to match.\n   * @returns {{route: RouteDefinition, params: Object<string, string>} | null} The matched route and its params, or null.\n   */\n  _matchRoute(path) {\n    const pathSegments = path.split(\"/\").filter(Boolean);\n\n    for (const route of this.routes) {\n      // Handle the root path as a special case.\n      if (route.path === \"/\") {\n        if (pathSegments.length === 0) return { route, params: {} };\n        continue;\n      }\n\n      if (route.segments.length !== pathSegments.length) continue;\n\n      const params = {};\n      let isMatch = true;\n      for (let i = 0; i < route.segments.length; i++) {\n        const routeSegment = route.segments[i];\n        const pathSegment = pathSegments[i];\n        if (routeSegment.type === \"param\") {\n          params[routeSegment.name] = decodeURIComponent(pathSegment);\n        } else if (routeSegment.value !== pathSegment) {\n          isMatch = false;\n          break;\n        }\n      }\n      if (isMatch) return { route, params };\n    }\n    return null;\n  }\n\n  // ============================================\n  // Dynamic Route Management API\n  // ============================================\n\n  /**\n   * Adds a new route dynamically at runtime.\n   * The route will be processed and available for navigation immediately.\n   * Routes are inserted before the wildcard (*) route if one exists.\n   *\n   * @param {RouteDefinition} route - The route definition to add.\n   * @param {RouteDefinition} [parentRoute] - Optional parent route to add as a child (not yet implemented).\n   * @returns {() => void} A function to remove the added route (returns no-op if route was invalid).\n   * @emits router:routeAdded When a route is successfully added.\n   *\n   * @example\n   * // Add a route dynamically\n   * const removeRoute = router.addRoute({\n   *   path: '/dynamic',\n   *   component: DynamicPage,\n   *   meta: { title: 'Dynamic Page' }\n   * });\n   *\n   * // Later, remove the route\n   * removeRoute();\n   */\n  addRoute(route, parentRoute = null) {\n    if (!route || !route.path) {\n      this.errorHandler.warn(\"Invalid route definition: missing path\", {\n        route,\n      });\n      return () => {};\n    }\n\n    // Check if route already exists\n    if (this.hasRoute(route.path)) {\n      this.errorHandler.warn(`Route \"${route.path}\" already exists`, { route });\n      return () => {};\n    }\n\n    // Process the route (parse segments)\n    const processedRoute = {\n      ...route,\n      segments: this._parsePathIntoSegments(route.path),\n    };\n\n    // Add to routes array (before wildcard if exists)\n    const wildcardIndex = this.routes.findIndex((r) => r.path === \"*\");\n    if (wildcardIndex !== -1) {\n      this.routes.splice(wildcardIndex, 0, processedRoute);\n    } else {\n      this.routes.push(processedRoute);\n    }\n\n    // Emit event for plugins\n    this.emitter.emit(\"router:routeAdded\", processedRoute);\n\n    // Return removal function\n    return () => this.removeRoute(route.path);\n  }\n\n  /**\n   * Removes a route by its path.\n   *\n   * @param {string} path - The path of the route to remove.\n   * @returns {boolean} True if the route was removed, false if not found.\n   * @emits router:routeRemoved When a route is successfully removed.\n   *\n   * @example\n   * router.removeRoute('/dynamic');\n   */\n  removeRoute(path) {\n    const index = this.routes.findIndex((r) => r.path === path);\n    if (index === -1) {\n      return false;\n    }\n\n    const [removedRoute] = this.routes.splice(index, 1);\n\n    // Emit event for plugins\n    this.emitter.emit(\"router:routeRemoved\", removedRoute);\n\n    return true;\n  }\n\n  /**\n   * Checks if a route with the given path exists.\n   *\n   * @param {string} path - The path to check.\n   * @returns {boolean} True if the route exists.\n   *\n   * @example\n   * if (router.hasRoute('/users/:id')) {\n   *   console.log('User route exists');\n   * }\n   */\n  hasRoute(path) {\n    return this.routes.some((r) => r.path === path);\n  }\n\n  /**\n   * Gets all registered routes.\n   *\n   * @returns {RouteDefinition[]} A copy of the routes array.\n   *\n   * @example\n   * const routes = router.getRoutes();\n   * console.log('Available routes:', routes.map(r => r.path));\n   */\n  getRoutes() {\n    return [...this.routes];\n  }\n\n  /**\n   * Gets a route by its path.\n   *\n   * @param {string} path - The path of the route to get.\n   * @returns {RouteDefinition | undefined} The route definition or undefined.\n   *\n   * @example\n   * const route = router.getRoute('/users/:id');\n   * if (route) {\n   *   console.log('Route meta:', route.meta);\n   * }\n   */\n  getRoute(path) {\n    return this.routes.find((r) => r.path === path);\n  }\n\n  // ============================================\n  // Hook Registration Methods\n  // ============================================\n\n  /**\n   * Registers a global pre-navigation guard.\n   * Multiple guards can be registered and will be executed in order.\n   * Guards can also be registered via the emitter using `router:beforeEach` event.\n   *\n   * @param {NavigationGuard} guard - The guard function to register.\n   * @returns {() => void} A function to unregister the guard.\n   *\n   * @example\n   * // Register a guard\n   * const unregister = router.onBeforeEach((to, from) => {\n   *   if (to.meta.requiresAuth && !isAuthenticated()) {\n   *     return '/login';\n   *   }\n   * });\n   *\n   * // Later, unregister the guard\n   * unregister();\n   */\n  onBeforeEach(guard) {\n    this._beforeEachGuards.push(guard);\n    return () => {\n      const index = this._beforeEachGuards.indexOf(guard);\n      if (index > -1) {\n        this._beforeEachGuards.splice(index, 1);\n      }\n    };\n  }\n  /**\n   * Registers a global hook that runs after a new route component has been mounted.\n   * @param {NavigationHook} hook - The hook function to register.\n   * @returns {() => void} A function to unregister the hook.\n   * @listens router:afterEnter\n   */\n  onAfterEnter(hook) {\n    return this.emitter.on(\"router:afterEnter\", hook);\n  }\n\n  /**\n   * Registers a global hook that runs after a route component has been unmounted.\n   * @param {NavigationHook} hook - The hook function to register.\n   * @returns {() => void} A function to unregister the hook.\n   * @listens router:afterLeave\n   */\n  onAfterLeave(hook) {\n    return this.emitter.on(\"router:afterLeave\", hook);\n  }\n\n  /**\n   * Registers a global hook that runs after a navigation has been confirmed and all hooks have completed.\n   * @param {NavigationHook} hook - The hook function to register.\n   * @returns {() => void} A function to unregister the hook.\n   * @listens router:afterEach\n   */\n  onAfterEach(hook) {\n    return this.emitter.on(\"router:afterEach\", hook);\n  }\n\n  /**\n   * Registers a global error handler for navigation errors.\n   * @param {(error: Error, to?: RouteLocation, from?: RouteLocation) => void} handler - The error handler function.\n   * @returns {() => void} A function to unregister the handler.\n   * @listens router:error\n   */\n  onError(handler) {\n    return this.emitter.on(\"router:error\", handler);\n  }\n\n  /**\n   * Registers a plugin with the router.\n   * Logs a warning if the plugin is already registered.\n   *\n   * @param {RouterPlugin} plugin - The plugin to register (must have install method).\n   * @param {Record<string, unknown>} [options={}] - Options to pass to plugin.install().\n   * @returns {void}\n   * @throws {Error} If plugin does not have an install method.\n   */\n  use(plugin, options = {}) {\n    if (typeof plugin.install !== \"function\") {\n      this.errorHandler.handle(\n        new Error(\"Plugin must have an install method\"),\n        \"Plugin registration failed\",\n        { plugin }\n      );\n    }\n\n    // Check if plugin is already registered\n    if (this.plugins.has(plugin.name)) {\n      this.errorHandler.warn(`Plugin \"${plugin.name}\" is already registered`, {\n        existingPlugin: this.plugins.get(plugin.name),\n      });\n      return;\n    }\n\n    this.plugins.set(plugin.name, plugin);\n    plugin.install(this, options);\n  }\n\n  /**\n   * Gets all registered plugins.\n   * @returns {RouterPlugin[]} Array of registered plugins.\n   */\n  getPlugins() {\n    return Array.from(this.plugins.values());\n  }\n\n  /**\n   * Gets a plugin by name.\n   * @param {string} name - The plugin name.\n   * @returns {RouterPlugin | undefined} The plugin or undefined.\n   */\n  getPlugin(name) {\n    return this.plugins.get(name);\n  }\n\n  /**\n   * Removes a plugin from the router.\n   * @param {string} name - The plugin name.\n   * @returns {boolean} True if the plugin was removed.\n   */\n  removePlugin(name) {\n    const plugin = this.plugins.get(name);\n    if (!plugin) return false;\n\n    // Call destroy if available\n    if (typeof plugin.destroy === \"function\") {\n      try {\n        plugin.destroy(this);\n      } catch (error) {\n        this.errorHandler.log(`Plugin ${name} destroy failed`, error);\n      }\n    }\n\n    return this.plugins.delete(name);\n  }\n\n  /**\n   * Sets a custom error handler. Used by error handling plugins.\n   * Logs a warning if the provided handler is invalid (missing required methods).\n   * @param {RouterErrorHandler} errorHandler - The error handler object with handle, warn, and log methods.\n   * @returns {void}\n   */\n  setErrorHandler(errorHandler) {\n    if (\n      errorHandler &&\n      typeof errorHandler.handle === \"function\" &&\n      typeof errorHandler.warn === \"function\" &&\n      typeof errorHandler.log === \"function\"\n    ) {\n      this.errorHandler = errorHandler;\n    } else {\n      console.warn(\n        \"[ElevaRouter] Invalid error handler provided. Must have handle, warn, and log methods.\"\n      );\n    }\n  }\n}\n\n/**\n * @class 🚀 RouterPlugin\n * @classdesc A powerful, reactive, and flexible Router Plugin for Eleva applications.\n * This plugin provides comprehensive client-side routing functionality including:\n * - Multiple routing modes (hash, history, query)\n * - Navigation guards and lifecycle hooks\n * - Reactive state management\n * - Component resolution and lazy loading\n * - Layout and page component separation\n * - Plugin system for extensibility\n * - Advanced error handling\n *\n * @example\n * // Install the plugin\n * const app = new Eleva(\"myApp\");\n *\n * const HomePage = { template: () => `<h1>Home</h1>` };\n * const AboutPage = { template: () => `<h1>About Us</h1>` };\n * const UserPage = {\n *   template: (ctx) => `<h1>User: ${ctx.router.params.id}</h1>`\n * };\n *\n * app.use(RouterPlugin, {\n *   mount: '#app',\n *   mode: 'hash',\n *   routes: [\n *     { path: '/', component: HomePage },\n *     { path: '/about', component: AboutPage },\n *     { path: '/users/:id', component: UserPage }\n *   ]\n * });\n */\nexport const RouterPlugin = {\n  /**\n   * Unique identifier for the plugin\n   * @type {string}\n   */\n  name: \"router\",\n\n  /**\n   * Plugin version\n   * @type {string}\n   */\n  version: \"1.1.1\",\n\n  /**\n   * Plugin description\n   * @type {string}\n   */\n  description: \"Client-side routing for Eleva applications\",\n\n  /**\n   * Installs the RouterPlugin into an Eleva instance.\n   *\n   * @public\n   * @param {Eleva} eleva - The Eleva instance.\n   * @param {RouterOptions} options - Router configuration options.\n   * @param {string} options.mount - A CSS selector for the main element where the app is mounted.\n   * @param {RouteDefinition[]} options.routes - An array of route definitions.\n   * @param {'hash' | 'query' | 'history'} [options.mode='hash'] - The routing mode.\n   * @param {string} [options.queryParam='view'] - The query parameter to use in 'query' mode.\n   * @param {string} [options.viewSelector='view'] - Base selector for the view element (matched as #id, .class, [data-*], or raw selector).\n   * @param {boolean} [options.autoStart=true] - Whether to start the router automatically.\n   * @param {NavigationGuard} [options.onBeforeEach] - A global guard executed before every navigation.\n   * @param {RouteComponent} [options.globalLayout] - A global layout for all routes.\n   * @returns {Router} The created router instance.\n   * @throws {Error} If 'mount' option is not provided.\n   * @throws {Error} If 'routes' option is not an array.\n   * @throws {Error} If component registration fails during route processing.\n   * @description\n   * Registers route/layout components, sets `eleva.router`, and adds helpers\n   * (`eleva.navigate`, `eleva.getCurrentRoute`, `eleva.getRouteParams`, `eleva.getRouteQuery`).\n   * When `autoStart` is enabled, startup is scheduled via microtask.\n   *\n   * @example\n   * // main.js\n   * import Eleva from 'eleva';\n   * import { RouterPlugin } from './plugins/RouterPlugin.js';\n   *\n   * const app = new Eleva('myApp');\n   *\n   * const HomePage = { template: () => `<h1>Home</h1>` };\n   * const AboutPage = { template: () => `<h1>About Us</h1>` };\n   *\n   * app.use(RouterPlugin, {\n   *  mount: '#app',\n   *  routes: [\n   *    { path: '/', component: HomePage },\n   *    { path: '/about', component: AboutPage }\n   *  ]\n   * });\n   */\n  install(eleva, options = {}) {\n    if (!options.mount) {\n      throw new Error(\"[RouterPlugin] 'mount' option is required\");\n    }\n\n    if (!options.routes || !Array.isArray(options.routes)) {\n      throw new Error(\"[RouterPlugin] 'routes' option must be an array\");\n    }\n\n    /**\n     * Registers a component definition with the Eleva instance.\n     * This method handles both inline component objects and pre-registered component names.\n     *\n     * @inner\n     * @param {unknown} def - The component definition to register.\n     * @param {string} type - The type of component for naming (e.g., \"Route\", \"Layout\").\n     * @returns {string | null} The registered component name or null if no definition provided.\n     */\n    const register = (def, type) => {\n      if (!def) return null;\n\n      if (typeof def === \"object\" && def !== null && !def.name) {\n        const name = `Eleva${type}Component_${Math.random()\n          .toString(36)\n          .slice(2, 11)}`;\n\n        try {\n          eleva.component(name, def);\n          return name;\n        } catch (error) {\n          throw new Error(\n            `[RouterPlugin] Failed to register ${type} component: ${error.message}`\n          );\n        }\n      }\n      return def;\n    };\n\n    if (options.globalLayout) {\n      options.globalLayout = register(options.globalLayout, \"GlobalLayout\");\n    }\n\n    (options.routes || []).forEach((route) => {\n      route.component = register(route.component, \"Route\");\n      if (route.layout) {\n        route.layout = register(route.layout, \"RouteLayout\");\n      }\n    });\n\n    const router = new Router(eleva, options);\n    /** @type {Router} */\n    eleva.router = router;\n\n    if (options.autoStart !== false) {\n      queueMicrotask(() => router.start());\n    }\n\n    // Add plugin metadata to the Eleva instance\n    if (!eleva.plugins) {\n      eleva.plugins = new Map();\n    }\n    eleva.plugins.set(this.name, {\n      name: this.name,\n      version: this.version,\n      description: this.description,\n      options,\n    });\n\n    // Add utility methods for manual router access\n    /** @type {NavigateFunction} */\n    eleva.navigate = router.navigate.bind(router);\n    /** @type {() => RouteLocation | null} */\n    eleva.getCurrentRoute = () => router.currentRoute.value;\n    /** @type {() => RouteParams} */\n    eleva.getRouteParams = () => router.currentParams.value;\n    /** @type {() => QueryParams} */\n    eleva.getRouteQuery = () => router.currentQuery.value;\n\n    return router;\n  },\n\n  /**\n   * Uninstalls the plugin from the Eleva instance.\n   *\n   * @public\n   * @async\n   * @param {Eleva} eleva - The Eleva instance.\n   * @returns {Promise<void>}\n   * @description\n   * Destroys the router instance, removes `eleva.router`, and deletes helper methods\n   * (`eleva.navigate`, `eleva.getCurrentRoute`, `eleva.getRouteParams`, `eleva.getRouteQuery`).\n   */\n  async uninstall(eleva) {\n    if (eleva.router) {\n      await eleva.router.destroy();\n      delete eleva.router;\n    }\n\n    // Remove plugin metadata\n    if (eleva.plugins) {\n      eleva.plugins.delete(this.name);\n    }\n\n    // Remove utility methods\n    delete eleva.navigate;\n    delete eleva.getCurrentRoute;\n    delete eleva.getRouteParams;\n    delete eleva.getRouteQuery;\n  },\n};\n\n// Short name export for convenience\nexport { RouterPlugin as Router };\n"],"names":["CoreErrorHandler","handle","error","context","details","message","formattedError","Error","originalError","console","warn","log","Router","_validateOptions","includes","options","mode","errorHandler","_processRoutes","routes","processedRoutes","route","push","segments","_parsePathIntoSegments","path","normalizedPath","replace","split","filter","Boolean","map","segment","startsWith","paramName","substring","type","name","value","_findViewElement","container","selector","viewSelector","querySelector","start","isStarted","window","document","mount","mountSelector","handler","_handleRouteChange","addEventListener","eventListeners","removeEventListener","isReady","emitter","emit","destroy","plugin","plugins","values","forEach","cleanup","currentLayout","unmount","stop","navigate","location","params","target","_buildPath","query","Object","keys","length","queryString","URLSearchParams","toString","_isSameRoute","navigationSuccessful","_proceedWithNavigation","currentNavId","_navigationId","_isNavigating","state","historyMethod","newUrl","pathname","search","history","replaceState","hash","url","_buildQueryUrl","queueMicrotask","urlParams","set","queryParam","current","currentRoute","targetPath","targetQuery","_parseQuery","JSON","stringify","result","key","entries","encodedValue","encodeURIComponent","String","RegExp","isPopState","from","toLocation","_getCurrentLocation","fullUrl","currentUrl","href","fullPath","toMatch","_matchRoute","notFoundRoute","find","pathMatch","decodeURIComponent","to","meta","matched","canNavigate","_runGuards","_scrollPositions","x","scrollX","pageXOffset","y","scrollY","pageYOffset","resolveContext","layoutComponent","pageComponent","cancelled","redirectTo","_resolveComponents","toLayout","layout","globalLayout","fromLayout","tryUnmount","instance","currentView","afterLeave","previousRoute","currentParams","currentQuery","renderContext","_render","scrollContext","savedPosition","get","afterEnter","navContext","guards","_beforeEachGuards","beforeLeave","beforeEnter","guard","_resolveStringComponent","def","componentDef","eleva","_components","componentName","availableComponents","Array","_resolveFunctionComponent","funcStr","isAsyncImport","default","function","_validateComponentDefinition","definition","template","_resolveComponent","undefined","effectiveLayout","Promise","all","component","mountEl","layoutInstance","_wrapComponentWithChildren","viewEl","viewInstance","_createRouteGetter","property","defaultValue","_wrapComponent","originalSetup","setup","self","ctx","router","bind","previous","wrappedComponent","children","wrappedChildren","childComponent","slice","pathSegments","isMatch","i","routeSegment","pathSegment","addRoute","parentRoute","hasRoute","processedRoute","wildcardIndex","findIndex","r","splice","removeRoute","index","removedRoute","some","getRoutes","getRoute","onBeforeEach","indexOf","onAfterEnter","hook","on","onAfterLeave","onAfterEach","onError","use","install","has","existingPlugin","getPlugins","getPlugin","removePlugin","delete","setErrorHandler","signal","Map","RouterPlugin","version","description","isArray","register","Math","random","autoStart","getCurrentRoute","getRouteParams","getRouteQuery","uninstall"],"mappings":";;;AAEA;;;;AAIC;AAGD;AACA;AAEA;AACA;AACA;AAEA;;;;;;;;;;;AAaC;AAGD;AACA;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6EC;AAGD;AACA;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiIC;AAGD;AACA;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2GC;AAGD;AACA;AAEA;;;AAGC,IACD,MAAMA,gBAAAA,GAAmB;AACvB;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