eleva 1.0.0-alpha → 1.0.0-rc.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +554 -137
  3. package/dist/eleva-plugins.cjs.js +3397 -0
  4. package/dist/eleva-plugins.cjs.js.map +1 -0
  5. package/dist/eleva-plugins.esm.js +3392 -0
  6. package/dist/eleva-plugins.esm.js.map +1 -0
  7. package/dist/eleva-plugins.umd.js +3403 -0
  8. package/dist/eleva-plugins.umd.js.map +1 -0
  9. package/dist/eleva-plugins.umd.min.js +3 -0
  10. package/dist/eleva-plugins.umd.min.js.map +1 -0
  11. package/dist/eleva.cjs.js +1448 -0
  12. package/dist/eleva.cjs.js.map +1 -0
  13. package/dist/eleva.d.ts +1057 -80
  14. package/dist/eleva.esm.js +1230 -274
  15. package/dist/eleva.esm.js.map +1 -1
  16. package/dist/eleva.umd.js +1230 -274
  17. package/dist/eleva.umd.js.map +1 -1
  18. package/dist/eleva.umd.min.js +3 -0
  19. package/dist/eleva.umd.min.js.map +1 -0
  20. package/dist/plugins/attr.umd.js +231 -0
  21. package/dist/plugins/attr.umd.js.map +1 -0
  22. package/dist/plugins/attr.umd.min.js +3 -0
  23. package/dist/plugins/attr.umd.min.js.map +1 -0
  24. package/dist/plugins/props.umd.js +711 -0
  25. package/dist/plugins/props.umd.js.map +1 -0
  26. package/dist/plugins/props.umd.min.js +3 -0
  27. package/dist/plugins/props.umd.min.js.map +1 -0
  28. package/dist/plugins/router.umd.js +1807 -0
  29. package/dist/plugins/router.umd.js.map +1 -0
  30. package/dist/plugins/router.umd.min.js +3 -0
  31. package/dist/plugins/router.umd.min.js.map +1 -0
  32. package/dist/plugins/store.umd.js +684 -0
  33. package/dist/plugins/store.umd.js.map +1 -0
  34. package/dist/plugins/store.umd.min.js +3 -0
  35. package/dist/plugins/store.umd.min.js.map +1 -0
  36. package/package.json +240 -62
  37. package/src/core/Eleva.js +552 -145
  38. package/src/modules/Emitter.js +154 -18
  39. package/src/modules/Renderer.js +288 -86
  40. package/src/modules/Signal.js +132 -13
  41. package/src/modules/TemplateEngine.js +153 -27
  42. package/src/plugins/Attr.js +252 -0
  43. package/src/plugins/Props.js +590 -0
  44. package/src/plugins/Router.js +1919 -0
  45. package/src/plugins/Store.js +741 -0
  46. package/src/plugins/index.js +40 -0
  47. package/types/core/Eleva.d.ts +482 -48
  48. package/types/core/Eleva.d.ts.map +1 -1
  49. package/types/modules/Emitter.d.ts +151 -20
  50. package/types/modules/Emitter.d.ts.map +1 -1
  51. package/types/modules/Renderer.d.ts +151 -12
  52. package/types/modules/Renderer.d.ts.map +1 -1
  53. package/types/modules/Signal.d.ts +130 -16
  54. package/types/modules/Signal.d.ts.map +1 -1
  55. package/types/modules/TemplateEngine.d.ts +154 -14
  56. package/types/modules/TemplateEngine.d.ts.map +1 -1
  57. package/types/plugins/Attr.d.ts +28 -0
  58. package/types/plugins/Attr.d.ts.map +1 -0
  59. package/types/plugins/Props.d.ts +48 -0
  60. package/types/plugins/Props.d.ts.map +1 -0
  61. package/types/plugins/Router.d.ts +1000 -0
  62. package/types/plugins/Router.d.ts.map +1 -0
  63. package/types/plugins/Store.d.ts +86 -0
  64. package/types/plugins/Store.d.ts.map +1 -0
  65. package/types/plugins/index.d.ts +5 -0
  66. package/types/plugins/index.d.ts.map +1 -0
  67. package/dist/eleva.min.js +0 -2
  68. package/dist/eleva.min.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eleva-plugins.umd.js","sources":["../src/plugins/Attr.js","../src/plugins/Router.js","../src/modules/TemplateEngine.js","../src/plugins/Props.js","../src/plugins/Store.js"],"sourcesContent":["\"use strict\";\n\n/**\n * A regular expression to match hyphenated lowercase letters.\n * @private\n * @type {RegExp}\n */\nconst CAMEL_RE = /-([a-z])/g;\n\n/**\n * @class 🎯 AttrPlugin\n * @classdesc A plugin that provides advanced attribute handling for Eleva components.\n * This plugin extends the renderer with sophisticated attribute processing including:\n * - ARIA attribute handling with proper property mapping\n * - Data attribute management\n * - Boolean attribute processing\n * - Dynamic property detection and mapping\n * - Attribute cleanup and removal\n *\n * @example\n * // Install the plugin\n * const app = new Eleva(\"myApp\");\n * app.use(AttrPlugin);\n *\n * // Use advanced attributes in components\n * app.component(\"myComponent\", {\n * template: (ctx) => `\n * <button\n * aria-expanded=\"${ctx.isExpanded.value}\"\n * data-user-id=\"${ctx.userId.value}\"\n * disabled=\"${ctx.isLoading.value}\"\n * class=\"btn ${ctx.variant.value}\"\n * >\n * ${ctx.text.value}\n * </button>\n * `\n * });\n */\nexport const AttrPlugin = {\n /**\n * Unique identifier for the plugin\n * @type {string}\n */\n name: \"attr\",\n\n /**\n * Plugin version\n * @type {string}\n */\n version: \"1.0.0-rc.10\",\n\n /**\n * Plugin description\n * @type {string}\n */\n description: \"Advanced attribute handling for Eleva components\",\n\n /**\n * Installs the plugin into the Eleva instance\n *\n * @param {Object} eleva - The Eleva instance\n * @param {Object} options - Plugin configuration options\n * @param {boolean} [options.enableAria=true] - Enable ARIA attribute handling\n * @param {boolean} [options.enableData=true] - Enable data attribute handling\n * @param {boolean} [options.enableBoolean=true] - Enable boolean attribute handling\n * @param {boolean} [options.enableDynamic=true] - Enable dynamic property detection\n */\n install(eleva, options = {}) {\n const {\n enableAria = true,\n enableData = true,\n enableBoolean = true,\n enableDynamic = true,\n } = options;\n\n /**\n * Updates the attributes of an element to match a new element's attributes.\n * This method provides sophisticated attribute processing including:\n * - ARIA attribute handling with proper property mapping\n * - Data attribute management\n * - Boolean attribute processing\n * - Dynamic property detection and mapping\n * - Attribute cleanup and removal\n *\n * @param {HTMLElement} oldEl - The original element to update\n * @param {HTMLElement} newEl - The new element to update\n * @returns {void}\n */\n const updateAttributes = (oldEl, newEl) => {\n const oldAttrs = oldEl.attributes;\n const newAttrs = newEl.attributes;\n\n // Process new attributes\n for (let i = 0; i < newAttrs.length; i++) {\n const { name, value } = newAttrs[i];\n\n // Skip event attributes (handled by event system)\n if (name.startsWith(\"@\")) continue;\n\n // Skip if attribute hasn't changed\n if (oldEl.getAttribute(name) === value) continue;\n\n // Handle ARIA attributes\n if (enableAria && name.startsWith(\"aria-\")) {\n const prop =\n \"aria\" + name.slice(5).replace(CAMEL_RE, (_, l) => l.toUpperCase());\n oldEl[prop] = value;\n oldEl.setAttribute(name, value);\n }\n // Handle data attributes\n else if (enableData && name.startsWith(\"data-\")) {\n oldEl.dataset[name.slice(5)] = value;\n oldEl.setAttribute(name, value);\n }\n // Handle other attributes\n else {\n let prop = name.replace(CAMEL_RE, (_, l) => l.toUpperCase());\n\n // Dynamic property detection\n if (\n enableDynamic &&\n !(prop in oldEl) &&\n !Object.getOwnPropertyDescriptor(Object.getPrototypeOf(oldEl), prop)\n ) {\n const elementProps = Object.getOwnPropertyNames(\n Object.getPrototypeOf(oldEl)\n );\n const matchingProp = elementProps.find(\n (p) =>\n p.toLowerCase() === name.toLowerCase() ||\n p.toLowerCase().includes(name.toLowerCase()) ||\n name.toLowerCase().includes(p.toLowerCase())\n );\n\n if (matchingProp) {\n prop = matchingProp;\n }\n }\n\n const descriptor = Object.getOwnPropertyDescriptor(\n Object.getPrototypeOf(oldEl),\n prop\n );\n const hasProperty = prop in oldEl || descriptor;\n\n if (hasProperty) {\n // Boolean attribute handling\n if (enableBoolean) {\n const isBoolean =\n typeof oldEl[prop] === \"boolean\" ||\n (descriptor?.get &&\n typeof descriptor.get.call(oldEl) === \"boolean\");\n\n if (isBoolean) {\n const boolValue =\n value !== \"false\" &&\n (value === \"\" || value === prop || value === \"true\");\n oldEl[prop] = boolValue;\n\n if (boolValue) {\n oldEl.setAttribute(name, \"\");\n } else {\n oldEl.removeAttribute(name);\n }\n } else {\n oldEl[prop] = value;\n oldEl.setAttribute(name, value);\n }\n } else {\n oldEl[prop] = value;\n oldEl.setAttribute(name, value);\n }\n } else {\n oldEl.setAttribute(name, value);\n }\n }\n }\n\n // Remove old attributes that are no longer present\n for (let i = oldAttrs.length - 1; i >= 0; i--) {\n const name = oldAttrs[i].name;\n if (!newEl.hasAttribute(name)) {\n oldEl.removeAttribute(name);\n }\n }\n };\n\n // Extend the renderer with the advanced attribute handler\n if (eleva.renderer) {\n eleva.renderer.updateAttributes = updateAttributes;\n\n // Store the original _patchNode method\n const originalPatchNode = eleva.renderer._patchNode;\n eleva.renderer._originalPatchNode = originalPatchNode;\n\n // Override the _patchNode method to use our attribute handler\n eleva.renderer._patchNode = function (oldNode, newNode) {\n if (oldNode?._eleva_instance) return;\n\n if (!this._isSameNode(oldNode, newNode)) {\n oldNode.replaceWith(newNode.cloneNode(true));\n return;\n }\n\n if (oldNode.nodeType === Node.ELEMENT_NODE) {\n updateAttributes(oldNode, newNode);\n this._diff(oldNode, newNode);\n } else if (\n oldNode.nodeType === Node.TEXT_NODE &&\n oldNode.nodeValue !== newNode.nodeValue\n ) {\n oldNode.nodeValue = newNode.nodeValue;\n }\n };\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 attribute updates\n eleva.updateElementAttributes = updateAttributes;\n },\n\n /**\n * Uninstalls the plugin from the Eleva instance\n *\n * @param {Object} eleva - The Eleva instance\n */\n uninstall(eleva) {\n // Restore original _patchNode method if it exists\n if (eleva.renderer && eleva.renderer._originalPatchNode) {\n eleva.renderer._patchNode = eleva.renderer._originalPatchNode;\n delete eleva.renderer._originalPatchNode;\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.updateElementAttributes;\n },\n};\n","\"use strict\";\n\n/**\n * @typedef {import('eleva').Eleva} Eleva\n * @typedef {import('eleva').Signal} Signal\n * @typedef {import('eleva').ComponentDefinition} ComponentDefinition\n * @typedef {import('eleva').Emitter} Emitter\n * @typedef {import('eleva').MountResult} MountResult\n */\n\n// ============================================\n// Core Type Definitions\n// ============================================\n\n/**\n * @typedef {'hash' | 'history' | 'query'} RouterMode\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 */\n\n/**\n * @typedef {Object} RouterOptions\n * @property {RouterMode} [mode='hash'] - The routing mode to use.\n * @property {string} [queryParam='view'] - Query parameter name for 'query' mode.\n * @property {string} [viewSelector='root'] - Selector for the view container element.\n * @property {string} mount - CSS selector for the mount point element.\n * @property {RouteDefinition[]} routes - Array of route definitions.\n * @property {string | ComponentDefinition} [globalLayout] - Default layout for all routes.\n * @property {NavigationGuard} [onBeforeEach] - Global navigation guard.\n * @description Configuration options for the Router plugin.\n */\n\n/**\n * @typedef {Object} NavigationTarget\n * @property {string} path - The target path (can include params like '/users/:id').\n * @property {Record<string, string>} [params] - Route parameters to inject into the path.\n * @property {Record<string, string>} [query] - Query parameters to append.\n * @property {boolean} [replace=false] - Whether to replace current history entry.\n * @property {Record<string, any>} [state] - State object to pass to history.\n * @description Object describing a navigation target for `router.navigate()`.\n */\n\n/**\n * @typedef {Object} ScrollPosition\n * @property {number} x - Horizontal scroll position.\n * @property {number} y - Vertical scroll position.\n * @description Represents a saved scroll position.\n */\n\n/**\n * @typedef {Object} RouteSegment\n * @property {'static' | 'param'} type - The segment type.\n * @property {string} value - The segment value (for static) or empty string (for param).\n * @property {string} [name] - The parameter name (for param segments).\n * @description Internal representation of a parsed route path segment.\n * @private\n */\n\n/**\n * @typedef {Object} RouteMatch\n * @property {RouteDefinition} route - The matched route definition.\n * @property {Record<string, string>} params - The extracted route parameters.\n * @description Result of matching a path against route definitions.\n * @private\n */\n\n/**\n * @typedef {Record<string, any>} RouteMeta\n * @description Arbitrary metadata attached to routes for use in guards and components.\n * 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 * @typedef {Object} RouterErrorHandler\n * @property {(error: Error, context: string, details?: Record<string, any>) => void} handle - Throws a formatted error.\n * @property {(message: string, details?: Record<string, any>) => void} warn - Logs a warning.\n * @property {(message: string, error: Error, details?: Record<string, any>) => void} log - Logs an error without throwing.\n * @description Interface for the router's error handling system.\n */\n\n// ============================================\n// Event Callback Type Definitions\n// ============================================\n\n/**\n * @callback NavigationContextCallback\n * @param {NavigationContext} context - The navigation context (can be modified to block/redirect).\n * @returns {void | Promise<void>}\n * @description Callback for `router:beforeEach` event. Modify context to control navigation.\n */\n\n/**\n * @callback ResolveContextCallback\n * @param {ResolveContext} context - 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 RenderContextCallback\n * @param {RenderContext} context - The render context.\n * @returns {void | Promise<void>}\n * @description Callback for `router:beforeRender` and `router:afterRender` events.\n */\n\n/**\n * @callback ScrollContextCallback\n * @param {ScrollContext} context - The scroll context with saved position info.\n * @returns {void | Promise<void>}\n * @description Callback for `router:scroll` event. Use to implement scroll behavior.\n */\n\n/**\n * @callback RouteChangeCallback\n * @param {RouteLocation} to - The target route location.\n * @param {RouteLocation | null} from - The source route location.\n * @returns {void | Promise<void>}\n * @description Callback for `router:afterEnter`, `router:afterLeave`, `router:afterEach` events.\n */\n\n/**\n * @callback RouterErrorCallback\n * @param {Error} error - The error that occurred.\n * @param {RouteLocation} [to] - The target route (if available).\n * @param {RouteLocation | null} [from] - The source route (if available).\n * @returns {void | Promise<void>}\n * @description Callback for `router:onError` event.\n */\n\n/**\n * @callback RouterReadyCallback\n * @param {Router} router - The router instance.\n * @returns {void | Promise<void>}\n * @description Callback for `router:ready` event.\n */\n\n/**\n * @callback RouteAddedCallback\n * @param {RouteDefinition} route - The added route definition.\n * @returns {void | Promise<void>}\n * @description Callback for `router:routeAdded` event.\n */\n\n/**\n * @callback RouteRemovedCallback\n * @param {RouteDefinition} route - The removed route definition.\n * @returns {void | Promise<void>}\n * @description Callback for `router:routeRemoved` event.\n */\n\n// ============================================\n// Core Type Definitions (continued)\n// ============================================\n\n/**\n * Simple error handler for the core router.\n * Can be overridden by error handling plugins.\n * Provides consistent error formatting and logging for router operations.\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 {Object} 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 {Object} 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 {Object} details - Additional error details.\n */\n log(message, error, details = {}) {\n console.error(`[ElevaRouter] ${message}`, { error, details });\n },\n};\n\n/**\n * @typedef {Object} RouteLocation\n * @property {string} path - The path of the route (e.g., '/users/123').\n * @property {Record<string, string>} query - Query parameters as key-value pairs.\n * @property {string} fullUrl - The complete URL including hash, path, and query string.\n * @property {Record<string, string>} params - Dynamic route parameters (e.g., `{ id: '123' }`).\n * @property {RouteMeta} meta - Metadata associated with the matched route.\n * @property {string} [name] - The optional name of the matched route.\n * @property {RouteDefinition} matched - The raw route definition object that was matched.\n * @description Represents the current or target location in the router.\n */\n\n/**\n * @typedef {boolean | string | NavigationTarget | void} NavigationGuardResult\n * The 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 */\n\n/**\n * @callback NavigationGuard\n * @param {RouteLocation} to - The target route location.\n * @param {RouteLocation | null} from - The source route location (null on initial navigation).\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 * @callback NavigationHook\n * @param {RouteLocation} to - The target route location.\n * @param {RouteLocation | null} from - 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 * @typedef {Object} RouterPlugin\n * @property {string} name - Unique plugin identifier.\n * @property {string} [version] - Plugin version (recommended to match router version).\n * @property {(router: Router, options?: Record<string, any>) => void} install - Installation function.\n * @property {(router: Router) => void | Promise<void>} [destroy] - 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 * @typedef {Object} NavigationContext\n * @property {RouteLocation} to - The target route location.\n * @property {RouteLocation | null} from - The source route location.\n * @property {boolean} cancelled - Whether navigation has been cancelled.\n * @property {string | {path: string} | null} redirectTo - Redirect target if navigation should redirect.\n * @description A context object passed to navigation events that plugins can modify to control navigation flow.\n */\n\n/**\n * @typedef {Object} ResolveContext\n * @property {RouteLocation} to - The target route location.\n * @property {RouteLocation | null} from - The source route location.\n * @property {RouteDefinition} route - The matched route definition.\n * @property {ComponentDefinition | null} layoutComponent - The resolved layout component (available in afterResolve).\n * @property {ComponentDefinition | null} pageComponent - The resolved page component (available in afterResolve).\n * @property {boolean} cancelled - Whether navigation has been cancelled.\n * @property {string | {path: string} | null} redirectTo - Redirect target if navigation should redirect.\n * @description A context object passed to component resolution events.\n */\n\n/**\n * @typedef {Object} RenderContext\n * @property {RouteLocation} to - The target route location.\n * @property {RouteLocation | null} from - The source route location.\n * @property {ComponentDefinition | null} layoutComponent - The layout component being rendered.\n * @property {ComponentDefinition} pageComponent - The page component being rendered.\n * @description A context object passed to render events.\n */\n\n/**\n * @typedef {Object} ScrollContext\n * @property {RouteLocation} to - The target route location.\n * @property {RouteLocation | null} from - The source route location.\n * @property {{x: number, y: number} | null} savedPosition - The saved scroll position (if navigating via back/forward).\n * @description A context object passed to scroll events for plugins to handle scroll behavior.\n */\n\n/**\n * @typedef {string | ComponentDefinition | (() => Promise<{default: ComponentDefinition}>)} RouteComponent\n * A component that can be rendered for a route.\n * - `string`: Name of a registered component\n * - `ComponentDefinition`: Inline component definition\n * - `() => Promise<{default: ComponentDefinition}>`: Lazy-loaded component (e.g., `() => import('./Page.js')`)\n */\n\n/**\n * @typedef {Object} RouteDefinition\n * @property {string} path - URL path pattern. Supports:\n * - Static: `'/about'`\n * - Dynamic params: `'/users/:id'`\n * - Wildcard: `'*'` (catch-all, must be last)\n * @property {RouteComponent} component - The component to render for this route.\n * @property {RouteComponent} [layout] - Optional layout component to wrap the route component.\n * @property {string} [name] - Optional route name for programmatic navigation.\n * @property {RouteMeta} [meta] - Optional metadata (auth flags, titles, etc.).\n * @property {NavigationGuard} [beforeEnter] - Route-specific guard before entering.\n * @property {NavigationHook} [afterEnter] - Hook after entering and component is mounted.\n * @property {NavigationGuard} [beforeLeave] - Guard before leaving this route.\n * @property {NavigationHook} [afterLeave] - Hook after leaving and component is unmounted.\n * @property {RouteSegment[]} [segments] - Internal: parsed path segments (added by router).\n * @description Defines a route in the application.\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 (must be last)\n * { path: '*', component: NotFoundPage }\n */\n\n/**\n * @class Router\n * @classdesc A powerful, reactive, and flexible Router Plugin for Eleva.js.\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:onError` | {@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<Record<string, string>>` - Current route params\n * - `currentQuery: Signal<Record<string, string>>` - 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 */\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: \"root\",\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 {import('eleva').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 {Array<() => void>} 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<Object<string, string>>} A reactive signal holding the current route's parameters. */\n this.currentParams = new this.eleva.signal({});\n\n /** @type {Signal<Object<string, string>>} A reactive signal holding the current route's query parameters. */\n this.currentQuery = new this.eleva.signal({});\n\n /** @type {Signal<import('eleva').MountResult | null>} A reactive signal for the currently mounted layout instance. */\n this.currentLayout = new this.eleva.signal(null);\n\n /** @type {Signal<import('eleva').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 {Array<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 {Object} 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 {Array<{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 *\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 all event listeners and mounted components.\n * @returns {Promise<void>}\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 * @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 * @param {string | NavigationTarget} location - The target location as a path string or navigation target object.\n * @param {Record<string, string>} [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 *\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 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\n // Only reset the flag if no newer navigation has started\n queueMicrotask(() => {\n if (this._navigationId === currentNavId) {\n this._isNavigating = false;\n }\n });\n }\n\n return navigationSuccessful;\n } catch (error) {\n this.errorHandler.log(\"Navigation failed\", error);\n await this.emitter.emit(\"router:onError\", 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 * @private\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 * @private\n * @param {boolean} [isPopState=true] - Whether this is a popstate event (back/forward navigation).\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:onError\", error);\n }\n }\n\n /**\n * Manages the core navigation lifecycle. Runs guards before committing changes.\n * Emits lifecycle events that plugins can hook into:\n * - router:beforeEach - Before guards run (can block/redirect via context)\n * - router:beforeResolve - Before component resolution (can block/redirect)\n * - router:afterResolve - After components are resolved\n * - router:beforeRender - Before DOM rendering\n * - router:afterRender - After DOM rendering\n * - router:scroll - After render, for scroll behavior\n * - router:afterEnter - After entering a route\n * - router:afterLeave - After leaving a route\n * - router:afterEach - After navigation completes\n *\n * @private\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 */\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:onError\",\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, to);\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:onError\", 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 */\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, Props, 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 * @param {Function} 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 {any} 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 {any} 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 * @param {RouteDefinition} route - The route to resolve components for.\n * @returns {Promise<{layoutComponent: ComponentDefinition | null, pageComponent: ComponentDefinition}>}\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 * @private\n * @param {ComponentDefinition | null} layoutComponent - The pre-loaded layout component.\n * @param {ComponentDefinition} pageComponent - The pre-loaded page component.\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 {any} defaultValue - The default value if property is undefined.\n * @returns {Function} 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 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 * @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 */\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 * @private\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 *\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.\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 *\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 */\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 */\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 */\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 */\n onError(handler) {\n return this.emitter.on(\"router:onError\", handler);\n }\n\n /**\n * Registers a plugin with the router.\n * @param {RouterPlugin} plugin - The plugin to register.\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 * @param {Object} errorHandler - The error handler object with handle, warn, and log methods.\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 * @typedef {Object} RouterOptions\n * @property {string} mount - A CSS selector for the main element where the app is mounted.\n * @property {RouteDefinition[]} routes - An array of route definitions.\n * @property {'hash' | 'query' | 'history'} [mode='hash'] - The routing mode.\n * @property {string} [queryParam='page'] - The query parameter to use in 'query' mode.\n * @property {string} [viewSelector='view'] - The selector for the view element within a layout.\n * @property {boolean} [autoStart=true] - Whether to start the router automatically.\n * @property {NavigationGuard} [onBeforeEach] - A global guard executed before every navigation.\n * @property {string | ComponentDefinition | (() => Promise<{default: ComponentDefinition}>)} [globalLayout] - A global layout for all routes. Can be overridden by a route's specific layout.\n */\n\n/**\n * @class 🚀 RouterPlugin\n * @classdesc A powerful, reactive, and flexible Router Plugin for Eleva.js 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.0.0-rc.10\",\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 * @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='page'] - The query parameter to use in 'query' mode\n * @param {string} [options.viewSelector='view'] - The selector for the view element within a layout\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 {string | ComponentDefinition | (() => Promise<{default: ComponentDefinition}>)} [options.globalLayout] - A global layout for all routes\n *\n * @example\n * // main.js\n * import Eleva from './eleva.js';\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 * @param {any} 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 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 eleva.navigate = router.navigate.bind(router);\n eleva.getCurrentRoute = () => router.currentRoute.value;\n eleva.getRouteParams = () => router.currentParams.value;\n eleva.getRouteQuery = () => router.currentQuery.value;\n\n return router;\n },\n\n /**\n * Uninstalls the plugin from the Eleva instance\n *\n * @param {Eleva} eleva - The Eleva instance\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","\"use strict\";\n\n// ============================================================================\n// TYPE DEFINITIONS - TypeScript-friendly JSDoc types for IDE support\n// ============================================================================\n\n/**\n * @typedef {Record<string, unknown>} TemplateData\n * Data context for template interpolation\n */\n\n/**\n * @typedef {string} TemplateString\n * A string containing {{ expression }} interpolation markers\n */\n\n/**\n * @typedef {string} Expression\n * A JavaScript expression to be evaluated in the data context\n */\n\n/**\n * @typedef {unknown} EvaluationResult\n * The result of evaluating an expression (string, number, boolean, object, etc.)\n */\n\n/**\n * @class 🔒 TemplateEngine\n * @classdesc A secure template engine that handles interpolation and dynamic attribute parsing.\n * Provides a way to evaluate expressions in templates.\n * All methods are static and can be called directly on the class.\n *\n * Template Syntax:\n * - `{{ expression }}` - Interpolate any JavaScript expression\n * - `{{ variable }}` - Access data properties directly\n * - `{{ object.property }}` - Access nested properties\n * - `{{ condition ? a : b }}` - Ternary expressions\n * - `{{ func(arg) }}` - Call functions from data context\n *\n * @example\n * // Basic interpolation\n * const template = \"Hello, {{name}}!\";\n * const data = { name: \"World\" };\n * const result = TemplateEngine.parse(template, data);\n * // Result: \"Hello, World!\"\n *\n * @example\n * // Nested properties\n * const template = \"Welcome, {{user.name}}!\";\n * const data = { user: { name: \"John\" } };\n * const result = TemplateEngine.parse(template, data);\n * // Result: \"Welcome, John!\"\n *\n * @example\n * // Expressions\n * const template = \"Status: {{active ? 'Online' : 'Offline'}}\";\n * const data = { active: true };\n * const result = TemplateEngine.parse(template, data);\n * // Result: \"Status: Online\"\n *\n * @example\n * // With Signal values\n * const template = \"Count: {{count.value}}\";\n * const data = { count: { value: 42 } };\n * const result = TemplateEngine.parse(template, data);\n * // Result: \"Count: 42\"\n */\nexport class TemplateEngine {\n /**\n * Regular expression for matching template expressions in the format {{ expression }}\n * Matches: {{ anything }} with optional whitespace inside braces\n *\n * @static\n * @private\n * @type {RegExp}\n */\n static expressionPattern = /\\{\\{\\s*(.*?)\\s*\\}\\}/g;\n\n /**\n * Parses a template string, replacing expressions with their evaluated values.\n * Expressions are evaluated in the provided data context.\n *\n * @public\n * @static\n * @param {TemplateString|unknown} template - The template string to parse.\n * @param {TemplateData} data - The data context for evaluating expressions.\n * @returns {string} The parsed template with expressions replaced by their values.\n *\n * @example\n * // Simple variables\n * TemplateEngine.parse(\"Hello, {{name}}!\", { name: \"World\" });\n * // Result: \"Hello, World!\"\n *\n * @example\n * // Nested properties\n * TemplateEngine.parse(\"{{user.name}} is {{user.age}} years old\", {\n * user: { name: \"John\", age: 30 }\n * });\n * // Result: \"John is 30 years old\"\n *\n * @example\n * // Multiple expressions\n * TemplateEngine.parse(\"{{greeting}}, {{name}}! You have {{count}} messages.\", {\n * greeting: \"Hello\",\n * name: \"User\",\n * count: 5\n * });\n * // Result: \"Hello, User! You have 5 messages.\"\n *\n * @example\n * // With conditionals\n * TemplateEngine.parse(\"Status: {{online ? 'Active' : 'Inactive'}}\", {\n * online: true\n * });\n * // Result: \"Status: Active\"\n */\n static parse(template, data) {\n if (typeof template !== \"string\") return template;\n return template.replace(this.expressionPattern, (_, expression) =>\n this.evaluate(expression, data)\n );\n }\n\n /**\n * Evaluates an expression in the context of the provided data object.\n *\n * Note: This does not provide a true sandbox and evaluated expressions may access global scope.\n * The use of the `with` statement is necessary for expression evaluation but has security implications.\n * Only use with trusted templates. User input should never be directly interpolated.\n *\n * @public\n * @static\n * @param {Expression|unknown} expression - The expression to evaluate.\n * @param {TemplateData} data - The data context for evaluation.\n * @returns {EvaluationResult} The result of the evaluation, or an empty string if evaluation fails.\n *\n * @example\n * // Property access\n * TemplateEngine.evaluate(\"user.name\", { user: { name: \"John\" } });\n * // Result: \"John\"\n *\n * @example\n * // Numeric values\n * TemplateEngine.evaluate(\"user.age\", { user: { age: 30 } });\n * // Result: 30\n *\n * @example\n * // Expressions\n * TemplateEngine.evaluate(\"items.length > 0\", { items: [1, 2, 3] });\n * // Result: true\n *\n * @example\n * // Function calls\n * TemplateEngine.evaluate(\"formatDate(date)\", {\n * date: new Date(),\n * formatDate: (d) => d.toISOString()\n * });\n * // Result: \"2024-01-01T00:00:00.000Z\"\n *\n * @example\n * // Failed evaluation returns empty string\n * TemplateEngine.evaluate(\"nonexistent.property\", {});\n * // Result: \"\"\n */\n static evaluate(expression, data) {\n if (typeof expression !== \"string\") return expression;\n try {\n return new Function(\"data\", `with(data) { return ${expression}; }`)(data);\n } catch {\n return \"\";\n }\n }\n}\n","\"use strict\";\n\nimport { TemplateEngine } from \"../modules/TemplateEngine.js\";\n\n/**\n * @class 🎯 PropsPlugin\n * @classdesc A plugin that extends Eleva's props data handling to support any type of data structure\n * with automatic type detection, parsing, and reactive prop updates. This plugin enables seamless\n * passing of complex data types from parent to child components without manual parsing.\n *\n * Core Features:\n * - Automatic type detection and parsing (strings, numbers, booleans, objects, arrays, dates, etc.)\n * - Support for complex data structures including nested objects and arrays\n * - Reactive props that automatically update when parent data changes\n * - Comprehensive error handling with custom error callbacks\n * - Simple configuration with minimal setup required\n *\n * @example\n * // Install the plugin\n * const app = new Eleva(\"myApp\");\n * app.use(PropsPlugin, {\n * enableAutoParsing: true,\n * enableReactivity: true,\n * onError: (error, value) => {\n * console.error('Props parsing error:', error, value);\n * }\n * });\n *\n * // Use complex props in components\n * app.component(\"UserCard\", {\n * template: (ctx) => `\n * <div class=\"user-info-container\"\n * :user='${JSON.stringify(ctx.user.value)}'\n * :permissions='${JSON.stringify(ctx.permissions.value)}'\n * :settings='${JSON.stringify(ctx.settings.value)}'>\n * </div>\n * `,\n * children: {\n * '.user-info-container': 'UserInfo'\n * }\n * });\n *\n * app.component(\"UserInfo\", {\n * setup({ props }) {\n * return {\n * user: props.user, // Automatically parsed object\n * permissions: props.permissions, // Automatically parsed array\n * settings: props.settings // Automatically parsed object\n * };\n * }\n * });\n */\nexport const PropsPlugin = {\n /**\n * Unique identifier for the plugin\n * @type {string}\n */\n name: \"props\",\n\n /**\n * Plugin version\n * @type {string}\n */\n version: \"1.0.0-rc.10\",\n\n /**\n * Plugin description\n * @type {string}\n */\n description:\n \"Advanced props data handling for complex data structures with automatic type detection and reactivity\",\n\n /**\n * Installs the plugin into the Eleva instance\n *\n * @param {Object} eleva - The Eleva instance\n * @param {Object} options - Plugin configuration options\n * @param {boolean} [options.enableAutoParsing=true] - Enable automatic type detection and parsing\n * @param {boolean} [options.enableReactivity=true] - Enable reactive prop updates using Eleva's signal system\n * @param {Function} [options.onError=null] - Error handler function called when parsing fails\n *\n * @example\n * // Basic installation\n * app.use(PropsPlugin);\n *\n * // Installation with custom options\n * app.use(PropsPlugin, {\n * enableAutoParsing: true,\n * enableReactivity: false,\n * onError: (error, value) => {\n * console.error('Props parsing error:', error, value);\n * }\n * });\n */\n install(eleva, options = {}) {\n const {\n enableAutoParsing = true,\n enableReactivity = true,\n onError = null,\n } = options;\n\n /**\n * Detects the type of a given value\n * @private\n * @param {any} value - The value to detect type for\n * @returns {string} The detected type ('string', 'number', 'boolean', 'object', 'array', 'date', 'map', 'set', 'function', 'null', 'undefined', 'unknown')\n *\n * @example\n * detectType(\"hello\") // → \"string\"\n * detectType(42) // → \"number\"\n * detectType(true) // → \"boolean\"\n * detectType([1, 2, 3]) // → \"array\"\n * detectType({}) // → \"object\"\n * detectType(new Date()) // → \"date\"\n * detectType(null) // → \"null\"\n */\n const detectType = (value) => {\n if (value === null) return \"null\";\n if (value === undefined) return \"undefined\";\n if (typeof value === \"boolean\") return \"boolean\";\n if (typeof value === \"number\") return \"number\";\n if (typeof value === \"string\") return \"string\";\n if (typeof value === \"function\") return \"function\";\n if (value instanceof Date) return \"date\";\n if (value instanceof Map) return \"map\";\n if (value instanceof Set) return \"set\";\n if (Array.isArray(value)) return \"array\";\n if (typeof value === \"object\") return \"object\";\n return \"unknown\";\n };\n\n /**\n * Parses a prop value with automatic type detection\n * @private\n * @param {any} value - The value to parse\n * @returns {any} The parsed value with appropriate type\n *\n * @description\n * This function automatically detects and parses different data types from string values:\n * - Special strings: \"true\" → true, \"false\" → false, \"null\" → null, \"undefined\" → undefined\n * - JSON objects/arrays: '{\"key\": \"value\"}' → {key: \"value\"}, '[1, 2, 3]' → [1, 2, 3]\n * - Boolean-like strings: \"1\" → true, \"0\" → false, \"\" → true\n * - Numeric strings: \"42\" → 42, \"3.14\" → 3.14\n * - Date strings: \"2023-01-01T00:00:00.000Z\" → Date object\n * - Other strings: returned as-is\n *\n * @example\n * parsePropValue(\"true\") // → true\n * parsePropValue(\"42\") // → 42\n * parsePropValue('{\"key\": \"val\"}') // → {key: \"val\"}\n * parsePropValue('[1, 2, 3]') // → [1, 2, 3]\n * parsePropValue(\"hello\") // → \"hello\"\n */\n const parsePropValue = (value) => {\n try {\n // Handle non-string values - return as-is\n if (typeof value !== \"string\") {\n return value;\n }\n\n // Handle special string patterns first\n if (value === \"true\") return true;\n if (value === \"false\") return false;\n if (value === \"null\") return null;\n if (value === \"undefined\") return undefined;\n\n // Try to parse as JSON (for objects and arrays)\n // This handles complex data structures like objects and arrays\n if (value.startsWith(\"{\") || value.startsWith(\"[\")) {\n try {\n return JSON.parse(value);\n } catch (e) {\n // Not valid JSON, throw error to trigger error handler\n throw new Error(`Invalid JSON: ${value}`);\n }\n }\n\n // Handle boolean-like strings (including \"1\" and \"0\")\n // These are common in HTML attributes and should be treated as booleans\n if (value === \"1\") return true;\n if (value === \"0\") return false;\n if (value === \"\") return true; // Empty string is truthy in HTML attributes\n\n // Handle numeric strings (after boolean check to avoid conflicts)\n // This ensures \"0\" is treated as boolean false, not number 0\n if (!isNaN(value) && value !== \"\" && !isNaN(parseFloat(value))) {\n return Number(value);\n }\n\n // Handle date strings (ISO format)\n // Recognizes standard ISO date format and converts to Date object\n if (value.match(/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}/)) {\n const date = new Date(value);\n if (!isNaN(date.getTime())) {\n return date;\n }\n }\n\n // Return as string if no other parsing applies\n // This is the fallback for regular text strings\n return value;\n } catch (error) {\n // Call error handler if provided\n if (onError) {\n onError(error, value);\n }\n // Fallback to original value to prevent breaking the application\n return value;\n }\n };\n\n /**\n * Enhanced props extraction with automatic type detection\n * @private\n * @param {HTMLElement} element - The DOM element to extract props from\n * @returns {Object} Object containing parsed props with appropriate types\n *\n * @description\n * Extracts props from DOM element attributes that start with \":\" and automatically\n * parses them to their appropriate types. Removes the attributes from the element\n * after extraction.\n *\n * @example\n * // HTML: <div :name=\"John\" :age=\"30\" :active=\"true\" :data='{\"key\": \"value\"}'></div>\n * const props = extractProps(element);\n * // Result: { name: \"John\", age: 30, active: true, data: {key: \"value\"} }\n */\n const extractProps = (element) => {\n const props = {};\n const attrs = element.attributes;\n\n // Iterate through attributes in reverse order to handle removal correctly\n for (let i = attrs.length - 1; i >= 0; i--) {\n const attr = attrs[i];\n // Only process attributes that start with \":\" (prop attributes)\n if (attr.name.startsWith(\":\")) {\n const propName = attr.name.slice(1); // Remove the \":\" prefix\n // Parse the value if auto-parsing is enabled, otherwise use as-is\n const parsedValue = enableAutoParsing\n ? parsePropValue(attr.value)\n : attr.value;\n props[propName] = parsedValue;\n // Remove the attribute from the DOM element after extraction\n element.removeAttribute(attr.name);\n }\n }\n\n return props;\n };\n\n /**\n * Creates reactive props using Eleva's signal system\n * @private\n * @param {Object} props - The props object to make reactive\n * @returns {Object} Object containing reactive props (Eleva signals)\n *\n * @description\n * Converts regular prop values into Eleva signals for reactive updates.\n * If a value is already a signal, it's passed through unchanged.\n *\n * @example\n * const props = { name: \"John\", age: 30, active: true };\n * const reactiveProps = createReactiveProps(props);\n * // Result: {\n * // name: Signal(\"John\"),\n * // age: Signal(30),\n * // active: Signal(true)\n * // }\n */\n const createReactiveProps = (props) => {\n const reactiveProps = {};\n\n // Convert each prop value to a reactive signal\n Object.entries(props).forEach(([key, value]) => {\n // Check if value is already a signal (has 'value' and 'watch' properties)\n if (\n value &&\n typeof value === \"object\" &&\n \"value\" in value &&\n \"watch\" in value\n ) {\n // Value is already a signal, use it as-is\n reactiveProps[key] = value;\n } else {\n // Create new signal for the prop value to make it reactive\n reactiveProps[key] = new eleva.signal(value);\n }\n });\n\n return reactiveProps;\n };\n\n // Override Eleva's internal _extractProps method with our enhanced version\n eleva._extractProps = extractProps;\n\n // Override Eleva's mount method to apply enhanced prop handling\n const originalMount = eleva.mount;\n eleva.mount = async (container, compName, props = {}) => {\n // Create reactive props if reactivity is enabled\n const enhancedProps = enableReactivity\n ? createReactiveProps(props)\n : props;\n\n // Call the original mount method with enhanced props\n return await originalMount.call(\n eleva,\n container,\n compName,\n enhancedProps\n );\n };\n\n // Override Eleva's _mountComponents method to enable signal reference passing\n const originalMountComponents = eleva._mountComponents;\n\n // Cache to store parent contexts by container element\n const parentContextCache = new WeakMap();\n // Store child instances that need signal linking\n const pendingSignalLinks = new Set();\n\n eleva._mountComponents = async (container, children, childInstances) => {\n for (const [selector, component] of Object.entries(children)) {\n if (!selector) continue;\n for (const el of container.querySelectorAll(selector)) {\n if (!(el instanceof HTMLElement)) continue;\n\n // Extract props from DOM attributes\n const extractedProps = eleva._extractProps(el);\n\n // Get parent context to check for signal references\n let enhancedProps = extractedProps;\n\n // Try to find parent context by looking up the DOM tree\n let parentContext = parentContextCache.get(container);\n if (!parentContext) {\n let currentElement = container;\n while (currentElement && !parentContext) {\n if (\n currentElement._eleva_instance &&\n currentElement._eleva_instance.data\n ) {\n parentContext = currentElement._eleva_instance.data;\n // Cache the parent context for future use\n parentContextCache.set(container, parentContext);\n break;\n }\n currentElement = currentElement.parentElement;\n }\n }\n\n if (enableReactivity && parentContext) {\n const signalProps = {};\n\n // Check each extracted prop to see if there's a matching signal in parent context\n Object.keys(extractedProps).forEach((propName) => {\n if (\n parentContext[propName] &&\n parentContext[propName] instanceof eleva.signal\n ) {\n // Found a signal in parent context with the same name as the prop\n // Pass the signal reference instead of creating a new one\n signalProps[propName] = parentContext[propName];\n }\n });\n\n // Merge signal props with regular props (signal props take precedence)\n enhancedProps = {\n ...extractedProps,\n ...signalProps,\n };\n }\n\n // Create reactive props for non-signal props only\n let finalProps = enhancedProps;\n if (enableReactivity) {\n // Only create reactive props for values that aren't already signals\n const nonSignalProps = {};\n Object.entries(enhancedProps).forEach(([key, value]) => {\n if (\n !(\n value &&\n typeof value === \"object\" &&\n \"value\" in value &&\n \"watch\" in value\n )\n ) {\n // This is not a signal, create a reactive prop for it\n nonSignalProps[key] = value;\n }\n });\n\n // Create reactive props only for non-signal values\n const reactiveNonSignalProps = createReactiveProps(nonSignalProps);\n\n // Merge signal props with reactive non-signal props\n finalProps = {\n ...reactiveNonSignalProps,\n ...enhancedProps, // Signal props take precedence\n };\n }\n\n /** @type {MountResult} */\n const instance = await eleva.mount(el, component, finalProps);\n if (instance && !childInstances.includes(instance)) {\n childInstances.push(instance);\n\n // If we have extracted props but no parent context yet, mark for later signal linking\n if (\n enableReactivity &&\n Object.keys(extractedProps).length > 0 &&\n !parentContext\n ) {\n pendingSignalLinks.add({\n instance,\n extractedProps,\n container,\n component,\n });\n }\n }\n }\n }\n\n // After mounting all children, try to link signals for pending instances\n if (enableReactivity && pendingSignalLinks.size > 0) {\n for (const pending of pendingSignalLinks) {\n const { instance, extractedProps, container, component } = pending;\n\n // Try to find parent context again\n let parentContext = parentContextCache.get(container);\n if (!parentContext) {\n let currentElement = container;\n while (currentElement && !parentContext) {\n if (\n currentElement._eleva_instance &&\n currentElement._eleva_instance.data\n ) {\n parentContext = currentElement._eleva_instance.data;\n parentContextCache.set(container, parentContext);\n break;\n }\n currentElement = currentElement.parentElement;\n }\n }\n\n if (parentContext) {\n const signalProps = {};\n\n // Check each extracted prop to see if there's a matching signal in parent context\n Object.keys(extractedProps).forEach((propName) => {\n if (\n parentContext[propName] &&\n parentContext[propName] instanceof eleva.signal\n ) {\n signalProps[propName] = parentContext[propName];\n }\n });\n\n // Update the child instance's data with signal references\n if (Object.keys(signalProps).length > 0) {\n Object.assign(instance.data, signalProps);\n\n // Set up signal watchers for the newly linked signals\n Object.keys(signalProps).forEach((propName) => {\n const signal = signalProps[propName];\n if (signal && typeof signal.watch === \"function\") {\n signal.watch((newValue) => {\n // Trigger a re-render of the child component when the signal changes\n const childComponent =\n eleva._components.get(component) || component;\n if (childComponent && childComponent.template) {\n const templateResult =\n typeof childComponent.template === \"function\"\n ? childComponent.template(instance.data)\n : childComponent.template;\n const newHtml = TemplateEngine.parse(\n templateResult,\n instance.data\n );\n eleva.renderer.patchDOM(instance.container, newHtml);\n }\n });\n }\n });\n\n // Initial re-render to show the correct signal values\n const childComponent =\n eleva._components.get(component) || component;\n if (childComponent && childComponent.template) {\n const templateResult =\n typeof childComponent.template === \"function\"\n ? childComponent.template(instance.data)\n : childComponent.template;\n const newHtml = TemplateEngine.parse(\n templateResult,\n instance.data\n );\n eleva.renderer.patchDOM(instance.container, newHtml);\n }\n }\n\n // Remove from pending list\n pendingSignalLinks.delete(pending);\n }\n }\n }\n };\n\n /**\n * Expose utility methods on the Eleva instance\n * @namespace eleva.props\n */\n eleva.props = {\n /**\n * Parse a single value with automatic type detection\n * @param {any} value - The value to parse\n * @returns {any} The parsed value with appropriate type\n *\n * @example\n * app.props.parse(\"42\") // → 42\n * app.props.parse(\"true\") // → true\n * app.props.parse('{\"key\": \"val\"}') // → {key: \"val\"}\n */\n parse: (value) => {\n // Return value as-is if auto parsing is disabled\n if (!enableAutoParsing) {\n return value;\n }\n // Use our enhanced parsing function\n return parsePropValue(value);\n },\n\n /**\n * Detect the type of a value\n * @param {any} value - The value to detect type for\n * @returns {string} The detected type\n *\n * @example\n * app.props.detectType(\"hello\") // → \"string\"\n * app.props.detectType(42) // → \"number\"\n * app.props.detectType([1, 2, 3]) // → \"array\"\n */\n detectType,\n };\n\n // Store original methods for uninstall\n eleva._originalExtractProps = eleva._extractProps;\n eleva._originalMount = originalMount;\n eleva._originalMountComponents = originalMountComponents;\n },\n\n /**\n * Uninstalls the plugin from the Eleva instance\n *\n * @param {Object} eleva - The Eleva instance\n *\n * @description\n * Restores the original Eleva methods and removes all plugin-specific\n * functionality. This method should be called when the plugin is no\n * longer needed.\n *\n * @example\n * // Uninstall the plugin\n * PropsPlugin.uninstall(app);\n */\n uninstall(eleva) {\n // Restore original _extractProps method\n if (eleva._originalExtractProps) {\n eleva._extractProps = eleva._originalExtractProps;\n delete eleva._originalExtractProps;\n }\n\n // Restore original mount method\n if (eleva._originalMount) {\n eleva.mount = eleva._originalMount;\n delete eleva._originalMount;\n }\n\n // Restore original _mountComponents method\n if (eleva._originalMountComponents) {\n eleva._mountComponents = eleva._originalMountComponents;\n delete eleva._originalMountComponents;\n }\n\n // Remove plugin utility methods\n if (eleva.props) {\n delete eleva.props;\n }\n },\n};\n","\"use strict\";\n\n/**\n * @class 🏪 StorePlugin\n * @classdesc A powerful reactive state management plugin for Eleva.js that enables sharing\n * reactive data across the entire application. The Store plugin provides a centralized,\n * reactive data store that can be accessed from any component's setup function.\n *\n * Core Features:\n * - Centralized reactive state management using Eleva's signal system\n * - Global state accessibility through component setup functions\n * - Namespace support for organizing store modules\n * - Built-in persistence with localStorage/sessionStorage support\n * - Action-based state mutations with validation\n * - Subscription system for reactive updates\n * - DevTools integration for debugging\n * - Plugin architecture for extensibility\n *\n * @example\n * // Install the plugin\n * const app = new Eleva(\"myApp\");\n * app.use(StorePlugin, {\n * state: {\n * user: { name: \"John\", email: \"john@example.com\" },\n * counter: 0,\n * todos: []\n * },\n * actions: {\n * increment: (state) => state.counter.value++,\n * addTodo: (state, todo) => state.todos.value.push(todo),\n * setUser: (state, user) => state.user.value = user\n * },\n * persistence: {\n * enabled: true,\n * key: \"myApp-store\",\n * storage: \"localStorage\"\n * }\n * });\n *\n * // Use store in components\n * app.component(\"Counter\", {\n * setup({ store }) {\n * return {\n * count: store.state.counter,\n * increment: () => store.dispatch(\"increment\"),\n * user: store.state.user\n * };\n * },\n * template: (ctx) => `\n * <div>\n * <p>Hello ${ctx.user.value.name}!</p>\n * <p>Count: ${ctx.count.value}</p>\n * <button onclick=\"ctx.increment()\">+</button>\n * </div>\n * `\n * });\n */\nexport const StorePlugin = {\n /**\n * Unique identifier for the plugin\n * @type {string}\n */\n name: \"store\",\n\n /**\n * Plugin version\n * @type {string}\n */\n version: \"1.0.0-rc.10\",\n\n /**\n * Plugin description\n * @type {string}\n */\n description:\n \"Reactive state management for sharing data across the entire Eleva application\",\n\n /**\n * Installs the plugin into the Eleva instance\n *\n * @param {Object} eleva - The Eleva instance\n * @param {Object} options - Plugin configuration options\n * @param {Object} [options.state={}] - Initial state object\n * @param {Object} [options.actions={}] - Action functions for state mutations\n * @param {Object} [options.namespaces={}] - Namespaced modules for organizing store\n * @param {Object} [options.persistence] - Persistence configuration\n * @param {boolean} [options.persistence.enabled=false] - Enable state persistence\n * @param {string} [options.persistence.key=\"eleva-store\"] - Storage key\n * @param {\"localStorage\" | \"sessionStorage\"} [options.persistence.storage=\"localStorage\"] - Storage type\n * @param {Array<string>} [options.persistence.include] - State keys to persist (if not provided, all state is persisted)\n * @param {Array<string>} [options.persistence.exclude] - State keys to exclude from persistence\n * @param {boolean} [options.devTools=false] - Enable development tools integration\n * @param {Function} [options.onError=null] - Error handler function\n *\n * @example\n * // Basic installation\n * app.use(StorePlugin, {\n * state: { count: 0, user: null },\n * actions: {\n * increment: (state) => state.count.value++,\n * setUser: (state, user) => state.user.value = user\n * }\n * });\n *\n * // Advanced installation with persistence and namespaces\n * app.use(StorePlugin, {\n * state: { theme: \"light\" },\n * namespaces: {\n * auth: {\n * state: { user: null, token: null },\n * actions: {\n * login: (state, { user, token }) => {\n * state.user.value = user;\n * state.token.value = token;\n * },\n * logout: (state) => {\n * state.user.value = null;\n * state.token.value = null;\n * }\n * }\n * }\n * },\n * persistence: {\n * enabled: true,\n * include: [\"theme\", \"auth.user\"]\n * }\n * });\n */\n install(eleva, options = {}) {\n const {\n state = {},\n actions = {},\n namespaces = {},\n persistence = {},\n devTools = false,\n onError = null,\n } = options;\n\n /**\n * Store instance that manages all state and provides the API\n * @private\n */\n class Store {\n constructor() {\n this.state = {};\n this.actions = {};\n this.subscribers = new Set();\n this.mutations = [];\n this.persistence = {\n enabled: false,\n key: \"eleva-store\",\n storage: \"localStorage\",\n include: null,\n exclude: null,\n ...persistence,\n };\n this.devTools = devTools;\n this.onError = onError;\n\n this._initializeState(state, actions);\n this._initializeNamespaces(namespaces);\n this._loadPersistedState();\n this._setupDevTools();\n }\n\n /**\n * Initializes the root state and actions\n * @private\n */\n _initializeState(initialState, initialActions) {\n // Create reactive signals for each state property\n Object.entries(initialState).forEach(([key, value]) => {\n this.state[key] = new eleva.signal(value);\n });\n\n // Set up actions\n this.actions = { ...initialActions };\n }\n\n /**\n * Initializes namespaced modules\n * @private\n */\n _initializeNamespaces(namespaces) {\n Object.entries(namespaces).forEach(([namespace, module]) => {\n const { state: moduleState = {}, actions: moduleActions = {} } =\n module;\n\n // Create namespace object if it doesn't exist\n if (!this.state[namespace]) {\n this.state[namespace] = {};\n }\n if (!this.actions[namespace]) {\n this.actions[namespace] = {};\n }\n\n // Initialize namespaced state\n Object.entries(moduleState).forEach(([key, value]) => {\n this.state[namespace][key] = new eleva.signal(value);\n });\n\n // Set up namespaced actions\n this.actions[namespace] = { ...moduleActions };\n });\n }\n\n /**\n * Loads persisted state from storage\n * @private\n */\n _loadPersistedState() {\n if (!this.persistence.enabled || typeof window === \"undefined\") {\n return;\n }\n\n try {\n const storage = window[this.persistence.storage];\n const persistedData = storage.getItem(this.persistence.key);\n\n if (persistedData) {\n const data = JSON.parse(persistedData);\n this._applyPersistedData(data);\n }\n } catch (error) {\n if (this.onError) {\n this.onError(error, \"Failed to load persisted state\");\n } else {\n console.warn(\n \"[StorePlugin] Failed to load persisted state:\",\n error\n );\n }\n }\n }\n\n /**\n * Applies persisted data to the current state\n * @private\n */\n _applyPersistedData(data, currentState = this.state, path = \"\") {\n Object.entries(data).forEach(([key, value]) => {\n const fullPath = path ? `${path}.${key}` : key;\n\n if (this._shouldPersist(fullPath)) {\n if (\n currentState[key] &&\n typeof currentState[key] === \"object\" &&\n \"value\" in currentState[key]\n ) {\n // This is a signal, update its value\n currentState[key].value = value;\n } else if (\n typeof value === \"object\" &&\n value !== null &&\n currentState[key]\n ) {\n // This is a nested object, recurse\n this._applyPersistedData(value, currentState[key], fullPath);\n }\n }\n });\n }\n\n /**\n * Determines if a state path should be persisted\n * @private\n */\n _shouldPersist(path) {\n const { include, exclude } = this.persistence;\n\n if (include && include.length > 0) {\n return include.some((includePath) => path.startsWith(includePath));\n }\n\n if (exclude && exclude.length > 0) {\n return !exclude.some((excludePath) => path.startsWith(excludePath));\n }\n\n return true;\n }\n\n /**\n * Saves current state to storage\n * @private\n */\n _saveState() {\n if (!this.persistence.enabled || typeof window === \"undefined\") {\n return;\n }\n\n try {\n const storage = window[this.persistence.storage];\n const dataToSave = this._extractPersistedData();\n storage.setItem(this.persistence.key, JSON.stringify(dataToSave));\n } catch (error) {\n if (this.onError) {\n this.onError(error, \"Failed to save state\");\n } else {\n console.warn(\"[StorePlugin] Failed to save state:\", error);\n }\n }\n }\n\n /**\n * Extracts data that should be persisted\n * @private\n */\n _extractPersistedData(currentState = this.state, path = \"\") {\n const result = {};\n\n Object.entries(currentState).forEach(([key, value]) => {\n const fullPath = path ? `${path}.${key}` : key;\n\n if (this._shouldPersist(fullPath)) {\n if (value && typeof value === \"object\" && \"value\" in value) {\n // This is a signal, extract its value\n result[key] = value.value;\n } else if (typeof value === \"object\" && value !== null) {\n // This is a nested object, recurse\n const nestedData = this._extractPersistedData(value, fullPath);\n if (Object.keys(nestedData).length > 0) {\n result[key] = nestedData;\n }\n }\n }\n });\n\n return result;\n }\n\n /**\n * Sets up development tools integration\n * @private\n */\n _setupDevTools() {\n if (\n !this.devTools ||\n typeof window === \"undefined\" ||\n !window.__ELEVA_DEVTOOLS__\n ) {\n return;\n }\n\n window.__ELEVA_DEVTOOLS__.registerStore(this);\n }\n\n /**\n * Dispatches an action to mutate the state\n * @param {string} actionName - The name of the action to dispatch (supports namespaced actions like \"auth.login\")\n * @param {any} payload - The payload to pass to the action\n * @returns {Promise<any>} The result of the action\n */\n async dispatch(actionName, payload) {\n try {\n const action = this._getAction(actionName);\n\n if (!action) {\n const error = new Error(`Action \"${actionName}\" not found`);\n if (this.onError) {\n this.onError(error, actionName);\n }\n throw error;\n }\n\n const mutation = {\n type: actionName,\n payload,\n timestamp: Date.now(),\n };\n\n // Record mutation for devtools\n this.mutations.push(mutation);\n if (this.mutations.length > 100) {\n this.mutations.shift(); // Keep only last 100 mutations\n }\n\n // Execute the action\n const result = await action.call(null, this.state, payload);\n\n // Save state if persistence is enabled\n this._saveState();\n\n // Notify subscribers\n this.subscribers.forEach((callback) => {\n try {\n callback(mutation, this.state);\n } catch (error) {\n if (this.onError) {\n this.onError(error, \"Subscriber callback failed\");\n }\n }\n });\n\n // Notify devtools\n if (\n this.devTools &&\n typeof window !== \"undefined\" &&\n window.__ELEVA_DEVTOOLS__\n ) {\n window.__ELEVA_DEVTOOLS__.notifyMutation(mutation, this.state);\n }\n\n return result;\n } catch (error) {\n if (this.onError) {\n this.onError(error, `Action dispatch failed: ${actionName}`);\n }\n throw error;\n }\n }\n\n /**\n * Gets an action by name (supports namespaced actions)\n * @private\n */\n _getAction(actionName) {\n const parts = actionName.split(\".\");\n let current = this.actions;\n\n for (const part of parts) {\n if (current[part] === undefined) {\n return null;\n }\n current = current[part];\n }\n\n return typeof current === \"function\" ? current : null;\n }\n\n /**\n * Subscribes to store mutations\n * @param {Function} callback - Callback function to call on mutations\n * @returns {Function} Unsubscribe function\n */\n subscribe(callback) {\n if (typeof callback !== \"function\") {\n throw new Error(\"Subscribe callback must be a function\");\n }\n\n this.subscribers.add(callback);\n\n // Return unsubscribe function\n return () => {\n this.subscribers.delete(callback);\n };\n }\n\n /**\n * Gets a deep copy of the current state values (not signals)\n * @returns {Object} The current state values\n */\n getState() {\n return this._extractPersistedData();\n }\n\n /**\n * Replaces the entire state (useful for testing or state hydration)\n * @param {Object} newState - The new state object\n */\n replaceState(newState) {\n this._applyPersistedData(newState);\n this._saveState();\n }\n\n /**\n * Clears persisted state from storage\n */\n clearPersistedState() {\n if (!this.persistence.enabled || typeof window === \"undefined\") {\n return;\n }\n\n try {\n const storage = window[this.persistence.storage];\n storage.removeItem(this.persistence.key);\n } catch (error) {\n if (this.onError) {\n this.onError(error, \"Failed to clear persisted state\");\n }\n }\n }\n\n /**\n * Registers a new namespaced module at runtime\n * @param {string} namespace - The namespace for the module\n * @param {Object} module - The module definition\n * @param {Object} module.state - The module's initial state\n * @param {Object} module.actions - The module's actions\n */\n registerModule(namespace, module) {\n if (this.state[namespace] || this.actions[namespace]) {\n console.warn(`[StorePlugin] Module \"${namespace}\" already exists`);\n return;\n }\n\n // Initialize the module\n this.state[namespace] = {};\n this.actions[namespace] = {};\n\n const namespaces = { [namespace]: module };\n this._initializeNamespaces(namespaces);\n\n this._saveState();\n }\n\n /**\n * Unregisters a namespaced module\n * @param {string} namespace - The namespace to unregister\n */\n unregisterModule(namespace) {\n if (!this.state[namespace] && !this.actions[namespace]) {\n console.warn(`[StorePlugin] Module \"${namespace}\" does not exist`);\n return;\n }\n\n delete this.state[namespace];\n delete this.actions[namespace];\n this._saveState();\n }\n\n /**\n * Creates a new reactive state property at runtime\n * @param {string} key - The state key\n * @param {*} initialValue - The initial value\n * @returns {Object} The created signal\n */\n createState(key, initialValue) {\n if (this.state[key]) {\n return this.state[key]; // Return existing state\n }\n\n this.state[key] = new eleva.signal(initialValue);\n this._saveState();\n return this.state[key];\n }\n\n /**\n * Creates a new action at runtime\n * @param {string} name - The action name\n * @param {Function} actionFn - The action function\n */\n createAction(name, actionFn) {\n if (typeof actionFn !== \"function\") {\n throw new Error(\"Action must be a function\");\n }\n\n this.actions[name] = actionFn;\n }\n }\n\n // Create the store instance\n const store = new Store();\n\n // Store the original mount method to override it\n const originalMount = eleva.mount;\n\n /**\n * Override the mount method to inject store context into components\n */\n eleva.mount = async (container, compName, props = {}) => {\n // Get the component definition\n const componentDef =\n typeof compName === \"string\"\n ? eleva._components.get(compName) || compName\n : compName;\n\n if (!componentDef) {\n return await originalMount.call(eleva, container, compName, props);\n }\n\n // Create a wrapped component that injects store into setup\n const wrappedComponent = {\n ...componentDef,\n async setup(ctx) {\n // Inject store into the context with enhanced API\n ctx.store = {\n // Core store functionality\n state: store.state,\n dispatch: store.dispatch.bind(store),\n subscribe: store.subscribe.bind(store),\n getState: store.getState.bind(store),\n\n // Module management\n registerModule: store.registerModule.bind(store),\n unregisterModule: store.unregisterModule.bind(store),\n\n // Utilities for dynamic state/action creation\n createState: store.createState.bind(store),\n createAction: store.createAction.bind(store),\n\n // Access to signal constructor for manual state creation\n signal: eleva.signal,\n };\n\n // Call original setup if it exists\n const originalSetup = componentDef.setup;\n const result = originalSetup ? await originalSetup(ctx) : {};\n\n return result;\n },\n };\n\n // Call original mount with wrapped component\n return await originalMount.call(\n eleva,\n container,\n wrappedComponent,\n props\n );\n };\n\n // Override _mountComponents to ensure child components also get store context\n const originalMountComponents = eleva._mountComponents;\n eleva._mountComponents = async (container, children, childInstances) => {\n // Create wrapped children with store injection\n const wrappedChildren = {};\n\n for (const [selector, childComponent] of Object.entries(children)) {\n const componentDef =\n typeof childComponent === \"string\"\n ? eleva._components.get(childComponent) || childComponent\n : childComponent;\n\n if (componentDef && typeof componentDef === \"object\") {\n wrappedChildren[selector] = {\n ...componentDef,\n async setup(ctx) {\n // Inject store into the context with enhanced API\n ctx.store = {\n // Core store functionality\n state: store.state,\n dispatch: store.dispatch.bind(store),\n subscribe: store.subscribe.bind(store),\n getState: store.getState.bind(store),\n\n // Module management\n registerModule: store.registerModule.bind(store),\n unregisterModule: store.unregisterModule.bind(store),\n\n // Utilities for dynamic state/action creation\n createState: store.createState.bind(store),\n createAction: store.createAction.bind(store),\n\n // Access to signal constructor for manual state creation\n signal: eleva.signal,\n };\n\n // Call original setup if it exists\n const originalSetup = componentDef.setup;\n const result = originalSetup ? await originalSetup(ctx) : {};\n\n return result;\n },\n };\n } else {\n wrappedChildren[selector] = childComponent;\n }\n }\n\n // Call original _mountComponents with wrapped children\n return await originalMountComponents.call(\n eleva,\n container,\n wrappedChildren,\n childInstances\n );\n };\n\n // Expose store instance and utilities on the Eleva instance\n eleva.store = store;\n\n /**\n * Expose utility methods on the Eleva instance\n * @namespace eleva.store\n */\n eleva.createAction = (name, actionFn) => {\n store.actions[name] = actionFn;\n };\n\n eleva.dispatch = (actionName, payload) => {\n return store.dispatch(actionName, payload);\n };\n\n eleva.getState = () => {\n return store.getState();\n };\n\n eleva.subscribe = (callback) => {\n return store.subscribe(callback);\n };\n\n // Store original methods for cleanup\n eleva._originalMount = originalMount;\n eleva._originalMountComponents = originalMountComponents;\n },\n\n /**\n * Uninstalls the plugin from the Eleva instance\n *\n * @param {Object} eleva - The Eleva instance\n *\n * @description\n * Restores the original Eleva methods and removes all plugin-specific\n * functionality. This method should be called when the plugin is no\n * longer needed.\n *\n * @example\n * // Uninstall the plugin\n * StorePlugin.uninstall(app);\n */\n uninstall(eleva) {\n // Restore original mount method\n if (eleva._originalMount) {\n eleva.mount = eleva._originalMount;\n delete eleva._originalMount;\n }\n\n // Restore original _mountComponents method\n if (eleva._originalMountComponents) {\n eleva._mountComponents = eleva._originalMountComponents;\n delete eleva._originalMountComponents;\n }\n\n // Remove store instance and utility methods\n if (eleva.store) {\n delete eleva.store;\n }\n if (eleva.createAction) {\n delete eleva.createAction;\n }\n if (eleva.dispatch) {\n delete eleva.dispatch;\n }\n if (eleva.getState) {\n delete eleva.getState;\n }\n if (eleva.subscribe) {\n delete eleva.subscribe;\n }\n },\n};\n"],"names":["CAMEL_RE","AttrPlugin","name","version","description","install","eleva","options","enableAria","enableData","enableBoolean","enableDynamic","updateAttributes","oldEl","newEl","oldAttrs","attributes","newAttrs","i","length","value","startsWith","getAttribute","prop","slice","replace","_","l","toUpperCase","setAttribute","dataset","Object","getOwnPropertyDescriptor","getPrototypeOf","elementProps","getOwnPropertyNames","matchingProp","find","p","toLowerCase","includes","descriptor","hasProperty","isBoolean","get","call","boolValue","removeAttribute","hasAttribute","renderer","originalPatchNode","_patchNode","_originalPatchNode","oldNode","newNode","_eleva_instance","_isSameNode","replaceWith","cloneNode","nodeType","Node","ELEMENT_NODE","_diff","TEXT_NODE","nodeValue","plugins","Map","set","updateElementAttributes","uninstall","delete","CoreErrorHandler","handle","error","context","details","message","formattedError","Error","originalError","console","warn","log","Router","constructor","mode","queryParam","viewSelector","routes","_processRoutes","emitter","isStarted","_isNavigating","_navigationId","eventListeners","currentRoute","signal","previousRoute","currentParams","currentQuery","currentLayout","currentView","isReady","_beforeEachGuards","onBeforeEach","push","errorHandler","_scrollPositions","_validateOptions","processedRoutes","route","segments","_parsePathIntoSegments","path","normalizedPath","split","filter","Boolean","map","segment","paramName","substring","type","_findViewElement","container","selector","querySelector","start","window","document","mount","mountSelector","handler","_handleRouteChange","addEventListener","removeEventListener","emit","destroy","plugin","values","forEach","cleanup","unmount","stop","navigate","location","params","target","_buildPath","query","keys","queryString","URLSearchParams","toString","_isSameRoute","navigationSuccessful","_proceedWithNavigation","currentNavId","state","historyMethod","newUrl","pathname","search","history","replaceState","hash","url","_buildQueryUrl","queueMicrotask","urlParams","current","targetPath","targetQuery","_parseQuery","JSON","stringify","result","key","entries","encodedValue","encodeURIComponent","String","RegExp","isPopState","from","toLocation","_getCurrentLocation","fullUrl","currentUrl","href","fullPath","toMatch","_matchRoute","notFoundRoute","pathMatch","decodeURIComponent","to","meta","matched","canNavigate","_runGuards","x","scrollX","pageXOffset","y","scrollY","pageYOffset","resolveContext","layoutComponent","pageComponent","cancelled","redirectTo","_resolveComponents","toLayout","layout","globalLayout","fromLayout","tryUnmount","instance","afterLeave","renderContext","_render","scrollContext","savedPosition","afterEnter","navContext","guards","beforeLeave","beforeEnter","guard","_resolveStringComponent","def","componentDef","_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","pathSegments","isMatch","routeSegment","pathSegment","addRoute","parentRoute","hasRoute","processedRoute","wildcardIndex","findIndex","r","splice","removeRoute","index","removedRoute","some","getRoutes","getRoute","indexOf","onAfterEnter","hook","on","onAfterLeave","onAfterEach","onError","use","has","existingPlugin","getPlugins","getPlugin","removePlugin","setErrorHandler","RouterPlugin","isArray","register","Math","random","autoStart","getCurrentRoute","getRouteParams","getRouteQuery","TemplateEngine","expressionPattern","parse","data","expression","evaluate","Function","PropsPlugin","enableAutoParsing","enableReactivity","detectType","Date","Set","parsePropValue","e","isNaN","parseFloat","Number","match","date","getTime","extractProps","element","props","attrs","attr","propName","parsedValue","createReactiveProps","reactiveProps","_extractProps","originalMount","compName","enhancedProps","originalMountComponents","_mountComponents","parentContextCache","WeakMap","pendingSignalLinks","childInstances","el","querySelectorAll","HTMLElement","extractedProps","parentContext","currentElement","parentElement","signalProps","finalProps","nonSignalProps","reactiveNonSignalProps","add","size","pending","assign","watch","newValue","templateResult","newHtml","patchDOM","_originalExtractProps","_originalMount","_originalMountComponents","StorePlugin","actions","namespaces","persistence","devTools","Store","subscribers","mutations","enabled","storage","include","exclude","_initializeState","_initializeNamespaces","_loadPersistedState","_setupDevTools","initialState","initialActions","namespace","module","moduleState","moduleActions","persistedData","getItem","_applyPersistedData","currentState","_shouldPersist","includePath","excludePath","_saveState","dataToSave","_extractPersistedData","setItem","nestedData","__ELEVA_DEVTOOLS__","registerStore","dispatch","actionName","payload","action","_getAction","mutation","timestamp","now","shift","callback","notifyMutation","parts","part","subscribe","getState","newState","clearPersistedState","removeItem","registerModule","unregisterModule","createState","initialValue","createAction","actionFn","store"],"mappings":";;;;;;;EAEA;EACA;EACA;EACA;EACA;EACA,MAAMA,QAAQ,GAAG,WAAW;;EAE5B;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAC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ACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA,MAAMG,gBAAgB,GAAG;EACvB;EACF;EACA;EACA;EACA;EACA;EACA;IACEC,MAAMA,CAACC,KAAK,EAAEC,OAAO,EAAEC,OAAO,GAAG,EAAE,EAAE;MACnC,MAAMC,OAAO,GAAG,CAAA,cAAA,EAAiBF,OAAO,KAAKD,KAAK,CAACG,OAAO,CAAA,CAAE;EAC5D,IAAA,MAAMC,cAAc,GAAG,IAAIC,KAAK,CAACF,OAAO,CAAC;;EAEzC;MACAC,cAAc,CAACE,aAAa,GAAGN,KAAK;MACpCI,cAAc,CAACH,OAAO,GAAGA,OAAO;MAChCG,cAAc,CAACF,OAAO,GAAGA,OAAO;EAEhCK,IAAAA,OAAO,CAACP,KAAK,CAACG,OAAO,EAAE;QAAEH,KAAK;QAAEC,OAAO;EAAEC,MAAAA;EAAQ,KAAC,CAAC;EACnD,IAAA,MAAME,cAAc;IACtB,CAAC;EAED;EACF;EACA;EACA;EACA;EACEI,EAAAA,IAAIA,CAACL,OAAO,EAAED,OAAO,GAAG,EAAE,EAAE;MAC1BK,OAAO,CAACC,IAAI,CAAC,CAAA,cAAA,EAAiBL,OAAO,CAAA,CAAE,EAAED,OAAO,CAAC;IACnD,CAAC;EAED;EACF;EACA;EACA;EACA;EACA;IACEO,GAAGA,CAACN,OAAO,EAAEH,KAAK,EAAEE,OAAO,GAAG,EAAE,EAAE;EAChCK,IAAAA,OAAO,CAACP,KAAK,CAAC,CAAA,cAAA,EAAiBG,OAAO,EAAE,EAAE;QAAEH,KAAK;EAAEE,MAAAA;EAAQ,KAAC,CAAC;EAC/D,EAAA;EACF,CAAC;;EAED;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAC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A;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACO,MAAMC,cAAc,CAAC;EAC1B;EACF;EACA;EACA;EACA;EACA;EACA;EACA;IACE,OAAOC,iBAAiB,GAAG,sBAAsB;;EAEjD;EACF;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACE,EAAA,OAAOC,KAAKA,CAACtE,QAAQ,EAAEuE,IAAI,EAAE;EAC3B,IAAA,IAAI,OAAOvE,QAAQ,KAAK,QAAQ,EAAE,OAAOA,QAAQ;MACjD,OAAOA,QAAQ,CAAC3N,OAAO,CAAC,IAAI,CAACgS,iBAAiB,EAAE,CAAC/R,CAAC,EAAEkS,UAAU,KAC5D,IAAI,CAACC,QAAQ,CAACD,UAAU,EAAED,IAAI,CAChC,CAAC;EACH,EAAA;;EAEA;EACF;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACE,EAAA,OAAOE,QAAQA,CAACD,UAAU,EAAED,IAAI,EAAE;EAChC,IAAA,IAAI,OAAOC,UAAU,KAAK,QAAQ,EAAE,OAAOA,UAAU;MACrD,IAAI;QACF,OAAO,IAAIE,QAAQ,CAAC,MAAM,EAAE,CAAA,oBAAA,EAAuBF,UAAU,CAAA,GAAA,CAAK,CAAC,CAACD,IAAI,CAAC;EAC3E,IAAA,CAAC,CAAC,MAAM;EACN,MAAA,OAAO,EAAE;EACX,IAAA;EACF,EAAA;EACF;;ECxKA;EACA;EACA;EACA;EACA;EACA;EACA;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,CAAC;QAC9B,CAAC;EAED;EACN;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACM8S,MAAAA;OACD;;EAED;EACA5T,IAAAA,KAAK,CAAC8W,qBAAqB,GAAG9W,KAAK,CAACgV,aAAa;MACjDhV,KAAK,CAAC+W,cAAc,GAAG9B,aAAa;MACpCjV,KAAK,CAACgX,wBAAwB,GAAG5B,uBAAuB;IAC1D,CAAC;EAED;EACF;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;IACErR,SAASA,CAAC/D,KAAK,EAAE;EACf;MACA,IAAIA,KAAK,CAAC8W,qBAAqB,EAAE;EAC/B9W,MAAAA,KAAK,CAACgV,aAAa,GAAGhV,KAAK,CAAC8W,qBAAqB;QACjD,OAAO9W,KAAK,CAAC8W,qBAAqB;EACpC,IAAA;;EAEA;MACA,IAAI9W,KAAK,CAAC+W,cAAc,EAAE;EACxB/W,MAAAA,KAAK,CAAC4H,KAAK,GAAG5H,KAAK,CAAC+W,cAAc;QAClC,OAAO/W,KAAK,CAAC+W,cAAc;EAC7B,IAAA;;EAEA;MACA,IAAI/W,KAAK,CAACgX,wBAAwB,EAAE;EAClChX,MAAAA,KAAK,CAACqV,gBAAgB,GAAGrV,KAAK,CAACgX,wBAAwB;QACvD,OAAOhX,KAAK,CAACgX,wBAAwB;EACvC,IAAA;;EAEA;MACA,IAAIhX,KAAK,CAACyU,KAAK,EAAE;QACf,OAAOzU,KAAK,CAACyU,KAAK;EACpB,IAAA;EACF,EAAA;EACF;;EC3kBA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;AACO,QAAM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com */
