@qredence/fleet 0.6.2 → 0.6.4

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 (313) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/web/client/assets/DialogTitle-BwQ9k-MZ.js +1 -0
  3. package/dist/web/client/assets/agent-disclosure-YgLa4c2y.js +1 -0
  4. package/dist/web/client/assets/alert-dialog-BfK7648p.js +1 -0
  5. package/dist/web/client/assets/analytics-stub-BY-GADyA.js +1 -0
  6. package/dist/web/client/assets/arrow-up-DCwrqIrK.js +1 -0
  7. package/dist/web/client/assets/artifacts-panel-DDlPULVv.js +1 -0
  8. package/dist/web/client/assets/bot-DETalD3q.js +1 -0
  9. package/dist/web/client/assets/{button-Dl0ce3Y5.js → button-BrwYi6QP.js} +1 -1
  10. package/dist/web/client/assets/{card-DCEnYd2G.js → card-BScRdZNS.js} +1 -1
  11. package/dist/web/client/assets/chat-command-palette-DdPlRVuL.js +1 -0
  12. package/dist/web/client/assets/chat-helpers-Bj7_hES7.js +1 -0
  13. package/dist/web/client/assets/check-BTwIaCtI.js +1 -0
  14. package/dist/web/client/assets/chevron-down-Bse1ggZM.js +1 -0
  15. package/dist/web/client/assets/chevron-right-BPCB1mOg.js +1 -0
  16. package/dist/web/client/assets/chunk-YOKDWASO-C8deEx7Z.js +143 -0
  17. package/dist/web/client/assets/circle-check-DBhaebaM.js +1 -0
  18. package/dist/web/client/assets/citations-DOkXsdCi.js +1 -0
  19. package/dist/web/client/assets/clsx-DB0hHKMi.js +1 -0
  20. package/dist/web/client/assets/{collapsible-CUxOjhDJ.js → collapsible-DsbKpD_Y.js} +1 -1
  21. package/dist/web/client/assets/command-DSxdh_1v.js +1 -0
  22. package/dist/web/client/assets/composer-intent-C5pz72T6.js +62 -0
  23. package/dist/web/client/assets/create-project-dialog-CaXurRpm.js +1 -0
  24. package/dist/web/client/assets/{createBaseUIEventDetails-B58Jldei.js → createBaseUIEventDetails-DklXWq23.js} +1 -1
  25. package/dist/web/client/assets/createLucideIcon-CQY2ECfR.js +1 -0
  26. package/dist/web/client/assets/dialog-B9nXTto4.js +1 -0
  27. package/dist/web/client/assets/{dist-DbHxXSgQ.js → dist-BJJVCio8.js} +1 -1
  28. package/dist/web/client/assets/dist-BogNzeK9.js +1 -0
  29. package/dist/web/client/assets/{ease-CMumuPlX.js → ease-2UPBQU5v.js} +1 -1
  30. package/dist/web/client/assets/eye-iNSvs0UA.js +1 -0
  31. package/dist/web/client/assets/file-text-cqOanUYv.js +1 -0
  32. package/dist/web/client/assets/folder-COBtkKZa.js +1 -0
  33. package/dist/web/client/assets/{fork-picker-dialog-CpwEwsxA.js → fork-picker-dialog-DEdHU89A.js} +1 -1
  34. package/dist/web/client/assets/gauge-0Nn96wfZ.js +1 -0
  35. package/dist/web/client/assets/git-branch-DZEh2mM2.js +1 -0
  36. package/dist/web/client/assets/globals-B-fD_O7k.css +2 -0
  37. package/dist/web/client/assets/hard-drive-B3opVeEB.js +1 -0
  38. package/dist/web/client/assets/{highlighted-body-KPVGNVTW-CgT7gqvs.js → highlighted-body-KPVGNVTW-CZcNaoxi.js} +1 -1
  39. package/dist/web/client/assets/horizontal-resize-5AxYvGLA.js +1 -0
  40. package/dist/web/client/assets/index-BJIGh8ag.js +12 -0
  41. package/dist/web/client/assets/{input-CxZp56Im.js → input-BceH49B1.js} +1 -1
  42. package/dist/web/client/assets/{input-group-D7lAfKHR.js → input-group-DThl_vkS.js} +1 -1
  43. package/dist/web/client/assets/ipython-tool-CuSGRhXl.js +3 -0
  44. package/dist/web/client/assets/is-ref-object-CEXqIz6L.js +1 -0
  45. package/dist/web/client/assets/loader-circle-BmKYM_C4.js +1 -0
  46. package/dist/web/client/assets/markdown-C-Y9gskI.js +2 -0
  47. package/dist/web/client/assets/{markdown-code-CDTRq-HZ.js → markdown-code-BqFVdovL.js} +1 -1
  48. package/dist/web/client/assets/mermaid-HWGCJPDP-CVNXPao6.js +1 -0
  49. package/dist/web/client/assets/{message-queue-Dl8wbCOu.js → message-queue-CPYj2iaw.js} +1 -1
  50. package/dist/web/client/assets/{model-selector-list-CRZCXeBf.js → model-selector-list-DDsuJCgB.js} +1 -1
  51. package/dist/web/client/assets/{notify-DjVixft7.js → notify-GSsGEKtR.js} +1 -1
  52. package/dist/web/client/assets/{openui-renderer-Bkkx5kmA.js → openui-renderer-l1qI5JDt.js} +41 -41
  53. package/dist/web/client/assets/package-BkC-HSi-.js +1 -0
  54. package/dist/web/client/assets/pencil-Cbgq3ybX.js +1 -0
  55. package/dist/web/client/assets/plug-wCz-036u.js +1 -0
  56. package/dist/web/client/assets/prompt-input-a7UP_MAw.js +1 -0
  57. package/dist/web/client/assets/{prompt-suggestions-BNyTcyWg.js → prompt-suggestions-ULqmPijZ.js} +1 -1
  58. package/dist/web/client/assets/provider-catalog-L0c-bZv6.js +1 -0
  59. package/dist/web/client/assets/provider-label-Buq3HZrP.js +1 -0
  60. package/dist/web/client/assets/react-Cvdyeg_0.js +1 -0
  61. package/dist/web/client/assets/react-dom-B7th3XGm.js +1 -0
  62. package/dist/web/client/assets/refresh-cw-CqPE3kNY.js +1 -0
  63. package/dist/web/client/assets/{repl-panel-L9dmPqio.js → repl-panel-UQN9UFG7.js} +1 -1
  64. package/dist/web/client/assets/resource-helpers-CKbSmzpw.js +2 -0
  65. package/dist/web/client/assets/{resources-panel-mT-aMCvV.js → resources-panel-kp_UjnpX.js} +1 -1
  66. package/dist/web/client/assets/right-panel-context-DHKWoetk.js +1 -0
  67. package/dist/web/client/assets/right-panel-registry-BqtgZw7Z.js +2 -0
  68. package/dist/web/client/assets/rotate-ccw-DLkfsmG9.js +1 -0
  69. package/dist/web/client/assets/routes-C37r2W1K.js +16 -0
  70. package/dist/web/client/assets/safe-external-url-BnEhm9A0.js +1 -0
  71. package/dist/web/client/assets/search-Cb6fFWew.js +1 -0
  72. package/dist/web/client/assets/{session-reasoning-panel-8D2P7iaJ.js → session-reasoning-panel-BAtKTsjn.js} +1 -1
  73. package/dist/web/client/assets/session-tool-renderer-pGdW2MnV.js +1389 -0
  74. package/dist/web/client/assets/session-tree-panel-DF3kuF0P.js +1 -0
  75. package/dist/web/client/assets/settings-dialog-BRWheaBZ.js +2 -0
  76. package/dist/web/client/assets/{skeleton-C3mo31Qu.js → skeleton-D5Y9nBfp.js} +1 -1
  77. package/dist/web/client/assets/{skeleton-loaders-BMa_G4yX.js → skeleton-loaders-DOKGa7CW.js} +1 -1
  78. package/dist/web/client/assets/sparkles-C4VQyMox.js +1 -0
  79. package/dist/web/client/assets/spinner-C3sPnLdu.js +1 -0
  80. package/dist/web/client/assets/square-BbTF3gLc.js +1 -0
  81. package/dist/web/client/assets/square-terminal-BLq2bQVF.js +1 -0
  82. package/dist/web/client/assets/{subagent-chat-panel-C5ukYiUx.js → subagent-chat-panel-B6d4Z3bV.js} +1 -1
  83. package/dist/web/client/assets/subagent-transcript-CQuPs6N4.js +1 -0
  84. package/dist/web/client/assets/{subagents-panel-SJKhaVTr.js → subagents-panel-ajf--C_-.js} +1 -1
  85. package/dist/web/client/assets/sun-C7zg8Oas.js +1 -0
  86. package/dist/web/client/assets/{surfaces-CpfsGAIA.js → surfaces-BULKVm-B.js} +1 -1
  87. package/dist/web/client/assets/switch-CoSNSJEY.js +1 -0
  88. package/dist/web/client/assets/terminal-Ceucj7us.js +1 -0
  89. package/dist/web/client/assets/toast-CS0pnDlS.js +1 -0
  90. package/dist/web/client/assets/tokens-BcUIpW6Y.js +1 -0
  91. package/dist/web/client/assets/tool-result-C-vs_tjQ.js +4 -0
  92. package/dist/web/client/assets/tool-timeline-B4ci1oJg.js +1 -0
  93. package/dist/web/client/assets/triangle-alert-BuzmrrqI.js +1 -0
  94. package/dist/web/client/assets/types-Cr5Z97oW.js +1 -0
  95. package/dist/web/client/assets/{ui-preferences-aG2U2jjW.js → ui-preferences-1YaENqef.js} +1 -1
  96. package/dist/web/client/assets/{use-presence-7I2qv4qI.js → use-presence-D2YmRKr3.js} +1 -1
  97. package/dist/web/client/assets/{use-reduced-motion-BOcG709U.js → use-reduced-motion-CaQBb3Qc.js} +2 -2
  98. package/dist/web/client/assets/{useBaseUiId-D9ZGPZ6f.js → useBaseUiId-BlzQUkVG.js} +1 -1
  99. package/dist/web/client/assets/{useControlled-CgAAWIy9.js → useControlled-CkQSkSv1.js} +1 -1
  100. package/dist/web/client/assets/utils-Dpy9ZFOr.js +1 -0
  101. package/dist/web/client/assets/virtualized-turn-list-Bcq088gZ.js +6 -0
  102. package/dist/web/client/assets/workspace-panel-CjKMroC6.js +1 -0
  103. package/dist/web/client/assets/{workspace-path-nav-DqPbETfJ.js → workspace-path-nav-DmxBrMV6.js} +2 -2
  104. package/dist/web/client/assets/wrench-BYnD147U.js +1 -0
  105. package/dist/web/client/assets/x-DEU6H3M-.js +1 -0
  106. package/dist/web/client/bundle-budget.json +6 -6
  107. package/dist/web/server/_tanstack-start-manifest_v-BZR0i182-OLTGGEDQ.js +96 -0
  108. package/dist/web/server/{artifacts-panel-BN3DgqfV-N73J6N5Y.js → artifacts-panel-BySfu7im-AKBWHYJS.js} +75 -67
  109. package/dist/web/server/{chat-command-palette-G8awyZRw-2QE7FXGT.js → chat-command-palette-BLGKnp-w-OKFIKD3T.js} +52 -43
  110. package/dist/web/server/{chunk-6SOMNRAX.js → chunk-22XP6PHK.js} +56 -17
  111. package/dist/web/server/{chunk-O2UYZT3Z.js → chunk-2GQATGF4.js} +93 -37
  112. package/dist/web/server/{chunk-EDAWH2MT.js → chunk-2HOITUWV.js} +5 -5
  113. package/dist/web/server/{chunk-NZ6KQT2X.js → chunk-2XQYM4KB.js} +2 -2
  114. package/dist/web/server/{chunk-K6PTNSCW.js → chunk-36BG6OPK.js} +2 -2
  115. package/dist/web/server/chunk-3OOZPQZF.js +51 -0
  116. package/dist/web/server/{chunk-YMPJMHXZ.js → chunk-3YYNG52U.js} +5774 -4759
  117. package/dist/web/server/{chunk-NMBH57JT.js → chunk-47TH5VUT.js} +17 -15
  118. package/dist/web/server/{chunk-CCYLHNZJ.js → chunk-4B2PJSK5.js} +150 -1787
  119. package/dist/web/server/chunk-4IVORBQD.js +39 -0
  120. package/dist/web/server/{chunk-CW6KZUKT.js → chunk-4LBXVBM7.js} +5 -5
  121. package/dist/web/server/{chunk-DKD32TRM.js → chunk-5FIJPXUA.js} +3343 -14
  122. package/dist/web/server/{chunk-JVOW2NWC.js → chunk-5VPNOUVY.js} +13 -104
  123. package/dist/web/server/chunk-7LUHWO5G.js +28 -0
  124. package/dist/web/server/chunk-7SZKAHLD.js +25 -0
  125. package/dist/web/server/{chunk-UE32PAV2.js → chunk-ACZS5EEZ.js} +4 -4
  126. package/dist/web/server/{chunk-CAPTFJOC.js → chunk-AWVHN432.js} +4 -4
  127. package/dist/web/server/{chunk-SDV3P3IW.js → chunk-BMXYQRMJ.js} +96 -78
  128. package/dist/web/server/{chunk-OVJYUWSQ.js → chunk-C2YGLMFE.js} +1 -1
  129. package/dist/web/server/{chunk-7HXCGBUP.js → chunk-CIE2PLNB.js} +5 -5
  130. package/dist/web/server/chunk-CMOAC245.js +28 -0
  131. package/dist/web/server/{chunk-7FK6YEMA.js → chunk-CRCVWYBA.js} +2 -9
  132. package/dist/web/server/chunk-DIVIHC5K.js +100 -0
  133. package/dist/web/server/{chunk-XJ6TGSUB.js → chunk-EKVRPCBJ.js} +1 -1
  134. package/dist/web/server/{chunk-ZNFXBGLK.js → chunk-ERYPONRF.js} +1 -1
  135. package/dist/web/server/chunk-F3OV445J.js +25 -0
  136. package/dist/web/server/{chunk-5727TXOK.js → chunk-F5DJQ3PQ.js} +36 -36
  137. package/dist/web/server/{chunk-NCK2FJAD.js → chunk-FAJILEF2.js} +142 -110
  138. package/dist/web/server/{chunk-JPDRUSUD.js → chunk-FF2M3MLP.js} +2 -2
  139. package/dist/web/server/{chunk-IPV4GLJL.js → chunk-FHZAFF2A.js} +7 -24
  140. package/dist/web/server/chunk-FOMB2JR7.js +26 -0
  141. package/dist/web/server/{chunk-43S5N7SH.js → chunk-FVWPODLT.js} +9 -8
  142. package/dist/web/server/chunk-G3WQTXJY.js +25 -0
  143. package/dist/web/server/{chunk-ESM7OCRL.js → chunk-GLNLSEZJ.js} +7 -7
  144. package/dist/web/server/chunk-GNDXVFJY.js +28 -0
  145. package/dist/web/server/chunk-GR765UTQ.js +102 -0
  146. package/dist/web/server/{chunk-RXUMFFUV.js → chunk-GSG3K6RA.js} +2 -2
  147. package/dist/web/server/chunk-HFN4TNR3.js +31 -0
  148. package/dist/web/server/chunk-I36LJXNY.js +113 -0
  149. package/dist/web/server/{chunk-ZOVXMNJM.js → chunk-IIPUA4LB.js} +249 -304
  150. package/dist/web/server/{chunk-7PQTPSEE.js → chunk-INWLYZZ6.js} +1 -1
  151. package/dist/web/server/chunk-JCK6B7ZW.js +1677 -0
  152. package/dist/web/server/chunk-JEQQEY6O.js +30 -0
  153. package/dist/web/server/{chunk-4OTHKQMG.js → chunk-JLGBOCFM.js} +145 -111
  154. package/dist/web/server/chunk-JVXQQYXB.js +154 -0
  155. package/dist/web/server/{chunk-FT74GAAH.js → chunk-JZ2WBCIH.js} +674 -669
  156. package/dist/web/server/chunk-KABZXD6N.js +152 -0
  157. package/dist/web/server/{chunk-WB2LJC3R.js → chunk-L2SVMQWB.js} +14 -45
  158. package/dist/web/server/chunk-LOFZS555.js +28 -0
  159. package/dist/web/server/{chunk-MJXXVQNA.js → chunk-LQRH6BP6.js} +25 -18
  160. package/dist/web/server/{chunk-WU6X3GPJ.js → chunk-MTVGA2MH.js} +72 -52
  161. package/dist/web/server/{chunk-DLA5TLKX.js → chunk-NHZRY22Z.js} +110 -39
  162. package/dist/web/server/chunk-NZ5YXXQ5.js +39 -0
  163. package/dist/web/server/chunk-ONWT54IL.js +148 -0
  164. package/dist/web/server/{chunk-E5HALE4M.js → chunk-OYWUPJ72.js} +2 -2
  165. package/dist/web/server/{chunk-YVGCPUAW.js → chunk-PISNXFEK.js} +3 -3
  166. package/dist/web/server/{chunk-33QA7BQJ.js → chunk-PYTU4DGR.js} +16 -10
  167. package/dist/web/server/{chunk-7E76R7MB.js → chunk-QHCQDVCQ.js} +1 -2
  168. package/dist/web/server/{chunk-ENGEUJIH.js → chunk-QN7KFCUW.js} +4321 -3650
  169. package/dist/web/server/chunk-QWWG3YC6.js +25 -0
  170. package/dist/web/server/chunk-RPGWRA2X.js +39 -0
  171. package/dist/web/server/chunk-RPWKCJHL.js +18 -0
  172. package/dist/web/server/chunk-RWYAKZCZ.js +39 -0
  173. package/dist/web/server/chunk-SGMJ5CGW.js +36 -0
  174. package/dist/web/server/{chunk-BQROC4PL.js → chunk-TNZKPEE6.js} +13 -7
  175. package/dist/web/server/chunk-TSOBRZPG.js +41 -0
  176. package/dist/web/server/{chunk-BUXJSBE3.js → chunk-UIUZ4ETR.js} +2 -2
  177. package/dist/web/server/{chunk-TLNZNR7C.js → chunk-UUDBEYKV.js} +2 -2
  178. package/dist/web/server/{chunk-HQ5TEXHT.js → chunk-UXS5E6OE.js} +4 -4
  179. package/dist/web/server/chunk-V7PDLH3T.js +73 -0
  180. package/dist/web/server/chunk-VCQ65B3G.js +28 -0
  181. package/dist/web/server/{chunk-IXGLKAPN.js → chunk-VHLBXWEN.js} +57 -42
  182. package/dist/web/server/{chunk-OMEDERPG.js → chunk-WU6KNEGU.js} +47 -32
  183. package/dist/web/server/chunk-X37KO4BO.js +29 -0
  184. package/dist/web/server/chunk-X5AQ7KHU.js +22 -0
  185. package/dist/web/server/chunk-XZCIEF54.js +28 -0
  186. package/dist/web/server/{chunk-7NZ3FJDA.js → chunk-YBCP4V6T.js} +2 -2
  187. package/dist/web/server/{chunk-7UTDOTOU.js → chunk-YKJJDQAK.js} +28 -100
  188. package/dist/web/server/chunk-Z4OTKGMN.js +25 -0
  189. package/dist/web/server/chunk-ZJIELDZL.js +39 -0
  190. package/dist/web/server/{chunk-UDD5W4CR.js → chunk-ZMF45HAO.js} +58 -45
  191. package/dist/web/server/chunk-ZNED4KTU.js +105 -0
  192. package/dist/web/server/chunk-ZNI5AL4B.js +30 -0
  193. package/dist/web/server/create-project-dialog-CigfFgAj-QS27NAJH.js +295 -0
  194. package/dist/web/server/{fork-picker-dialog-YKlapaxN-DR5L74ST.js → fork-picker-dialog-B5J-S5Nm-QOMVVHI7.js} +11 -10
  195. package/dist/web/server/{highlighted-body-KPVGNVTW-Ct6g7FVa-YZHVMLW4.js → highlighted-body-KPVGNVTW-D4Xsgab0-BZNKZ2YE.js} +3 -3
  196. package/dist/web/server/{markdown-BzNejPoZ-6ITTDAV6.js → markdown-DaTMVcnu-37DWI2JW.js} +4 -4
  197. package/dist/web/server/{markdown-code-DAwXuW6m-HHVELO6I.js → markdown-code-Cvz3a-x3-WAD4KC4A.js} +5 -5
  198. package/dist/web/server/{mermaid-HWGCJPDP-Ca26PwPZ-5EWRESLM.js → mermaid-HWGCJPDP-CDDePcVz-4BWFRGWL.js} +2 -2
  199. package/dist/web/server/{message-queue-Demph1x4-RBJUC3AT.js → message-queue-BsrLcNPX-CUCBSF6U.js} +15 -14
  200. package/dist/web/server/{model-selector-list-BmzLiCx9-TK6JGGKU.js → model-selector-list-Csw4nOra-IOMN5JMO.js} +23 -22
  201. package/dist/web/server/openui-renderer-TbIFXEW2-BET2OXM2.js +39 -0
  202. package/dist/web/server/{prompt-suggestions-yPZqX__K-3VGJC4IF.js → prompt-suggestions-D6RXFQF4-7WHYRNMN.js} +5 -5
  203. package/dist/web/server/{repl-panel-CgUF1qUw-3DFD2V53.js → repl-panel-CBwh0VGD-USDEOGGJ.js} +8 -9
  204. package/dist/web/server/{resources-panel-ChUliWV--JITAGS6Q.js → resources-panel-rn64m-sL-7QXEGRNX.js} +9 -10
  205. package/dist/web/server/{router-CPdFlpbe-LAD4MNZB.js → router-RPObiwZR-AFMFSYSZ.js} +2852 -186
  206. package/dist/web/server/{routes-hkom6S6L-DUPPQHPY.js → routes-Dn-deuPY-MDXEQXRU.js} +2219 -2435
  207. package/dist/web/server/server.js +6 -6
  208. package/dist/web/server/{session-insights-panel-xgrkX1Rp-FDNURBXZ.js → session-insights-panel-DKkakWj6-ITHKDXF4.js} +1 -1
  209. package/dist/web/server/{session-reasoning-panel-m1RgcIph-NUXGXVKE.js → session-reasoning-panel-CXMCAM8C-HZMR5JCO.js} +9 -10
  210. package/dist/web/server/session-tool-renderer-jldnNioy-5ATOVAG5.js +46 -0
  211. package/dist/web/server/session-tree-panel-WaHHv775-HRUHFSFO.js +229 -0
  212. package/dist/web/server/{settings-dialog-BCEfmgtP-T3WQEZHB.js → settings-dialog-CzeangBl-YKL7CLPF.js} +565 -388
  213. package/dist/web/server/{start-DVUbMfrb-ELVIFRUY.js → start-QK6aG02q-RXFV6K5L.js} +1 -1
  214. package/dist/web/server/{subagent-chat-panel-BTwI1kdB-LKBWA4GD.js → subagent-chat-panel-Fa31QewE-YDPOKN74.js} +49 -46
  215. package/dist/web/server/{subagents-panel-8Z9_csoV-HYMEEBHB.js → subagents-panel-DjOcQxp4-GZYOZOYC.js} +46 -44
  216. package/dist/web/server/tool-timeline-CfuizRid-L3Y3OSCH.js +15 -0
  217. package/dist/web/server/{workspace-panel-BHEB9nRM-TS62SYBA.js → workspace-panel-BU50q4Bu-JHTQPR6R.js} +109 -93
  218. package/package.json +1 -1
  219. package/dist/web/client/assets/agent-disclosure-CMrxF7L-.js +0 -1
  220. package/dist/web/client/assets/analytics-stub-C2vgmGm_.js +0 -1
  221. package/dist/web/client/assets/artifacts-panel-DmQghvw8.js +0 -1
  222. package/dist/web/client/assets/bot-DbB9BKL0.js +0 -1
  223. package/dist/web/client/assets/bundle-mjs-cJTHqqzI.js +0 -1
  224. package/dist/web/client/assets/chat-C24kD2SP.js +0 -52
  225. package/dist/web/client/assets/chat-command-palette-BIwjhE6s.js +0 -1
  226. package/dist/web/client/assets/check-B3LlvM65.js +0 -1
  227. package/dist/web/client/assets/chevron-down-DUUprRP5.js +0 -1
  228. package/dist/web/client/assets/chevron-right-NVqQIoiO.js +0 -1
  229. package/dist/web/client/assets/chunk-YOKDWASO-Bte3iwlH.js +0 -143
  230. package/dist/web/client/assets/citations-BUvM92nt.js +0 -1
  231. package/dist/web/client/assets/command-Dv96gATQ.js +0 -1
  232. package/dist/web/client/assets/createLucideIcon-_dfI7Arx.js +0 -1
  233. package/dist/web/client/assets/dialog-BCb4rQh0.js +0 -1
  234. package/dist/web/client/assets/dist-52wg4XPY.js +0 -1
  235. package/dist/web/client/assets/eye-CDHqtVoE.js +0 -1
  236. package/dist/web/client/assets/file-text-TmalmYrb.js +0 -1
  237. package/dist/web/client/assets/folder-vuNT4shY.js +0 -1
  238. package/dist/web/client/assets/gauge-BsDqNM1A.js +0 -1
  239. package/dist/web/client/assets/globals-DCtBkCSD.css +0 -2
  240. package/dist/web/client/assets/hard-drive-BT7UxHQu.js +0 -1
  241. package/dist/web/client/assets/horizontal-resize-VLjLByUV.js +0 -1
  242. package/dist/web/client/assets/index-BGnQeUYE.js +0 -12
  243. package/dist/web/client/assets/ipython-tool-CkHaO3PW.js +0 -3
  244. package/dist/web/client/assets/is-ref-object-BcRWZ4l7.js +0 -1
  245. package/dist/web/client/assets/loader-circle-B5GIZGxd.js +0 -1
  246. package/dist/web/client/assets/markdown-BHkByC9K.js +0 -2
  247. package/dist/web/client/assets/mermaid-HWGCJPDP-CY3N5ECk.js +0 -1
  248. package/dist/web/client/assets/package-BKBPgwMP.js +0 -1
  249. package/dist/web/client/assets/pencil-CdO6qfv3.js +0 -1
  250. package/dist/web/client/assets/plug-BRROUIw-.js +0 -1
  251. package/dist/web/client/assets/prompt-input-WaGSKZCU.js +0 -1
  252. package/dist/web/client/assets/provider-catalog-C0XBIasJ.js +0 -1
  253. package/dist/web/client/assets/provider-label-Cka0ep0S.js +0 -1
  254. package/dist/web/client/assets/react-CwJFpaho.js +0 -1
  255. package/dist/web/client/assets/react-dom-DX3XddaT.js +0 -1
  256. package/dist/web/client/assets/refresh-cw-l9WPHRkq.js +0 -1
  257. package/dist/web/client/assets/resource-helpers-BuWybA8l.js +0 -2
  258. package/dist/web/client/assets/right-panel-context-CS8tJMzE.js +0 -1
  259. package/dist/web/client/assets/right-panel-registry-BCW7fQTG.js +0 -2
  260. package/dist/web/client/assets/rotate-ccw-CfGhzOv7.js +0 -1
  261. package/dist/web/client/assets/routes-BWe5Iz-2.js +0 -16
  262. package/dist/web/client/assets/safe-external-url-BbAom7Bm.js +0 -1
  263. package/dist/web/client/assets/search-BjcXAUrI.js +0 -1
  264. package/dist/web/client/assets/session-tool-renderer-3E3cv8D0.js +0 -1395
  265. package/dist/web/client/assets/settings-dialog-B8lHq2tT.js +0 -2
  266. package/dist/web/client/assets/sparkles-D8XIY8pN.js +0 -1
  267. package/dist/web/client/assets/square-DQaQu9bp.js +0 -1
  268. package/dist/web/client/assets/square-terminal-BsopiuN7.js +0 -1
  269. package/dist/web/client/assets/subagent-transcript-lqNcSVbH.js +0 -1
  270. package/dist/web/client/assets/sun-D0llhiMU.js +0 -1
  271. package/dist/web/client/assets/switch-D3FhZU-S.js +0 -1
  272. package/dist/web/client/assets/terminal-BQAKkBY6.js +0 -1
  273. package/dist/web/client/assets/toast-lnCWGgSE.js +0 -1
  274. package/dist/web/client/assets/tokens-Ch5WqXC_.js +0 -1
  275. package/dist/web/client/assets/tool-result-B_yb2JoE.js +0 -4
  276. package/dist/web/client/assets/tool-timeline-VnMRQoLS.js +0 -1
  277. package/dist/web/client/assets/triangle-alert-GAYh_5d3.js +0 -1
  278. package/dist/web/client/assets/utils-Brtgag-m.js +0 -1
  279. package/dist/web/client/assets/virtualized-turn-list-BgUgX6tM.js +0 -6
  280. package/dist/web/client/assets/workspace-panel-CKF5JQl2.js +0 -1
  281. package/dist/web/client/assets/wrench-Myc12BTA.js +0 -1
  282. package/dist/web/client/assets/x-BGsDD848.js +0 -1
  283. package/dist/web/server/_tanstack-start-manifest_v-BDPifIFN-DTSNCHBX.js +0 -91
  284. package/dist/web/server/chunk-2ST2ULW7.js +0 -24
  285. package/dist/web/server/chunk-3C4CFCIS.js +0 -19
  286. package/dist/web/server/chunk-3IHTZSBY.js +0 -22
  287. package/dist/web/server/chunk-4QD4PCVP.js +0 -19
  288. package/dist/web/server/chunk-4ZIEVI5O.js +0 -63
  289. package/dist/web/server/chunk-7CNGNFFK.js +0 -23
  290. package/dist/web/server/chunk-AHTO6GDS.js +0 -33
  291. package/dist/web/server/chunk-CHEC7TWB.js +0 -22
  292. package/dist/web/server/chunk-D7ELZVTI.js +0 -33
  293. package/dist/web/server/chunk-GS2IZGRC.js +0 -19
  294. package/dist/web/server/chunk-HFQZLPU2.js +0 -29
  295. package/dist/web/server/chunk-JBLHIEVG.js +0 -22
  296. package/dist/web/server/chunk-JDCCC7A7.js +0 -3382
  297. package/dist/web/server/chunk-JIULUYHT.js +0 -24
  298. package/dist/web/server/chunk-KBWUBWVJ.js +0 -60
  299. package/dist/web/server/chunk-LJ6Y7DBH.js +0 -128
  300. package/dist/web/server/chunk-M5RSPNYN.js +0 -22
  301. package/dist/web/server/chunk-O2DUZJYK.js +0 -19
  302. package/dist/web/server/chunk-OKL5ZRVB.js +0 -33
  303. package/dist/web/server/chunk-OOXWPL22.js +0 -22
  304. package/dist/web/server/chunk-OSMP55KI.js +0 -94
  305. package/dist/web/server/chunk-SFTKGQ7H.js +0 -33
  306. package/dist/web/server/chunk-TNL4YV63.js +0 -29
  307. package/dist/web/server/chunk-UCA4WN66.js +0 -45
  308. package/dist/web/server/chunk-WWJF4RO2.js +0 -19
  309. package/dist/web/server/chunk-X7D6GFQU.js +0 -34
  310. package/dist/web/server/chunk-XA42CHF2.js +0 -22
  311. package/dist/web/server/openui-renderer-moJGf0LA-QCU3PI6H.js +0 -38
  312. package/dist/web/server/session-tool-renderer-CglQ2ky7-2JVYNZG2.js +0 -45
  313. package/dist/web/server/tool-timeline-QL9k5dzA-RLU26HXT.js +0 -16
