@uniqbit/mate-core 0.18.5 → 1.0.0-canary.2

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 (390) hide show
  1. package/claude-capability-plugins/companion-mentions/.claude-plugin/marketplace.json +14 -0
  2. package/claude-capability-plugins/companion-mentions/.claude-plugin/plugin.json +8 -0
  3. package/claude-capability-plugins/companion-mentions/hooks/companion.ts +457 -0
  4. package/claude-capability-plugins/companion-mentions/hooks/hooks.json +1 -0
  5. package/claude-capability-plugins/companion-mentions/hooks/register.ts +403 -0
  6. package/claude-plugin/hooks/companion-instructions.mjs +9 -0
  7. package/claude-plugin/hooks/hooks.json +21 -2
  8. package/claude-plugin/hooks/tokensave-route.mjs +52 -0
  9. package/opencode-plugin/src/server.ts +4 -0
  10. package/opencode-plugin/src/tui.tsx +2 -0
  11. package/opencode-plugin/tui.tsx +2 -0
  12. package/package.json +52 -15
  13. package/src/brand/art.generated.ts +69 -0
  14. package/src/brand/index.ts +12 -0
  15. package/src/brand/palette.ts +19 -0
  16. package/src/brand/svg.generated.ts +8 -0
  17. package/src/brand/terminal.ts +88 -0
  18. package/src/brand/types.ts +33 -0
  19. package/src/cli/commands/artifact/apply-context.ts +275 -0
  20. package/src/cli/commands/artifact/artifact.ts +12 -0
  21. package/src/cli/commands/artifact/delivery/archive.ts +125 -0
  22. package/src/cli/commands/artifact/delivery/branch-flags.ts +55 -0
  23. package/src/cli/commands/artifact/delivery/environment.ts +127 -0
  24. package/src/cli/commands/artifact/delivery/link.ts +174 -0
  25. package/src/cli/commands/artifact/delivery/output.ts +89 -0
  26. package/src/cli/commands/artifact/finish/command.ts +83 -8
  27. package/src/cli/commands/artifact/finish/engine.ts +91 -14
  28. package/src/cli/commands/artifact/finish/finisher.ts +10 -0
  29. package/src/cli/commands/artifact/finish/git.ts +132 -19
  30. package/src/cli/commands/artifact/finish/openspec.ts +182 -138
  31. package/src/cli/commands/artifact/finish/secret-scan.ts +43 -0
  32. package/src/cli/commands/artifact/finish/worktree-cleanup.ts +92 -0
  33. package/src/cli/commands/artifact/pending/command.ts +31 -3
  34. package/src/cli/commands/artifact/pending/discovery.ts +21 -57
  35. package/src/cli/commands/cap/graphify.ts +52 -3
  36. package/src/cli/commands/cap/index-cmd.ts +71 -15
  37. package/src/cli/commands/cap/openspec.ts +13 -25
  38. package/src/cli/commands/cap/tokensave.ts +7 -5
  39. package/src/cli/commands/companion/link.ts +14 -1
  40. package/src/cli/commands/companion/open.ts +68 -46
  41. package/src/cli/commands/companion/sync.ts +10 -0
  42. package/src/cli/commands/companion/tui.ts +17 -7
  43. package/src/cli/commands/companion/update.ts +143 -48
  44. package/src/cli/commands/doctor.ts +195 -7
  45. package/src/cli/commands/factory/factory.ts +301 -0
  46. package/src/cli/commands/install.ts +133 -9
  47. package/src/cli/commands/launch/shared.ts +16 -11
  48. package/src/cli/commands/plugin/install.ts +9 -4
  49. package/src/cli/commands/plugin/plugin.ts +3 -2
  50. package/src/cli/commands/report/adapter.ts +11 -2
  51. package/src/cli/commands/report/contract.ts +21 -0
  52. package/src/cli/commands/report/highlight.ts +34 -4
  53. package/src/cli/commands/report/index.ts +20 -1
  54. package/src/cli/commands/report/markdown.ts +110 -0
  55. package/src/cli/commands/report/palette.ts +118 -0
  56. package/src/cli/commands/report/renderer.ts +456 -153
  57. package/src/cli/commands/report/types.ts +16 -0
  58. package/src/cli/commands/session/context.ts +102 -0
  59. package/src/cli/commands/setup.ts +50 -24
  60. package/src/cli/commands/studio/factory-credential.ts +49 -0
  61. package/src/cli/commands/studio/index.ts +29 -2
  62. package/src/cli/commands/studio/openspec-cli.ts +10 -58
  63. package/src/cli/commands/studio/payload.ts +249 -15
  64. package/src/cli/commands/studio/routes.ts +41 -6
  65. package/src/cli/commands/studio/selection.ts +161 -17
  66. package/src/cli/commands/studio/server.ts +404 -324
  67. package/src/cli/commands/studio/services.ts +60 -0
  68. package/src/cli/commands/studio/studio-app.ts +67 -0
  69. package/src/cli/commands/studio/terminal-assets.ts +21 -33
  70. package/src/cli/commands/studio/terminal.ts +85 -15
  71. package/src/cli/commands/studio/views/model.ts +18 -0
  72. package/src/cli/commands/studio/views/vault/markdown-tree.ts +267 -0
  73. package/src/cli/commands/studio/views/vault/view.ts +185 -0
  74. package/src/cli/commands/studio/workset-session.ts +131 -0
  75. package/src/cli/commands/unwrap.ts +8 -0
  76. package/src/cli/commands/update.ts +27 -1
  77. package/src/cli/commands/working/cleanup.ts +10 -1
  78. package/src/cli/commands/working/link.ts +76 -0
  79. package/src/cli/commands/working/working.ts +10 -0
  80. package/src/cli/commands/working/worktree.ts +356 -0
  81. package/src/cli/commands/wrap.ts +5 -13
  82. package/src/cli/companion-link-wizard.tsx +2 -0
  83. package/src/cli/companion-selector.tsx +2 -0
  84. package/src/cli/confirm.ts +2 -0
  85. package/src/cli/install-plan.tsx +127 -160
  86. package/src/cli/launch-selector.tsx +2 -0
  87. package/src/cli/main.ts +22 -1
  88. package/src/cli/parse-flags.ts +32 -6
  89. package/src/cli/repo-list-table.tsx +2 -0
  90. package/src/cli/setup-selector.tsx +86 -151
  91. package/src/cli/usage.ts +14 -0
  92. package/src/create-mate.ts +5 -4
  93. package/src/hooks/companion-instructions.ts +190 -0
  94. package/src/hooks/hook-io.ts +63 -0
  95. package/src/hooks/session-banner.ts +21 -29
  96. package/src/hooks/session-guidance.ts +9 -17
  97. package/src/hooks/session-prepare.ts +115 -28
  98. package/src/hooks/tokensave-route.ts +26 -0
  99. package/src/hooks/validate-artifact-path.ts +82 -24
  100. package/src/index.ts +4 -0
  101. package/src/lib/apply-context/fingerprint.ts +174 -0
  102. package/src/lib/apply-context/protocol.ts +193 -0
  103. package/src/lib/change-layout.ts +154 -0
  104. package/src/lib/components/confirm-prompt.tsx +21 -9
  105. package/src/lib/components/select-menu.tsx +10 -3
  106. package/src/lib/components/spinner.tsx +4 -2
  107. package/src/lib/components/startup-progress.tsx +227 -41
  108. package/src/lib/components/text-input-display.tsx +2 -0
  109. package/src/lib/components/wizard-footer.tsx +2 -0
  110. package/src/lib/components/wizard-header.tsx +16 -12
  111. package/src/lib/context-mode-package.ts +24 -11
  112. package/src/lib/delivery/archive-change.ts +166 -0
  113. package/src/lib/delivery/branches.ts +132 -0
  114. package/src/lib/delivery/environment.ts +35 -0
  115. package/src/lib/delivery/forge.ts +279 -0
  116. package/src/lib/delivery/merge-git.ts +261 -0
  117. package/src/lib/delivery/overlap.ts +209 -0
  118. package/src/lib/delivery/record-delivery.ts +283 -0
  119. package/src/lib/delivery/record.ts +403 -0
  120. package/src/lib/delivery/refresh.ts +268 -0
  121. package/src/lib/delivery/repository-access.ts +141 -0
  122. package/src/lib/delivery/resolve-branch.ts +162 -0
  123. package/src/lib/delivery/stages.ts +111 -0
  124. package/src/lib/delivery/token.ts +24 -0
  125. package/src/lib/factory/attach-client.ts +113 -0
  126. package/src/lib/factory/attach.ts +178 -0
  127. package/src/lib/factory/broker.ts +190 -0
  128. package/src/lib/factory/bun-commands.ts +39 -0
  129. package/src/lib/factory/client.ts +92 -0
  130. package/src/lib/factory/command.ts +61 -0
  131. package/src/lib/factory/credential-store.ts +153 -0
  132. package/src/lib/factory/frames.ts +77 -0
  133. package/src/lib/factory/ids.ts +58 -0
  134. package/src/lib/factory/keyed-serial.ts +27 -0
  135. package/src/lib/factory/outcomes/actions.ts +114 -0
  136. package/src/lib/factory/outcomes/index.ts +381 -0
  137. package/src/lib/factory/outcomes/lifecycle.ts +205 -0
  138. package/src/lib/factory/outcomes/runs.ts +81 -0
  139. package/src/lib/factory/outcomes/sessions.ts +38 -0
  140. package/src/lib/factory/prepare.ts +49 -0
  141. package/src/lib/factory/pty.ts +103 -0
  142. package/src/lib/factory/runner/companion-context.ts +178 -0
  143. package/src/lib/factory/runner/control.ts +92 -0
  144. package/src/lib/factory/runner/harness-agent.ts +250 -0
  145. package/src/lib/factory/runner/live.ts +159 -0
  146. package/src/lib/factory/runner/questions.ts +22 -0
  147. package/src/lib/factory/runner/rank.ts +26 -0
  148. package/src/lib/factory/runner/run-policy.ts +12 -0
  149. package/src/lib/factory/runner/run.ts +199 -0
  150. package/src/lib/factory/runner/scheduler.ts +416 -0
  151. package/src/lib/factory/runner/state.ts +233 -0
  152. package/src/lib/factory/runner/workflow.ts +542 -0
  153. package/src/lib/factory/runtime.ts +972 -0
  154. package/src/lib/factory/sandbox.ts +292 -0
  155. package/src/lib/factory/worktree-branch.ts +17 -0
  156. package/src/lib/frontmatter.ts +18 -0
  157. package/src/lib/install.ts +66 -14
  158. package/src/lib/live-progress.ts +36 -0
  159. package/src/lib/member-choices.ts +67 -0
  160. package/src/lib/opencode-plugin-package.ts +5 -5
  161. package/src/lib/openspec-cli.ts +116 -0
  162. package/src/lib/openspec-scopes.ts +86 -0
  163. package/src/lib/orchestrator/adapters/base.ts +55 -22
  164. package/src/lib/orchestrator/adapters/claude-args.ts +50 -0
  165. package/src/lib/orchestrator/adapters/claude.ts +54 -41
  166. package/src/lib/orchestrator/adapters/opencode.ts +2 -0
  167. package/src/lib/orchestrator/config-store.ts +3 -2
  168. package/src/lib/orchestrator/editor.ts +31 -25
  169. package/src/lib/orchestrator/openspec-store.ts +14 -54
  170. package/src/lib/orchestrator/projection-claude-commands.ts +36 -0
  171. package/src/lib/orchestrator/projection-claude-links.ts +159 -0
  172. package/src/lib/orchestrator/projection-claude-skills.ts +19 -137
  173. package/src/lib/orchestrator/projection-entries.ts +100 -34
  174. package/src/lib/orchestrator/projection-opencode-copies.ts +32 -15
  175. package/src/lib/orchestrator/projection-openspec-store.ts +54 -9
  176. package/src/lib/orchestrator/projection-runtime-documents.ts +15 -6
  177. package/src/lib/orchestrator/projection-types.ts +36 -1
  178. package/src/lib/orchestrator/refresh-working-claude-links.ts +87 -0
  179. package/src/lib/orchestrator/session-context-link.ts +67 -0
  180. package/src/lib/orchestrator/session-prepare.ts +45 -5
  181. package/src/lib/orchestrator/setup-compatibilities.ts +56 -70
  182. package/src/lib/orchestrator/types.ts +7 -2
  183. package/src/lib/orchestrator/working-repo-projection.ts +50 -7
  184. package/src/lib/orchestrator/workspace-document.ts +105 -0
  185. package/src/lib/orchestrator/wrap-pass.ts +22 -1
  186. package/src/lib/package-paths.ts +37 -0
  187. package/src/lib/runtime-directory-refresh.ts +17 -1
  188. package/src/lib/workset/record.ts +513 -0
  189. package/src/lib/workset/repositories.ts +55 -0
  190. package/src/lib/workset/stage.ts +148 -0
  191. package/src/lib/workset/stages.ts +113 -0
  192. package/src/lib/workset/worktree-index.ts +116 -0
  193. package/src/lib/workset/worktree.ts +830 -0
  194. package/src/opencode/companion-hooks.ts +109 -7
  195. package/src/opencode/companion-policy.ts +37 -18
  196. package/src/opencode/enter-worktree.ts +72 -0
  197. package/src/opencode/projected-guidance.ts +4 -1
  198. package/src/opencode/session-prepare.ts +2 -1
  199. package/src/opencode/tui.tsx +13 -6
  200. package/src/plugins.ts +1 -0
  201. package/src/runtime/artifact-refusal.ts +63 -0
  202. package/src/runtime/claude-delivery-plan.ts +107 -8
  203. package/src/runtime/commit-attribution-guard.ts +181 -0
  204. package/src/runtime/companion-git.ts +52 -10
  205. package/src/runtime/companion-guidance.ts +20 -8
  206. package/src/runtime/companion-instructions.ts +340 -0
  207. package/src/runtime/companion-lock.ts +30 -7
  208. package/src/runtime/env.ts +48 -3
  209. package/src/runtime/error-message.ts +4 -0
  210. package/src/runtime/git-layout.ts +219 -0
  211. package/src/runtime/index.ts +29 -0
  212. package/src/runtime/managed-block.ts +117 -0
  213. package/src/runtime/markdown-scan.ts +266 -0
  214. package/src/runtime/physical-path.ts +111 -0
  215. package/src/runtime/policy.ts +50 -2
  216. package/src/runtime/projected-flag.ts +7 -0
  217. package/src/runtime/projected-guidance.ts +1 -0
  218. package/src/runtime/runtime-directory.ts +5 -0
  219. package/src/runtime/runtime-document-manifest.ts +62 -11
  220. package/src/runtime/secret-guard.ts +162 -0
  221. package/src/runtime/secret-patterns.ts +397 -0
  222. package/src/runtime/secret-scan.ts +90 -0
  223. package/src/runtime/session-context.ts +98 -0
  224. package/src/runtime/session-kind.ts +13 -0
  225. package/src/runtime/shell-heredoc.ts +81 -0
  226. package/src/runtime/tokensave-route.ts +152 -0
  227. package/src/runtime/wrap-state.ts +44 -2
  228. package/src/runtime/write-atomic.ts +64 -0
  229. package/src/studio.ts +124 -0
  230. package/src/templates/capabilities/openspec-cap/mate-minimal/schema.yaml +14 -10
  231. package/src/templates/capabilities/openspec-cap/mate-minimal/templates/spec.md +3 -5
  232. package/src/templates/capabilities/openspec-cap/mate-v1/schema.yaml +18 -102
  233. package/src/templates/capabilities/openspec-cap/mate-v1/templates/spec.md +3 -5
  234. package/src/templates/capabilities/openspec-cap/openspec-conventions.yaml +20 -14
  235. package/src/templates/mate-skills/THIRD-PARTY-NOTICES.md +40 -0
  236. package/src/templates/mate-skills/agents/mate-apply-change/SKILL.md +134 -0
  237. package/src/templates/mate-skills/agents/mate-apply-change/references/mate-compact-apply.md +47 -0
  238. package/src/templates/mate-skills/agents/mate-apply-change/references/openspec-apply-change.md +200 -0
  239. package/src/templates/mate-skills/agents/mate-archive-change/SKILL.md +86 -0
  240. package/src/templates/mate-skills/{claude/mate-openspec-backfill → agents/mate-backfill-spec}/SKILL.md +11 -4
  241. package/src/templates/mate-skills/agents/mate-clarify-intent/SKILL.md +110 -0
  242. package/src/templates/mate-skills/agents/mate-explore-change/SKILL.md +66 -0
  243. package/src/templates/mate-skills/agents/mate-explore-change/references/openspec-explore.md +350 -0
  244. package/src/templates/mate-skills/agents/mate-grill-me/SKILL.md +11 -4
  245. package/src/templates/mate-skills/agents/mate-grill-with-docs/SKILL.md +2 -2
  246. package/src/templates/mate-skills/agents/mate-interview-me/SKILL.md +12 -5
  247. package/src/templates/mate-skills/agents/mate-propose-change/SKILL.md +108 -0
  248. package/src/templates/mate-skills/agents/mate-propose-change/references/mate-revise.md +47 -0
  249. package/src/templates/mate-skills/agents/mate-propose-change/references/openspec-propose.md +169 -0
  250. package/src/templates/mate-skills/agents/mate-propose-change/references/openspec-update-change.md +103 -0
  251. package/src/templates/mate-skills/agents/{mate-artifact-publish → mate-publish-artifact}/SKILL.md +111 -24
  252. package/src/templates/mate-skills/{claude/mate-artifact-publish → agents/mate-publish-artifact}/references/openspec.md +8 -5
  253. package/src/templates/mate-skills/agents/mate-show-me/SKILL.md +95 -16
  254. package/src/templates/mate-skills/agents/mate-simplify-code/SKILL.md +87 -68
  255. package/src/templates/mate-skills/claude/mate-apply-change/SKILL.md +134 -0
  256. package/src/templates/mate-skills/claude/mate-apply-change/references/mate-compact-apply.md +47 -0
  257. package/src/templates/mate-skills/claude/mate-apply-change/references/openspec-apply-change.md +200 -0
  258. package/src/templates/mate-skills/claude/mate-archive-change/SKILL.md +86 -0
  259. package/src/templates/mate-skills/{agents/mate-openspec-backfill → claude/mate-backfill-spec}/SKILL.md +11 -4
  260. package/src/templates/mate-skills/claude/mate-clarify-intent/SKILL.md +110 -0
  261. package/src/templates/mate-skills/claude/mate-explore-change/SKILL.md +66 -0
  262. package/src/templates/mate-skills/claude/mate-explore-change/references/openspec-explore.md +350 -0
  263. package/src/templates/mate-skills/claude/mate-grill-me/SKILL.md +11 -4
  264. package/src/templates/mate-skills/claude/mate-grill-with-docs/SKILL.md +2 -2
  265. package/src/templates/mate-skills/claude/mate-interview-me/SKILL.md +12 -5
  266. package/src/templates/mate-skills/claude/mate-propose-change/SKILL.md +108 -0
  267. package/src/templates/mate-skills/claude/mate-propose-change/references/mate-revise.md +47 -0
  268. package/src/templates/mate-skills/claude/mate-propose-change/references/openspec-propose.md +169 -0
  269. package/src/templates/mate-skills/claude/mate-propose-change/references/openspec-update-change.md +103 -0
  270. package/src/templates/mate-skills/claude/{mate-artifact-publish → mate-publish-artifact}/SKILL.md +111 -24
  271. package/src/templates/mate-skills/{agents/mate-artifact-publish → claude/mate-publish-artifact}/references/openspec.md +8 -5
  272. package/src/templates/mate-skills/claude/mate-show-me/SKILL.md +95 -16
  273. package/src/templates/mate-skills/claude/mate-simplify-code/SKILL.md +87 -68
  274. package/src/templates/mate-skills/openspec-references.ts +142 -0
  275. package/src/templates/root/TEMPLATE_AGENTS.md +2 -2
  276. package/src/tools/setup/__snapshots__/runtime-surface-golden.test.ts.snap +3938 -391
  277. package/src/tools/setup/capabilities/companion-mentions.ts +27 -0
  278. package/src/tools/setup/capabilities/context-mode.ts +56 -7
  279. package/src/tools/setup/capabilities/graphify-gate.ts +31 -0
  280. package/src/tools/setup/capabilities/graphify-secrets.ts +243 -0
  281. package/src/tools/setup/capabilities/graphify.ts +46 -7
  282. package/src/tools/setup/capabilities/openspec.ts +163 -272
  283. package/src/tools/setup/capabilities/react-doctor.ts +8 -1
  284. package/src/tools/setup/capabilities/rtk.ts +4 -0
  285. package/src/tools/setup/capabilities/tokensave.ts +113 -71
  286. package/src/tools/setup/context-services.ts +9 -17
  287. package/src/tools/setup/dynamic-plugins/install.ts +24 -28
  288. package/src/tools/setup/engine.ts +100 -23
  289. package/src/tools/setup/install-contract.ts +8 -0
  290. package/src/tools/setup/managed-output.ts +51 -0
  291. package/src/tools/setup/mate-skill-copies.ts +51 -0
  292. package/src/tools/setup/mate.ts +86 -11
  293. package/src/tools/setup/package-managers/uv.ts +73 -11
  294. package/src/tools/setup/plugin.ts +40 -0
  295. package/src/tools/setup/plugins/guidance.ts +7 -4
  296. package/src/tools/setup/providers/agent-file-sections.ts +4 -2
  297. package/src/tools/setup/providers/claude-attribution.ts +65 -0
  298. package/src/tools/setup/providers/claude-plugin-folders.ts +625 -0
  299. package/src/tools/setup/providers/claude-plugin-hooks.ts +51 -19
  300. package/src/tools/setup/providers/claude-worktree-plugins.ts +122 -0
  301. package/src/tools/setup/providers/claude.ts +290 -8
  302. package/src/tools/setup/providers/opencode.ts +180 -1
  303. package/src/tools/setup/utils.ts +18 -4
  304. package/src/tools/setup/working-repo-cleanup.ts +29 -1
  305. package/src/tools/setup/working-repo-local-state.ts +252 -75
  306. package/src/tools/setup.ts +183 -26
  307. package/studio-dist/client/assets/companion-view-Csva26Ir.js +1 -0
  308. package/studio-dist/client/assets/delivery-path-DJMpRmiY.js +1 -0
  309. package/studio-dist/client/assets/dist-Dm7MtyHc.js +5 -0
  310. package/studio-dist/client/assets/factory-B7l9ZQyx.js +4 -0
  311. package/studio-dist/client/assets/index-n6uo_92S.js +40 -0
  312. package/studio-dist/client/assets/preload-helper-BLdHbfdN.js +1 -0
  313. package/studio-dist/client/assets/prepaint-CD5OpmTM.js +24 -0
  314. package/studio-dist/client/assets/queries-CN3JwMBX.js +1 -0
  315. package/studio-dist/client/assets/react-CabXf2Ds.js +1 -0
  316. package/studio-dist/client/assets/report-time-Dc-KOqQu.js +1 -0
  317. package/studio-dist/client/assets/reports-C01RsnMA.js +1 -0
  318. package/studio-dist/client/assets/rolldown-runtime-WkwZ5CU-.js +1 -0
  319. package/studio-dist/client/assets/routes-4pbC-2Hj.js +1 -0
  320. package/studio-dist/client/assets/skills-CihQganl.js +1 -0
  321. package/studio-dist/client/assets/spec-areas-C2L48N4C.js +1 -0
  322. package/studio-dist/client/assets/specs-D24_35_K.js +1 -0
  323. package/studio-dist/client/assets/studio-DKxfi691.css +1 -0
  324. package/studio-dist/client/assets/studio-queries-rvbJupCy.js +3 -0
  325. package/studio-dist/client/assets/terminal-eU5fzQzv.css +1 -0
  326. package/studio-dist/client/assets/vault-Bd4CQiTK.js +1 -0
  327. package/studio-dist/client/assets/warnings-V_Ys51wJ.js +1 -0
  328. package/studio-dist/client/assets/wasm-inline-C2en61B5.js +1 -0
  329. package/studio-dist/client/assets/workflow-BJejeVwQ.js +1 -0
  330. package/studio-dist/server/assets/__23tanstack-start-server-fn-resolver-BQKuMdJW.js +3881 -0
  331. package/studio-dist/server/assets/_tanstack-start-manifest_v.js +85 -0
  332. package/studio-dist/server/assets/actions-Bvgj9eb8.js +54 -0
  333. package/studio-dist/server/assets/actions-D8erOphH.js +44 -0
  334. package/studio-dist/server/assets/companion-view-aBady57v.js +33 -0
  335. package/studio-dist/server/assets/createServerFn-F5sAOF8V.js +459 -0
  336. package/studio-dist/server/assets/createServerRpc-tK2lE9R2.js +11 -0
  337. package/studio-dist/server/assets/delivery-path-BkKNjgkf.js +778 -0
  338. package/studio-dist/server/assets/dist-DpJWKyCm.js +5582 -0
  339. package/studio-dist/server/assets/empty-plugin-adapters-Cipd4ZH4.js +4 -0
  340. package/studio-dist/server/assets/factory-D6xnjedJ.js +2385 -0
  341. package/studio-dist/server/assets/factory-DT3UzHlh.js +68 -0
  342. package/studio-dist/server/assets/model-PyPALjii.js +18 -0
  343. package/studio-dist/server/assets/prepaint-BMke0fo1.js +41 -0
  344. package/studio-dist/server/assets/queries-Ag2iL8q2.js +107 -0
  345. package/studio-dist/server/assets/react-COs0LHn-.js +51 -0
  346. package/studio-dist/server/assets/report-time-DAfzln-N.js +8 -0
  347. package/studio-dist/server/assets/reports-BnUNJVtx.js +126 -0
  348. package/studio-dist/server/assets/rolldown-runtime-DYf_mQCB.js +34 -0
  349. package/studio-dist/server/assets/router-BH--drIx.js +4298 -0
  350. package/studio-dist/server/assets/routes-khSDK1bV.js +361 -0
  351. package/studio-dist/server/assets/search-JAKurDNh.js +36 -0
  352. package/studio-dist/server/assets/shell-CboT2f66.js +51 -0
  353. package/studio-dist/server/assets/skills-MWYnWoKs.js +106 -0
  354. package/studio-dist/server/assets/spec-areas-DcnO6vW-.js +16 -0
  355. package/studio-dist/server/assets/specs-DE3w8hZP.js +155 -0
  356. package/studio-dist/server/assets/start-BW5ovN0k.js +33 -0
  357. package/studio-dist/server/assets/studio-BeltxxKt.js +216 -0
  358. package/studio-dist/server/assets/studio-queries-CLnP9kGu.js +3365 -0
  359. package/studio-dist/server/assets/utils-C9CX1kcy.js +221 -0
  360. package/studio-dist/server/assets/vault-BGulVoNh.js +70 -0
  361. package/studio-dist/server/assets/vault-CuyyhLyB.js +832 -0
  362. package/studio-dist/server/assets/views-Bd7cRr27.js +82 -0
  363. package/studio-dist/server/assets/warnings-BH05rOuG.js +15 -0
  364. package/studio-dist/server/assets/wasm-inline-CNeBKGwC.js +3 -0
  365. package/studio-dist/server/assets/workflow-BSuIKWqH.js +42 -0
  366. package/studio-dist/server/server.js +16220 -0
  367. package/wrappers/bin/graphify +52 -4
  368. package/wrappers/bin/openspec +33 -9
  369. package/wrappers/lib/graphify-gate.mjs +8 -0
  370. package/src/cli/commands/studio/views/client.ts +0 -654
  371. package/src/cli/commands/studio/views/companion-picker.tsx +0 -95
  372. package/src/cli/commands/studio/views/companion-selector.tsx +0 -94
  373. package/src/cli/commands/studio/views/dashboard/changes.tsx +0 -107
  374. package/src/cli/commands/studio/views/dashboard/index.tsx +0 -19
  375. package/src/cli/commands/studio/views/document.tsx +0 -842
  376. package/src/cli/commands/studio/views/error.tsx +0 -20
  377. package/src/cli/commands/studio/views/reports/index.tsx +0 -49
  378. package/src/cli/commands/studio/views/selection-fields.tsx +0 -14
  379. package/src/cli/commands/studio/views/skills/index.tsx +0 -87
  380. package/src/cli/commands/studio/views/specs/index.tsx +0 -157
  381. package/src/cli/commands/studio/views/styles.ts +0 -519
  382. package/src/cli/commands/studio/views/terminal.tsx +0 -484
  383. package/src/cli/commands/studio/views/vault/state.ts +0 -43
  384. package/src/cli/commands/studio/views/warnings.tsx +0 -21
  385. package/src/cli/commands/studio/views/workflow/index.tsx +0 -21
  386. package/src/cli/commands/studio/views/workflow/steps.ts +0 -337
  387. package/src/cli/commands/studio/views/workflow/transcript.tsx +0 -190
  388. package/src/lib/components/theme.ts +0 -2
  389. package/src/tools/setup/git-utils.ts +0 -30
  390. package/src/tools/setup/runtime-documents.ts +0 -291