2
+ var t,e;t=this,e=function(t){"use strict";const e=/-([a-z])/g,r={name:"attr",version:"1.0.0-rc.10",description:"Advanced attribute handling for Eleva components",install(t,r={}){const{enableAria:n=!0,enableData:o=!0,enableBoolean:i=!0,enableDynamic:s=!0}=r,a=(t,r)=>{const a=t.attributes,u=r.attributes;for(let r=0;r<u.length;r++){const{name:a,value:l}=u[r];if(!a.startsWith("@")&&t.getAttribute(a)!==l)if(n&&a.startsWith("aria-"))t["aria"+a.slice(5).replace(e,(t,e)=>e.toUpperCase())]=l,t.setAttribute(a,l);else if(o&&a.startsWith("data-"))t.dataset[a.slice(5)]=l,t.setAttribute(a,l);else{let r=a.replace(e,(t,e)=>e.toUpperCase());if(s&&!(r in t)&&!Object.getOwnPropertyDescriptor(Object.getPrototypeOf(t),r)){const e=Object.getOwnPropertyNames(Object.getPrototypeOf(t)).find(t=>t.toLowerCase()===a.toLowerCase()||t.toLowerCase().includes(a.toLowerCase())||a.toLowerCase().includes(t.toLowerCase()));e&&(r=e)}const n=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(t),r);if(r in t||n)if(i)if("boolean"==typeof t[r]||n?.get&&"boolean"==typeof n.get.call(t)){const e="false"!==l&&(""===l||l===r||"true"===l);t[r]=e,e?t.setAttribute(a,""):t.removeAttribute(a)}else t[r]=l,t.setAttribute(a,l);else t[r]=l,t.setAttribute(a,l);else t.setAttribute(a,l)}}for(let e=a.length-1;e>=0;e--){const n=a[e].name;r.hasAttribute(n)||t.removeAttribute(n)}};t.renderer&&(t.renderer.updateAttributes=a,t.renderer._originalPatchNode=t.renderer._patchNode,t.renderer._patchNode=function(t,e){t?._eleva_instance||(this._isSameNode(t,e)?t.nodeType===Node.ELEMENT_NODE?(a(t,e),this._diff(t,e)):t.nodeType===Node.TEXT_NODE&&t.nodeValue!==e.nodeValue&&(t.nodeValue=e.nodeValue):t.replaceWith(e.cloneNode(!0)))}),t.plugins||(t.plugins=new Map),t.plugins.set(this.name,{name:this.name,version:this.version,description:this.description,options:r}),t.updateElementAttributes=a},uninstall(t){t.renderer&&t.renderer._originalPatchNode&&(t.renderer._patchNode=t.renderer._originalPatchNode,delete t.renderer._originalPatchNode),t.plugins&&t.plugins.delete(this.name),delete t.updateElementAttributes}},n={handle(t,e,r={}){const n=new Error(`[ElevaRouter] ${e}: ${t.message}`);throw n.originalError=t,n.context=e,n.details=r,n},warn(t,e={}){},log(t,e,r={}){}};class o{constructor(t,e={}){this.eleva=t,this.options={mode:"hash",queryParam:"view",viewSelector:"root",...e},this.routes=this._processRoutes(e.routes||[]),this.emitter=this.eleva.emitter,this.isStarted=!1,this._isNavigating=!1,this._navigationId=0,this.eventListeners=[],this.currentRoute=new this.eleva.signal(null),this.previousRoute=new this.eleva.signal(null),this.currentParams=new this.eleva.signal({}),this.currentQuery=new this.eleva.signal({}),this.currentLayout=new this.eleva.signal(null),this.currentView=new this.eleva.signal(null),this.isReady=new this.eleva.signal(!1),this.plugins=new Map,this._beforeEachGuards=[],e.onBeforeEach&&this._beforeEachGuards.push(e.onBeforeEach),this.errorHandler=n,this._scrollPositions=new Map,this._validateOptions()}_validateOptions(){["hash","query","history"].includes(this.options.mode)||this.errorHandler.handle(new Error(`Invalid routing mode: ${this.options.mode}. Must be "hash", "query", or "history".`),"Configuration validation failed")}_processRoutes(t){const e=[];for(const r of t)try{e.push({...r,segments:this._parsePathIntoSegments(r.path)})}catch(t){this.errorHandler.warn(`Invalid path in route definition "${r.path||"undefined"}": ${t.message}`,{route:r,error:t})}return e}_parsePathIntoSegments(t){t&&"string"==typeof t||this.errorHandler.handle(new Error("Route path must be a non-empty string"),"Path parsing failed",{path:t});const e=t.replace(/\/+/g,"/").replace(/\/$/,"")||"/";return"/"===e?[]:e.split("/").filter(Boolean).map(e=>{if(e.startsWith(":")){const r=e.substring(1);return r||this.errorHandler.handle(new Error(`Invalid parameter segment: ${e}`),"Path parsing failed",{segment:e,path:t}),{type:"param",name:r}}return{type:"static",value:e}})}_findViewElement(t){const e=this.options.viewSelector;return t.querySelector(`#${e}`)||t.querySelector(`.${e}`)||t.querySelector(`[data-${e}]`)||t.querySelector(e)||t}async start(){if(this.isStarted)return this.errorHandler.warn("Router is already started"),this;if("undefined"==typeof window)return this.errorHandler.warn("Router start skipped: `window` object not available (SSR environment)"),this;if("undefined"!=typeof document&&!document.querySelector(this.options.mount))return this.errorHandler.warn(`Mount element "${this.options.mount}" was not found in the DOM. The router will not start.`,{mountSelector:this.options.mount}),this;const t=()=>this._handleRouteChange();return"hash"===this.options.mode?(window.addEventListener("hashchange",t),this.eventListeners.push(()=>window.removeEventListener("hashchange",t))):(window.addEventListener("popstate",t),this.eventListeners.push(()=>window.removeEventListener("popstate",t))),this.isStarted=!0,await this._handleRouteChange(!1),this.isReady.value=!0,await this.emitter.emit("router:ready",this),this}async destroy(){if(this.isStarted){for(const t of this.plugins.values())if("function"==typeof t.destroy)try{await t.destroy(this)}catch(e){this.errorHandler.log(`Plugin ${t.name} destroy failed`,e)}this.eventListeners.forEach(t=>t()),this.eventListeners=[],this.currentLayout.value&&await this.currentLayout.value.unmount(),this.isStarted=!1,this.isReady.value=!1}}async stop(){return this.destroy()}async navigate(t,e={}){try{const r="string"==typeof t?{path:t,params:e}:t;let n=this._buildPath(r.path,r.params||{});const o=r.query||{};if(Object.keys(o).length>0){const t=new URLSearchParams(o).toString();t&&(n+=`?${t}`)}if(this._isSameRoute(n,r.params,o))return!0;const i=await this._proceedWithNavigation(n);if(i){const t=++this._navigationId;this._isNavigating=!0;const e=r.state||{},o=r.replace||!1,i=o?"replaceState":"pushState";if("hash"===this.options.mode)if(o){const t=`${window.location.pathname}${window.location.search}#${n}`;window.history.replaceState(e,"",t)}else window.location.hash=n;else{const t="query"===this.options.mode?this._buildQueryUrl(n):n;history[i](e,"",t)}queueMicrotask(()=>{this._navigationId===t&&(this._isNavigating=!1)})}return i}catch(t){return this.errorHandler.log("Navigation failed",t),await this.emitter.emit("router:onError",t),!1}}_buildQueryUrl(t){const e=new URLSearchParams(window.location.search);return e.set(this.options.queryParam,t.split("?")[0]),`${window.location.pathname}?${e.toString()}`}_isSameRoute(t,e,r){const n=this.currentRoute.value;if(!n)return!1;const[o,i]=t.split("?"),s=r||this._parseQuery(i||"");return n.path===o&&JSON.stringify(n.params)===JSON.stringify(e||{})&&JSON.stringify(n.query)===JSON.stringify(s)}_buildPath(t,e){let r=t;for(const[t,n]of Object.entries(e)){const e=encodeURIComponent(String(n));r=r.replace(new RegExp(`:${t}\\b`,"g"),e)}return r}async _handleRouteChange(t=!0){if(!this._isNavigating)try{const e=this.currentRoute.value,r=this._getCurrentLocation();!await this._proceedWithNavigation(r.fullUrl,t)&&e&&this.navigate({path:e.path,query:e.query,replace:!0})}catch(t){this.errorHandler.log("Route change handling failed",t,{currentUrl:"undefined"!=typeof window?window.location.href:""}),await this.emitter.emit("router:onError",t)}}async _proceedWithNavigation(t,e=!1){const r=this.currentRoute.value,[n,o]=(t||"/").split("?"),i={path:n.startsWith("/")?n:`/${n}`,query:this._parseQuery(o),fullUrl:t};let s=this._matchRoute(i.path);if(!s){const t=this.routes.find(t=>"*"===t.path);if(!t)return await this.emitter.emit("router:onError",new Error(`Route not found: ${i.path}`),i,r),!1;s={route:t,params:{pathMatch:decodeURIComponent(i.path.substring(1))}}}const a={...i,params:s.params,meta:s.route.meta||{},name:s.route.name,matched:s.route};try{if(!await this._runGuards(a,r,s.route))return!1;r&&"undefined"!=typeof window&&this._scrollPositions.set(r.path,{x:window.scrollX||window.pageXOffset||0,y:window.scrollY||window.pageYOffset||0});const t={to:a,from:r,route:s.route,layoutComponent:null,pageComponent:null,cancelled:!1,redirectTo:null};if(await this.emitter.emit("router:beforeResolve",t),t.cancelled)return!1;if(t.redirectTo)return this.navigate(t.redirectTo),!1;const{layoutComponent:n,pageComponent:o}=await this._resolveComponents(s.route);if(t.layoutComponent=n,t.pageComponent=o,await this.emitter.emit("router:afterResolve",t),r){const t=async t=>{if(t)try{await t.unmount()}catch(e){this.errorHandler.warn("Error during component unmount",{error:e,instance:t})}};(s.route.layout||this.options.globalLayout)!==(r.matched.layout||this.options.globalLayout)?(await t(this.currentLayout.value),this.currentLayout.value=null):(await t(this.currentView.value),this.currentView.value=null),r.matched.afterLeave&&await r.matched.afterLeave(a,r),await this.emitter.emit("router:afterLeave",a,r)}this.previousRoute.value=r,this.currentRoute.value=a,this.currentParams.value=a.params||{},this.currentQuery.value=a.query||{};const i={to:a,from:r,layoutComponent:n,pageComponent:o};await this.emitter.emit("router:beforeRender",i),await this._render(n,o,a),await this.emitter.emit("router:afterRender",i);const u={to:a,from:r,savedPosition:e&&this._scrollPositions.get(a.path)||null};return await this.emitter.emit("router:scroll",u),s.route.afterEnter&&await s.route.afterEnter(a,r),await this.emitter.emit("router:afterEnter",a,r),await this.emitter.emit("router:afterEach",a,r),!0}catch(t){return this.errorHandler.log("Error during navigation",t,{to:a,from:r}),await this.emitter.emit("router:onError",t,a,r),!1}}async _runGuards(t,e,r){const n={to:t,from:e,cancelled:!1,redirectTo:null};if(await this.emitter.emit("router:beforeEach",n),n.cancelled)return!1;if(n.redirectTo)return this.navigate(n.redirectTo),!1;const o=[...this._beforeEachGuards,...e&&e.matched.beforeLeave?[e.matched.beforeLeave]:[],...r.beforeEnter?[r.beforeEnter]:[]];for(const r of o){const n=await r(t,e);if(!1===n)return!1;if("string"==typeof n||"object"==typeof n)return this.navigate(n),!1}return!0}_resolveStringComponent(t){const e=this.eleva._components.get(t);return e||this.errorHandler.handle(new Error(`Component "${t}" not registered.`),"Component resolution failed",{componentName:t,availableComponents:Array.from(this.eleva._components.keys())}),e}async _resolveFunctionComponent(t){try{const e=t.toString(),r=e.includes("import(")||e.startsWith("() =>"),n=await t();return r&&n.default||n}catch(e){this.errorHandler.handle(new Error(`Failed to load async component: ${e.message}`),"Component resolution failed",{function:t.toString(),error:e})}}_validateComponentDefinition(t){return t&&"object"==typeof t||this.errorHandler.handle(new Error("Invalid component definition: "+typeof t),"Component validation failed",{definition:t}),"function"!=typeof t.template&&"string"!=typeof t.template&&this.errorHandler.handle(new Error("Component missing template property"),"Component validation failed",{definition:t}),t}async _resolveComponent(t){return null==t?null:"string"==typeof t?this._resolveStringComponent(t):"function"==typeof t?await this._resolveFunctionComponent(t):t&&"object"==typeof t?this._validateComponentDefinition(t):void this.errorHandler.handle(new Error("Invalid component definition: "+typeof t),"Component resolution failed",{definition:t})}async _resolveComponents(t){const e=t.layout||this.options.globalLayout;try{const[r,n]=await Promise.all([this._resolveComponent(e),this._resolveComponent(t.component)]);return n||this.errorHandler.handle(new Error(`Page component is null or undefined for route: ${t.path}`),"Component resolution failed",{route:t.path}),{layoutComponent:r,pageComponent:n}}catch(e){throw this.errorHandler.log(`Error resolving components for route ${t.path}`,e,{route:t.path}),e}}async _render(t,e){const r=document.querySelector(this.options.mount);if(r||this.errorHandler.handle(new Error(`Mount element "${this.options.mount}" not found.`),{mountSelector:this.options.mount}),t){const n=await this.eleva.mount(r,this._wrapComponentWithChildren(t));this.currentLayout.value=n;const o=this._findViewElement(n.container),i=await this.eleva.mount(o,this._wrapComponentWithChildren(e));this.currentView.value=i}else{const t=await this.eleva.mount(r,this._wrapComponentWithChildren(e));this.currentView.value=t,this.currentLayout.value=null}}_createRouteGetter(t,e){return()=>this.currentRoute.value?.[t]??e}_wrapComponent(t){const e=t.setup,r=this;return{...t,setup:async t=>(t.router={navigate:r.navigate.bind(r),current:r.currentRoute,previous:r.previousRoute,get params(){return r._createRouteGetter("params",{})()},get query(){return r._createRouteGetter("query",{})()},get path(){return r._createRouteGetter("path","/")()},get fullUrl(){return r._createRouteGetter("fullUrl",window.location.href)()},get meta(){return r._createRouteGetter("meta",{})()}},e?await e(t):{})}}_wrapComponentWithChildren(t){if("string"==typeof t)return t;if(!t||"object"!=typeof t)return t;const e=this._wrapComponent(t);if(e.children&&"object"==typeof e.children){const t={};for(const[r,n]of Object.entries(e.children))t[r]=this._wrapComponentWithChildren(n);e.children=t}return e}_getCurrentLocation(){if("undefined"==typeof window)return{path:"/",query:{},fullUrl:""};let t,e,r;switch(this.options.mode){case"hash":r=window.location.hash.slice(1)||"/",[t,e]=r.split("?");break;case"query":t=new URLSearchParams(window.location.search).get(this.options.queryParam)||"/",e=window.location.search.slice(1),r=t;break;default:t=window.location.pathname||"/",e=window.location.search.slice(1),r=`${t}${e?"?"+e:""}`}return{path:t.startsWith("/")?t:`/${t}`,query:this._parseQuery(e),fullUrl:r}}_parseQuery(t){const e={};return t&&new URLSearchParams(t).forEach((t,r)=>{e[r]=t}),e}_matchRoute(t){const e=t.split("/").filter(Boolean);for(const t of this.routes){if("/"===t.path){if(0===e.length)return{route:t,params:{}};continue}if(t.segments.length!==e.length)continue;const r={};let n=!0;for(let o=0;o<t.segments.length;o++){const i=t.segments[o],s=e[o];if("param"===i.type)r[i.name]=decodeURIComponent(s);else if(i.value!==s){n=!1;break}}if(n)return{route:t,params:r}}return null}addRoute(t,e=null){if(!t||!t.path)return this.errorHandler.warn("Invalid route definition: missing path",{route:t}),()=>{};if(this.hasRoute(t.path))return this.errorHandler.warn(`Route "${t.path}" already exists`,{route:t}),()=>{};const r={...t,segments:this._parsePathIntoSegments(t.path)},n=this.routes.findIndex(t=>"*"===t.path);return-1!==n?this.routes.splice(n,0,r):this.routes.push(r),this.emitter.emit("router:routeAdded",r),()=>this.removeRoute(t.path)}removeRoute(t){const e=this.routes.findIndex(e=>e.path===t);if(-1===e)return!1;const[r]=this.routes.splice(e,1);return this.emitter.emit("router:routeRemoved",r),!0}hasRoute(t){return this.routes.some(e=>e.path===t)}getRoutes(){return[...this.routes]}getRoute(t){return this.routes.find(e=>e.path===t)}onBeforeEach(t){return this._beforeEachGuards.push(t),()=>{const e=this._beforeEachGuards.indexOf(t);e>-1&&this._beforeEachGuards.splice(e,1)}}onAfterEnter(t){return this.emitter.on("router:afterEnter",t)}onAfterLeave(t){return this.emitter.on("router:afterLeave",t)}onAfterEach(t){return this.emitter.on("router:afterEach",t)}onError(t){return this.emitter.on("router:onError",t)}use(t,e={}){"function"!=typeof t.install&&this.errorHandler.handle(new Error("Plugin must have an install method"),"Plugin registration failed",{plugin:t}),this.plugins.has(t.name)?this.errorHandler.warn(`Plugin "${t.name}" is already registered`,{existingPlugin:this.plugins.get(t.name)}):(this.plugins.set(t.name,t),t.install(this,e))}getPlugins(){return Array.from(this.plugins.values())}getPlugin(t){return this.plugins.get(t)}removePlugin(t){const e=this.plugins.get(t);if(!e)return!1;if("function"==typeof e.destroy)try{e.destroy(this)}catch(e){this.errorHandler.log(`Plugin ${t} destroy failed`,e)}return this.plugins.delete(t)}setErrorHandler(t){t&&"function"==typeof t.handle&&"function"==typeof t.warn&&"function"==typeof t.log&&(this.errorHandler=t)}}const i={name:"router",version:"1.0.0-rc.10",description:"Client-side routing for Eleva applications",install(t,e={}){if(!e.mount)throw new Error("[RouterPlugin] 'mount' option is required");if(!e.routes||!Array.isArray(e.routes))throw new Error("[RouterPlugin] 'routes' option must be an array");const r=(e,r)=>{if(!e)return null;if("object"==typeof e&&null!==e&&!e.name){const n=`Eleva${r}Component_${Math.random().toString(36).slice(2,11)}`;try{return t.component(n,e),n}catch(t){throw new Error(`[RouterPlugin] Failed to register ${r} component: ${t.message}`)}}return e};e.globalLayout&&(e.globalLayout=r(e.globalLayout,"GlobalLayout")),(e.routes||[]).forEach(t=>{t.component=r(t.component,"Route"),t.layout&&(t.layout=r(t.layout,"RouteLayout"))});const n=new o(t,e);return t.router=n,!1!==e.autoStart&&queueMicrotask(()=>n.start()),t.plugins||(t.plugins=new Map),t.plugins.set(this.name,{name:this.name,version:this.version,description:this.description,options:e}),t.navigate=n.navigate.bind(n),t.getCurrentRoute=()=>n.currentRoute.value,t.getRouteParams=()=>n.currentParams.value,t.getRouteQuery=()=>n.currentQuery.value,n},async uninstall(t){t.router&&(await t.router.destroy(),delete t.router),t.plugins&&t.plugins.delete(this.name),delete t.navigate,delete t.getCurrentRoute,delete t.getRouteParams,delete t.getRouteQuery}};class s{static expressionPattern=/\{\{\s*(.*?)\s*\}\}/g;static parse(t,e){return"string"!=typeof t?t:t.replace(this.expressionPattern,(t,r)=>this.evaluate(r,e))}static evaluate(t,e){if("string"!=typeof t)return t;try{return new Function("data",`with(data) { return ${t}; }`)(e)}catch{return""}}}const a={name:"props",version:"1.0.0-rc.10",description:"Advanced props data handling for complex data structures with automatic type detection and reactivity",install(t,e={}){const{enableAutoParsing:r=!0,enableReactivity:n=!0,onError:o=null}=e,i=t=>{try{if("string"!=typeof t)return t;if("true"===t)return!0;if("false"===t)return!1;if("null"===t)return null;if("undefined"===t)return;if(t.startsWith("{")||t.startsWith("["))try{return JSON.parse(t)}catch(e){throw new Error(`Invalid JSON: ${t}`)}if("1"===t)return!0;if("0"===t)return!1;if(""===t)return!0;if(!isNaN(t)&&""!==t&&!isNaN(parseFloat(t)))return Number(t);if(t.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/)){const e=new Date(t);if(!isNaN(e.getTime()))return e}return t}catch(e){return o&&o(e,t),t}},a=e=>{const r={};return Object.entries(e).forEach(([e,n])=>{r[e]=n&&"object"==typeof n&&"value"in n&&"watch"in n?n:new t.signal(n)}),r};t._extractProps=t=>{const e={},n=t.attributes;for(let o=n.length-1;o>=0;o--){const s=n[o];if(s.name.startsWith(":")){const n=s.name.slice(1),o=r?i(s.value):s.value;e[n]=o,t.removeAttribute(s.name)}}return e};const u=t.mount;t.mount=async(e,r,o={})=>{const i=n?a(o):o;return await u.call(t,e,r,i)};const l=t._mountComponents,c=new WeakMap,h=new Set;t._mountComponents=async(e,r,o)=>{for(const[i,s]of Object.entries(r))if(i)for(const r of e.querySelectorAll(i)){if(!(r instanceof HTMLElement))continue;const i=t._extractProps(r);let u=i,l=c.get(e);if(!l){let t=e;for(;t&&!l;){if(t._eleva_instance&&t._eleva_instance.data){l=t._eleva_instance.data,c.set(e,l);break}t=t.parentElement}}if(n&&l){const e={};Object.keys(i).forEach(r=>{l[r]&&l[r]instanceof t.signal&&(e[r]=l[r])}),u={...i,...e}}let d=u;if(n){const t={};Object.entries(u).forEach(([e,r])=>{r&&"object"==typeof r&&"value"in r&&"watch"in r||(t[e]=r)}),d={...a(t),...u}}const p=await t.mount(r,s,d);p&&!o.includes(p)&&(o.push(p),n&&Object.keys(i).length>0&&!l&&h.add({instance:p,extractedProps:i,container:e,component:s}))}if(n&&h.size>0)for(const e of h){const{instance:r,extractedProps:n,container:o,component:i}=e;let a=c.get(o);if(!a){let t=o;for(;t&&!a;){if(t._eleva_instance&&t._eleva_instance.data){a=t._eleva_instance.data,c.set(o,a);break}t=t.parentElement}}if(a){const o={};if(Object.keys(n).forEach(e=>{a[e]&&a[e]instanceof t.signal&&(o[e]=a[e])}),Object.keys(o).length>0){Object.assign(r.data,o),Object.keys(o).forEach(e=>{const n=o[e];n&&"function"==typeof n.watch&&n.watch(()=>{const e=t._components.get(i)||i;if(e&&e.template){const n="function"==typeof e.template?e.template(r.data):e.template,o=s.parse(n,r.data);t.renderer.patchDOM(r.container,o)}})});const e=t._components.get(i)||i;if(e&&e.template){const n="function"==typeof e.template?e.template(r.data):e.template,o=s.parse(n,r.data);t.renderer.patchDOM(r.container,o)}}h.delete(e)}}},t.props={parse:t=>r?i(t):t,detectType:t=>null===t?"null":void 0===t?"undefined":"boolean"==typeof t?"boolean":"number"==typeof t?"number":"string"==typeof t?"string":"function"==typeof t?"function":t instanceof Date?"date":t instanceof Map?"map":t instanceof Set?"set":Array.isArray(t)?"array":"object"==typeof t?"object":"unknown"},t._originalExtractProps=t._extractProps,t._originalMount=u,t._originalMountComponents=l},uninstall(t){t._originalExtractProps&&(t._extractProps=t._originalExtractProps,delete t._originalExtractProps),t._originalMount&&(t.mount=t._originalMount,delete t._originalMount),t._originalMountComponents&&(t._mountComponents=t._originalMountComponents,delete t._originalMountComponents),t.props&&delete t.props}},u={name:"store",version:"1.0.0-rc.10",description:"Reactive state management for sharing data across the entire Eleva application",install(t,e={}){const{state:r={},actions:n={},namespaces:o={},persistence:i={},devTools:s=!1,onError:a=null}=e,u=new class{constructor(){this.state={},this.actions={},this.subscribers=new Set,this.mutations=[],this.persistence={enabled:!1,key:"eleva-store",storage:"localStorage",include:null,exclude:null,...i},this.devTools=s,this.onError=a,this._initializeState(r,n),this._initializeNamespaces(o),this._loadPersistedState(),this._setupDevTools()}_initializeState(e,r){Object.entries(e).forEach(([e,r])=>{this.state[e]=new t.signal(r)}),this.actions={...r}}_initializeNamespaces(e){Object.entries(e).forEach(([e,r])=>{const{state:n={},actions:o={}}=r;this.state[e]||(this.state[e]={}),this.actions[e]||(this.actions[e]={}),Object.entries(n).forEach(([r,n])=>{this.state[e][r]=new t.signal(n)}),this.actions[e]={...o}})}_loadPersistedState(){if(this.persistence.enabled&&"undefined"!=typeof window)try{const t=window[this.persistence.storage].getItem(this.persistence.key);if(t){const e=JSON.parse(t);this._applyPersistedData(e)}}catch(t){this.onError&&this.onError(t,"Failed to load persisted state")}}_applyPersistedData(t,e=this.state,r=""){Object.entries(t).forEach(([t,n])=>{const o=r?`${r}.${t}`:t;this._shouldPersist(o)&&(e[t]&&"object"==typeof e[t]&&"value"in e[t]?e[t].value=n:"object"==typeof n&&null!==n&&e[t]&&this._applyPersistedData(n,e[t],o))})}_shouldPersist(t){const{include:e,exclude:r}=this.persistence;return e&&e.length>0?e.some(e=>t.startsWith(e)):!(r&&r.length>0&&r.some(e=>t.startsWith(e)))}_saveState(){if(this.persistence.enabled&&"undefined"!=typeof window)try{const t=window[this.persistence.storage],e=this._extractPersistedData();t.setItem(this.persistence.key,JSON.stringify(e))}catch(t){this.onError&&this.onError(t,"Failed to save state")}}_extractPersistedData(t=this.state,e=""){const r={};return Object.entries(t).forEach(([t,n])=>{const o=e?`${e}.${t}`:t;if(this._shouldPersist(o))if(n&&"object"==typeof n&&"value"in n)r[t]=n.value;else if("object"==typeof n&&null!==n){const e=this._extractPersistedData(n,o);Object.keys(e).length>0&&(r[t]=e)}}),r}_setupDevTools(){this.devTools&&"undefined"!=typeof window&&window.__ELEVA_DEVTOOLS__&&window.__ELEVA_DEVTOOLS__.registerStore(this)}async dispatch(t,e){try{const r=this._getAction(t);if(!r){const e=new Error(`Action "${t}" not found`);throw this.onError&&this.onError(e,t),e}const n={type:t,payload:e,timestamp:Date.now()};this.mutations.push(n),this.mutations.length>100&&this.mutations.shift();const o=await r.call(null,this.state,e);return this._saveState(),this.subscribers.forEach(t=>{try{t(n,this.state)}catch(t){this.onError&&this.onError(t,"Subscriber callback failed")}}),this.devTools&&"undefined"!=typeof window&&window.__ELEVA_DEVTOOLS__&&window.__ELEVA_DEVTOOLS__.notifyMutation(n,this.state),o}catch(e){throw this.onError&&this.onError(e,`Action dispatch failed: ${t}`),e}}_getAction(t){const e=t.split(".");let r=this.actions;for(const t of e){if(void 0===r[t])return null;r=r[t]}return"function"==typeof r?r:null}subscribe(t){if("function"!=typeof t)throw new Error("Subscribe callback must be a function");return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}getState(){return this._extractPersistedData()}replaceState(t){this._applyPersistedData(t),this._saveState()}clearPersistedState(){if(this.persistence.enabled&&"undefined"!=typeof window)try{window[this.persistence.storage].removeItem(this.persistence.key)}catch(t){this.onError&&this.onError(t,"Failed to clear persisted state")}}registerModule(t,e){this.state[t]||this.actions[t]||(this.state[t]={},this.actions[t]={},this._initializeNamespaces({[t]:e}),this._saveState())}unregisterModule(t){(this.state[t]||this.actions[t])&&(delete this.state[t],delete this.actions[t],this._saveState())}createState(e,r){return this.state[e]||(this.state[e]=new t.signal(r),this._saveState()),this.state[e]}createAction(t,e){if("function"!=typeof e)throw new Error("Action must be a function");this.actions[t]=e}},l=t.mount;t.mount=async(e,r,n={})=>{const o="string"==typeof r&&t._components.get(r)||r;if(!o)return await l.call(t,e,r,n);const i={...o,async setup(e){e.store={state:u.state,dispatch:u.dispatch.bind(u),subscribe:u.subscribe.bind(u),getState:u.getState.bind(u),registerModule:u.registerModule.bind(u),unregisterModule:u.unregisterModule.bind(u),createState:u.createState.bind(u),createAction:u.createAction.bind(u),signal:t.signal};const r=o.setup;return r?await r(e):{}}};return await l.call(t,e,i,n)};const c=t._mountComponents;t._mountComponents=async(e,r,n)=>{const o={};for(const[e,n]of Object.entries(r)){const r="string"==typeof n&&t._components.get(n)||n;o[e]=r&&"object"==typeof r?{...r,async setup(e){e.store={state:u.state,dispatch:u.dispatch.bind(u),subscribe:u.subscribe.bind(u),getState:u.getState.bind(u),registerModule:u.registerModule.bind(u),unregisterModule:u.unregisterModule.bind(u),createState:u.createState.bind(u),createAction:u.createAction.bind(u),signal:t.signal};const n=r.setup;return n?await n(e):{}}}:n}return await c.call(t,e,o,n)},t.store=u,t.createAction=(t,e)=>{u.actions[t]=e},t.dispatch=(t,e)=>u.dispatch(t,e),t.getState=()=>u.getState(),t.subscribe=t=>u.subscribe(t),t._originalMount=l,t._originalMountComponents=c},uninstall(t){t._originalMount&&(t.mount=t._originalMount,delete t._originalMount),t._originalMountComponents&&(t._mountComponents=t._originalMountComponents,delete t._originalMountComponents),t.store&&delete t.store,t.createAction&&delete t.createAction,t.dispatch&&delete t.dispatch,t.getState&&delete t.getState,t.subscribe&&delete t.subscribe}};t.Attr=r,t.Props=a,t.Router=i,t.Store=u},"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ElevaPlugins={});
3
+ //# sourceMappingURL=eleva-plugins.umd.min.js.map