@truefoundry/trueforge 0.184.0 → 0.184.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (223) hide show
  1. package/dist/_frontend/assets/{AgentCodeSnippets-KAYJRSGM-t2jGx88c.js → AgentCodeSnippets-FCT4ZDVR-B_sFoO9A.js} +1 -1
  2. package/dist/_frontend/assets/AgentCodeSnippets-FCT4ZDVR-B_sFoO9A.js.br +0 -0
  3. package/dist/_frontend/assets/AgentCodeSnippets-FCT4ZDVR-B_sFoO9A.js.gz +0 -0
  4. package/dist/_frontend/assets/{AgentMetricChart-QKWQDPNE-D87qhLsV.js → AgentMetricChart-37YBCVCL-tdj26zQn.js} +1 -1
  5. package/dist/_frontend/assets/AgentMetricChart-37YBCVCL-tdj26zQn.js.br +0 -0
  6. package/dist/_frontend/assets/AgentMetricChart-37YBCVCL-tdj26zQn.js.gz +0 -0
  7. package/dist/_frontend/assets/AgentOverview-BNAPIHGD-DltvaeT_.js +1 -0
  8. package/dist/_frontend/assets/AgentOverview-BNAPIHGD-DltvaeT_.js.br +0 -0
  9. package/dist/_frontend/assets/AgentOverview-BNAPIHGD-DltvaeT_.js.gz +0 -0
  10. package/dist/_frontend/assets/{AgentSessionEventTimeline-LXZ4FOEP-BCsQ5q8M.js → AgentSessionEventTimeline-MSIFVG3P-B4ULRgh_.js} +1 -1
  11. package/dist/_frontend/assets/AgentSessionEventTimeline-MSIFVG3P-B4ULRgh_.js.br +0 -0
  12. package/dist/_frontend/assets/AgentSessionEventTimeline-MSIFVG3P-B4ULRgh_.js.gz +0 -0
  13. package/dist/_frontend/assets/{AgentSessionEventTimelineChart-UGDY3DXV-zv0rxgUh.js → AgentSessionEventTimelineChart-NLKGG2AE-BpJnekt3.js} +1 -1
  14. package/dist/_frontend/assets/AgentSessionEventTimelineChart-NLKGG2AE-BpJnekt3.js.br +0 -0
  15. package/dist/_frontend/assets/AgentSessionEventTimelineChart-NLKGG2AE-BpJnekt3.js.gz +0 -0
  16. package/dist/_frontend/assets/{AgentSessions-RNQJNNUN-JkCPXE-S.js → AgentSessions-KCKW65WJ-SNgac5n4.js} +1 -1
  17. package/dist/_frontend/assets/AgentSessions-KCKW65WJ-SNgac5n4.js.br +0 -0
  18. package/dist/_frontend/assets/AgentSessions-KCKW65WJ-SNgac5n4.js.gz +0 -0
  19. package/dist/_frontend/assets/{ConnectorSettings-FZ6PADBD-CdxBUs-y.js → ConnectorSettings-IXSIXHUE-CMo6GTOP.js} +1 -1
  20. package/dist/_frontend/assets/ConnectorSettings-IXSIXHUE-CMo6GTOP.js.br +0 -0
  21. package/dist/_frontend/assets/ConnectorSettings-IXSIXHUE-CMo6GTOP.js.gz +0 -0
  22. package/dist/_frontend/assets/{DockLayout-ZR7QXDF5-B32tt8v3.js → DockLayout-LCYSS4N6-yrmEYQIS.js} +1 -1
  23. package/dist/_frontend/assets/{DrawerLayout-G6IFSHR2-BMHEUtpn.js → DrawerLayout-EX3NLTTV-C6JKCTHb.js} +2 -2
  24. package/dist/_frontend/assets/DrawerLayout-EX3NLTTV-C6JKCTHb.js.br +0 -0
  25. package/dist/_frontend/assets/DrawerLayout-EX3NLTTV-C6JKCTHb.js.gz +0 -0
  26. package/dist/_frontend/assets/{EnvironmentsPage-YG7ABMNR-DeZwiCGc.js → EnvironmentsPage-DAJPUASL-nCQjN8ee.js} +1 -1
  27. package/dist/_frontend/assets/EnvironmentsPage-DAJPUASL-nCQjN8ee.js.br +0 -0
  28. package/dist/_frontend/assets/EnvironmentsPage-DAJPUASL-nCQjN8ee.js.gz +0 -0
  29. package/dist/_frontend/assets/MemorySettings-CIS5BHXY-CAN1KXMC.js +1 -0
  30. package/dist/_frontend/assets/MemorySettings-CIS5BHXY-CAN1KXMC.js.br +0 -0
  31. package/dist/_frontend/assets/MemorySettings-CIS5BHXY-CAN1KXMC.js.gz +0 -0
  32. package/dist/_frontend/assets/{ModelSettings-VVLPTON7-CjHRtjan.js → ModelSettings-XLENC7UZ-DC0RR0m-.js} +1 -1
  33. package/dist/_frontend/assets/ModelSettings-XLENC7UZ-DC0RR0m-.js.br +0 -0
  34. package/dist/_frontend/assets/ModelSettings-XLENC7UZ-DC0RR0m-.js.gz +0 -0
  35. package/dist/_frontend/assets/{SandboxSettings-FR5GBIEJ-RecKXXOz.js → SandboxSettings-PEJCTARS-DJYt-93s.js} +1 -1
  36. package/dist/_frontend/assets/SandboxSettings-PEJCTARS-DJYt-93s.js.br +0 -0
  37. package/dist/_frontend/assets/SandboxSettings-PEJCTARS-DJYt-93s.js.gz +0 -0
  38. package/dist/_frontend/assets/{SchedulesPage-VJNU6YI5-C3w2UmoO.js → SchedulesPage-RKL2JJTC-IsOsS2eL.js} +1 -1
  39. package/dist/_frontend/assets/SchedulesPage-RKL2JJTC-IsOsS2eL.js.br +0 -0
  40. package/dist/_frontend/assets/SchedulesPage-RKL2JJTC-IsOsS2eL.js.gz +0 -0
  41. package/dist/_frontend/assets/SettingsBuilder-C2RPDCLY-BxxIgV4z.js +2 -0
  42. package/dist/_frontend/assets/SettingsBuilder-C2RPDCLY-BxxIgV4z.js.br +0 -0
  43. package/dist/_frontend/assets/SettingsBuilder-C2RPDCLY-BxxIgV4z.js.gz +0 -0
  44. package/dist/_frontend/assets/{ShellRouteSync-UUGKAWDN-CyXGIlGM.js → ShellRouteSync-XZHRMEIQ-DDXZFSi2.js} +1 -1
  45. package/dist/_frontend/assets/ShellRouteSync-XZHRMEIQ-DDXZFSi2.js.br +0 -0
  46. package/dist/_frontend/assets/ShellRouteSync-XZHRMEIQ-DDXZFSi2.js.gz +0 -0
  47. package/dist/_frontend/assets/{SidebarLayout-H7DIHXYF-j8SSyd5l.js → SidebarLayout-REQEVMHO-sYFRqEj6.js} +2 -2
  48. package/dist/_frontend/assets/SidebarLayout-REQEVMHO-sYFRqEj6.js.br +0 -0
  49. package/dist/_frontend/assets/SidebarLayout-REQEVMHO-sYFRqEj6.js.gz +0 -0
  50. package/dist/_frontend/assets/{SkillSettings-4BFXYN43-DaWF2tPn.js → SkillSettings-7IU7QGT5-DMmMoUdV.js} +1 -1
  51. package/dist/_frontend/assets/SkillSettings-7IU7QGT5-DMmMoUdV.js.br +0 -0
  52. package/dist/_frontend/assets/SkillSettings-7IU7QGT5-DMmMoUdV.js.gz +0 -0
  53. package/dist/_frontend/assets/{TrueForgeUIWithRouter-7XLLWRDQ-DBaTdO8q.js → TrueForgeUIWithRouter-S6JNFFYJ-ti4yDPPN.js} +1 -1
  54. package/dist/_frontend/assets/{WebSearchSettings-F4GST24B-CyUAlECs.js → WebSearchSettings-BF72QZ5S-Dp_k-ZOn.js} +1 -1
  55. package/dist/_frontend/assets/WebSearchSettings-BF72QZ5S-Dp_k-ZOn.js.br +0 -0
  56. package/dist/_frontend/assets/WebSearchSettings-BF72QZ5S-Dp_k-ZOn.js.gz +0 -0
  57. package/dist/_frontend/assets/{WidgetLayout-7HIMRVUF-DEPMSv8o.js → WidgetLayout-V3QT6O2E-DMCiX66H.js} +1 -1
  58. package/dist/_frontend/assets/WidgetLayout-V3QT6O2E-DMCiX66H.js.br +0 -0
  59. package/dist/_frontend/assets/WidgetLayout-V3QT6O2E-DMCiX66H.js.gz +0 -0
  60. package/dist/_frontend/assets/{chunk-WW6L37U3-DmX_GP2D.js → chunk-BOLUYVO2-Y-H80bTu.js} +1 -1
  61. package/dist/_frontend/assets/{chunk-MIQXDKJG-BmOYOrKB.js → chunk-MIQXDKJG-DDf3acU8.js} +1 -1
  62. package/dist/_frontend/assets/chunk-MIQXDKJG-DDf3acU8.js.br +0 -0
  63. package/dist/_frontend/assets/chunk-MIQXDKJG-DDf3acU8.js.gz +0 -0
  64. package/dist/_frontend/assets/{chunk-F2MZYGMM-DHpanE7I.js → chunk-NGI4HR24-Ck1XamIM.js} +1 -1
  65. package/dist/_frontend/assets/chunk-NGI4HR24-Ck1XamIM.js.br +0 -0
  66. package/dist/_frontend/assets/chunk-NGI4HR24-Ck1XamIM.js.gz +0 -0
  67. package/dist/_frontend/assets/{chunk-YDJ4YR2V-DoV9K_ey.js → chunk-NHZJDZV6-B1IGm0KY.js} +2 -2
  68. package/dist/_frontend/assets/chunk-NHZJDZV6-B1IGm0KY.js.br +0 -0
  69. package/dist/_frontend/assets/chunk-NHZJDZV6-B1IGm0KY.js.gz +0 -0
  70. package/dist/_frontend/assets/{chunk-OB3PAWPO-B7JixYPy.js → chunk-OB3PAWPO-CZaXL0XY.js} +1 -1
  71. package/dist/_frontend/assets/chunk-OB3PAWPO-CZaXL0XY.js.br +0 -0
  72. package/dist/_frontend/assets/chunk-OB3PAWPO-CZaXL0XY.js.gz +0 -0
  73. package/dist/_frontend/assets/{cssMode-Bylkausn.js → cssMode-BXGvSkcM.js} +1 -1
  74. package/dist/_frontend/assets/cssMode-BXGvSkcM.js.br +0 -0
  75. package/dist/_frontend/assets/cssMode-BXGvSkcM.js.gz +0 -0
  76. package/dist/_frontend/assets/{freemarker2-D2xJV5zt.js → freemarker2-4Wrb3n8S.js} +1 -1
  77. package/dist/_frontend/assets/freemarker2-4Wrb3n8S.js.br +0 -0
  78. package/dist/_frontend/assets/freemarker2-4Wrb3n8S.js.gz +0 -0
  79. package/dist/_frontend/assets/{handlebars-C980sstL.js → handlebars-fcW4McxS.js} +1 -1
  80. package/dist/_frontend/assets/handlebars-fcW4McxS.js.br +0 -0
  81. package/dist/_frontend/assets/handlebars-fcW4McxS.js.gz +0 -0
  82. package/dist/_frontend/assets/{html-CAJSd_2U.js → html-CF5S3ctk.js} +1 -1
  83. package/dist/_frontend/assets/html-CF5S3ctk.js.br +0 -0
  84. package/dist/_frontend/assets/html-CF5S3ctk.js.gz +0 -0
  85. package/dist/_frontend/assets/{htmlMode-6rYtYcvL.js → htmlMode-CgtoShwJ.js} +1 -1
  86. package/dist/_frontend/assets/htmlMode-CgtoShwJ.js.br +0 -0
  87. package/dist/_frontend/assets/htmlMode-CgtoShwJ.js.gz +0 -0
  88. package/dist/_frontend/assets/{index-Dx9OO7_F.js → index-CPZofK7c.js} +3 -3
  89. package/dist/_frontend/assets/index-CPZofK7c.js.br +0 -0
  90. package/dist/_frontend/assets/index-CPZofK7c.js.gz +0 -0
  91. package/dist/_frontend/assets/{index-CbQ6bGFO.js → index-J4S6NjFF.js} +268 -268
  92. package/dist/_frontend/assets/index-J4S6NjFF.js.br +0 -0
  93. package/dist/_frontend/assets/index-J4S6NjFF.js.gz +0 -0
  94. package/dist/_frontend/assets/{javascript-LmMOOF_J.js → javascript-DXIZJHPi.js} +1 -1
  95. package/dist/_frontend/assets/{jsonMode-DqyhOdz1.js → jsonMode-BG7s-ZXL.js} +1 -1
  96. package/dist/_frontend/assets/jsonMode-BG7s-ZXL.js.br +0 -0
  97. package/dist/_frontend/assets/jsonMode-BG7s-ZXL.js.gz +0 -0
  98. package/dist/_frontend/assets/{liquid-CuEtLH2I.js → liquid-CwRXMFlh.js} +1 -1
  99. package/dist/_frontend/assets/liquid-CwRXMFlh.js.br +0 -0
  100. package/dist/_frontend/assets/liquid-CwRXMFlh.js.gz +0 -0
  101. package/dist/_frontend/assets/{lspLanguageFeatures-DOi8NUmF.js → lspLanguageFeatures-B98nYdvb.js} +1 -1
  102. package/dist/_frontend/assets/lspLanguageFeatures-B98nYdvb.js.br +0 -0
  103. package/dist/_frontend/assets/lspLanguageFeatures-B98nYdvb.js.gz +0 -0
  104. package/dist/_frontend/assets/{mdx-BL2dt5jx.js → mdx-D0UlWv_H.js} +1 -1
  105. package/dist/_frontend/assets/mdx-D0UlWv_H.js.br +0 -0
  106. package/dist/_frontend/assets/mdx-D0UlWv_H.js.gz +0 -0
  107. package/dist/_frontend/assets/{python-CkuGrV2N.js → python-CIXaRbYy.js} +1 -1
  108. package/dist/_frontend/assets/python-CIXaRbYy.js.br +0 -0
  109. package/dist/_frontend/assets/python-CIXaRbYy.js.gz +0 -0
  110. package/dist/_frontend/assets/{razor-Dt8sFrC-.js → razor-CBLZ0NzN.js} +1 -1
  111. package/dist/_frontend/assets/razor-CBLZ0NzN.js.br +0 -0
  112. package/dist/_frontend/assets/razor-CBLZ0NzN.js.gz +0 -0
  113. package/dist/_frontend/assets/{tsMode-B_gRQCx3.js → tsMode-CivC8OeI.js} +1 -1
  114. package/dist/_frontend/assets/tsMode-CivC8OeI.js.br +0 -0
  115. package/dist/_frontend/assets/tsMode-CivC8OeI.js.gz +0 -0
  116. package/dist/_frontend/assets/{typescript-DnJ1ogIc.js → typescript-BM4iNKSB.js} +1 -1
  117. package/dist/_frontend/assets/typescript-BM4iNKSB.js.br +0 -0
  118. package/dist/_frontend/assets/typescript-BM4iNKSB.js.gz +0 -0
  119. package/dist/_frontend/assets/{workers-fWtSUNw0.js → workers-BR6L-g0Y.js} +1 -1
  120. package/dist/_frontend/assets/workers-BR6L-g0Y.js.br +0 -0
  121. package/dist/_frontend/assets/workers-BR6L-g0Y.js.gz +0 -0
  122. package/dist/_frontend/assets/{xml-CJuaWeYH.js → xml-Boz2MZIU.js} +1 -1
  123. package/dist/_frontend/assets/xml-Boz2MZIU.js.br +0 -0
  124. package/dist/_frontend/assets/xml-Boz2MZIU.js.gz +0 -0
  125. package/dist/_frontend/assets/{yaml-BYCHZC_g.js → yaml-xyc41kUk.js} +1 -1
  126. package/dist/_frontend/assets/yaml-xyc41kUk.js.br +0 -0
  127. package/dist/_frontend/assets/yaml-xyc41kUk.js.gz +0 -0
  128. package/dist/_frontend/index.html +1 -1
  129. package/dist/controller-main.js +475 -273
  130. package/dist/controller-main.js.map +1 -1
  131. package/dist/main.js +2207 -1556
  132. package/dist/main.js.map +1 -1
  133. package/dist/postgres/migrations/20260727_000001_init.js +1 -0
  134. package/dist/postgres/migrations/20260727_000001_init.js.map +1 -1
  135. package/dist/postgres/migrations/20261103_000001_sandbox_environment_type_truefoundry.js +1 -0
  136. package/dist/postgres/migrations/20261103_000001_sandbox_environment_type_truefoundry.js.map +1 -1
  137. package/dist/postgres/migrations/20261104_000002_memory_provider.js +15 -0
  138. package/dist/postgres/migrations/20261104_000002_memory_provider.js.map +1 -0
  139. package/dist/sqlite/migrations/20261104_000002_memory_provider.js +25 -0
  140. package/dist/sqlite/migrations/20261104_000002_memory_provider.js.map +1 -0
  141. package/package.json +2 -2
  142. package/dist/_frontend/assets/AgentCodeSnippets-KAYJRSGM-t2jGx88c.js.br +0 -0
  143. package/dist/_frontend/assets/AgentCodeSnippets-KAYJRSGM-t2jGx88c.js.gz +0 -0
  144. package/dist/_frontend/assets/AgentMetricChart-QKWQDPNE-D87qhLsV.js.br +0 -0
  145. package/dist/_frontend/assets/AgentMetricChart-QKWQDPNE-D87qhLsV.js.gz +0 -0
  146. package/dist/_frontend/assets/AgentOverview-QML2L4VB-Buf9yM4Z.js +0 -1
  147. package/dist/_frontend/assets/AgentOverview-QML2L4VB-Buf9yM4Z.js.br +0 -0
  148. package/dist/_frontend/assets/AgentOverview-QML2L4VB-Buf9yM4Z.js.gz +0 -0
  149. package/dist/_frontend/assets/AgentSessionEventTimeline-LXZ4FOEP-BCsQ5q8M.js.br +0 -0
  150. package/dist/_frontend/assets/AgentSessionEventTimeline-LXZ4FOEP-BCsQ5q8M.js.gz +0 -0
  151. package/dist/_frontend/assets/AgentSessionEventTimelineChart-UGDY3DXV-zv0rxgUh.js.br +0 -0
  152. package/dist/_frontend/assets/AgentSessionEventTimelineChart-UGDY3DXV-zv0rxgUh.js.gz +0 -0
  153. package/dist/_frontend/assets/AgentSessions-RNQJNNUN-JkCPXE-S.js.br +0 -0
  154. package/dist/_frontend/assets/AgentSessions-RNQJNNUN-JkCPXE-S.js.gz +0 -0
  155. package/dist/_frontend/assets/ConnectorSettings-FZ6PADBD-CdxBUs-y.js.br +0 -0
  156. package/dist/_frontend/assets/ConnectorSettings-FZ6PADBD-CdxBUs-y.js.gz +0 -0
  157. package/dist/_frontend/assets/DrawerLayout-G6IFSHR2-BMHEUtpn.js.br +0 -0
  158. package/dist/_frontend/assets/DrawerLayout-G6IFSHR2-BMHEUtpn.js.gz +0 -0
  159. package/dist/_frontend/assets/EnvironmentsPage-YG7ABMNR-DeZwiCGc.js.br +0 -0
  160. package/dist/_frontend/assets/EnvironmentsPage-YG7ABMNR-DeZwiCGc.js.gz +0 -0
  161. package/dist/_frontend/assets/ModelSettings-VVLPTON7-CjHRtjan.js.br +0 -0
  162. package/dist/_frontend/assets/ModelSettings-VVLPTON7-CjHRtjan.js.gz +0 -0
  163. package/dist/_frontend/assets/SandboxSettings-FR5GBIEJ-RecKXXOz.js.br +0 -0
  164. package/dist/_frontend/assets/SandboxSettings-FR5GBIEJ-RecKXXOz.js.gz +0 -0
  165. package/dist/_frontend/assets/SchedulesPage-VJNU6YI5-C3w2UmoO.js.br +0 -0
  166. package/dist/_frontend/assets/SchedulesPage-VJNU6YI5-C3w2UmoO.js.gz +0 -0
  167. package/dist/_frontend/assets/SettingsBuilder-OZXAOONL-C3FLBig-.js +0 -2
  168. package/dist/_frontend/assets/SettingsBuilder-OZXAOONL-C3FLBig-.js.br +0 -0
  169. package/dist/_frontend/assets/SettingsBuilder-OZXAOONL-C3FLBig-.js.gz +0 -0
  170. package/dist/_frontend/assets/ShellRouteSync-UUGKAWDN-CyXGIlGM.js.br +0 -0
  171. package/dist/_frontend/assets/ShellRouteSync-UUGKAWDN-CyXGIlGM.js.gz +0 -0
  172. package/dist/_frontend/assets/SidebarLayout-H7DIHXYF-j8SSyd5l.js.br +0 -0
  173. package/dist/_frontend/assets/SidebarLayout-H7DIHXYF-j8SSyd5l.js.gz +0 -0
  174. package/dist/_frontend/assets/SkillSettings-4BFXYN43-DaWF2tPn.js.br +0 -0
  175. package/dist/_frontend/assets/SkillSettings-4BFXYN43-DaWF2tPn.js.gz +0 -0
  176. package/dist/_frontend/assets/WebSearchSettings-F4GST24B-CyUAlECs.js.br +0 -0
  177. package/dist/_frontend/assets/WebSearchSettings-F4GST24B-CyUAlECs.js.gz +0 -0
  178. package/dist/_frontend/assets/WidgetLayout-7HIMRVUF-DEPMSv8o.js.br +0 -0
  179. package/dist/_frontend/assets/WidgetLayout-7HIMRVUF-DEPMSv8o.js.gz +0 -0
  180. package/dist/_frontend/assets/chunk-F2MZYGMM-DHpanE7I.js.br +0 -0
  181. package/dist/_frontend/assets/chunk-F2MZYGMM-DHpanE7I.js.gz +0 -0
  182. package/dist/_frontend/assets/chunk-MIQXDKJG-BmOYOrKB.js.br +0 -0
  183. package/dist/_frontend/assets/chunk-MIQXDKJG-BmOYOrKB.js.gz +0 -0
  184. package/dist/_frontend/assets/chunk-OB3PAWPO-B7JixYPy.js.br +0 -0
  185. package/dist/_frontend/assets/chunk-OB3PAWPO-B7JixYPy.js.gz +0 -0
  186. package/dist/_frontend/assets/chunk-YDJ4YR2V-DoV9K_ey.js.br +0 -0
  187. package/dist/_frontend/assets/chunk-YDJ4YR2V-DoV9K_ey.js.gz +0 -0
  188. package/dist/_frontend/assets/cssMode-Bylkausn.js.br +0 -0
  189. package/dist/_frontend/assets/cssMode-Bylkausn.js.gz +0 -0
  190. package/dist/_frontend/assets/freemarker2-D2xJV5zt.js.br +0 -0
  191. package/dist/_frontend/assets/freemarker2-D2xJV5zt.js.gz +0 -0
  192. package/dist/_frontend/assets/handlebars-C980sstL.js.br +0 -0
  193. package/dist/_frontend/assets/handlebars-C980sstL.js.gz +0 -0
  194. package/dist/_frontend/assets/html-CAJSd_2U.js.br +0 -0
  195. package/dist/_frontend/assets/html-CAJSd_2U.js.gz +0 -0
  196. package/dist/_frontend/assets/htmlMode-6rYtYcvL.js.br +0 -0
  197. package/dist/_frontend/assets/htmlMode-6rYtYcvL.js.gz +0 -0
  198. package/dist/_frontend/assets/index-CbQ6bGFO.js.br +0 -0
  199. package/dist/_frontend/assets/index-CbQ6bGFO.js.gz +0 -0
  200. package/dist/_frontend/assets/index-Dx9OO7_F.js.br +0 -0
  201. package/dist/_frontend/assets/index-Dx9OO7_F.js.gz +0 -0
  202. package/dist/_frontend/assets/jsonMode-DqyhOdz1.js.br +0 -0
  203. package/dist/_frontend/assets/jsonMode-DqyhOdz1.js.gz +0 -0
  204. package/dist/_frontend/assets/liquid-CuEtLH2I.js.br +0 -0
  205. package/dist/_frontend/assets/liquid-CuEtLH2I.js.gz +0 -0
  206. package/dist/_frontend/assets/lspLanguageFeatures-DOi8NUmF.js.br +0 -0
  207. package/dist/_frontend/assets/lspLanguageFeatures-DOi8NUmF.js.gz +0 -0
  208. package/dist/_frontend/assets/mdx-BL2dt5jx.js.br +0 -0
  209. package/dist/_frontend/assets/mdx-BL2dt5jx.js.gz +0 -0
  210. package/dist/_frontend/assets/python-CkuGrV2N.js.br +0 -0
  211. package/dist/_frontend/assets/python-CkuGrV2N.js.gz +0 -0
  212. package/dist/_frontend/assets/razor-Dt8sFrC-.js.br +0 -0
  213. package/dist/_frontend/assets/razor-Dt8sFrC-.js.gz +0 -0
  214. package/dist/_frontend/assets/tsMode-B_gRQCx3.js.br +0 -0
  215. package/dist/_frontend/assets/tsMode-B_gRQCx3.js.gz +0 -0
  216. package/dist/_frontend/assets/typescript-DnJ1ogIc.js.br +0 -0
  217. package/dist/_frontend/assets/typescript-DnJ1ogIc.js.gz +0 -0
  218. package/dist/_frontend/assets/workers-fWtSUNw0.js.br +0 -0
  219. package/dist/_frontend/assets/workers-fWtSUNw0.js.gz +0 -0
  220. package/dist/_frontend/assets/xml-CJuaWeYH.js.br +0 -0
  221. package/dist/_frontend/assets/xml-CJuaWeYH.js.gz +0 -0
  222. package/dist/_frontend/assets/yaml-BYCHZC_g.js.br +0 -0
  223. package/dist/_frontend/assets/yaml-BYCHZC_g.js.gz +0 -0