@@ -0,0 +1,3881 @@
1
+ import { i as __toESM, t as __commonJSMin } from "./rolldown-runtime-DYf_mQCB.js";
2
+ import { v as isRedirect, y as redirect } from "./createServerFn-F5sAOF8V.js";
3
+ import { _ as protocolRelativePrefixRegex, a as deepEqual, c as functionalUpdate, d as hasOwn, g as nullReplaceEqualDeep, h as last, i as decodePath, l as getUrlScheme, n as arraysEqual, o as encodePathLikeUrl, r as createNull, t as DEFAULT_PROTOCOL_ALLOWLIST, u as hasKeys, v as replaceEqualDeep } from "./utils-C9CX1kcy.js";
4
+ // ../../node_modules/.bun/react@19.2.7/node_modules/react/cjs/react.production.js
5
+ /**
6
+ * @license React
7
+ * react.production.js
8
+ *
9
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
10
+ *
11
+ * This source code is licensed under the MIT license found in the
12
+ * LICENSE file in the root directory of this source tree.
13
+ */
14
+ var require_react_production = /* @__PURE__ */ __commonJSMin(((exports) => {
15
+ var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element");
16
+ var REACT_PORTAL_TYPE = Symbol.for("react.portal");
17
+ var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
18
+ var REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode");
19
+ var REACT_PROFILER_TYPE = Symbol.for("react.profiler");
20
+ var REACT_CONSUMER_TYPE = Symbol.for("react.consumer");
21
+ var REACT_CONTEXT_TYPE = Symbol.for("react.context");
22
+ var REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref");
23
+ var REACT_SUSPENSE_TYPE = Symbol.for("react.suspense");
24
+ var REACT_MEMO_TYPE = Symbol.for("react.memo");
25
+ var REACT_LAZY_TYPE = Symbol.for("react.lazy");
26
+ var REACT_ACTIVITY_TYPE = Symbol.for("react.activity");
27
+ var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
28
+ function getIteratorFn(maybeIterable) {
29
+ if (null === maybeIterable || "object" !== typeof maybeIterable) return null;
30
+ maybeIterable = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable["@@iterator"];
31
+ return "function" === typeof maybeIterable ? maybeIterable : null;
32
+ }
33
+ var ReactNoopUpdateQueue = {
34
+ isMounted: function() {
35
+ return !1;
36
+ },
37
+ enqueueForceUpdate: function() {},
38
+ enqueueReplaceState: function() {},
39
+ enqueueSetState: function() {}
40
+ };
41
+ var assign = Object.assign;
42
+ var emptyObject = {};
43
+ function Component(props, context, updater) {
44
+ this.props = props;
45
+ this.context = context;
46
+ this.refs = emptyObject;
47
+ this.updater = updater || ReactNoopUpdateQueue;
48
+ }
49
+ Component.prototype.isReactComponent = {};
50
+ Component.prototype.setState = function(partialState, callback) {
51
+ if ("object" !== typeof partialState && "function" !== typeof partialState && null != partialState) throw Error("takes an object of state variables to update or a function which returns an object of state variables.");
52
+ this.updater.enqueueSetState(this, partialState, callback, "setState");
53
+ };
54
+ Component.prototype.forceUpdate = function(callback) {
55
+ this.updater.enqueueForceUpdate(this, callback, "forceUpdate");
56
+ };
57
+ function ComponentDummy() {}
58
+ ComponentDummy.prototype = Component.prototype;
59
+ function PureComponent(props, context, updater) {
60
+ this.props = props;
61
+ this.context = context;
62
+ this.refs = emptyObject;
63
+ this.updater = updater || ReactNoopUpdateQueue;
64
+ }
65
+ var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
66
+ pureComponentPrototype.constructor = PureComponent;
67
+ assign(pureComponentPrototype, Component.prototype);
68
+ pureComponentPrototype.isPureReactComponent = !0;
69
+ var isArrayImpl = Array.isArray;
70
+ function noop() {}
71
+ var ReactSharedInternals = {
72
+ H: null,
73
+ A: null,
74
+ T: null,
75
+ S: null
76
+ };
77
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
78
+ function ReactElement(type, key, props) {
79
+ var refProp = props.ref;
80
+ return {
81
+ $$typeof: REACT_ELEMENT_TYPE,
82
+ type,
83
+ key,
84
+ ref: void 0 !== refProp ? refProp : null,
85
+ props
86
+ };
87
+ }
88
+ function cloneAndReplaceKey(oldElement, newKey) {
89
+ return ReactElement(oldElement.type, newKey, oldElement.props);
90
+ }
91
+ function isValidElement(object) {
92
+ return "object" === typeof object && null !== object && object.$$typeof === REACT_ELEMENT_TYPE;
93
+ }
94
+ function escape(key) {
95
+ var escaperLookup = {
96
+ "=": "=0",
97
+ ":": "=2"
98
+ };
99
+ return "$" + key.replace(/[=:]/g, function(match) {
100
+ return escaperLookup[match];
101
+ });
102
+ }
103
+ var userProvidedKeyEscapeRegex = /\/+/g;
104
+ function getElementKey(element, index) {
105
+ return "object" === typeof element && null !== element && null != element.key ? escape("" + element.key) : index.toString(36);
106
+ }
107
+ function resolveThenable(thenable) {
108
+ switch (thenable.status) {
109
+ case "fulfilled": return thenable.value;
110
+ case "rejected": throw thenable.reason;
111
+ default: switch ("string" === typeof thenable.status ? thenable.then(noop, noop) : (thenable.status = "pending", thenable.then(function(fulfilledValue) {
112
+ "pending" === thenable.status && (thenable.status = "fulfilled", thenable.value = fulfilledValue);
113
+ }, function(error) {
114
+ "pending" === thenable.status && (thenable.status = "rejected", thenable.reason = error);
115
+ })), thenable.status) {
116
+ case "fulfilled": return thenable.value;
117
+ case "rejected": throw thenable.reason;
118
+ }
119
+ }
120
+ throw thenable;
121
+ }
122
+ function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
123
+ var type = typeof children;
124
+ if ("undefined" === type || "boolean" === type) children = null;
125
+ var invokeCallback = !1;
126
+ if (null === children) invokeCallback = !0;
127
+ else switch (type) {
128
+ case "bigint":
129
+ case "string":
130
+ case "number":
131
+ invokeCallback = !0;
132
+ break;
133
+ case "object": switch (children.$$typeof) {
134
+ case REACT_ELEMENT_TYPE:
135
+ case REACT_PORTAL_TYPE:
136
+ invokeCallback = !0;
137
+ break;
138
+ case REACT_LAZY_TYPE: return invokeCallback = children._init, mapIntoArray(invokeCallback(children._payload), array, escapedPrefix, nameSoFar, callback);
139
+ }
140
+ }
141
+ if (invokeCallback) return callback = callback(children), invokeCallback = "" === nameSoFar ? "." + getElementKey(children, 0) : nameSoFar, isArrayImpl(callback) ? (escapedPrefix = "", null != invokeCallback && (escapedPrefix = invokeCallback.replace(userProvidedKeyEscapeRegex, "$&/") + "/"), mapIntoArray(callback, array, escapedPrefix, "", function(c) {
142
+ return c;
143
+ })) : null != callback && (isValidElement(callback) && (callback = cloneAndReplaceKey(callback, escapedPrefix + (null == callback.key || children && children.key === callback.key ? "" : ("" + callback.key).replace(userProvidedKeyEscapeRegex, "$&/") + "/") + invokeCallback)), array.push(callback)), 1;
144
+ invokeCallback = 0;
145
+ var nextNamePrefix = "" === nameSoFar ? "." : nameSoFar + ":";
146
+ if (isArrayImpl(children)) for (var i = 0; i < children.length; i++) nameSoFar = children[i], type = nextNamePrefix + getElementKey(nameSoFar, i), invokeCallback += mapIntoArray(nameSoFar, array, escapedPrefix, type, callback);
147
+ else if (i = getIteratorFn(children), "function" === typeof i) for (children = i.call(children), i = 0; !(nameSoFar = children.next()).done;) nameSoFar = nameSoFar.value, type = nextNamePrefix + getElementKey(nameSoFar, i++), invokeCallback += mapIntoArray(nameSoFar, array, escapedPrefix, type, callback);
148
+ else if ("object" === type) {
149
+ if ("function" === typeof children.then) return mapIntoArray(resolveThenable(children), array, escapedPrefix, nameSoFar, callback);
150
+ array = String(children);
151
+ throw Error("Objects are not valid as a React child (found: " + ("[object Object]" === array ? "object with keys {" + Object.keys(children).join(", ") + "}" : array) + "). If you meant to render a collection of children, use an array instead.");
152
+ }
153
+ return invokeCallback;
154
+ }
155
+ function mapChildren(children, func, context) {
156
+ if (null == children) return children;
157
+ var result = [], count = 0;
158
+ mapIntoArray(children, result, "", "", function(child) {
159
+ return func.call(context, child, count++);
160
+ });
161
+ return result;
162
+ }
163
+ function lazyInitializer(payload) {
164
+ if (-1 === payload._status) {
165
+ var ctor = payload._result;
166
+ ctor = ctor();
167
+ ctor.then(function(moduleObject) {
168
+ if (0 === payload._status || -1 === payload._status) payload._status = 1, payload._result = moduleObject;
169
+ }, function(error) {
170
+ if (0 === payload._status || -1 === payload._status) payload._status = 2, payload._result = error;
171
+ });
172
+ -1 === payload._status && (payload._status = 0, payload._result = ctor);
173
+ }
174
+ if (1 === payload._status) return payload._result.default;
175
+ throw payload._result;
176
+ }
177
+ var reportGlobalError = "function" === typeof reportError ? reportError : function(error) {
178
+ if ("object" === typeof window && "function" === typeof window.ErrorEvent) {
179
+ var event = new window.ErrorEvent("error", {
180
+ bubbles: !0,
181
+ cancelable: !0,
182
+ message: "object" === typeof error && null !== error && "string" === typeof error.message ? String(error.message) : String(error),
183
+ error
184
+ });
185
+ if (!window.dispatchEvent(event)) return;
186
+ } else if ("object" === typeof process && "function" === typeof process.emit) {
187
+ process.emit("uncaughtException", error);
188
+ return;
189
+ }
190
+ console.error(error);
191
+ };
192
+ var Children = {
193
+ map: mapChildren,
194
+ forEach: function(children, forEachFunc, forEachContext) {
195
+ mapChildren(children, function() {
196
+ forEachFunc.apply(this, arguments);
197
+ }, forEachContext);
198
+ },
199
+ count: function(children) {
200
+ var n = 0;
201
+ mapChildren(children, function() {
202
+ n++;
203
+ });
204
+ return n;
205
+ },
206
+ toArray: function(children) {
207
+ return mapChildren(children, function(child) {
208
+ return child;
209
+ }) || [];
210
+ },
211
+ only: function(children) {
212
+ if (!isValidElement(children)) throw Error("React.Children.only expected to receive a single React element child.");
213
+ return children;
214
+ }
215
+ };
216
+ exports.Activity = REACT_ACTIVITY_TYPE;
217
+ exports.Children = Children;
218
+ exports.Component = Component;
219
+ exports.Fragment = REACT_FRAGMENT_TYPE;
220
+ exports.Profiler = REACT_PROFILER_TYPE;
221
+ exports.PureComponent = PureComponent;
222
+ exports.StrictMode = REACT_STRICT_MODE_TYPE;
223
+ exports.Suspense = REACT_SUSPENSE_TYPE;
224
+ exports.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = ReactSharedInternals;
225
+ exports.__COMPILER_RUNTIME = {
226
+ __proto__: null,
227
+ c: function(size) {
228
+ return ReactSharedInternals.H.useMemoCache(size);
229
+ }
230
+ };
231
+ exports.cache = function(fn) {
232
+ return function() {
233
+ return fn.apply(null, arguments);
234
+ };
235
+ };
236
+ exports.cacheSignal = function() {
237
+ return null;
238
+ };
239
+ exports.cloneElement = function(element, config, children) {
240
+ if (null === element || void 0 === element) throw Error("The argument must be a React element, but you passed " + element + ".");
241
+ var props = assign({}, element.props), key = element.key;
242
+ if (null != config) for (propName in void 0 !== config.key && (key = "" + config.key), config) !hasOwnProperty.call(config, propName) || "key" === propName || "__self" === propName || "__source" === propName || "ref" === propName && void 0 === config.ref || (props[propName] = config[propName]);
243
+ var propName = arguments.length - 2;
244
+ if (1 === propName) props.children = children;
245
+ else if (1 < propName) {
246
+ for (var childArray = Array(propName), i = 0; i < propName; i++) childArray[i] = arguments[i + 2];
247
+ props.children = childArray;
248
+ }
249
+ return ReactElement(element.type, key, props);
250
+ };
251
+ exports.createContext = function(defaultValue) {
252
+ defaultValue = {
253
+ $$typeof: REACT_CONTEXT_TYPE,
254
+ _currentValue: defaultValue,
255
+ _currentValue2: defaultValue,
256
+ _threadCount: 0,
257
+ Provider: null,
258
+ Consumer: null
259
+ };
260
+ defaultValue.Provider = defaultValue;
261
+ defaultValue.Consumer = {
262
+ $$typeof: REACT_CONSUMER_TYPE,
263
+ _context: defaultValue
264
+ };
265
+ return defaultValue;
266
+ };
267
+ exports.createElement = function(type, config, children) {
268
+ var propName, props = {}, key = null;
269
+ if (null != config) for (propName in void 0 !== config.key && (key = "" + config.key), config) hasOwnProperty.call(config, propName) && "key" !== propName && "__self" !== propName && "__source" !== propName && (props[propName] = config[propName]);
270
+ var childrenLength = arguments.length - 2;
271
+ if (1 === childrenLength) props.children = children;
272
+ else if (1 < childrenLength) {
273
+ for (var childArray = Array(childrenLength), i = 0; i < childrenLength; i++) childArray[i] = arguments[i + 2];
274
+ props.children = childArray;
275
+ }
276
+ if (type && type.defaultProps) for (propName in childrenLength = type.defaultProps, childrenLength) void 0 === props[propName] && (props[propName] = childrenLength[propName]);
277
+ return ReactElement(type, key, props);
278
+ };
279
+ exports.createRef = function() {
280
+ return { current: null };
281
+ };
282
+ exports.forwardRef = function(render) {
283
+ return {
284
+ $$typeof: REACT_FORWARD_REF_TYPE,
285
+ render
286
+ };
287
+ };
288
+ exports.isValidElement = isValidElement;
289
+ exports.lazy = function(ctor) {
290
+ return {
291
+ $$typeof: REACT_LAZY_TYPE,
292
+ _payload: {
293
+ _status: -1,
294
+ _result: ctor
295
+ },
296
+ _init: lazyInitializer
297
+ };
298
+ };
299
+ exports.memo = function(type, compare) {
300
+ return {
301
+ $$typeof: REACT_MEMO_TYPE,
302
+ type,
303
+ compare: void 0 === compare ? null : compare
304
+ };
305
+ };
306
+ exports.startTransition = function(scope) {
307
+ var prevTransition = ReactSharedInternals.T, currentTransition = {};
308
+ ReactSharedInternals.T = currentTransition;
309
+ try {
310
+ var returnValue = scope(), onStartTransitionFinish = ReactSharedInternals.S;
311
+ null !== onStartTransitionFinish && onStartTransitionFinish(currentTransition, returnValue);
312
+ "object" === typeof returnValue && null !== returnValue && "function" === typeof returnValue.then && returnValue.then(noop, reportGlobalError);
313
+ } catch (error) {
314
+ reportGlobalError(error);
315
+ } finally {
316
+ null !== prevTransition && null !== currentTransition.types && (prevTransition.types = currentTransition.types), ReactSharedInternals.T = prevTransition;
317
+ }
318
+ };
319
+ exports.unstable_useCacheRefresh = function() {
320
+ return ReactSharedInternals.H.useCacheRefresh();
321
+ };
322
+ exports.use = function(usable) {
323
+ return ReactSharedInternals.H.use(usable);
324
+ };
325
+ exports.useActionState = function(action, initialState, permalink) {
326
+ return ReactSharedInternals.H.useActionState(action, initialState, permalink);
327
+ };
328
+ exports.useCallback = function(callback, deps) {
329
+ return ReactSharedInternals.H.useCallback(callback, deps);
330
+ };
331
+ exports.useContext = function(Context) {
332
+ return ReactSharedInternals.H.useContext(Context);
333
+ };
334
+ exports.useDebugValue = function() {};
335
+ exports.useDeferredValue = function(value, initialValue) {
336
+ return ReactSharedInternals.H.useDeferredValue(value, initialValue);
337
+ };
338
+ exports.useEffect = function(create, deps) {
339
+ return ReactSharedInternals.H.useEffect(create, deps);
340
+ };
341
+ exports.useEffectEvent = function(callback) {
342
+ return ReactSharedInternals.H.useEffectEvent(callback);
343
+ };
344
+ exports.useId = function() {
345
+ return ReactSharedInternals.H.useId();
346
+ };
347
+ exports.useImperativeHandle = function(ref, create, deps) {
348
+ return ReactSharedInternals.H.useImperativeHandle(ref, create, deps);
349
+ };
350
+ exports.useInsertionEffect = function(create, deps) {
351
+ return ReactSharedInternals.H.useInsertionEffect(create, deps);
352
+ };
353
+ exports.useLayoutEffect = function(create, deps) {
354
+ return ReactSharedInternals.H.useLayoutEffect(create, deps);
355
+ };
356
+ exports.useMemo = function(create, deps) {
357
+ return ReactSharedInternals.H.useMemo(create, deps);
358
+ };
359
+ exports.useOptimistic = function(passthrough, reducer) {
360
+ return ReactSharedInternals.H.useOptimistic(passthrough, reducer);
361
+ };
362
+ exports.useReducer = function(reducer, initialArg, init) {
363
+ return ReactSharedInternals.H.useReducer(reducer, initialArg, init);
364
+ };
365
+ exports.useRef = function(initialValue) {
366
+ return ReactSharedInternals.H.useRef(initialValue);
367
+ };
368
+ exports.useState = function(initialState) {
369
+ return ReactSharedInternals.H.useState(initialState);
370
+ };
371
+ exports.useSyncExternalStore = function(subscribe, getSnapshot, getServerSnapshot) {
372
+ return ReactSharedInternals.H.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
373
+ };
374
+ exports.useTransition = function() {
375
+ return ReactSharedInternals.H.useTransition();
376
+ };
377
+ exports.version = "19.2.7";
378
+ }));
379
+ // ../../node_modules/.bun/react@19.2.7/node_modules/react/index.js
380
+ var require_react = /* @__PURE__ */ __commonJSMin(((exports, module) => {
381
+ module.exports = require_react_production();
382
+ }));
383
+ // ../../node_modules/.bun/@tanstack+router-core@1.171.39/node_modules/@tanstack/router-core/dist/esm/not-found.js
384
+ /** Determine if a value is a TanStack Router not-found error. */
385
+ function isNotFound(obj) {
386
+ return obj?.isNotFound === true;
387
+ }
388
+ // ../../node_modules/.bun/@tanstack+router-core@1.171.39/node_modules/@tanstack/router-core/dist/esm/root.js
389
+ /** Stable identifier used for the root route in a route tree. */
390
+ var rootRouteId = "__root__";
391
+ // ../../node_modules/.bun/@tanstack+router-core@1.171.39/node_modules/@tanstack/router-core/dist/esm/path.js
392
+ /** Remove repeated slashes from a path string. */
393
+ function cleanPath(path) {
394
+ return path.replace(/\/{2,}/g, "/");
395
+ }
396
+ /** Trim leading slashes (except preserving root '/'). */
397
+ function trimPathLeft(path) {
398
+ return path === "/" ? path : path.replace(/^\/+/, "");
399
+ }
400
+ /** Trim trailing slashes (except preserving root '/'). */
401
+ function trimPathRight(path) {
402
+ const len = path.length;
403
+ return len > 1 && path[len - 1] === "/" ? path.replace(/\/+$/, "") : path;
404
+ }
405
+ /** Trim both leading and trailing slashes. */
406
+ function trimPath(path) {
407
+ return trimPathRight(trimPathLeft(path));
408
+ }
409
+ /** Remove a trailing slash from value when appropriate for comparisons. */
410
+ function removeTrailingSlash(value, basepath) {
411
+ if (value?.endsWith("/") && value !== "/" && value !== `${basepath}/`) return value.slice(0, -1);
412
+ return value;
413
+ }
414
+ /**
415
+ * Resolve a destination path against a base, honoring trailing-slash policy
416
+ * and supporting relative segments (`.`/`..`) and absolute `to` values.
417
+ *
418
+ * Internal: parameters are positional so the router's hot callers pass no
419
+ * options object.
420
+ */
421
+ function resolvePath(base, to, trailingSlash = "never", cache) {
422
+ if (to.includes("//")) to = cleanPath(to);
423
+ if (to.startsWith("/")) {
424
+ if (to.length === 1 || trailingSlash === "preserve") return to;
425
+ if (trailingSlash === "always") return to.endsWith("/") ? to : `${to}/`;
426
+ return to.endsWith("/") ? to.slice(0, -1) : to;
427
+ }
428
+ const isBase = to === ".";
429
+ let key;
430
+ if (cache) {
431
+ key = isBase ? base : base + "\0" + to;
432
+ const cached = cache.get(key);
433
+ if (cached) return cached;
434
+ }
435
+ let baseSegments;
436
+ if (isBase) baseSegments = base.split("/");
437
+ else {
438
+ if (base.includes("//")) base = cleanPath(base);
439
+ baseSegments = base.split("/");
440
+ while (baseSegments.length > 1 && last(baseSegments) === "") baseSegments.pop();
441
+ const toSegments = to.split("/");
442
+ for (let index = 0, length = toSegments.length; index < length; index++) {
443
+ const value = toSegments[index];
444
+ if (value === "") {
445
+ if (!index) baseSegments = [value];
446
+ else if (index === length - 1) baseSegments.push(value);
447
+ } else if (value === "..") {
448
+ if (baseSegments.length > 1) baseSegments.pop();
449
+ else baseSegments = [""];
450
+ } else if (value === ".") {} else baseSegments.push(value);
451
+ }
452
+ }
453
+ if (baseSegments.length > 1) {
454
+ if (last(baseSegments) === "") {
455
+ if (trailingSlash === "never") baseSegments.pop();
456
+ } else if (trailingSlash === "always") baseSegments.push("");
457
+ }
458
+ const joined = baseSegments.join("/");
459
+ const result = (isBase ? cleanPath(joined) : joined) || "/";
460
+ if (key && cache) cache.set(key, result);
461
+ return result;
462
+ }
463
+ /**
464
+ * Create a pre-compiled decode config from allowed characters.
465
+ * Created once for the router's fixed encoding configuration.
466
+ */
467
+ function compileDecodeCharMap(pathParamsAllowedCharacters) {
468
+ const charMap = new Map(pathParamsAllowedCharacters.map((char) => [encodeURIComponent(char), char]));
469
+ const regex = new RegExp([...charMap.keys()].join("|").replace(/[.*()]/g, "\\$&"), "g");
470
+ return (encoded) => encoded.replace(regex, (match) => charMap.get(match) ?? match);
471
+ }
472
+ /** A splat is missing when it has no value; `0` and `false` are stringified like any other param. */
473
+ function isMissingSplat(value) {
474
+ return value == null || value === "";
475
+ }
476
+ function encodeParam(key, value, decoder) {
477
+ if (typeof value !== "string") return "" + (value ?? void 0);
478
+ const splat = key === "_splat";
479
+ if (splat && (!value || /^[a-zA-Z0-9\-._~!/]*$/.test(value))) return value;
480
+ let encoded = encodeURIComponent(value);
481
+ if (splat) encoded = encoded.replaceAll("%2F", "/");
482
+ return decoder ? decoder(encoded) : encoded;
483
+ }
484
+ /** Substitute current values into parsed segments, optionally collecting raw params. */
485
+ function interpolatePath(path, segments, params, decoder, usedParams) {
486
+ const trailingSlash = path.endsWith("/") ? "/" : "";
487
+ let joined = "";
488
+ for (const part of segments) {
489
+ if (typeof part === "string") {
490
+ joined += part;
491
+ continue;
492
+ }
493
+ const [kind, key, prefix, rawSuffix] = part;
494
+ const splat = kind === 2;
495
+ const suffix = splat && rawSuffix !== void 0 ? rawSuffix + trailingSlash : rawSuffix;
496
+ let paramValue = params[key];
497
+ if (kind === 3 && paramValue == null) continue;
498
+ if (usedParams) {
499
+ usedParams[key] = paramValue;
500
+ if (splat) usedParams["*"] = paramValue;
501
+ }
502
+ if (splat && isMissingSplat(paramValue)) {
503
+ if (prefix === "/" && !suffix) continue;
504
+ paramValue = "";
505
+ }
506
+ joined += prefix + encodeParam(key, paramValue, decoder) + (suffix || "");
507
+ }
508
+ return joined + trailingSlash || "/";
509
+ }
510
+ // ../../node_modules/.bun/@tanstack+router-core@1.171.39/node_modules/@tanstack/router-core/dist/esm/sieve-cache.js
511
+ /**
512
+ * A fixed-capacity cache using the SIEVE eviction algorithm
513
+ * (https://cachemon.github.io/SIEVE-website/).
514
+ *
515
+ * Entries live in the Map's FIFO insertion order; a hit only flips a `visited`
516
+ * bit instead of relinking the entry, which makes `get` (by far the hottest
517
+ * operation here) one `Map.get` plus a boolean store. Eviction sweeps a `hand`
518
+ * from the oldest entry towards the newest, clearing `visited` bits until it
519
+ * finds an unvisited entry to drop, so entries touched since the last sweep
520
+ * survive one more round. This keeps LRU-like hit ratios while being
521
+ * scan-resistant.
522
+ */
523
+ function createSieveCache(max) {
524
+ const cache = /* @__PURE__ */ new Map();
525
+ let hand;
526
+ let newest;
527
+ return {
528
+ get(key) {
529
+ const entry = cache.get(key);
530
+ if (!entry) return;
531
+ entry.visited = true;
532
+ return entry.value;
533
+ },
534
+ set(key, value) {
535
+ const existing = cache.get(key);
536
+ if (existing) {
537
+ existing.value = value;
538
+ return;
539
+ }
540
+ if (cache.size >= max) {
541
+ let node = hand?.next().value;
542
+ while (!node || node.visited) {
543
+ if (node) node.visited = false;
544
+ else hand = cache.values();
545
+ node = hand.next().value;
546
+ }
547
+ if (node === newest) hand = void 0;
548
+ cache.delete(node.key);
549
+ }
550
+ const entry = {
551
+ key,
552
+ value,
553
+ visited: false
554
+ };
555
+ newest = entry;
556
+ cache.set(key, entry);
557
+ },
558
+ clear() {
559
+ cache.clear();
560
+ hand = void 0;
561
+ newest = void 0;
562
+ }
563
+ };
564
+ }
565
+ // ../../node_modules/.bun/@tanstack+router-core@1.171.39/node_modules/@tanstack/router-core/dist/esm/invariant.js
566
+ function invariant() {
567
+ throw new Error("Invariant failed");
568
+ }
569
+ // ../../node_modules/.bun/@tanstack+router-core@1.171.39/node_modules/@tanstack/router-core/dist/esm/new-process-route-tree.js
570
+ var SEGMENT_TYPE_INDEX = 4;
571
+ var SEGMENT_TYPE_PATHLESS = 5;
572
+ function getParamNames(data) {
573
+ const cached = data.names;
574
+ if (cached) return cached;
575
+ const keys = [];
576
+ for (const segment of data) if (typeof segment !== "string") keys.push(segment[1]);
577
+ return data.names = keys;
578
+ }
579
+ /** Parse one segment for matching and retain the same record for interpolation. */
580
+ function parseSegment(path, start, end) {
581
+ const part = path.slice(start, end);
582
+ if (part.charCodeAt(0) === 36) return part.length === 1 ? [
583
+ 2,
584
+ "_splat",
585
+ "",
586
+ void 0
587
+ ] : [
588
+ 1,
589
+ part.slice(1),
590
+ "",
591
+ ""
592
+ ];
593
+ const open = part.indexOf("{");
594
+ if (open >= 0) {
595
+ const close = part.indexOf("}", open);
596
+ const optional = part.charCodeAt(open + 1) === 45;
597
+ const nameStart = open + (optional ? 3 : 2);
598
+ if (close >= 0 && part.charCodeAt(nameStart - 1) === 36 && (!optional || nameStart < close)) {
599
+ const key = part.slice(nameStart, close);
600
+ return [
601
+ optional ? 3 : key ? 1 : 2,
602
+ key || "_splat",
603
+ part.slice(0, open),
604
+ path.slice(start + close + 1, key ? end : path.length)
605
+ ];
606
+ }
607
+ }
608
+ return part;
609
+ }
610
+ function parseSegments(defaultCaseSensitive, route, start, node, dynamicListsToSort, parentInterpolation) {
611
+ let cursor = start;
612
+ const path = route.fullPath ?? route.from;
613
+ const options = route.options;
614
+ const length = path.length;
615
+ const literalEnd = path.endsWith("/") ? length - 1 : length;
616
+ const caseSensitive = options?.caseSensitive ?? defaultCaseSensitive;
617
+ const parseParams = options?.params?.parse ?? options?.parseParams;
618
+ let interpolation;
619
+ let literalStart = parentInterpolation ? start - 1 : 0;
620
+ if (!node || path.includes("$")) {
621
+ interpolation = parentInterpolation?.slice() ?? [];
622
+ const tail = last(interpolation);
623
+ if (tail && typeof tail !== "string" && tail[0] === 2) {
624
+ interpolation[interpolation.length - 1] = [
625
+ tail[0],
626
+ tail[1],
627
+ tail[2],
628
+ tail[3] === void 0 ? void 0 : tail[3] + path.substring(start - (path[start - 2] === "/" ? 2 : 1), literalEnd)
629
+ ];
630
+ literalStart = length;
631
+ }
632
+ }
633
+ while (cursor < length) {
634
+ const start = cursor;
635
+ const next = path.indexOf("/", start);
636
+ let end = next === -1 ? length : next;
637
+ const segment = parseSegment(path, start, end);
638
+ cursor = end + 1;
639
+ let nextNode;
640
+ if (typeof segment === "string") {
641
+ if (!node) continue;
642
+ let name = segment;
643
+ let staticChildren;
644
+ if (caseSensitive) staticChildren = node.static ??= /* @__PURE__ */ new Map();
645
+ else {
646
+ name = segment.toLowerCase();
647
+ staticChildren = node.staticInsensitive ??= /* @__PURE__ */ new Map();
648
+ }
649
+ const existingNode = staticChildren.get(name);
650
+ if (existingNode) nextNode = existingNode;
651
+ else {
652
+ const next = createSegmentNode(node);
653
+ nextNode = next;
654
+ staticChildren.set(name, next);
655
+ }
656
+ } else {
657
+ const kind = segment[0];
658
+ let prefix = segment[2];
659
+ let suffix = segment[3] ?? "";
660
+ if (kind === 2) {
661
+ end = length;
662
+ cursor = end + 1;
663
+ }
664
+ if (interpolation && literalStart < end) {
665
+ if (literalStart < start - 1) interpolation.push(path.slice(literalStart, start - 1));
666
+ segment[2] = "/" + prefix;
667
+ if (kind === 2 && segment[3] !== void 0 && literalEnd < length) segment[3] = suffix.slice(0, -1);
668
+ interpolation.push(segment);
669
+ literalStart = end;
670
+ }
671
+ if (!node) continue;
672
+ const actuallyCaseSensitive = caseSensitive && !!(prefix || suffix);
673
+ if (!caseSensitive) {
674
+ prefix = prefix.toLowerCase();
675
+ suffix = suffix.toLowerCase();
676
+ }
677
+ const siblings = kind === 1 ? node.dynamic ??= [] : kind === 3 ? node.optional ??= [] : node.wildcard ??= [];
678
+ const existingNode = kind !== 2 && !parseParams && siblings.find((s) => !s.parse && s.caseSensitive === actuallyCaseSensitive && s.prefix === prefix && s.suffix === suffix);
679
+ if (existingNode) nextNode = existingNode;
680
+ else {
681
+ const next = createSegmentNode(node, kind, actuallyCaseSensitive, prefix, suffix);
682
+ nextNode = next;
683
+ siblings.push(next);
684
+ if (siblings.length === 2) dynamicListsToSort?.push(siblings);
685
+ }
686
+ }
687
+ node = nextNode;
688
+ }
689
+ if (interpolation && literalStart < literalEnd) interpolation.push(path.slice(literalStart, literalEnd));
690
+ const segmentData = interpolation?.slice();
691
+ if (!node) return segmentData;
692
+ if (parseParams && route.children && !route.isRoot && route.id && route.id.charCodeAt(route.id.lastIndexOf("/") + 1) === 95) {
693
+ const pathlessNode = createSegmentNode(node, SEGMENT_TYPE_PATHLESS);
694
+ (node.pathless ??= []).push(pathlessNode);
695
+ node = pathlessNode;
696
+ }
697
+ const isLeaf = (route.path || !route.children) && !route.isRoot;
698
+ if (isLeaf && literalEnd < length) {
699
+ const indexNode = createSegmentNode(node, SEGMENT_TYPE_INDEX);
700
+ node.index = indexNode;
701
+ node = indexNode;
702
+ }
703
+ node.parse = parseParams ?? null;
704
+ node.priority = options?.params?.priority ?? 0;
705
+ if (!node.route) {
706
+ node.data = segmentData;
707
+ if (isLeaf) node.route = route;
708
+ }
709
+ return [
710
+ node,
711
+ cursor,
712
+ segmentData
713
+ ];
714
+ }
715
+ function sortDynamic(a, b) {
716
+ if (a.parse && !b.parse) return -1;
717
+ if (!a.parse && b.parse) return 1;
718
+ if (a.parse && b.parse && (a.priority || b.priority)) return b.priority - a.priority;
719
+ if (a.prefix && b.prefix && a.prefix !== b.prefix) {
720
+ if (a.prefix.startsWith(b.prefix)) return -1;
721
+ if (b.prefix.startsWith(a.prefix)) return 1;
722
+ }
723
+ if (a.suffix && b.suffix && a.suffix !== b.suffix) {
724
+ if (a.suffix.endsWith(b.suffix)) return -1;
725
+ if (b.suffix.endsWith(a.suffix)) return 1;
726
+ }
727
+ if (a.prefix && !b.prefix) return -1;
728
+ if (!a.prefix && b.prefix) return 1;
729
+ if (a.suffix && !b.suffix) return -1;
730
+ if (!a.suffix && b.suffix) return 1;
731
+ if (a.caseSensitive && !b.caseSensitive) return -1;
732
+ if (!a.caseSensitive && b.caseSensitive) return 1;
733
+ return 0;
734
+ }
735
+ function createSegmentNode(parent, kind = 0, caseSensitive, prefix, suffix) {
736
+ return {
737
+ kind,
738
+ depth: parent ? parent.depth + 1 : 0,
739
+ pathless: null,
740
+ index: null,
741
+ static: null,
742
+ staticInsensitive: null,
743
+ dynamic: null,
744
+ optional: null,
745
+ wildcard: null,
746
+ route: null,
747
+ data: void 0,
748
+ parent,
749
+ parse: null,
750
+ priority: 0,
751
+ caseSensitive,
752
+ prefix,
753
+ suffix
754
+ };
755
+ }
756
+ function processRouteMasks(routeList, processedTree) {
757
+ const segmentTree = createSegmentNode();
758
+ const dynamicListsToSort = [];
759
+ function visit(route, start, parentNode, parentInterpolation) {
760
+ const [node, cursor, segments] = parseSegments(false, route, start, parentNode, dynamicListsToSort, parentInterpolation);
761
+ if (route.children) for (const child of route.children) visit(child, cursor, node, segments);
762
+ }
763
+ for (const route of routeList) visit(route, 1, segmentTree);
764
+ for (const nodes of dynamicListsToSort) nodes.sort(sortDynamic);
765
+ processedTree.masksTree = segmentTree;
766
+ processedTree.flatCache = createSieveCache(1e3);
767
+ }
768
+ /**
769
+ * Take an arbitrary list of routes, create a tree from them (if it hasn't been created already), and match a path against it.
770
+ */
771
+ function findFlatMatch(path, processedTree) {
772
+ path ||= "/";
773
+ const cached = processedTree.flatCache.get(path);
774
+ if (cached !== void 0) return cached;
775
+ const result = findMatch(path, processedTree.masksTree);
776
+ processedTree.flatCache.set(path, result);
777
+ return result;
778
+ }
779
+ /**
780
+ * @deprecated keep until v2 so that `router.matchRoute` can keep not caring about the actual route tree
781
+ */
782
+ function findSingleMatch(from, caseSensitive, fuzzy, path, processedTree) {
783
+ from ||= "/";
784
+ path ||= "/";
785
+ const key = caseSensitive ? `case\0${from}` : from;
786
+ let tree = processedTree.singleCache.get(key);
787
+ if (!tree) {
788
+ tree = createSegmentNode();
789
+ parseSegments(caseSensitive, { from }, 1, tree);
790
+ processedTree.singleCache.set(key, tree);
791
+ }
792
+ return findMatch(path, tree, fuzzy);
793
+ }
794
+ function findRouteMatch(path, processedTree, fuzzy = false) {
795
+ const key = fuzzy ? path : `nofuzz\0${path}`;
796
+ const cached = processedTree.matchCache.get(key);
797
+ if (cached !== void 0) return cached;
798
+ path ||= "/";
799
+ let result;
800
+ try {
801
+ result = findMatch(path, processedTree.segmentTree, fuzzy);
802
+ } catch (err) {
803
+ if (err instanceof URIError) result = null;
804
+ else throw err;
805
+ }
806
+ if (result) result.branch = buildRouteBranch(result.route);
807
+ processedTree.matchCache.set(key, result);
808
+ return result;
809
+ }
810
+ /**
811
+ * Processes a route tree into a segment trie for efficient path matching.
812
+ * Also builds lookup maps for routes by ID and by trimmed full path.
813
+ */
814
+ function processRouteTree(routeTree, caseSensitive = false) {
815
+ const segmentTree = createSegmentNode();
816
+ const dynamicListsToSort = [];
817
+ const routesById = {};
818
+ const routesByPath = {};
819
+ let index = 0;
820
+ function visit(route, start, parentNode, parentInterpolation) {
821
+ route.init(index);
822
+ if (route.id in routesById) invariant();
823
+ routesById[route.id] = route;
824
+ if (index !== 0 && route.path) {
825
+ const trimmedFullPath = trimPathRight(route.fullPath);
826
+ if (!routesByPath[trimmedFullPath] || route.fullPath.endsWith("/")) routesByPath[trimmedFullPath] = route;
827
+ }
828
+ index++;
829
+ const [node, cursor, segments] = parseSegments(caseSensitive, route, start, parentNode, dynamicListsToSort, parentInterpolation);
830
+ route._interpolation = segments;
831
+ if (route.children) for (const child of route.children) visit(child, cursor, node, segments);
832
+ }
833
+ visit(routeTree, 1, segmentTree);
834
+ for (const nodes of dynamicListsToSort) nodes.sort(sortDynamic);
835
+ return {
836
+ processedTree: {
837
+ segmentTree,
838
+ singleCache: createSieveCache(1e3),
839
+ matchCache: createSieveCache(1e3),
840
+ flatCache: null,
841
+ masksTree: null
842
+ },
843
+ routesById,
844
+ routesByPath
845
+ };
846
+ }
847
+ function findMatch(path, segmentTree, fuzzy = false) {
848
+ const parts = path.split("/");
849
+ const leaf = getNodeMatch(path, parts, segmentTree, fuzzy);
850
+ if (!leaf) return null;
851
+ const [rawParams] = extractParams(path, parts, leaf);
852
+ return {
853
+ route: leaf.node.route,
854
+ rawParams
855
+ };
856
+ }
857
+ /**
858
+ * This function is "resumable":
859
+ * - the `leaf` input can contain `extract` and `rawParams` properties from a previous `extractParams` call
860
+ * - the returned `state` can be passed back as `extract` in a future call to continue extracting params from where we left off
861
+ *
862
+ * Inputs are *not* mutated.
863
+ */
864
+ function extractParams(path, parts, leaf) {
865
+ const list = buildBranch(leaf.node);
866
+ const names = leaf.node.data && getParamNames(leaf.node.data);
867
+ const rawParams = Object.create(null);
868
+ /** which segment of the path we're currently processing */
869
+ let partIndex = leaf.extract?.part ?? 0;
870
+ /** which node of the route tree branch we're currently processing */
871
+ let nodeIndex = leaf.extract?.node ?? 0;
872
+ /** index of the 1st character of the segment we're processing in the path string */
873
+ let pathIndex = leaf.extract?.path ?? 0;
874
+ /** Next original parameter name, independent of pathless/static nodes. */
875
+ let paramIndex = leaf.extract?.param ?? 0;
876
+ for (; nodeIndex < list.length; partIndex++, nodeIndex++, pathIndex++) {
877
+ const node = list[nodeIndex];
878
+ if (node.kind === SEGMENT_TYPE_INDEX) break;
879
+ if (node.kind === SEGMENT_TYPE_PATHLESS) {
880
+ partIndex--;
881
+ pathIndex--;
882
+ continue;
883
+ }
884
+ const part = parts[partIndex];
885
+ const currentPathIndex = pathIndex;
886
+ if (part) pathIndex += part.length;
887
+ if (node.kind === 1 || node.kind === 3) {
888
+ const name = names[paramIndex++];
889
+ if (node.kind === 3 && leaf.skipped & 1 << nodeIndex) {
890
+ partIndex--;
891
+ pathIndex = currentPathIndex - 1;
892
+ continue;
893
+ }
894
+ const value = node.suffix || node.prefix ? part.substring(node.prefix.length, part.length - node.suffix.length) : part;
895
+ if (value || node.kind === 1) rawParams[name] = decodeURIComponent(value);
896
+ } else if (node.kind === 2) {
897
+ const n = node;
898
+ const value = path.substring(currentPathIndex + n.prefix.length, path.length - n.suffix.length);
899
+ const splat = decodeURIComponent(value);
900
+ rawParams["*"] = splat;
901
+ rawParams._splat = splat;
902
+ break;
903
+ }
904
+ }
905
+ if (leaf.rawParams) Object.assign(rawParams, leaf.rawParams);
906
+ return [rawParams, {
907
+ part: partIndex,
908
+ node: nodeIndex,
909
+ path: pathIndex,
910
+ param: paramIndex
911
+ }];
912
+ }
913
+ function buildRouteBranch(route) {
914
+ const list = [route];
915
+ while (route.parentRoute) {
916
+ route = route.parentRoute;
917
+ list.push(route);
918
+ }
919
+ list.reverse();
920
+ return list;
921
+ }
922
+ function buildBranch(node) {
923
+ const list = Array(node.depth + 1);
924
+ do {
925
+ list[node.depth] = node;
926
+ node = node.parent;
927
+ } while (node);
928
+ return list;
929
+ }
930
+ function getNodeMatch(path, parts, segmentTree, fuzzy) {
931
+ if (path === "/" && segmentTree.index) return {
932
+ node: segmentTree.index,
933
+ skipped: 0
934
+ };
935
+ const trailingSlash = !last(parts);
936
+ const pathIsIndex = trailingSlash && path !== "/";
937
+ const partsLength = parts.length - (trailingSlash ? 1 : 0);
938
+ const stack = [{
939
+ node: segmentTree,
940
+ index: 1,
941
+ skipped: 0,
942
+ statics: 0,
943
+ dynamics: 0,
944
+ optionals: 0
945
+ }];
946
+ let bestFuzzy = null;
947
+ let bestMatch = null;
948
+ while (stack.length) {
949
+ const frame = stack.pop();
950
+ const { node, index, skipped, statics, dynamics, optionals } = frame;
951
+ let { extract, rawParams } = frame;
952
+ if (node.kind === 2 && node.route && !isFrameMoreSpecific(bestMatch, frame)) continue;
953
+ if (node.parse) {
954
+ if (!validateParseParams(path, parts, frame)) continue;
955
+ rawParams = frame.rawParams;
956
+ extract = frame.extract;
957
+ }
958
+ if (fuzzy && node.route && node.kind !== SEGMENT_TYPE_INDEX && isFrameMoreSpecific(bestFuzzy, frame)) bestFuzzy = frame;
959
+ const isBeyondPath = index === partsLength;
960
+ if (isBeyondPath) {
961
+ if (node.route && (!pathIsIndex || node.kind === SEGMENT_TYPE_INDEX || node.kind === 2) && isFrameMoreSpecific(bestMatch, frame)) bestMatch = frame;
962
+ if (!node.optional && !node.wildcard && !node.index && !node.pathless) continue;
963
+ }
964
+ const part = isBeyondPath ? void 0 : parts[index];
965
+ let lowerPart;
966
+ if (isBeyondPath && node.index) {
967
+ const indexFrame = {
968
+ node: node.index,
969
+ index,
970
+ skipped,
971
+ statics,
972
+ dynamics,
973
+ optionals,
974
+ extract,
975
+ rawParams
976
+ };
977
+ let indexValid = true;
978
+ if (node.index.parse) {
979
+ if (!validateParseParams(path, parts, indexFrame)) indexValid = false;
980
+ }
981
+ if (indexValid) {
982
+ if (!dynamics && !optionals && !skipped && isPerfectStaticMatch(statics, partsLength)) return indexFrame;
983
+ if (isFrameMoreSpecific(bestMatch, indexFrame)) bestMatch = indexFrame;
984
+ }
985
+ }
986
+ if (node.wildcard) for (let i = node.wildcard.length - 1; i >= 0; i--) {
987
+ const segment = node.wildcard[i];
988
+ const { prefix, suffix } = segment;
989
+ if (prefix) {
990
+ if (isBeyondPath) continue;
991
+ if (!(segment.caseSensitive ? part : lowerPart ??= part.toLowerCase()).startsWith(prefix)) continue;
992
+ }
993
+ if (suffix) {
994
+ if (isBeyondPath) continue;
995
+ const end = parts.slice(index).join("/");
996
+ const suffixPart = end.slice(-suffix.length);
997
+ if ((segment.caseSensitive ? suffixPart : suffixPart.toLowerCase()) !== suffix || end.length - suffix.length < prefix.length) continue;
998
+ }
999
+ stack.push({
1000
+ node: segment,
1001
+ index: partsLength,
1002
+ skipped,
1003
+ statics,
1004
+ dynamics,
1005
+ optionals,
1006
+ extract,
1007
+ rawParams
1008
+ });
1009
+ }
1010
+ if (node.optional) {
1011
+ const nextSkipped = skipped | 1 << node.depth + 1;
1012
+ for (let i = node.optional.length - 1; i >= 0; i--) {
1013
+ const segment = node.optional[i];
1014
+ stack.push({
1015
+ node: segment,
1016
+ index,
1017
+ skipped: nextSkipped,
1018
+ statics,
1019
+ dynamics,
1020
+ optionals,
1021
+ extract,
1022
+ rawParams
1023
+ });
1024
+ }
1025
+ if (!isBeyondPath) for (let i = node.optional.length - 1; i >= 0; i--) {
1026
+ const segment = node.optional[i];
1027
+ const { prefix, suffix } = segment;
1028
+ if (prefix || suffix) {
1029
+ const casePart = segment.caseSensitive ? part : lowerPart ??= part.toLowerCase();
1030
+ if (prefix && !casePart.startsWith(prefix)) continue;
1031
+ if (suffix && casePart.indexOf(suffix, casePart.length - suffix.length) < prefix.length) continue;
1032
+ }
1033
+ stack.push({
1034
+ node: segment,
1035
+ index: index + 1,
1036
+ skipped,
1037
+ statics,
1038
+ dynamics,
1039
+ optionals: optionals + segmentScore(partsLength, index),
1040
+ extract,
1041
+ rawParams
1042
+ });
1043
+ }
1044
+ }
1045
+ if (!isBeyondPath && node.dynamic && part) for (let i = node.dynamic.length - 1; i >= 0; i--) {
1046
+ const segment = node.dynamic[i];
1047
+ const { prefix, suffix } = segment;
1048
+ if (prefix || suffix) {
1049
+ const casePart = segment.caseSensitive ? part : lowerPart ??= part.toLowerCase();
1050
+ if (prefix && !casePart.startsWith(prefix)) continue;
1051
+ if (suffix && casePart.indexOf(suffix, casePart.length - suffix.length) < prefix.length) continue;
1052
+ }
1053
+ stack.push({
1054
+ node: segment,
1055
+ index: index + 1,
1056
+ skipped,
1057
+ statics,
1058
+ dynamics: dynamics + segmentScore(partsLength, index),
1059
+ optionals,
1060
+ extract,
1061
+ rawParams
1062
+ });
1063
+ }
1064
+ if (!isBeyondPath && node.staticInsensitive) {
1065
+ const match = node.staticInsensitive.get(lowerPart ??= part.toLowerCase());
1066
+ if (match) stack.push({
1067
+ node: match,
1068
+ index: index + 1,
1069
+ skipped,
1070
+ statics: statics + segmentScore(partsLength, index),
1071
+ dynamics,
1072
+ optionals,
1073
+ extract,
1074
+ rawParams
1075
+ });
1076
+ }
1077
+ if (!isBeyondPath && node.static) {
1078
+ const match = node.static.get(part);
1079
+ if (match) stack.push({
1080
+ node: match,
1081
+ index: index + 1,
1082
+ skipped,
1083
+ statics: statics + segmentScore(partsLength, index),
1084
+ dynamics,
1085
+ optionals,
1086
+ extract,
1087
+ rawParams
1088
+ });
1089
+ }
1090
+ if (node.pathless) for (let i = node.pathless.length - 1; i >= 0; i--) {
1091
+ const segment = node.pathless[i];
1092
+ stack.push({
1093
+ node: segment,
1094
+ index,
1095
+ skipped,
1096
+ statics,
1097
+ dynamics,
1098
+ optionals,
1099
+ extract,
1100
+ rawParams
1101
+ });
1102
+ }
1103
+ }
1104
+ if (bestMatch) return bestMatch;
1105
+ if (fuzzy && bestFuzzy) {
1106
+ let sliceIndex = bestFuzzy.index;
1107
+ for (let i = 0; i < bestFuzzy.index; i++) sliceIndex += parts[i].length;
1108
+ const splat = sliceIndex === path.length ? "/" : path.slice(sliceIndex);
1109
+ bestFuzzy.rawParams ??= Object.create(null);
1110
+ bestFuzzy.rawParams["**"] = decodeURIComponent(splat);
1111
+ return bestFuzzy;
1112
+ }
1113
+ return null;
1114
+ }
1115
+ function segmentScore(partsLength, index) {
1116
+ return 2 ** (partsLength - index - 1);
1117
+ }
1118
+ function isPerfectStaticMatch(statics, partsLength) {
1119
+ return statics === 2 ** (partsLength - 1) - 1;
1120
+ }
1121
+ function validateParseParams(path, parts, frame) {
1122
+ let rawParams;
1123
+ let state;
1124
+ try {
1125
+ [rawParams, state] = extractParams(path, parts, frame);
1126
+ } catch {
1127
+ return null;
1128
+ }
1129
+ frame.rawParams = rawParams;
1130
+ frame.extract = state;
1131
+ if (!frame.node.parse) return true;
1132
+ try {
1133
+ if (frame.node.parse(rawParams) === false) return null;
1134
+ } catch {}
1135
+ return true;
1136
+ }
1137
+ function isFrameMoreSpecific(prev, next) {
1138
+ if (!prev) return true;
1139
+ return next.statics > prev.statics || next.statics === prev.statics && (next.dynamics > prev.dynamics || next.dynamics === prev.dynamics && (next.optionals > prev.optionals || next.optionals === prev.optionals && ((next.node.kind === SEGMENT_TYPE_INDEX) > (prev.node.kind === SEGMENT_TYPE_INDEX) || next.node.kind === SEGMENT_TYPE_INDEX === (prev.node.kind === SEGMENT_TYPE_INDEX) && next.node.depth > prev.node.depth)));
1140
+ }
1141
+ // ../../node_modules/.bun/@tanstack+router-core@1.171.39/node_modules/@tanstack/router-core/dist/esm/scroll-restoration.js
1142
+ function getSafeSessionStorage() {
1143
+ try {
1144
+ return sessionStorage;
1145
+ } catch {
1146
+ return;
1147
+ }
1148
+ }
1149
+ var storageKey = "tsr-scroll-restoration-v1_3";
1150
+ getSafeSessionStorage();
1151
+ /**
1152
+ * The default `getKey` function for `useScrollRestoration`.
1153
+ * It returns the `key` from the location state or the `href` of the location.
1154
+ *
1155
+ * The `location.href` is used as a fallback to support the use case where the location state is not available like the initial render.
1156
+ */
1157
+ var defaultGetScrollRestorationKey = (location) => {
1158
+ return location.state.__TSR_key || location.href;
1159
+ };
1160
+ // ../../node_modules/.bun/@tanstack+router-core@1.171.39/node_modules/@tanstack/router-core/dist/esm/qss.js
1161
+ /**
1162
+ * Program is a reimplementation of the `qss` package:
1163
+ * Copyright (c) Luke Edwards luke.edwards05@gmail.com, MIT License
1164
+ * https://github.com/lukeed/qss/blob/master/license.md
1165
+ *
1166
+ * This reimplementation uses modern browser APIs
1167
+ * (namely URLSearchParams) and TypeScript while still
1168
+ * maintaining the original functionality and interface.
1169
+ *
1170
+ * Update: this implementation has also been mangled to
1171
+ * fit exactly our use-case (single value per key in encoding).
1172
+ */
1173
+ /**
1174
+ * Encodes an object into a query string.
1175
+ * @param obj - The object to encode into a query string.
1176
+ * @param stringify - An optional custom stringify function.
1177
+ * @returns The encoded query string.
1178
+ * @example
1179
+ * ```
1180
+ * // Example input: encode({ token: 'foo', key: 'value' })
1181
+ * // Expected output: "token=foo&key=value"
1182
+ * ```
1183
+ */
1184
+ function encode(obj, stringify = String) {
1185
+ let result;
1186
+ for (const key in obj) {
1187
+ const val = obj[key];
1188
+ if (val !== void 0) (result ||= new URLSearchParams()).set(key, stringify(val));
1189
+ }
1190
+ return result ? result.toString() : "";
1191
+ }
1192
+ /**
1193
+ * Converts a string value to its appropriate type (string, number, boolean).
1194
+ * @param mix - The string value to convert.
1195
+ * @returns The converted value.
1196
+ * @example
1197
+ * // Example input: toValue("123")
1198
+ * // Expected output: 123
1199
+ */
1200
+ function toValue(str) {
1201
+ if (!str) return "";
1202
+ if (str === "false") return false;
1203
+ if (str === "true") return true;
1204
+ return +str * 0 === 0 && +str + "" === str ? +str : str;
1205
+ }
1206
+ /**
1207
+ * Decodes a query string into an object.
1208
+ * @param str - The query string to decode.
1209
+ * @returns The decoded key-value pairs in an object format.
1210
+ * @example
1211
+ * // Example input: decode("token=foo&key=value")
1212
+ * // Expected output: { "token": "foo", "key": "value" }
1213
+ */
1214
+ function decode(str) {
1215
+ const searchParams = new URLSearchParams(str);
1216
+ const result = Object.create(null);
1217
+ for (const [key, value] of searchParams.entries()) {
1218
+ const previousValue = result[key];
1219
+ if (previousValue == null) result[key] = toValue(value);
1220
+ else if (Array.isArray(previousValue)) previousValue.push(toValue(value));
1221
+ else result[key] = [previousValue, toValue(value)];
1222
+ }
1223
+ return result;
1224
+ }
1225
+ // ../../node_modules/.bun/@tanstack+router-core@1.171.39/node_modules/@tanstack/router-core/dist/esm/searchParams.js
1226
+ var jsonStart = /^(?:\s|["[{\d-]|fa|nu|tr)/;
1227
+ /** Default `parseSearch` that strips leading '?' and JSON-parses values. */
1228
+ var defaultParseSearch = parseSearchWith(JSON.parse);
1229
+ /** Default `stringifySearch` using JSON.stringify for complex values. */
1230
+ var defaultStringifySearch = stringifySearchWith(JSON.stringify, JSON.parse);
1231
+ /**
1232
+ * Build a `parseSearch` function using a provided JSON-like parser.
1233
+ *
1234
+ * The returned function strips a leading `?`, decodes values, and attempts to
1235
+ * JSON-parse string values using the given `parser`.
1236
+ *
1237
+ * @param parser Function to parse a string value (e.g. `JSON.parse`).
1238
+ * @returns A `parseSearch` function compatible with `Router` options.
1239
+ * @link https://tanstack.com/router/latest/docs/framework/react/guide/custom-search-param-serialization
1240
+ */
1241
+ function parseSearchWith(parser) {
1242
+ const isJsonParser = parser === JSON.parse;
1243
+ return (searchStr) => {
1244
+ if (searchStr[0] === "?") searchStr = searchStr.slice(1);
1245
+ const query = decode(searchStr);
1246
+ for (const key in query) {
1247
+ const value = query[key];
1248
+ if (typeof value === "string") {
1249
+ if (isJsonParser && !jsonStart.test(value)) continue;
1250
+ try {
1251
+ query[key] = parser(value);
1252
+ } catch (_err) {}
1253
+ }
1254
+ }
1255
+ return query;
1256
+ };
1257
+ }
1258
+ /**
1259
+ * Build a `stringifySearch` function using a provided serializer.
1260
+ *
1261
+ * Non-primitive values are serialized with `stringify`. If a `parser` is
1262
+ * supplied, string values that are parseable are re-serialized to ensure
1263
+ * symmetry with `parseSearch`.
1264
+ *
1265
+ * @param stringify Function to serialize a value (e.g. `JSON.stringify`).
1266
+ * @param parser Optional parser to detect parseable strings.
1267
+ * @returns A `stringifySearch` function compatible with `Router` options.
1268
+ * @link https://tanstack.com/router/latest/docs/framework/react/guide/custom-search-param-serialization
1269
+ */
1270
+ function stringifySearchWith(stringify, parser) {
1271
+ const isJsonParser = parser === JSON.parse;
1272
+ function stringifyValue(val) {
1273
+ if (val && typeof val === "object") try {
1274
+ return stringify(val);
1275
+ } catch (_err) {}
1276
+ else if (parser && typeof val === "string") {
1277
+ if (isJsonParser && !jsonStart.test(val)) return val;
1278
+ try {
1279
+ parser(val);
1280
+ return stringify(val);
1281
+ } catch (_err) {}
1282
+ }
1283
+ return val;
1284
+ }
1285
+ return (search) => {
1286
+ const searchStr = encode(search, stringifyValue);
1287
+ return searchStr ? `?${searchStr}` : "";
1288
+ };
1289
+ }
1290
+ // ../../node_modules/.bun/@tanstack+router-core@1.171.39/node_modules/@tanstack/router-core/dist/esm/rewrite.js
1291
+ /** Create a rewrite pair that strips/adds a basepath on input/output. */
1292
+ function rewriteBasepath(basepath, caseSensitive, rewrite) {
1293
+ const trimmedBasepath = trimPath(basepath);
1294
+ const normalizedBasepath = `/${trimmedBasepath}`;
1295
+ const checkBasepath = caseSensitive ? normalizedBasepath : normalizedBasepath.toLowerCase();
1296
+ const checkBasepathWithSlash = `${checkBasepath}/`;
1297
+ const basepathRewrite = {
1298
+ input: ({ url }) => {
1299
+ const pathname = caseSensitive ? url.pathname : url.pathname.toLowerCase();
1300
+ if (pathname === checkBasepath) url.pathname = "/";
1301
+ else if (pathname.startsWith(checkBasepathWithSlash)) url.pathname = url.pathname.slice(normalizedBasepath.length);
1302
+ return url;
1303
+ },
1304
+ output: ({ url }) => {
1305
+ url.pathname = cleanPath(`/${trimmedBasepath}${url.pathname}`);
1306
+ return url;
1307
+ }
1308
+ };
1309
+ return rewrite ? {
1310
+ input: ({ url }) => executeRewriteInput(rewrite, basepathRewrite.input({ url })),
1311
+ output: ({ url }) => basepathRewrite.output({ url: executeRewriteOutput(rewrite, url) })
1312
+ } : basepathRewrite;
1313
+ }
1314
+ /** Execute a location input rewrite if provided. */
1315
+ function executeRewriteInput(rewrite, url) {
1316
+ const res = rewrite?.input?.({ url });
1317
+ if (res) {
1318
+ if (typeof res === "string") return new URL(res);
1319
+ else if (res instanceof URL) return res;
1320
+ }
1321
+ return url;
1322
+ }
1323
+ /** Execute a location output rewrite if provided. */
1324
+ function executeRewriteOutput(rewrite, url) {
1325
+ const res = rewrite?.output?.({ url });
1326
+ if (res) {
1327
+ if (typeof res === "string") return new URL(res);
1328
+ else if (res instanceof URL) return res;
1329
+ }
1330
+ return url;
1331
+ }
1332
+ // ../../node_modules/.bun/@tanstack+router-core@1.171.39/node_modules/@tanstack/router-core/dist/esm/stores.js
1333
+ /** SSR non-reactive createMutableStore */
1334
+ function createNonReactiveMutableStore(initialValue) {
1335
+ let value = initialValue;
1336
+ return {
1337
+ get() {
1338
+ return value;
1339
+ },
1340
+ set(nextOrUpdater) {
1341
+ value = functionalUpdate(nextOrUpdater, value);
1342
+ }
1343
+ };
1344
+ }
1345
+ /** SSR non-reactive createReadonlyStore */
1346
+ function createNonReactiveReadonlyStore(read) {
1347
+ return { get() {
1348
+ return read();
1349
+ } };
1350
+ }
1351
+ function createRouterStores(initialLocation, config) {
1352
+ const { createMutableStore, createReadonlyStore, batch } = config;
1353
+ const byRoute = /* @__PURE__ */ new Map();
1354
+ const status = createMutableStore("idle");
1355
+ const location = createMutableStore(initialLocation);
1356
+ const resolvedLocation = createMutableStore(void 0);
1357
+ const ids = createMutableStore([]);
1358
+ const matches = createReadonlyStore(() => ids.get().map((id) => byRoute.get(id).get()));
1359
+ const __store = createReadonlyStore(() => ({
1360
+ status: status.get(),
1361
+ isLoading: status.get() === "pending",
1362
+ matches: matches.get(),
1363
+ location: location.get(),
1364
+ resolvedLocation: resolvedLocation.get()
1365
+ }));
1366
+ function getMatchStore(routeId) {
1367
+ let matchStore = byRoute.get(routeId);
1368
+ if (!matchStore) {
1369
+ matchStore = createMutableStore(void 0);
1370
+ byRoute.set(routeId, matchStore);
1371
+ }
1372
+ return matchStore;
1373
+ }
1374
+ const store = {
1375
+ status,
1376
+ location,
1377
+ resolvedLocation,
1378
+ ids,
1379
+ matches,
1380
+ byRoute,
1381
+ __store,
1382
+ getMatchStore,
1383
+ setMatches
1384
+ };
1385
+ function setMatches(nextMatches) {
1386
+ const previousIds = ids.get();
1387
+ const nextIds = nextMatches.map((match) => match.routeId);
1388
+ batch(() => {
1389
+ if (!arraysEqual(previousIds, nextIds)) ids.set(nextIds);
1390
+ for (const id of previousIds) if (!nextIds.includes(id)) byRoute.get(id).set(() => void 0);
1391
+ for (const nextMatch of nextMatches) {
1392
+ const matchStore = getMatchStore(nextMatch.routeId);
1393
+ if (matchStore.get() !== nextMatch) matchStore.set(nextMatch);
1394
+ }
1395
+ });
1396
+ }
1397
+ return store;
1398
+ }
1399
+ // ../../node_modules/.bun/@tanstack+history@1.162.5/node_modules/@tanstack/history/dist/esm/index.js
1400
+ var stateIndexKey = "__TSR_index";
1401
+ /**
1402
+ * Turn protocol-relative inputs such as "//evil.example" into paths
1403
+ * such as "/evil.example", keeping navigation on the current origin.
1404
+ *
1405
+ * For HTTP(S) URLs, WHATWG parsing ignores leading C0 controls and spaces,
1406
+ * removes tabs/newlines, and treats backslashes as slashes, so inputs like
1407
+ * "/\evil.example" also need normalization. This only allocates when those
1408
+ * rules would make the input protocol-relative.
1409
+ */
1410
+ var protocolRelativePrefix = /^[\x00-\x20]*(?:[\\/][\t\n\r]*){2,}/;
1411
+ function normalizeProtocolRelative(url) {
1412
+ const match = protocolRelativePrefix.exec(url);
1413
+ return match ? "/" + url.slice(match[0].length) : url;
1414
+ }
1415
+ function normalizeHref(href) {
1416
+ if (/[\x00-\x1f\x7f]/.test(href)) href = href.replace(/[\x00-\x1f\x7f]/g, (character) => " \n\r".includes(character) ? "" : encodeURIComponent(character));
1417
+ return normalizeProtocolRelative(href);
1418
+ }
1419
+ var noop = () => {};
1420
+ var ServerHistory = class {
1421
+ constructor(location) {
1422
+ this.location = location;
1423
+ }
1424
+ get length() {
1425
+ return 1;
1426
+ }
1427
+ get subscribers() {
1428
+ return this._subscribers ??= /* @__PURE__ */ new Set();
1429
+ }
1430
+ subscribe() {
1431
+ return noop;
1432
+ }
1433
+ push() {}
1434
+ replace() {}
1435
+ go() {}
1436
+ back() {}
1437
+ forward() {}
1438
+ canGoBack() {
1439
+ return false;
1440
+ }
1441
+ createHref(href) {
1442
+ return normalizeHref(href);
1443
+ }
1444
+ block() {
1445
+ return noop;
1446
+ }
1447
+ flush() {}
1448
+ destroy() {}
1449
+ notify() {}
1450
+ _getBlockers() {
1451
+ return [];
1452
+ }
1453
+ };
1454
+ /** A fixed request location; server navigation is a no-op. */
1455
+ function createServerHistory(href) {
1456
+ return new ServerHistory(parseHref(href, void 0));
1457
+ }
1458
+ function parseHref(href, state) {
1459
+ const sanitizedHref = normalizeHref(href);
1460
+ const hashIndex = sanitizedHref.indexOf("#");
1461
+ const searchIndex = sanitizedHref.indexOf("?");
1462
+ if (!state) {
1463
+ const key = createRandomKey();
1464
+ state = {
1465
+ [stateIndexKey]: 0,
1466
+ key,
1467
+ __TSR_key: key
1468
+ };
1469
+ }
1470
+ return {
1471
+ href: sanitizedHref,
1472
+ pathname: sanitizedHref.slice(0, hashIndex > -1 ? searchIndex > -1 ? Math.min(hashIndex, searchIndex) : hashIndex : searchIndex > -1 ? searchIndex : sanitizedHref.length),
1473
+ hash: hashIndex > -1 ? sanitizedHref.slice(hashIndex) : "",
1474
+ search: searchIndex > -1 ? sanitizedHref.slice(searchIndex, hashIndex === -1 ? void 0 : hashIndex) : "",
1475
+ state
1476
+ };
1477
+ }
1478
+ function createRandomKey() {
1479
+ return (Math.random() + 1).toString(36).slice(7);
1480
+ }
1481
+ // ../../node_modules/.bun/@tanstack+router-core@1.171.39/node_modules/@tanstack/router-core/dist/esm/router.js
1482
+ function isExternalUrl(url, origin) {
1483
+ return url.protocol !== "http:" && url.protocol !== "https:" || url.origin !== origin || !!url.username || !!url.password;
1484
+ }
1485
+ function getUrlPath(url) {
1486
+ return url.pathname + url.search + url.hash;
1487
+ }
1488
+ function routeNeedsLoad(route) {
1489
+ return route.options.loader || route.options.beforeLoad || route.lazyFn || route.options.component?.preload || route.options.pendingComponent?.preload;
1490
+ }
1491
+ /**
1492
+ * Compute whether path, href or hash changed between previous and current
1493
+ * resolved locations.
1494
+ */
1495
+ function getLocationChangeInfo(location, resolvedLocation) {
1496
+ return {
1497
+ fromLocation: resolvedLocation,
1498
+ toLocation: location,
1499
+ pathChanged: resolvedLocation?.pathname !== location.pathname,
1500
+ hrefChanged: resolvedLocation?.href !== location.href,
1501
+ hashChanged: resolvedLocation?.hash !== location.hash
1502
+ };
1503
+ }
1504
+ function lifecycleEnd(matches) {
1505
+ return matches.findIndex((match) => match.status === "error" || match.status === "notFound" || match._notFound) + 1;
1506
+ }
1507
+ /** Run route lifecycle callbacks in leave/enter/stay phases. */
1508
+ function runRouteLifecycle(router, previous, matches, previousEnd, nextEnd, owner) {
1509
+ if (previousEnd) previous = previous.slice(0, previousEnd);
1510
+ if (nextEnd) matches = matches.slice(0, nextEnd);
1511
+ for (const match of previous) {
1512
+ if (owner && router._tx !== owner) return;
1513
+ if (!matches.some((candidate) => candidate.routeId === match.routeId)) router.routesById[match.routeId].options.onLeave?.(match);
1514
+ }
1515
+ for (const match of matches) {
1516
+ if (owner && router._tx !== owner) return;
1517
+ router.routesById[match.routeId].options[previous.some((candidate) => candidate.routeId === match.routeId) ? "onStay" : "onEnter"]?.(match);
1518
+ }
1519
+ }
1520
+ /**
1521
+ * Core, framework-agnostic router engine that powers TanStack Router.
1522
+ *
1523
+ * Provides navigation, matching, loading, preloading, caching and event APIs
1524
+ * used by framework adapters (React/Solid). Prefer framework helpers like
1525
+ * `createRouter` in app code.
1526
+ *
1527
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/RouterType
1528
+ */
1529
+ var RouterCore = class {
1530
+ /**
1531
+ * @deprecated Use the `createRouter` function instead
1532
+ */
1533
+ constructor(options, getStoreConfig) {
1534
+ this.tempLocationKey = `${Math.round(Math.random() * 1e7)}`;
1535
+ this._scroll = { n: true };
1536
+ this.subscribers = /* @__PURE__ */ new Set();
1537
+ this._cache = /* @__PURE__ */ new Map();
1538
+ this._committed = [];
1539
+ this.startTransition = async (fn) => {
1540
+ fn();
1541
+ return false;
1542
+ };
1543
+ this.update = (newOptions) => {
1544
+ const prevOptions = this.options;
1545
+ this.options = {
1546
+ ...prevOptions,
1547
+ ...newOptions
1548
+ };
1549
+ this.isServer = this.options.isServer ?? true ?? typeof document === "undefined";
1550
+ this.protocolAllowlist = new Set(this.options.protocolAllowlist);
1551
+ if (!this.history || this.options.history && this.options.history !== this.history) {
1552
+ if (!this.options.history) {} else this.history = this.options.history;
1553
+ }
1554
+ this.origin = this.options.origin;
1555
+ if (!this.origin) this.origin = "http://localhost";
1556
+ const nextBasepath = this.options.basepath ?? "/";
1557
+ const nextRewriteOption = this.options.rewrite;
1558
+ const rewriteChanged = this.basepath !== nextBasepath || prevOptions?.rewrite !== nextRewriteOption || prevOptions?.caseSensitive !== this.options.caseSensitive;
1559
+ if (rewriteChanged) {
1560
+ this.basepath = nextBasepath;
1561
+ this.rewrite = nextBasepath !== "/" && trimPath(nextBasepath) ? rewriteBasepath(nextBasepath, this.options.caseSensitive, nextRewriteOption) : nextRewriteOption;
1562
+ }
1563
+ if (this.history) this.updateLatestLocation();
1564
+ if (this.options.routeTree !== this.routeTree || prevOptions?.caseSensitive !== this.options.caseSensitive) {
1565
+ this.routeTree = this.options.routeTree;
1566
+ let processRouteTreeResult;
1567
+ if (globalThis.__TSR_CACHE__ && globalThis.__TSR_CACHE__.routeTree === this.routeTree && globalThis.__TSR_CACHE__.caseSensitive === this.options.caseSensitive) processRouteTreeResult = globalThis.__TSR_CACHE__.processRouteTreeResult;
1568
+ else {
1569
+ processRouteTreeResult = this.buildRouteTree();
1570
+ if (globalThis.__TSR_CACHE__ === void 0) globalThis.__TSR_CACHE__ = {
1571
+ routeTree: this.routeTree,
1572
+ caseSensitive: this.options.caseSensitive,
1573
+ processRouteTreeResult
1574
+ };
1575
+ }
1576
+ this.setRoutes(processRouteTreeResult);
1577
+ }
1578
+ if (!this.stores) {
1579
+ if (this.latestLocation) {
1580
+ const config = this.getStoreConfig(this);
1581
+ this.batch = config.batch;
1582
+ this.stores = createRouterStores(this.latestLocation, config);
1583
+ }
1584
+ } else if (rewriteChanged) this.stores.location.set(this.latestLocation);
1585
+ };
1586
+ this.updateLatestLocation = () => {
1587
+ this.latestLocation = this.parseLocation(this.history.location, this.latestLocation);
1588
+ };
1589
+ this.buildRouteTree = () => {
1590
+ const result = processRouteTree(this.routeTree, this.options.caseSensitive);
1591
+ if (this.options.routeMasks) processRouteMasks(this.options.routeMasks, result.processedTree);
1592
+ return {
1593
+ ...result,
1594
+ resolvePathCache: createSieveCache(1e3)
1595
+ };
1596
+ };
1597
+ this.subscribe = (eventType, fn) => {
1598
+ const listener = {
1599
+ eventType,
1600
+ fn
1601
+ };
1602
+ this.subscribers.add(listener);
1603
+ return () => {
1604
+ this.subscribers.delete(listener);
1605
+ };
1606
+ };
1607
+ this.emit = (routerEvent) => {
1608
+ for (const listener of this.subscribers) if (listener.eventType === routerEvent.type) try {
1609
+ listener.fn(routerEvent);
1610
+ } catch (e) {
1611
+ console.error(e);
1612
+ }
1613
+ };
1614
+ this.parseLocation = (locationToParse, previousLocation) => {
1615
+ const parse = ({ pathname, search, hash, href }, state) => {
1616
+ if (!this.rewrite && !/[ \x00-\x1f\x7f\u0080-\uffff]/.test(pathname)) {
1617
+ const parsedSearch = this.options.parseSearch(search);
1618
+ const searchStr = this.options.stringifySearch(parsedSearch);
1619
+ return {
1620
+ href: pathname + searchStr + hash,
1621
+ publicHref: pathname + searchStr + hash,
1622
+ pathname: decodePath(pathname),
1623
+ external: false,
1624
+ searchStr,
1625
+ search: nullReplaceEqualDeep(previousLocation?.search, parsedSearch),
1626
+ hash: decodePath(hash.slice(1)),
1627
+ state: replaceEqualDeep(previousLocation?.state, state)
1628
+ };
1629
+ }
1630
+ const url = executeRewriteInput(this.rewrite, new URL(href, this.origin));
1631
+ const parsedSearch = this.options.parseSearch(url.search);
1632
+ const searchStr = this.options.stringifySearch(parsedSearch);
1633
+ url.search = searchStr;
1634
+ return {
1635
+ href: url.href.replace(url.origin, ""),
1636
+ publicHref: href,
1637
+ pathname: decodePath(normalizeProtocolRelative(url.pathname)),
1638
+ external: !!this.rewrite && isExternalUrl(url, this.origin),
1639
+ searchStr,
1640
+ search: nullReplaceEqualDeep(previousLocation?.search, parsedSearch),
1641
+ hash: decodePath(url.hash.slice(1)),
1642
+ state: replaceEqualDeep(previousLocation?.state, state)
1643
+ };
1644
+ };
1645
+ const location = parse(locationToParse, locationToParse.state);
1646
+ const { __tempLocation, __tempKey } = location.state;
1647
+ if (__tempLocation && (!__tempKey || __tempKey === this.tempLocationKey)) {
1648
+ const parsedTempLocation = parse(__tempLocation, {
1649
+ ...__tempLocation.state,
1650
+ __tempLocation: void 0,
1651
+ key: location.state.key,
1652
+ __TSR_key: location.state.__TSR_key
1653
+ });
1654
+ parsedTempLocation.maskedLocation = location;
1655
+ return parsedTempLocation;
1656
+ }
1657
+ return location;
1658
+ };
1659
+ this.matchRoutes = (pathnameOrNext, locationSearchOrOpts, opts) => {
1660
+ if (typeof pathnameOrNext === "string") return this.matchRoutesInternal({
1661
+ pathname: pathnameOrNext,
1662
+ search: locationSearchOrOpts
1663
+ }, opts);
1664
+ return this.matchRoutesInternal(pathnameOrNext, locationSearchOrOpts);
1665
+ };
1666
+ this.getMatchedRoutes = (pathname) => {
1667
+ const rawParams = Object.create(null);
1668
+ const match = findRouteMatch(trimPathRight(pathname), this.processedTree, true);
1669
+ if (match) Object.assign(rawParams, match.rawParams);
1670
+ return [
1671
+ match?.branch || [this.routesById["__root__"]],
1672
+ rawParams,
1673
+ match?.route
1674
+ ];
1675
+ };
1676
+ this.buildLocation = (opts) => {
1677
+ const build = (dest = {}) => {
1678
+ if (dest.href) {
1679
+ const parsed = parseHref(dest.href, {});
1680
+ dest = {
1681
+ ...dest,
1682
+ to: executeRewriteInput(this.rewrite, new URL(parsed.pathname, this.origin)).pathname,
1683
+ search: this.options.parseSearch(parsed.search),
1684
+ hash: parsed.hash.slice(1)
1685
+ };
1686
+ }
1687
+ const currentLocation = opts._fromLocation || this._pendingLocation || this.latestLocation;
1688
+ let lightweight;
1689
+ const current = () => {
1690
+ return currentLocation;
1691
+ };
1692
+ const currentMatch = () => lightweight ??= this.matchRoutesLightweight(current());
1693
+ const to = dest.to ? `${dest.to}` : ".";
1694
+ const nextTo = resolvePath(to[0] === "/" ? "" : dest.unsafeRelative === "path" ? current().pathname : dest.from ?? currentMatch()[1], to, this.options.trailingSlash, this.resolvePathCache);
1695
+ const destRoute = this.routesByPath[trimPathRight(nextTo)];
1696
+ const isTemplate = nextTo.includes("$");
1697
+ let destRoutes;
1698
+ if (destRoute) destRoutes = destRoute._branch ??= buildRouteBranch(destRoute);
1699
+ else if (isTemplate) destRoutes = [];
1700
+ else {
1701
+ const [matchedRoutes, rawParams, foundRoute] = this.getMatchedRoutes(nextTo);
1702
+ destRoutes = matchedRoutes;
1703
+ if (this.options.notFoundRoute && (!foundRoute || foundRoute.path !== "/" && rawParams["**"])) destRoutes = [...destRoutes, this.options.notFoundRoute];
1704
+ }
1705
+ const interpolation = isTemplate ? destRoute?._interpolation ?? parseSegments(false, { fullPath: nextTo }, 0) : void 0;
1706
+ let nextParams;
1707
+ for (const route of destRoutes) {
1708
+ const fn = route.options.params?.stringify ?? route.options.stringifyParams;
1709
+ if (fn) {
1710
+ const fromParams = currentMatch()[3];
1711
+ nextParams ??= resolveNextParams(dest.params, fromParams);
1712
+ if (!hasKeys(nextParams)) break;
1713
+ if (nextParams === fromParams) nextParams = Object.assign(createNull(), nextParams);
1714
+ try {
1715
+ Object.assign(nextParams, fn(nextParams));
1716
+ } catch {}
1717
+ }
1718
+ }
1719
+ nextParams ??= resolveNextParams(dest.params, needsInheritedParams(dest.params, interpolation) ? currentMatch()[3] : EMPTY_RECORD);
1720
+ const nextPathname = opts.leaveParams ? nextTo : normalizeProtocolRelative(decodePath(interpolation ? interpolatePath(nextTo, interpolation, nextParams, this.pathParamsDecoder) : nextTo));
1721
+ const middlewares = getSearchMiddlewares(destRoutes, opts._includeValidateSearch);
1722
+ const fromSearch = () => {
1723
+ let search = currentMatch()[2];
1724
+ if (opts._includeValidateSearch && this.options.search?.strict) {
1725
+ const validatedSearch = {};
1726
+ destRoutes.forEach((route) => {
1727
+ if (route.options.validateSearch) try {
1728
+ Object.assign(validatedSearch, validateSearch(route.options.validateSearch, {
1729
+ ...validatedSearch,
1730
+ ...search
1731
+ }));
1732
+ } catch {}
1733
+ });
1734
+ search = validatedSearch;
1735
+ }
1736
+ return search;
1737
+ };
1738
+ const nextSearch = middlewares.length ? applySearchMiddleware(middlewares, fromSearch(), dest) : dest.search === true ? fromSearch() : typeof dest.search === "function" ? dest.search(fromSearch()) : dest.search || EMPTY_RECORD;
1739
+ const searchStr = this.options.stringifySearch(nextSearch);
1740
+ const hash = dest.hash === true ? current().hash : typeof dest.hash === "function" ? dest.hash(current().hash) : dest.hash || void 0;
1741
+ const hashStr = hash ? `#${hash}` : "";
1742
+ const nextState = !dest.state ? EMPTY_RECORD : dest.state === true ? current().state : typeof dest.state === "function" ? dest.state(current().state) : dest.state;
1743
+ const fullPath = `${nextPathname}${searchStr}${hashStr}`;
1744
+ let href;
1745
+ let publicHref;
1746
+ let external = false;
1747
+ if (this.rewrite) {
1748
+ const url = new URL(fullPath, this.origin);
1749
+ const origin = url.origin;
1750
+ const rewrittenUrl = executeRewriteOutput(this.rewrite, url);
1751
+ href = getUrlPath(url);
1752
+ if (isExternalUrl(rewrittenUrl, origin)) {
1753
+ publicHref = rewrittenUrl.href;
1754
+ external = true;
1755
+ } else publicHref = normalizeProtocolRelative(getUrlPath(rewrittenUrl));
1756
+ } else {
1757
+ href = encodePathLikeUrl(fullPath);
1758
+ publicHref = href;
1759
+ }
1760
+ return {
1761
+ publicHref,
1762
+ href,
1763
+ pathname: nextPathname,
1764
+ search: nextSearch,
1765
+ searchStr,
1766
+ state: nextState,
1767
+ hash: hash ?? "",
1768
+ external,
1769
+ unmaskOnReload: dest.unmaskOnReload
1770
+ };
1771
+ };
1772
+ const next = build(opts);
1773
+ if (opts.mask) next.maskedLocation = build({
1774
+ from: opts.from,
1775
+ ...opts.mask
1776
+ });
1777
+ else if (this.options.routeMasks) {
1778
+ const match = findFlatMatch(next.pathname, this.processedTree);
1779
+ if (match) {
1780
+ const params = Object.assign(createNull(), match.rawParams);
1781
+ const { from: _from, params: maskParams, ...maskProps } = match.route;
1782
+ const nextParams = resolveNextParams(maskParams, params);
1783
+ next.maskedLocation = build({
1784
+ from: opts.from,
1785
+ ...maskProps,
1786
+ params: nextParams
1787
+ });
1788
+ }
1789
+ }
1790
+ return next;
1791
+ };
1792
+ this.commitLocation = async ({ viewTransition, ignoreBlocker, ...next }) => {};
1793
+ this.buildAndCommitLocation = ({ replace, resetScroll, hashScrollIntoView, viewTransition, ignoreBlocker, ...rest } = {}) => {
1794
+ return Promise.resolve();
1795
+ };
1796
+ this.navigate = async ({ to, reloadDocument, href, publicHref, ...rest }) => {};
1797
+ this.load = async (opts) => {
1798
+ return loadServerRoute(this, opts);
1799
+ };
1800
+ this.startViewTransition = (fn) => {
1801
+ this.shouldViewTransition ?? this.options.defaultViewTransition;
1802
+ this.shouldViewTransition = void 0;
1803
+ return fn();
1804
+ };
1805
+ this.invalidate = (opts) => {
1806
+ const committedMatches = this._committed;
1807
+ const filter = opts?.filter;
1808
+ const preloads = this._preloads;
1809
+ const invalidIds = /* @__PURE__ */ new Set();
1810
+ const consider = (match) => {
1811
+ if (!filter || filter(match)) invalidIds.add(match.id);
1812
+ };
1813
+ committedMatches.forEach(consider);
1814
+ this._cache.forEach(consider);
1815
+ preloads?.forEach((matches) => matches.forEach(consider));
1816
+ this._tx?.[3].forEach(consider);
1817
+ const abort = [];
1818
+ for (const [controller, matches] of preloads ?? []) if (matches.some((match) => invalidIds.has(match.id))) {
1819
+ preloads.delete(controller);
1820
+ abort.push(controller);
1821
+ }
1822
+ const invalidate = (d) => {
1823
+ if (invalidIds.has(d.id)) {
1824
+ const route = this.routesById[d.routeId];
1825
+ const next = {
1826
+ ...d,
1827
+ invalid: true,
1828
+ ...(opts?.forcePending || d.status === "error" || d.status === "notFound") && routeNeedsLoad(route) ? {
1829
+ status: "pending",
1830
+ error: void 0
1831
+ } : void 0
1832
+ };
1833
+ d._flight = void 0;
1834
+ return next;
1835
+ }
1836
+ return d;
1837
+ };
1838
+ this._committed = committedMatches.map(invalidate);
1839
+ for (const [id, match] of this._cache) if (invalidIds.has(id)) {
1840
+ match.invalid = true;
1841
+ if (opts?.forcePending) match.status = "pending";
1842
+ }
1843
+ for (const id of invalidIds) {
1844
+ const flight = this._flights?.get(id);
1845
+ this._flights?.delete(id);
1846
+ if (flight && !flight[2]) abort.push(flight[1]);
1847
+ }
1848
+ for (const controller of abort) controller.abort();
1849
+ this.shouldViewTransition = false;
1850
+ return this.load({ sync: opts?.sync });
1851
+ };
1852
+ this.resolveRedirect = (redirect) => {
1853
+ const options = redirect.options;
1854
+ let href = redirect.headers.get("Location") || options.href;
1855
+ if (!href) {
1856
+ const location = this.buildLocation(options);
1857
+ href = (location.maskedLocation ?? location).publicHref || "/";
1858
+ }
1859
+ let scheme;
1860
+ if (protocolRelativePrefixRegex.test(href) || (scheme = getUrlScheme(href)) && !this.protocolAllowlist.has(scheme)) throw new Error("Redirect blocked: unsafe protocol");
1861
+ if (scheme === "http:" || scheme === "https:") {
1862
+ const url = new URL(href);
1863
+ if (url.pathname.startsWith("//")) href = url.href;
1864
+ else if (!isExternalUrl(url, this.origin)) {
1865
+ href = getUrlPath(url);
1866
+ scheme = void 0;
1867
+ }
1868
+ }
1869
+ if (scheme) options.reloadDocument = true;
1870
+ options.href = href;
1871
+ redirect.headers.set("Location", href);
1872
+ return redirect;
1873
+ };
1874
+ this.clearCache = (opts) => {
1875
+ const cached = this._cache;
1876
+ const preloads = this._preloads;
1877
+ const filter = opts?.filter;
1878
+ const discarded = [];
1879
+ const discardedIds = [];
1880
+ for (const [id, match] of cached) if (!filter || filter(match)) {
1881
+ discardedIds.push(id);
1882
+ discarded.push(match);
1883
+ }
1884
+ const abort = [];
1885
+ for (const [controller, matches] of preloads ?? []) if (!filter || matches.some(filter)) {
1886
+ abort.push(controller);
1887
+ discarded.push(...matches);
1888
+ }
1889
+ for (const id of discardedIds) cached.delete(id);
1890
+ for (const controller of abort) preloads.delete(controller);
1891
+ for (const match of discarded) {
1892
+ const flight = match._flight;
1893
+ match._flight = void 0;
1894
+ if (flight && !--flight[2]) {
1895
+ if (this._flights?.get(match.id) === flight) this._flights.delete(match.id);
1896
+ abort.push(flight[1]);
1897
+ }
1898
+ }
1899
+ for (const controller of abort) controller.abort();
1900
+ };
1901
+ this.loadRouteChunk = loadRouteChunk;
1902
+ this.preloadRoute = (opts) => preloadClientRoute(this, opts);
1903
+ this.matchRoute = (location, opts) => {
1904
+ const matchLocation = {
1905
+ ...location,
1906
+ to: location.to ? resolvePath(location.from || "", location.to, this.options.trailingSlash, this.resolvePathCache) : void 0,
1907
+ params: location.params || {},
1908
+ leaveParams: true
1909
+ };
1910
+ const next = this.buildLocation(matchLocation);
1911
+ const isPending = this.stores.status.get() === "pending";
1912
+ if (opts?.pending && !isPending) return false;
1913
+ const baseLocation = opts?.pending ?? !isPending ? this.latestLocation : this.stores.resolvedLocation.get() || this.stores.location.get();
1914
+ const match = findSingleMatch(next.pathname, opts?.caseSensitive ?? false, opts?.fuzzy ?? false, baseLocation.pathname, this.processedTree);
1915
+ if (!match) return false;
1916
+ if (location.params) {
1917
+ if (!deepEqual(match.rawParams, location.params, true)) return false;
1918
+ }
1919
+ if (opts?.includeSearch ?? true) return deepEqual(baseLocation.search, next.search, true) ? match.rawParams : false;
1920
+ return match.rawParams;
1921
+ };
1922
+ this.getStoreConfig = getStoreConfig;
1923
+ if (options.pathParamsAllowedCharacters?.length) this.pathParamsDecoder = compileDecodeCharMap(options.pathParamsAllowedCharacters);
1924
+ this.update({
1925
+ defaultPreloadDelay: 50,
1926
+ defaultPendingMs: 1e3,
1927
+ defaultPendingMinMs: 500,
1928
+ context: void 0,
1929
+ ...options,
1930
+ caseSensitive: options.caseSensitive ?? false,
1931
+ notFoundMode: options.notFoundMode ?? "fuzzy",
1932
+ stringifySearch: options.stringifySearch ?? defaultStringifySearch,
1933
+ parseSearch: options.parseSearch ?? defaultParseSearch,
1934
+ protocolAllowlist: options.protocolAllowlist ?? DEFAULT_PROTOCOL_ALLOWLIST
1935
+ });
1936
+ }
1937
+ isShell() {
1938
+ return !!this.options.isShell;
1939
+ }
1940
+ get state() {
1941
+ return this.stores.__store.get();
1942
+ }
1943
+ setRoutes(caches) {
1944
+ Object.assign(this, caches);
1945
+ this.lightweightCache = /* @__PURE__ */ new WeakMap();
1946
+ const notFoundRoute = this.options.notFoundRoute;
1947
+ if (notFoundRoute) {
1948
+ notFoundRoute.init(99999999999);
1949
+ if (this.routesById[notFoundRoute.id] !== notFoundRoute) notFoundRoute._interpolation = parseSegments(false, notFoundRoute, 0);
1950
+ this.routesById[notFoundRoute.id] = notFoundRoute;
1951
+ }
1952
+ }
1953
+ matchRoutesInternal(next, opts) {
1954
+ const [initialMatchedRoutes, rawParams, foundRoute] = this.getMatchedRoutes(next.pathname);
1955
+ let matchedRoutes = initialMatchedRoutes;
1956
+ let isGlobalNotFound = false;
1957
+ if (foundRoute ? foundRoute.path !== "/" && rawParams["**"] : trimPathRight(next.pathname)) {
1958
+ if (this.options.notFoundRoute) matchedRoutes = [...matchedRoutes, this.options.notFoundRoute];
1959
+ else isGlobalNotFound = true;
1960
+ }
1961
+ const _notFoundRouteId = isGlobalNotFound ? findGlobalNotFoundRouteId(this.options.notFoundMode, matchedRoutes) : void 0;
1962
+ const matches = new Array(matchedRoutes.length);
1963
+ const committed = this._committed;
1964
+ const previousAt = (route, index) => {
1965
+ const match = committed[index];
1966
+ return match?.routeId === route.id ? match : route === this.options.notFoundRoute ? committed.find((candidate) => candidate.routeId === route.id) : void 0;
1967
+ };
1968
+ let strictParams;
1969
+ for (let index = 0; index < matchedRoutes.length; index++) {
1970
+ const route = matchedRoutes[index];
1971
+ const parentMatch = matches[index - 1];
1972
+ let preMatchSearch;
1973
+ let strictMatchSearch;
1974
+ let searchError;
1975
+ {
1976
+ const parentSearch = parentMatch?.search ?? next.search;
1977
+ const parentStrictSearch = parentMatch?._strictSearch ?? void 0;
1978
+ try {
1979
+ const strictSearch = validateSearch(route.options.validateSearch, { ...parentSearch }) ?? void 0;
1980
+ preMatchSearch = {
1981
+ ...parentSearch,
1982
+ ...strictSearch
1983
+ };
1984
+ strictMatchSearch = {
1985
+ ...parentStrictSearch,
1986
+ ...strictSearch
1987
+ };
1988
+ } catch (err) {
1989
+ let searchParamError = err;
1990
+ if (!(err instanceof SearchParamError)) searchParamError = new SearchParamError(err.message, { cause: err });
1991
+ if (opts?.throwOnError) throw searchParamError;
1992
+ preMatchSearch = parentSearch;
1993
+ strictMatchSearch = {};
1994
+ searchError = searchParamError;
1995
+ }
1996
+ }
1997
+ let loaderDeps = "";
1998
+ let loaderDepsHash = "";
1999
+ try {
2000
+ loaderDeps = route.options.loaderDeps?.({ search: preMatchSearch }) ?? "";
2001
+ loaderDepsHash = loaderDeps ? JSON.stringify(loaderDeps) || "" : "";
2002
+ } catch (cause) {
2003
+ if (opts?.throwOnError) throw cause;
2004
+ searchError ??= cause;
2005
+ }
2006
+ const usedParams = createNull();
2007
+ const interpolatedPath = route._interpolation ? interpolatePath(route.fullPath, route._interpolation, rawParams, this.pathParamsDecoder, usedParams) : route.fullPath;
2008
+ const matchId = route.id + interpolatedPath + loaderDepsHash;
2009
+ const previousMatch = previousAt(route, index);
2010
+ const existingMatch = this._cache.get(matchId) ?? (previousMatch?.id === matchId ? previousMatch : void 0);
2011
+ strictParams = existingMatch?._strictParams ?? Object.assign(usedParams, strictParams);
2012
+ let paramsError;
2013
+ if (!existingMatch) try {
2014
+ extractStrictParams(route, strictParams);
2015
+ } catch (err) {
2016
+ if (isNotFound(err) || isRedirect(err)) paramsError = err;
2017
+ else paramsError = new PathParamError(err.message, { cause: err });
2018
+ if (opts?.throwOnError) throw paramsError;
2019
+ }
2020
+ const cause = previousMatch ? "stay" : "enter";
2021
+ let match;
2022
+ if (existingMatch) match = {
2023
+ ...existingMatch,
2024
+ cause,
2025
+ search: previousMatch ? nullReplaceEqualDeep(previousMatch.search, preMatchSearch) : nullReplaceEqualDeep(existingMatch.search, preMatchSearch),
2026
+ _strictSearch: strictMatchSearch,
2027
+ searchError
2028
+ };
2029
+ else {
2030
+ const status = routeNeedsLoad(route) ? "pending" : "success";
2031
+ match = {
2032
+ id: matchId,
2033
+ ssr: void 0,
2034
+ index,
2035
+ routeId: route.id,
2036
+ params: previousMatch?.params ?? strictParams,
2037
+ _strictParams: strictParams,
2038
+ pathname: interpolatedPath,
2039
+ updatedAt: Date.now(),
2040
+ search: previousMatch ? nullReplaceEqualDeep(previousMatch.search, preMatchSearch) : preMatchSearch,
2041
+ _strictSearch: strictMatchSearch,
2042
+ searchError,
2043
+ status,
2044
+ isFetching: false,
2045
+ error: void 0,
2046
+ paramsError,
2047
+ context: {},
2048
+ abortController: opts?._controller ?? new AbortController(),
2049
+ cause,
2050
+ loaderDeps: previousMatch ? replaceEqualDeep(previousMatch.loaderDeps, loaderDeps) : loaderDeps,
2051
+ invalid: false,
2052
+ preload: false,
2053
+ staticData: route.options.staticData || {},
2054
+ fullPath: route.fullPath
2055
+ };
2056
+ }
2057
+ const _notFound = _notFoundRouteId === route.id;
2058
+ if (match._notFound && !_notFound) match.error = void 0;
2059
+ match._notFound = _notFound;
2060
+ matches[index] = match;
2061
+ }
2062
+ for (let index = 0; index < matches.length; index++) {
2063
+ const match = matches[index];
2064
+ match.params = match.cause === "stay" ? nullReplaceEqualDeep(match.params, strictParams) : strictParams;
2065
+ if (opts?._controller) match.context = {};
2066
+ }
2067
+ return matches;
2068
+ }
2069
+ /**
2070
+ * Lightweight route matching for buildLocation.
2071
+ * Only computes fullPath, accumulated search, and params - skipping expensive
2072
+ * operations like AbortController, loaderDeps, and full match objects.
2073
+ */
2074
+ matchRoutesLightweight(location) {
2075
+ const lastRouteId = last(this.stores.ids.get());
2076
+ const lastStateMatch = lastRouteId ? this.stores.byRoute.get(lastRouteId).get() : void 0;
2077
+ const lastStateMatchId = lastStateMatch?.id;
2078
+ const cached = this.lightweightCache.get(location);
2079
+ if (cached && cached[0] === lastStateMatchId) return cached[1];
2080
+ const [matchedRoutes, rawParams] = this.getMatchedRoutes(location.pathname);
2081
+ const lastRoute = last(matchedRoutes);
2082
+ const accumulatedSearch = { ...location.search };
2083
+ for (const route of matchedRoutes) try {
2084
+ Object.assign(accumulatedSearch, validateSearch(route.options.validateSearch, accumulatedSearch));
2085
+ } catch {}
2086
+ const canReuseParams = lastStateMatch && lastStateMatch.routeId === lastRoute.id && lastStateMatch.pathname === location.pathname;
2087
+ let params;
2088
+ if (canReuseParams) params = lastStateMatch.params;
2089
+ else {
2090
+ const strictParams = rawParams;
2091
+ for (const route of matchedRoutes) try {
2092
+ extractStrictParams(route, strictParams);
2093
+ } catch {}
2094
+ params = strictParams;
2095
+ }
2096
+ const result = [
2097
+ matchedRoutes,
2098
+ lastRoute.fullPath,
2099
+ accumulatedSearch,
2100
+ params
2101
+ ];
2102
+ this.lightweightCache.set(location, [lastStateMatchId, result]);
2103
+ return result;
2104
+ }
2105
+ };
2106
+ /** Error thrown when search parameter validation fails. */
2107
+ var SearchParamError = class extends Error {};
2108
+ /** Error thrown when path parameter parsing/validation fails. */
2109
+ var PathParamError = class extends Error {};
2110
+ function validateSearch(validateSearch, input) {
2111
+ if (validateSearch == null) return {};
2112
+ if ("~standard" in validateSearch) {
2113
+ const result = validateSearch["~standard"].validate(input);
2114
+ if (result instanceof Promise) throw new SearchParamError("Async validation not supported");
2115
+ if (result.issues) throw new SearchParamError(JSON.stringify(result.issues, void 0, 2), { cause: result });
2116
+ return result.value;
2117
+ }
2118
+ if ("parse" in validateSearch) return validateSearch.parse(input);
2119
+ if (typeof validateSearch === "function") return validateSearch(input);
2120
+ return {};
2121
+ }
2122
+ function resolveNextParams(spec, base) {
2123
+ if (spec === void 0 || spec === true) return base;
2124
+ const next = Object.create(null);
2125
+ if (spec === false || spec === null) return next;
2126
+ if (typeof spec === "function") {
2127
+ Object.assign(next, base);
2128
+ return Object.assign(next, spec(next));
2129
+ }
2130
+ return Object.assign(next, base, spec);
2131
+ }
2132
+ function needsInheritedParams(spec, interpolation) {
2133
+ if (typeof spec === "function") return true;
2134
+ if (!interpolation || spec === false || spec === null) return false;
2135
+ return spec === void 0 || spec === true || interpolation.some((part) => typeof part !== "string" && !hasOwn.call(spec, part[1]));
2136
+ }
2137
+ var EMPTY_RECORD = Object.freeze({});
2138
+ function getSearchMiddlewares(destRoutes, includeValidateSearch) {
2139
+ const middlewares = [];
2140
+ for (let i = 0; i < destRoutes.length; i++) {
2141
+ const routeOptions = destRoutes[i].options;
2142
+ if ("search" in routeOptions) {
2143
+ if (routeOptions.search?.middlewares) middlewares.push(...routeOptions.search.middlewares);
2144
+ } else if (routeOptions.preSearchFilters || routeOptions.postSearchFilters) {
2145
+ const legacyMiddleware = ({ search, next }) => {
2146
+ const result = next(routeOptions.preSearchFilters ? routeOptions.preSearchFilters.reduce((prev, next) => next(prev), search) : search);
2147
+ return routeOptions.postSearchFilters ? routeOptions.postSearchFilters.reduce((prev, next) => next(prev), result) : result;
2148
+ };
2149
+ middlewares.push(legacyMiddleware);
2150
+ }
2151
+ const routeValidateSearch = routeOptions.validateSearch;
2152
+ if (includeValidateSearch && routeValidateSearch) {
2153
+ const validate = ({ search, next, meta }) => {
2154
+ const result = next(search);
2155
+ try {
2156
+ const validated = validateSearch(routeValidateSearch, result);
2157
+ if (meta && validated) {
2158
+ for (const key in validated) if (!(key in result)) (meta.defaulted ||= /* @__PURE__ */ new Map()).set(key, validated[key]);
2159
+ }
2160
+ return {
2161
+ ...result,
2162
+ ...validated
2163
+ };
2164
+ } catch {}
2165
+ return result;
2166
+ };
2167
+ middlewares.push(validate);
2168
+ }
2169
+ }
2170
+ return middlewares;
2171
+ }
2172
+ function applySearchMiddleware(middlewares, search, dest) {
2173
+ const applyNext = (index, currentSearch, meta) => {
2174
+ if (index >= middlewares.length) {
2175
+ if (!dest.search) return {};
2176
+ if (dest.search === true) return currentSearch;
2177
+ const result = functionalUpdate(dest.search, currentSearch);
2178
+ if (meta) meta.explicit = result;
2179
+ return result;
2180
+ }
2181
+ const next = (newSearch, collectMeta) => {
2182
+ if (collectMeta) {
2183
+ const nextMeta = meta || {};
2184
+ return {
2185
+ search: applyNext(index + 1, newSearch, nextMeta),
2186
+ meta: nextMeta
2187
+ };
2188
+ }
2189
+ return applyNext(index + 1, newSearch, meta);
2190
+ };
2191
+ return middlewares[index]({
2192
+ search: currentSearch,
2193
+ next,
2194
+ meta
2195
+ });
2196
+ };
2197
+ return applyNext(0, search);
2198
+ }
2199
+ function findGlobalNotFoundRouteId(notFoundMode, routes) {
2200
+ if (notFoundMode !== "root") {
2201
+ let fallback;
2202
+ for (let i = routes.length - 1; i >= 0; i--) {
2203
+ const route = routes[i];
2204
+ if (route.options.notFoundComponent) return route.id;
2205
+ fallback ||= route.children && route.id;
2206
+ }
2207
+ if (fallback) return fallback;
2208
+ }
2209
+ return rootRouteId;
2210
+ }
2211
+ function extractStrictParams(route, accumulatedParams) {
2212
+ const parseParams = route.options.params?.parse ?? route.options.parseParams;
2213
+ if (parseParams) Object.assign(accumulatedParams, parseParams(accumulatedParams));
2214
+ }
2215
+ // ../../node_modules/.bun/@tanstack+router-core@1.171.39/node_modules/@tanstack/router-core/dist/esm/load-client.js
2216
+ function preloadComponent(route, type) {
2217
+ return route.options[type]?.preload?.();
2218
+ }
2219
+ function loadComponents(route, onPendingReady) {
2220
+ const component = preloadComponent(route, "component");
2221
+ let pending = preloadComponent(route, "pendingComponent");
2222
+ if (onPendingReady) {
2223
+ if (pending) pending = pending.then(onPendingReady);
2224
+ else onPendingReady();
2225
+ }
2226
+ if (component && pending) return Promise.all([component, pending]).then(() => {});
2227
+ return component ?? pending;
2228
+ }
2229
+ function loadRouteChunk(route, componentType, onPendingReady) {
2230
+ const afterLazy = () => componentType === false ? void 0 : componentType ? preloadComponent(route, componentType) : loadComponents(route, onPendingReady);
2231
+ const current = route._lazy;
2232
+ if (current) return current === true ? afterLazy() : current.then(afterLazy);
2233
+ if (!route.lazyFn) return afterLazy();
2234
+ const promise = route.lazyFn().then((lazyRoute) => {
2235
+ {
2236
+ const { id: _id, ...options } = lazyRoute.options;
2237
+ Object.assign(route.options, options);
2238
+ route._lazy = true;
2239
+ }
2240
+ }, (error) => {
2241
+ route._lazy = void 0;
2242
+ throw error;
2243
+ });
2244
+ route._lazy = promise;
2245
+ return promise.then(afterLazy);
2246
+ }
2247
+ /** Return the structural lane through the first terminal render boundary. */
2248
+ function _getRenderedMatches(matches) {
2249
+ const end = matches.findIndex((match) => match.status !== "success" || match._notFound) + 1;
2250
+ return end && end < matches.length ? matches.slice(0, end) : matches;
2251
+ }
2252
+ /**
2253
+ * Truthy when the transaction publishing `location` leaves `routeId` out of its
2254
+ * matches, so subscribers scoped to that route can skip the publication: the
2255
+ * route unmounts when the transaction commits, and a transaction that ends
2256
+ * otherwise is superseded or redirected by a newer publication. Only valid
2257
+ * synchronously inside the publication: the transaction's matches are emptied
2258
+ * at commit and before following a redirect. Publications without a matching
2259
+ * transaction (hydration) and scopes without a route never depart.
2260
+ */
2261
+ function _isRouteDeparting(router, routeId, location) {
2262
+ const tx = router._tx;
2263
+ return routeId && tx?.[2] === location && !tx[3].some((match) => match.routeId === routeId);
2264
+ }
2265
+ /** Return the lane whose document assets belong to the current presentation. */
2266
+ function _getAssetMatches(matches) {
2267
+ let end = matches.length;
2268
+ for (let index = 0; index < end; index++) {
2269
+ const match = matches[index];
2270
+ if (match._assetEnd !== void 0) {
2271
+ end = Math.min(end, Math.max(index + 1, match._assetEnd));
2272
+ continue;
2273
+ }
2274
+ if (match.status !== "success" || match._notFound) {
2275
+ end = index + 1;
2276
+ break;
2277
+ }
2278
+ }
2279
+ return end < matches.length ? matches.slice(0, end) : matches;
2280
+ }
2281
+ var SUCCESS$1 = 0;
2282
+ var ERROR$1 = 1;
2283
+ var NOT_FOUND$1 = 2;
2284
+ var REDIRECTED$1 = 3;
2285
+ var CANCELED_OUTCOME = [4];
2286
+ function isControl(result) {
2287
+ return typeof result[0] === "number";
2288
+ }
2289
+ function waitFor$1(value, signal) {
2290
+ if (signal.aborted) return Promise.race([Promise.reject(signal), value]);
2291
+ return new Promise((resolve, reject) => {
2292
+ const abort = () => reject(signal);
2293
+ signal.addEventListener("abort", abort, { once: true });
2294
+ Promise.resolve(value).then(resolve, reject).then(() => signal.removeEventListener("abort", abort));
2295
+ });
2296
+ }
2297
+ function getRoute$1(router, match) {
2298
+ return router.routesById[match.routeId];
2299
+ }
2300
+ function normalize$1(value, rejected, routeId) {
2301
+ if (isRedirect(value)) return [REDIRECTED$1, value];
2302
+ if (isNotFound(value)) {
2303
+ value.routeId ||= routeId;
2304
+ return [NOT_FOUND$1, value];
2305
+ }
2306
+ if (!rejected) return [SUCCESS$1, value];
2307
+ if (typeof value?.then === "function") value = new Error("A Promise was thrown", { cause: value });
2308
+ return [ERROR$1, value];
2309
+ }
2310
+ function normalizeError$1(route, cause) {
2311
+ let outcome = normalize$1(cause, true, route.id);
2312
+ if (outcome[0] !== ERROR$1) return outcome;
2313
+ try {
2314
+ route.options.onError?.(outcome[1]);
2315
+ } catch (onErrorCause) {
2316
+ outcome = normalize$1(onErrorCause, true, route.id);
2317
+ }
2318
+ return outcome;
2319
+ }
2320
+ function normalizeLaneError(router, lane, route, cause, options) {
2321
+ if (options[0].signal.aborted) return CANCELED_OUTCOME;
2322
+ return materializeRedirect$1(router, lane, route, normalizeError$1(route, cause), options);
2323
+ }
2324
+ async function contextualize$1(router, lane, options, end, planSuccessfulLane, retainedEnd) {
2325
+ const [location, matches] = lane;
2326
+ const signal = options[0].signal;
2327
+ const preload = !!options[3];
2328
+ for (let index = options[6] ?? 0; index < end; index++) {
2329
+ const match = matches[index];
2330
+ const route = getRoute$1(router, match);
2331
+ match.abortController = options[0];
2332
+ const parentContext = matches[index - 1]?.context ?? router.options.context ?? {};
2333
+ const common = {
2334
+ params: match.params,
2335
+ location,
2336
+ navigate: (opts) => router.navigate({
2337
+ ...opts,
2338
+ _fromLocation: location
2339
+ }),
2340
+ buildLocation: router.buildLocation,
2341
+ cause: preload ? "preload" : match.cause,
2342
+ abortController: options[0],
2343
+ preload,
2344
+ matches,
2345
+ routeId: route.id
2346
+ };
2347
+ try {
2348
+ const routeContext = match._ctx ||= route.options.context ? route.options.context({
2349
+ ...common,
2350
+ deps: match.loaderDeps,
2351
+ context: parentContext
2352
+ }) || {} : void 0;
2353
+ match.context = {
2354
+ ...parentContext,
2355
+ ...routeContext
2356
+ };
2357
+ } catch (cause) {
2358
+ releaseFlight(router, match);
2359
+ return [index, normalizeLaneError(router, lane, route, cause, options)];
2360
+ }
2361
+ if (signal.aborted) return [index, CANCELED_OUTCOME];
2362
+ const validationError = match.paramsError ?? match.searchError;
2363
+ if (validationError !== void 0) {
2364
+ releaseFlight(router, match);
2365
+ return [index, normalizeLaneError(router, lane, route, validationError, options)];
2366
+ }
2367
+ const beforeLoad = route.options.beforeLoad;
2368
+ if (!beforeLoad) continue;
2369
+ const previousStatus = match.status;
2370
+ if (index >= retainedEnd) {
2371
+ match.status = "pending";
2372
+ options[7]?.();
2373
+ }
2374
+ try {
2375
+ setFetching(router, match, "beforeLoad", options[0]);
2376
+ const value = beforeLoad({
2377
+ ...common,
2378
+ search: match.search,
2379
+ context: match.context,
2380
+ ...router.options.additionalContext
2381
+ });
2382
+ const result = await (typeof value?.then === "function" ? waitFor$1(value, signal) : value);
2383
+ if (signal.aborted) return [index, CANCELED_OUTCOME];
2384
+ const outcome = materializeRedirect$1(router, lane, route, normalize$1(result, false, route.id), options);
2385
+ if (outcome[0] !== SUCCESS$1) {
2386
+ releaseFlight(router, match);
2387
+ return [index, outcome];
2388
+ }
2389
+ match.context = {
2390
+ ...match.context,
2391
+ ...result
2392
+ };
2393
+ } catch (cause) {
2394
+ releaseFlight(router, match);
2395
+ return [index, normalizeLaneError(router, lane, route, cause, options)];
2396
+ } finally {
2397
+ match.status = previousStatus;
2398
+ setFetching(router, match, false, options[0]);
2399
+ }
2400
+ }
2401
+ planSuccessfulLane();
2402
+ }
2403
+ function releaseOwnedFlight(router, match, flight) {
2404
+ if (!flight || --flight[2]) return;
2405
+ if (router._flights?.get(match.id) === flight) {
2406
+ const current = router._tx;
2407
+ if (current && !current[0].signal.aborted && !current[3].includes(match) && current[3].some((candidate) => candidate.id === match.id) && current[3].some((candidate) => candidate.isFetching === "beforeLoad")) return;
2408
+ router._flights.delete(match.id);
2409
+ }
2410
+ return flight[1];
2411
+ }
2412
+ function releaseFlight(router, match) {
2413
+ const flight = match._flight;
2414
+ match._flight = void 0;
2415
+ releaseOwnedFlight(router, match, flight)?.abort();
2416
+ }
2417
+ /**
2418
+ * Not passing in a `next` ownership recipient
2419
+ * is equivalent to discarding the match resources
2420
+ */
2421
+ function transferMatchResources(router, previous, next, deferSameIdFlight) {
2422
+ const abort = [];
2423
+ for (const match of previous) if (!next?.includes(match)) {
2424
+ const flight = match._flight;
2425
+ match._flight = void 0;
2426
+ if (deferSameIdFlight && flight?.[2] === 1 && router._flights?.get(match.id) === flight && next?.some((candidate) => candidate.id === match.id)) flight[2] = 0;
2427
+ else {
2428
+ const controller = releaseOwnedFlight(router, match, flight);
2429
+ if (controller) abort.push(controller);
2430
+ }
2431
+ }
2432
+ for (const controller of abort) controller.abort();
2433
+ }
2434
+ function acquireMatchResources(matches) {
2435
+ for (const match of matches) {
2436
+ const flight = match._flight;
2437
+ if (flight) flight[2]++;
2438
+ }
2439
+ }
2440
+ function setFetching(router, match, value, owner) {
2441
+ match.isFetching = value;
2442
+ if (owner && router._tx?.[0] !== owner) return;
2443
+ const store = router.stores.byRoute.get(match.routeId);
2444
+ const presented = store?.get();
2445
+ if (presented?.id === match.id) store.set({
2446
+ ...presented,
2447
+ isFetching: value
2448
+ });
2449
+ }
2450
+ function getLoaderContext$1(router, lane, match, route, controller, parentMatchPromise, preload) {
2451
+ const location = lane[0];
2452
+ return {
2453
+ params: match.params,
2454
+ location,
2455
+ navigate: (opts) => router.navigate({
2456
+ ...opts,
2457
+ _fromLocation: location
2458
+ }),
2459
+ cause: preload ? "preload" : match.cause,
2460
+ abortController: controller,
2461
+ preload,
2462
+ deps: match.loaderDeps,
2463
+ parentMatchPromise,
2464
+ context: match.context,
2465
+ route,
2466
+ ...router.options.additionalContext
2467
+ };
2468
+ }
2469
+ async function loadResource(router, lane, match, route, loader, parentMatchPromise, options) {
2470
+ const owner = options[0];
2471
+ const signal = owner.signal;
2472
+ if (signal.aborted) return CANCELED_OUTCOME;
2473
+ if (!loader) return [SUCCESS$1, void 0];
2474
+ let flight = match._flight;
2475
+ setFetching(router, match, "loader", owner);
2476
+ try {
2477
+ if (!flight) {
2478
+ const controller = new AbortController();
2479
+ flight = [
2480
+ Promise.resolve().then(() => loader(getLoaderContext$1(router, lane, match, route, controller, parentMatchPromise, !!options[3]))).then((value) => normalize$1(value, false, route.id), (cause) => normalize$1(cause, true, route.id)).then((result) => {
2481
+ if (result[0] !== SUCCESS$1 && router._flights?.get(match.id) === flight) {
2482
+ router._flights.delete(match.id);
2483
+ if (!flight[2]) controller.abort();
2484
+ }
2485
+ return result[0] === ERROR$1 && flight[2] ? normalizeError$1(route, result[1]) : result;
2486
+ }),
2487
+ controller,
2488
+ 1
2489
+ ];
2490
+ (router._flights ??= /* @__PURE__ */ new Map()).set(match.id, flight);
2491
+ }
2492
+ match._flight = flight;
2493
+ match.abortController = flight[1];
2494
+ return materializeRedirect$1(router, lane, route, await waitFor$1(flight[0], signal), options);
2495
+ } catch (cause) {
2496
+ if (cause !== signal || !signal.aborted) throw cause;
2497
+ releaseFlight(router, match);
2498
+ return CANCELED_OUTCOME;
2499
+ } finally {
2500
+ setFetching(router, match, false, owner);
2501
+ }
2502
+ }
2503
+ function settleInto(match, result, preload) {
2504
+ if (result[0] === REDIRECTED$1) return;
2505
+ match.status = "success";
2506
+ match.error = void 0;
2507
+ if (result[0] === SUCCESS$1) {
2508
+ match.loaderData = result[1];
2509
+ match.invalid = false;
2510
+ match.updatedAt = Date.now();
2511
+ match.preload = preload;
2512
+ } else match.invalid = true;
2513
+ }
2514
+ function cacheLoaderMatch(router, match, planned) {
2515
+ const current = router._cache.get(match.id);
2516
+ if (current !== planned || router._committed.some((candidate) => candidate.id === match.id && candidate._flight === match._flight)) return;
2517
+ const cached = {
2518
+ ...match,
2519
+ _notFound: void 0,
2520
+ context: {}
2521
+ };
2522
+ if (cached._flight) cached._flight[2]++;
2523
+ router._cache.set(match.id, cached);
2524
+ if (current) releaseFlight(router, current);
2525
+ }
2526
+ function getParentSnapshot(match, outcome) {
2527
+ if (outcome[0] === ERROR$1 || outcome[0] === NOT_FOUND$1) return {
2528
+ ...match,
2529
+ status: outcome[0] === ERROR$1 ? "error" : "notFound",
2530
+ error: outcome[1],
2531
+ _flight: void 0
2532
+ };
2533
+ return match;
2534
+ }
2535
+ function createLoaderTask$1(router, lane, index, tasks, semanticParent, options, retainedEnd) {
2536
+ const match = lane[1][index];
2537
+ const route = getRoute$1(router, match);
2538
+ const preload = !!options[3];
2539
+ const plannedCacheMatch = router._cache.get(match.id);
2540
+ let configured;
2541
+ let reload = false;
2542
+ let reloadFailure;
2543
+ try {
2544
+ if (match.status === "success") {
2545
+ configured = route.options.shouldReload;
2546
+ if (typeof configured === "function") configured = configured(getLoaderContext$1(router, lane, match, route, options[0], semanticParent, preload));
2547
+ if (options[0].signal.aborted) reloadFailure = CANCELED_OUTCOME;
2548
+ }
2549
+ if (!reloadFailure) {
2550
+ if (match.status !== "success") reload = true;
2551
+ else {
2552
+ const staleAge = preload || match.preload ? route.options.preloadStaleTime ?? router.options.defaultPreloadStaleTime ?? 3e4 : route.options.staleTime ?? router.options.defaultStaleTime ?? 0;
2553
+ reload = !!(match.invalid || configured || configured === void 0 && Date.now() - match.updatedAt >= staleAge && (options[5] || match.cause === "enter" || options[2].some((candidate) => candidate.routeId === match.routeId && candidate.id !== match.id)));
2554
+ }
2555
+ }
2556
+ } catch (cause) {
2557
+ match.invalid = true;
2558
+ releaseFlight(router, match);
2559
+ reloadFailure = normalizeLaneError(router, lane, route, cause, options);
2560
+ }
2561
+ const routeLoader = route.options.loader;
2562
+ const isLoaderFn = typeof routeLoader === "function";
2563
+ const loader = isLoaderFn ? routeLoader : routeLoader?.handler;
2564
+ const preloadable = !preload || route.options.preload !== false;
2565
+ let donor = preloadable && routeLoader && true ? router._flights?.get(match.id) : void 0;
2566
+ if (donor === match._flight || reloadFailure) donor = void 0;
2567
+ else if (donor && !reload && !preload && configured === void 0) reload = true;
2568
+ else if (!reload) donor = void 0;
2569
+ const background = !!(routeLoader && reload && match.status === "success" && !preload && !options[4] && ((isLoaderFn ? void 0 : routeLoader.staleReloadMode) ?? router.options.defaultStaleReloadMode) !== "blocking");
2570
+ const loaded = reload && preloadable;
2571
+ const blocking = loaded && !background && (match.status !== "success" || !!routeLoader);
2572
+ const onReady = index >= retainedEnd ? options[7] : void 0;
2573
+ const onLazyReady = route.lazyFn && route._lazy !== true ? onReady : void 0;
2574
+ if (loaded && !routeLoader) {
2575
+ match.invalid = false;
2576
+ match.updatedAt = Date.now();
2577
+ }
2578
+ if (donor) donor[2]++;
2579
+ if (blocking) {
2580
+ const acceptedFlight = match._flight;
2581
+ match._flight = donor;
2582
+ releaseOwnedFlight(router, match, acceptedFlight)?.abort();
2583
+ if (index >= retainedEnd) match.status = "pending";
2584
+ onReady?.();
2585
+ }
2586
+ if (!loaded) match.isFetching = false;
2587
+ const outcome = !reloadFailure && blocking ? loadResource(router, lane, match, route, loader, semanticParent, options).then((result) => {
2588
+ settleInto(match, result, preload);
2589
+ if (result[0] === SUCCESS$1) {
2590
+ if (routeLoader && !options[0].signal.aborted) cacheLoaderMatch(router, match, plannedCacheMatch);
2591
+ if (index >= retainedEnd) match.status = "pending";
2592
+ }
2593
+ return result;
2594
+ }) : Promise.resolve(reloadFailure ?? [SUCCESS$1, match.loaderData]);
2595
+ const chunkFailure = (async () => {
2596
+ try {
2597
+ const chunk = loadRouteChunk(route, void 0, onLazyReady);
2598
+ if (chunk) await waitFor$1(chunk, options[0].signal);
2599
+ } catch (cause) {
2600
+ if (!lane[1].some((candidate, candidateIndex) => candidateIndex <= index && (candidate.status === "error" || candidate.status === "notFound" || candidate._notFound))) return [index, normalizeLaneError(router, lane, route, cause, options)];
2601
+ }
2602
+ const result = await outcome;
2603
+ if (blocking && result[0] === SUCCESS$1 && match.status === "pending" && !options[0].signal.aborted) {
2604
+ match.status = "success";
2605
+ onReady?.();
2606
+ }
2607
+ })();
2608
+ tasks.push([
2609
+ index,
2610
+ outcome,
2611
+ chunkFailure
2612
+ ]);
2613
+ if (!background) return outcome.then((result) => getParentSnapshot(match, result));
2614
+ const candidate = {
2615
+ ...match,
2616
+ status: "pending",
2617
+ preload: false,
2618
+ _flight: donor
2619
+ };
2620
+ match.invalid = false;
2621
+ match.isFetching = "loader";
2622
+ const backgroundOutcome = loadResource(router, lane, candidate, route, loader, semanticParent, options).then((result) => {
2623
+ match.isFetching = false;
2624
+ settleInto(candidate, result, false);
2625
+ return result;
2626
+ });
2627
+ (lane[2] ??= []).push([
2628
+ index,
2629
+ backgroundOutcome,
2630
+ chunkFailure,
2631
+ candidate
2632
+ ]);
2633
+ return backgroundOutcome.then((result) => getParentSnapshot(candidate, result));
2634
+ }
2635
+ async function getNotFoundBoundary$1(router, matches, indexed, signal, fallback = 0) {
2636
+ const cause = indexed?.[1][1];
2637
+ let index = cause?.routeId ? matches.findIndex((match) => match.routeId === cause.routeId) : indexed?.[0] ?? matches.length - 1;
2638
+ if (index < 0) index = 0;
2639
+ for (let i = index; i >= 0; i--) {
2640
+ const route = getRoute$1(router, matches[i]);
2641
+ try {
2642
+ const loading = loadRouteChunk(route, false);
2643
+ if (loading) await waitFor$1(loading, signal);
2644
+ } catch (cause) {
2645
+ if (cause === signal && signal.aborted) throw cause;
2646
+ }
2647
+ if (route.options.notFoundComponent) return i;
2648
+ }
2649
+ return cause?.routeId ? index : fallback;
2650
+ }
2651
+ function discardBackground(router, lane) {
2652
+ if (lane[2]) {
2653
+ transferMatchResources(router, lane[2].map((task) => task[3]));
2654
+ lane[2] = void 0;
2655
+ }
2656
+ }
2657
+ async function settleTasks(tasks, serialFailure, redirectTasks, gate) {
2658
+ let loaderFailure;
2659
+ try {
2660
+ await Promise.all(tasks.map((task) => task[1].then(async (outcome) => {
2661
+ const taskIndex = task[0];
2662
+ if (gate && taskIndex >= await gate) return;
2663
+ if (outcome[0] >= REDIRECTED$1) throw [taskIndex, outcome];
2664
+ if (!loaderFailure && outcome[0] !== SUCCESS$1) {
2665
+ loaderFailure = [taskIndex, outcome];
2666
+ await Promise.all((redirectTasks ?? []).map((nextTask) => {
2667
+ if (nextTask[0] <= taskIndex) return;
2668
+ return nextTask[1].then((nextOutcome) => {
2669
+ if (nextOutcome[0] === REDIRECTED$1) throw [nextTask[0], nextOutcome];
2670
+ });
2671
+ }));
2672
+ }
2673
+ })));
2674
+ } catch (cause) {
2675
+ return cause;
2676
+ }
2677
+ return serialFailure ?? loaderFailure;
2678
+ }
2679
+ function materializeRedirect$1(router, lane, route, outcome, options, failed) {
2680
+ while (outcome[0] === REDIRECTED$1) {
2681
+ const redirect = outcome[1];
2682
+ const redirectOptions = redirect.options;
2683
+ try {
2684
+ if (redirectOptions.href || redirect.headers.has("Location")) {
2685
+ router.resolveRedirect(redirect);
2686
+ if (redirectOptions.reloadDocument) return outcome;
2687
+ }
2688
+ if (redirectOptions.reloadDocument ? options[3] : options[1] >= 20) return outcome;
2689
+ const location = router.buildLocation({
2690
+ ...redirectOptions,
2691
+ _fromLocation: lane[0],
2692
+ _includeValidateSearch: true
2693
+ });
2694
+ const publicLocation = location.maskedLocation ?? location;
2695
+ if (publicLocation.external) {
2696
+ const resolved = redirect.clone();
2697
+ resolved.options = { ...redirectOptions };
2698
+ resolved.headers.set("Location", publicLocation.publicHref);
2699
+ router.resolveRedirect(resolved);
2700
+ return options[3] ? [REDIRECTED$1, resolved] : [
2701
+ REDIRECTED$1,
2702
+ resolved,
2703
+ publicLocation
2704
+ ];
2705
+ }
2706
+ return [
2707
+ REDIRECTED$1,
2708
+ redirect,
2709
+ location
2710
+ ];
2711
+ } catch (cause) {
2712
+ outcome = failed ? [ERROR$1, cause] : normalizeError$1(route, cause);
2713
+ failed = true;
2714
+ }
2715
+ }
2716
+ return outcome;
2717
+ }
2718
+ async function reduceLane(router, lane, tasks, controller, settlement, onReady) {
2719
+ const matches = lane[1];
2720
+ let failure = await settlement;
2721
+ let redirectLimitExceeded = false;
2722
+ const plannedBoundary = matches.findIndex((match) => match._notFound);
2723
+ const boundaryOf = (found) => found[1][0] === NOT_FOUND$1 ? getNotFoundBoundary$1(router, matches, found, controller.signal) : found[0];
2724
+ let readinessEnd = plannedBoundary < 0 ? matches.length : plannedBoundary;
2725
+ if ((failure?.[1][0] ?? 0) >= REDIRECTED$1) readinessEnd = 0;
2726
+ else if (failure) {
2727
+ readinessEnd = failure[2] ??= await boundaryOf(failure);
2728
+ for (const task of tasks) {
2729
+ if (task[0] >= readinessEnd) break;
2730
+ const outcome = await task[1];
2731
+ if (outcome[0] !== SUCCESS$1 && outcome[0] < REDIRECTED$1 && !("loaderData" in matches[task[0]])) {
2732
+ failure = [task[0], outcome];
2733
+ readinessEnd = failure[2] = await boundaryOf(failure);
2734
+ break;
2735
+ }
2736
+ }
2737
+ }
2738
+ for (const task of tasks) {
2739
+ if (task[0] >= readinessEnd) break;
2740
+ const chunkFailure = await task[2];
2741
+ if (!chunkFailure) continue;
2742
+ failure = chunkFailure;
2743
+ break;
2744
+ }
2745
+ if ((failure?.[1][0] ?? 0) >= REDIRECTED$1) {
2746
+ const outcome = failure[1];
2747
+ if (outcome[0] !== REDIRECTED$1 || outcome[1].options.reloadDocument || outcome[2]) {
2748
+ discardBackground(router, lane);
2749
+ return outcome;
2750
+ }
2751
+ redirectLimitExceeded = true;
2752
+ failure = [0, [ERROR$1, /* @__PURE__ */ new Error("Too many redirects")]];
2753
+ }
2754
+ const boundary = failure ? failure[2] ?? await boundaryOf(failure) : plannedBoundary;
2755
+ if (boundary >= 0) {
2756
+ const outcome = failure?.[1];
2757
+ const kind = outcome?.[0];
2758
+ const match = matches[boundary];
2759
+ const cause = outcome?.[1];
2760
+ const install = () => {
2761
+ if (outcome) {
2762
+ match._notFound = void 0;
2763
+ if (kind === ERROR$1) match.status = "error";
2764
+ else {
2765
+ cause.routeId = match.routeId;
2766
+ if (match.routeId === router.routeTree.id) {
2767
+ match.status = "success";
2768
+ match._notFound = true;
2769
+ } else match.status = "notFound";
2770
+ }
2771
+ match.error = cause;
2772
+ match.isFetching = false;
2773
+ }
2774
+ };
2775
+ install();
2776
+ if (!outcome) onReady?.();
2777
+ const route = getRoute$1(router, match);
2778
+ try {
2779
+ await waitFor$1(outcome ? Promise.resolve().then(() => loadRouteChunk(route, kind === ERROR$1 ? "errorComponent" : "notFoundComponent")) : Promise.all([loadRouteChunk(route), loadRouteChunk(route, "notFoundComponent")]), controller.signal);
2780
+ } catch (cause) {
2781
+ if (cause === controller.signal && controller.signal.aborted) {
2782
+ discardBackground(router, lane);
2783
+ return CANCELED_OUTCOME;
2784
+ }
2785
+ }
2786
+ if (!outcome) match.status = "success";
2787
+ else if (redirectLimitExceeded) {
2788
+ controller.abort();
2789
+ await Promise.all([
2790
+ ...tasks.map((task) => task[1]),
2791
+ ...tasks.map((task) => task[2]),
2792
+ ...(lane[2] ?? []).map((task) => task[1])
2793
+ ]);
2794
+ discardBackground(router, lane);
2795
+ transferMatchResources(router, matches);
2796
+ install();
2797
+ }
2798
+ }
2799
+ return lane;
2800
+ }
2801
+ async function projectLane$1(router, lane, signal, start = 0, end = lane[1].length) {
2802
+ const matches = lane[1];
2803
+ for (let index = start; index < end; index++) {
2804
+ const match = matches[index];
2805
+ const routeOptions = getRoute$1(router, match).options;
2806
+ if (routeOptions.head || routeOptions.scripts) try {
2807
+ const context = {
2808
+ ssr: router.options.ssr,
2809
+ matches,
2810
+ match,
2811
+ params: match.params,
2812
+ loaderData: match.loaderData
2813
+ };
2814
+ const [head, scripts] = await waitFor$1(Promise.all([routeOptions.head?.(context), routeOptions.scripts?.(context)]), signal);
2815
+ match.meta = head?.meta;
2816
+ match.links = head?.links;
2817
+ match.headScripts = head?.scripts;
2818
+ match.styles = head?.styles;
2819
+ match.scripts = scripts;
2820
+ } catch (cause) {
2821
+ if (cause === signal && signal.aborted) break;
2822
+ console.error(cause);
2823
+ }
2824
+ if (match.status !== "success" || match._notFound) break;
2825
+ }
2826
+ return lane;
2827
+ }
2828
+ async function executeClientLane(router, location, matches, options) {
2829
+ const matched = [location, matches];
2830
+ const signal = options[0].signal;
2831
+ let reduced;
2832
+ try {
2833
+ const presented = router.stores.matches.get();
2834
+ let plannedBoundary = matches.findIndex((match) => match._notFound);
2835
+ if (router.options.notFoundMode !== "root" && plannedBoundary >= 0) {
2836
+ const boundary = await getNotFoundBoundary$1(router, matches, void 0, signal, plannedBoundary);
2837
+ matches[plannedBoundary]._notFound = void 0;
2838
+ matches[boundary]._notFound = true;
2839
+ plannedBoundary = boundary;
2840
+ }
2841
+ let end = plannedBoundary < 0 ? matches.length : plannedBoundary + 1;
2842
+ let retainedEnd = 0;
2843
+ while (retainedEnd < end && retainedEnd !== plannedBoundary) {
2844
+ const match = matches[retainedEnd];
2845
+ const committed = options[2][retainedEnd];
2846
+ const visible = presented[retainedEnd];
2847
+ if (committed?.id !== match.id || committed.status !== "success" || match.preload || visible?.id !== match.id || visible.status !== "success") break;
2848
+ retainedEnd++;
2849
+ if (committed._notFound || visible._notFound) break;
2850
+ }
2851
+ const tasks = [];
2852
+ const start = options[6] ?? 0;
2853
+ let semanticParent = start ? Promise.resolve(matches[start - 1]) : void 0;
2854
+ const planSuccessfulLane = () => {
2855
+ for (let index = start; index < end; index++) {
2856
+ if (signal.aborted) break;
2857
+ semanticParent = createLoaderTask$1(router, matched, index, tasks, semanticParent, options, retainedEnd);
2858
+ }
2859
+ };
2860
+ const failure = await contextualize$1(router, matched, options, end, planSuccessfulLane, retainedEnd);
2861
+ if (failure) {
2862
+ options[4] = true;
2863
+ end = failure[0];
2864
+ if (failure[1][0] === NOT_FOUND$1) {
2865
+ const boundary = await getNotFoundBoundary$1(router, matches, failure, signal);
2866
+ failure[2] = boundary;
2867
+ end = Math.min(end, boundary + 1);
2868
+ } else if (failure[1][0] >= REDIRECTED$1) end = 0;
2869
+ planSuccessfulLane();
2870
+ }
2871
+ if (!signal.aborted && !options[3]) {
2872
+ const abort = [];
2873
+ for (const [id, flight] of router._flights ?? []) if (!flight[2]) {
2874
+ router._flights.delete(id);
2875
+ abort.push(flight[1]);
2876
+ }
2877
+ for (const controller of abort) controller.abort();
2878
+ }
2879
+ const reduction = reduceLane(router, matched, tasks, options[0], settleTasks(tasks, failure, matched[2]), options[7]);
2880
+ if (matched[2]?.length) matched[3] = settleTasks(matched[2], void 0, void 0, reduction.then((foreground) => isControl(foreground) ? 0 : _getRenderedMatches(matches).length, () => 0));
2881
+ reduced = await reduction;
2882
+ } catch (cause) {
2883
+ discardBackground(router, matched);
2884
+ if (cause === signal && signal.aborted) return CANCELED_OUTCOME;
2885
+ throw cause;
2886
+ }
2887
+ if (isControl(reduced)) return reduced;
2888
+ return projectLane$1(router, reduced, signal, options[6] === matches.length ? options[6] : 0);
2889
+ }
2890
+ async function preloadClientRoute(router, opts) {
2891
+ let location = router.buildLocation(opts);
2892
+ for (let redirects = 0;; redirects++) {
2893
+ const base = router._committed;
2894
+ const controller = new AbortController();
2895
+ let matches;
2896
+ let active;
2897
+ let result;
2898
+ try {
2899
+ try {
2900
+ matches = router.matchRoutes(location, { _controller: controller });
2901
+ acquireMatchResources(matches);
2902
+ active = (router._preloads ??= /* @__PURE__ */ new Map()).set(controller, matches);
2903
+ result = await executeClientLane(router, location, matches, [
2904
+ controller,
2905
+ redirects,
2906
+ base,
2907
+ true
2908
+ ]);
2909
+ } finally {
2910
+ if (active) {
2911
+ active = active.delete(controller);
2912
+ transferMatchResources(router, matches);
2913
+ }
2914
+ controller.abort();
2915
+ }
2916
+ if (!isControl(result)) return result[1];
2917
+ if (!active || result.length < 3 || false) return;
2918
+ location = result[2];
2919
+ } catch (cause) {
2920
+ if (!isNotFound(cause)) console.error(cause);
2921
+ return;
2922
+ }
2923
+ }
2924
+ }
2925
+ // ../../node_modules/.bun/@tanstack+router-core@1.171.39/node_modules/@tanstack/router-core/dist/esm/await-signal.js
2926
+ function observeLate(callback, value) {
2927
+ if (!callback) return;
2928
+ try {
2929
+ const result = callback(value);
2930
+ if (result !== void 0) Promise.resolve(result).catch(() => {});
2931
+ } catch {}
2932
+ }
2933
+ /**
2934
+ * Await `value` unless `signal` aborts first. A result that settles after the
2935
+ * abort is passed to `onLate` / `onLateError` instead.
2936
+ *
2937
+ * One abort listener per wait: SSR requests nest at most a few waits on one
2938
+ * signal, so pooling them was measurably slower than this.
2939
+ */
2940
+ function waitForReason(value, signal, onLate, onLateError) {
2941
+ const promise = Promise.resolve(value);
2942
+ if (signal.aborted) {
2943
+ promise.then((result) => observeLate(onLate, result), (error) => observeLate(onLateError, error));
2944
+ return Promise.reject(signal.reason);
2945
+ }
2946
+ return new Promise((resolve, reject) => {
2947
+ const abort = () => reject(signal.reason);
2948
+ signal.addEventListener("abort", abort, { once: true });
2949
+ promise.then((result) => {
2950
+ signal.removeEventListener("abort", abort);
2951
+ if (signal.aborted) observeLate(onLate, result);
2952
+ else resolve(result);
2953
+ }, (error) => {
2954
+ signal.removeEventListener("abort", abort);
2955
+ if (signal.aborted) observeLate(onLateError, error);
2956
+ else reject(error);
2957
+ });
2958
+ });
2959
+ }
2960
+ // ../../node_modules/.bun/@tanstack+router-core@1.171.39/node_modules/@tanstack/router-core/dist/esm/load-server.js
2961
+ var SUCCESS = 0;
2962
+ var ERROR = 1;
2963
+ var NOT_FOUND = 2;
2964
+ var REDIRECTED = 3;
2965
+ var SKIPPED = 4;
2966
+ var MATCH_SETTLED_ABORT_REASON = Object.freeze({
2967
+ name: "AbortError",
2968
+ message: "TanStack Router aborted this server match because it settled."
2969
+ });
2970
+ var REDIRECT_ABORT_REASON = Object.freeze({
2971
+ name: "AbortError",
2972
+ message: "TanStack Router aborted this server match because of a redirect."
2973
+ });
2974
+ function getRoute(router, match) {
2975
+ return router.routesById[match.routeId];
2976
+ }
2977
+ function normalize(value, rejected) {
2978
+ if (isRedirect(value)) return [REDIRECTED, value];
2979
+ if (isNotFound(value)) return [NOT_FOUND, value];
2980
+ if (rejected && typeof value?.then === "function") value = new Error("A Promise was thrown", { cause: value });
2981
+ return rejected ? [ERROR, value] : [SUCCESS, value];
2982
+ }
2983
+ function normalizeError(router, lane, route, cause, signal, notify = true) {
2984
+ signal?.throwIfAborted();
2985
+ let outcome = normalize(cause, true);
2986
+ if (outcome[0] !== ERROR) return materializeRedirect(router, lane, route, outcome, signal, notify);
2987
+ try {
2988
+ route.options.onError?.(outcome[1]);
2989
+ } catch (onErrorCause) {
2990
+ outcome = normalize(onErrorCause, true);
2991
+ }
2992
+ signal?.throwIfAborted();
2993
+ return materializeRedirect(router, lane, route, outcome, signal, notify);
2994
+ }
2995
+ function materializeRedirect(router, lane, route, outcome, signal, notify = true) {
2996
+ if (outcome[0] !== REDIRECTED) return outcome;
2997
+ signal?.throwIfAborted();
2998
+ try {
2999
+ outcome[1].options._fromLocation = lane.location;
3000
+ router.resolveRedirect(outcome[1]);
3001
+ signal?.throwIfAborted();
3002
+ return outcome;
3003
+ } catch (cause) {
3004
+ signal?.throwIfAborted();
3005
+ return notify ? normalizeError(router, lane, route, cause, signal, false) : [ERROR, cause];
3006
+ }
3007
+ }
3008
+ function maybe(value, cause) {
3009
+ if (cause !== void 0) return {
3010
+ status: "error",
3011
+ error: cause
3012
+ };
3013
+ return {
3014
+ status: "success",
3015
+ value
3016
+ };
3017
+ }
3018
+ function navigateFrom(router, location) {
3019
+ return (options) => router.navigate({
3020
+ ...options,
3021
+ _fromLocation: location
3022
+ });
3023
+ }
3024
+ function waitFor(value, signal) {
3025
+ return signal ? waitForReason(value, signal) : value;
3026
+ }
3027
+ function resolveSsr(router, lane, index) {
3028
+ const match = lane.matches[index];
3029
+ const route = getRoute(router, match);
3030
+ const parentSsr = lane.matches[index - 1]?.ssr;
3031
+ if (router.isShell()) return route.id === rootRouteId;
3032
+ if (parentSsr === false) return false;
3033
+ const inherit = (value) => {
3034
+ return value === true && parentSsr === "data-only" ? "data-only" : value;
3035
+ };
3036
+ const defaultSsr = router.options.defaultSsr ?? true;
3037
+ const inheritedDefault = inherit(defaultSsr);
3038
+ match.ssr = inheritedDefault;
3039
+ const option = route.options.ssr;
3040
+ if (option === void 0) return inheritedDefault;
3041
+ if (typeof option !== "function") return inherit(option);
3042
+ const context = {
3043
+ search: maybe(match.search, match.searchError),
3044
+ params: maybe(match.params, match.paramsError),
3045
+ location: lane.location,
3046
+ matches: lane.matches.map((candidate) => ({
3047
+ index: candidate.index,
3048
+ pathname: candidate.pathname,
3049
+ fullPath: candidate.fullPath,
3050
+ staticData: candidate.staticData,
3051
+ id: candidate.id,
3052
+ routeId: candidate.routeId,
3053
+ search: maybe(candidate.search, candidate.searchError),
3054
+ params: maybe(candidate.params, candidate.paramsError),
3055
+ ssr: candidate.ssr
3056
+ }))
3057
+ };
3058
+ try {
3059
+ return Promise.resolve(option(context)).then((value) => inherit(value ?? defaultSsr));
3060
+ } catch (cause) {
3061
+ return Promise.reject(cause);
3062
+ }
3063
+ }
3064
+ function stampNotFound(match, outcome) {
3065
+ if (outcome[0] === NOT_FOUND && !outcome[1].routeId) outcome[1].routeId = match.routeId;
3066
+ return outcome;
3067
+ }
3068
+ async function contextualize(router, lane, signal) {
3069
+ const globalBoundary = lane.matches.findIndex((match) => match._notFound);
3070
+ let end = globalBoundary < 0 ? lane.matches.length : globalBoundary + 1;
3071
+ let failure;
3072
+ let parentContext = { ...router.options.context ?? {} };
3073
+ for (let index = 0; index < end; index++) {
3074
+ const match = lane.matches[index];
3075
+ const route = getRoute(router, match);
3076
+ try {
3077
+ const ssr = resolveSsr(router, lane, index);
3078
+ match.ssr = ssr instanceof Promise ? await ssr : ssr;
3079
+ } catch (cause) {
3080
+ signal?.throwIfAborted();
3081
+ failure = [index, stampNotFound(match, normalizeError(router, lane, route, cause, signal))];
3082
+ end = index;
3083
+ }
3084
+ signal?.throwIfAborted();
3085
+ if (failure?.[1][0] === REDIRECTED) break;
3086
+ match.__beforeLoadContext = void 0;
3087
+ let context = parentContext;
3088
+ try {
3089
+ let routeContext;
3090
+ if (route.options.context) {
3091
+ const routeContextOptions = {
3092
+ deps: match.loaderDeps,
3093
+ params: match.params,
3094
+ context: parentContext,
3095
+ location: lane.location,
3096
+ navigate: navigateFrom(router, lane.location),
3097
+ buildLocation: router.buildLocation,
3098
+ cause: match.cause,
3099
+ abortController: match.abortController,
3100
+ preload: false,
3101
+ matches: lane.matches,
3102
+ routeId: route.id
3103
+ };
3104
+ routeContext = route.options.context(routeContextOptions) ?? void 0;
3105
+ }
3106
+ context = {
3107
+ ...parentContext,
3108
+ ...routeContext
3109
+ };
3110
+ match.context = context;
3111
+ } catch (cause) {
3112
+ signal?.throwIfAborted();
3113
+ if (!failure) failure = [index, stampNotFound(match, normalizeError(router, lane, route, cause, signal))];
3114
+ end = index;
3115
+ break;
3116
+ }
3117
+ signal?.throwIfAborted();
3118
+ if (failure) break;
3119
+ const validationError = match.paramsError ?? match.searchError;
3120
+ if (validationError !== void 0) {
3121
+ failure = [index, stampNotFound(match, normalizeError(router, lane, route, validationError, signal))];
3122
+ end = index;
3123
+ break;
3124
+ }
3125
+ signal?.throwIfAborted();
3126
+ if (match.ssr === false || !route.options.beforeLoad) {
3127
+ parentContext = context;
3128
+ continue;
3129
+ }
3130
+ const abortController = match.abortController;
3131
+ const options = {
3132
+ search: match.search,
3133
+ abortController,
3134
+ params: match.params,
3135
+ preload: false,
3136
+ context,
3137
+ location: lane.location,
3138
+ navigate: navigateFrom(router, lane.location),
3139
+ buildLocation: router.buildLocation,
3140
+ cause: match.cause,
3141
+ matches: lane.matches,
3142
+ routeId: route.id,
3143
+ ...router.options.additionalContext
3144
+ };
3145
+ try {
3146
+ const beforeLoadContext = await route.options.beforeLoad(options);
3147
+ signal?.throwIfAborted();
3148
+ const outcome = stampNotFound(match, materializeRedirect(router, lane, route, normalize(beforeLoadContext, false), signal));
3149
+ if (outcome[0] !== SUCCESS) {
3150
+ failure = [index, outcome];
3151
+ end = index;
3152
+ break;
3153
+ }
3154
+ match.__beforeLoadContext = beforeLoadContext;
3155
+ match.context = {
3156
+ ...context,
3157
+ ...beforeLoadContext
3158
+ };
3159
+ parentContext = match.context;
3160
+ } catch (cause) {
3161
+ signal?.throwIfAborted();
3162
+ failure = [index, stampNotFound(match, normalizeError(router, lane, route, cause, signal))];
3163
+ end = index;
3164
+ break;
3165
+ }
3166
+ }
3167
+ return {
3168
+ location: lane.location,
3169
+ matches: lane.matches,
3170
+ end,
3171
+ failure
3172
+ };
3173
+ }
3174
+ function getLoaderContext(router, lane, match, route, index, tasks) {
3175
+ return {
3176
+ params: match.params,
3177
+ deps: match.loaderDeps,
3178
+ preload: false,
3179
+ parentMatchPromise: tasks[index - 1]?.match,
3180
+ abortController: match.abortController,
3181
+ context: match.context,
3182
+ location: lane.location,
3183
+ navigate: navigateFrom(router, lane.location),
3184
+ cause: match.cause,
3185
+ route,
3186
+ ...router.options.additionalContext
3187
+ };
3188
+ }
3189
+ function createLoaderTask(router, lane, index, tasks, signal) {
3190
+ const match = lane.matches[index];
3191
+ const route = getRoute(router, match);
3192
+ let outcome;
3193
+ if (match.ssr === false) outcome = Promise.resolve([SKIPPED]);
3194
+ else {
3195
+ const routeLoader = route.options.loader;
3196
+ const loader = typeof routeLoader === "function" ? routeLoader : routeLoader?.handler;
3197
+ if (!loader) outcome = Promise.resolve([SUCCESS, void 0]);
3198
+ else outcome = Promise.resolve().then(() => loader(getLoaderContext(router, lane, match, route, index, tasks))).then((result) => normalize(result, false), (cause) => normalize(cause, true)).then((result) => {
3199
+ if (signal?.aborted || match.abortController.signal.reason === REDIRECT_ABORT_REASON) return [SKIPPED];
3200
+ if (result[0] === ERROR) result = normalizeError(router, lane, route, result[1], signal);
3201
+ else result = materializeRedirect(router, lane, route, result, signal);
3202
+ return stampNotFound(match, result);
3203
+ });
3204
+ }
3205
+ const parentMatch = outcome.then((result) => {
3206
+ const snapshot = { ...match };
3207
+ if (result[0] === SUCCESS) {
3208
+ snapshot.loaderData = result[1];
3209
+ snapshot.status = "success";
3210
+ snapshot.error = void 0;
3211
+ snapshot.invalid = false;
3212
+ snapshot.isFetching = false;
3213
+ } else if (result[0] === ERROR) {
3214
+ snapshot.status = "error";
3215
+ snapshot.error = result[1];
3216
+ } else if (result[0] === NOT_FOUND) {
3217
+ snapshot.status = "notFound";
3218
+ snapshot.error = result[1];
3219
+ }
3220
+ return snapshot;
3221
+ });
3222
+ return {
3223
+ index,
3224
+ outcome,
3225
+ match: parentMatch
3226
+ };
3227
+ }
3228
+ async function getNotFoundBoundary(router, matches, indexed, signal, fallback = 0) {
3229
+ const cause = indexed?.[1][1];
3230
+ let index = cause?.routeId ? matches.findIndex((match) => match.routeId === cause.routeId) : indexed?.[0] ?? matches.length - 1;
3231
+ if (index < 0) index = 0;
3232
+ for (let candidate = index; candidate >= 0; candidate--) {
3233
+ const route = getRoute(router, matches[candidate]);
3234
+ try {
3235
+ const loading = loadRouteChunk(route, false);
3236
+ if (loading) await loading;
3237
+ } catch {
3238
+ signal?.throwIfAborted();
3239
+ }
3240
+ signal?.throwIfAborted();
3241
+ if (route.options.notFoundComponent) return candidate;
3242
+ }
3243
+ return cause?.routeId ? index : fallback;
3244
+ }
3245
+ function abortMatches(matches, start = 0, reason = MATCH_SETTLED_ABORT_REASON) {
3246
+ for (let index = start; index < matches.length; index++) matches[index].abortController.abort(reason);
3247
+ }
3248
+ async function applyFailure(router, lane, indexed, signal) {
3249
+ if (!indexed) {
3250
+ const boundary = lane.matches.findIndex((match) => match._notFound);
3251
+ if (boundary >= 0) {
3252
+ abortMatches(lane.matches, boundary + 1);
3253
+ return {
3254
+ status: 404,
3255
+ boundary,
3256
+ kind: NOT_FOUND
3257
+ };
3258
+ }
3259
+ return { status: 200 };
3260
+ }
3261
+ const [index, outcome] = indexed;
3262
+ if (outcome[0] === ERROR) {
3263
+ const match = lane.matches[index];
3264
+ match._notFound = void 0;
3265
+ match.status = "error";
3266
+ match.error = outcome[1];
3267
+ match.isFetching = false;
3268
+ abortMatches(lane.matches, index + 1);
3269
+ return {
3270
+ status: 500,
3271
+ boundary: index,
3272
+ kind: ERROR
3273
+ };
3274
+ }
3275
+ const boundary = indexed[2] ?? await getNotFoundBoundary(router, lane.matches, indexed, signal);
3276
+ const match = lane.matches[boundary];
3277
+ const cause = outcome[1];
3278
+ cause.routeId = match.routeId;
3279
+ match._notFound = void 0;
3280
+ if (match.routeId === router.routeTree.id) {
3281
+ match.status = "success";
3282
+ match._notFound = true;
3283
+ match.error = cause;
3284
+ } else {
3285
+ match.status = "notFound";
3286
+ match.error = cause;
3287
+ }
3288
+ match.isFetching = false;
3289
+ abortMatches(lane.matches, boundary + 1);
3290
+ return {
3291
+ status: 404,
3292
+ boundary,
3293
+ kind: NOT_FOUND
3294
+ };
3295
+ }
3296
+ async function loadNormalChunks(router, lane, end, signal) {
3297
+ const chunks = [];
3298
+ for (let index = 0; index < lane.matches.length; index++) {
3299
+ const match = lane.matches[index];
3300
+ if (index >= end || match.ssr !== true || match.status !== "success") continue;
3301
+ const route = getRoute(router, match);
3302
+ try {
3303
+ const loading = loadRouteChunk(route);
3304
+ if (loading) {
3305
+ const chunk = loading.then(() => {
3306
+ signal?.throwIfAborted();
3307
+ }, (cause) => {
3308
+ signal?.throwIfAborted();
3309
+ return [index, stampNotFound(match, normalizeError(router, lane, route, cause, signal))];
3310
+ });
3311
+ chunk.catch(() => {});
3312
+ chunks.push(chunk);
3313
+ }
3314
+ } catch (cause) {
3315
+ signal?.throwIfAborted();
3316
+ chunks.push([index, stampNotFound(match, normalizeError(router, lane, route, cause, signal))]);
3317
+ }
3318
+ }
3319
+ for (const chunk of chunks) {
3320
+ const indexed = Array.isArray(chunk) ? chunk : await chunk;
3321
+ if (indexed) return indexed;
3322
+ }
3323
+ }
3324
+ async function projectLane(router, lane, signal) {
3325
+ for (const match of lane.matches) {
3326
+ const routeOptions = getRoute(router, match).options;
3327
+ if (routeOptions.head || routeOptions.scripts || routeOptions.headers) {
3328
+ const context = {
3329
+ ssr: router.options.ssr,
3330
+ matches: lane.matches,
3331
+ match,
3332
+ params: match.params,
3333
+ loaderData: match.loaderData
3334
+ };
3335
+ try {
3336
+ const [head, scripts, headers] = await Promise.all([
3337
+ routeOptions.head?.(context),
3338
+ routeOptions.scripts?.(context),
3339
+ routeOptions.headers?.(context)
3340
+ ]);
3341
+ signal?.throwIfAborted();
3342
+ match.meta = head?.meta;
3343
+ match.links = head?.links;
3344
+ match.headScripts = head?.scripts;
3345
+ match.styles = head?.styles;
3346
+ match.scripts = scripts;
3347
+ match.headers = headers;
3348
+ } catch (cause) {
3349
+ signal?.throwIfAborted();
3350
+ console.error(cause);
3351
+ }
3352
+ }
3353
+ if (match.ssr === false || match.status !== "success" || match._notFound) break;
3354
+ }
3355
+ }
3356
+ async function executeServerLane(router, location, matchedMatches, signal) {
3357
+ const matched = {
3358
+ location,
3359
+ matches: matchedMatches.map((match) => ({
3360
+ ...match,
3361
+ __beforeLoadContext: void 0,
3362
+ context: {},
3363
+ isFetching: false,
3364
+ abortController: new AbortController()
3365
+ }))
3366
+ };
3367
+ const abortLane = () => abortMatches(matched.matches, 0, signal?.reason ?? MATCH_SETTLED_ABORT_REASON);
3368
+ if (signal?.aborted) {
3369
+ abortLane();
3370
+ signal.throwIfAborted();
3371
+ }
3372
+ signal?.addEventListener("abort", abortLane, { once: true });
3373
+ try {
3374
+ const plannedGlobalBoundary = matched.matches.findIndex((match) => match._notFound);
3375
+ if (router.options.notFoundMode !== "root" && plannedGlobalBoundary >= 0) {
3376
+ const boundary = await getNotFoundBoundary(router, matched.matches, void 0, signal, plannedGlobalBoundary);
3377
+ if (boundary !== plannedGlobalBoundary) {
3378
+ matched.matches[plannedGlobalBoundary]._notFound = void 0;
3379
+ matched.matches[boundary]._notFound = true;
3380
+ }
3381
+ }
3382
+ const lane = await contextualize(router, matched, signal);
3383
+ signal?.throwIfAborted();
3384
+ let loaderEnd = lane.end;
3385
+ if (lane.failure?.[1][0] === REDIRECTED) loaderEnd = 0;
3386
+ else if (lane.failure?.[1][0] === NOT_FOUND) {
3387
+ lane.failure[2] = await getNotFoundBoundary(router, lane.matches, lane.failure, signal);
3388
+ loaderEnd = Math.min(loaderEnd, lane.failure[2] + 1);
3389
+ }
3390
+ const tasks = [];
3391
+ for (let index = 0; index < loaderEnd; index++) {
3392
+ const task = createLoaderTask(router, lane, index, tasks, signal);
3393
+ tasks.push(task);
3394
+ }
3395
+ let loaderFailure;
3396
+ let control = lane.failure?.[1][0] === REDIRECTED ? lane.failure : void 0;
3397
+ try {
3398
+ await Promise.all(tasks.map((task) => task.outcome.then((loadedOutcome) => {
3399
+ const match = lane.matches[task.index];
3400
+ const outcome = loadedOutcome;
3401
+ if (outcome[0] === SUCCESS) {
3402
+ match.loaderData = outcome[1];
3403
+ match.status = "success";
3404
+ match.error = void 0;
3405
+ match.invalid = false;
3406
+ match.isFetching = false;
3407
+ match.updatedAt = Date.now();
3408
+ } else if (outcome[0] === REDIRECTED) {
3409
+ control = [task.index, outcome];
3410
+ throw control;
3411
+ } else {
3412
+ if (match.ssr !== false) {
3413
+ match.status = "success";
3414
+ match.error = void 0;
3415
+ match.invalid = true;
3416
+ match.isFetching = false;
3417
+ }
3418
+ if (!loaderFailure && outcome[0] !== SKIPPED) loaderFailure = [task.index, outcome];
3419
+ }
3420
+ })));
3421
+ } catch (cause) {
3422
+ if (!Array.isArray(cause)) throw cause;
3423
+ control = cause;
3424
+ }
3425
+ signal?.throwIfAborted();
3426
+ if (control?.[1][0] === REDIRECTED) {
3427
+ abortMatches(lane.matches, 0, REDIRECT_ABORT_REASON);
3428
+ return {
3429
+ type: "redirect",
3430
+ redirect: control[1][1]
3431
+ };
3432
+ }
3433
+ let failure = lane.failure ?? loaderFailure;
3434
+ const plannedBoundary = lane.matches.findIndex((match) => match._notFound);
3435
+ let readinessEnd;
3436
+ if (failure) {
3437
+ const outcomeEnd = failure[2] ??= failure[1][0] === NOT_FOUND ? await getNotFoundBoundary(router, lane.matches, failure, signal) : failure[0];
3438
+ for (const task of tasks) {
3439
+ if (task.index >= outcomeEnd) break;
3440
+ const outcome = await task.outcome;
3441
+ if (outcome[0] !== SUCCESS && outcome[0] < REDIRECTED && !("loaderData" in lane.matches[task.index])) {
3442
+ failure = [task.index, outcome];
3443
+ failure[2] = outcome[0] === NOT_FOUND ? await getNotFoundBoundary(router, lane.matches, failure, signal) : task.index;
3444
+ break;
3445
+ }
3446
+ }
3447
+ readinessEnd = failure[2];
3448
+ } else readinessEnd = plannedBoundary < 0 ? lane.matches.length : plannedBoundary;
3449
+ const requiredFailure = await loadNormalChunks(router, lane, readinessEnd, signal);
3450
+ signal?.throwIfAborted();
3451
+ if (requiredFailure) {
3452
+ if (requiredFailure[1][0] === REDIRECTED) {
3453
+ abortMatches(lane.matches, 0, REDIRECT_ABORT_REASON);
3454
+ return {
3455
+ type: "redirect",
3456
+ redirect: requiredFailure[1][1]
3457
+ };
3458
+ }
3459
+ failure = requiredFailure;
3460
+ }
3461
+ const terminal = await applyFailure(router, lane, failure, signal);
3462
+ if (terminal.boundary !== void 0) {
3463
+ const match = lane.matches[terminal.boundary];
3464
+ if (match.ssr === true) {
3465
+ const route = getRoute(router, match);
3466
+ try {
3467
+ if (terminal.kind === ERROR) await loadRouteChunk(route, "errorComponent");
3468
+ else if (match._notFound) await Promise.all([loadRouteChunk(route), loadRouteChunk(route, "notFoundComponent")]);
3469
+ else await loadRouteChunk(route, "notFoundComponent");
3470
+ } catch {}
3471
+ signal?.throwIfAborted();
3472
+ }
3473
+ }
3474
+ signal?.throwIfAborted();
3475
+ await projectLane(router, {
3476
+ location: lane.location,
3477
+ matches: lane.matches
3478
+ }, signal);
3479
+ signal?.throwIfAborted();
3480
+ router.serverSsr?.onCleanup((settled) => {
3481
+ if (!settled) abortLane();
3482
+ });
3483
+ return {
3484
+ type: "render",
3485
+ status: terminal.status,
3486
+ matches: lane.matches
3487
+ };
3488
+ } finally {
3489
+ signal?.removeEventListener("abort", abortLane);
3490
+ }
3491
+ }
3492
+ async function loadServerRoute(router, opts) {
3493
+ if (!opts?._skipLocationUpdate) router.updateLatestLocation();
3494
+ const next = router.latestLocation;
3495
+ const previous = router._committed;
3496
+ const previousEnd = router._lifecycleEnd;
3497
+ let result;
3498
+ try {
3499
+ const canonical = router.buildLocation({
3500
+ to: next.pathname,
3501
+ search: true,
3502
+ params: true,
3503
+ hash: true,
3504
+ state: true,
3505
+ _includeValidateSearch: true
3506
+ });
3507
+ if (next.publicHref !== canonical.publicHref) {
3508
+ const href = canonical.publicHref || "/";
3509
+ throw redirect({ href });
3510
+ }
3511
+ const changeInfo = getLocationChangeInfo(next, router.stores.resolvedLocation.get());
3512
+ router.emit({
3513
+ type: "onBeforeNavigate",
3514
+ ...changeInfo
3515
+ });
3516
+ router.emit({
3517
+ type: "onBeforeLoad",
3518
+ ...changeInfo
3519
+ });
3520
+ opts?._signal?.throwIfAborted();
3521
+ result = await waitFor(executeServerLane(router, next, router.matchRoutes(next), opts?._signal), opts?._signal);
3522
+ opts?._signal?.throwIfAborted();
3523
+ } catch (cause) {
3524
+ opts?._signal?.throwIfAborted();
3525
+ if (!isRedirect(cause)) throw cause;
3526
+ cause.options._fromLocation = next;
3527
+ result = {
3528
+ type: "redirect",
3529
+ redirect: router.resolveRedirect(cause)
3530
+ };
3531
+ }
3532
+ router._serverResult = result;
3533
+ let nextEnd = 0;
3534
+ router.batch(() => {
3535
+ router.stores.location.set(next);
3536
+ router.stores.status.set("idle");
3537
+ if (result.type === "render") {
3538
+ router._committed = result.matches;
3539
+ nextEnd = router._lifecycleEnd = lifecycleEnd(result.matches);
3540
+ router.stores.setMatches(result.matches);
3541
+ router.stores.resolvedLocation.set(next);
3542
+ }
3543
+ });
3544
+ if (result.type === "render") runRouteLifecycle(router, previous, result.matches, previousEnd, nextEnd);
3545
+ router._commitPromise?.resolve();
3546
+ router._commitPromise = void 0;
3547
+ }
3548
+ // ../../node_modules/.bun/@tanstack+react-router@1.170.46+7492c01c6988791b/node_modules/@tanstack/react-router/dist/esm/utils.js
3549
+ var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
3550
+ /**
3551
+ * React.use if available (React 19+), undefined otherwise.
3552
+ * Use dynamic lookup to avoid Webpack compilation errors with React 18.
3553
+ */
3554
+ var reactUse = import_react.use;
3555
+ var useLayoutEffect = import_react.useEffect;
3556
+ // ../../node_modules/.bun/react@19.2.7/node_modules/react/cjs/react-jsx-runtime.production.js
3557
+ /**
3558
+ * @license React
3559
+ * react-jsx-runtime.production.js
3560
+ *
3561
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3562
+ *
3563
+ * This source code is licensed under the MIT license found in the
3564
+ * LICENSE file in the root directory of this source tree.
3565
+ */
3566
+ var require_react_jsx_runtime_production = /* @__PURE__ */ __commonJSMin(((exports) => {
3567
+ var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element");
3568
+ var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
3569
+ function jsxProd(type, config, maybeKey) {
3570
+ var key = null;
3571
+ void 0 !== maybeKey && (key = "" + maybeKey);
3572
+ void 0 !== config.key && (key = "" + config.key);
3573
+ if ("key" in config) {
3574
+ maybeKey = {};
3575
+ for (var propName in config) "key" !== propName && (maybeKey[propName] = config[propName]);
3576
+ } else maybeKey = config;
3577
+ config = maybeKey.ref;
3578
+ return {
3579
+ $$typeof: REACT_ELEMENT_TYPE,
3580
+ type,
3581
+ key,
3582
+ ref: void 0 !== config ? config : null,
3583
+ props: maybeKey
3584
+ };
3585
+ }
3586
+ exports.Fragment = REACT_FRAGMENT_TYPE;
3587
+ exports.jsx = jsxProd;
3588
+ exports.jsxs = jsxProd;
3589
+ }));
3590
+ // ../../node_modules/.bun/react@19.2.7/node_modules/react/jsx-runtime.js
3591
+ var require_jsx_runtime = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3592
+ module.exports = require_react_jsx_runtime_production();
3593
+ }));
3594
+ // ../../node_modules/.bun/@tanstack+react-router@1.170.46+7492c01c6988791b/node_modules/@tanstack/react-router/dist/esm/routerContext.js
3595
+ var routerContext = import_react.createContext(null);
3596
+ // ../../node_modules/.bun/@tanstack+react-router@1.170.46+7492c01c6988791b/node_modules/@tanstack/react-router/dist/esm/useRouter.js
3597
+ /**
3598
+ * Access the current TanStack Router instance from React context.
3599
+ * Must be used within a `RouterProvider`.
3600
+ *
3601
+ * Options:
3602
+ * - `warn`: Log a warning if no router context is found (default: true).
3603
+ *
3604
+ * @returns The registered router instance.
3605
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useRouterHook
3606
+ */
3607
+ function useRouter(opts) {
3608
+ const value = import_react.useContext(routerContext);
3609
+ if (!value);
3610
+ return value;
3611
+ }
3612
+ // ../../node_modules/.bun/@tanstack+react-router@1.170.46+7492c01c6988791b/node_modules/@tanstack/react-router/dist/esm/matchContext.js
3613
+ function createLinkScope(router, routeId) {
3614
+ const store = router.stores.location;
3615
+ const listeners = /* @__PURE__ */ new Set();
3616
+ let source;
3617
+ let unsubscribe;
3618
+ const update = (location) => {
3619
+ if (!_isRouteDeparting(router, routeId, location)) {
3620
+ source = location;
3621
+ listeners.forEach((listener) => listener());
3622
+ }
3623
+ };
3624
+ return [() => source ?? store.get(), (listener) => {
3625
+ if (!listeners.size) {
3626
+ source = store.get();
3627
+ unsubscribe = store.subscribe(update).unsubscribe;
3628
+ }
3629
+ listeners.add(listener);
3630
+ return () => {
3631
+ listeners.delete(listener);
3632
+ if (!listeners.size) {
3633
+ unsubscribe();
3634
+ source = void 0;
3635
+ }
3636
+ };
3637
+ }];
3638
+ }
3639
+ var matchContext = import_react.createContext(void 0);
3640
+ var dummyMatchContext = import_react.createContext(void 0);
3641
+ // ../../node_modules/.bun/use-sync-external-store@1.6.0+e14d3f224186685e/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js
3642
+ /**
3643
+ * @license React
3644
+ * use-sync-external-store-shim.production.js
3645
+ *
3646
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3647
+ *
3648
+ * This source code is licensed under the MIT license found in the
3649
+ * LICENSE file in the root directory of this source tree.
3650
+ */
3651
+ var require_use_sync_external_store_shim_production = /* @__PURE__ */ __commonJSMin(((exports) => {
3652
+ var React = require_react();
3653
+ function is(x, y) {
3654
+ return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
3655
+ }
3656
+ var objectIs = "function" === typeof Object.is ? Object.is : is;
3657
+ var useState = React.useState;
3658
+ var useEffect = React.useEffect;
3659
+ var useLayoutEffect = React.useLayoutEffect;
3660
+ var useDebugValue = React.useDebugValue;
3661
+ function useSyncExternalStore$2(subscribe, getSnapshot) {
3662
+ var value = getSnapshot(), _useState = useState({ inst: {
3663
+ value,
3664
+ getSnapshot
3665
+ } }), inst = _useState[0].inst, forceUpdate = _useState[1];
3666
+ useLayoutEffect(function() {
3667
+ inst.value = value;
3668
+ inst.getSnapshot = getSnapshot;
3669
+ checkIfSnapshotChanged(inst) && forceUpdate({ inst });
3670
+ }, [
3671
+ subscribe,
3672
+ value,
3673
+ getSnapshot
3674
+ ]);
3675
+ useEffect(function() {
3676
+ checkIfSnapshotChanged(inst) && forceUpdate({ inst });
3677
+ return subscribe(function() {
3678
+ checkIfSnapshotChanged(inst) && forceUpdate({ inst });
3679
+ });
3680
+ }, [subscribe]);
3681
+ useDebugValue(value);
3682
+ return value;
3683
+ }
3684
+ function checkIfSnapshotChanged(inst) {
3685
+ var latestGetSnapshot = inst.getSnapshot;
3686
+ inst = inst.value;
3687
+ try {
3688
+ var nextValue = latestGetSnapshot();
3689
+ return !objectIs(inst, nextValue);
3690
+ } catch (error) {
3691
+ return !0;
3692
+ }
3693
+ }
3694
+ function useSyncExternalStore$1(subscribe, getSnapshot) {
3695
+ return getSnapshot();
3696
+ }
3697
+ var shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
3698
+ exports.useSyncExternalStore = void 0 !== React.useSyncExternalStore ? React.useSyncExternalStore : shim;
3699
+ }));
3700
+ // ../../node_modules/.bun/use-sync-external-store@1.6.0+e14d3f224186685e/node_modules/use-sync-external-store/shim/index.js
3701
+ var require_shim = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3702
+ module.exports = require_use_sync_external_store_shim_production();
3703
+ }));
3704
+ // ../../node_modules/.bun/use-sync-external-store@1.6.0+e14d3f224186685e/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.js
3705
+ /**
3706
+ * @license React
3707
+ * use-sync-external-store-shim/with-selector.production.js
3708
+ *
3709
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3710
+ *
3711
+ * This source code is licensed under the MIT license found in the
3712
+ * LICENSE file in the root directory of this source tree.
3713
+ */
3714
+ var require_with_selector_production = /* @__PURE__ */ __commonJSMin(((exports) => {
3715
+ var React = require_react();
3716
+ var shim = require_shim();
3717
+ function is(x, y) {
3718
+ return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
3719
+ }
3720
+ var objectIs = "function" === typeof Object.is ? Object.is : is;
3721
+ var useSyncExternalStore = shim.useSyncExternalStore;
3722
+ var useRef = React.useRef;
3723
+ var useEffect = React.useEffect;
3724
+ var useMemo = React.useMemo;
3725
+ var useDebugValue = React.useDebugValue;
3726
+ exports.useSyncExternalStoreWithSelector = function(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
3727
+ var instRef = useRef(null);
3728
+ if (null === instRef.current) {
3729
+ var inst = {
3730
+ hasValue: !1,
3731
+ value: null
3732
+ };
3733
+ instRef.current = inst;
3734
+ } else inst = instRef.current;
3735
+ instRef = useMemo(function() {
3736
+ function memoizedSelector(nextSnapshot) {
3737
+ if (!hasMemo) {
3738
+ hasMemo = !0;
3739
+ memoizedSnapshot = nextSnapshot;
3740
+ nextSnapshot = selector(nextSnapshot);
3741
+ if (void 0 !== isEqual && inst.hasValue) {
3742
+ var currentSelection = inst.value;
3743
+ if (isEqual(currentSelection, nextSnapshot)) return memoizedSelection = currentSelection;
3744
+ }
3745
+ return memoizedSelection = nextSnapshot;
3746
+ }
3747
+ currentSelection = memoizedSelection;
3748
+ if (objectIs(memoizedSnapshot, nextSnapshot)) return currentSelection;
3749
+ var nextSelection = selector(nextSnapshot);
3750
+ if (void 0 !== isEqual && isEqual(currentSelection, nextSelection)) return memoizedSnapshot = nextSnapshot, currentSelection;
3751
+ memoizedSnapshot = nextSnapshot;
3752
+ return memoizedSelection = nextSelection;
3753
+ }
3754
+ var hasMemo = !1, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
3755
+ return [function() {
3756
+ return memoizedSelector(getSnapshot());
3757
+ }, null === maybeGetServerSnapshot ? void 0 : function() {
3758
+ return memoizedSelector(maybeGetServerSnapshot());
3759
+ }];
3760
+ }, [
3761
+ getSnapshot,
3762
+ getServerSnapshot,
3763
+ selector,
3764
+ isEqual
3765
+ ]);
3766
+ var value = useSyncExternalStore(subscribe, instRef[0], instRef[1]);
3767
+ useEffect(function() {
3768
+ inst.hasValue = !0;
3769
+ inst.value = value;
3770
+ }, [value]);
3771
+ useDebugValue(value);
3772
+ return value;
3773
+ };
3774
+ }));
3775
+ // ../../node_modules/.bun/@tanstack+react-store@0.11.2+7492c01c6988791b/node_modules/@tanstack/react-store/dist/useSelector.js
3776
+ var import_with_selector = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
3777
+ module.exports = require_with_selector_production();
3778
+ })))();
3779
+ function defaultCompare(a, b) {
3780
+ return a === b;
3781
+ }
3782
+ /**
3783
+ * Selects a slice of state from an atom or store and subscribes the component
3784
+ * to that selection.
3785
+ *
3786
+ * This is the primary React read hook for TanStack Store. It works with any
3787
+ * source that exposes `get()` and `subscribe()`, including atoms, readonly
3788
+ * atoms, stores, and readonly stores.
3789
+ *
3790
+ * Omit the selector to subscribe to the whole value.
3791
+ *
3792
+ * @example
3793
+ * ```tsx
3794
+ * const count = useSelector(counterStore, (state) => state.count)
3795
+ * ```
3796
+ *
3797
+ * @example
3798
+ * ```tsx
3799
+ * const value = useSelector(countAtom)
3800
+ * ```
3801
+ */
3802
+ function useSelector(source, selector = (s) => s, options) {
3803
+ const compare = options?.compare ?? defaultCompare;
3804
+ const subscribe = (0, import_react.useCallback)((handleStoreChange) => {
3805
+ const { unsubscribe } = source.subscribe(handleStoreChange);
3806
+ return unsubscribe;
3807
+ }, [source]);
3808
+ const getSnapshot = (0, import_react.useCallback)(() => source.get(), [source]);
3809
+ return (0, import_with_selector.useSyncExternalStoreWithSelector)(subscribe, getSnapshot, getSnapshot, selector, compare);
3810
+ }
3811
+ function useStructuralSharing(opts, router) {
3812
+ const previousResult = import_react.useRef();
3813
+ return (slice) => {
3814
+ const selected = opts?.select ? opts.select(slice) : slice;
3815
+ if (opts?.structuralSharing ?? router.options.defaultStructuralSharing) return previousResult.current = replaceEqualDeep(previousResult.current, selected);
3816
+ return selected;
3817
+ };
3818
+ }
3819
+ /**
3820
+ * Read and select the nearest or targeted route match.
3821
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useMatchHook
3822
+ */
3823
+ function useMatch(opts) {
3824
+ const router = useRouter();
3825
+ const nearestRouteId = import_react.useContext(opts.from ? dummyMatchContext : matchContext);
3826
+ const routeId = opts.from ?? nearestRouteId;
3827
+ const matchStore = router.stores.getMatchStore(routeId);
3828
+ {
3829
+ const match = matchStore.get();
3830
+ if (!match) {
3831
+ if (opts.shouldThrow ?? true) invariant();
3832
+ return;
3833
+ }
3834
+ return opts.select ? opts.select(match) : match;
3835
+ }
3836
+ }
3837
+ // \0%23tanstack-start-server-fn-resolver
3838
+ var manifest = {
3839
+ "332ea72d0b70383661ce66a3228167cb05dc752e7269134a11855d1329c936aa": {
3840
+ functionName: "getFactory_createServerFn_handler",
3841
+ importer: () => import("./factory-DT3UzHlh.js")
3842
+ },
3843
+ "63d1e2171062e2d082e16522c162963c4da2a71c447f69f0937bd6e5e10b73ba": {
3844
+ functionName: "saveVaultFile_createServerFn_handler",
3845
+ importer: () => import("./vault-BGulVoNh.js")
3846
+ },
3847
+ "7564d662d1e0ede6133407d7dde8d613b3b11718bc4f95160680342deeaf9cfd": {
3848
+ functionName: "getVaultChildren_createServerFn_handler",
3849
+ importer: () => import("./vault-BGulVoNh.js")
3850
+ },
3851
+ "99f4d57911b5959a331ed18424ab13369de22f8b2b142a146ea967742dfbc997": {
3852
+ functionName: "getVaultMatches_createServerFn_handler",
3853
+ importer: () => import("./vault-BGulVoNh.js")
3854
+ },
3855
+ "a09876e9d912d4f3edfe004081679f011fcebe77cfe1b2b25cf6f3e6f1eafc6a": {
3856
+ functionName: "getCompanionView_createServerFn_handler",
3857
+ importer: () => import("./views-Bd7cRr27.js")
3858
+ },
3859
+ "b0ff357be654d7d833a4f9550953dda5e215e97cdc5b21639aef40d8a2401c4f": {
3860
+ functionName: "runFactoryAction_createServerFn_handler",
3861
+ importer: () => import("./factory-DT3UzHlh.js")
3862
+ },
3863
+ "b4cd58adfccec803b6c97478c78656e3acf554351ec97ef0ce550a10e235ebce": {
3864
+ functionName: "getShell_createServerFn_handler",
3865
+ importer: () => import("./shell-CboT2f66.js")
3866
+ },
3867
+ "cc0685774bfb5205a762c25bdd4b959c1f541584df4b67aac816fe529fa37c87": {
3868
+ functionName: "getVault_createServerFn_handler",
3869
+ importer: () => import("./vault-BGulVoNh.js")
3870
+ }
3871
+ };
3872
+ async function getServerFnById(id, access) {
3873
+ const serverFnInfo = manifest[id];
3874
+ if (!serverFnInfo) throw new Error("Server function info not found for " + id);
3875
+ const fnModule = serverFnInfo.module ??= await serverFnInfo.importer();
3876
+ if (!fnModule) throw new Error("Server function module not resolved for " + id);
3877
+ const action = fnModule[serverFnInfo.functionName];
3878
+ if (!action) throw new Error("Server function module export not resolved for serverFn ID: " + id);
3879
+ return action;
3880
+ }
3881
+ export { require_react as A, createSieveCache as C, trimPathRight as D, trimPathLeft as E, rootRouteId as O, invariant as S, removeTrailingSlash as T, createServerHistory as _, createLinkScope as a, defaultGetScrollRestorationKey as b, routerContext as c, useLayoutEffect as d, waitForReason as f, getLocationChangeInfo as g, RouterCore as h, useSelector as i, isNotFound as k, require_jsx_runtime as l, _getRenderedMatches as m, useMatch as n, matchContext as o, _getAssetMatches as p, useStructuralSharing as r, useRouter as s, getServerFnById as t, reactUse as u, createNonReactiveMutableStore as v, cleanPath as w, storageKey as x, createNonReactiveReadonlyStore as y };