@mhmo91/schmancy 0.4.97 → 0.5.1
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.
- package/dist/area.cjs +1 -1
- package/dist/{area.component-5hvsA6_h.js → area.component-Oe5ARA8j.js} +37 -25
- package/dist/area.component-Oe5ARA8j.js.map +1 -0
- package/dist/area.component-VxW9QIje.cjs +12 -0
- package/dist/area.component-VxW9QIje.cjs.map +1 -0
- package/dist/area.js +19 -17
- package/dist/{avatar-B51KRC34.cjs → avatar-8S9Tq43j.cjs} +2 -2
- package/dist/{avatar-B51KRC34.cjs.map → avatar-8S9Tq43j.cjs.map} +1 -1
- package/dist/{avatar-Dpy9JzIW.js → avatar-KoZsr-CS.js} +2 -2
- package/dist/{avatar-Dpy9JzIW.js.map → avatar-KoZsr-CS.js.map} +1 -1
- package/dist/badge.cjs +1 -1
- package/dist/badge.js +1 -1
- package/dist/content-drawer.cjs +1 -1
- package/dist/content-drawer.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +213 -211
- package/dist/nav-drawer.cjs +1 -1
- package/dist/nav-drawer.js +1 -1
- package/dist/teleport.cjs +1 -1
- package/dist/teleport.js +1 -1
- package/dist/{lazy-DObpkuL6.cjs → utils-C38P63L6.cjs} +2 -2
- package/dist/utils-C38P63L6.cjs.map +1 -0
- package/dist/{lazy-E2LCDm7n.js → utils-CYOVFxSx.js} +68 -60
- package/dist/utils-CYOVFxSx.js.map +1 -0
- package/package.json +4 -236
- package/types/src/area/area.component.d.ts +2 -4
- package/types/src/area/index.d.ts +3 -2
- package/types/src/area/route.component.d.ts +3 -7
- package/types/src/area/router.types.d.ts +2 -3
- package/types/src/area/utils.d.ts +2 -2
- package/dist/area.component-5hvsA6_h.js.map +0 -1
- package/dist/area.component-DSAxybsX.cjs +0 -12
- package/dist/area.component-DSAxybsX.cjs.map +0 -1
- package/dist/lazy-DObpkuL6.cjs.map +0 -1
- package/dist/lazy-E2LCDm7n.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"area.component-5hvsA6_h.js","sources":["../src/area/area.service.ts","../src/area/route.component.ts","../src/area/router.types.ts","../src/area/area.component.ts"],"sourcesContent":["import {\n\tbufferTime,\n\tcatchError,\n\tdistinctUntilChanged,\n\tEMPTY,\n\tfilter,\n\tfromEvent,\n\tmap,\n\tObservable,\n\tof,\n\tReplaySubject,\n\tshareReplay,\n\tskip,\n\tSubject,\n\tSubscription,\n\ttap,\n\ttimeout,\n\tzip\n} from 'rxjs'\nimport { SchmancyTeleportation } from '../teleport'\nimport { ActiveRoute, AreaSubscription, RouteAction } from './router.types'\n\nexport const routerHistory = new Subject<RouteAction>()\n\nexport const FINDING_MORTIES = 'FINDING_MORTIES'\nexport const HERE_RICKY = 'HERE_RICKY'\nexport type HERE_RICKY_EVENT = CustomEvent<{\n\tcomponent: SchmancyTeleportation\n}>\nexport type FINDING_MORTIES_EVENT = CustomEvent<{\n\tcomponent: SchmancyTeleportation\n}>\n\n// WeakMap for better memory management of area subjects\nconst areaSubjectsCache = new WeakMap<AreaService, Map<string, ReplaySubject<ActiveRoute>>>()\n\n// Track navigation source to prevent history conflicts\ntype NavigationSource = 'programmatic' | 'browser' | 'initial'\n\nclass AreaService implements AreaSubscription {\n\tprivate static instance: AreaService\n\tpublic prettyURL = false\n\tpublic mode: 'SILENT' | 'HISTORY' = 'HISTORY'\n\tpublic request = new ReplaySubject<RouteAction>(1)\n\tpublic current = new Map<string, ActiveRoute>()\n\tpublic $current = new ReplaySubject<Map<string, ActiveRoute>>(1)\n\t\n\t// Create a dictionary of ReplaySubjects for area-specific subscriptions\n\tprivate get areaSubjects(): Map<string, ReplaySubject<ActiveRoute>> {\n\t\tlet subjects = areaSubjectsCache.get(this)\n\t\tif (!subjects) {\n\t\t\tsubjects = new Map()\n\t\t\tareaSubjectsCache.set(this, subjects)\n\t\t}\n\t\treturn subjects\n\t}\n\t\n\tpublic enableHistoryMode = true\n\tprivate findingMortiesEvent = new CustomEvent<FINDING_MORTIES_EVENT['detail']>(FINDING_MORTIES)\n\tprivate disposed = false\n\tpublic isProcessingPopstate = false\n\tprivate unloadSubscription?: Subscription\n\n\tconstructor() {\n\t\tthis.$current.next(this.current)\n\t\t\n\t\t// Subscribe to current changes to update area-specific subjects\n\t\tthis.$current.subscribe(currentAreas => {\n\t\t\tif (this.disposed) return\n\t\t\t\n\t\t\t// For each area in the current map\n\t\t\tcurrentAreas.forEach((route, areaName) => {\n\t\t\t\t// Get or create a subject for this area\n\t\t\t\tconst areaSubject = this.getOrCreateAreaSubject(areaName)\n\t\t\t\t// Emit the updated route to area-specific subscribers\n\t\t\t\tareaSubject.next(route)\n\t\t\t})\n\t\t})\n\n\t\t// Initialize from browser state if available\n\t\tthis.initializeFromBrowserState()\n\n\t\t// Setup unload subscription using RxJS\n\t\tif (typeof window !== 'undefined') {\n\t\t\tthis.unloadSubscription = fromEvent(window, 'unload').subscribe(() => {\n\t\t\t\tthis.dispose()\n\t\t\t})\n\t\t}\n\t}\n\n\t/**\n\t * Initialize router state from browser history state\n\t */\n\tprivate initializeFromBrowserState() {\n\t\ttry {\n\t\t\tconst browserState = history.state\n\t\t\tif (browserState && browserState.schmancyAreas) {\n\t\t\t\tObject.entries(browserState.schmancyAreas).forEach(([areaName, route]) => {\n\t\t\t\t\tthis.current.set(areaName, route as ActiveRoute)\n\t\t\t\t})\n\t\t\t\tthis.$current.next(this.current)\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsole.warn('Failed to initialize from browser state:', error)\n\t\t}\n\t}\n\n\t/**\n\t * Get or create a ReplaySubject for a specific area with proper cleanup\n\t */\n\tprivate getOrCreateAreaSubject(areaName: string): ReplaySubject<ActiveRoute> {\n\t\tlet subject = this.areaSubjects.get(areaName)\n\t\t\n\t\tif (!subject || subject.closed) {\n\t\t\tsubject = new ReplaySubject<ActiveRoute>(1)\n\t\t\tthis.areaSubjects.set(areaName, subject)\n\t\t\t\n\t\t\t// If the area already exists in current, emit it immediately\n\t\t\tconst currentRoute = this.current.get(areaName)\n\t\t\tif (currentRoute) {\n\t\t\t\tsubject.next({\n\t\t\t\t\t...currentRoute,\n\t\t\t\t\t// Ensure state, params and props are initialized if undefined\n\t\t\t\t\tstate: currentRoute.state || {},\n\t\t\t\t\tparams: currentRoute.params || {},\n\t\t\t\t\tprops: currentRoute.props || {}\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn subject\n\t}\n\n\t/**\n\t * Subscribe to a specific area with caching\n\t */\n\ton(areaName: string, skipCurrent = false): Observable<ActiveRoute> {\n\t\tif (!areaName) {\n\t\t\tthrow new Error('Area name is required')\n\t\t}\n\t\t\n\t\tconst areaSubject = this.getOrCreateAreaSubject(areaName)\n\t\tconst observable = areaSubject.asObservable().pipe(\n\t\t\t// Add distinct to prevent duplicate emissions - now includes state\n\t\t\tdistinctUntilChanged((a, b) => \n\t\t\t\ta.component === b.component &&\n\t\t\t\tJSON.stringify(a.state) === JSON.stringify(b.state) &&\n\t\t\t\tJSON.stringify(a.params) === JSON.stringify(b.params)\n\t\t\t),\n\t\t\t// Share the subscription\n\t\t\tshareReplay(1)\n\t\t)\n\t\t\n\t\treturn skipCurrent ? observable.pipe(skip(1)) : observable\n\t}\n\t\n\t/**\n\t * Subscribe to all areas\n\t */\n\tall(skipCurrent = false): Observable<Map<string, ActiveRoute>> {\n\t\tconst observable = this.$current.asObservable().pipe(\n\t\t\tshareReplay(1)\n\t\t)\n\t\treturn skipCurrent ? observable.pipe(skip(1)) : observable\n\t}\n\t\n\t/**\n\t * Get state from an area with type safety\n\t */\n\tgetState<T = unknown>(areaName: string): Observable<T> {\n\t\tif (!areaName) {\n\t\t\tthrow new Error('Area name is required')\n\t\t}\n\t\t\n\t\treturn this.on(areaName).pipe(\n\t\t\tmap(route => route.state),\n\t\t\tfilter((state): state is NonNullable<Record<string, unknown>> => \n\t\t\t\tstate !== undefined && state !== null\n\t\t\t),\n\t\t\tdistinctUntilChanged((a, b) => JSON.stringify(a) === JSON.stringify(b)),\n\t\t\tmap(state => state as T),\n\t\t\tcatchError(err => {\n\t\t\t\tconsole.error(`Error getting state for area \"${areaName}\":`, err)\n\t\t\t\treturn EMPTY\n\t\t\t})\n\t\t)\n\t}\n\t\n\t/**\n\t * Get params from an area with type safety\n\t */\n\tparams<T extends Record<string, unknown> = Record<string, unknown>>(areaName: string): Observable<T> {\n\t\tif (!areaName) {\n\t\t\tthrow new Error('Area name is required')\n\t\t}\n\t\t\n\t\treturn this.on(areaName).pipe(\n\t\t\tmap(route => route.params),\n\t\t\tfilter((params): params is NonNullable<Record<string, unknown>> => \n\t\t\t\tparams !== undefined && params !== null\n\t\t\t),\n\t\t\tdistinctUntilChanged((a, b) => JSON.stringify(a) === JSON.stringify(b)),\n\t\t\tmap(params => params as T),\n\t\t\tcatchError(err => {\n\t\t\t\tconsole.error(`Error getting params for area \"${areaName}\":`, err)\n\t\t\t\treturn EMPTY\n\t\t\t})\n\t\t)\n\t}\n\t\n\t/**\n\t * Get a specific param from an area with null safety\n\t */\n\tparam<T = unknown>(areaName: string, key: string): Observable<T> {\n\t\tif (!areaName || !key) {\n\t\t\tthrow new Error('Area name and key are required')\n\t\t}\n\t\t\n\t\treturn this.params<Record<string, unknown>>(areaName).pipe(\n\t\t\tmap(params => params[key]),\n\t\t\tfilter((value): value is NonNullable<unknown> => value !== undefined),\n\t\t\tdistinctUntilChanged(),\n\t\t\tmap(value => value as T),\n\t\t\tcatchError(err => {\n\t\t\t\tconsole.error(`Error getting param \"${key}\" for area \"${areaName}\":`, err)\n\t\t\t\treturn EMPTY\n\t\t\t})\n\t\t)\n\t}\n\t\n\t/**\n\t * Get props from an area with type safety\n\t */\n\tprops<T extends Record<string, unknown> = Record<string, unknown>>(areaName: string): Observable<T> {\n\t\tif (!areaName) {\n\t\t\tthrow new Error('Area name is required')\n\t\t}\n\t\t\n\t\treturn this.on(areaName).pipe(\n\t\t\tmap(route => route.props),\n\t\t\tfilter((props): props is NonNullable<Record<string, unknown>> => \n\t\t\t\tprops !== undefined && props !== null\n\t\t\t),\n\t\t\tdistinctUntilChanged((a, b) => JSON.stringify(a) === JSON.stringify(b)),\n\t\t\tmap(props => props as T),\n\t\t\tcatchError(err => {\n\t\t\t\tconsole.error(`Error getting props for area \"${areaName}\":`, err)\n\t\t\t\treturn EMPTY\n\t\t\t})\n\t\t)\n\t}\n\t\n\t/**\n\t * Get a specific prop from an area with null safety\n\t */\n\tprop<T = unknown>(areaName: string, key: string): Observable<T> {\n\t\tif (!areaName || !key) {\n\t\t\tthrow new Error('Area name and key are required')\n\t\t}\n\t\t\n\t\treturn this.props<Record<string, unknown>>(areaName).pipe(\n\t\t\tmap(props => props[key]),\n\t\t\tfilter((value): value is NonNullable<unknown> => value !== undefined),\n\t\t\tdistinctUntilChanged(),\n\t\t\tmap(value => value as T),\n\t\t\tcatchError(err => {\n\t\t\t\tconsole.error(`Error getting prop \"${key}\" for area \"${areaName}\":`, err)\n\t\t\t\treturn EMPTY\n\t\t\t})\n\t\t)\n\t}\n\n\t/**\n\t * Find teleportation components\n\t */\n\tfind() {\n\t\treturn zip([\n\t\t\tfromEvent<HERE_RICKY_EVENT>(window, HERE_RICKY).pipe(\n\t\t\t\tmap(e => e.detail),\n\t\t\t\tbufferTime(0),\n\t\t\t),\n\t\t\tof(1).pipe(tap(() => window.dispatchEvent(this.findingMortiesEvent))),\n\t\t]).pipe(\n\t\t\tmap(([component]) => component),\n\t\t\ttimeout(1),\n\t\t\tcatchError(() => EMPTY)\n\t\t)\n\t}\n\n\t/**\n\t * Push a new route action with validation\n\t */\n\tpush(r: RouteAction) {\n\t\tif (!r.area) {\n\t\t\tthrow new Error('Area is required for route action')\n\t\t}\n\t\t\n\t\t// Prevent processing during popstate handling\n\t\tif (this.isProcessingPopstate) {\n\t\t\treturn\n\t\t}\n\t\t\n\t\t// Ensure state, params and props are initialized\n\t\tconst routeAction: RouteAction = {\n\t\t\t...r,\n\t\t\tstate: r.state || {},\n\t\t\tparams: r.params || {},\n\t\t\tprops: r.props || {},\n\t\t\t_source: 'programmatic' as NavigationSource\n\t\t}\n\t\t\n\t\t// Add to history if enabled\n\t\tif (this.enableHistoryMode) {\n\t\t\trouterHistory.next(routeAction)\n\t\t}\n\t\t\n\t\tthis.request.next(routeAction)\n\t\t// Emit an area-specific event for those who want to listen directly to DOM events\n\t\tthis.dispatchAreaEvent(routeAction.area, routeAction)\n\t}\n\n\t/**\n\t * Internal method to update route from browser navigation\n\t * This should only be called by area components during popstate handling\n\t */\n\t_updateFromBrowser(routeAction: RouteAction) {\n\t\tconst enhancedRoute: RouteAction = {\n\t\t\t...routeAction,\n\t\t\tstate: routeAction.state || {},\n\t\t\tparams: routeAction.params || {},\n\t\t\tprops: routeAction.props || {},\n\t\t\t_source: 'browser' as NavigationSource\n\t\t}\n\t\t\n\t\tthis.isProcessingPopstate = true\n\t\tthis.request.next(enhancedRoute)\n\t\tthis.isProcessingPopstate = false\n\t}\n\n\t/**\n\t * Update browser history state (called by area components)\n\t */\n\t_updateBrowserHistory(areaName: string, route: ActiveRoute, historyStrategy?: string, clearQueryParams?: string[] | boolean | null) {\n\t\tif (!this.enableHistoryMode) return\n\t\t\n\t\ttry {\n\t\t\t// Get current browser state or create new one\n\t\t\tconst currentState = history.state || {}\n\t\t\tconst schmancyAreas = currentState.schmancyAreas || {}\n\t\t\t\n\t\t\t// Update the specific area - only include non-empty state/params/props\n\t\t\tconst areaData: any = {\n\t\t\t\tcomponent: route.component,\n\t\t\t\tarea: route.area\n\t\t\t}\n\t\t\t\n\t\t\t// Only include state if it has content\n\t\t\tif (route.state && Object.keys(route.state).length > 0) {\n\t\t\t\tareaData.state = route.state\n\t\t\t}\n\t\t\t\n\t\t\t// Only include params if it has content\n\t\t\tif (route.params && Object.keys(route.params).length > 0) {\n\t\t\t\tareaData.params = route.params\n\t\t\t}\n\t\t\t\n\t\t\t// Only include props if it has content\n\t\t\tif (route.props && Object.keys(route.props).length > 0) {\n\t\t\t\tareaData.props = route.props\n\t\t\t}\n\t\t\t\n\t\t\tschmancyAreas[areaName] = areaData\n\t\t\t\n\t\t\tconst newState = {\n\t\t\t\t...currentState,\n\t\t\t\tschmancyAreas\n\t\t\t}\n\t\t\t\n\t\t\t// Create clean URL\n\t\t\tconst url = this.createCleanURL(schmancyAreas, clearQueryParams)\n\t\t\t\n\t\t\t// Update browser history\n\t\t\tif (historyStrategy === 'replace' || historyStrategy === 'pop') {\n\t\t\t\thistory.replaceState(newState, '', url)\n\t\t\t} else if (historyStrategy === 'push' || !historyStrategy) {\n\t\t\t\thistory.pushState(newState, '', url)\n\t\t\t}\n\t\t\t// 'silent' strategy doesn't update browser history\n\t\t\t\n\t\t} catch (error) {\n\t\t\tconsole.error('Failed to update browser history:', error)\n\t\t}\n\t}\n\n\t/**\n\t * Create a clean URL from area states\n\t */\n\tprivate createCleanURL(areas: Record<string, ActiveRoute>, clearQueryParams?: string[] | boolean | null): string {\n\t\t// Get the current base path (everything except the last segment which might be encoded state)\n\t\tconst currentPath = location.pathname\n\t\tconst pathSegments = currentPath.split('/')\n\t\tlet basePath = '/'\n\n\t\t// Check if the last segment is encoded state (contains { or %7B)\n\t\tconst lastSegment = pathSegments[pathSegments.length - 1]\n\t\tif (lastSegment && (lastSegment.includes('{') || lastSegment.includes('%7B'))) {\n\t\t\t// Remove the encoded state segment to get the base path\n\t\t\tpathSegments.pop()\n\t\t\tbasePath = pathSegments.join('/') || '/'\n\t\t} else {\n\t\t\t// Keep the current path as base path\n\t\t\tbasePath = currentPath\n\t\t}\n\n\t\t// Ensure base path ends properly\n\t\tif (basePath !== '/' && !basePath.endsWith('/')) {\n\t\t\tbasePath += '/'\n\t\t}\n\n\t\t// Handle query parameters\n\t\tlet queryString = ''\n\n\t\tif (clearQueryParams !== true) {\n\t\t\t// Get current query params\n\t\t\tconst urlParams = new URLSearchParams(location.search)\n\n\t\t\t// Clear specific params if provided\n\t\t\tif (Array.isArray(clearQueryParams)) {\n\t\t\t\tclearQueryParams.forEach(param => urlParams.delete(param))\n\t\t\t}\n\n\t\t\t// Convert back to string\n\t\t\tqueryString = urlParams.toString()\n\t\t\tqueryString = queryString ? `?${queryString}` : ''\n\t\t}\n\t\t// If clearQueryParams === true, queryString remains empty (all params cleared)\n\n\t\tif (this.prettyURL) {\n\t\t\t// Create pretty URLs - customize this based on your routing needs\n\t\t\tconst mainArea = areas.main\n\t\t\tif (mainArea) {\n\t\t\t\tlet path = basePath === '/' ? `/${mainArea.component}` : `${basePath}${mainArea.component}`\n\n\t\t\t\t// Add simple params to URL\n\t\t\t\tconst searchParams = new URLSearchParams(queryString)\n\t\t\t\tif (mainArea.params) {\n\t\t\t\t\tObject.entries(mainArea.params).forEach(([key, value]) => {\n\t\t\t\t\t\tif (typeof value === 'string' || typeof value === 'number') {\n\t\t\t\t\t\t\tsearchParams.set(key, String(value))\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t}\n\n\t\t\t\tconst query = searchParams.toString()\n\t\t\t\treturn path + (query ? `?${query}` : '')\n\t\t\t}\n\t\t}\n\n\t\t// Fallback to encoded state in URL (original behavior)\n\t\ttry {\n\t\t\t// Clean up empty objects before encoding\n\t\t\tconst cleanedAreas: Record<string, any> = {}\n\t\t\tObject.entries(areas).forEach(([areaName, route]) => {\n\t\t\t\tconst cleanRoute: any = { component: route.component }\n\n\t\t\t\t// Only include state if it has content\n\t\t\t\tif (route.state && Object.keys(route.state).length > 0) {\n\t\t\t\t\tcleanRoute.state = route.state\n\t\t\t\t}\n\n\t\t\t\t// Only include params if it has content\n\t\t\t\tif (route.params && Object.keys(route.params).length > 0) {\n\t\t\t\t\tcleanRoute.params = route.params\n\t\t\t\t}\n\n\t\t\t\t// Only include props if it has content\n\t\t\t\tif (route.props && Object.keys(route.props).length > 0) {\n\t\t\t\t\tcleanRoute.props = route.props\n\t\t\t\t}\n\n\t\t\t\tcleanedAreas[areaName] = cleanRoute\n\t\t\t})\n\n\t\t\t// If cleanedAreas is empty, preserve the base path\n\t\t\tif (Object.keys(cleanedAreas).length === 0) {\n\t\t\t\tconst cleanBasePath = basePath === '/' ? '' : basePath.replace(/\\/$/, '')\n\t\t\t\treturn `${cleanBasePath}${queryString}`\n\t\t\t}\n\n\t\t\tconst encoded = encodeURIComponent(JSON.stringify(cleanedAreas))\n\t\t\tconst cleanBasePath = basePath === '/' ? '' : basePath.replace(/\\/$/, '')\n\t\t\treturn `${cleanBasePath}/${encoded}${queryString}`\n\t\t} catch (error) {\n\t\t\tconsole.error('Failed to encode URL state:', error)\n\t\t\treturn location.pathname\n\t\t}\n\t}\n\n\t/**\n\t * Restore state from browser history state\n\t */\n\trestoreFromBrowserState(browserState: any): Record<string, ActiveRoute> {\n\t\ttry {\n\t\t\tif (browserState && browserState.schmancyAreas) {\n\t\t\t\treturn browserState.schmancyAreas\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsole.error('Failed to restore from browser state:', error)\n\t\t}\n\t\t\n\t\t// Fallback to URL parsing (original behavior)\n\t\treturn this.parseStateFromURL()\n\t}\n\n\t/**\n\t * Parse state from URL (fallback method)\n\t */\n\tprivate parseStateFromURL(): Record<string, ActiveRoute> {\n\t\tconst pathname = location.pathname.split('/').pop()\n\t\tif (!pathname) return {}\n\t\t\n\t\ttry {\n\t\t\tconst decoded = decodeURIComponent(pathname)\n\t\t\tconst parsed = JSON.parse(decoded)\n\t\t\t\n\t\t\tif (typeof parsed === 'object' && parsed !== null) {\n\t\t\t\treturn parsed\n\t\t\t}\n\t\t} catch {\n\t\t\t// Ignore parse errors\n\t\t}\n\t\t\n\t\treturn {}\n\t}\n\t\n\t/**\n\t * Dispatch a DOM event for a specific area change\n\t */\n\tprivate dispatchAreaEvent(areaName: string, routeAction: RouteAction) {\n\t\tconst eventName = `schmancy-area-${areaName}-changed`\n\t\tconst event = new CustomEvent(eventName, { \n\t\t\tdetail: { \n\t\t\t\tarea: areaName,\n\t\t\t\tcomponent: routeAction.component,\n\t\t\t\tstate: routeAction.state,\n\t\t\t\tparams: routeAction.params,\n\t\t\t\tprops: routeAction.props,\n\t\t\t\thistoryStrategy: routeAction.historyStrategy\n\t\t\t},\n\t\t\tbubbles: true,\n\t\t\tcomposed: true\n\t\t})\n\t\twindow.dispatchEvent(event)\n\t}\n\n\t/**\n\t * Remove an area from the current state\n\t */\n\tpop(name: string) {\n\t\tif (!name) {\n\t\t\tthrow new Error('Area name is required')\n\t\t}\n\n\t\t// Before removing from current map, emit a clearing signal to the area's subject\n\t\t// This notifies the area component to clear itself\n\t\tconst areaSubject = this.areaSubjects.get(name)\n\t\tif (areaSubject && !areaSubject.closed) {\n\t\t\t// Send a route with null component to signal clearing\n\t\t\tareaSubject.next({\n\t\t\t\tcomponent: null as any,\n\t\t\t\tstate: {},\n\t\t\t\tarea: name,\n\t\t\t\tparams: {},\n\t\t\t\tprops: {}\n\t\t\t})\n\t\t}\n\n\t\t// Send a clearing signal through the request pipeline\n\t\t// This ensures the area component receives the signal to clear\n\t\tthis.request.next({\n\t\t\tarea: name,\n\t\t\tcomponent: null as any,\n\t\t\tstate: {},\n\t\t\tparams: {},\n\t\t\tprops: {},\n\t\t\thistoryStrategy: 'silent' as any,\n\t\t\t_source: 'programmatic' as NavigationSource\n\t\t})\n\n\t\t// Remove from current map\n\t\tthis.current.delete(name)\n\t\tthis.$current.next(this.current)\n\n\t\t// Update browser history\n\t\tif (this.enableHistoryMode) {\n\t\t\ttry {\n\t\t\t\tconst currentState = history.state || {}\n\t\t\t\tconst schmancyAreas = { ...(currentState.schmancyAreas || {}) }\n\t\t\t\tdelete schmancyAreas[name]\n\n\t\t\t\tconst newState = {\n\t\t\t\t\t...currentState,\n\t\t\t\t\tschmancyAreas\n\t\t\t\t}\n\n\t\t\t\tconst url = this.createCleanURL(schmancyAreas)\n\t\t\t\thistory.replaceState(newState, '', url)\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error('Failed to update history after pop:', error)\n\t\t\t}\n\t\t}\n\t}\n\t\n\t/**\n\t * Clear all areas\n\t */\n\tclear() {\n\t\t// Complete all area subjects\n\t\tthis.areaSubjects.forEach(subject => subject.complete())\n\t\tthis.areaSubjects.clear()\n\n\t\t// Clear current state\n\t\tthis.current.clear()\n\t\tthis.$current.next(this.current)\n\n\t\t// Update URL\n\t\tif (this.enableHistoryMode) {\n\t\t\tconst url = this.createCleanURL({})\n\t\t\thistory.replaceState({ schmancyAreas: {} }, '', url)\n\t\t}\n\t}\n\t\n\t/**\n\t * Dispose of the service and clean up resources\n\t */\n\tdispose() {\n\t\tif (this.disposed) return\n\n\t\tthis.disposed = true\n\n\t\t// Unsubscribe from unload event\n\t\tif (this.unloadSubscription) {\n\t\t\tthis.unloadSubscription.unsubscribe()\n\t\t\tthis.unloadSubscription = undefined\n\t\t}\n\n\t\t// Complete all subjects\n\t\tthis.areaSubjects.forEach(subject => subject.complete())\n\t\tthis.areaSubjects.clear()\n\n\t\tthis.request.complete()\n\t\tthis.$current.complete()\n\t\trouterHistory.complete()\n\n\t\t// Clear references\n\t\tthis.current.clear()\n\t\tareaSubjectsCache.delete(this)\n\t}\n\t\n\t/**\n\t * Get singleton instance\n\t */\n\tstatic getInstance() {\n\t\tif (!AreaService.instance) {\n\t\t\tAreaService.instance = new AreaService()\n\t\t}\n\t\treturn AreaService.instance\n\t}\n\n\t/**\n\t * Get current state from URL (deprecated - use browser state instead)\n\t */\n\tget state(): Record<string, unknown> {\n\t\t// Try browser state first\n\t\ttry {\n\t\t\tconst browserState = history.state\n\t\t\tif (browserState && browserState.schmancyAreas) {\n\t\t\t\treturn browserState.schmancyAreas\n\t\t\t}\n\t\t} catch {\n\t\t\t// Fallback to URL parsing\n\t\t}\n\t\t\n\t\t// Fallback to URL parsing (original behavior)\n\t\treturn this.parseStateFromURL()\n\t}\n\t\n\t/**\n\t * Check if an area exists in current state\n\t */\n\thasArea(areaName: string): boolean {\n\t\treturn this.current.has(areaName)\n\t}\n\t\n\t/**\n\t * Get all active area names\n\t */\n\tgetActiveAreas(): string[] {\n\t\treturn Array.from(this.current.keys())\n\t}\n\t\n\t/**\n\t * Get route for a specific area synchronously\n\t */\n\tgetRoute(areaName: string): ActiveRoute | undefined {\n\t\treturn this.current.get(areaName)\n\t}\n}\n\nexport const area = AreaService.getInstance()\nexport default area","import { html, css, TemplateResult } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { $LitElement } from '@mixins/index';\nimport { Observable } from 'rxjs';\n\nexport type ObservableGuardResult = Observable<boolean>;\n\n// Component types that can be passed to routes\nexport type RouteComponent =\n | string // Tag name\n | CustomElementConstructor // Constructor function\n | HTMLElement // Existing element\n | TemplateResult<1> // Lit template\n | (() => Promise<{ default: CustomElementConstructor }>) // Lazy loader\n | Promise<{ default: CustomElementConstructor }>; // Dynamic import\n\nexport interface RouteConfig {\n when: string;\n component: RouteComponent;\n exact?: boolean;\n guard?: ObservableGuardResult;\n}\n\n/**\n * A marker component that holds route configuration.\n * This component doesn't render anything - it's used by schmancy-area\n * to configure routing via slot change detection.\n *\n * @example\n * ```html\n * <schmancy-area>\n * <schmancy-route\n * when=\"users\"\n * .component=${UserComponent}\n * exact\n * ></schmancy-route>\n * </schmancy-area>\n * ```\n */\n@customElement('schmancy-route')\nexport class SchmancyRoute extends $LitElement(css`\n :host {\n display: none;\n }\n`) {\n @property({ type: String })\n when!: string;\n\n @property({ type: Object })\n component!: RouteComponent;\n\n @property({ type: Boolean })\n exact?: boolean = false;\n\n @property({ type: Object })\n guard?:ObservableGuardResult ;\n\n /**\n * Returns the route configuration object\n */\n getConfig(): RouteConfig {\n return {\n when: this.when,\n component: this.component,\n exact: this.exact,\n guard: this.guard\n };\n }\n\n render() {\n // This is a marker component - no visual output\n return html``;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'schmancy-route': SchmancyRoute;\n }\n}","export type RouteAction = {\n\tcomponent: CustomElementConstructor | string | HTMLElement | (() => Promise<{ default: CustomElementConstructor }>)\n\tarea: string\n\tstate?: Record<string, unknown>\n\tparams?: Record<string, unknown>\n\tprops?: Record<string, unknown> // Alias for params\n\thistoryStrategy?: THistoryStrategy\n\tclearQueryParams?: string[] | boolean | null\n\t_source?: 'programmatic' | 'browser' | 'initial' // Internal use only\n}\n\nexport type ActiveRoute = {\n\tcomponent: string\n\tarea: string\n\tstate?: Record<string, unknown>\n\tparams?: Record<string, unknown>\n\tprops?: Record<string, unknown>\n}\n\n/**\n * Interface for subscribing to area changes\n */\nexport interface AreaSubscription {\n\t/**\n\t * Subscribe to a specific area\n\t * @param areaName Name of the area to subscribe to\n\t * @param skipCurrent Whether to skip the current value\n\t * @returns Observable of the active route for the specified area\n\t */\n\ton(areaName: string, skipCurrent?: boolean): import('rxjs').Observable<ActiveRoute>\n\t\n\t/**\n\t * Subscribe to all areas\n\t * @param skipCurrent Whether to skip the current value\n\t * @returns Observable of all active routes\n\t */\n\tall(skipCurrent?: boolean): import('rxjs').Observable<Map<string, ActiveRoute>>\n\t\n\t/**\n\t * Get state from an area\n\t * @param areaName Name of the area to subscribe to\n\t * @returns Observable of the area's state\n\t */\n\tgetState<T = unknown>(areaName: string): import('rxjs').Observable<T>\n\t\n\t/**\n\t * Get params from an area\n\t * @param areaName Name of the area to subscribe to\n\t * @returns Observable of the area's params\n\t */\n\tparams<T extends Record<string, unknown> = Record<string, unknown>>(areaName: string): import('rxjs').Observable<T>\n\t\n\t/**\n\t * Get a specific param from an area\n\t * @param areaName Name of the area to subscribe to\n\t * @param key Key of the param to select\n\t * @returns Observable of the param value\n\t */\n\tparam<T = unknown>(areaName: string, key: string): import('rxjs').Observable<T>\n\t\n\t/**\n\t * Get props from an area\n\t * @param areaName Name of the area to subscribe to\n\t * @returns Observable of the area's props\n\t */\n\tprops<T extends Record<string, unknown> = Record<string, unknown>>(areaName: string): import('rxjs').Observable<T>\n\t\n\t/**\n\t * Get a specific prop from an area\n\t * @param areaName Name of the area to subscribe to\n\t * @param key Key of the prop to select\n\t * @returns Observable of the prop value\n\t */\n\tprop<T = unknown>(areaName: string, key: string): import('rxjs').Observable<T>\n}\n\nexport type THistoryStrategy = 'push' | 'replace' | 'pop' | 'silent'\n\nexport enum HISTORY_STRATEGY {\n\tpush = 'push',\n\treplace = 'replace',\n\tpop = 'pop',\n\tsilent = 'silent',\n}\n\n/**\n * Browser history state structure used by Schmancy Area\n */\nexport interface SchmancyHistoryState {\n\tschmancyAreas: Record<string, ActiveRoute>\n\t[key: string]: any // Allow other apps to store additional state\n}","import { $LitElement } from '@mixins/index'\nimport { css, html } from 'lit'\nimport { customElement, property, queryAssignedElements } from 'lit/decorators.js'\nimport {\n\tEMPTY,\n\tcatchError,\n\tdistinctUntilChanged,\n\tfilter,\n\tfromEvent,\n\tmap,\n\tmerge,\n\tof,\n\tshareReplay,\n\tswitchMap,\n\ttake,\n\ttakeUntil,\n\ttap,\n} from 'rxjs'\nimport area from './area.service'\nimport { SchmancyRoute } from './route.component'\nimport { ActiveRoute, HISTORY_STRATEGY, RouteAction } from './router.types'\n\nexport type ComponentType =\n\t| CustomElementConstructor\n\t| string\n\t| HTMLElement\n\t| (() => Promise<{ default: CustomElementConstructor }>)\n@customElement('schmancy-area')\nexport class SchmancyArea extends $LitElement(css`\n\t:host {\n\t\tposition: relative;\n\t\tdisplay: block;\n\t\tinset: 0;\n\t}\n`) {\n\t/**\n\t * The name of the router outlet\n\t * @attr\n\t * @type {string}\n\t * @public\n\t * @required\n\t */\n\t@property() name!: string\n\n\t@property() default!: ComponentType\n\n\t/**\n\t * Query for assigned route elements in the slot\n\t * This will automatically update when slot content changes\n\t */\n\t@queryAssignedElements({ selector: 'schmancy-route', flatten: true })\n\tprivate routes!: SchmancyRoute[]\n\n\tprotected firstUpdated(): void {\n\t\tif (!this.name) throw new Error('Area name is required')\n\t\t// Single unified routing pipeline - all logic inline\n\t\tmerge(\n\t\t\t// Programmatic navigation\n\t\t\tarea.request.pipe(filter(({ area }) => area === this.name)),\n\n\t\t\t// Initial load - simplified to use this.routes directly\n\t\t\tof(location.pathname).pipe(\n\t\t\t\ttake(1),\n\t\t\t\tswitchMap(() => {\n\t\t\t\t\tconst path = location.pathname\n\t\t\t\t\tconst lastSegment = path.split('/').pop() || ''\n\t\t\t\t\tlet route: SchmancyRoute\n\t\t\t\t\tlet originalWhen: string | undefined\n\n\t\t\t\t\t// Check for JSON encoded route\n\t\t\t\t\tif (lastSegment && (lastSegment.includes('{') || lastSegment.includes('%7B'))) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst parsed = JSON.parse(decodeURIComponent(lastSegment)) as Record<string, ActiveRoute>\n\t\t\t\t\t\t\tif (parsed[this.name]) {\n\t\t\t\t\t\t\t\tconst componentTag = parsed[this.name]\n\t\t\t\t\t\t\t\troute = this.routes?.find(r => r.when === componentTag.component)\n\t\t\t\t\t\t\t\toriginalWhen = componentTag.component // Track the original 'when' value\n\t\t\t\t\t\t\t\t// if the route.component is a lazy loaded module we need to load it\n\t\t\t\t\t\t\t\tif (route)\n\t\t\t\t\t\t\t\t\treturn of({\n\t\t\t\t\t\t\t\t\t\tarea: this.name,\n\t\t\t\t\t\t\t\t\t\tcomponent: route.component,\n\t\t\t\t\t\t\t\t\t\tstate: parsed[this.name].state || {},\n\t\t\t\t\t\t\t\t\t\tparams: parsed[this.name].params || {},\n\t\t\t\t\t\t\t\t\t\thistoryStrategy: HISTORY_STRATEGY.replace,\n\t\t\t\t\t\t\t\t\t\toriginalWhen, // Pass along the original route identifier\n\t\t\t\t\t\t\t\t\t} as RouteAction & { originalWhen?: string })\n\n\t\t\t\t\t\t\t\treturn of({\n\t\t\t\t\t\t\t\t\tarea: this.name,\n\t\t\t\t\t\t\t\t\tcomponent: parsed[this.name].component,\n\t\t\t\t\t\t\t\t\tstate: parsed[this.name].state || {},\n\t\t\t\t\t\t\t\t\tparams: parsed[this.name].params || {},\n\t\t\t\t\t\t\t\t\thistoryStrategy: HISTORY_STRATEGY.replace,\n\t\t\t\t\t\t\t\t\toriginalWhen: parsed[this.name].component, // Track even for direct component references\n\t\t\t\t\t\t\t\t} as RouteAction & { originalWhen?: string })\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch {}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Segment-based routing\n\t\t\t\t\tconst segments = path.split('/').filter(Boolean)\n\t\t\t\t\troute = this.routes?.find(r => segments.includes(r.when))\n\t\t\t\t\toriginalWhen = route?.when // Track the original 'when' value\n\t\t\t\t\t// if the route.component is a lazy loaded module we need to load it\n\n\t\t\t\t\tif (!route) {\n\t\t\t\t\t\treturn this.default\n\t\t\t\t\t\t\t? of({\n\t\t\t\t\t\t\t\t\tarea: this.name,\n\t\t\t\t\t\t\t\t\tcomponent: this.default,\n\t\t\t\t\t\t\t\t\tstate: {},\n\t\t\t\t\t\t\t\t\tparams: {},\n\t\t\t\t\t\t\t\t\thistoryStrategy: HISTORY_STRATEGY.silent,\n\t\t\t\t\t\t\t\t} as RouteAction)\n\t\t\t\t\t\t\t: EMPTY\n\t\t\t\t\t}\n\n\t\t\t\t\treturn of({\n\t\t\t\t\t\tarea: this.name,\n\t\t\t\t\t\tcomponent: route.component,\n\t\t\t\t\t\tstate: {},\n\t\t\t\t\t\tparams: {},\n\t\t\t\t\t\thistoryStrategy: HISTORY_STRATEGY.silent,\n\t\t\t\t\t\toriginalWhen, // Pass along the original route identifier\n\t\t\t\t\t} as RouteAction & { originalWhen?: string })\n\t\t\t\t}),\n\t\t\t),\n\n\t\t\t// Browser back/forward - simplified to directly use popstate\n\t\t\tfromEvent<PopStateEvent>(window, 'popstate').pipe(\n\t\t\t\tmap(event =>\n\t\t\t\t\tevent.state?.schmancyAreas?.[this.name]\n\t\t\t\t\t\t? ({\n\t\t\t\t\t\t\t\tarea: this.name,\n\t\t\t\t\t\t\t\tcomponent: event.state.schmancyAreas[this.name].component,\n\t\t\t\t\t\t\t\tstate: event.state.schmancyAreas[this.name].state || {},\n\t\t\t\t\t\t\t\tparams: event.state.schmancyAreas[this.name].params || {},\n\t\t\t\t\t\t\t\thistoryStrategy: HISTORY_STRATEGY.pop,\n\t\t\t\t\t\t\t} as RouteAction)\n\t\t\t\t\t\t: null,\n\t\t\t\t),\n\t\t\t\tfilter(route => route !== null),\n\t\t\t),\n\t\t)\n\t\t\t.pipe(\n\t\t\t\tfilter(route => route?.component !== undefined),\n\t\t\t\t// Step 1: Resolve ONLY lazy components to constructors (no element creation)\n\t\t\t\tswitchMap(async route => {\n\t\t\t\t\tlet component = route.component\n\n\t\t\t\t\t// Resolve lazy components first\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof component === 'function' &&\n\t\t\t\t\t\t('preload' in component || '_promise' in component || '_module' in component)\n\t\t\t\t\t) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst module = await (component as () => Promise<{ default: CustomElementConstructor }>)()\n\t\t\t\t\t\t\tcomponent = module.default\n\t\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\t\tconsole.error(`[${this.name}] Lazy load failed:`, e)\n\t\t\t\t\t\t\treturn { component: null, route }\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\treturn { component, route }\n\t\t\t\t}),\n\n\t\t\t\t// Step 2: Extract component identifier for comparison (without creating elements)\n\t\t\t\tmap(({ component, route }) => {\n\t\t\t\t\tlet identifier = ''\n\n\t\t\t\t\tif (!component || component === '') {\n\t\t\t\t\t\tidentifier = 'null'\n\t\t\t\t\t} else if (typeof component === 'string') {\n\t\t\t\t\t\tidentifier = component\n\t\t\t\t\t} else if (component instanceof HTMLElement) {\n\t\t\t\t\t\tidentifier = component.tagName\n\t\t\t\t\t} else if (typeof component === 'function') {\n\t\t\t\t\t\tidentifier = component.name || 'CustomElement'\n\t\t\t\t\t}\n\t\t\t\t\t\n\n\t\t\t\t\tconst key = `${identifier}${JSON.stringify(route.params)}${JSON.stringify(route.state)}`\n\n\t\t\t\t\treturn { component, route, key , tagName:identifier}\n\t\t\t\t}),\n\n\t\t\t\t// Step 3: Deduplicate using the identifier (before creating expensive elements)\n\t\t\t\tdistinctUntilChanged((a, b) => {\n\t\t\t\t\treturn a.key === b.key\n\t\t\t\t}),\n\t\t\t\t// Step 0: Guard\n\t\t\t\tswitchMap(r => {\n\t\t\t\t\n\t\t\t\t\tconsole.log(r.tagName)\n\t\t\t\t\tconst route = this.routes.find(route => route.when === r.tagName);\n\n\t\t\t\t\t// If route has a guard, evaluate it\n\t\t\t\t\tif (route?.guard) {\n\t\t\t\t\t\treturn route.guard.pipe(\n\t\t\t\t\t\t\ttap(guardResult => {\n\t\t\t\t\t\t\t\tconsole.log(`[${this.name}] Guard evaluation for route '${route.when}':`, guardResult)\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tswitchMap(guardResult => {\n\t\t\t\t\t\t\t\tif (guardResult === true) return of(r);\n\n\t\t\t\t\t\t\t\t// Guard failed, dispatch redirect event\n\t\t\t\t\t\t\t\tconst redirectEvent = new CustomEvent('redirect', {\n\t\t\t\t\t\t\t\t\tdetail: {\n\t\t\t\t\t\t\t\t\t\tblockedRoute: r.tagName,\n\t\t\t\t\t\t\t\t\t\tarea: this.name,\n\t\t\t\t\t\t\t\t\t\tparams: r.route?.params || {},\n\t\t\t\t\t\t\t\t\t\tstate: r.route?.state || {},\n\t\t\t\t\t\t\t\t\t\tredirectTarget: typeof guardResult === 'object' ? guardResult : undefined,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tbubbles: true,\n\t\t\t\t\t\t\t\t\tcomposed: true,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\troute.dispatchEvent(redirectEvent);\n\n\t\t\t\t\t\t\t\treturn EMPTY;\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\t// No guard, allow navigation\n\t\t\t\t\treturn of(r);\n\t\t\t\t}),\n\n\t\t\t\t// Step 4: Create the HTMLElement and apply properties\n\t\t\t\tmap(({ component, route }) => {\n\t\t\t\t\tlet element: HTMLElement | null = null\n\n\t\t\t\t\t// Now resolve to HTMLElement\n\t\t\t\t\tif (!component || component === '') {\n\t\t\t\t\t\telement = null\n\t\t\t\t\t} else if (typeof component === 'string') {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\telement = document.createElement(component)\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\tconsole.error(`[${this.name}] Failed to create element:`, component)\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (component instanceof HTMLElement) {\n\t\t\t\t\t\telement = component\n\t\t\t\t\t} else if (typeof component === 'function') {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\telement = new (component as CustomElementConstructor)()\n\t\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\t\tconsole.error(`[${this.name}] Failed to instantiate:`, e)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Apply properties inline\n\t\t\t\t\tif (element) {\n\t\t\t\t\t\tif (route.params) Object.assign(element, route.params)\n\t\t\t\t\t\tif (route.props) Object.assign(element, route.props)\n\t\t\t\t\t\tif (route.state) (element as any).state = route.state\n\t\t\t\t\t}\n\n\t\t\t\t\treturn { element, route }\n\t\t\t\t}),\n\n\t\t\t\tshareReplay(1),\n\n\t\t\t\t// Swap components\n\t\t\t\ttap(({ element, route }) => this.swapComponents(element, route)),\n\n\t\t\t\tcatchError(error => {\n\t\t\t\t\tconsole.error(`[${this.name}] Navigation error:`, error)\n\t\t\t\t\treturn EMPTY\n\t\t\t\t}),\n\n\t\t\t\ttakeUntil(this.disconnecting),\n\t\t\t)\n\t\t\t.subscribe()\n\t}\n\n\t/**\n\t * Swap components with animation following the original pattern\n\t */\n\tprivate swapComponents(newComponent: HTMLElement | null, routeAction: RouteAction) {\n\t\t// Important: We need to work with the light DOM, not shadow DOM\n\t\t// The slot should remain in shadow DOM, and we append content to light DOM\n\n\t\t// Find the current routed component (not the route definitions)\n\t\t// Route definitions have display:none, actual components don't\n\t\tconst oldComponent = Array.from(this.children).find(\n\t\t\tchild => !(child instanceof SchmancyRoute)\n\t\t) as HTMLElement | undefined\n\n\t\t// If no new component, just clear\n\t\tif (!newComponent) {\n\t\t\tif (oldComponent) {\n\t\t\t\toldComponent.remove()\n\t\t\t}\n\t\t\treturn\n\t\t}\n\n\t\t// Animate transition\n\t\tif (oldComponent) {\n\t\t\t// Fade out old component\n\t\t\tconst fadeOut = oldComponent.animate([{ opacity: 1 }, { opacity: 0 }], { duration: 150, easing: 'ease-out' })\n\n\t\t\tfadeOut.onfinish = () => {\n\t\t\t\toldComponent.remove()\n\t\t\t\t// Add new component to light DOM (not shadow DOM!)\n\t\t\t\tthis.appendChild(newComponent)\n\t\t\t\tnewComponent.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 150, easing: 'ease-in' })\n\t\t\t}\n\t\t} else {\n\t\t\t// No old component, just add and fade in to light DOM\n\t\t\tthis.appendChild(newComponent)\n\t\t\tnewComponent.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 100, easing: 'ease-in' })\n\t\t}\n\n\t\t// Update internal state\n\t\tif (newComponent) {\n\t\t\tconst activeRoute: ActiveRoute = {\n\t\t\t\tcomponent: newComponent.tagName.toLowerCase(),\n\t\t\t\tstate: routeAction.state || {},\n\t\t\t\tarea: this.name,\n\t\t\t\tparams: routeAction.params || {},\n\t\t\t}\n\n\t\t\tarea.current.set(this.name, activeRoute)\n\t\t\tarea.$current.next(area.current)\n\t\t}\n\n\t\t// Update browser history\n\t\tif (area.enableHistoryMode && newComponent) {\n\t\t\tconst activeRoute: ActiveRoute = {\n\t\t\t\tcomponent: newComponent.tagName.toLowerCase(),\n\t\t\t\tstate: routeAction.state || {},\n\t\t\t\tarea: this.name,\n\t\t\t\tparams: routeAction.params || {},\n\t\t\t}\n\n\t\t\tarea._updateBrowserHistory(\n\t\t\t\tthis.name,\n\t\t\t\tactiveRoute,\n\t\t\t\trouteAction.historyStrategy || HISTORY_STRATEGY.push,\n\t\t\t\trouteAction.clearQueryParams,\n\t\t\t)\n\t\t}\n\t}\n\n\t/**\n\t * Create URL path for the route (legacy method, now handled by service)\n\t */\n\tnewPath(tag: string, route: RouteAction) {\n\t\tconst oldPathname = location.pathname.split('/').pop()\n\t\tlet oldAreaState = {}\n\t\ttry {\n\t\t\toldAreaState = oldPathname ? JSON.parse(decodeURIComponent(oldPathname)) : {}\n\t\t} catch {\n\t\t\toldAreaState = {}\n\t\t}\n\t\troute.state = route.state ?? {}\n\t\tconst queryParams = route.clearQueryParams ? this.queryParamClear(route.clearQueryParams) : document.location.search\n\n\t\treturn encodeURIComponent(\n\t\t\tJSON.stringify({\n\t\t\t\t...oldAreaState,\n\t\t\t\t[this.name]: { component: tag.toLowerCase(), state: route.state, params: route.params },\n\t\t\t}),\n\t\t).concat(`${queryParams}`)\n\t}\n\n\t/**\n\t * Clear query parameters\n\t */\n\tqueryParamClear(params?: string[] | boolean) {\n\t\tif (!params) {\n\t\t\treturn ''\n\t\t}\n\t\t// get query params from url\n\t\tconst urlParams = new URLSearchParams(location.search)\n\n\t\tif (params === true) {\n\t\t\t// Clear all query params\n\t\t\treturn ''\n\t\t} else {\n\t\t\t// Clear specific query params\n\t\t\tparams.forEach(param => urlParams.delete(param))\n\t\t\t// update url\n\t\t\tif (urlParams.toString() === '') return ''\n\t\t\treturn `?${urlParams.toString()}`\n\t\t}\n\t}\n\n\tdisconnectedCallback() {\n\t\tsuper.disconnectedCallback()\n\t}\n\n\trender() {\n\t\treturn html`<slot></slot>`\n\t}\n}\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t'schmancy-area': SchmancyArea\n\t}\n}\n"],"names":["routerHistory","Subject","FINDING_MORTIES","HERE_RICKY","areaSubjectsCache","WeakMap","AreaService","constructor","this","prettyURL","mode","request","ReplaySubject","current","Map","$current","enableHistoryMode","findingMortiesEvent","CustomEvent","disposed","isProcessingPopstate","next","subscribe","currentAreas","forEach","route","areaName","getOrCreateAreaSubject","initializeFromBrowserState","window","unloadSubscription","fromEvent","dispose","areaSubjects","subjects","get","set","browserState","history","state","schmancyAreas","Object","entries","error","subject","closed","currentRoute","params","props","skipCurrent","Error","observable","asObservable","pipe","distinctUntilChanged","a","b","component","JSON","stringify","shareReplay","skip","on","map","filter","catchError","err","EMPTY","key","value","find","zip","e","detail","bufferTime","of","tap","dispatchEvent","timeout","r","area","routeAction","_source","dispatchAreaEvent","enhancedRoute","historyStrategy","clearQueryParams","currentState","areaData","keys","length","newState","url","createCleanURL","replaceState","pushState","areas","currentPath","location","pathname","pathSegments","split","basePath","lastSegment","includes","pop","join","endsWith","queryString","urlParams","URLSearchParams","search","Array","isArray","param","delete","toString","mainArea","main","path","searchParams","String","query","cleanedAreas","cleanRoute","replace","encoded","encodeURIComponent","parseStateFromURL","decoded","decodeURIComponent","parsed","parse","event","bubbles","composed","name","areaSubject","clear","complete","unsubscribe","getInstance","instance","has","getActiveAreas","from","SchmancyRoute","$LitElement","css","super","arguments","exact","getConfig","when","guard","render","html","__decorateClass","property","type","prototype","Boolean","customElement","HISTORY_STRATEGY","SchmancyArea","firstUpdated","merge","take","switchMap","originalWhen","componentTag","routes","segments","silent","default","async","identifier","HTMLElement","tagName","guardResult","redirectEvent","blockedRoute","redirectTarget","element","document","createElement","assign","swapComponents","takeUntil","disconnecting","newComponent","oldComponent","children","child","animate","opacity","duration","easing","onfinish","remove","appendChild","activeRoute","toLowerCase","_updateBrowserHistory","push","tag","oldPathname","oldAreaState","queryParams","queryParamClear","concat","disconnectedCallback","queryAssignedElements","selector","flatten"],"mappings":";;;;;;;AAsBO,MAAMA,IAAgB,IAAIC,KAEpBC,IAAkB,mBAClBC,IAAa,cASpBC,wBAAwBC;AAK9B,MAAMC,EAAAA;AAAAA,EAwBL,cAAAC;AAtBAC,SAAOC,YAAAA,IACPD,KAAOE,OAA6B,WACpCF,KAAOG,UAAU,IAAIC,EAA2B,IAChDJ,KAAOK,8BAAcC,OACrBN,KAAOO,WAAW,IAAIH,EAAwC,CAAA,GAY9DJ,KAAOQ,oBAAAA,IACPR,KAAQS,sBAAsB,IAAIC,YAA6ChB,CAAAA,GAC/EM,KAAQW,WAAAA,IACRX,KAAOY,uB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QAAA,CAAA,GAEAH,EAAA,CAAXC,EAAAA,CAAAA,GAhBWM,EAgBAJ,WAAA,WAAA,CAAA,GAOJH,EAAA,CADPuD,EAAsB,EAAEC,UAAU,kBAAkBC,YAAS,CAAA,CAAA,GAtBlDlD,EAuBJJ,WAAA,UAAA,CAAA,GAvBII,IAANP,EAAA,CADNK,EAAc,eAAA,CAAA,GACFE,CAAAA;"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";const r=require("rxjs");require("lit/directives/class-map.js"),require("lit/directives/style-map.js");const m=require("lit/decorators.js");require("./tailwind.mixin-DvXzFSLc.cjs");const R=require("./litElement.mixin-BnXm63YO.cjs"),b=require("lit"),A=new r.Subject,C="FINDING_MORTIES",j="HERE_RICKY",O=new WeakMap;class f{constructor(){this.prettyURL=!1,this.mode="HISTORY",this.request=new r.ReplaySubject(1),this.current=new Map,this.$current=new r.ReplaySubject(1),this.enableHistoryMode=!0,this.findingMortiesEvent=new CustomEvent(C),this.disposed=!1,this.isProcessingPopstate=!1,this.$current.next(this.current),this.$current.subscribe(e=>{this.disposed||e.forEach((t,a)=>{this.getOrCreateAreaSubject(a).next(t)})}),this.initializeFromBrowserState(),typeof window<"u"&&(this.unloadSubscription=r.fromEvent(window,"unload").subscribe(()=>{this.dispose()}))}get areaSubjects(){let e=O.get(this);return e||(e=new Map,O.set(this,e)),e}initializeFromBrowserState(){try{const e=history.state;e&&e.schmancyAreas&&(Object.entries(e.schmancyAreas).forEach(([t,a])=>{this.current.set(t,a)}),this.$current.next(this.current))}catch{}}getOrCreateAreaSubject(e){let t=this.areaSubjects.get(e);if(!t||t.closed){t=new r.ReplaySubject(1),this.areaSubjects.set(e,t);const a=this.current.get(e);a&&t.next({...a,state:a.state||{},params:a.params||{},props:a.props||{}})}return t}on(e,t=!1){if(!e)throw new Error("Area name is required");const a=this.getOrCreateAreaSubject(e).asObservable().pipe(r.distinctUntilChanged((o,n)=>o.component===n.component&&JSON.stringify(o.state)===JSON.stringify(n.state)&&JSON.stringify(o.params)===JSON.stringify(n.params)),r.shareReplay(1));return t?a.pipe(r.skip(1)):a}all(e=!1){const t=this.$current.asObservable().pipe(r.shareReplay(1));return e?t.pipe(r.skip(1)):t}getState(e){if(!e)throw new Error("Area name is required");return this.on(e).pipe(r.map(t=>t.state),r.filter(t=>t!=null),r.distinctUntilChanged((t,a)=>JSON.stringify(t)===JSON.stringify(a)),r.map(t=>t),r.catchError(t=>r.EMPTY))}params(e){if(!e)throw new Error("Area name is required");return this.on(e).pipe(r.map(t=>t.params),r.filter(t=>t!=null),r.distinctUntilChanged((t,a)=>JSON.stringify(t)===JSON.stringify(a)),r.map(t=>t),r.catchError(t=>r.EMPTY))}param(e,t){if(!e||!t)throw new Error("Area name and key are required");return this.params(e).pipe(r.map(a=>a[t]),r.filter(a=>a!==void 0),r.distinctUntilChanged(),r.map(a=>a),r.catchError(a=>r.EMPTY))}props(e){if(!e)throw new Error("Area name is required");return this.on(e).pipe(r.map(t=>t.props),r.filter(t=>t!=null),r.distinctUntilChanged((t,a)=>JSON.stringify(t)===JSON.stringify(a)),r.map(t=>t),r.catchError(t=>r.EMPTY))}prop(e,t){if(!e||!t)throw new Error("Area name and key are required");return this.props(e).pipe(r.map(a=>a[t]),r.filter(a=>a!==void 0),r.distinctUntilChanged(),r.map(a=>a),r.catchError(a=>r.EMPTY))}find(){return r.zip([r.fromEvent(window,j).pipe(r.map(e=>e.detail),r.bufferTime(0)),r.of(1).pipe(r.tap(()=>window.dispatchEvent(this.findingMortiesEvent)))]).pipe(r.map(([e])=>e),r.timeout(1),r.catchError(()=>r.EMPTY))}push(e){if(!e.area)throw new Error("Area is required for route action");if(this.isProcessingPopstate)return;const t={...e,state:e.state||{},params:e.params||{},props:e.props||{},_source:"programmatic"};this.enableHistoryMode&&A.next(t),this.request.next(t),this.dispatchAreaEvent(t.area,t)}_updateFromBrowser(e){const t={...e,state:e.state||{},params:e.params||{},props:e.props||{},_source:"browser"};this.isProcessingPopstate=!0,this.request.next(t),this.isProcessingPopstate=!1}_updateBrowserHistory(e,t,a,o){if(this.enableHistoryMode)try{const n=history.state||{},i=n.schmancyAreas||{},p={component:t.component,area:t.area};t.state&&Object.keys(t.state).length>0&&(p.state=t.state),t.params&&Object.keys(t.params).length>0&&(p.params=t.params),t.props&&Object.keys(t.props).length>0&&(p.props=t.props),i[e]=p;const c={...n,schmancyAreas:i},u=this.createCleanURL(i,o);a==="replace"||a==="pop"?history.replaceState(c,"",u):a!=="push"&&a||history.pushState(c,"",u)}catch{}}createCleanURL(e,t){const a=location.pathname,o=a.split("/");let n="/";const i=o[o.length-1];i&&(i.includes("{")||i.includes("%7B"))?(o.pop(),n=o.join("/")||"/"):n=a,n==="/"||n.endsWith("/")||(n+="/");let p="";if(t!==!0){const c=new URLSearchParams(location.search);Array.isArray(t)&&t.forEach(u=>c.delete(u)),p=c.toString(),p=p?`?${p}`:""}if(this.prettyURL){const c=e.main;if(c){let u=n==="/"?`/${c.component}`:`${n}${c.component}`;const S=new URLSearchParams(p);c.params&&Object.entries(c.params).forEach(([d,E])=>{typeof E!="string"&&typeof E!="number"||S.set(d,String(E))});const h=S.toString();return u+(h?`?${h}`:"")}}try{const c={};if(Object.entries(e).forEach(([S,h])=>{const d={component:h.component};h.state&&Object.keys(h.state).length>0&&(d.state=h.state),h.params&&Object.keys(h.params).length>0&&(d.params=h.params),h.props&&Object.keys(h.props).length>0&&(d.props=h.props),c[S]=d}),Object.keys(c).length===0)return`${n==="/"?"":n.replace(/\/$/,"")}${p}`;const u=encodeURIComponent(JSON.stringify(c));return`${n==="/"?"":n.replace(/\/$/,"")}/${u}${p}`}catch{return location.pathname}}restoreFromBrowserState(e){try{if(e&&e.schmancyAreas)return e.schmancyAreas}catch{}return this.parseStateFromURL()}parseStateFromURL(){const e=location.pathname.split("/").pop();if(!e)return{};try{const t=decodeURIComponent(e),a=JSON.parse(t);if(typeof a=="object"&&a!==null)return a}catch{}return{}}dispatchAreaEvent(e,t){const a=new CustomEvent(`schmancy-area-${e}-changed`,{detail:{area:e,component:t.component,state:t.state,params:t.params,props:t.props,historyStrategy:t.historyStrategy},bubbles:!0,composed:!0});window.dispatchEvent(a)}pop(e){if(!e)throw new Error("Area name is required");const t=this.areaSubjects.get(e);if(t&&!t.closed&&t.next({component:null,state:{},area:e,params:{},props:{}}),this.request.next({area:e,component:null,state:{},params:{},props:{},historyStrategy:"silent",_source:"programmatic"}),this.current.delete(e),this.$current.next(this.current),this.enableHistoryMode)try{const a=history.state||{},o={...a.schmancyAreas||{}};delete o[e];const n={...a,schmancyAreas:o},i=this.createCleanURL(o);history.replaceState(n,"",i)}catch{}}clear(){if(this.areaSubjects.forEach(e=>e.complete()),this.areaSubjects.clear(),this.current.clear(),this.$current.next(this.current),this.enableHistoryMode){const e=this.createCleanURL({});history.replaceState({schmancyAreas:{}},"",e)}}dispose(){this.disposed||(this.disposed=!0,this.unloadSubscription&&(this.unloadSubscription.unsubscribe(),this.unloadSubscription=void 0),this.areaSubjects.forEach(e=>e.complete()),this.areaSubjects.clear(),this.request.complete(),this.$current.complete(),A.complete(),this.current.clear(),O.delete(this))}static getInstance(){return f.instance||(f.instance=new f),f.instance}get state(){try{const e=history.state;if(e&&e.schmancyAreas)return e.schmancyAreas}catch{}return this.parseStateFromURL()}hasArea(e){return this.current.has(e)}getActiveAreas(){return Array.from(this.current.keys())}getRoute(e){return this.current.get(e)}}const y=f.getInstance();var v=Object.defineProperty,P=Object.getOwnPropertyDescriptor,g=(s,e,t,a)=>{for(var o,n=a>1?void 0:a?P(e,t):e,i=s.length-1;i>=0;i--)(o=s[i])&&(n=(a?o(e,t,n):o(n))||n);return a&&n&&v(e,t,n),n};exports.SchmancyRoute=class extends R.$LitElement(b.css`
|
|
2
|
-
:host {
|
|
3
|
-
display: none;
|
|
4
|
-
}
|
|
5
|
-
`){constructor(){super(...arguments),this.exact=!1}getConfig(){return{when:this.when,component:this.component,exact:this.exact,guard:this.guard}}render(){return b.html``}},g([m.property({type:String})],exports.SchmancyRoute.prototype,"when",2),g([m.property({type:Object})],exports.SchmancyRoute.prototype,"component",2),g([m.property({type:Boolean})],exports.SchmancyRoute.prototype,"exact",2),g([m.property({type:Object})],exports.SchmancyRoute.prototype,"guard",2),exports.SchmancyRoute=g([m.customElement("schmancy-route")],exports.SchmancyRoute);var l=(s=>(s.push="push",s.replace="replace",s.pop="pop",s.silent="silent",s))(l||{}),$=Object.defineProperty,M=Object.getOwnPropertyDescriptor,w=(s,e,t,a)=>{for(var o,n=a>1?void 0:a?M(e,t):e,i=s.length-1;i>=0;i--)(o=s[i])&&(n=(a?o(e,t,n):o(n))||n);return a&&n&&$(e,t,n),n};exports.SchmancyArea=class extends R.$LitElement(b.css`
|
|
6
|
-
:host {
|
|
7
|
-
position: relative;
|
|
8
|
-
display: block;
|
|
9
|
-
inset: 0;
|
|
10
|
-
}
|
|
11
|
-
`){firstUpdated(){if(!this.name)throw new Error("Area name is required");r.merge(y.request.pipe(r.filter(({area:s})=>s===this.name)),r.of(location.pathname).pipe(r.take(1),r.switchMap(()=>{const s=location.pathname,e=s.split("/").pop()||"";let t,a;if(e&&(e.includes("{")||e.includes("%7B")))try{const n=JSON.parse(decodeURIComponent(e));if(n[this.name]){const i=n[this.name];return t=this.routes?.find(p=>p.when===i.component),a=i.component,t?r.of({area:this.name,component:t.component,state:n[this.name].state||{},params:n[this.name].params||{},historyStrategy:l.replace,originalWhen:a}):r.of({area:this.name,component:n[this.name].component,state:n[this.name].state||{},params:n[this.name].params||{},historyStrategy:l.replace,originalWhen:n[this.name].component})}}catch{}const o=s.split("/").filter(Boolean);return t=this.routes?.find(n=>o.includes(n.when)),a=t?.when,t?r.of({area:this.name,component:t.component,state:{},params:{},historyStrategy:l.silent,originalWhen:a}):this.default?r.of({area:this.name,component:this.default,state:{},params:{},historyStrategy:l.silent}):r.EMPTY})),r.fromEvent(window,"popstate").pipe(r.map(s=>s.state?.schmancyAreas?.[this.name]?{area:this.name,component:s.state.schmancyAreas[this.name].component,state:s.state.schmancyAreas[this.name].state||{},params:s.state.schmancyAreas[this.name].params||{},historyStrategy:l.pop}:null),r.filter(s=>s!==null))).pipe(r.filter(s=>s?.component!==void 0),r.switchMap(async s=>{let e=s.component;if(typeof e=="function"&&("preload"in e||"_promise"in e||"_module"in e))try{e=(await e()).default}catch{return{component:null,route:s}}return{component:e,route:s}}),r.map(({component:s,route:e})=>{let t="";return s&&s!==""?typeof s=="string"?t=s:s instanceof HTMLElement?t=s.tagName:typeof s=="function"&&(t=s.name||"CustomElement"):t="null",{component:s,route:e,key:`${t}${JSON.stringify(e.params)}${JSON.stringify(e.state)}`,tagName:t}}),r.distinctUntilChanged((s,e)=>s.key===e.key),r.switchMap(s=>{const e=this.routes.find(t=>t.when===s.tagName);return e?.guard?e.guard.pipe(r.tap(t=>{}),r.switchMap(t=>{if(t===!0)return r.of(s);const a=new CustomEvent("redirect",{detail:{blockedRoute:s.tagName,area:this.name,params:s.route?.params||{},state:s.route?.state||{},redirectTarget:typeof t=="object"?t:void 0},bubbles:!0,composed:!0});return e.dispatchEvent(a),r.EMPTY})):r.of(s)}),r.map(({component:s,route:e})=>{let t=null;if(s&&s!==""){if(typeof s=="string")try{t=document.createElement(s)}catch{}else if(s instanceof HTMLElement)t=s;else if(typeof s=="function")try{t=new s}catch{}}else t=null;return t&&(e.params&&Object.assign(t,e.params),e.props&&Object.assign(t,e.props),e.state&&(t.state=e.state)),{element:t,route:e}}),r.shareReplay(1),r.tap(({element:s,route:e})=>this.swapComponents(s,e)),r.catchError(s=>r.EMPTY),r.takeUntil(this.disconnecting)).subscribe()}swapComponents(s,e){const t=Array.from(this.children).find(a=>!(a instanceof exports.SchmancyRoute));if(s){if(t?t.animate([{opacity:1},{opacity:0}],{duration:150,easing:"ease-out"}).onfinish=()=>{t.remove(),this.appendChild(s),s.animate([{opacity:0},{opacity:1}],{duration:150,easing:"ease-in"})}:(this.appendChild(s),s.animate([{opacity:0},{opacity:1}],{duration:100,easing:"ease-in"})),s){const a={component:s.tagName.toLowerCase(),state:e.state||{},area:this.name,params:e.params||{}};y.current.set(this.name,a),y.$current.next(y.current)}if(y.enableHistoryMode&&s){const a={component:s.tagName.toLowerCase(),state:e.state||{},area:this.name,params:e.params||{}};y._updateBrowserHistory(this.name,a,e.historyStrategy||l.push,e.clearQueryParams)}}else t&&t.remove()}newPath(s,e){const t=location.pathname.split("/").pop();let a={};try{a=t?JSON.parse(decodeURIComponent(t)):{}}catch{a={}}e.state=e.state??{};const o=e.clearQueryParams?this.queryParamClear(e.clearQueryParams):document.location.search;return encodeURIComponent(JSON.stringify({...a,[this.name]:{component:s.toLowerCase(),state:e.state,params:e.params}})).concat(`${o}`)}queryParamClear(s){if(!s)return"";const e=new URLSearchParams(location.search);return s===!0?"":(s.forEach(t=>e.delete(t)),e.toString()===""?"":`?${e.toString()}`)}disconnectedCallback(){super.disconnectedCallback()}render(){return b.html`<slot></slot>`}},w([m.property()],exports.SchmancyArea.prototype,"name",2),w([m.property()],exports.SchmancyArea.prototype,"default",2),w([m.queryAssignedElements({selector:"schmancy-route",flatten:!0})],exports.SchmancyArea.prototype,"routes",2),exports.SchmancyArea=w([m.customElement("schmancy-area")],exports.SchmancyArea),exports.FINDING_MORTIES=C,exports.HERE_RICKY=j,exports.HISTORY_STRATEGY=l,exports.area=y,exports.routerHistory=A;
|
|
12
|
-
//# sourceMappingURL=area.component-DSAxybsX.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"area.component-DSAxybsX.cjs","sources":["../src/area/area.service.ts","../src/area/route.component.ts","../src/area/router.types.ts","../src/area/area.component.ts"],"sourcesContent":["import {\n\tbufferTime,\n\tcatchError,\n\tdistinctUntilChanged,\n\tEMPTY,\n\tfilter,\n\tfromEvent,\n\tmap,\n\tObservable,\n\tof,\n\tReplaySubject,\n\tshareReplay,\n\tskip,\n\tSubject,\n\tSubscription,\n\ttap,\n\ttimeout,\n\tzip\n} from 'rxjs'\nimport { SchmancyTeleportation } from '../teleport'\nimport { ActiveRoute, AreaSubscription, RouteAction } from './router.types'\n\nexport const routerHistory = new Subject<RouteAction>()\n\nexport const FINDING_MORTIES = 'FINDING_MORTIES'\nexport const HERE_RICKY = 'HERE_RICKY'\nexport type HERE_RICKY_EVENT = CustomEvent<{\n\tcomponent: SchmancyTeleportation\n}>\nexport type FINDING_MORTIES_EVENT = CustomEvent<{\n\tcomponent: SchmancyTeleportation\n}>\n\n// WeakMap for better memory management of area subjects\nconst areaSubjectsCache = new WeakMap<AreaService, Map<string, ReplaySubject<ActiveRoute>>>()\n\n// Track navigation source to prevent history conflicts\ntype NavigationSource = 'programmatic' | 'browser' | 'initial'\n\nclass AreaService implements AreaSubscription {\n\tprivate static instance: AreaService\n\tpublic prettyURL = false\n\tpublic mode: 'SILENT' | 'HISTORY' = 'HISTORY'\n\tpublic request = new ReplaySubject<RouteAction>(1)\n\tpublic current = new Map<string, ActiveRoute>()\n\tpublic $current = new ReplaySubject<Map<string, ActiveRoute>>(1)\n\t\n\t// Create a dictionary of ReplaySubjects for area-specific subscriptions\n\tprivate get areaSubjects(): Map<string, ReplaySubject<ActiveRoute>> {\n\t\tlet subjects = areaSubjectsCache.get(this)\n\t\tif (!subjects) {\n\t\t\tsubjects = new Map()\n\t\t\tareaSubjectsCache.set(this, subjects)\n\t\t}\n\t\treturn subjects\n\t}\n\t\n\tpublic enableHistoryMode = true\n\tprivate findingMortiesEvent = new CustomEvent<FINDING_MORTIES_EVENT['detail']>(FINDING_MORTIES)\n\tprivate disposed = false\n\tpublic isProcessingPopstate = false\n\tprivate unloadSubscription?: Subscription\n\n\tconstructor() {\n\t\tthis.$current.next(this.current)\n\t\t\n\t\t// Subscribe to current changes to update area-specific subjects\n\t\tthis.$current.subscribe(currentAreas => {\n\t\t\tif (this.disposed) return\n\t\t\t\n\t\t\t// For each area in the current map\n\t\t\tcurrentAreas.forEach((route, areaName) => {\n\t\t\t\t// Get or create a subject for this area\n\t\t\t\tconst areaSubject = this.getOrCreateAreaSubject(areaName)\n\t\t\t\t// Emit the updated route to area-specific subscribers\n\t\t\t\tareaSubject.next(route)\n\t\t\t})\n\t\t})\n\n\t\t// Initialize from browser state if available\n\t\tthis.initializeFromBrowserState()\n\n\t\t// Setup unload subscription using RxJS\n\t\tif (typeof window !== 'undefined') {\n\t\t\tthis.unloadSubscription = fromEvent(window, 'unload').subscribe(() => {\n\t\t\t\tthis.dispose()\n\t\t\t})\n\t\t}\n\t}\n\n\t/**\n\t * Initialize router state from browser history state\n\t */\n\tprivate initializeFromBrowserState() {\n\t\ttry {\n\t\t\tconst browserState = history.state\n\t\t\tif (browserState && browserState.schmancyAreas) {\n\t\t\t\tObject.entries(browserState.schmancyAreas).forEach(([areaName, route]) => {\n\t\t\t\t\tthis.current.set(areaName, route as ActiveRoute)\n\t\t\t\t})\n\t\t\t\tthis.$current.next(this.current)\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsole.warn('Failed to initialize from browser state:', error)\n\t\t}\n\t}\n\n\t/**\n\t * Get or create a ReplaySubject for a specific area with proper cleanup\n\t */\n\tprivate getOrCreateAreaSubject(areaName: string): ReplaySubject<ActiveRoute> {\n\t\tlet subject = this.areaSubjects.get(areaName)\n\t\t\n\t\tif (!subject || subject.closed) {\n\t\t\tsubject = new ReplaySubject<ActiveRoute>(1)\n\t\t\tthis.areaSubjects.set(areaName, subject)\n\t\t\t\n\t\t\t// If the area already exists in current, emit it immediately\n\t\t\tconst currentRoute = this.current.get(areaName)\n\t\t\tif (currentRoute) {\n\t\t\t\tsubject.next({\n\t\t\t\t\t...currentRoute,\n\t\t\t\t\t// Ensure state, params and props are initialized if undefined\n\t\t\t\t\tstate: currentRoute.state || {},\n\t\t\t\t\tparams: currentRoute.params || {},\n\t\t\t\t\tprops: currentRoute.props || {}\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn subject\n\t}\n\n\t/**\n\t * Subscribe to a specific area with caching\n\t */\n\ton(areaName: string, skipCurrent = false): Observable<ActiveRoute> {\n\t\tif (!areaName) {\n\t\t\tthrow new Error('Area name is required')\n\t\t}\n\t\t\n\t\tconst areaSubject = this.getOrCreateAreaSubject(areaName)\n\t\tconst observable = areaSubject.asObservable().pipe(\n\t\t\t// Add distinct to prevent duplicate emissions - now includes state\n\t\t\tdistinctUntilChanged((a, b) => \n\t\t\t\ta.component === b.component &&\n\t\t\t\tJSON.stringify(a.state) === JSON.stringify(b.state) &&\n\t\t\t\tJSON.stringify(a.params) === JSON.stringify(b.params)\n\t\t\t),\n\t\t\t// Share the subscription\n\t\t\tshareReplay(1)\n\t\t)\n\t\t\n\t\treturn skipCurrent ? observable.pipe(skip(1)) : observable\n\t}\n\t\n\t/**\n\t * Subscribe to all areas\n\t */\n\tall(skipCurrent = false): Observable<Map<string, ActiveRoute>> {\n\t\tconst observable = this.$current.asObservable().pipe(\n\t\t\tshareReplay(1)\n\t\t)\n\t\treturn skipCurrent ? observable.pipe(skip(1)) : observable\n\t}\n\t\n\t/**\n\t * Get state from an area with type safety\n\t */\n\tgetState<T = unknown>(areaName: string): Observable<T> {\n\t\tif (!areaName) {\n\t\t\tthrow new Error('Area name is required')\n\t\t}\n\t\t\n\t\treturn this.on(areaName).pipe(\n\t\t\tmap(route => route.state),\n\t\t\tfilter((state): state is NonNullable<Record<string, unknown>> => \n\t\t\t\tstate !== undefined && state !== null\n\t\t\t),\n\t\t\tdistinctUntilChanged((a, b) => JSON.stringify(a) === JSON.stringify(b)),\n\t\t\tmap(state => state as T),\n\t\t\tcatchError(err => {\n\t\t\t\tconsole.error(`Error getting state for area \"${areaName}\":`, err)\n\t\t\t\treturn EMPTY\n\t\t\t})\n\t\t)\n\t}\n\t\n\t/**\n\t * Get params from an area with type safety\n\t */\n\tparams<T extends Record<string, unknown> = Record<string, unknown>>(areaName: string): Observable<T> {\n\t\tif (!areaName) {\n\t\t\tthrow new Error('Area name is required')\n\t\t}\n\t\t\n\t\treturn this.on(areaName).pipe(\n\t\t\tmap(route => route.params),\n\t\t\tfilter((params): params is NonNullable<Record<string, unknown>> => \n\t\t\t\tparams !== undefined && params !== null\n\t\t\t),\n\t\t\tdistinctUntilChanged((a, b) => JSON.stringify(a) === JSON.stringify(b)),\n\t\t\tmap(params => params as T),\n\t\t\tcatchError(err => {\n\t\t\t\tconsole.error(`Error getting params for area \"${areaName}\":`, err)\n\t\t\t\treturn EMPTY\n\t\t\t})\n\t\t)\n\t}\n\t\n\t/**\n\t * Get a specific param from an area with null safety\n\t */\n\tparam<T = unknown>(areaName: string, key: string): Observable<T> {\n\t\tif (!areaName || !key) {\n\t\t\tthrow new Error('Area name and key are required')\n\t\t}\n\t\t\n\t\treturn this.params<Record<string, unknown>>(areaName).pipe(\n\t\t\tmap(params => params[key]),\n\t\t\tfilter((value): value is NonNullable<unknown> => value !== undefined),\n\t\t\tdistinctUntilChanged(),\n\t\t\tmap(value => value as T),\n\t\t\tcatchError(err => {\n\t\t\t\tconsole.error(`Error getting param \"${key}\" for area \"${areaName}\":`, err)\n\t\t\t\treturn EMPTY\n\t\t\t})\n\t\t)\n\t}\n\t\n\t/**\n\t * Get props from an area with type safety\n\t */\n\tprops<T extends Record<string, unknown> = Record<string, unknown>>(areaName: string): Observable<T> {\n\t\tif (!areaName) {\n\t\t\tthrow new Error('Area name is required')\n\t\t}\n\t\t\n\t\treturn this.on(areaName).pipe(\n\t\t\tmap(route => route.props),\n\t\t\tfilter((props): props is NonNullable<Record<string, unknown>> => \n\t\t\t\tprops !== undefined && props !== null\n\t\t\t),\n\t\t\tdistinctUntilChanged((a, b) => JSON.stringify(a) === JSON.stringify(b)),\n\t\t\tmap(props => props as T),\n\t\t\tcatchError(err => {\n\t\t\t\tconsole.error(`Error getting props for area \"${areaName}\":`, err)\n\t\t\t\treturn EMPTY\n\t\t\t})\n\t\t)\n\t}\n\t\n\t/**\n\t * Get a specific prop from an area with null safety\n\t */\n\tprop<T = unknown>(areaName: string, key: string): Observable<T> {\n\t\tif (!areaName || !key) {\n\t\t\tthrow new Error('Area name and key are required')\n\t\t}\n\t\t\n\t\treturn this.props<Record<string, unknown>>(areaName).pipe(\n\t\t\tmap(props => props[key]),\n\t\t\tfilter((value): value is NonNullable<unknown> => value !== undefined),\n\t\t\tdistinctUntilChanged(),\n\t\t\tmap(value => value as T),\n\t\t\tcatchError(err => {\n\t\t\t\tconsole.error(`Error getting prop \"${key}\" for area \"${areaName}\":`, err)\n\t\t\t\treturn EMPTY\n\t\t\t})\n\t\t)\n\t}\n\n\t/**\n\t * Find teleportation components\n\t */\n\tfind() {\n\t\treturn zip([\n\t\t\tfromEvent<HERE_RICKY_EVENT>(window, HERE_RICKY).pipe(\n\t\t\t\tmap(e => e.detail),\n\t\t\t\tbufferTime(0),\n\t\t\t),\n\t\t\tof(1).pipe(tap(() => window.dispatchEvent(this.findingMortiesEvent))),\n\t\t]).pipe(\n\t\t\tmap(([component]) => component),\n\t\t\ttimeout(1),\n\t\t\tcatchError(() => EMPTY)\n\t\t)\n\t}\n\n\t/**\n\t * Push a new route action with validation\n\t */\n\tpush(r: RouteAction) {\n\t\tif (!r.area) {\n\t\t\tthrow new Error('Area is required for route action')\n\t\t}\n\t\t\n\t\t// Prevent processing during popstate handling\n\t\tif (this.isProcessingPopstate) {\n\t\t\treturn\n\t\t}\n\t\t\n\t\t// Ensure state, params and props are initialized\n\t\tconst routeAction: RouteAction = {\n\t\t\t...r,\n\t\t\tstate: r.state || {},\n\t\t\tparams: r.params || {},\n\t\t\tprops: r.props || {},\n\t\t\t_source: 'programmatic' as NavigationSource\n\t\t}\n\t\t\n\t\t// Add to history if enabled\n\t\tif (this.enableHistoryMode) {\n\t\t\trouterHistory.next(routeAction)\n\t\t}\n\t\t\n\t\tthis.request.next(routeAction)\n\t\t// Emit an area-specific event for those who want to listen directly to DOM events\n\t\tthis.dispatchAreaEvent(routeAction.area, routeAction)\n\t}\n\n\t/**\n\t * Internal method to update route from browser navigation\n\t * This should only be called by area components during popstate handling\n\t */\n\t_updateFromBrowser(routeAction: RouteAction) {\n\t\tconst enhancedRoute: RouteAction = {\n\t\t\t...routeAction,\n\t\t\tstate: routeAction.state || {},\n\t\t\tparams: routeAction.params || {},\n\t\t\tprops: routeAction.props || {},\n\t\t\t_source: 'browser' as NavigationSource\n\t\t}\n\t\t\n\t\tthis.isProcessingPopstate = true\n\t\tthis.request.next(enhancedRoute)\n\t\tthis.isProcessingPopstate = false\n\t}\n\n\t/**\n\t * Update browser history state (called by area components)\n\t */\n\t_updateBrowserHistory(areaName: string, route: ActiveRoute, historyStrategy?: string, clearQueryParams?: string[] | boolean | null) {\n\t\tif (!this.enableHistoryMode) return\n\t\t\n\t\ttry {\n\t\t\t// Get current browser state or create new one\n\t\t\tconst currentState = history.state || {}\n\t\t\tconst schmancyAreas = currentState.schmancyAreas || {}\n\t\t\t\n\t\t\t// Update the specific area - only include non-empty state/params/props\n\t\t\tconst areaData: any = {\n\t\t\t\tcomponent: route.component,\n\t\t\t\tarea: route.area\n\t\t\t}\n\t\t\t\n\t\t\t// Only include state if it has content\n\t\t\tif (route.state && Object.keys(route.state).length > 0) {\n\t\t\t\tareaData.state = route.state\n\t\t\t}\n\t\t\t\n\t\t\t// Only include params if it has content\n\t\t\tif (route.params && Object.keys(route.params).length > 0) {\n\t\t\t\tareaData.params = route.params\n\t\t\t}\n\t\t\t\n\t\t\t// Only include props if it has content\n\t\t\tif (route.props && Object.keys(route.props).length > 0) {\n\t\t\t\tareaData.props = route.props\n\t\t\t}\n\t\t\t\n\t\t\tschmancyAreas[areaName] = areaData\n\t\t\t\n\t\t\tconst newState = {\n\t\t\t\t...currentState,\n\t\t\t\tschmancyAreas\n\t\t\t}\n\t\t\t\n\t\t\t// Create clean URL\n\t\t\tconst url = this.createCleanURL(schmancyAreas, clearQueryParams)\n\t\t\t\n\t\t\t// Update browser history\n\t\t\tif (historyStrategy === 'replace' || historyStrategy === 'pop') {\n\t\t\t\thistory.replaceState(newState, '', url)\n\t\t\t} else if (historyStrategy === 'push' || !historyStrategy) {\n\t\t\t\thistory.pushState(newState, '', url)\n\t\t\t}\n\t\t\t// 'silent' strategy doesn't update browser history\n\t\t\t\n\t\t} catch (error) {\n\t\t\tconsole.error('Failed to update browser history:', error)\n\t\t}\n\t}\n\n\t/**\n\t * Create a clean URL from area states\n\t */\n\tprivate createCleanURL(areas: Record<string, ActiveRoute>, clearQueryParams?: string[] | boolean | null): string {\n\t\t// Get the current base path (everything except the last segment which might be encoded state)\n\t\tconst currentPath = location.pathname\n\t\tconst pathSegments = currentPath.split('/')\n\t\tlet basePath = '/'\n\n\t\t// Check if the last segment is encoded state (contains { or %7B)\n\t\tconst lastSegment = pathSegments[pathSegments.length - 1]\n\t\tif (lastSegment && (lastSegment.includes('{') || lastSegment.includes('%7B'))) {\n\t\t\t// Remove the encoded state segment to get the base path\n\t\t\tpathSegments.pop()\n\t\t\tbasePath = pathSegments.join('/') || '/'\n\t\t} else {\n\t\t\t// Keep the current path as base path\n\t\t\tbasePath = currentPath\n\t\t}\n\n\t\t// Ensure base path ends properly\n\t\tif (basePath !== '/' && !basePath.endsWith('/')) {\n\t\t\tbasePath += '/'\n\t\t}\n\n\t\t// Handle query parameters\n\t\tlet queryString = ''\n\n\t\tif (clearQueryParams !== true) {\n\t\t\t// Get current query params\n\t\t\tconst urlParams = new URLSearchParams(location.search)\n\n\t\t\t// Clear specific params if provided\n\t\t\tif (Array.isArray(clearQueryParams)) {\n\t\t\t\tclearQueryParams.forEach(param => urlParams.delete(param))\n\t\t\t}\n\n\t\t\t// Convert back to string\n\t\t\tqueryString = urlParams.toString()\n\t\t\tqueryString = queryString ? `?${queryString}` : ''\n\t\t}\n\t\t// If clearQueryParams === true, queryString remains empty (all params cleared)\n\n\t\tif (this.prettyURL) {\n\t\t\t// Create pretty URLs - customize this based on your routing needs\n\t\t\tconst mainArea = areas.main\n\t\t\tif (mainArea) {\n\t\t\t\tlet path = basePath === '/' ? `/${mainArea.component}` : `${basePath}${mainArea.component}`\n\n\t\t\t\t// Add simple params to URL\n\t\t\t\tconst searchParams = new URLSearchParams(queryString)\n\t\t\t\tif (mainArea.params) {\n\t\t\t\t\tObject.entries(mainArea.params).forEach(([key, value]) => {\n\t\t\t\t\t\tif (typeof value === 'string' || typeof value === 'number') {\n\t\t\t\t\t\t\tsearchParams.set(key, String(value))\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t}\n\n\t\t\t\tconst query = searchParams.toString()\n\t\t\t\treturn path + (query ? `?${query}` : '')\n\t\t\t}\n\t\t}\n\n\t\t// Fallback to encoded state in URL (original behavior)\n\t\ttry {\n\t\t\t// Clean up empty objects before encoding\n\t\t\tconst cleanedAreas: Record<string, any> = {}\n\t\t\tObject.entries(areas).forEach(([areaName, route]) => {\n\t\t\t\tconst cleanRoute: any = { component: route.component }\n\n\t\t\t\t// Only include state if it has content\n\t\t\t\tif (route.state && Object.keys(route.state).length > 0) {\n\t\t\t\t\tcleanRoute.state = route.state\n\t\t\t\t}\n\n\t\t\t\t// Only include params if it has content\n\t\t\t\tif (route.params && Object.keys(route.params).length > 0) {\n\t\t\t\t\tcleanRoute.params = route.params\n\t\t\t\t}\n\n\t\t\t\t// Only include props if it has content\n\t\t\t\tif (route.props && Object.keys(route.props).length > 0) {\n\t\t\t\t\tcleanRoute.props = route.props\n\t\t\t\t}\n\n\t\t\t\tcleanedAreas[areaName] = cleanRoute\n\t\t\t})\n\n\t\t\t// If cleanedAreas is empty, preserve the base path\n\t\t\tif (Object.keys(cleanedAreas).length === 0) {\n\t\t\t\tconst cleanBasePath = basePath === '/' ? '' : basePath.replace(/\\/$/, '')\n\t\t\t\treturn `${cleanBasePath}${queryString}`\n\t\t\t}\n\n\t\t\tconst encoded = encodeURIComponent(JSON.stringify(cleanedAreas))\n\t\t\tconst cleanBasePath = basePath === '/' ? '' : basePath.replace(/\\/$/, '')\n\t\t\treturn `${cleanBasePath}/${encoded}${queryString}`\n\t\t} catch (error) {\n\t\t\tconsole.error('Failed to encode URL state:', error)\n\t\t\treturn location.pathname\n\t\t}\n\t}\n\n\t/**\n\t * Restore state from browser history state\n\t */\n\trestoreFromBrowserState(browserState: any): Record<string, ActiveRoute> {\n\t\ttry {\n\t\t\tif (browserState && browserState.schmancyAreas) {\n\t\t\t\treturn browserState.schmancyAreas\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsole.error('Failed to restore from browser state:', error)\n\t\t}\n\t\t\n\t\t// Fallback to URL parsing (original behavior)\n\t\treturn this.parseStateFromURL()\n\t}\n\n\t/**\n\t * Parse state from URL (fallback method)\n\t */\n\tprivate parseStateFromURL(): Record<string, ActiveRoute> {\n\t\tconst pathname = location.pathname.split('/').pop()\n\t\tif (!pathname) return {}\n\t\t\n\t\ttry {\n\t\t\tconst decoded = decodeURIComponent(pathname)\n\t\t\tconst parsed = JSON.parse(decoded)\n\t\t\t\n\t\t\tif (typeof parsed === 'object' && parsed !== null) {\n\t\t\t\treturn parsed\n\t\t\t}\n\t\t} catch {\n\t\t\t// Ignore parse errors\n\t\t}\n\t\t\n\t\treturn {}\n\t}\n\t\n\t/**\n\t * Dispatch a DOM event for a specific area change\n\t */\n\tprivate dispatchAreaEvent(areaName: string, routeAction: RouteAction) {\n\t\tconst eventName = `schmancy-area-${areaName}-changed`\n\t\tconst event = new CustomEvent(eventName, { \n\t\t\tdetail: { \n\t\t\t\tarea: areaName,\n\t\t\t\tcomponent: routeAction.component,\n\t\t\t\tstate: routeAction.state,\n\t\t\t\tparams: routeAction.params,\n\t\t\t\tprops: routeAction.props,\n\t\t\t\thistoryStrategy: routeAction.historyStrategy\n\t\t\t},\n\t\t\tbubbles: true,\n\t\t\tcomposed: true\n\t\t})\n\t\twindow.dispatchEvent(event)\n\t}\n\n\t/**\n\t * Remove an area from the current state\n\t */\n\tpop(name: string) {\n\t\tif (!name) {\n\t\t\tthrow new Error('Area name is required')\n\t\t}\n\n\t\t// Before removing from current map, emit a clearing signal to the area's subject\n\t\t// This notifies the area component to clear itself\n\t\tconst areaSubject = this.areaSubjects.get(name)\n\t\tif (areaSubject && !areaSubject.closed) {\n\t\t\t// Send a route with null component to signal clearing\n\t\t\tareaSubject.next({\n\t\t\t\tcomponent: null as any,\n\t\t\t\tstate: {},\n\t\t\t\tarea: name,\n\t\t\t\tparams: {},\n\t\t\t\tprops: {}\n\t\t\t})\n\t\t}\n\n\t\t// Send a clearing signal through the request pipeline\n\t\t// This ensures the area component receives the signal to clear\n\t\tthis.request.next({\n\t\t\tarea: name,\n\t\t\tcomponent: null as any,\n\t\t\tstate: {},\n\t\t\tparams: {},\n\t\t\tprops: {},\n\t\t\thistoryStrategy: 'silent' as any,\n\t\t\t_source: 'programmatic' as NavigationSource\n\t\t})\n\n\t\t// Remove from current map\n\t\tthis.current.delete(name)\n\t\tthis.$current.next(this.current)\n\n\t\t// Update browser history\n\t\tif (this.enableHistoryMode) {\n\t\t\ttry {\n\t\t\t\tconst currentState = history.state || {}\n\t\t\t\tconst schmancyAreas = { ...(currentState.schmancyAreas || {}) }\n\t\t\t\tdelete schmancyAreas[name]\n\n\t\t\t\tconst newState = {\n\t\t\t\t\t...currentState,\n\t\t\t\t\tschmancyAreas\n\t\t\t\t}\n\n\t\t\t\tconst url = this.createCleanURL(schmancyAreas)\n\t\t\t\thistory.replaceState(newState, '', url)\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error('Failed to update history after pop:', error)\n\t\t\t}\n\t\t}\n\t}\n\t\n\t/**\n\t * Clear all areas\n\t */\n\tclear() {\n\t\t// Complete all area subjects\n\t\tthis.areaSubjects.forEach(subject => subject.complete())\n\t\tthis.areaSubjects.clear()\n\n\t\t// Clear current state\n\t\tthis.current.clear()\n\t\tthis.$current.next(this.current)\n\n\t\t// Update URL\n\t\tif (this.enableHistoryMode) {\n\t\t\tconst url = this.createCleanURL({})\n\t\t\thistory.replaceState({ schmancyAreas: {} }, '', url)\n\t\t}\n\t}\n\t\n\t/**\n\t * Dispose of the service and clean up resources\n\t */\n\tdispose() {\n\t\tif (this.disposed) return\n\n\t\tthis.disposed = true\n\n\t\t// Unsubscribe from unload event\n\t\tif (this.unloadSubscription) {\n\t\t\tthis.unloadSubscription.unsubscribe()\n\t\t\tthis.unloadSubscription = undefined\n\t\t}\n\n\t\t// Complete all subjects\n\t\tthis.areaSubjects.forEach(subject => subject.complete())\n\t\tthis.areaSubjects.clear()\n\n\t\tthis.request.complete()\n\t\tthis.$current.complete()\n\t\trouterHistory.complete()\n\n\t\t// Clear references\n\t\tthis.current.clear()\n\t\tareaSubjectsCache.delete(this)\n\t}\n\t\n\t/**\n\t * Get singleton instance\n\t */\n\tstatic getInstance() {\n\t\tif (!AreaService.instance) {\n\t\t\tAreaService.instance = new AreaService()\n\t\t}\n\t\treturn AreaService.instance\n\t}\n\n\t/**\n\t * Get current state from URL (deprecated - use browser state instead)\n\t */\n\tget state(): Record<string, unknown> {\n\t\t// Try browser state first\n\t\ttry {\n\t\t\tconst browserState = history.state\n\t\t\tif (browserState && browserState.schmancyAreas) {\n\t\t\t\treturn browserState.schmancyAreas\n\t\t\t}\n\t\t} catch {\n\t\t\t// Fallback to URL parsing\n\t\t}\n\t\t\n\t\t// Fallback to URL parsing (original behavior)\n\t\treturn this.parseStateFromURL()\n\t}\n\t\n\t/**\n\t * Check if an area exists in current state\n\t */\n\thasArea(areaName: string): boolean {\n\t\treturn this.current.has(areaName)\n\t}\n\t\n\t/**\n\t * Get all active area names\n\t */\n\tgetActiveAreas(): string[] {\n\t\treturn Array.from(this.current.keys())\n\t}\n\t\n\t/**\n\t * Get route for a specific area synchronously\n\t */\n\tgetRoute(areaName: string): ActiveRoute | undefined {\n\t\treturn this.current.get(areaName)\n\t}\n}\n\nexport const area = AreaService.getInstance()\nexport default area","import { html, css, TemplateResult } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { $LitElement } from '@mixins/index';\nimport { Observable } from 'rxjs';\n\nexport type ObservableGuardResult = Observable<boolean>;\n\n// Component types that can be passed to routes\nexport type RouteComponent =\n | string // Tag name\n | CustomElementConstructor // Constructor function\n | HTMLElement // Existing element\n | TemplateResult<1> // Lit template\n | (() => Promise<{ default: CustomElementConstructor }>) // Lazy loader\n | Promise<{ default: CustomElementConstructor }>; // Dynamic import\n\nexport interface RouteConfig {\n when: string;\n component: RouteComponent;\n exact?: boolean;\n guard?: ObservableGuardResult;\n}\n\n/**\n * A marker component that holds route configuration.\n * This component doesn't render anything - it's used by schmancy-area\n * to configure routing via slot change detection.\n *\n * @example\n * ```html\n * <schmancy-area>\n * <schmancy-route\n * when=\"users\"\n * .component=${UserComponent}\n * exact\n * ></schmancy-route>\n * </schmancy-area>\n * ```\n */\n@customElement('schmancy-route')\nexport class SchmancyRoute extends $LitElement(css`\n :host {\n display: none;\n }\n`) {\n @property({ type: String })\n when!: string;\n\n @property({ type: Object })\n component!: RouteComponent;\n\n @property({ type: Boolean })\n exact?: boolean = false;\n\n @property({ type: Object })\n guard?:ObservableGuardResult ;\n\n /**\n * Returns the route configuration object\n */\n getConfig(): RouteConfig {\n return {\n when: this.when,\n component: this.component,\n exact: this.exact,\n guard: this.guard\n };\n }\n\n render() {\n // This is a marker component - no visual output\n return html``;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'schmancy-route': SchmancyRoute;\n }\n}","export type RouteAction = {\n\tcomponent: CustomElementConstructor | string | HTMLElement | (() => Promise<{ default: CustomElementConstructor }>)\n\tarea: string\n\tstate?: Record<string, unknown>\n\tparams?: Record<string, unknown>\n\tprops?: Record<string, unknown> // Alias for params\n\thistoryStrategy?: THistoryStrategy\n\tclearQueryParams?: string[] | boolean | null\n\t_source?: 'programmatic' | 'browser' | 'initial' // Internal use only\n}\n\nexport type ActiveRoute = {\n\tcomponent: string\n\tarea: string\n\tstate?: Record<string, unknown>\n\tparams?: Record<string, unknown>\n\tprops?: Record<string, unknown>\n}\n\n/**\n * Interface for subscribing to area changes\n */\nexport interface AreaSubscription {\n\t/**\n\t * Subscribe to a specific area\n\t * @param areaName Name of the area to subscribe to\n\t * @param skipCurrent Whether to skip the current value\n\t * @returns Observable of the active route for the specified area\n\t */\n\ton(areaName: string, skipCurrent?: boolean): import('rxjs').Observable<ActiveRoute>\n\t\n\t/**\n\t * Subscribe to all areas\n\t * @param skipCurrent Whether to skip the current value\n\t * @returns Observable of all active routes\n\t */\n\tall(skipCurrent?: boolean): import('rxjs').Observable<Map<string, ActiveRoute>>\n\t\n\t/**\n\t * Get state from an area\n\t * @param areaName Name of the area to subscribe to\n\t * @returns Observable of the area's state\n\t */\n\tgetState<T = unknown>(areaName: string): import('rxjs').Observable<T>\n\t\n\t/**\n\t * Get params from an area\n\t * @param areaName Name of the area to subscribe to\n\t * @returns Observable of the area's params\n\t */\n\tparams<T extends Record<string, unknown> = Record<string, unknown>>(areaName: string): import('rxjs').Observable<T>\n\t\n\t/**\n\t * Get a specific param from an area\n\t * @param areaName Name of the area to subscribe to\n\t * @param key Key of the param to select\n\t * @returns Observable of the param value\n\t */\n\tparam<T = unknown>(areaName: string, key: string): import('rxjs').Observable<T>\n\t\n\t/**\n\t * Get props from an area\n\t * @param areaName Name of the area to subscribe to\n\t * @returns Observable of the area's props\n\t */\n\tprops<T extends Record<string, unknown> = Record<string, unknown>>(areaName: string): import('rxjs').Observable<T>\n\t\n\t/**\n\t * Get a specific prop from an area\n\t * @param areaName Name of the area to subscribe to\n\t * @param key Key of the prop to select\n\t * @returns Observable of the prop value\n\t */\n\tprop<T = unknown>(areaName: string, key: string): import('rxjs').Observable<T>\n}\n\nexport type THistoryStrategy = 'push' | 'replace' | 'pop' | 'silent'\n\nexport enum HISTORY_STRATEGY {\n\tpush = 'push',\n\treplace = 'replace',\n\tpop = 'pop',\n\tsilent = 'silent',\n}\n\n/**\n * Browser history state structure used by Schmancy Area\n */\nexport interface SchmancyHistoryState {\n\tschmancyAreas: Record<string, ActiveRoute>\n\t[key: string]: any // Allow other apps to store additional state\n}","import { $LitElement } from '@mixins/index'\nimport { css, html } from 'lit'\nimport { customElement, property, queryAssignedElements } from 'lit/decorators.js'\nimport {\n\tEMPTY,\n\tcatchError,\n\tdistinctUntilChanged,\n\tfilter,\n\tfromEvent,\n\tmap,\n\tmerge,\n\tof,\n\tshareReplay,\n\tswitchMap,\n\ttake,\n\ttakeUntil,\n\ttap,\n} from 'rxjs'\nimport area from './area.service'\nimport { SchmancyRoute } from './route.component'\nimport { ActiveRoute, HISTORY_STRATEGY, RouteAction } from './router.types'\n\nexport type ComponentType =\n\t| CustomElementConstructor\n\t| string\n\t| HTMLElement\n\t| (() => Promise<{ default: CustomElementConstructor }>)\n@customElement('schmancy-area')\nexport class SchmancyArea extends $LitElement(css`\n\t:host {\n\t\tposition: relative;\n\t\tdisplay: block;\n\t\tinset: 0;\n\t}\n`) {\n\t/**\n\t * The name of the router outlet\n\t * @attr\n\t * @type {string}\n\t * @public\n\t * @required\n\t */\n\t@property() name!: string\n\n\t@property() default!: ComponentType\n\n\t/**\n\t * Query for assigned route elements in the slot\n\t * This will automatically update when slot content changes\n\t */\n\t@queryAssignedElements({ selector: 'schmancy-route', flatten: true })\n\tprivate routes!: SchmancyRoute[]\n\n\tprotected firstUpdated(): void {\n\t\tif (!this.name) throw new Error('Area name is required')\n\t\t// Single unified routing pipeline - all logic inline\n\t\tmerge(\n\t\t\t// Programmatic navigation\n\t\t\tarea.request.pipe(filter(({ area }) => area === this.name)),\n\n\t\t\t// Initial load - simplified to use this.routes directly\n\t\t\tof(location.pathname).pipe(\n\t\t\t\ttake(1),\n\t\t\t\tswitchMap(() => {\n\t\t\t\t\tconst path = location.pathname\n\t\t\t\t\tconst lastSegment = path.split('/').pop() || ''\n\t\t\t\t\tlet route: SchmancyRoute\n\t\t\t\t\tlet originalWhen: string | undefined\n\n\t\t\t\t\t// Check for JSON encoded route\n\t\t\t\t\tif (lastSegment && (lastSegment.includes('{') || lastSegment.includes('%7B'))) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst parsed = JSON.parse(decodeURIComponent(lastSegment)) as Record<string, ActiveRoute>\n\t\t\t\t\t\t\tif (parsed[this.name]) {\n\t\t\t\t\t\t\t\tconst componentTag = parsed[this.name]\n\t\t\t\t\t\t\t\troute = this.routes?.find(r => r.when === componentTag.component)\n\t\t\t\t\t\t\t\toriginalWhen = componentTag.component // Track the original 'when' value\n\t\t\t\t\t\t\t\t// if the route.component is a lazy loaded module we need to load it\n\t\t\t\t\t\t\t\tif (route)\n\t\t\t\t\t\t\t\t\treturn of({\n\t\t\t\t\t\t\t\t\t\tarea: this.name,\n\t\t\t\t\t\t\t\t\t\tcomponent: route.component,\n\t\t\t\t\t\t\t\t\t\tstate: parsed[this.name].state || {},\n\t\t\t\t\t\t\t\t\t\tparams: parsed[this.name].params || {},\n\t\t\t\t\t\t\t\t\t\thistoryStrategy: HISTORY_STRATEGY.replace,\n\t\t\t\t\t\t\t\t\t\toriginalWhen, // Pass along the original route identifier\n\t\t\t\t\t\t\t\t\t} as RouteAction & { originalWhen?: string })\n\n\t\t\t\t\t\t\t\treturn of({\n\t\t\t\t\t\t\t\t\tarea: this.name,\n\t\t\t\t\t\t\t\t\tcomponent: parsed[this.name].component,\n\t\t\t\t\t\t\t\t\tstate: parsed[this.name].state || {},\n\t\t\t\t\t\t\t\t\tparams: parsed[this.name].params || {},\n\t\t\t\t\t\t\t\t\thistoryStrategy: HISTORY_STRATEGY.replace,\n\t\t\t\t\t\t\t\t\toriginalWhen: parsed[this.name].component, // Track even for direct component references\n\t\t\t\t\t\t\t\t} as RouteAction & { originalWhen?: string })\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch {}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Segment-based routing\n\t\t\t\t\tconst segments = path.split('/').filter(Boolean)\n\t\t\t\t\troute = this.routes?.find(r => segments.includes(r.when))\n\t\t\t\t\toriginalWhen = route?.when // Track the original 'when' value\n\t\t\t\t\t// if the route.component is a lazy loaded module we need to load it\n\n\t\t\t\t\tif (!route) {\n\t\t\t\t\t\treturn this.default\n\t\t\t\t\t\t\t? of({\n\t\t\t\t\t\t\t\t\tarea: this.name,\n\t\t\t\t\t\t\t\t\tcomponent: this.default,\n\t\t\t\t\t\t\t\t\tstate: {},\n\t\t\t\t\t\t\t\t\tparams: {},\n\t\t\t\t\t\t\t\t\thistoryStrategy: HISTORY_STRATEGY.silent,\n\t\t\t\t\t\t\t\t} as RouteAction)\n\t\t\t\t\t\t\t: EMPTY\n\t\t\t\t\t}\n\n\t\t\t\t\treturn of({\n\t\t\t\t\t\tarea: this.name,\n\t\t\t\t\t\tcomponent: route.component,\n\t\t\t\t\t\tstate: {},\n\t\t\t\t\t\tparams: {},\n\t\t\t\t\t\thistoryStrategy: HISTORY_STRATEGY.silent,\n\t\t\t\t\t\toriginalWhen, // Pass along the original route identifier\n\t\t\t\t\t} as RouteAction & { originalWhen?: string })\n\t\t\t\t}),\n\t\t\t),\n\n\t\t\t// Browser back/forward - simplified to directly use popstate\n\t\t\tfromEvent<PopStateEvent>(window, 'popstate').pipe(\n\t\t\t\tmap(event =>\n\t\t\t\t\tevent.state?.schmancyAreas?.[this.name]\n\t\t\t\t\t\t? ({\n\t\t\t\t\t\t\t\tarea: this.name,\n\t\t\t\t\t\t\t\tcomponent: event.state.schmancyAreas[this.name].component,\n\t\t\t\t\t\t\t\tstate: event.state.schmancyAreas[this.name].state || {},\n\t\t\t\t\t\t\t\tparams: event.state.schmancyAreas[this.name].params || {},\n\t\t\t\t\t\t\t\thistoryStrategy: HISTORY_STRATEGY.pop,\n\t\t\t\t\t\t\t} as RouteAction)\n\t\t\t\t\t\t: null,\n\t\t\t\t),\n\t\t\t\tfilter(route => route !== null),\n\t\t\t),\n\t\t)\n\t\t\t.pipe(\n\t\t\t\tfilter(route => route?.component !== undefined),\n\t\t\t\t// Step 1: Resolve ONLY lazy components to constructors (no element creation)\n\t\t\t\tswitchMap(async route => {\n\t\t\t\t\tlet component = route.component\n\n\t\t\t\t\t// Resolve lazy components first\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof component === 'function' &&\n\t\t\t\t\t\t('preload' in component || '_promise' in component || '_module' in component)\n\t\t\t\t\t) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst module = await (component as () => Promise<{ default: CustomElementConstructor }>)()\n\t\t\t\t\t\t\tcomponent = module.default\n\t\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\t\tconsole.error(`[${this.name}] Lazy load failed:`, e)\n\t\t\t\t\t\t\treturn { component: null, route }\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\treturn { component, route }\n\t\t\t\t}),\n\n\t\t\t\t// Step 2: Extract component identifier for comparison (without creating elements)\n\t\t\t\tmap(({ component, route }) => {\n\t\t\t\t\tlet identifier = ''\n\n\t\t\t\t\tif (!component || component === '') {\n\t\t\t\t\t\tidentifier = 'null'\n\t\t\t\t\t} else if (typeof component === 'string') {\n\t\t\t\t\t\tidentifier = component\n\t\t\t\t\t} else if (component instanceof HTMLElement) {\n\t\t\t\t\t\tidentifier = component.tagName\n\t\t\t\t\t} else if (typeof component === 'function') {\n\t\t\t\t\t\tidentifier = component.name || 'CustomElement'\n\t\t\t\t\t}\n\t\t\t\t\t\n\n\t\t\t\t\tconst key = `${identifier}${JSON.stringify(route.params)}${JSON.stringify(route.state)}`\n\n\t\t\t\t\treturn { component, route, key , tagName:identifier}\n\t\t\t\t}),\n\n\t\t\t\t// Step 3: Deduplicate using the identifier (before creating expensive elements)\n\t\t\t\tdistinctUntilChanged((a, b) => {\n\t\t\t\t\treturn a.key === b.key\n\t\t\t\t}),\n\t\t\t\t// Step 0: Guard\n\t\t\t\tswitchMap(r => {\n\t\t\t\t\n\t\t\t\t\tconsole.log(r.tagName)\n\t\t\t\t\tconst route = this.routes.find(route => route.when === r.tagName);\n\n\t\t\t\t\t// If route has a guard, evaluate it\n\t\t\t\t\tif (route?.guard) {\n\t\t\t\t\t\treturn route.guard.pipe(\n\t\t\t\t\t\t\ttap(guardResult => {\n\t\t\t\t\t\t\t\tconsole.log(`[${this.name}] Guard evaluation for route '${route.when}':`, guardResult)\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tswitchMap(guardResult => {\n\t\t\t\t\t\t\t\tif (guardResult === true) return of(r);\n\n\t\t\t\t\t\t\t\t// Guard failed, dispatch redirect event\n\t\t\t\t\t\t\t\tconst redirectEvent = new CustomEvent('redirect', {\n\t\t\t\t\t\t\t\t\tdetail: {\n\t\t\t\t\t\t\t\t\t\tblockedRoute: r.tagName,\n\t\t\t\t\t\t\t\t\t\tarea: this.name,\n\t\t\t\t\t\t\t\t\t\tparams: r.route?.params || {},\n\t\t\t\t\t\t\t\t\t\tstate: r.route?.state || {},\n\t\t\t\t\t\t\t\t\t\tredirectTarget: typeof guardResult === 'object' ? guardResult : undefined,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tbubbles: true,\n\t\t\t\t\t\t\t\t\tcomposed: true,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\troute.dispatchEvent(redirectEvent);\n\n\t\t\t\t\t\t\t\treturn EMPTY;\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\t// No guard, allow navigation\n\t\t\t\t\treturn of(r);\n\t\t\t\t}),\n\n\t\t\t\t// Step 4: Create the HTMLElement and apply properties\n\t\t\t\tmap(({ component, route }) => {\n\t\t\t\t\tlet element: HTMLElement | null = null\n\n\t\t\t\t\t// Now resolve to HTMLElement\n\t\t\t\t\tif (!component || component === '') {\n\t\t\t\t\t\telement = null\n\t\t\t\t\t} else if (typeof component === 'string') {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\telement = document.createElement(component)\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\tconsole.error(`[${this.name}] Failed to create element:`, component)\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (component instanceof HTMLElement) {\n\t\t\t\t\t\telement = component\n\t\t\t\t\t} else if (typeof component === 'function') {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\telement = new (component as CustomElementConstructor)()\n\t\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\t\tconsole.error(`[${this.name}] Failed to instantiate:`, e)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Apply properties inline\n\t\t\t\t\tif (element) {\n\t\t\t\t\t\tif (route.params) Object.assign(element, route.params)\n\t\t\t\t\t\tif (route.props) Object.assign(element, route.props)\n\t\t\t\t\t\tif (route.state) (element as any).state = route.state\n\t\t\t\t\t}\n\n\t\t\t\t\treturn { element, route }\n\t\t\t\t}),\n\n\t\t\t\tshareReplay(1),\n\n\t\t\t\t// Swap components\n\t\t\t\ttap(({ element, route }) => this.swapComponents(element, route)),\n\n\t\t\t\tcatchError(error => {\n\t\t\t\t\tconsole.error(`[${this.name}] Navigation error:`, error)\n\t\t\t\t\treturn EMPTY\n\t\t\t\t}),\n\n\t\t\t\ttakeUntil(this.disconnecting),\n\t\t\t)\n\t\t\t.subscribe()\n\t}\n\n\t/**\n\t * Swap components with animation following the original pattern\n\t */\n\tprivate swapComponents(newComponent: HTMLElement | null, routeAction: RouteAction) {\n\t\t// Important: We need to work with the light DOM, not shadow DOM\n\t\t// The slot should remain in shadow DOM, and we append content to light DOM\n\n\t\t// Find the current routed component (not the route definitions)\n\t\t// Route definitions have display:none, actual components don't\n\t\tconst oldComponent = Array.from(this.children).find(\n\t\t\tchild => !(child instanceof SchmancyRoute)\n\t\t) as HTMLElement | undefined\n\n\t\t// If no new component, just clear\n\t\tif (!newComponent) {\n\t\t\tif (oldComponent) {\n\t\t\t\toldComponent.remove()\n\t\t\t}\n\t\t\treturn\n\t\t}\n\n\t\t// Animate transition\n\t\tif (oldComponent) {\n\t\t\t// Fade out old component\n\t\t\tconst fadeOut = oldComponent.animate([{ opacity: 1 }, { opacity: 0 }], { duration: 150, easing: 'ease-out' })\n\n\t\t\tfadeOut.onfinish = () => {\n\t\t\t\toldComponent.remove()\n\t\t\t\t// Add new component to light DOM (not shadow DOM!)\n\t\t\t\tthis.appendChild(newComponent)\n\t\t\t\tnewComponent.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 150, easing: 'ease-in' })\n\t\t\t}\n\t\t} else {\n\t\t\t// No old component, just add and fade in to light DOM\n\t\t\tthis.appendChild(newComponent)\n\t\t\tnewComponent.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 100, easing: 'ease-in' })\n\t\t}\n\n\t\t// Update internal state\n\t\tif (newComponent) {\n\t\t\tconst activeRoute: ActiveRoute = {\n\t\t\t\tcomponent: newComponent.tagName.toLowerCase(),\n\t\t\t\tstate: routeAction.state || {},\n\t\t\t\tarea: this.name,\n\t\t\t\tparams: routeAction.params || {},\n\t\t\t}\n\n\t\t\tarea.current.set(this.name, activeRoute)\n\t\t\tarea.$current.next(area.current)\n\t\t}\n\n\t\t// Update browser history\n\t\tif (area.enableHistoryMode && newComponent) {\n\t\t\tconst activeRoute: ActiveRoute = {\n\t\t\t\tcomponent: newComponent.tagName.toLowerCase(),\n\t\t\t\tstate: routeAction.state || {},\n\t\t\t\tarea: this.name,\n\t\t\t\tparams: routeAction.params || {},\n\t\t\t}\n\n\t\t\tarea._updateBrowserHistory(\n\t\t\t\tthis.name,\n\t\t\t\tactiveRoute,\n\t\t\t\trouteAction.historyStrategy || HISTORY_STRATEGY.push,\n\t\t\t\trouteAction.clearQueryParams,\n\t\t\t)\n\t\t}\n\t}\n\n\t/**\n\t * Create URL path for the route (legacy method, now handled by service)\n\t */\n\tnewPath(tag: string, route: RouteAction) {\n\t\tconst oldPathname = location.pathname.split('/').pop()\n\t\tlet oldAreaState = {}\n\t\ttry {\n\t\t\toldAreaState = oldPathname ? JSON.parse(decodeURIComponent(oldPathname)) : {}\n\t\t} catch {\n\t\t\toldAreaState = {}\n\t\t}\n\t\troute.state = route.state ?? {}\n\t\tconst queryParams = route.clearQueryParams ? this.queryParamClear(route.clearQueryParams) : document.location.search\n\n\t\treturn encodeURIComponent(\n\t\t\tJSON.stringify({\n\t\t\t\t...oldAreaState,\n\t\t\t\t[this.name]: { component: tag.toLowerCase(), state: route.state, params: route.params },\n\t\t\t}),\n\t\t).concat(`${queryParams}`)\n\t}\n\n\t/**\n\t * Clear query parameters\n\t */\n\tqueryParamClear(params?: string[] | boolean) {\n\t\tif (!params) {\n\t\t\treturn ''\n\t\t}\n\t\t// get query params from url\n\t\tconst urlParams = new URLSearchParams(location.search)\n\n\t\tif (params === true) {\n\t\t\t// Clear all query params\n\t\t\treturn ''\n\t\t} else {\n\t\t\t// Clear specific query params\n\t\t\tparams.forEach(param => urlParams.delete(param))\n\t\t\t// update url\n\t\t\tif (urlParams.toString() === '') return ''\n\t\t\treturn `?${urlParams.toString()}`\n\t\t}\n\t}\n\n\tdisconnectedCallback() {\n\t\tsuper.disconnectedCallback()\n\t}\n\n\trender() {\n\t\treturn html`<slot></slot>`\n\t}\n}\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t'schmancy-area': SchmancyArea\n\t}\n}\n"],"names":["routerHistory","Subject","FINDING_MORTIES","HERE_RICKY","areaSubjectsCache","WeakMap","AreaService","constructor","this","prettyURL","mode","request","ReplaySubject","current","Map","$current","enableHistoryMode","findingMortiesEvent","CustomEvent","disposed","isProcessingPopstate","next","subscribe","currentAreas","forEach","route","areaName","getOrCreateAreaSubject","initializeFromBrowserState","window","unloadSubscription","fromEvent","dispose","areaSubjects","subjects","get","set","browserState","history","state","schmancyAreas","Object","entries","error","subject","closed","currentRoute","params","props","skipCurrent","Error","observable","asObservable","pipe","distinctUntilChanged","a","b","component","JSON","stringify","shareReplay","skip","on","map","filter","catchError","err","EMPTY","key","value","zip","e","detail","bufferTime","of","tap","dispatchEvent","timeout","r","area","routeAction","_source","dispatchAreaEvent","enhancedRoute","historyStrategy","clearQueryParams","currentState","areaData","keys","length","newState","url","createCleanURL","replaceState","pushState","areas","currentPath","location","pathname","pathSegments","split","basePath","lastSegment","includes","pop","join","endsWith","queryString","urlParams","URLSearchParams","search","Array","isArray","param","delete","toString","mainArea","main","path","searchParams","String","query","cleanedAreas","cleanRoute","replace","encoded","encodeURIComponent","parseStateFromURL","decoded","decodeURIComponent","parsed","parse","event","bubbles","composed","name","areaSubject","complete","clear","unsubscribe","getInstance","instance","has","getActiveAreas","from","SchmancyRoute","$LitElement","css","super","arguments","exact","getConfig","when","guard","render","html","__decorateClass","property","type","prototype","Boolean","customElement","HISTORY_STRATEGY","SchmancyArea","firstUpdated","merge","take","switchMap","originalWhen","componentTag","routes","find","segments","silent","default","async","module","identifier","HTMLElement","tagName","guardResult","redirectEvent","blockedRoute","redirectTarget","element","document","createElement","assign","swapComponents","takeUntil","disconnecting","newComponent","oldComponent","children","child","animate","opacity","duration","easing","onfinish","remove","appendChild","activeRoute","toLowerCase","_updateBrowserHistory","push","tag","oldPathname","oldAreaState","queryParams","queryParamClear","concat","disconnectedCallback","queryAssignedElements","selector","flatten"],"mappings":"qQAsBaA,EAAgB,IAAIC,EAAAA,QAEpBC,EAAkB,kBAClBC,EAAa,aASpBC,MAAwBC,QAK9B,MAAMC,CAAAA,CAwBL,aAAAC,CAtBAC,KAAOC,aACPD,KAAOE,KAA6B,UACpCF,KAAOG,QAAU,IAAIC,EAAAA,cAA2B,GAChDJ,KAAOK,YAAcC,IACrBN,KAAOO,SAAW,IAAIH,EAAAA,cAAwC,CAAA,EAY9DJ,KAAOQ,kBAAAA,GACPR,KAAQS,oBAAsB,IAAIC,YAA6ChB,CAAAA,EAC/EM,KAAQW,SAAAA,GACRX,KAAOY,qBAAAA,GAINZ,KAAKO,SAASM,KAAKb,KAAKK,OAAAA,EAGxBL,KAAKO,SAASO,UAAUC,IACnBf,KAAKW,UAGTI,EAAaC,QAAQ,CAACC,EAAOC,IAAAA,CAERlB,KAAKmB,uBAAuBD,GAEpCL,KAAKI,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,EAKnBjB,KAAKoB,2BAAAA,SAGMC,OAAW,MACrBrB,KAAKsB,mBAAqBC,EAAAA,UAAUF,OAAQ,QAAA,EAAUP,UAAU,IAAA,CAC/Dd,KAAKwB,YAGR,CAxCA,IAAA,cAAYC,CACX,IAAIC,EAAW9B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OAAOD,IAErCL,EAAUO,aAAe,GAAW,GACjC,IAAIP,EAAUO,SAAAA,CAAAA,GACtB,CAGD,uBACCiC,MAAMgE,qBAAAA,CAAqB,CAG5B,QAAA1D,CACC,OAAOC,EAAAA,mBAAA,CAAA,EAlWIC,EAAA,CAAXC,EAAAA,YAdWM,qBAcAJ,UAAA,OAAA,CAAA,EAEAH,EAAA,CAAXC,EAAAA,SAAAA,CAAAA,EAhBWM,qBAgBAJ,UAAA,UAAA,CAAA,EAOJH,EAAA,CADPyD,EAAAA,sBAAsB,CAAEC,SAAU,iBAAkBC,QAAAA,EAAS,CAAA,CAAA,EAtBlDpD,qBAuBJJ,UAAA,SAAA,CAAA,EAvBII,QAAAA,aAANP,EAAA,CADNK,EAAAA,cAAc,eAAA,CAAA,EACFE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lazy-DObpkuL6.cjs","sources":["../src/area/utils.ts","../src/area/lazy.ts"],"sourcesContent":["import { ComponentType } from './area.component'\nimport { RouteAction, ActiveRoute } from './router.types'\n\n/**\n * Compare two custom element constructors for equality\n * @param constructor1 First constructor to compare\n * @param constructor2 Second constructor to compare\n * @returns true if constructors are functionally equivalent\n */\nexport function compareCustomElementConstructors(\n\tconstructor1: CustomElementConstructor | Function,\n\tconstructor2: CustomElementConstructor | Function,\n): boolean {\n\t// Quick reference check\n\tif (constructor1 === constructor2) {\n\t\treturn true\n\t}\n\n\t// Check if both are functions\n\tif (typeof constructor1 !== 'function' || typeof constructor2 !== 'function') {\n\t\treturn false\n\t}\n\n\t// Compare by name (handles minification)\n\tif (constructor1.name && constructor2.name && constructor1.name === constructor2.name) {\n\t\treturn true\n\t}\n\n\t// Compare observed attributes if available\n\tconst obs1 = (constructor1 as any).observedAttributes\n\tconst obs2 = (constructor2 as any).observedAttributes\n\n\tif (obs1 && obs2) {\n\t\tif (Array.isArray(obs1) && Array.isArray(obs2)) {\n\t\t\tif (obs1.length !== obs2.length) return false\n\t\t\treturn obs1.every((attr, i) => attr === obs2[i])\n\t\t}\n\t}\n\n\t// Try to compare prototypes\n\ttry {\n\t\tconst proto1 = constructor1.prototype\n\t\tconst proto2 = constructor2.prototype\n\n\t\t// Check if they have the same prototype chain\n\t\tif (Object.getPrototypeOf(proto1) === Object.getPrototypeOf(proto2)) {\n\t\t\t// Check if they have the same property names\n\t\t\tconst keys1 = Object.getOwnPropertyNames(proto1).sort()\n\t\t\tconst keys2 = Object.getOwnPropertyNames(proto2).sort()\n\n\t\t\treturn keys1.length === keys2.length && keys1.every((key, i) => key === keys2[i])\n\t\t}\n\t} catch {\n\t\t// Ignore prototype access errors\n\t}\n\n\treturn false\n}\n\n/**\n * Normalize a component tag name for comparison\n * @param tagName Tag name to normalize\n * @returns Normalized tag name\n */\nexport function normalizeTagName(tagName: string): string {\n\treturn tagName.toLowerCase().replace(/[^a-z0-9]/g, '') // Remove all non-alphanumeric characters\n}\n\n/**\n * Get tag name from a component\n * @param component Component to get tag name from\n * @returns Tag name or null if unable to determine\n */\nexport function getTagName(component: ComponentType): string | null {\n\tif (typeof component === 'string') {\n\t\treturn component.toLowerCase()\n\t}\n\n\tif (component instanceof HTMLElement) {\n\t\treturn component.tagName.toLowerCase()\n\t}\n\n\tif (typeof component === 'function') {\n\t\t// Try to get custom element name from constructor\n\t\tconst name = component.name\n\t\tif (name) {\n\t\t\t// Convert PascalCase to kebab-case\n\t\t\treturn name\n\t\t\t\t.replace(/([A-Z])/g, '-$1')\n\t\t\t\t.toLowerCase()\n\t\t\t\t.replace(/^-/, '')\n\t\t}\n\t}\n\n\treturn null\n}\n\n/**\n * Deep merge two objects\n * @param target Target object\n * @param source Source object to merge\n * @returns Merged object\n */\nexport function deepMerge<T extends Record<string, any>>(target: T, source: Partial<T>): T {\n\tconst output = { ...target }\n\n\tfor (const key in source) {\n\t\tif (source.hasOwnProperty(key)) {\n\t\t\tconst sourceValue = source[key]\n\t\t\tconst targetValue = output[key]\n\n\t\t\tif (isObject(sourceValue) && isObject(targetValue)) {\n\t\t\t\toutput[key] = deepMerge(targetValue, sourceValue)\n\t\t\t} else {\n\t\t\t\toutput[key] = sourceValue as T[Extract<keyof T, string>]\n\t\t\t}\n\t\t}\n\t}\n\n\treturn output\n}\n\n/**\n * Check if value is a plain object\n * @param obj Value to check\n * @returns true if value is a plain object\n */\nexport function isObject(obj: any): obj is Record<string, any> {\n\treturn (\n\t\tobj !== null &&\n\t\ttypeof obj === 'object' &&\n\t\tobj.constructor === Object &&\n\t\tObject.prototype.toString.call(obj) === '[object Object]'\n\t)\n}\n\n/**\n * Debounce a function\n * @param func Function to debounce\n * @param wait Wait time in milliseconds\n * @returns Debounced function\n */\nexport function debounce<T extends (...args: any[]) => any>(func: T, wait: number): (...args: Parameters<T>) => void {\n\tlet timeout: ReturnType<typeof setTimeout> | null = null\n\n\treturn function (this: any, ...args: Parameters<T>) {\n\t\tconst context = this\n\n\t\tif (timeout !== null) {\n\t\t\tclearTimeout(timeout)\n\t\t}\n\n\t\ttimeout = setTimeout(() => {\n\t\t\tfunc.apply(context, args)\n\t\t\ttimeout = null\n\t\t}, wait)\n\t}\n}\n\n/**\n * Create a URL-safe string from route state\n * @param state Route state object\n * @returns URL-safe encoded string\n */\nexport function encodeRouteState(state: Record<string, unknown>): string {\n\ttry {\n\t\tconst json = JSON.stringify(state)\n\t\treturn encodeURIComponent(json)\n\t} catch (error) {\n\t\tconsole.error('Failed to encode route state:', error)\n\t\treturn ''\n\t}\n}\n\n/**\n * Decode a URL-safe string to route state\n * @param encoded Encoded string\n * @returns Decoded route state or empty object\n */\nexport function decodeRouteState(encoded: string): Record<string, unknown> {\n\tif (!encoded) return {}\n\n\ttry {\n\t\tconst decoded = decodeURIComponent(encoded)\n\t\tconst parsed = JSON.parse(decoded)\n\n\t\tif (isObject(parsed)) {\n\t\t\treturn parsed\n\t\t}\n\t} catch (error) {\n\t\tconsole.error('Failed to decode route state:', error)\n\t}\n\n\treturn {}\n}\n\n/**\n * Compare two route actions for equality\n * @param a First route action\n * @param b Second route action\n * @returns true if route actions are equal\n */\nexport function compareRouteActions(a: RouteAction, b: RouteAction): boolean {\n\t// Compare areas\n\tif (a.area !== b.area) return false\n\n\t// Compare components\n\tif (typeof a.component !== typeof b.component) return false\n\n\tif (typeof a.component === 'string' && typeof b.component === 'string') {\n\t\tif (normalizeTagName(a.component) !== normalizeTagName(b.component)) {\n\t\t\treturn false\n\t\t}\n\t} else if (typeof a.component === 'function' && typeof b.component === 'function') {\n\t\tif (!compareCustomElementConstructors(a.component, b.component)) {\n\t\t\treturn false\n\t\t}\n\t} else if (a.component !== b.component) {\n\t\treturn false\n\t}\n\n\t// Compare state\n\tif (JSON.stringify(a.state || {}) !== JSON.stringify(b.state || {})) {\n\t\treturn false\n\t}\n\n\t// Compare params\n\tif (JSON.stringify(a.params || {}) !== JSON.stringify(b.params || {})) {\n\t\treturn false\n\t}\n\n\treturn true\n}\n\n/**\n * Compare two active routes for equality\n * @param a First active route\n * @param b Second active route\n * @returns true if active routes are equal\n */\nexport function compareActiveRoutes(a: ActiveRoute, b: ActiveRoute): boolean {\n\treturn (\n\t\ta.area === b.area &&\n\t\ta.component === b.component &&\n\t\tJSON.stringify(a.state || {}) === JSON.stringify(b.state || {}) &&\n\t\tJSON.stringify(a.params || {}) === JSON.stringify(b.params || {})\n\t)\n}\n\n/**\n * Create a cache key from a route action\n * @param route Route action\n * @returns Cache key string\n */\nexport function createRouteCacheKey(route: RouteAction): string {\n\tconst tagName = getTagName(route.component) || 'unknown'\n\tconst stateHash = simpleHash(JSON.stringify(route.state || {}))\n\tconst paramsHash = simpleHash(JSON.stringify(route.params || {}))\n\n\treturn `${route.area}:${tagName}:${stateHash}:${paramsHash}`\n}\n\n/**\n * Simple hash function for creating cache keys\n * @param str String to hash\n * @returns Hash string\n */\nfunction simpleHash(str: string): string {\n\tlet hash = 0\n\n\tfor (let i = 0; i < str.length; i++) {\n\t\tconst char = str.charCodeAt(i)\n\t\thash = (hash << 5) - hash + char\n\t\thash = hash & hash // Convert to 32-bit integer\n\t}\n\n\treturn Math.abs(hash).toString(36)\n}\n\n/**\n * Sanitize route state to remove sensitive data\n * @param state Route state\n * @param keysToRemove Keys to remove from state\n * @returns Sanitized state\n */\nexport function sanitizeRouteState(\n\tstate: Record<string, unknown>,\n\tkeysToRemove: string[] = ['password', 'token', 'secret', 'apiKey'],\n): Record<string, unknown> {\n\tconst sanitized: Record<string, unknown> = {}\n\n\tfor (const key in state) {\n\t\tif (state.hasOwnProperty(key) && !keysToRemove.includes(key)) {\n\t\t\tconst value = state[key]\n\n\t\t\tif (isObject(value)) {\n\t\t\t\tsanitized[key] = sanitizeRouteState(value, keysToRemove)\n\t\t\t} else if (Array.isArray(value)) {\n\t\t\t\tsanitized[key] = value.map(item => (isObject(item) ? sanitizeRouteState(item, keysToRemove) : item))\n\t\t\t} else {\n\t\t\t\tsanitized[key] = value\n\t\t\t}\n\t\t}\n\t}\n\n\treturn sanitized\n}\n\n/**\n * Extract query parameters from URL\n * @param url URL string or URLSearchParams\n * @returns Object with query parameters\n */\nexport function extractQueryParams(url?: string | URLSearchParams): Record<string, string> {\n\tconst params: Record<string, string> = {}\n\n\tlet searchParams: URLSearchParams\n\n\tif (url instanceof URLSearchParams) {\n\t\tsearchParams = url\n\t} else if (typeof url === 'string') {\n\t\tconst urlObj = new URL(url, window.location.origin)\n\t\tsearchParams = urlObj.searchParams\n\t} else {\n\t\tsearchParams = new URLSearchParams(window.location.search)\n\t}\n\n\tsearchParams.forEach((value, key) => {\n\t\tparams[key] = value\n\t})\n\n\treturn params\n}\n\n/**\n * Build query string from parameters object\n * @param params Parameters object\n * @returns Query string with leading '?'\n */\nexport function buildQueryString(params: Record<string, string | number | boolean>): string {\n\tconst searchParams = new URLSearchParams()\n\n\tfor (const key in params) {\n\t\tif (params.hasOwnProperty(key)) {\n\t\t\tconst value = params[key]\n\t\t\tif (value !== undefined && value !== null && value !== '') {\n\t\t\t\tsearchParams.set(key, String(value))\n\t\t\t}\n\t\t}\n\t}\n\n\tconst queryString = searchParams.toString()\n\treturn queryString ? `?${queryString}` : ''\n}\n","/**\r\n * Lazy loading for Schmancy Area components\r\n * Similar to React.lazy() but adapted for Web Components\r\n */\r\n\r\n// Type definition for custom element constructors\r\ntype CustomElementConstructor = typeof HTMLElement\r\n\r\n/**\r\n * LazyComponent interface with preload capability\r\n */\r\nexport interface LazyComponent<T extends CustomElementConstructor = CustomElementConstructor> {\r\n (): Promise<{ default: T }>\r\n preload(): Promise<void>\r\n _promise?: Promise<{ default: T }>\r\n _module?: { default: T }\r\n}\r\n\r\n/**\r\n * Create a lazy-loaded component that will be imported on demand\r\n *\r\n * @example\r\n * ```typescript\r\n * const LazyProfile = lazy(() => import('./profile'))\r\n *\r\n * // Use with area.push\r\n * area.push({\r\n * component: LazyProfile,\r\n * area: 'main'\r\n * })\r\n *\r\n * // Preload on hover\r\n * element.addEventListener('mouseenter', () => LazyProfile.preload())\r\n * ```\r\n *\r\n * @param loader - Dynamic import function that returns a module with default export\r\n * @returns LazyComponent function compatible with area.push()\r\n */\r\nexport function lazy<T extends CustomElementConstructor>(\r\n loader: () => Promise<{ default: T }>\r\n): LazyComponent<T> {\r\n\r\n // Create the lazy component function\r\n const lazyComponent = function(): Promise<{ default: T }> {\r\n // Return cached promise if already loading/loaded\r\n if (lazyComponent._promise) {\r\n return lazyComponent._promise\r\n }\r\n\r\n // Return cached module if already loaded\r\n if (lazyComponent._module) {\r\n return Promise.resolve(lazyComponent._module)\r\n }\r\n\r\n // Start loading and cache the promise\r\n lazyComponent._promise = loader()\r\n .then(module => {\r\n // Cache the loaded module\r\n lazyComponent._module = module\r\n return module\r\n })\r\n .catch(error => {\r\n // Clear promise on error to allow retry\r\n lazyComponent._promise = undefined\r\n throw error\r\n })\r\n\r\n return lazyComponent._promise\r\n } as LazyComponent<T>\r\n\r\n // Add preload method for manual preloading\r\n lazyComponent.preload = async function(): Promise<void> {\r\n try {\r\n await lazyComponent()\r\n } catch (error) {\r\n console.error('Failed to preload component:', error)\r\n }\r\n }\r\n\r\n return lazyComponent\r\n}\r\n\r\n\r\n"],"names":["compareCustomElementConstructors","constructor1","constructor2","name","obs1","observedAttributes","obs2","Array","isArray","length","every","attr","i","proto1","prototype","proto2","Object","getPrototypeOf","keys1","getOwnPropertyNames","sort","keys2","key","normalizeTagName","tagName","toLowerCase","replace","getTagName","component","HTMLElement","isObject","obj","constructor","toString","call","simpleHash","str","hash","charCodeAt","Math","abs","params","searchParams","URLSearchParams","hasOwnProperty","value","set","String","queryString","a","b","area","JSON","stringify","state","route","stateHash","paramsHash","func","wait","timeout","args","context","this","clearTimeout","setTimeout","apply","encoded","decoded","decodeURIComponent","parsed","parse","error","deepMerge","target","source","output","sourceValue","targetValue","json","encodeURIComponent","url","URL","window","location","origin","search","forEach","loader","lazyComponent","_promise","_module","Promise","resolve","then","module","catch","preload","async","sanitizeRouteState","keysToRemove","sanitized","includes","map","item"],"mappings":"aASO,SAASA,EACfC,EACAC,EAAAA,CAGA,GAAID,IAAiBC,EACpB,MAAA,GAID,UAAWD,GAAiB,YAAsC,OAAjBC,GAAiB,WACjE,MAAA,GAID,GAAID,EAAaE,MAAQD,EAAaC,MAAQF,EAAaE,OAASD,EAAaC,KAChF,MAAA,GAID,MAAMC,EAAQH,EAAqBI,mBAC7BC,EAAQJ,EAAqBG,mBAEnC,GAAID,GAAQE,GACPC,MAAMC,QAAQJ,CAAAA,GAASG,MAAMC,QAAQF,CAAAA,EACxC,OAAIF,EAAKK,SAAWH,EAAKG,QAClBL,EAAKM,MAAM,CAACC,EAAMC,IAAMD,IAASL,EAAKM,CAAAA,CAAAA,EAK/C,IACC,MAAMC,EAASZ,EAAaa,UACtBC,EAASb,EAAaY,UAG5B,GAAIE,OAAOC,eAAeJ,KAAYG,OAAOC,eAAeF,GAAS,CAEpE,MAAMG,EAAQF,OAAOG,oBAAoBN,CAAAA,EAAQO,KAAAA,EAC3CC,EAAQL,OAAOG,oBAAoBJ,GAAQK,KAAAA,EAEjD,OAAOF,EAAMT,SA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,EAGRJ,CACR,uDCtSO,SACL+C,EAAAA,CAIA,MAAMC,EAAgB,UAAA,CAEpB,OAAIA,EAAcC,SACTD,EAAcC,SAInBD,EAAcE,QACTC,QAAQC,QAAQJ,EAAcE,OAAAA,GAIvCF,EAAcC,SAAWF,EAAAA,EACtBM,KAAKC,IAEJN,EAAcE,QAAUI,EACjBA,EAAAA,EAERC,MAAMxB,GAAAA,CAGL,MADAiB,EAAcC,SAAAA,OACRlB,CAAAA,CAAAA,EAGHiB,EAAcC,SACvB,EAWA,OARAD,EAAcQ,QAAUC,iBACtB,GAAA,CAAA,MACQT,EAAAA,CACR,MAASjB,CAET,CACF,EAEOiB,CACT,wDD6MO,SAASU,EACf7C,EACA8C,EAAyB,CAAC,WAAY,QAAS,SAAU,QAAA,EAAA,CAEzD,MAAMC,EAAqC,CAAA,EAE3C,UAAW/E,KAAOgC,EACjB,GAAIA,EAAMV,eAAetB,CAAAA,GAAAA,CAAS8E,EAAaE,SAAShF,CAAAA,EAAM,CAC7D,MAAMuB,EAAQS,EAAMhC,CAAAA,EAEhBQ,EAASe,CAAAA,EACZwD,EAAU/E,GAAO6E,EAAmBtD,EAAOuD,CAAAA,EACjC7F,MAAMC,QAAQqC,CAAAA,EACxBwD,EAAU/E,GAAOuB,EAAM0D,IAAIC,GAAS1E,EAAS0E,CAAAA,EAAQL,EAAmBK,EAAMJ,GAAgBI,CAAAA,EAE9FH,EAAU/E,GAAOuB,CAEnB,CAGD,OAAOwD,CACR"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lazy-E2LCDm7n.js","sources":["../src/area/utils.ts","../src/area/lazy.ts"],"sourcesContent":["import { ComponentType } from './area.component'\nimport { RouteAction, ActiveRoute } from './router.types'\n\n/**\n * Compare two custom element constructors for equality\n * @param constructor1 First constructor to compare\n * @param constructor2 Second constructor to compare\n * @returns true if constructors are functionally equivalent\n */\nexport function compareCustomElementConstructors(\n\tconstructor1: CustomElementConstructor | Function,\n\tconstructor2: CustomElementConstructor | Function,\n): boolean {\n\t// Quick reference check\n\tif (constructor1 === constructor2) {\n\t\treturn true\n\t}\n\n\t// Check if both are functions\n\tif (typeof constructor1 !== 'function' || typeof constructor2 !== 'function') {\n\t\treturn false\n\t}\n\n\t// Compare by name (handles minification)\n\tif (constructor1.name && constructor2.name && constructor1.name === constructor2.name) {\n\t\treturn true\n\t}\n\n\t// Compare observed attributes if available\n\tconst obs1 = (constructor1 as any).observedAttributes\n\tconst obs2 = (constructor2 as any).observedAttributes\n\n\tif (obs1 && obs2) {\n\t\tif (Array.isArray(obs1) && Array.isArray(obs2)) {\n\t\t\tif (obs1.length !== obs2.length) return false\n\t\t\treturn obs1.every((attr, i) => attr === obs2[i])\n\t\t}\n\t}\n\n\t// Try to compare prototypes\n\ttry {\n\t\tconst proto1 = constructor1.prototype\n\t\tconst proto2 = constructor2.prototype\n\n\t\t// Check if they have the same prototype chain\n\t\tif (Object.getPrototypeOf(proto1) === Object.getPrototypeOf(proto2)) {\n\t\t\t// Check if they have the same property names\n\t\t\tconst keys1 = Object.getOwnPropertyNames(proto1).sort()\n\t\t\tconst keys2 = Object.getOwnPropertyNames(proto2).sort()\n\n\t\t\treturn keys1.length === keys2.length && keys1.every((key, i) => key === keys2[i])\n\t\t}\n\t} catch {\n\t\t// Ignore prototype access errors\n\t}\n\n\treturn false\n}\n\n/**\n * Normalize a component tag name for comparison\n * @param tagName Tag name to normalize\n * @returns Normalized tag name\n */\nexport function normalizeTagName(tagName: string): string {\n\treturn tagName.toLowerCase().replace(/[^a-z0-9]/g, '') // Remove all non-alphanumeric characters\n}\n\n/**\n * Get tag name from a component\n * @param component Component to get tag name from\n * @returns Tag name or null if unable to determine\n */\nexport function getTagName(component: ComponentType): string | null {\n\tif (typeof component === 'string') {\n\t\treturn component.toLowerCase()\n\t}\n\n\tif (component instanceof HTMLElement) {\n\t\treturn component.tagName.toLowerCase()\n\t}\n\n\tif (typeof component === 'function') {\n\t\t// Try to get custom element name from constructor\n\t\tconst name = component.name\n\t\tif (name) {\n\t\t\t// Convert PascalCase to kebab-case\n\t\t\treturn name\n\t\t\t\t.replace(/([A-Z])/g, '-$1')\n\t\t\t\t.toLowerCase()\n\t\t\t\t.replace(/^-/, '')\n\t\t}\n\t}\n\n\treturn null\n}\n\n/**\n * Deep merge two objects\n * @param target Target object\n * @param source Source object to merge\n * @returns Merged object\n */\nexport function deepMerge<T extends Record<string, any>>(target: T, source: Partial<T>): T {\n\tconst output = { ...target }\n\n\tfor (const key in source) {\n\t\tif (source.hasOwnProperty(key)) {\n\t\t\tconst sourceValue = source[key]\n\t\t\tconst targetValue = output[key]\n\n\t\t\tif (isObject(sourceValue) && isObject(targetValue)) {\n\t\t\t\toutput[key] = deepMerge(targetValue, sourceValue)\n\t\t\t} else {\n\t\t\t\toutput[key] = sourceValue as T[Extract<keyof T, string>]\n\t\t\t}\n\t\t}\n\t}\n\n\treturn output\n}\n\n/**\n * Check if value is a plain object\n * @param obj Value to check\n * @returns true if value is a plain object\n */\nexport function isObject(obj: any): obj is Record<string, any> {\n\treturn (\n\t\tobj !== null &&\n\t\ttypeof obj === 'object' &&\n\t\tobj.constructor === Object &&\n\t\tObject.prototype.toString.call(obj) === '[object Object]'\n\t)\n}\n\n/**\n * Debounce a function\n * @param func Function to debounce\n * @param wait Wait time in milliseconds\n * @returns Debounced function\n */\nexport function debounce<T extends (...args: any[]) => any>(func: T, wait: number): (...args: Parameters<T>) => void {\n\tlet timeout: ReturnType<typeof setTimeout> | null = null\n\n\treturn function (this: any, ...args: Parameters<T>) {\n\t\tconst context = this\n\n\t\tif (timeout !== null) {\n\t\t\tclearTimeout(timeout)\n\t\t}\n\n\t\ttimeout = setTimeout(() => {\n\t\t\tfunc.apply(context, args)\n\t\t\ttimeout = null\n\t\t}, wait)\n\t}\n}\n\n/**\n * Create a URL-safe string from route state\n * @param state Route state object\n * @returns URL-safe encoded string\n */\nexport function encodeRouteState(state: Record<string, unknown>): string {\n\ttry {\n\t\tconst json = JSON.stringify(state)\n\t\treturn encodeURIComponent(json)\n\t} catch (error) {\n\t\tconsole.error('Failed to encode route state:', error)\n\t\treturn ''\n\t}\n}\n\n/**\n * Decode a URL-safe string to route state\n * @param encoded Encoded string\n * @returns Decoded route state or empty object\n */\nexport function decodeRouteState(encoded: string): Record<string, unknown> {\n\tif (!encoded) return {}\n\n\ttry {\n\t\tconst decoded = decodeURIComponent(encoded)\n\t\tconst parsed = JSON.parse(decoded)\n\n\t\tif (isObject(parsed)) {\n\t\t\treturn parsed\n\t\t}\n\t} catch (error) {\n\t\tconsole.error('Failed to decode route state:', error)\n\t}\n\n\treturn {}\n}\n\n/**\n * Compare two route actions for equality\n * @param a First route action\n * @param b Second route action\n * @returns true if route actions are equal\n */\nexport function compareRouteActions(a: RouteAction, b: RouteAction): boolean {\n\t// Compare areas\n\tif (a.area !== b.area) return false\n\n\t// Compare components\n\tif (typeof a.component !== typeof b.component) return false\n\n\tif (typeof a.component === 'string' && typeof b.component === 'string') {\n\t\tif (normalizeTagName(a.component) !== normalizeTagName(b.component)) {\n\t\t\treturn false\n\t\t}\n\t} else if (typeof a.component === 'function' && typeof b.component === 'function') {\n\t\tif (!compareCustomElementConstructors(a.component, b.component)) {\n\t\t\treturn false\n\t\t}\n\t} else if (a.component !== b.component) {\n\t\treturn false\n\t}\n\n\t// Compare state\n\tif (JSON.stringify(a.state || {}) !== JSON.stringify(b.state || {})) {\n\t\treturn false\n\t}\n\n\t// Compare params\n\tif (JSON.stringify(a.params || {}) !== JSON.stringify(b.params || {})) {\n\t\treturn false\n\t}\n\n\treturn true\n}\n\n/**\n * Compare two active routes for equality\n * @param a First active route\n * @param b Second active route\n * @returns true if active routes are equal\n */\nexport function compareActiveRoutes(a: ActiveRoute, b: ActiveRoute): boolean {\n\treturn (\n\t\ta.area === b.area &&\n\t\ta.component === b.component &&\n\t\tJSON.stringify(a.state || {}) === JSON.stringify(b.state || {}) &&\n\t\tJSON.stringify(a.params || {}) === JSON.stringify(b.params || {})\n\t)\n}\n\n/**\n * Create a cache key from a route action\n * @param route Route action\n * @returns Cache key string\n */\nexport function createRouteCacheKey(route: RouteAction): string {\n\tconst tagName = getTagName(route.component) || 'unknown'\n\tconst stateHash = simpleHash(JSON.stringify(route.state || {}))\n\tconst paramsHash = simpleHash(JSON.stringify(route.params || {}))\n\n\treturn `${route.area}:${tagName}:${stateHash}:${paramsHash}`\n}\n\n/**\n * Simple hash function for creating cache keys\n * @param str String to hash\n * @returns Hash string\n */\nfunction simpleHash(str: string): string {\n\tlet hash = 0\n\n\tfor (let i = 0; i < str.length; i++) {\n\t\tconst char = str.charCodeAt(i)\n\t\thash = (hash << 5) - hash + char\n\t\thash = hash & hash // Convert to 32-bit integer\n\t}\n\n\treturn Math.abs(hash).toString(36)\n}\n\n/**\n * Sanitize route state to remove sensitive data\n * @param state Route state\n * @param keysToRemove Keys to remove from state\n * @returns Sanitized state\n */\nexport function sanitizeRouteState(\n\tstate: Record<string, unknown>,\n\tkeysToRemove: string[] = ['password', 'token', 'secret', 'apiKey'],\n): Record<string, unknown> {\n\tconst sanitized: Record<string, unknown> = {}\n\n\tfor (const key in state) {\n\t\tif (state.hasOwnProperty(key) && !keysToRemove.includes(key)) {\n\t\t\tconst value = state[key]\n\n\t\t\tif (isObject(value)) {\n\t\t\t\tsanitized[key] = sanitizeRouteState(value, keysToRemove)\n\t\t\t} else if (Array.isArray(value)) {\n\t\t\t\tsanitized[key] = value.map(item => (isObject(item) ? sanitizeRouteState(item, keysToRemove) : item))\n\t\t\t} else {\n\t\t\t\tsanitized[key] = value\n\t\t\t}\n\t\t}\n\t}\n\n\treturn sanitized\n}\n\n/**\n * Extract query parameters from URL\n * @param url URL string or URLSearchParams\n * @returns Object with query parameters\n */\nexport function extractQueryParams(url?: string | URLSearchParams): Record<string, string> {\n\tconst params: Record<string, string> = {}\n\n\tlet searchParams: URLSearchParams\n\n\tif (url instanceof URLSearchParams) {\n\t\tsearchParams = url\n\t} else if (typeof url === 'string') {\n\t\tconst urlObj = new URL(url, window.location.origin)\n\t\tsearchParams = urlObj.searchParams\n\t} else {\n\t\tsearchParams = new URLSearchParams(window.location.search)\n\t}\n\n\tsearchParams.forEach((value, key) => {\n\t\tparams[key] = value\n\t})\n\n\treturn params\n}\n\n/**\n * Build query string from parameters object\n * @param params Parameters object\n * @returns Query string with leading '?'\n */\nexport function buildQueryString(params: Record<string, string | number | boolean>): string {\n\tconst searchParams = new URLSearchParams()\n\n\tfor (const key in params) {\n\t\tif (params.hasOwnProperty(key)) {\n\t\t\tconst value = params[key]\n\t\t\tif (value !== undefined && value !== null && value !== '') {\n\t\t\t\tsearchParams.set(key, String(value))\n\t\t\t}\n\t\t}\n\t}\n\n\tconst queryString = searchParams.toString()\n\treturn queryString ? `?${queryString}` : ''\n}\n","/**\r\n * Lazy loading for Schmancy Area components\r\n * Similar to React.lazy() but adapted for Web Components\r\n */\r\n\r\n// Type definition for custom element constructors\r\ntype CustomElementConstructor = typeof HTMLElement\r\n\r\n/**\r\n * LazyComponent interface with preload capability\r\n */\r\nexport interface LazyComponent<T extends CustomElementConstructor = CustomElementConstructor> {\r\n (): Promise<{ default: T }>\r\n preload(): Promise<void>\r\n _promise?: Promise<{ default: T }>\r\n _module?: { default: T }\r\n}\r\n\r\n/**\r\n * Create a lazy-loaded component that will be imported on demand\r\n *\r\n * @example\r\n * ```typescript\r\n * const LazyProfile = lazy(() => import('./profile'))\r\n *\r\n * // Use with area.push\r\n * area.push({\r\n * component: LazyProfile,\r\n * area: 'main'\r\n * })\r\n *\r\n * // Preload on hover\r\n * element.addEventListener('mouseenter', () => LazyProfile.preload())\r\n * ```\r\n *\r\n * @param loader - Dynamic import function that returns a module with default export\r\n * @returns LazyComponent function compatible with area.push()\r\n */\r\nexport function lazy<T extends CustomElementConstructor>(\r\n loader: () => Promise<{ default: T }>\r\n): LazyComponent<T> {\r\n\r\n // Create the lazy component function\r\n const lazyComponent = function(): Promise<{ default: T }> {\r\n // Return cached promise if already loading/loaded\r\n if (lazyComponent._promise) {\r\n return lazyComponent._promise\r\n }\r\n\r\n // Return cached module if already loaded\r\n if (lazyComponent._module) {\r\n return Promise.resolve(lazyComponent._module)\r\n }\r\n\r\n // Start loading and cache the promise\r\n lazyComponent._promise = loader()\r\n .then(module => {\r\n // Cache the loaded module\r\n lazyComponent._module = module\r\n return module\r\n })\r\n .catch(error => {\r\n // Clear promise on error to allow retry\r\n lazyComponent._promise = undefined\r\n throw error\r\n })\r\n\r\n return lazyComponent._promise\r\n } as LazyComponent<T>\r\n\r\n // Add preload method for manual preloading\r\n lazyComponent.preload = async function(): Promise<void> {\r\n try {\r\n await lazyComponent()\r\n } catch (error) {\r\n console.error('Failed to preload component:', error)\r\n }\r\n }\r\n\r\n return lazyComponent\r\n}\r\n\r\n\r\n"],"names":["compareCustomElementConstructors","constructor1","constructor2","name","obs1","observedAttributes","obs2","Array","isArray","length","every","attr","i","proto1","prototype","proto2","Object","getPrototypeOf","keys1","getOwnPropertyNames","sort","keys2","key","normalizeTagName","tagName","toLowerCase","replace","getTagName","component","HTMLElement","deepMerge","target","source","output","hasOwnProperty","sourceValue","targetValue","isObject","obj","constructor","toString","call","debounce","func","wait","timeout","args","context","this","clearTimeout","setTimeout","apply","encodeRouteState","state","json","JSON","stringify","encodeURIComponent","error","decodeRouteState","encoded","decoded","decodeURIComponent","parsed","parse","compareRouteActions","a","b","area","params","compareActiveRoutes","createRouteCacheKey","route","stateHash","simpleHash","paramsHash","str","hash","charCodeAt","Math","abs","sanitizeRouteState","keysToRemove","sanitized","includes","value","map","item","extractQueryParams","url","searchParams","URLSearchParams","URL","window","location","origin","search","forEach","buildQueryString","set","String","queryString","lazy","loader","lazyComponent","_promise","_module","Promise","resolve","then","module","catch","preload","async"],"mappings":"AASO,SAASA,EACfC,GACAC,GAAAA;AAGA,MAAID,MAAiBC,EACpB,QAAA;AAID,MAA4B,OAAjBD,KAAiB,cAAsC,OAAjBC,KAAiB,WACjE;AAID,MAAID,EAAaE,QAAQD,EAAaC,QAAQF,EAAa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