vibe64 0.1.48 → 0.1.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/bin/run.js +1746 -1725
  2. package/bin/server.js +75 -75
  3. package/bin/upgrade-state.js +4275 -4254
  4. package/dist/assets/GithubBrowserTabs-BwpiRS2u.js +1 -0
  5. package/dist/assets/{LocalDatabaseServer-ih_gadbx.js → LocalDatabaseServer-u_Ky7bNS.js} +1 -1
  6. package/dist/assets/{Vibe64AuthSettingsButton-BZsCIA2Z.js → Vibe64AuthSettingsButton-BCwswT1G.js} +1 -1
  7. package/dist/assets/{Vibe64DashboardShell-DFE-2tFZ.js → Vibe64DashboardShell-CWlgrR2B.js} +1 -1
  8. package/dist/assets/{Vibe64DatabaseWorkspace-BdvxuFPT.js → Vibe64DatabaseWorkspace-Dhs8_H0P.js} +1 -1
  9. package/dist/assets/Vibe64OutputControls-Dn548CZa.js +8 -0
  10. package/dist/assets/{Vibe64RepositoryWorkspace-CVN2HKCB.js → Vibe64RepositoryWorkspace-C-8S4JUF.js} +1 -1
  11. package/dist/assets/{Vibe64SessionFiles-DKo5wd8-.js → Vibe64SessionFiles-Cx6J7DDN.js} +1 -1
  12. package/dist/assets/{Vibe64UiStoryboardView-BYqVdBAt.js → Vibe64UiStoryboardView-DHyhJiWS.js} +1 -1
  13. package/dist/assets/{Vibe64UnavailableSessions-CQjgoaS0.js → Vibe64UnavailableSessions-Da4RxIhA.js} +1 -1
  14. package/dist/assets/{_sessionId_-ByUkrRd7.js → _sessionId_-DCpgDPSI.js} +1 -1
  15. package/dist/assets/_slug_-BbEWp01a.js +25 -0
  16. package/dist/assets/{_slug_-B16mTWjj.css → _slug_-DerKOisL.css} +1 -1
  17. package/dist/assets/{access-CWZMu-ND.js → access-D4di2sCr.js} +1 -1
  18. package/dist/assets/{app-D_itm2S5.js → app-Adr9Iz8p.js} +1 -1
  19. package/dist/assets/{changes-BYuFfnEm.js → changes-3Dd1O8Lu.js} +1 -1
  20. package/dist/assets/{client-CP2EwnrY.js → client-BAXHGUOC.js} +1 -1
  21. package/dist/assets/{client-B88Jggew.js → client-CCZIu6yc.js} +1 -1
  22. package/dist/assets/{conversation-DL4AODd9.js → conversation-ErAO1CmH.js} +1 -1
  23. package/dist/assets/{dashboard-R4qgYv8O.js → dashboard-0tCzDYCX.js} +1 -1
  24. package/dist/assets/{english-definitions-CdIGswXU.js → english-definitions-DeiQ-jTT.js} +1 -1
  25. package/dist/assets/env-DsyQ2MFX.js +1 -0
  26. package/dist/assets/{health-Ut9eZrbK.js → health-DyTXU-nb.js} +1 -1
  27. package/dist/assets/{history-BrmvkGgi.js → history-BXGAdPMI.js} +1 -1
  28. package/dist/assets/{incoming-CicEs40v.js → incoming-yajkdGBY.js} +1 -1
  29. package/dist/assets/{index-DZgCwvFD.js → index-CGz4Yow6.js} +4 -4
  30. package/dist/assets/{integrations-QHeHC-C9.js → integrations-BMrXET36.js} +1 -1
  31. package/dist/assets/{issues-Ds7iAQFQ.js → issues-kc1XBZCK.js} +1 -1
  32. package/dist/assets/{learning-Dq0xbg3x.js → learning-CIE5ghYv.js} +1 -1
  33. package/dist/assets/publish-DTh6amqi.js +3 -0
  34. package/dist/assets/{pull-requests-DHLK83qZ.js → pull-requests-CbfGSSIh.js} +1 -1
  35. package/dist/assets/{repository-DWw1VFIQ.js → repository-BstMh-bG.js} +1 -1
  36. package/dist/assets/settings-Bf8C6dls.js +1 -0
  37. package/dist/assets/useArchivedVibe64Sessions-DIOpfUxD.js +1 -0
  38. package/dist/assets/{useCommand-DhwB5k1w.js → useCommand-CVuya6vG.js} +1 -1
  39. package/dist/assets/{useEndpointResource-tVvsJvd4.js → useEndpointResource-7-YDfAxX.js} +1 -1
  40. package/dist/assets/{useUiFeedback-DLUToc5y.js → useUiFeedback-Bd3rao6E.js} +1 -1
  41. package/dist/assets/useVibe64ConversationLog-ChJOU2SD.js +1 -0
  42. package/dist/assets/{useVibe64DatabaseTools-Cac_aZnv.js → useVibe64DatabaseTools-DKV-TeNJ.js} +1 -1
  43. package/dist/assets/useVibe64SessionData-BkIHUrP5.js +1 -0
  44. package/dist/assets/useVibe64SessionSelection-N8wX5oqo.js +1 -0
  45. package/dist/assets/{useVibe64SystemGraph-idV9zXa9.js → useVibe64SystemGraph-Db_eD-X8.js} +1 -1
  46. package/dist/assets/vibe64RepositoryRealtime-CHT4-6VN.js +1 -0
  47. package/dist/assets/vibe64SessionFocus-CS6Ex53G.js +1 -0
  48. package/dist/assets/vibe64SessionFocus-CSm4YJQD.css +1 -0
  49. package/dist/assets/vibe64SessionRequestConfig-xIx-5jxQ.js +1 -0
  50. package/dist/index.html +10 -9
  51. package/docs/colleague-usage/ai-accounts.md +6 -2
  52. package/docs/colleague-usage/ai-balance-and-allowance.md +15 -2
  53. package/docs/colleague-usage/coding-agent-failures.md +2 -1
  54. package/docs/colleague-usage/coding-agent-goals.md +8 -3
  55. package/docs/colleague-usage/coding-agents.md +16 -0
  56. package/docs/colleague-usage/github-work.md +14 -0
  57. package/docs/colleague-usage/project-setup.md +6 -3
  58. package/docs/colleague-usage/running-vibe64-on-your-computer.md +3 -1
  59. package/docs/colleague-usage/sessions.md +35 -7
  60. package/docs/colleague-usage/starter-apps.md +3 -0
  61. package/docs/colleague-usage/temporary-chat-context.md +2 -1
  62. package/docs/colleague-usage/temporary-chats.md +17 -5
  63. package/node_modules/@jskit-ai/assistant-core/package.json +1 -1
  64. package/node_modules/@jskit-ai/assistant-runtime/README.md +2 -1
  65. package/node_modules/@jskit-ai/assistant-runtime/locales/en.json +2 -1
  66. package/node_modules/@jskit-ai/assistant-runtime/package.json +1 -1
  67. package/node_modules/@jskit-ai/assistant-voice/package.json +1 -1
  68. package/node_modules/@local/vibe64-execution/src/host/execHelper.js +34 -34
  69. package/node_modules/@local/vibe64-execution/src/server/gitTurnCheckpointCommand.js +1327 -0
  70. package/node_modules/@local/vibe64-genesis/bin/vibe64-genesis-host-context +120 -120
  71. package/node_modules/@local/vibe64-runtime/src/server/codexAppServerProcess.js +143 -143
  72. package/node_modules/@local/vibe64-sessions/package.json +2 -1
  73. package/node_modules/@local/vibe64-terminals/src/server/sessionWorkOperationCommand.js +1385 -1362
  74. package/package.json +5 -5
  75. package/server.bundle.mjs +38576 -38459
  76. package/dist/assets/GithubBrowserTabs-_l6htLOV.js +0 -1
  77. package/dist/assets/Vibe64OutputControls-DsCbasR0.js +0 -8
  78. package/dist/assets/_slug_-hep_be7Z.js +0 -24
  79. package/dist/assets/env-DtkytCtq.js +0 -1
  80. package/dist/assets/publish-eErG67LW.js +0 -3
  81. package/dist/assets/settings-QkwnoNn3.js +0 -1
  82. package/dist/assets/useArchivedVibe64Sessions-Biy_4sxD.js +0 -1
  83. package/dist/assets/useVibe64ConversationLog-jM3KOvN7.js +0 -1
  84. package/dist/assets/useVibe64SessionData-FGnNvFfK.js +0 -1
  85. package/dist/assets/useVibe64SessionSelection-Bgsif-tm.js +0 -1
  86. package/dist/assets/vibe64RepositoryRealtime-C-J0I5jY.js +0 -1
  87. package/dist/assets/vibe64SessionFocus-CDIB5Gpr.js +0 -1
  88. package/dist/assets/vibe64SessionFocus-DSW5Irm6.css +0 -1
