@truefoundry/trueforge 0.183.0-rc.3 → 0.183.0

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 (206) hide show
  1. package/dist/_frontend/assets/{AgentCodeSnippets-36MVPNIZ-BHPZ8jtE.js → AgentCodeSnippets-36MVPNIZ-DO0Y_xWq.js} +1 -1
  2. package/dist/_frontend/assets/AgentCodeSnippets-36MVPNIZ-DO0Y_xWq.js.br +0 -0
  3. package/dist/_frontend/assets/AgentCodeSnippets-36MVPNIZ-DO0Y_xWq.js.gz +0 -0
  4. package/dist/_frontend/assets/{AgentMetricChart-2R23OEEA-Dymf0lou.js → AgentMetricChart-2R23OEEA-D7SBsc7p.js} +1 -1
  5. package/dist/_frontend/assets/AgentMetricChart-2R23OEEA-D7SBsc7p.js.br +0 -0
  6. package/dist/_frontend/assets/AgentMetricChart-2R23OEEA-D7SBsc7p.js.gz +0 -0
  7. package/dist/_frontend/assets/{AgentOverview-YSUEPAVB-BlCRVWZP.js → AgentOverview-YSUEPAVB-CSMGELBr.js} +1 -1
  8. package/dist/_frontend/assets/AgentOverview-YSUEPAVB-CSMGELBr.js.br +0 -0
  9. package/dist/_frontend/assets/AgentOverview-YSUEPAVB-CSMGELBr.js.gz +0 -0
  10. package/dist/_frontend/assets/{AgentSessionEventTimeline-H7JP34RB-DmwwwqNv.js → AgentSessionEventTimeline-H7JP34RB-TYYeaElm.js} +1 -1
  11. package/dist/_frontend/assets/AgentSessionEventTimeline-H7JP34RB-TYYeaElm.js.br +0 -0
  12. package/dist/_frontend/assets/AgentSessionEventTimeline-H7JP34RB-TYYeaElm.js.gz +0 -0
  13. package/dist/_frontend/assets/{AgentSessionEventTimelineChart-2O3LQZ6M-Cl4BaSre.js → AgentSessionEventTimelineChart-2O3LQZ6M-CPZPCe24.js} +1 -1
  14. package/dist/_frontend/assets/AgentSessionEventTimelineChart-2O3LQZ6M-CPZPCe24.js.br +0 -0
  15. package/dist/_frontend/assets/AgentSessionEventTimelineChart-2O3LQZ6M-CPZPCe24.js.gz +0 -0
  16. package/dist/_frontend/assets/{AgentSessions-4LXWAOQM-BO_fTzMm.js → AgentSessions-4LXWAOQM-D5zQOhcY.js} +1 -1
  17. package/dist/_frontend/assets/AgentSessions-4LXWAOQM-D5zQOhcY.js.br +0 -0
  18. package/dist/_frontend/assets/AgentSessions-4LXWAOQM-D5zQOhcY.js.gz +0 -0
  19. package/dist/_frontend/assets/{ConnectorSettings-PYELU62E-IonCdccY.js → ConnectorSettings-PYELU62E-DMbJA7AI.js} +1 -1
  20. package/dist/_frontend/assets/ConnectorSettings-PYELU62E-DMbJA7AI.js.br +0 -0
  21. package/dist/_frontend/assets/ConnectorSettings-PYELU62E-DMbJA7AI.js.gz +0 -0
  22. package/dist/_frontend/assets/{DockLayout-BLRDAQKF-CADCRst5.js → DockLayout-BLRDAQKF-Bd8XL5hR.js} +1 -1
  23. package/dist/_frontend/assets/{DrawerLayout-K2ZKOBJB-CWm9P8rK.js → DrawerLayout-K2ZKOBJB-CVsZvHIE.js} +2 -2
  24. package/dist/_frontend/assets/DrawerLayout-K2ZKOBJB-CVsZvHIE.js.br +0 -0
  25. package/dist/_frontend/assets/DrawerLayout-K2ZKOBJB-CVsZvHIE.js.gz +0 -0
  26. package/dist/_frontend/assets/{EnvironmentsPage-5SEQP4QD-BuLuc3Ok.js → EnvironmentsPage-5SEQP4QD-BxOU9R1E.js} +1 -1
  27. package/dist/_frontend/assets/EnvironmentsPage-5SEQP4QD-BxOU9R1E.js.br +0 -0
  28. package/dist/_frontend/assets/EnvironmentsPage-5SEQP4QD-BxOU9R1E.js.gz +0 -0
  29. package/dist/_frontend/assets/{ModelSettings-JQ57P7UZ-CLJFh7hP.js → ModelSettings-JQ57P7UZ--AqoNP6X.js} +1 -1
  30. package/dist/_frontend/assets/ModelSettings-JQ57P7UZ--AqoNP6X.js.br +0 -0
  31. package/dist/_frontend/assets/ModelSettings-JQ57P7UZ--AqoNP6X.js.gz +0 -0
  32. package/dist/_frontend/assets/{SandboxSettings-6DIQUD2C-222OAKeC.js → SandboxSettings-6DIQUD2C-Dq81qn8k.js} +1 -1
  33. package/dist/_frontend/assets/SandboxSettings-6DIQUD2C-Dq81qn8k.js.br +0 -0
  34. package/dist/_frontend/assets/SandboxSettings-6DIQUD2C-Dq81qn8k.js.gz +0 -0
  35. package/dist/_frontend/assets/{SchedulesPage-25JKAP5G-DEB03OMM.js → SchedulesPage-25JKAP5G-DRHxlR8X.js} +1 -1
  36. package/dist/_frontend/assets/SchedulesPage-25JKAP5G-DRHxlR8X.js.br +0 -0
  37. package/dist/_frontend/assets/SchedulesPage-25JKAP5G-DRHxlR8X.js.gz +0 -0
  38. package/dist/_frontend/assets/{SettingsBuilder-QM224JED-CLIPJX4x.js → SettingsBuilder-QM224JED-Bp00qPG0.js} +2 -2
  39. package/dist/_frontend/assets/SettingsBuilder-QM224JED-Bp00qPG0.js.br +0 -0
  40. package/dist/_frontend/assets/SettingsBuilder-QM224JED-Bp00qPG0.js.gz +0 -0
  41. package/dist/_frontend/assets/{ShellRouteSync-QAVCYLHL-DOgjvGZX.js → ShellRouteSync-QAVCYLHL-CDlB0WM-.js} +1 -1
  42. package/dist/_frontend/assets/ShellRouteSync-QAVCYLHL-CDlB0WM-.js.br +0 -0
  43. package/dist/_frontend/assets/ShellRouteSync-QAVCYLHL-CDlB0WM-.js.gz +0 -0
  44. package/dist/_frontend/assets/{SidebarLayout-3CSKXO4Z-2FMHEkbH.js → SidebarLayout-3CSKXO4Z-DHrtYD50.js} +2 -2
  45. package/dist/_frontend/assets/SidebarLayout-3CSKXO4Z-DHrtYD50.js.br +0 -0
  46. package/dist/_frontend/assets/SidebarLayout-3CSKXO4Z-DHrtYD50.js.gz +0 -0
  47. package/dist/_frontend/assets/{SkillSettings-EDNAAMP6-DU5CIdrG.js → SkillSettings-EDNAAMP6-D5QMdCsj.js} +1 -1
  48. package/dist/_frontend/assets/SkillSettings-EDNAAMP6-D5QMdCsj.js.br +0 -0
  49. package/dist/_frontend/assets/SkillSettings-EDNAAMP6-D5QMdCsj.js.gz +0 -0
  50. package/dist/_frontend/assets/{TrueForgeUIWithRouter-HUUOU77K-B0i6RRj2.js → TrueForgeUIWithRouter-HUUOU77K-DnWfMFqB.js} +1 -1
  51. package/dist/_frontend/assets/{WebSearchSettings-5SXM5JCV-DQLdgrLM.js → WebSearchSettings-5SXM5JCV-ls7UX68H.js} +1 -1
  52. package/dist/_frontend/assets/WebSearchSettings-5SXM5JCV-ls7UX68H.js.br +0 -0
  53. package/dist/_frontend/assets/WebSearchSettings-5SXM5JCV-ls7UX68H.js.gz +0 -0
  54. package/dist/_frontend/assets/{WidgetLayout-7S2WT37T-D4GdCGpz.js → WidgetLayout-7S2WT37T-C1dWBcJh.js} +1 -1
  55. package/dist/_frontend/assets/WidgetLayout-7S2WT37T-C1dWBcJh.js.br +0 -0
  56. package/dist/_frontend/assets/WidgetLayout-7S2WT37T-C1dWBcJh.js.gz +0 -0
  57. package/dist/_frontend/assets/{chunk-2L7W3OHQ-BC-N5kEf.js → chunk-2L7W3OHQ-KYs3TW6o.js} +1 -1
  58. package/dist/_frontend/assets/{chunk-5XPPTYZ7-qsHmevBU.js → chunk-5XPPTYZ7-C3ltUDTq.js} +2 -2
  59. package/dist/_frontend/assets/chunk-5XPPTYZ7-C3ltUDTq.js.br +0 -0
  60. package/dist/_frontend/assets/chunk-5XPPTYZ7-C3ltUDTq.js.gz +0 -0
  61. package/dist/_frontend/assets/{chunk-HDD5IS3M-CKbwAtVa.js → chunk-HDD5IS3M-C0hVH4Fk.js} +1 -1
  62. package/dist/_frontend/assets/chunk-HDD5IS3M-C0hVH4Fk.js.br +0 -0
  63. package/dist/_frontend/assets/chunk-HDD5IS3M-C0hVH4Fk.js.gz +0 -0
  64. package/dist/_frontend/assets/{chunk-OB3PAWPO-kbiWSc01.js → chunk-OB3PAWPO-DN1Qz_zd.js} +1 -1
  65. package/dist/_frontend/assets/chunk-OB3PAWPO-DN1Qz_zd.js.br +0 -0
  66. package/dist/_frontend/assets/chunk-OB3PAWPO-DN1Qz_zd.js.gz +0 -0
  67. package/dist/_frontend/assets/{chunk-P2W5VLGK-wQaO2rNt.js → chunk-P2W5VLGK-B6YzGXAg.js} +1 -1
  68. package/dist/_frontend/assets/chunk-P2W5VLGK-B6YzGXAg.js.br +0 -0
  69. package/dist/_frontend/assets/chunk-P2W5VLGK-B6YzGXAg.js.gz +0 -0
  70. package/dist/_frontend/assets/{cssMode-BXkPhxO4.js → cssMode-C9oytjDO.js} +1 -1
  71. package/dist/_frontend/assets/cssMode-C9oytjDO.js.br +0 -0
  72. package/dist/_frontend/assets/cssMode-C9oytjDO.js.gz +0 -0
  73. package/dist/_frontend/assets/{freemarker2-CZ1cz5bn.js → freemarker2-DLOOWR4R.js} +1 -1
  74. package/dist/_frontend/assets/freemarker2-DLOOWR4R.js.br +0 -0
  75. package/dist/_frontend/assets/freemarker2-DLOOWR4R.js.gz +0 -0
  76. package/dist/_frontend/assets/{handlebars-BVTWR8Om.js → handlebars-4dJAQcpZ.js} +1 -1
  77. package/dist/_frontend/assets/handlebars-4dJAQcpZ.js.br +0 -0
  78. package/dist/_frontend/assets/handlebars-4dJAQcpZ.js.gz +0 -0
  79. package/dist/_frontend/assets/{html-H93jjxT-.js → html-5KQYV_zA.js} +1 -1
  80. package/dist/_frontend/assets/html-5KQYV_zA.js.br +0 -0
  81. package/dist/_frontend/assets/html-5KQYV_zA.js.gz +0 -0
  82. package/dist/_frontend/assets/{htmlMode-Dnc0ZmAv.js → htmlMode-CVtmab4S.js} +1 -1
  83. package/dist/_frontend/assets/htmlMode-CVtmab4S.js.br +0 -0
  84. package/dist/_frontend/assets/htmlMode-CVtmab4S.js.gz +0 -0
  85. package/dist/_frontend/assets/{index-ZbO6e6SF.js → index-DdpoXKyE.js} +3 -3
  86. package/dist/_frontend/assets/index-DdpoXKyE.js.br +0 -0
  87. package/dist/_frontend/assets/index-DdpoXKyE.js.gz +0 -0
  88. package/dist/_frontend/assets/{index-BOPxame4.js → index-o2o-gWoN.js} +4 -4
  89. package/dist/_frontend/assets/index-o2o-gWoN.js.br +0 -0
  90. package/dist/_frontend/assets/index-o2o-gWoN.js.gz +0 -0
  91. package/dist/_frontend/assets/{javascript-BNCRm75I.js → javascript-I_0YW_KY.js} +1 -1
  92. package/dist/_frontend/assets/{jsonMode-Bo7jR5xc.js → jsonMode-BkAzv-WD.js} +1 -1
  93. package/dist/_frontend/assets/jsonMode-BkAzv-WD.js.br +0 -0
  94. package/dist/_frontend/assets/jsonMode-BkAzv-WD.js.gz +0 -0
  95. package/dist/_frontend/assets/{liquid-DcfhcVwg.js → liquid-CPxyHsAI.js} +1 -1
  96. package/dist/_frontend/assets/liquid-CPxyHsAI.js.br +0 -0
  97. package/dist/_frontend/assets/liquid-CPxyHsAI.js.gz +0 -0
  98. package/dist/_frontend/assets/{lspLanguageFeatures-C53uszd-.js → lspLanguageFeatures-C5NNjmui.js} +1 -1
  99. package/dist/_frontend/assets/lspLanguageFeatures-C5NNjmui.js.br +0 -0
  100. package/dist/_frontend/assets/lspLanguageFeatures-C5NNjmui.js.gz +0 -0
  101. package/dist/_frontend/assets/{mdx-DSwEbppS.js → mdx-iFgTB6MB.js} +1 -1
  102. package/dist/_frontend/assets/mdx-iFgTB6MB.js.br +0 -0
  103. package/dist/_frontend/assets/mdx-iFgTB6MB.js.gz +0 -0
  104. package/dist/_frontend/assets/{python-ZZcz9k9_.js → python-CbF5qB9O.js} +1 -1
  105. package/dist/_frontend/assets/python-CbF5qB9O.js.br +0 -0
  106. package/dist/_frontend/assets/python-CbF5qB9O.js.gz +0 -0
  107. package/dist/_frontend/assets/{razor-DDJq-CZk.js → razor-BzBNiQv5.js} +1 -1
  108. package/dist/_frontend/assets/razor-BzBNiQv5.js.br +0 -0
  109. package/dist/_frontend/assets/razor-BzBNiQv5.js.gz +0 -0
  110. package/dist/_frontend/assets/{tsMode-CgQ15tRy.js → tsMode-CDZ69pt0.js} +1 -1
  111. package/dist/_frontend/assets/tsMode-CDZ69pt0.js.br +0 -0
  112. package/dist/_frontend/assets/tsMode-CDZ69pt0.js.gz +0 -0
  113. package/dist/_frontend/assets/{typescript-C68KpWXt.js → typescript-0zTFlQSu.js} +1 -1
  114. package/dist/_frontend/assets/typescript-0zTFlQSu.js.br +0 -0
  115. package/dist/_frontend/assets/typescript-0zTFlQSu.js.gz +0 -0
  116. package/dist/_frontend/assets/{workers-ETQuj3lV.js → workers-CZgJz51Q.js} +1 -1
  117. package/dist/_frontend/assets/workers-CZgJz51Q.js.br +0 -0
  118. package/dist/_frontend/assets/workers-CZgJz51Q.js.gz +0 -0
  119. package/dist/_frontend/assets/{xml-CgpI1XvU.js → xml-CsjOr0hl.js} +1 -1
  120. package/dist/_frontend/assets/xml-CsjOr0hl.js.br +0 -0
  121. package/dist/_frontend/assets/xml-CsjOr0hl.js.gz +0 -0
  122. package/dist/_frontend/assets/{yaml-nsi6_mrm.js → yaml-9U0A0dh0.js} +1 -1
  123. package/dist/_frontend/assets/yaml-9U0A0dh0.js.br +0 -0
  124. package/dist/_frontend/assets/yaml-9U0A0dh0.js.gz +0 -0
  125. package/dist/_frontend/index.html +1 -1
  126. package/package.json +3 -3
  127. package/dist/_frontend/assets/AgentCodeSnippets-36MVPNIZ-BHPZ8jtE.js.br +0 -0
  128. package/dist/_frontend/assets/AgentCodeSnippets-36MVPNIZ-BHPZ8jtE.js.gz +0 -0
  129. package/dist/_frontend/assets/AgentMetricChart-2R23OEEA-Dymf0lou.js.br +0 -0
  130. package/dist/_frontend/assets/AgentMetricChart-2R23OEEA-Dymf0lou.js.gz +0 -0
  131. package/dist/_frontend/assets/AgentOverview-YSUEPAVB-BlCRVWZP.js.br +0 -0
  132. package/dist/_frontend/assets/AgentOverview-YSUEPAVB-BlCRVWZP.js.gz +0 -0
  133. package/dist/_frontend/assets/AgentSessionEventTimeline-H7JP34RB-DmwwwqNv.js.br +0 -0
  134. package/dist/_frontend/assets/AgentSessionEventTimeline-H7JP34RB-DmwwwqNv.js.gz +0 -0
  135. package/dist/_frontend/assets/AgentSessionEventTimelineChart-2O3LQZ6M-Cl4BaSre.js.br +0 -0
  136. package/dist/_frontend/assets/AgentSessionEventTimelineChart-2O3LQZ6M-Cl4BaSre.js.gz +0 -0
  137. package/dist/_frontend/assets/AgentSessions-4LXWAOQM-BO_fTzMm.js.br +0 -0
  138. package/dist/_frontend/assets/AgentSessions-4LXWAOQM-BO_fTzMm.js.gz +0 -0
  139. package/dist/_frontend/assets/ConnectorSettings-PYELU62E-IonCdccY.js.br +0 -0
  140. package/dist/_frontend/assets/ConnectorSettings-PYELU62E-IonCdccY.js.gz +0 -0
  141. package/dist/_frontend/assets/DrawerLayout-K2ZKOBJB-CWm9P8rK.js.br +0 -0
  142. package/dist/_frontend/assets/DrawerLayout-K2ZKOBJB-CWm9P8rK.js.gz +0 -0
  143. package/dist/_frontend/assets/EnvironmentsPage-5SEQP4QD-BuLuc3Ok.js.br +0 -0
  144. package/dist/_frontend/assets/EnvironmentsPage-5SEQP4QD-BuLuc3Ok.js.gz +0 -0
  145. package/dist/_frontend/assets/ModelSettings-JQ57P7UZ-CLJFh7hP.js.br +0 -0
  146. package/dist/_frontend/assets/ModelSettings-JQ57P7UZ-CLJFh7hP.js.gz +0 -0
  147. package/dist/_frontend/assets/SandboxSettings-6DIQUD2C-222OAKeC.js.br +0 -0
  148. package/dist/_frontend/assets/SandboxSettings-6DIQUD2C-222OAKeC.js.gz +0 -0
  149. package/dist/_frontend/assets/SchedulesPage-25JKAP5G-DEB03OMM.js.br +0 -0
  150. package/dist/_frontend/assets/SchedulesPage-25JKAP5G-DEB03OMM.js.gz +0 -0
  151. package/dist/_frontend/assets/SettingsBuilder-QM224JED-CLIPJX4x.js.br +0 -0
  152. package/dist/_frontend/assets/SettingsBuilder-QM224JED-CLIPJX4x.js.gz +0 -0
  153. package/dist/_frontend/assets/ShellRouteSync-QAVCYLHL-DOgjvGZX.js.br +0 -0
  154. package/dist/_frontend/assets/ShellRouteSync-QAVCYLHL-DOgjvGZX.js.gz +0 -0
  155. package/dist/_frontend/assets/SidebarLayout-3CSKXO4Z-2FMHEkbH.js.br +0 -0
  156. package/dist/_frontend/assets/SidebarLayout-3CSKXO4Z-2FMHEkbH.js.gz +0 -0
  157. package/dist/_frontend/assets/SkillSettings-EDNAAMP6-DU5CIdrG.js.br +0 -0
  158. package/dist/_frontend/assets/SkillSettings-EDNAAMP6-DU5CIdrG.js.gz +0 -0
  159. package/dist/_frontend/assets/WebSearchSettings-5SXM5JCV-DQLdgrLM.js.br +0 -0
  160. package/dist/_frontend/assets/WebSearchSettings-5SXM5JCV-DQLdgrLM.js.gz +0 -0
  161. package/dist/_frontend/assets/WidgetLayout-7S2WT37T-D4GdCGpz.js.br +0 -0
  162. package/dist/_frontend/assets/WidgetLayout-7S2WT37T-D4GdCGpz.js.gz +0 -0
  163. package/dist/_frontend/assets/chunk-5XPPTYZ7-qsHmevBU.js.br +0 -0
  164. package/dist/_frontend/assets/chunk-5XPPTYZ7-qsHmevBU.js.gz +0 -0
  165. package/dist/_frontend/assets/chunk-HDD5IS3M-CKbwAtVa.js.br +0 -0
  166. package/dist/_frontend/assets/chunk-HDD5IS3M-CKbwAtVa.js.gz +0 -0
  167. package/dist/_frontend/assets/chunk-OB3PAWPO-kbiWSc01.js.br +0 -0
  168. package/dist/_frontend/assets/chunk-OB3PAWPO-kbiWSc01.js.gz +0 -0
  169. package/dist/_frontend/assets/chunk-P2W5VLGK-wQaO2rNt.js.br +0 -0
  170. package/dist/_frontend/assets/chunk-P2W5VLGK-wQaO2rNt.js.gz +0 -0
  171. package/dist/_frontend/assets/cssMode-BXkPhxO4.js.br +0 -0
  172. package/dist/_frontend/assets/cssMode-BXkPhxO4.js.gz +0 -0
  173. package/dist/_frontend/assets/freemarker2-CZ1cz5bn.js.br +0 -0
  174. package/dist/_frontend/assets/freemarker2-CZ1cz5bn.js.gz +0 -0
  175. package/dist/_frontend/assets/handlebars-BVTWR8Om.js.br +0 -0
  176. package/dist/_frontend/assets/handlebars-BVTWR8Om.js.gz +0 -0
  177. package/dist/_frontend/assets/html-H93jjxT-.js.br +0 -0
  178. package/dist/_frontend/assets/html-H93jjxT-.js.gz +0 -0
  179. package/dist/_frontend/assets/htmlMode-Dnc0ZmAv.js.br +0 -0
  180. package/dist/_frontend/assets/htmlMode-Dnc0ZmAv.js.gz +0 -0
  181. package/dist/_frontend/assets/index-BOPxame4.js.br +0 -0
  182. package/dist/_frontend/assets/index-BOPxame4.js.gz +0 -0
  183. package/dist/_frontend/assets/index-ZbO6e6SF.js.br +0 -0
  184. package/dist/_frontend/assets/index-ZbO6e6SF.js.gz +0 -0
  185. package/dist/_frontend/assets/jsonMode-Bo7jR5xc.js.br +0 -0
  186. package/dist/_frontend/assets/jsonMode-Bo7jR5xc.js.gz +0 -0
  187. package/dist/_frontend/assets/liquid-DcfhcVwg.js.br +0 -0
  188. package/dist/_frontend/assets/liquid-DcfhcVwg.js.gz +0 -0
  189. package/dist/_frontend/assets/lspLanguageFeatures-C53uszd-.js.br +0 -0
  190. package/dist/_frontend/assets/lspLanguageFeatures-C53uszd-.js.gz +0 -0
  191. package/dist/_frontend/assets/mdx-DSwEbppS.js.br +0 -0
  192. package/dist/_frontend/assets/mdx-DSwEbppS.js.gz +0 -0
  193. package/dist/_frontend/assets/python-ZZcz9k9_.js.br +0 -0
  194. package/dist/_frontend/assets/python-ZZcz9k9_.js.gz +0 -0
  195. package/dist/_frontend/assets/razor-DDJq-CZk.js.br +0 -0
  196. package/dist/_frontend/assets/razor-DDJq-CZk.js.gz +0 -0
  197. package/dist/_frontend/assets/tsMode-CgQ15tRy.js.br +0 -0
  198. package/dist/_frontend/assets/tsMode-CgQ15tRy.js.gz +0 -0
  199. package/dist/_frontend/assets/typescript-C68KpWXt.js.br +0 -0
  200. package/dist/_frontend/assets/typescript-C68KpWXt.js.gz +0 -0
  201. package/dist/_frontend/assets/workers-ETQuj3lV.js.br +0 -0
  202. package/dist/_frontend/assets/workers-ETQuj3lV.js.gz +0 -0
  203. package/dist/_frontend/assets/xml-CgpI1XvU.js.br +0 -0
  204. package/dist/_frontend/assets/xml-CgpI1XvU.js.gz +0 -0
  205. package/dist/_frontend/assets/yaml-nsi6_mrm.js.br +0 -0
  206. package/dist/_frontend/assets/yaml-nsi6_mrm.js.gz +0 -0