@@ -1,6 +1,3 @@
1
- import {
2
- isModelPatternEnabled
3
- } from "./chunk-WTYNN6EV.js";
4
1
  import {
5
2
  ChatMcpDeleteRequestSchema,
6
3
  ChatMcpOAuthLoginRequestSchema,
@@ -10,41 +7,24 @@ import {
10
7
  ChatProviderRemoveRequestSchema,
11
8
  ChatProviderUpdateRequestSchema,
12
9
  ChatSettingsUpdateRequestSchema,
10
+ ComposerCompletionRequestSchema,
11
+ ComposerIntentCredentialSchema,
12
+ ComposerIntentRequestSchema,
13
+ ComposerIntentSettingsUpdateSchema,
13
14
  FLEET_ADAPTER_CAPABILITIES,
14
- HTMLVisualElement,
15
- MotionConfig,
16
15
  NETWORK_DISCONNECTED_MESSAGE,
17
16
  QueryClient,
18
17
  QueryClientProvider,
19
- SVGVisualElement,
20
- addValueToWillChange,
21
- animateMotionValue,
22
- animateSingleValue,
23
- animateTarget,
24
- applyBoxDelta,
25
- applyTreeDeltas,
26
- circOut,
27
- convertBoundingBoxToBox,
28
- convertBoxToBoundingBox,
29
- getOptimisedAppearId,
30
- getValueTransition,
31
- has2DTranslate,
32
- hasScale,
33
- hasTransform,
18
+ SessionTreeNavigateRequestSchema,
19
+ SessionTreeNavigateResponseSchema,
20
+ SessionTreeSnapshotResponseSchema,
21
+ composerCompletionIgnores,
34
22
  initAnalytics,
35
- isKeyframesTarget,
36
- isSVGElement,
37
- isSVGSVGElement,
38
- isServer,
39
- measurePageBox,
40
- pipe,
41
- progress,
42
- resolveElements,
43
- resolveVariant,
44
- scalePoint,
45
- transformBox,
46
- translateAxis
47
- } from "./chunk-CCYLHNZJ.js";
23
+ isServer
24
+ } from "./chunk-4B2PJSK5.js";
25
+ import {
26
+ isModelPatternEnabled
27
+ } from "./chunk-WTYNN6EV.js";
48
28
  import {
49
29
  DEFAULT_UI_PREFERENCES,
50
30
  applyUiPreferencesToDocument,
@@ -52,53 +32,102 @@ import {
52
32
  } from "./chunk-4EBSM4JR.js";
53
33
  import {
54
34
  Toaster
55
- } from "./chunk-IXGLKAPN.js";
35
+ } from "./chunk-VHLBXWEN.js";
56
36
  import {
57
37
  fallbackSessionLabel,
58
38
  meaningfulSessionLabel,
59
39
  redactSessionLabelSecrets
60
40
  } from "./chunk-PTCKOR23.js";
61
41
  import "./chunk-SZJUXVWG.js";