@@ -1 +1 @@
1
- import{E as AUTH_POLICY_PUBLIC,T as AUTH_POLICY_AUTHENTICATED,k as setJskitI18n}from"./useEndpointResource-tVvsJvd4.js";import{i as createSurfaceRegistry,n as createSurfacePathHelpers,o as normalizeSurfaceId}from"./returnToPath-gKtcu91D.js";import{a as normalizeBoolean,c as normalizeLowerText,f as normalizeText,l as normalizeObject,m as normalizeUniqueTextList,n as hasValue,r as isRecord,u as normalizePositiveInteger}from"./normalize-BNAdWJYg.js";import{t as isExternalLinkTarget}from"./linkPath-Ch9eft18.js";import"./asyncModuleRecovery-DJsn5NrL.js";var MOBILE_ASSET_MODES=Object.freeze([`bundled`,`dev_server`]);var MOBILE_STRATEGIES=Object.freeze([`capacitor`]);var DEFAULT_MOBILE_AUTH_CONFIG=Object.freeze({callbackPath:`/auth/login`,customScheme:``,appLinkDomains:Object.freeze([])});var DEFAULT_MOBILE_ANDROID_CONFIG=Object.freeze({packageName:``,minSdk:26,targetSdk:35,versionCode:1,versionName:`1.0.0`});function normalizeMobileStrategy(value=``,{fallback=``}={}){const normalized=normalizeLowerText(value);return MOBILE_STRATEGIES.includes(normalized)?normalized:normalizeLowerText(fallback)}function normalizeMobileAssetMode(value=``,{fallback=`bundled`}={}){const normalized=normalizeLowerText(value);if(!normalized)return normalizeLowerText(fallback,{fallback:`bundled`});if(!MOBILE_ASSET_MODES.includes(normalized))throw new TypeError(`config.mobile.assetMode must be "bundled" or "dev_server".`);return normalized}function normalizeMobileCallbackPath(value=``,{fallback=`/auth/login`}={}){const normalized=normalizeText(value,{fallback});if(!normalized)return``;return normalized.startsWith(`/`)?normalized:`/${normalized}`}function normalizeMobileConfig(source={}){const mobile=normalizeObject(source);const auth=normalizeObject(mobile.auth);const android=normalizeObject(mobile.android);return Object.freeze({enabled:hasValue(mobile.enabled)?normalizeBoolean(mobile.enabled):false,strategy:normalizeMobileStrategy(mobile.strategy),appId:normalizeText(mobile.appId),appName:normalizeText(mobile.appName),assetMode:normalizeMobileAssetMode(mobile.assetMode),devServerUrl:normalizeText(mobile.devServerUrl),apiBaseUrl:normalizeText(mobile.apiBaseUrl),auth:Object.freeze({callbackPath:normalizeMobileCallbackPath(auth.callbackPath,{fallback:DEFAULT_MOBILE_AUTH_CONFIG.callbackPath}),customScheme:normalizeLowerText(auth.customScheme),appLinkDomains:Object.freeze([...new Set(normalizeUniqueTextList(auth.appLinkDomains,{acceptSingle:true}).map(entry=>normalizeLowerText(entry)))])}),android:Object.freeze({packageName:normalizeText(android.packageName),minSdk:normalizePositiveInteger(android.minSdk,{fallback:DEFAULT_MOBILE_ANDROID_CONFIG.minSdk}),targetSdk:normalizePositiveInteger(android.targetSdk,{fallback:DEFAULT_MOBILE_ANDROID_CONFIG.targetSdk}),versionCode:normalizePositiveInteger(android.versionCode,{fallback:DEFAULT_MOBILE_ANDROID_CONFIG.versionCode}),versionName:normalizeText(android.versionName,{fallback:DEFAULT_MOBILE_ANDROID_CONFIG.versionName})})})}var CLIENT_APP_CONFIG_GLOBAL_KEY=`__JSKIT_CLIENT_APP_CONFIG__`;var EMPTY_CLIENT_APP_CONFIG=Object.freeze({});function normalizeClientAppConfig(source={}){if(!isRecord(source))return EMPTY_CLIENT_APP_CONFIG;return Object.freeze({...source})}function setClientAppConfig(source={}){const appConfig=normalizeClientAppConfig(source);if(typeof globalThis===`object`&&globalThis)globalThis[CLIENT_APP_CONFIG_GLOBAL_KEY]=appConfig;return appConfig}function getClientAppConfig(){if(typeof globalThis!==`object`||!globalThis)return EMPTY_CLIENT_APP_CONFIG;const appConfig=globalThis[CLIENT_APP_CONFIG_GLOBAL_KEY];return isRecord(appConfig)?appConfig:EMPTY_CLIENT_APP_CONFIG}function resolveMobileConfig(appConfig=getClientAppConfig()){return normalizeMobileConfig(isRecord(appConfig)?appConfig.mobile:{})}function normalizeRoutePath(pathLike=``){const rawPath=String(pathLike||``).trim();if(!rawPath||rawPath===`/`)return`/`;return(rawPath.startsWith(`/`)?rawPath:`/${rawPath}`).replace(/\/{2,}/g,`/`).replace(/\/+$/,``)||`/`}function resolveAbsoluteRoutePath(parentAbsolutePath=`/`,routePath=``){const normalizedParentPath=normalizeRoutePath(parentAbsolutePath);const rawRoutePath=String(routePath||``).trim();if(!rawRoutePath)return normalizedParentPath;if(rawRoutePath.startsWith(`/`))return normalizeRoutePath(rawRoutePath);if(normalizedParentPath===`/`)return normalizeRoutePath(`/${rawRoutePath}`);return normalizeRoutePath(`${normalizedParentPath}/${rawRoutePath}`)}function readRouteJskitMeta(route){if(!isRecord(route)||!isRecord(route.meta)||!isRecord(route.meta.jskit))return{};return route.meta.jskit}function resolveRouteExplicitSurface(route){const metaSurface=readRouteJskitMeta(route).surface;return normalizeSurfaceId(route?.surface||metaSurface)}function resolveOwnRouteScope(route){const metaScope=readRouteJskitMeta(route).scope;const normalizedScope=String(route?.scope||metaScope||``).trim().toLowerCase();if(!normalizedScope)return``;return normalizedScope===`global`?`global`:`surface`}function resolveRouteSurface(route,inheritedSurfaceId=``,{surfaceRuntime,absolutePath=`/`}={}){const explicitSurface=resolveRouteExplicitSurface(route);if(explicitSurface)return explicitSurface;const normalizedInheritedSurface=normalizeSurfaceId(inheritedSurfaceId);if(normalizedInheritedSurface)return normalizedInheritedSurface;return surfaceRuntime.resolveSurfaceFromPathname(absolutePath)}function normalizeRoutesBySurfaceBoundaries(routeList=[],{surfaceRuntime}={}){const normalizedRoutes=Array.isArray(routeList)?routeList:[];const hoistedRoutes=[];function cloneRouteWithChildren(route,children){const nextRoute={...route};if(children.length>0)nextRoute.children=children;else if(Object.prototype.hasOwnProperty.call(nextRoute,`children`))delete nextRoute.children;return nextRoute}function cloneRouteAsHoisted(route,absolutePath,children){const nextRoute=cloneRouteWithChildren(route,children);nextRoute.path=absolutePath;return nextRoute}function visitRoute(route,parentSurfaceId=``,parentAbsolutePath=`/`){if(!isRecord(route))return null;const absolutePath=resolveAbsoluteRoutePath(parentAbsolutePath,route.path);const explicitSurface=resolveRouteExplicitSurface(route);const normalizedParentSurfaceId=normalizeSurfaceId(parentSurfaceId);const resolvedSurface=resolveRouteSurface(route,normalizedParentSurfaceId,{surfaceRuntime,absolutePath});const surfaceBoundary=Boolean(explicitSurface)&&Boolean(normalizedParentSurfaceId)&&explicitSurface!==normalizedParentSurfaceId;const children=Array.isArray(route.children)?route.children:[];const filteredChildren=[];for(const child of children){const normalizedChild=visitRoute(child,resolvedSurface,absolutePath);if(normalizedChild)filteredChildren.push(normalizedChild)}const routeWithChildren=children.length!==filteredChildren.length||filteredChildren.some((child,index)=>child!==children[index])?cloneRouteWithChildren(route,filteredChildren):route;if(!surfaceBoundary)return routeWithChildren;hoistedRoutes.push(cloneRouteAsHoisted(routeWithChildren,absolutePath,filteredChildren));return null}const keptRoutes=[];for(const route of normalizedRoutes){const normalizedRoute=visitRoute(route,``,`/`);if(normalizedRoute)keptRoutes.push(normalizedRoute)}return[...keptRoutes,...hoistedRoutes]}function createSurfaceRuntime(options={}){const allMode=normalizeSurfaceId(options?.allMode||`all`)||`all`;const registry=createSurfaceRegistry({surfaces:isRecord(options?.surfaces)?options.surfaces:{},defaultSurfaceId:options?.defaultSurfaceId});const{SURFACE_REGISTRY,DEFAULT_SURFACE_ID}=registry;const surfaceDefinitions=registry.listSurfaceDefinitions();const surfaceIds=surfaceDefinitions.map(definition=>definition.id);const enabledSurfaceIds=surfaceDefinitions.filter(definition=>definition.enabled).map(definition=>definition.id);const pathHelpers=createSurfacePathHelpers({apiBasePath:options?.apiBasePath,defaultSurfaceId:DEFAULT_SURFACE_ID,surfaceDefinitions});function normalizeSurfaceMode(value){const normalized=normalizeSurfaceId(value);if(!normalized||normalized===allMode)return allMode;return SURFACE_REGISTRY[normalized]?normalized:allMode}function listEnabledSurfaceIds(){return[...enabledSurfaceIds]}function getSurfaceDefinition(surfaceId){return SURFACE_REGISTRY[normalizeSurfaceId(surfaceId)]||null}function listSurfaceDefinitions({enabledOnly=false}={}){return enabledOnly?surfaceDefinitions.filter(definition=>definition.enabled):[...surfaceDefinitions]}function isSurfaceEnabled(surfaceId){const normalizedSurface=normalizeSurfaceMode(surfaceId);if(normalizedSurface===allMode)return false;return enabledSurfaceIds.includes(normalizedSurface)}return{SURFACE_MODE_ALL:allMode,SURFACE_IDS:[...surfaceIds],DEFAULT_SURFACE_ID,DEFAULT_SURFACE:SURFACE_REGISTRY[DEFAULT_SURFACE_ID],normalizeSurfaceMode,resolveSurfaceFromPathname:pathHelpers.resolveSurfaceFromPathname,getSurfaceDefinition,listSurfaceDefinitions,listEnabledSurfaceIds,isSurfaceEnabled}}function filterRoutesBySurface(routeList,{surfaceRuntime,surfaceMode}={}){if(!surfaceRuntime||typeof surfaceRuntime!==`object`)throw new Error(`filterRoutesBySurface requires surfaceRuntime.`);if(typeof surfaceRuntime.normalizeSurfaceMode!==`function`)throw new Error(`filterRoutesBySurface requires surfaceRuntime.normalizeSurfaceMode().`);if(typeof surfaceRuntime.resolveSurfaceFromPathname!==`function`)throw new Error(`filterRoutesBySurface requires surfaceRuntime.resolveSurfaceFromPathname().`);if(typeof surfaceRuntime.listEnabledSurfaceIds!==`function`)throw new Error(`filterRoutesBySurface requires surfaceRuntime.listEnabledSurfaceIds().`);const normalizedRoutes=normalizeRoutesBySurfaceBoundaries(routeList,{surfaceRuntime});const allMode=String(surfaceRuntime.SURFACE_MODE_ALL||`all`).trim().toLowerCase()||`all`;const normalizedMode=surfaceRuntime.normalizeSurfaceMode(surfaceMode);const enabledSurfaces=new Set(surfaceRuntime.listEnabledSurfaceIds());function filterRouteNode(route,inheritedSurfaceId=``){if(!isRecord(route))return null;const resolvedSurface=resolveRouteSurface(route,inheritedSurfaceId,{surfaceRuntime,absolutePath:String(route.path||`/`)});const isGlobalScope=resolveOwnRouteScope(route)===`global`;const isEnabledSurfaceRoute=enabledSurfaces.has(resolvedSurface);const ownIncluded=isGlobalScope||isEnabledSurfaceRoute&&(normalizedMode===allMode||resolvedSurface===normalizedMode);const children=Array.isArray(route.children)?route.children:[];const filteredChildren=children.map(child=>filterRouteNode(child,resolvedSurface)).filter(Boolean);if(!ownIncluded&&filteredChildren.length<1)return null;if(children.length<1)return route;return{...route,children:filteredChildren}}return normalizedRoutes.map(route=>filterRouteNode(route)).filter(Boolean)}var DEFAULT_GUARD_EVALUATOR_KEY=`__JSKIT_WEB_SHELL_GUARD_EVALUATOR__`;var WEB_ROOT_ALLOW_YES=`yes`;var WEB_ROOT_ALLOW_NO=`no`;function createFallbackNotFoundRoute(component){if(!component)throw new Error(`createFallbackNotFoundRoute requires a component.`);return Object.freeze({path:`/:pathMatch(.*)*`,name:`not-found`,component,meta:{jskit:{scope:`global`}}})}function buildSurfaceAwareRoutes({routes=[],surfaceRuntime,surfaceMode,fallbackRoute,notFoundComponent}={}){const effectiveFallback=fallbackRoute||(notFoundComponent?createFallbackNotFoundRoute(notFoundComponent):null);if(!effectiveFallback)throw new TypeError(`buildSurfaceAwareRoutes requires fallbackRoute or notFoundComponent.`);return filterRoutesBySurface([...routes,effectiveFallback],{surfaceRuntime,surfaceMode})}function normalizeGuardPolicy(value){return String(value||``).trim().toLowerCase()}function resolveRouteGuardFromMeta(meta){if(!meta||typeof meta!==`object`||Array.isArray(meta))return null;if(meta.guard&&typeof meta.guard===`object`&&!Array.isArray(meta.guard))return meta.guard;if(meta.jskit&&typeof meta.jskit===`object`&&!Array.isArray(meta.jskit)){const jskitGuard=meta.jskit.guard;if(jskitGuard&&typeof jskitGuard===`object`&&!Array.isArray(jskitGuard))return jskitGuard}return null}function resolveRouteGuard(to){const matched=Array.isArray(to?.matched)?to.matched:[];for(let index=matched.length-1;index>=0;index-=1){const routeRecord=matched[index]&&typeof matched[index]===`object`?matched[index]:null;if(!routeRecord)continue;if(routeRecord.guard&&typeof routeRecord.guard===`object`&&!Array.isArray(routeRecord.guard))return routeRecord.guard;const metaGuard=resolveRouteGuardFromMeta(routeRecord.meta);if(metaGuard)return metaGuard}return null}function resolveSearchFromFullPath(fullPath){const rawFullPath=String(fullPath||``).trim();const queryStart=rawFullPath.indexOf(`?`);if(queryStart<0)return``;const hashStart=rawFullPath.indexOf(`#`,queryStart);return hashStart<0?rawFullPath.slice(queryStart):rawFullPath.slice(queryStart,hashStart)}function normalizeWebRootAllowed(value){const normalizedValue=String(value||``).trim().toLowerCase();if(normalizedValue===`yes`||normalizedValue===`no`)return normalizedValue;return`yes`}function resolveEffectiveRouteGuard({to,surfaceRuntime,authenticatedPolicy,publicPolicy}){const routePolicy=normalizeGuardPolicy(resolveRouteGuard(to)?.policy);if(routePolicy)return{policy:routePolicy};const surfaceId=surfaceRuntime.resolveSurfaceFromPathname(String(to?.path||`/`).trim()||`/`);if(surfaceRuntime.getSurfaceDefinition(surfaceId)?.requiresAuth)return{policy:authenticatedPolicy};return{policy:publicPolicy}}function resolveGuardEvaluator(guardEvaluatorKey){if(typeof globalThis!==`object`||!globalThis)return null;const evaluator=globalThis[guardEvaluatorKey];if(typeof evaluator!==`function`)return null;return evaluator}function normalizeGuardOutcome(outcome){if(outcome===false)return{allow:false,redirectTo:``,reason:``};if(outcome==null||outcome===true||typeof outcome!==`object`||Array.isArray(outcome))return{allow:true,redirectTo:``,reason:``};return{allow:outcome.allow!==false,redirectTo:String(outcome.redirectTo||``).trim(),reason:String(outcome.reason||``).trim()}}function evaluateShellGuard({guard,to,guardEvaluatorKey}){const evaluator=resolveGuardEvaluator(guardEvaluatorKey);if(!evaluator)return{allow:true,redirectTo:``,reason:``};const pathname=String(to?.path||`/`).trim()||`/`;const search=resolveSearchFromFullPath(to?.fullPath||``);try{return normalizeGuardOutcome(evaluator({guard,phase:`route`,context:{to,location:{pathname,search}}}))}catch{return{allow:false,redirectTo:``,reason:`guard-evaluator-error`}}}function createShellBeforeEachGuard({surfaceRuntime,webRootAllowed=`yes`,guardEvaluatorKey=DEFAULT_GUARD_EVALUATOR_KEY,authenticatedPolicy=AUTH_POLICY_AUTHENTICATED,publicPolicy=AUTH_POLICY_PUBLIC}={}){if(!surfaceRuntime||typeof surfaceRuntime.resolveSurfaceFromPathname!==`function`||typeof surfaceRuntime.getSurfaceDefinition!==`function`)throw new TypeError(`createShellBeforeEachGuard requires surfaceRuntime.resolveSurfaceFromPathname() and getSurfaceDefinition().`);const defaultSurfaceRootPath=surfaceRuntime.getSurfaceDefinition(surfaceRuntime.DEFAULT_SURFACE_ID)?.routeBase||`/`;const redirectWebRoot=normalizeWebRootAllowed(webRootAllowed)===`no`&&defaultSurfaceRootPath!==`/`;return to=>{if(redirectWebRoot&&String(to?.path||`/`).trim()===`/`){const search=resolveSearchFromFullPath(to?.fullPath||``);const hash=String(to?.hash||``).trim();return`${defaultSurfaceRootPath}${search}${hash}`}const guard=resolveEffectiveRouteGuard({to,surfaceRuntime,authenticatedPolicy,publicPolicy});if(guard.policy!==authenticatedPolicy)return true;const outcome=evaluateShellGuard({guard,to,guardEvaluatorKey});if(outcome.allow)return true;if(outcome.redirectTo){if(isExternalLinkTarget(outcome.redirectTo)){if(typeof window===`object`&&window?.location&&typeof window.location.assign===`function`)window.location.assign(outcome.redirectTo);return false}return outcome.redirectTo}return false}}function createStructuredLogger(logger=console){if(isRecord(logger)){const hasDebug=typeof logger.debug===`function`;return Object.freeze({info:typeof logger.info===`function`?logger.info.bind(logger):console.info.bind(console),warn:typeof logger.warn===`function`?logger.warn.bind(logger):console.warn.bind(console),error:typeof logger.error===`function`?logger.error.bind(logger):console.error.bind(console),debug:hasDebug?logger.debug.bind(logger):()=>{},isDebugEnabled:typeof logger.isDebugEnabled===`boolean`?logger.isDebugEnabled:hasDebug})}return Object.freeze({info:console.info.bind(console),warn:console.warn.bind(console),error:console.error.bind(console),debug:()=>{},isDebugEnabled:false})}function summarizeRouterRoutes(router){if(!router||typeof router.getRoutes!==`function`)return Object.freeze([]);return Object.freeze(router.getRoutes().map(route=>Object.freeze({name:String(route?.name||``).trim(),path:String(route?.path||``).trim(),metaScope:String(route?.meta?.jskit?.scope||``).trim(),metaSurface:String(route?.meta?.jskit?.surface||``).trim()})))}function resolveClientBootstrapDebugEnabled({env={},debugEnabled=void 0,debugEnvKey=`VITE_JSKIT_CLIENT_DEBUG`}={}){if(typeof debugEnabled===`boolean`)return debugEnabled;if(!isRecord(env))return false;return String(env[debugEnvKey]||``).trim()===`1`}function createClientBootstrapLogger({env={},logger=console,debugEnabled=void 0,debugEnvKey=`VITE_JSKIT_CLIENT_DEBUG`}={}){const baseLogger=createStructuredLogger(logger);const isDebugEnabled=resolveClientBootstrapDebugEnabled({env,debugEnabled,debugEnvKey});return Object.freeze({info:baseLogger.info,warn:baseLogger.warn,error:baseLogger.error,debug:isDebugEnabled?baseLogger.info:()=>{},isDebugEnabled})}function installAppPlugins(app,appPlugins=[]){const plugins=Array.isArray(appPlugins)?appPlugins:[];for(const pluginEntry of plugins){if(!pluginEntry)continue;if(Array.isArray(pluginEntry)){const[plugin,...pluginArgs]=pluginEntry;if(!plugin)continue;app.use(plugin,...pluginArgs);continue}app.use(pluginEntry)}}function isSurfaceRootRecord(record){return Boolean(record?.meta?.jskit?.surface)}function staysOnSamePage(to,from){if(to.path===from.path)return true;const fromParents=new Set((from.matched||[]).slice(0,-1));return(to.matched||[]).slice(0,-1).some(record=>fromParents.has(record)&&!isSurfaceRootRecord(record))}function shellScrollBehavior(to,from,savedPosition){if(savedPosition)return savedPosition;if(staysOnSamePage(to,from))return false;if(to.hash)return{el:to.hash,top:0};return{top:0}}function createSurfaceShellRouter({createRouter,history,routes=[],surfaceRuntime,surfaceMode,fallbackRoute=null,notFoundComponent=null,guard=false,scrollBehavior=shellScrollBehavior}={}){if(typeof createRouter!==`function`)throw new TypeError(`createSurfaceShellRouter requires createRouter().`);const effectiveFallbackRoute=fallbackRoute||(notFoundComponent?createFallbackNotFoundRoute(notFoundComponent):null);const activeRoutes=buildSurfaceAwareRoutes({routes,surfaceRuntime,surfaceMode,fallbackRoute:effectiveFallbackRoute});const router=createRouter({history,routes:activeRoutes,...typeof scrollBehavior===`function`?{scrollBehavior}:{}});if(guard!==false){if(!router||typeof router.beforeEach!==`function`)throw new TypeError(`createSurfaceShellRouter requires router.beforeEach() when guard is enabled.`);const beforeEachGuard=typeof guard===`function`?guard:createShellBeforeEachGuard({surfaceRuntime,...isRecord(guard)?guard:{}});router.beforeEach(beforeEachGuard)}return Object.freeze({router,activeRoutes:Object.freeze([...activeRoutes]),fallbackRoute:effectiveFallbackRoute})}async function bootstrapClientShellApp({createApp,rootComponent,appConfig={},appPlugins=[],i18n=null,pinia=null,queryClient=null,router,bootClientModules,surfaceRuntime,surfaceMode,env={},fallbackRoute=null,logger=console,createBootstrapLogger=null,debugEnabled=void 0,debugEnvKey=`VITE_JSKIT_CLIENT_DEBUG`,debugMessage=`Client modules bootstrapped before router install.`,onAfterModulesBootstrapped=null,onAfterRouterReady=null,mountSelector=`#app`}={}){if(typeof createApp!==`function`)throw new TypeError(`bootstrapClientShellApp requires createApp().`);if(!router||typeof router.addRoute!==`function`)throw new TypeError(`bootstrapClientShellApp requires router.addRoute().`);if(typeof bootClientModules!==`function`)throw new TypeError(`bootstrapClientShellApp requires bootClientModules().`);const app=createApp(rootComponent);if(!app||typeof app.use!==`function`||typeof app.mount!==`function`)throw new TypeError(`bootstrapClientShellApp requires createApp() to return a Vue app with use() and mount().`);installAppPlugins(app,appPlugins);if(i18n){if(!appPlugins.includes(i18n))app.use(i18n);setJskitI18n(i18n)}setClientAppConfig(appConfig);const resolvedLogger=typeof createBootstrapLogger===`function`?createBootstrapLogger({env,logger,debugEnabled,debugEnvKey}):createClientBootstrapLogger({env,logger,debugEnabled,debugEnvKey});const bootstrapLogger=createStructuredLogger(resolvedLogger);const clientBootstrap=await bootClientModules({app,pinia,queryClient,router,surfaceRuntime,surfaceMode,env,logger:bootstrapLogger});const{isDebugEnabled}=bootstrapLogger;if(isDebugEnabled)bootstrapLogger.info({bootstrap:{modules:clientBootstrap?.modules||[],providerCount:Number(clientBootstrap?.providerCount||0),routeCount:Number(clientBootstrap?.routeCount||0)},routerRoutesBeforeInstall:summarizeRouterRoutes(router),currentPath:typeof window!==`undefined`?String(window.location?.pathname||``):``},String(debugMessage||``).trim()||`Client modules bootstrapped before router install.`);if(fallbackRoute?.name&&typeof router.addRoute===`function`){if(typeof router.hasRoute===`function`&&router.hasRoute(fallbackRoute.name)&&typeof router.removeRoute===`function`)router.removeRoute(fallbackRoute.name);router.addRoute(fallbackRoute)}if(typeof onAfterModulesBootstrapped===`function`)await onAfterModulesBootstrapped(Object.freeze({app,router,clientBootstrap,surfaceRuntime,surfaceMode,env:isRecord(env)?{...env}:{},logger:bootstrapLogger,debugEnabled:isDebugEnabled}));app.use(router);if(typeof router.isReady===`function`)await router.isReady();if(typeof onAfterRouterReady===`function`)await onAfterRouterReady(Object.freeze({app,router,clientBootstrap,surfaceRuntime,surfaceMode,env:isRecord(env)?{...env}:{},logger:bootstrapLogger,debugEnabled:isDebugEnabled}));app.mount(mountSelector);return Object.freeze({app,router,clientBootstrap,logger:bootstrapLogger,debugEnabled:isDebugEnabled})}export{summarizeRouterRoutes as a,getClientAppConfig as c,createStructuredLogger as i,resolveMobileConfig as l,createSurfaceShellRouter as n,createSurfaceRuntime as o,resolveClientBootstrapDebugEnabled as r,filterRoutesBySurface as s,bootstrapClientShellApp as t};
1
+ import{E as AUTH_POLICY_PUBLIC,T as AUTH_POLICY_AUTHENTICATED,k as setJskitI18n}from"./useEndpointResource-7-YDfAxX.js";import{i as createSurfaceRegistry,n as createSurfacePathHelpers,o as normalizeSurfaceId}from"./returnToPath-gKtcu91D.js";import{a as normalizeBoolean,c as normalizeLowerText,f as normalizeText,l as normalizeObject,m as normalizeUniqueTextList,n as hasValue,r as isRecord,u as normalizePositiveInteger}from"./normalize-BNAdWJYg.js";import{t as isExternalLinkTarget}from"./linkPath-Ch9eft18.js";import"./asyncModuleRecovery-DJsn5NrL.js";var MOBILE_ASSET_MODES=Object.freeze([`bundled`,`dev_server`]);var MOBILE_STRATEGIES=Object.freeze([`capacitor`]);var DEFAULT_MOBILE_AUTH_CONFIG=Object.freeze({callbackPath:`/auth/login`,customScheme:``,appLinkDomains:Object.freeze([])});var DEFAULT_MOBILE_ANDROID_CONFIG=Object.freeze({packageName:``,minSdk:26,targetSdk:35,versionCode:1,versionName:`1.0.0`});function normalizeMobileStrategy(value=``,{fallback=``}={}){const normalized=normalizeLowerText(value);return MOBILE_STRATEGIES.includes(normalized)?normalized:normalizeLowerText(fallback)}function normalizeMobileAssetMode(value=``,{fallback=`bundled`}={}){const normalized=normalizeLowerText(value);if(!normalized)return normalizeLowerText(fallback,{fallback:`bundled`});if(!MOBILE_ASSET_MODES.includes(normalized))throw new TypeError(`config.mobile.assetMode must be "bundled" or "dev_server".`);return normalized}function normalizeMobileCallbackPath(value=``,{fallback=`/auth/login`}={}){const normalized=normalizeText(value,{fallback});if(!normalized)return``;return normalized.startsWith(`/`)?normalized:`/${normalized}`}function normalizeMobileConfig(source={}){const mobile=normalizeObject(source);const auth=normalizeObject(mobile.auth);const android=normalizeObject(mobile.android);return Object.freeze({enabled:hasValue(mobile.enabled)?normalizeBoolean(mobile.enabled):false,strategy:normalizeMobileStrategy(mobile.strategy),appId:normalizeText(mobile.appId),appName:normalizeText(mobile.appName),assetMode:normalizeMobileAssetMode(mobile.assetMode),devServerUrl:normalizeText(mobile.devServerUrl),apiBaseUrl:normalizeText(mobile.apiBaseUrl),auth:Object.freeze({callbackPath:normalizeMobileCallbackPath(auth.callbackPath,{fallback:DEFAULT_MOBILE_AUTH_CONFIG.callbackPath}),customScheme:normalizeLowerText(auth.customScheme),appLinkDomains:Object.freeze([...new Set(normalizeUniqueTextList(auth.appLinkDomains,{acceptSingle:true}).map(entry=>normalizeLowerText(entry)))])}),android:Object.freeze({packageName:normalizeText(android.packageName),minSdk:normalizePositiveInteger(android.minSdk,{fallback:DEFAULT_MOBILE_ANDROID_CONFIG.minSdk}),targetSdk:normalizePositiveInteger(android.targetSdk,{fallback:DEFAULT_MOBILE_ANDROID_CONFIG.targetSdk}),versionCode:normalizePositiveInteger(android.versionCode,{fallback:DEFAULT_MOBILE_ANDROID_CONFIG.versionCode}),versionName:normalizeText(android.versionName,{fallback:DEFAULT_MOBILE_ANDROID_CONFIG.versionName})})})}var CLIENT_APP_CONFIG_GLOBAL_KEY=`__JSKIT_CLIENT_APP_CONFIG__`;var EMPTY_CLIENT_APP_CONFIG=Object.freeze({});function normalizeClientAppConfig(source={}){if(!isRecord(source))return EMPTY_CLIENT_APP_CONFIG;return Object.freeze({...source})}function setClientAppConfig(source={}){const appConfig=normalizeClientAppConfig(source);if(typeof globalThis===`object`&&globalThis)globalThis[CLIENT_APP_CONFIG_GLOBAL_KEY]=appConfig;return appConfig}function getClientAppConfig(){if(typeof globalThis!==`object`||!globalThis)return EMPTY_CLIENT_APP_CONFIG;const appConfig=globalThis[CLIENT_APP_CONFIG_GLOBAL_KEY];return isRecord(appConfig)?appConfig:EMPTY_CLIENT_APP_CONFIG}function resolveMobileConfig(appConfig=getClientAppConfig()){return normalizeMobileConfig(isRecord(appConfig)?appConfig.mobile:{})}function normalizeRoutePath(pathLike=``){const rawPath=String(pathLike||``).trim();if(!rawPath||rawPath===`/`)return`/`;return(rawPath.startsWith(`/`)?rawPath:`/${rawPath}`).replace(/\/{2,}/g,`/`).replace(/\/+$/,``)||`/`}function resolveAbsoluteRoutePath(parentAbsolutePath=`/`,routePath=``){const normalizedParentPath=normalizeRoutePath(parentAbsolutePath);const rawRoutePath=String(routePath||``).trim();if(!rawRoutePath)return normalizedParentPath;if(rawRoutePath.startsWith(`/`))return normalizeRoutePath(rawRoutePath);if(normalizedParentPath===`/`)return normalizeRoutePath(`/${rawRoutePath}`);return normalizeRoutePath(`${normalizedParentPath}/${rawRoutePath}`)}function readRouteJskitMeta(route){if(!isRecord(route)||!isRecord(route.meta)||!isRecord(route.meta.jskit))return{};return route.meta.jskit}function resolveRouteExplicitSurface(route){const metaSurface=readRouteJskitMeta(route).surface;return normalizeSurfaceId(route?.surface||metaSurface)}function resolveOwnRouteScope(route){const metaScope=readRouteJskitMeta(route).scope;const normalizedScope=String(route?.scope||metaScope||``).trim().toLowerCase();if(!normalizedScope)return``;return normalizedScope===`global`?`global`:`surface`}function resolveRouteSurface(route,inheritedSurfaceId=``,{surfaceRuntime,absolutePath=`/`}={}){const explicitSurface=resolveRouteExplicitSurface(route);if(explicitSurface)return explicitSurface;const normalizedInheritedSurface=normalizeSurfaceId(inheritedSurfaceId);if(normalizedInheritedSurface)return normalizedInheritedSurface;return surfaceRuntime.resolveSurfaceFromPathname(absolutePath)}function normalizeRoutesBySurfaceBoundaries(routeList=[],{surfaceRuntime}={}){const normalizedRoutes=Array.isArray(routeList)?routeList:[];const hoistedRoutes=[];function cloneRouteWithChildren(route,children){const nextRoute={...route};if(children.length>0)nextRoute.children=children;else if(Object.prototype.hasOwnProperty.call(nextRoute,`children`))delete nextRoute.children;return nextRoute}function cloneRouteAsHoisted(route,absolutePath,children){const nextRoute=cloneRouteWithChildren(route,children);nextRoute.path=absolutePath;return nextRoute}function visitRoute(route,parentSurfaceId=``,parentAbsolutePath=`/`){if(!isRecord(route))return null;const absolutePath=resolveAbsoluteRoutePath(parentAbsolutePath,route.path);const explicitSurface=resolveRouteExplicitSurface(route);const normalizedParentSurfaceId=normalizeSurfaceId(parentSurfaceId);const resolvedSurface=resolveRouteSurface(route,normalizedParentSurfaceId,{surfaceRuntime,absolutePath});const surfaceBoundary=Boolean(explicitSurface)&&Boolean(normalizedParentSurfaceId)&&explicitSurface!==normalizedParentSurfaceId;const children=Array.isArray(route.children)?route.children:[];const filteredChildren=[];for(const child of children){const normalizedChild=visitRoute(child,resolvedSurface,absolutePath);if(normalizedChild)filteredChildren.push(normalizedChild)}const routeWithChildren=children.length!==filteredChildren.length||filteredChildren.some((child,index)=>child!==children[index])?cloneRouteWithChildren(route,filteredChildren):route;if(!surfaceBoundary)return routeWithChildren;hoistedRoutes.push(cloneRouteAsHoisted(routeWithChildren,absolutePath,filteredChildren));return null}const keptRoutes=[];for(const route of normalizedRoutes){const normalizedRoute=visitRoute(route,``,`/`);if(normalizedRoute)keptRoutes.push(normalizedRoute)}return[...keptRoutes,...hoistedRoutes]}function createSurfaceRuntime(options={}){const allMode=normalizeSurfaceId(options?.allMode||`all`)||`all`;const registry=createSurfaceRegistry({surfaces:isRecord(options?.surfaces)?options.surfaces:{},defaultSurfaceId:options?.defaultSurfaceId});const{SURFACE_REGISTRY,DEFAULT_SURFACE_ID}=registry;const surfaceDefinitions=registry.listSurfaceDefinitions();const surfaceIds=surfaceDefinitions.map(definition=>definition.id);const enabledSurfaceIds=surfaceDefinitions.filter(definition=>definition.enabled).map(definition=>definition.id);const pathHelpers=createSurfacePathHelpers({apiBasePath:options?.apiBasePath,defaultSurfaceId:DEFAULT_SURFACE_ID,surfaceDefinitions});function normalizeSurfaceMode(value){const normalized=normalizeSurfaceId(value);if(!normalized||normalized===allMode)return allMode;return SURFACE_REGISTRY[normalized]?normalized:allMode}function listEnabledSurfaceIds(){return[...enabledSurfaceIds]}function getSurfaceDefinition(surfaceId){return SURFACE_REGISTRY[normalizeSurfaceId(surfaceId)]||null}function listSurfaceDefinitions({enabledOnly=false}={}){return enabledOnly?surfaceDefinitions.filter(definition=>definition.enabled):[...surfaceDefinitions]}function isSurfaceEnabled(surfaceId){const normalizedSurface=normalizeSurfaceMode(surfaceId);if(normalizedSurface===allMode)return false;return enabledSurfaceIds.includes(normalizedSurface)}return{SURFACE_MODE_ALL:allMode,SURFACE_IDS:[...surfaceIds],DEFAULT_SURFACE_ID,DEFAULT_SURFACE:SURFACE_REGISTRY[DEFAULT_SURFACE_ID],normalizeSurfaceMode,resolveSurfaceFromPathname:pathHelpers.resolveSurfaceFromPathname,getSurfaceDefinition,listSurfaceDefinitions,listEnabledSurfaceIds,isSurfaceEnabled}}function filterRoutesBySurface(routeList,{surfaceRuntime,surfaceMode}={}){if(!surfaceRuntime||typeof surfaceRuntime!==`object`)throw new Error(`filterRoutesBySurface requires surfaceRuntime.`);if(typeof surfaceRuntime.normalizeSurfaceMode!==`function`)throw new Error(`filterRoutesBySurface requires surfaceRuntime.normalizeSurfaceMode().`);if(typeof surfaceRuntime.resolveSurfaceFromPathname!==`function`)throw new Error(`filterRoutesBySurface requires surfaceRuntime.resolveSurfaceFromPathname().`);if(typeof surfaceRuntime.listEnabledSurfaceIds!==`function`)throw new Error(`filterRoutesBySurface requires surfaceRuntime.listEnabledSurfaceIds().`);const normalizedRoutes=normalizeRoutesBySurfaceBoundaries(routeList,{surfaceRuntime});const allMode=String(surfaceRuntime.SURFACE_MODE_ALL||`all`).trim().toLowerCase()||`all`;const normalizedMode=surfaceRuntime.normalizeSurfaceMode(surfaceMode);const enabledSurfaces=new Set(surfaceRuntime.listEnabledSurfaceIds());function filterRouteNode(route,inheritedSurfaceId=``){if(!isRecord(route))return null;const resolvedSurface=resolveRouteSurface(route,inheritedSurfaceId,{surfaceRuntime,absolutePath:String(route.path||`/`)});const isGlobalScope=resolveOwnRouteScope(route)===`global`;const isEnabledSurfaceRoute=enabledSurfaces.has(resolvedSurface);const ownIncluded=isGlobalScope||isEnabledSurfaceRoute&&(normalizedMode===allMode||resolvedSurface===normalizedMode);const children=Array.isArray(route.children)?route.children:[];const filteredChildren=children.map(child=>filterRouteNode(child,resolvedSurface)).filter(Boolean);if(!ownIncluded&&filteredChildren.length<1)return null;if(children.length<1)return route;return{...route,children:filteredChildren}}return normalizedRoutes.map(route=>filterRouteNode(route)).filter(Boolean)}var DEFAULT_GUARD_EVALUATOR_KEY=`__JSKIT_WEB_SHELL_GUARD_EVALUATOR__`;var WEB_ROOT_ALLOW_YES=`yes`;var WEB_ROOT_ALLOW_NO=`no`;function createFallbackNotFoundRoute(component){if(!component)throw new Error(`createFallbackNotFoundRoute requires a component.`);return Object.freeze({path:`/:pathMatch(.*)*`,name:`not-found`,component,meta:{jskit:{scope:`global`}}})}function buildSurfaceAwareRoutes({routes=[],surfaceRuntime,surfaceMode,fallbackRoute,notFoundComponent}={}){const effectiveFallback=fallbackRoute||(notFoundComponent?createFallbackNotFoundRoute(notFoundComponent):null);if(!effectiveFallback)throw new TypeError(`buildSurfaceAwareRoutes requires fallbackRoute or notFoundComponent.`);return filterRoutesBySurface([...routes,effectiveFallback],{surfaceRuntime,surfaceMode})}function normalizeGuardPolicy(value){return String(value||``).trim().toLowerCase()}function resolveRouteGuardFromMeta(meta){if(!meta||typeof meta!==`object`||Array.isArray(meta))return null;if(meta.guard&&typeof meta.guard===`object`&&!Array.isArray(meta.guard))return meta.guard;if(meta.jskit&&typeof meta.jskit===`object`&&!Array.isArray(meta.jskit)){const jskitGuard=meta.jskit.guard;if(jskitGuard&&typeof jskitGuard===`object`&&!Array.isArray(jskitGuard))return jskitGuard}return null}function resolveRouteGuard(to){const matched=Array.isArray(to?.matched)?to.matched:[];for(let index=matched.length-1;index>=0;index-=1){const routeRecord=matched[index]&&typeof matched[index]===`object`?matched[index]:null;if(!routeRecord)continue;if(routeRecord.guard&&typeof routeRecord.guard===`object`&&!Array.isArray(routeRecord.guard))return routeRecord.guard;const metaGuard=resolveRouteGuardFromMeta(routeRecord.meta);if(metaGuard)return metaGuard}return null}function resolveSearchFromFullPath(fullPath){const rawFullPath=String(fullPath||``).trim();const queryStart=rawFullPath.indexOf(`?`);if(queryStart<0)return``;const hashStart=rawFullPath.indexOf(`#`,queryStart);return hashStart<0?rawFullPath.slice(queryStart):rawFullPath.slice(queryStart,hashStart)}function normalizeWebRootAllowed(value){const normalizedValue=String(value||``).trim().toLowerCase();if(normalizedValue===`yes`||normalizedValue===`no`)return normalizedValue;return`yes`}function resolveEffectiveRouteGuard({to,surfaceRuntime,authenticatedPolicy,publicPolicy}){const routePolicy=normalizeGuardPolicy(resolveRouteGuard(to)?.policy);if(routePolicy)return{policy:routePolicy};const surfaceId=surfaceRuntime.resolveSurfaceFromPathname(String(to?.path||`/`).trim()||`/`);if(surfaceRuntime.getSurfaceDefinition(surfaceId)?.requiresAuth)return{policy:authenticatedPolicy};return{policy:publicPolicy}}function resolveGuardEvaluator(guardEvaluatorKey){if(typeof globalThis!==`object`||!globalThis)return null;const evaluator=globalThis[guardEvaluatorKey];if(typeof evaluator!==`function`)return null;return evaluator}function normalizeGuardOutcome(outcome){if(outcome===false)return{allow:false,redirectTo:``,reason:``};if(outcome==null||outcome===true||typeof outcome!==`object`||Array.isArray(outcome))return{allow:true,redirectTo:``,reason:``};return{allow:outcome.allow!==false,redirectTo:String(outcome.redirectTo||``).trim(),reason:String(outcome.reason||``).trim()}}function evaluateShellGuard({guard,to,guardEvaluatorKey}){const evaluator=resolveGuardEvaluator(guardEvaluatorKey);if(!evaluator)return{allow:true,redirectTo:``,reason:``};const pathname=String(to?.path||`/`).trim()||`/`;const search=resolveSearchFromFullPath(to?.fullPath||``);try{return normalizeGuardOutcome(evaluator({guard,phase:`route`,context:{to,location:{pathname,search}}}))}catch{return{allow:false,redirectTo:``,reason:`guard-evaluator-error`}}}function createShellBeforeEachGuard({surfaceRuntime,webRootAllowed=`yes`,guardEvaluatorKey=DEFAULT_GUARD_EVALUATOR_KEY,authenticatedPolicy=AUTH_POLICY_AUTHENTICATED,publicPolicy=AUTH_POLICY_PUBLIC}={}){if(!surfaceRuntime||typeof surfaceRuntime.resolveSurfaceFromPathname!==`function`||typeof surfaceRuntime.getSurfaceDefinition!==`function`)throw new TypeError(`createShellBeforeEachGuard requires surfaceRuntime.resolveSurfaceFromPathname() and getSurfaceDefinition().`);const defaultSurfaceRootPath=surfaceRuntime.getSurfaceDefinition(surfaceRuntime.DEFAULT_SURFACE_ID)?.routeBase||`/`;const redirectWebRoot=normalizeWebRootAllowed(webRootAllowed)===`no`&&defaultSurfaceRootPath!==`/`;return to=>{if(redirectWebRoot&&String(to?.path||`/`).trim()===`/`){const search=resolveSearchFromFullPath(to?.fullPath||``);const hash=String(to?.hash||``).trim();return`${defaultSurfaceRootPath}${search}${hash}`}const guard=resolveEffectiveRouteGuard({to,surfaceRuntime,authenticatedPolicy,publicPolicy});if(guard.policy!==authenticatedPolicy)return true;const outcome=evaluateShellGuard({guard,to,guardEvaluatorKey});if(outcome.allow)return true;if(outcome.redirectTo){if(isExternalLinkTarget(outcome.redirectTo)){if(typeof window===`object`&&window?.location&&typeof window.location.assign===`function`)window.location.assign(outcome.redirectTo);return false}return outcome.redirectTo}return false}}function createStructuredLogger(logger=console){if(isRecord(logger)){const hasDebug=typeof logger.debug===`function`;return Object.freeze({info:typeof logger.info===`function`?logger.info.bind(logger):console.info.bind(console),warn:typeof logger.warn===`function`?logger.warn.bind(logger):console.warn.bind(console),error:typeof logger.error===`function`?logger.error.bind(logger):console.error.bind(console),debug:hasDebug?logger.debug.bind(logger):()=>{},isDebugEnabled:typeof logger.isDebugEnabled===`boolean`?logger.isDebugEnabled:hasDebug})}return Object.freeze({info:console.info.bind(console),warn:console.warn.bind(console),error:console.error.bind(console),debug:()=>{},isDebugEnabled:false})}function summarizeRouterRoutes(router){if(!router||typeof router.getRoutes!==`function`)return Object.freeze([]);return Object.freeze(router.getRoutes().map(route=>Object.freeze({name:String(route?.name||``).trim(),path:String(route?.path||``).trim(),metaScope:String(route?.meta?.jskit?.scope||``).trim(),metaSurface:String(route?.meta?.jskit?.surface||``).trim()})))}function resolveClientBootstrapDebugEnabled({env={},debugEnabled=void 0,debugEnvKey=`VITE_JSKIT_CLIENT_DEBUG`}={}){if(typeof debugEnabled===`boolean`)return debugEnabled;if(!isRecord(env))return false;return String(env[debugEnvKey]||``).trim()===`1`}function createClientBootstrapLogger({env={},logger=console,debugEnabled=void 0,debugEnvKey=`VITE_JSKIT_CLIENT_DEBUG`}={}){const baseLogger=createStructuredLogger(logger);const isDebugEnabled=resolveClientBootstrapDebugEnabled({env,debugEnabled,debugEnvKey});return Object.freeze({info:baseLogger.info,warn:baseLogger.warn,error:baseLogger.error,debug:isDebugEnabled?baseLogger.info:()=>{},isDebugEnabled})}function installAppPlugins(app,appPlugins=[]){const plugins=Array.isArray(appPlugins)?appPlugins:[];for(const pluginEntry of plugins){if(!pluginEntry)continue;if(Array.isArray(pluginEntry)){const[plugin,...pluginArgs]=pluginEntry;if(!plugin)continue;app.use(plugin,...pluginArgs);continue}app.use(pluginEntry)}}function isSurfaceRootRecord(record){return Boolean(record?.meta?.jskit?.surface)}function staysOnSamePage(to,from){if(to.path===from.path)return true;const fromParents=new Set((from.matched||[]).slice(0,-1));return(to.matched||[]).slice(0,-1).some(record=>fromParents.has(record)&&!isSurfaceRootRecord(record))}function shellScrollBehavior(to,from,savedPosition){if(savedPosition)return savedPosition;if(staysOnSamePage(to,from))return false;if(to.hash)return{el:to.hash,top:0};return{top:0}}function createSurfaceShellRouter({createRouter,history,routes=[],surfaceRuntime,surfaceMode,fallbackRoute=null,notFoundComponent=null,guard=false,scrollBehavior=shellScrollBehavior}={}){if(typeof createRouter!==`function`)throw new TypeError(`createSurfaceShellRouter requires createRouter().`);const effectiveFallbackRoute=fallbackRoute||(notFoundComponent?createFallbackNotFoundRoute(notFoundComponent):null);const activeRoutes=buildSurfaceAwareRoutes({routes,surfaceRuntime,surfaceMode,fallbackRoute:effectiveFallbackRoute});const router=createRouter({history,routes:activeRoutes,...typeof scrollBehavior===`function`?{scrollBehavior}:{}});if(guard!==false){if(!router||typeof router.beforeEach!==`function`)throw new TypeError(`createSurfaceShellRouter requires router.beforeEach() when guard is enabled.`);const beforeEachGuard=typeof guard===`function`?guard:createShellBeforeEachGuard({surfaceRuntime,...isRecord(guard)?guard:{}});router.beforeEach(beforeEachGuard)}return Object.freeze({router,activeRoutes:Object.freeze([...activeRoutes]),fallbackRoute:effectiveFallbackRoute})}async function bootstrapClientShellApp({createApp,rootComponent,appConfig={},appPlugins=[],i18n=null,pinia=null,queryClient=null,router,bootClientModules,surfaceRuntime,surfaceMode,env={},fallbackRoute=null,logger=console,createBootstrapLogger=null,debugEnabled=void 0,debugEnvKey=`VITE_JSKIT_CLIENT_DEBUG`,debugMessage=`Client modules bootstrapped before router install.`,onAfterModulesBootstrapped=null,onAfterRouterReady=null,mountSelector=`#app`}={}){if(typeof createApp!==`function`)throw new TypeError(`bootstrapClientShellApp requires createApp().`);if(!router||typeof router.addRoute!==`function`)throw new TypeError(`bootstrapClientShellApp requires router.addRoute().`);if(typeof bootClientModules!==`function`)throw new TypeError(`bootstrapClientShellApp requires bootClientModules().`);const app=createApp(rootComponent);if(!app||typeof app.use!==`function`||typeof app.mount!==`function`)throw new TypeError(`bootstrapClientShellApp requires createApp() to return a Vue app with use() and mount().`);installAppPlugins(app,appPlugins);if(i18n){if(!appPlugins.includes(i18n))app.use(i18n);setJskitI18n(i18n)}setClientAppConfig(appConfig);const resolvedLogger=typeof createBootstrapLogger===`function`?createBootstrapLogger({env,logger,debugEnabled,debugEnvKey}):createClientBootstrapLogger({env,logger,debugEnabled,debugEnvKey});const bootstrapLogger=createStructuredLogger(resolvedLogger);const clientBootstrap=await bootClientModules({app,pinia,queryClient,router,surfaceRuntime,surfaceMode,env,logger:bootstrapLogger});const{isDebugEnabled}=bootstrapLogger;if(isDebugEnabled)bootstrapLogger.info({bootstrap:{modules:clientBootstrap?.modules||[],providerCount:Number(clientBootstrap?.providerCount||0),routeCount:Number(clientBootstrap?.routeCount||0)},routerRoutesBeforeInstall:summarizeRouterRoutes(router),currentPath:typeof window!==`undefined`?String(window.location?.pathname||``):``},String(debugMessage||``).trim()||`Client modules bootstrapped before router install.`);if(fallbackRoute?.name&&typeof router.addRoute===`function`){if(typeof router.hasRoute===`function`&&router.hasRoute(fallbackRoute.name)&&typeof router.removeRoute===`function`)router.removeRoute(fallbackRoute.name);router.addRoute(fallbackRoute)}if(typeof onAfterModulesBootstrapped===`function`)await onAfterModulesBootstrapped(Object.freeze({app,router,clientBootstrap,surfaceRuntime,surfaceMode,env:isRecord(env)?{...env}:{},logger:bootstrapLogger,debugEnabled:isDebugEnabled}));app.use(router);if(typeof router.isReady===`function`)await router.isReady();if(typeof onAfterRouterReady===`function`)await onAfterRouterReady(Object.freeze({app,router,clientBootstrap,surfaceRuntime,surfaceMode,env:isRecord(env)?{...env}:{},logger:bootstrapLogger,debugEnabled:isDebugEnabled}));app.mount(mountSelector);return Object.freeze({app,router,clientBootstrap,logger:bootstrapLogger,debugEnabled:isDebugEnabled})}export{summarizeRouterRoutes as a,getClientAppConfig as c,createStructuredLogger as i,resolveMobileConfig as l,createSurfaceShellRouter as n,createSurfaceRuntime as o,resolveClientBootstrapDebugEnabled as r,filterRoutesBySurface as s,bootstrapClientShellApp as t};