@truefoundry/trueforge 0.2.0-rc.5 → 0.2.0-rc.7

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 (212) hide show
  1. package/dist/_frontend/assets/{AgentCodeSnippets-V5A56M7R-ZCh9CtX_.js → AgentCodeSnippets-UWKIJI6U-BuMY_5q9.js} +1 -1
  2. package/dist/_frontend/assets/AgentCodeSnippets-UWKIJI6U-BuMY_5q9.js.br +0 -0
  3. package/dist/_frontend/assets/AgentCodeSnippets-UWKIJI6U-BuMY_5q9.js.gz +0 -0
  4. package/dist/_frontend/assets/AgentMetricChart-4ZJJED5Q-Ck2gd1mC.js +1 -0
  5. package/dist/_frontend/assets/AgentMetricChart-4ZJJED5Q-Ck2gd1mC.js.br +0 -0
  6. package/dist/_frontend/assets/AgentMetricChart-4ZJJED5Q-Ck2gd1mC.js.gz +0 -0
  7. package/dist/_frontend/assets/AgentOverview-UZBCVNMP-EMNirCRT.js +1 -0
  8. package/dist/_frontend/assets/AgentOverview-UZBCVNMP-EMNirCRT.js.br +0 -0
  9. package/dist/_frontend/assets/AgentOverview-UZBCVNMP-EMNirCRT.js.gz +0 -0
  10. package/dist/_frontend/assets/{AgentSessionEventTimeline-UUXOJXTC-Nk5ZgtJk.js → AgentSessionEventTimeline-N4RXG2NU-JgVOEYK9.js} +1 -1
  11. package/dist/_frontend/assets/AgentSessionEventTimeline-N4RXG2NU-JgVOEYK9.js.br +0 -0
  12. package/dist/_frontend/assets/AgentSessionEventTimeline-N4RXG2NU-JgVOEYK9.js.gz +0 -0
  13. package/dist/_frontend/assets/{AgentSessionEventTimelineChart-FIAQCYJC-TBWekOBI.js → AgentSessionEventTimelineChart-EMWNJMMK-BRwdPd5w.js} +1 -1
  14. package/dist/_frontend/assets/AgentSessionEventTimelineChart-EMWNJMMK-BRwdPd5w.js.br +0 -0
  15. package/dist/_frontend/assets/AgentSessionEventTimelineChart-EMWNJMMK-BRwdPd5w.js.gz +0 -0
  16. package/dist/_frontend/assets/{AgentSessions-WHODEG2M-OzQblCn4.js → AgentSessions-CD7JAQTC-BXh1e6-3.js} +1 -1
  17. package/dist/_frontend/assets/AgentSessions-CD7JAQTC-BXh1e6-3.js.br +0 -0
  18. package/dist/_frontend/assets/AgentSessions-CD7JAQTC-BXh1e6-3.js.gz +0 -0
  19. package/dist/_frontend/assets/{ConnectorSettings-QTAI4TQX-PySj_xEm.js → ConnectorSettings-GEI4S6SD-BUjOgTQp.js} +1 -1
  20. package/dist/_frontend/assets/ConnectorSettings-GEI4S6SD-BUjOgTQp.js.br +0 -0
  21. package/dist/_frontend/assets/ConnectorSettings-GEI4S6SD-BUjOgTQp.js.gz +0 -0
  22. package/dist/_frontend/assets/{DockLayout-TATYU5SV-DAuT7yes.js → DockLayout-JZ4DKDOR-jsSVZPx1.js} +1 -1
  23. package/dist/_frontend/assets/{DrawerLayout-DXHNV33K-BP-6TUEf.js → DrawerLayout-AV4FJTGV-DoyHvbgS.js} +2 -2
  24. package/dist/_frontend/assets/DrawerLayout-AV4FJTGV-DoyHvbgS.js.br +0 -0
  25. package/dist/_frontend/assets/DrawerLayout-AV4FJTGV-DoyHvbgS.js.gz +0 -0
  26. package/dist/_frontend/assets/{ModelSettings-UWTBHQRG-L5KYrHBM.js → ModelSettings-4TNETPJJ-1PfEncEw.js} +1 -1
  27. package/dist/_frontend/assets/ModelSettings-4TNETPJJ-1PfEncEw.js.br +0 -0
  28. package/dist/_frontend/assets/ModelSettings-4TNETPJJ-1PfEncEw.js.gz +0 -0
  29. package/dist/_frontend/assets/SandboxSettings-IEIWFKQW-DMx0nXkz.js +1 -0
  30. package/dist/_frontend/assets/SandboxSettings-IEIWFKQW-DMx0nXkz.js.br +0 -0
  31. package/dist/_frontend/assets/SandboxSettings-IEIWFKQW-DMx0nXkz.js.gz +0 -0
  32. package/dist/_frontend/assets/SchedulesPage-ZG5IMQI3-DM9Xo4uZ.js +1 -0
  33. package/dist/_frontend/assets/SchedulesPage-ZG5IMQI3-DM9Xo4uZ.js.br +0 -0
  34. package/dist/_frontend/assets/SchedulesPage-ZG5IMQI3-DM9Xo4uZ.js.gz +0 -0
  35. package/dist/_frontend/assets/{SettingsBuilder-3OA4UCIM-AN2PJd1q.js → SettingsBuilder-B2ULQPIT-D67kXI0z.js} +2 -2
  36. package/dist/_frontend/assets/SettingsBuilder-B2ULQPIT-D67kXI0z.js.br +0 -0
  37. package/dist/_frontend/assets/SettingsBuilder-B2ULQPIT-D67kXI0z.js.gz +0 -0
  38. package/dist/_frontend/assets/{ShellRouteSync-J74MV23Q-CDk4uzrR.js → ShellRouteSync-SJXFKUAJ-BhQD7AoV.js} +1 -1
  39. package/dist/_frontend/assets/ShellRouteSync-SJXFKUAJ-BhQD7AoV.js.br +0 -0
  40. package/dist/_frontend/assets/ShellRouteSync-SJXFKUAJ-BhQD7AoV.js.gz +0 -0
  41. package/dist/_frontend/assets/{SidebarLayout-EQXQPYIU-zWCTPIcp.js → SidebarLayout-XUM2Y6PA-BQdDTrNi.js} +2 -2
  42. package/dist/_frontend/assets/SidebarLayout-XUM2Y6PA-BQdDTrNi.js.br +0 -0
  43. package/dist/_frontend/assets/SidebarLayout-XUM2Y6PA-BQdDTrNi.js.gz +0 -0
  44. package/dist/_frontend/assets/{SkillSettings-KQ6GQ7JW-oZVHsKV_.js → SkillSettings-NHBL5ZXU-BmInxxan.js} +1 -1
  45. package/dist/_frontend/assets/SkillSettings-NHBL5ZXU-BmInxxan.js.br +0 -0
  46. package/dist/_frontend/assets/SkillSettings-NHBL5ZXU-BmInxxan.js.gz +0 -0
  47. package/dist/_frontend/assets/TrueForgeUIWithRouter-NVV7IXXP-DBsGykLD.js +1 -0
  48. package/dist/_frontend/assets/{WidgetLayout-YWZTYFZL-BgYVWW8O.js → WidgetLayout-T7DBLKV3-CfF0xPJV.js} +1 -1
  49. package/dist/_frontend/assets/WidgetLayout-T7DBLKV3-CfF0xPJV.js.br +0 -0
  50. package/dist/_frontend/assets/WidgetLayout-T7DBLKV3-CfF0xPJV.js.gz +0 -0
  51. package/dist/_frontend/assets/{chunk-4MCIDE2C-ClJFqC75.js → chunk-2QTH6JHX-DIiHfgUm.js} +1 -1
  52. package/dist/_frontend/assets/chunk-2QTH6JHX-DIiHfgUm.js.br +0 -0
  53. package/dist/_frontend/assets/chunk-2QTH6JHX-DIiHfgUm.js.gz +0 -0
  54. package/dist/_frontend/assets/chunk-3R62ISBR-CDV8LPCs.js +1 -0
  55. package/dist/_frontend/assets/chunk-3R62ISBR-CDV8LPCs.js.br +0 -0
  56. package/dist/_frontend/assets/chunk-3R62ISBR-CDV8LPCs.js.gz +0 -0
  57. package/dist/_frontend/assets/{chunk-62JRHF6Z-CXLsU_my.js → chunk-62JRHF6Z-bd9_iLmQ.js} +1 -1
  58. package/dist/_frontend/assets/chunk-62JRHF6Z-bd9_iLmQ.js.br +0 -0
  59. package/dist/_frontend/assets/chunk-62JRHF6Z-bd9_iLmQ.js.gz +0 -0
  60. package/dist/_frontend/assets/{chunk-ZZB3JIBQ-EN4V28Ji.js → chunk-NFUX2ESW-D-OknU8a.js} +2 -2
  61. package/dist/_frontend/assets/chunk-NFUX2ESW-D-OknU8a.js.br +0 -0
  62. package/dist/_frontend/assets/chunk-NFUX2ESW-D-OknU8a.js.gz +0 -0
  63. package/dist/_frontend/assets/{cssMode-Dk1ChNt4.js → cssMode-Buxt2F5C.js} +1 -1
  64. package/dist/_frontend/assets/cssMode-Buxt2F5C.js.br +0 -0
  65. package/dist/_frontend/assets/cssMode-Buxt2F5C.js.gz +0 -0
  66. package/dist/_frontend/assets/{freemarker2-D_Yi-Euz.js → freemarker2-Cdfv6ur6.js} +1 -1
  67. package/dist/_frontend/assets/freemarker2-Cdfv6ur6.js.br +0 -0
  68. package/dist/_frontend/assets/freemarker2-Cdfv6ur6.js.gz +0 -0
  69. package/dist/_frontend/assets/{handlebars-Cm_UQxos.js → handlebars-Dv-Q7Um6.js} +1 -1
  70. package/dist/_frontend/assets/handlebars-Dv-Q7Um6.js.br +0 -0
  71. package/dist/_frontend/assets/handlebars-Dv-Q7Um6.js.gz +0 -0
  72. package/dist/_frontend/assets/{html-BIx_CMMA.js → html-Cwmd4EDN.js} +1 -1
  73. package/dist/_frontend/assets/html-Cwmd4EDN.js.br +0 -0
  74. package/dist/_frontend/assets/html-Cwmd4EDN.js.gz +0 -0
  75. package/dist/_frontend/assets/{htmlMode-D7eeA6bm.js → htmlMode-Cf0xNt85.js} +1 -1
  76. package/dist/_frontend/assets/htmlMode-Cf0xNt85.js.br +0 -0
  77. package/dist/_frontend/assets/htmlMode-Cf0xNt85.js.gz +0 -0
  78. package/dist/_frontend/assets/{index-Y_4XXAao.js → index-BIRSKAK8.js} +243 -243
  79. package/dist/_frontend/assets/index-BIRSKAK8.js.br +0 -0
  80. package/dist/_frontend/assets/index-BIRSKAK8.js.gz +0 -0
  81. package/dist/_frontend/assets/{index-uWXj7DW5.js → index-BxyaDaQf.js} +1 -1
  82. package/dist/_frontend/assets/index-BxyaDaQf.js.br +0 -0
  83. package/dist/_frontend/assets/{index-uWXj7DW5.js.gz → index-BxyaDaQf.js.gz} +0 -0
  84. package/dist/_frontend/assets/{index-BJUe77Ib.js → index-OPxVm2Vd.js} +3 -3
  85. package/dist/_frontend/assets/index-OPxVm2Vd.js.br +0 -0
  86. package/dist/_frontend/assets/index-OPxVm2Vd.js.gz +0 -0
  87. package/dist/_frontend/assets/{javascript-CHojKZO8.js → javascript-BooEWA5C.js} +1 -1
  88. package/dist/_frontend/assets/{jsonMode-BTk9mIUo.js → jsonMode-Bc4b557E.js} +1 -1
  89. package/dist/_frontend/assets/jsonMode-Bc4b557E.js.br +0 -0
  90. package/dist/_frontend/assets/jsonMode-Bc4b557E.js.gz +0 -0
  91. package/dist/_frontend/assets/{liquid-M5ngFTv5.js → liquid-Dpr5_yD4.js} +1 -1
  92. package/dist/_frontend/assets/liquid-Dpr5_yD4.js.br +0 -0
  93. package/dist/_frontend/assets/liquid-Dpr5_yD4.js.gz +0 -0
  94. package/dist/_frontend/assets/{lspLanguageFeatures-jPhJA8WX.js → lspLanguageFeatures-BR2DRsTt.js} +1 -1
  95. package/dist/_frontend/assets/lspLanguageFeatures-BR2DRsTt.js.br +0 -0
  96. package/dist/_frontend/assets/lspLanguageFeatures-BR2DRsTt.js.gz +0 -0
  97. package/dist/_frontend/assets/{mdx-DmyHsr0E.js → mdx-HA7ugVt3.js} +1 -1
  98. package/dist/_frontend/assets/mdx-HA7ugVt3.js.br +0 -0
  99. package/dist/_frontend/assets/mdx-HA7ugVt3.js.gz +0 -0
  100. package/dist/_frontend/assets/{python-BRFA9b-I.js → python-C2JnSJsq.js} +1 -1
  101. package/dist/_frontend/assets/python-C2JnSJsq.js.br +0 -0
  102. package/dist/_frontend/assets/python-C2JnSJsq.js.gz +0 -0
  103. package/dist/_frontend/assets/{razor-CYsS4Kjw.js → razor-DxJxbSt9.js} +1 -1
  104. package/dist/_frontend/assets/razor-DxJxbSt9.js.br +0 -0
  105. package/dist/_frontend/assets/razor-DxJxbSt9.js.gz +0 -0
  106. package/dist/_frontend/assets/{tsMode-COQtB6OT.js → tsMode-DSQIB4wq.js} +1 -1
  107. package/dist/_frontend/assets/tsMode-DSQIB4wq.js.br +0 -0
  108. package/dist/_frontend/assets/tsMode-DSQIB4wq.js.gz +0 -0
  109. package/dist/_frontend/assets/{typescript-B3uUksf0.js → typescript-CYdXdQVS.js} +1 -1
  110. package/dist/_frontend/assets/typescript-CYdXdQVS.js.br +0 -0
  111. package/dist/_frontend/assets/typescript-CYdXdQVS.js.gz +0 -0
  112. package/dist/_frontend/assets/{workers-CgLq606Q.js → workers-C1M-tlfr.js} +1 -1
  113. package/dist/_frontend/assets/workers-C1M-tlfr.js.br +0 -0
  114. package/dist/_frontend/assets/workers-C1M-tlfr.js.gz +0 -0
  115. package/dist/_frontend/assets/{xml-YO228FLn.js → xml-uosDAHfe.js} +1 -1
  116. package/dist/_frontend/assets/xml-uosDAHfe.js.br +0 -0
  117. package/dist/_frontend/assets/xml-uosDAHfe.js.gz +0 -0
  118. package/dist/_frontend/assets/{yaml-CirMKB9x.js → yaml-CFmHi-W6.js} +1 -1
  119. package/dist/_frontend/assets/yaml-CFmHi-W6.js.br +0 -0
  120. package/dist/_frontend/assets/yaml-CFmHi-W6.js.gz +0 -0
  121. package/dist/_frontend/index.html +1 -1
  122. package/dist/controller-main.js.map +1 -1
  123. package/dist/main.js +481 -289
  124. package/dist/main.js.map +1 -1
  125. package/dist/postgres/migrations/20260909_000001_agent_description.js +16 -0
  126. package/dist/postgres/migrations/20260909_000001_agent_description.js.map +1 -0
  127. package/dist/sqlite/migrations/20260911_000001_agent_description.js +18 -0
  128. package/dist/sqlite/migrations/20260911_000001_agent_description.js.map +1 -0
  129. package/package.json +3 -3
  130. package/dist/_frontend/assets/AgentCodeSnippets-V5A56M7R-ZCh9CtX_.js.br +0 -0
  131. package/dist/_frontend/assets/AgentCodeSnippets-V5A56M7R-ZCh9CtX_.js.gz +0 -0
  132. package/dist/_frontend/assets/AgentMetricChart-GEADURES-CIR5UtB4.js +0 -1
  133. package/dist/_frontend/assets/AgentMetricChart-GEADURES-CIR5UtB4.js.br +0 -0
  134. package/dist/_frontend/assets/AgentMetricChart-GEADURES-CIR5UtB4.js.gz +0 -0
  135. package/dist/_frontend/assets/AgentOverview-NPC4P2EY-Z0AslRUd.js +0 -1
  136. package/dist/_frontend/assets/AgentOverview-NPC4P2EY-Z0AslRUd.js.br +0 -0
  137. package/dist/_frontend/assets/AgentOverview-NPC4P2EY-Z0AslRUd.js.gz +0 -0
  138. package/dist/_frontend/assets/AgentSessionEventTimeline-UUXOJXTC-Nk5ZgtJk.js.br +0 -0
  139. package/dist/_frontend/assets/AgentSessionEventTimeline-UUXOJXTC-Nk5ZgtJk.js.gz +0 -0
  140. package/dist/_frontend/assets/AgentSessionEventTimelineChart-FIAQCYJC-TBWekOBI.js.br +0 -0
  141. package/dist/_frontend/assets/AgentSessionEventTimelineChart-FIAQCYJC-TBWekOBI.js.gz +0 -0
  142. package/dist/_frontend/assets/AgentSessions-WHODEG2M-OzQblCn4.js.br +0 -0
  143. package/dist/_frontend/assets/AgentSessions-WHODEG2M-OzQblCn4.js.gz +0 -0
  144. package/dist/_frontend/assets/ConnectorSettings-QTAI4TQX-PySj_xEm.js.br +0 -0
  145. package/dist/_frontend/assets/ConnectorSettings-QTAI4TQX-PySj_xEm.js.gz +0 -0
  146. package/dist/_frontend/assets/DrawerLayout-DXHNV33K-BP-6TUEf.js.br +0 -0
  147. package/dist/_frontend/assets/DrawerLayout-DXHNV33K-BP-6TUEf.js.gz +0 -0
  148. package/dist/_frontend/assets/ModelSettings-UWTBHQRG-L5KYrHBM.js.br +0 -0
  149. package/dist/_frontend/assets/ModelSettings-UWTBHQRG-L5KYrHBM.js.gz +0 -0
  150. package/dist/_frontend/assets/SandboxSettings-BITQONS3-COVuckfo.js +0 -1
  151. package/dist/_frontend/assets/SandboxSettings-BITQONS3-COVuckfo.js.br +0 -0
  152. package/dist/_frontend/assets/SandboxSettings-BITQONS3-COVuckfo.js.gz +0 -0
  153. package/dist/_frontend/assets/SchedulesPage-JIUWNYUH-5f3ROPme.js +0 -1
  154. package/dist/_frontend/assets/SchedulesPage-JIUWNYUH-5f3ROPme.js.br +0 -0
  155. package/dist/_frontend/assets/SchedulesPage-JIUWNYUH-5f3ROPme.js.gz +0 -0
  156. package/dist/_frontend/assets/SettingsBuilder-3OA4UCIM-AN2PJd1q.js.br +0 -0
  157. package/dist/_frontend/assets/SettingsBuilder-3OA4UCIM-AN2PJd1q.js.gz +0 -0
  158. package/dist/_frontend/assets/ShellRouteSync-J74MV23Q-CDk4uzrR.js.br +0 -0
  159. package/dist/_frontend/assets/ShellRouteSync-J74MV23Q-CDk4uzrR.js.gz +0 -0
  160. package/dist/_frontend/assets/SidebarLayout-EQXQPYIU-zWCTPIcp.js.br +0 -0
  161. package/dist/_frontend/assets/SidebarLayout-EQXQPYIU-zWCTPIcp.js.gz +0 -0
  162. package/dist/_frontend/assets/SkillSettings-KQ6GQ7JW-oZVHsKV_.js.br +0 -0
  163. package/dist/_frontend/assets/SkillSettings-KQ6GQ7JW-oZVHsKV_.js.gz +0 -0
  164. package/dist/_frontend/assets/TrueForgeUIWithRouter-R3UXQZRY-wD0P6NXT.js +0 -1
  165. package/dist/_frontend/assets/WidgetLayout-YWZTYFZL-BgYVWW8O.js.br +0 -0
  166. package/dist/_frontend/assets/WidgetLayout-YWZTYFZL-BgYVWW8O.js.gz +0 -0
  167. package/dist/_frontend/assets/chunk-4MCIDE2C-ClJFqC75.js.br +0 -0
  168. package/dist/_frontend/assets/chunk-4MCIDE2C-ClJFqC75.js.gz +0 -0
  169. package/dist/_frontend/assets/chunk-62JRHF6Z-CXLsU_my.js.br +0 -0
  170. package/dist/_frontend/assets/chunk-62JRHF6Z-CXLsU_my.js.gz +0 -0
  171. package/dist/_frontend/assets/chunk-7NYDADYN-_y_WJnHd.js +0 -1
  172. package/dist/_frontend/assets/chunk-7NYDADYN-_y_WJnHd.js.br +0 -0
  173. package/dist/_frontend/assets/chunk-7NYDADYN-_y_WJnHd.js.gz +0 -0
  174. package/dist/_frontend/assets/chunk-ZZB3JIBQ-EN4V28Ji.js.br +0 -0
  175. package/dist/_frontend/assets/chunk-ZZB3JIBQ-EN4V28Ji.js.gz +0 -0
  176. package/dist/_frontend/assets/cssMode-Dk1ChNt4.js.br +0 -0
  177. package/dist/_frontend/assets/cssMode-Dk1ChNt4.js.gz +0 -0
  178. package/dist/_frontend/assets/freemarker2-D_Yi-Euz.js.br +0 -0
  179. package/dist/_frontend/assets/freemarker2-D_Yi-Euz.js.gz +0 -0
  180. package/dist/_frontend/assets/handlebars-Cm_UQxos.js.br +0 -0
  181. package/dist/_frontend/assets/handlebars-Cm_UQxos.js.gz +0 -0
  182. package/dist/_frontend/assets/html-BIx_CMMA.js.br +0 -0
  183. package/dist/_frontend/assets/html-BIx_CMMA.js.gz +0 -0
  184. package/dist/_frontend/assets/htmlMode-D7eeA6bm.js.br +0 -0
  185. package/dist/_frontend/assets/htmlMode-D7eeA6bm.js.gz +0 -0
  186. package/dist/_frontend/assets/index-BJUe77Ib.js.br +0 -0
  187. package/dist/_frontend/assets/index-BJUe77Ib.js.gz +0 -0
  188. package/dist/_frontend/assets/index-Y_4XXAao.js.br +0 -0
  189. package/dist/_frontend/assets/index-Y_4XXAao.js.gz +0 -0
  190. package/dist/_frontend/assets/index-uWXj7DW5.js.br +0 -0
  191. package/dist/_frontend/assets/jsonMode-BTk9mIUo.js.br +0 -0
  192. package/dist/_frontend/assets/jsonMode-BTk9mIUo.js.gz +0 -0
  193. package/dist/_frontend/assets/liquid-M5ngFTv5.js.br +0 -0
  194. package/dist/_frontend/assets/liquid-M5ngFTv5.js.gz +0 -0
  195. package/dist/_frontend/assets/lspLanguageFeatures-jPhJA8WX.js.br +0 -0
  196. package/dist/_frontend/assets/lspLanguageFeatures-jPhJA8WX.js.gz +0 -0
  197. package/dist/_frontend/assets/mdx-DmyHsr0E.js.br +0 -0
  198. package/dist/_frontend/assets/mdx-DmyHsr0E.js.gz +0 -0
  199. package/dist/_frontend/assets/python-BRFA9b-I.js.br +0 -0
  200. package/dist/_frontend/assets/python-BRFA9b-I.js.gz +0 -0
  201. package/dist/_frontend/assets/razor-CYsS4Kjw.js.br +0 -0
  202. package/dist/_frontend/assets/razor-CYsS4Kjw.js.gz +0 -0
  203. package/dist/_frontend/assets/tsMode-COQtB6OT.js.br +0 -0
  204. package/dist/_frontend/assets/tsMode-COQtB6OT.js.gz +0 -0
  205. package/dist/_frontend/assets/typescript-B3uUksf0.js.br +0 -0
  206. package/dist/_frontend/assets/typescript-B3uUksf0.js.gz +0 -0
  207. package/dist/_frontend/assets/workers-CgLq606Q.js.br +0 -0
  208. package/dist/_frontend/assets/workers-CgLq606Q.js.gz +0 -0
  209. package/dist/_frontend/assets/xml-YO228FLn.js.br +0 -0
  210. package/dist/_frontend/assets/xml-YO228FLn.js.gz +0 -0
  211. package/dist/_frontend/assets/yaml-CirMKB9x.js.br +0 -0
  212. package/dist/_frontend/assets/yaml-CirMKB9x.js.gz +0 -0