@@ -1 +1 @@
1
- import{B as rt}from"./chunk-P2W5VLGK-wQaO2rNt.js";import{l as Te,o as Ue,p as Ce,q as Ge,t as He,v as lt,r as o,w as ve,x as it,y as Fe,z as Ee,A as ot,j as e,P as ct,S as dt,B as xe,C as qe,D as Ve,E as $,I as R,F as ut,G as Ne,H as _e,J as mt,K as ht,L as Le,M as W,N as xt,O as K,k as We,Q as ft,c as B,R as gt,U as bt,V as pt,W as Nt,X as jt,Y as yt,Z as vt,_ as Q,$ as St,a0 as wt,u as kt,a1 as Tt,a2 as je,a3 as Ct,a4 as Et,a5 as zt,a6 as At,a7 as Rt,a8 as It,a9 as Pt,aa as ye,ab as Dt,ac as Ft,ad as _t}from"./index-BOPxame4.js";var Oe=[{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 Ke(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function Lt(t){const n=Ke(),r=new Set(Oe.map(l=>l.value));return[...[n,t].flatMap(l=>l==null||l.length===0||r.has(l)?[]:(r.add(l),[{value:l,label:l===n?`${l} (Local)`:l}])),...Oe]}var Qe=[{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"}],Ot={"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 fe(){return{name:"",task:"",recurrence:"daily",hour:9,minute:0,weekdays:[1],customCron:"0 9 * * *",timezone:Ke()}}function Mt(t){return Ot[t]??t.split("/").pop()??t}function Ye(t){return t.toString().padStart(2,"0")}function me({hour:t,minute:n}){const r=t>=12?"PM":"AM",a=t%12===0?12:t%12;return`${String(a)}:${Ye(n)} ${r}`}function Se(t){const n=t.minute,r=t.hour;switch(t.recurrence){case"hourly":return`${String(n)} * * * *`;case"daily":return`${String(n)} ${String(r)} * * *`;case"weekly":{const a=[...t.weekdays].sort((u,S)=>u-S),l=a.length>0?a.join(","):"*";return`${String(n)} ${String(r)} * * ${l}`}case"custom":return t.customCron.trim()}}function we(t){return t.trim().split(/\s+/).length===5}function ce(t){const n=Mt(t.timezone),r=t.cron.trim().split(/\s+/);if(r.length!==5)return t.cron;const[a,l,u,S,b]=r;if(u!=="*"||S!=="*")return t.cron;const d=Number(a),h=Number(l);if(l==="*"&&b==="*"&&a!==void 0&&!Number.isNaN(d))return`Hourly at :${Ye(d)} ${n}`;if(b==="*"&&l!==void 0&&a!==void 0&&!Number.isNaN(h)&&!Number.isNaN(d))return`Daily ${me({hour:h,minute:d})} ${n}`;if(b==="1-5"&&l!==void 0&&a!==void 0&&!Number.isNaN(h)&&!Number.isNaN(d))return`Weekdays ${me({hour:h,minute:d})} ${n}`;if(b!=null&&/^\d(?:,\d)*$/.test(b)&&l!==void 0&&a!==void 0&&!Number.isNaN(h)&&!Number.isNaN(d)){const j=b.split(",").map(x=>{var k;return((k=Qe.find(p=>p.value===Number(x)))==null?void 0:k.label)??x});return j.length===1?`Every ${j[0]==="Mon"?"Monday":j[0]} ${me({hour:h,minute:d})} ${n}`:`${j.join(", ")} ${me({hour:h,minute:d})} ${n}`}return t.cron}function Me(t){const n=fe(),r=t.cron.trim().split(/\s+/);if(r.length!==5)return{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"custom",customCron:t.cron};const[a,l,u,S,b]=r,d=Number(a),h=Number(l);return u!=="*"||S!=="*"?{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"custom",customCron:t.cron}:l==="*"&&b==="*"&&!Number.isNaN(d)?{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"hourly",minute:d,customCron:t.cron}:b==="*"&&!Number.isNaN(h)&&!Number.isNaN(d)?{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"daily",hour:h,minute:d,customCron:t.cron}:b!=null&&/^\d(?:,\d)*$/.test(b)&&!Number.isNaN(h)&&!Number.isNaN(d)?{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"weekly",hour:h,minute:d,weekdays:b.split(",").map(Number),customCron:t.cron}:{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"custom",customCron:t.cron,hour:Number.isNaN(h)?n.hour:h,minute:Number.isNaN(d)?n.minute:d}}function $t(t,n=Date.now()){return _t(t,{fallback:"Never",nowMs:n})}var Bt=[{value:"hourly",label:"Hourly"},{value:"daily",label:"Daily"},{value:"weekly",label:"Weekly"},{value:"custom",label:"Custom"}],Ut=Array.from({length:24},(t,n)=>({value:String(n),label:n.toString().padStart(2,"0")})),Gt=[0,15,30,45].map(t=>({value:String(t),label:`:${t.toString().padStart(2,"0")}`}));function Ht({values:t,onChange:n,agentId:r,agentLabel:a,onAgentIdChange:l,onAgentPicked:u,agentPickerDisabled:S=!1,onBuildAgent:b}){const d=Se(t),h=ce({cron:d,timezone:t.timezone}),j=Lt(t.timezone),x=(i,y)=>{n({...t,[i]:y})},k=i=>{const y=i==="custom"&&t.recurrence!=="custom"?d:t.customCron;n({...t,recurrence:i,customCron:y})},p=i=>{const z=t.weekdays.includes(i)?t.weekdays.filter(m=>m!==i):[...t.weekdays,i];n({...t,weekdays:z.length>0?z:[i]})};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(qe,{"aria-label":"Agent",placeholder:"Search agent",value:r,selectedLabel:a,onValueChange:i=>l==null?void 0:l(i),onAgentPicked:u,disabled:S||l==null,onBuildAgent:b})]}),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:i=>x("name",i.target.value),placeholder:"harness-daily-digest",className:ye("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:i=>x("task",i.target.value),rows:3,placeholder:"Summarise yesterday's harness runs and post the digest…",className:ye("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-4 gap-1 rounded-lg border border-border bg-primary-bg p-1",children:Bt.map(i=>{const y=t.recurrence===i.value;return e.jsx("button",{type:"button",className:B("rounded-md border px-2 py-2 text-sm font-medium transition-colors",y?"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":y,onClick:()=>k(i.value),children:i.label},i.value)})}),t.recurrence==="custom"?e.jsxs("div",{className:"block",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Cron expression"}),e.jsx("input",{"aria-label":"Cron expression",value:t.customCron,onChange:i=>x("customCron",i.target.value),placeholder:"0 */4 * * *",spellCheck:!1,"aria-invalid":!we(t.customCron),className:B(ye("h-8"),"font-mono")}),e.jsx("span",{className:"mt-1 block text-xs text-text-secondary",children:"minute hour day-of-month month day-of-week. Runs must be at least 1 hour apart."}),we(t.customCron)?null:e.jsx("span",{className:"mt-1 block text-xs text-failure-bg",children:"Enter exactly 5 space-separated fields."})]}):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:Qe.map(i=>{const y=t.weekdays.includes(i.value);return e.jsx("button",{type:"button",className:B("min-w-0 flex-1 rounded-md border px-3 py-2 text-[0.8125rem] font-medium",y?"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":y,onClick:()=>p(i.value),children:i.label},i.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(xe,{"aria-label":"Hour",value:String(t.hour),options:Ut,onValueChange:i=>x("hour",Number(i))})]}):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(xe,{"aria-label":"Minute",value:String(t.minute),options:Gt,onValueChange:i=>x("minute",Number(i))})]}):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(xe,{"aria-label":"Timezone",value:t.timezone,options:j,onValueChange:i=>x("timezone",i),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(R,{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:h||"—"}),e.jsx("code",{className:"shrink-0 whitespace-nowrap font-mono text-[0.8125rem] font-bold text-text-secondary",children:d||"—"})]})})]})]})}function qt(t){return t.startsWith("manual-")}function Vt(t){return t==="failed"?"failed":"success"}function Ze(t){return t==="failed"?"Failed":t==="triggered"?"Triggered":"Scheduled"}function Je(t){return qt(t)?"Manual test":"Cron"}function Wt(t,n=5){return t.filter(a=>a.status!=="scheduled").slice(0,n).reverse()}function ke(t){if(t==null)return"—";const n=new Date(t);return Number.isNaN(n.getTime())?"—":It(n)}function Kt({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:Ze(t.status)}),e.jsx("p",{className:"text-text-secondary",children:Je(t.name)}),e.jsxs("p",{className:"text-text-secondary",children:["Scheduled for: ",ke(t.scheduledFor)]}),t.triggeredAt!=null?e.jsxs("p",{className:"text-text-secondary",children:["Triggered at: ",ke(t.triggeredAt)]}):null,e.jsxs("p",{className:"text-text-secondary",children:["Triggered by: ",t.triggeredBy]}),t.status==="failed"&&t.reason?e.jsxs("p",{className:"text-text-secondary",children:["Reason: ",t.reason]}):null]})}var Qt={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 Xe({run:t,onOpenSession:n}){const r=Vt(t.status),a=ke(t.triggeredAt??t.scheduledFor),l=`${Ze(t.status)} run at ${a}`,u=B("inline-flex size-6 shrink-0 items-center justify-center rounded-md border",Qt[r]),S=e.jsx(R,{name:r==="failed"?"triangle-exclamation":"check",className:"size-3.5"});return e.jsx(We,{content:e.jsx(Kt,{run:t}),className:"max-w-sm whitespace-normal",side:"top",children:n!=null&&t.sessionId!=null&&t.sessionId!==""?e.jsx("button",{type:"button",className:B(u,"cursor-pointer hover:brightness-95"),"aria-label":`Open session for ${l}`,onClick:()=>n(t),children:S}):e.jsx("span",{className:u,"aria-label":l,children:S})})}function et({status:t}){const n=t==="active";return e.jsx(rt,{variant:n?"success":"warning",shape:"pill",size:"md",dot:!0,children:n?"Active":"Paused"})}function Yt(t,n){return t.find(r=>r.name===n||r.id===n)??null}function Zt({connector:t,onConnected:n}){return Dt()==null?null:e.jsx(Ft,{connector:t,onConnected:n})}function ie({label:t,children:n}){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:n})]})}function Jt({schedule:t,agentName:n,mcpMounts:r,onEditConfiguration:a}){const l=Te(),u=Ce(),{connectors:S,ensureLoaded:b,refreshConnectors:d,loading:h,error:j}=Pt(),[x,k]=o.useState(!1),[p,i]=o.useState(null),y=ce({cron:t.cron,timezone:t.timezone}),z=async()=>{k(!0);try{const m=await l.createScheduleRun({scheduleId:t.id});i(m),u==null||u.showSuccess({title:"Test run started"})}catch(m){u==null||u.showError(m)}finally{k(!1)}};return o.useEffect(()=>{b()},[b]),o.useEffect(()=>{j!=null&&(u==null||u.showError(j))},[j,u]),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(ie,{label:"Agent",children:n}),e.jsx(ie,{label:"Name",children:t.name}),e.jsx(ie,{label:"Status",children:e.jsx(et,{status:t.status})}),e.jsx(ie,{label:"Task",children:e.jsx("span",{className:"whitespace-pre-wrap break-words",children:t.task})}),e.jsx(ie,{label:"Frequency",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-1.5",children:[e.jsx("span",{children:y}),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($.Secondary,{type:"button",size:"small",onClick:a,children:[e.jsx(R,{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"})}),r.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:r.map(m=>{const C=Yt(S,m.name),U=(C==null?void 0:C.authenticated)===!0,q=C==null&&!h;return e.jsxs("li",{className:"flex items-center gap-2 px-3 py-2.5",children:[e.jsx("span",{className:B("inline-flex size-4 shrink-0 items-center justify-center rounded-full border",U?"border-emerald-600/40 bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"border-border text-transparent"),"aria-hidden":!0,children:U?e.jsx(R,{name:"check",className:"size-3"}):null}),e.jsx("span",{className:"text-text-primary min-w-0 flex-1 truncate text-sm",children:m.name}),U?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(Zt,{connector:C,onConnected:d}):h?e.jsx("span",{className:"text-text-secondary text-xs",children:"Loading…"}):null]},m.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($.Primary,{type:"button",disabled:x,size:"small",onClick:()=>void z(),children:[e.jsx(R,{name:x?"loader":"play",className:B("size-3.5",x&&"animate-spin")}),"Run Test"]})]}),p==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(Xe,{run:p}),e.jsxs("div",{className:"min-w-0 text-sm",children:[e.jsx("p",{className:"text-text-primary font-medium",children:Je(p.name)}),e.jsx("p",{className:"text-text-secondary",children:$t(p.triggeredAt??p.scheduledFor)})]})]})]})]})}function Xt({open:t,onOpenChange:n,mode:r,schedule:a,initialAgentId:l="",onSaved:u}){const S=Te(),b=Ue(),d=He(),h=Ce(),j=Ge(),[x,k]=o.useState(fe),[p,i]=o.useState(l),[y,z]=o.useState(null),[m,C]=o.useState({kind:"form"}),[U,q]=o.useState(!1),[re,Y]=o.useState(!1),[A,_]=o.useState(null),L=o.useRef(p);L.current=p;const Z=m.kind==="form"?m.saved:m.schedule,N=r==="edit"&&m.kind==="form"&&m.saved==null&&a!=null,O=m.kind==="form"&&m.saved!=null,T=r==="create"&&m.kind==="form"&&m.saved==null,{allows:J}=ve({resourceType:"agent",resourceIds:p.length===0?[]:[p]});o.useEffect(()=>{if(!t){k(fe()),i(l),z(null),_(null),C({kind:"form"}),Y(!1);return}if(r==="edit"&&a!=null){k(Me({name:a.name,task:a.task,cron:a.cron,timezone:a.timezone})),i(a.agentId),z(null),C({kind:"form"});return}k(fe()),i(l),z(null),C({kind:"form"})},[t,r,a,l]),o.useEffect(()=>{if(!t||r!=="create"||l.length===0)return;let f=!1;const v=l;return zt({server:b,agentKey:v}).then(w=>{f||w==null||L.current===v&&(z(w),i(Ve(w)))}).catch(()=>{}),()=>{f=!0}},[t,r,l,b]);const G=(y==null?void 0:y.name)??(Z==null?void 0:Z.agentName)??(a==null?void 0:a.agentName)??(p.length>0?p:""),ge=o.useMemo(()=>{var v;return(((v=y==null?void 0:y.agentSpec)==null?void 0:v.mcpServers)??[]).map(At).filter(w=>w!=null).map(w=>({name:w}))},[y]),le=o.useMemo(()=>{const f=Se(x);return x.name.trim().length>0&&x.task.trim().length>0&&we(f)&&p.length>0&&(!T||J(p,"USE"))},[p,J,x,T]),V=f=>{C({kind:"test",schedule:f}),k(Me({name:f.name,task:f.task,cron:f.cron,timezone:f.timezone})),i(f.agentId)},X=async f=>{if(f.preventDefault(),!le)return;const v=Se(x);q(!0),_(null);try{if(N&&a!=null){await S.updateSchedule({id:a.id,name:x.name.trim(),task:x.task.trim(),cron:v,timezone:x.timezone,status:a.status}),j(Q.Schedule.EDITED,{schedule_id:a.id,agent_id:a.agentId}),u==null||u(),n(!1);return}if(O&&m.kind==="form"&&m.saved!=null){const I=await S.updateSchedule({id:m.saved.id,name:x.name.trim(),task:x.task.trim(),cron:v,timezone:x.timezone,status:"paused"});j(Q.Schedule.EDITED,{schedule_id:I.id,agent_id:I.agentId}),u==null||u(),V(I),h==null||h.showSuccess({title:"Schedule saved as paused",description:ce({cron:I.cron,timezone:I.timezone})});return}const w=await S.createSchedule({agentId:p,name:x.name.trim(),task:x.task.trim(),cron:v,timezone:x.timezone,status:"paused"});j(Q.Schedule.CREATED,{schedule_id:w.id,agent_id:p}),u==null||u(),V(w),h==null||h.showSuccess({title:"Schedule saved as paused",description:ce({cron:w.cron,timezone:w.timezone})})}catch(w){const I=w instanceof Error?w.message:"Failed to save schedule";_(I)}finally{q(!1)}},ee=async()=>{if(m.kind==="test"){Y(!0),_(null);try{await S.updateSchedule({id:m.schedule.id,name:m.schedule.name,task:m.schedule.task,cron:m.schedule.cron,timezone:m.schedule.timezone,status:"active"}),u==null||u(),h==null||h.showSuccess({title:"Schedule activated"}),n(!1)}catch(f){const v=f instanceof Error?f.message:"Failed to activate schedule";_(v),h==null||h.showError(f)}finally{Y(!1)}}},te=m.kind==="test"?"Test Schedule":N||O?"Edit Schedule":"New Schedule",M=m.kind==="test"?`Recurring unattended runs of ${G}.`:N||O?"Update cadence and task for this schedule.":"Create a recurring unattended run for an agent.";let se;return m.kind==="test"?se=e.jsxs("div",{className:"flex flex-col gap-2",children:[A!=null?e.jsx("p",{className:"text-failure-bg text-sm",children:A}):null,e.jsx($.Secondary,{type:"button",className:"w-full",disabled:re,onClick:()=>void ee(),children:"Activate Schedule"})]}):se=e.jsxs("div",{className:"flex flex-col gap-2",children:[A!=null?e.jsx("p",{className:"text-failure-bg text-sm",children:A}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx($.Secondary,{type:"button",onClick:()=>n(!1),disabled:U,children:"Cancel"}),e.jsx($.Primary,{type:"submit",form:"schedule-form",disabled:!le||U,children:"Save"})]})]}),e.jsx(Rt,{open:t,onOpenChange:n,title:te,description:M,anchor:"right",size:"xl",headerIcon:e.jsx("span",{className:"text-primary-button-bg inline-flex size-8 items-center justify-center",children:e.jsx(R,{name:m.kind==="test"||N||O?"calendar":"calendar-plus",className:"size-5"})}),footer:se,children:m.kind==="test"?e.jsx(Jt,{schedule:m.schedule,agentName:G,mcpMounts:ge,onEditConfiguration:()=>{_(null),C({kind:"form",saved:m.schedule})}}):e.jsx("form",{id:"schedule-form",onSubmit:f=>void X(f),children:e.jsx(Ht,{values:x,onChange:k,agentId:p,agentLabel:G,onAgentIdChange:N||O?void 0:f=>{i(f),f.length===0&&z(null)},onAgentPicked:z,agentPickerDisabled:N||O,onBuildAgent:r==="create"&&(d==null?void 0:d.isComposerEnabled)===!0?()=>{n(!1),d.openAgentBuilder()}:void 0})})})}function $e(t){return e.jsx(Et,{children:e.jsx(Xt,{...t})})}function es({runs:t,onOpenSession:n}){const r=Wt(t);return r.length===0?e.jsx("span",{className:"text-text-secondary text-sm",children:"—"}):e.jsx("div",{className:"flex items-center gap-1",children:r.map(a=>e.jsx(Xe,{run:a,...n==null?{}:{onOpenSession:n}},a.id))})}var ts=[{value:"all",label:"All statuses"},{value:"active",label:"Active"},{value:"paused",label:"Paused"}],Be=[10,25];function he(t){return Math.min(Math.max(t,1),25)}function oe(t){const n=Ee(t);return{nameQuery:n.q??"",statusFilter:n.status??"all",agentFilter:n.agent??"all",scheduleId:n.scheduleId}}function ss(t){const n=Ee(window.location.search);if(!n.isNew)return{kind:"closed"};const r=t??n.agent;return{kind:"create",...r==null?{}:{agentId:r}}}function ns({schedule:t,running:n,canManage:r,canDelete:a,onRunNow:l,onEdit:u,onTogglePause:S,onDelete:b}){const d=kt("PermissionGuard");return e.jsxs("div",{className:"inline-flex items-center justify-end gap-1.5",children:[e.jsx(d,{allowed:r,children:e.jsxs($.Secondary,{type:"button",disabled:n,"aria-label":`Run now ${t.name}`,size:"large",onClick:l,children:[e.jsx(R,{name:n?"loader":"play",className:B("size-3.5",n&&"animate-spin")}),"Run now"]})}),e.jsxs(Tt,{align:"end",trigger:e.jsx("button",{type:"button",className:Ct({variant:"ghost",size:"icon"}),"aria-label":`Actions for ${t.name}`,children:e.jsx(R,{name:"ellipsis"})}),children:[e.jsx(d,{allowed:r,children:e.jsxs(je,{onClick:u,children:[e.jsx(R,{name:"pencil",className:"size-3.5"}),"Edit"]})}),e.jsx(d,{allowed:r,children:e.jsxs(je,{onClick:S,children:[e.jsx(R,{name:t.status==="active"?"pause":"play",className:"size-3.5"}),t.status==="active"?"Pause":"Resume"]})}),e.jsx(d,{allowed:a,children:e.jsxs(je,{className:"text-failure-bg focus:text-failure-bg",onClick:b,children:[e.jsx(R,{name:"trash",className:"size-3.5"}),"Delete"]})})]})]})}function ls({agentId:t}){const n=Te(),r=Ue(),a=Ce(),l=Ge(),u=He(),S=lt(),b=u!=null&&vt({sessions:S}),[d,h]=o.useState([]),{allows:j}=ve({resourceType:"schedule",resourceIds:d.map(s=>s.id)}),[x,k]=o.useState({}),[p,i]=o.useState(!1),[y,z]=o.useState(()=>new Set),[m,C]=o.useState({}),[U,q]=o.useState(!0),[re,Y]=o.useState(null),[A,_]=o.useState(()=>oe(window.location.search).nameQuery),[L,Z]=o.useState(()=>oe(window.location.search).statusFilter),[N,O]=o.useState(()=>t??oe(window.location.search).agentFilter),[T,J]=o.useState(()=>oe(window.location.search).scheduleId),G=t??(N==="all"?null:N),{allows:ge}=ve({resourceType:"agent",resourceIds:G==null?[]:[G]}),le=r.permissions==null||G==null||ge(G,"USE"),[V,X]=o.useState(()=>ss(t)),[ee,te]=o.useState(null),[M,se]=o.useState(()=>he(yt)),[f,v]=o.useState(void 0),[w,I]=o.useState(void 0),[ne,P]=o.useState(void 0),tt=({run:s,schedule:c})=>{if(!b||u==null||s.sessionId==null)return;l(Q.Schedule.RUN_SESSION_OPENED,{schedule_id:c.id,agent_id:c.agentId});const g=St(s.triggeredAt??s.scheduledFor);wt({sessionId:s.sessionId,view:"sessions",...g==null?{}:{timeRange:g}}),u.setSessionsOpen(!0)},H=o.useRef(0),ze=o.useRef(!1),be=o.useCallback(async({rows:s,gen:c})=>{if(s.length===0){c===H.current&&k({});return}i(!0);try{const g=await Promise.allSettled(s.map(E=>n.listScheduleRuns({scheduleId:E.id})));if(c!==H.current)return;k(Object.fromEntries(s.map((E,D)=>{const F=g[D],ue=(F==null?void 0:F.status)==="fulfilled"?F.value:[];return[E.id,ue]})))}finally{c===H.current&&i(!1)}},[n]),ae=o.useCallback(async({token:s,size:c,agentId:g,pinnedScheduleId:E})=>{const D=++H.current;q(!0),Y(null);try{if(E!=null){const ue=await n.getSchedule({id:E});if(D!==H.current)return;h([ue]),I(void 0),P(void 0),be({rows:[ue],gen:D});return}const F=await n.listSchedules({limit:he(c),...s===void 0||s===""?{}:{pageToken:s},...g==="all"?{}:{agentIds:[g]}});if(D!==H.current)return;h(F.data),I(F.nextPageToken),P(F.previousPageToken),be({rows:F.data,gen:D})}catch(F){if(D!==H.current)return;Y(it(F,"Check your connection and try again.")),h([]),k({}),I(void 0),P(void 0)}finally{D===H.current&&q(!1)}},[n,be]),Ae=o.useCallback(s=>{const c=(s==null?void 0:s.size)??M,g=(s==null?void 0:s.agentId)??N;J(null),v(void 0),P(void 0),ae({token:void 0,size:c,agentId:g,pinnedScheduleId:null})},[N,ae,M]);o.useEffect(()=>{Fe({agent:t===void 0&&N!=="all"?N:null,status:L==="all"?null:L,q:A.trim().length===0?null:A,scheduleId:T})},[N,t,L,A,T]),o.useEffect(()=>{t!==void 0&&O(s=>s===t?s:(v(void 0),P(void 0),t))},[t]),o.useEffect(()=>{ze.current||!Ee(window.location.search).isNew||(ze.current=!0,Fe({isNew:null}))},[]),o.useEffect(()=>{const s=()=>{const c=oe(window.location.search);_(c.nameQuery),Z(c.statusFilter),J(g=>g===c.scheduleId?g:(v(void 0),P(void 0),c.scheduleId)),O(g=>{const E=t??c.agentFilter;return g===E?g:(v(void 0),P(void 0),E)})};return window.addEventListener("popstate",s),()=>{window.removeEventListener("popstate",s)}},[t]),o.useEffect(()=>{ae({token:f,size:M,agentId:N,pinnedScheduleId:T})},[N,M,f,ae,T]),o.useEffect(()=>{if(T==null||A.trim().length>0)return;const s=d.find(c=>c.id===T);s!=null&&_(s.name)},[A,T,d]);const de=o.useMemo(()=>{if(T!=null)return d;const s=A.trim().toLowerCase();return d.filter(c=>!(L!=="all"&&c.status!==L||s.length>0&&!c.name.toLowerCase().includes(s)))},[d,A,L,T]),Re=ot(d),Ie=ne!=null||w!=null,st=async s=>{if(!j(s.id,"MANAGE"))return;const c=s.status==="active"?"paused":"active";try{await n.updateSchedule({...s,status:c}),l(Q.Schedule.TOGGLED,{schedule_id:s.id,agent_id:s.agentId,next_status:c}),await ae({token:f,size:M,agentId:N,pinnedScheduleId:T})}catch(g){a==null||a.showError(g)}},nt=async s=>{if(j(s.id,"MANAGE")){z(c=>new Set(c).add(s.id));try{if(await n.createScheduleRun({scheduleId:s.id}),l(Q.Schedule.RUN_NOW,{schedule_id:s.id,agent_id:s.agentId}),a==null||a.showSuccess({title:"Run started"}),T!=null){const g=await n.getSchedule({id:T});h(E=>{const D=E.length===1?E[0]:void 0;return D!=null&&D.id===g.id?[g]:E})}const c=await n.listScheduleRuns({scheduleId:s.id});k(g=>({...g,[s.id]:c}))}catch(c){a==null||a.showError(c)}finally{z(c=>{const g=new Set(c);return g.delete(s.id),g})}}},at=async s=>{if(j(s.id,"DELETE")){te(null);try{await n.deleteSchedule({id:s.id}),l(Q.Schedule.DELETED,{schedule_id:s.id,agent_id:s.agentId}),Ae()}catch(c){a==null||a.showError(c)}}},Pe=()=>{w!=null&&v(w)},De=()=>{ne==null||ne===""||v(ne)},pe=()=>{T!=null&&(J(null),v(void 0),P(void 0))};return e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-primary-bg",children:[e.jsx(ct,{title:t===void 0?"Agent Schedules":void 0,end:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-full sm:w-60",children:e.jsx(dt,{query:A,setQuery:s=>{_(s),pe()},placeholder:"Search schedules by name"})}),e.jsx(xe,{value:L,onValueChange:s=>{Z(s),pe()},options:ts,className:"sm:w-40","aria-label":"Filter by status"}),t===void 0?e.jsx(qe,{value:N,selectedLabel:N==="all"?"All agents":m[N]??N,onValueChange:s=>{O(s),v(void 0),P(void 0),pe()},onAgentPicked:s=>{C(c=>({...c,[Ve(s)]:s.name}))},allOption:{value:"all",label:"All agents"},className:"sm:w-48","aria-label":"Filter by agent",placeholder:"Search agent"}):null,e.jsxs($.Primary,{type:"button",disabled:!le,onClick:()=>le&&X({kind:"create",agentId:N!=="all"?N:void 0}),children:[e.jsx(R,{name:"plus",className:"size-3.5"}),"New Schedule"]})]})}),e.jsx("div",{className:B("min-h-0 flex-1 overflow-auto px-4 py-4",re!=null?"flex flex-col":void 0),children:U?e.jsx("div",{className:"flex flex-col gap-2",role:"status","aria-label":"Loading schedules",children:Array.from({length:5},(s,c)=>e.jsx(ut,{className:"h-12 w-full rounded-md"},c))}):re!=null?e.jsx("div",{role:"alert",className:"flex flex-1 flex-col items-center justify-center",children:e.jsx(Ne,{title:"Couldn't load schedules",description:re,className:"h-auto min-h-0 flex-none py-0"})}):d.length===0?e.jsx(Ne,{title:"No Schedules Found",description:"Create one to get started.",className:"min-h-full"}):de.length===0?e.jsxs("div",{className:"flex min-h-full flex-col",children:[e.jsx(Ne,{title:"No Schedules Found",description:"No schedules match your filters.",className:"flex-1"}),Ie?e.jsx(_e,{pageSize:M,rowCount:0,canPrev:ne!=null,canNext:w!=null,onPrev:De,onNext:Pe,pageSizeOptions:Be,onPageSizeChange:s=>{const c=he(s);se(c),v(void 0),P(void 0)}}):null]}):e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border",children:[e.jsxs(mt,{className:"min-w-240",children:[e.jsx(ht,{children:e.jsxs(Le,{className:"hover:bg-transparent",children:[e.jsx(W,{children:"Schedule Name"}),e.jsx(W,{children:"Task"}),Re?e.jsx(W,{children:"Created by"}):null,e.jsx(W,{children:"Frequency"}),e.jsx(W,{children:"Status"}),e.jsx(W,{children:"Last 5 runs"}),e.jsx(W,{children:e.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e.jsx(xt,{children:de.map(s=>{const c=ce({cron:s.cron,timezone:s.timezone}),g=s.agentName??m[s.agentId]??s.agentId;return e.jsxs(Le,{children:[e.jsxs(K,{className:"w-48 max-w-48",children:[e.jsx("span",{className:"text-text-primary block truncate font-medium",children:s.name}),e.jsxs("span",{className:"mt-1 flex min-w-0 items-center gap-1 text-xs",children:[e.jsx(R,{name:"agent-2",className:"size-3 shrink-0"}),e.jsx("span",{className:"truncate",children:g})]})]}),e.jsx(K,{className:"w-64 max-w-64",children:e.jsx(We,{content:s.task,className:"max-w-sm whitespace-normal text-left",triggerClassName:"block min-w-0 w-full max-w-full",children:e.jsx("span",{className:"block truncate",children:s.task})})}),Re?e.jsx(K,{children:e.jsx(ft,{subject:s.createdBySubject})}):null,e.jsx(K,{children:c}),e.jsx(K,{children:e.jsx(et,{status:s.status})}),e.jsx(K,{children:p?e.jsx("span",{className:"text-text-secondary text-sm",children:"…"}):e.jsx(es,{runs:x[s.id]??[],...b?{onOpenSession:E=>tt({run:E,schedule:s})}:{}})}),e.jsx(K,{className:"text-right",children:e.jsx(ns,{schedule:s,running:y.has(s.id),canManage:j(s.id,"MANAGE"),canDelete:j(s.id,"DELETE"),onRunNow:()=>void nt(s),onEdit:()=>{j(s.id,"MANAGE")&&X({kind:"edit",schedule:s})},onTogglePause:()=>void st(s),onDelete:()=>{j(s.id,"DELETE")&&te(s)}})})]},s.id)})})]}),(de.length>0||Ie)&&e.jsx(_e,{pageSize:M,rowCount:de.length,canPrev:ne!=null,canNext:w!=null,onPrev:De,onNext:Pe,pageSizeOptions:Be,onPageSizeChange:s=>{const c=he(s);se(c),v(void 0),P(void 0)}})]})}),V.kind==="create"?e.jsx($e,{open:!0,mode:"create",initialAgentId:V.agentId??"",onOpenChange:s=>{s||X({kind:"closed"})},onSaved:()=>Ae()}):null,V.kind==="edit"?e.jsx($e,{open:!0,mode:"edit",schedule:V.schedule,onOpenChange:s=>{s||X({kind:"closed"})},onSaved:()=>void ae({token:f,size:M,agentId:N,pinnedScheduleId:T})}):null,ee!=null?e.jsxs(gt,{open:!0,onOpenChange:s=>{s||te(null)},"aria-label":"Delete schedule",className:"max-w-md",children:[e.jsx(bt,{children:e.jsxs(pt,{children:[e.jsx(Nt,{children:"Delete schedule"}),e.jsxs("p",{className:"text-text-secondary text-sm",children:["“",ee.name,"” will stop running. This cannot be undone."]})]})}),e.jsxs(jt,{children:[e.jsx($.Secondary,{type:"button",onClick:()=>te(null),children:"Cancel"}),e.jsx($.Destructive,{type:"button",disabled:!j(ee.id,"DELETE"),onClick:()=>void at(ee),children:"Delete"})]})]}):null]})}export{ls as SchedulesPage};
1
+ import{B as rt}from"./chunk-P2W5VLGK-B6YzGXAg.js";import{l as Te,o as Ue,p as Ce,q as Ge,t as He,v as lt,r as o,w as ve,x as it,y as Fe,z as Ee,A as ot,j as e,P as ct,S as dt,B as xe,C as qe,D as Ve,E as $,I as R,F as ut,G as Ne,H as _e,J as mt,K as ht,L as Le,M as W,N as xt,O as K,k as We,Q as ft,c as B,R as gt,U as bt,V as pt,W as Nt,X as jt,Y as yt,Z as vt,_ as Q,$ as St,a0 as wt,u as kt,a1 as Tt,a2 as je,a3 as Ct,a4 as Et,a5 as zt,a6 as At,a7 as Rt,a8 as It,a9 as Pt,aa as ye,ab as Dt,ac as Ft,ad as _t}from"./index-o2o-gWoN.js";var Oe=[{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 Ke(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function Lt(t){const n=Ke(),r=new Set(Oe.map(l=>l.value));return[...[n,t].flatMap(l=>l==null||l.length===0||r.has(l)?[]:(r.add(l),[{value:l,label:l===n?`${l} (Local)`:l}])),...Oe]}var Qe=[{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"}],Ot={"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 fe(){return{name:"",task:"",recurrence:"daily",hour:9,minute:0,weekdays:[1],customCron:"0 9 * * *",timezone:Ke()}}function Mt(t){return Ot[t]??t.split("/").pop()??t}function Ye(t){return t.toString().padStart(2,"0")}function me({hour:t,minute:n}){const r=t>=12?"PM":"AM",a=t%12===0?12:t%12;return`${String(a)}:${Ye(n)} ${r}`}function Se(t){const n=t.minute,r=t.hour;switch(t.recurrence){case"hourly":return`${String(n)} * * * *`;case"daily":return`${String(n)} ${String(r)} * * *`;case"weekly":{const a=[...t.weekdays].sort((u,S)=>u-S),l=a.length>0?a.join(","):"*";return`${String(n)} ${String(r)} * * ${l}`}case"custom":return t.customCron.trim()}}function we(t){return t.trim().split(/\s+/).length===5}function ce(t){const n=Mt(t.timezone),r=t.cron.trim().split(/\s+/);if(r.length!==5)return t.cron;const[a,l,u,S,b]=r;if(u!=="*"||S!=="*")return t.cron;const d=Number(a),h=Number(l);if(l==="*"&&b==="*"&&a!==void 0&&!Number.isNaN(d))return`Hourly at :${Ye(d)} ${n}`;if(b==="*"&&l!==void 0&&a!==void 0&&!Number.isNaN(h)&&!Number.isNaN(d))return`Daily ${me({hour:h,minute:d})} ${n}`;if(b==="1-5"&&l!==void 0&&a!==void 0&&!Number.isNaN(h)&&!Number.isNaN(d))return`Weekdays ${me({hour:h,minute:d})} ${n}`;if(b!=null&&/^\d(?:,\d)*$/.test(b)&&l!==void 0&&a!==void 0&&!Number.isNaN(h)&&!Number.isNaN(d)){const j=b.split(",").map(x=>{var k;return((k=Qe.find(p=>p.value===Number(x)))==null?void 0:k.label)??x});return j.length===1?`Every ${j[0]==="Mon"?"Monday":j[0]} ${me({hour:h,minute:d})} ${n}`:`${j.join(", ")} ${me({hour:h,minute:d})} ${n}`}return t.cron}function Me(t){const n=fe(),r=t.cron.trim().split(/\s+/);if(r.length!==5)return{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"custom",customCron:t.cron};const[a,l,u,S,b]=r,d=Number(a),h=Number(l);return u!=="*"||S!=="*"?{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"custom",customCron:t.cron}:l==="*"&&b==="*"&&!Number.isNaN(d)?{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"hourly",minute:d,customCron:t.cron}:b==="*"&&!Number.isNaN(h)&&!Number.isNaN(d)?{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"daily",hour:h,minute:d,customCron:t.cron}:b!=null&&/^\d(?:,\d)*$/.test(b)&&!Number.isNaN(h)&&!Number.isNaN(d)?{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"weekly",hour:h,minute:d,weekdays:b.split(",").map(Number),customCron:t.cron}:{...n,name:t.name,task:t.task,timezone:t.timezone,recurrence:"custom",customCron:t.cron,hour:Number.isNaN(h)?n.hour:h,minute:Number.isNaN(d)?n.minute:d}}function $t(t,n=Date.now()){return _t(t,{fallback:"Never",nowMs:n})}var Bt=[{value:"hourly",label:"Hourly"},{value:"daily",label:"Daily"},{value:"weekly",label:"Weekly"},{value:"custom",label:"Custom"}],Ut=Array.from({length:24},(t,n)=>({value:String(n),label:n.toString().padStart(2,"0")})),Gt=[0,15,30,45].map(t=>({value:String(t),label:`:${t.toString().padStart(2,"0")}`}));function Ht({values:t,onChange:n,agentId:r,agentLabel:a,onAgentIdChange:l,onAgentPicked:u,agentPickerDisabled:S=!1,onBuildAgent:b}){const d=Se(t),h=ce({cron:d,timezone:t.timezone}),j=Lt(t.timezone),x=(i,y)=>{n({...t,[i]:y})},k=i=>{const y=i==="custom"&&t.recurrence!=="custom"?d:t.customCron;n({...t,recurrence:i,customCron:y})},p=i=>{const z=t.weekdays.includes(i)?t.weekdays.filter(m=>m!==i):[...t.weekdays,i];n({...t,weekdays:z.length>0?z:[i]})};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(qe,{"aria-label":"Agent",placeholder:"Search agent",value:r,selectedLabel:a,onValueChange:i=>l==null?void 0:l(i),onAgentPicked:u,disabled:S||l==null,onBuildAgent:b})]}),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:i=>x("name",i.target.value),placeholder:"harness-daily-digest",className:ye("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:i=>x("task",i.target.value),rows:3,placeholder:"Summarise yesterday's harness runs and post the digest…",className:ye("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-4 gap-1 rounded-lg border border-border bg-primary-bg p-1",children:Bt.map(i=>{const y=t.recurrence===i.value;return e.jsx("button",{type:"button",className:B("rounded-md border px-2 py-2 text-sm font-medium transition-colors",y?"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":y,onClick:()=>k(i.value),children:i.label},i.value)})}),t.recurrence==="custom"?e.jsxs("div",{className:"block",children:[e.jsx("span",{className:"mb-1.5 block text-sm font-medium",children:"Cron expression"}),e.jsx("input",{"aria-label":"Cron expression",value:t.customCron,onChange:i=>x("customCron",i.target.value),placeholder:"0 */4 * * *",spellCheck:!1,"aria-invalid":!we(t.customCron),className:B(ye("h-8"),"font-mono")}),e.jsx("span",{className:"mt-1 block text-xs text-text-secondary",children:"minute hour day-of-month month day-of-week. Runs must be at least 1 hour apart."}),we(t.customCron)?null:e.jsx("span",{className:"mt-1 block text-xs text-failure-bg",children:"Enter exactly 5 space-separated fields."})]}):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:Qe.map(i=>{const y=t.weekdays.includes(i.value);return e.jsx("button",{type:"button",className:B("min-w-0 flex-1 rounded-md border px-3 py-2 text-[0.8125rem] font-medium",y?"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":y,onClick:()=>p(i.value),children:i.label},i.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(xe,{"aria-label":"Hour",value:String(t.hour),options:Ut,onValueChange:i=>x("hour",Number(i))})]}):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(xe,{"aria-label":"Minute",value:String(t.minute),options:Gt,onValueChange:i=>x("minute",Number(i))})]}):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(xe,{"aria-label":"Timezone",value:t.timezone,options:j,onValueChange:i=>x("timezone",i),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(R,{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:h||"—"}),e.jsx("code",{className:"shrink-0 whitespace-nowrap font-mono text-[0.8125rem] font-bold text-text-secondary",children:d||"—"})]})})]})]})}function qt(t){return t.startsWith("manual-")}function Vt(t){return t==="failed"?"failed":"success"}function Ze(t){return t==="failed"?"Failed":t==="triggered"?"Triggered":"Scheduled"}function Je(t){return qt(t)?"Manual test":"Cron"}function Wt(t,n=5){return t.filter(a=>a.status!=="scheduled").slice(0,n).reverse()}function ke(t){if(t==null)return"—";const n=new Date(t);return Number.isNaN(n.getTime())?"—":It(n)}function Kt({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:Ze(t.status)}),e.jsx("p",{className:"text-text-secondary",children:Je(t.name)}),e.jsxs("p",{className:"text-text-secondary",children:["Scheduled for: ",ke(t.scheduledFor)]}),t.triggeredAt!=null?e.jsxs("p",{className:"text-text-secondary",children:["Triggered at: ",ke(t.triggeredAt)]}):null,e.jsxs("p",{className:"text-text-secondary",children:["Triggered by: ",t.triggeredBy]}),t.status==="failed"&&t.reason?e.jsxs("p",{className:"text-text-secondary",children:["Reason: ",t.reason]}):null]})}var Qt={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 Xe({run:t,onOpenSession:n}){const r=Vt(t.status),a=ke(t.triggeredAt??t.scheduledFor),l=`${Ze(t.status)} run at ${a}`,u=B("inline-flex size-6 shrink-0 items-center justify-center rounded-md border",Qt[r]),S=e.jsx(R,{name:r==="failed"?"triangle-exclamation":"check",className:"size-3.5"});return e.jsx(We,{content:e.jsx(Kt,{run:t}),className:"max-w-sm whitespace-normal",side:"top",children:n!=null&&t.sessionId!=null&&t.sessionId!==""?e.jsx("button",{type:"button",className:B(u,"cursor-pointer hover:brightness-95"),"aria-label":`Open session for ${l}`,onClick:()=>n(t),children:S}):e.jsx("span",{className:u,"aria-label":l,children:S})})}function et({status:t}){const n=t==="active";return e.jsx(rt,{variant:n?"success":"warning",shape:"pill",size:"md",dot:!0,children:n?"Active":"Paused"})}function Yt(t,n){return t.find(r=>r.name===n||r.id===n)??null}function Zt({connector:t,onConnected:n}){return Dt()==null?null:e.jsx(Ft,{connector:t,onConnected:n})}function ie({label:t,children:n}){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:n})]})}function Jt({schedule:t,agentName:n,mcpMounts:r,onEditConfiguration:a}){const l=Te(),u=Ce(),{connectors:S,ensureLoaded:b,refreshConnectors:d,loading:h,error:j}=Pt(),[x,k]=o.useState(!1),[p,i]=o.useState(null),y=ce({cron:t.cron,timezone:t.timezone}),z=async()=>{k(!0);try{const m=await l.createScheduleRun({scheduleId:t.id});i(m),u==null||u.showSuccess({title:"Test run started"})}catch(m){u==null||u.showError(m)}finally{k(!1)}};return o.useEffect(()=>{b()},[b]),o.useEffect(()=>{j!=null&&(u==null||u.showError(j))},[j,u]),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(ie,{label:"Agent",children:n}),e.jsx(ie,{label:"Name",children:t.name}),e.jsx(ie,{label:"Status",children:e.jsx(et,{status:t.status})}),e.jsx(ie,{label:"Task",children:e.jsx("span",{className:"whitespace-pre-wrap break-words",children:t.task})}),e.jsx(ie,{label:"Frequency",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-1.5",children:[e.jsx("span",{children:y}),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($.Secondary,{type:"button",size:"small",onClick:a,children:[e.jsx(R,{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"})}),r.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:r.map(m=>{const C=Yt(S,m.name),U=(C==null?void 0:C.authenticated)===!0,q=C==null&&!h;return e.jsxs("li",{className:"flex items-center gap-2 px-3 py-2.5",children:[e.jsx("span",{className:B("inline-flex size-4 shrink-0 items-center justify-center rounded-full border",U?"border-emerald-600/40 bg-emerald-500/15 text-emerald-700 dark:text-emerald-300":"border-border text-transparent"),"aria-hidden":!0,children:U?e.jsx(R,{name:"check",className:"size-3"}):null}),e.jsx("span",{className:"text-text-primary min-w-0 flex-1 truncate text-sm",children:m.name}),U?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(Zt,{connector:C,onConnected:d}):h?e.jsx("span",{className:"text-text-secondary text-xs",children:"Loading…"}):null]},m.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($.Primary,{type:"button",disabled:x,size:"small",onClick:()=>void z(),children:[e.jsx(R,{name:x?"loader":"play",className:B("size-3.5",x&&"animate-spin")}),"Run Test"]})]}),p==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(Xe,{run:p}),e.jsxs("div",{className:"min-w-0 text-sm",children:[e.jsx("p",{className:"text-text-primary font-medium",children:Je(p.name)}),e.jsx("p",{className:"text-text-secondary",children:$t(p.triggeredAt??p.scheduledFor)})]})]})]})]})}function Xt({open:t,onOpenChange:n,mode:r,schedule:a,initialAgentId:l="",onSaved:u}){const S=Te(),b=Ue(),d=He(),h=Ce(),j=Ge(),[x,k]=o.useState(fe),[p,i]=o.useState(l),[y,z]=o.useState(null),[m,C]=o.useState({kind:"form"}),[U,q]=o.useState(!1),[re,Y]=o.useState(!1),[A,_]=o.useState(null),L=o.useRef(p);L.current=p;const Z=m.kind==="form"?m.saved:m.schedule,N=r==="edit"&&m.kind==="form"&&m.saved==null&&a!=null,O=m.kind==="form"&&m.saved!=null,T=r==="create"&&m.kind==="form"&&m.saved==null,{allows:J}=ve({resourceType:"agent",resourceIds:p.length===0?[]:[p]});o.useEffect(()=>{if(!t){k(fe()),i(l),z(null),_(null),C({kind:"form"}),Y(!1);return}if(r==="edit"&&a!=null){k(Me({name:a.name,task:a.task,cron:a.cron,timezone:a.timezone})),i(a.agentId),z(null),C({kind:"form"});return}k(fe()),i(l),z(null),C({kind:"form"})},[t,r,a,l]),o.useEffect(()=>{if(!t||r!=="create"||l.length===0)return;let f=!1;const v=l;return zt({server:b,agentKey:v}).then(w=>{f||w==null||L.current===v&&(z(w),i(Ve(w)))}).catch(()=>{}),()=>{f=!0}},[t,r,l,b]);const G=(y==null?void 0:y.name)??(Z==null?void 0:Z.agentName)??(a==null?void 0:a.agentName)??(p.length>0?p:""),ge=o.useMemo(()=>{var v;return(((v=y==null?void 0:y.agentSpec)==null?void 0:v.mcpServers)??[]).map(At).filter(w=>w!=null).map(w=>({name:w}))},[y]),le=o.useMemo(()=>{const f=Se(x);return x.name.trim().length>0&&x.task.trim().length>0&&we(f)&&p.length>0&&(!T||J(p,"USE"))},[p,J,x,T]),V=f=>{C({kind:"test",schedule:f}),k(Me({name:f.name,task:f.task,cron:f.cron,timezone:f.timezone})),i(f.agentId)},X=async f=>{if(f.preventDefault(),!le)return;const v=Se(x);q(!0),_(null);try{if(N&&a!=null){await S.updateSchedule({id:a.id,name:x.name.trim(),task:x.task.trim(),cron:v,timezone:x.timezone,status:a.status}),j(Q.Schedule.EDITED,{schedule_id:a.id,agent_id:a.agentId}),u==null||u(),n(!1);return}if(O&&m.kind==="form"&&m.saved!=null){const I=await S.updateSchedule({id:m.saved.id,name:x.name.trim(),task:x.task.trim(),cron:v,timezone:x.timezone,status:"paused"});j(Q.Schedule.EDITED,{schedule_id:I.id,agent_id:I.agentId}),u==null||u(),V(I),h==null||h.showSuccess({title:"Schedule saved as paused",description:ce({cron:I.cron,timezone:I.timezone})});return}const w=await S.createSchedule({agentId:p,name:x.name.trim(),task:x.task.trim(),cron:v,timezone:x.timezone,status:"paused"});j(Q.Schedule.CREATED,{schedule_id:w.id,agent_id:p}),u==null||u(),V(w),h==null||h.showSuccess({title:"Schedule saved as paused",description:ce({cron:w.cron,timezone:w.timezone})})}catch(w){const I=w instanceof Error?w.message:"Failed to save schedule";_(I)}finally{q(!1)}},ee=async()=>{if(m.kind==="test"){Y(!0),_(null);try{await S.updateSchedule({id:m.schedule.id,name:m.schedule.name,task:m.schedule.task,cron:m.schedule.cron,timezone:m.schedule.timezone,status:"active"}),u==null||u(),h==null||h.showSuccess({title:"Schedule activated"}),n(!1)}catch(f){const v=f instanceof Error?f.message:"Failed to activate schedule";_(v),h==null||h.showError(f)}finally{Y(!1)}}},te=m.kind==="test"?"Test Schedule":N||O?"Edit Schedule":"New Schedule",M=m.kind==="test"?`Recurring unattended runs of ${G}.`:N||O?"Update cadence and task for this schedule.":"Create a recurring unattended run for an agent.";let se;return m.kind==="test"?se=e.jsxs("div",{className:"flex flex-col gap-2",children:[A!=null?e.jsx("p",{className:"text-failure-bg text-sm",children:A}):null,e.jsx($.Secondary,{type:"button",className:"w-full",disabled:re,onClick:()=>void ee(),children:"Activate Schedule"})]}):se=e.jsxs("div",{className:"flex flex-col gap-2",children:[A!=null?e.jsx("p",{className:"text-failure-bg text-sm",children:A}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx($.Secondary,{type:"button",onClick:()=>n(!1),disabled:U,children:"Cancel"}),e.jsx($.Primary,{type:"submit",form:"schedule-form",disabled:!le||U,children:"Save"})]})]}),e.jsx(Rt,{open:t,onOpenChange:n,title:te,description:M,anchor:"right",size:"xl",headerIcon:e.jsx("span",{className:"text-primary-button-bg inline-flex size-8 items-center justify-center",children:e.jsx(R,{name:m.kind==="test"||N||O?"calendar":"calendar-plus",className:"size-5"})}),footer:se,children:m.kind==="test"?e.jsx(Jt,{schedule:m.schedule,agentName:G,mcpMounts:ge,onEditConfiguration:()=>{_(null),C({kind:"form",saved:m.schedule})}}):e.jsx("form",{id:"schedule-form",onSubmit:f=>void X(f),children:e.jsx(Ht,{values:x,onChange:k,agentId:p,agentLabel:G,onAgentIdChange:N||O?void 0:f=>{i(f),f.length===0&&z(null)},onAgentPicked:z,agentPickerDisabled:N||O,onBuildAgent:r==="create"&&(d==null?void 0:d.isComposerEnabled)===!0?()=>{n(!1),d.openAgentBuilder()}:void 0})})})}function $e(t){return e.jsx(Et,{children:e.jsx(Xt,{...t})})}function es({runs:t,onOpenSession:n}){const r=Wt(t);return r.length===0?e.jsx("span",{className:"text-text-secondary text-sm",children:"—"}):e.jsx("div",{className:"flex items-center gap-1",children:r.map(a=>e.jsx(Xe,{run:a,...n==null?{}:{onOpenSession:n}},a.id))})}var ts=[{value:"all",label:"All statuses"},{value:"active",label:"Active"},{value:"paused",label:"Paused"}],Be=[10,25];function he(t){return Math.min(Math.max(t,1),25)}function oe(t){const n=Ee(t);return{nameQuery:n.q??"",statusFilter:n.status??"all",agentFilter:n.agent??"all",scheduleId:n.scheduleId}}function ss(t){const n=Ee(window.location.search);if(!n.isNew)return{kind:"closed"};const r=t??n.agent;return{kind:"create",...r==null?{}:{agentId:r}}}function ns({schedule:t,running:n,canManage:r,canDelete:a,onRunNow:l,onEdit:u,onTogglePause:S,onDelete:b}){const d=kt("PermissionGuard");return e.jsxs("div",{className:"inline-flex items-center justify-end gap-1.5",children:[e.jsx(d,{allowed:r,children:e.jsxs($.Secondary,{type:"button",disabled:n,"aria-label":`Run now ${t.name}`,size:"large",onClick:l,children:[e.jsx(R,{name:n?"loader":"play",className:B("size-3.5",n&&"animate-spin")}),"Run now"]})}),e.jsxs(Tt,{align:"end",trigger:e.jsx("button",{type:"button",className:Ct({variant:"ghost",size:"icon"}),"aria-label":`Actions for ${t.name}`,children:e.jsx(R,{name:"ellipsis"})}),children:[e.jsx(d,{allowed:r,children:e.jsxs(je,{onClick:u,children:[e.jsx(R,{name:"pencil",className:"size-3.5"}),"Edit"]})}),e.jsx(d,{allowed:r,children:e.jsxs(je,{onClick:S,children:[e.jsx(R,{name:t.status==="active"?"pause":"play",className:"size-3.5"}),t.status==="active"?"Pause":"Resume"]})}),e.jsx(d,{allowed:a,children:e.jsxs(je,{className:"text-failure-bg focus:text-failure-bg",onClick:b,children:[e.jsx(R,{name:"trash",className:"size-3.5"}),"Delete"]})})]})]})}function ls({agentId:t}){const n=Te(),r=Ue(),a=Ce(),l=Ge(),u=He(),S=lt(),b=u!=null&&vt({sessions:S}),[d,h]=o.useState([]),{allows:j}=ve({resourceType:"schedule",resourceIds:d.map(s=>s.id)}),[x,k]=o.useState({}),[p,i]=o.useState(!1),[y,z]=o.useState(()=>new Set),[m,C]=o.useState({}),[U,q]=o.useState(!0),[re,Y]=o.useState(null),[A,_]=o.useState(()=>oe(window.location.search).nameQuery),[L,Z]=o.useState(()=>oe(window.location.search).statusFilter),[N,O]=o.useState(()=>t??oe(window.location.search).agentFilter),[T,J]=o.useState(()=>oe(window.location.search).scheduleId),G=t??(N==="all"?null:N),{allows:ge}=ve({resourceType:"agent",resourceIds:G==null?[]:[G]}),le=r.permissions==null||G==null||ge(G,"USE"),[V,X]=o.useState(()=>ss(t)),[ee,te]=o.useState(null),[M,se]=o.useState(()=>he(yt)),[f,v]=o.useState(void 0),[w,I]=o.useState(void 0),[ne,P]=o.useState(void 0),tt=({run:s,schedule:c})=>{if(!b||u==null||s.sessionId==null)return;l(Q.Schedule.RUN_SESSION_OPENED,{schedule_id:c.id,agent_id:c.agentId});const g=St(s.triggeredAt??s.scheduledFor);wt({sessionId:s.sessionId,view:"sessions",...g==null?{}:{timeRange:g}}),u.setSessionsOpen(!0)},H=o.useRef(0),ze=o.useRef(!1),be=o.useCallback(async({rows:s,gen:c})=>{if(s.length===0){c===H.current&&k({});return}i(!0);try{const g=await Promise.allSettled(s.map(E=>n.listScheduleRuns({scheduleId:E.id})));if(c!==H.current)return;k(Object.fromEntries(s.map((E,D)=>{const F=g[D],ue=(F==null?void 0:F.status)==="fulfilled"?F.value:[];return[E.id,ue]})))}finally{c===H.current&&i(!1)}},[n]),ae=o.useCallback(async({token:s,size:c,agentId:g,pinnedScheduleId:E})=>{const D=++H.current;q(!0),Y(null);try{if(E!=null){const ue=await n.getSchedule({id:E});if(D!==H.current)return;h([ue]),I(void 0),P(void 0),be({rows:[ue],gen:D});return}const F=await n.listSchedules({limit:he(c),...s===void 0||s===""?{}:{pageToken:s},...g==="all"?{}:{agentIds:[g]}});if(D!==H.current)return;h(F.data),I(F.nextPageToken),P(F.previousPageToken),be({rows:F.data,gen:D})}catch(F){if(D!==H.current)return;Y(it(F,"Check your connection and try again.")),h([]),k({}),I(void 0),P(void 0)}finally{D===H.current&&q(!1)}},[n,be]),Ae=o.useCallback(s=>{const c=(s==null?void 0:s.size)??M,g=(s==null?void 0:s.agentId)??N;J(null),v(void 0),P(void 0),ae({token:void 0,size:c,agentId:g,pinnedScheduleId:null})},[N,ae,M]);o.useEffect(()=>{Fe({agent:t===void 0&&N!=="all"?N:null,status:L==="all"?null:L,q:A.trim().length===0?null:A,scheduleId:T})},[N,t,L,A,T]),o.useEffect(()=>{t!==void 0&&O(s=>s===t?s:(v(void 0),P(void 0),t))},[t]),o.useEffect(()=>{ze.current||!Ee(window.location.search).isNew||(ze.current=!0,Fe({isNew:null}))},[]),o.useEffect(()=>{const s=()=>{const c=oe(window.location.search);_(c.nameQuery),Z(c.statusFilter),J(g=>g===c.scheduleId?g:(v(void 0),P(void 0),c.scheduleId)),O(g=>{const E=t??c.agentFilter;return g===E?g:(v(void 0),P(void 0),E)})};return window.addEventListener("popstate",s),()=>{window.removeEventListener("popstate",s)}},[t]),o.useEffect(()=>{ae({token:f,size:M,agentId:N,pinnedScheduleId:T})},[N,M,f,ae,T]),o.useEffect(()=>{if(T==null||A.trim().length>0)return;const s=d.find(c=>c.id===T);s!=null&&_(s.name)},[A,T,d]);const de=o.useMemo(()=>{if(T!=null)return d;const s=A.trim().toLowerCase();return d.filter(c=>!(L!=="all"&&c.status!==L||s.length>0&&!c.name.toLowerCase().includes(s)))},[d,A,L,T]),Re=ot(d),Ie=ne!=null||w!=null,st=async s=>{if(!j(s.id,"MANAGE"))return;const c=s.status==="active"?"paused":"active";try{await n.updateSchedule({...s,status:c}),l(Q.Schedule.TOGGLED,{schedule_id:s.id,agent_id:s.agentId,next_status:c}),await ae({token:f,size:M,agentId:N,pinnedScheduleId:T})}catch(g){a==null||a.showError(g)}},nt=async s=>{if(j(s.id,"MANAGE")){z(c=>new Set(c).add(s.id));try{if(await n.createScheduleRun({scheduleId:s.id}),l(Q.Schedule.RUN_NOW,{schedule_id:s.id,agent_id:s.agentId}),a==null||a.showSuccess({title:"Run started"}),T!=null){const g=await n.getSchedule({id:T});h(E=>{const D=E.length===1?E[0]:void 0;return D!=null&&D.id===g.id?[g]:E})}const c=await n.listScheduleRuns({scheduleId:s.id});k(g=>({...g,[s.id]:c}))}catch(c){a==null||a.showError(c)}finally{z(c=>{const g=new Set(c);return g.delete(s.id),g})}}},at=async s=>{if(j(s.id,"DELETE")){te(null);try{await n.deleteSchedule({id:s.id}),l(Q.Schedule.DELETED,{schedule_id:s.id,agent_id:s.agentId}),Ae()}catch(c){a==null||a.showError(c)}}},Pe=()=>{w!=null&&v(w)},De=()=>{ne==null||ne===""||v(ne)},pe=()=>{T!=null&&(J(null),v(void 0),P(void 0))};return e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-primary-bg",children:[e.jsx(ct,{title:t===void 0?"Agent Schedules":void 0,end:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-full sm:w-60",children:e.jsx(dt,{query:A,setQuery:s=>{_(s),pe()},placeholder:"Search schedules by name"})}),e.jsx(xe,{value:L,onValueChange:s=>{Z(s),pe()},options:ts,className:"sm:w-40","aria-label":"Filter by status"}),t===void 0?e.jsx(qe,{value:N,selectedLabel:N==="all"?"All agents":m[N]??N,onValueChange:s=>{O(s),v(void 0),P(void 0),pe()},onAgentPicked:s=>{C(c=>({...c,[Ve(s)]:s.name}))},allOption:{value:"all",label:"All agents"},className:"sm:w-48","aria-label":"Filter by agent",placeholder:"Search agent"}):null,e.jsxs($.Primary,{type:"button",disabled:!le,onClick:()=>le&&X({kind:"create",agentId:N!=="all"?N:void 0}),children:[e.jsx(R,{name:"plus",className:"size-3.5"}),"New Schedule"]})]})}),e.jsx("div",{className:B("min-h-0 flex-1 overflow-auto px-4 py-4",re!=null?"flex flex-col":void 0),children:U?e.jsx("div",{className:"flex flex-col gap-2",role:"status","aria-label":"Loading schedules",children:Array.from({length:5},(s,c)=>e.jsx(ut,{className:"h-12 w-full rounded-md"},c))}):re!=null?e.jsx("div",{role:"alert",className:"flex flex-1 flex-col items-center justify-center",children:e.jsx(Ne,{title:"Couldn't load schedules",description:re,className:"h-auto min-h-0 flex-none py-0"})}):d.length===0?e.jsx(Ne,{title:"No Schedules Found",description:"Create one to get started.",className:"min-h-full"}):de.length===0?e.jsxs("div",{className:"flex min-h-full flex-col",children:[e.jsx(Ne,{title:"No Schedules Found",description:"No schedules match your filters.",className:"flex-1"}),Ie?e.jsx(_e,{pageSize:M,rowCount:0,canPrev:ne!=null,canNext:w!=null,onPrev:De,onNext:Pe,pageSizeOptions:Be,onPageSizeChange:s=>{const c=he(s);se(c),v(void 0),P(void 0)}}):null]}):e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border",children:[e.jsxs(mt,{className:"min-w-240",children:[e.jsx(ht,{children:e.jsxs(Le,{className:"hover:bg-transparent",children:[e.jsx(W,{children:"Schedule Name"}),e.jsx(W,{children:"Task"}),Re?e.jsx(W,{children:"Created by"}):null,e.jsx(W,{children:"Frequency"}),e.jsx(W,{children:"Status"}),e.jsx(W,{children:"Last 5 runs"}),e.jsx(W,{children:e.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e.jsx(xt,{children:de.map(s=>{const c=ce({cron:s.cron,timezone:s.timezone}),g=s.agentName??m[s.agentId]??s.agentId;return e.jsxs(Le,{children:[e.jsxs(K,{className:"w-48 max-w-48",children:[e.jsx("span",{className:"text-text-primary block truncate font-medium",children:s.name}),e.jsxs("span",{className:"mt-1 flex min-w-0 items-center gap-1 text-xs",children:[e.jsx(R,{name:"agent-2",className:"size-3 shrink-0"}),e.jsx("span",{className:"truncate",children:g})]})]}),e.jsx(K,{className:"w-64 max-w-64",children:e.jsx(We,{content:s.task,className:"max-w-sm whitespace-normal text-left",triggerClassName:"block min-w-0 w-full max-w-full",children:e.jsx("span",{className:"block truncate",children:s.task})})}),Re?e.jsx(K,{children:e.jsx(ft,{subject:s.createdBySubject})}):null,e.jsx(K,{children:c}),e.jsx(K,{children:e.jsx(et,{status:s.status})}),e.jsx(K,{children:p?e.jsx("span",{className:"text-text-secondary text-sm",children:"…"}):e.jsx(es,{runs:x[s.id]??[],...b?{onOpenSession:E=>tt({run:E,schedule:s})}:{}})}),e.jsx(K,{className:"text-right",children:e.jsx(ns,{schedule:s,running:y.has(s.id),canManage:j(s.id,"MANAGE"),canDelete:j(s.id,"DELETE"),onRunNow:()=>void nt(s),onEdit:()=>{j(s.id,"MANAGE")&&X({kind:"edit",schedule:s})},onTogglePause:()=>void st(s),onDelete:()=>{j(s.id,"DELETE")&&te(s)}})})]},s.id)})})]}),(de.length>0||Ie)&&e.jsx(_e,{pageSize:M,rowCount:de.length,canPrev:ne!=null,canNext:w!=null,onPrev:De,onNext:Pe,pageSizeOptions:Be,onPageSizeChange:s=>{const c=he(s);se(c),v(void 0),P(void 0)}})]})}),V.kind==="create"?e.jsx($e,{open:!0,mode:"create",initialAgentId:V.agentId??"",onOpenChange:s=>{s||X({kind:"closed"})},onSaved:()=>Ae()}):null,V.kind==="edit"?e.jsx($e,{open:!0,mode:"edit",schedule:V.schedule,onOpenChange:s=>{s||X({kind:"closed"})},onSaved:()=>void ae({token:f,size:M,agentId:N,pinnedScheduleId:T})}):null,ee!=null?e.jsxs(gt,{open:!0,onOpenChange:s=>{s||te(null)},"aria-label":"Delete schedule",className:"max-w-md",children:[e.jsx(bt,{children:e.jsxs(pt,{children:[e.jsx(Nt,{children:"Delete schedule"}),e.jsxs("p",{className:"text-text-secondary text-sm",children:["“",ee.name,"” will stop running. This cannot be undone."]})]})}),e.jsxs(jt,{children:[e.jsx($.Secondary,{type:"button",onClick:()=>te(null),children:"Cancel"}),e.jsx($.Destructive,{type:"button",disabled:!j(ee.id,"DELETE"),onClick:()=>void at(ee),children:"Delete"})]})]}):null]})}export{ls as SchedulesPage};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ModelSettings-JQ57P7UZ-CLJFh7hP.js","./chunk-2L7W3OHQ-BC-N5kEf.js","./index-BOPxame4.js","./index-B01pXqvC.css","./ConnectorSettings-PYELU62E-IonCdccY.js","./SkillSettings-EDNAAMP6-DU5CIdrG.js","./SandboxSettings-6DIQUD2C-222OAKeC.js","./WebSearchSettings-5SXM5JCV-DQLdgrLM.js"])))=>i.map(i=>d[i]);
2
- import{b9 as N,ab as O,bl as D,b as L,bm as P,q as I,a9 as A,bn as T,b1 as z,r as l,_,bo as M,j as s,P as R,I as S,a3 as B,c as x,bp as V,b6 as c,b4 as W}from"./index-BOPxame4.js";var H=l.lazy(()=>c(()=>import("./ModelSettings-JQ57P7UZ-CLJFh7hP.js"),__vite__mapDeps([0,1,2,3]),import.meta.url)),q=l.lazy(()=>c(()=>import("./ConnectorSettings-PYELU62E-IonCdccY.js"),__vite__mapDeps([4,1,2,3]),import.meta.url)),F=l.lazy(()=>c(()=>import("./SkillSettings-EDNAAMP6-DU5CIdrG.js"),__vite__mapDeps([5,1,2,3]),import.meta.url)),G=l.lazy(()=>c(()=>import("./SandboxSettings-6DIQUD2C-222OAKeC.js"),__vite__mapDeps([6,1,2,3]),import.meta.url)),K=l.lazy(()=>c(()=>import("./WebSearchSettings-5SXM5JCV-DQLdgrLM.js"),__vite__mapDeps([7,2,3]),import.meta.url));function J(){return s.jsxs("div",{className:"flex flex-1 items-center justify-center py-8",role:"status","aria-live":"polite","aria-busy":"true",children:[s.jsx(W,{size:20,className:"text-text-secondary"}),s.jsx("span",{className:"sr-only",children:"Loading"})]})}var Q=({headerStart:j}={})=>{var w;const{settingsOpen:n,settingsSection:i,setSettingsOpen:r}=N(),a=O(),E=D(),p=(w=L())==null?void 0:w.settings,u=P(),f=I(),{refresh:h}=A(),k=T(),C=z(),o=k||C,g=(a==null?void 0:a.skillCatalog)!=null,y=(a==null?void 0:a.sandboxCatalog)!=null,v=(a==null?void 0:a.webSearchCatalog)!=null||E!=null,m=l.useCallback(()=>{f(_.Settings.CLOSED,{section:i}),r(!1)},[i,r,f]);l.useEffect(()=>{if(n)return()=>{h(),u==null||u()}},[n,h,u]),l.useEffect(()=>{if(!n)return;const e=b=>{b.key==="Escape"&&(V()||(b.stopImmediatePropagation(),m()))};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[m,n]);const d=l.useMemo(()=>{const e=[{id:"models",label:"Models",icon:"cpu",capability:"modelProviders"},{id:"connectors",label:"Connectors",icon:"plug",capability:"mcpServers"}];return g&&e.push({id:"skills",label:"Skills",icon:"lightbulb",capability:"skills"}),y&&e.push({id:"sandbox",label:"Sandbox providers",icon:"cube",capability:"sandboxProviders"}),v&&e.push({id:"web-search",label:"Web search",icon:"search",capability:"webSearch"}),e.filter(b=>M({settings:p,section:b.capability}))},[g,y,v,p]),t=d.find(e=>e.id===i);return l.useEffect(()=>{const e=d[0];t!==void 0||e===void 0||r(n,e.id)},[t,d,n,r]),!n||!a?null:s.jsxs("div",{className:"flex h-full min-h-0 w-full min-w-0 flex-col overflow-x-hidden bg-primary-bg",children:[s.jsx(R,{title:"Settings",start:j??s.jsx("button",{type:"button","aria-label":"Back",title:"Back",className:B({variant:"ghost",size:"icon"}),onClick:m,children:s.jsx(S,{name:"arrow-left"})})}),s.jsxs("div",{className:x("flex min-h-0 min-w-0 flex-1 flex-col",!o&&"md:flex-row"),children:[s.jsx("nav",{"aria-label":"Settings sections",className:x("flex w-full min-w-0 gap-1 border-b border-border bg-secondary-bg/40 p-2",o?"overflow-x-auto":"justify-center md:w-48 md:flex-col md:justify-start md:border-b-0 md:border-r"),children:d.map(e=>s.jsxs("button",{type:"button","aria-current":i===e.id?"page":void 0,...o?{title:e.label}:{},className:x("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",o?"min-w-0 flex-1 justify-center gap-1.5 px-1.5":"shrink-0",i===e.id?"bg-primary-button-bg/10 text-primary-button-bg":"text-text-secondary hover:bg-ghost-button-hover/60 hover:text-text-primary"),onClick:()=>{f(_.Settings.SECTION_CHANGED,{section:e.id}),r(!0,e.id)},children:[s.jsx(S,{name:e.icon,className:"h-4 w-4 shrink-0"}),o?s.jsx("span",{className:"truncate",children:e.label}):e.label]},e.id))}),s.jsx("section",{className:"flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden overflow-y-hidden px-4 py-4 sm:px-6",children:s.jsx("div",{className:"mx-auto flex h-full min-h-0 w-full min-w-0 max-w-210 flex-col",children:s.jsxs(l.Suspense,{fallback:s.jsx(J,{}),children:[(t==null?void 0:t.id)==="models"?s.jsx(H,{}):null,(t==null?void 0:t.id)==="connectors"?s.jsx(q,{}):null,(t==null?void 0:t.id)==="skills"?s.jsx(F,{}):null,(t==null?void 0:t.id)==="sandbox"?s.jsx(G,{}):null,(t==null?void 0:t.id)==="web-search"?s.jsx(K,{}):null]})})})]})]})},X=Q;export{X as default};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ModelSettings-JQ57P7UZ--AqoNP6X.js","./chunk-2L7W3OHQ-KYs3TW6o.js","./index-o2o-gWoN.js","./index-B01pXqvC.css","./ConnectorSettings-PYELU62E-DMbJA7AI.js","./SkillSettings-EDNAAMP6-D5QMdCsj.js","./SandboxSettings-6DIQUD2C-Dq81qn8k.js","./WebSearchSettings-5SXM5JCV-ls7UX68H.js"])))=>i.map(i=>d[i]);
2
+ import{b9 as N,ab as O,bl as D,b as L,bm as P,q as I,a9 as A,bn as T,b1 as z,r as l,_,bo as M,j as s,P as R,I as S,a3 as B,c as x,bp as V,b6 as c,b4 as W}from"./index-o2o-gWoN.js";var H=l.lazy(()=>c(()=>import("./ModelSettings-JQ57P7UZ--AqoNP6X.js"),__vite__mapDeps([0,1,2,3]),import.meta.url)),q=l.lazy(()=>c(()=>import("./ConnectorSettings-PYELU62E-DMbJA7AI.js"),__vite__mapDeps([4,1,2,3]),import.meta.url)),F=l.lazy(()=>c(()=>import("./SkillSettings-EDNAAMP6-D5QMdCsj.js"),__vite__mapDeps([5,1,2,3]),import.meta.url)),G=l.lazy(()=>c(()=>import("./SandboxSettings-6DIQUD2C-Dq81qn8k.js"),__vite__mapDeps([6,1,2,3]),import.meta.url)),K=l.lazy(()=>c(()=>import("./WebSearchSettings-5SXM5JCV-ls7UX68H.js"),__vite__mapDeps([7,2,3]),import.meta.url));function J(){return s.jsxs("div",{className:"flex flex-1 items-center justify-center py-8",role:"status","aria-live":"polite","aria-busy":"true",children:[s.jsx(W,{size:20,className:"text-text-secondary"}),s.jsx("span",{className:"sr-only",children:"Loading"})]})}var Q=({headerStart:j}={})=>{var w;const{settingsOpen:n,settingsSection:i,setSettingsOpen:r}=N(),a=O(),E=D(),p=(w=L())==null?void 0:w.settings,u=P(),f=I(),{refresh:h}=A(),k=T(),C=z(),o=k||C,g=(a==null?void 0:a.skillCatalog)!=null,y=(a==null?void 0:a.sandboxCatalog)!=null,v=(a==null?void 0:a.webSearchCatalog)!=null||E!=null,m=l.useCallback(()=>{f(_.Settings.CLOSED,{section:i}),r(!1)},[i,r,f]);l.useEffect(()=>{if(n)return()=>{h(),u==null||u()}},[n,h,u]),l.useEffect(()=>{if(!n)return;const e=b=>{b.key==="Escape"&&(V()||(b.stopImmediatePropagation(),m()))};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[m,n]);const d=l.useMemo(()=>{const e=[{id:"models",label:"Models",icon:"cpu",capability:"modelProviders"},{id:"connectors",label:"Connectors",icon:"plug",capability:"mcpServers"}];return g&&e.push({id:"skills",label:"Skills",icon:"lightbulb",capability:"skills"}),y&&e.push({id:"sandbox",label:"Sandbox providers",icon:"cube",capability:"sandboxProviders"}),v&&e.push({id:"web-search",label:"Web search",icon:"search",capability:"webSearch"}),e.filter(b=>M({settings:p,section:b.capability}))},[g,y,v,p]),t=d.find(e=>e.id===i);return l.useEffect(()=>{const e=d[0];t!==void 0||e===void 0||r(n,e.id)},[t,d,n,r]),!n||!a?null:s.jsxs("div",{className:"flex h-full min-h-0 w-full min-w-0 flex-col overflow-x-hidden bg-primary-bg",children:[s.jsx(R,{title:"Settings",start:j??s.jsx("button",{type:"button","aria-label":"Back",title:"Back",className:B({variant:"ghost",size:"icon"}),onClick:m,children:s.jsx(S,{name:"arrow-left"})})}),s.jsxs("div",{className:x("flex min-h-0 min-w-0 flex-1 flex-col",!o&&"md:flex-row"),children:[s.jsx("nav",{"aria-label":"Settings sections",className:x("flex w-full min-w-0 gap-1 border-b border-border bg-secondary-bg/40 p-2",o?"overflow-x-auto":"justify-center md:w-48 md:flex-col md:justify-start md:border-b-0 md:border-r"),children:d.map(e=>s.jsxs("button",{type:"button","aria-current":i===e.id?"page":void 0,...o?{title:e.label}:{},className:x("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",o?"min-w-0 flex-1 justify-center gap-1.5 px-1.5":"shrink-0",i===e.id?"bg-primary-button-bg/10 text-primary-button-bg":"text-text-secondary hover:bg-ghost-button-hover/60 hover:text-text-primary"),onClick:()=>{f(_.Settings.SECTION_CHANGED,{section:e.id}),r(!0,e.id)},children:[s.jsx(S,{name:e.icon,className:"h-4 w-4 shrink-0"}),o?s.jsx("span",{className:"truncate",children:e.label}):e.label]},e.id))}),s.jsx("section",{className:"flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden overflow-y-hidden px-4 py-4 sm:px-6",children:s.jsx("div",{className:"mx-auto flex h-full min-h-0 w-full min-w-0 max-w-210 flex-col",children:s.jsxs(l.Suspense,{fallback:s.jsx(J,{}),children:[(t==null?void 0:t.id)==="models"?s.jsx(H,{}):null,(t==null?void 0:t.id)==="connectors"?s.jsx(q,{}):null,(t==null?void 0:t.id)==="skills"?s.jsx(F,{}):null,(t==null?void 0:t.id)==="sandbox"?s.jsx(G,{}):null,(t==null?void 0:t.id)==="web-search"?s.jsx(K,{}):null]})})})]})]})},X=Q;export{X as default};
@@ -1 +1 @@
1
- import{b9 as ce,d as pe,ab as ge,v as fe,ba as ye,bb as he,bc as de,b as me,bd as Se,r as a,be,bf as Ae,x as Oe,bg as ve,D as Ne,bh as _,bi as C,bj as ne,bk as B}from"./index-BOPxame4.js";import{u as Re,a as Ee}from"./chunk-OB3PAWPO-kbiWSc01.js";var T="try_agent_name",$="history_agent_name";function te(t){return t!=null&&t.length>0?t:null}function k(t){const o=new URLSearchParams(t.startsWith("?")?t.slice(1):t),u=te(o.get(T));if(u!=null)return{intent:"try-agent",agentName:u};const e=te(o.get($));return e==null?null:{intent:"history",agentName:e}}function Pe(t,o){t.delete(T),t.delete($),o!=null&&t.set(o.intent==="try-agent"?T:$,o.agentName)}function se(t,o){const u=new URLSearchParams(t.startsWith("?")?t.slice(1):t);Pe(u,o);const e=u.toString();return e.length>0?`?${e}`:""}function re(t){const o=t.sessionAccessError!=null?t.pendingSessionId:t.activeRemoteId??t.pendingSessionId;if(o!=null)return{type:"session",sessionId:o};const{mode:u,agentConfigMode:e}=t;if(u.status==="active"&&u.isMutable&&u.isCreateAgent)return{type:"buildAgent"};if(u.status==="active"&&!u.isMutable&&e!=="SingleAgent"){const p=u.agentName??u.agentId;if(p!=null)return{type:"agent",agentName:p}}return{type:"root"}}function Ce(t){return t.settingsOpen?{type:"settings"}:t.schedulesOpen?{type:"schedules"}:t.environmentsOpen?{type:"environments"}:t.sessionsOpen&&t.sharedSessionId!=null?{type:"sharedSession",sessionId:t.sharedSessionId}:t.sessionsOpen?{type:"sessionsBrowser"}:t.libraryOpen&&t.libraryAgentId!=null?{type:"libraryAgent",agentId:t.libraryAgentId}:t.libraryOpen?{type:"library"}:re(t)}function O(t){return t.type==="root"||t.type==="agent"||t.type==="session"}function Ie(t){return t.type==="sessionsBrowser"||t.type==="sharedSession"}function Le({routes:t,activeRemoteId:o,initialSettingsOpen:u}){var Z,x;const e=ce(),p=pe(),q=ge(),v=fe(),I=ye(),U=he(),G=de(),K=me(),W=Se(),H=Re(),r=Ee(),c=a.useMemo(()=>be({routes:t,catalog:q,capabilities:K,sessions:v,schedules:U,sandboxEnvironments:G}),[t,q,K,v,U,G]),Y=c.settings!=null,ae=[c.settings,c.sessionsBrowser,c.sharedSession,c.libraryAgent,c.schedules,c.environments].join("\0"),j={settingsOpen:e.settingsOpen,libraryOpen:e.libraryOpen,sessionsOpen:e.sessionsOpen,sharedSessionId:e.sharedSessionId,libraryAgentId:e.libraryAgentId,schedulesOpen:e.schedulesOpen,environmentsOpen:e.environmentsOpen,pendingSessionId:e.pendingSessionId,activeRemoteId:o,sessionAccessError:e.sessionAccessError,mode:e.mode,agentConfigMode:e.agentConfigMode},g=Ce(j),ie=JSON.stringify(g),S=a.useRef(null),w=a.useRef(null),N=a.useRef(null),R=a.useRef(!1),b=a.useRef(null),[le,oe]=a.useState(0),m=a.useRef(null),L=a.useRef(null),D=`${e.runtimeKey}\0${e.pendingSessionEpoch}`,M=a.useRef(D);M.current=D;const f=a.useRef(null),Q=a.useRef(!1),z=a.useRef(!1),J=a.useCallback(()=>{switch(e.setSettingsOpen(!1),e.setLibraryOpen(!1),e.setSchedulesOpen(!1),e.setEnvironmentsOpen(!1),e.agentConfigMode){case"AgentLibrary":e.openLibraryHome();return;case"AgentComposer":case"AgentLibraryWithComposer":e.openDraft();return;case"SingleAgent":e.clearChat();return}},[e]),A=a.useCallback(n=>{const s=b.current;(s==null?void 0:s.type)==="session"&&s.sessionId===n&&(b.current=null,oe(l=>l+1))},[]),V=a.useCallback(n=>{if(L.current=n,p==null){e.openHistorySession({sessionId:n});return}const s=M.current,l=I==null||v==null?Promise.resolve(!0):I.listPermissions({resourceType:"session",resourceIds:[n]}).then(i=>(i.data.permissions[n]??[]).includes("MANAGE")).catch(()=>!0);Promise.all([p.getSession({sessionId:n}),l]).then(([i,y])=>{if(L.current!==n){A(n);return}if(!y){A(n),e.openSharedSession(n);return}e.openHistorySession({sessionId:n,isMutable:i.isMutable,isCreateAgent:Ae(i),...i.agentName!=null?{agentName:i.agentName}:{}})}).catch(i=>{if(L.current!==n){A(n);return}if(M.current!==s){A(n);return}e.openInaccessibleSession({sessionId:n,message:Oe(i,"This session could not be loaded.")})})},[I,A,p,v,e]),d=a.useCallback(n=>{if(n==null){f.current=null,m.current=null,e.setHistoryAgentFilter(null);return}const s=`${n.intent}\0${n.agentName}`,l=e.historyAgentFilter;if((l==null?void 0:l.intent)===n.intent&&l.agentName===n.agentName&&l.agentId!=null){f.current=null;return}f.current=s,e.setHistoryAgentFilter(n),p!=null&&ve({server:p,agentName:n.agentName}).then(i=>{if(f.current===s){if(i==null){f.current=null,m.current=null,e.setHistoryAgentFilter(null);return}f.current=null,e.setHistoryAgentFilter({agentId:Ne(i),agentName:i.name,intent:n.intent})}}).catch(()=>{f.current===s&&(f.current=null,m.current=null,e.setHistoryAgentFilter(null))})},[p,e]),X=a.useCallback(n=>{e.selectLibraryAgent({isMutable:!1,agentName:n}),d({intent:"try-agent",agentName:n})},[d,e]),F=a.useCallback(n=>{switch(n.type){case"settings":e.setSettingsOpen(!0);return;case"library":e.setLibraryOpen(!0);return;case"sessionsBrowser":e.setSessionsOpen(!0);return;case"sharedSession":e.openSharedSession(n.sessionId);return;case"libraryAgent":e.openLibraryAgent(n.agentId);return;case"schedules":e.setSchedulesOpen(!0);return;case"environments":e.setEnvironmentsOpen(!0);return;case"buildAgent":e.openAgentBuilder();return;case"session":if(e.setLibraryOpen(!1),e.pendingSessionId===n.sessionId||o===n.sessionId)return;V(n.sessionId);return;case"agent":e.setLibraryOpen(!1),X(n.agentName);return;case"root":J();return}},[e,o,J,X,V]);return a.useEffect(()=>{if(R.current)return;const n=_({pathname:r.pathname,search:r.search,routes:t});if(!W&&(n==null?void 0:n.type)==="settings")return;R.current=!0;const s=_({pathname:r.pathname,search:r.search,routes:c})??{type:"root"},l=s.type==="agent"?{intent:"try-agent",agentName:s.agentName}:O(s)?k(r.search):null;m.current=l,N.current=s;const i=Y&&(u||s.type==="settings");if(s.type==="settings")Y&&e.setSettingsOpen(!0);else if(s.type==="library")e.setLibraryOpen(!0);else if(s.type==="sessionsBrowser")e.setSessionsOpen(!0);else if(s.type==="libraryAgent")e.openLibraryAgent(s.agentId);else if(s.type==="schedules")e.setSchedulesOpen(!0);else if(s.type==="environments")e.setEnvironmentsOpen(!0);else{const P=re(j);C(P,s)||F(s),i&&e.setSettingsOpen(!0)}s.type!=="agent"&&l!=null?d(l):O(s)||d(null);const y=i?{type:"settings"}:s;b.current=C(g,y)?null:y;const h=ne(y,c),E=se(B(y,r.search),l);w.current=y,h!=null&&(h!==r.pathname||E!==r.search)&&(S.current=h!==r.pathname?h:null,H({pathname:h,search:E,hash:r.hash},{replace:!0}))},[W]),a.useEffect(()=>{if(!R.current)return;if(!Q.current){Q.current=!0;return}const n=b.current;if(n!=null){if(!C(g,n))return;b.current=null}const s=ne(g,c);if(s==null)return;const i=`${c.basename.endsWith("/")?c.basename.slice(0,-1):c.basename}${r.pathname}`||"/",y=window.location.pathname===i?window.location.search:r.search,h=O(g),E=h?e.historyAgentFilter==null?m.current:{intent:e.historyAgentFilter.intent,agentName:e.historyAgentFilter.agentName}:null;!h&&e.historyAgentFilter!=null&&(f.current=null,e.setHistoryAgentFilter(null)),e.historyAgentFilter!=null&&(m.current=null);const P=se(B(g,y),E),ee=w.current;if(w.current=g,s===r.pathname&&P===r.search)return;const ue=g.type==="session"&&e.pendingSessionId==null&&ee!=null&&ee.type!=="session";S.current=s!==r.pathname?s:null,H({pathname:s,search:P,hash:r.hash},{replace:ue})},[ie,ae,le,(Z=e.historyAgentFilter)==null?void 0:Z.agentName,(x=e.historyAgentFilter)==null?void 0:x.intent]),a.useEffect(()=>{if(!R.current)return;if(!z.current){z.current=!0;return}if(S.current===r.pathname){S.current=null,N.current=g;return}const n=_({pathname:r.pathname,search:r.search,routes:c});if(n==null){const l=c.root,i=B({type:"root"},r.search);S.current=l,H({pathname:l,search:i,hash:r.hash},{replace:!0}),F({type:"root"}),d(k(i));return}const s=N.current;N.current=n,(s==null||!C(s,n))&&(n.type!=="settings"&&e.settingsOpen&&e.setSettingsOpen(!1),n.type!=="library"&&n.type!=="libraryAgent"&&e.libraryOpen&&e.setLibraryOpen(!1),!Ie(n)&&e.sessionsOpen&&e.setSessionsOpen(!1),n.type!=="schedules"&&e.schedulesOpen&&e.setSchedulesOpen(!1),n.type!=="environments"&&e.environmentsOpen&&e.setEnvironmentsOpen(!1),F(n)),n.type!=="agent"&&O(n)?d(k(r.search)):O(n)||d(null)},[r.pathname,r.search]),null}export{Le as ShellRouteSync};
1
+ import{b9 as ce,d as pe,ab as ge,v as fe,ba as ye,bb as he,bc as de,b as me,bd as Se,r as a,be,bf as Ae,x as Oe,bg as ve,D as Ne,bh as _,bi as C,bj as ne,bk as B}from"./index-o2o-gWoN.js";import{u as Re,a as Ee}from"./chunk-OB3PAWPO-DN1Qz_zd.js";var T="try_agent_name",$="history_agent_name";function te(t){return t!=null&&t.length>0?t:null}function k(t){const o=new URLSearchParams(t.startsWith("?")?t.slice(1):t),u=te(o.get(T));if(u!=null)return{intent:"try-agent",agentName:u};const e=te(o.get($));return e==null?null:{intent:"history",agentName:e}}function Pe(t,o){t.delete(T),t.delete($),o!=null&&t.set(o.intent==="try-agent"?T:$,o.agentName)}function se(t,o){const u=new URLSearchParams(t.startsWith("?")?t.slice(1):t);Pe(u,o);const e=u.toString();return e.length>0?`?${e}`:""}function re(t){const o=t.sessionAccessError!=null?t.pendingSessionId:t.activeRemoteId??t.pendingSessionId;if(o!=null)return{type:"session",sessionId:o};const{mode:u,agentConfigMode:e}=t;if(u.status==="active"&&u.isMutable&&u.isCreateAgent)return{type:"buildAgent"};if(u.status==="active"&&!u.isMutable&&e!=="SingleAgent"){const p=u.agentName??u.agentId;if(p!=null)return{type:"agent",agentName:p}}return{type:"root"}}function Ce(t){return t.settingsOpen?{type:"settings"}:t.schedulesOpen?{type:"schedules"}:t.environmentsOpen?{type:"environments"}:t.sessionsOpen&&t.sharedSessionId!=null?{type:"sharedSession",sessionId:t.sharedSessionId}:t.sessionsOpen?{type:"sessionsBrowser"}:t.libraryOpen&&t.libraryAgentId!=null?{type:"libraryAgent",agentId:t.libraryAgentId}:t.libraryOpen?{type:"library"}:re(t)}function O(t){return t.type==="root"||t.type==="agent"||t.type==="session"}function Ie(t){return t.type==="sessionsBrowser"||t.type==="sharedSession"}function Le({routes:t,activeRemoteId:o,initialSettingsOpen:u}){var Z,x;const e=ce(),p=pe(),q=ge(),v=fe(),I=ye(),U=he(),G=de(),K=me(),W=Se(),H=Re(),r=Ee(),c=a.useMemo(()=>be({routes:t,catalog:q,capabilities:K,sessions:v,schedules:U,sandboxEnvironments:G}),[t,q,K,v,U,G]),Y=c.settings!=null,ae=[c.settings,c.sessionsBrowser,c.sharedSession,c.libraryAgent,c.schedules,c.environments].join("\0"),j={settingsOpen:e.settingsOpen,libraryOpen:e.libraryOpen,sessionsOpen:e.sessionsOpen,sharedSessionId:e.sharedSessionId,libraryAgentId:e.libraryAgentId,schedulesOpen:e.schedulesOpen,environmentsOpen:e.environmentsOpen,pendingSessionId:e.pendingSessionId,activeRemoteId:o,sessionAccessError:e.sessionAccessError,mode:e.mode,agentConfigMode:e.agentConfigMode},g=Ce(j),ie=JSON.stringify(g),S=a.useRef(null),w=a.useRef(null),N=a.useRef(null),R=a.useRef(!1),b=a.useRef(null),[le,oe]=a.useState(0),m=a.useRef(null),L=a.useRef(null),D=`${e.runtimeKey}\0${e.pendingSessionEpoch}`,M=a.useRef(D);M.current=D;const f=a.useRef(null),Q=a.useRef(!1),z=a.useRef(!1),J=a.useCallback(()=>{switch(e.setSettingsOpen(!1),e.setLibraryOpen(!1),e.setSchedulesOpen(!1),e.setEnvironmentsOpen(!1),e.agentConfigMode){case"AgentLibrary":e.openLibraryHome();return;case"AgentComposer":case"AgentLibraryWithComposer":e.openDraft();return;case"SingleAgent":e.clearChat();return}},[e]),A=a.useCallback(n=>{const s=b.current;(s==null?void 0:s.type)==="session"&&s.sessionId===n&&(b.current=null,oe(l=>l+1))},[]),V=a.useCallback(n=>{if(L.current=n,p==null){e.openHistorySession({sessionId:n});return}const s=M.current,l=I==null||v==null?Promise.resolve(!0):I.listPermissions({resourceType:"session",resourceIds:[n]}).then(i=>(i.data.permissions[n]??[]).includes("MANAGE")).catch(()=>!0);Promise.all([p.getSession({sessionId:n}),l]).then(([i,y])=>{if(L.current!==n){A(n);return}if(!y){A(n),e.openSharedSession(n);return}e.openHistorySession({sessionId:n,isMutable:i.isMutable,isCreateAgent:Ae(i),...i.agentName!=null?{agentName:i.agentName}:{}})}).catch(i=>{if(L.current!==n){A(n);return}if(M.current!==s){A(n);return}e.openInaccessibleSession({sessionId:n,message:Oe(i,"This session could not be loaded.")})})},[I,A,p,v,e]),d=a.useCallback(n=>{if(n==null){f.current=null,m.current=null,e.setHistoryAgentFilter(null);return}const s=`${n.intent}\0${n.agentName}`,l=e.historyAgentFilter;if((l==null?void 0:l.intent)===n.intent&&l.agentName===n.agentName&&l.agentId!=null){f.current=null;return}f.current=s,e.setHistoryAgentFilter(n),p!=null&&ve({server:p,agentName:n.agentName}).then(i=>{if(f.current===s){if(i==null){f.current=null,m.current=null,e.setHistoryAgentFilter(null);return}f.current=null,e.setHistoryAgentFilter({agentId:Ne(i),agentName:i.name,intent:n.intent})}}).catch(()=>{f.current===s&&(f.current=null,m.current=null,e.setHistoryAgentFilter(null))})},[p,e]),X=a.useCallback(n=>{e.selectLibraryAgent({isMutable:!1,agentName:n}),d({intent:"try-agent",agentName:n})},[d,e]),F=a.useCallback(n=>{switch(n.type){case"settings":e.setSettingsOpen(!0);return;case"library":e.setLibraryOpen(!0);return;case"sessionsBrowser":e.setSessionsOpen(!0);return;case"sharedSession":e.openSharedSession(n.sessionId);return;case"libraryAgent":e.openLibraryAgent(n.agentId);return;case"schedules":e.setSchedulesOpen(!0);return;case"environments":e.setEnvironmentsOpen(!0);return;case"buildAgent":e.openAgentBuilder();return;case"session":if(e.setLibraryOpen(!1),e.pendingSessionId===n.sessionId||o===n.sessionId)return;V(n.sessionId);return;case"agent":e.setLibraryOpen(!1),X(n.agentName);return;case"root":J();return}},[e,o,J,X,V]);return a.useEffect(()=>{if(R.current)return;const n=_({pathname:r.pathname,search:r.search,routes:t});if(!W&&(n==null?void 0:n.type)==="settings")return;R.current=!0;const s=_({pathname:r.pathname,search:r.search,routes:c})??{type:"root"},l=s.type==="agent"?{intent:"try-agent",agentName:s.agentName}:O(s)?k(r.search):null;m.current=l,N.current=s;const i=Y&&(u||s.type==="settings");if(s.type==="settings")Y&&e.setSettingsOpen(!0);else if(s.type==="library")e.setLibraryOpen(!0);else if(s.type==="sessionsBrowser")e.setSessionsOpen(!0);else if(s.type==="libraryAgent")e.openLibraryAgent(s.agentId);else if(s.type==="schedules")e.setSchedulesOpen(!0);else if(s.type==="environments")e.setEnvironmentsOpen(!0);else{const P=re(j);C(P,s)||F(s),i&&e.setSettingsOpen(!0)}s.type!=="agent"&&l!=null?d(l):O(s)||d(null);const y=i?{type:"settings"}:s;b.current=C(g,y)?null:y;const h=ne(y,c),E=se(B(y,r.search),l);w.current=y,h!=null&&(h!==r.pathname||E!==r.search)&&(S.current=h!==r.pathname?h:null,H({pathname:h,search:E,hash:r.hash},{replace:!0}))},[W]),a.useEffect(()=>{if(!R.current)return;if(!Q.current){Q.current=!0;return}const n=b.current;if(n!=null){if(!C(g,n))return;b.current=null}const s=ne(g,c);if(s==null)return;const i=`${c.basename.endsWith("/")?c.basename.slice(0,-1):c.basename}${r.pathname}`||"/",y=window.location.pathname===i?window.location.search:r.search,h=O(g),E=h?e.historyAgentFilter==null?m.current:{intent:e.historyAgentFilter.intent,agentName:e.historyAgentFilter.agentName}:null;!h&&e.historyAgentFilter!=null&&(f.current=null,e.setHistoryAgentFilter(null)),e.historyAgentFilter!=null&&(m.current=null);const P=se(B(g,y),E),ee=w.current;if(w.current=g,s===r.pathname&&P===r.search)return;const ue=g.type==="session"&&e.pendingSessionId==null&&ee!=null&&ee.type!=="session";S.current=s!==r.pathname?s:null,H({pathname:s,search:P,hash:r.hash},{replace:ue})},[ie,ae,le,(Z=e.historyAgentFilter)==null?void 0:Z.agentName,(x=e.historyAgentFilter)==null?void 0:x.intent]),a.useEffect(()=>{if(!R.current)return;if(!z.current){z.current=!0;return}if(S.current===r.pathname){S.current=null,N.current=g;return}const n=_({pathname:r.pathname,search:r.search,routes:c});if(n==null){const l=c.root,i=B({type:"root"},r.search);S.current=l,H({pathname:l,search:i,hash:r.hash},{replace:!0}),F({type:"root"}),d(k(i));return}const s=N.current;N.current=n,(s==null||!C(s,n))&&(n.type!=="settings"&&e.settingsOpen&&e.setSettingsOpen(!1),n.type!=="library"&&n.type!=="libraryAgent"&&e.libraryOpen&&e.setLibraryOpen(!1),!Ie(n)&&e.sessionsOpen&&e.setSessionsOpen(!1),n.type!=="schedules"&&e.schedulesOpen&&e.setSchedulesOpen(!1),n.type!=="environments"&&e.environmentsOpen&&e.setEnvironmentsOpen(!1),F(n)),n.type!=="agent"&&O(n)?d(k(r.search)):O(n)||d(null)},[r.pathname,r.search]),null}export{Le as ShellRouteSync};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SettingsBuilder-QM224JED-CLIPJX4x.js","./index-BOPxame4.js","./index-B01pXqvC.css","./SchedulesPage-25JKAP5G-DEB03OMM.js","./chunk-P2W5VLGK-wQaO2rNt.js","./EnvironmentsPage-5SEQP4QD-BuLuc3Ok.js"])))=>i.map(i=>d[i]);
2
- import{cm as _,cn as Jt,b0 as Y,j as r,co as en,r as m,bG as E,cp as Xe,cq as tn,cr as Ye,cs as qe,ct as Qe,cu as Ze,cv as Je,cw as Z,cx as nn,cy as N,cz as rn,cA as sn,cB as on,cC as an,cD as cn,cE as ln,cF as un,cG as dn,cH as je,cI as mn,cJ as fn,cK as me,cL as pn,cM as hn,cN as xn,cO as et,cP as Fe,cQ as fe,cR as Me,cS as ae,cT as Se,cU as Ce,cV as Le,cW as Ke,d as Re,q as tt,t as ne,u as C,w as gn,cX as vn,c as z,p as bn,cY as wn,_ as le,bE as ue,cZ as ge,c_ as yn,b1 as Te,bn as nt,c$ as In,S as jn,a2 as $e,I as H,D as Mn,a3 as te,d0 as rt,d1 as Sn,d2 as Cn,d3 as Ln,d4 as ze,bs as Rn,aa as Tn,E as Ge,b3 as st,d5 as Nn,P as Pn,d6 as En,b4 as ve,b5 as Dn,d7 as ot,d8 as at,bS as An,b6 as Ne,d9 as _n,cj as On}from"./index-BOPxame4.js";import{A as kn,N as Bn,T as Fn,S as it}from"./chunk-HDD5IS3M-CKbwAtVa.js";const Pe=n=>{const e=_(8),{index:t,archived:s,children:o}=n;let i;e[0]!==s||e[1]!==t?(i=Jt({source:"threads",query:{type:"index",index:t,archived:s},get:u=>u.threads().item({index:t,archived:s})}),e[0]=s,e[1]=t,e[2]=i):i=e[2];let c;e[3]!==i?(c={threadListItem:i},e[3]=i,e[4]=c):c=e[4];const a=Y(c);let d;return e[5]!==a||e[6]!==o?(d=r.jsx(en,{value:a,children:o}),e[5]=a,e[6]=o,e[7]=d):d=e[7],d},ct=m.memo(n=>{const e=_(6),{index:t,archived:s,components:o}=n,i=s===void 0?!1:s,c=o.ThreadListItem;let a;e[0]!==c?(a=r.jsx(c,{}),e[0]=c,e[1]=a):a=e[1];let d;return e[2]!==i||e[3]!==t||e[4]!==a?(d=r.jsx(Pe,{index:t,archived:i,children:a}),e[2]=i,e[3]=t,e[4]=a,e[5]=d):d=e[5],d},(n,e)=>n.index===e.index&&n.archived===e.archived&&n.components.ThreadListItem===e.components.ThreadListItem);ct.displayName="ThreadListPrimitive.ItemByIndex";const He=({archived:n,children:e})=>{const t=E(s=>n?s.threads.archivedThreadIds.length:s.threads.threadIds.length);return Xe(()=>Array.from({length:t},(s,o)=>r.jsx(Pe,{index:o,archived:n,children:r.jsx(tn,{getItemState:i=>i.threads().item({index:o,archived:n}).getState(),children:i=>e({get threadListItem(){return i()}})})},o)),[t,n,e])},lt=n=>{const e=_(8),{archived:t,components:s,children:o}=n,i=t===void 0?!1:t;if(s){const a=s.ThreadListItem;let d;e[0]!==a?(d=()=>r.jsx(a,{}),e[0]=a,e[1]=d):d=e[1];let u;return e[2]!==i||e[3]!==d?(u=r.jsx(He,{archived:i,children:d}),e[2]=i,e[3]=d,e[4]=u):u=e[4],u}let c;return e[5]!==i||e[6]!==o?(c=r.jsx(He,{archived:i,children:o}),e[5]=i,e[6]=o,e[7]=c):c=e[7],c};lt.displayName="ThreadListPrimitive.Items";const ut=n=>{const e=_(2),{fallback:t}=n,s=E(Kn)||t;let o;return e[0]!==s?(o=r.jsx(r.Fragment,{children:s}),e[0]=s,e[1]=o):o=e[1],o};ut.displayName="ThreadListItemPrimitive.Title";function Kn(n){return n.threadListItem.title}const $n=()=>{const n=_(4),e=Y();let t;n[0]!==e?(t=()=>{e.threadListItem().archive()},n[0]=e,n[1]=t):t=n[1];const s=t;let o;return n[2]!==s?(o={archive:s},n[2]=s,n[3]=o):o=n[3],o},zn=()=>{const n=_(4),e=Y();let t;n[0]!==e?(t=()=>{e.threadListItem().delete()},n[0]=e,n[1]=t):t=n[1];const s=t;let o;return n[2]!==s?(o={delete:s},n[2]=s,n[3]=o):o=n[3],o},Gn=()=>{const n=_(4),e=Y();let t;n[0]!==e?(t=()=>{e.threadListItem().unarchive()},n[0]=e,n[1]=t):t=n[1];const s=t;let o;return n[2]!==s?(o={unarchive:s},n[2]=s,n[3]=o):o=n[3],o},Hn=()=>{const n=_(4),e=Y();let t;n[0]!==e?(t=()=>{e.threadListItem().switchTo()},n[0]=e,n[1]=t):t=n[1];const s=t;let o;return n[2]!==s?(o={switchTo:s},n[2]=s,n[3]=o):o=n[3],o},Un=()=>{const n=_(4),e=Y();let t;n[0]!==e?(t=()=>{e.threads().switchToNewThread()},n[0]=e,n[1]=t):t=n[1];const s=t;let o;return n[2]!==s?(o={switchToNewThread:s},n[2]=s,n[3]=o):o=n[3],o},Vn=()=>{const n=_(5),e=Y(),t=E(Wn);let s;n[0]!==e?(s=()=>{e.threads().loadMore()},n[0]=e,n[1]=s):s=n[1];const o=s;let i;return n[2]!==t||n[3]!==o?(i={loadMore:o,disabled:t},n[2]=t,n[3]=o,n[4]=i):i=n[4],i};function Wn(n){return!n.threads.hasMore||n.threads.isLoading||n.threads.isLoadingMore}var Xn=Object.defineProperty,L=(n,e)=>Xn(n,"name",{value:e,configurable:!0}),Yn=["Enter"," "],qn=["ArrowDown","PageUp","Home"],dt=["ArrowUp","PageDown","End"],Qn=[...qn,...dt],pe="Menu",[we,Zn,Jn]=Ze(pe),[J,mt]=Ye(pe,[Jn,qe,Qe]),Ee=qe(),ft=Qe(),[er,ie]=J(pe),[tr,De]=J(pe),nr=L(n=>{const{__scopeMenu:e,open:t=!1,children:s,dir:o,onOpenChange:i,modal:c=!0}=n,a=Ee(e),[d,u]=m.useState(null),l=m.useRef(!1),h=fn(i),p=me(o);return m.useEffect(()=>{const f=L(()=>{l.current=!0,document.addEventListener("pointerdown",x,{capture:!0,once:!0}),document.addEventListener("pointermove",x,{capture:!0,once:!0})},"handleKeyDown"),x=L(()=>l.current=!1,"handlePointer");return document.addEventListener("keydown",f,{capture:!0}),()=>{document.removeEventListener("keydown",f,{capture:!0}),document.removeEventListener("pointerdown",x,{capture:!0}),document.removeEventListener("pointermove",x,{capture:!0})}},[]),m.useEffect(()=>{if(!t)return;const f=L(()=>h(!1),"handleBlur");return window.addEventListener("blur",f),()=>window.removeEventListener("blur",f)},[t,h]),r.jsx(pn,{...a,children:r.jsx(er,{scope:e,open:t,onOpenChange:h,content:d,onContentChange:u,children:r.jsx(tr,{scope:e,onClose:m.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:l,dir:p,modal:c,children:s})})})},"Menu"),rr=m.forwardRef(L(function(e,t){const{__scopeMenu:s,...o}=e,i=Ee(s);return r.jsx(hn,{...i,...o,ref:t})},"MenuAnchor")),pt="MenuPortal",[sr,or]=J(pt,{forceMount:void 0}),ar=L(n=>{const{__scopeMenu:e,forceMount:t,children:s,container:o}=n,i=ie(pt,e);return r.jsx(sr,{scope:e,forceMount:t,children:r.jsx(Je,{present:t||i.open,children:r.jsx(xn,{asChild:!0,container:o,children:s})})})},"MenuPortal"),Q="MenuContent",[ir,ht]=J(Q),cr=m.forwardRef(L(function(e,t){const s=or(Q,e.__scopeMenu),{forceMount:o=s.forceMount,...i}=e,c=ie(Q,e.__scopeMenu),a=De(Q,e.__scopeMenu);return r.jsx(we.Provider,{scope:e.__scopeMenu,children:r.jsx(Je,{present:o||c.open,children:r.jsx(we.Slot,{scope:e.__scopeMenu,children:a.modal?r.jsx(lr,{...i,ref:t}):r.jsx(ur,{...i,ref:t})})})})},"MenuContent")),lr=m.forwardRef(L(function(e,t){const s=ie(Q,e.__scopeMenu),o=m.useRef(null),i=Z(t,o);return m.useEffect(()=>{const c=o.current;if(c)return nn(c)},[]),r.jsx(xt,{...e,ref:i,trapFocus:s.open,disableOutsidePointerEvents:s.open,disableOutsideScroll:!0,onFocusOutside:N(e.onFocusOutside,c=>c.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>s.onOpenChange(!1)})},"MenuRootContentModal")),ur=m.forwardRef(L(function(e,t){const s=ie(Q,e.__scopeMenu);return r.jsx(xt,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>s.onOpenChange(!1)})},"MenuRootContentNonModal")),dr=mn("MenuContent.ScrollLock"),xt=m.forwardRef(L(function(e,t){const{__scopeMenu:s,loop:o=!1,trapFocus:i,onOpenAutoFocus:c,onCloseAutoFocus:a,disableOutsidePointerEvents:d,onEntryFocus:u,onEscapeKeyDown:l,onPointerDownOutside:h,onFocusOutside:p,onInteractOutside:f,onDismiss:x,disableOutsideScroll:g,...I}=e,j=ie(Q,s),M=De(Q,s),y=Ee(s),B=ft(s),P=Zn(s),[F,K]=m.useState(null),O=m.useRef(null),S=Z(t,O,j.onContentChange),R=m.useRef(0),T=m.useRef(""),U=m.useRef(0),$=m.useRef(null),V=m.useRef("right"),G=m.useRef(0),W=g?sn:m.Fragment,w=g?{as:dr,allowPinchZoom:!0}:void 0,D=L(v=>{var ee,ke;const A=T.current+v,k=P().filter(q=>!q.disabled),X=document.activeElement,he=(ee=k.find(q=>q.ref.current===X))==null?void 0:ee.textValue,xe=k.map(q=>q.textValue),Oe=yt(xe,A,he),oe=(ke=k.find(q=>q.textValue===Oe))==null?void 0:ke.ref.current;L((function q(Be){T.current=Be,window.clearTimeout(R.current),Be!==""&&(R.current=window.setTimeout(()=>q(""),1e3))}),"updateSearch")(A),oe&&setTimeout(()=>oe.focus())},"handleTypeaheadSearch");m.useEffect(()=>()=>window.clearTimeout(R.current),[]),rn();const b=m.useCallback(v=>{var k,X;return V.current===((k=$.current)==null?void 0:k.side)&&jt(v,(X=$.current)==null?void 0:X.area)},[]);return r.jsx(ir,{scope:s,searchRef:T,onItemEnter:m.useCallback(v=>{b(v)&&v.preventDefault()},[b]),onItemLeave:m.useCallback(v=>{var A;b(v)||((A=O.current)==null||A.focus(),K(null))},[b]),onTriggerLeave:m.useCallback(v=>{b(v)&&v.preventDefault()},[b]),pointerGraceTimerRef:U,onPointerGraceIntentChange:m.useCallback(v=>{$.current=v},[]),children:r.jsx(W,{...w,children:r.jsx(on,{asChild:!0,trapped:i,onMountAutoFocus:N(c,v=>{var A;v.preventDefault(),(A=O.current)==null||A.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:r.jsx(an,{asChild:!0,disableOutsidePointerEvents:d,onEscapeKeyDown:l,onPointerDownOutside:h,onFocusOutside:p,onInteractOutside:f,onDismiss:x,children:r.jsx(cn,{asChild:!0,...B,dir:M.dir,orientation:"vertical",loop:o,currentTabStopId:F,onCurrentTabStopIdChange:K,onEntryFocus:N(u,v=>{M.isUsingKeyboardRef.current||v.preventDefault()}),preventScrollOnEntryFocus:!0,children:r.jsx(ln,{role:"menu","aria-orientation":"vertical","data-state":gt(j.open),"data-radix-menu-content":"",dir:M.dir,...y,...I,ref:S,style:{outline:"none",...I.style},onKeyDown:N(I.onKeyDown,v=>{const k=v.target.closest("[data-radix-menu-content]")===v.currentTarget,X=v.ctrlKey||v.altKey||v.metaKey,he=v.key.length===1;k&&(v.key==="Tab"&&v.preventDefault(),!X&&he&&D(v.key));const xe=O.current;if(v.target!==xe||!Qn.includes(v.key))return;v.preventDefault();const oe=P().filter(ee=>!ee.disabled).map(ee=>ee.ref.current);dt.includes(v.key)&&oe.reverse(),bt(oe)}),onBlur:N(e.onBlur,v=>{v.currentTarget.contains(v.target)||(window.clearTimeout(R.current),T.current="")}),onPointerMove:N(e.onPointerMove,de(v=>{const A=v.target,k=G.current!==v.clientX;if(v.currentTarget.contains(A)&&k){const X=v.clientX>G.current?"right":"left";V.current=X,G.current=v.clientX}}))})})})})})})},"MenuContentImpl")),ye="MenuItem",Ue="menu.itemSelect",mr=m.forwardRef(L(function(e,t){const{disabled:s=!1,onSelect:o,...i}=e,c=m.useRef(null),a=De(ye,e.__scopeMenu),d=ht(ye,e.__scopeMenu),u=Z(t,c),l=m.useRef(!1),h=L(()=>{const p=c.current;if(!s&&p){const f=new CustomEvent(Ue,{bubbles:!0,cancelable:!0});p.addEventListener(Ue,x=>o==null?void 0:o(x),{once:!0}),un(p,f),f.defaultPrevented?l.current=!1:a.onClose()}},"handleSelect");return r.jsx(fr,{...i,ref:u,disabled:s,onClick:N(e.onClick,h),onPointerDown:p=>{var f;(f=e.onPointerDown)==null||f.call(e,p),l.current=!0},onPointerUp:N(e.onPointerUp,p=>{var f;l.current||(f=p.currentTarget)==null||f.click()}),onKeyDown:N(e.onKeyDown,p=>{s||p.target!==p.currentTarget||d.searchRef.current!==""&&p.key===" "||Yn.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})},"MenuItem")),fr=m.forwardRef(L(function(e,t){const{__scopeMenu:s,disabled:o=!1,textValue:i,...c}=e,a=ht(ye,s),d=ft(s),u=m.useRef(null),l=Z(t,u),[h,p]=m.useState(!1),[f,x]=m.useState("");return m.useEffect(()=>{const g=u.current;g&&x((g.textContent??"").trim())},[c.children]),r.jsx(we.ItemSlot,{scope:s,disabled:o,textValue:i??f,children:r.jsx(dn,{asChild:!0,...d,focusable:!o,children:r.jsx(je.div,{role:"menuitem","data-highlighted":h?"":void 0,"aria-disabled":o||void 0,"data-disabled":o?"":void 0,...c,ref:l,onPointerMove:N(e.onPointerMove,de(g=>{o?a.onItemLeave(g):(a.onItemEnter(g),g.defaultPrevented||g.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:N(e.onPointerLeave,de(g=>a.onItemLeave(g))),onFocus:N(e.onFocus,()=>p(!0)),onBlur:N(e.onBlur,()=>p(!1))})})})},"MenuItemImpl")),pr="MenuRadioGroup",[js,Ms]=J(pr,{value:void 0,onValueChange:L(()=>{},"onValueChange")}),hr="MenuItemIndicator",[Ss,Cs]=J(hr,{checked:!1}),xr=m.forwardRef(L(function(e,t){const{__scopeMenu:s,...o}=e;return r.jsx(je.div,{role:"separator","aria-orientation":"horizontal",...o,ref:t})},"MenuSeparator")),gr="MenuSub",[Ls,Rs]=J(gr);function gt(n){return n?"open":"closed"}L(gt,"getOpenState");function vt(n){return n==="indeterminate"}L(vt,"isIndeterminate");function vr(n){return vt(n)?"indeterminate":n?"checked":"unchecked"}L(vr,"getCheckedState");function bt(n){const e=document.activeElement;for(const t of n)if(t===e||(t.focus(),document.activeElement!==e))return}L(bt,"focusFirst");function wt(n,e){return n.map((t,s)=>n[(e+s)%n.length])}L(wt,"wrapArray");function yt(n,e,t){const o=e.length>1&&Array.from(e).every(u=>u===e[0])?e[0]:e,i=t?n.indexOf(t):-1;let c=wt(n,Math.max(i,0));o.length===1&&(c=c.filter(u=>u!==t));const d=c.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return d!==t?d:void 0}L(yt,"getNextMatch");function It(n,e){const{x:t,y:s}=n;let o=!1;for(let i=0,c=e.length-1;i<e.length;c=i++){const a=e[i],d=e[c],u=a.x,l=a.y,h=d.x,p=d.y;l>s!=p>s&&t<(h-u)*(s-l)/(p-l)+u&&(o=!o)}return o}L(It,"isPointInPolygon");function jt(n,e){if(!e)return!1;const t={x:n.clientX,y:n.clientY};return It(t,e)}L(jt,"isPointerInGraceArea");function de(n){return e=>e.pointerType==="mouse"?n(e):void 0}L(de,"whenMouse");var br=nr,wr=rr,yr=ar,Ir=cr,jr=mr,Mr=xr,Sr=Object.defineProperty,re=(n,e)=>Sr(n,"name",{value:e,configurable:!0}),Ae="DropdownMenu",[Cr,Mt]=Ye(Ae,[mt]),se=mt(),[Lr,St]=Cr(Ae),Ct=re(n=>{const{__scopeDropdownMenu:e,children:t,dir:s,open:o,defaultOpen:i,onOpenChange:c,modal:a=!0}=n,d=se(e),u=m.useRef(null),[l,h]=et({prop:o,defaultProp:i??!1,onChange:c,caller:Ae});return r.jsx(Lr,{scope:e,triggerId:Fe(),triggerRef:u,contentId:Fe(),open:l,onOpenChange:h,onOpenToggle:m.useCallback(()=>h(p=>!p),[h]),modal:a,children:r.jsx(br,{...d,open:l,onOpenChange:h,dir:s,modal:a,children:t})})},"DropdownMenu"),Rr="DropdownMenuTrigger",Lt=m.forwardRef(re(function(e,t){const{__scopeDropdownMenu:s,disabled:o=!1,...i}=e,c=St(Rr,s),a=se(s),d=Z(t,c.triggerRef);return r.jsx(wr,{asChild:!0,...a,children:r.jsx(je.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":o?"":void 0,disabled:o,...i,ref:d,onPointerDown:N(e.onPointerDown,u=>{!o&&u.button===0&&u.ctrlKey===!1&&(c.onOpenToggle(),c.open||u.preventDefault())}),onKeyDown:N(e.onKeyDown,u=>{o||(["Enter"," "].includes(u.key)&&c.onOpenToggle(),u.key==="ArrowDown"&&c.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(u.key)&&u.preventDefault())})})})},"DropdownMenuTrigger")),Rt=re(n=>{const{__scopeDropdownMenu:e,...t}=n,s=se(e);return r.jsx(yr,{...s,...t})},"DropdownMenuPortal"),Tr="DropdownMenuContent",Tt=m.forwardRef(re(function(e,t){const{__scopeDropdownMenu:s,...o}=e,i=St(Tr,s),c=se(s),a=m.useRef(!1);return r.jsx(Ir,{id:i.contentId,"aria-labelledby":i.triggerId,...c,...o,ref:t,onCloseAutoFocus:N(e.onCloseAutoFocus,d=>{var u;a.current||(u=i.triggerRef.current)==null||u.focus(),a.current=!1,d.preventDefault()}),onInteractOutside:N(e.onInteractOutside,d=>{const u=d.detail.originalEvent,l=u.button===0&&u.ctrlKey===!0,h=u.button===2||l;(!i.modal||h)&&(a.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")),Nt=m.forwardRef(re(function(e,t){const{__scopeDropdownMenu:s,...o}=e,i=se(s);return r.jsx(jr,{...i,...o,ref:t})},"DropdownMenuItem")),Pt=m.forwardRef(re(function(e,t){const{__scopeDropdownMenu:s,...o}=e,i=se(s);return r.jsx(Mr,{...i,...o,ref:t})},"DropdownMenuSeparator")),Et=Ct,Dt=Lt,Nr=Rt,At=Tt,_t=Nt,Ot=Pt;const Pr=Object.freeze(Object.defineProperty({__proto__:null,Content:At,DropdownMenu:Ct,DropdownMenuContent:Tt,DropdownMenuItem:Nt,DropdownMenuPortal:Rt,DropdownMenuSeparator:Pt,DropdownMenuTrigger:Lt,Item:_t,Portal:Nr,Root:Et,Separator:Ot,Trigger:Dt,createDropdownMenuScope:Mt},Symbol.toStringTag,{value:"Module"})),Er=fe(Dt),Dr=fe(At),Ar=fe(_t),_r=fe(Ot),kt=m.forwardRef((n,e)=>{const t=_(15);let s,o,i;t[0]!==n?({onClick:o,disabled:s,...i}=n,t[0]=n,t[1]=s,t[2]=o,t[3]=i):(s=t[1],o=t[2],i=t[3]);const c=E(Or),{switchToNewThread:a}=Un();let d;t[4]!==c?(d=c?{"data-active":"true","aria-current":"true"}:null,t[4]=c,t[5]=d):d=t[5];let u;t[6]!==o||t[7]!==a?(u=N(o,a),t[6]=o,t[7]=a,t[8]=u):u=t[8];let l;return t[9]!==s||t[10]!==e||t[11]!==i||t[12]!==d||t[13]!==u?(l=r.jsx(Me.button,{type:"button",...d,...i,ref:e,disabled:s,onClick:u}),t[9]=s,t[10]=e,t[11]=i,t[12]=d,t[13]=u,t[14]=l):l=t[14],l});kt.displayName="ThreadListPrimitive.New";function Or(n){return n.threads.newThreadId===n.threads.mainThreadId}const kr=()=>{const{loadMore:n,disabled:e}=Vn();return e?null:n},Br=ae("ThreadListPrimitive.LoadMore",kr),[Fr,Kr]=Ze("ThreadList"),Ie=Fr,Bt=Ce(null),$r=Bt.Provider,_e=()=>Se(Bt),Ft=m.forwardRef((n,e)=>{const t=_(3);let s;return t[0]!==n||t[1]!==e?(s=r.jsx(Ie.Provider,{scope:void 0,children:r.jsx(Ie.Slot,{scope:void 0,children:r.jsx(Me.div,{...n,ref:e})})}),t[0]=n,t[1]=e,t[2]=s):s=t[2],s});Ft.displayName="ThreadListPrimitive.Root";var zr=Le({ItemByIndex:()=>ct,Items:()=>lt,LoadMore:()=>Br,New:()=>kt,Root:()=>Ft});const Kt=m.forwardRef((n,e)=>{const t=E(u=>u.threads.mainThreadId===u.threadListItem.id),s=Ke(null),o=Ke(null),i=Xe(()=>({triggerRef:s,moreRef:o}),[]),c=Kr(void 0),a=me(),d=u=>{const l=a==="rtl"?"ArrowLeft":"ArrowRight",h=a==="rtl"?"ArrowRight":"ArrowLeft",p=s.current,f=o.current;if(p&&u.target===p)if(u.key==="ArrowDown"||u.key==="ArrowUp"){const x=c().map(I=>I.ref.current).filter(I=>I!==null),g=x[x.indexOf(p)+(u.key==="ArrowDown"?1:-1)];g&&(g.focus(),u.preventDefault())}else u.key===l&&f&&(f.focus(),u.preventDefault());else f&&u.target===f&&u.key===h&&(p==null||p.focus(),u.preventDefault())};return r.jsx($r,{value:i,children:r.jsx(Me.div,{...t?{"data-active":"true","aria-current":"true"}:null,...n,onKeyDown:N(n.onKeyDown,d),ref:e})})});Kt.displayName="ThreadListItemPrimitive.Root";const Gr=()=>{const{archive:n}=$n();return n},Hr=ae("ThreadListItemPrimitive.Archive",Gr),Ur=()=>{const{unarchive:n}=Gn();return n},Vr=ae("ThreadListItemPrimitive.Unarchive",Ur),Wr=()=>{const{delete:n}=zn();return n},Xr=ae("ThreadListItemPrimitive.Delete",Wr),Yr=()=>{const{switchTo:n}=Hn();return n},qr=ae("ThreadListItemPrimitive.Trigger",Yr),$t=m.forwardRef((n,e)=>{var i;const t=_(3),s=Z(e,(i=_e())==null?void 0:i.triggerRef);let o;return t[0]!==n||t[1]!==s?(o=r.jsx(Ie.ItemSlot,{scope:void 0,children:r.jsx(qr,{...n,ref:s})}),t[0]=n,t[1]=s,t[2]=o):o=t[2],o});$t.displayName="ThreadListItemPrimitive.Trigger";var zt=Le({Archive:()=>Hr,Delete:()=>Xr,Root:()=>Kt,Title:()=>ut,Trigger:()=>$t,Unarchive:()=>Vr});const ce=Mt(),Gt=Ce(()=>{}),Ht=()=>Se(Gt),Ut=Ce(!1),Vt=()=>Se(Ut),Wt=n=>{const e=_(26);let t,s,o,i,c,a,d;e[0]!==n?({__scopeThreadListItemMore:t,open:c,defaultOpen:s,onOpenChange:i,sharedFocusGroup:d,modal:o,...a}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=c,e[6]=a,e[7]=d):(t=e[1],s=e[2],o=e[3],i=e[4],c=e[5],a=e[6],d=e[7]);const u=d===void 0?!1:d,l=u?!1:o??!0,h=ce(t),p=s??!1;let f;e[8]!==i?(f=i?{onChange:i}:{},e[8]=i,e[9]=f):f=e[9];let x;e[10]!==c||e[11]!==p||e[12]!==f?(x={prop:c,defaultProp:p,caller:"ThreadListItemMorePrimitive.Root",...f},e[10]=c,e[11]=p,e[12]=f,e[13]=x):x=e[13];const[g,I]=et(x);let j;e[14]!==l||e[15]!==g||e[16]!==a||e[17]!==h||e[18]!==I?(j=r.jsx(Et,{...h,...a,modal:l,open:g,onOpenChange:I}),e[14]=l,e[15]=g,e[16]=a,e[17]=h,e[18]=I,e[19]=j):j=e[19];let M;e[20]!==I||e[21]!==j?(M=r.jsx(Gt.Provider,{value:I,children:j}),e[20]=I,e[21]=j,e[22]=M):M=e[22];let y;return e[23]!==u||e[24]!==M?(y=r.jsx(Ut.Provider,{value:u,children:M}),e[23]=u,e[24]=M,e[25]=y):y=e[25],y};Wt.displayName="ThreadListItemMorePrimitive.Root";const Xt=m.forwardRef((n,e)=>{const t=_(10),{__scopeThreadListItemMore:s,...o}=n,i=ce(s),c=_e(),a=Ht(),d=Vt(),u=Z(e,c==null?void 0:c.moreRef),l=me()==="rtl"?"ArrowLeft":"ArrowRight",h=Er;let p;t[0]!==l||t[1]!==a||t[2]!==d?(p=g=>{!d||g.key!==l||(g.preventDefault(),a(!0))},t[0]=l,t[1]=a,t[2]=d,t[3]=p):p=t[3];const f=N(o.onKeyDown,p);let x;return t[4]!==h||t[5]!==u||t[6]!==o||t[7]!==i||t[8]!==f?(x=r.jsx(h,{...i,...o,onKeyDown:f,ref:u}),t[4]=h,t[5]=u,t[6]=o,t[7]=i,t[8]=f,t[9]=x):x=t[9],x});Xt.displayName="ThreadListItemMorePrimitive.Trigger";const Yt=m.forwardRef((n,e)=>{const t=_(21),{__scopeThreadListItemMore:s,portalProps:o,sideOffset:i,...c}=n,a=i===void 0?4:i,d=ce(s),u=Ht(),l=_e(),h=Vt(),p=me()==="rtl"?"ArrowRight":"ArrowLeft",f=Pr,x=Dr;let g;t[0]!==p||t[1]!==(l==null?void 0:l.moreRef)||t[2]!==u||t[3]!==h?(g=P=>{var F;!h||P.key!==p||(P.preventDefault(),u(!1),(F=l==null?void 0:l.moreRef.current)==null||F.focus())},t[0]=p,t[1]=l==null?void 0:l.moreRef,t[2]=u,t[3]=h,t[4]=g):g=t[4];const I=N(c.onKeyDown,g);let j;t[5]!==(l==null?void 0:l.moreRef)||t[6]!==h?(j=()=>{var P;h&&((P=l==null?void 0:l.moreRef.current)==null||P.focus())},t[5]=l==null?void 0:l.moreRef,t[6]=h,t[7]=j):j=t[7];const M=N(c.onEscapeKeyDown,j);let y;t[8]!==x||t[9]!==e||t[10]!==c||t[11]!==d||t[12]!==a||t[13]!==I||t[14]!==M?(y=r.jsx(x,{...d,...c,onKeyDown:I,onEscapeKeyDown:M,ref:e,sideOffset:a}),t[8]=x,t[9]=e,t[10]=c,t[11]=d,t[12]=a,t[13]=I,t[14]=M,t[15]=y):y=t[15];let B;return t[16]!==o||t[17]!==d||t[18]!==f.Portal||t[19]!==y?(B=r.jsx(f.Portal,{...d,...o,children:y}),t[16]=o,t[17]=d,t[18]=f.Portal,t[19]=y,t[20]=B):B=t[20],B});Yt.displayName="ThreadListItemMorePrimitive.Content";const qt=m.forwardRef((n,e)=>{const t=_(7);let s,o;t[0]!==n?({__scopeThreadListItemMore:s,...o}=n,t[0]=n,t[1]=s,t[2]=o):(s=t[1],o=t[2]);const i=ce(s);let c;return t[3]!==e||t[4]!==o||t[5]!==i?(c=r.jsx(Ar,{...i,...o,ref:e}),t[3]=e,t[4]=o,t[5]=i,t[6]=c):c=t[6],c});qt.displayName="ThreadListItemMorePrimitive.Item";const Qt=m.forwardRef((n,e)=>{const t=_(7);let s,o;t[0]!==n?({__scopeThreadListItemMore:s,...o}=n,t[0]=n,t[1]=s,t[2]=o):(s=t[1],o=t[2]);const i=ce(s);let c;return t[3]!==e||t[4]!==o||t[5]!==i?(c=r.jsx(_r,{...i,...o,ref:e}),t[3]=e,t[4]=o,t[5]=i,t[6]=c):c=t[6],c});Qt.displayName="ThreadListItemMorePrimitive.Separator";var be=Le({Content:()=>Yt,Item:()=>qt,Root:()=>Wt,Separator:()=>Qt,Trigger:()=>Xt});function Qr(){const n=ne(),e=Re(),t=Te(),s=nt(),o=t||s,[i,c]=m.useState(!1),[a,d]=m.useState(""),[u,l]=m.useState(null),h=m.useRef(null),p=m.useRef(null),f=m.useId(),x=(n==null?void 0:n.isLibraryEnabled)===!0&&e!=null,g=(n==null?void 0:n.historyAgentFilter)??null;m.useEffect(()=>{i||d("")},[i]);const{agents:I,isInitialLoading:j,isSearching:M,loadingMore:y,hasMore:B,listRef:P,sentinelRef:F}=In({enabled:i&&x,query:a});if(m.useLayoutEffect(()=>{if(!i||o){l(null);return}const S=()=>{var T;const R=(T=h.current)==null?void 0:T.getBoundingClientRect();R&&l({top:R.top,left:R.right+4})};return S(),window.addEventListener("resize",S),window.addEventListener("scroll",S,!0),()=>{window.removeEventListener("resize",S),window.removeEventListener("scroll",S,!0)}},[i,o]),m.useEffect(()=>{if(!i||o)return;const S=R=>{var U,$;const T=R.target;(U=h.current)!=null&&U.contains(T)||($=p.current)!=null&&$.contains(T)||c(!1)};return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[i,o]),!x)return null;const K=S=>{(n==null?void 0:n.isComposerEnabled)===!0?n.openDraft():n==null||n.openLibraryHome(),n==null||n.setHistoryAgentFilter(S),c(!1)},O=r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"p-1",onMouseDown:S=>S.stopPropagation(),children:[r.jsx(jn,{query:a,setQuery:d,placeholder:"Search agents"}),M?r.jsx("p",{className:"text-text-secondary px-1 pt-1 text-[11px]",role:"status",children:"Searching…"}):null]}),r.jsxs("div",{ref:P,className:z("mt-1 overflow-y-auto",o?"min-h-0 flex-1 px-1 pb-2":"min-h-48 max-h-64"),children:[a.trim()===""?r.jsxs($e,{className:z("justify-between",g==null&&"bg-dropdown-selected-item-bg text-dropdown-selected-item-text"),onClick:()=>K(null),children:["All chats",g==null?r.jsx(H,{name:"check",className:"size-3.5 shrink-0"}):null]}):null,j?r.jsx("p",{className:"px-2 py-3 text-center text-xs text-text-secondary",children:"Loading…"}):I.length===0?r.jsx("p",{className:"text-text-secondary px-2 py-6 text-center text-xs",role:"status",children:a.trim()?`No agents match "${a.trim()}".`:"No agents yet."}):r.jsxs(r.Fragment,{children:[I.map(S=>{const R=Mn(S),T=(g==null?void 0:g.agentId)===R;return r.jsxs($e,{className:z("justify-between gap-2 text-left",T&&"bg-dropdown-selected-item-bg text-dropdown-selected-item-text"),onClick:()=>K({agentId:R,agentName:S.name,intent:"history"}),children:[r.jsx("span",{className:"min-w-0 truncate",children:S.name}),T?r.jsx(H,{name:"check",className:"size-3.5 shrink-0"}):null]},R)}),B?r.jsx("div",{ref:F,className:"flex h-6 shrink-0 items-center justify-center","aria-hidden":!0,children:y?r.jsx("span",{className:"text-text-secondary text-[11px]",role:"status",children:"Loading more…"}):null}):null]})]})]});return r.jsxs("div",{className:"relative shrink-0",children:[r.jsxs("button",{ref:h,type:"button","aria-label":g!=null?`Filter chat history by agent (${g.agentName})`:"Filter chat history by agent","aria-haspopup":o?"dialog":"menu","aria-expanded":i,"aria-controls":i?f:void 0,title:"Filter by agent",className:te({variant:"ghost",size:"icon",className:z("relative size-7 shrink-0 text-text-secondary hover:bg-ghost-button-hover hover:text-ghost-button-text",g!=null&&"text-text-primary")}),onClick:()=>c(S=>!S),children:[r.jsx(H,{name:"funnel",className:"size-3.5"}),g!=null?r.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]}),o&&i?r.jsx(rt,{open:!0,onOpenChange:c,id:f,"aria-label":"Filter agents",children:r.jsx("div",{className:"flex min-h-0 flex-1 flex-col p-2",role:"menu",children:O})}):null,!o&&i&&u!=null?Sn.createPortal(r.jsx("div",{ref:p,id:f,role:"menu","aria-label":"Filter agents",style:{top:u.top,left:u.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:O}),Cn(h.current)):null]})}function Zr({open:n,initialTitle:e,saving:t=!1,onOpenChange:s,onSave:o}){const[i,c]=m.useState(e),a=m.useRef(null);m.useEffect(()=>{n&&c(e)},[n,e]),m.useEffect(()=>{if(!n)return;const f=a.current;f!=null&&(f.focus(),f.select())},[n]);const d=i.trim(),l=d.length>0&&d.length<=ze&&!t,h=()=>{l&&o(d)},p=f=>{t||s(f)};return r.jsx(Rn,{open:n,onOpenChange:p,title:"Rename session",contentSized:!0,"aria-label":"Rename session",footer:r.jsxs("div",{className:"flex items-center justify-end gap-2",children:[r.jsx(Ge.Secondary,{type:"button",disabled:t,onClick:()=>p(!1),children:"Cancel"}),r.jsx(Ge.Primary,{type:"button",disabled:!l,onClick:h,children:"Save"})]}),children:r.jsx("div",{className:"px-5 py-4",children:r.jsx("input",{ref:a,"aria-label":"Session title",value:i,readOnly:t,maxLength:ze,className:Tn("h-9"),onChange:f=>c(f.target.value),onKeyDown:f=>{f.key==="Enter"&&(f.preventDefault(),h())}})})})}var Jr="flex w-full cursor-pointer select-none items-center gap-2 rounded-md px-2 py-1.5 text-sm font-medium outline-none transition-colors hover:bg-ghost-button-hover focus:bg-ghost-button-hover data-[highlighted]:bg-ghost-button-hover",es="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 ts({canRename:n,renameDisabled:e,canDelete:t,deleteDisabled:s,onRename:o,onDelete:i}){const c=C("PermissionGuard"),a=nt(),d=Te(),[u,l]=m.useState(!1),[h,p]=m.useState(),f=d||a,x=m.useCallback(M=>{const y=M==null?void 0:M.closest(".aui-theme-root");p(y instanceof HTMLElement?y:void 0)},[]),g=te({variant:"ghost",size:"icon",className:"size-7 shrink-0 text-text-secondary hover:bg-transparent hover:text-text-primary"}),I=n?r.jsx(c,{allowed:!e,children:r.jsxs("button",{type:"button",className:Jr,disabled:e,onClick:()=>{e||(l(!1),o())},children:[r.jsx(H,{name:"pencil",className:"size-3.5"}),"Rename"]})}):null,j=t?r.jsx(c,{allowed:!s,children:r.jsxs(zt.Delete,{className:es,onClick:()=>{s||(l(!1),i())},children:[r.jsx(H,{name:"trash",className:"size-3.5"}),"Delete"]})}):null;return f?r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button","aria-label":"Session actions",title:"Session actions","aria-haspopup":"dialog","aria-expanded":u,className:g,onClick:()=>l(!0),children:r.jsx(H,{name:"ellipsis",className:"size-3.5"})}),u?r.jsx(rt,{open:!0,onOpenChange:l,"aria-label":"Session actions",children:r.jsxs("div",{className:"flex flex-col gap-1 p-2 *:w-full",role:"menu",children:[I,j]})}):null]}):r.jsxs(be.Root,{sharedFocusGroup:!0,children:[r.jsx(be.Trigger,{ref:x,"aria-label":"Session actions",title:"Session actions",className:g,children:r.jsx(H,{name:"ellipsis",className:"size-3.5"})}),r.jsxs(be.Content,{portalProps:{container:h},align:"end",sideOffset:4,className:"aui-popup-enter font-sans-flex z-50 min-w-32 rounded-md border border-border bg-card-bg p-1 text-text-primary shadow-md *:w-full",children:[I,j]})]})}function ns({selectionRef:n,onThreadOpen:e,canRenameSession:t,canDeleteSession:s,canManageResource:o,canDeleteResource:i}){const c=Y(),a=ne(),d=Re(),u=m.useRef(a==null?void 0:a.runtimeKey);u.current=a==null?void 0:a.runtimeKey;const l=tt(),h=bn(),p=C("ThreadListRow"),f=E(w=>w.threadListItem.id),x=E(w=>w.threadListItem.remoteId),g=E(w=>w.threadListItem.title),I=E(w=>w.threadListItem.lastMessageAt),j=E(w=>w.threadListItem.custom),M=E(w=>w.threads.mainThreadId),y=wn(j),B=t&&x!=null,P=s&&x!=null,F=B||P,K=x!=null&&!o(x),O=x!=null&&!i(x),S=(a==null?void 0:a.libraryOpen)===!0||(a==null?void 0:a.sessionsOpen)===!0||(a==null?void 0:a.schedulesOpen)===!0||(a==null?void 0:a.environmentsOpen)===!0,[R,T]=m.useState(!1),[U,$]=m.useState(!1),V=g??"New Chat",G=async w=>{if(w===(g??"").trim()){T(!1);return}$(!0);try{await c.threadListItem().rename(w),l(le.Session.RENAMED,ue(void 0,{sessionId:x,agentName:y})),T(!1)}catch(D){h==null||h.showError(D)}finally{$(!1)}},W=({sessionMutable:w,rowAgentName:D})=>{const b=!w&&(a==null?void 0:a.mode.status)==="active"&&!a.mode.isMutable&&(D==null?a.mode.agentName==null&&a.mode.agentId==null:a.mode.agentName===D||a.mode.agentId===D),v=Ln({sessionMutable:w,shellMutable:(a==null?void 0:a.mode.status)==="active"&&a.mode.isMutable,...(a==null?void 0:a.mode.status)==="active"&&a.mode.isMutable?{shellAgentName:a.mode.agentName,shellAgentId:a.mode.agentId}:{},remoteId:x,pendingSessionId:a==null?void 0:a.pendingSessionId});if((b||v)&&x!=null&&(a==null?void 0:a.sessionAccessError)==null){Promise.resolve(c.threads().switchToThread(f)).catch(()=>{});return}if(x!=null){a==null||a.openHistorySession({sessionId:x,isMutable:w,...D!=null?{agentName:D}:{}});return}Promise.resolve(c.threads().switchToThread(f)).catch(()=>{})};return r.jsxs(zt.Root,{className:"min-w-0",children:[r.jsx(p,{title:V,active:f===M&&!S,agentName:y,lastMessageAt:I,onSelect:()=>{l(le.Session.SELECTED,ue({is_mutable:ge(j)},{sessionId:x,agentName:y}));const w=++n.current,D=a==null?void 0:a.runtimeKey;if(e==null||e(),a==null||a.setSettingsOpen(!1),a==null||a.setLibraryOpen(!1),a==null||a.setSessionsOpen(!1),a==null||a.setSchedulesOpen(!1),a==null||a.setEnvironmentsOpen(!1),x!=null&&d!=null&&yn(j)===void 0&&y==null){d.getSession({sessionId:x}).then(b=>({sessionMutable:b.isMutable,rowAgentName:b.agentName??void 0}),()=>({sessionMutable:ge(j),rowAgentName:y})).then(b=>{n.current===w&&u.current===D&&W(b)});return}W({sessionMutable:ge(j),rowAgentName:y})},actions:F?r.jsx(ts,{canRename:B,renameDisabled:K,canDelete:P,deleteDisabled:O,onRename:()=>T(!0),onDelete:()=>{l(le.Session.DELETED,ue(void 0,{sessionId:x,agentName:y}))}}):void 0}),r.jsx(Zr,{open:R,initialTitle:g??"",saving:U,onOpenChange:T,onSave:w=>{G(w)}})]})}function rs(n){const e=E(s=>s.threads.threadIds),t=E(s=>s.threads.threadItems);return m.useMemo(()=>{const s=vn({threadIds:e,threadItems:t});if(n==="default")return s;const o=new Map;for(const i of t)o.set(i.id,i),i.remoteId!=null&&o.set(i.remoteId,i);return s.filter(i=>{const c=e[i];if(c===void 0)return!1;const a=o.get(c);return(a==null?void 0:a.remoteId)!=null})},[e,t,n])}function ss(n){return n==="recent-history"||n==="mobile-drawer"}function os({selectionRef:n,indices:e,onThreadOpen:t,canRenameSession:s,canDeleteSession:o,canManageResource:i,canDeleteResource:c}){const a=E(d=>d.threads.threadIds);return r.jsx(r.Fragment,{children:e.map(d=>{const u=a[d]??String(d);return r.jsx(Pe,{index:d,archived:!1,children:r.jsx(ns,{selectionRef:n,onThreadOpen:t,canRenameSession:s,canDeleteSession:o,canManageResource:i,canDeleteResource:c})},u)})})}var as="aui_thread-list-viewport",is=80;function cs({children:n,viewportRef:e,hideScrollbar:t}){var d;const s=ne(),o=E(u=>u.threadListItem.remoteId),i=(d=s==null?void 0:s.historyAgentFilter)==null?void 0:d.intent,c=(s==null?void 0:s.isLibraryEnabled)===!0&&i!=="try-agent"&&(i==="history"||s.mode.status!=="active"||s.mode.isMutable||s.pendingSessionId!=null||o!=null),a=(s==null?void 0:s.historyAgentFilter)==null?"Chat History":`Chats for ${s.historyAgentFilter.agentName}`;return r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[r.jsxs("div",{className:"flex shrink-0 items-center gap-1 px-1 py-1",children:[r.jsx("h2",{className:"min-w-0 flex-1 truncate px-1.5 py-1 text-sm font-medium text-text-secondary",children:a}),c?r.jsx(Qr,{}):null]}),r.jsx("div",{ref:e,"data-slot":as,className:z("flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto",t&&"aui-scrollbar-hidden"),children:n})]})}function Zt({onThreadOpen:n,variant:e="default"}={}){const t=Y(),s=Re(),o=tt(),i=E(b=>b.threads.isLoading),c=E(b=>b.threads.isLoadingMore),a=E(b=>b.threads.hasMore),d=E(b=>b.threads.threadIds),u=E(b=>b.threads.threadItems),l=ne(),h=C("ThreadListShell"),p=C("ThreadListNewButton"),f=C("AgentsLibraryButton"),x=C("SessionsBrowserButton"),g=C("SchedulesButton"),I=C("EnvironmentsButton"),j=C("ThreadListRowSkeleton"),M=C("ThreadListEmptyState"),y=rs(e),B=m.useRef(null),P=m.useRef(a),F=m.useRef(t),K=m.useRef(0);P.current=a,F.current=t;const O=(l==null?void 0:l.isNewChatEnabled)!==!1,S=(l==null?void 0:l.mode.status)==="idle",R=ss(e),T=e==="mobile-drawer",U=typeof(s==null?void 0:s.renameSession)=="function",$=typeof(s==null?void 0:s.deleteSession)=="function",V=m.useMemo(()=>u.flatMap(b=>b.remoteId==null?[]:[b.remoteId]),[u]),{allows:G}=gn({resourceType:"session",resourceIds:V});m.useEffect(()=>{if(S||i||c)return;const b=B.current;if(!b)return;let v=!1;const A=()=>{if(v||!P.current||b.clientHeight<=0)return;const X=b.scrollHeight-b.scrollTop-b.clientHeight;b.scrollHeight>b.clientHeight&&X>is||F.current.threads().loadMore()};b.addEventListener("scroll",A,{passive:!0});const k=typeof ResizeObserver>"u"?void 0:new ResizeObserver(()=>A());return k?k.observe(b):window.addEventListener("resize",A),A(),()=>{v=!0,b.removeEventListener("scroll",A),k==null||k.disconnect(),k||window.removeEventListener("resize",A)}},[a,S,i,c,d.length]);const W=()=>{if(o(le.Session.NEW,ue({is_composer_enabled:(l==null?void 0:l.isComposerEnabled)===!0},{...(l==null?void 0:l.mode.status)==="active"?{agentId:l.mode.agentId,agentName:l.mode.agentName}:{}})),n==null||n(),l==null||l.setLibraryOpen(!1),l==null||l.setSessionsOpen(!1),l!=null&&l.isComposerEnabled){l.openDraft();return}l==null||l.setSettingsOpen(!1),l==null||l.setSchedulesOpen(!1),l==null||l.setEnvironmentsOpen(!1),Promise.resolve(t.threads().switchToNewThread()).catch(()=>{})};let w;S?w=r.jsx(M,{message:R?"No recent chats":void 0}):i?w=r.jsx(j,{}):y.length===0?w=r.jsx(M,{message:R?"No recent chats":void 0}):w=r.jsx(zr.Root,{className:"flex min-h-0 flex-col gap-0.5",children:r.jsx(os,{selectionRef:K,indices:y,onThreadOpen:n,canRenameSession:U,canDeleteSession:$,canManageResource:b=>G(b,"MANAGE"),canDeleteResource:b=>G(b,"DELETE")})});const D=e==="recent-history"?null:r.jsxs("div",{className:"flex flex-col gap-1",children:[O?r.jsx(p,{onClick:W}):null,r.jsx("div",{className:"contents",onClick:()=>{T&&(n==null||n())},children:r.jsx(f,{})}),T?null:r.jsxs(r.Fragment,{children:[r.jsx(x,{}),r.jsx(g,{}),r.jsx(I,{})]})]});return r.jsx(h,{header:D,children:r.jsxs(cs,{viewportRef:B,hideScrollbar:R,children:[w,!S&&a?r.jsx("div",{className:"h-4 shrink-0","aria-hidden":!0}):null]})})}var ls=m.lazy(()=>Ne(()=>import("./SettingsBuilder-QM224JED-CLIPJX4x.js"),__vite__mapDeps([0,1,2]),import.meta.url)),us=m.lazy(()=>Ne(()=>import("./SchedulesPage-25JKAP5G-DEB03OMM.js"),__vite__mapDeps([3,4,1,2]),import.meta.url).then(n=>({default:n.SchedulesPage}))),ds=m.lazy(()=>Ne(()=>import("./EnvironmentsPage-5SEQP4QD-BuLuc3Ok.js"),__vite__mapDeps([5,4,1,2]),import.meta.url).then(n=>({default:n.EnvironmentsPage}))),ms="h-5 w-5 max-w-40 shrink-0 object-contain",fs="h-5 max-w-40 shrink-0 object-contain",ps="w-20",hs="w-80",Ve=z(On,"text-sidebar-text"),We="bg-primary-button-bg font-medium text-primary-button-text hover:bg-primary-button-hover hover:text-primary-button-text";function xs({overlayOpen:n,mode:e}){return!n&&(e==null?void 0:e.status)==="active"&&!e.isCreateAgent}function gs(){return An().presentation==="full"?null:r.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:r.jsx(Zt,{variant:"recent-history"})})}function vs(){var f;const n=Y(),e=ne(),t=C("AgentsLibraryButton"),s=C("SessionsBrowserButton"),o=C("SchedulesButton"),i=C("EnvironmentsButton"),c=(e==null?void 0:e.isNewChatEnabled)!==!1,a=(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||(e==null?void 0:e.environmentsOpen)===!0,d=e==null?void 0:e.mode,u=!a&&(d==null?void 0:d.status)==="active"&&!d.isCreateAgent&&((f=e==null?void 0:e.historyAgentFilter)==null?void 0:f.intent)!=="try-agent",l=!a&&d!=null&&st(d),h=()=>{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),e==null||e.setEnvironmentsOpen(!1),Promise.resolve(n.threads().switchToNewThread()).catch(()=>{})},p=()=>{e==null||e.setLibraryOpen(!1),e==null||e.setSessionsOpen(!1),e!=null&&e.isComposerEnabled&&e.openAgentBuilder()};return r.jsxs("nav",{className:"flex min-h-0 flex-1 flex-col items-center gap-1 p-1","aria-label":"Sidebar",children:[c?r.jsxs("button",{type:"button","aria-label":"Start new chat",title:"New chat","aria-current":u?"page":void 0,className:te({variant:"ghost",className:z(Ve,u&&We)}),onClick:h,children:[r.jsx(H,{name:"square-pen",size:14}),r.jsx("span",{className:"text-center",children:"New Chat"})]}):null,c&&(e!=null&&e.isComposerEnabled)?r.jsxs("button",{type:"button","aria-label":"Start new agent",title:"New Agent","aria-current":l?"page":void 0,className:te({variant:"ghost",className:z(Ve,l&&We)}),onClick:p,children:[r.jsx(H,{name:"agent-2",size:14}),r.jsx("span",{className:"text-center whitespace-nowrap",children:"Build Agent"})]}):null,r.jsx(t,{compact:!0}),r.jsx(s,{compact:!0}),r.jsx(o,{compact:!0}),r.jsx(i,{compact:!0})]})}function bs({className:n,railRef:e,...t}){const s=ot(),o=at(s),i=C("BrandLogo"),c=C("UserAvatar");return r.jsxs("aside",{ref:e,className:z(ps,"flex min-h-0 shrink-0 flex-col border-r border-border bg-sidebar-bg",n),...t,children:[r.jsx("div",{className:"flex h-14 w-full shrink-0 items-center justify-center text-text-primary",children:r.jsx(i,{variant:o.collapsedVariant,className:ms})}),r.jsx(vs,{}),r.jsxs("footer",{className:"flex shrink-0 flex-col items-center border-border p-2",children:[r.jsx(it,{labeled:!0,className:"flex-col"}),r.jsx(c,{labeled:!0,className:"mt-2 py-1.5"})]})]})}function ws({drawerRef:n,onClose:e}){const t=ot(),s=at(t),o=_n(),i=C("BrandLogo"),c=C("UserAvatar");return r.jsxs("aside",{ref:n,role:"dialog","aria-label":"Navigation",tabIndex:-1,className:z(hs,"absolute inset-y-0 left-0 z-10 flex min-h-0 flex-col border-r border-border bg-sidebar-bg shadow-lg outline-none md:hidden"),children:[r.jsxs("div",{className:"flex h-14 w-full shrink-0 items-center gap-2 border-b border-border px-3 text-text-primary",children:[r.jsx(i,{variant:s.expandedVariant,className:fs}),s.showTitle&&o!=null?r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:o}):r.jsx("span",{className:"min-w-0 flex-1"}),r.jsx("button",{type:"button","aria-label":"Close navigation",className:te({variant:"ghost",size:"icon"}),onClick:e,children:r.jsx(H,{name:"xmark"})})]}),r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(Zt,{variant:"mobile-drawer",onThreadOpen:e})}),r.jsxs("footer",{className:"flex shrink-0 items-center justify-around gap-1 border-t border-border p-2 text-sidebar-text",children:[r.jsx(it,{labeled:!0,onAction:e,className:"contents"}),r.jsx(c,{labeled:!0})]})]})}function Ts({className:n}){const e=ne(),t=Te(),s=C("AgentDetailsPage"),o=C("AgentsLibrary"),i=C("SessionsPage"),c=C("ShareChatButton"),a=C("ResetAgentBuilderButton"),d=C("ClearChatButton"),u=C("SaveAgentButton"),l=C("SelectAgentEmptyState"),[h,p]=m.useState(!1),f=m.useRef(null),x=m.useRef(null),g=m.useRef(null),I=m.useRef(!1),j=(e==null?void 0:e.mode.status)==="idle",M=(e==null?void 0:e.settingsOpen)===!0,y=(e==null?void 0:e.libraryOpen)===!0,B=y&&(e==null?void 0:e.libraryAgentId)==null,P=(e==null?void 0:e.sessionsOpen)===!0,F=(e==null?void 0:e.schedulesOpen)===!0,K=(e==null?void 0:e.environmentsOpen)===!0,O=M||y||P||F||K,S=e!=null&&st(e.mode),R=t&&(P||F||K||S&&!M&&!y),T=S&&!O&&!t,U=xs({overlayOpen:O,mode:e==null?void 0:e.mode}),$=Nn(),V=t&&(M||B),G=()=>p(!1),W=r.jsx("button",{ref:f,type:"button","aria-label":"Navigation","aria-expanded":h,className:z(te({variant:"ghost",size:"icon"}),"md:hidden"),onClick:()=>p(!0),children:r.jsx(H,{name:"panel-left"})});return m.useEffect(()=>{if(!h)return;const w=D=>{D.key==="Escape"&&(D.stopImmediatePropagation(),p(!1))};return window.addEventListener("keydown",w,!0),()=>window.removeEventListener("keydown",w,!0)},[h]),m.useEffect(()=>{var D,b;const w=g.current;if(h){I.current=!0,w&&(w.inert=!0),(D=x.current)==null||D.focus();return}I.current&&(w&&(w.inert=!1),(b=f.current)==null||b.focus(),I.current=!1)},[h]),r.jsxs("div",{className:z("relative flex h-full min-h-0 w-full min-w-0",n),children:[r.jsx(bs,{className:"hidden md:flex"}),T?r.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:r.jsx(kn,{})}):null,r.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col bg-primary-bg",children:[V?null:r.jsx(Pn,{className:z("bg-topbar-bg",(O||j||!$||R)&&"md:hidden"),start:W,title:!O&&!R?r.jsx(Bn,{}):null,end:!O&&!R?r.jsxs(r.Fragment,{children:[r.jsx(a,{}),r.jsx(c,{}),r.jsx(d,{}),r.jsx(u,{})]}):null}),r.jsx(En,{children:r.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1",children:[U?r.jsx(gs,{}):null,r.jsx("div",{ref:g,className:"min-h-0 min-w-0 flex-1",children:M?r.jsx(m.Suspense,{fallback:r.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[r.jsx(ve,{size:28,className:"text-text-primary"}),r.jsx("span",{className:"sr-only",children:"Loading"})]}),children:r.jsx(ls,{...V?{headerStart:W}:{}})}):R?r.jsx(Dn,{}):P?r.jsx(i,{}):y&&(e==null?void 0:e.libraryAgentId)!=null?r.jsx(s,{agentId:e.libraryAgentId},e.libraryAgentId):y?r.jsx(o,{onSelectAgent:G,...V?{headerStart:W}:{}}):F?r.jsx(m.Suspense,{fallback:r.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[r.jsx(ve,{size:28,className:"text-text-primary"}),r.jsx("span",{className:"sr-only",children:"Loading"})]}),children:r.jsx(us,{})}):K?r.jsx(m.Suspense,{fallback:r.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[r.jsx(ve,{size:28,className:"text-text-primary"}),r.jsx("span",{className:"sr-only",children:"Loading"})]}),children:r.jsx(ds,{})}):j?r.jsx(l,{}):r.jsx(Fn,{})})]})})]}),h?r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button","aria-label":"Close navigation backdrop",className:"absolute inset-0 z-[9] cursor-pointer bg-[var(--overlay)] md:hidden",onClick:G}),r.jsx(ws,{drawerRef:x,onClose:G})]}):null]})}export{Ts as SidebarLayout};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SettingsBuilder-QM224JED-Bp00qPG0.js","./index-o2o-gWoN.js","./index-B01pXqvC.css","./SchedulesPage-25JKAP5G-DRHxlR8X.js","./chunk-P2W5VLGK-B6YzGXAg.js","./EnvironmentsPage-5SEQP4QD-BxOU9R1E.js"])))=>i.map(i=>d[i]);
2
+ import{cm as _,cn as Jt,b0 as Y,j as r,co as en,r as m,bG as E,cp as Xe,cq as tn,cr as Ye,cs as qe,ct as Qe,cu as Ze,cv as Je,cw as Z,cx as nn,cy as N,cz as rn,cA as sn,cB as on,cC as an,cD as cn,cE as ln,cF as un,cG as dn,cH as je,cI as mn,cJ as fn,cK as me,cL as pn,cM as hn,cN as xn,cO as et,cP as Fe,cQ as fe,cR as Me,cS as ae,cT as Se,cU as Ce,cV as Le,cW as Ke,d as Re,q as tt,t as ne,u as C,w as gn,cX as vn,c as z,p as bn,cY as wn,_ as le,bE as ue,cZ as ge,c_ as yn,b1 as Te,bn as nt,c$ as In,S as jn,a2 as $e,I as H,D as Mn,a3 as te,d0 as rt,d1 as Sn,d2 as Cn,d3 as Ln,d4 as ze,bs as Rn,aa as Tn,E as Ge,b3 as st,d5 as Nn,P as Pn,d6 as En,b4 as ve,b5 as Dn,d7 as ot,d8 as at,bS as An,b6 as Ne,d9 as _n,cj as On}from"./index-o2o-gWoN.js";import{A as kn,N as Bn,T as Fn,S as it}from"./chunk-HDD5IS3M-C0hVH4Fk.js";const Pe=n=>{const e=_(8),{index:t,archived:s,children:o}=n;let i;e[0]!==s||e[1]!==t?(i=Jt({source:"threads",query:{type:"index",index:t,archived:s},get:u=>u.threads().item({index:t,archived:s})}),e[0]=s,e[1]=t,e[2]=i):i=e[2];let c;e[3]!==i?(c={threadListItem:i},e[3]=i,e[4]=c):c=e[4];const a=Y(c);let d;return e[5]!==a||e[6]!==o?(d=r.jsx(en,{value:a,children:o}),e[5]=a,e[6]=o,e[7]=d):d=e[7],d},ct=m.memo(n=>{const e=_(6),{index:t,archived:s,components:o}=n,i=s===void 0?!1:s,c=o.ThreadListItem;let a;e[0]!==c?(a=r.jsx(c,{}),e[0]=c,e[1]=a):a=e[1];let d;return e[2]!==i||e[3]!==t||e[4]!==a?(d=r.jsx(Pe,{index:t,archived:i,children:a}),e[2]=i,e[3]=t,e[4]=a,e[5]=d):d=e[5],d},(n,e)=>n.index===e.index&&n.archived===e.archived&&n.components.ThreadListItem===e.components.ThreadListItem);ct.displayName="ThreadListPrimitive.ItemByIndex";const He=({archived:n,children:e})=>{const t=E(s=>n?s.threads.archivedThreadIds.length:s.threads.threadIds.length);return Xe(()=>Array.from({length:t},(s,o)=>r.jsx(Pe,{index:o,archived:n,children:r.jsx(tn,{getItemState:i=>i.threads().item({index:o,archived:n}).getState(),children:i=>e({get threadListItem(){return i()}})})},o)),[t,n,e])},lt=n=>{const e=_(8),{archived:t,components:s,children:o}=n,i=t===void 0?!1:t;if(s){const a=s.ThreadListItem;let d;e[0]!==a?(d=()=>r.jsx(a,{}),e[0]=a,e[1]=d):d=e[1];let u;return e[2]!==i||e[3]!==d?(u=r.jsx(He,{archived:i,children:d}),e[2]=i,e[3]=d,e[4]=u):u=e[4],u}let c;return e[5]!==i||e[6]!==o?(c=r.jsx(He,{archived:i,children:o}),e[5]=i,e[6]=o,e[7]=c):c=e[7],c};lt.displayName="ThreadListPrimitive.Items";const ut=n=>{const e=_(2),{fallback:t}=n,s=E(Kn)||t;let o;return e[0]!==s?(o=r.jsx(r.Fragment,{children:s}),e[0]=s,e[1]=o):o=e[1],o};ut.displayName="ThreadListItemPrimitive.Title";function Kn(n){return n.threadListItem.title}const $n=()=>{const n=_(4),e=Y();let t;n[0]!==e?(t=()=>{e.threadListItem().archive()},n[0]=e,n[1]=t):t=n[1];const s=t;let o;return n[2]!==s?(o={archive:s},n[2]=s,n[3]=o):o=n[3],o},zn=()=>{const n=_(4),e=Y();let t;n[0]!==e?(t=()=>{e.threadListItem().delete()},n[0]=e,n[1]=t):t=n[1];const s=t;let o;return n[2]!==s?(o={delete:s},n[2]=s,n[3]=o):o=n[3],o},Gn=()=>{const n=_(4),e=Y();let t;n[0]!==e?(t=()=>{e.threadListItem().unarchive()},n[0]=e,n[1]=t):t=n[1];const s=t;let o;return n[2]!==s?(o={unarchive:s},n[2]=s,n[3]=o):o=n[3],o},Hn=()=>{const n=_(4),e=Y();let t;n[0]!==e?(t=()=>{e.threadListItem().switchTo()},n[0]=e,n[1]=t):t=n[1];const s=t;let o;return n[2]!==s?(o={switchTo:s},n[2]=s,n[3]=o):o=n[3],o},Un=()=>{const n=_(4),e=Y();let t;n[0]!==e?(t=()=>{e.threads().switchToNewThread()},n[0]=e,n[1]=t):t=n[1];const s=t;let o;return n[2]!==s?(o={switchToNewThread:s},n[2]=s,n[3]=o):o=n[3],o},Vn=()=>{const n=_(5),e=Y(),t=E(Wn);let s;n[0]!==e?(s=()=>{e.threads().loadMore()},n[0]=e,n[1]=s):s=n[1];const o=s;let i;return n[2]!==t||n[3]!==o?(i={loadMore:o,disabled:t},n[2]=t,n[3]=o,n[4]=i):i=n[4],i};function Wn(n){return!n.threads.hasMore||n.threads.isLoading||n.threads.isLoadingMore}var Xn=Object.defineProperty,L=(n,e)=>Xn(n,"name",{value:e,configurable:!0}),Yn=["Enter"," "],qn=["ArrowDown","PageUp","Home"],dt=["ArrowUp","PageDown","End"],Qn=[...qn,...dt],pe="Menu",[we,Zn,Jn]=Ze(pe),[J,mt]=Ye(pe,[Jn,qe,Qe]),Ee=qe(),ft=Qe(),[er,ie]=J(pe),[tr,De]=J(pe),nr=L(n=>{const{__scopeMenu:e,open:t=!1,children:s,dir:o,onOpenChange:i,modal:c=!0}=n,a=Ee(e),[d,u]=m.useState(null),l=m.useRef(!1),h=fn(i),p=me(o);return m.useEffect(()=>{const f=L(()=>{l.current=!0,document.addEventListener("pointerdown",x,{capture:!0,once:!0}),document.addEventListener("pointermove",x,{capture:!0,once:!0})},"handleKeyDown"),x=L(()=>l.current=!1,"handlePointer");return document.addEventListener("keydown",f,{capture:!0}),()=>{document.removeEventListener("keydown",f,{capture:!0}),document.removeEventListener("pointerdown",x,{capture:!0}),document.removeEventListener("pointermove",x,{capture:!0})}},[]),m.useEffect(()=>{if(!t)return;const f=L(()=>h(!1),"handleBlur");return window.addEventListener("blur",f),()=>window.removeEventListener("blur",f)},[t,h]),r.jsx(pn,{...a,children:r.jsx(er,{scope:e,open:t,onOpenChange:h,content:d,onContentChange:u,children:r.jsx(tr,{scope:e,onClose:m.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:l,dir:p,modal:c,children:s})})})},"Menu"),rr=m.forwardRef(L(function(e,t){const{__scopeMenu:s,...o}=e,i=Ee(s);return r.jsx(hn,{...i,...o,ref:t})},"MenuAnchor")),pt="MenuPortal",[sr,or]=J(pt,{forceMount:void 0}),ar=L(n=>{const{__scopeMenu:e,forceMount:t,children:s,container:o}=n,i=ie(pt,e);return r.jsx(sr,{scope:e,forceMount:t,children:r.jsx(Je,{present:t||i.open,children:r.jsx(xn,{asChild:!0,container:o,children:s})})})},"MenuPortal"),Q="MenuContent",[ir,ht]=J(Q),cr=m.forwardRef(L(function(e,t){const s=or(Q,e.__scopeMenu),{forceMount:o=s.forceMount,...i}=e,c=ie(Q,e.__scopeMenu),a=De(Q,e.__scopeMenu);return r.jsx(we.Provider,{scope:e.__scopeMenu,children:r.jsx(Je,{present:o||c.open,children:r.jsx(we.Slot,{scope:e.__scopeMenu,children:a.modal?r.jsx(lr,{...i,ref:t}):r.jsx(ur,{...i,ref:t})})})})},"MenuContent")),lr=m.forwardRef(L(function(e,t){const s=ie(Q,e.__scopeMenu),o=m.useRef(null),i=Z(t,o);return m.useEffect(()=>{const c=o.current;if(c)return nn(c)},[]),r.jsx(xt,{...e,ref:i,trapFocus:s.open,disableOutsidePointerEvents:s.open,disableOutsideScroll:!0,onFocusOutside:N(e.onFocusOutside,c=>c.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>s.onOpenChange(!1)})},"MenuRootContentModal")),ur=m.forwardRef(L(function(e,t){const s=ie(Q,e.__scopeMenu);return r.jsx(xt,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>s.onOpenChange(!1)})},"MenuRootContentNonModal")),dr=mn("MenuContent.ScrollLock"),xt=m.forwardRef(L(function(e,t){const{__scopeMenu:s,loop:o=!1,trapFocus:i,onOpenAutoFocus:c,onCloseAutoFocus:a,disableOutsidePointerEvents:d,onEntryFocus:u,onEscapeKeyDown:l,onPointerDownOutside:h,onFocusOutside:p,onInteractOutside:f,onDismiss:x,disableOutsideScroll:g,...I}=e,j=ie(Q,s),M=De(Q,s),y=Ee(s),B=ft(s),P=Zn(s),[F,K]=m.useState(null),O=m.useRef(null),S=Z(t,O,j.onContentChange),R=m.useRef(0),T=m.useRef(""),U=m.useRef(0),$=m.useRef(null),V=m.useRef("right"),G=m.useRef(0),W=g?sn:m.Fragment,w=g?{as:dr,allowPinchZoom:!0}:void 0,D=L(v=>{var ee,ke;const A=T.current+v,k=P().filter(q=>!q.disabled),X=document.activeElement,he=(ee=k.find(q=>q.ref.current===X))==null?void 0:ee.textValue,xe=k.map(q=>q.textValue),Oe=yt(xe,A,he),oe=(ke=k.find(q=>q.textValue===Oe))==null?void 0:ke.ref.current;L((function q(Be){T.current=Be,window.clearTimeout(R.current),Be!==""&&(R.current=window.setTimeout(()=>q(""),1e3))}),"updateSearch")(A),oe&&setTimeout(()=>oe.focus())},"handleTypeaheadSearch");m.useEffect(()=>()=>window.clearTimeout(R.current),[]),rn();const b=m.useCallback(v=>{var k,X;return V.current===((k=$.current)==null?void 0:k.side)&&jt(v,(X=$.current)==null?void 0:X.area)},[]);return r.jsx(ir,{scope:s,searchRef:T,onItemEnter:m.useCallback(v=>{b(v)&&v.preventDefault()},[b]),onItemLeave:m.useCallback(v=>{var A;b(v)||((A=O.current)==null||A.focus(),K(null))},[b]),onTriggerLeave:m.useCallback(v=>{b(v)&&v.preventDefault()},[b]),pointerGraceTimerRef:U,onPointerGraceIntentChange:m.useCallback(v=>{$.current=v},[]),children:r.jsx(W,{...w,children:r.jsx(on,{asChild:!0,trapped:i,onMountAutoFocus:N(c,v=>{var A;v.preventDefault(),(A=O.current)==null||A.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:r.jsx(an,{asChild:!0,disableOutsidePointerEvents:d,onEscapeKeyDown:l,onPointerDownOutside:h,onFocusOutside:p,onInteractOutside:f,onDismiss:x,children:r.jsx(cn,{asChild:!0,...B,dir:M.dir,orientation:"vertical",loop:o,currentTabStopId:F,onCurrentTabStopIdChange:K,onEntryFocus:N(u,v=>{M.isUsingKeyboardRef.current||v.preventDefault()}),preventScrollOnEntryFocus:!0,children:r.jsx(ln,{role:"menu","aria-orientation":"vertical","data-state":gt(j.open),"data-radix-menu-content":"",dir:M.dir,...y,...I,ref:S,style:{outline:"none",...I.style},onKeyDown:N(I.onKeyDown,v=>{const k=v.target.closest("[data-radix-menu-content]")===v.currentTarget,X=v.ctrlKey||v.altKey||v.metaKey,he=v.key.length===1;k&&(v.key==="Tab"&&v.preventDefault(),!X&&he&&D(v.key));const xe=O.current;if(v.target!==xe||!Qn.includes(v.key))return;v.preventDefault();const oe=P().filter(ee=>!ee.disabled).map(ee=>ee.ref.current);dt.includes(v.key)&&oe.reverse(),bt(oe)}),onBlur:N(e.onBlur,v=>{v.currentTarget.contains(v.target)||(window.clearTimeout(R.current),T.current="")}),onPointerMove:N(e.onPointerMove,de(v=>{const A=v.target,k=G.current!==v.clientX;if(v.currentTarget.contains(A)&&k){const X=v.clientX>G.current?"right":"left";V.current=X,G.current=v.clientX}}))})})})})})})},"MenuContentImpl")),ye="MenuItem",Ue="menu.itemSelect",mr=m.forwardRef(L(function(e,t){const{disabled:s=!1,onSelect:o,...i}=e,c=m.useRef(null),a=De(ye,e.__scopeMenu),d=ht(ye,e.__scopeMenu),u=Z(t,c),l=m.useRef(!1),h=L(()=>{const p=c.current;if(!s&&p){const f=new CustomEvent(Ue,{bubbles:!0,cancelable:!0});p.addEventListener(Ue,x=>o==null?void 0:o(x),{once:!0}),un(p,f),f.defaultPrevented?l.current=!1:a.onClose()}},"handleSelect");return r.jsx(fr,{...i,ref:u,disabled:s,onClick:N(e.onClick,h),onPointerDown:p=>{var f;(f=e.onPointerDown)==null||f.call(e,p),l.current=!0},onPointerUp:N(e.onPointerUp,p=>{var f;l.current||(f=p.currentTarget)==null||f.click()}),onKeyDown:N(e.onKeyDown,p=>{s||p.target!==p.currentTarget||d.searchRef.current!==""&&p.key===" "||Yn.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})},"MenuItem")),fr=m.forwardRef(L(function(e,t){const{__scopeMenu:s,disabled:o=!1,textValue:i,...c}=e,a=ht(ye,s),d=ft(s),u=m.useRef(null),l=Z(t,u),[h,p]=m.useState(!1),[f,x]=m.useState("");return m.useEffect(()=>{const g=u.current;g&&x((g.textContent??"").trim())},[c.children]),r.jsx(we.ItemSlot,{scope:s,disabled:o,textValue:i??f,children:r.jsx(dn,{asChild:!0,...d,focusable:!o,children:r.jsx(je.div,{role:"menuitem","data-highlighted":h?"":void 0,"aria-disabled":o||void 0,"data-disabled":o?"":void 0,...c,ref:l,onPointerMove:N(e.onPointerMove,de(g=>{o?a.onItemLeave(g):(a.onItemEnter(g),g.defaultPrevented||g.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:N(e.onPointerLeave,de(g=>a.onItemLeave(g))),onFocus:N(e.onFocus,()=>p(!0)),onBlur:N(e.onBlur,()=>p(!1))})})})},"MenuItemImpl")),pr="MenuRadioGroup",[js,Ms]=J(pr,{value:void 0,onValueChange:L(()=>{},"onValueChange")}),hr="MenuItemIndicator",[Ss,Cs]=J(hr,{checked:!1}),xr=m.forwardRef(L(function(e,t){const{__scopeMenu:s,...o}=e;return r.jsx(je.div,{role:"separator","aria-orientation":"horizontal",...o,ref:t})},"MenuSeparator")),gr="MenuSub",[Ls,Rs]=J(gr);function gt(n){return n?"open":"closed"}L(gt,"getOpenState");function vt(n){return n==="indeterminate"}L(vt,"isIndeterminate");function vr(n){return vt(n)?"indeterminate":n?"checked":"unchecked"}L(vr,"getCheckedState");function bt(n){const e=document.activeElement;for(const t of n)if(t===e||(t.focus(),document.activeElement!==e))return}L(bt,"focusFirst");function wt(n,e){return n.map((t,s)=>n[(e+s)%n.length])}L(wt,"wrapArray");function yt(n,e,t){const o=e.length>1&&Array.from(e).every(u=>u===e[0])?e[0]:e,i=t?n.indexOf(t):-1;let c=wt(n,Math.max(i,0));o.length===1&&(c=c.filter(u=>u!==t));const d=c.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return d!==t?d:void 0}L(yt,"getNextMatch");function It(n,e){const{x:t,y:s}=n;let o=!1;for(let i=0,c=e.length-1;i<e.length;c=i++){const a=e[i],d=e[c],u=a.x,l=a.y,h=d.x,p=d.y;l>s!=p>s&&t<(h-u)*(s-l)/(p-l)+u&&(o=!o)}return o}L(It,"isPointInPolygon");function jt(n,e){if(!e)return!1;const t={x:n.clientX,y:n.clientY};return It(t,e)}L(jt,"isPointerInGraceArea");function de(n){return e=>e.pointerType==="mouse"?n(e):void 0}L(de,"whenMouse");var br=nr,wr=rr,yr=ar,Ir=cr,jr=mr,Mr=xr,Sr=Object.defineProperty,re=(n,e)=>Sr(n,"name",{value:e,configurable:!0}),Ae="DropdownMenu",[Cr,Mt]=Ye(Ae,[mt]),se=mt(),[Lr,St]=Cr(Ae),Ct=re(n=>{const{__scopeDropdownMenu:e,children:t,dir:s,open:o,defaultOpen:i,onOpenChange:c,modal:a=!0}=n,d=se(e),u=m.useRef(null),[l,h]=et({prop:o,defaultProp:i??!1,onChange:c,caller:Ae});return r.jsx(Lr,{scope:e,triggerId:Fe(),triggerRef:u,contentId:Fe(),open:l,onOpenChange:h,onOpenToggle:m.useCallback(()=>h(p=>!p),[h]),modal:a,children:r.jsx(br,{...d,open:l,onOpenChange:h,dir:s,modal:a,children:t})})},"DropdownMenu"),Rr="DropdownMenuTrigger",Lt=m.forwardRef(re(function(e,t){const{__scopeDropdownMenu:s,disabled:o=!1,...i}=e,c=St(Rr,s),a=se(s),d=Z(t,c.triggerRef);return r.jsx(wr,{asChild:!0,...a,children:r.jsx(je.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":o?"":void 0,disabled:o,...i,ref:d,onPointerDown:N(e.onPointerDown,u=>{!o&&u.button===0&&u.ctrlKey===!1&&(c.onOpenToggle(),c.open||u.preventDefault())}),onKeyDown:N(e.onKeyDown,u=>{o||(["Enter"," "].includes(u.key)&&c.onOpenToggle(),u.key==="ArrowDown"&&c.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(u.key)&&u.preventDefault())})})})},"DropdownMenuTrigger")),Rt=re(n=>{const{__scopeDropdownMenu:e,...t}=n,s=se(e);return r.jsx(yr,{...s,...t})},"DropdownMenuPortal"),Tr="DropdownMenuContent",Tt=m.forwardRef(re(function(e,t){const{__scopeDropdownMenu:s,...o}=e,i=St(Tr,s),c=se(s),a=m.useRef(!1);return r.jsx(Ir,{id:i.contentId,"aria-labelledby":i.triggerId,...c,...o,ref:t,onCloseAutoFocus:N(e.onCloseAutoFocus,d=>{var u;a.current||(u=i.triggerRef.current)==null||u.focus(),a.current=!1,d.preventDefault()}),onInteractOutside:N(e.onInteractOutside,d=>{const u=d.detail.originalEvent,l=u.button===0&&u.ctrlKey===!0,h=u.button===2||l;(!i.modal||h)&&(a.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")),Nt=m.forwardRef(re(function(e,t){const{__scopeDropdownMenu:s,...o}=e,i=se(s);return r.jsx(jr,{...i,...o,ref:t})},"DropdownMenuItem")),Pt=m.forwardRef(re(function(e,t){const{__scopeDropdownMenu:s,...o}=e,i=se(s);return r.jsx(Mr,{...i,...o,ref:t})},"DropdownMenuSeparator")),Et=Ct,Dt=Lt,Nr=Rt,At=Tt,_t=Nt,Ot=Pt;const Pr=Object.freeze(Object.defineProperty({__proto__:null,Content:At,DropdownMenu:Ct,DropdownMenuContent:Tt,DropdownMenuItem:Nt,DropdownMenuPortal:Rt,DropdownMenuSeparator:Pt,DropdownMenuTrigger:Lt,Item:_t,Portal:Nr,Root:Et,Separator:Ot,Trigger:Dt,createDropdownMenuScope:Mt},Symbol.toStringTag,{value:"Module"})),Er=fe(Dt),Dr=fe(At),Ar=fe(_t),_r=fe(Ot),kt=m.forwardRef((n,e)=>{const t=_(15);let s,o,i;t[0]!==n?({onClick:o,disabled:s,...i}=n,t[0]=n,t[1]=s,t[2]=o,t[3]=i):(s=t[1],o=t[2],i=t[3]);const c=E(Or),{switchToNewThread:a}=Un();let d;t[4]!==c?(d=c?{"data-active":"true","aria-current":"true"}:null,t[4]=c,t[5]=d):d=t[5];let u;t[6]!==o||t[7]!==a?(u=N(o,a),t[6]=o,t[7]=a,t[8]=u):u=t[8];let l;return t[9]!==s||t[10]!==e||t[11]!==i||t[12]!==d||t[13]!==u?(l=r.jsx(Me.button,{type:"button",...d,...i,ref:e,disabled:s,onClick:u}),t[9]=s,t[10]=e,t[11]=i,t[12]=d,t[13]=u,t[14]=l):l=t[14],l});kt.displayName="ThreadListPrimitive.New";function Or(n){return n.threads.newThreadId===n.threads.mainThreadId}const kr=()=>{const{loadMore:n,disabled:e}=Vn();return e?null:n},Br=ae("ThreadListPrimitive.LoadMore",kr),[Fr,Kr]=Ze("ThreadList"),Ie=Fr,Bt=Ce(null),$r=Bt.Provider,_e=()=>Se(Bt),Ft=m.forwardRef((n,e)=>{const t=_(3);let s;return t[0]!==n||t[1]!==e?(s=r.jsx(Ie.Provider,{scope:void 0,children:r.jsx(Ie.Slot,{scope:void 0,children:r.jsx(Me.div,{...n,ref:e})})}),t[0]=n,t[1]=e,t[2]=s):s=t[2],s});Ft.displayName="ThreadListPrimitive.Root";var zr=Le({ItemByIndex:()=>ct,Items:()=>lt,LoadMore:()=>Br,New:()=>kt,Root:()=>Ft});const Kt=m.forwardRef((n,e)=>{const t=E(u=>u.threads.mainThreadId===u.threadListItem.id),s=Ke(null),o=Ke(null),i=Xe(()=>({triggerRef:s,moreRef:o}),[]),c=Kr(void 0),a=me(),d=u=>{const l=a==="rtl"?"ArrowLeft":"ArrowRight",h=a==="rtl"?"ArrowRight":"ArrowLeft",p=s.current,f=o.current;if(p&&u.target===p)if(u.key==="ArrowDown"||u.key==="ArrowUp"){const x=c().map(I=>I.ref.current).filter(I=>I!==null),g=x[x.indexOf(p)+(u.key==="ArrowDown"?1:-1)];g&&(g.focus(),u.preventDefault())}else u.key===l&&f&&(f.focus(),u.preventDefault());else f&&u.target===f&&u.key===h&&(p==null||p.focus(),u.preventDefault())};return r.jsx($r,{value:i,children:r.jsx(Me.div,{...t?{"data-active":"true","aria-current":"true"}:null,...n,onKeyDown:N(n.onKeyDown,d),ref:e})})});Kt.displayName="ThreadListItemPrimitive.Root";const Gr=()=>{const{archive:n}=$n();return n},Hr=ae("ThreadListItemPrimitive.Archive",Gr),Ur=()=>{const{unarchive:n}=Gn();return n},Vr=ae("ThreadListItemPrimitive.Unarchive",Ur),Wr=()=>{const{delete:n}=zn();return n},Xr=ae("ThreadListItemPrimitive.Delete",Wr),Yr=()=>{const{switchTo:n}=Hn();return n},qr=ae("ThreadListItemPrimitive.Trigger",Yr),$t=m.forwardRef((n,e)=>{var i;const t=_(3),s=Z(e,(i=_e())==null?void 0:i.triggerRef);let o;return t[0]!==n||t[1]!==s?(o=r.jsx(Ie.ItemSlot,{scope:void 0,children:r.jsx(qr,{...n,ref:s})}),t[0]=n,t[1]=s,t[2]=o):o=t[2],o});$t.displayName="ThreadListItemPrimitive.Trigger";var zt=Le({Archive:()=>Hr,Delete:()=>Xr,Root:()=>Kt,Title:()=>ut,Trigger:()=>$t,Unarchive:()=>Vr});const ce=Mt(),Gt=Ce(()=>{}),Ht=()=>Se(Gt),Ut=Ce(!1),Vt=()=>Se(Ut),Wt=n=>{const e=_(26);let t,s,o,i,c,a,d;e[0]!==n?({__scopeThreadListItemMore:t,open:c,defaultOpen:s,onOpenChange:i,sharedFocusGroup:d,modal:o,...a}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=o,e[4]=i,e[5]=c,e[6]=a,e[7]=d):(t=e[1],s=e[2],o=e[3],i=e[4],c=e[5],a=e[6],d=e[7]);const u=d===void 0?!1:d,l=u?!1:o??!0,h=ce(t),p=s??!1;let f;e[8]!==i?(f=i?{onChange:i}:{},e[8]=i,e[9]=f):f=e[9];let x;e[10]!==c||e[11]!==p||e[12]!==f?(x={prop:c,defaultProp:p,caller:"ThreadListItemMorePrimitive.Root",...f},e[10]=c,e[11]=p,e[12]=f,e[13]=x):x=e[13];const[g,I]=et(x);let j;e[14]!==l||e[15]!==g||e[16]!==a||e[17]!==h||e[18]!==I?(j=r.jsx(Et,{...h,...a,modal:l,open:g,onOpenChange:I}),e[14]=l,e[15]=g,e[16]=a,e[17]=h,e[18]=I,e[19]=j):j=e[19];let M;e[20]!==I||e[21]!==j?(M=r.jsx(Gt.Provider,{value:I,children:j}),e[20]=I,e[21]=j,e[22]=M):M=e[22];let y;return e[23]!==u||e[24]!==M?(y=r.jsx(Ut.Provider,{value:u,children:M}),e[23]=u,e[24]=M,e[25]=y):y=e[25],y};Wt.displayName="ThreadListItemMorePrimitive.Root";const Xt=m.forwardRef((n,e)=>{const t=_(10),{__scopeThreadListItemMore:s,...o}=n,i=ce(s),c=_e(),a=Ht(),d=Vt(),u=Z(e,c==null?void 0:c.moreRef),l=me()==="rtl"?"ArrowLeft":"ArrowRight",h=Er;let p;t[0]!==l||t[1]!==a||t[2]!==d?(p=g=>{!d||g.key!==l||(g.preventDefault(),a(!0))},t[0]=l,t[1]=a,t[2]=d,t[3]=p):p=t[3];const f=N(o.onKeyDown,p);let x;return t[4]!==h||t[5]!==u||t[6]!==o||t[7]!==i||t[8]!==f?(x=r.jsx(h,{...i,...o,onKeyDown:f,ref:u}),t[4]=h,t[5]=u,t[6]=o,t[7]=i,t[8]=f,t[9]=x):x=t[9],x});Xt.displayName="ThreadListItemMorePrimitive.Trigger";const Yt=m.forwardRef((n,e)=>{const t=_(21),{__scopeThreadListItemMore:s,portalProps:o,sideOffset:i,...c}=n,a=i===void 0?4:i,d=ce(s),u=Ht(),l=_e(),h=Vt(),p=me()==="rtl"?"ArrowRight":"ArrowLeft",f=Pr,x=Dr;let g;t[0]!==p||t[1]!==(l==null?void 0:l.moreRef)||t[2]!==u||t[3]!==h?(g=P=>{var F;!h||P.key!==p||(P.preventDefault(),u(!1),(F=l==null?void 0:l.moreRef.current)==null||F.focus())},t[0]=p,t[1]=l==null?void 0:l.moreRef,t[2]=u,t[3]=h,t[4]=g):g=t[4];const I=N(c.onKeyDown,g);let j;t[5]!==(l==null?void 0:l.moreRef)||t[6]!==h?(j=()=>{var P;h&&((P=l==null?void 0:l.moreRef.current)==null||P.focus())},t[5]=l==null?void 0:l.moreRef,t[6]=h,t[7]=j):j=t[7];const M=N(c.onEscapeKeyDown,j);let y;t[8]!==x||t[9]!==e||t[10]!==c||t[11]!==d||t[12]!==a||t[13]!==I||t[14]!==M?(y=r.jsx(x,{...d,...c,onKeyDown:I,onEscapeKeyDown:M,ref:e,sideOffset:a}),t[8]=x,t[9]=e,t[10]=c,t[11]=d,t[12]=a,t[13]=I,t[14]=M,t[15]=y):y=t[15];let B;return t[16]!==o||t[17]!==d||t[18]!==f.Portal||t[19]!==y?(B=r.jsx(f.Portal,{...d,...o,children:y}),t[16]=o,t[17]=d,t[18]=f.Portal,t[19]=y,t[20]=B):B=t[20],B});Yt.displayName="ThreadListItemMorePrimitive.Content";const qt=m.forwardRef((n,e)=>{const t=_(7);let s,o;t[0]!==n?({__scopeThreadListItemMore:s,...o}=n,t[0]=n,t[1]=s,t[2]=o):(s=t[1],o=t[2]);const i=ce(s);let c;return t[3]!==e||t[4]!==o||t[5]!==i?(c=r.jsx(Ar,{...i,...o,ref:e}),t[3]=e,t[4]=o,t[5]=i,t[6]=c):c=t[6],c});qt.displayName="ThreadListItemMorePrimitive.Item";const Qt=m.forwardRef((n,e)=>{const t=_(7);let s,o;t[0]!==n?({__scopeThreadListItemMore:s,...o}=n,t[0]=n,t[1]=s,t[2]=o):(s=t[1],o=t[2]);const i=ce(s);let c;return t[3]!==e||t[4]!==o||t[5]!==i?(c=r.jsx(_r,{...i,...o,ref:e}),t[3]=e,t[4]=o,t[5]=i,t[6]=c):c=t[6],c});Qt.displayName="ThreadListItemMorePrimitive.Separator";var be=Le({Content:()=>Yt,Item:()=>qt,Root:()=>Wt,Separator:()=>Qt,Trigger:()=>Xt});function Qr(){const n=ne(),e=Re(),t=Te(),s=nt(),o=t||s,[i,c]=m.useState(!1),[a,d]=m.useState(""),[u,l]=m.useState(null),h=m.useRef(null),p=m.useRef(null),f=m.useId(),x=(n==null?void 0:n.isLibraryEnabled)===!0&&e!=null,g=(n==null?void 0:n.historyAgentFilter)??null;m.useEffect(()=>{i||d("")},[i]);const{agents:I,isInitialLoading:j,isSearching:M,loadingMore:y,hasMore:B,listRef:P,sentinelRef:F}=In({enabled:i&&x,query:a});if(m.useLayoutEffect(()=>{if(!i||o){l(null);return}const S=()=>{var T;const R=(T=h.current)==null?void 0:T.getBoundingClientRect();R&&l({top:R.top,left:R.right+4})};return S(),window.addEventListener("resize",S),window.addEventListener("scroll",S,!0),()=>{window.removeEventListener("resize",S),window.removeEventListener("scroll",S,!0)}},[i,o]),m.useEffect(()=>{if(!i||o)return;const S=R=>{var U,$;const T=R.target;(U=h.current)!=null&&U.contains(T)||($=p.current)!=null&&$.contains(T)||c(!1)};return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[i,o]),!x)return null;const K=S=>{(n==null?void 0:n.isComposerEnabled)===!0?n.openDraft():n==null||n.openLibraryHome(),n==null||n.setHistoryAgentFilter(S),c(!1)},O=r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"p-1",onMouseDown:S=>S.stopPropagation(),children:[r.jsx(jn,{query:a,setQuery:d,placeholder:"Search agents"}),M?r.jsx("p",{className:"text-text-secondary px-1 pt-1 text-[11px]",role:"status",children:"Searching…"}):null]}),r.jsxs("div",{ref:P,className:z("mt-1 overflow-y-auto",o?"min-h-0 flex-1 px-1 pb-2":"min-h-48 max-h-64"),children:[a.trim()===""?r.jsxs($e,{className:z("justify-between",g==null&&"bg-dropdown-selected-item-bg text-dropdown-selected-item-text"),onClick:()=>K(null),children:["All chats",g==null?r.jsx(H,{name:"check",className:"size-3.5 shrink-0"}):null]}):null,j?r.jsx("p",{className:"px-2 py-3 text-center text-xs text-text-secondary",children:"Loading…"}):I.length===0?r.jsx("p",{className:"text-text-secondary px-2 py-6 text-center text-xs",role:"status",children:a.trim()?`No agents match "${a.trim()}".`:"No agents yet."}):r.jsxs(r.Fragment,{children:[I.map(S=>{const R=Mn(S),T=(g==null?void 0:g.agentId)===R;return r.jsxs($e,{className:z("justify-between gap-2 text-left",T&&"bg-dropdown-selected-item-bg text-dropdown-selected-item-text"),onClick:()=>K({agentId:R,agentName:S.name,intent:"history"}),children:[r.jsx("span",{className:"min-w-0 truncate",children:S.name}),T?r.jsx(H,{name:"check",className:"size-3.5 shrink-0"}):null]},R)}),B?r.jsx("div",{ref:F,className:"flex h-6 shrink-0 items-center justify-center","aria-hidden":!0,children:y?r.jsx("span",{className:"text-text-secondary text-[11px]",role:"status",children:"Loading more…"}):null}):null]})]})]});return r.jsxs("div",{className:"relative shrink-0",children:[r.jsxs("button",{ref:h,type:"button","aria-label":g!=null?`Filter chat history by agent (${g.agentName})`:"Filter chat history by agent","aria-haspopup":o?"dialog":"menu","aria-expanded":i,"aria-controls":i?f:void 0,title:"Filter by agent",className:te({variant:"ghost",size:"icon",className:z("relative size-7 shrink-0 text-text-secondary hover:bg-ghost-button-hover hover:text-ghost-button-text",g!=null&&"text-text-primary")}),onClick:()=>c(S=>!S),children:[r.jsx(H,{name:"funnel",className:"size-3.5"}),g!=null?r.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]}),o&&i?r.jsx(rt,{open:!0,onOpenChange:c,id:f,"aria-label":"Filter agents",children:r.jsx("div",{className:"flex min-h-0 flex-1 flex-col p-2",role:"menu",children:O})}):null,!o&&i&&u!=null?Sn.createPortal(r.jsx("div",{ref:p,id:f,role:"menu","aria-label":"Filter agents",style:{top:u.top,left:u.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:O}),Cn(h.current)):null]})}function Zr({open:n,initialTitle:e,saving:t=!1,onOpenChange:s,onSave:o}){const[i,c]=m.useState(e),a=m.useRef(null);m.useEffect(()=>{n&&c(e)},[n,e]),m.useEffect(()=>{if(!n)return;const f=a.current;f!=null&&(f.focus(),f.select())},[n]);const d=i.trim(),l=d.length>0&&d.length<=ze&&!t,h=()=>{l&&o(d)},p=f=>{t||s(f)};return r.jsx(Rn,{open:n,onOpenChange:p,title:"Rename session",contentSized:!0,"aria-label":"Rename session",footer:r.jsxs("div",{className:"flex items-center justify-end gap-2",children:[r.jsx(Ge.Secondary,{type:"button",disabled:t,onClick:()=>p(!1),children:"Cancel"}),r.jsx(Ge.Primary,{type:"button",disabled:!l,onClick:h,children:"Save"})]}),children:r.jsx("div",{className:"px-5 py-4",children:r.jsx("input",{ref:a,"aria-label":"Session title",value:i,readOnly:t,maxLength:ze,className:Tn("h-9"),onChange:f=>c(f.target.value),onKeyDown:f=>{f.key==="Enter"&&(f.preventDefault(),h())}})})})}var Jr="flex w-full cursor-pointer select-none items-center gap-2 rounded-md px-2 py-1.5 text-sm font-medium outline-none transition-colors hover:bg-ghost-button-hover focus:bg-ghost-button-hover data-[highlighted]:bg-ghost-button-hover",es="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 ts({canRename:n,renameDisabled:e,canDelete:t,deleteDisabled:s,onRename:o,onDelete:i}){const c=C("PermissionGuard"),a=nt(),d=Te(),[u,l]=m.useState(!1),[h,p]=m.useState(),f=d||a,x=m.useCallback(M=>{const y=M==null?void 0:M.closest(".aui-theme-root");p(y instanceof HTMLElement?y:void 0)},[]),g=te({variant:"ghost",size:"icon",className:"size-7 shrink-0 text-text-secondary hover:bg-transparent hover:text-text-primary"}),I=n?r.jsx(c,{allowed:!e,children:r.jsxs("button",{type:"button",className:Jr,disabled:e,onClick:()=>{e||(l(!1),o())},children:[r.jsx(H,{name:"pencil",className:"size-3.5"}),"Rename"]})}):null,j=t?r.jsx(c,{allowed:!s,children:r.jsxs(zt.Delete,{className:es,onClick:()=>{s||(l(!1),i())},children:[r.jsx(H,{name:"trash",className:"size-3.5"}),"Delete"]})}):null;return f?r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button","aria-label":"Session actions",title:"Session actions","aria-haspopup":"dialog","aria-expanded":u,className:g,onClick:()=>l(!0),children:r.jsx(H,{name:"ellipsis",className:"size-3.5"})}),u?r.jsx(rt,{open:!0,onOpenChange:l,"aria-label":"Session actions",children:r.jsxs("div",{className:"flex flex-col gap-1 p-2 *:w-full",role:"menu",children:[I,j]})}):null]}):r.jsxs(be.Root,{sharedFocusGroup:!0,children:[r.jsx(be.Trigger,{ref:x,"aria-label":"Session actions",title:"Session actions",className:g,children:r.jsx(H,{name:"ellipsis",className:"size-3.5"})}),r.jsxs(be.Content,{portalProps:{container:h},align:"end",sideOffset:4,className:"aui-popup-enter font-sans-flex z-50 min-w-32 rounded-md border border-border bg-card-bg p-1 text-text-primary shadow-md *:w-full",children:[I,j]})]})}function ns({selectionRef:n,onThreadOpen:e,canRenameSession:t,canDeleteSession:s,canManageResource:o,canDeleteResource:i}){const c=Y(),a=ne(),d=Re(),u=m.useRef(a==null?void 0:a.runtimeKey);u.current=a==null?void 0:a.runtimeKey;const l=tt(),h=bn(),p=C("ThreadListRow"),f=E(w=>w.threadListItem.id),x=E(w=>w.threadListItem.remoteId),g=E(w=>w.threadListItem.title),I=E(w=>w.threadListItem.lastMessageAt),j=E(w=>w.threadListItem.custom),M=E(w=>w.threads.mainThreadId),y=wn(j),B=t&&x!=null,P=s&&x!=null,F=B||P,K=x!=null&&!o(x),O=x!=null&&!i(x),S=(a==null?void 0:a.libraryOpen)===!0||(a==null?void 0:a.sessionsOpen)===!0||(a==null?void 0:a.schedulesOpen)===!0||(a==null?void 0:a.environmentsOpen)===!0,[R,T]=m.useState(!1),[U,$]=m.useState(!1),V=g??"New Chat",G=async w=>{if(w===(g??"").trim()){T(!1);return}$(!0);try{await c.threadListItem().rename(w),l(le.Session.RENAMED,ue(void 0,{sessionId:x,agentName:y})),T(!1)}catch(D){h==null||h.showError(D)}finally{$(!1)}},W=({sessionMutable:w,rowAgentName:D})=>{const b=!w&&(a==null?void 0:a.mode.status)==="active"&&!a.mode.isMutable&&(D==null?a.mode.agentName==null&&a.mode.agentId==null:a.mode.agentName===D||a.mode.agentId===D),v=Ln({sessionMutable:w,shellMutable:(a==null?void 0:a.mode.status)==="active"&&a.mode.isMutable,...(a==null?void 0:a.mode.status)==="active"&&a.mode.isMutable?{shellAgentName:a.mode.agentName,shellAgentId:a.mode.agentId}:{},remoteId:x,pendingSessionId:a==null?void 0:a.pendingSessionId});if((b||v)&&x!=null&&(a==null?void 0:a.sessionAccessError)==null){Promise.resolve(c.threads().switchToThread(f)).catch(()=>{});return}if(x!=null){a==null||a.openHistorySession({sessionId:x,isMutable:w,...D!=null?{agentName:D}:{}});return}Promise.resolve(c.threads().switchToThread(f)).catch(()=>{})};return r.jsxs(zt.Root,{className:"min-w-0",children:[r.jsx(p,{title:V,active:f===M&&!S,agentName:y,lastMessageAt:I,onSelect:()=>{l(le.Session.SELECTED,ue({is_mutable:ge(j)},{sessionId:x,agentName:y}));const w=++n.current,D=a==null?void 0:a.runtimeKey;if(e==null||e(),a==null||a.setSettingsOpen(!1),a==null||a.setLibraryOpen(!1),a==null||a.setSessionsOpen(!1),a==null||a.setSchedulesOpen(!1),a==null||a.setEnvironmentsOpen(!1),x!=null&&d!=null&&yn(j)===void 0&&y==null){d.getSession({sessionId:x}).then(b=>({sessionMutable:b.isMutable,rowAgentName:b.agentName??void 0}),()=>({sessionMutable:ge(j),rowAgentName:y})).then(b=>{n.current===w&&u.current===D&&W(b)});return}W({sessionMutable:ge(j),rowAgentName:y})},actions:F?r.jsx(ts,{canRename:B,renameDisabled:K,canDelete:P,deleteDisabled:O,onRename:()=>T(!0),onDelete:()=>{l(le.Session.DELETED,ue(void 0,{sessionId:x,agentName:y}))}}):void 0}),r.jsx(Zr,{open:R,initialTitle:g??"",saving:U,onOpenChange:T,onSave:w=>{G(w)}})]})}function rs(n){const e=E(s=>s.threads.threadIds),t=E(s=>s.threads.threadItems);return m.useMemo(()=>{const s=vn({threadIds:e,threadItems:t});if(n==="default")return s;const o=new Map;for(const i of t)o.set(i.id,i),i.remoteId!=null&&o.set(i.remoteId,i);return s.filter(i=>{const c=e[i];if(c===void 0)return!1;const a=o.get(c);return(a==null?void 0:a.remoteId)!=null})},[e,t,n])}function ss(n){return n==="recent-history"||n==="mobile-drawer"}function os({selectionRef:n,indices:e,onThreadOpen:t,canRenameSession:s,canDeleteSession:o,canManageResource:i,canDeleteResource:c}){const a=E(d=>d.threads.threadIds);return r.jsx(r.Fragment,{children:e.map(d=>{const u=a[d]??String(d);return r.jsx(Pe,{index:d,archived:!1,children:r.jsx(ns,{selectionRef:n,onThreadOpen:t,canRenameSession:s,canDeleteSession:o,canManageResource:i,canDeleteResource:c})},u)})})}var as="aui_thread-list-viewport",is=80;function cs({children:n,viewportRef:e,hideScrollbar:t}){var d;const s=ne(),o=E(u=>u.threadListItem.remoteId),i=(d=s==null?void 0:s.historyAgentFilter)==null?void 0:d.intent,c=(s==null?void 0:s.isLibraryEnabled)===!0&&i!=="try-agent"&&(i==="history"||s.mode.status!=="active"||s.mode.isMutable||s.pendingSessionId!=null||o!=null),a=(s==null?void 0:s.historyAgentFilter)==null?"Chat History":`Chats for ${s.historyAgentFilter.agentName}`;return r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[r.jsxs("div",{className:"flex shrink-0 items-center gap-1 px-1 py-1",children:[r.jsx("h2",{className:"min-w-0 flex-1 truncate px-1.5 py-1 text-sm font-medium text-text-secondary",children:a}),c?r.jsx(Qr,{}):null]}),r.jsx("div",{ref:e,"data-slot":as,className:z("flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto",t&&"aui-scrollbar-hidden"),children:n})]})}function Zt({onThreadOpen:n,variant:e="default"}={}){const t=Y(),s=Re(),o=tt(),i=E(b=>b.threads.isLoading),c=E(b=>b.threads.isLoadingMore),a=E(b=>b.threads.hasMore),d=E(b=>b.threads.threadIds),u=E(b=>b.threads.threadItems),l=ne(),h=C("ThreadListShell"),p=C("ThreadListNewButton"),f=C("AgentsLibraryButton"),x=C("SessionsBrowserButton"),g=C("SchedulesButton"),I=C("EnvironmentsButton"),j=C("ThreadListRowSkeleton"),M=C("ThreadListEmptyState"),y=rs(e),B=m.useRef(null),P=m.useRef(a),F=m.useRef(t),K=m.useRef(0);P.current=a,F.current=t;const O=(l==null?void 0:l.isNewChatEnabled)!==!1,S=(l==null?void 0:l.mode.status)==="idle",R=ss(e),T=e==="mobile-drawer",U=typeof(s==null?void 0:s.renameSession)=="function",$=typeof(s==null?void 0:s.deleteSession)=="function",V=m.useMemo(()=>u.flatMap(b=>b.remoteId==null?[]:[b.remoteId]),[u]),{allows:G}=gn({resourceType:"session",resourceIds:V});m.useEffect(()=>{if(S||i||c)return;const b=B.current;if(!b)return;let v=!1;const A=()=>{if(v||!P.current||b.clientHeight<=0)return;const X=b.scrollHeight-b.scrollTop-b.clientHeight;b.scrollHeight>b.clientHeight&&X>is||F.current.threads().loadMore()};b.addEventListener("scroll",A,{passive:!0});const k=typeof ResizeObserver>"u"?void 0:new ResizeObserver(()=>A());return k?k.observe(b):window.addEventListener("resize",A),A(),()=>{v=!0,b.removeEventListener("scroll",A),k==null||k.disconnect(),k||window.removeEventListener("resize",A)}},[a,S,i,c,d.length]);const W=()=>{if(o(le.Session.NEW,ue({is_composer_enabled:(l==null?void 0:l.isComposerEnabled)===!0},{...(l==null?void 0:l.mode.status)==="active"?{agentId:l.mode.agentId,agentName:l.mode.agentName}:{}})),n==null||n(),l==null||l.setLibraryOpen(!1),l==null||l.setSessionsOpen(!1),l!=null&&l.isComposerEnabled){l.openDraft();return}l==null||l.setSettingsOpen(!1),l==null||l.setSchedulesOpen(!1),l==null||l.setEnvironmentsOpen(!1),Promise.resolve(t.threads().switchToNewThread()).catch(()=>{})};let w;S?w=r.jsx(M,{message:R?"No recent chats":void 0}):i?w=r.jsx(j,{}):y.length===0?w=r.jsx(M,{message:R?"No recent chats":void 0}):w=r.jsx(zr.Root,{className:"flex min-h-0 flex-col gap-0.5",children:r.jsx(os,{selectionRef:K,indices:y,onThreadOpen:n,canRenameSession:U,canDeleteSession:$,canManageResource:b=>G(b,"MANAGE"),canDeleteResource:b=>G(b,"DELETE")})});const D=e==="recent-history"?null:r.jsxs("div",{className:"flex flex-col gap-1",children:[O?r.jsx(p,{onClick:W}):null,r.jsx("div",{className:"contents",onClick:()=>{T&&(n==null||n())},children:r.jsx(f,{})}),T?null:r.jsxs(r.Fragment,{children:[r.jsx(x,{}),r.jsx(g,{}),r.jsx(I,{})]})]});return r.jsx(h,{header:D,children:r.jsxs(cs,{viewportRef:B,hideScrollbar:R,children:[w,!S&&a?r.jsx("div",{className:"h-4 shrink-0","aria-hidden":!0}):null]})})}var ls=m.lazy(()=>Ne(()=>import("./SettingsBuilder-QM224JED-Bp00qPG0.js"),__vite__mapDeps([0,1,2]),import.meta.url)),us=m.lazy(()=>Ne(()=>import("./SchedulesPage-25JKAP5G-DRHxlR8X.js"),__vite__mapDeps([3,4,1,2]),import.meta.url).then(n=>({default:n.SchedulesPage}))),ds=m.lazy(()=>Ne(()=>import("./EnvironmentsPage-5SEQP4QD-BxOU9R1E.js"),__vite__mapDeps([5,4,1,2]),import.meta.url).then(n=>({default:n.EnvironmentsPage}))),ms="h-5 w-5 max-w-40 shrink-0 object-contain",fs="h-5 max-w-40 shrink-0 object-contain",ps="w-20",hs="w-80",Ve=z(On,"text-sidebar-text"),We="bg-primary-button-bg font-medium text-primary-button-text hover:bg-primary-button-hover hover:text-primary-button-text";function xs({overlayOpen:n,mode:e}){return!n&&(e==null?void 0:e.status)==="active"&&!e.isCreateAgent}function gs(){return An().presentation==="full"?null:r.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:r.jsx(Zt,{variant:"recent-history"})})}function vs(){var f;const n=Y(),e=ne(),t=C("AgentsLibraryButton"),s=C("SessionsBrowserButton"),o=C("SchedulesButton"),i=C("EnvironmentsButton"),c=(e==null?void 0:e.isNewChatEnabled)!==!1,a=(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||(e==null?void 0:e.environmentsOpen)===!0,d=e==null?void 0:e.mode,u=!a&&(d==null?void 0:d.status)==="active"&&!d.isCreateAgent&&((f=e==null?void 0:e.historyAgentFilter)==null?void 0:f.intent)!=="try-agent",l=!a&&d!=null&&st(d),h=()=>{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),e==null||e.setEnvironmentsOpen(!1),Promise.resolve(n.threads().switchToNewThread()).catch(()=>{})},p=()=>{e==null||e.setLibraryOpen(!1),e==null||e.setSessionsOpen(!1),e!=null&&e.isComposerEnabled&&e.openAgentBuilder()};return r.jsxs("nav",{className:"flex min-h-0 flex-1 flex-col items-center gap-1 p-1","aria-label":"Sidebar",children:[c?r.jsxs("button",{type:"button","aria-label":"Start new chat",title:"New chat","aria-current":u?"page":void 0,className:te({variant:"ghost",className:z(Ve,u&&We)}),onClick:h,children:[r.jsx(H,{name:"square-pen",size:14}),r.jsx("span",{className:"text-center",children:"New Chat"})]}):null,c&&(e!=null&&e.isComposerEnabled)?r.jsxs("button",{type:"button","aria-label":"Start new agent",title:"New Agent","aria-current":l?"page":void 0,className:te({variant:"ghost",className:z(Ve,l&&We)}),onClick:p,children:[r.jsx(H,{name:"agent-2",size:14}),r.jsx("span",{className:"text-center whitespace-nowrap",children:"Build Agent"})]}):null,r.jsx(t,{compact:!0}),r.jsx(s,{compact:!0}),r.jsx(o,{compact:!0}),r.jsx(i,{compact:!0})]})}function bs({className:n,railRef:e,...t}){const s=ot(),o=at(s),i=C("BrandLogo"),c=C("UserAvatar");return r.jsxs("aside",{ref:e,className:z(ps,"flex min-h-0 shrink-0 flex-col border-r border-border bg-sidebar-bg",n),...t,children:[r.jsx("div",{className:"flex h-14 w-full shrink-0 items-center justify-center text-text-primary",children:r.jsx(i,{variant:o.collapsedVariant,className:ms})}),r.jsx(vs,{}),r.jsxs("footer",{className:"flex shrink-0 flex-col items-center border-border p-2",children:[r.jsx(it,{labeled:!0,className:"flex-col"}),r.jsx(c,{labeled:!0,className:"mt-2 py-1.5"})]})]})}function ws({drawerRef:n,onClose:e}){const t=ot(),s=at(t),o=_n(),i=C("BrandLogo"),c=C("UserAvatar");return r.jsxs("aside",{ref:n,role:"dialog","aria-label":"Navigation",tabIndex:-1,className:z(hs,"absolute inset-y-0 left-0 z-10 flex min-h-0 flex-col border-r border-border bg-sidebar-bg shadow-lg outline-none md:hidden"),children:[r.jsxs("div",{className:"flex h-14 w-full shrink-0 items-center gap-2 border-b border-border px-3 text-text-primary",children:[r.jsx(i,{variant:s.expandedVariant,className:fs}),s.showTitle&&o!=null?r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:o}):r.jsx("span",{className:"min-w-0 flex-1"}),r.jsx("button",{type:"button","aria-label":"Close navigation",className:te({variant:"ghost",size:"icon"}),onClick:e,children:r.jsx(H,{name:"xmark"})})]}),r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(Zt,{variant:"mobile-drawer",onThreadOpen:e})}),r.jsxs("footer",{className:"flex shrink-0 items-center justify-around gap-1 border-t border-border p-2 text-sidebar-text",children:[r.jsx(it,{labeled:!0,onAction:e,className:"contents"}),r.jsx(c,{labeled:!0})]})]})}function Ts({className:n}){const e=ne(),t=Te(),s=C("AgentDetailsPage"),o=C("AgentsLibrary"),i=C("SessionsPage"),c=C("ShareChatButton"),a=C("ResetAgentBuilderButton"),d=C("ClearChatButton"),u=C("SaveAgentButton"),l=C("SelectAgentEmptyState"),[h,p]=m.useState(!1),f=m.useRef(null),x=m.useRef(null),g=m.useRef(null),I=m.useRef(!1),j=(e==null?void 0:e.mode.status)==="idle",M=(e==null?void 0:e.settingsOpen)===!0,y=(e==null?void 0:e.libraryOpen)===!0,B=y&&(e==null?void 0:e.libraryAgentId)==null,P=(e==null?void 0:e.sessionsOpen)===!0,F=(e==null?void 0:e.schedulesOpen)===!0,K=(e==null?void 0:e.environmentsOpen)===!0,O=M||y||P||F||K,S=e!=null&&st(e.mode),R=t&&(P||F||K||S&&!M&&!y),T=S&&!O&&!t,U=xs({overlayOpen:O,mode:e==null?void 0:e.mode}),$=Nn(),V=t&&(M||B),G=()=>p(!1),W=r.jsx("button",{ref:f,type:"button","aria-label":"Navigation","aria-expanded":h,className:z(te({variant:"ghost",size:"icon"}),"md:hidden"),onClick:()=>p(!0),children:r.jsx(H,{name:"panel-left"})});return m.useEffect(()=>{if(!h)return;const w=D=>{D.key==="Escape"&&(D.stopImmediatePropagation(),p(!1))};return window.addEventListener("keydown",w,!0),()=>window.removeEventListener("keydown",w,!0)},[h]),m.useEffect(()=>{var D,b;const w=g.current;if(h){I.current=!0,w&&(w.inert=!0),(D=x.current)==null||D.focus();return}I.current&&(w&&(w.inert=!1),(b=f.current)==null||b.focus(),I.current=!1)},[h]),r.jsxs("div",{className:z("relative flex h-full min-h-0 w-full min-w-0",n),children:[r.jsx(bs,{className:"hidden md:flex"}),T?r.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:r.jsx(kn,{})}):null,r.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col bg-primary-bg",children:[V?null:r.jsx(Pn,{className:z("bg-topbar-bg",(O||j||!$||R)&&"md:hidden"),start:W,title:!O&&!R?r.jsx(Bn,{}):null,end:!O&&!R?r.jsxs(r.Fragment,{children:[r.jsx(a,{}),r.jsx(c,{}),r.jsx(d,{}),r.jsx(u,{})]}):null}),r.jsx(En,{children:r.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1",children:[U?r.jsx(gs,{}):null,r.jsx("div",{ref:g,className:"min-h-0 min-w-0 flex-1",children:M?r.jsx(m.Suspense,{fallback:r.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[r.jsx(ve,{size:28,className:"text-text-primary"}),r.jsx("span",{className:"sr-only",children:"Loading"})]}),children:r.jsx(ls,{...V?{headerStart:W}:{}})}):R?r.jsx(Dn,{}):P?r.jsx(i,{}):y&&(e==null?void 0:e.libraryAgentId)!=null?r.jsx(s,{agentId:e.libraryAgentId},e.libraryAgentId):y?r.jsx(o,{onSelectAgent:G,...V?{headerStart:W}:{}}):F?r.jsx(m.Suspense,{fallback:r.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[r.jsx(ve,{size:28,className:"text-text-primary"}),r.jsx("span",{className:"sr-only",children:"Loading"})]}),children:r.jsx(us,{})}):K?r.jsx(m.Suspense,{fallback:r.jsxs("div",{className:"flex h-full items-center justify-center",role:"status","aria-live":"polite","aria-busy":"true",children:[r.jsx(ve,{size:28,className:"text-text-primary"}),r.jsx("span",{className:"sr-only",children:"Loading"})]}),children:r.jsx(ds,{})}):j?r.jsx(l,{}):r.jsx(Fn,{})})]})})]}),h?r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button","aria-label":"Close navigation backdrop",className:"absolute inset-0 z-[9] cursor-pointer bg-[var(--overlay)] md:hidden",onClick:G}),r.jsx(ws,{drawerRef:x,onClose:G})]}):null]})}export{Ts as SidebarLayout};
@@ -1 +1 @@
1
- import{C as J}from"./chunk-2L7W3OHQ-BC-N5kEf.js";import{bq as V,p as W,q as X,r as l,x as U,j as e,S as Y,E,I as q,bs as Z,aa as k,_ as z}from"./index-BOPxame4.js";var ee=({open:s,onOpenChange:c,onImport:d,busy:p=!1,error:y})=>{const[i,N]=l.useState(""),[m,C]=l.useState(""),[n,j]=l.useState(""),[u,x]=l.useState(""),[b,h]=l.useState(""),o=()=>{N(""),C(""),j(""),x(""),h("")},v=()=>{o(),c(!1)},f=async a=>{if(a.preventDefault(),!(!i.trim()||!m.trim()||!n.trim()||!u.trim()||!b.trim()||p))try{await d({name:i.trim(),description:m.trim(),repoURL:n.trim(),path:u.trim(),ref:b.trim()}),v()}catch{}},L=!!(i.trim()&&m.trim()&&n.trim()&&u.trim()&&b.trim())&&!p;return e.jsx(Z,{open:s,onOpenChange:a=>{a||v()},title:"Import from GitHub",description:"Import a skill from a SKILL.md file in a GitHub repository.",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",children:e.jsx(q,{name:"github",className:"size-5"})}),contentSized:!0,className:"md:max-w-2xl",children:e.jsx("form",{onSubmit:a=>void f(a),children:e.jsxs("div",{className:"space-y-5 px-5 py-5 md:px-6",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"skill-name",className:"mb-2 block text-sm font-semibold text-text-primary",children:"Name"}),e.jsx("input",{id:"skill-name",value:i,onChange:a=>{N(a.target.value)},placeholder:"release-notes",autoFocus:!0,required:!0,className:k("h-11")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"skill-description",className:"mb-2 block text-sm font-semibold text-text-primary",children:"Description"}),e.jsx("textarea",{id:"skill-description",value:m,onChange:a=>{C(a.target.value)},placeholder:"Generate release notes from merged pull requests",required:!0,rows:3,className:k("resize-y py-2.5")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"skill-repo-url",className:"mb-2 block text-sm font-semibold text-text-primary",children:"Repository URL"}),e.jsx("input",{id:"skill-repo-url",type:"url",value:n,onChange:a=>{j(a.target.value)},placeholder:"https://github.com/org/repo",required:!0,className:k("h-11")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"skill-path",className:"mb-2 block text-sm font-semibold text-text-primary",children:"Folder containing the SKILL.md"}),e.jsx("input",{id:"skill-path",value:u,onChange:a=>{x(a.target.value)},placeholder:"skills/release-notes",required:!0,className:k("h-11")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"skill-ref",className:"mb-2 block text-sm font-semibold text-text-primary",children:"Branch"}),e.jsx("input",{id:"skill-ref",value:b,onChange:a=>{h(a.target.value)},placeholder:"main",required:!0,className:k("h-11")})]}),e.jsxs("div",{className:"space-y-3",children:[y?e.jsx("p",{className:"text-failure-bg text-sm",children:y}):null,e.jsx(E.Primary,{type:"submit",disabled:!L,className:"w-full",children:"Import"})]})]})})})},te=ee,B=(s,c,d)=>!s||c.toLowerCase().includes(s)||d.toLowerCase().includes(s),se=s=>"catalogId"in s;function le(s){return typeof s=="object"&&s!==null&&Reflect.get(s,"statusCode")===424}var ae=()=>{const{skillCatalog:s}=V(),c=W(),d=X(),[p,y]=l.useState(""),[i,N]=l.useState([]),[m,C]=l.useState([]),[n,j]=l.useState(!0),[u,x]=l.useState(null),[b,h]=l.useState(null),[o,v]=l.useState(!1),[f,L]=l.useState(!1),[a,G]=l.useState(!1),[D,F]=l.useState(null),[P,I]=l.useState(null),M=l.useCallback(async()=>{if(s){j(!0),x(null);try{const[t,r]=await Promise.all([s.listSkills(),s.getSkillCatalog()]);N(t),C(r)}catch(t){x(U(t,"Failed to load skills"))}finally{j(!1)}}},[s]);l.useEffect(()=>{M()},[M]);const S=p.trim().toLowerCase(),w=l.useMemo(()=>i.filter(t=>B(S,t.name,t.description)),[i,S]),R=l.useMemo(()=>{const t=new Set(i.flatMap(r=>se(r)?[r.catalogId]:[]));return m.filter(r=>!t.has(r.id)&&B(S,r.name,r.description))},[m,i,S]),_=async(t,r=x)=>{v(!0),x(null);try{await t(),await M()}catch(g){throw le(g)&&L(!0),r(U(g,"Request failed")),g}finally{v(!1)}};if(!s)return e.jsx("p",{className:"text-sm text-text-secondary",children:"Skills catalog is not available."});const T=t=>{_(async()=>{await s.createSkill({catalogId:t.id,name:t.name,description:t.description,repoURL:t.repoURL,path:t.path,ref:t.ref}),d(z.Settings.SKILL_IMPORTED,{skill_name:t.name})}).catch(()=>{})},K=()=>{o||(F(null),I(null))},$=t=>{const r=s.deleteSkill;r&&(I(null),_(async()=>{await r({id:t.id}),d(z.Settings.SKILL_DELETED,{skill_name:t.name}),F(null)},I).catch(()=>{}))},H=async t=>{h(null),await _(async()=>{await s.createSkill(t)},h),setTimeout(()=>{c==null||c.showSuccess({title:`${t.name} imported`}),d(z.Settings.SKILL_IMPORTED,{skill_name:t.name})},0)},O=({key:t,name:r,description:g,action:Q})=>e.jsxs("article",{className:"flex min-h-16 items-center gap-3 border-b border-border p-3 last:border-b-0",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg","aria-hidden":!0,children:e.jsx(q,{name:"lightbulb",className:"size-4.5 text-text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:r}),g?e.jsx("p",{className:"mt-0.5 truncate text-sm text-text-secondary",children:g}):null]}),Q]},t),A=w.length>0||R.length>0;return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Skills"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Use built-in skills or import custom skills from GitHub."}),u?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:u}):null,e.jsxs("div",{className:"mt-4 flex min-h-0 flex-1 flex-col gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(Y,{query:p,setQuery:y,placeholder:"Search skills"})}),e.jsxs(E.Secondary,{type:"button",className:"shrink-0",disabled:o||f,onClick:()=>{h(null),G(!0)},children:[e.jsx(q,{name:"github",className:"size-4"}),"Import from GitHub"]})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-5 overflow-y-auto pb-1",children:[n?e.jsx("p",{className:"py-8 text-center text-sm text-text-secondary",children:"Loading…"}):null,!n&&w.length>0?e.jsxs("section",{"aria-labelledby":"enabled-skills-heading",children:[e.jsxs("h4",{id:"enabled-skills-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:["Enabled · ",w.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:w.map(t=>O({key:t.id,name:t.name,description:t.description,action:s.deleteSkill?e.jsx(E.Secondary,{size:"small",type:"button",disabled:o||f,"aria-label":`Remove ${t.name}`,onClick:()=>{I(null),F(t)},children:"Remove"}):null}))})]}):null,!n&&R.length>0?e.jsxs("section",{"aria-labelledby":"available-skills-heading",children:[e.jsxs("h4",{id:"available-skills-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:["Available · ",R.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:R.map(t=>O({key:t.id,name:t.name,description:t.description,action:e.jsx(E.Secondary,{size:"small",type:"button",disabled:o||f,"aria-label":`Enable ${t.name}`,onClick:()=>{T(t)},children:"Enable"})}))})]}):null,!n&&!A?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:S?`No skills match “${p.trim()}”.`:"No skills yet."}):null]})]}),D?e.jsx(J,{title:"Remove skill?",description:`“${D.name}” will no longer be available to your agents.`,busy:o,error:P,onCancel:K,onConfirm:()=>{$(D)}}):null,e.jsx(te,{open:a,onOpenChange:t=>{G(t),t||h(null)},onImport:H,busy:o||f,error:b})]})},ne=ae;export{ne as default};
1
+ import{C as J}from"./chunk-2L7W3OHQ-KYs3TW6o.js";import{bq as V,p as W,q as X,r as l,x as U,j as e,S as Y,E,I as q,bs as Z,aa as k,_ as z}from"./index-o2o-gWoN.js";var ee=({open:s,onOpenChange:c,onImport:d,busy:p=!1,error:y})=>{const[i,N]=l.useState(""),[m,C]=l.useState(""),[n,j]=l.useState(""),[u,x]=l.useState(""),[b,h]=l.useState(""),o=()=>{N(""),C(""),j(""),x(""),h("")},v=()=>{o(),c(!1)},f=async a=>{if(a.preventDefault(),!(!i.trim()||!m.trim()||!n.trim()||!u.trim()||!b.trim()||p))try{await d({name:i.trim(),description:m.trim(),repoURL:n.trim(),path:u.trim(),ref:b.trim()}),v()}catch{}},L=!!(i.trim()&&m.trim()&&n.trim()&&u.trim()&&b.trim())&&!p;return e.jsx(Z,{open:s,onOpenChange:a=>{a||v()},title:"Import from GitHub",description:"Import a skill from a SKILL.md file in a GitHub repository.",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",children:e.jsx(q,{name:"github",className:"size-5"})}),contentSized:!0,className:"md:max-w-2xl",children:e.jsx("form",{onSubmit:a=>void f(a),children:e.jsxs("div",{className:"space-y-5 px-5 py-5 md:px-6",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"skill-name",className:"mb-2 block text-sm font-semibold text-text-primary",children:"Name"}),e.jsx("input",{id:"skill-name",value:i,onChange:a=>{N(a.target.value)},placeholder:"release-notes",autoFocus:!0,required:!0,className:k("h-11")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"skill-description",className:"mb-2 block text-sm font-semibold text-text-primary",children:"Description"}),e.jsx("textarea",{id:"skill-description",value:m,onChange:a=>{C(a.target.value)},placeholder:"Generate release notes from merged pull requests",required:!0,rows:3,className:k("resize-y py-2.5")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"skill-repo-url",className:"mb-2 block text-sm font-semibold text-text-primary",children:"Repository URL"}),e.jsx("input",{id:"skill-repo-url",type:"url",value:n,onChange:a=>{j(a.target.value)},placeholder:"https://github.com/org/repo",required:!0,className:k("h-11")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"skill-path",className:"mb-2 block text-sm font-semibold text-text-primary",children:"Folder containing the SKILL.md"}),e.jsx("input",{id:"skill-path",value:u,onChange:a=>{x(a.target.value)},placeholder:"skills/release-notes",required:!0,className:k("h-11")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"skill-ref",className:"mb-2 block text-sm font-semibold text-text-primary",children:"Branch"}),e.jsx("input",{id:"skill-ref",value:b,onChange:a=>{h(a.target.value)},placeholder:"main",required:!0,className:k("h-11")})]}),e.jsxs("div",{className:"space-y-3",children:[y?e.jsx("p",{className:"text-failure-bg text-sm",children:y}):null,e.jsx(E.Primary,{type:"submit",disabled:!L,className:"w-full",children:"Import"})]})]})})})},te=ee,B=(s,c,d)=>!s||c.toLowerCase().includes(s)||d.toLowerCase().includes(s),se=s=>"catalogId"in s;function le(s){return typeof s=="object"&&s!==null&&Reflect.get(s,"statusCode")===424}var ae=()=>{const{skillCatalog:s}=V(),c=W(),d=X(),[p,y]=l.useState(""),[i,N]=l.useState([]),[m,C]=l.useState([]),[n,j]=l.useState(!0),[u,x]=l.useState(null),[b,h]=l.useState(null),[o,v]=l.useState(!1),[f,L]=l.useState(!1),[a,G]=l.useState(!1),[D,F]=l.useState(null),[P,I]=l.useState(null),M=l.useCallback(async()=>{if(s){j(!0),x(null);try{const[t,r]=await Promise.all([s.listSkills(),s.getSkillCatalog()]);N(t),C(r)}catch(t){x(U(t,"Failed to load skills"))}finally{j(!1)}}},[s]);l.useEffect(()=>{M()},[M]);const S=p.trim().toLowerCase(),w=l.useMemo(()=>i.filter(t=>B(S,t.name,t.description)),[i,S]),R=l.useMemo(()=>{const t=new Set(i.flatMap(r=>se(r)?[r.catalogId]:[]));return m.filter(r=>!t.has(r.id)&&B(S,r.name,r.description))},[m,i,S]),_=async(t,r=x)=>{v(!0),x(null);try{await t(),await M()}catch(g){throw le(g)&&L(!0),r(U(g,"Request failed")),g}finally{v(!1)}};if(!s)return e.jsx("p",{className:"text-sm text-text-secondary",children:"Skills catalog is not available."});const T=t=>{_(async()=>{await s.createSkill({catalogId:t.id,name:t.name,description:t.description,repoURL:t.repoURL,path:t.path,ref:t.ref}),d(z.Settings.SKILL_IMPORTED,{skill_name:t.name})}).catch(()=>{})},K=()=>{o||(F(null),I(null))},$=t=>{const r=s.deleteSkill;r&&(I(null),_(async()=>{await r({id:t.id}),d(z.Settings.SKILL_DELETED,{skill_name:t.name}),F(null)},I).catch(()=>{}))},H=async t=>{h(null),await _(async()=>{await s.createSkill(t)},h),setTimeout(()=>{c==null||c.showSuccess({title:`${t.name} imported`}),d(z.Settings.SKILL_IMPORTED,{skill_name:t.name})},0)},O=({key:t,name:r,description:g,action:Q})=>e.jsxs("article",{className:"flex min-h-16 items-center gap-3 border-b border-border p-3 last:border-b-0",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg","aria-hidden":!0,children:e.jsx(q,{name:"lightbulb",className:"size-4.5 text-text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:r}),g?e.jsx("p",{className:"mt-0.5 truncate text-sm text-text-secondary",children:g}):null]}),Q]},t),A=w.length>0||R.length>0;return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Skills"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Use built-in skills or import custom skills from GitHub."}),u?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:u}):null,e.jsxs("div",{className:"mt-4 flex min-h-0 flex-1 flex-col gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(Y,{query:p,setQuery:y,placeholder:"Search skills"})}),e.jsxs(E.Secondary,{type:"button",className:"shrink-0",disabled:o||f,onClick:()=>{h(null),G(!0)},children:[e.jsx(q,{name:"github",className:"size-4"}),"Import from GitHub"]})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-5 overflow-y-auto pb-1",children:[n?e.jsx("p",{className:"py-8 text-center text-sm text-text-secondary",children:"Loading…"}):null,!n&&w.length>0?e.jsxs("section",{"aria-labelledby":"enabled-skills-heading",children:[e.jsxs("h4",{id:"enabled-skills-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:["Enabled · ",w.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:w.map(t=>O({key:t.id,name:t.name,description:t.description,action:s.deleteSkill?e.jsx(E.Secondary,{size:"small",type:"button",disabled:o||f,"aria-label":`Remove ${t.name}`,onClick:()=>{I(null),F(t)},children:"Remove"}):null}))})]}):null,!n&&R.length>0?e.jsxs("section",{"aria-labelledby":"available-skills-heading",children:[e.jsxs("h4",{id:"available-skills-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:["Available · ",R.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:R.map(t=>O({key:t.id,name:t.name,description:t.description,action:e.jsx(E.Secondary,{size:"small",type:"button",disabled:o||f,"aria-label":`Enable ${t.name}`,onClick:()=>{T(t)},children:"Enable"})}))})]}):null,!n&&!A?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:S?`No skills match “${p.trim()}”.`:"No skills yet."}):null]})]}),D?e.jsx(J,{title:"Remove skill?",description:`“${D.name}” will no longer be available to your agents.`,busy:o,error:P,onCancel:K,onConfirm:()=>{$(D)}}):null,e.jsx(te,{open:a,onOpenChange:t=>{G(t),t||h(null)},onImport:H,busy:o||f,error:b})]})},ne=ae;export{ne as default};
@@ -1 +1 @@
1
- import{r as t,a,j as o,T as n}from"./index-BOPxame4.js";import{B as u}from"./chunk-OB3PAWPO-kbiWSc01.js";function l({routes:e,...s}){const r=t.useMemo(()=>a(e),[e]);return o.jsx(u,{basename:r.basename||void 0,children:o.jsx(n,{...s,resolvedRoutes:r})})}export{l as TrueForgeUIWithRouter};
1
+ import{r as t,a,j as o,T as n}from"./index-o2o-gWoN.js";import{B as u}from"./chunk-OB3PAWPO-DN1Qz_zd.js";function l({routes:e,...s}){const r=t.useMemo(()=>a(e),[e]);return o.jsx(u,{basename:r.basename||void 0,children:o.jsx(n,{...s,resolvedRoutes:r})})}export{l as TrueForgeUIWithRouter};