@@ -1 +1 @@
1
- import{b9 as ce,d as pe,ab as ge,v as ye,ba as fe,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 P,bj as ne,bk as B}from"./index-CbQ6bGFO.js";import{u as Re,a as Ee}from"./chunk-OB3PAWPO-B7JixYPy.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 Ce(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);Ce(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 Pe(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=ye(),I=fe(),G=he(),K=de(),W=me(),Y=Se(),H=Re(),r=Ee(),c=a.useMemo(()=>be({routes:t,catalog:q,capabilities:W,sessions:v,schedules:G,sandboxEnvironments:K}),[t,q,W,v,G,K]),U=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=Pe(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 y=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,f])=>{if(L.current!==n){A(n);return}if(!f){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){y.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){y.current=null;return}y.current=s,e.setHistoryAgentFilter(n),p!=null&&ve({server:p,agentName:n.agentName}).then(i=>{if(y.current===s){if(i==null){y.current=null,m.current=null,e.setHistoryAgentFilter(null);return}y.current=null,e.setHistoryAgentFilter({agentId:Ne(i),agentName:i.name,intent:n.intent})}}).catch(()=>{y.current===s&&(y.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(!Y&&((n==null?void 0:n.type)==="settings"||(n==null?void 0:n.type)==="environments"))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=U&&(u||s.type==="settings");if(s.type==="settings")U&&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 C=re(j);P(C,s)||F(s),i&&e.setSettingsOpen(!0)}s.type!=="agent"&&l!=null?d(l):O(s)||d(null);const f=i?{type:"settings"}:s;b.current=P(g,f)?null:f;const h=ne(f,c),E=se(B(f,r.search),l);w.current=f,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}))},[Y]),a.useEffect(()=>{if(!R.current)return;if(!Q.current){Q.current=!0;return}const n=b.current;if(n!=null){if(!P(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}`||"/",f=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&&(y.current=null,e.setHistoryAgentFilter(null)),e.historyAgentFilter!=null&&(m.current=null);const C=se(B(g,f),E),ee=w.current;if(w.current=g,s===r.pathname&&C===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:C,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||!P(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 ye,ba as fe,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 P,bj as ne,bk as B}from"./index-J4S6NjFF.js";import{u as Re,a as Ee}from"./chunk-OB3PAWPO-CZaXL0XY.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 Ce(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);Ce(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 Pe(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=ye(),I=fe(),G=he(),K=de(),W=me(),Y=Se(),H=Re(),r=Ee(),c=a.useMemo(()=>be({routes:t,catalog:q,capabilities:W,sessions:v,schedules:G,sandboxEnvironments:K}),[t,q,W,v,G,K]),U=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=Pe(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 y=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,f])=>{if(L.current!==n){A(n);return}if(!f){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){y.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){y.current=null;return}y.current=s,e.setHistoryAgentFilter(n),p!=null&&ve({server:p,agentName:n.agentName}).then(i=>{if(y.current===s){if(i==null){y.current=null,m.current=null,e.setHistoryAgentFilter(null);return}y.current=null,e.setHistoryAgentFilter({agentId:Ne(i),agentName:i.name,intent:n.intent})}}).catch(()=>{y.current===s&&(y.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(!Y&&((n==null?void 0:n.type)==="settings"||(n==null?void 0:n.type)==="environments"))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=U&&(u||s.type==="settings");if(s.type==="settings")U&&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 C=re(j);P(C,s)||F(s),i&&e.setSettingsOpen(!0)}s.type!=="agent"&&l!=null?d(l):O(s)||d(null);const f=i?{type:"settings"}:s;b.current=P(g,f)?null:f;const h=ne(f,c),E=se(B(f,r.search),l);w.current=f,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}))},[Y]),a.useEffect(()=>{if(!R.current)return;if(!Q.current){Q.current=!0;return}const n=b.current;if(n!=null){if(!P(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}`||"/",f=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&&(y.current=null,e.setHistoryAgentFilter(null)),e.historyAgentFilter!=null&&(m.current=null);const C=se(B(g,f),E),ee=w.current;if(w.current=g,s===r.pathname&&C===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:C,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||!P(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-OZXAOONL-C3FLBig-.js","./index-CbQ6bGFO.js","./index-B01pXqvC.css","./SchedulesPage-VJNU6YI5-C3w2UmoO.js","./chunk-MIQXDKJG-BmOYOrKB.js","./EnvironmentsPage-YG7ABMNR-DeZwiCGc.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-CbQ6bGFO.js";import{A as kn,N as Bn,T as Fn,S as it}from"./chunk-F2MZYGMM-DHpanE7I.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-OZXAOONL-C3FLBig-.js"),__vite__mapDeps([0,1,2]),import.meta.url)),us=m.lazy(()=>Ne(()=>import("./SchedulesPage-VJNU6YI5-C3w2UmoO.js"),__vite__mapDeps([3,4,1,2]),import.meta.url).then(n=>({default:n.SchedulesPage}))),ds=m.lazy(()=>Ne(()=>import("./EnvironmentsPage-YG7ABMNR-DeZwiCGc.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-C2RPDCLY-BxxIgV4z.js","./index-J4S6NjFF.js","./index-B01pXqvC.css","./SchedulesPage-RKL2JJTC-IsOsS2eL.js","./chunk-MIQXDKJG-DDf3acU8.js","./EnvironmentsPage-DAJPUASL-nCQjN8ee.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-J4S6NjFF.js";import{A as kn,N as Bn,T as Fn,S as it}from"./chunk-NGI4HR24-Ck1XamIM.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-C2RPDCLY-BxxIgV4z.js"),__vite__mapDeps([0,1,2]),import.meta.url)),us=m.lazy(()=>Ne(()=>import("./SchedulesPage-RKL2JJTC-IsOsS2eL.js"),__vite__mapDeps([3,4,1,2]),import.meta.url).then(n=>({default:n.SchedulesPage}))),ds=m.lazy(()=>Ne(()=>import("./EnvironmentsPage-DAJPUASL-nCQjN8ee.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-WW6L37U3-DmX_GP2D.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-CbQ6bGFO.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-BOLUYVO2-Y-H80bTu.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-J4S6NjFF.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-CbQ6bGFO.js";import{B as u}from"./chunk-OB3PAWPO-B7JixYPy.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-J4S6NjFF.js";import{B as u}from"./chunk-OB3PAWPO-CZaXL0XY.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 +1 @@
1
- import{ab as X,b as Y,bd as Z,bl as ee,p as ae,q as te,r as s,x as C,j as e,ak as se,I as F,E as B,_ as z,bs as re,aa as ne}from"./index-CbQ6bGFO.js";var le=ne("h-11 shadow-sm"),ie=({open:m,onOpenChange:f,onSave:k,title:l,description:n,requireApiKey:u=!0,busy:E=!1,error:r})=>{const[i,p]=s.useState(""),v=()=>{p("")};s.useEffect(()=>{m&&p("")},[m]);const w=d=>{d||v(),f(d)},c=i.trim(),g=!u||!!c,y=async d=>{if(d.preventDefault(),!(!g||E))try{await k({apiKey:c}),v(),f(!1)}catch{}};return e.jsx(re,{open:m,onOpenChange:w,title:l,description:n,contentSized:!0,headerIcon:e.jsx("span",{className:"flex size-11 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:e.jsx(F,{name:"search",className:"size-6"})}),children:e.jsxs("form",{className:"flex flex-col overflow-y-auto p-5 md:p-6",onSubmit:y,children:[e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"web-search-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",u?null:e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"web-search-api-key",type:"password",required:u,value:i,onChange:d=>{p(d.target.value)},placeholder:u?"Parallel API key":"Leave blank to keep existing",autoFocus:!0,className:le})]})}),e.jsxs("div",{className:"mt-6 space-y-3",children:[r?e.jsx("p",{className:"text-failure-bg text-sm",children:r}):null,e.jsx(B.Primary,{type:"submit",size:"large",disabled:!g||E,className:"w-full shrink-0",children:"Save"})]})]})})},ce=ie,de=()=>{var D,M;const m=X(),f=(D=Y())==null?void 0:D.settings,k=Z(),l=ee(),n=ae(),u=te(),r=k&&((M=f==null?void 0:f.webSearch)==null?void 0:M.manageProviders)!==!1?m==null?void 0:m.webSearchCatalog:void 0,[i,p]=s.useState(null),[v,w]=s.useState(!1),[c,g]=s.useState([]),[y,d]=s.useState([]),[U,P]=s.useState(!0),[O,x]=s.useState(null),[L,b]=s.useState(null),[A,R]=s.useState(!1),[o,j]=s.useState(null),[h,S]=s.useState(null),W=s.useCallback(async({quiet:a=!1}={})=>{if(!r){g([]),d([]),P(!1);return}a||P(!0),x(null);try{const[t,N]=await Promise.all([r.listWebSearchProviders(),r.getWebSearchProviderCatalog()]);g(t),d(N)}catch(t){x(C(t,"Failed to load web search providers"))}finally{a||P(!1)}},[r]);s.useEffect(()=>{W()},[W]),s.useEffect(()=>{if(!l)return;let a=!1;return l.getConfiguration().then(t=>{a||p(t.webSearch.enabled)}).catch(t=>{a||x(C(t,"Failed to load the web search setting"))}),()=>{a=!0}},[l]);const V=async a=>{if(l){w(!0),x(null);try{const t=await l.updateConfiguration({webSearch:{enabled:a}});p(t.webSearch.enabled),n==null||n.showSuccess({title:t.webSearch.enabled?"Web search turned on":"Web search turned off"}),u(z.Settings.WEB_SEARCH_TENANT_TOGGLED,{enabled:t.webSearch.enabled})}catch(t){x(C(t,"Failed to save the web search setting"))}finally{w(!1)}}},_=c.length>0,I=s.useMemo(()=>{if(_)return[];const a=new Set(c.map(t=>t.catalogId));return y.filter(t=>!a.has(t.id))},[y,c,_]),$=l==null||i!==null,H=r!=null&&$&&i!==!1;if(r==null&&l==null)return e.jsx("p",{className:"text-sm text-text-secondary",children:"Web search provider catalog is not available."});const K=async(a,t=x)=>{R(!0),x(null);try{await a(),await W({quiet:!0})}catch(N){throw t(C(N,"Request failed")),N}finally{R(!1)}},G=async a=>{!o||!r||(b(null),await K(async()=>{await r.createWebSearchProvider({catalogId:o.id,name:o.name,type:o.type,apiKey:a.apiKey})},b),j(null),setTimeout(()=>{n==null||n.showSuccess({title:`${o.name} configured`}),u(z.Settings.WEB_SEARCH_PROVIDER_SAVED,{provider_name:o.name,mode:"create"})},0))},q=async a=>{!h||!r||(b(null),await K(async()=>{await r.updateWebSearchProvider({id:h.id,...a.apiKey?{apiKey:a.apiKey}:{}})},b),S(null),setTimeout(()=>{n==null||n.showSuccess({title:`${h.name} updated`}),u(z.Settings.WEB_SEARCH_PROVIDER_SAVED,{provider_name:h.name,mode:"update"})},0))},J=o!=null||h!=null,T=h!=null,Q=h?`Update ${h.name}`:o?`Configure ${o.name}`:"Configure web search provider";return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Web search"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Choose whether agents in this tenant may search the web."}),O?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:O}):null,i!==null?e.jsxs("div",{className:"mt-4 flex items-center justify-between gap-4 rounded-xl border border-border bg-card-bg p-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h4",{className:"text-sm font-medium text-text-primary",children:"Allow web search"}),e.jsx("p",{className:"mt-0.5 text-xs text-text-secondary",children:i?"New chats may use web search. Chats already using it keep it.":"New chats cannot use web search. Chats already using it keep it."})]}),e.jsx(se,{checked:i,disabled:v,"aria-label":"Allow web search",onCheckedChange:a=>{V(a)}})]}):null,i===!1?e.jsxs("p",{className:"mt-3 text-sm text-text-secondary",children:["Turn this back on whenever you want. Nothing is deleted while web search is off",r==null?".":", and provider setup comes back with it."]}):null,e.jsx("div",{className:"mt-4 flex-1 overflow-y-auto",children:H?U?e.jsx("p",{className:"text-sm text-text-secondary",children:"Loading web search providers…"}):e.jsxs("div",{className:"space-y-6",children:[e.jsx("p",{className:"text-sm text-text-secondary",children:"Configure a provider so agents can search the web. Only one can be active at a time."}),c.length>0?e.jsxs("section",{children:[e.jsxs("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Configured · ",c.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:c.map(a=>e.jsxs("article",{className:"flex flex-col gap-3 border-b border-border p-3 last:border-b-0 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:e.jsx(F,{name:"search",className:"size-4.5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:a.name}),e.jsx("p",{className:"truncate text-xs text-text-secondary",children:"Parallel web search"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 sm:justify-end",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-sm font-medium text-success-bg",children:[e.jsx("span",{className:"size-2 rounded-full bg-success-bg","aria-hidden":!0}),"Connected"]}),e.jsx(B.Secondary,{size:"small",type:"button",disabled:A,onClick:()=>{b(null),j(null),S(a)},children:"Update"})]})]},a.id))})]}):null,_?null:e.jsxs("section",{children:[e.jsxs("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Available · ",I.length]}),I.length===0?e.jsx("p",{className:"text-sm text-text-secondary",children:y.length>0?"All catalog providers are configured.":"No web search providers in the catalog."}):e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:I.map(a=>e.jsxs("article",{className:"flex flex-col gap-3 border-b border-border p-3 last:border-b-0 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:e.jsx(F,{name:"search",className:"size-4.5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:a.name}),e.jsx("p",{className:"truncate text-xs text-text-secondary",children:"Parallel web search"})]})]}),e.jsx(B.Secondary,{type:"button",disabled:A,onClick:()=>{b(null),S(null),j(a)},children:"Configure"})]},a.id))})]})]}):null}),e.jsx(ce,{open:J,onOpenChange:a=>{a||(b(null),j(null),S(null))},onSave:T?q:G,title:Q,description:T?"Update this web search provider. Leave API key blank to keep the existing key.":"Configure this web search provider. API key is never stored in the catalog.",requireApiKey:!T,busy:A,error:L})]})},ue=de;export{ue as default};
1
+ import{ab as X,b as Y,bd as Z,bl as ee,p as ae,q as te,r as s,x as C,j as e,ak as se,I as F,E as B,_ as z,bs as re,aa as ne}from"./index-J4S6NjFF.js";var le=ne("h-11 shadow-sm"),ie=({open:m,onOpenChange:f,onSave:k,title:l,description:n,requireApiKey:u=!0,busy:E=!1,error:r})=>{const[i,p]=s.useState(""),v=()=>{p("")};s.useEffect(()=>{m&&p("")},[m]);const w=d=>{d||v(),f(d)},c=i.trim(),g=!u||!!c,y=async d=>{if(d.preventDefault(),!(!g||E))try{await k({apiKey:c}),v(),f(!1)}catch{}};return e.jsx(re,{open:m,onOpenChange:w,title:l,description:n,contentSized:!0,headerIcon:e.jsx("span",{className:"flex size-11 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:e.jsx(F,{name:"search",className:"size-6"})}),children:e.jsxs("form",{className:"flex flex-col overflow-y-auto p-5 md:p-6",onSubmit:y,children:[e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"web-search-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",u?null:e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"web-search-api-key",type:"password",required:u,value:i,onChange:d=>{p(d.target.value)},placeholder:u?"Parallel API key":"Leave blank to keep existing",autoFocus:!0,className:le})]})}),e.jsxs("div",{className:"mt-6 space-y-3",children:[r?e.jsx("p",{className:"text-failure-bg text-sm",children:r}):null,e.jsx(B.Primary,{type:"submit",size:"large",disabled:!g||E,className:"w-full shrink-0",children:"Save"})]})]})})},ce=ie,de=()=>{var D,M;const m=X(),f=(D=Y())==null?void 0:D.settings,k=Z(),l=ee(),n=ae(),u=te(),r=k&&((M=f==null?void 0:f.webSearch)==null?void 0:M.manageProviders)!==!1?m==null?void 0:m.webSearchCatalog:void 0,[i,p]=s.useState(null),[v,w]=s.useState(!1),[c,g]=s.useState([]),[y,d]=s.useState([]),[U,P]=s.useState(!0),[O,x]=s.useState(null),[L,b]=s.useState(null),[A,R]=s.useState(!1),[o,j]=s.useState(null),[h,S]=s.useState(null),W=s.useCallback(async({quiet:a=!1}={})=>{if(!r){g([]),d([]),P(!1);return}a||P(!0),x(null);try{const[t,N]=await Promise.all([r.listWebSearchProviders(),r.getWebSearchProviderCatalog()]);g(t),d(N)}catch(t){x(C(t,"Failed to load web search providers"))}finally{a||P(!1)}},[r]);s.useEffect(()=>{W()},[W]),s.useEffect(()=>{if(!l)return;let a=!1;return l.getConfiguration().then(t=>{a||p(t.webSearch.enabled)}).catch(t=>{a||x(C(t,"Failed to load the web search setting"))}),()=>{a=!0}},[l]);const V=async a=>{if(l){w(!0),x(null);try{const t=await l.updateConfiguration({webSearch:{enabled:a}});p(t.webSearch.enabled),n==null||n.showSuccess({title:t.webSearch.enabled?"Web search turned on":"Web search turned off"}),u(z.Settings.WEB_SEARCH_TENANT_TOGGLED,{enabled:t.webSearch.enabled})}catch(t){x(C(t,"Failed to save the web search setting"))}finally{w(!1)}}},_=c.length>0,I=s.useMemo(()=>{if(_)return[];const a=new Set(c.map(t=>t.catalogId));return y.filter(t=>!a.has(t.id))},[y,c,_]),$=l==null||i!==null,H=r!=null&&$&&i!==!1;if(r==null&&l==null)return e.jsx("p",{className:"text-sm text-text-secondary",children:"Web search provider catalog is not available."});const K=async(a,t=x)=>{R(!0),x(null);try{await a(),await W({quiet:!0})}catch(N){throw t(C(N,"Request failed")),N}finally{R(!1)}},G=async a=>{!o||!r||(b(null),await K(async()=>{await r.createWebSearchProvider({catalogId:o.id,name:o.name,type:o.type,apiKey:a.apiKey})},b),j(null),setTimeout(()=>{n==null||n.showSuccess({title:`${o.name} configured`}),u(z.Settings.WEB_SEARCH_PROVIDER_SAVED,{provider_name:o.name,mode:"create"})},0))},q=async a=>{!h||!r||(b(null),await K(async()=>{await r.updateWebSearchProvider({id:h.id,...a.apiKey?{apiKey:a.apiKey}:{}})},b),S(null),setTimeout(()=>{n==null||n.showSuccess({title:`${h.name} updated`}),u(z.Settings.WEB_SEARCH_PROVIDER_SAVED,{provider_name:h.name,mode:"update"})},0))},J=o!=null||h!=null,T=h!=null,Q=h?`Update ${h.name}`:o?`Configure ${o.name}`:"Configure web search provider";return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Web search"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Choose whether agents in this tenant may search the web."}),O?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:O}):null,i!==null?e.jsxs("div",{className:"mt-4 flex items-center justify-between gap-4 rounded-xl border border-border bg-card-bg p-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h4",{className:"text-sm font-medium text-text-primary",children:"Allow web search"}),e.jsx("p",{className:"mt-0.5 text-xs text-text-secondary",children:i?"New chats may use web search. Chats already using it keep it.":"New chats cannot use web search. Chats already using it keep it."})]}),e.jsx(se,{checked:i,disabled:v,"aria-label":"Allow web search",onCheckedChange:a=>{V(a)}})]}):null,i===!1?e.jsxs("p",{className:"mt-3 text-sm text-text-secondary",children:["Turn this back on whenever you want. Nothing is deleted while web search is off",r==null?".":", and provider setup comes back with it."]}):null,e.jsx("div",{className:"mt-4 flex-1 overflow-y-auto",children:H?U?e.jsx("p",{className:"text-sm text-text-secondary",children:"Loading web search providers…"}):e.jsxs("div",{className:"space-y-6",children:[e.jsx("p",{className:"text-sm text-text-secondary",children:"Configure a provider so agents can search the web. Only one can be active at a time."}),c.length>0?e.jsxs("section",{children:[e.jsxs("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Configured · ",c.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:c.map(a=>e.jsxs("article",{className:"flex flex-col gap-3 border-b border-border p-3 last:border-b-0 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:e.jsx(F,{name:"search",className:"size-4.5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:a.name}),e.jsx("p",{className:"truncate text-xs text-text-secondary",children:"Parallel web search"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 sm:justify-end",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-sm font-medium text-success-bg",children:[e.jsx("span",{className:"size-2 rounded-full bg-success-bg","aria-hidden":!0}),"Connected"]}),e.jsx(B.Secondary,{size:"small",type:"button",disabled:A,onClick:()=>{b(null),j(null),S(a)},children:"Update"})]})]},a.id))})]}):null,_?null:e.jsxs("section",{children:[e.jsxs("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Available · ",I.length]}),I.length===0?e.jsx("p",{className:"text-sm text-text-secondary",children:y.length>0?"All catalog providers are configured.":"No web search providers in the catalog."}):e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:I.map(a=>e.jsxs("article",{className:"flex flex-col gap-3 border-b border-border p-3 last:border-b-0 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:e.jsx(F,{name:"search",className:"size-4.5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:a.name}),e.jsx("p",{className:"truncate text-xs text-text-secondary",children:"Parallel web search"})]})]}),e.jsx(B.Secondary,{type:"button",disabled:A,onClick:()=>{b(null),S(null),j(a)},children:"Configure"})]},a.id))})]})]}):null}),e.jsx(ce,{open:J,onOpenChange:a=>{a||(b(null),j(null),S(null))},onSave:T?q:G,title:Q,description:T?"Update this web search provider. Leave API key blank to keep the existing key.":"Configure this web search provider. API key is never stored in the catalog.",requireApiKey:!T,busy:A,error:L})]})},ue=de;export{ue as default};
@@ -1 +1 @@
1
- import{S as m}from"./chunk-YDJ4YR2V-DoV9K_ey.js";import{u as x,b8 as f,r,j as e,b7 as p,I as b,a3 as h,c as v}from"./index-CbQ6bGFO.js";import"./chunk-F2MZYGMM-DHpanE7I.js";function j({className:u}){const d=x("BrandLogo"),{open:a,setOpen:n}=f(),l=r.useRef(null),s=r.useRef(null),i=r.useRef(!1);return r.useEffect(()=>{if(!a)return;const t=o=>{var c;o.key==="Escape"&&!((c=s.current)!=null&&c.querySelector("dialog[open]"))&&n(!1)};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[a,n]),r.useEffect(()=>{var t,o;if(a){i.current=!0,(t=s.current)==null||t.focus();return}i.current&&((o=l.current)==null||o.focus(),i.current=!1)},[a]),e.jsxs("div",{className:v("pointer-events-none relative h-full min-h-0 w-full",u),children:[a?e.jsx("div",{ref:s,"data-aui-compact-layout":!0,className:"pointer-events-auto absolute right-[max(1.25rem,env(safe-area-inset-right,0px))] bottom-[calc(5.25rem+env(safe-area-inset-bottom,0px))] z-[19] flex h-[min(560px,calc(100%-6.5rem-env(safe-area-inset-bottom,0px)))] max-h-[calc(100%-6.5rem)] w-[min(380px,calc(100%-2.5rem))] flex-col overflow-hidden rounded-xl border border-border bg-primary-bg shadow-[0_16px_48px_color-mix(in_oklab,var(--shadow-color)_14%,transparent)] outline-none",role:"dialog","aria-modal":!0,"aria-label":"Chat",tabIndex:-1,children:e.jsx(p,{children:e.jsx(m,{threadHeaderEnd:e.jsx("button",{type:"button","aria-label":"Close",title:"Close",className:h({variant:"ghost",size:"icon"}),onClick:()=>n(!1),children:e.jsx(b,{name:"xmark"})})})})}):null,e.jsx("button",{ref:l,type:"button",className:"pointer-events-auto absolute right-[max(1.25rem,env(safe-area-inset-right,0px))] bottom-[max(1.25rem,env(safe-area-inset-bottom,0px))] z-20 flex size-14 cursor-pointer items-center justify-center rounded-full text-sm font-medium shadow-[0_8px_24px_color-mix(in_oklab,var(--primary-button-bg)_45%,transparent)]",style:{backgroundColor:"var(--primary-button-bg)",color:"var(--primary-button-text)"},"aria-expanded":a,"aria-label":a?"Close chat":"Open chat",onClick:()=>n(t=>!t),children:a?e.jsx("span",{"aria-hidden":!0,className:"text-xl leading-none",children:"×"}):e.jsx(d,{variant:"icon",className:"size-6"})})]})}export{j as WidgetLayout};
1
+ import{S as m}from"./chunk-NHZJDZV6-B1IGm0KY.js";import{u as x,b8 as f,r,j as e,b7 as p,I as b,a3 as h,c as v}from"./index-J4S6NjFF.js";import"./chunk-NGI4HR24-Ck1XamIM.js";function j({className:u}){const d=x("BrandLogo"),{open:a,setOpen:n}=f(),l=r.useRef(null),s=r.useRef(null),i=r.useRef(!1);return r.useEffect(()=>{if(!a)return;const t=o=>{var c;o.key==="Escape"&&!((c=s.current)!=null&&c.querySelector("dialog[open]"))&&n(!1)};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[a,n]),r.useEffect(()=>{var t,o;if(a){i.current=!0,(t=s.current)==null||t.focus();return}i.current&&((o=l.current)==null||o.focus(),i.current=!1)},[a]),e.jsxs("div",{className:v("pointer-events-none relative h-full min-h-0 w-full",u),children:[a?e.jsx("div",{ref:s,"data-aui-compact-layout":!0,className:"pointer-events-auto absolute right-[max(1.25rem,env(safe-area-inset-right,0px))] bottom-[calc(5.25rem+env(safe-area-inset-bottom,0px))] z-[19] flex h-[min(560px,calc(100%-6.5rem-env(safe-area-inset-bottom,0px)))] max-h-[calc(100%-6.5rem)] w-[min(380px,calc(100%-2.5rem))] flex-col overflow-hidden rounded-xl border border-border bg-primary-bg shadow-[0_16px_48px_color-mix(in_oklab,var(--shadow-color)_14%,transparent)] outline-none",role:"dialog","aria-modal":!0,"aria-label":"Chat",tabIndex:-1,children:e.jsx(p,{children:e.jsx(m,{threadHeaderEnd:e.jsx("button",{type:"button","aria-label":"Close",title:"Close",className:h({variant:"ghost",size:"icon"}),onClick:()=>n(!1),children:e.jsx(b,{name:"xmark"})})})})}):null,e.jsx("button",{ref:l,type:"button",className:"pointer-events-auto absolute right-[max(1.25rem,env(safe-area-inset-right,0px))] bottom-[max(1.25rem,env(safe-area-inset-bottom,0px))] z-20 flex size-14 cursor-pointer items-center justify-center rounded-full text-sm font-medium shadow-[0_8px_24px_color-mix(in_oklab,var(--primary-button-bg)_45%,transparent)]",style:{backgroundColor:"var(--primary-button-bg)",color:"var(--primary-button-text)"},"aria-expanded":a,"aria-label":a?"Close chat":"Open chat",onClick:()=>n(t=>!t),children:a?e.jsx("span",{"aria-hidden":!0,className:"text-xl leading-none",children:"×"}):e.jsx(d,{variant:"icon",className:"size-6"})})]})}export{j as WidgetLayout};
@@ -1 +1 @@
1
- import{j as e,R as m,U as u,V as h,W as j,X as p,E as n}from"./index-CbQ6bGFO.js";function g(a){return a.replace(/\?$/,"").replace(/^Remove /i,"Can't remove ")}var f=({title:a,description:o,confirmLabel:c="Remove",busy:i=!1,error:l=null,onCancel:t,onConfirm:d})=>{const s=l!=null&&l!=="",r=s?g(a):a;return e.jsxs(m,{open:!0,onOpenChange:x=>{x||t()},"aria-label":r,className:"max-w-md",children:[e.jsx(u,{children:e.jsxs(h,{children:[e.jsx(j,{children:r}),s?e.jsx("p",{role:"alert",className:"text-sm text-failure-bg",children:l}):e.jsx("p",{className:"text-sm text-text-secondary",children:o})]})}),e.jsx(p,{children:s?e.jsx(n.Secondary,{type:"button",onClick:t,children:"Close"}):e.jsxs(e.Fragment,{children:[e.jsx(n.Secondary,{type:"button",disabled:i,onClick:t,children:"Cancel"}),e.jsx(n.Destructive,{type:"button",disabled:i,onClick:d,children:c})]})})]})},C=f;export{C};
1
+ import{j as e,R as m,U as u,V as h,W as j,X as p,E as n}from"./index-J4S6NjFF.js";function g(a){return a.replace(/\?$/,"").replace(/^Remove /i,"Can't remove ")}var f=({title:a,description:o,confirmLabel:c="Remove",busy:i=!1,error:l=null,onCancel:t,onConfirm:d})=>{const s=l!=null&&l!=="",r=s?g(a):a;return e.jsxs(m,{open:!0,onOpenChange:x=>{x||t()},"aria-label":r,className:"max-w-md",children:[e.jsx(u,{children:e.jsxs(h,{children:[e.jsx(j,{children:r}),s?e.jsx("p",{role:"alert",className:"text-sm text-failure-bg",children:l}):e.jsx("p",{className:"text-sm text-text-secondary",children:o})]})}),e.jsx(p,{children:s?e.jsx(n.Secondary,{type:"button",onClick:t,children:"Close"}):e.jsxs(e.Fragment,{children:[e.jsx(n.Secondary,{type:"button",disabled:i,onClick:t,children:"Cancel"}),e.jsx(n.Destructive,{type:"button",disabled:i,onClick:d,children:c})]})})]})},C=f;export{C};
@@ -1 +1 @@
1
- import{al as o,j as t,c as s}from"./index-CbQ6bGFO.js";var u={default:"border-border bg-card-bg text-text-primary",success:"border-success-bg/30 bg-success-bg/10 text-success-bg",info:"border-primary-button-bg/30 bg-primary-button-bg/10 text-primary-button-bg",warning:"border-warning-bg/40 bg-warning-bg/10 text-warning-bg",destructive:"border-failure-bg/30 bg-failure-bg/10 text-failure-bg",outline:"border-border bg-transparent text-text-secondary"},l={default:"bg-text-secondary",success:"bg-success-bg",info:"bg-primary-button-bg",warning:"bg-warning-bg",destructive:"bg-failure-bg",outline:"bg-text-secondary"},c={rounded:"rounded-sm",pill:"rounded-full"},x={sm:"px-2 py-0.5 text-xs",md:"px-2.5 py-0.5 text-xs"},m=o.forwardRef(({className:n,variant:e="default",shape:r="rounded",size:a="sm",dot:b=!1,children:d,...g},i)=>t.jsxs("span",{ref:i,"data-slot":"badge","data-variant":e,"data-shape":r,"data-size":a,className:s("inline-flex items-center gap-1.5 border font-medium leading-normal",u[e],c[r],x[a],n),...g,children:[b?t.jsx("span",{className:s("size-1.5 shrink-0 rounded-full",l[e]),"aria-hidden":!0}):null,d]}));m.displayName="Badge";export{m as B};
1
+ import{al as o,j as t,c as s}from"./index-J4S6NjFF.js";var u={default:"border-border bg-card-bg text-text-primary",success:"border-success-bg/30 bg-success-bg/10 text-success-bg",info:"border-primary-button-bg/30 bg-primary-button-bg/10 text-primary-button-bg",warning:"border-warning-bg/40 bg-warning-bg/10 text-warning-bg",destructive:"border-failure-bg/30 bg-failure-bg/10 text-failure-bg",outline:"border-border bg-transparent text-text-secondary"},l={default:"bg-text-secondary",success:"bg-success-bg",info:"bg-primary-button-bg",warning:"bg-warning-bg",destructive:"bg-failure-bg",outline:"bg-text-secondary"},c={rounded:"rounded-sm",pill:"rounded-full"},x={sm:"px-2 py-0.5 text-xs",md:"px-2.5 py-0.5 text-xs"},m=o.forwardRef(({className:n,variant:e="default",shape:r="rounded",size:a="sm",dot:b=!1,children:d,...g},i)=>t.jsxs("span",{ref:i,"data-slot":"badge","data-variant":e,"data-shape":r,"data-size":a,className:s("inline-flex items-center gap-1.5 border font-medium leading-normal",u[e],c[r],x[a],n),...g,children:[b?t.jsx("span",{className:s("size-1.5 shrink-0 rounded-full",l[e]),"aria-hidden":!0}):null,d]}));m.displayName="Badge";export{m as B};
@@ -1 +1 @@
1
- import{t as D,j as t,G as me,r as d,bF as fe,u as b,bG as A,bH as ge,bI as pe,bJ as he,bK as xe,bL as H,bM as J,d as ne,b0 as se,bN as B,bO as ve,bP as be,bQ as Ce,bR as Se,bS as je,bn as we,b1 as ye,p as oe,bT as ke,bU as X,bV as re,bW as ae,bX as Ie,ab as ie,q,bY as G,_ as T,bZ as $,a4 as Ae,b_ as Ee,b$ as Me,c0 as Ne,c1 as Re,c2 as P,E as Z,c3 as Te,c4 as Pe,c5 as De,c6 as Le,bw as Oe,a9 as le,c7 as _e,c8 as ce,c9 as Fe,ca as Be,bE as z,cb as Ue,cc as He,cd as ze,ce as Ve,b9 as We,w as qe,b as ue,b3 as Qe,cf as Ke,cg as Ge,ch as Ye,ci as Je,I as F,a3 as W,c as _,cj as Y,ck as Xe,k as $e,cl as Ze}from"./index-CbQ6bGFO.js";function et(){var h;const{pending:n}=re(),e=_e(),[s,a]=d.useState({approvalId:null,index:0}),o=d.useRef(null),l=n.length,u=s.approvalId==null?-1:n.findIndex(f=>f.approvalId===s.approvalId),i=u>=0?u:l===0?0:Math.min(s.index,l-1),r=(h=n[i])==null?void 0:h.approvalId;d.useEffect(()=>{const f=r??null;s.approvalId===f&&s.index===i||a({approvalId:f,index:i})},[r,i,s.approvalId,s.index]),d.useEffect(()=>{if(r==null||e==null){r==null&&(o.current=null);return}o.current!==r&&(o.current=r,e.focus(r))},[r,e]);const c=d.useCallback(()=>{var C;const f=Math.max(0,i-1);a({approvalId:((C=n[f])==null?void 0:C.approvalId)??null,index:f})},[n,i]),m=d.useCallback(()=>{var C;const f=Math.min(Math.max(l-1,0),i+1);a({approvalId:((C=n[f])==null?void 0:C.approvalId)??null,index:f})},[l,n,i]),p=d.useCallback(()=>{r==null||e==null||e.focus(r)},[r,e]);return{count:l,index:i,canPrev:i>0,canNext:i<l-1,goPrev:c,goNext:m,focusCurrent:p}}function tt(){const n=b("ApprovalNavBanner"),{count:e,index:s,canPrev:a,canNext:o,goPrev:l,goNext:u,focusCurrent:i}=et();return e===0?null:t.jsx(n,{total:e,current:s+1,canPrev:a,canNext:o,onPrev:l,onNext:u,onFocusCurrent:i})}var O={radioValue:"",custom:""};function nt({disabled:n=!1}){const e=b("AskUserPrompt"),{pending:s,respond:a}=X(),o=q(),l=B(),u=s[0],i=d.useMemo(()=>u==null?[]:[{id:u.toolCallId,question:u.question??"Answer required",options:u.options??[]}],[u]),[r,c]=d.useState(0),[m,p]=d.useState({});d.useEffect(()=>{c(0),p({})},[u==null?void 0:u.toolCallId]);const h=Math.min(r,Math.max(i.length-1,0)),f=i[h],C=f==null?O:m[f.id]??O,S=d.useCallback(y=>{const k=m[y]??O;return k.radioValue===G?k.custom.trim():k.radioValue.trim()},[m]),x=d.useMemo(()=>i.every(y=>S(y.id)),[S,i]),j=C.radioValue===G?C.custom.trim():C.radioValue.trim(),w=l||n||f==null||j.length===0,I=w||!x,M=d.useCallback((y,k)=>{p(R=>({...R,[y]:{...R[y]??O,...k}}))},[]),E=d.useCallback(()=>{if(n||u==null||!x)return;const y=S(u.toolCallId);if(!y)return;const k=m[u.toolCallId]??O;o(T.AskUser.SUBMITTED,{tool_call_id:u.toolCallId,question_count:i.length,is_custom_option:k.radioValue===G}),a({toolCallId:u.toolCallId,content:y})},[x,m,n,S,u,i.length,a,o]);return u==null||f==null?null:t.jsx(e,{questions:i,readOnly:l||n,currentQuestion:f,currentQuestionIndex:h,currentAnswer:C,totalQuestions:i.length,isMultiQuestion:i.length>1,isLastQuestion:h===i.length-1,allQuestionsAnswered:x,isSubmitDisabled:w,isSubmitAllDisabled:I,onCurrentQuestionIndexChange:c,onCurrentAnswerChange:M,onSubmit:E})}function st(n){var a,o,l;const e=n.thread.messages,s=e[e.length-1];return(s==null?void 0:s.role)!=="assistant"||((a=s.status)==null?void 0:a.type)!=="requires-action"?!1:((l=(o=s.metadata)==null?void 0:o.custom)==null?void 0:l.pendingMcpAuth)===!0}function ot(){const n=A(st),{pending:e}=X(),{pending:s}=re(),a=ae();if(n)return{kind:"mcp"};const o=e[0];if(o!=null){const l=o.toolName;return l!=null&&(a==null?void 0:a[l])!=null?{kind:"custom",toolName:l}:{kind:"ask-user"}}return s.length>0?{kind:"approval"}:{kind:"compose"}}function rt({disabled:n=!1}){const e=ae(),{pending:s,respond:a}=X(),o=B(),l=s[0],u=d.useCallback(r=>{if(n||l==null)return;const c=r.trim();c&&a({toolCallId:l.toolCallId,content:c})},[n,l,a]);if(l==null||l.toolName==null)return null;const i=e==null?void 0:e[l.toolName];return i==null?null:t.jsx(i,{args:l.args??{},disabled:o||n,onSubmit:u})}function at({servers:n,onContinue:e,readOnly:s}){const a=b("McpAuthPrompt"),{handleAuthorize:o}=Oe(),{refreshConnectors:l}=le(),[u,i]=d.useState(()=>new Set),r=d.useRef(u),[c,m]=d.useState(!1),p=d.useRef(!1),h=d.useRef(0);d.useEffect(()=>()=>{h.current+=1},[]);const f=()=>{s||p.current||(p.current=!0,m(!0),e().catch(()=>{p.current=!1,m(!1)}))},C=S=>{const x=h.current;o(S,j=>{if(x!==h.current||!j)return;const w=new Set([...r.current,S]);r.current=w,i(w),l(),n.every(I=>w.has(I.id))&&f()})};return t.jsx(a,{servers:n,connectedServerIds:u,continueLoading:c,onConnect:C,onContinue:f,readOnly:s})}function it({disabled:n=!1}){const e=b("McpAuthPrompt"),{pending:s,resume:a}=Ie(),o=B(),l=ie();if(!s)return null;if(l){const i=JSON.stringify(s.mcpServers.map(r=>r.id));return t.jsx(at,{servers:s.mcpServers,onContinue:a,readOnly:o||n},i)}const u=i=>{const r=s.mcpServers.find(c=>c.id===i);r!=null&&r.authUrl&&window.open(r.authUrl,"_blank","noopener,noreferrer")};return t.jsx(e,{servers:s.mcpServers,onConnect:u,onContinue:()=>{n||a()},readOnly:o||n})}function lt(n){var s;const e=n.items;if(e.length>0){const a=[];let o=0;for(const l of Array.from(e)){if(l.kind!=="file")continue;const u=((s=l.webkitGetAsEntry)==null?void 0:s.call(l))??null;if((u==null?void 0:u.isDirectory)===!0){o+=1;continue}const i=l.getAsFile();i!=null&&a.push(i)}return{files:a,rejectedDirectoryCount:o}}return{files:Array.from(n.files),rejectedDirectoryCount:0}}function ct({disabled:n,hasText:e,hasAttachments:s,requiresModel:a,hasModel:o}){return!n&&(e||s)&&(!a||o)}function ee({placeholder:n,connectedToBanner:e=!1}){var L,v;const s=b("ComposerShell"),a=se(),o=D(),l=q(),u=A(g=>g.threadListItem.remoteId),i=A(g=>g.composer.text.trim().length>0),r=A(g=>g.composer.attachments.length),c=r>0,m=i||c,{agentSpec:p}=ce(),h=o==null||o.mode.status==="active"&&o.mode.isMutable,f=!!((v=(L=p==null?void 0:p.model)==null?void 0:L.name)!=null&&v.trim()),{isBusy:C,send:S,resetBusy:x}=Fe(),j=J(),w=Be(),I=oe(),M=d.useRef(null),E=!j,y=ct({disabled:E,hasText:i,hasAttachments:c,requiresModel:h,hasModel:f}),k=(o==null?void 0:o.mode.status)==="active"?{agentId:o.mode.agentId,agentName:o.mode.agentName}:{},R=()=>{var g;y&&(l(T.Message.SENT,z({has_text:i,has_attachments:c,attachment_count:r,requires_model:h,model:(g=p==null?void 0:p.model)==null?void 0:g.name},{sessionId:u,...k})),S(()=>a.composer().send()))},Q=g=>{g.key!=="Enter"||g.shiftKey||g.nativeEvent.isComposing||y&&(g.preventDefault(),R())};return t.jsxs(t.Fragment,{children:[t.jsx("input",{ref:M,type:"file",multiple:!0,hidden:!0,onChange:g=>{const N=g.target.files;if(N){l(T.Attachment.PICKED,z({file_count:N.length},{sessionId:u,...k}));for(const U of N)a.composer().addAttachment(U).catch(K=>{I==null||I.showError(K)})}g.target.value=""}}),t.jsx(P.AttachmentDropzone,{disabled:E,"data-slot":"aui_composer-attachment-dropzone",className:"w-full rounded-[0.75rem] transition-[box-shadow] data-[dragging=true]:ring-focus-ring/20 data-[dragging=true]:ring-3",onDropCapture:g=>{if(E)return;const N=g.dataTransfer;if(N==null)return;const{files:U,rejectedDirectoryCount:K}=lt(N);K>0&&(I==null||I.showError(new Error("Folders cannot be attached. Attach individual files instead."))),U.length!==0&&l(T.Attachment.PICKED,z({file_count:U.length},{sessionId:u,...k}))},children:t.jsx(P.Root,{"data-slot":"aui_composer-root",className:"w-full",onSubmit:g=>{g.preventDefault(),R()},children:t.jsx(s,{className:e?"rounded-t-none border-t-0 focus-within:ring-0":void 0,attachments:t.jsx(Ue,{}),input:t.jsx(P.Input,{"data-slot":"aui_composer-input",placeholder:n,disabled:E,submitMode:"enter",onKeyDown:Q,"aria-label":"Message input",className:"text-text-primary placeholder:text-text-secondary/80 max-h-[10lh] min-h-10 w-full resize-none overflow-y-auto rounded-lg border-none bg-transparent px-1 py-1 text-base leading-normal shadow-none outline-none disabled:cursor-not-allowed"}),disabled:E,canSubmit:y,hasContent:m,isRunning:C,onSubmit:R,onCancel:j?()=>{l(T.Message.CANCELLED,z(void 0,{sessionId:u,...k})),x(),w()}:void 0,onAttach:j?()=>{var g;return(g=M.current)==null?void 0:g.click()}:void 0})})})]})}function V({placeholder:n,connectedToBanner:e=!1}){const s=D(),a=b("ComposerLeftSection"),o=b("ComposerRightSection"),l=$("ComposerLeftSection"),u=$("ComposerRightSection"),i=b("DraftComposerLeftSection"),r=b("DraftComposerRightSection");return(s==null?void 0:s.mode.status)==="active"&&s.mode.isMutable?t.jsx(Ae,{children:t.jsx(Ee,{overrides:{ComposerLeftSection:l?i:a,ComposerRightSection:u?r:o},children:t.jsx(ee,{placeholder:n,connectedToBanner:e})})}):t.jsx(ee,{placeholder:n,connectedToBanner:e})}function ut({placeholder:n="Ask anything... (Shift+Enter for new line)"}){const e=ot(),s=J(),a=e.kind==="mcp"?t.jsx(it,{disabled:!s}):e.kind==="custom"?t.jsx(rt,{disabled:!s}):e.kind==="ask-user"?t.jsx(nt,{disabled:!s}):e.kind==="approval"?t.jsx(tt,{}):null;return a==null?t.jsx(V,{placeholder:n}):e.kind==="approval"?t.jsxs("div",{"data-slot":"aui_composer-pause","data-pause-kind":e.kind,className:"flex w-full flex-col",children:[a,t.jsx(V,{placeholder:n,connectedToBanner:!0})]}):e.kind==="mcp"?t.jsxs("div",{"data-slot":"aui_composer-pause","data-pause-kind":e.kind,className:"relative flex w-full flex-col",children:[t.jsx("div",{className:"pb-2",children:a}),t.jsx("div",{className:"relative z-10 -mt-3",children:t.jsx(V,{placeholder:n})})]}):t.jsxs("div",{"data-slot":"aui_composer-pause","data-pause-kind":e.kind,className:"flex w-full flex-col",children:[a,t.jsx("div",{className:"relative z-10 -mt-1",children:t.jsx(V,{placeholder:n})})]})}var dt=200,te='[data-slot="aui_thread-viewport"]';function mt(){const n=b("HistoryLoader"),{hasOlderHistory:e,isLoadingOlderHistory:s,loadOlderHistory:a}=ve(),[o,l]=d.useState(null),u=d.useRef(!1),i=d.useCallback(async()=>{if(u.current)return;u.current=!0;const r=(o==null?void 0:o.closest(te))??null,c=(r==null?void 0:r.scrollHeight)??0,m=(r==null?void 0:r.scrollTop)??0;try{await a(),requestAnimationFrame(()=>{if(r==null)return;const p=r.scrollHeight-c;p>0&&r.scrollTo({top:m+p,behavior:"instant"})})}catch{}finally{u.current=!1}},[o,a]);return d.useEffect(()=>{if(o==null||!e)return;const r=o.closest(te),c=new IntersectionObserver(m=>{m.some(p=>p.isIntersecting)&&i()},{root:r,rootMargin:`${dt}px 0px 0px 0px`});return c.observe(o),()=>c.disconnect()},[o,e,i]),e?t.jsx(n,{ref:l,isLoading:s}):null}function ft(){const n=b("ResumeUnavailable");return Se()?t.jsx(n,{}):null}function gt(){return A(e=>{var s;return(((s=e.message.attachments)==null?void 0:s.length)??0)>0})?t.jsx("div",{className:"pointer-events-none mb-2 opacity-90",children:t.jsx(He,{})}):null}function pt(){const n=b("UserMessageEdit"),e=b("MessageTimestamp"),s=B(),a=J(),o=A(r=>r.message.createdAt),{cancel:l,disabled:u}=Me(),{disabled:i}=Ne();return t.jsx(Re.Root,{"data-role":"user",children:t.jsx(P.Root,{"data-slot":"aui_user-edit-composer-root",className:"fade-in slide-in-from-bottom-1 animate-in flex w-full justify-end px-2 duration-150",children:t.jsx(n,{timestamp:t.jsx(e,{createdAt:o}),attachments:t.jsx(gt,{}),input:t.jsx("div",{className:"mt-1 rounded border border-border bg-secondary-bg p-2 text-text-primary",children:t.jsx(P.Input,{"data-slot":"aui_user-edit-input",disabled:s||!a,submitMode:"enter","aria-label":"Edit message",className:"max-h-32 min-h-10 w-full resize-none border-none bg-transparent p-0 text-base leading-[1.34] outline-none focus:shadow-none"})}),footer:t.jsxs("div",{className:"flex items-center justify-end gap-2",children:[t.jsx(Z.Secondary,{type:"button",disabled:u,onClick:l,children:"Cancel"}),t.jsx(P.Send,{asChild:!0,children:t.jsx(Z.Primary,{type:"submit",disabled:i||s||!a,children:"Save & Rerun"})})]})})})})}function ht(){const n=ne(),e=se(),s=A(i=>i.threadListItem.remoteId),a=A(i=>i.threadListItem.title),o=B(),l=d.useRef(!1),u=d.useRef(void 0);d.useEffect(()=>{u.current=void 0},[s]),d.useEffect(()=>{const i=l.current&&!o;if(l.current=o,!i||n==null||s==null||u.current===s)return;if(a!=null&&a.trim()!==""){u.current=s;return}let r=!1;return n.getSession({sessionId:s}).then(c=>{if(r)return;const m=typeof c.title=="string"?c.title.trim():"";if(m.length!==0)return u.current=s,e.threadListItem().rename(m)}).catch(()=>{}),()=>{r=!0}},[e,o,s,n,a])}var de="trueforge.file-preview-width";function xt(){try{const n=sessionStorage.getItem(de);if(n==null)return null;const e=Number(n);return Number.isFinite(e)?e:null}catch{return null}}function vt(n){try{sessionStorage.setItem(de,String(Math.round(n)))}catch{}}function bt(){const n=je(),e=b("FilePreviewPanel"),s=we(),a=ye(),o=oe(),[l,u]=d.useState(0),[i,r]=d.useState(!1),[c,m]=d.useState(xt),p=ke(n.target,l),h=n.target,f=n.presentation==="full"?"full":s||a?"overlay":"side";if(d.useLayoutEffect(()=>{var w;if(h==null||f!=="side")return;const x=((w=document.querySelector('[data-slot="aui_file-preview-row"]'))==null?void 0:w.getBoundingClientRect().width)??0;if(x<=0)return;const j=c==null?Te(x):Pe({requested:c,rowWidth:x});(c==null||Math.abs(j-c)>1)&&m(j)},[f,h,c]),h==null)return null;const C=p.view.status==="error",S=()=>{i||(r(!0),(async()=>{try{const x=p.blob??await h.load();De(x,Le(h.path))}catch(x){o!=null?o.showError(x):console.error("Failed to download sandbox file",x)}finally{r(!1)}})())};return t.jsx(e,{name:h.name,placement:f,view:p.view,onClose:n.close,onDownload:S,onEnterFullPage:()=>n.setPresentation("full"),onExitFullPage:()=>n.setPresentation("panel"),downloadBusy:i,...f==="side"&&c!=null?{widthPx:c}:{},...f==="side"?{onWidthChange:x=>{m(x),vt(x)}}:{},...C?{onRetry:()=>u(x=>x+1)}:{}})}function Ct({children:n}){return t.jsx("div",{className:"animate-in fade-in slide-in-from-bottom-1 fill-mode-both duration-200",children:n})}function St({isEditing:n}){return A(s=>s.message.role)==="user"?n?t.jsx(pt,{}):t.jsx(be,{}):t.jsx(Ce,{})}function jt({composer:n}){d.useEffect(()=>{fe()},[]),ht();const e=D(),s=b("WelcomeScreen"),a=b("MessageListSkeleton"),o=b("ScrollToBottomButton"),l=b("MessageGroup"),u=b("ThreadComposerAreaShell"),i=b("ThreadRootShell"),r=b("ThreadViewportShell"),c=A(ge),m=A(h=>h.thread.isLoading),p=(e==null?void 0:e.mode.status)==="active"?e.mode.agentName!=null&&e.mode.agentName.length>0?e.mode.agentName:e.mode.isMutable&&e.mode.isCreateAgent?"Start building a new Agent":void 0:void 0;return t.jsx(pe,{children:t.jsx(he,{children:t.jsx(xe,{children:t.jsx(H.Root,{asChild:!0,children:t.jsx(i,{children:t.jsxs("div",{"data-slot":"aui_file-preview-row",className:"relative flex min-h-0 w-full min-w-0 flex-1",children:[t.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[t.jsx(H.Viewport,{asChild:!0,autoScroll:!0,children:t.jsxs(r,{isEmpty:c,children:[c&&t.jsx(s,{heading:p}),c&&!m&&n,m?t.jsx(a,{}):!c&&t.jsxs(t.Fragment,{children:[t.jsx(mt,{}),t.jsxs(l,{children:[t.jsx(H.Messages,{children:({message:h})=>t.jsx(Ct,{children:t.jsx(St,{isEditing:h.role==="user"&&h.composer.isEditing})})}),t.jsx(ft,{})]})]})]})}),!m&&!c&&t.jsxs(u,{isEmpty:c,children:[t.jsx(H.ScrollToBottom,{asChild:!0,children:t.jsx(o,{})}),n]})]}),t.jsx(bt,{})]})})})})})})}function yt(){const n=D();return(n==null?void 0:n.sessionAccessError)!=null?t.jsx(me,{title:"Unable to load session",description:n.sessionAccessError,className:"bg-primary-bg"}):t.jsx(jt,{composer:t.jsx(ut,{})})}function kt({className:n}){var r;const e=D(),s=q(),a=Xe(),o=A(c=>c.threadListItem.title);if(a===null)return null;const l=(o==null?void 0:o.trim())??"",u=a.allowThreadTitle&&l.length>0?l:a.name,i=(e==null?void 0:e.isLibraryEnabled)===!0&&((r=e.historyAgentFilter)==null?void 0:r.intent)==="try-agent";return t.jsxs("h1",{className:_("flex min-w-0 items-center gap-1.5",Ze,n),children:[i?t.jsx("button",{type:"button","aria-label":"Back to all agents",title:"Back to all agents",className:W({variant:"ghost",size:"icon",className:"text-text-secondary"}),onClick:()=>{s(T.Library.OPENED),e==null||e.setLibraryOpen(!0)},children:t.jsx(F,{name:"arrow-left"})}):null,t.jsx("span",{className:"truncate",title:u,children:u}),a.isEditing?t.jsx($e,{content:"Try changes here, then choose Update agent to save.",side:"bottom",children:t.jsxs("span",{className:"border-warning-bg/40 bg-warning-bg/10 text-warning-bg inline-flex shrink-0 items-center gap-1 rounded-full border px-2 py-0.5 text-xs font-medium",children:[t.jsx(F,{name:"pencil",className:"size-3"}),"Editing"]})}):null]})}function It({className:n,labeled:e=!1,onAction:s}){const a=D(),o=q(),l=ie(),u=ue(),{mode:i,setTheme:r}=Ye(),c=b("ShellActionsActionSlot"),m=i==="dark",p=m?"Light":"Dark",h=Je({catalog:l,capabilities:u}),f="hover:bg-secondary-button-hover hover:text-ghost-button-text";return t.jsxs("div",{className:_("flex shrink-0 items-center gap-1",e?"w-full flex-col items-center gap-1 text-sidebar-text":"text-text-primary",n),children:[t.jsxs("a",{href:"https://trueforge.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"Documentation",title:"Documentation",className:W({variant:"ghost",size:e?void 0:"icon",className:_(f,e&&Y)}),onClick:()=>s==null?void 0:s(),children:[t.jsx(F,{name:"book-open",size:e?14:void 0}),e?t.jsx("span",{className:"text-center",children:"Docs"}):null]}),t.jsxs("button",{type:"button","aria-label":m?"Switch to light theme":"Switch to dark theme",title:m?"Light theme":"Dark theme",className:W({variant:"ghost",size:e?void 0:"icon",className:_(f,e&&Y)}),onClick:()=>{r(m?"light":"dark"),s==null||s()},children:[t.jsx(F,{name:m?"sun":"moon",size:e?14:void 0}),e?t.jsx("span",{className:"text-center",children:p}):null]}),a!=null&&h?t.jsxs("button",{type:"button","aria-label":"Settings",title:"Settings","aria-expanded":a.settingsOpen,"aria-current":a.settingsOpen?"page":void 0,className:W({variant:"ghost",size:e?void 0:"icon",className:_(f,e&&Y,a.settingsOpen&&"bg-primary-button-bg font-medium text-primary-button-text hover:bg-primary-button-hover hover:text-primary-button-text")}),onClick:()=>{a.settingsOpen||o(T.Settings.OPENED),a.setSettingsOpen(!0),s==null||s()},children:[t.jsx(F,{name:"settings",size:e?14:void 0}),e?t.jsx("span",{className:"text-center",children:"Settings"}):null]}):null,t.jsx(c,{})]})}function At({showClose:n=!1}){var L;const{agentSpec:e}=ce(),s=ze(),a=Ve(),o=We(),l=o.mode.status==="active"?o.mode.agentId:void 0,{allows:u}=qe({resourceType:"agent",resourceIds:l==null?[]:[l]}),i=u(l,"MANAGE"),r=ne(),c=ue(),m=le(),p=b("AgentConfigPanel"),h=b("AgentConfigEditors"),[f,C]=d.useState(null),S=Qe(o.mode),{draft:x,flush:j}=Ke(),w=d.useCallback(()=>{j(),a(),o.setAgentConfigOpen(!1)},[a,j,o]);d.useEffect(()=>{S&&m.ensureLoaded()},[m,S]),d.useEffect(()=>{i||C(null)},[i]),d.useEffect(()=>{if(!n||!o.agentConfigOpen)return;const v=g=>{!g.defaultPrevented&&g.key==="Escape"&&f===null&&document.querySelector("dialog[open]")===null&&w()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[w,f,o.agentConfigOpen,n]);const I=d.useRef({flushAgentSpec:a,flushInstructions:j});I.current={flushAgentSpec:a,flushInstructions:j},d.useEffect(()=>()=>{const{flushAgentSpec:v,flushInstructions:g}=I.current;g();try{v()}catch{}},[]);const M=d.useCallback(({next:v,instructions:g})=>{var N;if(i){if(v.skills&&v.skills.length>0&&(c==null?void 0:c.sandbox.enabled)===!0){s==null||s({...v,instructions:g||void 0,config:{...v.config,sandbox:{...(N=v.config)==null?void 0:N.sandbox,enabled:!0}}});return}s==null||s({...v,instructions:g||void 0})}},[i,c==null?void 0:c.sandbox.enabled,s]),E=d.useCallback(v=>{M({next:v,instructions:x})},[M,x]),y=d.useCallback(v=>{e!==null&&M({next:Ge({spec:e,messages:v.messages}),instructions:v.instructions})},[e,M]),k=d.useCallback(async v=>(r==null?void 0:r.getMcpTools)===void 0?[]:r.getMcpTools({connectorId:v}),[r]),R=d.useCallback(async v=>{var g;return(g=r==null?void 0:r.getMcpConnector)==null?void 0:g.call(r,{connectorId:v})},[r]);if(!S||e===null||n&&!o.agentConfigOpen)return null;const Q=m.models.find(v=>v.name===e.model.name);return t.jsxs(t.Fragment,{children:[t.jsx(p,{spec:e,model:Q,models:m.models,modelsLoading:m.loading,modelsError:m.error,skills:m.skills,skillsAvailable:(c==null?void 0:c.skill.enabled)===!0,webSearchAvailable:((L=c==null?void 0:c.webSearch)==null?void 0:L.enabled)===!0,instructions:x,onOpenEditor:v=>{i&&C(v)},onChange:E,disabled:!i,onClose:n?w:void 0}),t.jsx(h,{editor:f,spec:e,models:m.models,connectors:m.connectors,skills:m.skills,loading:m.loading,error:m.error,skillsDisabled:(c==null?void 0:c.skill.enabled)!==!0,sandboxAvailable:(c==null?void 0:c.sandbox.enabled)===!0,instructions:x,onInstructionsSave:y,...(r==null?void 0:r.getMcpConnector)===void 0?{}:{loadMcpConnector:R},loadMcpTools:k,onRefreshConnectors:m.refreshConnectors,onChange:E,onClose:()=>C(null)})]})}export{At as A,kt as N,It as S,yt as T};
1
+ import{t as D,j as t,G as me,r as d,bF as fe,u as b,bG as A,bH as ge,bI as he,bJ as pe,bK as xe,bL as H,bM as J,d as ne,b0 as se,bN as B,bO as ve,bP as be,bQ as Ce,bR as Se,bS as je,bn as we,b1 as ye,p as oe,bT as ke,bU as X,bV as re,bW as ae,bX as Ie,ab as ie,q,bY as G,_ as T,bZ as $,a4 as Ae,b_ as Ee,b$ as Me,c0 as Ne,c1 as Re,c2 as P,E as Z,c3 as Te,c4 as Pe,c5 as De,c6 as Le,bw as Oe,a9 as le,c7 as _e,c8 as ce,c9 as Fe,ca as Be,bE as z,cb as Ue,cc as He,cd as ze,ce as Ve,b9 as We,w as qe,b as ue,b3 as Qe,cf as Ke,cg as Ge,ch as Ye,ci as Je,I as F,a3 as W,c as _,cj as Y,ck as Xe,k as $e,cl as Ze}from"./index-J4S6NjFF.js";function et(){var p;const{pending:n}=re(),e=_e(),[s,a]=d.useState({approvalId:null,index:0}),o=d.useRef(null),c=n.length,u=s.approvalId==null?-1:n.findIndex(f=>f.approvalId===s.approvalId),i=u>=0?u:c===0?0:Math.min(s.index,c-1),r=(p=n[i])==null?void 0:p.approvalId;d.useEffect(()=>{const f=r??null;s.approvalId===f&&s.index===i||a({approvalId:f,index:i})},[r,i,s.approvalId,s.index]),d.useEffect(()=>{if(r==null||e==null){r==null&&(o.current=null);return}o.current!==r&&(o.current=r,e.focus(r))},[r,e]);const l=d.useCallback(()=>{var C;const f=Math.max(0,i-1);a({approvalId:((C=n[f])==null?void 0:C.approvalId)??null,index:f})},[n,i]),m=d.useCallback(()=>{var C;const f=Math.min(Math.max(c-1,0),i+1);a({approvalId:((C=n[f])==null?void 0:C.approvalId)??null,index:f})},[c,n,i]),h=d.useCallback(()=>{r==null||e==null||e.focus(r)},[r,e]);return{count:c,index:i,canPrev:i>0,canNext:i<c-1,goPrev:l,goNext:m,focusCurrent:h}}function tt(){const n=b("ApprovalNavBanner"),{count:e,index:s,canPrev:a,canNext:o,goPrev:c,goNext:u,focusCurrent:i}=et();return e===0?null:t.jsx(n,{total:e,current:s+1,canPrev:a,canNext:o,onPrev:c,onNext:u,onFocusCurrent:i})}var O={radioValue:"",custom:""};function nt({disabled:n=!1}){const e=b("AskUserPrompt"),{pending:s,respond:a}=X(),o=q(),c=B(),u=s[0],i=d.useMemo(()=>u==null?[]:[{id:u.toolCallId,question:u.question??"Answer required",options:u.options??[]}],[u]),[r,l]=d.useState(0),[m,h]=d.useState({});d.useEffect(()=>{l(0),h({})},[u==null?void 0:u.toolCallId]);const p=Math.min(r,Math.max(i.length-1,0)),f=i[p],C=f==null?O:m[f.id]??O,S=d.useCallback(y=>{const k=m[y]??O;return k.radioValue===G?k.custom.trim():k.radioValue.trim()},[m]),x=d.useMemo(()=>i.every(y=>S(y.id)),[S,i]),j=C.radioValue===G?C.custom.trim():C.radioValue.trim(),w=c||n||f==null||j.length===0,I=w||!x,M=d.useCallback((y,k)=>{h(R=>({...R,[y]:{...R[y]??O,...k}}))},[]),E=d.useCallback(()=>{if(n||u==null||!x)return;const y=S(u.toolCallId);if(!y)return;const k=m[u.toolCallId]??O;o(T.AskUser.SUBMITTED,{tool_call_id:u.toolCallId,question_count:i.length,is_custom_option:k.radioValue===G}),a({toolCallId:u.toolCallId,content:y})},[x,m,n,S,u,i.length,a,o]);return u==null||f==null?null:t.jsx(e,{questions:i,readOnly:c||n,currentQuestion:f,currentQuestionIndex:p,currentAnswer:C,totalQuestions:i.length,isMultiQuestion:i.length>1,isLastQuestion:p===i.length-1,allQuestionsAnswered:x,isSubmitDisabled:w,isSubmitAllDisabled:I,onCurrentQuestionIndexChange:l,onCurrentAnswerChange:M,onSubmit:E})}function st(n){var a,o,c;const e=n.thread.messages,s=e[e.length-1];return(s==null?void 0:s.role)!=="assistant"||((a=s.status)==null?void 0:a.type)!=="requires-action"?!1:((c=(o=s.metadata)==null?void 0:o.custom)==null?void 0:c.pendingMcpAuth)===!0}function ot(){const n=A(st),{pending:e}=X(),{pending:s}=re(),a=ae();if(n)return{kind:"mcp"};const o=e[0];if(o!=null){const c=o.toolName;return c!=null&&(a==null?void 0:a[c])!=null?{kind:"custom",toolName:c}:{kind:"ask-user"}}return s.length>0?{kind:"approval"}:{kind:"compose"}}function rt({disabled:n=!1}){const e=ae(),{pending:s,respond:a}=X(),o=B(),c=s[0],u=d.useCallback(r=>{if(n||c==null)return;const l=r.trim();l&&a({toolCallId:c.toolCallId,content:l})},[n,c,a]);if(c==null||c.toolName==null)return null;const i=e==null?void 0:e[c.toolName];return i==null?null:t.jsx(i,{args:c.args??{},disabled:o||n,onSubmit:u})}function at({servers:n,onContinue:e,readOnly:s}){const a=b("McpAuthPrompt"),{handleAuthorize:o}=Oe(),{refreshConnectors:c}=le(),[u,i]=d.useState(()=>new Set),r=d.useRef(u),[l,m]=d.useState(!1),h=d.useRef(!1),p=d.useRef(0);d.useEffect(()=>()=>{p.current+=1},[]);const f=()=>{s||h.current||(h.current=!0,m(!0),e().catch(()=>{h.current=!1,m(!1)}))},C=S=>{const x=p.current;o(S,j=>{if(x!==p.current||!j)return;const w=new Set([...r.current,S]);r.current=w,i(w),c(),n.every(I=>w.has(I.id))&&f()})};return t.jsx(a,{servers:n,connectedServerIds:u,continueLoading:l,onConnect:C,onContinue:f,readOnly:s})}function it({disabled:n=!1}){const e=b("McpAuthPrompt"),{pending:s,resume:a}=Ie(),o=B(),c=ie();if(!s)return null;if(c){const i=JSON.stringify(s.mcpServers.map(r=>r.id));return t.jsx(at,{servers:s.mcpServers,onContinue:a,readOnly:o||n},i)}const u=i=>{const r=s.mcpServers.find(l=>l.id===i);r!=null&&r.authUrl&&window.open(r.authUrl,"_blank","noopener,noreferrer")};return t.jsx(e,{servers:s.mcpServers,onConnect:u,onContinue:()=>{n||a()},readOnly:o||n})}function lt(n){var s;const e=n.items;if(e.length>0){const a=[];let o=0;for(const c of Array.from(e)){if(c.kind!=="file")continue;const u=((s=c.webkitGetAsEntry)==null?void 0:s.call(c))??null;if((u==null?void 0:u.isDirectory)===!0){o+=1;continue}const i=c.getAsFile();i!=null&&a.push(i)}return{files:a,rejectedDirectoryCount:o}}return{files:Array.from(n.files),rejectedDirectoryCount:0}}function ct({disabled:n,hasText:e,hasAttachments:s,requiresModel:a,hasModel:o}){return!n&&(e||s)&&(!a||o)}function ee({placeholder:n,connectedToBanner:e=!1}){var L,v;const s=b("ComposerShell"),a=se(),o=D(),c=q(),u=A(g=>g.threadListItem.remoteId),i=A(g=>g.composer.text.trim().length>0),r=A(g=>g.composer.attachments.length),l=r>0,m=i||l,{agentSpec:h}=ce(),p=o==null||o.mode.status==="active"&&o.mode.isMutable,f=!!((v=(L=h==null?void 0:h.model)==null?void 0:L.name)!=null&&v.trim()),{isBusy:C,send:S,resetBusy:x}=Fe(),j=J(),w=Be(),I=oe(),M=d.useRef(null),E=!j,y=ct({disabled:E,hasText:i,hasAttachments:l,requiresModel:p,hasModel:f}),k=(o==null?void 0:o.mode.status)==="active"?{agentId:o.mode.agentId,agentName:o.mode.agentName}:{},R=()=>{var g;y&&(c(T.Message.SENT,z({has_text:i,has_attachments:l,attachment_count:r,requires_model:p,model:(g=h==null?void 0:h.model)==null?void 0:g.name},{sessionId:u,...k})),S(()=>a.composer().send()))},Q=g=>{g.key!=="Enter"||g.shiftKey||g.nativeEvent.isComposing||y&&(g.preventDefault(),R())};return t.jsxs(t.Fragment,{children:[t.jsx("input",{ref:M,type:"file",multiple:!0,hidden:!0,onChange:g=>{const N=g.target.files;if(N){c(T.Attachment.PICKED,z({file_count:N.length},{sessionId:u,...k}));for(const U of N)a.composer().addAttachment(U).catch(K=>{I==null||I.showError(K)})}g.target.value=""}}),t.jsx(P.AttachmentDropzone,{disabled:E,"data-slot":"aui_composer-attachment-dropzone",className:"w-full rounded-[0.75rem] transition-[box-shadow] data-[dragging=true]:ring-focus-ring/20 data-[dragging=true]:ring-3",onDropCapture:g=>{if(E)return;const N=g.dataTransfer;if(N==null)return;const{files:U,rejectedDirectoryCount:K}=lt(N);K>0&&(I==null||I.showError(new Error("Folders cannot be attached. Attach individual files instead."))),U.length!==0&&c(T.Attachment.PICKED,z({file_count:U.length},{sessionId:u,...k}))},children:t.jsx(P.Root,{"data-slot":"aui_composer-root",className:"w-full",onSubmit:g=>{g.preventDefault(),R()},children:t.jsx(s,{className:e?"rounded-t-none border-t-0 focus-within:ring-0":void 0,attachments:t.jsx(Ue,{}),input:t.jsx(P.Input,{"data-slot":"aui_composer-input",placeholder:n,disabled:E,submitMode:"enter",onKeyDown:Q,"aria-label":"Message input",className:"text-text-primary placeholder:text-text-secondary/80 max-h-[10lh] min-h-10 w-full resize-none overflow-y-auto rounded-lg border-none bg-transparent px-1 py-1 text-base leading-normal shadow-none outline-none disabled:cursor-not-allowed"}),disabled:E,canSubmit:y,hasContent:m,isRunning:C,onSubmit:R,onCancel:j?()=>{c(T.Message.CANCELLED,z(void 0,{sessionId:u,...k})),x(),w()}:void 0,onAttach:j?()=>{var g;return(g=M.current)==null?void 0:g.click()}:void 0})})})]})}function V({placeholder:n,connectedToBanner:e=!1}){const s=D(),a=b("ComposerLeftSection"),o=b("ComposerRightSection"),c=$("ComposerLeftSection"),u=$("ComposerRightSection"),i=b("DraftComposerLeftSection"),r=b("DraftComposerRightSection");return(s==null?void 0:s.mode.status)==="active"&&s.mode.isMutable?t.jsx(Ae,{children:t.jsx(Ee,{overrides:{ComposerLeftSection:c?i:a,ComposerRightSection:u?r:o},children:t.jsx(ee,{placeholder:n,connectedToBanner:e})})}):t.jsx(ee,{placeholder:n,connectedToBanner:e})}function ut({placeholder:n="Ask anything... (Shift+Enter for new line)"}){const e=ot(),s=J(),a=e.kind==="mcp"?t.jsx(it,{disabled:!s}):e.kind==="custom"?t.jsx(rt,{disabled:!s}):e.kind==="ask-user"?t.jsx(nt,{disabled:!s}):e.kind==="approval"?t.jsx(tt,{}):null;return a==null?t.jsx(V,{placeholder:n}):e.kind==="approval"?t.jsxs("div",{"data-slot":"aui_composer-pause","data-pause-kind":e.kind,className:"flex w-full flex-col",children:[a,t.jsx(V,{placeholder:n,connectedToBanner:!0})]}):e.kind==="mcp"?t.jsxs("div",{"data-slot":"aui_composer-pause","data-pause-kind":e.kind,className:"relative flex w-full flex-col",children:[t.jsx("div",{className:"pb-2",children:a}),t.jsx("div",{className:"relative z-10 -mt-3",children:t.jsx(V,{placeholder:n})})]}):t.jsxs("div",{"data-slot":"aui_composer-pause","data-pause-kind":e.kind,className:"flex w-full flex-col",children:[a,t.jsx("div",{className:"relative z-10 -mt-1",children:t.jsx(V,{placeholder:n})})]})}var dt=200,te='[data-slot="aui_thread-viewport"]';function mt(){const n=b("HistoryLoader"),{hasOlderHistory:e,isLoadingOlderHistory:s,loadOlderHistory:a}=ve(),[o,c]=d.useState(null),u=d.useRef(!1),i=d.useCallback(async()=>{if(u.current)return;u.current=!0;const r=(o==null?void 0:o.closest(te))??null,l=(r==null?void 0:r.scrollHeight)??0,m=(r==null?void 0:r.scrollTop)??0;try{await a(),requestAnimationFrame(()=>{if(r==null)return;const h=r.scrollHeight-l;h>0&&r.scrollTo({top:m+h,behavior:"instant"})})}catch{}finally{u.current=!1}},[o,a]);return d.useEffect(()=>{if(o==null||!e)return;const r=o.closest(te),l=new IntersectionObserver(m=>{m.some(h=>h.isIntersecting)&&i()},{root:r,rootMargin:`${dt}px 0px 0px 0px`});return l.observe(o),()=>l.disconnect()},[o,e,i]),e?t.jsx(n,{ref:c,isLoading:s}):null}function ft(){const n=b("ResumeUnavailable");return Se()?t.jsx(n,{}):null}function gt(){return A(e=>{var s;return(((s=e.message.attachments)==null?void 0:s.length)??0)>0})?t.jsx("div",{className:"pointer-events-none mb-2 opacity-90",children:t.jsx(He,{})}):null}function ht(){const n=b("UserMessageEdit"),e=b("MessageTimestamp"),s=B(),a=J(),o=A(r=>r.message.createdAt),{cancel:c,disabled:u}=Me(),{disabled:i}=Ne();return t.jsx(Re.Root,{"data-role":"user",children:t.jsx(P.Root,{"data-slot":"aui_user-edit-composer-root",className:"fade-in slide-in-from-bottom-1 animate-in flex w-full justify-end px-2 duration-150",children:t.jsx(n,{timestamp:t.jsx(e,{createdAt:o}),attachments:t.jsx(gt,{}),input:t.jsx("div",{className:"mt-1 rounded border border-border bg-secondary-bg p-2 text-text-primary",children:t.jsx(P.Input,{"data-slot":"aui_user-edit-input",disabled:s||!a,submitMode:"enter","aria-label":"Edit message",className:"max-h-32 min-h-10 w-full resize-none border-none bg-transparent p-0 text-base leading-[1.34] outline-none focus:shadow-none"})}),footer:t.jsxs("div",{className:"flex items-center justify-end gap-2",children:[t.jsx(Z.Secondary,{type:"button",disabled:u,onClick:c,children:"Cancel"}),t.jsx(P.Send,{asChild:!0,children:t.jsx(Z.Primary,{type:"submit",disabled:i||s||!a,children:"Save & Rerun"})})]})})})})}function pt(){const n=ne(),e=se(),s=A(i=>i.threadListItem.remoteId),a=A(i=>i.threadListItem.title),o=B(),c=d.useRef(!1),u=d.useRef(void 0);d.useEffect(()=>{u.current=void 0},[s]),d.useEffect(()=>{const i=c.current&&!o;if(c.current=o,!i||n==null||s==null||u.current===s)return;if(a!=null&&a.trim()!==""){u.current=s;return}let r=!1;return n.getSession({sessionId:s}).then(l=>{if(r)return;const m=typeof l.title=="string"?l.title.trim():"";if(m.length!==0)return u.current=s,e.threadListItem().rename(m)}).catch(()=>{}),()=>{r=!0}},[e,o,s,n,a])}var de="trueforge.file-preview-width";function xt(){try{const n=sessionStorage.getItem(de);if(n==null)return null;const e=Number(n);return Number.isFinite(e)?e:null}catch{return null}}function vt(n){try{sessionStorage.setItem(de,String(Math.round(n)))}catch{}}function bt(){const n=je(),e=b("FilePreviewPanel"),s=we(),a=ye(),o=oe(),[c,u]=d.useState(0),[i,r]=d.useState(!1),[l,m]=d.useState(xt),h=ke(n.target,c),p=n.target,f=n.presentation==="full"?"full":s||a?"overlay":"side";if(d.useLayoutEffect(()=>{var w;if(p==null||f!=="side")return;const x=((w=document.querySelector('[data-slot="aui_file-preview-row"]'))==null?void 0:w.getBoundingClientRect().width)??0;if(x<=0)return;const j=l==null?Te(x):Pe({requested:l,rowWidth:x});(l==null||Math.abs(j-l)>1)&&m(j)},[f,p,l]),p==null)return null;const C=h.view.status==="error",S=()=>{i||(r(!0),(async()=>{try{const x=h.blob??await p.load();De(x,Le(p.path))}catch(x){o!=null?o.showError(x):console.error("Failed to download sandbox file",x)}finally{r(!1)}})())};return t.jsx(e,{name:p.name,placement:f,view:h.view,onClose:n.close,onDownload:S,onEnterFullPage:()=>n.setPresentation("full"),onExitFullPage:()=>n.setPresentation("panel"),downloadBusy:i,...f==="side"&&l!=null?{widthPx:l}:{},...f==="side"?{onWidthChange:x=>{m(x),vt(x)}}:{},...C?{onRetry:()=>u(x=>x+1)}:{}})}function Ct({children:n}){return t.jsx("div",{className:"animate-in fade-in slide-in-from-bottom-1 fill-mode-both duration-200",children:n})}function St({isEditing:n}){return A(s=>s.message.role)==="user"?n?t.jsx(ht,{}):t.jsx(be,{}):t.jsx(Ce,{})}function jt({composer:n}){d.useEffect(()=>{fe()},[]),pt();const e=D(),s=b("WelcomeScreen"),a=b("MessageListSkeleton"),o=b("ScrollToBottomButton"),c=b("MessageGroup"),u=b("ThreadComposerAreaShell"),i=b("ThreadRootShell"),r=b("ThreadViewportShell"),l=A(ge),m=A(p=>p.thread.isLoading),h=(e==null?void 0:e.mode.status)==="active"?e.mode.agentName!=null&&e.mode.agentName.length>0?e.mode.agentName:e.mode.isMutable&&e.mode.isCreateAgent?"Start building a new Agent":void 0:void 0;return t.jsx(he,{children:t.jsx(pe,{children:t.jsx(xe,{children:t.jsx(H.Root,{asChild:!0,children:t.jsx(i,{children:t.jsxs("div",{"data-slot":"aui_file-preview-row",className:"relative flex min-h-0 w-full min-w-0 flex-1",children:[t.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[t.jsx(H.Viewport,{asChild:!0,autoScroll:!0,children:t.jsxs(r,{isEmpty:l,children:[l&&t.jsx(s,{heading:h}),l&&!m&&n,m?t.jsx(a,{}):!l&&t.jsxs(t.Fragment,{children:[t.jsx(mt,{}),t.jsxs(c,{children:[t.jsx(H.Messages,{children:({message:p})=>t.jsx(Ct,{children:t.jsx(St,{isEditing:p.role==="user"&&p.composer.isEditing})})}),t.jsx(ft,{})]})]})]})}),!m&&!l&&t.jsxs(u,{isEmpty:l,children:[t.jsx(H.ScrollToBottom,{asChild:!0,children:t.jsx(o,{})}),n]})]}),t.jsx(bt,{})]})})})})})})}function yt(){const n=D();return(n==null?void 0:n.sessionAccessError)!=null?t.jsx(me,{title:"Unable to load session",description:n.sessionAccessError,className:"bg-primary-bg"}):t.jsx(jt,{composer:t.jsx(ut,{})})}function kt({className:n}){var r;const e=D(),s=q(),a=Xe(),o=A(l=>l.threadListItem.title);if(a===null)return null;const c=(o==null?void 0:o.trim())??"",u=a.allowThreadTitle&&c.length>0?c:a.name,i=(e==null?void 0:e.isLibraryEnabled)===!0&&((r=e.historyAgentFilter)==null?void 0:r.intent)==="try-agent";return t.jsxs("h1",{className:_("flex min-w-0 items-center gap-1.5",Ze,n),children:[i?t.jsx("button",{type:"button","aria-label":"Back to all agents",title:"Back to all agents",className:W({variant:"ghost",size:"icon",className:"text-text-secondary"}),onClick:()=>{s(T.Library.OPENED),e==null||e.setLibraryOpen(!0)},children:t.jsx(F,{name:"arrow-left"})}):null,t.jsx("span",{className:"truncate",title:u,children:u}),a.isEditing?t.jsx($e,{content:"Try changes here, then choose Update agent to save.",side:"bottom",children:t.jsxs("span",{className:"border-warning-bg/40 bg-warning-bg/10 text-warning-bg inline-flex shrink-0 items-center gap-1 rounded-full border px-2 py-0.5 text-xs font-medium",children:[t.jsx(F,{name:"pencil",className:"size-3"}),"Editing"]})}):null]})}function It({className:n,labeled:e=!1,onAction:s}){const a=D(),o=q(),c=ie(),u=ue(),{mode:i,setTheme:r}=Ye(),l=b("ShellActionsActionSlot"),m=i==="dark",h=m?"Light":"Dark",p=Je({catalog:c,capabilities:u}),f="hover:bg-secondary-button-hover hover:text-ghost-button-text";return t.jsxs("div",{className:_("flex shrink-0 items-center gap-1",e?"w-full flex-col items-center gap-1 text-sidebar-text":"text-text-primary",n),children:[t.jsxs("a",{href:"https://trueforge.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"Documentation",title:"Documentation",className:W({variant:"ghost",size:e?void 0:"icon",className:_(f,e&&Y)}),onClick:()=>s==null?void 0:s(),children:[t.jsx(F,{name:"book-open",size:e?14:void 0}),e?t.jsx("span",{className:"text-center",children:"Docs"}):null]}),t.jsxs("button",{type:"button","aria-label":m?"Switch to light theme":"Switch to dark theme",title:m?"Light theme":"Dark theme",className:W({variant:"ghost",size:e?void 0:"icon",className:_(f,e&&Y)}),onClick:()=>{r(m?"light":"dark"),s==null||s()},children:[t.jsx(F,{name:m?"sun":"moon",size:e?14:void 0}),e?t.jsx("span",{className:"text-center",children:h}):null]}),a!=null&&p?t.jsxs("button",{type:"button","aria-label":"Settings",title:"Settings","aria-expanded":a.settingsOpen,"aria-current":a.settingsOpen?"page":void 0,className:W({variant:"ghost",size:e?void 0:"icon",className:_(f,e&&Y,a.settingsOpen&&"bg-primary-button-bg font-medium text-primary-button-text hover:bg-primary-button-hover hover:text-primary-button-text")}),onClick:()=>{a.settingsOpen||o(T.Settings.OPENED),a.setSettingsOpen(!0),s==null||s()},children:[t.jsx(F,{name:"settings",size:e?14:void 0}),e?t.jsx("span",{className:"text-center",children:"Settings"}):null]}):null,t.jsx(l,{})]})}function At({showClose:n=!1}){var L;const{agentSpec:e}=ce(),s=ze(),a=Ve(),o=We(),c=o.mode.status==="active"?o.mode.agentId:void 0,{allows:u}=qe({resourceType:"agent",resourceIds:c==null?[]:[c]}),i=u(c,"MANAGE"),r=ne(),l=ue(),m=le(),h=b("AgentConfigPanel"),p=b("AgentConfigEditors"),[f,C]=d.useState(null),S=Qe(o.mode),{draft:x,flush:j}=Ke(),w=d.useCallback(()=>{j(),a(),o.setAgentConfigOpen(!1)},[a,j,o]);d.useEffect(()=>{S&&m.ensureLoaded()},[m,S]),d.useEffect(()=>{i||C(null)},[i]),d.useEffect(()=>{if(!n||!o.agentConfigOpen)return;const v=g=>{!g.defaultPrevented&&g.key==="Escape"&&f===null&&document.querySelector("dialog[open]")===null&&w()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[w,f,o.agentConfigOpen,n]);const I=d.useRef({flushAgentSpec:a,flushInstructions:j});I.current={flushAgentSpec:a,flushInstructions:j},d.useEffect(()=>()=>{const{flushAgentSpec:v,flushInstructions:g}=I.current;g();try{v()}catch{}},[]);const M=d.useCallback(({next:v,instructions:g})=>{var N;if(i){if(v.skills&&v.skills.length>0&&(l==null?void 0:l.sandbox.enabled)===!0){s==null||s({...v,instructions:g||void 0,config:{...v.config,sandbox:{...(N=v.config)==null?void 0:N.sandbox,enabled:!0}}});return}s==null||s({...v,instructions:g||void 0})}},[i,l==null?void 0:l.sandbox.enabled,s]),E=d.useCallback(v=>{M({next:v,instructions:x})},[M,x]),y=d.useCallback(v=>{e!==null&&M({next:Ge({spec:e,messages:v.messages}),instructions:v.instructions})},[e,M]),k=d.useCallback(async v=>(r==null?void 0:r.getMcpTools)===void 0?[]:r.getMcpTools({connectorId:v}),[r]),R=d.useCallback(async v=>{var g;return(g=r==null?void 0:r.getMcpConnector)==null?void 0:g.call(r,{connectorId:v})},[r]);if(!S||e===null||n&&!o.agentConfigOpen)return null;const Q=m.models.find(v=>v.name===e.model.name);return t.jsxs(t.Fragment,{children:[t.jsx(h,{spec:e,model:Q,models:m.models,modelsLoading:m.loading,modelsError:m.error,skills:m.skills,skillsAvailable:(l==null?void 0:l.skill.enabled)===!0,webSearchAvailable:((L=l==null?void 0:l.webSearch)==null?void 0:L.enabled)===!0,memoryOffered:(l==null?void 0:l.memory)!=null,instructions:x,onOpenEditor:v=>{i&&C(v)},onChange:E,disabled:!i,onClose:n?w:void 0}),t.jsx(p,{editor:f,spec:e,models:m.models,connectors:m.connectors,skills:m.skills,loading:m.loading,error:m.error,skillsDisabled:(l==null?void 0:l.skill.enabled)!==!0,sandboxAvailable:(l==null?void 0:l.sandbox.enabled)===!0,instructions:x,onInstructionsSave:y,...(r==null?void 0:r.getMcpConnector)===void 0?{}:{loadMcpConnector:R},loadMcpTools:k,onRefreshConnectors:m.refreshConnectors,onChange:E,onClose:()=>C(null)})]})}export{At as A,kt as N,It as S,yt as T};