@@ -1 +1 @@
1
- import{aF as be,D as fe,r as l,aG as Y,j as e,J as ge,L as B,I as P,aH as ie,aI as xe,aJ as ye,aK as ve,e as T,aL as je,ab as Ne}from"./index-Y_4XXAao.js";var me=Ne("h-11 shadow-sm"),we=({open:n,onOpenChange:o,onSave:b,title:k,description:p,initialBaseUrl:E="",baseUrlPlaceholder:d="https://api.openai.com/v1",requireApiKey:c=!0,submitLabel:S="Save",busy:O=!1,error:F})=>{const[M,I]=l.useState(""),[y,x]=l.useState(""),[w,$]=l.useState(!1),U=()=>{I(""),x(""),$(!1)};l.useEffect(()=>{n&&(I(""),x(E),$(!1))},[n,E]);const J=i=>{i||U(),o(i)},L=M.trim(),Q=!c||!!L,v=async i=>{if(i.preventDefault(),!(!Q||O))try{await b({apiKey:L,baseUrl:y.trim()}),U(),o(!1)}catch{}};return e.jsx(xe,{open:n,onOpenChange:J,title:k,description:p,contentSized:!0,children:e.jsxs("form",{className:"flex flex-col overflow-y-auto p-5 md:p-6",onSubmit:v,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"model-provider-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",c?null:e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"model-provider-api-key",type:"password",required:c,value:M,onChange:i=>{I(i.target.value)},placeholder:c?"Enter API key":"Enter a new key",autoFocus:!0,className:me}),c?null:e.jsx("p",{className:"mt-1.5 text-xs text-text-secondary",children:"Leave blank to keep the current key; enter a new one to replace it."})]}),e.jsxs(ye,{expanded:w,onChange:(i,K)=>$(K),className:"rounded-md border border-border",children:[e.jsx(ve,{className:"px-3 py-2.5",children:e.jsxs("span",{className:"flex w-full items-center justify-between text-sm font-medium text-text-primary",children:["Advanced · custom endpoint",e.jsx(P,{name:"chevron-down",className:T("size-4 shrink-0 text-text-secondary transition-transform duration-200",w?"rotate-0":"-rotate-90")})]})}),e.jsxs(je,{className:"space-y-1.5 border-t border-border px-3 pb-3 pt-4",children:[e.jsx("label",{htmlFor:"model-provider-base-url",className:"block text-sm font-medium text-text-primary",children:"Base URL"}),e.jsx("input",{id:"model-provider-base-url",type:"url",value:y,onChange:i=>{x(i.target.value)},placeholder:d,className:me}),e.jsx("p",{className:"text-xs text-text-secondary",children:"Leave blank unless you use a regional or proxy endpoint."})]})]})]}),e.jsxs("div",{className:"mt-6 space-y-3",children:[F?e.jsx("p",{className:"text-failure-bg text-sm",children:F}):null,e.jsx(B.Primary,{type:"submit",size:"large",disabled:!Q||O,className:"w-full shrink-0",children:S})]})]})})},Ce=we,ke="128000",Ee="4096",pe=()=>({id:"",name:"",advancedExpanded:!0,contextLength:"",maxOutputTokens:""}),ue=n=>(n==null?void 0:n.models.map(o=>{var b,k,p,E,d;return{id:o.id,name:o.name,advancedExpanded:!0,reasoningEfforts:(b=o.properties)==null?void 0:b.reasoningEfforts,contextLength:((p=(k=o.properties)==null?void 0:k.contextLength)==null?void 0:p.toString())??"",maxOutputTokens:((d=(E=o.properties)==null?void 0:E.maxOutputTokens)==null?void 0:d.toString())??"",nameDirty:!0}}))??[pe()],G="h-11 w-full rounded-md border border-border/70 bg-secondary-bg px-3 text-sm text-text-primary outline-none transition-colors placeholder:text-text-secondary/70 focus-visible:border-focus-ring focus-visible:ring-2 focus-visible:ring-focus-ring/50",V="border-failure-bg focus-visible:border-failure-bg focus-visible:ring-failure-bg";function ce(n){const o=n.trim();if(o==="")return null;const b=Number(o);return Number.isInteger(b)&&b>0?b:null}function Se(n){return n.replace(/([a-zA-Z])(\d)/g,"$1-$2").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^[^a-z]+/,"").slice(0,64).replace(/-+$/g,"")}var re=()=>e.jsx("span",{className:"ml-0.5 text-failure-bg","aria-hidden":!0,children:"*"}),ee=({children:n})=>e.jsx("p",{className:"mt-1 text-xs text-failure-bg",children:n}),ne=({children:n})=>e.jsx("p",{className:"mt-1 text-xs text-text-secondary",children:n}),Me=({open:n,onOpenChange:o,onSubmit:b,reasoningEffortOptions:k,busy:p=!1,error:E,isEditMode:d=!1,initialValues:c})=>{const[S,O]=l.useState((c==null?void 0:c.name)??""),[F,M]=l.useState((c==null?void 0:c.baseUrl)??""),[I,y]=l.useState(""),[x,w]=l.useState(()=>ue(c)),[$,U]=l.useState(!1),[J,L]=l.useState(!1),Q=()=>{O((c==null?void 0:c.name)??""),M((c==null?void 0:c.baseUrl)??""),y(""),w(ue(c)),U(!1),L(!1)},v=s=>{s||Q(),o(s)},i=(s,r)=>{w(g=>g.map((u,j)=>j===s?{...u,...r}:u))},K=()=>{U(!0),L(!0),w(s=>s.map(r=>({...r,idTouched:!0,contextTouched:!0,maxTouched:!0})))},f=S.trim(),D=f?null:"Name is required.",_=F.trim();let h=null;if(!_)h="Base URL is required.";else try{new URL(_)}catch{h="Enter a valid URL."}const X=s=>s.id.trim()?null:"Model ID is required.",te=s=>s.name.trim()?null:"Model name is required.",q=s=>ce(s.contextLength)==null?"Set the model's context window.":null,W=s=>ce(s.maxOutputTokens)==null?"Set the max output tokens.":null,le=!D&&!h&&x.every(s=>!X(s)&&!te(s)),se=$&&D,H=J&&h,A=async()=>{if(K(),!le||p)return;const s=x.findIndex(r=>q(r)||W(r));if(s!==-1){i(s,{advancedExpanded:!0});const r=x[s],g=r&&q(r)?"context-length":"max-output-tokens";setTimeout(()=>{var j;const u=document.getElementById(`custom-provider-model-${s}-${g}`);(j=u==null?void 0:u.scrollIntoView)==null||j.call(u,{block:"center",behavior:"smooth"}),u==null||u.focus()},0);return}try{await b({name:f,baseUrl:_,apiKey:I.trim(),models:x.map(r=>{var R;const g={};(R=r.reasoningEfforts)!=null&&R.length&&(g.reasoningEfforts=r.reasoningEfforts);const u=ce(r.contextLength);u!=null&&(g.contextLength=u);const j=ce(r.maxOutputTokens);return j!=null&&(g.maxOutputTokens=j),{id:r.id.trim(),name:r.name.trim(),...Object.keys(g).length>0?{properties:g}:{}}})}),v(!1)}catch{}};return e.jsx(xe,{open:n,onOpenChange:v,title:d?`Edit ${(c==null?void 0:c.name)??S}`:"Add custom provider",description:d?"Update the endpoint, credentials, and models for this provider.":"Connect any OpenAI-compatible endpoint, whether it's a local model, a proxy, or your own hosted service.",contentSized:!0,children:e.jsxs("form",{className:"flex min-h-0 flex-1 flex-col",onSubmit:s=>{s.preventDefault(),A()},children:[e.jsxs("div",{className:"min-h-0 flex-1 space-y-4 overflow-y-auto px-5 pt-4 pb-8",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"custom-provider-name",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Name",e.jsx(re,{})]}),e.jsx("input",{id:"custom-provider-name",type:"text",value:S,onChange:s=>O(s.target.value),onBlur:()=>U(!0),placeholder:"local-llama",autoFocus:!d,readOnly:d,"aria-readonly":d,"aria-invalid":se?!0:void 0,className:T(G,d&&"cursor-not-allowed bg-secondary-bg/60 text-text-secondary",se&&V)}),d?e.jsx(ne,{children:"Provider names cannot be changed after creation."}):null,se?e.jsx(ee,{children:D}):null]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"custom-provider-base-url",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Base URL",e.jsx(re,{})]}),e.jsx("input",{id:"custom-provider-base-url",type:"text",value:F,onChange:s=>M(s.target.value),onBlur:()=>L(!0),placeholder:"http://localhost:11434/v1",autoFocus:d,"aria-invalid":H?!0:void 0,className:T(G,H&&V)}),H?e.jsx(ee,{children:h}):_?null:e.jsx(ne,{children:"OpenAI-compatible endpoint, usually ending in /v1."})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"custom-provider-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"custom-provider-api-key",type:"password",value:I,onChange:s=>y(s.target.value),placeholder:"sk-…",className:G}),e.jsx(ne,{children:d?"Leave blank to keep the saved key, or enter a new key to replace it.":"Leave blank if your endpoint needs no key (e.g. a local model)."})]}),e.jsxs("fieldset",{className:"m-0 min-w-0 border-0 p-0",children:[e.jsxs("legend",{className:"float-left mb-2 w-full p-0 text-sm font-medium text-text-primary",children:["Models",e.jsx(re,{})]}),e.jsx("div",{className:"clear-both",children:x.map((s,r)=>{const g=X(s),u=s.idTouched&&g,j=te(s),R=!!j&&s.nameDirty,oe=q(s),C=W(s),z=s.contextTouched&&oe,ae=s.maxTouched&&C;return e.jsxs("div",{className:T("pb-6",r>0?"border-t border-border pt-6":"pt-1"),style:r>0?{borderTopWidth:"0.5px"}:void 0,children:[e.jsxs("div",{className:"grid grid-cols-[1fr_1fr_2rem] items-end gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("label",{htmlFor:`custom-provider-model-${r}-id`,className:"mb-1 block text-xs font-normal text-text-secondary",children:"Model ID"}),e.jsx("input",{id:`custom-provider-model-${r}-id`,type:"text",value:s.id,onChange:t=>{const a=t.target.value;i(r,{id:a,...s.nameDirty?{}:{name:Se(a)}})},onBlur:()=>i(r,{idTouched:!0}),placeholder:"llama3.1:70b","aria-invalid":u?!0:void 0,className:T(G,"font-mono",u&&V)})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("label",{htmlFor:`custom-provider-model-${r}-name`,className:"mb-1 block text-xs font-normal text-text-secondary",children:"Model name"}),e.jsx("input",{id:`custom-provider-model-${r}-name`,type:"text",value:s.name,onChange:t=>i(r,{name:t.target.value,nameDirty:!0}),placeholder:"llama-3-1-70b","aria-invalid":R?!0:void 0,className:T(G,R&&V)})]}),e.jsx("button",{type:"button","aria-label":`Remove model ${r+1}`,disabled:x.length===1||p,className:"mb-0.5 flex size-9 items-center justify-center rounded-md text-text-secondary transition-colors hover:text-text-primary disabled:opacity-40",onClick:()=>w(t=>t.filter((a,m)=>m!==r)),children:e.jsx(P,{name:"trash",className:"size-4"})})]}),u?e.jsx(ee,{children:g}):null,R?e.jsx(ee,{children:j}):null,e.jsxs("div",{className:"mt-2",children:[e.jsxs("button",{type:"button","aria-expanded":s.advancedExpanded,"aria-controls":`custom-provider-model-${r}-advanced`,className:"flex cursor-pointer items-center gap-1.5 text-sm font-medium text-text-primary",onClick:()=>i(r,{advancedExpanded:!s.advancedExpanded}),children:[e.jsx(P,{name:"chevron-down",className:T("size-4 text-text-secondary transition-transform",s.advancedExpanded?"":"-rotate-90")}),"Advanced"]}),s.advancedExpanded?e.jsxs("div",{id:`custom-provider-model-${r}-advanced`,className:"mt-3 space-y-4 pl-6",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`custom-provider-model-${r}-context-length`,className:"mb-1.5 block text-xs font-medium text-text-secondary",children:["Context length",e.jsx(re,{})]}),e.jsx("input",{id:`custom-provider-model-${r}-context-length`,type:"number",min:1,inputMode:"numeric",value:s.contextLength,onChange:t=>i(r,{contextLength:t.target.value}),onBlur:()=>i(r,{contextTouched:!0}),placeholder:ke,"aria-invalid":z?!0:void 0,className:T(G,z&&V)}),z?e.jsx(ee,{children:oe}):s.contextLength.trim()===""?e.jsx(ne,{children:"Model's total token window."}):null]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`custom-provider-model-${r}-max-output-tokens`,className:"mb-1.5 block text-xs font-medium text-text-secondary",children:["Max output tokens",e.jsx(re,{})]}),e.jsx("input",{id:`custom-provider-model-${r}-max-output-tokens`,type:"number",min:1,inputMode:"numeric",value:s.maxOutputTokens,onChange:t=>i(r,{maxOutputTokens:t.target.value}),onBlur:()=>i(r,{maxTouched:!0}),placeholder:Ee,"aria-invalid":ae?!0:void 0,className:T(G,ae&&V)}),ae?e.jsx(ee,{children:C}):s.maxOutputTokens.trim()===""?e.jsx(ne,{children:"Longest reply the model allows — use its real limit."}):null]}),k&&k.length>0?e.jsxs("div",{children:[e.jsxs("label",{className:"flex w-fit cursor-pointer items-center gap-2 select-none",children:[e.jsx("input",{type:"checkbox",className:"size-4 shrink-0 cursor-pointer accent-primary-button-bg disabled:cursor-not-allowed disabled:opacity-50",checked:s.reasoningEfforts!==void 0,"aria-label":`Enable reasoning effort for model ${r+1}`,disabled:p,onChange:t=>i(r,{reasoningEfforts:t.target.checked?[]:void 0})}),e.jsx("span",{className:"text-text-secondary text-xs font-medium",children:"Reasoning effort"})]}),s.reasoningEfforts!==void 0?e.jsx("div",{role:"group","aria-label":`Supported reasoning efforts for model ${r+1}`,className:"mt-2 flex flex-wrap gap-2",children:k.map(t=>{var m;const a=((m=s.reasoningEfforts)==null?void 0:m.includes(t))??!1;return e.jsx("button",{type:"button","aria-pressed":a,disabled:p,className:T("rounded-full border px-3 py-1 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring/40 disabled:opacity-50",a?"border-primary-button-bg bg-primary-button-bg text-primary-button-text":"border-border text-text-secondary hover:bg-ghost-button-hover"),onClick:()=>{var Z;return i(r,{reasoningEfforts:a?(Z=s.reasoningEfforts)==null?void 0:Z.filter(de=>de!==t):[...s.reasoningEfforts??[],t]})},children:t},t)})}):null]}):null]}):null]})]},r)})}),e.jsxs(B.Secondary,{size:"small",type:"button",className:"mt-4 w-fit",onClick:()=>w(s=>[...s,pe()]),children:[e.jsx(P,{name:"plus",className:"size-3.5"}),"Add model"]})]})]}),e.jsxs("div",{className:"shrink-0 space-y-3 border-t border-border px-5 py-4",children:[E?e.jsx("p",{className:"text-failure-bg text-sm",children:E}):null,e.jsx(B.Primary,{type:"submit",size:"large",disabled:!le||p,className:"w-full",children:d?"Save changes":"Add provider"})]})]})})},Ue=Me;function Le(n){return"baseUrl"in n&&typeof n.baseUrl=="string"?n.baseUrl:""}var Te=()=>{const{modelCatalog:n}=be(),o=fe(),[b,k]=l.useState(""),[p,E]=l.useState([]),[d,c]=l.useState([]),[S,O]=l.useState(!0),[F,M]=l.useState(null),[I,y]=l.useState(null),[x,w]=l.useState(!1),[$,U]=l.useState(null),[J,L]=l.useState(null),[Q,v]=l.useState(null),[i,K]=l.useState(!1),[f,D]=l.useState(null),_=l.useMemo(()=>(d??[]).reduce((t,a)=>(t[a.name]=a.logo??"",t),{}),[d]),h=b.trim().toLowerCase(),X=l.useCallback(async()=>{O(!0),M(null);try{const[t,a]=await Promise.all([n.listModelProviders(),n.getModelProviderCatalog()]);E(t),c(a)}catch(t){M(Y(t,"Failed to load model providers"))}finally{O(!1)}},[n]);l.useEffect(()=>{X()},[X]);const te=l.useMemo(()=>new Set(p.map(t=>t.type)),[p]),q=l.useMemo(()=>p.filter(t=>{var a;return((a=t.name)==null?void 0:a.toLowerCase().includes(h))||t.models.some(m=>m.name.toLowerCase().includes(h)||m.id.toLowerCase().includes(h))}),[p,h]),W=l.useMemo(()=>d.filter(t=>t.type!=="custom"&&!te.has(t.type)&&(t.name.toLowerCase().includes(h)||t.models.some(a=>a.name.toLowerCase().includes(h)||a.id.toLowerCase().includes(h)))),[d,te,h]),le=l.useMemo(()=>{var t;return(t=d.find(a=>a.type==="custom"))==null?void 0:t.supportedReasoningEfforts},[d]),se=l.useMemo(()=>{const t=new Map;for(const a of d)t.set(a.type,a.models);return t},[d]),H=()=>{U(null),L(null),v(null)},A=async(t,a)=>{w(!0),M(null);try{await t(),await X(),H()}catch(m){throw a?a(m):o==null?M(Y(m,"Request failed")):o.showError(m),m}finally{w(!1)}},s=async(t,a)=>{v(null),await A(async()=>{await n.createModelProvider({type:t.type,name:t.name,...a.baseUrl?{baseUrl:a.baseUrl}:{},apiKey:a.apiKey,models:t.models})},m=>v(Y(m,"Request failed")))},r=async(t,a)=>{v(null),await A(async()=>{await n.updateModelProvider({id:t.id,type:t.type,name:t.name,...a.baseUrl?{baseUrl:a.baseUrl}:{},apiKey:a.apiKey,models:t.models})},m=>v(Y(m,"Request failed"))),o==null||o.showSuccess({title:`${t.name} updated`})},g=t=>{n.deleteModelProvider&&A(async()=>{await n.deleteModelProvider({id:t.id})}).catch(()=>{})},u=(t,a)=>{A(async()=>{await n.updateModelProvider({id:t.id,type:t.type,name:t.name,...t.baseUrl?{baseUrl:t.baseUrl}:{},apiKey:"",models:a})}).catch(()=>{})},j=async t=>{y(null),await A(async()=>{await n.createModelProvider({type:"custom",name:t.name,baseUrl:t.baseUrl,apiKey:t.apiKey,models:t.models})},a=>y(Y(a,"Request failed"))),setTimeout(()=>{o==null||o.showSuccess({title:`${t.name} added`})},0)},R=async t=>{if(!f)return;const a=f;y(null),await A(async()=>{await n.updateModelProvider({id:a.id,type:a.type,name:a.name,baseUrl:t.baseUrl,apiKey:t.apiKey,models:t.models})},m=>y(Y(m,"Request failed"))),setTimeout(()=>{o==null||o.showSuccess({title:"Model provider updated",description:`${a.name} was updated successfully.`})},0)},oe=f?{name:f.name,baseUrl:f.baseUrl??"",models:f.models}:void 0,C=$!=null?p.find(t=>t.id===$)??null:null,z=J!=null?d.find(t=>t.type===J)??null:null,ae=C!=null||z!=null;return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Models"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Connect providers and choose which models are available."}),F?e.jsx("p",{className:"mt-3 rounded-md border border-failure-bg/30 bg-failure-bg/10 px-3 py-2 text-sm text-failure-bg",children:F}):null,e.jsx("div",{className:"mt-4 flex-1 overflow-y-hidden",children:e.jsxs("div",{className:"flex h-full flex-col gap-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:"flex-1",children:e.jsx(ge,{query:b,setQuery:k,placeholder:"Search providers and models"})}),e.jsxs(B.Secondary,{type:"button",onClick:()=>{y(null),D(null),K(!0)},children:[e.jsx(P,{name:"plus",size:"1rem",className:"mr-1"}),"Add Custom Provider"]})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-2 overflow-y-auto",children:[S?e.jsx("p",{className:"py-8 text-center text-sm text-text-secondary",children:"Loading…"}):null,!S&&q.length>0?e.jsxs("section",{"aria-labelledby":"configured-providers-heading",children:[e.jsx("div",{id:"configured-providers-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:"Configured"}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:q.map(t=>{const a=se.get(t.type)??[],m=new Set(t.models.map(N=>N.id)),Z=a.filter(N=>!m.has(N.id)),de=_[t.name];return e.jsxs("article",{className:"border-b border-border p-3 last:border-b-0",children:[e.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:de?e.jsx(ie,{src:de,alt:t.name,className:"size-4.5"}):e.jsx(P,{name:"cpu",className:"size-4.5"})}),e.jsx("h5",{className:"truncate text-base font-medium text-text-primary",children:t.name})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 sm:justify-end",children:[e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full border border-border bg-secondary-bg/40 px-2 py-0.5 text-xs font-medium text-success-bg",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-success-bg"}),"Connected"]}),e.jsxs(B.Secondary,{size:"small",className:"text-[0.8125rem]",type:"button","aria-label":`Edit ${t.name}`,title:`Edit ${t.name}`,disabled:x,onClick:()=>{t.type==="custom"?(H(),y(null),D(t),K(!0)):(v(null),L(null),U(t.id))},children:[e.jsx(P,{name:"pencil",className:"size-3.5"}),"Edit"]}),n.deleteModelProvider?e.jsx(B.Secondary,{size:"small",className:"transition-colors hover:bg-failure-bg/10 hover:text-failure-bg",type:"button",disabled:x,onClick:()=>{g(t)},children:"Remove"}):null]})]}),e.jsxs("div",{className:"mt-3 overflow-hidden rounded-lg border border-border bg-secondary-bg/30",children:[t.models.map(N=>e.jsxs("div",{className:"flex min-h-10 items-center gap-3 border-b border-border px-3 py-2 text-sm text-text-primary last:border-b-0",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:N.name}),e.jsx("button",{type:"button","aria-label":`Remove ${N.name}`,disabled:x,className:"inline-flex size-7 shrink-0 items-center justify-center rounded-md text-text-secondary hover:bg-ghost-button-hover hover:text-ghost-button-text focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring disabled:opacity-50",onClick:()=>{u(t,t.models.filter(he=>he.id!==N.id))},children:e.jsx(P,{name:"trash",className:"size-3.5"})})]},N.id)),Z.length>0?e.jsxs("section",{children:[e.jsxs("div",{className:"border-b border-border bg-secondary-bg/40 px-3 py-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Available to add · ",Z.length]}),Z.map(N=>e.jsxs("div",{className:"flex min-h-12 items-center gap-3 border-b border-border px-3 py-2 text-sm text-text-primary last:border-b-0",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:N.name}),e.jsx(B.Secondary,{size:"small",type:"button",disabled:x,onClick:()=>{u(t,[...t.models,N])},children:"Add"})]},N.id))]}):null]})]},t.id)})})]}):null,!S&&W.length>0?e.jsxs("section",{"aria-labelledby":"available-providers-heading",className:"mt-2",children:[e.jsx("div",{id:"available-providers-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:"Available"}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:W.map(t=>{const a=_[t.name];return e.jsx("article",{className:"border-b border-border p-3 last:border-b-0",children:e.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:a?e.jsx(ie,{src:a,alt:t.name,className:"size-4.5"}):e.jsx(P,{name:"cpu",className:"size-4.5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h5",{className:"truncate text-base font-medium text-text-primary",children:t.name}),e.jsx("p",{className:"truncate text-sm text-text-secondary",children:t.models.map(m=>m.name).join(" · ")})]})]}),e.jsxs(B.Secondary,{type:"button",disabled:x,onClick:()=>{v(null),U(null),L(t.type)},children:[e.jsx(P,{name:"wrench",className:"size-4"}),"Configure"]})]})},t.type)})})]}):null,!S&&q.length===0&&W.length===0?e.jsx("div",{className:"flex flex-1 items-center justify-center rounded-xl border border-dashed border-border p-8 text-center text-sm text-text-secondary",children:h?`No providers match “${b.trim()}”.`:"No model providers yet."}):null]}),e.jsx(Ce,{open:ae,onOpenChange:t=>{t||H()},onSave:t=>{if(C)return r(C,t);if(z)return s(z,t)},title:C?"Edit Provider Details":"Configure Provider Details",initialBaseUrl:C?C.baseUrl??"":z?Le(z):"",requireApiKey:C==null,submitLabel:C?"Save":"Create",busy:x,error:Q}),e.jsx(Ue,{open:i,onOpenChange:t=>{K(t),t||(y(null),D(null))},isEditMode:f!==null,initialValues:oe,onSubmit:f?R:j,reasoningEffortOptions:le,busy:x,error:I},(f==null?void 0:f.id)??"add-custom-provider")]})})]})},ze=Te;export{ze as default};
1
+ import{aL as be,D as fe,r as l,aM as Y,j as e,H as ge,K as B,I as L,aN as ie,aO as xe,aP as ye,aQ as ve,e as T,aR as je,ah as Ne}from"./index-BIRSKAK8.js";var me=Ne("h-11 shadow-sm"),we=({open:n,onOpenChange:o,onSave:b,title:k,description:p,initialBaseUrl:E="",baseUrlPlaceholder:d="https://api.openai.com/v1",requireApiKey:c=!0,submitLabel:S="Save",busy:z=!1,error:F})=>{const[M,$]=l.useState(""),[y,x]=l.useState(""),[w,I]=l.useState(!1),U=()=>{$(""),x(""),I(!1)};l.useEffect(()=>{n&&($(""),x(E),I(!1))},[n,E]);const X=i=>{i||U(),o(i)},P=M.trim(),G=!c||!!P,v=async i=>{if(i.preventDefault(),!(!G||z))try{await b({apiKey:P,baseUrl:y.trim()}),U(),o(!1)}catch{}};return e.jsx(xe,{open:n,onOpenChange:X,title:k,description:p,contentSized:!0,children:e.jsxs("form",{className:"flex flex-col overflow-y-auto p-5 md:p-6",onSubmit:v,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"model-provider-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",c?null:e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"model-provider-api-key",type:"password",required:c,value:M,onChange:i=>{$(i.target.value)},placeholder:c?"Enter API key":"Enter a new key",autoFocus:!0,className:me}),c?null:e.jsx("p",{className:"mt-1.5 text-xs text-text-secondary",children:"Leave blank to keep the current key; enter a new one to replace it."})]}),e.jsxs(ye,{expanded:w,onChange:(i,K)=>I(K),className:"rounded-md border border-border",children:[e.jsx(ve,{className:"px-3 py-2.5",children:e.jsxs("span",{className:"flex w-full items-center justify-between text-sm font-medium text-text-primary",children:["Advanced · custom endpoint",e.jsx(L,{name:"chevron-down",className:T("size-4 shrink-0 text-text-secondary transition-transform duration-200",w?"rotate-0":"-rotate-90")})]})}),e.jsxs(je,{className:"space-y-1.5 border-t border-border px-3 pb-3 pt-4",children:[e.jsx("label",{htmlFor:"model-provider-base-url",className:"block text-sm font-medium text-text-primary",children:"Base URL"}),e.jsx("input",{id:"model-provider-base-url",type:"url",value:y,onChange:i=>{x(i.target.value)},placeholder:d,className:me}),e.jsx("p",{className:"text-xs text-text-secondary",children:"Leave blank unless you use a regional or proxy endpoint."})]})]})]}),e.jsxs("div",{className:"mt-6 space-y-3",children:[F?e.jsx("p",{className:"text-failure-bg text-sm",children:F}):null,e.jsx(B.Primary,{type:"submit",size:"large",disabled:!G||z,className:"w-full shrink-0",children:S})]})]})})},Ce=we,ke="128000",Ee="4096",pe=()=>({id:"",name:"",advancedExpanded:!0,contextLength:"",maxOutputTokens:""}),ue=n=>(n==null?void 0:n.models.map(o=>{var b,k,p,E,d;return{id:o.id,name:o.name,advancedExpanded:!0,reasoningEfforts:(b=o.properties)==null?void 0:b.reasoningEfforts,contextLength:((p=(k=o.properties)==null?void 0:k.contextLength)==null?void 0:p.toString())??"",maxOutputTokens:((d=(E=o.properties)==null?void 0:E.maxOutputTokens)==null?void 0:d.toString())??"",nameDirty:!0}}))??[pe()],Q="h-11 w-full rounded-md border border-border/70 bg-secondary-bg px-3 text-sm text-text-primary outline-none transition-colors placeholder:text-text-secondary/70 focus-visible:border-focus-ring focus-visible:ring-2 focus-visible:ring-focus-ring/50",V="border-failure-bg focus-visible:border-failure-bg focus-visible:ring-failure-bg";function ce(n){const o=n.trim();if(o==="")return null;const b=Number(o);return Number.isInteger(b)&&b>0?b:null}function Se(n){return n.replace(/([a-zA-Z])(\d)/g,"$1-$2").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^[^a-z]+/,"").slice(0,64).replace(/-+$/g,"")}var re=()=>e.jsx("span",{className:"ml-0.5 text-failure-bg","aria-hidden":!0,children:"*"}),ee=({children:n})=>e.jsx("p",{className:"mt-1 text-xs text-failure-bg",children:n}),ne=({children:n})=>e.jsx("p",{className:"mt-1 text-xs text-text-secondary",children:n}),Me=({open:n,onOpenChange:o,onSubmit:b,reasoningEffortOptions:k,busy:p=!1,error:E,isEditMode:d=!1,initialValues:c})=>{const[S,z]=l.useState((c==null?void 0:c.name)??""),[F,M]=l.useState((c==null?void 0:c.baseUrl)??""),[$,y]=l.useState(""),[x,w]=l.useState(()=>ue(c)),[I,U]=l.useState(!1),[X,P]=l.useState(!1),G=()=>{z((c==null?void 0:c.name)??""),M((c==null?void 0:c.baseUrl)??""),y(""),w(ue(c)),U(!1),P(!1)},v=s=>{s||G(),o(s)},i=(s,r)=>{w(g=>g.map((u,j)=>j===s?{...u,...r}:u))},K=()=>{U(!0),P(!0),w(s=>s.map(r=>({...r,idTouched:!0,contextTouched:!0,maxTouched:!0})))},f=S.trim(),D=f?null:"Name is required.",_=F.trim();let h=null;if(!_)h="Base URL is required.";else try{new URL(_)}catch{h="Enter a valid URL."}const W=s=>s.id.trim()?null:"Model ID is required.",te=s=>s.name.trim()?null:"Model name is required.",q=s=>ce(s.contextLength)==null?"Set the model's context window.":null,Z=s=>ce(s.maxOutputTokens)==null?"Set the max output tokens.":null,le=!D&&!h&&x.every(s=>!W(s)&&!te(s)),se=I&&D,H=X&&h,R=async()=>{if(K(),!le||p)return;const s=x.findIndex(r=>q(r)||Z(r));if(s!==-1){i(s,{advancedExpanded:!0});const r=x[s],g=r&&q(r)?"context-length":"max-output-tokens";setTimeout(()=>{var j;const u=document.getElementById(`custom-provider-model-${s}-${g}`);(j=u==null?void 0:u.scrollIntoView)==null||j.call(u,{block:"center",behavior:"smooth"}),u==null||u.focus()},0);return}try{await b({name:f,baseUrl:_,apiKey:$.trim(),models:x.map(r=>{var A;const g={};(A=r.reasoningEfforts)!=null&&A.length&&(g.reasoningEfforts=r.reasoningEfforts);const u=ce(r.contextLength);u!=null&&(g.contextLength=u);const j=ce(r.maxOutputTokens);return j!=null&&(g.maxOutputTokens=j),{id:r.id.trim(),name:r.name.trim(),...Object.keys(g).length>0?{properties:g}:{}}})}),v(!1)}catch{}};return e.jsx(xe,{open:n,onOpenChange:v,title:d?`Edit ${(c==null?void 0:c.name)??S}`:"Add custom provider",description:d?"Update the endpoint, credentials, and models for this provider.":"Connect any OpenAI-compatible endpoint, whether it's a local model, a proxy, or your own hosted service.",contentSized:!0,children:e.jsxs("form",{className:"flex min-h-0 flex-1 flex-col",onSubmit:s=>{s.preventDefault(),R()},children:[e.jsxs("div",{className:"min-h-0 flex-1 space-y-4 overflow-y-auto px-5 pt-4 pb-8",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"custom-provider-name",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Name",e.jsx(re,{})]}),e.jsx("input",{id:"custom-provider-name",type:"text",value:S,onChange:s=>z(s.target.value),onBlur:()=>U(!0),placeholder:"local-llama",autoFocus:!d,readOnly:d,"aria-readonly":d,"aria-invalid":se?!0:void 0,className:T(Q,d&&"cursor-not-allowed bg-secondary-bg/60 text-text-secondary",se&&V)}),d?e.jsx(ne,{children:"Provider names cannot be changed after creation."}):null,se?e.jsx(ee,{children:D}):null]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"custom-provider-base-url",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Base URL",e.jsx(re,{})]}),e.jsx("input",{id:"custom-provider-base-url",type:"text",value:F,onChange:s=>M(s.target.value),onBlur:()=>P(!0),placeholder:"http://localhost:11434/v1",autoFocus:d,"aria-invalid":H?!0:void 0,className:T(Q,H&&V)}),H?e.jsx(ee,{children:h}):_?null:e.jsx(ne,{children:"OpenAI-compatible endpoint, usually ending in /v1."})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"custom-provider-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"custom-provider-api-key",type:"password",value:$,onChange:s=>y(s.target.value),placeholder:"sk-…",className:Q}),e.jsx(ne,{children:d?"Leave blank to keep the saved key, or enter a new key to replace it.":"Leave blank if your endpoint needs no key (e.g. a local model)."})]}),e.jsxs("fieldset",{className:"m-0 min-w-0 border-0 p-0",children:[e.jsxs("legend",{className:"float-left mb-2 w-full p-0 text-sm font-medium text-text-primary",children:["Models",e.jsx(re,{})]}),e.jsx("div",{className:"clear-both",children:x.map((s,r)=>{const g=W(s),u=s.idTouched&&g,j=te(s),A=!!j&&s.nameDirty,oe=q(s),C=Z(s),O=s.contextTouched&&oe,ae=s.maxTouched&&C;return e.jsxs("div",{className:T("pb-6",r>0?"border-t border-border pt-6":"pt-1"),style:r>0?{borderTopWidth:"0.5px"}:void 0,children:[e.jsxs("div",{className:"grid grid-cols-[1fr_1fr_2rem] items-end gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("label",{htmlFor:`custom-provider-model-${r}-id`,className:"mb-1 block text-xs font-normal text-text-secondary",children:"Model ID"}),e.jsx("input",{id:`custom-provider-model-${r}-id`,type:"text",value:s.id,onChange:t=>{const a=t.target.value;i(r,{id:a,...s.nameDirty?{}:{name:Se(a)}})},onBlur:()=>i(r,{idTouched:!0}),placeholder:"llama3.1:70b","aria-invalid":u?!0:void 0,className:T(Q,"font-mono",u&&V)})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("label",{htmlFor:`custom-provider-model-${r}-name`,className:"mb-1 block text-xs font-normal text-text-secondary",children:"Model name"}),e.jsx("input",{id:`custom-provider-model-${r}-name`,type:"text",value:s.name,onChange:t=>i(r,{name:t.target.value,nameDirty:!0}),placeholder:"llama-3-1-70b","aria-invalid":A?!0:void 0,className:T(Q,A&&V)})]}),e.jsx("button",{type:"button","aria-label":`Remove model ${r+1}`,disabled:x.length===1||p,className:"mb-0.5 flex size-9 items-center justify-center rounded-md text-text-secondary transition-colors hover:text-text-primary disabled:opacity-40",onClick:()=>w(t=>t.filter((a,m)=>m!==r)),children:e.jsx(L,{name:"trash",className:"size-4"})})]}),u?e.jsx(ee,{children:g}):null,A?e.jsx(ee,{children:j}):null,e.jsxs("div",{className:"mt-2",children:[e.jsxs("button",{type:"button","aria-expanded":s.advancedExpanded,"aria-controls":`custom-provider-model-${r}-advanced`,className:"flex cursor-pointer items-center gap-1.5 text-sm font-medium text-text-primary",onClick:()=>i(r,{advancedExpanded:!s.advancedExpanded}),children:[e.jsx(L,{name:"chevron-down",className:T("size-4 text-text-secondary transition-transform",s.advancedExpanded?"":"-rotate-90")}),"Advanced"]}),s.advancedExpanded?e.jsxs("div",{id:`custom-provider-model-${r}-advanced`,className:"mt-3 space-y-4 pl-6",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`custom-provider-model-${r}-context-length`,className:"mb-1.5 block text-xs font-medium text-text-secondary",children:["Context length",e.jsx(re,{})]}),e.jsx("input",{id:`custom-provider-model-${r}-context-length`,type:"number",min:1,inputMode:"numeric",value:s.contextLength,onChange:t=>i(r,{contextLength:t.target.value}),onBlur:()=>i(r,{contextTouched:!0}),placeholder:ke,"aria-invalid":O?!0:void 0,className:T(Q,O&&V)}),O?e.jsx(ee,{children:oe}):s.contextLength.trim()===""?e.jsx(ne,{children:"Model's total token window."}):null]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`custom-provider-model-${r}-max-output-tokens`,className:"mb-1.5 block text-xs font-medium text-text-secondary",children:["Max output tokens",e.jsx(re,{})]}),e.jsx("input",{id:`custom-provider-model-${r}-max-output-tokens`,type:"number",min:1,inputMode:"numeric",value:s.maxOutputTokens,onChange:t=>i(r,{maxOutputTokens:t.target.value}),onBlur:()=>i(r,{maxTouched:!0}),placeholder:Ee,"aria-invalid":ae?!0:void 0,className:T(Q,ae&&V)}),ae?e.jsx(ee,{children:C}):s.maxOutputTokens.trim()===""?e.jsx(ne,{children:"Longest reply the model allows — use its real limit."}):null]}),k&&k.length>0?e.jsxs("div",{children:[e.jsxs("label",{className:"flex w-fit cursor-pointer items-center gap-2 select-none",children:[e.jsx("input",{type:"checkbox",className:"size-4 shrink-0 cursor-pointer accent-primary-button-bg disabled:cursor-not-allowed disabled:opacity-50",checked:s.reasoningEfforts!==void 0,"aria-label":`Enable reasoning effort for model ${r+1}`,disabled:p,onChange:t=>i(r,{reasoningEfforts:t.target.checked?[]:void 0})}),e.jsx("span",{className:"text-text-secondary text-xs font-medium",children:"Reasoning effort"})]}),s.reasoningEfforts!==void 0?e.jsx("div",{role:"group","aria-label":`Supported reasoning efforts for model ${r+1}`,className:"mt-2 flex flex-wrap gap-2",children:k.map(t=>{var m;const a=((m=s.reasoningEfforts)==null?void 0:m.includes(t))??!1;return e.jsx("button",{type:"button","aria-pressed":a,disabled:p,className:T("rounded-full border px-3 py-1 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring/40 disabled:opacity-50",a?"border-primary-button-bg bg-primary-button-bg text-primary-button-text":"border-border text-text-secondary hover:bg-ghost-button-hover"),onClick:()=>{var J;return i(r,{reasoningEfforts:a?(J=s.reasoningEfforts)==null?void 0:J.filter(de=>de!==t):[...s.reasoningEfforts??[],t]})},children:t},t)})}):null]}):null]}):null]})]},r)})}),e.jsxs(B.Secondary,{size:"small",type:"button",className:"mt-4 w-fit",onClick:()=>w(s=>[...s,pe()]),children:[e.jsx(L,{name:"plus",className:"size-3.5"}),"Add model"]})]})]}),e.jsxs("div",{className:"shrink-0 space-y-3 border-t border-border px-5 py-4",children:[E?e.jsx("p",{className:"text-failure-bg text-sm",children:E}):null,e.jsx(B.Primary,{type:"submit",size:"large",disabled:!le||p,className:"w-full",children:d?"Save changes":"Add provider"})]})]})})},Ue=Me;function Pe(n){return"baseUrl"in n&&typeof n.baseUrl=="string"?n.baseUrl:""}var Te=()=>{const{modelCatalog:n}=be(),o=fe(),[b,k]=l.useState(""),[p,E]=l.useState([]),[d,c]=l.useState([]),[S,z]=l.useState(!0),[F,M]=l.useState(null),[$,y]=l.useState(null),[x,w]=l.useState(!1),[I,U]=l.useState(null),[X,P]=l.useState(null),[G,v]=l.useState(null),[i,K]=l.useState(!1),[f,D]=l.useState(null),_=l.useMemo(()=>(d??[]).reduce((t,a)=>(t[a.name]=a.logo??"",t),{}),[d]),h=b.trim().toLowerCase(),W=l.useCallback(async()=>{z(!0),M(null);try{const[t,a]=await Promise.all([n.listModelProviders(),n.getModelProviderCatalog()]);E(t),c(a)}catch(t){M(Y(t,"Failed to load model providers"))}finally{z(!1)}},[n]);l.useEffect(()=>{W()},[W]);const te=l.useMemo(()=>new Set(p.map(t=>t.type)),[p]),q=l.useMemo(()=>p.filter(t=>{var a;return((a=t.name)==null?void 0:a.toLowerCase().includes(h))||t.models.some(m=>m.name.toLowerCase().includes(h)||m.id.toLowerCase().includes(h))}),[p,h]),Z=l.useMemo(()=>d.filter(t=>t.type!=="custom"&&!te.has(t.type)&&(t.name.toLowerCase().includes(h)||t.models.some(a=>a.name.toLowerCase().includes(h)||a.id.toLowerCase().includes(h)))),[d,te,h]),le=l.useMemo(()=>{var t;return(t=d.find(a=>a.type==="custom"))==null?void 0:t.supportedReasoningEfforts},[d]),se=l.useMemo(()=>{const t=new Map;for(const a of d)t.set(a.type,a.models);return t},[d]),H=()=>{U(null),P(null),v(null)},R=async(t,a)=>{w(!0),M(null);try{await t(),await W(),H()}catch(m){throw a?a(m):o==null?M(Y(m,"Request failed")):o.showError(m),m}finally{w(!1)}},s=async(t,a)=>{v(null),await R(async()=>{await n.createModelProvider({type:t.type,name:t.name,...a.baseUrl?{baseUrl:a.baseUrl}:{},apiKey:a.apiKey,models:t.models})},m=>v(Y(m,"Request failed")))},r=async(t,a)=>{v(null),await R(async()=>{await n.updateModelProvider({id:t.id,type:t.type,name:t.name,...a.baseUrl?{baseUrl:a.baseUrl}:{},apiKey:a.apiKey,models:t.models})},m=>v(Y(m,"Request failed"))),o==null||o.showSuccess({title:`${t.name} updated`})},g=t=>{n.deleteModelProvider&&R(async()=>{await n.deleteModelProvider({id:t.id})}).catch(()=>{})},u=(t,a)=>{R(async()=>{await n.updateModelProvider({id:t.id,type:t.type,name:t.name,...t.baseUrl?{baseUrl:t.baseUrl}:{},apiKey:"",models:a})}).catch(()=>{})},j=async t=>{y(null),await R(async()=>{await n.createModelProvider({type:"custom",name:t.name,baseUrl:t.baseUrl,apiKey:t.apiKey,models:t.models})},a=>y(Y(a,"Request failed"))),setTimeout(()=>{o==null||o.showSuccess({title:`${t.name} added`})},0)},A=async t=>{if(!f)return;const a=f;y(null),await R(async()=>{await n.updateModelProvider({id:a.id,type:a.type,name:a.name,baseUrl:t.baseUrl,apiKey:t.apiKey,models:t.models})},m=>y(Y(m,"Request failed"))),setTimeout(()=>{o==null||o.showSuccess({title:"Model provider updated",description:`${a.name} was updated successfully.`})},0)},oe=f?{name:f.name,baseUrl:f.baseUrl??"",models:f.models}:void 0,C=I!=null?p.find(t=>t.id===I)??null:null,O=X!=null?d.find(t=>t.type===X)??null:null,ae=C!=null||O!=null;return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Models"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Connect providers and choose which models are available."}),F?e.jsx("p",{className:"mt-3 rounded-md border border-failure-bg/30 bg-failure-bg/10 px-3 py-2 text-sm text-failure-bg",children:F}):null,e.jsx("div",{className:"mt-4 flex-1 overflow-y-hidden",children:e.jsxs("div",{className:"flex h-full flex-col gap-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:"flex-1",children:e.jsx(ge,{query:b,setQuery:k,placeholder:"Search providers and models"})}),e.jsxs(B.Secondary,{type:"button",onClick:()=>{y(null),D(null),K(!0)},children:[e.jsx(L,{name:"plus",size:"1rem",className:"mr-1"}),"Add Custom Provider"]})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-2 overflow-y-auto",children:[S?e.jsx("p",{className:"py-8 text-center text-sm text-text-secondary",children:"Loading…"}):null,!S&&q.length>0?e.jsxs("section",{"aria-labelledby":"configured-providers-heading",children:[e.jsx("div",{id:"configured-providers-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:"Configured"}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:q.map(t=>{const a=se.get(t.type)??[],m=new Set(t.models.map(N=>N.id)),J=a.filter(N=>!m.has(N.id)),de=_[t.name];return e.jsxs("article",{className:"border-b border-border p-3 last:border-b-0",children:[e.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:de?e.jsx(ie,{src:de,alt:t.name,className:"size-4.5"}):e.jsx(L,{name:"cpu",className:"size-4.5"})}),e.jsx("h5",{className:"truncate text-base font-medium text-text-primary",children:t.name})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 sm:justify-end",children:[e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full border border-border bg-secondary-bg/40 px-2 py-0.5 text-xs font-medium text-success-bg",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-success-bg"}),"Connected"]}),e.jsxs(B.Secondary,{size:"small",className:"text-[0.8125rem]",type:"button","aria-label":`Edit ${t.name}`,title:`Edit ${t.name}`,disabled:x,onClick:()=>{t.type==="custom"?(H(),y(null),D(t),K(!0)):(v(null),P(null),U(t.id))},children:[e.jsx(L,{name:"pencil",className:"size-3.5"}),"Edit"]}),n.deleteModelProvider?e.jsx(B.Secondary,{size:"small",className:"transition-colors hover:bg-failure-bg/10 hover:text-failure-bg",type:"button",disabled:x,onClick:()=>{g(t)},children:"Remove"}):null]})]}),e.jsxs("div",{className:"mt-3 overflow-hidden rounded-lg border border-border bg-secondary-bg/30",children:[t.models.map(N=>e.jsxs("div",{className:"flex min-h-10 items-center gap-3 border-b border-border px-3 py-2 text-sm text-text-primary last:border-b-0",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:N.name}),e.jsx("button",{type:"button","aria-label":`Remove ${N.name}`,disabled:x,className:"inline-flex size-7 shrink-0 items-center justify-center rounded-md text-text-secondary hover:bg-ghost-button-hover hover:text-ghost-button-text focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring disabled:opacity-50",onClick:()=>{u(t,t.models.filter(he=>he.id!==N.id))},children:e.jsx(L,{name:"trash",className:"size-3.5"})})]},N.id)),J.length>0?e.jsxs("section",{children:[e.jsxs("div",{className:"border-b border-border bg-secondary-bg/40 px-3 py-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Available to add · ",J.length]}),J.map(N=>e.jsxs("div",{className:"flex min-h-12 items-center gap-3 border-b border-border px-3 py-2 text-sm text-text-primary last:border-b-0",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:N.name}),e.jsx(B.Secondary,{size:"small",type:"button",disabled:x,onClick:()=>{u(t,[...t.models,N])},children:"Add"})]},N.id))]}):null]})]},t.id)})})]}):null,!S&&Z.length>0?e.jsxs("section",{"aria-labelledby":"available-providers-heading",className:"mt-2",children:[e.jsx("div",{id:"available-providers-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:"Available"}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:Z.map(t=>{const a=_[t.name];return e.jsx("article",{className:"border-b border-border p-3 last:border-b-0",children:e.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:a?e.jsx(ie,{src:a,alt:t.name,className:"size-4.5"}):e.jsx(L,{name:"cpu",className:"size-4.5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h5",{className:"truncate text-base font-medium text-text-primary",children:t.name}),e.jsx("p",{className:"truncate text-sm text-text-secondary",children:t.models.map(m=>m.name).join(" · ")})]})]}),e.jsxs(B.Secondary,{type:"button",disabled:x,onClick:()=>{v(null),U(null),P(t.type)},children:[e.jsx(L,{name:"wrench",className:"size-4"}),"Configure"]})]})},t.type)})})]}):null,!S&&q.length===0&&Z.length===0?e.jsx("div",{className:"flex flex-1 items-center justify-center rounded-xl border border-dashed border-border p-8 text-center text-sm text-text-secondary",children:h?`No providers match “${b.trim()}”.`:"No model providers yet."}):null]}),e.jsx(Ce,{open:ae,onOpenChange:t=>{t||H()},onSave:t=>{if(C)return r(C,t);if(O)return s(O,t)},title:C?"Edit Provider Details":"Configure Provider Details",initialBaseUrl:C?C.baseUrl??"":O?Pe(O):"",requireApiKey:C==null,submitLabel:C?"Save":"Create",busy:x,error:G}),e.jsx(Ue,{open:i,onOpenChange:t=>{K(t),t||(y(null),D(null))},isEditMode:f!==null,initialValues:oe,onSubmit:f?A:j,reasoningEffortOptions:le,busy:x,error:$},(f==null?void 0:f.id)??"add-custom-provider")]})})]})},Oe=Te;export{Oe as default};
@@ -0,0 +1 @@
1
+ import{aL as V,D as H,r,aM as B,j as e,S as Q,I as N,ac as Y,K as R,aO as J,aP as W,aQ as X,e as Z,aR as ee,ah as te}from"./index-BIRSKAK8.js";var se={execTimeoutMs:3e5,autoStopIntervalInMinutes:15,autoArchiveIntervalInMinutes:10080,autoDeleteIntervalInMinutes:43200},F=te("h-11 shadow-sm");function U(s){if(s.trim()==="")return null;const l=Number(s);return!Number.isFinite(l)||l<0?null:l}var ae=({open:s,onOpenChange:l,onSave:d,title:g,description:I,initialConfig:D=null,requireApiKey:y=!0,busy:w=!1,error:C})=>{const[m,k]=r.useState(""),[u,x]=r.useState(""),[M,i]=r.useState(""),[p,o]=r.useState(""),[b,f]=r.useState(""),[P,v]=r.useState(!1),S=()=>{k(""),x(""),i(""),o(""),f(""),v(!1)};r.useEffect(()=>{if(!s)return;const a=D??se;k(String(a.execTimeoutMs)),x(String(a.autoStopIntervalInMinutes)),i(String(a.autoArchiveIntervalInMinutes)),o(String(a.autoDeleteIntervalInMinutes)),f(""),v(!1)},[s,D]);const $=a=>{a||S(),l(a)},h=U(m),A=U(u),T=U(M),z=U(p),_=b.trim(),K=(!y||!!_)&&h!=null&&A!=null&&T!=null&&z!=null,E=async a=>{if(a.preventDefault(),!(!K||w||h==null||A==null||T==null||z==null))try{await d({execTimeoutMs:h,autoStopIntervalInMinutes:A,autoArchiveIntervalInMinutes:T,autoDeleteIntervalInMinutes:z,apiKey:_}),S(),l(!1)}catch{}};return e.jsx(J,{open:s,onOpenChange:$,title:g,description:I,contentSized:!0,headerIcon:e.jsx("span",{className:"flex size-11 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:e.jsx(N,{name:"cube",className:"size-6"})}),children:e.jsxs("form",{className:"flex flex-col overflow-y-auto p-5 md:p-6",onSubmit:E,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"sandbox-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",y?null:e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"sandbox-api-key",type:"password",required:y,value:b,onChange:a=>{f(a.target.value)},placeholder:y?"dtn_...":"Leave blank to keep existing",autoFocus:!0,className:F})]}),e.jsxs(W,{expanded:P,onChange:(a,t)=>v(t),className:"rounded-md border border-border",children:[e.jsx(X,{className:"px-3 py-2.5",children:e.jsxs("span",{className:"flex w-full items-center justify-between text-sm font-medium text-text-primary",children:["Advanced settings",e.jsx(N,{name:"chevron-down",className:Z("size-4 shrink-0 text-text-secondary transition-transform duration-200",P?"rotate-0":"-rotate-90")})]})}),e.jsxs(ee,{className:"space-y-4 border-t border-border px-3 pb-3 pt-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sandbox-exec-timeout",className:"mb-1.5 block text-sm font-medium text-text-primary",children:"Exec timeout (ms)"}),e.jsx("input",{id:"sandbox-exec-timeout",type:"number",min:0,required:!0,value:m,onChange:a=>{k(a.target.value)},placeholder:"300000",className:F})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sandbox-auto-stop",className:"mb-1.5 block text-sm font-medium text-text-primary",children:"Auto-stop interval (minutes)"}),e.jsx("input",{id:"sandbox-auto-stop",type:"number",min:0,required:!0,value:u,onChange:a=>{x(a.target.value)},placeholder:"15",className:F})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sandbox-auto-archive",className:"mb-1.5 block text-sm font-medium text-text-primary",children:"Auto-archive interval (minutes)"}),e.jsx("input",{id:"sandbox-auto-archive",type:"number",min:0,required:!0,value:M,onChange:a=>{i(a.target.value)},placeholder:"10080",className:F})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sandbox-auto-delete",className:"mb-1.5 block text-sm font-medium text-text-primary",children:"Auto-delete interval (minutes)"}),e.jsx("input",{id:"sandbox-auto-delete",type:"number",min:0,required:!0,value:p,onChange:a=>{o(a.target.value)},placeholder:"43200",className:F})]})]})]})]}),e.jsxs("div",{className:"mt-6 space-y-3",children:[C?e.jsx("p",{className:"text-failure-bg text-sm",children:C}):null,e.jsx(R.Primary,{type:"submit",size:"large",disabled:!K||w,className:"w-full shrink-0",children:"Save"})]})]})})},ne=ae,re=1e4,O=({execTimeoutMs:s,autoStopIntervalInMinutes:l,autoArchiveIntervalInMinutes:d,autoDeleteIntervalInMinutes:g})=>({execTimeoutMs:s,autoStopIntervalInMinutes:l,autoArchiveIntervalInMinutes:d,autoDeleteIntervalInMinutes:g}),le=s=>{switch(s){case"pending":return{label:"Syncing image...",className:"text-warning-bg"};case"ready":return{label:"Connected",className:"text-success-bg"};case"failed":return{label:"Sync failed",className:"text-failure-bg"};default:return{label:s,className:"text-text-secondary"}}},ie=()=>{const{sandboxCatalog:s}=V(),l=H(),[d,g]=r.useState([]),[I,D]=r.useState([]),[y,w]=r.useState(!0),[C,m]=r.useState(null),[k,u]=r.useState(null),[x,M]=r.useState(!1),[i,p]=r.useState(null),[o,b]=r.useState(null),f=r.useCallback(async({quiet:t=!1}={})=>{if(s){t||w(!0),m(null);try{const[n,c]=await Promise.all([s.listSandboxProviders(),s.getSandboxProviderCatalog()]);g(n),D(c)}catch(n){m(B(n,"Failed to load sandbox providers"))}finally{t||w(!1)}}},[s]);r.useEffect(()=>{f()},[f]);const P=d.some(t=>t.snapshotSyncStatus.status==="pending");r.useEffect(()=>{if(!s||!P)return;const t=s;let n=!1,c;function j(){c=window.setTimeout(()=>{q()},re)}async function q(){try{const L=await t.listSandboxProviders();if(n)return;g(L),m(null),L.some(G=>G.snapshotSyncStatus.status==="pending")&&j()}catch(L){if(n)return;m(B(L,"Failed to refresh sandbox providers")),j()}}return j(),()=>{n=!0,c!==void 0&&window.clearTimeout(c)}},[s,P]);const v=d.length>0,S=r.useMemo(()=>{if(v)return[];const t=new Set(d.map(n=>n.data.catalogId));return I.filter(n=>!t.has(n.id))},[I,d,v]),$=r.useMemo(()=>o?O(o):i?O(i):null,[o,i]);if(!s)return e.jsx("p",{className:"text-sm text-text-secondary",children:"Sandbox provider catalog is not available."});const h=async(t,n=m)=>{M(!0),m(null);try{await t(),await f({quiet:!0})}catch(c){throw n(B(c,"Request failed")),c}finally{M(!1)}},A=async t=>{i&&(u(null),await h(async()=>{await s.createSandboxProvider({catalogId:i.id,name:i.name,type:i.type,...O(t),apiKey:t.apiKey})},u),p(null),setTimeout(()=>{l==null||l.showSuccess({title:`${i.name} configured`})},0))},T=async t=>{o&&(u(null),await h(async()=>{await s.updateSandboxProvider({id:o.id,...O(t),...t.apiKey?{apiKey:t.apiKey}:{}})},u),b(null),setTimeout(()=>{l==null||l.showSuccess({title:`${o.name} updated`})},0))},z=t=>{h(async()=>{await s.updateSandboxProvider({id:t.id,...O(t)})}).catch(()=>{})},_=t=>{const n=s.deleteSandboxProvider;n&&h(async()=>{await n({id:t.id})}).catch(()=>{})},K=i!=null||o!=null,E=o!=null,a=o?`Update ${o.name}`:i?`Configure ${i.name}`:"Configure sandbox provider";return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Sandbox providers"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Choose a provider that runs sandboxes for code, files and shell commands. Only one can be active at a time."}),C?e.jsx("p",{className:"mt-3 rounded-md border border-failure-bg/30 bg-failure-bg/10 px-3 py-2 text-sm text-failure-bg",children:C}):null,e.jsx("div",{className:"mt-4 flex-1 overflow-y-auto",children:y?e.jsx("p",{className:"text-sm text-text-secondary",children:"Loading sandbox providers…"}):e.jsxs("div",{className:"space-y-6",children:[d.length>0?e.jsxs("section",{children:[e.jsxs("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Configured · ",d.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:d.map(t=>{const n=t.data,c=le(t.snapshotSyncStatus.status),j=t.snapshotSyncStatus.statusReason,q=e.jsxs("span",{className:`inline-flex items-center gap-1.5 text-sm font-medium ${c.className}`,children:[t.snapshotSyncStatus.status==="pending"?e.jsx(Q,{size:16,"aria-label":"Syncing snapshot image"}):t.snapshotSyncStatus.status==="ready"?e.jsx("span",{className:"size-2 rounded-full bg-success-bg","aria-hidden":!0}):t.snapshotSyncStatus.status==="failed"?e.jsx(N,{name:"triangle-exclamation",className:"size-4"}):null,c.label]});return e.jsxs("article",{className:"flex flex-col gap-3 border-b border-border p-3 last:border-b-0 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:e.jsx(N,{name:"cube",className:"size-4.5"})}),e.jsx("div",{className:"min-w-0",children:e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:n.name})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 sm:justify-end",children:[q,j?e.jsx(Y,{content:j,children:e.jsx("button",{type:"button","aria-label":"Snapshot sync status details",className:"inline-flex text-text-secondary transition-colors hover:text-text-primary",children:e.jsx(N,{name:"info",className:"size-4"})})}):null,t.snapshotSyncStatus.status==="failed"?e.jsx(R.Ghost,{size:"small",type:"button",disabled:x,onClick:()=>{z(n)},children:"Retry"}):null,e.jsx(R.Secondary,{size:"small",type:"button",disabled:x,onClick:()=>{u(null),p(null),b(n)},children:"Update"}),s.deleteSandboxProvider?e.jsx(R.Ghost,{size:"small",className:"text-text-secondary",type:"button",disabled:x,onClick:()=>{_(n)},children:"Remove"}):null]})]},n.id)})})]}):null,v?null:e.jsxs("section",{children:[e.jsxs("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Available · ",S.length]}),S.length===0?e.jsx("p",{className:"text-sm text-text-secondary",children:I.length>0?"All catalog providers are configured.":"No sandbox providers in the catalog."}):e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:S.map(t=>e.jsxs("article",{className:"flex flex-col gap-3 border-b border-border p-3 last:border-b-0 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:e.jsx(N,{name:"cube",className:"size-4.5"})}),e.jsx("div",{className:"min-w-0",children:e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:t.name})})]}),e.jsx(R.Secondary,{type:"button",disabled:x,onClick:()=>{u(null),b(null),p(t)},children:"Configure"})]},t.id))})]})]})}),e.jsx(ne,{open:K,onOpenChange:t=>{t||(u(null),p(null),b(null))},onSave:E?T:A,title:a,description:E?"Update this sandbox provider. Leave API key blank to keep the existing key.":"Configure this sandbox provider. API key is never stored in the catalog.",initialConfig:$,requireApiKey:!E,busy:x,error:k})]})},de=ie;export{de as default};
@@ -0,0 +1 @@
1
+ import{A as ge,B as Le,D as be,r as l,E as xe,F as Se,y as pe,G as Ke,j as e,P as Qe,H as We,J as ce,q as ue,K as H,I as A,L as Ye,M as ke,N as Te,O as Ze,Q as Je,R as Ce,U as J,V as Xe,W as X,X as et,Y as tt,Z as st,$ as nt,a0 as at,a1 as rt,a2 as lt,a3 as it,a4 as ot,e as $,a5 as Ee,a6 as ct,a7 as dt,a8 as ut,c as mt,a9 as xt,aa as me,d as ht,ab as ft,ac as gt,a as bt,ad as pt,ae as Nt,af as yt,ag as jt,ah as ze,i as vt,ai as wt}from"./index-BIRSKAK8.js";function Fe({value:t,selectedLabel:s,onValueChange:i,onAgentPicked:a,disabled:r=!1,onBuildAgent:d,allOption:b,"aria-label":y="Agent",placeholder:m="Search agent",className:f}){const[u,p]=l.useState(!1),[j,o]=l.useState(""),[w,E]=l.useState(null),g=l.useRef(null),k=l.useRef(null),C=l.useRef(null),z=l.useRef(null),q=l.useId(),{agents:R,isInitialLoading:F,isSearching:v,loadingMore:Q,hasMore:B,error:D,listRef:I,sentinelRef:G}=it({enabled:u&&!r,query:j});l.useEffect(()=>{u||o("")},[u]),l.useLayoutEffect(()=>{if(!u){E(null);return}const h=()=>{const c=k.current;if(!c)return;const N=c.getBoundingClientRect();E({top:N.bottom+4,left:N.left,width:N.width})};return h(),window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),()=>{window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}},[u]),l.useEffect(()=>{if(!u)return;const h=c=>{var N,S;c.target instanceof Node&&((N=g.current)!=null&&N.contains(c.target)||(S=z.current)!=null&&S.contains(c.target)||p(!1))};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[u]);const O=()=>{var h;p(!1),o(""),(h=C.current)==null||h.blur()},_=h=>{const c=ue(h);i(c),a==null||a(h),O()},W=()=>{b!=null&&(i(b.value),O())},P=u?j:s,U=j.trim(),V=!F&&D!=null,L=!F&&D==null&&R.length===0&&U==="",K=!F&&D==null&&R.length===0&&U!=="",ee=u&&w!=null&&!r?ot.createPortal(e.jsxs("div",{ref:z,className:ct("fixed z-[200] flex max-h-64 flex-col overflow-hidden"),style:{top:w.top,left:w.left,width:w.width},onMouseDown:h=>h.stopPropagation(),children:[e.jsxs("div",{ref:I,id:q,role:"listbox","aria-label":y,className:"min-h-0 flex-1 overflow-y-auto p-1",children:[b!=null&&U===""?e.jsxs("button",{type:"button",role:"option","aria-selected":t===b.value,className:Ee(),onClick:W,children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:b.label}),e.jsx(A,{name:"check",className:$("ml-auto size-4 shrink-0",t===b.value?"opacity-100":"opacity-0")})]}):null,F?e.jsx("p",{className:"text-text-secondary px-3 py-5 text-center text-sm",role:"status",children:"Loading…"}):V?e.jsx("p",{className:"text-failure-bg px-3 py-5 text-center text-sm",role:"alert",children:D}):L?e.jsx("p",{className:"text-text-secondary px-3 py-5 text-center text-sm",children:"No Agents created yet"}):K?e.jsxs("p",{className:"text-text-secondary px-3 py-5 text-center text-sm",role:"status",children:['No agents match "',U,'".']}):e.jsxs(e.Fragment,{children:[v?e.jsx("p",{className:"sr-only",role:"status",children:"Searching…"}):null,R.map(h=>{const c=ue(h),N=t===c;return e.jsxs("button",{type:"button",role:"option","aria-selected":N,className:Ee(),onClick:()=>_(h),children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:h.name}),e.jsx(A,{name:"check",className:$("ml-auto size-4 shrink-0",N?"opacity-100":"opacity-0")})]},c)}),B?e.jsx("div",{ref:G,className:"flex h-6 shrink-0 items-center justify-center","aria-hidden":!0,children:Q?e.jsx("span",{className:"text-text-secondary text-[11px]",role:"status",children:"Loading more…"}):null}):null]})]}),L&&d!=null?e.jsx("div",{className:"flex justify-end border-t border-border px-2 pt-2",children:e.jsxs(H.Ghost,{type:"button",onClick:d,children:[e.jsx(A,{name:"plus",className:"size-3.5"}),"Build Agent"]})}):null]}),dt(g.current)):null;return e.jsxs("div",{ref:g,className:$("relative",f),children:[e.jsxs("div",{ref:k,className:ut(r?"cursor-not-allowed opacity-50":"cursor-text"),children:[e.jsx("input",{ref:C,type:"text",role:"combobox","aria-label":y,"aria-expanded":u,"aria-controls":u?q:void 0,"aria-autocomplete":"list",disabled:r,placeholder:m,value:P,className:"min-w-0 flex-1 bg-transparent outline-none placeholder:text-text-secondary/70 disabled:cursor-not-allowed",onFocus:()=>{r||p(!0)},onChange:h=>{r||(o(h.target.value),p(!0))},onKeyDown:h=>{var c;if(h.key==="Escape"){h.preventDefault(),p(!1),(c=C.current)==null||c.blur();return}h.key==="ArrowDown"&&!u&&!r&&(h.preventDefault(),p(!0))}}),e.jsx(A,{name:"chevron-down",className:"size-4 shrink-0 text-text-secondary"})]}),ee]})}var Ae=[{value:"America/New_York",label:"America/New_York (ET)"},{value:"America/Chicago",label:"America/Chicago (CT)"},{value:"America/Denver",label:"America/Denver (MT)"},{value:"America/Los_Angeles",label:"America/Los_Angeles (PT)"},{value:"UTC",label:"UTC"},{value:"Europe/London",label:"Europe/London (GMT/BST)"},{value:"Europe/Berlin",label:"Europe/Berlin (CET)"},{value:"Asia/Kolkata",label:"Asia/Kolkata (IST)"},{value:"Asia/Tokyo",label:"Asia/Tokyo (JST)"}];function Ie(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function St(t){const s=Ie(),i=new Set(Ae.map(r=>r.value));return[...[s,t].flatMap(r=>r==null||r.length===0||i.has(r)?[]:(i.add(r),[{value:r,label:r===s?`${r} (Local)`:r}])),...Ae]}var Me=[{value:1,label:"Mon"},{value:2,label:"Tue"},{value:3,label:"Wed"},{value:4,label:"Thu"},{value:5,label:"Fri"},{value:6,label:"Sat"},{value:0,label:"Sun"}],kt={"America/New_York":"ET","America/Chicago":"CT","America/Denver":"MT","America/Los_Angeles":"PT",UTC:"UTC","Europe/London":"GMT","Europe/Berlin":"CET","Asia/Kolkata":"IST","Asia/Tokyo":"JST"};function de(){return{name:"",task:"",recurrence:"daily",hour:9,minute:0,weekdays:[1],customCron:"0 9 * * *",timezone:Ie()}}function Tt(t){return kt[t]??t.split("/").pop()??t}function $e(t){return t.toString().padStart(2,"0")}function le({hour:t,minute:s}){const i=t>=12?"PM":"AM",a=t%12===0?12:t%12;return`${String(a)}:${$e(s)} ${i}`}function he(t){const s=t.minute,i=t.hour;switch(t.recurrence){case"hourly":return`${String(s)} * * * *`;case"daily":return`${String(s)} ${String(i)} * * *`;case"weekly":{const a=[...t.weekdays].sort((d,b)=>d-b),r=a.length>0?a.join(","):"*";return`${String(s)} ${String(i)} * * ${r}`}case"custom":return t.customCron.trim()}}function ae(t){const s=Tt(t.timezone),i=t.cron.trim().split(/\s+/);if(i.length!==5)return t.cron;const[a,r,d,b,y]=i;if(d!=="*"||b!=="*")return t.cron;const m=Number(a),f=Number(r);if(r==="*"&&y==="*"&&a!==void 0&&!Number.isNaN(m))return`Hourly at :${$e(m)} ${s}`;if(y==="*"&&r!==void 0&&a!==void 0&&!Number.isNaN(f)&&!Number.isNaN(m))return`Daily ${le({hour:f,minute:m})} ${s}`;if(y==="1-5"&&r!==void 0&&a!==void 0&&!Number.isNaN(f)&&!Number.isNaN(m))return`Weekdays ${le({hour:f,minute:m})} ${s}`;if(y!=null&&/^\d(?:,\d)*$/.test(y)&&r!==void 0&&a!==void 0&&!Number.isNaN(f)&&!Number.isNaN(m)){const u=y.split(",").map(p=>{var j;return((j=Me.find(o=>o.value===Number(p)))==null?void 0:j.label)??p});return u.length===1?`Every ${u[0]==="Mon"?"Monday":u[0]} ${le({hour:f,minute:m})} ${s}`:`${u.join(", ")} ${le({hour:f,minute:m})} ${s}`}return t.cron}function Re(t){const s=de(),i=t.cron.trim().split(/\s+/);if(i.length!==5)return{...s,name:t.name,task:t.task,timezone:t.timezone,recurrence:"custom",customCron:t.cron};const[a,r,d,b,y]=i,m=Number(a),f=Number(r);return d!=="*"||b!=="*"?{...s,name:t.name,task:t.task,timezone:t.timezone,recurrence:"custom",customCron:t.cron}:r==="*"&&y==="*"&&!Number.isNaN(m)?{...s,name:t.name,task:t.task,timezone:t.timezone,recurrence:"hourly",minute:m,customCron:t.cron}:y==="*"&&!Number.isNaN(f)&&!Number.isNaN(m)?{...s,name:t.name,task:t.task,timezone:t.timezone,recurrence:"daily",hour:f,minute:m,customCron:t.cron}:y!=null&&/^\d(?:,\d)*$/.test(y)&&!Number.isNaN(f)&&!Number.isNaN(m)?{...s,name:t.name,task:t.task,timezone:t.timezone,recurrence:"weekly",hour:f,minute:m,weekdays:y.split(",").map(Number),customCron:t.cron}:{...s,name:t.name,task:t.task,timezone:t.timezone,recurrence:"custom",customCron:t.cron,hour:Number.isNaN(f)?s.hour:f,minute:Number.isNaN(m)?s.minute:m}}function Ct(t,s=Date.now()){if(t==null)return"Never";const i=Date.parse(t);if(Number.isNaN(i))return"Never";const a=Math.round((s-i)/1e3);if(a<60)return"just now";const r=Math.round(a/60);if(r<60)return`${String(r)} min ago`;const d=Math.round(r/60);if(d<48)return`${String(d)} hour${d===1?"":"s"} ago`;const b=Math.round(d/24);return`${String(b)} day${b===1?"":"s"} ago`}var Et=[{value:"hourly",label:"Hourly"},{value:"daily",label:"Daily"},{value:"weekly",label:"Weekly"}],zt=Array.from({length:24},(t,s)=>({value:String(s),label:s.toString().padStart(2,"0")})),At=[0,15,30,45].map(t=>({value:String(t),label:`:${t.toString().padStart(2,"0")}`}));function Rt({values:t,onChange:s,agentId:i,agentLabel:a,onAgentIdChange:r,onAgentPicked:d,agentPickerDisabled:b=!1,onBuildAgent:y}){const m=he(t),f=ae({cron:m,timezone:t.timezone}),u=St(t.timezone),p=(o,w)=>{s({...t,[o]:w})},j=o=>{const E=t.weekdays.includes(o)?t.weekdays.filter(g=>g!==o):[...t.weekdays,o];s({...t,weekdays:E.length>0?E:[o]})};return e.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4",children:[e.jsxs("div",{className:"block",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Agent"}),e.jsx(Fe,{"aria-label":"Agent",placeholder:"Search agent",value:i,selectedLabel:a,onValueChange:o=>r==null?void 0:r(o),onAgentPicked:d,disabled:b||r==null,onBuildAgent:y})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Name"}),e.jsx("input",{value:t.name,onChange:o=>p("name",o.target.value),placeholder:"harness-daily-digest",className:ze("h-8"),required:!0})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Task"}),e.jsx("textarea",{value:t.task,onChange:o=>p("task",o.target.value),rows:3,placeholder:"Summarise yesterday's harness runs and post the digest…",className:ze("resize-y py-2"),required:!0})]}),e.jsxs("fieldset",{children:[e.jsx("legend",{className:"mb-1.5 text-sm font-medium",children:"Frequency"}),e.jsx("div",{className:"rounded-t-lg border border-border p-4",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"grid grid-cols-3 gap-1 rounded-lg border border-border bg-primary-bg p-1",children:Et.map(o=>{const w=t.recurrence===o.value;return e.jsx("button",{type:"button",className:$("rounded-md border px-2 py-2 text-sm font-medium transition-colors",w?"border-primary-button-bg/40 bg-primary-button-bg/10 font-semibold text-primary-button-bg":"border-transparent text-text-secondary hover:bg-ghost-button-hover"),"aria-pressed":w,onClick:()=>p("recurrence",o.value),children:o.label},o.value)})}),t.recurrence==="custom"?e.jsxs("div",{className:"rounded-md border border-border bg-secondary-bg/40 px-3 py-2",children:[e.jsx("span",{className:"block text-xs text-text-secondary",children:"Existing custom schedule"}),e.jsx("code",{className:"mt-1 block font-mono text-sm text-text-primary",children:t.customCron}),e.jsx("span",{className:"mt-1 block text-xs text-text-secondary",children:"Select Hourly, Daily, or Weekly to replace this schedule."})]}):null,t.recurrence==="weekly"?e.jsxs("fieldset",{children:[e.jsx("legend",{className:"mb-2 text-sm font-medium",children:"Days"}),e.jsx("div",{className:"flex gap-2",children:Me.map(o=>{const w=t.weekdays.includes(o.value);return e.jsx("button",{type:"button",className:$("min-w-0 flex-1 rounded-md border px-3 py-2 text-[0.8125rem] font-medium",w?"border-primary-button-bg/40 bg-primary-button-bg/10 font-semibold text-primary-button-bg":"border-border text-text-secondary hover:bg-ghost-button-hover"),"aria-pressed":w,onClick:()=>j(o.value),children:o.label},o.value)})})]}):null,e.jsxs("div",{className:"flex gap-4",children:[t.recurrence==="daily"||t.recurrence==="weekly"?e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Hour"}),e.jsx(ce,{"aria-label":"Hour",value:String(t.hour),options:zt,onValueChange:o=>p("hour",Number(o))})]}):null,t.recurrence!=="custom"?e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Minute"}),e.jsx(ce,{"aria-label":"Minute",value:String(t.minute),options:At,onValueChange:o=>p("minute",Number(o))})]}):null,e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Timezone"}),e.jsx(ce,{"aria-label":"Timezone",value:t.timezone,options:u,onValueChange:o=>p("timezone",o),menuClassName:"w-full min-w-0"})]})]})]})}),e.jsx("div",{className:"rounded-b-lg border border-t-0 border-border bg-primary-button-bg/10 px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(A,{name:"clock",className:"size-4 shrink-0 text-primary-button-bg"}),e.jsx("span",{className:"shrink-0 text-xs font-medium text-text-secondary",children:"Schedule"}),e.jsx("p",{className:"min-w-0 flex-1 truncate text-sm text-text-primary",children:f||"—"}),e.jsx("code",{className:"shrink-0 whitespace-nowrap font-mono text-[0.8125rem] font-bold text-text-secondary",children:m||"—"})]})})]})]})}function Dt(t){return t.startsWith("manual-")}function Pt(t){return t==="failed"?"failed":"success"}function Be(t){return t==="failed"?"Failed":t==="triggered"?"Triggered":"Scheduled"}function Oe(t){return Dt(t)?"Manual test":"Cron"}function Lt(t,s=5){return t.filter(a=>a.status!=="scheduled").slice(0,s).reverse()}function fe(t){if(t==null)return"—";const s=new Date(t);return Number.isNaN(s.getTime())?"—":new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",hour12:!0}).format(s)}function Ft({run:t}){return e.jsxs("div",{className:"flex flex-col gap-1 text-left text-xs",children:[e.jsx("p",{className:"text-text-primary font-medium",children:Be(t.status)}),e.jsx("p",{className:"text-text-secondary",children:Oe(t.name)}),e.jsxs("p",{className:"text-text-secondary",children:["Scheduled for: ",fe(t.scheduledFor)]}),t.triggeredAt!=null?e.jsxs("p",{className:"text-text-secondary",children:["Triggered at: ",fe(t.triggeredAt)]}):null,e.jsxs("p",{className:"text-text-secondary",children:["Triggered by: ",t.triggeredBy]})]})}var It={success:"border-emerald-600/30 bg-emerald-500/10 text-emerald-700 dark:border-emerald-400/35 dark:bg-emerald-500/15 dark:text-emerald-300",failed:"border-red-600/30 bg-red-500/10 text-red-700 dark:border-red-400/35 dark:bg-red-500/15 dark:text-red-300"};function _e({run:t}){const s=Pt(t.status),i=fe(t.triggeredAt??t.scheduledFor);return e.jsx(gt,{content:e.jsx(Ft,{run:t}),side:"top",children:e.jsx("span",{className:$("inline-flex size-6 shrink-0 items-center justify-center rounded-md border",It[s]),"aria-label":`${Be(t.status)} run at ${i}`,children:e.jsx(A,{name:s==="failed"?"triangle-exclamation":"check",className:"size-3.5"})})})}function Ue({status:t}){const s=t==="active";return e.jsxs("span",{className:$("inline-flex items-center gap-1.5 rounded-full border px-2.5 py-0.5 text-xs font-medium",s?"border-emerald-600/30 bg-emerald-500/10 text-emerald-700 dark:border-emerald-400/35 dark:bg-emerald-500/15 dark:text-emerald-300":"border-amber-600/30 bg-amber-500/10 text-amber-800 dark:border-amber-400/35 dark:bg-amber-500/15 dark:text-amber-300"),children:[e.jsx("span",{className:$("size-1.5 shrink-0 rounded-full",s?"bg-emerald-600 dark:bg-emerald-400":"bg-amber-600 dark:bg-amber-400"),"aria-hidden":!0}),s?"Active":"Paused"]})}function Mt(t,s){return t.find(i=>i.name===s||i.id===s)??null}function $t({connector:t,onConnected:s}){return vt()==null?null:e.jsx(wt,{connector:t,onConnected:s})}function ne({label:t,children:s}){return e.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-border px-3 py-2.5 last:border-b-0",children:[e.jsx("span",{className:"text-text-secondary shrink-0 text-[10px] font-semibold tracking-wide uppercase",children:t}),e.jsx("div",{className:"min-w-0 text-right text-sm text-text-primary",children:s})]})}function Bt({schedule:t,agentName:s,mcpMounts:i,onEditConfiguration:a}){const r=ge(),d=be(),{connectors:b,ensureLoaded:y,refreshConnectors:m,loading:f,error:u}=jt(),[p,j]=l.useState(!1),[o,w]=l.useState(null),E=ae({cron:t.cron,timezone:t.timezone}),g=async()=>{j(!0);try{const k=await r.createScheduleRun({scheduleId:t.id});w(k),d==null||d.showSuccess({title:"Test run started"})}catch(k){d==null||d.showError(k)}finally{j(!1)}};return l.useEffect(()=>{y()},[y]),l.useEffect(()=>{u!=null&&(d==null||d.showError(u))},[u,d]),e.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4",children:[e.jsxs("section",{className:"overflow-hidden rounded-lg border border-border bg-card-bg",children:[e.jsx(ne,{label:"Agent",children:s}),e.jsx(ne,{label:"Name",children:t.name}),e.jsx(ne,{label:"Status",children:e.jsx(Ue,{status:t.status})}),e.jsx(ne,{label:"Task",children:e.jsx("span",{className:"whitespace-pre-wrap break-words",children:t.task})}),e.jsx(ne,{label:"Frequency",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-1.5",children:[e.jsx("span",{children:E}),e.jsx("code",{className:"text-text-secondary font-mono text-xs",children:t.cron})]})}),e.jsx("div",{className:"flex justify-end px-3 py-2.5",children:e.jsxs(H.Secondary,{type:"button",size:"small",onClick:a,children:[e.jsx(A,{name:"pencil",className:"size-3.5"}),"Edit Configuration"]})})]}),e.jsxs("section",{className:"overflow-hidden rounded-lg border border-border bg-card-bg",children:[e.jsx("div",{className:"border-b border-border px-3 py-2",children:e.jsx("h3",{className:"text-text-secondary text-[10px] font-semibold tracking-wide uppercase",children:"Tool Authorization"})}),i.length===0?e.jsx("p",{className:"text-text-secondary px-3 py-3 text-sm",children:"No MCP connectors configured for this agent."}):e.jsx("ul",{className:"divide-y divide-border",children:i.map(k=>{const C=Mt(b,k.name),z=(C==null?void 0:C.authenticated)===!0,q=C==null&&!f;return e.jsxs("li",{className:"flex items-center gap-2 px-3 py-2.5",children:[e.jsx("span",{className:$("inline-flex size-4 shrink-0 items-center justify-center rounded-full border",z?"border-emerald-600/40 bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"border-border text-transparent"),"aria-hidden":!0,children:z?e.jsx(A,{name:"check",className:"size-3"}):null}),e.jsx("span",{className:"text-text-primary min-w-0 flex-1 truncate text-sm",children:k.name}),z?e.jsx("span",{className:"text-success-bg text-xs font-medium",children:"Connected"}):q?e.jsx("span",{className:"text-text-secondary text-xs",children:"Unavailable"}):C!=null&&C.authenticated===!1?e.jsx($t,{connector:C,onConnected:m}):f?e.jsx("span",{className:"text-text-secondary text-xs",children:"Loading…"}):null]},k.name)})})]}),e.jsxs("section",{className:"overflow-hidden rounded-lg border border-border bg-card-bg",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border px-3 py-2",children:[e.jsx("h3",{className:"text-text-secondary text-[10px] font-semibold tracking-wide uppercase",children:"Test Run"}),e.jsxs(H.Primary,{type:"button",disabled:p,size:"small",onClick:()=>void g(),children:[e.jsx(A,{name:p?"loader":"play",className:$("size-3.5",p&&"animate-spin")}),"Run Test"]})]}),o==null?e.jsx("p",{className:"text-text-secondary px-3 py-3 text-sm",children:"Run a one-off test using the schedule task. This does not change the cron pending run."}):e.jsxs("div",{className:"flex items-center gap-3 px-3 py-3",children:[e.jsx(_e,{run:o}),e.jsxs("div",{className:"min-w-0 text-sm",children:[e.jsx("p",{className:"text-text-primary font-medium",children:Oe(o.name)}),e.jsx("p",{className:"text-text-secondary",children:Ct(o.triggeredAt??o.scheduledFor)})]})]})]})]})}function Ot({open:t,onOpenChange:s,mode:i,schedule:a,initialAgentId:r="",onSaved:d}){const b=ge(),y=Le(),m=bt(),f=be(),[u,p]=l.useState(de),[j,o]=l.useState(r),[w,E]=l.useState(null),[g,k]=l.useState({kind:"form"}),[C,z]=l.useState(!1),[q,R]=l.useState(!1),[F,v]=l.useState(null),Q=l.useRef(j);Q.current=j;const B=g.kind==="form"?g.saved:g.schedule,D=i==="edit"&&g.kind==="form"&&g.saved==null&&a!=null,I=g.kind==="form"&&g.saved!=null,G=i==="create"&&g.kind==="form"&&g.saved==null,{allows:O}=xe({resourceType:"agent",resourceIds:j.length===0?[]:[j]});l.useEffect(()=>{if(!t){p(de()),o(r),E(null),v(null),k({kind:"form"}),R(!1);return}if(i==="edit"&&a!=null){p(Re({name:a.name,task:a.task,cron:a.cron,timezone:a.timezone})),o(a.agentId),E(null),k({kind:"form"});return}p(de()),o(r),E(null),k({kind:"form"})},[t,i,a,r]),l.useEffect(()=>{if(!t||i!=="create"||r.length===0)return;let c=!1;const N=r;return pt({server:y,agentKey:N}).then(S=>{c||S==null||Q.current===N&&(E(S),o(ue(S)))}).catch(()=>{}),()=>{c=!0}},[t,i,r,y]);const _=(w==null?void 0:w.name)??(B==null?void 0:B.agentName)??(a==null?void 0:a.agentName)??(j.length>0?j:""),W=l.useMemo(()=>{var N;return(((N=w==null?void 0:w.agentSpec)==null?void 0:N.mcpServers)??[]).map(Nt).filter(S=>S!=null).map(S=>({name:S}))},[w]),P=l.useMemo(()=>{const c=he(u);return u.name.trim().length>0&&u.task.trim().length>0&&c.length>0&&j.length>0&&(!G||O(j,"USE"))},[j,O,u,G]),U=c=>{k({kind:"test",schedule:c}),p(Re({name:c.name,task:c.task,cron:c.cron,timezone:c.timezone})),o(c.agentId)},V=async c=>{if(c.preventDefault(),!P)return;const N=he(u);z(!0),v(null);try{if(D&&a!=null){await b.updateSchedule({id:a.id,name:u.name.trim(),task:u.task.trim(),cron:N,timezone:u.timezone,status:a.status}),d==null||d(),s(!1);return}if(I&&g.kind==="form"&&g.saved!=null){const Y=await b.updateSchedule({id:g.saved.id,name:u.name.trim(),task:u.task.trim(),cron:N,timezone:u.timezone,status:"paused"});d==null||d(),U(Y),f==null||f.showSuccess({title:"Schedule saved as paused",description:ae({cron:Y.cron,timezone:Y.timezone})});return}const S=await b.createSchedule({agentId:j,name:u.name.trim(),task:u.task.trim(),cron:N,timezone:u.timezone,status:"paused"});d==null||d(),U(S),f==null||f.showSuccess({title:"Schedule saved as paused",description:ae({cron:S.cron,timezone:S.timezone})})}catch(S){const Y=S instanceof Error?S.message:"Failed to save schedule";v(Y)}finally{z(!1)}},L=async()=>{if(g.kind==="test"){R(!0),v(null);try{await b.updateSchedule({id:g.schedule.id,name:g.schedule.name,task:g.schedule.task,cron:g.schedule.cron,timezone:g.schedule.timezone,status:"active"}),d==null||d(),f==null||f.showSuccess({title:"Schedule activated"}),s(!1)}catch(c){const N=c instanceof Error?c.message:"Failed to activate schedule";v(N),f==null||f.showError(c)}finally{R(!1)}}},K=g.kind==="test"?"Test Schedule":D||I?"Edit Schedule":"New Schedule",ee=g.kind==="test"?`Recurring unattended runs of ${_}.`:D||I?"Update cadence and task for this schedule.":"Create a recurring unattended run for an agent.";let h;return g.kind==="test"?h=e.jsxs("div",{className:"flex flex-col gap-2",children:[F!=null?e.jsx("p",{className:"text-failure-bg text-sm",children:F}):null,e.jsx(H.Secondary,{type:"button",className:"w-full",disabled:q,onClick:()=>void L(),children:"Activate Schedule"})]}):h=e.jsxs("div",{className:"flex flex-col gap-2",children:[F!=null?e.jsx("p",{className:"text-failure-bg text-sm",children:F}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(H.Secondary,{type:"button",onClick:()=>s(!1),disabled:C,children:"Cancel"}),e.jsx(H.Primary,{type:"submit",form:"schedule-form",disabled:!P||C,children:"Save"})]})]}),e.jsx(yt,{open:t,onOpenChange:s,title:K,description:ee,anchor:"right",size:"xl",headerIcon:e.jsx("span",{className:"text-primary-button-bg inline-flex size-8 items-center justify-center",children:e.jsx(A,{name:g.kind==="test"||D||I?"calendar":"calendar-plus",className:"size-5"})}),footer:h,children:g.kind==="test"?e.jsx(Bt,{schedule:g.schedule,agentName:_,mcpMounts:W,onEditConfiguration:()=>{v(null),k({kind:"form",saved:g.schedule})}}):e.jsx("form",{id:"schedule-form",onSubmit:c=>void V(c),children:e.jsx(Rt,{values:u,onChange:p,agentId:j,agentLabel:_,onAgentIdChange:D||I?void 0:c=>{o(c),c.length===0&&E(null)},onAgentPicked:E,agentPickerDisabled:D||I,onBuildAgent:i==="create"&&(m==null?void 0:m.isComposerEnabled)===!0?()=>{s(!1),m.openAgentBuilder()}:void 0})})})}function De(t){return e.jsx(ft,{children:e.jsx(Ot,{...t})})}function _t({runs:t}){const s=Lt(t);return s.length===0?e.jsx("span",{className:"text-text-secondary text-sm",children:"—"}):e.jsx("div",{className:"flex items-center gap-1",children:s.map(i=>e.jsx(_e,{run:i},i.id))})}var Ut=[{value:"all",label:"All statuses"},{value:"active",label:"Active"},{value:"paused",label:"Paused"}],Pe=[10,25];function ie(t){return Math.min(Math.max(t,1),25)}function oe(t){const s=pe(t);return{nameQuery:s.q??"",statusFilter:s.status??"all",agentFilter:s.agent??"all"}}function Ht(t){const s=pe(window.location.search);if(!s.isNew)return{kind:"closed"};const i=t??s.agent;return{kind:"create",...i==null?{}:{agentId:i}}}function qt({schedule:t,running:s,canManage:i,canDelete:a,onRunNow:r,onEdit:d,onTogglePause:b,onDelete:y}){const m=mt("PermissionGuard");return e.jsxs("div",{className:"inline-flex items-center justify-end gap-1.5",children:[e.jsx(m,{allowed:i,children:e.jsxs(H.Secondary,{type:"button",disabled:s,"aria-label":`Run now ${t.name}`,size:"large",onClick:r,children:[e.jsx(A,{name:s?"loader":"play",className:$("size-3.5",s&&"animate-spin")}),"Run now"]})}),e.jsxs(xt,{align:"end",trigger:e.jsx("button",{type:"button",className:ht({variant:"ghost",size:"icon"}),"aria-label":`Actions for ${t.name}`,children:e.jsx(A,{name:"ellipsis"})}),children:[e.jsx(m,{allowed:i,children:e.jsxs(me,{onClick:d,children:[e.jsx(A,{name:"pencil",className:"size-3.5"}),"Edit"]})}),e.jsx(m,{allowed:i,children:e.jsxs(me,{onClick:b,children:[e.jsx(A,{name:t.status==="active"?"pause":"play",className:"size-3.5"}),t.status==="active"?"Pause":"Resume"]})}),e.jsx(m,{allowed:a,children:e.jsxs(me,{className:"text-failure-bg focus:text-failure-bg",onClick:y,children:[e.jsx(A,{name:"trash",className:"size-3.5"}),"Delete"]})})]})]})}function Vt({agentId:t}){const s=ge(),i=Le(),a=be(),[r,d]=l.useState([]),{allows:b}=xe({resourceType:"schedule",resourceIds:r.map(n=>n.id)}),[y,m]=l.useState({}),[f,u]=l.useState(!1),[p,j]=l.useState(()=>new Set),[o,w]=l.useState({}),[E,g]=l.useState(!0),[k,C]=l.useState(null),[z,q]=l.useState(()=>oe(window.location.search).nameQuery),[R,F]=l.useState(()=>oe(window.location.search).statusFilter),[v,Q]=l.useState(()=>t??oe(window.location.search).agentFilter),B=t??(v==="all"?null:v),{allows:D}=xe({resourceType:"agent",resourceIds:B==null?[]:[B]}),I=i.permissions==null||B==null||D(B,"USE"),[G,O]=l.useState(()=>Ht(t)),[_,W]=l.useState(null),[P,U]=l.useState(()=>ie(lt)),[V,L]=l.useState(void 0),[K,ee]=l.useState(void 0),[h,c]=l.useState([]),N=l.useRef(0),S=l.useRef(!1),Y=l.useCallback(async({rows:n,gen:x})=>{if(n.length===0){x===N.current&&m({});return}u(!0);try{const T=await Promise.allSettled(n.map(M=>s.listScheduleRuns({scheduleId:M.id})));if(x!==N.current)return;m(Object.fromEntries(n.map((M,Z)=>{const se=T[Z],Ve=(se==null?void 0:se.status)==="fulfilled"?se.value:[];return[M.id,Ve]})))}finally{x===N.current&&u(!1)}},[s]),te=l.useCallback(async({token:n,size:x,agentId:T})=>{const M=++N.current;g(!0),C(null);try{const Z=await s.listSchedules({limit:ie(x),...n===void 0||n===""?{}:{pageToken:n},...T==="all"?{}:{agentIds:[T]}});if(M!==N.current)return;d(Z.data),ee(Z.nextPageToken),Y({rows:Z.data,gen:M})}catch(Z){if(M!==N.current)return;const se=Z instanceof Error?Z.message:"Failed to load schedules";C(se),d([]),m({}),ee(void 0)}finally{M===N.current&&g(!1)}},[s,Y]),Ne=l.useCallback(n=>{const x=(n==null?void 0:n.size)??P,T=(n==null?void 0:n.agentId)??v;L(void 0),c([]),te({token:void 0,size:x,agentId:T})},[v,te,P]);l.useEffect(()=>{Se({agent:t===void 0&&v!=="all"?v:null,status:R==="all"?null:R,q:z.trim().length===0?null:z})},[v,t,R,z]),l.useEffect(()=>{t!==void 0&&Q(n=>n===t?n:(L(void 0),c([]),t))},[t]),l.useEffect(()=>{S.current||!pe(window.location.search).isNew||(S.current=!0,Se({isNew:null}))},[]),l.useEffect(()=>{const n=()=>{const x=oe(window.location.search);q(x.nameQuery),F(x.statusFilter),Q(T=>{const M=t??x.agentFilter;return T===M?T:(L(void 0),c([]),M)})};return window.addEventListener("popstate",n),()=>{window.removeEventListener("popstate",n)}},[t]),l.useEffect(()=>{te({token:V,size:P,agentId:v})},[v,P,V,te]);const re=l.useMemo(()=>{const n=z.trim().toLowerCase();return r.filter(x=>!(R!=="all"&&x.status!==R||n.length>0&&!x.name.toLowerCase().includes(n)))},[r,z,R]),ye=Ke(r),je=h.length>0||K!=null,He=async n=>{if(!b(n.id,"MANAGE"))return;const x=n.status==="active"?"paused":"active";try{await s.updateSchedule({...n,status:x}),await te({token:V,size:P,agentId:v})}catch(T){a==null||a.showError(T)}},qe=async n=>{if(b(n.id,"MANAGE")){j(x=>new Set(x).add(n.id));try{await s.createScheduleRun({scheduleId:n.id}),a==null||a.showSuccess({title:"Run started"});const x=await s.listScheduleRuns({scheduleId:n.id});m(T=>({...T,[n.id]:x}))}catch(x){a==null||a.showError(x)}finally{j(x=>{const T=new Set(x);return T.delete(n.id),T})}}},Ge=async n=>{if(b(n.id,"DELETE")){W(null);try{await s.deleteSchedule({id:n.id}),Ne()}catch(x){a==null||a.showError(x)}}},ve=()=>{K!=null&&(c(n=>[...n,V??""]),L(K))},we=()=>{if(h.length===0)return;const n=[...h],x=n.pop();c(n),L(x===""?void 0:x)};return e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-primary-bg",children:[e.jsx(Qe,{title:t===void 0?"Scheduled Agents":void 0,end:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-full sm:w-60",children:e.jsx(We,{query:z,setQuery:q,placeholder:"Search schedules by name"})}),e.jsx(ce,{value:R,onValueChange:F,options:Ut,className:"sm:w-40","aria-label":"Filter by status"}),t===void 0?e.jsx(Fe,{value:v,selectedLabel:v==="all"?"All agents":o[v]??v,onValueChange:n=>{Q(n),L(void 0),c([])},onAgentPicked:n=>{w(x=>({...x,[ue(n)]:n.name}))},allOption:{value:"all",label:"All agents"},className:"sm:w-48","aria-label":"Filter by agent",placeholder:"Search agent"}):null,e.jsxs(H.Primary,{type:"button",disabled:!I,onClick:()=>I&&O({kind:"create",agentId:v!=="all"?v:void 0}),children:[e.jsx(A,{name:"plus",className:"size-3.5"}),"Create Schedule"]})]})}),e.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-4 py-4",children:E?e.jsx("div",{className:"flex flex-col gap-2",role:"status","aria-label":"Loading schedules",children:Array.from({length:5},(n,x)=>e.jsx(Ye,{className:"h-12 w-full rounded-md"},x))}):k!=null?e.jsx("p",{className:"text-failure-bg px-3 py-8 text-center text-sm",children:k}):r.length===0?e.jsx(ke,{title:"No Schedules Found",description:"Create one to get started.",className:"min-h-full"}):re.length===0?e.jsxs("div",{className:"flex min-h-full flex-col",children:[e.jsx(ke,{title:"No Schedules Found",description:"No schedules match your filters.",className:"flex-1"}),je?e.jsx(Te,{pageSize:P,rowCount:0,canPrev:h.length>0,canNext:K!=null,onPrev:we,onNext:ve,pageSizeOptions:Pe,onPageSizeChange:n=>{const x=ie(n);U(x),L(void 0),c([])}}):null]}):e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border",children:[e.jsxs(Ze,{className:"min-w-[48rem]",children:[e.jsx(Je,{children:e.jsxs(Ce,{className:"hover:bg-transparent",children:[e.jsx(J,{children:"Name"}),e.jsx(J,{children:"Agent"}),ye?e.jsx(J,{children:"Created by"}):null,e.jsx(J,{children:"Frequency"}),e.jsx(J,{children:"Status"}),e.jsx(J,{children:"Last 5 runs"}),e.jsx(J,{children:e.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e.jsx(Xe,{children:re.map(n=>{const x=ae({cron:n.cron,timezone:n.timezone}),T=n.agentName??o[n.agentId]??n.agentId;return e.jsxs(Ce,{children:[e.jsx(X,{className:"text-text-primary font-medium",children:e.jsx("span",{className:"text-left !no-underline",children:n.name})}),e.jsx(X,{children:T}),ye?e.jsx(X,{children:e.jsx(et,{subject:n.createdBySubject})}):null,e.jsx(X,{children:x}),e.jsx(X,{children:e.jsx(Ue,{status:n.status})}),e.jsx(X,{children:f?e.jsx("span",{className:"text-text-secondary text-sm",children:"…"}):e.jsx(_t,{runs:y[n.id]??[]})}),e.jsx(X,{className:"text-right",children:e.jsx(qt,{schedule:n,running:p.has(n.id),canManage:b(n.id,"MANAGE"),canDelete:b(n.id,"DELETE"),onRunNow:()=>void qe(n),onEdit:()=>{b(n.id,"MANAGE")&&O({kind:"edit",schedule:n})},onTogglePause:()=>void He(n),onDelete:()=>{b(n.id,"DELETE")&&W(n)}})})]},n.id)})})]}),(re.length>0||je)&&e.jsx(Te,{pageSize:P,rowCount:re.length,canPrev:h.length>0,canNext:K!=null,onPrev:we,onNext:ve,pageSizeOptions:Pe,onPageSizeChange:n=>{const x=ie(n);U(x),L(void 0),c([])}})]})}),G.kind==="create"?e.jsx(De,{open:!0,mode:"create",initialAgentId:G.agentId??"",onOpenChange:n=>{n||O({kind:"closed"})},onSaved:()=>Ne()}):null,G.kind==="edit"?e.jsx(De,{open:!0,mode:"edit",schedule:G.schedule,onOpenChange:n=>{n||O({kind:"closed"})},onSaved:()=>void te({token:V,size:P,agentId:v})}):null,_!=null?e.jsxs(tt,{open:!0,onOpenChange:n=>{n||W(null)},"aria-label":"Delete schedule",className:"max-w-md",children:[e.jsx(st,{children:e.jsxs(nt,{children:[e.jsx(at,{children:"Delete schedule"}),e.jsxs("p",{className:"text-text-secondary text-sm",children:["“",_.name,"” will stop running. This cannot be undone."]})]})}),e.jsxs(rt,{children:[e.jsx(H.Secondary,{type:"button",onClick:()=>W(null),children:"Cancel"}),e.jsx(H.Destructive,{type:"button",disabled:!b(_.id,"DELETE"),onClick:()=>void Ge(_),children:"Delete"})]})]}):null]})}export{Vt as SchedulesPage};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ModelSettings-UWTBHQRG-L5KYrHBM.js","./index-Y_4XXAao.js","./index-B01pXqvC.css","./ConnectorSettings-QTAI4TQX-PySj_xEm.js","./SkillSettings-KQ6GQ7JW-oZVHsKV_.js","./SandboxSettings-BITQONS3-COVuckfo.js"])))=>i.map(i=>d[i]);
2
- import{g as h,i as v,aD as y,aa as j,aE as S,r as t,j as e,P as _,I as p,d as k,e as f,_ as d,S as w}from"./index-Y_4XXAao.js";var E=t.lazy(()=>d(()=>import("./ModelSettings-UWTBHQRG-L5KYrHBM.js"),__vite__mapDeps([0,1,2]),import.meta.url)),C=t.lazy(()=>d(()=>import("./ConnectorSettings-QTAI4TQX-PySj_xEm.js"),__vite__mapDeps([3,1,2]),import.meta.url)),N=t.lazy(()=>d(()=>import("./SkillSettings-KQ6GQ7JW-oZVHsKV_.js"),__vite__mapDeps([4,1,2]),import.meta.url)),D=t.lazy(()=>d(()=>import("./SandboxSettings-BITQONS3-COVuckfo.js"),__vite__mapDeps([5,1,2]),import.meta.url));function L(){return e.jsxs("div",{className:"flex flex-1 items-center justify-center py-8",role:"status","aria-live":"polite","aria-busy":"true",children:[e.jsx(w,{size:20,className:"text-text-secondary"}),e.jsx("span",{className:"sr-only",children:"Loading"})]})}var O=()=>{const{settingsOpen:n,settingsSection:l,setSettingsOpen:r}=h(),a=v(),u=y(),{refresh:m}=j(),i=S(),o=(a==null?void 0:a.skillCatalog)!=null,c=(a==null?void 0:a.sandboxCatalog)!=null,x=t.useCallback(()=>{r(!1)},[r]);t.useEffect(()=>{if(n)return()=>{m(),u==null||u()}},[n,m,u]),t.useEffect(()=>{!o&&l==="skills"&&r(n,"models"),!c&&l==="sandbox"&&r(n,"models")},[o,c,l,n,r]),t.useEffect(()=>{if(!n)return;const s=b=>{b.key==="Escape"&&(b.stopImmediatePropagation(),x())};return window.addEventListener("keydown",s,!0),()=>window.removeEventListener("keydown",s,!0)},[x,n]);const g=t.useMemo(()=>{const s=[{id:"models",label:"Models",icon:"cpu"},{id:"connectors",label:"Connectors",icon:"plug"}];return o&&s.push({id:"skills",label:"Skills",icon:"lightbulb"}),c&&s.push({id:"sandbox",label:"Sandbox providers",icon:"cube"}),s},[o,c]);return!n||!a?null:e.jsxs("div",{className:"flex h-full min-h-0 w-full flex-col bg-primary-bg",children:[e.jsx(_,{title:"Settings",start:e.jsx("button",{type:"button","aria-label":"Back",title:"Back",className:k({variant:"ghost",size:"icon"}),onClick:x,children:e.jsx(p,{name:"arrow-left"})})}),e.jsxs("div",{className:f("flex min-h-0 flex-1 flex-col",!i&&"md:flex-row"),children:[e.jsx("nav",{"aria-label":"Settings sections",className:f("flex w-full gap-1 border-b border-border bg-secondary-bg/40 p-2",i?"min-w-0":"justify-center md:w-48 md:flex-col md:justify-start md:border-b-0 md:border-r"),children:g.map(s=>e.jsxs("button",{type:"button","aria-current":l===s.id?"page":void 0,...i?{title:s.label}:{},className:f("flex min-h-9 items-center gap-2 rounded-md px-3 text-sm font-medium transition-colors","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring",i?"min-w-0 flex-1 justify-center gap-1.5 px-1.5":"shrink-0",l===s.id?"bg-primary-button-bg text-primary-button-text":"text-text-secondary hover:bg-ghost-button-hover/60 hover:text-text-primary"),onClick:()=>{r(!0,s.id)},children:[e.jsx(p,{name:s.icon,className:"h-4 w-4 shrink-0"}),i?e.jsx("span",{className:"truncate",children:s.label}):s.label]},s.id))}),e.jsx("section",{className:"flex flex-col h-full flex-1 overflow-y-hidden px-6 py-4",children:e.jsx("div",{className:"w-full max-w-210 h-full min-h-0 flex flex-col mx-auto",children:e.jsxs(t.Suspense,{fallback:e.jsx(L,{}),children:[l==="models"?e.jsx(E,{}):null,l==="connectors"?e.jsx(C,{}):null,l==="skills"&&o?e.jsx(N,{}):null,l==="sandbox"&&c?e.jsx(D,{}):null]})})})]})]})},I=O;export{I as default};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ModelSettings-4TNETPJJ-1PfEncEw.js","./index-BIRSKAK8.js","./index-B01pXqvC.css","./ConnectorSettings-GEI4S6SD-BUjOgTQp.js","./SkillSettings-NHBL5ZXU-BmInxxan.js","./SandboxSettings-IEIWFKQW-DMx0nXkz.js"])))=>i.map(i=>d[i]);
2
+ import{g as h,i as v,aJ as y,ag as j,aK as S,r as t,j as e,P as _,I as p,d as k,e as f,_ as d,S as w}from"./index-BIRSKAK8.js";var E=t.lazy(()=>d(()=>import("./ModelSettings-4TNETPJJ-1PfEncEw.js"),__vite__mapDeps([0,1,2]),import.meta.url)),C=t.lazy(()=>d(()=>import("./ConnectorSettings-GEI4S6SD-BUjOgTQp.js"),__vite__mapDeps([3,1,2]),import.meta.url)),N=t.lazy(()=>d(()=>import("./SkillSettings-NHBL5ZXU-BmInxxan.js"),__vite__mapDeps([4,1,2]),import.meta.url)),L=t.lazy(()=>d(()=>import("./SandboxSettings-IEIWFKQW-DMx0nXkz.js"),__vite__mapDeps([5,1,2]),import.meta.url));function O(){return e.jsxs("div",{className:"flex flex-1 items-center justify-center py-8",role:"status","aria-live":"polite","aria-busy":"true",children:[e.jsx(w,{size:20,className:"text-text-secondary"}),e.jsx("span",{className:"sr-only",children:"Loading"})]})}var P=()=>{const{settingsOpen:n,settingsSection:l,setSettingsOpen:r}=h(),a=v(),u=y(),{refresh:m}=j(),i=S(),o=(a==null?void 0:a.skillCatalog)!=null,c=(a==null?void 0:a.sandboxCatalog)!=null,x=t.useCallback(()=>{r(!1)},[r]);t.useEffect(()=>{if(n)return()=>{m(),u==null||u()}},[n,m,u]),t.useEffect(()=>{!o&&l==="skills"&&r(n,"models"),!c&&l==="sandbox"&&r(n,"models")},[o,c,l,n,r]),t.useEffect(()=>{if(!n)return;const s=b=>{b.key==="Escape"&&(b.stopImmediatePropagation(),x())};return window.addEventListener("keydown",s,!0),()=>window.removeEventListener("keydown",s,!0)},[x,n]);const g=t.useMemo(()=>{const s=[{id:"models",label:"Models",icon:"cpu"},{id:"connectors",label:"Connectors",icon:"plug"}];return o&&s.push({id:"skills",label:"Skills",icon:"lightbulb"}),c&&s.push({id:"sandbox",label:"Sandbox providers",icon:"cube"}),s},[o,c]);return!n||!a?null:e.jsxs("div",{className:"flex h-full min-h-0 w-full flex-col bg-primary-bg",children:[e.jsx(_,{title:"Settings",start:e.jsx("button",{type:"button","aria-label":"Back",title:"Back",className:k({variant:"ghost",size:"icon"}),onClick:x,children:e.jsx(p,{name:"arrow-left"})})}),e.jsxs("div",{className:f("flex min-h-0 flex-1 flex-col",!i&&"md:flex-row"),children:[e.jsx("nav",{"aria-label":"Settings sections",className:f("flex w-full gap-1 border-b border-border bg-secondary-bg/40 p-2",i?"min-w-0":"justify-center md:w-48 md:flex-col md:justify-start md:border-b-0 md:border-r"),children:g.map(s=>e.jsxs("button",{type:"button","aria-current":l===s.id?"page":void 0,...i?{title:s.label}:{},className:f("flex min-h-9 items-center gap-2 rounded-md px-3 text-sm font-medium transition-colors","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring",i?"min-w-0 flex-1 justify-center gap-1.5 px-1.5":"shrink-0",l===s.id?"bg-primary-button-bg/10 text-primary-button-bg":"text-text-secondary hover:bg-ghost-button-hover/60 hover:text-text-primary"),onClick:()=>{r(!0,s.id)},children:[e.jsx(p,{name:s.icon,className:"h-4 w-4 shrink-0"}),i?e.jsx("span",{className:"truncate",children:s.label}):s.label]},s.id))}),e.jsx("section",{className:"flex flex-col h-full flex-1 overflow-y-hidden px-6 py-4",children:e.jsx("div",{className:"w-full max-w-210 h-full min-h-0 flex flex-col mx-auto",children:e.jsxs(t.Suspense,{fallback:e.jsx(O,{}),children:[l==="models"?e.jsx(E,{}):null,l==="connectors"?e.jsx(C,{}):null,l==="skills"&&o?e.jsx(N,{}):null,l==="sandbox"&&c?e.jsx(L,{}):null]})})})]})]})},I=P;export{I as default};
@@ -1 +1 @@
1
- import{m as F,p as v,b as J,s as I}from"./chunk-4MCIDE2C-ClJFqC75.js";import{g as ne,h as re,i as se,k as ae,l as ie,m as le,n as ue,r as a,t as oe,o as ce,p as ge,q as pe}from"./index-Y_4XXAao.js";import{u as fe,a as ye}from"./chunk-62JRHF6Z-CXLsU_my.js";var M="try_agent_name",_="history_agent_name";function V(n){return n!=null&&n.length>0?n:null}function E(n){const i=new URLSearchParams(n.startsWith("?")?n.slice(1):n),l=V(i.get(M));if(l!=null)return{intent:"try-agent",agentName:l};const e=V(i.get(_));return e==null?null:{intent:"history",agentName:e}}function he(n,i){n.delete(M),n.delete(_),i!=null&&n.set(i.intent==="try-agent"?M:_,i.agentName)}function X(n,i){const l=new URLSearchParams(n.startsWith("?")?n.slice(1):n);he(l,i);const e=l.toString();return e.length>0?`?${e}`:""}function Z(n){const i=n.activeRemoteId??n.pendingSessionId;if(i!=null)return{type:"session",sessionId:i};const{mode:l,agentConfigMode:e}=n;if(l.status==="active"&&l.isMutable&&l.isCreateAgent)return{type:"buildAgent"};if(l.status==="active"&&!l.isMutable&&e!=="SingleAgent"){const g=l.agentName??l.agentId;if(g!=null)return{type:"agent",agentName:g}}return{type:"root"}}function de(n){return n.settingsOpen?{type:"settings"}:n.schedulesOpen?{type:"schedules"}:n.sessionsOpen?{type:"sessionsBrowser"}:n.libraryOpen&&n.libraryAgentId!=null?{type:"libraryAgent",agentId:n.libraryAgentId}:n.libraryOpen?{type:"library"}:Z(n)}function b(n){return n.type==="root"||n.type==="agent"||n.type==="session"}function Ae({routes:n,activeRemoteId:i,initialSettingsOpen:l}){var j,z;const e=ne(),g=re(),B=se(),k=ae(),q=ie(),U=le(),$=ue(),C=fe(),s=ye(),o=a.useMemo(()=>oe({routes:n,catalog:B,capabilities:U,sessions:k,schedules:q}),[n,B,U,k,q]),T=o.settings!=null,x=[o.settings,o.sessionsBrowser,o.libraryAgent,o.schedules].join("\0"),W={settingsOpen:e.settingsOpen,libraryOpen:e.libraryOpen,sessionsOpen:e.sessionsOpen,libraryAgentId:e.libraryAgentId,schedulesOpen:e.schedulesOpen,pendingSessionId:e.pendingSessionId,activeRemoteId:i,mode:e.mode,agentConfigMode:e.agentConfigMode},p=de(W),ee=JSON.stringify(p),S=a.useRef(null),H=a.useRef(null),A=a.useRef(null),O=a.useRef(!1),P=a.useRef(null),m=a.useRef(null),w=a.useRef(null),f=a.useRef(null),Y=a.useRef(!1),G=a.useRef(!1),K=a.useCallback(t=>{if(w.current=t,g==null){e.openHistorySession({sessionId:t});return}g.getSession({sessionId:t}).then(r=>{w.current===t&&e.openHistorySession({sessionId:t,isMutable:r.isMutable,isCreateAgent:ce(r),...r.agentName!=null?{agentName:r.agentName}:{}})}).catch(()=>{w.current===t&&e.openHistorySession({sessionId:t})})},[g,e]),h=a.useCallback(t=>{if(t==null){f.current=null,m.current=null,e.setHistoryAgentFilter(null);return}const r=`${t.intent}\0${t.agentName}`,u=e.historyAgentFilter;if((u==null?void 0:u.intent)===t.intent&&u.agentName===t.agentName&&u.agentId!=null){f.current=null;return}f.current=r,e.setHistoryAgentFilter(t),g!=null&&ge({server:g,agentName:t.agentName}).then(c=>{if(f.current===r){if(c==null){f.current=null,m.current=null,e.setHistoryAgentFilter(null);return}f.current=null,e.setHistoryAgentFilter({agentId:pe(c),agentName:c.name,intent:t.intent})}}).catch(()=>{f.current===r&&(f.current=null,m.current=null,e.setHistoryAgentFilter(null))})},[g,e]),Q=a.useCallback(t=>{e.selectLibraryAgent({isMutable:!1,agentName:t}),h({intent:"try-agent",agentName:t})},[h,e]),L=a.useCallback(t=>{switch(t.type){case"settings":e.setSettingsOpen(!0);return;case"library":e.setLibraryOpen(!0);return;case"sessionsBrowser":e.setSessionsOpen(!0);return;case"libraryAgent":e.openLibraryAgent(t.agentId);return;case"schedules":e.setSchedulesOpen(!0);return;case"buildAgent":e.openAgentBuilder();return;case"session":if(e.setLibraryOpen(!1),e.pendingSessionId===t.sessionId||i===t.sessionId)return;K(t.sessionId);return;case"agent":e.setLibraryOpen(!1),Q(t.agentName);return;case"root":switch(e.setSettingsOpen(!1),e.setLibraryOpen(!1),e.setSchedulesOpen(!1),e.agentConfigMode){case"AgentLibrary":e.openLibraryHome();return;case"AgentComposer":case"AgentLibraryWithComposer":e.openDraft();return;case"SingleAgent":e.clearChat();return}}},[e,i,Q,K]);return a.useEffect(()=>{if(O.current)return;const t=F({pathname:s.pathname,search:s.search,routes:n});if(!$&&(t==null?void 0:t.type)==="settings")return;O.current=!0;const r=F({pathname:s.pathname,search:s.search,routes:o})??{type:"root"},u=r.type==="agent"?{intent:"try-agent",agentName:r.agentName}:b(r)?E(s.search):null;m.current=u,A.current=r;const c=T&&(l||r.type==="settings");if(r.type==="settings")T&&e.setSettingsOpen(!0);else if(r.type==="library")e.setLibraryOpen(!0);else if(r.type==="sessionsBrowser")e.setSessionsOpen(!0);else if(r.type==="libraryAgent")e.openLibraryAgent(r.agentId);else if(r.type==="schedules")e.setSchedulesOpen(!0);else{const R=Z(W);v(R,r)||L(r),c&&e.setSettingsOpen(!0)}r.type!=="agent"&&u!=null?h(u):b(r)||h(null);const d=c?{type:"settings"}:r;P.current=v(p,d)?null:d;const y=J(d,o),N=X(I(d,s.search),u);H.current=d,y!=null&&(y!==s.pathname||N!==s.search)&&(S.current=y!==s.pathname?y:null,C({pathname:y,search:N,hash:s.hash},{replace:!0}))},[$]),a.useEffect(()=>{if(!O.current)return;if(!Y.current){Y.current=!0;return}const t=P.current;if(t!=null){if(!v(p,t))return;P.current=null}const r=J(p,o);if(r==null)return;const c=`${o.basename.endsWith("/")?o.basename.slice(0,-1):o.basename}${s.pathname}`||"/",d=window.location.pathname===c?window.location.search:s.search,y=b(p),N=y?e.historyAgentFilter==null?m.current:{intent:e.historyAgentFilter.intent,agentName:e.historyAgentFilter.agentName}:null;!y&&e.historyAgentFilter!=null&&(f.current=null,e.setHistoryAgentFilter(null)),e.historyAgentFilter!=null&&(m.current=null);const R=X(I(p,d),N),D=H.current;if(H.current=p,r===s.pathname&&R===s.search)return;const te=p.type==="session"&&e.pendingSessionId==null&&D!=null&&D.type!=="session";S.current=r!==s.pathname?r:null,C({pathname:r,search:R,hash:s.hash},{replace:te})},[ee,x,(j=e.historyAgentFilter)==null?void 0:j.agentName,(z=e.historyAgentFilter)==null?void 0:z.intent]),a.useEffect(()=>{if(!O.current)return;if(!G.current){G.current=!0;return}if(S.current===s.pathname){S.current=null,A.current=p;return}const t=F({pathname:s.pathname,search:s.search,routes:o});if(t==null){const u=o.root,c=I({type:"root"},s.search);S.current=u,C({pathname:u,search:c,hash:s.hash},{replace:!0}),L({type:"root"}),h(E(c));return}const r=A.current;A.current=t,(r==null||!v(r,t))&&(t.type!=="settings"&&e.settingsOpen&&e.setSettingsOpen(!1),t.type!=="library"&&t.type!=="libraryAgent"&&e.libraryOpen&&e.setLibraryOpen(!1),t.type!=="sessionsBrowser"&&e.sessionsOpen&&e.setSessionsOpen(!1),t.type!=="schedules"&&e.schedulesOpen&&e.setSchedulesOpen(!1),L(t)),t.type!=="agent"&&b(t)?h(E(s.search)):b(t)||h(null)},[s.pathname,s.search]),null}export{Ae as ShellRouteSync};
1
+ import{m as F,p as v,b as J,s as I}from"./chunk-2QTH6JHX-DIiHfgUm.js";import{g as ne,h as re,i as se,k as ae,l as ie,m as le,n as ue,r as a,t as oe,o as ce,p as ge,q as pe}from"./index-BIRSKAK8.js";import{u as fe,a as ye}from"./chunk-62JRHF6Z-bd9_iLmQ.js";var M="try_agent_name",_="history_agent_name";function V(n){return n!=null&&n.length>0?n:null}function E(n){const i=new URLSearchParams(n.startsWith("?")?n.slice(1):n),l=V(i.get(M));if(l!=null)return{intent:"try-agent",agentName:l};const e=V(i.get(_));return e==null?null:{intent:"history",agentName:e}}function he(n,i){n.delete(M),n.delete(_),i!=null&&n.set(i.intent==="try-agent"?M:_,i.agentName)}function X(n,i){const l=new URLSearchParams(n.startsWith("?")?n.slice(1):n);he(l,i);const e=l.toString();return e.length>0?`?${e}`:""}function Z(n){const i=n.activeRemoteId??n.pendingSessionId;if(i!=null)return{type:"session",sessionId:i};const{mode:l,agentConfigMode:e}=n;if(l.status==="active"&&l.isMutable&&l.isCreateAgent)return{type:"buildAgent"};if(l.status==="active"&&!l.isMutable&&e!=="SingleAgent"){const g=l.agentName??l.agentId;if(g!=null)return{type:"agent",agentName:g}}return{type:"root"}}function de(n){return n.settingsOpen?{type:"settings"}:n.schedulesOpen?{type:"schedules"}:n.sessionsOpen?{type:"sessionsBrowser"}:n.libraryOpen&&n.libraryAgentId!=null?{type:"libraryAgent",agentId:n.libraryAgentId}:n.libraryOpen?{type:"library"}:Z(n)}function b(n){return n.type==="root"||n.type==="agent"||n.type==="session"}function Ae({routes:n,activeRemoteId:i,initialSettingsOpen:l}){var j,z;const e=ne(),g=re(),B=se(),k=ae(),q=ie(),U=le(),$=ue(),C=fe(),s=ye(),o=a.useMemo(()=>oe({routes:n,catalog:B,capabilities:U,sessions:k,schedules:q}),[n,B,U,k,q]),T=o.settings!=null,x=[o.settings,o.sessionsBrowser,o.libraryAgent,o.schedules].join("\0"),W={settingsOpen:e.settingsOpen,libraryOpen:e.libraryOpen,sessionsOpen:e.sessionsOpen,libraryAgentId:e.libraryAgentId,schedulesOpen:e.schedulesOpen,pendingSessionId:e.pendingSessionId,activeRemoteId:i,mode:e.mode,agentConfigMode:e.agentConfigMode},p=de(W),ee=JSON.stringify(p),S=a.useRef(null),H=a.useRef(null),A=a.useRef(null),O=a.useRef(!1),P=a.useRef(null),m=a.useRef(null),w=a.useRef(null),f=a.useRef(null),Y=a.useRef(!1),G=a.useRef(!1),K=a.useCallback(t=>{if(w.current=t,g==null){e.openHistorySession({sessionId:t});return}g.getSession({sessionId:t}).then(r=>{w.current===t&&e.openHistorySession({sessionId:t,isMutable:r.isMutable,isCreateAgent:ce(r),...r.agentName!=null?{agentName:r.agentName}:{}})}).catch(()=>{w.current===t&&e.openHistorySession({sessionId:t})})},[g,e]),h=a.useCallback(t=>{if(t==null){f.current=null,m.current=null,e.setHistoryAgentFilter(null);return}const r=`${t.intent}\0${t.agentName}`,u=e.historyAgentFilter;if((u==null?void 0:u.intent)===t.intent&&u.agentName===t.agentName&&u.agentId!=null){f.current=null;return}f.current=r,e.setHistoryAgentFilter(t),g!=null&&ge({server:g,agentName:t.agentName}).then(c=>{if(f.current===r){if(c==null){f.current=null,m.current=null,e.setHistoryAgentFilter(null);return}f.current=null,e.setHistoryAgentFilter({agentId:pe(c),agentName:c.name,intent:t.intent})}}).catch(()=>{f.current===r&&(f.current=null,m.current=null,e.setHistoryAgentFilter(null))})},[g,e]),Q=a.useCallback(t=>{e.selectLibraryAgent({isMutable:!1,agentName:t}),h({intent:"try-agent",agentName:t})},[h,e]),L=a.useCallback(t=>{switch(t.type){case"settings":e.setSettingsOpen(!0);return;case"library":e.setLibraryOpen(!0);return;case"sessionsBrowser":e.setSessionsOpen(!0);return;case"libraryAgent":e.openLibraryAgent(t.agentId);return;case"schedules":e.setSchedulesOpen(!0);return;case"buildAgent":e.openAgentBuilder();return;case"session":if(e.setLibraryOpen(!1),e.pendingSessionId===t.sessionId||i===t.sessionId)return;K(t.sessionId);return;case"agent":e.setLibraryOpen(!1),Q(t.agentName);return;case"root":switch(e.setSettingsOpen(!1),e.setLibraryOpen(!1),e.setSchedulesOpen(!1),e.agentConfigMode){case"AgentLibrary":e.openLibraryHome();return;case"AgentComposer":case"AgentLibraryWithComposer":e.openDraft();return;case"SingleAgent":e.clearChat();return}}},[e,i,Q,K]);return a.useEffect(()=>{if(O.current)return;const t=F({pathname:s.pathname,search:s.search,routes:n});if(!$&&(t==null?void 0:t.type)==="settings")return;O.current=!0;const r=F({pathname:s.pathname,search:s.search,routes:o})??{type:"root"},u=r.type==="agent"?{intent:"try-agent",agentName:r.agentName}:b(r)?E(s.search):null;m.current=u,A.current=r;const c=T&&(l||r.type==="settings");if(r.type==="settings")T&&e.setSettingsOpen(!0);else if(r.type==="library")e.setLibraryOpen(!0);else if(r.type==="sessionsBrowser")e.setSessionsOpen(!0);else if(r.type==="libraryAgent")e.openLibraryAgent(r.agentId);else if(r.type==="schedules")e.setSchedulesOpen(!0);else{const R=Z(W);v(R,r)||L(r),c&&e.setSettingsOpen(!0)}r.type!=="agent"&&u!=null?h(u):b(r)||h(null);const d=c?{type:"settings"}:r;P.current=v(p,d)?null:d;const y=J(d,o),N=X(I(d,s.search),u);H.current=d,y!=null&&(y!==s.pathname||N!==s.search)&&(S.current=y!==s.pathname?y:null,C({pathname:y,search:N,hash:s.hash},{replace:!0}))},[$]),a.useEffect(()=>{if(!O.current)return;if(!Y.current){Y.current=!0;return}const t=P.current;if(t!=null){if(!v(p,t))return;P.current=null}const r=J(p,o);if(r==null)return;const c=`${o.basename.endsWith("/")?o.basename.slice(0,-1):o.basename}${s.pathname}`||"/",d=window.location.pathname===c?window.location.search:s.search,y=b(p),N=y?e.historyAgentFilter==null?m.current:{intent:e.historyAgentFilter.intent,agentName:e.historyAgentFilter.agentName}:null;!y&&e.historyAgentFilter!=null&&(f.current=null,e.setHistoryAgentFilter(null)),e.historyAgentFilter!=null&&(m.current=null);const R=X(I(p,d),N),D=H.current;if(H.current=p,r===s.pathname&&R===s.search)return;const te=p.type==="session"&&e.pendingSessionId==null&&D!=null&&D.type!=="session";S.current=r!==s.pathname?r:null,C({pathname:r,search:R,hash:s.hash},{replace:te})},[ee,x,(j=e.historyAgentFilter)==null?void 0:j.agentName,(z=e.historyAgentFilter)==null?void 0:z.intent]),a.useEffect(()=>{if(!O.current)return;if(!G.current){G.current=!0;return}if(S.current===s.pathname){S.current=null,A.current=p;return}const t=F({pathname:s.pathname,search:s.search,routes:o});if(t==null){const u=o.root,c=I({type:"root"},s.search);S.current=u,C({pathname:u,search:c,hash:s.hash},{replace:!0}),L({type:"root"}),h(E(c));return}const r=A.current;A.current=t,(r==null||!v(r,t))&&(t.type!=="settings"&&e.settingsOpen&&e.setSettingsOpen(!1),t.type!=="library"&&t.type!=="libraryAgent"&&e.libraryOpen&&e.setLibraryOpen(!1),t.type!=="sessionsBrowser"&&e.sessionsOpen&&e.setSessionsOpen(!1),t.type!=="schedules"&&e.schedulesOpen&&e.setSchedulesOpen(!1),L(t)),t.type!=="agent"&&b(t)?h(E(s.search)):b(t)||h(null)},[s.pathname,s.search]),null}export{Ae as ShellRouteSync};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SettingsBuilder-3OA4UCIM-AN2PJd1q.js","./index-Y_4XXAao.js","./index-B01pXqvC.css","./SchedulesPage-JIUWNYUH-5f3ROPme.js"])))=>i.map(i=>d[i]);
2
- import{br as N,bs as Ut,u as G,j as s,bt as Vt,r as d,aO as S,bu as Ge,bv as Wt,bw as He,bx as Ue,by as Ve,bz as We,bA as Xe,bB as X,bC as Xt,bD as C,bE as Yt,bF as qt,bG as Jt,bH as Qt,bI as Zt,bJ as en,bK as tn,bL as nn,bM as be,bN as rn,bO as sn,bP as ce,bQ as on,bR as an,bS as cn,bT as Ye,bU as Ee,bV as le,bW as we,bX as se,bY as Ie,bZ as ye,b_ as Me,b$ as _e,h as qe,a as Q,c as T,E as ln,c0 as un,e as F,c1 as dn,c2 as mn,c3 as fn,b as Le,aE as Je,c4 as hn,J as pn,a5 as Ae,I as z,q as xn,d as re,c5 as Qe,c6 as gn,c7 as vn,s as Ze,c8 as bn,P as wn,S as Oe,c9 as In,ca as yn,_ as et,bk as Mn}from"./index-Y_4XXAao.js";import{A as Ln,N as Cn,T as jn,S as Tn}from"./chunk-7NYDADYN-_y_WJnHd.js";const Ce=n=>{const e=N(8),{index:t,archived:o,children:r}=n;let a;e[0]!==o||e[1]!==t?(a=Ut({source:"threads",query:{type:"index",index:t,archived:o},get:i=>i.threads().item({index:t,archived:o})}),e[0]=o,e[1]=t,e[2]=a):a=e[2];let c;e[3]!==a?(c={threadListItem:a},e[3]=a,e[4]=c):c=e[4];const l=G(c);let u;return e[5]!==l||e[6]!==r?(u=s.jsx(Vt,{value:l,children:r}),e[5]=l,e[6]=r,e[7]=u):u=e[7],u},tt=d.memo(n=>{const e=N(6),{index:t,archived:o,components:r}=n,a=o===void 0?!1:o,c=r.ThreadListItem;let l;e[0]!==c?(l=s.jsx(c,{}),e[0]=c,e[1]=l):l=e[1];let u;return e[2]!==a||e[3]!==t||e[4]!==l?(u=s.jsx(Ce,{index:t,archived:a,children:l}),e[2]=a,e[3]=t,e[4]=l,e[5]=u):u=e[5],u},(n,e)=>n.index===e.index&&n.archived===e.archived&&n.components.ThreadListItem===e.components.ThreadListItem);tt.displayName="ThreadListPrimitive.ItemByIndex";const ke=({archived:n,children:e})=>{const t=S(o=>n?o.threads.archivedThreadIds.length:o.threads.threadIds.length);return Ge(()=>Array.from({length:t},(o,r)=>s.jsx(Ce,{index:r,archived:n,children:s.jsx(Wt,{getItemState:a=>a.threads().item({index:r,archived:n}).getState(),children:a=>e({get threadListItem(){return a()}})})},r)),[t,n,e])},nt=n=>{const e=N(8),{archived:t,components:o,children:r}=n,a=t===void 0?!1:t;if(o){const l=o.ThreadListItem;let u;e[0]!==l?(u=()=>s.jsx(l,{}),e[0]=l,e[1]=u):u=e[1];let i;return e[2]!==a||e[3]!==u?(i=s.jsx(ke,{archived:a,children:u}),e[2]=a,e[3]=u,e[4]=i):i=e[4],i}let c;return e[5]!==a||e[6]!==r?(c=s.jsx(ke,{archived:a,children:r}),e[5]=a,e[6]=r,e[7]=c):c=e[7],c};nt.displayName="ThreadListPrimitive.Items";const rt=n=>{const e=N(2),{fallback:t}=n,o=S(Sn)||t;let r;return e[0]!==o?(r=s.jsx(s.Fragment,{children:o}),e[0]=o,e[1]=r):r=e[1],r};rt.displayName="ThreadListItemPrimitive.Title";function Sn(n){return n.threadListItem.title}const Rn=()=>{const n=N(4),e=G();let t;n[0]!==e?(t=()=>{e.threadListItem().archive()},n[0]=e,n[1]=t):t=n[1];const o=t;let r;return n[2]!==o?(r={archive:o},n[2]=o,n[3]=r):r=n[3],r},Pn=()=>{const n=N(4),e=G();let t;n[0]!==e?(t=()=>{e.threadListItem().delete()},n[0]=e,n[1]=t):t=n[1];const o=t;let r;return n[2]!==o?(r={delete:o},n[2]=o,n[3]=r):r=n[3],r},Nn=()=>{const n=N(4),e=G();let t;n[0]!==e?(t=()=>{e.threadListItem().unarchive()},n[0]=e,n[1]=t):t=n[1];const o=t;let r;return n[2]!==o?(r={unarchive:o},n[2]=o,n[3]=r):r=n[3],r},Dn=()=>{const n=N(4),e=G();let t;n[0]!==e?(t=()=>{e.threadListItem().switchTo()},n[0]=e,n[1]=t):t=n[1];const o=t;let r;return n[2]!==o?(r={switchTo:o},n[2]=o,n[3]=r):r=n[3],r},En=()=>{const n=N(4),e=G();let t;n[0]!==e?(t=()=>{e.threads().switchToNewThread()},n[0]=e,n[1]=t):t=n[1];const o=t;let r;return n[2]!==o?(r={switchToNewThread:o},n[2]=o,n[3]=r):r=n[3],r},_n=()=>{const n=N(5),e=G(),t=S(An);let o;n[0]!==e?(o=()=>{e.threads().loadMore()},n[0]=e,n[1]=o):o=n[1];const r=o;let a;return n[2]!==t||n[3]!==r?(a={loadMore:r,disabled:t},n[2]=t,n[3]=r,n[4]=a):a=n[4],a};function An(n){return!n.threads.hasMore||n.threads.isLoading||n.threads.isLoadingMore}var On=Object.defineProperty,y=(n,e)=>On(n,"name",{value:e,configurable:!0}),kn=["Enter"," "],Fn=["ArrowDown","PageUp","Home"],st=["ArrowUp","PageDown","End"],Bn=[...Fn,...st],ue="Menu",[pe,$n,Kn]=We(ue),[Y,ot]=He(ue,[Kn,Ue,Ve]),je=Ue(),at=Ve(),[zn,oe]=Y(ue),[Gn,Te]=Y(ue),Hn=y(n=>{const{__scopeMenu:e,open:t=!1,children:o,dir:r,onOpenChange:a,modal:c=!0}=n,l=je(e),[u,i]=d.useState(null),m=d.useRef(!1),h=sn(a),f=ce(r);return d.useEffect(()=>{const p=y(()=>{m.current=!0,document.addEventListener("pointerdown",b,{capture:!0,once:!0}),document.addEventListener("pointermove",b,{capture:!0,once:!0})},"handleKeyDown"),b=y(()=>m.current=!1,"handlePointer");return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",b,{capture:!0}),document.removeEventListener("pointermove",b,{capture:!0})}},[]),d.useEffect(()=>{if(!t)return;const p=y(()=>h(!1),"handleBlur");return window.addEventListener("blur",p),()=>window.removeEventListener("blur",p)},[t,h]),s.jsx(on,{...l,children:s.jsx(zn,{scope:e,open:t,onOpenChange:h,content:u,onContentChange:i,children:s.jsx(Gn,{scope:e,onClose:d.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:m,dir:f,modal:c,children:o})})})},"Menu"),Un=d.forwardRef(y(function(e,t){const{__scopeMenu:o,...r}=e,a=je(o);return s.jsx(an,{...a,...r,ref:t})},"MenuAnchor")),it="MenuPortal",[Vn,Wn]=Y(it,{forceMount:void 0}),Xn=y(n=>{const{__scopeMenu:e,forceMount:t,children:o,container:r}=n,a=oe(it,e);return s.jsx(Vn,{scope:e,forceMount:t,children:s.jsx(Xe,{present:t||a.open,children:s.jsx(cn,{asChild:!0,container:r,children:o})})})},"MenuPortal"),W="MenuContent",[Yn,ct]=Y(W),qn=d.forwardRef(y(function(e,t){const o=Wn(W,e.__scopeMenu),{forceMount:r=o.forceMount,...a}=e,c=oe(W,e.__scopeMenu),l=Te(W,e.__scopeMenu);return s.jsx(pe.Provider,{scope:e.__scopeMenu,children:s.jsx(Xe,{present:r||c.open,children:s.jsx(pe.Slot,{scope:e.__scopeMenu,children:l.modal?s.jsx(Jn,{...a,ref:t}):s.jsx(Qn,{...a,ref:t})})})})},"MenuContent")),Jn=d.forwardRef(y(function(e,t){const o=oe(W,e.__scopeMenu),r=d.useRef(null),a=X(t,r);return d.useEffect(()=>{const c=r.current;if(c)return Xt(c)},[]),s.jsx(lt,{...e,ref:a,trapFocus:o.open,disableOutsidePointerEvents:o.open,disableOutsideScroll:!0,onFocusOutside:C(e.onFocusOutside,c=>c.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>o.onOpenChange(!1)})},"MenuRootContentModal")),Qn=d.forwardRef(y(function(e,t){const o=oe(W,e.__scopeMenu);return s.jsx(lt,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>o.onOpenChange(!1)})},"MenuRootContentNonModal")),Zn=rn("MenuContent.ScrollLock"),lt=d.forwardRef(y(function(e,t){const{__scopeMenu:o,loop:r=!1,trapFocus:a,onOpenAutoFocus:c,onCloseAutoFocus:l,disableOutsidePointerEvents:u,onEntryFocus:i,onEscapeKeyDown:m,onPointerDownOutside:h,onFocusOutside:f,onInteractOutside:p,onDismiss:b,disableOutsideScroll:x,...g}=e,M=oe(W,o),L=Te(W,o),j=je(o),P=at(o),_=$n(o),[A,O]=d.useState(null),D=d.useRef(null),I=X(t,D,M.onContentChange),R=d.useRef(0),E=d.useRef(""),B=d.useRef(0),w=d.useRef(null),te=d.useRef("right"),$=d.useRef(0),U=x?qt:d.Fragment,de=x?{as:Zn,allowPinchZoom:!0}:void 0,Ht=y(v=>{var J,Ne;const k=E.current+v,K=_().filter(H=>!H.disabled),V=document.activeElement,me=(J=K.find(H=>H.ref.current===V))==null?void 0:J.textValue,fe=K.map(H=>H.textValue),Pe=ht(fe,k,me),ne=(Ne=K.find(H=>H.textValue===Pe))==null?void 0:Ne.ref.current;y((function H(De){E.current=De,window.clearTimeout(R.current),De!==""&&(R.current=window.setTimeout(()=>H(""),1e3))}),"updateSearch")(k),ne&&setTimeout(()=>ne.focus())},"handleTypeaheadSearch");d.useEffect(()=>()=>window.clearTimeout(R.current),[]),Yt();const q=d.useCallback(v=>{var K,V;return te.current===((K=w.current)==null?void 0:K.side)&&xt(v,(V=w.current)==null?void 0:V.area)},[]);return s.jsx(Yn,{scope:o,searchRef:E,onItemEnter:d.useCallback(v=>{q(v)&&v.preventDefault()},[q]),onItemLeave:d.useCallback(v=>{var k;q(v)||((k=D.current)==null||k.focus(),O(null))},[q]),onTriggerLeave:d.useCallback(v=>{q(v)&&v.preventDefault()},[q]),pointerGraceTimerRef:B,onPointerGraceIntentChange:d.useCallback(v=>{w.current=v},[]),children:s.jsx(U,{...de,children:s.jsx(Jt,{asChild:!0,trapped:a,onMountAutoFocus:C(c,v=>{var k;v.preventDefault(),(k=D.current)==null||k.focus({preventScroll:!0})}),onUnmountAutoFocus:l,children:s.jsx(Qt,{asChild:!0,disableOutsidePointerEvents:u,onEscapeKeyDown:m,onPointerDownOutside:h,onFocusOutside:f,onInteractOutside:p,onDismiss:b,children:s.jsx(Zt,{asChild:!0,...P,dir:L.dir,orientation:"vertical",loop:r,currentTabStopId:A,onCurrentTabStopIdChange:O,onEntryFocus:C(i,v=>{L.isUsingKeyboardRef.current||v.preventDefault()}),preventScrollOnEntryFocus:!0,children:s.jsx(en,{role:"menu","aria-orientation":"vertical","data-state":ut(M.open),"data-radix-menu-content":"",dir:L.dir,...j,...g,ref:I,style:{outline:"none",...g.style},onKeyDown:C(g.onKeyDown,v=>{const K=v.target.closest("[data-radix-menu-content]")===v.currentTarget,V=v.ctrlKey||v.altKey||v.metaKey,me=v.key.length===1;K&&(v.key==="Tab"&&v.preventDefault(),!V&&me&&Ht(v.key));const fe=D.current;if(v.target!==fe||!Bn.includes(v.key))return;v.preventDefault();const ne=_().filter(J=>!J.disabled).map(J=>J.ref.current);st.includes(v.key)&&ne.reverse(),mt(ne)}),onBlur:C(e.onBlur,v=>{v.currentTarget.contains(v.target)||(window.clearTimeout(R.current),E.current="")}),onPointerMove:C(e.onPointerMove,ie(v=>{const k=v.target,K=$.current!==v.clientX;if(v.currentTarget.contains(k)&&K){const V=v.clientX>$.current?"right":"left";te.current=V,$.current=v.clientX}}))})})})})})})},"MenuContentImpl")),xe="MenuItem",Fe="menu.itemSelect",er=d.forwardRef(y(function(e,t){const{disabled:o=!1,onSelect:r,...a}=e,c=d.useRef(null),l=Te(xe,e.__scopeMenu),u=ct(xe,e.__scopeMenu),i=X(t,c),m=d.useRef(!1),h=y(()=>{const f=c.current;if(!o&&f){const p=new CustomEvent(Fe,{bubbles:!0,cancelable:!0});f.addEventListener(Fe,b=>r==null?void 0:r(b),{once:!0}),tn(f,p),p.defaultPrevented?m.current=!1:l.onClose()}},"handleSelect");return s.jsx(tr,{...a,ref:i,disabled:o,onClick:C(e.onClick,h),onPointerDown:f=>{var p;(p=e.onPointerDown)==null||p.call(e,f),m.current=!0},onPointerUp:C(e.onPointerUp,f=>{var p;m.current||(p=f.currentTarget)==null||p.click()}),onKeyDown:C(e.onKeyDown,f=>{o||f.target!==f.currentTarget||u.searchRef.current!==""&&f.key===" "||kn.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})},"MenuItem")),tr=d.forwardRef(y(function(e,t){const{__scopeMenu:o,disabled:r=!1,textValue:a,...c}=e,l=ct(xe,o),u=at(o),i=d.useRef(null),m=X(t,i),[h,f]=d.useState(!1),[p,b]=d.useState("");return d.useEffect(()=>{const x=i.current;x&&b((x.textContent??"").trim())},[c.children]),s.jsx(pe.ItemSlot,{scope:o,disabled:r,textValue:a??p,children:s.jsx(nn,{asChild:!0,...u,focusable:!r,children:s.jsx(be.div,{role:"menuitem","data-highlighted":h?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...c,ref:m,onPointerMove:C(e.onPointerMove,ie(x=>{r?l.onItemLeave(x):(l.onItemEnter(x),x.defaultPrevented||x.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:C(e.onPointerLeave,ie(x=>l.onItemLeave(x))),onFocus:C(e.onFocus,()=>f(!0)),onBlur:C(e.onBlur,()=>f(!1))})})})},"MenuItemImpl")),nr="MenuRadioGroup",[ns,rs]=Y(nr,{value:void 0,onValueChange:y(()=>{},"onValueChange")}),rr="MenuItemIndicator",[ss,os]=Y(rr,{checked:!1}),sr=d.forwardRef(y(function(e,t){const{__scopeMenu:o,...r}=e;return s.jsx(be.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})},"MenuSeparator")),or="MenuSub",[as,is]=Y(or);function ut(n){return n?"open":"closed"}y(ut,"getOpenState");function dt(n){return n==="indeterminate"}y(dt,"isIndeterminate");function ar(n){return dt(n)?"indeterminate":n?"checked":"unchecked"}y(ar,"getCheckedState");function mt(n){const e=document.activeElement;for(const t of n)if(t===e||(t.focus(),document.activeElement!==e))return}y(mt,"focusFirst");function ft(n,e){return n.map((t,o)=>n[(e+o)%n.length])}y(ft,"wrapArray");function ht(n,e,t){const r=e.length>1&&Array.from(e).every(i=>i===e[0])?e[0]:e,a=t?n.indexOf(t):-1;let c=ft(n,Math.max(a,0));r.length===1&&(c=c.filter(i=>i!==t));const u=c.find(i=>i.toLowerCase().startsWith(r.toLowerCase()));return u!==t?u:void 0}y(ht,"getNextMatch");function pt(n,e){const{x:t,y:o}=n;let r=!1;for(let a=0,c=e.length-1;a<e.length;c=a++){const l=e[a],u=e[c],i=l.x,m=l.y,h=u.x,f=u.y;m>o!=f>o&&t<(h-i)*(o-m)/(f-m)+i&&(r=!r)}return r}y(pt,"isPointInPolygon");function xt(n,e){if(!e)return!1;const t={x:n.clientX,y:n.clientY};return pt(t,e)}y(xt,"isPointerInGraceArea");function ie(n){return e=>e.pointerType==="mouse"?n(e):void 0}y(ie,"whenMouse");var ir=Hn,cr=Un,lr=Xn,ur=qn,dr=er,mr=sr,fr=Object.defineProperty,Z=(n,e)=>fr(n,"name",{value:e,configurable:!0}),Se="DropdownMenu",[hr,gt]=He(Se,[ot]),ee=ot(),[pr,vt]=hr(Se),bt=Z(n=>{const{__scopeDropdownMenu:e,children:t,dir:o,open:r,defaultOpen:a,onOpenChange:c,modal:l=!0}=n,u=ee(e),i=d.useRef(null),[m,h]=Ye({prop:r,defaultProp:a??!1,onChange:c,caller:Se});return s.jsx(pr,{scope:e,triggerId:Ee(),triggerRef:i,contentId:Ee(),open:m,onOpenChange:h,onOpenToggle:d.useCallback(()=>h(f=>!f),[h]),modal:l,children:s.jsx(ir,{...u,open:m,onOpenChange:h,dir:o,modal:l,children:t})})},"DropdownMenu"),xr="DropdownMenuTrigger",wt=d.forwardRef(Z(function(e,t){const{__scopeDropdownMenu:o,disabled:r=!1,...a}=e,c=vt(xr,o),l=ee(o),u=X(t,c.triggerRef);return s.jsx(cr,{asChild:!0,...l,children:s.jsx(be.button,{type:"button",id:c.triggerId,"aria-haspopup":"menu","aria-expanded":c.open,"aria-controls":c.open?c.contentId:void 0,"data-state":c.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...a,ref:u,onPointerDown:C(e.onPointerDown,i=>{!r&&i.button===0&&i.ctrlKey===!1&&(c.onOpenToggle(),c.open||i.preventDefault())}),onKeyDown:C(e.onKeyDown,i=>{r||(["Enter"," "].includes(i.key)&&c.onOpenToggle(),i.key==="ArrowDown"&&c.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(i.key)&&i.preventDefault())})})})},"DropdownMenuTrigger")),It=Z(n=>{const{__scopeDropdownMenu:e,...t}=n,o=ee(e);return s.jsx(lr,{...o,...t})},"DropdownMenuPortal"),gr="DropdownMenuContent",yt=d.forwardRef(Z(function(e,t){const{__scopeDropdownMenu:o,...r}=e,a=vt(gr,o),c=ee(o),l=d.useRef(!1);return s.jsx(ur,{id:a.contentId,"aria-labelledby":a.triggerId,...c,...r,ref:t,onCloseAutoFocus:C(e.onCloseAutoFocus,u=>{var i;l.current||(i=a.triggerRef.current)==null||i.focus(),l.current=!1,u.preventDefault()}),onInteractOutside:C(e.onInteractOutside,u=>{const i=u.detail.originalEvent,m=i.button===0&&i.ctrlKey===!0,h=i.button===2||m;(!a.modal||h)&&(l.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})},"DropdownMenuContent")),Mt=d.forwardRef(Z(function(e,t){const{__scopeDropdownMenu:o,...r}=e,a=ee(o);return s.jsx(dr,{...a,...r,ref:t})},"DropdownMenuItem")),Lt=d.forwardRef(Z(function(e,t){const{__scopeDropdownMenu:o,...r}=e,a=ee(o);return s.jsx(mr,{...a,...r,ref:t})},"DropdownMenuSeparator")),Ct=bt,jt=wt,vr=It,Tt=yt,St=Mt,Rt=Lt;const br=Object.freeze(Object.defineProperty({__proto__:null,Content:Tt,DropdownMenu:bt,DropdownMenuContent:yt,DropdownMenuItem:Mt,DropdownMenuPortal:It,DropdownMenuSeparator:Lt,DropdownMenuTrigger:wt,Item:St,Portal:vr,Root:Ct,Separator:Rt,Trigger:jt,createDropdownMenuScope:gt},Symbol.toStringTag,{value:"Module"})),wr=le(jt),Ir=le(Tt),yr=le(St),Mr=le(Rt),Pt=d.forwardRef((n,e)=>{const t=N(15);let o,r,a;t[0]!==n?({onClick:r,disabled:o,...a}=n,t[0]=n,t[1]=o,t[2]=r,t[3]=a):(o=t[1],r=t[2],a=t[3]);const c=S(Lr),{switchToNewThread:l}=En();let u;t[4]!==c?(u=c?{"data-active":"true","aria-current":"true"}:null,t[4]=c,t[5]=u):u=t[5];let i;t[6]!==r||t[7]!==l?(i=C(r,l),t[6]=r,t[7]=l,t[8]=i):i=t[8];let m;return t[9]!==o||t[10]!==e||t[11]!==a||t[12]!==u||t[13]!==i?(m=s.jsx(we.button,{type:"button",...u,...a,ref:e,disabled:o,onClick:i}),t[9]=o,t[10]=e,t[11]=a,t[12]=u,t[13]=i,t[14]=m):m=t[14],m});Pt.displayName="ThreadListPrimitive.New";function Lr(n){return n.threads.newThreadId===n.threads.mainThreadId}const Cr=()=>{const{loadMore:n,disabled:e}=_n();return e?null:n},jr=se("ThreadListPrimitive.LoadMore",Cr),[Tr,Sr]=We("ThreadList"),ge=Tr,Nt=ye(null),Rr=Nt.Provider,Re=()=>Ie(Nt),Dt=d.forwardRef((n,e)=>{const t=N(3);let o;return t[0]!==n||t[1]!==e?(o=s.jsx(ge.Provider,{scope:void 0,children:s.jsx(ge.Slot,{scope:void 0,children:s.jsx(we.div,{...n,ref:e})})}),t[0]=n,t[1]=e,t[2]=o):o=t[2],o});Dt.displayName="ThreadListPrimitive.Root";var Pr=Me({ItemByIndex:()=>tt,Items:()=>nt,LoadMore:()=>jr,New:()=>Pt,Root:()=>Dt});const Et=d.forwardRef((n,e)=>{const t=S(i=>i.threads.mainThreadId===i.threadListItem.id),o=_e(null),r=_e(null),a=Ge(()=>({triggerRef:o,moreRef:r}),[]),c=Sr(void 0),l=ce(),u=i=>{const m=l==="rtl"?"ArrowLeft":"ArrowRight",h=l==="rtl"?"ArrowRight":"ArrowLeft",f=o.current,p=r.current;if(f&&i.target===f)if(i.key==="ArrowDown"||i.key==="ArrowUp"){const b=c().map(g=>g.ref.current).filter(g=>g!==null),x=b[b.indexOf(f)+(i.key==="ArrowDown"?1:-1)];x&&(x.focus(),i.preventDefault())}else i.key===m&&p&&(p.focus(),i.preventDefault());else p&&i.target===p&&i.key===h&&(f==null||f.focus(),i.preventDefault())};return s.jsx(Rr,{value:a,children:s.jsx(we.div,{...t?{"data-active":"true","aria-current":"true"}:null,...n,onKeyDown:C(n.onKeyDown,u),ref:e})})});Et.displayName="ThreadListItemPrimitive.Root";const Nr=()=>{const{archive:n}=Rn();return n},Dr=se("ThreadListItemPrimitive.Archive",Nr),Er=()=>{const{unarchive:n}=Nn();return n},_r=se("ThreadListItemPrimitive.Unarchive",Er),Ar=()=>{const{delete:n}=Pn();return n},Or=se("ThreadListItemPrimitive.Delete",Ar),kr=()=>{const{switchTo:n}=Dn();return n},Fr=se("ThreadListItemPrimitive.Trigger",kr),_t=d.forwardRef((n,e)=>{var a;const t=N(3),o=X(e,(a=Re())==null?void 0:a.triggerRef);let r;return t[0]!==n||t[1]!==o?(r=s.jsx(ge.ItemSlot,{scope:void 0,children:s.jsx(Fr,{...n,ref:o})}),t[0]=n,t[1]=o,t[2]=r):r=t[2],r});_t.displayName="ThreadListItemPrimitive.Trigger";var ve=Me({Archive:()=>Dr,Delete:()=>Or,Root:()=>Et,Title:()=>rt,Trigger:()=>_t,Unarchive:()=>_r});const ae=gt(),At=ye(()=>{}),Ot=()=>Ie(At),kt=ye(!1),Ft=()=>Ie(kt),Bt=n=>{const e=N(26);let t,o,r,a,c,l,u;e[0]!==n?({__scopeThreadListItemMore:t,open:c,defaultOpen:o,onOpenChange:a,sharedFocusGroup:u,modal:r,...l}=n,e[0]=n,e[1]=t,e[2]=o,e[3]=r,e[4]=a,e[5]=c,e[6]=l,e[7]=u):(t=e[1],o=e[2],r=e[3],a=e[4],c=e[5],l=e[6],u=e[7]);const i=u===void 0?!1:u,m=i?!1:r??!0,h=ae(t),f=o??!1;let p;e[8]!==a?(p=a?{onChange:a}:{},e[8]=a,e[9]=p):p=e[9];let b;e[10]!==c||e[11]!==f||e[12]!==p?(b={prop:c,defaultProp:f,caller:"ThreadListItemMorePrimitive.Root",...p},e[10]=c,e[11]=f,e[12]=p,e[13]=b):b=e[13];const[x,g]=Ye(b);let M;e[14]!==m||e[15]!==x||e[16]!==l||e[17]!==h||e[18]!==g?(M=s.jsx(Ct,{...h,...l,modal:m,open:x,onOpenChange:g}),e[14]=m,e[15]=x,e[16]=l,e[17]=h,e[18]=g,e[19]=M):M=e[19];let L;e[20]!==g||e[21]!==M?(L=s.jsx(At.Provider,{value:g,children:M}),e[20]=g,e[21]=M,e[22]=L):L=e[22];let j;return e[23]!==i||e[24]!==L?(j=s.jsx(kt.Provider,{value:i,children:L}),e[23]=i,e[24]=L,e[25]=j):j=e[25],j};Bt.displayName="ThreadListItemMorePrimitive.Root";const $t=d.forwardRef((n,e)=>{const t=N(10),{__scopeThreadListItemMore:o,...r}=n,a=ae(o),c=Re(),l=Ot(),u=Ft(),i=X(e,c==null?void 0:c.moreRef),m=ce()==="rtl"?"ArrowLeft":"ArrowRight",h=wr;let f;t[0]!==m||t[1]!==l||t[2]!==u?(f=x=>{!u||x.key!==m||(x.preventDefault(),l(!0))},t[0]=m,t[1]=l,t[2]=u,t[3]=f):f=t[3];const p=C(r.onKeyDown,f);let b;return t[4]!==h||t[5]!==i||t[6]!==r||t[7]!==a||t[8]!==p?(b=s.jsx(h,{...a,...r,onKeyDown:p,ref:i}),t[4]=h,t[5]=i,t[6]=r,t[7]=a,t[8]=p,t[9]=b):b=t[9],b});$t.displayName="ThreadListItemMorePrimitive.Trigger";const Kt=d.forwardRef((n,e)=>{const t=N(21),{__scopeThreadListItemMore:o,portalProps:r,sideOffset:a,...c}=n,l=a===void 0?4:a,u=ae(o),i=Ot(),m=Re(),h=Ft(),f=ce()==="rtl"?"ArrowRight":"ArrowLeft",p=br,b=Ir;let x;t[0]!==f||t[1]!==(m==null?void 0:m.moreRef)||t[2]!==i||t[3]!==h?(x=_=>{var A;!h||_.key!==f||(_.preventDefault(),i(!1),(A=m==null?void 0:m.moreRef.current)==null||A.focus())},t[0]=f,t[1]=m==null?void 0:m.moreRef,t[2]=i,t[3]=h,t[4]=x):x=t[4];const g=C(c.onKeyDown,x);let M;t[5]!==(m==null?void 0:m.moreRef)||t[6]!==h?(M=()=>{var _;h&&((_=m==null?void 0:m.moreRef.current)==null||_.focus())},t[5]=m==null?void 0:m.moreRef,t[6]=h,t[7]=M):M=t[7];const L=C(c.onEscapeKeyDown,M);let j;t[8]!==b||t[9]!==e||t[10]!==c||t[11]!==u||t[12]!==l||t[13]!==g||t[14]!==L?(j=s.jsx(b,{...u,...c,onKeyDown:g,onEscapeKeyDown:L,ref:e,sideOffset:l}),t[8]=b,t[9]=e,t[10]=c,t[11]=u,t[12]=l,t[13]=g,t[14]=L,t[15]=j):j=t[15];let P;return t[16]!==r||t[17]!==u||t[18]!==p.Portal||t[19]!==j?(P=s.jsx(p.Portal,{...u,...r,children:j}),t[16]=r,t[17]=u,t[18]=p.Portal,t[19]=j,t[20]=P):P=t[20],P});Kt.displayName="ThreadListItemMorePrimitive.Content";const zt=d.forwardRef((n,e)=>{const t=N(7);let o,r;t[0]!==n?({__scopeThreadListItemMore:o,...r}=n,t[0]=n,t[1]=o,t[2]=r):(o=t[1],r=t[2]);const a=ae(o);let c;return t[3]!==e||t[4]!==r||t[5]!==a?(c=s.jsx(yr,{...a,...r,ref:e}),t[3]=e,t[4]=r,t[5]=a,t[6]=c):c=t[6],c});zt.displayName="ThreadListItemMorePrimitive.Item";const Gt=d.forwardRef((n,e)=>{const t=N(7);let o,r;t[0]!==n?({__scopeThreadListItemMore:o,...r}=n,t[0]=n,t[1]=o,t[2]=r):(o=t[1],r=t[2]);const a=ae(o);let c;return t[3]!==e||t[4]!==r||t[5]!==a?(c=s.jsx(Mr,{...a,...r,ref:e}),t[3]=e,t[4]=r,t[5]=a,t[6]=c):c=t[6],c});Gt.displayName="ThreadListItemMorePrimitive.Separator";var he=Me({Content:()=>Kt,Item:()=>zt,Root:()=>Bt,Separator:()=>Gt,Trigger:()=>$t});function Br(){const n=Q(),e=qe(),t=Le(),o=Je(),r=t||o,[a,c]=d.useState(!1),[l,u]=d.useState(""),[i,m]=d.useState(null),h=d.useRef(null),f=d.useRef(null),p=d.useId(),b=(n==null?void 0:n.isLibraryEnabled)===!0&&e!=null,x=(n==null?void 0:n.historyAgentFilter)??null;d.useEffect(()=>{a||u("")},[a]);const{agents:g,isInitialLoading:M,isSearching:L,loadingMore:j,hasMore:P,listRef:_,sentinelRef:A}=hn({enabled:a&&b,query:l});if(d.useLayoutEffect(()=>{if(!a||r){m(null);return}const I=()=>{var E;const R=(E=h.current)==null?void 0:E.getBoundingClientRect();R&&m({top:R.top,left:R.right+4})};return I(),window.addEventListener("resize",I),window.addEventListener("scroll",I,!0),()=>{window.removeEventListener("resize",I),window.removeEventListener("scroll",I,!0)}},[a,r]),d.useEffect(()=>{if(!a||r)return;const I=R=>{var B,w;const E=R.target;(B=h.current)!=null&&B.contains(E)||(w=f.current)!=null&&w.contains(E)||c(!1)};return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[a,r]),!b)return null;const O=I=>{(n==null?void 0:n.isComposerEnabled)===!0?n.openDraft():n==null||n.openLibraryHome(),n==null||n.setHistoryAgentFilter(I),c(!1)},D=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"p-1",onMouseDown:I=>I.stopPropagation(),children:[s.jsx(pn,{query:l,setQuery:u,placeholder:"Search agents"}),L?s.jsx("p",{className:"text-text-secondary px-1 pt-1 text-[11px]",role:"status",children:"Searching…"}):null]}),s.jsxs("div",{ref:_,className:F("mt-1 overflow-y-auto",r?"min-h-0 flex-1 px-1 pb-2":"min-h-48 max-h-64"),children:[l.trim()===""?s.jsxs(Ae,{className:F("justify-between",x==null&&"bg-dropdown-selected-item-bg text-dropdown-selected-item-text"),onClick:()=>O(null),children:["All chats",x==null?s.jsx(z,{name:"check",className:"size-3.5 shrink-0"}):null]}):null,M?s.jsx("p",{className:"px-2 py-3 text-center text-xs text-text-secondary",children:"Loading…"}):g.length===0?s.jsx("p",{className:"text-text-secondary px-2 py-6 text-center text-xs",role:"status",children:l.trim()?`No agents match "${l.trim()}".`:"No agents yet."}):s.jsxs(s.Fragment,{children:[g.map(I=>{const R=xn(I),E=(x==null?void 0:x.agentId)===R;return s.jsxs(Ae,{className:F("justify-between gap-2 text-left",E&&"bg-dropdown-selected-item-bg text-dropdown-selected-item-text"),onClick:()=>O({agentId:R,agentName:I.name,intent:"history"}),children:[s.jsx("span",{className:"min-w-0 truncate",children:I.name}),E?s.jsx(z,{name:"check",className:"size-3.5 shrink-0"}):null]},R)}),P?s.jsx("div",{ref:A,className:"flex h-6 shrink-0 items-center justify-center","aria-hidden":!0,children:j?s.jsx("span",{className:"text-text-secondary text-[11px]",role:"status",children:"Loading more…"}):null}):null]})]})]});return s.jsxs("div",{className:"relative shrink-0",children:[s.jsxs("button",{ref:h,type:"button","aria-label":x!=null?`Filter chat history by agent (${x.agentName})`:"Filter chat history by agent","aria-haspopup":r?"dialog":"menu","aria-expanded":a,"aria-controls":a?p:void 0,title:"Filter by agent",className:re({variant:"ghost",size:"icon",className:F("relative size-7 shrink-0 text-text-secondary hover:bg-ghost-button-hover hover:text-ghost-button-text",x!=null&&"text-text-primary")}),onClick:()=>c(I=>!I),children:[s.jsx(z,{name:"funnel",className:"size-3.5"}),x!=null?s.jsx("span",{className:"bg-primary-button-bg absolute top-1 right-1 size-1.5 rounded-full","aria-hidden":!0,"data-testid":"history-filter-active-dot"}):null]}),r&&a?s.jsx(Qe,{open:!0,onOpenChange:c,id:p,"aria-label":"Filter agents",children:s.jsx("div",{className:"flex min-h-0 flex-1 flex-col p-2",role:"menu",children:D})}):null,!r&&a&&i!=null?gn.createPortal(s.jsx("div",{ref:f,id:p,role:"menu","aria-label":"Filter agents",style:{top:i.top,left:i.left},className:"font-sans-flex fixed z-50 w-56 rounded-md border border-border bg-card-bg p-1 text-text-primary shadow-md",children:D}),vn(h.current)):null]})}var Be="flex w-full cursor-pointer select-none items-center gap-2 rounded-md px-2 py-1.5 text-sm font-medium text-failure-bg outline-none transition-colors hover:bg-failure-bg/12 hover:text-failure-bg focus:bg-failure-bg/12 focus:text-failure-bg data-[highlighted]:bg-failure-bg/12 data-[highlighted]:text-failure-bg";function $r({disabled:n}){const e=T("PermissionGuard"),t=Je(),o=Le(),[r,a]=d.useState(!1),[c,l]=d.useState(),u=o||t,i=d.useCallback(h=>{const f=h==null?void 0:h.closest(".aui-theme-root");l(f instanceof HTMLElement?f:void 0)},[]),m=re({variant:"ghost",size:"icon",className:"size-7 shrink-0 text-text-secondary hover:bg-transparent hover:text-text-primary"});return u?s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button","aria-label":"Session actions",title:"Session actions","aria-haspopup":"dialog","aria-expanded":r,className:m,onClick:()=>a(!0),children:s.jsx(z,{name:"ellipsis",className:"size-3.5"})}),r?s.jsx(Qe,{open:!0,onOpenChange:a,"aria-label":"Session actions",children:s.jsx("div",{className:"flex flex-col gap-1 p-2 *:w-full",role:"menu",children:s.jsx(e,{allowed:!n,children:s.jsxs(ve.Delete,{className:Be,onClick:()=>{n||a(!1)},children:[s.jsx(z,{name:"trash",className:"size-3.5"}),"Delete"]})})})}):null]}):s.jsxs(he.Root,{sharedFocusGroup:!0,children:[s.jsx(he.Trigger,{ref:i,"aria-label":"Session actions",title:"Session actions",className:m,children:s.jsx(z,{name:"ellipsis",className:"size-3.5"})}),s.jsx(he.Content,{portalProps:{container:c},align:"end",sideOffset:4,className:"font-sans-flex z-50 min-w-[8rem] rounded-md border border-border bg-card-bg p-1 text-text-primary shadow-md *:w-full",children:s.jsx(e,{allowed:!n,children:s.jsxs(ve.Delete,{className:Be,children:[s.jsx(z,{name:"trash",className:"size-3.5"}),"Delete"]})})})]})}function Kr({onThreadOpen:n,canDeleteSession:e,canDeleteResource:t}){const o=G(),r=Q(),a=T("ThreadListRow"),c=S(g=>g.threadListItem.id),l=S(g=>g.threadListItem.remoteId),u=S(g=>g.threadListItem.title),i=S(g=>g.threadListItem.lastMessageAt),m=S(g=>g.threadListItem.custom),h=S(g=>g.threads.mainThreadId),f=dn(m),p=e&&l!=null,b=l!=null&&!t(l),x=(r==null?void 0:r.libraryOpen)===!0||(r==null?void 0:r.sessionsOpen)===!0||(r==null?void 0:r.schedulesOpen)===!0;return s.jsx(ve.Root,{className:"min-w-0",children:s.jsx(a,{title:u??"New Chat",active:c===h&&!x,agentName:f,lastMessageAt:i,onSelect:()=>{n==null||n(),r==null||r.setSettingsOpen(!1),r==null||r.setLibraryOpen(!1),r==null||r.setSessionsOpen(!1),r==null||r.setSchedulesOpen(!1);const g=mn(m),M=!g&&(r==null?void 0:r.mode.status)==="active"&&!r.mode.isMutable&&(f==null?r.mode.agentName==null&&r.mode.agentId==null:r.mode.agentName===f||r.mode.agentId===f),L=fn({sessionMutable:g,shellMutable:(r==null?void 0:r.mode.status)==="active"&&r.mode.isMutable,...(r==null?void 0:r.mode.status)==="active"&&r.mode.isMutable?{shellAgentName:r.mode.agentName,shellAgentId:r.mode.agentId}:{},remoteId:l,pendingSessionId:r==null?void 0:r.pendingSessionId});if((M||L)&&l!=null){Promise.resolve(o.threads().switchToThread(c)).catch(()=>{});return}if(l!=null){r==null||r.openHistorySession({sessionId:l,isMutable:g,...f!=null?{agentName:f}:{}});return}Promise.resolve(o.threads().switchToThread(c)).catch(()=>{})},actions:p?s.jsx($r,{disabled:b}):void 0})})}function zr(n){const e=S(o=>o.threads.threadIds),t=S(o=>o.threads.threadItems);return d.useMemo(()=>{const o=un({threadIds:e,threadItems:t});if(n==="default")return o;const r=new Map;for(const a of t)r.set(a.id,a),a.remoteId!=null&&r.set(a.remoteId,a);return o.filter(a=>{const c=e[a];if(c===void 0)return!1;const l=r.get(c);return(l==null?void 0:l.remoteId)!=null})},[e,t,n])}function Gr({indices:n,onThreadOpen:e,canDeleteSession:t,canDeleteResource:o}){const r=S(a=>a.threads.threadIds);return s.jsx(s.Fragment,{children:n.map(a=>{const c=r[a]??String(a);return s.jsx(Ce,{index:a,archived:!1,children:s.jsx(Kr,{onThreadOpen:e,canDeleteSession:t,canDeleteResource:o})},c)})})}var Hr="aui_thread-list-viewport",Ur=80;function Vr({children:n,viewportRef:e,hideScrollbar:t}){var u;const o=Q(),r=S(i=>i.threadListItem.remoteId),a=(u=o==null?void 0:o.historyAgentFilter)==null?void 0:u.intent,c=(o==null?void 0:o.isLibraryEnabled)===!0&&a!=="try-agent"&&(a==="history"||o.mode.status!=="active"||o.mode.isMutable||o.pendingSessionId!=null||r!=null),l=(o==null?void 0:o.historyAgentFilter)==null?"Chat History":`Chats for ${o.historyAgentFilter.agentName}`;return s.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[s.jsxs("div",{className:"flex shrink-0 items-center gap-1 px-1 py-1",children:[s.jsx("h2",{className:"min-w-0 flex-1 truncate px-1.5 py-1 text-sm font-medium text-text-secondary",children:l}),c?s.jsx(Br,{}):null]}),s.jsx("div",{ref:e,"data-slot":Hr,className:F("flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto",t&&"aui-scrollbar-hidden"),children:n})]})}function Wr({onThreadOpen:n,variant:e="default"}={}){const t=G(),o=qe(),r=S(w=>w.threads.isLoading),a=S(w=>w.threads.isLoadingMore),c=S(w=>w.threads.hasMore),l=S(w=>w.threads.threadIds),u=S(w=>w.threads.threadItems),i=Q(),m=T("ThreadListShell"),h=T("ThreadListNewButton"),f=T("AgentsLibraryButton"),p=T("SessionsBrowserButton"),b=T("SchedulesButton"),x=T("ThreadListRowSkeleton"),g=T("ThreadListEmptyState"),M=zr(e),L=d.useRef(null),j=d.useRef(c),P=d.useRef(t);j.current=c,P.current=t;const _=(i==null?void 0:i.isNewChatEnabled)!==!1,A=(i==null?void 0:i.mode.status)==="idle",O=e==="recent-history",D=typeof(o==null?void 0:o.deleteSession)=="function",I=d.useMemo(()=>u.flatMap(w=>w.remoteId==null?[]:[w.remoteId]),[u]),{allows:R}=ln({resourceType:"session",resourceIds:I});d.useEffect(()=>{if(A||r||a)return;const w=L.current;if(!w)return;let te=!1;const $=()=>{if(te||!j.current||w.clientHeight<=0)return;const de=w.scrollHeight-w.scrollTop-w.clientHeight;w.scrollHeight>w.clientHeight&&de>Ur||P.current.threads().loadMore()};w.addEventListener("scroll",$,{passive:!0});const U=typeof ResizeObserver>"u"?void 0:new ResizeObserver(()=>$());return U?U.observe(w):window.addEventListener("resize",$),$(),()=>{te=!0,w.removeEventListener("scroll",$),U==null||U.disconnect(),U||window.removeEventListener("resize",$)}},[c,A,r,a,l.length]);const E=()=>{if(n==null||n(),i==null||i.setLibraryOpen(!1),i==null||i.setSessionsOpen(!1),i!=null&&i.isComposerEnabled){i.openDraft();return}i==null||i.setSettingsOpen(!1),i==null||i.setSchedulesOpen(!1),Promise.resolve(t.threads().switchToNewThread()).catch(()=>{})};let B;return A?B=s.jsx(g,{message:O?"No recent chats":void 0}):r?B=s.jsx(x,{}):M.length===0?B=s.jsx(g,{message:O?"No recent chats":void 0}):B=s.jsx(Pr.Root,{className:"flex min-h-0 flex-col gap-0.5",children:s.jsx(Gr,{indices:M,onThreadOpen:n,canDeleteSession:D,canDeleteResource:w=>R(w,"DELETE")})}),s.jsx(m,{header:O?null:s.jsxs("div",{className:"flex flex-col gap-1",children:[_?s.jsx(h,{onClick:E}):null,s.jsx(f,{}),s.jsx(p,{}),s.jsx(b,{})]}),children:s.jsxs(Vr,{viewportRef:L,hideScrollbar:O,children:[B,!A&&c?s.jsx("div",{className:"h-4 shrink-0","aria-hidden":!0}):null]})})}var Xr=d.lazy(()=>et(()=>import("./SettingsBuilder-3OA4UCIM-AN2PJd1q.js"),__vite__mapDeps([0,1,2]),import.meta.url)),Yr=d.lazy(()=>et(()=>import("./SchedulesPage-JIUWNYUH-5f3ROPme.js"),__vite__mapDeps([3,1,2]),import.meta.url).then(n=>({default:n.SchedulesPage}))),qr="h-5 w-5 max-w-40 shrink-0 object-contain",Jr="w-20",$e=F(Mn,"text-sidebar-text"),Ke="bg-primary-button-bg font-medium text-primary-button-text hover:bg-primary-button-hover hover:text-primary-button-text";function Qr({overlayOpen:n,mode:e}){return!n&&(e==null?void 0:e.status)==="active"&&!e.isCreateAgent}function Zr(){var f;const n=G(),e=Q(),t=T("AgentsLibraryButton"),o=T("SessionsBrowserButton"),r=T("SchedulesButton"),a=(e==null?void 0:e.isNewChatEnabled)!==!1,c=(e==null?void 0:e.settingsOpen)===!0||(e==null?void 0:e.libraryOpen)===!0||(e==null?void 0:e.sessionsOpen)===!0||(e==null?void 0:e.schedulesOpen)===!0,l=e==null?void 0:e.mode,u=!c&&(l==null?void 0:l.status)==="active"&&!l.isCreateAgent&&((f=e==null?void 0:e.historyAgentFilter)==null?void 0:f.intent)!=="try-agent",i=!c&&l!=null&&Ze(l),m=()=>{if(e==null||e.setLibraryOpen(!1),e==null||e.setSessionsOpen(!1),e!=null&&e.isComposerEnabled){e.openDraft();return}e==null||e.setSettingsOpen(!1),e==null||e.setSchedulesOpen(!1),Promise.resolve(n.threads().switchToNewThread()).catch(()=>{})},h=()=>{e==null||e.setLibraryOpen(!1),e==null||e.setSessionsOpen(!1),e!=null&&e.isComposerEnabled&&e.openAgentBuilder()};return s.jsxs("nav",{className:"flex min-h-0 flex-1 flex-col items-center gap-1 p-1","aria-label":"Sidebar",children:[a?s.jsxs("button",{type:"button","aria-label":"Start new chat",title:"New chat","aria-current":u?"page":void 0,className:re({variant:"ghost",className:F($e,u&&Ke)}),onClick:m,children:[s.jsx(z,{name:"square-pen",size:14}),s.jsx("span",{className:"text-center",children:"New Chat"})]}):null,a&&(e!=null&&e.isComposerEnabled)?s.jsxs("button",{type:"button","aria-label":"Start new agent",title:"New Agent","aria-current":i?"page":void 0,className:re({variant:"ghost",className:F($e,i&&Ke)}),onClick:h,children:[s.jsx(z,{name:"agent-2",size:14}),s.jsx("span",{className:"text-center whitespace-nowrap",children:"Build Agent"})]}):null,s.jsx(t,{compact:!0}),s.jsx(o,{compact:!0}),s.jsx(r,{compact:!0})]})}function ze({onNavigate:n,className:e,railRef:t,...o}){const r=In(),a=yn(r),c=T("BrandLogo"),l=T("UserAvatar");return s.jsxs("aside",{ref:t,className:F(Jr,"flex min-h-0 shrink-0 flex-col border-r border-border bg-sidebar-bg",e),onClick:u=>{if(n==null)return;const i=u.target;i instanceof Element&&i.closest("button")!=null&&n()},...o,children:[s.jsx("div",{className:"flex h-14 w-full shrink-0 items-center justify-center text-text-primary",children:s.jsx(c,{variant:a.collapsedVariant,className:qr})}),s.jsx(Zr,{}),s.jsxs("footer",{className:"flex shrink-0 flex-col items-center border-border p-2",children:[s.jsx(Tn,{labeled:!0,className:"flex-col"}),s.jsx(l,{labeled:!0,className:"mt-1"})]})]})}function cs({className:n}){const e=Q(),t=Le(),o=T("AgentDetailsPage"),r=T("AgentsLibrary"),a=T("SessionsPage"),c=T("ClearChatButton"),l=T("SaveAgentButton"),u=T("SelectAgentEmptyState"),[i,m]=d.useState(!1),h=d.useRef(null),f=d.useRef(null),p=d.useRef(null),b=d.useRef(!1),x=(e==null?void 0:e.mode.status)==="idle",g=(e==null?void 0:e.settingsOpen)===!0,M=(e==null?void 0:e.libraryOpen)===!0,L=(e==null?void 0:e.sessionsOpen)===!0,j=(e==null?void 0:e.schedulesOpen)===!0,P=g||M||L||j,_=e!=null&&Ze(e.mode)&&!P&&(!t||e.agentConfigOpen),A=Qr({overlayOpen:P,mode:e==null?void 0:e.mode}),O=bn();return d.useEffect(()=>{if(!i)return;const D=I=>{I.key==="Escape"&&m(!1)};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[i]),d.useEffect(()=>{var I,R;const D=p.current;if(i){b.current=!0,D&&(D.inert=!0),(I=f.current)==null||I.focus();return}b.current&&(D&&(D.inert=!1),(R=h.current)==null||R.focus(),b.current=!1)},[i]),s.jsxs("div",{className:F("relative flex h-full min-h-0 w-full min-w-0",n),children:[s.jsx(ze,{className:"hidden md:flex"}),_?s.jsx("aside",{role:"dialog","aria-label":"Agent Config",className:"absolute inset-y-0 left-0 z-20 w-full max-w-sm border-r border-border shadow-xl md:static md:z-auto md:max-w-140 md:flex-1 md:shadow-none 2xl:max-w-150",children:s.jsx(Ln,{showClose:t})}):null,s.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col bg-primary-bg",children:[s.jsx(wn,{className:F("bg-topbar-bg",(P||x||!O)&&"md:hidden"),start:P?null:s.jsx("button",{ref:h,type:"button","aria-label":"Navigation","aria-expanded":i,className:F(re({variant:"ghost",size:"icon"}),"md:hidden"),onClick:()=>m(!0),children:s.jsx(z,{name:"bars"})}),title:P?null:s.jsx(Cn,{}),end:P?null:s.jsxs(s.Fragment,{children:[s.jsx(c,{}),s.jsx(l,{})]})}),s.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1",children:[A?s.jsx("aside",{"aria-label":"Recent chats",className:"hidden min-h-0 w-64 shrink-0 border-r border-border bg-sidebar-bg md:flex",children:s.jsx(Wr,{variant:"recent-history"})}):null,s.jsx("div",{ref:p,className:"min-h-0 min-w-0 flex-1",children:g?s.jsx(d.Suspense,{fallback:s.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[s.jsx(Oe,{size:28,className:"text-text-primary"}),s.jsx("span",{className:"sr-only",children:"Loading"})]}),children:s.jsx(Xr,{})}):L?s.jsx(a,{}):M&&(e==null?void 0:e.libraryAgentId)!=null?s.jsx(o,{agentId:e.libraryAgentId},e.libraryAgentId):M?s.jsx(r,{onSelectAgent:()=>m(!1)}):j?s.jsx(d.Suspense,{fallback:s.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[s.jsx(Oe,{size:28,className:"text-text-primary"}),s.jsx("span",{className:"sr-only",children:"Loading"})]}),children:s.jsx(Yr,{})}):x?s.jsx(u,{}):s.jsx(jn,{})})]})]}),i?s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button","aria-label":"Close navigation",className:"absolute inset-0 z-[9] cursor-pointer bg-[var(--overlay)] md:hidden",onClick:()=>m(!1)}),s.jsx(ze,{railRef:f,role:"dialog","aria-label":"Navigation",tabIndex:-1,onNavigate:()=>m(!1),className:"absolute inset-y-0 left-0 z-10 shadow-lg outline-none md:hidden"})]}):null]})}export{cs as SidebarLayout};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SettingsBuilder-B2ULQPIT-D67kXI0z.js","./index-BIRSKAK8.js","./index-B01pXqvC.css","./SchedulesPage-ZG5IMQI3-DM9Xo4uZ.js"])))=>i.map(i=>d[i]);
2
+ import{bx as N,by as Ut,u as G,j as s,bz as Vt,r as d,aU as S,bA as Ge,bB as Wt,bC as He,bD as Ue,bE as Ve,bF as We,bG as Xe,bH as X,bI as Xt,bJ as C,bK as Yt,bL as qt,bM as Qt,bN as Zt,bO as Jt,bP as en,bQ as tn,bR as nn,bS as be,bT as rn,bU as sn,bV as ce,bW as on,bX as an,bY as cn,bZ as Ye,b_ as Ee,b$ as le,c0 as we,c1 as se,c2 as Ie,c3 as ye,c4 as Me,c5 as _e,h as qe,a as Z,c as T,E as ln,c6 as un,e as F,c7 as dn,c8 as mn,c9 as fn,b as Le,aK as Qe,a3 as hn,H as pn,aa as Ae,I as z,q as xn,d as re,ca as Ze,a4 as gn,a7 as vn,s as Je,cb as bn,P as wn,S as Oe,cc as In,cd as yn,_ as et,bq as Mn}from"./index-BIRSKAK8.js";import{A as Ln,N as Cn,T as jn,S as Tn}from"./chunk-3R62ISBR-CDV8LPCs.js";const Ce=n=>{const e=N(8),{index:t,archived:o,children:r}=n;let a;e[0]!==o||e[1]!==t?(a=Ut({source:"threads",query:{type:"index",index:t,archived:o},get:i=>i.threads().item({index:t,archived:o})}),e[0]=o,e[1]=t,e[2]=a):a=e[2];let c;e[3]!==a?(c={threadListItem:a},e[3]=a,e[4]=c):c=e[4];const l=G(c);let u;return e[5]!==l||e[6]!==r?(u=s.jsx(Vt,{value:l,children:r}),e[5]=l,e[6]=r,e[7]=u):u=e[7],u},tt=d.memo(n=>{const e=N(6),{index:t,archived:o,components:r}=n,a=o===void 0?!1:o,c=r.ThreadListItem;let l;e[0]!==c?(l=s.jsx(c,{}),e[0]=c,e[1]=l):l=e[1];let u;return e[2]!==a||e[3]!==t||e[4]!==l?(u=s.jsx(Ce,{index:t,archived:a,children:l}),e[2]=a,e[3]=t,e[4]=l,e[5]=u):u=e[5],u},(n,e)=>n.index===e.index&&n.archived===e.archived&&n.components.ThreadListItem===e.components.ThreadListItem);tt.displayName="ThreadListPrimitive.ItemByIndex";const ke=({archived:n,children:e})=>{const t=S(o=>n?o.threads.archivedThreadIds.length:o.threads.threadIds.length);return Ge(()=>Array.from({length:t},(o,r)=>s.jsx(Ce,{index:r,archived:n,children:s.jsx(Wt,{getItemState:a=>a.threads().item({index:r,archived:n}).getState(),children:a=>e({get threadListItem(){return a()}})})},r)),[t,n,e])},nt=n=>{const e=N(8),{archived:t,components:o,children:r}=n,a=t===void 0?!1:t;if(o){const l=o.ThreadListItem;let u;e[0]!==l?(u=()=>s.jsx(l,{}),e[0]=l,e[1]=u):u=e[1];let i;return e[2]!==a||e[3]!==u?(i=s.jsx(ke,{archived:a,children:u}),e[2]=a,e[3]=u,e[4]=i):i=e[4],i}let c;return e[5]!==a||e[6]!==r?(c=s.jsx(ke,{archived:a,children:r}),e[5]=a,e[6]=r,e[7]=c):c=e[7],c};nt.displayName="ThreadListPrimitive.Items";const rt=n=>{const e=N(2),{fallback:t}=n,o=S(Sn)||t;let r;return e[0]!==o?(r=s.jsx(s.Fragment,{children:o}),e[0]=o,e[1]=r):r=e[1],r};rt.displayName="ThreadListItemPrimitive.Title";function Sn(n){return n.threadListItem.title}const Rn=()=>{const n=N(4),e=G();let t;n[0]!==e?(t=()=>{e.threadListItem().archive()},n[0]=e,n[1]=t):t=n[1];const o=t;let r;return n[2]!==o?(r={archive:o},n[2]=o,n[3]=r):r=n[3],r},Pn=()=>{const n=N(4),e=G();let t;n[0]!==e?(t=()=>{e.threadListItem().delete()},n[0]=e,n[1]=t):t=n[1];const o=t;let r;return n[2]!==o?(r={delete:o},n[2]=o,n[3]=r):r=n[3],r},Nn=()=>{const n=N(4),e=G();let t;n[0]!==e?(t=()=>{e.threadListItem().unarchive()},n[0]=e,n[1]=t):t=n[1];const o=t;let r;return n[2]!==o?(r={unarchive:o},n[2]=o,n[3]=r):r=n[3],r},Dn=()=>{const n=N(4),e=G();let t;n[0]!==e?(t=()=>{e.threadListItem().switchTo()},n[0]=e,n[1]=t):t=n[1];const o=t;let r;return n[2]!==o?(r={switchTo:o},n[2]=o,n[3]=r):r=n[3],r},En=()=>{const n=N(4),e=G();let t;n[0]!==e?(t=()=>{e.threads().switchToNewThread()},n[0]=e,n[1]=t):t=n[1];const o=t;let r;return n[2]!==o?(r={switchToNewThread:o},n[2]=o,n[3]=r):r=n[3],r},_n=()=>{const n=N(5),e=G(),t=S(An);let o;n[0]!==e?(o=()=>{e.threads().loadMore()},n[0]=e,n[1]=o):o=n[1];const r=o;let a;return n[2]!==t||n[3]!==r?(a={loadMore:r,disabled:t},n[2]=t,n[3]=r,n[4]=a):a=n[4],a};function An(n){return!n.threads.hasMore||n.threads.isLoading||n.threads.isLoadingMore}var On=Object.defineProperty,y=(n,e)=>On(n,"name",{value:e,configurable:!0}),kn=["Enter"," "],Fn=["ArrowDown","PageUp","Home"],st=["ArrowUp","PageDown","End"],Bn=[...Fn,...st],ue="Menu",[pe,Kn,$n]=We(ue),[Y,ot]=He(ue,[$n,Ue,Ve]),je=Ue(),at=Ve(),[zn,oe]=Y(ue),[Gn,Te]=Y(ue),Hn=y(n=>{const{__scopeMenu:e,open:t=!1,children:o,dir:r,onOpenChange:a,modal:c=!0}=n,l=je(e),[u,i]=d.useState(null),m=d.useRef(!1),h=sn(a),f=ce(r);return d.useEffect(()=>{const p=y(()=>{m.current=!0,document.addEventListener("pointerdown",b,{capture:!0,once:!0}),document.addEventListener("pointermove",b,{capture:!0,once:!0})},"handleKeyDown"),b=y(()=>m.current=!1,"handlePointer");return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",b,{capture:!0}),document.removeEventListener("pointermove",b,{capture:!0})}},[]),d.useEffect(()=>{if(!t)return;const p=y(()=>h(!1),"handleBlur");return window.addEventListener("blur",p),()=>window.removeEventListener("blur",p)},[t,h]),s.jsx(on,{...l,children:s.jsx(zn,{scope:e,open:t,onOpenChange:h,content:u,onContentChange:i,children:s.jsx(Gn,{scope:e,onClose:d.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:m,dir:f,modal:c,children:o})})})},"Menu"),Un=d.forwardRef(y(function(e,t){const{__scopeMenu:o,...r}=e,a=je(o);return s.jsx(an,{...a,...r,ref:t})},"MenuAnchor")),it="MenuPortal",[Vn,Wn]=Y(it,{forceMount:void 0}),Xn=y(n=>{const{__scopeMenu:e,forceMount:t,children:o,container:r}=n,a=oe(it,e);return s.jsx(Vn,{scope:e,forceMount:t,children:s.jsx(Xe,{present:t||a.open,children:s.jsx(cn,{asChild:!0,container:r,children:o})})})},"MenuPortal"),W="MenuContent",[Yn,ct]=Y(W),qn=d.forwardRef(y(function(e,t){const o=Wn(W,e.__scopeMenu),{forceMount:r=o.forceMount,...a}=e,c=oe(W,e.__scopeMenu),l=Te(W,e.__scopeMenu);return s.jsx(pe.Provider,{scope:e.__scopeMenu,children:s.jsx(Xe,{present:r||c.open,children:s.jsx(pe.Slot,{scope:e.__scopeMenu,children:l.modal?s.jsx(Qn,{...a,ref:t}):s.jsx(Zn,{...a,ref:t})})})})},"MenuContent")),Qn=d.forwardRef(y(function(e,t){const o=oe(W,e.__scopeMenu),r=d.useRef(null),a=X(t,r);return d.useEffect(()=>{const c=r.current;if(c)return Xt(c)},[]),s.jsx(lt,{...e,ref:a,trapFocus:o.open,disableOutsidePointerEvents:o.open,disableOutsideScroll:!0,onFocusOutside:C(e.onFocusOutside,c=>c.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>o.onOpenChange(!1)})},"MenuRootContentModal")),Zn=d.forwardRef(y(function(e,t){const o=oe(W,e.__scopeMenu);return s.jsx(lt,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>o.onOpenChange(!1)})},"MenuRootContentNonModal")),Jn=rn("MenuContent.ScrollLock"),lt=d.forwardRef(y(function(e,t){const{__scopeMenu:o,loop:r=!1,trapFocus:a,onOpenAutoFocus:c,onCloseAutoFocus:l,disableOutsidePointerEvents:u,onEntryFocus:i,onEscapeKeyDown:m,onPointerDownOutside:h,onFocusOutside:f,onInteractOutside:p,onDismiss:b,disableOutsideScroll:x,...g}=e,M=oe(W,o),L=Te(W,o),j=je(o),P=at(o),_=Kn(o),[A,O]=d.useState(null),D=d.useRef(null),I=X(t,D,M.onContentChange),R=d.useRef(0),E=d.useRef(""),B=d.useRef(0),w=d.useRef(null),te=d.useRef("right"),K=d.useRef(0),U=x?qt:d.Fragment,de=x?{as:Jn,allowPinchZoom:!0}:void 0,Ht=y(v=>{var Q,Ne;const k=E.current+v,$=_().filter(H=>!H.disabled),V=document.activeElement,me=(Q=$.find(H=>H.ref.current===V))==null?void 0:Q.textValue,fe=$.map(H=>H.textValue),Pe=ht(fe,k,me),ne=(Ne=$.find(H=>H.textValue===Pe))==null?void 0:Ne.ref.current;y((function H(De){E.current=De,window.clearTimeout(R.current),De!==""&&(R.current=window.setTimeout(()=>H(""),1e3))}),"updateSearch")(k),ne&&setTimeout(()=>ne.focus())},"handleTypeaheadSearch");d.useEffect(()=>()=>window.clearTimeout(R.current),[]),Yt();const q=d.useCallback(v=>{var $,V;return te.current===(($=w.current)==null?void 0:$.side)&&xt(v,(V=w.current)==null?void 0:V.area)},[]);return s.jsx(Yn,{scope:o,searchRef:E,onItemEnter:d.useCallback(v=>{q(v)&&v.preventDefault()},[q]),onItemLeave:d.useCallback(v=>{var k;q(v)||((k=D.current)==null||k.focus(),O(null))},[q]),onTriggerLeave:d.useCallback(v=>{q(v)&&v.preventDefault()},[q]),pointerGraceTimerRef:B,onPointerGraceIntentChange:d.useCallback(v=>{w.current=v},[]),children:s.jsx(U,{...de,children:s.jsx(Qt,{asChild:!0,trapped:a,onMountAutoFocus:C(c,v=>{var k;v.preventDefault(),(k=D.current)==null||k.focus({preventScroll:!0})}),onUnmountAutoFocus:l,children:s.jsx(Zt,{asChild:!0,disableOutsidePointerEvents:u,onEscapeKeyDown:m,onPointerDownOutside:h,onFocusOutside:f,onInteractOutside:p,onDismiss:b,children:s.jsx(Jt,{asChild:!0,...P,dir:L.dir,orientation:"vertical",loop:r,currentTabStopId:A,onCurrentTabStopIdChange:O,onEntryFocus:C(i,v=>{L.isUsingKeyboardRef.current||v.preventDefault()}),preventScrollOnEntryFocus:!0,children:s.jsx(en,{role:"menu","aria-orientation":"vertical","data-state":ut(M.open),"data-radix-menu-content":"",dir:L.dir,...j,...g,ref:I,style:{outline:"none",...g.style},onKeyDown:C(g.onKeyDown,v=>{const $=v.target.closest("[data-radix-menu-content]")===v.currentTarget,V=v.ctrlKey||v.altKey||v.metaKey,me=v.key.length===1;$&&(v.key==="Tab"&&v.preventDefault(),!V&&me&&Ht(v.key));const fe=D.current;if(v.target!==fe||!Bn.includes(v.key))return;v.preventDefault();const ne=_().filter(Q=>!Q.disabled).map(Q=>Q.ref.current);st.includes(v.key)&&ne.reverse(),mt(ne)}),onBlur:C(e.onBlur,v=>{v.currentTarget.contains(v.target)||(window.clearTimeout(R.current),E.current="")}),onPointerMove:C(e.onPointerMove,ie(v=>{const k=v.target,$=K.current!==v.clientX;if(v.currentTarget.contains(k)&&$){const V=v.clientX>K.current?"right":"left";te.current=V,K.current=v.clientX}}))})})})})})})},"MenuContentImpl")),xe="MenuItem",Fe="menu.itemSelect",er=d.forwardRef(y(function(e,t){const{disabled:o=!1,onSelect:r,...a}=e,c=d.useRef(null),l=Te(xe,e.__scopeMenu),u=ct(xe,e.__scopeMenu),i=X(t,c),m=d.useRef(!1),h=y(()=>{const f=c.current;if(!o&&f){const p=new CustomEvent(Fe,{bubbles:!0,cancelable:!0});f.addEventListener(Fe,b=>r==null?void 0:r(b),{once:!0}),tn(f,p),p.defaultPrevented?m.current=!1:l.onClose()}},"handleSelect");return s.jsx(tr,{...a,ref:i,disabled:o,onClick:C(e.onClick,h),onPointerDown:f=>{var p;(p=e.onPointerDown)==null||p.call(e,f),m.current=!0},onPointerUp:C(e.onPointerUp,f=>{var p;m.current||(p=f.currentTarget)==null||p.click()}),onKeyDown:C(e.onKeyDown,f=>{o||f.target!==f.currentTarget||u.searchRef.current!==""&&f.key===" "||kn.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})},"MenuItem")),tr=d.forwardRef(y(function(e,t){const{__scopeMenu:o,disabled:r=!1,textValue:a,...c}=e,l=ct(xe,o),u=at(o),i=d.useRef(null),m=X(t,i),[h,f]=d.useState(!1),[p,b]=d.useState("");return d.useEffect(()=>{const x=i.current;x&&b((x.textContent??"").trim())},[c.children]),s.jsx(pe.ItemSlot,{scope:o,disabled:r,textValue:a??p,children:s.jsx(nn,{asChild:!0,...u,focusable:!r,children:s.jsx(be.div,{role:"menuitem","data-highlighted":h?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...c,ref:m,onPointerMove:C(e.onPointerMove,ie(x=>{r?l.onItemLeave(x):(l.onItemEnter(x),x.defaultPrevented||x.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:C(e.onPointerLeave,ie(x=>l.onItemLeave(x))),onFocus:C(e.onFocus,()=>f(!0)),onBlur:C(e.onBlur,()=>f(!1))})})})},"MenuItemImpl")),nr="MenuRadioGroup",[ns,rs]=Y(nr,{value:void 0,onValueChange:y(()=>{},"onValueChange")}),rr="MenuItemIndicator",[ss,os]=Y(rr,{checked:!1}),sr=d.forwardRef(y(function(e,t){const{__scopeMenu:o,...r}=e;return s.jsx(be.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})},"MenuSeparator")),or="MenuSub",[as,is]=Y(or);function ut(n){return n?"open":"closed"}y(ut,"getOpenState");function dt(n){return n==="indeterminate"}y(dt,"isIndeterminate");function ar(n){return dt(n)?"indeterminate":n?"checked":"unchecked"}y(ar,"getCheckedState");function mt(n){const e=document.activeElement;for(const t of n)if(t===e||(t.focus(),document.activeElement!==e))return}y(mt,"focusFirst");function ft(n,e){return n.map((t,o)=>n[(e+o)%n.length])}y(ft,"wrapArray");function ht(n,e,t){const r=e.length>1&&Array.from(e).every(i=>i===e[0])?e[0]:e,a=t?n.indexOf(t):-1;let c=ft(n,Math.max(a,0));r.length===1&&(c=c.filter(i=>i!==t));const u=c.find(i=>i.toLowerCase().startsWith(r.toLowerCase()));return u!==t?u:void 0}y(ht,"getNextMatch");function pt(n,e){const{x:t,y:o}=n;let r=!1;for(let a=0,c=e.length-1;a<e.length;c=a++){const l=e[a],u=e[c],i=l.x,m=l.y,h=u.x,f=u.y;m>o!=f>o&&t<(h-i)*(o-m)/(f-m)+i&&(r=!r)}return r}y(pt,"isPointInPolygon");function xt(n,e){if(!e)return!1;const t={x:n.clientX,y:n.clientY};return pt(t,e)}y(xt,"isPointerInGraceArea");function ie(n){return e=>e.pointerType==="mouse"?n(e):void 0}y(ie,"whenMouse");var ir=Hn,cr=Un,lr=Xn,ur=qn,dr=er,mr=sr,fr=Object.defineProperty,J=(n,e)=>fr(n,"name",{value:e,configurable:!0}),Se="DropdownMenu",[hr,gt]=He(Se,[ot]),ee=ot(),[pr,vt]=hr(Se),bt=J(n=>{const{__scopeDropdownMenu:e,children:t,dir:o,open:r,defaultOpen:a,onOpenChange:c,modal:l=!0}=n,u=ee(e),i=d.useRef(null),[m,h]=Ye({prop:r,defaultProp:a??!1,onChange:c,caller:Se});return s.jsx(pr,{scope:e,triggerId:Ee(),triggerRef:i,contentId:Ee(),open:m,onOpenChange:h,onOpenToggle:d.useCallback(()=>h(f=>!f),[h]),modal:l,children:s.jsx(ir,{...u,open:m,onOpenChange:h,dir:o,modal:l,children:t})})},"DropdownMenu"),xr="DropdownMenuTrigger",wt=d.forwardRef(J(function(e,t){const{__scopeDropdownMenu:o,disabled:r=!1,...a}=e,c=vt(xr,o),l=ee(o),u=X(t,c.triggerRef);return s.jsx(cr,{asChild:!0,...l,children:s.jsx(be.button,{type:"button",id:c.triggerId,"aria-haspopup":"menu","aria-expanded":c.open,"aria-controls":c.open?c.contentId:void 0,"data-state":c.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...a,ref:u,onPointerDown:C(e.onPointerDown,i=>{!r&&i.button===0&&i.ctrlKey===!1&&(c.onOpenToggle(),c.open||i.preventDefault())}),onKeyDown:C(e.onKeyDown,i=>{r||(["Enter"," "].includes(i.key)&&c.onOpenToggle(),i.key==="ArrowDown"&&c.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(i.key)&&i.preventDefault())})})})},"DropdownMenuTrigger")),It=J(n=>{const{__scopeDropdownMenu:e,...t}=n,o=ee(e);return s.jsx(lr,{...o,...t})},"DropdownMenuPortal"),gr="DropdownMenuContent",yt=d.forwardRef(J(function(e,t){const{__scopeDropdownMenu:o,...r}=e,a=vt(gr,o),c=ee(o),l=d.useRef(!1);return s.jsx(ur,{id:a.contentId,"aria-labelledby":a.triggerId,...c,...r,ref:t,onCloseAutoFocus:C(e.onCloseAutoFocus,u=>{var i;l.current||(i=a.triggerRef.current)==null||i.focus(),l.current=!1,u.preventDefault()}),onInteractOutside:C(e.onInteractOutside,u=>{const i=u.detail.originalEvent,m=i.button===0&&i.ctrlKey===!0,h=i.button===2||m;(!a.modal||h)&&(l.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})},"DropdownMenuContent")),Mt=d.forwardRef(J(function(e,t){const{__scopeDropdownMenu:o,...r}=e,a=ee(o);return s.jsx(dr,{...a,...r,ref:t})},"DropdownMenuItem")),Lt=d.forwardRef(J(function(e,t){const{__scopeDropdownMenu:o,...r}=e,a=ee(o);return s.jsx(mr,{...a,...r,ref:t})},"DropdownMenuSeparator")),Ct=bt,jt=wt,vr=It,Tt=yt,St=Mt,Rt=Lt;const br=Object.freeze(Object.defineProperty({__proto__:null,Content:Tt,DropdownMenu:bt,DropdownMenuContent:yt,DropdownMenuItem:Mt,DropdownMenuPortal:It,DropdownMenuSeparator:Lt,DropdownMenuTrigger:wt,Item:St,Portal:vr,Root:Ct,Separator:Rt,Trigger:jt,createDropdownMenuScope:gt},Symbol.toStringTag,{value:"Module"})),wr=le(jt),Ir=le(Tt),yr=le(St),Mr=le(Rt),Pt=d.forwardRef((n,e)=>{const t=N(15);let o,r,a;t[0]!==n?({onClick:r,disabled:o,...a}=n,t[0]=n,t[1]=o,t[2]=r,t[3]=a):(o=t[1],r=t[2],a=t[3]);const c=S(Lr),{switchToNewThread:l}=En();let u;t[4]!==c?(u=c?{"data-active":"true","aria-current":"true"}:null,t[4]=c,t[5]=u):u=t[5];let i;t[6]!==r||t[7]!==l?(i=C(r,l),t[6]=r,t[7]=l,t[8]=i):i=t[8];let m;return t[9]!==o||t[10]!==e||t[11]!==a||t[12]!==u||t[13]!==i?(m=s.jsx(we.button,{type:"button",...u,...a,ref:e,disabled:o,onClick:i}),t[9]=o,t[10]=e,t[11]=a,t[12]=u,t[13]=i,t[14]=m):m=t[14],m});Pt.displayName="ThreadListPrimitive.New";function Lr(n){return n.threads.newThreadId===n.threads.mainThreadId}const Cr=()=>{const{loadMore:n,disabled:e}=_n();return e?null:n},jr=se("ThreadListPrimitive.LoadMore",Cr),[Tr,Sr]=We("ThreadList"),ge=Tr,Nt=ye(null),Rr=Nt.Provider,Re=()=>Ie(Nt),Dt=d.forwardRef((n,e)=>{const t=N(3);let o;return t[0]!==n||t[1]!==e?(o=s.jsx(ge.Provider,{scope:void 0,children:s.jsx(ge.Slot,{scope:void 0,children:s.jsx(we.div,{...n,ref:e})})}),t[0]=n,t[1]=e,t[2]=o):o=t[2],o});Dt.displayName="ThreadListPrimitive.Root";var Pr=Me({ItemByIndex:()=>tt,Items:()=>nt,LoadMore:()=>jr,New:()=>Pt,Root:()=>Dt});const Et=d.forwardRef((n,e)=>{const t=S(i=>i.threads.mainThreadId===i.threadListItem.id),o=_e(null),r=_e(null),a=Ge(()=>({triggerRef:o,moreRef:r}),[]),c=Sr(void 0),l=ce(),u=i=>{const m=l==="rtl"?"ArrowLeft":"ArrowRight",h=l==="rtl"?"ArrowRight":"ArrowLeft",f=o.current,p=r.current;if(f&&i.target===f)if(i.key==="ArrowDown"||i.key==="ArrowUp"){const b=c().map(g=>g.ref.current).filter(g=>g!==null),x=b[b.indexOf(f)+(i.key==="ArrowDown"?1:-1)];x&&(x.focus(),i.preventDefault())}else i.key===m&&p&&(p.focus(),i.preventDefault());else p&&i.target===p&&i.key===h&&(f==null||f.focus(),i.preventDefault())};return s.jsx(Rr,{value:a,children:s.jsx(we.div,{...t?{"data-active":"true","aria-current":"true"}:null,...n,onKeyDown:C(n.onKeyDown,u),ref:e})})});Et.displayName="ThreadListItemPrimitive.Root";const Nr=()=>{const{archive:n}=Rn();return n},Dr=se("ThreadListItemPrimitive.Archive",Nr),Er=()=>{const{unarchive:n}=Nn();return n},_r=se("ThreadListItemPrimitive.Unarchive",Er),Ar=()=>{const{delete:n}=Pn();return n},Or=se("ThreadListItemPrimitive.Delete",Ar),kr=()=>{const{switchTo:n}=Dn();return n},Fr=se("ThreadListItemPrimitive.Trigger",kr),_t=d.forwardRef((n,e)=>{var a;const t=N(3),o=X(e,(a=Re())==null?void 0:a.triggerRef);let r;return t[0]!==n||t[1]!==o?(r=s.jsx(ge.ItemSlot,{scope:void 0,children:s.jsx(Fr,{...n,ref:o})}),t[0]=n,t[1]=o,t[2]=r):r=t[2],r});_t.displayName="ThreadListItemPrimitive.Trigger";var ve=Me({Archive:()=>Dr,Delete:()=>Or,Root:()=>Et,Title:()=>rt,Trigger:()=>_t,Unarchive:()=>_r});const ae=gt(),At=ye(()=>{}),Ot=()=>Ie(At),kt=ye(!1),Ft=()=>Ie(kt),Bt=n=>{const e=N(26);let t,o,r,a,c,l,u;e[0]!==n?({__scopeThreadListItemMore:t,open:c,defaultOpen:o,onOpenChange:a,sharedFocusGroup:u,modal:r,...l}=n,e[0]=n,e[1]=t,e[2]=o,e[3]=r,e[4]=a,e[5]=c,e[6]=l,e[7]=u):(t=e[1],o=e[2],r=e[3],a=e[4],c=e[5],l=e[6],u=e[7]);const i=u===void 0?!1:u,m=i?!1:r??!0,h=ae(t),f=o??!1;let p;e[8]!==a?(p=a?{onChange:a}:{},e[8]=a,e[9]=p):p=e[9];let b;e[10]!==c||e[11]!==f||e[12]!==p?(b={prop:c,defaultProp:f,caller:"ThreadListItemMorePrimitive.Root",...p},e[10]=c,e[11]=f,e[12]=p,e[13]=b):b=e[13];const[x,g]=Ye(b);let M;e[14]!==m||e[15]!==x||e[16]!==l||e[17]!==h||e[18]!==g?(M=s.jsx(Ct,{...h,...l,modal:m,open:x,onOpenChange:g}),e[14]=m,e[15]=x,e[16]=l,e[17]=h,e[18]=g,e[19]=M):M=e[19];let L;e[20]!==g||e[21]!==M?(L=s.jsx(At.Provider,{value:g,children:M}),e[20]=g,e[21]=M,e[22]=L):L=e[22];let j;return e[23]!==i||e[24]!==L?(j=s.jsx(kt.Provider,{value:i,children:L}),e[23]=i,e[24]=L,e[25]=j):j=e[25],j};Bt.displayName="ThreadListItemMorePrimitive.Root";const Kt=d.forwardRef((n,e)=>{const t=N(10),{__scopeThreadListItemMore:o,...r}=n,a=ae(o),c=Re(),l=Ot(),u=Ft(),i=X(e,c==null?void 0:c.moreRef),m=ce()==="rtl"?"ArrowLeft":"ArrowRight",h=wr;let f;t[0]!==m||t[1]!==l||t[2]!==u?(f=x=>{!u||x.key!==m||(x.preventDefault(),l(!0))},t[0]=m,t[1]=l,t[2]=u,t[3]=f):f=t[3];const p=C(r.onKeyDown,f);let b;return t[4]!==h||t[5]!==i||t[6]!==r||t[7]!==a||t[8]!==p?(b=s.jsx(h,{...a,...r,onKeyDown:p,ref:i}),t[4]=h,t[5]=i,t[6]=r,t[7]=a,t[8]=p,t[9]=b):b=t[9],b});Kt.displayName="ThreadListItemMorePrimitive.Trigger";const $t=d.forwardRef((n,e)=>{const t=N(21),{__scopeThreadListItemMore:o,portalProps:r,sideOffset:a,...c}=n,l=a===void 0?4:a,u=ae(o),i=Ot(),m=Re(),h=Ft(),f=ce()==="rtl"?"ArrowRight":"ArrowLeft",p=br,b=Ir;let x;t[0]!==f||t[1]!==(m==null?void 0:m.moreRef)||t[2]!==i||t[3]!==h?(x=_=>{var A;!h||_.key!==f||(_.preventDefault(),i(!1),(A=m==null?void 0:m.moreRef.current)==null||A.focus())},t[0]=f,t[1]=m==null?void 0:m.moreRef,t[2]=i,t[3]=h,t[4]=x):x=t[4];const g=C(c.onKeyDown,x);let M;t[5]!==(m==null?void 0:m.moreRef)||t[6]!==h?(M=()=>{var _;h&&((_=m==null?void 0:m.moreRef.current)==null||_.focus())},t[5]=m==null?void 0:m.moreRef,t[6]=h,t[7]=M):M=t[7];const L=C(c.onEscapeKeyDown,M);let j;t[8]!==b||t[9]!==e||t[10]!==c||t[11]!==u||t[12]!==l||t[13]!==g||t[14]!==L?(j=s.jsx(b,{...u,...c,onKeyDown:g,onEscapeKeyDown:L,ref:e,sideOffset:l}),t[8]=b,t[9]=e,t[10]=c,t[11]=u,t[12]=l,t[13]=g,t[14]=L,t[15]=j):j=t[15];let P;return t[16]!==r||t[17]!==u||t[18]!==p.Portal||t[19]!==j?(P=s.jsx(p.Portal,{...u,...r,children:j}),t[16]=r,t[17]=u,t[18]=p.Portal,t[19]=j,t[20]=P):P=t[20],P});$t.displayName="ThreadListItemMorePrimitive.Content";const zt=d.forwardRef((n,e)=>{const t=N(7);let o,r;t[0]!==n?({__scopeThreadListItemMore:o,...r}=n,t[0]=n,t[1]=o,t[2]=r):(o=t[1],r=t[2]);const a=ae(o);let c;return t[3]!==e||t[4]!==r||t[5]!==a?(c=s.jsx(yr,{...a,...r,ref:e}),t[3]=e,t[4]=r,t[5]=a,t[6]=c):c=t[6],c});zt.displayName="ThreadListItemMorePrimitive.Item";const Gt=d.forwardRef((n,e)=>{const t=N(7);let o,r;t[0]!==n?({__scopeThreadListItemMore:o,...r}=n,t[0]=n,t[1]=o,t[2]=r):(o=t[1],r=t[2]);const a=ae(o);let c;return t[3]!==e||t[4]!==r||t[5]!==a?(c=s.jsx(Mr,{...a,...r,ref:e}),t[3]=e,t[4]=r,t[5]=a,t[6]=c):c=t[6],c});Gt.displayName="ThreadListItemMorePrimitive.Separator";var he=Me({Content:()=>$t,Item:()=>zt,Root:()=>Bt,Separator:()=>Gt,Trigger:()=>Kt});function Br(){const n=Z(),e=qe(),t=Le(),o=Qe(),r=t||o,[a,c]=d.useState(!1),[l,u]=d.useState(""),[i,m]=d.useState(null),h=d.useRef(null),f=d.useRef(null),p=d.useId(),b=(n==null?void 0:n.isLibraryEnabled)===!0&&e!=null,x=(n==null?void 0:n.historyAgentFilter)??null;d.useEffect(()=>{a||u("")},[a]);const{agents:g,isInitialLoading:M,isSearching:L,loadingMore:j,hasMore:P,listRef:_,sentinelRef:A}=hn({enabled:a&&b,query:l});if(d.useLayoutEffect(()=>{if(!a||r){m(null);return}const I=()=>{var E;const R=(E=h.current)==null?void 0:E.getBoundingClientRect();R&&m({top:R.top,left:R.right+4})};return I(),window.addEventListener("resize",I),window.addEventListener("scroll",I,!0),()=>{window.removeEventListener("resize",I),window.removeEventListener("scroll",I,!0)}},[a,r]),d.useEffect(()=>{if(!a||r)return;const I=R=>{var B,w;const E=R.target;(B=h.current)!=null&&B.contains(E)||(w=f.current)!=null&&w.contains(E)||c(!1)};return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[a,r]),!b)return null;const O=I=>{(n==null?void 0:n.isComposerEnabled)===!0?n.openDraft():n==null||n.openLibraryHome(),n==null||n.setHistoryAgentFilter(I),c(!1)},D=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"p-1",onMouseDown:I=>I.stopPropagation(),children:[s.jsx(pn,{query:l,setQuery:u,placeholder:"Search agents"}),L?s.jsx("p",{className:"text-text-secondary px-1 pt-1 text-[11px]",role:"status",children:"Searching…"}):null]}),s.jsxs("div",{ref:_,className:F("mt-1 overflow-y-auto",r?"min-h-0 flex-1 px-1 pb-2":"min-h-48 max-h-64"),children:[l.trim()===""?s.jsxs(Ae,{className:F("justify-between",x==null&&"bg-dropdown-selected-item-bg text-dropdown-selected-item-text"),onClick:()=>O(null),children:["All chats",x==null?s.jsx(z,{name:"check",className:"size-3.5 shrink-0"}):null]}):null,M?s.jsx("p",{className:"px-2 py-3 text-center text-xs text-text-secondary",children:"Loading…"}):g.length===0?s.jsx("p",{className:"text-text-secondary px-2 py-6 text-center text-xs",role:"status",children:l.trim()?`No agents match "${l.trim()}".`:"No agents yet."}):s.jsxs(s.Fragment,{children:[g.map(I=>{const R=xn(I),E=(x==null?void 0:x.agentId)===R;return s.jsxs(Ae,{className:F("justify-between gap-2 text-left",E&&"bg-dropdown-selected-item-bg text-dropdown-selected-item-text"),onClick:()=>O({agentId:R,agentName:I.name,intent:"history"}),children:[s.jsx("span",{className:"min-w-0 truncate",children:I.name}),E?s.jsx(z,{name:"check",className:"size-3.5 shrink-0"}):null]},R)}),P?s.jsx("div",{ref:A,className:"flex h-6 shrink-0 items-center justify-center","aria-hidden":!0,children:j?s.jsx("span",{className:"text-text-secondary text-[11px]",role:"status",children:"Loading more…"}):null}):null]})]})]});return s.jsxs("div",{className:"relative shrink-0",children:[s.jsxs("button",{ref:h,type:"button","aria-label":x!=null?`Filter chat history by agent (${x.agentName})`:"Filter chat history by agent","aria-haspopup":r?"dialog":"menu","aria-expanded":a,"aria-controls":a?p:void 0,title:"Filter by agent",className:re({variant:"ghost",size:"icon",className:F("relative size-7 shrink-0 text-text-secondary hover:bg-ghost-button-hover hover:text-ghost-button-text",x!=null&&"text-text-primary")}),onClick:()=>c(I=>!I),children:[s.jsx(z,{name:"funnel",className:"size-3.5"}),x!=null?s.jsx("span",{className:"bg-primary-button-bg absolute top-1 right-1 size-1.5 rounded-full","aria-hidden":!0,"data-testid":"history-filter-active-dot"}):null]}),r&&a?s.jsx(Ze,{open:!0,onOpenChange:c,id:p,"aria-label":"Filter agents",children:s.jsx("div",{className:"flex min-h-0 flex-1 flex-col p-2",role:"menu",children:D})}):null,!r&&a&&i!=null?gn.createPortal(s.jsx("div",{ref:f,id:p,role:"menu","aria-label":"Filter agents",style:{top:i.top,left:i.left},className:"aui-popup-enter font-sans-flex fixed z-50 w-56 rounded-md border border-border bg-card-bg p-1 text-text-primary shadow-md",children:D}),vn(h.current)):null]})}var Be="flex w-full cursor-pointer select-none items-center gap-2 rounded-md px-2 py-1.5 text-sm font-medium text-failure-bg outline-none transition-colors hover:bg-failure-bg/12 hover:text-failure-bg focus:bg-failure-bg/12 focus:text-failure-bg data-[highlighted]:bg-failure-bg/12 data-[highlighted]:text-failure-bg";function Kr({disabled:n}){const e=T("PermissionGuard"),t=Qe(),o=Le(),[r,a]=d.useState(!1),[c,l]=d.useState(),u=o||t,i=d.useCallback(h=>{const f=h==null?void 0:h.closest(".aui-theme-root");l(f instanceof HTMLElement?f:void 0)},[]),m=re({variant:"ghost",size:"icon",className:"size-7 shrink-0 text-text-secondary hover:bg-transparent hover:text-text-primary"});return u?s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button","aria-label":"Session actions",title:"Session actions","aria-haspopup":"dialog","aria-expanded":r,className:m,onClick:()=>a(!0),children:s.jsx(z,{name:"ellipsis",className:"size-3.5"})}),r?s.jsx(Ze,{open:!0,onOpenChange:a,"aria-label":"Session actions",children:s.jsx("div",{className:"flex flex-col gap-1 p-2 *:w-full",role:"menu",children:s.jsx(e,{allowed:!n,children:s.jsxs(ve.Delete,{className:Be,onClick:()=>{n||a(!1)},children:[s.jsx(z,{name:"trash",className:"size-3.5"}),"Delete"]})})})}):null]}):s.jsxs(he.Root,{sharedFocusGroup:!0,children:[s.jsx(he.Trigger,{ref:i,"aria-label":"Session actions",title:"Session actions",className:m,children:s.jsx(z,{name:"ellipsis",className:"size-3.5"})}),s.jsx(he.Content,{portalProps:{container:c},align:"end",sideOffset:4,className:"aui-popup-enter font-sans-flex z-50 min-w-[8rem] rounded-md border border-border bg-card-bg p-1 text-text-primary shadow-md *:w-full",children:s.jsx(e,{allowed:!n,children:s.jsxs(ve.Delete,{className:Be,children:[s.jsx(z,{name:"trash",className:"size-3.5"}),"Delete"]})})})]})}function $r({onThreadOpen:n,canDeleteSession:e,canDeleteResource:t}){const o=G(),r=Z(),a=T("ThreadListRow"),c=S(g=>g.threadListItem.id),l=S(g=>g.threadListItem.remoteId),u=S(g=>g.threadListItem.title),i=S(g=>g.threadListItem.lastMessageAt),m=S(g=>g.threadListItem.custom),h=S(g=>g.threads.mainThreadId),f=dn(m),p=e&&l!=null,b=l!=null&&!t(l),x=(r==null?void 0:r.libraryOpen)===!0||(r==null?void 0:r.sessionsOpen)===!0||(r==null?void 0:r.schedulesOpen)===!0;return s.jsx(ve.Root,{className:"min-w-0",children:s.jsx(a,{title:u??"New Chat",active:c===h&&!x,agentName:f,lastMessageAt:i,onSelect:()=>{n==null||n(),r==null||r.setSettingsOpen(!1),r==null||r.setLibraryOpen(!1),r==null||r.setSessionsOpen(!1),r==null||r.setSchedulesOpen(!1);const g=mn(m),M=!g&&(r==null?void 0:r.mode.status)==="active"&&!r.mode.isMutable&&(f==null?r.mode.agentName==null&&r.mode.agentId==null:r.mode.agentName===f||r.mode.agentId===f),L=fn({sessionMutable:g,shellMutable:(r==null?void 0:r.mode.status)==="active"&&r.mode.isMutable,...(r==null?void 0:r.mode.status)==="active"&&r.mode.isMutable?{shellAgentName:r.mode.agentName,shellAgentId:r.mode.agentId}:{},remoteId:l,pendingSessionId:r==null?void 0:r.pendingSessionId});if((M||L)&&l!=null){Promise.resolve(o.threads().switchToThread(c)).catch(()=>{});return}if(l!=null){r==null||r.openHistorySession({sessionId:l,isMutable:g,...f!=null?{agentName:f}:{}});return}Promise.resolve(o.threads().switchToThread(c)).catch(()=>{})},actions:p?s.jsx(Kr,{disabled:b}):void 0})})}function zr(n){const e=S(o=>o.threads.threadIds),t=S(o=>o.threads.threadItems);return d.useMemo(()=>{const o=un({threadIds:e,threadItems:t});if(n==="default")return o;const r=new Map;for(const a of t)r.set(a.id,a),a.remoteId!=null&&r.set(a.remoteId,a);return o.filter(a=>{const c=e[a];if(c===void 0)return!1;const l=r.get(c);return(l==null?void 0:l.remoteId)!=null})},[e,t,n])}function Gr({indices:n,onThreadOpen:e,canDeleteSession:t,canDeleteResource:o}){const r=S(a=>a.threads.threadIds);return s.jsx(s.Fragment,{children:n.map(a=>{const c=r[a]??String(a);return s.jsx(Ce,{index:a,archived:!1,children:s.jsx($r,{onThreadOpen:e,canDeleteSession:t,canDeleteResource:o})},c)})})}var Hr="aui_thread-list-viewport",Ur=80;function Vr({children:n,viewportRef:e,hideScrollbar:t}){var u;const o=Z(),r=S(i=>i.threadListItem.remoteId),a=(u=o==null?void 0:o.historyAgentFilter)==null?void 0:u.intent,c=(o==null?void 0:o.isLibraryEnabled)===!0&&a!=="try-agent"&&(a==="history"||o.mode.status!=="active"||o.mode.isMutable||o.pendingSessionId!=null||r!=null),l=(o==null?void 0:o.historyAgentFilter)==null?"Chat History":`Chats for ${o.historyAgentFilter.agentName}`;return s.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[s.jsxs("div",{className:"flex shrink-0 items-center gap-1 px-1 py-1",children:[s.jsx("h2",{className:"min-w-0 flex-1 truncate px-1.5 py-1 text-sm font-medium text-text-secondary",children:l}),c?s.jsx(Br,{}):null]}),s.jsx("div",{ref:e,"data-slot":Hr,className:F("flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto",t&&"aui-scrollbar-hidden"),children:n})]})}function Wr({onThreadOpen:n,variant:e="default"}={}){const t=G(),o=qe(),r=S(w=>w.threads.isLoading),a=S(w=>w.threads.isLoadingMore),c=S(w=>w.threads.hasMore),l=S(w=>w.threads.threadIds),u=S(w=>w.threads.threadItems),i=Z(),m=T("ThreadListShell"),h=T("ThreadListNewButton"),f=T("AgentsLibraryButton"),p=T("SessionsBrowserButton"),b=T("SchedulesButton"),x=T("ThreadListRowSkeleton"),g=T("ThreadListEmptyState"),M=zr(e),L=d.useRef(null),j=d.useRef(c),P=d.useRef(t);j.current=c,P.current=t;const _=(i==null?void 0:i.isNewChatEnabled)!==!1,A=(i==null?void 0:i.mode.status)==="idle",O=e==="recent-history",D=typeof(o==null?void 0:o.deleteSession)=="function",I=d.useMemo(()=>u.flatMap(w=>w.remoteId==null?[]:[w.remoteId]),[u]),{allows:R}=ln({resourceType:"session",resourceIds:I});d.useEffect(()=>{if(A||r||a)return;const w=L.current;if(!w)return;let te=!1;const K=()=>{if(te||!j.current||w.clientHeight<=0)return;const de=w.scrollHeight-w.scrollTop-w.clientHeight;w.scrollHeight>w.clientHeight&&de>Ur||P.current.threads().loadMore()};w.addEventListener("scroll",K,{passive:!0});const U=typeof ResizeObserver>"u"?void 0:new ResizeObserver(()=>K());return U?U.observe(w):window.addEventListener("resize",K),K(),()=>{te=!0,w.removeEventListener("scroll",K),U==null||U.disconnect(),U||window.removeEventListener("resize",K)}},[c,A,r,a,l.length]);const E=()=>{if(n==null||n(),i==null||i.setLibraryOpen(!1),i==null||i.setSessionsOpen(!1),i!=null&&i.isComposerEnabled){i.openDraft();return}i==null||i.setSettingsOpen(!1),i==null||i.setSchedulesOpen(!1),Promise.resolve(t.threads().switchToNewThread()).catch(()=>{})};let B;return A?B=s.jsx(g,{message:O?"No recent chats":void 0}):r?B=s.jsx(x,{}):M.length===0?B=s.jsx(g,{message:O?"No recent chats":void 0}):B=s.jsx(Pr.Root,{className:"flex min-h-0 flex-col gap-0.5",children:s.jsx(Gr,{indices:M,onThreadOpen:n,canDeleteSession:D,canDeleteResource:w=>R(w,"DELETE")})}),s.jsx(m,{header:O?null:s.jsxs("div",{className:"flex flex-col gap-1",children:[_?s.jsx(h,{onClick:E}):null,s.jsx(f,{}),s.jsx(p,{}),s.jsx(b,{})]}),children:s.jsxs(Vr,{viewportRef:L,hideScrollbar:O,children:[B,!A&&c?s.jsx("div",{className:"h-4 shrink-0","aria-hidden":!0}):null]})})}var Xr=d.lazy(()=>et(()=>import("./SettingsBuilder-B2ULQPIT-D67kXI0z.js"),__vite__mapDeps([0,1,2]),import.meta.url)),Yr=d.lazy(()=>et(()=>import("./SchedulesPage-ZG5IMQI3-DM9Xo4uZ.js"),__vite__mapDeps([3,1,2]),import.meta.url).then(n=>({default:n.SchedulesPage}))),qr="h-5 w-5 max-w-40 shrink-0 object-contain",Qr="w-20",Ke=F(Mn,"text-sidebar-text"),$e="bg-primary-button-bg font-medium text-primary-button-text hover:bg-primary-button-hover hover:text-primary-button-text";function Zr({overlayOpen:n,mode:e}){return!n&&(e==null?void 0:e.status)==="active"&&!e.isCreateAgent}function Jr(){var f;const n=G(),e=Z(),t=T("AgentsLibraryButton"),o=T("SessionsBrowserButton"),r=T("SchedulesButton"),a=(e==null?void 0:e.isNewChatEnabled)!==!1,c=(e==null?void 0:e.settingsOpen)===!0||(e==null?void 0:e.libraryOpen)===!0||(e==null?void 0:e.sessionsOpen)===!0||(e==null?void 0:e.schedulesOpen)===!0,l=e==null?void 0:e.mode,u=!c&&(l==null?void 0:l.status)==="active"&&!l.isCreateAgent&&((f=e==null?void 0:e.historyAgentFilter)==null?void 0:f.intent)!=="try-agent",i=!c&&l!=null&&Je(l),m=()=>{if(e==null||e.setLibraryOpen(!1),e==null||e.setSessionsOpen(!1),e!=null&&e.isComposerEnabled){e.openDraft();return}e==null||e.setSettingsOpen(!1),e==null||e.setSchedulesOpen(!1),Promise.resolve(n.threads().switchToNewThread()).catch(()=>{})},h=()=>{e==null||e.setLibraryOpen(!1),e==null||e.setSessionsOpen(!1),e!=null&&e.isComposerEnabled&&e.openAgentBuilder()};return s.jsxs("nav",{className:"flex min-h-0 flex-1 flex-col items-center gap-1 p-1","aria-label":"Sidebar",children:[a?s.jsxs("button",{type:"button","aria-label":"Start new chat",title:"New chat","aria-current":u?"page":void 0,className:re({variant:"ghost",className:F(Ke,u&&$e)}),onClick:m,children:[s.jsx(z,{name:"square-pen",size:14}),s.jsx("span",{className:"text-center",children:"New Chat"})]}):null,a&&(e!=null&&e.isComposerEnabled)?s.jsxs("button",{type:"button","aria-label":"Start new agent",title:"New Agent","aria-current":i?"page":void 0,className:re({variant:"ghost",className:F(Ke,i&&$e)}),onClick:h,children:[s.jsx(z,{name:"agent-2",size:14}),s.jsx("span",{className:"text-center whitespace-nowrap",children:"Build Agent"})]}):null,s.jsx(t,{compact:!0}),s.jsx(o,{compact:!0}),s.jsx(r,{compact:!0})]})}function ze({onNavigate:n,className:e,railRef:t,...o}){const r=In(),a=yn(r),c=T("BrandLogo"),l=T("UserAvatar");return s.jsxs("aside",{ref:t,className:F(Qr,"flex min-h-0 shrink-0 flex-col border-r border-border bg-sidebar-bg",e),onClick:u=>{if(n==null)return;const i=u.target;i instanceof Element&&i.closest("button")!=null&&n()},...o,children:[s.jsx("div",{className:"flex h-14 w-full shrink-0 items-center justify-center text-text-primary",children:s.jsx(c,{variant:a.collapsedVariant,className:qr})}),s.jsx(Jr,{}),s.jsxs("footer",{className:"flex shrink-0 flex-col items-center border-border p-2",children:[s.jsx(Tn,{labeled:!0,className:"flex-col"}),s.jsx(l,{labeled:!0,className:"mt-1"})]})]})}function cs({className:n}){const e=Z(),t=Le(),o=T("AgentDetailsPage"),r=T("AgentsLibrary"),a=T("SessionsPage"),c=T("ClearChatButton"),l=T("SaveAgentButton"),u=T("SelectAgentEmptyState"),[i,m]=d.useState(!1),h=d.useRef(null),f=d.useRef(null),p=d.useRef(null),b=d.useRef(!1),x=(e==null?void 0:e.mode.status)==="idle",g=(e==null?void 0:e.settingsOpen)===!0,M=(e==null?void 0:e.libraryOpen)===!0,L=(e==null?void 0:e.sessionsOpen)===!0,j=(e==null?void 0:e.schedulesOpen)===!0,P=g||M||L||j,_=e!=null&&Je(e.mode)&&!P&&(!t||e.agentConfigOpen),A=Zr({overlayOpen:P,mode:e==null?void 0:e.mode}),O=bn();return d.useEffect(()=>{if(!i)return;const D=I=>{I.key==="Escape"&&m(!1)};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[i]),d.useEffect(()=>{var I,R;const D=p.current;if(i){b.current=!0,D&&(D.inert=!0),(I=f.current)==null||I.focus();return}b.current&&(D&&(D.inert=!1),(R=h.current)==null||R.focus(),b.current=!1)},[i]),s.jsxs("div",{className:F("relative flex h-full min-h-0 w-full min-w-0",n),children:[s.jsx(ze,{className:"hidden md:flex"}),_?s.jsx("aside",{role:"dialog","aria-label":"Agent Config",className:"absolute inset-y-0 left-0 z-20 w-full max-w-sm border-r border-border shadow-xl md:static md:z-auto md:max-w-140 md:flex-1 md:shadow-none 2xl:max-w-150",children:s.jsx(Ln,{showClose:t})}):null,s.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col bg-primary-bg",children:[s.jsx(wn,{className:F("bg-topbar-bg",(P||x||!O)&&"md:hidden"),start:P?null:s.jsx("button",{ref:h,type:"button","aria-label":"Navigation","aria-expanded":i,className:F(re({variant:"ghost",size:"icon"}),"md:hidden"),onClick:()=>m(!0),children:s.jsx(z,{name:"bars"})}),title:P?null:s.jsx(Cn,{}),end:P?null:s.jsxs(s.Fragment,{children:[s.jsx(c,{}),s.jsx(l,{})]})}),s.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1",children:[A?s.jsx("aside",{"aria-label":"Recent chats",className:"hidden min-h-0 w-64 shrink-0 border-r border-border bg-sidebar-bg md:flex",children:s.jsx(Wr,{variant:"recent-history"})}):null,s.jsx("div",{ref:p,className:"min-h-0 min-w-0 flex-1",children:g?s.jsx(d.Suspense,{fallback:s.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[s.jsx(Oe,{size:28,className:"text-text-primary"}),s.jsx("span",{className:"sr-only",children:"Loading"})]}),children:s.jsx(Xr,{})}):L?s.jsx(a,{}):M&&(e==null?void 0:e.libraryAgentId)!=null?s.jsx(o,{agentId:e.libraryAgentId},e.libraryAgentId):M?s.jsx(r,{onSelectAgent:()=>m(!1)}):j?s.jsx(d.Suspense,{fallback:s.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[s.jsx(Oe,{size:28,className:"text-text-primary"}),s.jsx("span",{className:"sr-only",children:"Loading"})]}),children:s.jsx(Yr,{})}):x?s.jsx(u,{}):s.jsx(jn,{})})]})]}),i?s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button","aria-label":"Close navigation",className:"absolute inset-0 z-[9] cursor-pointer bg-[var(--overlay)] md:hidden",onClick:()=>m(!1)}),s.jsx(ze,{railRef:f,role:"dialog","aria-label":"Navigation",tabIndex:-1,onNavigate:()=>m(!1),className:"absolute inset-y-0 left-0 z-10 shadow-lg outline-none md:hidden"})]}):null]})}export{cs as SidebarLayout};