62
- import "./chunk-TNL4YV63.js";
42
+ import "./chunk-HFN4TNR3.js";
63
43
  import {
64
44
  isHTMLElement,
45
+ isObject,
65
46
  usePresence
66
- } from "./chunk-K6PTNSCW.js";
47
+ } from "./chunk-36BG6OPK.js";
67
48
  import {
49
+ KeyframeResolver,
68
50
  LayoutGroupContext,
69
51
  LazyContext,
52
+ MotionConfigContext,
53
+ MotionGlobalConfig,
54
+ NativeAnimation,
70
55
  SubscriptionManager,
71
56
  SwitchLayoutGroupContext,
57
+ VisualElement,
58
+ WithPromise,
59
+ acceleratedValues,
72
60
  addUniqueItem,
61
+ analyseComplexValue,
62
+ buildHTMLStyles,
63
+ buildSVGAttrs,
64
+ camelToDash,
73
65
  cancelFrame,
74
66
  clamp,
67
+ color,
68
+ complex,
69
+ containsCSSVariable,
75
70
  cornerRadiusProps,
76
71
  createBox,
77
72
  createDelta,
73
+ cssStyleProperties,
74
+ defaultTransformValue,
75
+ findDimensionValueType,
76
+ flushKeyframeResolvers,
78
77
  frame,
79
78
  frameData,
80
79
  frameSteps,
80
+ generateLinearEasing,
81
+ getAnimatableNone,
82
+ getDefaultValueType,
83
+ getFinalKeyframe,
84
+ hex,
85
+ hsla,
81
86
  invariant,
82
87
  isAnimationControls,
88
+ isBezierDefinition,
89
+ isCSSVariableName,
90
+ isCSSVariableToken,
91
+ isGenerator,
92
+ isMotionValue,
93
+ isNumOrPxType,
94
+ isNumericalString,
83
95
  isRefObject,
84
96
  isSVGComponent,
97
+ isSVGTag,
85
98
  isVariantLabel,
99
+ isZeroValueString,
86
100
  loadFeatures,
101
+ memo$1,
87
102
  microtask,
88
103
  millisecondsToSeconds,
89
104
  mixNumber,
90
105
  motionValue,
91
106
  noop,
107
+ optimizedAppearDataAttribute,
92
108
  percent,
109
+ positionalValues,
93
110
  px,
111
+ readTransformValue,
94
112
  removeItem,
95
113
  resolveMotionValue,
114
+ resolveVariantFromProps,
115
+ rgba,
96
116
  scaleCorrectors,
117
+ scrapeMotionValuesFromProps,
118
+ scrapeMotionValuesFromProps$1,
97
119
  secondsToMilliseconds,
120
+ setStyle,
98
121
  time,
122
+ transformPropOrder,
123
+ transformProps,
124
+ useConstant,
99
125
  variantPriorityOrder,
100
- variantProps
101
- } from "./chunk-7E76R7MB.js";
126
+ variantProps,
127
+ velocityPerSecond,
128
+ warning
129
+ } from "./chunk-QHCQDVCQ.js";
130
+ import "./chunk-FOMB2JR7.js";
102
131
  import {
103
132
  Card,
104
133
  CardContent,
@@ -106,8 +135,10 @@ import {
106
135
  CardHeader,
107
136
  CardTitle,
108
137
  validateAndNormalizeOpenUIHtmlArtifact
109
- } from "./chunk-JPDRUSUD.js";
138
+ } from "./chunk-FF2M3MLP.js";
110
139
  import {
140
+ COMPOSER_INTENT_COMMANDS,
141
+ COMPOSER_INTENT_NONE,
111
142
  ChatNewRequestSchema,
112
143
  ChatOpenUIArtifactUpsertRequestSchema,
113
144
  ChatPlanPresentationSchema,
@@ -125,8 +156,11 @@ import {
125
156
  SessionIdSchema,
126
157
  UploadedAttachmentSchema,
127
158
  ZodError,
128
- external_exports
129
- } from "./chunk-YMPJMHXZ.js";
159
+ composerIntentCommand,
160
+ decideComposerIntent,
161
+ external_exports,
162
+ isSingleTokenDraft
163
+ } from "./chunk-3YYNG52U.js";
130
164
  import {
131
165
  KNOWN_PROVIDERS,
132
166
  OPENAI_CHAT_COMPLETIONS_PROVIDER_ID,
@@ -141,13 +175,13 @@ import {
141
175
  toInstanceSlug,
142
176
  toOccInstanceId
143
177
  } from "./chunk-RJOANOT4.js";
144
- import "./chunk-HQ5TEXHT.js";
145
- import "./chunk-TLNZNR7C.js";
146
- import "./chunk-JBLHIEVG.js";
147
- import "./chunk-XJ6TGSUB.js";
148
- import "./chunk-HFQZLPU2.js";
149
- import "./chunk-4ZIEVI5O.js";
150
- import "./chunk-CHEC7TWB.js";
178
+ import "./chunk-XZCIEF54.js";
179
+ import "./chunk-UXS5E6OE.js";
180
+ import "./chunk-UUDBEYKV.js";
181
+ import "./chunk-EKVRPCBJ.js";
182
+ import "./chunk-SGMJ5CGW.js";
183
+ import "./chunk-JVXQQYXB.js";
184
+ import "./chunk-JCK6B7ZW.js";
151
185
  import {
152
186
  HeadContent,
153
187
  Outlet,
@@ -156,13 +190,13 @@ import {
156
190
  createRootRoute,
157
191
  createRouter,
158
192
  lazyRouteComponent
159
- } from "./chunk-5727TXOK.js";
160
- import "./chunk-JDCCC7A7.js";
193
+ } from "./chunk-F5DJQ3PQ.js";
194
+ import "./chunk-RPWKCJHL.js";
161
195
  import "./chunk-L547YHC4.js";
162
196
  import "./chunk-MLKGABMK.js";
163
197
 
164
- // web/app/dist/server/assets/router-CPdFlpbe.js
165
- import { Component, Fragment, useContext, useEffect, useLayoutEffect, useRef, useState } from "react";
198
+ // web/app/dist/server/assets/router-RPObiwZR.js
199
+ import { Component, Fragment, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
166
200
  import { jsx, jsxs } from "react/jsx-runtime";
167
201
  import { basename, dirname, extname, isAbsolute, join, relative, resolve, sep } from "node:path";
168
202
  import { fileURLToPath } from "node:url";
@@ -172,12 +206,1295 @@ import { AuthStorage, DAEMON_PROTOCOL_NAME, DAEMON_PROTOCOL_VERSION, DaemonAgent
172
206
  import { spawn } from "node:child_process";
173
207
  import { homedir } from "node:os";
174
208
  import { getProviders, getSupportedThinkingLevels } from "@earendil-works/pi-ai";
209
+ var pipe = (...transformers) => transformers.reduce((a, b) => (v) => b(a(v)));
210
+ var progress = /* @__NO_SIDE_EFFECTS__ */ (from, to, value) => {
211
+ const range = to - from;
212
+ return range ? (value - from) / range : 1;
213
+ };
214
+ var calcBezier = (t, a1, a2) => (((1 - 3 * a2 + 3 * a1) * t + (3 * a2 - 6 * a1)) * t + 3 * a1) * t;
215
+ var subdivisionPrecision = 1e-7;
216
+ var subdivisionMaxIterations = 12;
217
+ function binarySubdivide(x, lowerBound, upperBound, mX1, mX2) {
218
+ let currentX;
219
+ let currentT;
220
+ let i = 0;
221
+ do {
222
+ currentT = lowerBound + (upperBound - lowerBound) / 2;
223
+ currentX = calcBezier(currentT, mX1, mX2) - x;
224
+ if (currentX > 0) upperBound = currentT;
225
+ else lowerBound = currentT;
226
+ } while (Math.abs(currentX) > subdivisionPrecision && ++i < subdivisionMaxIterations);
227
+ return currentT;
228
+ }
229
+ // @__NO_SIDE_EFFECTS__
230
+ function cubicBezier(mX1, mY1, mX2, mY2) {
231
+ if (mX1 === mY1 && mX2 === mY2) return noop;
232
+ const getTForX = (aX) => binarySubdivide(aX, 0, 1, mX1, mX2);
233
+ return (t) => t === 0 || t === 1 ? t : calcBezier(getTForX(t), mY1, mY2);
234
+ }
235
+ var mirrorEasing = /* @__NO_SIDE_EFFECTS__ */ (easing) => (p) => p <= 0.5 ? easing(2 * p) / 2 : (2 - easing(2 * (1 - p))) / 2;
236
+ var reverseEasing = /* @__NO_SIDE_EFFECTS__ */ (easing) => (p) => 1 - easing(1 - p);
237
+ var backOut = /* @__PURE__ */ cubicBezier(0.33, 1.53, 0.69, 0.99);
238
+ var backIn = /* @__PURE__ */ reverseEasing(backOut);
239
+ var backInOut = /* @__PURE__ */ mirrorEasing(backIn);
240
+ var anticipate = (p) => p >= 1 ? 1 : (p *= 2) < 1 ? 0.5 * backIn(p) : 0.5 * (2 - Math.pow(2, -10 * (p - 1)));
241
+ var circIn = (p) => 1 - Math.sin(Math.acos(p));
242
+ var circOut = /* @__PURE__ */ reverseEasing(circIn);
243
+ var circInOut = /* @__PURE__ */ mirrorEasing(circIn);
244
+ var easeIn = /* @__PURE__ */ cubicBezier(0.42, 0, 1, 1);
245
+ var easeOut = /* @__PURE__ */ cubicBezier(0, 0, 0.58, 1);
246
+ var easeInOut = /* @__PURE__ */ cubicBezier(0.42, 0, 0.58, 1);
247
+ var isEasingArray = /* @__NO_SIDE_EFFECTS__ */ (ease2) => {
248
+ return Array.isArray(ease2) && typeof ease2[0] !== "number";
249
+ };
250
+ var easingLookup = {
251
+ linear: noop,
252
+ easeIn,
253
+ easeInOut,
254
+ easeOut,
255
+ circIn,
256
+ circInOut,
257
+ circOut,
258
+ backIn,
259
+ backInOut,
260
+ backOut,
261
+ anticipate
262
+ };
263
+ var isValidEasing = (easing) => {
264
+ return typeof easing === "string";
265
+ };
266
+ var easingDefinitionToFunction = (definition) => {
267
+ if (isBezierDefinition(definition)) {
268
+ invariant(definition.length === 4, `Cubic bezier arrays must contain four numerical values.`, "cubic-bezier-length");
269
+ const [x1, y1, x2, y2] = definition;
270
+ return /* @__PURE__ */ cubicBezier(x1, y1, x2, y2);
271
+ } else if (isValidEasing(definition)) {
272
+ invariant(easingLookup[definition] !== void 0, `Invalid easing type '${definition}'`, "invalid-easing-type");
273
+ return easingLookup[definition];
274
+ }
275
+ return definition;
276
+ };
277
+ function hueToRgb(p, q, t) {
278
+ if (t < 0) t += 1;
279
+ if (t > 1) t -= 1;
280
+ if (t < 1 / 6) return p + (q - p) * 6 * t;
281
+ if (t < 1 / 2) return q;
282
+ if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
283
+ return p;
284
+ }
285
+ function hslaToRgba({ hue, saturation, lightness, alpha }) {
286
+ hue /= 360;
287
+ saturation /= 100;
288
+ lightness /= 100;
289
+ let red = 0;
290
+ let green = 0;
291
+ let blue = 0;
292
+ if (!saturation) red = green = blue = lightness;
293
+ else {
294
+ const q = lightness < 0.5 ? lightness * (1 + saturation) : lightness + saturation - lightness * saturation;
295
+ const p = 2 * lightness - q;
296
+ red = hueToRgb(p, q, hue + 1 / 3);
297
+ green = hueToRgb(p, q, hue);
298
+ blue = hueToRgb(p, q, hue - 1 / 3);
299
+ }
300
+ return {
301
+ red: Math.round(red * 255),
302
+ green: Math.round(green * 255),
303
+ blue: Math.round(blue * 255),
304
+ alpha
305
+ };
306
+ }
307
+ function mixImmediate(a, b) {
308
+ return (p) => p > 0 ? b : a;
309
+ }
310
+ var mixLinearColor = (from, to, v) => {
311
+ const fromExpo = from * from;
312
+ const expo = v * (to * to - fromExpo) + fromExpo;
313
+ return expo < 0 ? 0 : Math.sqrt(expo);
314
+ };
315
+ var colorTypes = [
316
+ hex,
317
+ rgba,
318
+ hsla
319
+ ];
320
+ var getColorType = (v) => colorTypes.find((type) => type.test(v));
321
+ function asRGBA(color2) {
322
+ const type = getColorType(color2);
323
+ warning(Boolean(type), `'${color2}' is not an animatable color. Use the equivalent color code instead.`, "color-not-animatable");
324
+ if (!Boolean(type)) return false;
325
+ let model = type.parse(color2);
326
+ if (type === hsla) model = hslaToRgba(model);
327
+ return model;
328
+ }
329
+ var mixColor = (from, to) => {
330
+ const fromRGBA = asRGBA(from);
331
+ const toRGBA = asRGBA(to);
332
+ if (!fromRGBA || !toRGBA) return mixImmediate(from, to);
333
+ const blended = { ...fromRGBA };
334
+ return (v) => {
335
+ blended.red = mixLinearColor(fromRGBA.red, toRGBA.red, v);
336
+ blended.green = mixLinearColor(fromRGBA.green, toRGBA.green, v);
337
+ blended.blue = mixLinearColor(fromRGBA.blue, toRGBA.blue, v);
338
+ blended.alpha = mixNumber(fromRGBA.alpha, toRGBA.alpha, v);
339
+ return rgba.transform(blended);
340
+ };
341
+ };
342
+ var invisibleValues = /* @__PURE__ */ new Set(["none", "hidden"]);
343
+ function mixVisibility(origin, target) {
344
+ if (invisibleValues.has(origin)) return (p) => p <= 0 ? origin : target;
345
+ else return (p) => p >= 1 ? target : origin;
346
+ }
347
+ function mixNumber2(a, b) {
348
+ return (p) => mixNumber(a, b, p);
349
+ }
350
+ function getMixer(a) {
351
+ if (typeof a === "number") return mixNumber2;
352
+ else if (typeof a === "string") return isCSSVariableToken(a) ? mixImmediate : color.test(a) ? mixColor : mixComplex;
353
+ else if (Array.isArray(a)) return mixArray;
354
+ else if (typeof a === "object") return color.test(a) ? mixColor : mixObject;
355
+ return mixImmediate;
356
+ }
357
+ function mixArray(a, b) {
358
+ const output = [...a];
359
+ const numValues = output.length;
360
+ const blendValue = a.map((v, i) => getMixer(v)(v, b[i]));
361
+ return (p) => {
362
+ for (let i = 0; i < numValues; i++) output[i] = blendValue[i](p);
363
+ return output;
364
+ };
365
+ }
366
+ function mixObject(a, b) {
367
+ const output = {
368
+ ...a,
369
+ ...b
370
+ };
371
+ const blendValue = {};
372
+ for (const key in output) if (a[key] !== void 0 && b[key] !== void 0) blendValue[key] = getMixer(a[key])(a[key], b[key]);
373
+ return (v) => {
374
+ for (const key in blendValue) output[key] = blendValue[key](v);
375
+ return output;
376
+ };
377
+ }
378
+ function matchOrder(origin, target) {
379
+ const orderedOrigin = [];
380
+ const pointers = {
381
+ color: 0,
382
+ var: 0,
383
+ number: 0
384
+ };
385
+ for (let i = 0; i < target.values.length; i++) {
386
+ const type = target.types[i];
387
+ const originIndex = origin.indexes[type][pointers[type]];
388
+ const originValue = origin.values[originIndex] ?? 0;
389
+ orderedOrigin[i] = originValue;
390
+ pointers[type]++;
391
+ }
392
+ return orderedOrigin;
393
+ }
394
+ var mixComplex = (origin, target) => {
395
+ const template = complex.createTransformer(target);
396
+ const originStats = analyseComplexValue(origin);
397
+ const targetStats = analyseComplexValue(target);
398
+ if (originStats.indexes.var.length === targetStats.indexes.var.length && originStats.indexes.color.length === targetStats.indexes.color.length && originStats.indexes.number.length >= targetStats.indexes.number.length) {
399
+ if (invisibleValues.has(origin) && !targetStats.values.length || invisibleValues.has(target) && !originStats.values.length) return mixVisibility(origin, target);
400
+ return pipe(mixArray(matchOrder(originStats, targetStats), targetStats.values), template);
401
+ } else {
402
+ warning(true, `Complex values '${origin}' and '${target}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`, "complex-values-different");
403
+ return mixImmediate(origin, target);
404
+ }
405
+ };
406
+ function mix(from, to, p) {
407
+ if (typeof from === "number" && typeof to === "number" && typeof p === "number") return mixNumber(from, to, p);
408
+ return getMixer(from)(from, to);
409
+ }
410
+ var frameloopDriver = (update) => {
411
+ const passTimestamp = ({ timestamp }) => update(timestamp);
412
+ return {
413
+ start: (keepAlive = true) => frame.update(passTimestamp, keepAlive),
414
+ stop: () => cancelFrame(passTimestamp),
415
+ /**
416
+ * If we're processing this frame we can use the
417
+ * framelocked timestamp to keep things in sync.
418
+ */
419
+ now: () => frameData.isProcessing ? frameData.timestamp : time.now()
420
+ };
421
+ };
422
+ var maxGeneratorDuration = 2e4;
423
+ function calcGeneratorDuration(generator, timeStep = 50, maxDuration = maxGeneratorDuration, keyframes2) {
424
+ let duration = 0;
425
+ let state = generator.next(duration);
426
+ keyframes2?.push(state.value);
427
+ while (!state.done && duration < maxDuration) {
428
+ duration += timeStep;
429
+ state = generator.next(duration);
430
+ keyframes2?.push(state.value);
431
+ }
432
+ return duration >= maxDuration ? Infinity : duration;
433
+ }
434
+ function createGeneratorEasing(options, scale = 100, createGenerator) {
435
+ const generator = createGenerator({
436
+ ...options,
437
+ keyframes: [0, scale]
438
+ });
439
+ const duration = Math.min(calcGeneratorDuration(generator), maxGeneratorDuration);
440
+ return {
441
+ type: "keyframes",
442
+ ease: (progress2) => {
443
+ return generator.next(duration * progress2).value / scale;
444
+ },
445
+ duration: millisecondsToSeconds(duration)
446
+ };
447
+ }
448
+ var springDefaults = {
449
+ stiffness: 100,
450
+ damping: 10,
451
+ mass: 1,
452
+ velocity: 0,
453
+ duration: 800,
454
+ bounce: 0.3,
455
+ visualDuration: 0.3,
456
+ restSpeed: {
457
+ granular: 0.01,
458
+ default: 2
459
+ },
460
+ restDelta: {
461
+ granular: 5e-3,
462
+ default: 0.5
463
+ },
464
+ minDuration: 0.01,
465
+ maxDuration: 10,
466
+ minDamping: 0.05,
467
+ maxDamping: 1
468
+ };
469
+ function calcAngularFreq(undampedFreq, dampingRatio) {
470
+ return undampedFreq * Math.sqrt(1 - dampingRatio * dampingRatio);
471
+ }
472
+ var rootIterations = 12;
473
+ function approximateRoot(envelope, derivative, initialGuess) {
474
+ let result = initialGuess;
475
+ for (let i = 1; i < rootIterations; i++) result = result - envelope(result) / derivative(result);
476
+ return result;
477
+ }
478
+ var safeMin = 1e-3;
479
+ function findSpring({ duration = springDefaults.duration, bounce = springDefaults.bounce, velocity = springDefaults.velocity, mass = springDefaults.mass }) {
480
+ let envelope;
481
+ let derivative;
482
+ warning(duration <= secondsToMilliseconds(springDefaults.maxDuration), "Spring duration must be 10 seconds or less", "spring-duration-limit");
483
+ let dampingRatio = 1 - bounce;
484
+ dampingRatio = clamp(springDefaults.minDamping, springDefaults.maxDamping, dampingRatio);
485
+ duration = clamp(springDefaults.minDuration, springDefaults.maxDuration, millisecondsToSeconds(duration));
486
+ if (dampingRatio < 1) {
487
+ envelope = (undampedFreq2) => {
488
+ const exponentialDecay = undampedFreq2 * dampingRatio;
489
+ const delta = exponentialDecay * duration;
490
+ const a = exponentialDecay - velocity;
491
+ const b = calcAngularFreq(undampedFreq2, dampingRatio);
492
+ const c = Math.exp(-delta);
493
+ return safeMin - a / b * c;
494
+ };
495
+ derivative = (undampedFreq2) => {
496
+ const delta = undampedFreq2 * dampingRatio * duration;
497
+ const d = delta * velocity + velocity;
498
+ const e = dampingRatio * dampingRatio * undampedFreq2 * undampedFreq2 * duration;
499
+ const f = Math.exp(-delta);
500
+ const g = calcAngularFreq(undampedFreq2 * undampedFreq2, dampingRatio);
501
+ return (-envelope(undampedFreq2) + safeMin > 0 ? -1 : 1) * ((d - e) * f) / g;
502
+ };
503
+ } else {
504
+ envelope = (undampedFreq2) => {
505
+ return -1e-3 + Math.exp(-undampedFreq2 * duration) * ((undampedFreq2 - velocity) * duration + 1);
506
+ };
507
+ derivative = (undampedFreq2) => {
508
+ return Math.exp(-undampedFreq2 * duration) * ((velocity - undampedFreq2) * (duration * duration));
509
+ };
510
+ }
511
+ const initialGuess = 5 / duration;
512
+ const undampedFreq = approximateRoot(envelope, derivative, initialGuess);
513
+ duration = secondsToMilliseconds(duration);
514
+ if (isNaN(undampedFreq)) return {
515
+ stiffness: springDefaults.stiffness,
516
+ damping: springDefaults.damping,
517
+ duration
518
+ };
519
+ else {
520
+ const stiffness = undampedFreq * undampedFreq * mass;
521
+ return {
522
+ stiffness,
523
+ damping: dampingRatio * 2 * Math.sqrt(mass * stiffness),
524
+ duration
525
+ };
526
+ }
527
+ }
528
+ var durationKeys = ["duration", "bounce"];
529
+ var physicsKeys = [
530
+ "stiffness",
531
+ "damping",
532
+ "mass"
533
+ ];
534
+ function isSpringType(options, keys) {
535
+ return keys.some((key) => options[key] !== void 0);
536
+ }
537
+ function getSpringOptions(options) {
538
+ let springOptions = {
539
+ velocity: springDefaults.velocity,
540
+ stiffness: springDefaults.stiffness,
541
+ damping: springDefaults.damping,
542
+ mass: springDefaults.mass,
543
+ isResolvedFromDuration: false,
544
+ ...options
545
+ };
546
+ if (!isSpringType(options, physicsKeys) && isSpringType(options, durationKeys)) {
547
+ springOptions.velocity = 0;
548
+ if (options.visualDuration) {
549
+ const visualDuration = options.visualDuration;
550
+ const root2 = 2 * Math.PI / (visualDuration * 1.2);
551
+ const stiffness = root2 * root2;
552
+ const damping = 2 * clamp(0.05, 1, 1 - (options.bounce || 0)) * Math.sqrt(stiffness);
553
+ springOptions = {
554
+ ...springOptions,
555
+ mass: springDefaults.mass,
556
+ stiffness,
557
+ damping
558
+ };
559
+ } else {
560
+ const derived = findSpring({
561
+ ...options,
562
+ velocity: 0
563
+ });
564
+ springOptions = {
565
+ ...springOptions,
566
+ ...derived,
567
+ mass: springDefaults.mass
568
+ };
569
+ springOptions.isResolvedFromDuration = true;
570
+ }
571
+ }
572
+ return springOptions;
573
+ }
574
+ function spring(optionsOrVisualDuration = springDefaults.visualDuration, bounce = springDefaults.bounce) {
575
+ const options = typeof optionsOrVisualDuration !== "object" ? {
576
+ visualDuration: optionsOrVisualDuration,
577
+ keyframes: [0, 1],
578
+ bounce
579
+ } : optionsOrVisualDuration;
580
+ let { restSpeed, restDelta } = options;
581
+ const origin = options.keyframes[0];
582
+ const target = options.keyframes[options.keyframes.length - 1];
583
+ const state = {
584
+ done: false,
585
+ value: origin
586
+ };
587
+ const { stiffness, damping, mass, duration, velocity, isResolvedFromDuration } = getSpringOptions({
588
+ ...options,
589
+ velocity: -millisecondsToSeconds(options.velocity || 0)
590
+ });
591
+ const initialVelocity = velocity || 0;
592
+ const dampingRatio = damping / (2 * Math.sqrt(stiffness * mass));
593
+ const initialDelta = target - origin;
594
+ const undampedAngularFreq = millisecondsToSeconds(Math.sqrt(stiffness / mass));
595
+ const decay = dampingRatio * undampedAngularFreq;
596
+ const isGranularScale = Math.abs(initialDelta) < 5;
597
+ restSpeed || (restSpeed = isGranularScale ? springDefaults.restSpeed.granular : springDefaults.restSpeed.default);
598
+ restDelta || (restDelta = isGranularScale ? springDefaults.restDelta.granular : springDefaults.restDelta.default);
599
+ let resolveSpring;
600
+ let resolveVelocity;
601
+ if (dampingRatio < 1) {
602
+ const angularFreq = calcAngularFreq(undampedAngularFreq, dampingRatio);
603
+ const A = (initialVelocity + decay * initialDelta) / angularFreq;
604
+ const sinCoeff = decay * A + initialDelta * angularFreq;
605
+ const cosCoeff = decay * initialDelta - A * angularFreq;
606
+ let sampledT = -1;
607
+ let position = 0;
608
+ let velocityAtT = 0;
609
+ const sample = (t) => {
610
+ if (t !== sampledT) {
611
+ sampledT = t;
612
+ const envelope = Math.exp(-decay * t);
613
+ const sin = Math.sin(angularFreq * t);
614
+ const cos = Math.cos(angularFreq * t);
615
+ position = target - envelope * (A * sin + initialDelta * cos);
616
+ velocityAtT = envelope * (sinCoeff * sin + cosCoeff * cos);
617
+ }
618
+ };
619
+ resolveSpring = (t) => {
620
+ sample(t);
621
+ return position;
622
+ };
623
+ resolveVelocity = (t) => {
624
+ sample(t);
625
+ return velocityAtT;
626
+ };
627
+ } else if (dampingRatio === 1) {
628
+ resolveSpring = (t) => target - Math.exp(-undampedAngularFreq * t) * (initialDelta + (initialVelocity + undampedAngularFreq * initialDelta) * t);
629
+ const C = initialVelocity + undampedAngularFreq * initialDelta;
630
+ resolveVelocity = (t) => Math.exp(-undampedAngularFreq * t) * (undampedAngularFreq * C * t - initialVelocity);
631
+ } else {
632
+ const dampedAngularFreq = undampedAngularFreq * Math.sqrt(dampingRatio * dampingRatio - 1);
633
+ resolveSpring = (t) => {
634
+ const envelope = Math.exp(-decay * t);
635
+ const freqForT = Math.min(dampedAngularFreq * t, 300);
636
+ return target - envelope * ((initialVelocity + decay * initialDelta) * Math.sinh(freqForT) + dampedAngularFreq * initialDelta * Math.cosh(freqForT)) / dampedAngularFreq;
637
+ };
638
+ const P = (initialVelocity + decay * initialDelta) / dampedAngularFreq;
639
+ const sinhCoeff = decay * P - initialDelta * dampedAngularFreq;
640
+ const coshCoeff = decay * initialDelta - P * dampedAngularFreq;
641
+ resolveVelocity = (t) => {
642
+ const envelope = Math.exp(-decay * t);
643
+ const freqForT = Math.min(dampedAngularFreq * t, 300);
644
+ return envelope * (sinhCoeff * Math.sinh(freqForT) + coshCoeff * Math.cosh(freqForT));
645
+ };
646
+ }
647
+ const generator = {
648
+ calculatedDuration: isResolvedFromDuration ? duration || null : null,
649
+ velocity: (t) => secondsToMilliseconds(resolveVelocity(t)),
650
+ next: (t) => {
651
+ const current = resolveSpring(t);
652
+ if (!isResolvedFromDuration) {
653
+ const currentVelocity = secondsToMilliseconds(resolveVelocity(t));
654
+ state.done = Math.abs(currentVelocity) <= restSpeed && Math.abs(target - current) <= restDelta;
655
+ } else state.done = t >= duration;
656
+ state.value = state.done ? target : current;
657
+ return state;
658
+ },
659
+ toString: () => {
660
+ const calculatedDuration = Math.min(calcGeneratorDuration(generator), maxGeneratorDuration);
661
+ const easing = generateLinearEasing((progress2) => generator.next(calculatedDuration * progress2).value, calculatedDuration, 30);
662
+ return calculatedDuration + "ms " + easing;
663
+ },
664
+ toTransition: () => {
665
+ }
666
+ };
667
+ return generator;
668
+ }
669
+ spring.applyToOptions = (options) => {
670
+ const generatorOptions = createGeneratorEasing(options, 100, spring);
671
+ options.ease = generatorOptions.ease;
672
+ options.duration = secondsToMilliseconds(generatorOptions.duration);
673
+ options.type = "keyframes";
674
+ return options;
675
+ };
676
+ function inertia({ keyframes: keyframes2, velocity = 0, power = 0.8, timeConstant = 325, bounceDamping = 10, bounceStiffness = 500, modifyTarget, min, max, restDelta = 0.5, restSpeed }) {
677
+ const origin = keyframes2[0];
678
+ const state = {
679
+ done: false,
680
+ value: origin
681
+ };
682
+ const isOutOfBounds = (v) => v < min || v > max;
683
+ const nearestBoundary = (v) => {
684
+ if (min === void 0) return max;
685
+ if (max === void 0) return min;
686
+ return Math.abs(min - v) < Math.abs(max - v) ? min : max;
687
+ };
688
+ let amplitude = power * velocity;
689
+ const ideal = origin + amplitude;
690
+ const target = modifyTarget === void 0 ? ideal : modifyTarget(ideal);
691
+ if (target !== ideal) amplitude = target - origin;
692
+ const calcDelta = (t) => -amplitude * Math.exp(-t / timeConstant);
693
+ const applyFriction = (t) => {
694
+ const delta = calcDelta(t);
695
+ state.done = Math.abs(delta) <= restDelta;
696
+ state.value = state.done ? target : target + delta;
697
+ };
698
+ let timeReachedBoundary;
699
+ let spring$1;
700
+ const checkCatchBoundary = (t) => {
701
+ if (!isOutOfBounds(state.value)) return;
702
+ timeReachedBoundary = t;
703
+ spring$1 = spring({
704
+ keyframes: [state.value, nearestBoundary(state.value)],
705
+ /**
706
+ * The friction curve is target + calcDelta(t), so its exact
707
+ * derivative is -calcDelta(t) / timeConstant in units/ms,
708
+ * converted here to the units/second expected by spring.
709
+ */
710
+ velocity: -calcDelta(t) / timeConstant * 1e3,
711
+ damping: bounceDamping,
712
+ stiffness: bounceStiffness,
713
+ restDelta,
714
+ restSpeed
715
+ });
716
+ };
717
+ checkCatchBoundary(0);
718
+ return {
719
+ calculatedDuration: null,
720
+ next: (t) => {
721
+ let hasUpdatedFrame = false;
722
+ if (!spring$1 && timeReachedBoundary === void 0) {
723
+ hasUpdatedFrame = true;
724
+ applyFriction(t);
725
+ checkCatchBoundary(t);
726
+ }
727
+ if (timeReachedBoundary !== void 0 && t >= timeReachedBoundary) return spring$1.next(t - timeReachedBoundary);
728
+ else {
729
+ !hasUpdatedFrame && applyFriction(t);
730
+ return state;
731
+ }
732
+ }
733
+ };
734
+ }
735
+ function createMixers(output, ease2, customMixer) {
736
+ const mixers = [];
737
+ const mixerFactory = customMixer || MotionGlobalConfig.mix || mix;
738
+ const numMixers = output.length - 1;
739
+ for (let i = 0; i < numMixers; i++) {
740
+ let mixer = mixerFactory(output[i], output[i + 1]);
741
+ if (ease2) mixer = pipe(Array.isArray(ease2) ? ease2[i] || noop : ease2, mixer);
742
+ mixers.push(mixer);
743
+ }
744
+ return mixers;
745
+ }
746
+ function interpolate(input, output, { clamp: isClamp = true, ease: ease2, mixer } = {}) {
747
+ const inputLength = input.length;
748
+ invariant(inputLength === output.length, "Both input and output ranges must be the same length", "range-length");
749
+ if (inputLength === 1) return () => output[0];
750
+ if (inputLength === 2 && output[0] === output[1]) return () => output[1];
751
+ const isZeroDeltaRange = input[0] === input[1];
752
+ if (input[0] > input[inputLength - 1]) {
753
+ input = [...input].reverse();
754
+ output = [...output].reverse();
755
+ }
756
+ const mixers = createMixers(output, ease2, mixer);
757
+ const numMixers = mixers.length;
758
+ const interpolator = (v) => {
759
+ if (isZeroDeltaRange && v < input[0]) return output[0];
760
+ let i = 0;
761
+ if (numMixers > 1) {
762
+ for (; i < input.length - 2; i++) if (v < input[i + 1]) break;
763
+ }
764
+ const progressInRange = /* @__PURE__ */ progress(input[i], input[i + 1], v);
765
+ return mixers[i](progressInRange);
766
+ };
767
+ return isClamp ? (v) => interpolator(clamp(input[0], input[inputLength - 1], v)) : interpolator;
768
+ }
769
+ function fillOffset(offset, remaining) {
770
+ const min = offset[offset.length - 1];
771
+ for (let i = 1; i <= remaining; i++) {
772
+ const offsetProgress = /* @__PURE__ */ progress(0, remaining, i);
773
+ offset.push(mixNumber(min, 1, offsetProgress));
774
+ }
775
+ }
776
+ function defaultOffset(arr) {
777
+ const offset = [0];
778
+ fillOffset(offset, arr.length - 1);
779
+ return offset;
780
+ }
781
+ function convertOffsetToTimes(offset, duration) {
782
+ return offset.map((o) => o * duration);
783
+ }
784
+ function defaultEasing(values, easing) {
785
+ return values.map(() => easing || easeInOut).splice(0, values.length - 1);
786
+ }
787
+ function keyframes({ duration = 300, keyframes: keyframeValues, times, ease: ease2 = "easeInOut" }) {
788
+ const easingFunctions = /* @__PURE__ */ isEasingArray(ease2) ? ease2.map(easingDefinitionToFunction) : easingDefinitionToFunction(ease2);
789
+ const state = {
790
+ done: false,
791
+ value: keyframeValues[0]
792
+ };
793
+ const mapTimeToKeyframe = interpolate(convertOffsetToTimes(times && times.length === keyframeValues.length ? times : defaultOffset(keyframeValues), duration), keyframeValues, { ease: Array.isArray(easingFunctions) ? easingFunctions : defaultEasing(keyframeValues, easingFunctions) });
794
+ return {
795
+ calculatedDuration: duration,
796
+ next: (t) => {
797
+ state.value = mapTimeToKeyframe(t);
798
+ state.done = t >= duration;
799
+ return state;
800
+ }
801
+ };
802
+ }
803
+ var velocitySampleDuration = 5;
804
+ function getGeneratorVelocity(resolveValue, t, current) {
805
+ const prevT = Math.max(t - velocitySampleDuration, 0);
806
+ return velocityPerSecond(current - resolveValue(prevT), t - prevT);
807
+ }
808
+ var transitionTypeMap = {
809
+ decay: inertia,
810
+ inertia,
811
+ tween: keyframes,
812
+ keyframes,
813
+ spring
814
+ };
815
+ function replaceTransitionType(transition) {
816
+ if (typeof transition.type === "string") transition.type = transitionTypeMap[transition.type];
817
+ }
818
+ var percentToProgress = (percent2) => percent2 / 100;
819
+ var JSAnimation = class extends WithPromise {
820
+ constructor(options) {
821
+ super();
822
+ this.state = "idle";
823
+ this.startTime = null;
824
+ this.isStopped = false;
825
+ this.currentTime = 0;
826
+ this.holdTime = null;
827
+ this.playbackSpeed = 1;
828
+ this.delayState = {
829
+ done: false,
830
+ value: void 0
831
+ };
832
+ this.stop = () => {
833
+ const { motionValue: motionValue2 } = this.options;
834
+ if (motionValue2 && motionValue2.updatedAt !== time.now()) this.tick(time.now());
835
+ this.isStopped = true;
836
+ if (this.state === "idle") return;
837
+ this.teardown();
838
+ this.options.onStop?.();
839
+ };
840
+ this.options = options;
841
+ this.initAnimation();
842
+ this.play();
843
+ if (options.autoplay === false) this.pause();
844
+ }
845
+ initAnimation() {
846
+ const { options } = this;
847
+ replaceTransitionType(options);
848
+ const { type = keyframes, repeat = 0, repeatDelay = 0, repeatType, velocity = 0 } = options;
849
+ let { keyframes: keyframes$1 } = options;
850
+ const generatorFactory = type || keyframes;
851
+ if (generatorFactory !== keyframes && typeof keyframes$1[0] !== "number") {
852
+ this.mixKeyframes = pipe(percentToProgress, mix(keyframes$1[0], keyframes$1[1]));
853
+ keyframes$1 = [0, 100];
854
+ }
855
+ const generator = generatorFactory({
856
+ ...options,
857
+ keyframes: keyframes$1
858
+ });
859
+ if (repeatType === "mirror") this.mirroredGenerator = generatorFactory({
860
+ ...options,
861
+ keyframes: [...keyframes$1].reverse(),
862
+ velocity: -velocity
863
+ });
864
+ if (generator.calculatedDuration === null) generator.calculatedDuration = calcGeneratorDuration(generator);
865
+ const { calculatedDuration } = generator;
866
+ this.calculatedDuration = calculatedDuration;
867
+ this.resolvedDuration = calculatedDuration + repeatDelay;
868
+ this.totalDuration = this.resolvedDuration * (repeat + 1) - repeatDelay;
869
+ this.generator = generator;
870
+ }
871
+ updateTime(timestamp) {
872
+ const animationTime = Math.round(timestamp - this.startTime) * this.playbackSpeed;
873
+ if (this.holdTime !== null) this.currentTime = this.holdTime;
874
+ else this.currentTime = animationTime;
875
+ }
876
+ tick(timestamp, sample = false) {
877
+ const { generator, totalDuration, mixKeyframes, mirroredGenerator, resolvedDuration, calculatedDuration } = this;
878
+ if (this.startTime === null) return generator.next(0);
879
+ const { delay: delay2 = 0, keyframes: keyframes2, repeat, repeatType, repeatDelay, type, onUpdate, finalKeyframe } = this.options;
880
+ if (this.speed > 0) this.startTime = Math.min(this.startTime, timestamp);
881
+ else if (this.speed < 0) this.startTime = Math.min(timestamp - totalDuration / this.speed, this.startTime);
882
+ if (sample) this.currentTime = timestamp;
883
+ else this.updateTime(timestamp);
884
+ const timeWithoutDelay = this.currentTime - delay2 * (this.playbackSpeed >= 0 ? 1 : -1);
885
+ const isInDelayPhase = this.playbackSpeed >= 0 ? timeWithoutDelay < 0 : timeWithoutDelay > totalDuration;
886
+ this.currentTime = Math.max(timeWithoutDelay, 0);
887
+ if (this.state === "finished" && this.holdTime === null) this.currentTime = totalDuration;
888
+ let elapsed = this.currentTime;
889
+ let frameGenerator = generator;
890
+ if (repeat) {
891
+ const progress2 = Math.min(this.currentTime, totalDuration) / resolvedDuration;
892
+ let currentIteration = Math.floor(progress2);
893
+ let iterationProgress = progress2 % 1;
894
+ if (!iterationProgress && progress2 >= 1) iterationProgress = 1;
895
+ iterationProgress === 1 && currentIteration--;
896
+ currentIteration = Math.min(currentIteration, repeat + 1);
897
+ if (Boolean(currentIteration % 2)) {
898
+ if (repeatType === "reverse") {
899
+ iterationProgress = 1 - iterationProgress;
900
+ if (repeatDelay) iterationProgress -= repeatDelay / resolvedDuration;
901
+ } else if (repeatType === "mirror") frameGenerator = mirroredGenerator;
902
+ }
903
+ elapsed = clamp(0, 1, iterationProgress) * resolvedDuration;
904
+ }
905
+ let state;
906
+ if (isInDelayPhase) {
907
+ this.delayState.value = keyframes2[0];
908
+ state = this.delayState;
909
+ } else state = frameGenerator.next(elapsed);
910
+ if (mixKeyframes && !isInDelayPhase) state.value = mixKeyframes(state.value);
911
+ let { done } = state;
912
+ if (!isInDelayPhase && calculatedDuration !== null) done = this.playbackSpeed >= 0 ? this.currentTime >= totalDuration : this.currentTime <= 0;
913
+ const isAnimationFinished = this.holdTime === null && (this.state === "finished" || this.state === "running" && done);
914
+ if (isAnimationFinished && type !== inertia) state.value = getFinalKeyframe(keyframes2, this.options, finalKeyframe, this.speed);
915
+ if (onUpdate) onUpdate(state.value);
916
+ if (isAnimationFinished) this.finish();
917
+ return state;
918
+ }
919
+ /**
920
+ * Allows the returned animation to be awaited or promise-chained. Currently
921
+ * resolves when the animation finishes at all but in a future update could/should
922
+ * reject if its cancels.
923
+ */
924
+ then(resolve2, reject) {
925
+ return this.finished.then(resolve2, reject);
926
+ }
927
+ get duration() {
928
+ return millisecondsToSeconds(this.calculatedDuration);
929
+ }
930
+ get iterationDuration() {
931
+ const { delay: delay2 = 0 } = this.options || {};
932
+ return this.duration + millisecondsToSeconds(delay2);
933
+ }
934
+ get time() {
935
+ return millisecondsToSeconds(this.currentTime);
936
+ }
937
+ set time(newTime) {
938
+ newTime = secondsToMilliseconds(newTime);
939
+ this.currentTime = newTime;
940
+ if (this.startTime === null || this.holdTime !== null || this.playbackSpeed === 0) this.holdTime = newTime;
941
+ else if (this.driver) this.startTime = this.driver.now() - newTime / this.playbackSpeed;
942
+ if (this.driver) this.driver.start(false);
943
+ else {
944
+ this.startTime = 0;
945
+ this.state = "paused";
946
+ this.holdTime = newTime;
947
+ this.tick(newTime);
948
+ }
949
+ }
950
+ /**
951
+ * Returns the generator's velocity at the current time in units/second.
952
+ * Uses the analytical derivative when available (springs), avoiding
953
+ * the MotionValue's frame-dependent velocity estimation.
954
+ */
955
+ getGeneratorVelocity() {
956
+ const t = this.currentTime;
957
+ if (t <= 0) return this.options.velocity || 0;
958
+ if (this.generator.velocity) return this.generator.velocity(t);
959
+ const current = this.generator.next(t).value;
960
+ return getGeneratorVelocity((s) => this.generator.next(s).value, t, current);
961
+ }
962
+ get speed() {
963
+ return this.playbackSpeed;
964
+ }
965
+ set speed(newSpeed) {
966
+ const hasChanged = this.playbackSpeed !== newSpeed;
967
+ if (hasChanged && this.driver) this.updateTime(time.now());
968
+ this.playbackSpeed = newSpeed;
969
+ if (hasChanged && this.driver) this.time = millisecondsToSeconds(this.currentTime);
970
+ }
971
+ play() {
972
+ if (this.isStopped) return;
973
+ const { driver = frameloopDriver, startTime } = this.options;
974
+ if (!this.driver) this.driver = driver((timestamp) => this.tick(timestamp));
975
+ this.options.onPlay?.();
976
+ const now2 = this.driver.now();
977
+ if (this.state === "finished") {
978
+ this.updateFinished();
979
+ this.startTime = now2;
980
+ } else if (this.holdTime !== null) this.startTime = now2 - this.holdTime;
981
+ else if (!this.startTime) this.startTime = startTime ?? now2;
982
+ if (this.state === "finished" && this.speed < 0) this.startTime += this.calculatedDuration;
983
+ this.holdTime = null;
984
+ this.state = "running";
985
+ this.driver.start();
986
+ }
987
+ pause() {
988
+ this.state = "paused";
989
+ this.updateTime(time.now());
990
+ this.holdTime = this.currentTime;
991
+ }
992
+ complete() {
993
+ if (this.state !== "running") this.play();
994
+ this.state = "finished";
995
+ this.holdTime = null;
996
+ }
997
+ finish() {
998
+ this.notifyFinished();
999
+ this.teardown();
1000
+ this.state = "finished";
1001
+ this.options.onComplete?.();
1002
+ }
1003
+ cancel() {
1004
+ this.holdTime = null;
1005
+ this.startTime = 0;
1006
+ this.tick(0);
1007
+ this.teardown();
1008
+ this.options.onCancel?.();
1009
+ }
1010
+ teardown() {
1011
+ this.state = "idle";
1012
+ this.stopDriver();
1013
+ this.startTime = this.holdTime = null;
1014
+ }
1015
+ stopDriver() {
1016
+ if (!this.driver) return;
1017
+ this.driver.stop();
1018
+ this.driver = void 0;
1019
+ }
1020
+ sample(sampleTime) {
1021
+ this.startTime = 0;
1022
+ return this.tick(sampleTime, true);
1023
+ }
1024
+ attachTimeline(timeline) {
1025
+ if (this.options.allowFlatten) {
1026
+ this.options.type = "keyframes";
1027
+ this.options.ease = "linear";
1028
+ this.initAnimation();
1029
+ }
1030
+ this.driver?.stop();
1031
+ return timeline.observe(this);
1032
+ }
1033
+ };
1034
+ var unsupportedEasingFunctions = {
1035
+ anticipate,
1036
+ backInOut,
1037
+ circInOut
1038
+ };
1039
+ function isUnsupportedEase(key) {
1040
+ return key in unsupportedEasingFunctions;
1041
+ }
1042
+ function replaceStringEasing(transition) {
1043
+ if (typeof transition.ease === "string" && isUnsupportedEase(transition.ease)) transition.ease = unsupportedEasingFunctions[transition.ease];
1044
+ }
1045
+ var sampleDelta = 10;
1046
+ var NativeAnimationExtended = class extends NativeAnimation {
1047
+ constructor(options) {
1048
+ replaceStringEasing(options);
1049
+ replaceTransitionType(options);
1050
+ super(options);
1051
+ if (options.startTime !== void 0 && options.autoplay !== false) this.startTime = options.startTime;
1052
+ this.options = options;
1053
+ }
1054
+ /**
1055
+ * WAAPI doesn't natively have any interruption capabilities.
1056
+ *
1057
+ * Rather than read committed styles back out of the DOM, we can
1058
+ * create a renderless JS animation and sample it twice to calculate
1059
+ * its current value, "previous" value, and therefore allow
1060
+ * Motion to calculate velocity for any subsequent animation.
1061
+ */
1062
+ updateMotionValue(value) {
1063
+ const { motionValue: motionValue2, onUpdate, onComplete, element, ...options } = this.options;
1064
+ if (!motionValue2) return;
1065
+ if (value !== void 0) {
1066
+ motionValue2.set(value);
1067
+ return;
1068
+ }
1069
+ const sampleAnimation = new JSAnimation({
1070
+ ...options,
1071
+ autoplay: false
1072
+ });
1073
+ const sampleTime = Math.max(sampleDelta, time.now() - this.startTime);
1074
+ const delta = clamp(0, sampleDelta, sampleTime - sampleDelta);
1075
+ const current = sampleAnimation.sample(sampleTime).value;
1076
+ const { name } = this.options;
1077
+ if (element && name) setStyle(element, name, current);
1078
+ motionValue2.setWithVelocity(sampleAnimation.sample(Math.max(0, sampleTime - delta)).value, current, delta);
1079
+ sampleAnimation.stop();
1080
+ }
1081
+ };
1082
+ var isAnimatable = (value, name) => {
1083
+ if (name === "zIndex") return false;
1084
+ if (typeof value === "number" || Array.isArray(value)) return true;
1085
+ if (typeof value === "string" && (complex.test(value) || value === "0") && !value.startsWith("url(")) return true;
1086
+ return false;
1087
+ };
1088
+ function hasKeyframesChanged(keyframes2) {
1089
+ const current = keyframes2[0];
1090
+ if (keyframes2.length === 1) return true;
1091
+ for (let i = 0; i < keyframes2.length; i++) if (keyframes2[i] !== current) return true;
1092
+ }
1093
+ function canAnimate(keyframes2, name, type, velocity) {
1094
+ const originKeyframe = keyframes2[0];
1095
+ if (originKeyframe === null) return false;
1096
+ if (name === "display" || name === "visibility") return true;
1097
+ const targetKeyframe = keyframes2[keyframes2.length - 1];
1098
+ const isOriginAnimatable = isAnimatable(originKeyframe, name);
1099
+ const isTargetAnimatable = isAnimatable(targetKeyframe, name);
1100
+ warning(isOriginAnimatable === isTargetAnimatable, `You are trying to animate ${name} from "${originKeyframe}" to "${targetKeyframe}". "${isOriginAnimatable ? targetKeyframe : originKeyframe}" is not an animatable value.`, "value-not-animatable");
1101
+ if (!isOriginAnimatable || !isTargetAnimatable) return false;
1102
+ return hasKeyframesChanged(keyframes2) || (type === "spring" || isGenerator(type)) && velocity;
1103
+ }
1104
+ function makeAnimationInstant(options) {
1105
+ options.duration = 0;
1106
+ options.type = "keyframes";
1107
+ }
1108
+ var browserColorFunctions = /^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;
1109
+ function hasBrowserOnlyColors(keyframes2) {
1110
+ for (let i = 0; i < keyframes2.length; i++) if (typeof keyframes2[i] === "string" && browserColorFunctions.test(keyframes2[i])) return true;
1111
+ return false;
1112
+ }
1113
+ var colorProperties = /* @__PURE__ */ new Set([
1114
+ "color",
1115
+ "backgroundColor",
1116
+ "outlineColor",
1117
+ "fill",
1118
+ "stroke",
1119
+ "borderColor",
1120
+ "borderTopColor",
1121
+ "borderRightColor",
1122
+ "borderBottomColor",
1123
+ "borderLeftColor"
1124
+ ]);
1125
+ var supportsWaapi = /* @__PURE__ */ memo$1(() => Object.hasOwnProperty.call(Element.prototype, "animate"));
1126
+ function supportsBrowserAnimation(options) {
1127
+ const { motionValue: motionValue2, name, repeatDelay, repeatType, damping, type, keyframes: keyframes2 } = options;
1128
+ const subject = motionValue2?.owner?.current;
1129
+ if (!(subject instanceof HTMLElement) && !(subject instanceof SVGElement)) return false;
1130
+ const { onUpdate, transformTemplate } = motionValue2.owner.getProps();
1131
+ return supportsWaapi() && name && (acceleratedValues.has(name) || colorProperties.has(name) && hasBrowserOnlyColors(keyframes2)) && (name !== "transform" || !transformTemplate) && !onUpdate && !repeatDelay && repeatType !== "mirror" && damping !== 0 && type !== "inertia";
1132
+ }
1133
+ var MAX_RESOLVE_DELAY = 40;
1134
+ var AsyncMotionValueAnimation = class extends WithPromise {
1135
+ constructor({ autoplay = true, delay: delay2 = 0, type = "keyframes", repeat = 0, repeatDelay = 0, repeatType = "loop", keyframes: keyframes2, name, motionValue: motionValue2, element, ...options }) {
1136
+ super();
1137
+ this.stop = () => {
1138
+ if (this._animation) {
1139
+ this._animation.stop();
1140
+ this.stopTimeline?.();
1141
+ }
1142
+ this.keyframeResolver?.cancel();
1143
+ };
1144
+ this.createdAt = time.now();
1145
+ const optionsWithDefaults = {
1146
+ autoplay,
1147
+ delay: delay2,
1148
+ type,
1149
+ repeat,
1150
+ repeatDelay,
1151
+ repeatType,
1152
+ name,
1153
+ motionValue: motionValue2,
1154
+ element,
1155
+ ...options
1156
+ };
1157
+ const KeyframeResolver$1 = element?.KeyframeResolver || KeyframeResolver;
1158
+ this.keyframeResolver = new KeyframeResolver$1(keyframes2, (resolvedKeyframes, finalKeyframe, forced) => this.onKeyframesResolved(resolvedKeyframes, finalKeyframe, optionsWithDefaults, !forced), name, motionValue2, element);
1159
+ this.keyframeResolver?.scheduleResolve();
1160
+ }
1161
+ onKeyframesResolved(keyframes2, finalKeyframe, options, sync) {
1162
+ this.keyframeResolver = void 0;
1163
+ const { name, type, velocity, delay: delay2, isHandoff, onUpdate } = options;
1164
+ this.resolvedAt = time.now();
1165
+ let canAnimateValue = true;
1166
+ if (!canAnimate(keyframes2, name, type, velocity)) {
1167
+ canAnimateValue = false;
1168
+ if (MotionGlobalConfig.instantAnimations || !delay2) onUpdate?.(getFinalKeyframe(keyframes2, options, finalKeyframe));
1169
+ keyframes2[0] = keyframes2[keyframes2.length - 1];
1170
+ makeAnimationInstant(options);
1171
+ options.repeat = 0;
1172
+ }
1173
+ const resolvedOptions = {
1174
+ startTime: sync ? !this.resolvedAt ? this.createdAt : this.resolvedAt - this.createdAt > MAX_RESOLVE_DELAY ? this.resolvedAt : this.createdAt : void 0,
1175
+ finalKeyframe,
1176
+ ...options,
1177
+ keyframes: keyframes2
1178
+ };
1179
+ const useWaapi = canAnimateValue && !isHandoff && supportsBrowserAnimation(resolvedOptions);
1180
+ const element = resolvedOptions.motionValue?.owner?.current;
1181
+ let animation;
1182
+ if (useWaapi) try {
1183
+ animation = new NativeAnimationExtended({
1184
+ ...resolvedOptions,
1185
+ element
1186
+ });
1187
+ } catch {
1188
+ animation = new JSAnimation(resolvedOptions);
1189
+ }
1190
+ else animation = new JSAnimation(resolvedOptions);
1191
+ animation.finished.then(() => {
1192
+ this.notifyFinished();
1193
+ }).catch(noop);
1194
+ if (this.pendingTimeline) {
1195
+ this.stopTimeline = animation.attachTimeline(this.pendingTimeline);
1196
+ this.pendingTimeline = void 0;
1197
+ }
1198
+ this._animation = animation;
1199
+ }
1200
+ get finished() {
1201
+ if (!this._animation) return this._finished;
1202
+ else return this.animation.finished;
1203
+ }
1204
+ then(onResolve, _onReject) {
1205
+ return this.finished.finally(onResolve).then(() => {
1206
+ });
1207
+ }
1208
+ get animation() {
1209
+ if (!this._animation) {
1210
+ this.keyframeResolver?.resume();
1211
+ flushKeyframeResolvers();
1212
+ }
1213
+ return this._animation;
1214
+ }
1215
+ get duration() {
1216
+ return this.animation.duration;
1217
+ }
1218
+ get iterationDuration() {
1219
+ return this.animation.iterationDuration;
1220
+ }
1221
+ get time() {
1222
+ return this.animation.time;
1223
+ }
1224
+ set time(newTime) {
1225
+ this.animation.time = newTime;
1226
+ }
1227
+ get speed() {
1228
+ return this.animation.speed;
1229
+ }
1230
+ get state() {
1231
+ return this.animation.state;
1232
+ }
1233
+ set speed(newSpeed) {
1234
+ this.animation.speed = newSpeed;
1235
+ }
1236
+ get startTime() {
1237
+ return this.animation.startTime;
1238
+ }
1239
+ attachTimeline(timeline) {
1240
+ if (this._animation) this.stopTimeline = this.animation.attachTimeline(timeline);
1241
+ else this.pendingTimeline = timeline;
1242
+ return () => this.stop();
1243
+ }
1244
+ play() {
1245
+ this.animation.play();
1246
+ }
1247
+ pause() {
1248
+ this.animation.pause();
1249
+ }
1250
+ complete() {
1251
+ this.animation.complete();
1252
+ }
1253
+ cancel() {
1254
+ if (this._animation) this.animation.cancel();
1255
+ this.keyframeResolver?.cancel();
1256
+ }
1257
+ };
175
1258
  function calcChildStagger(children, child, delayChildren, staggerChildren = 0, staggerDirection = 1) {
176
1259
  const index = Array.from(children).sort((a, b) => a.sortNodePosition(b)).indexOf(child);
177
1260
  const numChildren = children.size;
178
1261
  const maxStaggerDuration = (numChildren - 1) * staggerChildren;
179
1262
  return typeof delayChildren === "function" ? delayChildren(index, numChildren) : staggerDirection === 1 ? index * staggerChildren : maxStaggerDuration - index * staggerChildren;
180
1263
  }
1264
+ function resolveTransition(transition, parentTransition) {
1265
+ if (transition?.inherit && parentTransition) {
1266
+ const { inherit: _, ...rest } = transition;
1267
+ return {
1268
+ ...parentTransition,
1269
+ ...rest
1270
+ };
1271
+ }
1272
+ return transition;
1273
+ }
1274
+ function getValueTransition(transition, key) {
1275
+ const valueTransition = transition?.[key] ?? transition?.["default"] ?? transition;
1276
+ if (valueTransition !== transition) return resolveTransition(valueTransition, transition);
1277
+ return valueTransition;
1278
+ }
1279
+ var underDampedSpring = {
1280
+ type: "spring",
1281
+ stiffness: 500,
1282
+ damping: 25,
1283
+ restSpeed: 10
1284
+ };
1285
+ var criticallyDampedSpring = (target) => ({
1286
+ type: "spring",
1287
+ stiffness: 550,
1288
+ damping: target === 0 ? 2 * Math.sqrt(550) : 30,
1289
+ restSpeed: 10
1290
+ });
1291
+ var keyframesTransition = {
1292
+ type: "keyframes",
1293
+ duration: 0.8
1294
+ };
1295
+ var ease = {
1296
+ type: "keyframes",
1297
+ ease: [
1298
+ 0.25,
1299
+ 0.1,
1300
+ 0.35,
1301
+ 1
1302
+ ],
1303
+ duration: 0.3
1304
+ };
1305
+ var getDefaultTransition = (valueKey, { keyframes: keyframes2 }) => {
1306
+ if (keyframes2.length > 2) return keyframesTransition;
1307
+ else if (transformProps.has(valueKey)) return valueKey.startsWith("scale") ? criticallyDampedSpring(keyframes2[1]) : underDampedSpring;
1308
+ return ease;
1309
+ };
1310
+ var orchestrationKeys = /* @__PURE__ */ new Set([
1311
+ "when",
1312
+ "delay",
1313
+ "delayChildren",
1314
+ "staggerChildren",
1315
+ "staggerDirection",
1316
+ "repeat",
1317
+ "repeatType",
1318
+ "repeatDelay",
1319
+ "from",
1320
+ "elapsed"
1321
+ ]);
1322
+ function isTransitionDefined(transition) {
1323
+ for (const key in transition) if (!orchestrationKeys.has(key)) return true;
1324
+ return false;
1325
+ }
1326
+ var animateMotionValue = (name, value, target, transition = {}, element, isHandoff) => (onComplete) => {
1327
+ const valueTransition = getValueTransition(transition, name) || {};
1328
+ const delay2 = valueTransition.delay || transition.delay || 0;
1329
+ let { elapsed = 0 } = transition;
1330
+ elapsed = elapsed - secondsToMilliseconds(delay2);
1331
+ const options = {
1332
+ keyframes: Array.isArray(target) ? target : [null, target],
1333
+ ease: "easeOut",
1334
+ velocity: value.getVelocity(),
1335
+ ...valueTransition,
1336
+ delay: -elapsed,
1337
+ onUpdate: (v) => {
1338
+ value.set(v);
1339
+ valueTransition.onUpdate && valueTransition.onUpdate(v);
1340
+ },
1341
+ onComplete: () => {
1342
+ onComplete();
1343
+ valueTransition.onComplete && valueTransition.onComplete();
1344
+ },
1345
+ name,
1346
+ motionValue: value,
1347
+ element: isHandoff ? void 0 : element
1348
+ };
1349
+ if (!isTransitionDefined(valueTransition)) Object.assign(options, getDefaultTransition(name, options));
1350
+ options.duration && (options.duration = secondsToMilliseconds(options.duration));
1351
+ options.repeatDelay && (options.repeatDelay = secondsToMilliseconds(options.repeatDelay));
1352
+ if (options.from !== void 0) options.keyframes[0] = options.from;
1353
+ let shouldSkip = false;
1354
+ if (options.type === false || options.duration === 0 && !options.repeatDelay) {
1355
+ makeAnimationInstant(options);
1356
+ if (options.delay === 0) shouldSkip = true;
1357
+ }
1358
+ if (MotionGlobalConfig.instantAnimations || MotionGlobalConfig.skipAnimations || element?.shouldSkipAnimations || valueTransition.skipAnimations) {
1359
+ shouldSkip = true;
1360
+ makeAnimationInstant(options);
1361
+ options.delay = 0;
1362
+ }
1363
+ options.allowFlatten = !valueTransition.type && !valueTransition.ease;
1364
+ if (shouldSkip && !isHandoff && value.get() !== void 0) {
1365
+ const finalKeyframe = getFinalKeyframe(options.keyframes, valueTransition);
1366
+ if (finalKeyframe !== void 0) {
1367
+ frame.update(() => {
1368
+ options.onUpdate(finalKeyframe);
1369
+ options.onComplete();
1370
+ });
1371
+ return;
1372
+ }
1373
+ }
1374
+ return valueTransition.isSync ? new JSAnimation(options) : new AsyncMotionValueAnimation(options);
1375
+ };
1376
+ var splitCSSVariableRegex = /^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;
1377
+ function parseCSSVariable(current) {
1378
+ const match = splitCSSVariableRegex.exec(current);
1379
+ if (!match) return [,];
1380
+ const [, token1, token2, fallback] = match;
1381
+ return [`--${token1 ?? token2}`, fallback];
1382
+ }
1383
+ var maxDepth = 4;
1384
+ function getVariableValue(current, element, depth = 1) {
1385
+ invariant(depth <= maxDepth, `Max CSS variable fallback depth detected in property "${current}". This may indicate a circular fallback dependency.`, "max-css-var-depth");
1386
+ const [token, fallback] = parseCSSVariable(current);
1387
+ if (!token) return;
1388
+ const resolved = window.getComputedStyle(element).getPropertyValue(token);
1389
+ if (resolved) {
1390
+ const trimmed = resolved.trim();
1391
+ return isNumericalString(trimmed) ? parseFloat(trimmed) : trimmed;
1392
+ }
1393
+ return isCSSVariableToken(fallback) ? getVariableValue(fallback, element, depth + 1) : fallback;
1394
+ }
1395
+ function resolveVariant(visualElement, definition, custom) {
1396
+ const props = visualElement.getProps();
1397
+ return resolveVariantFromProps(props, definition, custom !== void 0 ? custom : props.custom, visualElement);
1398
+ }
1399
+ var positionalKeys = /* @__PURE__ */ new Set([
1400
+ "width",
1401
+ "height",
1402
+ "top",
1403
+ "left",
1404
+ "right",
1405
+ "bottom",
1406
+ ...transformPropOrder
1407
+ ]);
1408
+ var isKeyframesTarget = (v) => {
1409
+ return Array.isArray(v);
1410
+ };
1411
+ function setMotionValue(visualElement, key, value) {
1412
+ if (visualElement.hasValue(key)) visualElement.getValue(key).set(value);
1413
+ else visualElement.addValue(key, motionValue(value));
1414
+ }
1415
+ function resolveFinalValueInKeyframes(v) {
1416
+ return isKeyframesTarget(v) ? v[v.length - 1] || 0 : v;
1417
+ }
1418
+ function setTarget(visualElement, definition) {
1419
+ let { transitionEnd = {}, transition = {}, ...target } = resolveVariant(visualElement, definition) || {};
1420
+ target = {
1421
+ ...target,
1422
+ ...transitionEnd
1423
+ };
1424
+ for (const key in target) setMotionValue(visualElement, key, resolveFinalValueInKeyframes(target[key]));
1425
+ }
1426
+ function isWillChangeMotionValue(value) {
1427
+ return Boolean(isMotionValue(value) && value.add);
1428
+ }
1429
+ function addValueToWillChange(visualElement, key) {
1430
+ const willChange = visualElement.getValue("willChange");
1431
+ if (isWillChangeMotionValue(willChange)) return willChange.add(key);
1432
+ else if (!willChange && MotionGlobalConfig.WillChange) {
1433
+ const newWillChange = new MotionGlobalConfig.WillChange("auto");
1434
+ visualElement.addValue("willChange", newWillChange);
1435
+ newWillChange.add(key);
1436
+ }
1437
+ }
1438
+ function getOptimisedAppearId(visualElement) {
1439
+ return visualElement.props[optimizedAppearDataAttribute];
1440
+ }
1441
+ var isBrowser = typeof window !== "undefined";
1442
+ function shouldBlockAnimation({ protectedKeys, needsAnimating }, key) {
1443
+ const shouldBlock = protectedKeys.hasOwnProperty(key) && needsAnimating[key] !== true;
1444
+ needsAnimating[key] = false;
1445
+ return shouldBlock;
1446
+ }
1447
+ function animateTarget(visualElement, targetAndTransition, { delay: delay2 = 0, transitionOverride, type } = {}) {
1448
+ let { transition, transitionEnd, ...target } = targetAndTransition;
1449
+ const defaultTransition = visualElement.getDefaultTransition();
1450
+ transition = transition ? resolveTransition(transition, defaultTransition) : defaultTransition;
1451
+ const reduceMotion = transition?.reduceMotion;
1452
+ const skipAnimations = transition?.skipAnimations;
1453
+ if (transitionOverride) transition = transitionOverride;
1454
+ const animations2 = [];
1455
+ const animationTypeState = type && visualElement.animationState && visualElement.animationState.getState()[type];
1456
+ const path = transition?.path;
1457
+ if (path) path.animateVisualElement(visualElement, target, transition, delay2, animations2);
1458
+ for (const key in target) {
1459
+ const value = visualElement.getValue(key, visualElement.latestValues[key] ?? null);
1460
+ const valueTarget = target[key];
1461
+ if (valueTarget === void 0 || animationTypeState && shouldBlockAnimation(animationTypeState, key)) continue;
1462
+ const valueTransition = {
1463
+ delay: delay2,
1464
+ ...getValueTransition(transition || {}, key)
1465
+ };
1466
+ if (skipAnimations) valueTransition.skipAnimations = true;
1467
+ const currentValue = value.get();
1468
+ if (currentValue !== void 0 && !value.isAnimating() && !Array.isArray(valueTarget) && valueTarget === currentValue && !valueTransition.velocity) {
1469
+ frame.update(() => value.set(valueTarget));
1470
+ continue;
1471
+ }
1472
+ let isHandoff = false;
1473
+ if (isBrowser && window.MotionHandoffAnimation) {
1474
+ const appearId = getOptimisedAppearId(visualElement);
1475
+ if (appearId) {
1476
+ const startTime = window.MotionHandoffAnimation(appearId, key, frame);
1477
+ if (startTime !== null) {
1478
+ valueTransition.startTime = startTime;
1479
+ isHandoff = true;
1480
+ }
1481
+ }
1482
+ }
1483
+ addValueToWillChange(visualElement, key);
1484
+ const shouldReduceMotion = reduceMotion ?? visualElement.shouldReduceMotion;
1485
+ value.start(animateMotionValue(key, value, valueTarget, shouldReduceMotion && positionalKeys.has(key) ? { type: false } : valueTransition, visualElement, isHandoff));
1486
+ const animation = value.animation;
1487
+ if (animation) animations2.push(animation);
1488
+ }
1489
+ if (transitionEnd) {
1490
+ const applyTransitionEnd = () => frame.update(() => {
1491
+ transitionEnd && setTarget(visualElement, transitionEnd);
1492
+ });
1493
+ if (animations2.length) Promise.all(animations2).then(applyTransitionEnd);
1494
+ else applyTransitionEnd();
1495
+ }
1496
+ return animations2;
1497
+ }
181
1498
  function animateVariant(visualElement, variant, options = {}) {
182
1499
  const resolved = resolveVariant(visualElement, variant, options.type === "exit" ? visualElement.presenceContext?.custom : void 0);
183
1500
  let { transition = visualElement.getDefaultTransition() || {} } = resolved || {};
@@ -219,6 +1536,103 @@ function animateVisualElement(visualElement, definition, options = {}) {
219
1536
  visualElement.notify("AnimationComplete", definition);
220
1537
  });
221
1538
  }
1539
+ function isNone(value) {
1540
+ if (typeof value === "number") return value === 0;
1541
+ else if (value !== null) return value === "none" || value === "0" || isZeroValueString(value);
1542
+ else return true;
1543
+ }
1544
+ var invalidTemplates = /* @__PURE__ */ new Set([
1545
+ "auto",
1546
+ "none",
1547
+ "0"
1548
+ ]);
1549
+ function makeNoneKeyframesAnimatable(unresolvedKeyframes, noneKeyframeIndexes, name) {
1550
+ let i = 0;
1551
+ let animatableTemplate = void 0;
1552
+ while (i < unresolvedKeyframes.length && !animatableTemplate) {
1553
+ const keyframe = unresolvedKeyframes[i];
1554
+ if (typeof keyframe === "string" && !invalidTemplates.has(keyframe) && analyseComplexValue(keyframe).values.length) animatableTemplate = unresolvedKeyframes[i];
1555
+ i++;
1556
+ }
1557
+ if (animatableTemplate && name) for (const noneIndex of noneKeyframeIndexes) unresolvedKeyframes[noneIndex] = getAnimatableNone(name, animatableTemplate);
1558
+ }
1559
+ var DOMKeyframesResolver = class extends KeyframeResolver {
1560
+ constructor(unresolvedKeyframes, onComplete, name, motionValue2, element) {
1561
+ super(unresolvedKeyframes, onComplete, name, motionValue2, element, true);
1562
+ }
1563
+ readKeyframes() {
1564
+ const { unresolvedKeyframes, element, name } = this;
1565
+ if (!element || !element.current) return;
1566
+ super.readKeyframes();
1567
+ for (let i = 0; i < unresolvedKeyframes.length; i++) {
1568
+ let keyframe = unresolvedKeyframes[i];
1569
+ if (typeof keyframe === "string") {
1570
+ keyframe = keyframe.trim();
1571
+ if (isCSSVariableToken(keyframe)) {
1572
+ const resolved = getVariableValue(keyframe, element.current);
1573
+ if (resolved !== void 0) unresolvedKeyframes[i] = resolved;
1574
+ if (i === unresolvedKeyframes.length - 1) this.finalKeyframe = keyframe;
1575
+ }
1576
+ }
1577
+ }
1578
+ this.resolveNoneKeyframes();
1579
+ if (!positionalKeys.has(name) || unresolvedKeyframes.length !== 2) return;
1580
+ const [origin, target] = unresolvedKeyframes;
1581
+ const originType = findDimensionValueType(origin);
1582
+ const targetType = findDimensionValueType(target);
1583
+ if (containsCSSVariable(origin) !== containsCSSVariable(target) && positionalValues[name]) {
1584
+ this.needsMeasurement = true;
1585
+ return;
1586
+ }
1587
+ if (originType === targetType) return;
1588
+ if (isNumOrPxType(originType) && isNumOrPxType(targetType)) for (let i = 0; i < unresolvedKeyframes.length; i++) {
1589
+ const value = unresolvedKeyframes[i];
1590
+ if (typeof value === "string") unresolvedKeyframes[i] = parseFloat(value);
1591
+ }
1592
+ else if (positionalValues[name])
1593
+ this.needsMeasurement = true;
1594
+ }
1595
+ resolveNoneKeyframes() {
1596
+ const { unresolvedKeyframes, name } = this;
1597
+ const noneKeyframeIndexes = [];
1598
+ for (let i = 0; i < unresolvedKeyframes.length; i++) if (unresolvedKeyframes[i] === null || isNone(unresolvedKeyframes[i])) noneKeyframeIndexes.push(i);
1599
+ if (noneKeyframeIndexes.length) makeNoneKeyframesAnimatable(unresolvedKeyframes, noneKeyframeIndexes, name);
1600
+ }
1601
+ measureInitialState() {
1602
+ const { element, unresolvedKeyframes, name } = this;
1603
+ if (!element || !element.current) return;
1604
+ if (name === "height") this.suspendedScrollY = window.pageYOffset;
1605
+ this.measuredOrigin = positionalValues[name](element.measureViewportBox(), window.getComputedStyle(element.current));
1606
+ unresolvedKeyframes[0] = this.measuredOrigin;
1607
+ const measureKeyframe = unresolvedKeyframes[unresolvedKeyframes.length - 1];
1608
+ if (measureKeyframe !== void 0) element.getValue(name, measureKeyframe).jump(measureKeyframe, false);
1609
+ }
1610
+ measureEndState() {
1611
+ const { element, name, unresolvedKeyframes } = this;
1612
+ if (!element || !element.current) return;
1613
+ const value = element.getValue(name);
1614
+ value && value.jump(this.measuredOrigin, false);
1615
+ const finalKeyframeIndex = unresolvedKeyframes.length - 1;
1616
+ const finalKeyframe = unresolvedKeyframes[finalKeyframeIndex];
1617
+ unresolvedKeyframes[finalKeyframeIndex] = positionalValues[name](element.measureViewportBox(), window.getComputedStyle(element.current));
1618
+ if (finalKeyframe !== null && this.finalKeyframe === void 0) this.finalKeyframe = finalKeyframe;
1619
+ if (this.removedTransforms?.length) this.removedTransforms.forEach(([unsetTransformName, unsetTransformValue]) => {
1620
+ element.getValue(unsetTransformName).set(unsetTransformValue);
1621
+ });
1622
+ this.resolveNoneKeyframes();
1623
+ }
1624
+ };
1625
+ function resolveElements(elementOrSelector, scope, selectorCache) {
1626
+ if (elementOrSelector == null) return [];
1627
+ if (elementOrSelector instanceof EventTarget) return [elementOrSelector];
1628
+ else if (typeof elementOrSelector === "string") {
1629
+ let root2 = document;
1630
+ if (scope) root2 = scope.current;
1631
+ const elements = selectorCache?.[elementOrSelector] ?? root2.querySelectorAll(elementOrSelector);
1632
+ return elements ? Array.from(elements) : [];
1633
+ }
1634
+ return Array.from(elementOrSelector).filter((element) => element != null);
1635
+ }
222
1636
  var isDragging = {
223
1637
  x: false,
224
1638
  y: false
@@ -411,6 +1825,9 @@ function press(targetOrSelector, onPressStart, options = {}) {
411
1825
  });
412
1826
  return cancelEvents;
413
1827
  }
1828
+ function isSVGElement(element) {
1829
+ return isObject(element) && "ownerSVGElement" in element;
1830
+ }
414
1831
  var resizeHandlers = /* @__PURE__ */ new WeakMap();
415
1832
  var observer;
416
1833
  var getSize = (borderBoxAxis, svgAxis, htmlAxis) => (target, borderBoxSize) => {
@@ -493,6 +1910,36 @@ var statsBuffer = {
493
1910
  value: null,
494
1911
  addProjectionMetrics: null
495
1912
  };
1913
+ function isSVGSVGElement(element) {
1914
+ return isSVGElement(element) && element.tagName === "svg";
1915
+ }
1916
+ var DOMVisualElement = class extends VisualElement {
1917
+ constructor() {
1918
+ super(...arguments);
1919
+ this.KeyframeResolver = DOMKeyframesResolver;
1920
+ }
1921
+ sortInstanceNodePosition(a, b) {
1922
+ return a.compareDocumentPosition(b) & 2 ? 1 : -1;
1923
+ }
1924
+ getBaseTargetFromProps(props, key) {
1925
+ const style = props.style;
1926
+ return style ? style[key] : void 0;
1927
+ }
1928
+ removeValueFromRenderState(key, { vars, style }) {
1929
+ delete vars[key];
1930
+ delete style[key];
1931
+ }
1932
+ handleChildMotionValue() {
1933
+ if (this.childSubscription) {
1934
+ this.childSubscription();
1935
+ delete this.childSubscription;
1936
+ }
1937
+ const { children } = this.props;
1938
+ if (isMotionValue(children)) this.childSubscription = children.on("change", (latest) => {
1939
+ if (this.current) this.current.textContent = `${latest}`;
1940
+ });
1941
+ }
1942
+ };
496
1943
  var Feature = class {
497
1944
  constructor(node) {
498
1945
  this.isMounted = false;
@@ -501,6 +1948,231 @@ var Feature = class {
501
1948
  update() {
502
1949
  }
503
1950
  };
1951
+ function convertBoundingBoxToBox({ top, left, right, bottom }) {
1952
+ return {
1953
+ x: {
1954
+ min: left,
1955
+ max: right
1956
+ },
1957
+ y: {
1958
+ min: top,
1959
+ max: bottom
1960
+ }
1961
+ };
1962
+ }
1963
+ function convertBoxToBoundingBox({ x, y }) {
1964
+ return {
1965
+ top: y.min,
1966
+ right: x.max,
1967
+ bottom: y.max,
1968
+ left: x.min
1969
+ };
1970
+ }
1971
+ function transformBoxPoints(point, transformPoint2) {
1972
+ if (!transformPoint2) return point;
1973
+ const topLeft = transformPoint2({
1974
+ x: point.left,
1975
+ y: point.top
1976
+ });
1977
+ const bottomRight = transformPoint2({
1978
+ x: point.right,
1979
+ y: point.bottom
1980
+ });
1981
+ return {
1982
+ top: topLeft.y,
1983
+ left: topLeft.x,
1984
+ bottom: bottomRight.y,
1985
+ right: bottomRight.x
1986
+ };
1987
+ }
1988
+ function isIdentityScale(scale) {
1989
+ return scale === void 0 || scale === 1;
1990
+ }
1991
+ function hasScale({ scale, scaleX, scaleY }) {
1992
+ return !isIdentityScale(scale) || !isIdentityScale(scaleX) || !isIdentityScale(scaleY);
1993
+ }
1994
+ function hasTransform(values) {
1995
+ return hasScale(values) || has2DTranslate(values) || values.z || values.rotate || values.rotateX || values.rotateY || values.skewX || values.skewY;
1996
+ }
1997
+ function has2DTranslate(values) {
1998
+ return is2DTranslate(values.x) || is2DTranslate(values.y);
1999
+ }
2000
+ function is2DTranslate(value) {
2001
+ return value && value !== "0%";
2002
+ }
2003
+ function scalePoint(point, scale, originPoint) {
2004
+ return originPoint + scale * (point - originPoint);
2005
+ }
2006
+ function applyPointDelta(point, translate, scale, originPoint, boxScale) {
2007
+ if (boxScale !== void 0) point = scalePoint(point, boxScale, originPoint);
2008
+ return scalePoint(point, scale, originPoint) + translate;
2009
+ }
2010
+ function applyAxisDelta(axis, translate = 0, scale = 1, originPoint, boxScale) {
2011
+ axis.min = applyPointDelta(axis.min, translate, scale, originPoint, boxScale);
2012
+ axis.max = applyPointDelta(axis.max, translate, scale, originPoint, boxScale);
2013
+ }
2014
+ function applyBoxDelta(box, { x, y }) {
2015
+ applyAxisDelta(box.x, x.translate, x.scale, x.originPoint);
2016
+ applyAxisDelta(box.y, y.translate, y.scale, y.originPoint);
2017
+ }
2018
+ var TREE_SCALE_SNAP_MIN = 0.999999999999;
2019
+ var TREE_SCALE_SNAP_MAX = 1.0000000000001;
2020
+ function applyTreeDeltas(box, treeScale, treePath, isSharedTransition = false) {
2021
+ const treeLength = treePath.length;
2022
+ if (!treeLength) return;
2023
+ treeScale.x = treeScale.y = 1;
2024
+ let node;
2025
+ let delta;
2026
+ for (let i = 0; i < treeLength; i++) {
2027
+ node = treePath[i];
2028
+ delta = node.projectionDelta;
2029
+ const { visualElement } = node.options;
2030
+ if (visualElement && visualElement.props.style && visualElement.props.style.display === "contents") continue;
2031
+ if (isSharedTransition && node.options.layoutScroll && node.scroll && node !== node.root) {
2032
+ translateAxis(box.x, -node.scroll.offset.x);
2033
+ translateAxis(box.y, -node.scroll.offset.y);
2034
+ }
2035
+ if (delta) {
2036
+ treeScale.x *= delta.x.scale;
2037
+ treeScale.y *= delta.y.scale;
2038
+ applyBoxDelta(box, delta);
2039
+ }
2040
+ if (isSharedTransition && hasTransform(node.latestValues)) transformBox(box, node.latestValues, node.layout?.layoutBox);
2041
+ }
2042
+ if (treeScale.x < TREE_SCALE_SNAP_MAX && treeScale.x > TREE_SCALE_SNAP_MIN) treeScale.x = 1;
2043
+ if (treeScale.y < TREE_SCALE_SNAP_MAX && treeScale.y > TREE_SCALE_SNAP_MIN) treeScale.y = 1;
2044
+ }
2045
+ function translateAxis(axis, distance2) {
2046
+ axis.min += distance2;
2047
+ axis.max += distance2;
2048
+ }
2049
+ function transformAxis(axis, axisTranslate, axisScale, boxScale, axisOrigin = 0.5) {
2050
+ applyAxisDelta(axis, axisTranslate, axisScale, mixNumber(axis.min, axis.max, axisOrigin), boxScale);
2051
+ }
2052
+ function resolveAxisTranslate(value, axis) {
2053
+ if (typeof value === "string") return parseFloat(value) / 100 * (axis.max - axis.min);
2054
+ return value;
2055
+ }
2056
+ function transformBox(box, transform, sourceBox) {
2057
+ const resolveBox = sourceBox ?? box;
2058
+ transformAxis(box.x, resolveAxisTranslate(transform.x, resolveBox.x), transform.scaleX, transform.scale, transform.originX);
2059
+ transformAxis(box.y, resolveAxisTranslate(transform.y, resolveBox.y), transform.scaleY, transform.scale, transform.originY);
2060
+ }
2061
+ function measureViewportBox(instance, transformPoint2) {
2062
+ return convertBoundingBoxToBox(transformBoxPoints(instance.getBoundingClientRect(), transformPoint2));
2063
+ }
2064
+ function measurePageBox(element, rootProjectionNode2, transformPagePoint) {
2065
+ const viewportBox = measureViewportBox(element, transformPagePoint);
2066
+ const { scroll } = rootProjectionNode2;
2067
+ if (scroll) {
2068
+ translateAxis(viewportBox.x, scroll.offset.x);
2069
+ translateAxis(viewportBox.y, scroll.offset.y);
2070
+ }
2071
+ return viewportBox;
2072
+ }
2073
+ function renderHTML(element, { style, vars }, styleProp, projection) {
2074
+ const elementStyle = element.style;
2075
+ let key;
2076
+ for (key in style) elementStyle[key] = style[key];
2077
+ projection?.applyProjectionStyles(elementStyle, styleProp);
2078
+ for (key in vars) elementStyle.setProperty(key, vars[key]);
2079
+ }
2080
+ function getComputedStyle$1(element) {
2081
+ return window.getComputedStyle(element);
2082
+ }
2083
+ var HTMLVisualElement = class extends DOMVisualElement {
2084
+ constructor() {
2085
+ super(...arguments);
2086
+ this.type = "html";
2087
+ this.renderInstance = renderHTML;
2088
+ }
2089
+ mount(instance) {
2090
+ invariant(Boolean(instance.style), "motion.create() components must forward their ref to a HTML or SVG element", "custom-component-ref");
2091
+ super.mount(instance);
2092
+ }
2093
+ readValueFromInstance(instance, key) {
2094
+ if (transformProps.has(key)) return this.projection?.isProjecting ? defaultTransformValue(key) : readTransformValue(instance, key);
2095
+ else {
2096
+ const computedStyle = getComputedStyle$1(instance);
2097
+ const value = (isCSSVariableName(key) ? computedStyle.getPropertyValue(key) : computedStyle[key]) || 0;
2098
+ return typeof value === "string" ? value.trim() : value;
2099
+ }
2100
+ }
2101
+ measureInstanceViewportBox(instance, { transformPagePoint }) {
2102
+ return measureViewportBox(instance, transformPagePoint);
2103
+ }
2104
+ build(renderState, latestValues, props) {
2105
+ buildHTMLStyles(renderState, latestValues, props.transformTemplate);
2106
+ }
2107
+ scrapeMotionValuesFromProps(props, prevProps, visualElement) {
2108
+ return scrapeMotionValuesFromProps$1(props, prevProps, visualElement);
2109
+ }
2110
+ };
2111
+ var camelCaseAttributes = /* @__PURE__ */ new Set([
2112
+ "baseFrequency",
2113
+ "diffuseConstant",
2114
+ "kernelMatrix",
2115
+ "kernelUnitLength",
2116
+ "keySplines",
2117
+ "keyTimes",
2118
+ "limitingConeAngle",
2119
+ "markerHeight",
2120
+ "markerWidth",
2121
+ "numOctaves",
2122
+ "targetX",
2123
+ "targetY",
2124
+ "surfaceScale",
2125
+ "specularConstant",
2126
+ "specularExponent",
2127
+ "stdDeviation",
2128
+ "tableValues",
2129
+ "viewBox",
2130
+ "gradientTransform",
2131
+ "pathLength",
2132
+ "startOffset",
2133
+ "textLength",
2134
+ "lengthAdjust"
2135
+ ]);
2136
+ function renderSVG(element, renderState, _styleProp, projection) {
2137
+ renderHTML(element, renderState, void 0, projection);
2138
+ for (const key in renderState.attrs) element.setAttribute(!camelCaseAttributes.has(key) ? camelToDash(key) : key, renderState.attrs[key]);
2139
+ }
2140
+ var SVGVisualElement = class extends DOMVisualElement {
2141
+ constructor() {
2142
+ super(...arguments);
2143
+ this.type = "svg";
2144
+ this.isSVGTag = false;
2145
+ this.measureInstanceViewportBox = createBox;
2146
+ }
2147
+ getBaseTargetFromProps(props, key) {
2148
+ return props[key];
2149
+ }
2150
+ readValueFromInstance(instance, key) {
2151
+ if (transformProps.has(key)) {
2152
+ const defaultType = getDefaultValueType(key);
2153
+ return defaultType ? defaultType.default || 0 : 0;
2154
+ }
2155
+ if (cssStyleProperties.includes(key)) {
2156
+ const value = getComputedStyle(instance)[key];
2157
+ if (typeof value === "string" && value) return value.trim();
2158
+ }
2159
+ key = !camelCaseAttributes.has(key) ? camelToDash(key) : key;
2160
+ return instance.getAttribute(key);
2161
+ }
2162
+ scrapeMotionValuesFromProps(props, prevProps, visualElement) {
2163
+ return scrapeMotionValuesFromProps(props, prevProps, visualElement);
2164
+ }
2165
+ build(renderState, latestValues, props) {
2166
+ buildSVGAttrs(renderState, latestValues, this.isSVGTag, props.transformTemplate, props.style);
2167
+ }
2168
+ renderInstance(instance, renderState, styleProp, projection) {
2169
+ renderSVG(instance, renderState, styleProp, projection);
2170
+ }
2171
+ mount(instance) {
2172
+ this.isSVGTag = isSVGTag(instance.tagName);
2173
+ super.mount(instance);
2174
+ }
2175
+ };
504
2176
  var numVariantProps = variantProps.length;
505
2177
  function getVariantContext(visualElement) {
506
2178
  if (!visualElement) return void 0;
@@ -866,9 +2538,14 @@ function compress(min, max, easing) {
866
2538
  return (p) => {
867
2539
  if (p < min) return 0;
868
2540
  if (p > max) return 1;
869
- return easing(progress(min, max, p));
2541
+ return easing(/* @__PURE__ */ progress(min, max, p));
870
2542
  };
871
2543
  }
2544
+ function animateSingleValue(value, keyframes2, options) {
2545
+ const motionValue$1 = isMotionValue(value) ? value : motionValue(value);
2546
+ motionValue$1.start(animateMotionValue("", motionValue$1, keyframes2, options));
2547
+ return motionValue$1.animation;
2548
+ }
872
2549
  function addDomEvent(target, eventName, handler, options = { passive: true }) {
873
2550
  target.addEventListener(eventName, handler, options);
874
2551
  return () => target.removeEventListener(eventName, handler, options);
@@ -1550,10 +3227,10 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
1550
3227
  const shouldCrossfadeOpacity = Boolean(isSharedLayoutAnimation && !isOnlyMember && this.options.crossfade === true && !this.path.some(hasOpacityCrossfade));
1551
3228
  this.animationProgress = 0;
1552
3229
  let prevRelativeTarget;
1553
- const interpolate = pathFn?.interpolateProjection(delta);
3230
+ const interpolate2 = pathFn?.interpolateProjection(delta);
1554
3231
  this.mixTargetDelta = (latest) => {
1555
3232
  const progress2 = latest / 1e3;
1556
- const point = interpolate?.(progress2);
3233
+ const point = interpolate2?.(progress2);
1557
3234
  if (point) {
1558
3235
  targetDelta.x.translate = point.x;
1559
3236
  targetDelta.x.scale = mixNumber(delta.x.scale, 1, progress2);
@@ -1986,6 +3663,26 @@ function LazyMotion({ children, features, strict = false }) {
1986
3663
  function isLazyBundle(features) {
1987
3664
  return typeof features === "function";
1988
3665
  }
3666
+ function MotionConfig({ children, ...config }) {
3667
+ const parentConfig = useContext(MotionConfigContext);
3668
+ config = {
3669
+ ...parentConfig,
3670
+ ...config
3671
+ };
3672
+ config.transition = resolveTransition(config.transition, parentConfig.transition);
3673
+ config.isStatic = useConstant(() => config.isStatic);
3674
+ const context = useMemo(() => config, [
3675
+ JSON.stringify(config.transition),
3676
+ config.transformPagePoint,
3677
+ config.reducedMotion,
3678
+ config.skipAnimations,
3679
+ config.isValidProp
3680
+ ]);
3681
+ return jsx(MotionConfigContext.Provider, {
3682
+ value: context,
3683
+ children
3684
+ });
3685
+ }
1989
3686
  var createDomVisualElement = (Component2, options) => {
1990
3687
  return options.isSVG ?? isSVGComponent(Component2) ? new SVGVisualElement(options) : new HTMLVisualElement(options, { allowProjection: Component2 !== Fragment });
1991
3688
  };
@@ -2319,8 +4016,8 @@ function calcOrigin(source, target) {
2319
4016
  let origin = 0.5;
2320
4017
  const sourceLength = calcLength(source);
2321
4018
  const targetLength = calcLength(target);
2322
- if (targetLength > sourceLength) origin = progress(target.min, target.max - sourceLength, source.min);
2323
- else if (sourceLength > targetLength) origin = progress(source.min, source.max - targetLength, target.min);
4019
+ if (targetLength > sourceLength) origin = /* @__PURE__ */ progress(target.min, target.max - sourceLength, source.min);
4020
+ else if (sourceLength > targetLength) origin = /* @__PURE__ */ progress(source.min, source.max - targetLength, target.min);
2324
4021
  return clamp(0, 1, origin);
2325
4022
  }
2326
4023
  function rebaseAxisConstraints(layout2, constraints) {
@@ -2540,7 +4237,7 @@ var VisualElementDragControls = class {
2540
4237
  };
2541
4238
  const bounceStiffness = dragElastic ? 200 : 1e6;
2542
4239
  const bounceDamping = dragElastic ? 40 : 1e7;
2543
- const inertia = {
4240
+ const inertia2 = {
2544
4241
  type: "inertia",
2545
4242
  velocity: dragMomentum ? velocity[axis] : 0,
2546
4243
  bounceStiffness,
@@ -2551,7 +4248,7 @@ var VisualElementDragControls = class {
2551
4248
  ...dragTransition,
2552
4249
  ...transition
2553
4250
  };
2554
- return this.startAxisValueAnimation(axis, inertia);
4251
+ return this.startAxisValueAnimation(axis, inertia2);
2555
4252
  });
2556
4253
  return Promise.all(momentumAnimations).then(onDragTransitionEnd);
2557
4254
  }
@@ -3076,7 +4773,7 @@ function MotionRuntime({ children }) {
3076
4773
  })
3077
4774
  });
3078
4775
  }
3079
- var globals_default = "/assets/globals-DCtBkCSD.css";
4776
+ var globals_default = "/assets/globals-B-fD_O7k.css";
3080
4777
  function makeQueryClient() {
3081
4778
  return new QueryClient({ defaultOptions: { queries: {
3082
4779
  staleTime: 6e4,
@@ -3090,7 +4787,7 @@ function getQueryClient() {
3090
4787
  if (!browserQueryClient) browserQueryClient = makeQueryClient();
3091
4788
  return browserQueryClient;
3092
4789
  }
3093
- var Route$26 = createRootRoute({
4790
+ var Route$29 = createRootRoute({
3094
4791
  head: () => ({
3095
4792
  meta: [
3096
4793
  { charSet: "utf-8" },
@@ -3158,8 +4855,8 @@ function RootDocument({ children }) {
3158
4855
  ] })]
3159
4856
  });
3160
4857
  }
3161
- var $$splitComponentImporter = () => import("./routes-hkom6S6L-DUPPQHPY.js");
3162
- var Route$25 = createFileRoute("/")({ component: lazyRouteComponent($$splitComponentImporter, "component") });
4858
+ var $$splitComponentImporter = () => import("./routes-Dn-deuPY-MDXEQXRU.js");
4859
+ var Route$28 = createFileRoute("/")({ component: lazyRouteComponent($$splitComponentImporter, "component") });
3163
4860
  var ManagedAttachmentValidationError = class extends Error {
3164
4861
  status;
3165
4862
  constructor(message, status) {
@@ -3971,8 +5668,8 @@ var openUIPromptSpec = {
3971
5668
  description: "A button that triggers interactive actions or conversational updates."
3972
5669
  },
3973
5670
  PanelAction: {
3974
- signature: 'PanelAction(label: string, panel: "resources" | "workspace" | "artifacts" | "repl" | "subagents" | "session-insights", relativePath?: any, focus?: boolean)',
3975
- description: "A trusted local action that opens Resources, Workspace, Artifacts, REPL, Subagents, or Session insights. relativePath selects a contained workspace-relative path and is valid only for Workspace and Artifacts panels."
5671
+ signature: 'PanelAction(label: string, panel: "resources" | "workspace" | "artifacts" | "repl" | "subagents" | "session-insights" | "session-tree", relativePath?: any, focus?: boolean)',
5672
+ description: "A trusted local action that opens Resources, Workspace, Artifacts, REPL, Subagents, Session insights, or Session tree. relativePath selects a contained workspace-relative path and is valid only for Workspace and Artifacts panels."
3976
5673
  },
3977
5674
  Input: {
3978
5675
  signature: 'Input(name: string, value: $binding<string>, placeholder?: string, type?: "text" | "email" | "number" | "password" | "search", disabled?: boolean)',
@@ -4296,7 +5993,8 @@ var openUIPromptSpec = {
4296
5993
  "artifacts",
4297
5994
  "repl",
4298
5995
  "subagents",
4299
- "session-insights"
5996
+ "session-insights",
5997
+ "session-tree"
4300
5998
  ]
4301
5999
  },
4302
6000
  relativePath: { type: "string" },
@@ -4311,7 +6009,7 @@ var openUIPromptSpec = {
4311
6009
  "focus"
4312
6010
  ],
4313
6011
  additionalProperties: false,
4314
- description: "A trusted local action that opens Resources, Workspace, Artifacts, REPL, Subagents, or Session insights. relativePath selects a contained workspace-relative path and is valid only for Workspace and Artifacts panels."
6012
+ description: "A trusted local action that opens Resources, Workspace, Artifacts, REPL, Subagents, Session insights, or Session tree. relativePath selects a contained workspace-relative path and is valid only for Workspace and Artifacts panels."
4315
6013
  },
4316
6014
  Input: {
4317
6015
  type: "object",
@@ -5855,14 +7553,14 @@ function contentToChatParts(content) {
5855
7553
  }
5856
7554
  return parts;
5857
7555
  }
5858
- function isRecord(value) {
7556
+ function isRecord$1(value) {
5859
7557
  return typeof value === "object" && value !== null && !Array.isArray(value);
5860
7558
  }
5861
7559
  var PRIVATE_PAYLOAD_KEY = /(?:api[_-]?key|access[_-]?token|refresh[_-]?token|password|secret|authorization|sessionDir|fullOutputPath|harnessStatePath)/i;
5862
7560
  function browserSafePayload(value, key) {
5863
7561
  if (key && PRIVATE_PAYLOAD_KEY.test(key)) return "[redacted]";
5864
7562
  if (Array.isArray(value)) return value.map((item) => browserSafePayload(item));
5865
- if (isRecord(value)) return Object.fromEntries(Object.entries(value).map(([entryKey, entryValue]) => [entryKey, browserSafePayload(entryValue, entryKey)]));
7563
+ if (isRecord$1(value)) return Object.fromEntries(Object.entries(value).map(([entryKey, entryValue]) => [entryKey, browserSafePayload(entryValue, entryKey)]));
5866
7564
  if (typeof value === "string" || typeof value === "number" || typeof value === "boolean" || value === null) return value;
5867
7565
  }
5868
7566
  function stringifyPayload(value) {
@@ -6546,7 +8244,7 @@ function reasoningFrame(state, phase, streaming) {
6546
8244
  };
6547
8245
  }
6548
8246
  function sentAgentMessageId(value) {
6549
- const record2 = isRecord(value) ? value : void 0;
8247
+ const record2 = isRecord$1(value) ? value : void 0;
6550
8248
  return typeof record2?.id === "string" ? record2.id : void 0;
6551
8249
  }
6552
8250
  function rememberSentAgentMessage(state, toolCallId, message) {
@@ -6561,8 +8259,8 @@ function withSentAgentMessages(state, toolCallId, value) {
6561
8259
  if (!toolCallId) return value;
6562
8260
  const sentAgentMessages = state.currentToolSentAgentMessages[toolCallId];
6563
8261
  if (!sentAgentMessages || sentAgentMessages.length === 0) return value;
6564
- const base = isRecord(value) ? value : {};
6565
- const details = isRecord(base.details) ? base.details : {};
8262
+ const base = isRecord$1(value) ? value : {};
8263
+ const details = isRecord$1(base.details) ? base.details : {};
6566
8264
  return {
6567
8265
  ...base,
6568
8266
  details: {
@@ -7463,6 +9161,123 @@ var RingBuffer = class {
7463
9161
  this.nextSeq = 1;
7464
9162
  }
7465
9163
  };
9164
+ var SessionTreeBusyError = class extends Error {
9165
+ status = 409;
9166
+ constructor() {
9167
+ super("Session is still streaming. Stop the current turn before rewinding.");
9168
+ this.name = "SessionTreeBusyError";
9169
+ }
9170
+ };
9171
+ var SessionTreeConcurrencyError = class extends Error {
9172
+ status = 409;
9173
+ constructor() {
9174
+ super("The session tree changed while you were selecting a rewind target. Refresh and try again.");
9175
+ this.name = "SessionTreeConcurrencyError";
9176
+ }
9177
+ };
9178
+ var SessionTreeCancelledError = class extends Error {
9179
+ status = 409;
9180
+ constructor() {
9181
+ super("Session tree navigation was cancelled. Refresh and try again.");
9182
+ this.name = "SessionTreeCancelledError";
9183
+ }
9184
+ };
9185
+ function messageContentToText(content) {
9186
+ if (typeof content === "string") return content;
9187
+ if (!Array.isArray(content)) return "";
9188
+ return content.filter((part) => typeof part === "object" && part !== null && part.type === "text" && typeof part.text === "string").map((part) => part.text).join(" ");
9189
+ }
9190
+ function entryPreview(node) {
9191
+ const { entry } = node;
9192
+ if (entry.type === "message" && entry.message) {
9193
+ const role = entry.message.role ?? "message";
9194
+ const oneLine = messageContentToText(entry.message.content).replace(/\s+/g, " ").trim();
9195
+ return `${role}: ${oneLine.length > 72 ? `${oneLine.slice(0, 72)}\u2026` : oneLine}`;
9196
+ }
9197
+ return entry.label ?? node.label ?? entry.type;
9198
+ }
9199
+ function entryKind(entry) {
9200
+ if (entry.type === "message") return "message";
9201
+ if (entry.type === "system" || entry.type === "compaction" || entry.type === "model_change") return "system";
9202
+ return "other";
9203
+ }
9204
+ function entryRole(entry) {
9205
+ if (entry.type !== "message" || !entry.message?.role) return void 0;
9206
+ switch (entry.message.role) {
9207
+ case "user":
9208
+ return "user";
9209
+ case "assistant":
9210
+ return "assistant";
9211
+ case "system":
9212
+ return "system";
9213
+ default:
9214
+ return "unknown";
9215
+ }
9216
+ }
9217
+ function findActiveBranchPath(nodes, leafId) {
9218
+ const active = /* @__PURE__ */ new Set();
9219
+ if (!leafId) return active;
9220
+ const walk = (items) => {
9221
+ for (const node of items) {
9222
+ if (node.entry.id === leafId) {
9223
+ active.add(node.entry.id);
9224
+ return true;
9225
+ }
9226
+ if (walk(node.children)) {
9227
+ active.add(node.entry.id);
9228
+ return true;
9229
+ }
9230
+ }
9231
+ return false;
9232
+ };
9233
+ walk(nodes);
9234
+ return active;
9235
+ }
9236
+ function buildMessageIndexByEntryId(nodes, leafId) {
9237
+ const activePath = findActiveBranchPath(nodes, leafId);
9238
+ const messageIndexByEntryId = /* @__PURE__ */ new Map();
9239
+ let messageIndex = 0;
9240
+ const walk = (items) => {
9241
+ for (const node of items) {
9242
+ if (!activePath.has(node.entry.id)) continue;
9243
+ if (node.entry.type === "message") {
9244
+ messageIndexByEntryId.set(node.entry.id, messageIndex);
9245
+ messageIndex += 1;
9246
+ }
9247
+ walk(node.children);
9248
+ return;
9249
+ }
9250
+ };
9251
+ walk(nodes);
9252
+ return messageIndexByEntryId;
9253
+ }
9254
+ function mapNode(node, leafId, activePath, messageIndexByEntryId) {
9255
+ const preview = entryPreview(node);
9256
+ const role = entryRole(node.entry);
9257
+ const messageIndex = messageIndexByEntryId.get(node.entry.id);
9258
+ return {
9259
+ id: node.entry.id,
9260
+ ...node.entry.parentId ? { parentId: node.entry.parentId } : {},
9261
+ kind: entryKind(node.entry),
9262
+ ...role ? { role } : {},
9263
+ label: node.entry.label ?? node.label ?? node.entry.type,
9264
+ preview,
9265
+ isLeaf: node.entry.id === leafId,
9266
+ isOnActiveBranch: activePath.has(node.entry.id),
9267
+ ...messageIndex !== void 0 ? { messageIndex } : {},
9268
+ children: node.children.map((child) => mapNode(child, leafId, activePath, messageIndexByEntryId))
9269
+ };
9270
+ }
9271
+ function mapSessionTreeSnapshot(sessionId, nodes, leafId) {
9272
+ const upstreamNodes = nodes;
9273
+ const activePath = findActiveBranchPath(upstreamNodes, leafId);
9274
+ const messageIndexByEntryId = buildMessageIndexByEntryId(upstreamNodes, leafId);
9275
+ return {
9276
+ sessionId,
9277
+ leafId,
9278
+ nodes: upstreamNodes.map((node) => mapNode(node, leafId, activePath, messageIndexByEntryId))
9279
+ };
9280
+ }
7466
9281
  var WEB_UI_UNSUPPORTED = "Not available in the web UI";
7467
9282
  function unsupportedInWebUi(method) {
7468
9283
  throw new Error(`${method}: ${WEB_UI_UNSUPPORTED}`);
@@ -7774,6 +9589,7 @@ var PrimeBridge = class {
7774
9589
  #childPromptStarter;
7775
9590
  #childPrompts = /* @__PURE__ */ new Map();
7776
9591
  #caches = /* @__PURE__ */ new Map();
9592
+ #sessionTreeNavigationQueues = /* @__PURE__ */ new Map();
7777
9593
  #openUIPromptTransitions = /* @__PURE__ */ new Map();
7778
9594
  #daemonDialogs = /* @__PURE__ */ new Map();
7779
9595
  #auxiliaryWarnings = /* @__PURE__ */ new Set();
@@ -7869,6 +9685,7 @@ var PrimeBridge = class {
7869
9685
  this.#presentationWrites.clear();
7870
9686
  this.#presentationGenerations.clear();
7871
9687
  this.#caches.clear();
9688
+ this.#sessionTreeNavigationQueues.clear();
7872
9689
  this.#openUIPromptTransitions.clear();
7873
9690
  this.#daemonDialogs.clear();
7874
9691
  this.#auxiliaryWarnings.clear();
@@ -8734,8 +10551,12 @@ var PrimeBridge = class {
8734
10551
  /** /tree — session-tree navigation via navigateTree (requires entry id). */
8735
10552
  async navigateTree(sessionId, targetId) {
8736
10553
  const session = this.#requireSession(sessionId);
8737
- await session.connection.navigateTree(targetId, {});
8738
- await deleteManagedPlanPresentationsForSession(sessionId, session.sessionPath);
10554
+ await this.#withSessionTreeNavigationLock(sessionId, async () => {
10555
+ await session.connection.waitForIdle();
10556
+ await session.connection.navigateTree(targetId, {});
10557
+ await this.#refreshSessionTreeCache(sessionId, session.connection);
10558
+ await deleteManagedPlanPresentationsForSession(sessionId, session.sessionPath);
10559
+ });
8739
10560
  }
8740
10561
  /** /tree — the session's entry tree plus the current leaf, for pickers. */
8741
10562
  getSessionTree(sessionId) {
@@ -8747,6 +10568,43 @@ var PrimeBridge = class {
8747
10568
  leafId: null
8748
10569
  };
8749
10570
  }
10571
+ async #refreshSessionTreeCache(sessionId, connection) {
10572
+ const tree = await connection.getSessionTree();
10573
+ const cache = this.#caches.get(sessionId) ?? emptyCache();
10574
+ cache.tree = {
10575
+ tree: tree.tree,
10576
+ leafId: tree.leafId
10577
+ };
10578
+ this.#caches.set(sessionId, cache);
10579
+ }
10580
+ async #withSessionTreeNavigationLock(sessionId, operation) {
10581
+ const current = (this.#sessionTreeNavigationQueues.get(sessionId) ?? Promise.resolve()).catch(() => void 0).then(operation);
10582
+ const tail = current.then(() => void 0, () => void 0);
10583
+ this.#sessionTreeNavigationQueues.set(sessionId, tail);
10584
+ tail.then(() => {
10585
+ if (this.#sessionTreeNavigationQueues.get(sessionId) === tail) this.#sessionTreeNavigationQueues.delete(sessionId);
10586
+ });
10587
+ return current;
10588
+ }
10589
+ /** Reads a browser-safe session tree snapshot from the live connection. */
10590
+ async readSessionTreeSnapshot(sessionId) {
10591
+ const session = this.#requireSession(sessionId);
10592
+ await this.#refreshSessionTreeCache(sessionId, session.connection);
10593
+ const cached = this.getSessionTree(sessionId);
10594
+ return mapSessionTreeSnapshot(sessionId, cached.tree, cached.leafId);
10595
+ }
10596
+ /** Navigates the live session tree and returns the authoritative browser-safe snapshot. */
10597
+ async navigateSessionTree(sessionId, targetEntryId, expectedLeafId) {
10598
+ const session = this.#requireSession(sessionId);
10599
+ return this.#withSessionTreeNavigationLock(sessionId, async () => {
10600
+ await session.connection.waitForIdle();
10601
+ const before = await session.connection.getSessionTree();
10602
+ if (expectedLeafId && before.leafId !== expectedLeafId) throw new SessionTreeConcurrencyError();
10603
+ if ((await session.connection.navigateTree(targetEntryId, {})).cancelled) throw new SessionTreeCancelledError();
10604
+ await deleteManagedPlanPresentationsForSession(sessionId, session.sessionPath);
10605
+ return this.readSessionTreeSnapshot(sessionId);
10606
+ });
10607
+ }
8750
10608
  /**
8751
10609
  * /fork and /clone — branch the session at `entryId` into a NEW live session.
8752
10610
  *
@@ -8896,14 +10754,14 @@ var PrimeBridge = class {
8896
10754
  return session;
8897
10755
  }
8898
10756
  };
8899
- var globalStore = globalThis;
10757
+ var globalStore$2 = globalThis;
8900
10758
  function getBridge() {
8901
- if (!globalStore.__primeBridge) globalStore.__primeBridge = new PrimeBridge({
10759
+ if (!globalStore$2.__primeBridge) globalStore$2.__primeBridge = new PrimeBridge({
8902
10760
  kernelTimeoutMs: 3e4,
8903
10761
  ringBufferCapacity: 500,
8904
10762
  dialogTimeoutMs: 6e4
8905
10763
  });
8906
- return globalStore.__primeBridge;
10764
+ return globalStore$2.__primeBridge;
8907
10765
  }
8908
10766
  function isLoopbackHostname(hostname) {
8909
10767
  const host = hostname.toLowerCase().replace(/\.$/, "");
@@ -9644,6 +11502,331 @@ function handleChatCommandsGet(request) {
9644
11502
  });
9645
11503
  }, request);
9646
11504
  }
11505
+ function normalizeCompletionText(text) {
11506
+ return text.trim().replace(/\s+/g, " ");
11507
+ }
11508
+ function findCompletion(draft, candidates, options = {}) {
11509
+ const minChars = options.minChars ?? 4;
11510
+ const maxChars = options.maxChars ?? 200;
11511
+ const normalizedDraft = normalizeCompletionText(draft);
11512
+ if (normalizedDraft.length < minChars) return void 0;
11513
+ const needle = normalizedDraft.toLowerCase();
11514
+ let best;
11515
+ let bestText = "";
11516
+ for (const candidate of candidates) {
11517
+ const text = normalizeCompletionText(candidate.text);
11518
+ if (text.length <= normalizedDraft.length) continue;
11519
+ if (text.length > maxChars) continue;
11520
+ if (!text.toLowerCase().startsWith(needle)) continue;
11521
+ if (!best || candidate.at > best.at || candidate.at === best.at && text.length > bestText.length) {
11522
+ best = candidate;
11523
+ bestText = text;
11524
+ }
11525
+ }
11526
+ return best ? bestText : void 0;
11527
+ }
11528
+ function harvestPromptCandidates(messages, at, maxChars = 200) {
11529
+ const out = [];
11530
+ for (const message of messages) {
11531
+ if (message.role !== "user") continue;
11532
+ const text = normalizeCompletionText(message.text);
11533
+ if (text.length < 8 || text.length > maxChars) continue;
11534
+ if (text.startsWith("<") || text.startsWith("[harness") || text.includes("<harness_state>")) continue;
11535
+ out.push({
11536
+ text,
11537
+ at
11538
+ });
11539
+ }
11540
+ return out;
11541
+ }
11542
+ var INDEX_READY_TIMEOUT_MS = 250;
11543
+ function createComposerCompletionService(options) {
11544
+ return { async complete(draft) {
11545
+ if (composerCompletionIgnores(draft)) return {};
11546
+ await Promise.race([options.index.ready(), new Promise((resolve2) => setTimeout(resolve2, INDEX_READY_TIMEOUT_MS))]);
11547
+ const completion = findCompletion(draft, options.index.candidates());
11548
+ return completion ? { completion } : {};
11549
+ } };
11550
+ }
11551
+ function stringValue(value) {
11552
+ return typeof value === "string" && value.length > 0 ? value : void 0;
11553
+ }
11554
+ function timestampValue(value) {
11555
+ if (value instanceof Date) return value.toISOString();
11556
+ return stringValue(value);
11557
+ }
11558
+ function messageCountValue(value) {
11559
+ return typeof value === "number" && Number.isFinite(value) && value >= 0 ? Math.trunc(value) : 0;
11560
+ }
11561
+ function normalizeSessionListRow(source) {
11562
+ const raw = source;
11563
+ const sessionId = stringValue(raw.sessionId) ?? stringValue(raw.id);
11564
+ const cwd = stringValue(raw.cwd);
11565
+ if (!sessionId || !cwd) throw new Error("The Prime Agent session listing returned an invalid session entry");
11566
+ const createdAt = timestampValue(raw.created) ?? timestampValue(raw.modified) ?? (/* @__PURE__ */ new Date()).toISOString();
11567
+ const updatedAt = timestampValue(raw.modified) ?? timestampValue(raw.created) ?? createdAt;
11568
+ const isSubagent2 = typeof raw.runtimeKind === "string" ? raw.runtimeKind === "subagent" : Boolean(raw.rlmChildId ?? raw.rlmParentNodeId ?? raw.parentActiveSessionId ?? raw.parentSessionId ?? raw.parentSessionPath);
11569
+ return {
11570
+ source,
11571
+ sessionId,
11572
+ cwd,
11573
+ title: meaningfulSessionLabel(stringValue(raw.sessionName) ?? stringValue(raw.name)),
11574
+ createdAt,
11575
+ updatedAt,
11576
+ messageCount: messageCountValue(raw.messageCount),
11577
+ firstMessage: meaningfulSessionLabel(typeof raw.firstMessage === "string" ? raw.firstMessage : void 0) ?? "",
11578
+ isSubagent: isSubagent2
11579
+ };
11580
+ }
11581
+ function sessionSourcePath(source) {
11582
+ const raw = source;
11583
+ return stringValue(raw.sessionFile) ?? stringValue(raw.path);
11584
+ }
11585
+ function latestBy(entries, time2) {
11586
+ if (entries.length === 0) return void 0;
11587
+ return entries.reduce((latest, entry) => time2(entry) >= time2(latest) ? entry : latest);
11588
+ }
11589
+ function presentationListActivity(presentation) {
11590
+ if (!presentation) return { activityCount: 0 };
11591
+ const artifacts = presentation.artifactRuns.flatMap((run) => run.artifacts);
11592
+ const latestRefinement = latestBy(presentation.refinements, (entry) => entry.timestamp);
11593
+ const latestArtifact = latestBy(artifacts, (entry) => entry.timestamp);
11594
+ const latestBash = latestBy(presentation.userBash, (entry) => entry.startedAt);
11595
+ return {
11596
+ title: meaningfulSessionLabel(presentation.sessionName) ?? meaningfulSessionLabel(latestRefinement?.summary) ?? meaningfulSessionLabel(latestArtifact?.title) ?? meaningfulSessionLabel(latestBash?.command),
11597
+ activityCount: presentation.refinements.length + artifacts.length + presentation.userBash.length
11598
+ };
11599
+ }
11600
+ function applyPresentationToSessionRow(row, presentation) {
11601
+ const { title: presentationTitle, activityCount } = presentationListActivity(presentation);
11602
+ const firstMessage = row.firstMessage || presentationTitle || "";
11603
+ return {
11604
+ title: row.title ?? meaningfulSessionLabel(firstMessage) ?? presentationTitle ?? fallbackSessionLabel(row.sessionId),
11605
+ firstMessage,
11606
+ messageCount: row.messageCount > 0 ? row.messageCount : activityCount > 0 ? 1 : 0
11607
+ };
11608
+ }
11609
+ function sessionNeedsPresentationJoin(row) {
11610
+ return row.messageCount === 0 || !row.title || !row.firstMessage;
11611
+ }
11612
+ async function loadSessionListPresentation(row, source, livePresentation) {
11613
+ const liveActivity = presentationListActivity(livePresentation);
11614
+ if (liveActivity.activityCount > 0 || liveActivity.title) return livePresentation;
11615
+ if (!sessionNeedsPresentationJoin(row)) return livePresentation;
11616
+ const path = sessionSourcePath(source);
11617
+ if (!path) return livePresentation;
11618
+ return await loadManagedPrimePresentation({ sessionPath: path }) ?? livePresentation;
11619
+ }
11620
+ var PROMPT_INDEX_CANDIDATE_LIMIT = 2e3;
11621
+ var PROMPT_INDEX_RETRY_BACKOFF_MS = 6e4;
11622
+ var PROMPT_INDEX_FILE = "fleet-prompt-index.json";
11623
+ function promptIndexPath(agentDir) {
11624
+ return join(agentDir, PROMPT_INDEX_FILE);
11625
+ }
11626
+ function isSubagent(session) {
11627
+ return session.isSubagent === true;
11628
+ }
11629
+ function sessionRecency(session) {
11630
+ const raw = session.modified;
11631
+ const parsed = raw ? Date.parse(raw) : NaN;
11632
+ return Number.isFinite(parsed) ? parsed : 0;
11633
+ }
11634
+ async function readPersisted(agentDir) {
11635
+ try {
11636
+ const raw = JSON.parse(await readFile(promptIndexPath(agentDir), "utf8"));
11637
+ if (raw.version !== 1 || !Array.isArray(raw.sessions)) return void 0;
11638
+ const sessions2 = raw.sessions.filter((entry) => typeof entry?.sessionFile === "string" && typeof entry.modified === "string" && Array.isArray(entry.prompts) && entry.prompts.every((prompt) => typeof prompt === "string"));
11639
+ const emptyStreak = typeof raw.emptyStreak === "number" && raw.emptyStreak > 0 ? raw.emptyStreak : 0;
11640
+ return {
11641
+ version: 1,
11642
+ builtAt: typeof raw.builtAt === "string" ? raw.builtAt : "",
11643
+ emptyStreak,
11644
+ sessions: sessions2
11645
+ };
11646
+ } catch {
11647
+ return;
11648
+ }
11649
+ }
11650
+ async function writePersisted(agentDir, index) {
11651
+ const path = promptIndexPath(agentDir);
11652
+ await mkdir(dirname(path), { recursive: true });
11653
+ const temporary = `${path}.${process.pid}.${crypto.randomUUID()}.tmp`;
11654
+ await writeFile(temporary, `${JSON.stringify(index)}
11655
+ `, "utf8");
11656
+ await rename(temporary, path);
11657
+ }
11658
+ function flatten(index, limit) {
11659
+ const out = [];
11660
+ for (const session of index.sessions) {
11661
+ const base = Date.parse(session.modified);
11662
+ const at = Number.isFinite(base) ? base : 0;
11663
+ session.prompts.forEach((text, offset) => {
11664
+ out.push({
11665
+ text,
11666
+ at: at + Math.min(offset, 999) / 1e3
11667
+ });
11668
+ });
11669
+ }
11670
+ out.sort((a, b) => b.at - a.at);
11671
+ return out.slice(0, limit);
11672
+ }
11673
+ function createPromptIndex(options) {
11674
+ const limit = options.sessionLimit ?? 400;
11675
+ const maxSessionMessages = options.maxSessionMessages ?? 2e3;
11676
+ const now2 = options.now ?? Date.now;
11677
+ const log = options.log ?? (() => {
11678
+ });
11679
+ let persisted;
11680
+ let loading;
11681
+ let building;
11682
+ let retryAfter = 0;
11683
+ let flattened;
11684
+ const load = () => {
11685
+ loading ??= (async () => {
11686
+ persisted = await readPersisted(options.agentDir);
11687
+ flattened = void 0;
11688
+ })();
11689
+ return loading;
11690
+ };
11691
+ load();
11692
+ const build = async () => {
11693
+ await load();
11694
+ const previous = new Map((persisted?.sessions ?? []).map((entry) => [entry.sessionFile, entry]));
11695
+ let sessions2;
11696
+ try {
11697
+ sessions2 = await options.listSessions();
11698
+ } catch (error) {
11699
+ log(`prompt index: session listing failed (${error instanceof Error ? error.name : "unknown"})`);
11700
+ return false;
11701
+ }
11702
+ const scoped = sessions2.filter((session) => !isSubagent(session)).filter((session) => (session.messageCount ?? 0) <= maxSessionMessages).filter((session) => typeof session.sessionFile === "string" && session.sessionFile.length > 0).sort((a, b) => sessionRecency(b) - sessionRecency(a)).slice(0, limit);
11703
+ const next = [];
11704
+ for (const session of scoped) {
11705
+ const modified = session.modified ?? "";
11706
+ const cached = previous.get(session.sessionFile);
11707
+ if (cached && cached.modified === modified) {
11708
+ next.push(cached);
11709
+ continue;
11710
+ }
11711
+ try {
11712
+ const messages = await options.openSession(session.sessionFile);
11713
+ next.push({
11714
+ sessionFile: session.sessionFile,
11715
+ modified,
11716
+ prompts: harvestPromptCandidates(messages, 0).map((candidate) => candidate.text)
11717
+ });
11718
+ } catch {
11719
+ if (cached) next.push(cached);
11720
+ }
11721
+ }
11722
+ const harvest = next.reduce((total, entry) => total + entry.prompts.length, 0);
11723
+ const hadCorpus = (persisted?.sessions.length ?? 0) > 0;
11724
+ const emptyStreak = (persisted?.emptyStreak ?? 0) + 1;
11725
+ if (harvest === 0 && hadCorpus && emptyStreak < 2) {
11726
+ persisted = {
11727
+ ...persisted,
11728
+ emptyStreak
11729
+ };
11730
+ try {
11731
+ await writePersisted(options.agentDir, persisted);
11732
+ } catch {
11733
+ }
11734
+ log("prompt index: rebuild produced no prompts; keeping the previous corpus");
11735
+ return false;
11736
+ }
11737
+ if (harvest === 0 && hadCorpus) log("prompt index: store confirmed empty; clearing the corpus");
11738
+ persisted = {
11739
+ version: 1,
11740
+ builtAt: new Date(now2()).toISOString(),
11741
+ emptyStreak: 0,
11742
+ sessions: next
11743
+ };
11744
+ flattened = void 0;
11745
+ try {
11746
+ await writePersisted(options.agentDir, persisted);
11747
+ } catch (error) {
11748
+ log(`prompt index: persist failed (${error instanceof Error ? error.name : "unknown"})`);
11749
+ }
11750
+ return true;
11751
+ };
11752
+ const ensureFresh = () => {
11753
+ if (building) return;
11754
+ if (now2() < retryAfter) return;
11755
+ building = (async () => {
11756
+ await load();
11757
+ const builtAt = persisted ? Date.parse(persisted.builtAt) : NaN;
11758
+ if (Number.isFinite(builtAt) && now2() - builtAt <= 6e5) return;
11759
+ retryAfter = await build() ? 0 : now2() + PROMPT_INDEX_RETRY_BACKOFF_MS;
11760
+ })().catch(() => {
11761
+ retryAfter = now2() + PROMPT_INDEX_RETRY_BACKOFF_MS;
11762
+ }).finally(() => {
11763
+ building = void 0;
11764
+ });
11765
+ };
11766
+ return {
11767
+ ready: () => load(),
11768
+ candidates() {
11769
+ ensureFresh();
11770
+ if (!persisted) return [];
11771
+ flattened ??= flatten(persisted, PROMPT_INDEX_CANDIDATE_LIMIT);
11772
+ return flattened;
11773
+ },
11774
+ async refresh() {
11775
+ await (building ?? build().then(() => void 0));
11776
+ },
11777
+ stats() {
11778
+ const builtAt = persisted ? Date.parse(persisted.builtAt) : NaN;
11779
+ return {
11780
+ sessions: persisted?.sessions.length ?? 0,
11781
+ prompts: persisted?.sessions.reduce((total, entry) => total + entry.prompts.length, 0) ?? 0,
11782
+ builtAt: Number.isFinite(builtAt) ? builtAt : 0
11783
+ };
11784
+ }
11785
+ };
11786
+ }
11787
+ var globalStore$1 = globalThis;
11788
+ function messageText(message) {
11789
+ if (typeof message !== "object" || message === null) return "";
11790
+ const content = message.content;
11791
+ if (typeof content === "string") return content;
11792
+ if (!Array.isArray(content)) return "";
11793
+ return content.filter((part) => {
11794
+ if (typeof part !== "object" || part === null) return false;
11795
+ const candidate = part;
11796
+ return candidate.type === "text" && typeof candidate.text === "string";
11797
+ }).map((part) => part.text).join(" ");
11798
+ }
11799
+ var openSessionWithRuntime = async (sessionFile) => {
11800
+ return (await SessionManager.openAsync(sessionFile)).buildSessionContext().messages.map((message) => ({
11801
+ role: message.role,
11802
+ text: messageText(message)
11803
+ }));
11804
+ };
11805
+ function getPromptIndex() {
11806
+ if (!globalStore$1.__fleetPromptIndex) globalStore$1.__fleetPromptIndex = createPromptIndex({
11807
+ agentDir: getPrimeConfig().agentDir,
11808
+ listSessions: async () => (await getBridge().listSessions()).map((summary) => {
11809
+ const row = normalizeSessionListRow(summary);
11810
+ return {
11811
+ sessionFile: sessionSourcePath(row.source),
11812
+ modified: row.updatedAt,
11813
+ isSubagent: row.isSubagent,
11814
+ messageCount: row.messageCount
11815
+ };
11816
+ }),
11817
+ openSession: openSessionWithRuntime,
11818
+ log: (message) => process.stderr.write(`[completion] ${message}
11819
+ `)
11820
+ });
11821
+ return globalStore$1.__fleetPromptIndex;
11822
+ }
11823
+ function handleChatCompletionPost(request) {
11824
+ return wrapApiHandler(async () => {
11825
+ const body = ComposerCompletionRequestSchema.parse(await request.json().catch(() => ({})));
11826
+ const service = createComposerCompletionService({ index: getPromptIndex() });
11827
+ return Response.json(await service.complete(body.text));
11828
+ }, request);
11829
+ }
9647
11830
  function shouldReplaySseEvent(event, pendingQuestionIds) {
9648
11831
  if (!pendingQuestionIds) return true;
9649
11832
  if (!event || typeof event !== "object") return true;
@@ -9822,6 +12005,481 @@ function handleChatEventsGet(request) {
9822
12005
  return createSseResponse(request, getBridge(), { sessionId: sessionId.data }, lastEventIdFor(request, url));
9823
12006
  }, request);
9824
12007
  }
12008
+ var DEFAULT_FLEET_SETTINGS = {
12009
+ version: 1,
12010
+ composerIntentEnabled: false
12011
+ };
12012
+ var FLEET_SETTINGS_FILE = "fleet-settings.json";
12013
+ function fleetSettingsPath(agentDir) {
12014
+ return join(agentDir, FLEET_SETTINGS_FILE);
12015
+ }
12016
+ async function readFleetSettings(agentDir) {
12017
+ try {
12018
+ return {
12019
+ version: 1,
12020
+ composerIntentEnabled: JSON.parse(await readFile(fleetSettingsPath(agentDir), "utf8")).composerIntentEnabled === true
12021
+ };
12022
+ } catch {
12023
+ return { ...DEFAULT_FLEET_SETTINGS };
12024
+ }
12025
+ }
12026
+ var writeChain = Promise.resolve();
12027
+ async function updateFleetSettings(agentDir, patch) {
12028
+ const update = writeChain.then(() => writeFleetSettings(agentDir, patch));
12029
+ writeChain = update.catch(() => void 0);
12030
+ return update;
12031
+ }
12032
+ async function writeFleetSettings(agentDir, patch) {
12033
+ const current = await readFleetSettings(agentDir);
12034
+ const next = {
12035
+ version: 1,
12036
+ composerIntentEnabled: patch.composerIntentEnabled ?? current.composerIntentEnabled
12037
+ };
12038
+ const path = fleetSettingsPath(agentDir);
12039
+ await mkdir(dirname(path), { recursive: true });
12040
+ const temporary = `${path}.${process.pid}.${crypto.randomUUID()}.tmp`;
12041
+ await writeFile(temporary, `${JSON.stringify(next, null, " ")}
12042
+ `, "utf8");
12043
+ await rename(temporary, path);
12044
+ return next;
12045
+ }
12046
+ var TYPESAFE_CREDENTIAL_ID = "typesafe";
12047
+ function readCredential() {
12048
+ try {
12049
+ const credential = getPrimeConfig().authStorage.get(TYPESAFE_CREDENTIAL_ID);
12050
+ return credential?.type === "api_key" ? credential : void 0;
12051
+ } catch {
12052
+ return;
12053
+ }
12054
+ }
12055
+ function readStoredTypeSafeKey() {
12056
+ const key = readCredential()?.key?.trim();
12057
+ return key ? key : void 0;
12058
+ }
12059
+ function writeStoredTypeSafeKey(key) {
12060
+ const trimmed = key.trim();
12061
+ if (!trimmed) throw new Error("A TypeSafe API key cannot be empty");
12062
+ const config = getPrimeConfig();
12063
+ config.authStorage.set(TYPESAFE_CREDENTIAL_ID, {
12064
+ type: "api_key",
12065
+ key: trimmed
12066
+ });
12067
+ config.reloadAuth();
12068
+ }
12069
+ function clearStoredTypeSafeKey() {
12070
+ const config = getPrimeConfig();
12071
+ if (config.authStorage.has("typesafe")) config.authStorage.remove(TYPESAFE_CREDENTIAL_ID);
12072
+ config.reloadAuth();
12073
+ }
12074
+ function typeSafeKeySource() {
12075
+ if (readStoredTypeSafeKey()) return "settings";
12076
+ if ((process.env.TYPESAFE_API_KEY ?? "").trim()) return "environment";
12077
+ return "none";
12078
+ }
12079
+ var DEFAULT_TYPESAFE_INTENT_TIMEOUT_MS = 1500;
12080
+ var LOG_LEVELS = [
12081
+ "debug",
12082
+ "info",
12083
+ "warn",
12084
+ "error",
12085
+ "off"
12086
+ ];
12087
+ function positiveInt(value, fallback) {
12088
+ const parsed = Number.parseInt(value ?? "", 10);
12089
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
12090
+ }
12091
+ function nonNegativeInt(value, fallback) {
12092
+ const parsed = Number.parseInt(value ?? "", 10);
12093
+ return Number.isFinite(parsed) && parsed >= 0 ? parsed : fallback;
12094
+ }
12095
+ function isCredentialSafeBaseUrl(value) {
12096
+ let url;
12097
+ try {
12098
+ url = new URL(value);
12099
+ } catch {
12100
+ return false;
12101
+ }
12102
+ if (url.protocol === "https:") return true;
12103
+ if (url.protocol !== "http:") return false;
12104
+ const host = url.hostname.replace(/^\[|\]$/g, "");
12105
+ return host === "localhost" || host === "127.0.0.1" || host === "::1";
12106
+ }
12107
+ function isLogLevel(value) {
12108
+ return value !== void 0 && LOG_LEVELS.includes(value);
12109
+ }
12110
+ function readTypeSafeConfig(env = process.env, storedKey) {
12111
+ const apiKey = (storedKey ?? "").trim() || (env.TYPESAFE_API_KEY ?? "").trim() || void 0;
12112
+ const killed = (env.FLEET_TYPESAFE_ENABLED ?? "").trim() === "0";
12113
+ const requestedBaseUrl = (env.TYPESAFE_BASE_URL ?? "").trim().replace(/\/+$/, "");
12114
+ const baseUrlUsable = requestedBaseUrl === "" || isCredentialSafeBaseUrl(requestedBaseUrl);
12115
+ return {
12116
+ configured: Boolean(apiKey) && !killed && baseUrlUsable,
12117
+ apiKey,
12118
+ baseUrl: requestedBaseUrl || "https://api.typesafe.ai",
12119
+ model: (env.TYPESAFE_MODEL ?? "").trim() || "jev-latest",
12120
+ intentTimeoutMs: positiveInt(env.TYPESAFE_INTENT_TIMEOUT_MS, DEFAULT_TYPESAFE_INTENT_TIMEOUT_MS),
12121
+ intentMaxRetries: nonNegativeInt(env.TYPESAFE_INTENT_MAX_RETRIES, 1),
12122
+ logLevel: isLogLevel(env.TYPESAFE_LOG_LEVEL) ? env.TYPESAFE_LOG_LEVEL : "warn"
12123
+ };
12124
+ }
12125
+ var TypeSafeTransportError = class extends Error {
12126
+ kind;
12127
+ status;
12128
+ constructor(message, kind, status, options) {
12129
+ super(message, options);
12130
+ this.name = "TypeSafeTransportError";
12131
+ this.kind = kind;
12132
+ this.status = status;
12133
+ }
12134
+ };
12135
+ var TYPESAFE_RETRYABLE_STATUSES = /* @__PURE__ */ new Set([
12136
+ 408,
12137
+ 429,
12138
+ 500,
12139
+ 502,
12140
+ 503,
12141
+ 504,
12142
+ 529
12143
+ ]);
12144
+ var NO_RETRY_STATUSES = /* @__PURE__ */ new Set();
12145
+ var RETRY_MAX_DELAY_MS = 5e3;
12146
+ function retryDelayMs(response, attempt) {
12147
+ const header = response.headers.get("retry-after")?.trim();
12148
+ if (header) {
12149
+ const seconds = Number(header);
12150
+ if (Number.isFinite(seconds) && seconds >= 0) return Math.min(seconds * 1e3, RETRY_MAX_DELAY_MS);
12151
+ const date = Date.parse(header);
12152
+ if (Number.isFinite(date)) return Math.min(Math.max(date - Date.now(), 0), RETRY_MAX_DELAY_MS);
12153
+ }
12154
+ const exponential = Math.min(250 * 2 ** attempt, RETRY_MAX_DELAY_MS);
12155
+ return Math.round(exponential * (0.5 + Math.random() / 2));
12156
+ }
12157
+ function sleep(ms) {
12158
+ return new Promise((resolve2) => setTimeout(resolve2, ms));
12159
+ }
12160
+ function noul(instructions, criteria) {
12161
+ return criteria ? {
12162
+ type: "noul",
12163
+ instructions,
12164
+ criteria
12165
+ } : {
12166
+ type: "noul",
12167
+ instructions
12168
+ };
12169
+ }
12170
+ function choice(instructions, criteria) {
12171
+ return {
12172
+ type: "choice",
12173
+ instructions,
12174
+ criteria
12175
+ };
12176
+ }
12177
+ function choiceAnswer(result, id2) {
12178
+ const answer = result.answers[id2];
12179
+ return answer?.type === "choice" ? answer : void 0;
12180
+ }
12181
+ function noulAnswer(result, id2) {
12182
+ const answer = result.answers[id2];
12183
+ return answer?.type === "noul" ? answer : void 0;
12184
+ }
12185
+ function isRecord(value) {
12186
+ return typeof value === "object" && value !== null && !Array.isArray(value);
12187
+ }
12188
+ async function postSystemOne(config, body, options = {}, fetchImpl = globalThis.fetch) {
12189
+ if (!config.configured || !config.apiKey) throw new TypeSafeTransportError("TypeSafe is not configured", "unconfigured");
12190
+ const apiKey = config.apiKey;
12191
+ const timeoutMs = options.timeoutMs ?? config.intentTimeoutMs;
12192
+ const maxRetries = options.maxRetries ?? 0;
12193
+ const retryStatuses = options.retryStatuses ?? NO_RETRY_STATUSES;
12194
+ let lastError;
12195
+ for (let attempt = 0; attempt <= maxRetries; attempt += 1) {
12196
+ const timeoutSignal = AbortSignal.timeout(timeoutMs);
12197
+ const signal = options.signal ? AbortSignal.any([options.signal, timeoutSignal]) : timeoutSignal;
12198
+ try {
12199
+ const response = await fetchImpl(`${config.baseUrl}/v1/systemone`, {
12200
+ method: "POST",
12201
+ headers: {
12202
+ Authorization: `Bearer ${apiKey}`,
12203
+ "Content-Type": "application/json"
12204
+ },
12205
+ body: JSON.stringify({
12206
+ state: body.state,
12207
+ model: config.model,
12208
+ questions: body.questions
12209
+ }),
12210
+ signal
12211
+ });
12212
+ if (!response.ok) {
12213
+ await response.text().catch(() => "");
12214
+ const error = new TypeSafeTransportError(`TypeSafe request failed with HTTP ${response.status}`, "http", response.status);
12215
+ if (attempt < maxRetries && retryStatuses.has(response.status)) {
12216
+ lastError = error;
12217
+ await sleep(retryDelayMs(response, attempt));
12218
+ continue;
12219
+ }
12220
+ throw error;
12221
+ }
12222
+ const parsed = await response.json().catch(() => void 0);
12223
+ if (!isRecord(parsed) || !isRecord(parsed.answers)) throw new TypeSafeTransportError("TypeSafe returned an unreadable body", "malformed");
12224
+ const usage = isRecord(parsed.usage) ? parsed.usage : {};
12225
+ return {
12226
+ model: typeof parsed.model === "string" ? parsed.model : config.model,
12227
+ answers: parsed.answers,
12228
+ usage: {
12229
+ input_tokens: typeof usage.input_tokens === "number" ? usage.input_tokens : 0,
12230
+ output_tokens: typeof usage.output_tokens === "number" ? usage.output_tokens : 0
12231
+ }
12232
+ };
12233
+ } catch (error) {
12234
+ if (error instanceof TypeSafeTransportError) throw error;
12235
+ const kind = timeoutSignal.aborted ? "timeout" : options.signal?.aborted ? "aborted" : "http";
12236
+ lastError = new TypeSafeTransportError(kind === "timeout" ? `TypeSafe request exceeded ${timeoutMs}ms` : "TypeSafe request failed", kind, void 0, { cause: error });
12237
+ if (attempt >= maxRetries) throw lastError;
12238
+ }
12239
+ }
12240
+ throw lastError ?? new TypeSafeTransportError("TypeSafe request failed", "http");
12241
+ }
12242
+ async function probeConnection(config, fetchImpl = globalThis.fetch, timeoutMs = 3e3) {
12243
+ if (!config.configured || !config.apiKey) return false;
12244
+ try {
12245
+ const response = await fetchImpl(`${config.baseUrl}/v1/models`, {
12246
+ method: "GET",
12247
+ headers: { Authorization: `Bearer ${config.apiKey}` },
12248
+ signal: AbortSignal.timeout(timeoutMs)
12249
+ });
12250
+ await response.text().catch(() => "");
12251
+ return response.ok;
12252
+ } catch {
12253
+ return false;
12254
+ }
12255
+ }
12256
+ var INTENT_ROUTE_QUESTION_ID = "route";
12257
+ var INTENT_CODE_TASK_QUESTION_ID = "is_code_task";
12258
+ var MAX_INTENT_STATE_CHARS = 1e3;
12259
+ var ROUTE_INSTRUCTIONS = [
12260
+ "`utterance` is free text a developer typed into the message composer of a coding-agent chat app.",
12261
+ "`commands` lists the app's built-in commands, each with an `id`, a `what` description, and optional `args`.",
12262
+ "",
12263
+ "Decide whether the developer is asking the app to RUN one of those commands, or whether the text is an ordinary request for the coding agent.",
12264
+ "",
12265
+ "Rules:",
12266
+ "- Every command in `commands` only changes the app's own interface or the conversation session. None of them read, write, edit, run, or inspect code, files, tests, dependencies, or git.",
12267
+ "- If `utterance` asks for any work on code, files, tests, builds, dependencies, git, or the workspace, answer `none` \u2014 even when it also contains a word that appears in a command description.",
12268
+ "- Answer `none` when no command clearly matches what the developer wants, and when you are unsure.",
12269
+ "- Match the developer's intent, not a word the text happens to share with a description."
12270
+ ].join("\n");
12271
+ var CODE_TASK_INSTRUCTIONS = [
12272
+ "Does `utterance` ask for real engineering work on code, files, tests, builds, dependencies, git, or the workspace?",
12273
+ "Bug reports, feature requests, questions about the codebase, and refactors all count as yes.",
12274
+ "Requests about the app's own interface, the session, or the conversation do not count, even when they mention code:",
12275
+ "setting a goal, compacting the session, renaming a session, or changing how much reasoning the model uses are all no."
12276
+ ].join("\n");
12277
+ var CODE_TASK_CRITERIA = {
12278
+ true: "The developer wants engineering work done on code, files, tests, builds, dependencies, git, or the workspace.",
12279
+ false: "The developer wants the app's own interface or session acted on, or is making conversation."
12280
+ };
12281
+ function buildIntentState(text) {
12282
+ return {
12283
+ utterance: text.slice(0, MAX_INTENT_STATE_CHARS),
12284
+ commands: COMPOSER_INTENT_COMMANDS.map((command) => ({
12285
+ id: command.id,
12286
+ what: command.description,
12287
+ ...command.argumentHint ? { args: command.argumentHint } : {}
12288
+ }))
12289
+ };
12290
+ }
12291
+ function buildIntentQuestions() {
12292
+ const criteria = { [COMPOSER_INTENT_NONE]: "The text should be sent to the coding agent as an ordinary message." };
12293
+ for (const command of COMPOSER_INTENT_COMMANDS) criteria[command.id] = command.argumentHint ? `${command.description}. Arguments the developer may name: ${command.argumentHint}.` : command.description;
12294
+ const route = choice(ROUTE_INSTRUCTIONS, criteria);
12295
+ const codeTask = noul(CODE_TASK_INSTRUCTIONS, CODE_TASK_CRITERIA);
12296
+ return {
12297
+ [INTENT_ROUTE_QUESTION_ID]: route,
12298
+ [INTENT_CODE_TASK_QUESTION_ID]: codeTask
12299
+ };
12300
+ }
12301
+ function interpretIntentResult(result, draft) {
12302
+ const route = choiceAnswer(result, INTENT_ROUTE_QUESTION_ID);
12303
+ const codeTask = noulAnswer(result, INTENT_CODE_TASK_QUESTION_ID);
12304
+ if (!route) return {
12305
+ outcome: "none",
12306
+ reason: "no_match"
12307
+ };
12308
+ const confidence = typeof route.confidence === "number" ? route.confidence : 0;
12309
+ const codeTaskProbability = codeTask && typeof codeTask.noul === "number" ? codeTask.noul : 0;
12310
+ const decision = decideComposerIntent({
12311
+ command: route.choice,
12312
+ confidence,
12313
+ codeTaskProbability,
12314
+ requireConfirmation: isSingleTokenDraft(draft) || draft.trim().length > 1e3
12315
+ });
12316
+ if (decision.outcome === "none") return decision;
12317
+ if (!composerIntentCommand(decision.command.id)) return {
12318
+ outcome: "none",
12319
+ reason: "no_match"
12320
+ };
12321
+ return {
12322
+ ...decision,
12323
+ confidence,
12324
+ codeTaskProbability
12325
+ };
12326
+ }
12327
+ var CACHE_LIMIT = 48;
12328
+ var CACHE_TTL_MS = 3e5;
12329
+ var MIN_INTENT_CHARS = 4;
12330
+ var PROBE_TTL_MS = 3e5;
12331
+ function normalizeIntentText(text) {
12332
+ return text.trim().replace(/\s+/g, " ").toLowerCase();
12333
+ }
12334
+ function disabledResponse(enabled, reason) {
12335
+ return {
12336
+ enabled,
12337
+ outcome: "none",
12338
+ ...reason ? { reason } : {}
12339
+ };
12340
+ }
12341
+ function createTypeSafeService(options = {}) {
12342
+ const config = options.config ?? readTypeSafeConfig();
12343
+ const fetchImpl = options.fetch ?? ((...args) => globalThis.fetch(...args));
12344
+ const now2 = options.now ?? Date.now;
12345
+ const cache = /* @__PURE__ */ new Map();
12346
+ let probe;
12347
+ function readCache(key) {
12348
+ const entry = cache.get(key);
12349
+ if (!entry) return void 0;
12350
+ if (now2() - entry.at > CACHE_TTL_MS) {
12351
+ cache.delete(key);
12352
+ return;
12353
+ }
12354
+ return entry.response;
12355
+ }
12356
+ function writeCache(key, response) {
12357
+ cache.set(key, {
12358
+ response,
12359
+ at: now2()
12360
+ });
12361
+ while (cache.size > CACHE_LIMIT) {
12362
+ const oldest = cache.keys().next();
12363
+ if (oldest.done) break;
12364
+ cache.delete(oldest.value);
12365
+ }
12366
+ }
12367
+ return {
12368
+ configured: config.configured,
12369
+ model: config.model,
12370
+ async status() {
12371
+ if (!config.configured) return "unconfigured";
12372
+ if (probe && now2() - probe.at <= PROBE_TTL_MS) return probe.ok ? "ready" : "error";
12373
+ const ok = await probeConnection(config, fetchImpl);
12374
+ probe = {
12375
+ at: now2(),
12376
+ ok
12377
+ };
12378
+ return ok ? "ready" : "error";
12379
+ },
12380
+ async routeComposerIntent(request, enabled) {
12381
+ if (!enabled) return disabledResponse(false, "disabled");
12382
+ if (!config.configured) return disabledResponse(false, "disabled");
12383
+ const text = request.text.trim();
12384
+ if (text.length < MIN_INTENT_CHARS) return disabledResponse(true, "empty");
12385
+ if (text.startsWith("/")) return disabledResponse(true, "empty");
12386
+ const key = normalizeIntentText(text);
12387
+ const cached = readCache(key);
12388
+ if (cached) return cached;
12389
+ const startedAt = now2();
12390
+ try {
12391
+ const result = await postSystemOne(config, {
12392
+ state: buildIntentState(text),
12393
+ questions: buildIntentQuestions()
12394
+ }, {
12395
+ timeoutMs: config.intentTimeoutMs,
12396
+ maxRetries: config.intentMaxRetries,
12397
+ retryStatuses: TYPESAFE_RETRYABLE_STATUSES
12398
+ }, fetchImpl);
12399
+ const decision = interpretIntentResult(result, text);
12400
+ const response = decision.outcome === "matched" ? {
12401
+ enabled: true,
12402
+ outcome: "matched",
12403
+ command: decision.command.id,
12404
+ confidence: decision.confidence,
12405
+ disposition: decision.disposition,
12406
+ model: result.model,
12407
+ latencyMs: now2() - startedAt
12408
+ } : {
12409
+ enabled: true,
12410
+ outcome: "none",
12411
+ reason: decision.reason,
12412
+ confidence: decision.confidence,
12413
+ model: result.model,
12414
+ latencyMs: now2() - startedAt
12415
+ };
12416
+ writeCache(key, response);
12417
+ return response;
12418
+ } catch (error) {
12419
+ const rateLimited = error instanceof TypeSafeTransportError && error.status === 429;
12420
+ if (config.logLevel !== "off") {
12421
+ const kind = error instanceof TypeSafeTransportError ? error.kind : "unknown";
12422
+ process.stderr.write(`[typesafe] intent routing unavailable (${kind})
12423
+ `);
12424
+ }
12425
+ return disabledResponse(true, rateLimited ? "rate_limited" : "unavailable");
12426
+ }
12427
+ },
12428
+ resetCachesForTests() {
12429
+ cache.clear();
12430
+ probe = void 0;
12431
+ }
12432
+ };
12433
+ }
12434
+ var globalStore = globalThis;
12435
+ function getTypeSafeService() {
12436
+ if (!globalStore.__fleetTypeSafe) globalStore.__fleetTypeSafe = createTypeSafeService({ config: readTypeSafeConfig(process.env, readStoredTypeSafeKey()) });
12437
+ return globalStore.__fleetTypeSafe;
12438
+ }
12439
+ function resetTypeSafeService() {
12440
+ globalStore.__fleetTypeSafe = void 0;
12441
+ }
12442
+ async function composerIntentSettings() {
12443
+ const service = getTypeSafeService();
12444
+ return {
12445
+ enabled: (await readFleetSettings(getPrimeConfig().agentDir)).composerIntentEnabled,
12446
+ status: service.configured ? await service.status() : "unconfigured",
12447
+ keySource: typeSafeKeySource()
12448
+ };
12449
+ }
12450
+ function handleChatIntentGet(request) {
12451
+ return wrapApiHandler(async () => Response.json(await composerIntentSettings()), request);
12452
+ }
12453
+ function handleChatIntentPut(request) {
12454
+ return wrapApiHandler(async () => {
12455
+ const body = ComposerIntentCredentialSchema.parse(await request.json().catch(() => ({})));
12456
+ if (body.apiKey === null) clearStoredTypeSafeKey();
12457
+ else writeStoredTypeSafeKey(body.apiKey);
12458
+ resetTypeSafeService();
12459
+ return Response.json(await composerIntentSettings());
12460
+ }, request);
12461
+ }
12462
+ function handleChatIntentPatch(request) {
12463
+ return wrapApiHandler(async () => {
12464
+ const body = ComposerIntentSettingsUpdateSchema.parse(await request.json().catch(() => ({})));
12465
+ await updateFleetSettings(getPrimeConfig().agentDir, { composerIntentEnabled: body.enabled });
12466
+ return Response.json(await composerIntentSettings());
12467
+ }, request);
12468
+ }
12469
+ function handleChatIntentPost(request) {
12470
+ return wrapApiHandler(async () => {
12471
+ const body = ComposerIntentRequestSchema.parse(await request.json().catch(() => ({})));
12472
+ const service = getTypeSafeService();
12473
+ if (!service.configured) return Response.json({
12474
+ enabled: false,
12475
+ outcome: "none",
12476
+ reason: "disabled"
12477
+ });
12478
+ const settings = await readFleetSettings(getPrimeConfig().agentDir);
12479
+ const response = await service.routeComposerIntent(body, settings.composerIntentEnabled);
12480
+ return Response.json(response);
12481
+ }, request);
12482
+ }
9825
12483
  var PRIME_BUTTERFLY_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 178 178" aria-hidden="true"><path fill="currentColor" d="m 123.322,84.092671 c -0.192,0.0065 -0.43,0.0147 -0.74,0.0147 l -0.018,-0.0247 c -0.873,0.1977 -1.958,0.1266 -3.067,0.0537 -3.29,-0.216 -6.799,-0.4465 -5.635,6.2824 0.259,1.4822 -1.538,1.8465 -2.73,1.9082 -3.384,0.1853 -6.78,0.2594 -10.171,0.1915 -0.641,-0.0106 -1.2979,-0.5506 -1.8904,-1.0388 -0.1022,-0.0844 -0.2034,-0.1673 -0.3016,-0.2457 -0.1052,-0.0865 0.2898,-1.2042 0.4942,-1.2166 3.3078,-0.1931 4.5068,-2.4361 5.7028,-4.6724 0.603,-1.1253 1.204,-2.2488 2.072,-3.1088 7.856,-7.7874 15.878,-15.4265 25.054,-21.7008 0.895,-0.6114 1.989,-1.1733 2.73,-0.1111 0.571,0.8205 0.036,1.2854 -0.512,1.7627 -0.24,0.2088 -0.482,0.4199 -0.637,0.6642 -0.554,0.8792 -1.538,1.5273 -2.514,2.1717 -1.92,1.2655 -3.82,2.5172 -2.408,5.4798 1.225,2.5651 0.129,3.0202 -1.555,3.7198 l -0.069,0.0287 c -0.72,0.3021 -1.458,0.5764 -2.194,0.8506 -1.568,0.5835 -3.134,1.1662 -4.537,2.0149 -1.408,0.8522 -2.081,2.5134 0.222,3.4954 5.033,2.1428 18.064,-1.2784 20.608,-5.9965 2.377,-4.4147 5.931,-7.6891 9.481,-10.9611 1.992,-1.836 3.984,-3.6712 5.767,-5.7067 3.844,-4.3849 8.344,-8.1939 12.846,-12.005 2.239,-1.8944 4.478,-3.78938 6.637,-5.75588 1.624,-1.48207 2.297,-3.43353 1.026,-5.56412 -1.267,-2.118215 -3.416,-2.402287 -5.435,-1.926802 -13.309,3.130982 -26.166,7.355122 -37.585,15.241302 -18.23,12.5919 -36.4911,25.1406 -54.9002,37.4669 -6.2743,4.2056 -10.0723,2.1491 -12.1657,-5.1318 -4.6502,-16.1676 -11.4681,-30.2664 -31.0569,-32.4587 -7.1574,-0.8028 -12.4066,3.6807 -11.3692,10.7949 0.5249,3.6065 0.0495,7.003 -1.6858,10.3872 -0.3827,0.7472 -0.7689,1.4947 -1.1556,2.243 -2.672,5.1706 -5.3671,10.3857 -7.0394,15.8885 -0.1399,0.4602 -0.3002,0.9444 -0.4654,1.4437 -1.4909,4.5052 -3.3862,10.2323 5.659,10.5492 0.3705,0.0123 1.0808,0.944799 0.9943,1.290699 -0.1976,0.8213 -0.5991,1.797 -1.2413,2.2725 -8.6705,6.3917 -15.79706,14.1294 -18.860151,24.5971 -1.550066,5.2865 -0.524909,10.7765 3.989391,14.8705 3.22984,2.928 7.35516,4.625 10.97396,2.162 3.3009,-2.247 6.9232,-3.754 10.538,-5.259 3.1819,-1.324 6.358,-2.646 9.3041,-4.468 0.7101,-0.439 1.5727,-0.841 2.4456,-1.248 2.4138,-1.1228 4.9063,-2.2843 4.4709,-4.3841 -0.6854,-3.2908 -4.1623,-6.3418 -7.0586,-8.7384 -2.8716,-2.3769 -10.1897,-18.3411 -9.3189,-22.176099 1.2193,-5.3704 3.9645,-10.0201 6.7125,-14.6744 2.3458,-3.9731 4.6935,-7.9497 6.0956,-12.3806 0.5804,-1.828 2.8037,-2.8284 4.9466,-2.0997 1.4543,0.4928 1.2068,1.8278 0.9762,3.0715 -0.0063,0.0344 -0.0127,0.0685 -0.019,0.1027 -0.8688,4.7802 -1.721,9.566 -2.5733,14.3517 -0.4261,2.3924 -0.8521,4.7847 -1.2803,7.1762 -0.2717,1.5316 0.2038,2.7544 1.7909,3.0631 3.0569,0.599 2.989,1.9762 1.6119,4.341499 -1.4636,2.5072 -1.6674,5.5703 -0.0309,7.8861 1.6427,2.3282 4.3908,2.8161 7.1821,1.4204 1.7415,-0.8646 3.094,-0.0927 3.0755,1.6612 -0.1112,9.3688 3.8103,7.2561 8.584,3.1681 0.439,-0.3763 1.0373,-0.5846 1.6152,-0.7857 0.1048,-0.0366 0.2091,-0.0728 0.3116,-0.1098 0.4529,-0.1616 0.9062,-0.3224 1.3595,-0.4833 8.986,-3.1884 17.9603,-6.3725 23.0334,-15.573099 0.392,-0.7187 1.6783,-1.0669 2.6795,-1.3377 0.057,-0.0154 0.113,-0.0307 0.1681,-0.0456 5.8013,-1.5766 11.7248,-1.6001 17.6438,-1.6237 4.445,-0.0176 8.888,-0.0352 13.277,-0.7107 4.329,-0.667 9.047,-3.1928 9.084,-7.3736 0.035,-3.3707 -2.546,-3.1612 -5.123,-2.9519 -1.115,0.0906 -2.231,0.1811 -3.134,-0.0185 -0.182,-0.0381 -0.375,-0.0316 -0.686,-0.0209 z"/><path fill="currentColor" d="m 55.1325,131.29447 c -1.0745,7.1515 1.6551,13.2715 12.8266,13.1915 h -0.0062 c 9.5413,-0.389 20.3365,-6.164 30.8838,-13.5492 6.9653,-4.8787 12.9873,-10.0236 16.8903,-17.6253 2.872,-5.5889 1.395,-10.0723 -2.933,-13.993799 -1.908,-1.7291 -3.73,-1.9205 -5.867,0.1667 -7.5842,7.423099 -17.0261,11.474299 -26.7218,15.550099 -2.4706,1.0393 -5.2847,1.5582 -8.1187,2.0809 -7.5511,1.3924 -15.2431,2.8103 -16.954,14.1791 z"/></svg>`;
9826
12484
  function escapeHtml(value) {
9827
12485
  return value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
@@ -39274,75 +41932,6 @@ function handleChatSessionDelete(request) {
39274
41932
  });
39275
41933
  }, request);
39276
41934
  }
39277
- function stringValue(value) {
39278
- return typeof value === "string" && value.length > 0 ? value : void 0;
39279
- }
39280
- function timestampValue(value) {
39281
- if (value instanceof Date) return value.toISOString();
39282
- return stringValue(value);
39283
- }
39284
- function messageCountValue(value) {
39285
- return typeof value === "number" && Number.isFinite(value) && value >= 0 ? Math.trunc(value) : 0;
39286
- }
39287
- function normalizeSessionListRow(source) {
39288
- const raw = source;
39289
- const sessionId = stringValue(raw.sessionId) ?? stringValue(raw.id);
39290
- const cwd = stringValue(raw.cwd);
39291
- if (!sessionId || !cwd) throw new Error("The Prime Agent session listing returned an invalid session entry");
39292
- const createdAt = timestampValue(raw.created) ?? timestampValue(raw.modified) ?? (/* @__PURE__ */ new Date()).toISOString();
39293
- const updatedAt = timestampValue(raw.modified) ?? timestampValue(raw.created) ?? createdAt;
39294
- const isSubagent = typeof raw.runtimeKind === "string" ? raw.runtimeKind === "subagent" : Boolean(raw.rlmChildId ?? raw.rlmParentNodeId ?? raw.parentActiveSessionId ?? raw.parentSessionId ?? raw.parentSessionPath);
39295
- return {
39296
- source,
39297
- sessionId,
39298
- cwd,
39299
- title: meaningfulSessionLabel(stringValue(raw.sessionName) ?? stringValue(raw.name)),
39300
- createdAt,
39301
- updatedAt,
39302
- messageCount: messageCountValue(raw.messageCount),
39303
- firstMessage: meaningfulSessionLabel(typeof raw.firstMessage === "string" ? raw.firstMessage : void 0) ?? "",
39304
- isSubagent
39305
- };
39306
- }
39307
- function sessionSourcePath(source) {
39308
- const raw = source;
39309
- return stringValue(raw.sessionFile) ?? stringValue(raw.path);
39310
- }
39311
- function latestBy(entries, time2) {
39312
- if (entries.length === 0) return void 0;
39313
- return entries.reduce((latest, entry) => time2(entry) >= time2(latest) ? entry : latest);
39314
- }
39315
- function presentationListActivity(presentation) {
39316
- if (!presentation) return { activityCount: 0 };
39317
- const artifacts = presentation.artifactRuns.flatMap((run) => run.artifacts);
39318
- const latestRefinement = latestBy(presentation.refinements, (entry) => entry.timestamp);
39319
- const latestArtifact = latestBy(artifacts, (entry) => entry.timestamp);
39320
- const latestBash = latestBy(presentation.userBash, (entry) => entry.startedAt);
39321
- return {
39322
- title: meaningfulSessionLabel(presentation.sessionName) ?? meaningfulSessionLabel(latestRefinement?.summary) ?? meaningfulSessionLabel(latestArtifact?.title) ?? meaningfulSessionLabel(latestBash?.command),
39323
- activityCount: presentation.refinements.length + artifacts.length + presentation.userBash.length
39324
- };
39325
- }
39326
- function applyPresentationToSessionRow(row, presentation) {
39327
- const { title: presentationTitle, activityCount } = presentationListActivity(presentation);
39328
- const firstMessage = row.firstMessage || presentationTitle || "";
39329
- return {
39330
- title: row.title ?? meaningfulSessionLabel(firstMessage) ?? presentationTitle ?? fallbackSessionLabel(row.sessionId),
39331
- firstMessage,
39332
- messageCount: row.messageCount > 0 ? row.messageCount : activityCount > 0 ? 1 : 0
39333
- };
39334
- }
39335
- function sessionNeedsPresentationJoin(row) {
39336
- return row.messageCount === 0 || !row.title || !row.firstMessage;
39337
- }
39338
- async function loadSessionListPresentation(row, source, livePresentation) {
39339
- const liveActivity = presentationListActivity(livePresentation);
39340
- if (liveActivity.activityCount > 0 || liveActivity.title) return livePresentation;
39341
- if (!sessionNeedsPresentationJoin(row)) return livePresentation;
39342
- const path = sessionSourcePath(source);
39343
- if (!path) return livePresentation;
39344
- return await loadManagedPrimePresentation({ sessionPath: path }) ?? livePresentation;
39345
- }
39346
41935
  function sessionStatus(info, live) {
39347
41936
  if (live?.isStreaming || live?.session?.isStreaming || info.isStreaming) return "running";
39348
41937
  if (info.activity === "working" && (info.isSessionActive || info.hasRunningRlmChildren === true)) return "running";
@@ -39560,6 +42149,54 @@ function handleHealthGet(request) {
39560
42149
  });
39561
42150
  }, request);
39562
42151
  }
42152
+ async function requireReadableSession(sessionId) {
42153
+ const bridge = getBridge();
42154
+ const session = bridge.getSession(sessionId) ?? await bridge.resumeSessionById(sessionId);
42155
+ if (!await requireProjectSession(session)) return {
42156
+ ok: false,
42157
+ response: Response.json({ message: `Unknown session: ${sessionId}` }, { status: 404 })
42158
+ };
42159
+ return {
42160
+ ok: true,
42161
+ session
42162
+ };
42163
+ }
42164
+ async function requireWritableSession(sessionId) {
42165
+ const access = await requireReadableSession(sessionId);
42166
+ if (!access.ok) return access;
42167
+ const { session } = access;
42168
+ if (session?.isStreaming) return {
42169
+ ok: false,
42170
+ response: Response.json({ message: new SessionTreeBusyError().message }, { status: 409 })
42171
+ };
42172
+ return access;
42173
+ }
42174
+ function handleChatSessionTreeGet(request) {
42175
+ return wrapApiHandler(async () => {
42176
+ const sessionId = new URL(request.url).searchParams.get("sessionId");
42177
+ if (!sessionId) return Response.json({ message: "GET /api/chat/session-tree requires ?sessionId=" }, { status: 400 });
42178
+ const parsedSessionId = SessionIdSchema.safeParse(sessionId);
42179
+ if (!parsedSessionId.success) return Response.json({ message: "Invalid session id" }, { status: 400 });
42180
+ const access = await requireReadableSession(parsedSessionId.data);
42181
+ if (!access.ok) return access.response;
42182
+ const snapshot2 = await getBridge().readSessionTreeSnapshot(parsedSessionId.data);
42183
+ return Response.json(SessionTreeSnapshotResponseSchema.parse({ snapshot: snapshot2 }));
42184
+ }, request);
42185
+ }
42186
+ function handleChatSessionTreeNavigatePost(request) {
42187
+ return wrapApiHandler(async () => {
42188
+ const body = SessionTreeNavigateRequestSchema.parse(await request.json().catch(() => ({})));
42189
+ const access = await requireWritableSession(body.sessionId);
42190
+ if (!access.ok) return access.response;
42191
+ try {
42192
+ const snapshot2 = await getBridge().navigateSessionTree(body.sessionId, body.targetEntryId, body.expectedLeafId);
42193
+ return Response.json(SessionTreeNavigateResponseSchema.parse({ snapshot: snapshot2 }));
42194
+ } catch (error) {
42195
+ if (error instanceof SessionTreeConcurrencyError || error instanceof SessionTreeCancelledError) return Response.json({ message: error.message }, { status: error.status });
42196
+ throw error;
42197
+ }
42198
+ }, request);
42199
+ }
39563
42200
  function canonicalizePath(path) {
39564
42201
  try {
39565
42202
  return realpathSync(path);
@@ -39761,40 +42398,51 @@ function handleWorkspaceTreeGet(_request) {
39761
42398
  });
39762
42399
  }, _request);
39763
42400
  }
39764
- var Route$24 = createFileRoute("/api/chat")({ server: { handlers: { POST: ({ request }) => handleChatPost(request) } } });
39765
- var Route$23 = createFileRoute("/api/health")({ server: { handlers: { GET: ({ request }) => handleHealthGet(request) } } });
39766
- var Route$22 = createFileRoute("/api/projects")({ server: { handlers: {
42401
+ var Route$27 = createFileRoute("/api/chat")({ server: { handlers: { POST: ({ request }) => handleChatPost(request) } } });
42402
+ var Route$26 = createFileRoute("/api/health")({ server: { handlers: { GET: ({ request }) => handleHealthGet(request) } } });
42403
+ var Route$25 = createFileRoute("/api/projects")({ server: { handlers: {
39767
42404
  DELETE: ({ request }) => handleProjectDelete(request),
39768
42405
  GET: ({ request }) => handleProjectsGet(request),
39769
42406
  PATCH: ({ request }) => handleProjectPatch(request),
39770
42407
  POST: ({ request }) => handleProjectsPost(request)
39771
42408
  } } });
39772
- var Route$21 = createFileRoute("/api/chat/abort")({ server: { handlers: { POST: ({ request }) => handleChatAbortPost(request) } } });
39773
- var Route$20 = createFileRoute("/api/chat/artifacts")({ server: { handlers: { PUT: ({ request }) => handleChatOpenUIArtifactPut(request) } } });
39774
- var Route$19 = createFileRoute("/api/chat/command")({ server: { handlers: { POST: ({ request }) => handleChatCommandPost(request) } } });
39775
- var Route$18 = createFileRoute("/api/chat/commands")({ server: { handlers: { GET: ({ request }) => handleChatCommandsGet(request) } } });
39776
- var Route$17 = createFileRoute("/api/chat/events")({ server: { handlers: { GET: ({ request }) => handleChatEventsGet(request) } } });
39777
- var Route$16 = createFileRoute("/api/chat/mcp")({ server: { handlers: {
42409
+ var Route$24 = createFileRoute("/api/chat/abort")({ server: { handlers: { POST: ({ request }) => handleChatAbortPost(request) } } });
42410
+ var Route$23 = createFileRoute("/api/chat/artifacts")({ server: { handlers: { PUT: ({ request }) => handleChatOpenUIArtifactPut(request) } } });
42411
+ var Route$22 = createFileRoute("/api/chat/command")({ server: { handlers: { POST: ({ request }) => handleChatCommandPost(request) } } });
42412
+ var Route$21 = createFileRoute("/api/chat/commands")({ server: { handlers: { GET: ({ request }) => handleChatCommandsGet(request) } } });
42413
+ var Route$20 = createFileRoute("/api/chat/completion")({ server: { handlers: { POST: ({ request }) => handleChatCompletionPost(request) } } });
42414
+ var Route$19 = createFileRoute("/api/chat/events")({ server: { handlers: { GET: ({ request }) => handleChatEventsGet(request) } } });
42415
+ var Route$18 = createFileRoute("/api/chat/intent")({ server: { handlers: {
42416
+ GET: ({ request }) => handleChatIntentGet(request),
42417
+ PATCH: ({ request }) => handleChatIntentPatch(request),
42418
+ POST: ({ request }) => handleChatIntentPost(request),
42419
+ PUT: ({ request }) => handleChatIntentPut(request)
42420
+ } } });
42421
+ var Route$17 = createFileRoute("/api/chat/mcp")({ server: { handlers: {
39778
42422
  GET: ({ request }) => handleChatMcpGet(request),
39779
42423
  POST: ({ request }) => handleChatMcpPost(request),
39780
42424
  DELETE: ({ request }) => handleChatMcpDelete(request)
39781
42425
  } } });
39782
- var Route$15 = createFileRoute("/api/chat/models")({ server: { handlers: { GET: ({ request }) => handleChatModelsGet(request) } } });
39783
- var Route$14 = createFileRoute("/api/chat/new")({ server: { handlers: { POST: ({ request }) => handleChatNewPost(request) } } });
39784
- var Route$13 = createFileRoute("/api/chat/providers")({ server: { handlers: {
42426
+ var Route$16 = createFileRoute("/api/chat/models")({ server: { handlers: { GET: ({ request }) => handleChatModelsGet(request) } } });
42427
+ var Route$15 = createFileRoute("/api/chat/new")({ server: { handlers: { POST: ({ request }) => handleChatNewPost(request) } } });
42428
+ var Route$14 = createFileRoute("/api/chat/providers")({ server: { handlers: {
39785
42429
  GET: ({ request }) => handleChatProvidersGet(request),
39786
42430
  POST: ({ request }) => handleChatProvidersPost(request),
39787
42431
  DELETE: ({ request }) => handleChatProvidersDelete(request)
39788
42432
  } } });
39789
- var Route$12 = createFileRoute("/api/chat/question")({ server: { handlers: { POST: ({ request }) => handleChatQuestionPost(request) } } });
39790
- var Route$11 = createFileRoute("/api/chat/resources")({ server: { handlers: { GET: ({ request }) => handleChatResourcesGet(request) } } });
39791
- var Route$10 = createFileRoute("/api/chat/resume")({ server: { handlers: { POST: ({ request }) => handleChatResumePost(request) } } });
39792
- var Route$9 = createFileRoute("/api/chat/session")({ server: { handlers: {
42433
+ var Route$13 = createFileRoute("/api/chat/question")({ server: { handlers: { POST: ({ request }) => handleChatQuestionPost(request) } } });
42434
+ var Route$12 = createFileRoute("/api/chat/resources")({ server: { handlers: { GET: ({ request }) => handleChatResourcesGet(request) } } });
42435
+ var Route$11 = createFileRoute("/api/chat/resume")({ server: { handlers: { POST: ({ request }) => handleChatResumePost(request) } } });
42436
+ var Route$10 = createFileRoute("/api/chat/session")({ server: { handlers: {
39793
42437
  GET: ({ request }) => new URL(request.url).searchParams.has("attachmentId") ? handleChatAttachmentGet(request) : handleChatSessionGet(request),
39794
42438
  POST: ({ request }) => handleChatAttachmentsPost(request),
39795
42439
  PUT: ({ request }) => handleChatPlanPresentationPut(request),
39796
42440
  PATCH: ({ request }) => handleChatQueueMutationPost(request)
39797
42441
  } } });
42442
+ var Route$9 = createFileRoute("/api/chat/session-tree")({ server: { handlers: {
42443
+ GET: ({ request }) => handleChatSessionTreeGet(request),
42444
+ POST: ({ request }) => handleChatSessionTreeNavigatePost(request)
42445
+ } } });
39798
42446
  var Route$8 = createFileRoute("/api/chat/sessions")({ server: { handlers: {
39799
42447
  DELETE: ({ request }) => handleChatSessionDelete(request),
39800
42448
  GET: ({ request }) => handleChatSessionsGet(request),
@@ -39811,91 +42459,106 @@ var Route$3 = createFileRoute("/api/workspace/tree")({ server: { handlers: { GET
39811
42459
  var Route$2 = createFileRoute("/api/chat/mcp/oauth")({ server: { handlers: { POST: ({ request }) => handleChatMcpOAuthPost(request) } } });
39812
42460
  var Route$1 = createFileRoute("/api/chat/models/discover")({ server: { handlers: { POST: ({ request }) => handleChatModelsDiscoverPost(request) } } });
39813
42461
  var Route = createFileRoute("/api/chat/providers/oauth")({ server: { handlers: { POST: ({ request }) => handleChatProvidersOAuthPost(request) } } });
39814
- var IndexRoute = Route$25.update({
42462
+ var IndexRoute = Route$28.update({
39815
42463
  id: "/",
39816
42464
  path: "/",
39817
- getParentRoute: () => Route$26
42465
+ getParentRoute: () => Route$29
39818
42466
  });
39819
- var ApiChatRoute = Route$24.update({
42467
+ var ApiChatRoute = Route$27.update({
39820
42468
  id: "/api/chat",
39821
42469
  path: "/api/chat",
39822
- getParentRoute: () => Route$26
42470
+ getParentRoute: () => Route$29
39823
42471
  });
39824
- var ApiHealthRoute = Route$23.update({
42472
+ var ApiHealthRoute = Route$26.update({
39825
42473
  id: "/api/health",
39826
42474
  path: "/api/health",
39827
- getParentRoute: () => Route$26
42475
+ getParentRoute: () => Route$29
39828
42476
  });
39829
- var ApiProjectsRoute = Route$22.update({
42477
+ var ApiProjectsRoute = Route$25.update({
39830
42478
  id: "/api/projects",
39831
42479
  path: "/api/projects",
39832
- getParentRoute: () => Route$26
42480
+ getParentRoute: () => Route$29
39833
42481
  });
39834
- var ApiChatAbortRoute = Route$21.update({
42482
+ var ApiChatAbortRoute = Route$24.update({
39835
42483
  id: "/abort",
39836
42484
  path: "/abort",
39837
42485
  getParentRoute: () => ApiChatRoute
39838
42486
  });
39839
- var ApiChatArtifactsRoute = Route$20.update({
42487
+ var ApiChatArtifactsRoute = Route$23.update({
39840
42488
  id: "/artifacts",
39841
42489
  path: "/artifacts",
39842
42490
  getParentRoute: () => ApiChatRoute
39843
42491
  });
39844
- var ApiChatCommandRoute = Route$19.update({
42492
+ var ApiChatCommandRoute = Route$22.update({
39845
42493
  id: "/command",
39846
42494
  path: "/command",
39847
42495
  getParentRoute: () => ApiChatRoute
39848
42496
  });
39849
- var ApiChatCommandsRoute = Route$18.update({
42497
+ var ApiChatCommandsRoute = Route$21.update({
39850
42498
  id: "/commands",
39851
42499
  path: "/commands",
39852
42500
  getParentRoute: () => ApiChatRoute
39853
42501
  });
39854
- var ApiChatEventsRoute = Route$17.update({
42502
+ var ApiChatCompletionRoute = Route$20.update({
42503
+ id: "/completion",
42504
+ path: "/completion",
42505
+ getParentRoute: () => ApiChatRoute
42506
+ });
42507
+ var ApiChatEventsRoute = Route$19.update({
39855
42508
  id: "/events",
39856
42509
  path: "/events",
39857
42510
  getParentRoute: () => ApiChatRoute
39858
42511
  });
39859
- var ApiChatMcpRoute = Route$16.update({
42512
+ var ApiChatIntentRoute = Route$18.update({
42513
+ id: "/intent",
42514
+ path: "/intent",
42515
+ getParentRoute: () => ApiChatRoute
42516
+ });
42517
+ var ApiChatMcpRoute = Route$17.update({
39860
42518
  id: "/mcp",
39861
42519
  path: "/mcp",
39862
42520
  getParentRoute: () => ApiChatRoute
39863
42521
  });
39864
- var ApiChatModelsRoute = Route$15.update({
42522
+ var ApiChatModelsRoute = Route$16.update({
39865
42523
  id: "/models",
39866
42524
  path: "/models",
39867
42525
  getParentRoute: () => ApiChatRoute
39868
42526
  });
39869
- var ApiChatNewRoute = Route$14.update({
42527
+ var ApiChatNewRoute = Route$15.update({
39870
42528
  id: "/new",
39871
42529
  path: "/new",
39872
42530
  getParentRoute: () => ApiChatRoute
39873
42531
  });
39874
- var ApiChatProvidersRoute = Route$13.update({
42532
+ var ApiChatProvidersRoute = Route$14.update({
39875
42533
  id: "/providers",
39876
42534
  path: "/providers",
39877
42535
  getParentRoute: () => ApiChatRoute
39878
42536
  });
39879
- var ApiChatQuestionRoute = Route$12.update({
42537
+ var ApiChatQuestionRoute = Route$13.update({
39880
42538
  id: "/question",
39881
42539
  path: "/question",
39882
42540
  getParentRoute: () => ApiChatRoute
39883
42541
  });
39884
- var ApiChatResourcesRoute = Route$11.update({
42542
+ var ApiChatResourcesRoute = Route$12.update({
39885
42543
  id: "/resources",
39886
42544
  path: "/resources",
39887
42545
  getParentRoute: () => ApiChatRoute
39888
42546
  });
39889
- var ApiChatResumeRoute = Route$10.update({
42547
+ var ApiChatResumeRoute = Route$11.update({
39890
42548
  id: "/resume",
39891
42549
  path: "/resume",
39892
42550
  getParentRoute: () => ApiChatRoute
39893
42551
  });
39894
- var ApiChatSessionRoute = Route$9.update({
42552
+ var ApiChatSessionRoute = Route$10.update({
39895
42553
  id: "/session",
39896
42554
  path: "/session",
39897
42555
  getParentRoute: () => ApiChatRoute
39898
42556
  });
42557
+ var ApiChatSessionTreeRoute = Route$9.update({
42558
+ id: "/session-tree",
42559
+ path: "/session-tree",
42560
+ getParentRoute: () => ApiChatRoute
42561
+ });
39899
42562
  var ApiChatSessionsRoute = Route$8.update({
39900
42563
  id: "/sessions",
39901
42564
  path: "/sessions",
@@ -39919,12 +42582,12 @@ var ApiProjectsForkRoute = Route$5.update({
39919
42582
  var ApiWorkspaceFileRoute = Route$4.update({
39920
42583
  id: "/api/workspace/file",
39921
42584
  path: "/api/workspace/file",
39922
- getParentRoute: () => Route$26
42585
+ getParentRoute: () => Route$29
39923
42586
  });
39924
42587
  var ApiWorkspaceTreeRoute = Route$3.update({
39925
42588
  id: "/api/workspace/tree",
39926
42589
  path: "/api/workspace/tree",
39927
- getParentRoute: () => Route$26
42590
+ getParentRoute: () => Route$29
39928
42591
  });
39929
42592
  var ApiChatMcpOauthRoute = Route$2.update({
39930
42593
  id: "/oauth",
@@ -39951,7 +42614,9 @@ var ApiChatRouteChildren = {
39951
42614
  ApiChatArtifactsRoute,
39952
42615
  ApiChatCommandRoute,
39953
42616
  ApiChatCommandsRoute,
42617
+ ApiChatCompletionRoute,
39954
42618
  ApiChatEventsRoute,
42619
+ ApiChatIntentRoute,
39955
42620
  ApiChatMcpRoute: ApiChatMcpRouteWithChildren,
39956
42621
  ApiChatModelsRoute: ApiChatModelsRouteWithChildren,
39957
42622
  ApiChatNewRoute,
@@ -39960,6 +42625,7 @@ var ApiChatRouteChildren = {
39960
42625
  ApiChatResourcesRoute,
39961
42626
  ApiChatResumeRoute,
39962
42627
  ApiChatSessionRoute,
42628
+ ApiChatSessionTreeRoute,
39963
42629
  ApiChatSessionsRoute,
39964
42630
  ApiChatSettingsRoute
39965
42631
  };
@@ -39976,7 +42642,7 @@ var rootRouteChildren = {
39976
42642
  ApiWorkspaceFileRoute,
39977
42643
  ApiWorkspaceTreeRoute
39978
42644
  };
39979
- var routeTree = Route$26._addFileChildren(rootRouteChildren)._addFileTypes();
42645
+ var routeTree = Route$29._addFileChildren(rootRouteChildren)._addFileTypes();
39980
42646
  function getRouter() {
39981
42647
  return createRouter({
39982
42648
  routeTree,