bazilion 0.55.0 → 0.56.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/dist/cli.js +192 -37
  2. package/dist/cli.js.map +1 -1
  3. package/dist/daemon.js +1164 -412
  4. package/dist/daemon.js.map +1 -1
  5. package/dist/web/client/assets/AddProviderDialog-DZ9mXFdq.js +1 -0
  6. package/dist/web/client/assets/AgentTemplateParts-BfG3a-ri.js +1 -0
  7. package/dist/web/client/assets/{Button-bTJUy9Qf.js → Button-CoKQRO-s.js} +1 -1
  8. package/dist/web/client/assets/ConfigPage-Ch-DSJUO.js +1 -0
  9. package/dist/web/client/assets/ConfirmDialog-B_jXAPmh.js +1 -0
  10. package/dist/web/client/assets/ConnectionsView-D1Liebtf.js +1 -0
  11. package/dist/web/client/assets/ManagePage-kd7iWYEL.js +1 -0
  12. package/dist/web/client/assets/{SectionTabs-D7kPQGoh.js → SectionTabs-Dc0bNn-J.js} +1 -1
  13. package/dist/web/client/assets/{Segmented-oPkAHPO1.js → Segmented-iylzLwE6.js} +1 -1
  14. package/dist/web/client/assets/SkillsParts-C5T7sYDA.js +1 -0
  15. package/dist/web/client/assets/SpawnTeamModal-DatFF4f_.js +1 -0
  16. package/dist/web/client/assets/TeamForm-l-N_PYeE.js +1 -0
  17. package/dist/web/client/assets/TeamThread-BWmIQiAh.js +1 -0
  18. package/dist/web/client/assets/UnsavedChangesGuard-vQBdMl8h.js +1 -0
  19. package/dist/web/client/assets/_id-C6SADaiD.js +1 -0
  20. package/dist/web/client/assets/_id-CC9r0qsr.js +1 -0
  21. package/dist/web/client/assets/access-BbQFbTPh.js +1 -0
  22. package/dist/web/client/assets/{agent-actions-CUee6aJq.js → agent-actions-B-9KIwn6.js} +1 -1
  23. package/dist/web/client/assets/agents-BXwzmHu8.js +1 -0
  24. package/dist/web/client/assets/agents-BtETzVIY.js +1 -0
  25. package/dist/web/client/assets/arrow-right-BqqfPqVi.js +1 -0
  26. package/dist/web/client/assets/attention-BMrZJ9ui.js +1 -0
  27. package/dist/web/client/assets/{bot-BCone8es.js → bot-BHky7KAX.js} +1 -1
  28. package/dist/web/client/assets/chart-column-DTsDbzL0.js +1 -0
  29. package/dist/web/client/assets/chevron-right-D1shxvdo.js +1 -0
  30. package/dist/web/client/assets/config-B2ZDYo52.js +1 -0
  31. package/dist/web/client/assets/{createLucideIcon-jxSFpY0Q.js → createLucideIcon-CZHSSDYA.js} +1 -1
  32. package/dist/web/client/assets/{download-Dy88XavQ.js → download-Dr0PgyMr.js} +1 -1
  33. package/dist/web/client/assets/es2015-D1pnOGPG.js +41 -0
  34. package/dist/web/client/assets/{file-text-DPsZ8-h9.js → file-text-D6OTHixJ.js} +1 -1
  35. package/dist/web/client/assets/{images-QBh_rL8b.js → images-BULrW-FC.js} +1 -1
  36. package/dist/web/client/assets/index-B-N6NIX4.js +14 -0
  37. package/dist/web/client/assets/{key-round-C-I8fAG0.js → key-round-DmSZN0Kq.js} +1 -1
  38. package/dist/web/client/assets/{list-checks-C9Q-bjEi.js → list-checks-DdTdAQXS.js} +1 -1
  39. package/dist/web/client/assets/login-DM3q-V4R.js +1 -0
  40. package/dist/web/client/assets/{manage-BaIU5zKy.js → manage-R57MUzsY.js} +1 -1
  41. package/dist/web/client/assets/mcp-CSHrVH1t.js +1 -0
  42. package/dist/web/client/assets/{message-square-Bwf9cHOx.js → message-square-B_pULba_.js} +1 -1
  43. package/dist/web/client/assets/{network-B3FA93gC.js → network-BqmVqC4_.js} +1 -1
  44. package/dist/web/client/assets/parts-68zf8Fgw.js +1 -0
  45. package/dist/web/client/assets/plus-CEKaHPBw.js +1 -0
  46. package/dist/web/client/assets/preload-helper-CZOd_z6l.js +1 -0
  47. package/dist/web/client/assets/routes-DOoeKVwr.js +85 -0
  48. package/dist/web/client/assets/skills-CPZftp9O.js +1 -0
  49. package/dist/web/client/assets/{square-terminal-DaNLwvEs.js → square-terminal-CYfGBHPC.js} +1 -1
  50. package/dist/web/client/assets/style-Bm9QsFpy.js +7 -0
  51. package/dist/web/client/assets/styles-B-kTTvCo.css +2 -0
  52. package/dist/web/client/assets/{system-CrTSr5_t.js → system-Dd2P9eqE.js} +1 -1
  53. package/dist/web/client/assets/teams-7FEpSZg1.js +1 -0
  54. package/dist/web/client/assets/teams-ClirFbDV.js +1 -0
  55. package/dist/web/client/assets/telegram-BJnT5THs.js +1 -0
  56. package/dist/web/client/assets/tools-DqNXLMpc.js +1 -0
  57. package/dist/web/client/assets/usage-BC_TStVj.js +1 -0
  58. package/dist/web/client/assets/use-resource-Bn0Sx7r6.js +1 -0
  59. package/dist/web/client/assets/{users-round-BElBVSnw.js → users-round-cxQ5HF-C.js} +1 -1
  60. package/dist/web/client/assets/welcome-g8wtn_or.js +1 -0
  61. package/dist/web/client/assets/{wrench-DotqSqSm.js → wrench-BLEJjETg.js} +1 -1
  62. package/dist/web/server/assets/{AddProviderDialog-BbpuvC2a.js → AddProviderDialog-DtkjBMv4.js} +5 -2
  63. package/dist/web/server/assets/AgentAvatar-8gTAy_tP.js +37 -0
  64. package/dist/web/server/assets/{AgentTemplateParts-Ce7snK3m.js → AgentTemplateParts-CxWyovvM.js} +6 -2
  65. package/dist/web/server/assets/Button-Dsnw22OF.js +17 -0
  66. package/dist/web/server/assets/{ConfigPage-qP9ejjuw.js → ConfigPage-usZi48Zr.js} +2 -2
  67. package/dist/web/server/assets/{ConfirmDialog-Z-uYbE9B.js → ConfirmDialog-DAcSBHkT.js} +3 -1
  68. package/dist/web/server/assets/{ConnectionsView-CLIV7V5D.js → ConnectionsView-Dy6uYSRI.js} +9 -7
  69. package/dist/web/server/assets/Dialog-DTeF-nOZ.js +85 -0
  70. package/dist/web/server/assets/{ManagePage-BR9FwVZM.js → ManagePage-Dy1EdovO.js} +2 -2
  71. package/dist/web/server/assets/{SectionTabs-CWQ5orUW.js → SectionTabs-BVrMn76H.js} +2 -1
  72. package/dist/web/server/assets/{SkillsParts-DWpdydCJ.js → SkillsParts-Cw05b3al.js} +6 -2
  73. package/dist/web/server/assets/SpawnDialog-BAE8W91z.js +125 -0
  74. package/dist/web/server/assets/{SpawnTeamModal-C-YMvoaB.js → SpawnTeamModal-CgBY0HuN.js} +6 -2
  75. package/dist/web/server/assets/{TeamForm-CL45gBdt.js → TeamForm-JyO5xJXX.js} +6 -2
  76. package/dist/web/server/assets/{TeamThread-CVVH6kKj.js → TeamThread-5o48EbXL.js} +52 -4
  77. package/dist/web/server/assets/{UnsavedChangesGuard-CXK75QQp.js → UnsavedChangesGuard-CJQGu45L.js} +1 -1
  78. package/dist/web/server/assets/{_id-8zsImuGa.js → _id-BE_RSvuN.js} +14 -9
  79. package/dist/web/server/assets/{_id-d2OwovYV.js → _id-BNvm89oJ.js} +2 -2
  80. package/dist/web/server/assets/{_id-De3Bm0SG.js → _id-BW6sVrvw.js} +1 -1
  81. package/dist/web/server/assets/{_id-2I4CSMQj.js → _id-BfjTS4JO.js} +15 -9
  82. package/dist/web/server/assets/{_id-BKzOw78O.js → _id-BpumuCYL.js} +1 -1
  83. package/dist/web/server/assets/{_id-BpfoPuTv.js → _id-C54t_nX6.js} +2 -2
  84. package/dist/web/server/assets/_tanstack-start-manifest_v-BPwQX_5b.js +275 -0
  85. package/dist/web/server/assets/{access-CwZ27Wsl.js → access-6FWih7nC.js} +7 -4
  86. package/dist/web/server/assets/{access-WWspT0v4.js → access-BhAMfi7U.js} +1 -1
  87. package/dist/web/server/assets/{access-CyUoElTP.js → access-DEyq3uP_.js} +2 -2
  88. package/dist/web/server/assets/activity-Czfq-5_F.js +471 -0
  89. package/dist/web/server/assets/{agent-actions-C07Cp5Ue.js → agent-actions-ChH7Mne4.js} +1 -1
  90. package/dist/web/server/assets/{agents-CRtMfKqX.js → agents-3hBjrd8B.js} +1 -1
  91. package/dist/web/server/assets/{agents-vuXrAv1j.js → agents-BXuglv4G.js} +12 -6
  92. package/dist/web/server/assets/{agents-DTub-rJk.js → agents-DhenbitX.js} +2 -2
  93. package/dist/web/server/assets/{agents-CwzhpDPm.js → agents-KJcDMj0Y.js} +9 -6
  94. package/dist/web/server/assets/{agents-DCWEoaxY.js → agents-ncyhVx-T.js} +2 -2
  95. package/dist/web/server/assets/{agents-DQowl6Ly.js → agents-rTDlRZa5.js} +1 -1
  96. package/dist/web/server/assets/{attention-BqCnJ1hg.js → attention-CDdOCOio.js} +2 -2
  97. package/dist/web/server/assets/{attention-DwGaur_w.js → attention-DM__BzWY.js} +8 -6
  98. package/dist/web/server/assets/{attention-Dki8rmGZ.js → attention-X0U6ZmiA.js} +1 -1
  99. package/dist/web/server/assets/{auth-dJnrFW6y.js → auth-BexhV8Yq.js} +1 -1
  100. package/dist/web/server/assets/{config-B9dJiji_.js → config-Cld8Q8N7.js} +2 -2
  101. package/dist/web/server/assets/{config-X7qWbbpH.js → config-Cx5ri2DL2.js} +1 -1
  102. package/dist/web/server/assets/{config-D3MR2VjE.js → config-DpgYAXQ3.js} +9 -6
  103. package/dist/web/server/assets/createSsrRpc-6LHNEsSK.js +16 -0
  104. package/dist/web/server/assets/{daemon-client-B_ZRIIrT.js → daemon-client-RxAllljf.js} +1 -1
  105. package/dist/web/server/assets/form-BEjeiSy3.js +416 -0
  106. package/dist/web/server/assets/live-DbJeq6KP.js +263 -0
  107. package/dist/web/server/assets/{login-CRd1yTH5.js → login-BJdJ219n.js} +1 -1
  108. package/dist/web/server/assets/{login-ZN6KV8n-.js → login-C4lL4AxI.js} +2 -2
  109. package/dist/web/server/assets/{manage-Ce6cI4eW.js → manage-C6ucNYZW.js} +2 -1
  110. package/dist/web/server/assets/{mcp-BQ15a9dG.js → mcp-BXnWQOwM.js} +7 -4
  111. package/dist/web/server/assets/{mcp-C97uAZe1.js → mcp-C8VLspco.js} +1 -1
  112. package/dist/web/server/assets/{mcp-CYQuYWGX.js → mcp-DwCzj7eO.js} +2 -2
  113. package/dist/web/server/assets/open-groups-BMGYUTtY.js +12 -0
  114. package/dist/web/server/assets/{page-title-CVY-c2Pd.js → page-title-PTpFHXWo.js} +1 -1
  115. package/dist/web/server/assets/parts-k9M-atPa.js +436 -0
  116. package/dist/web/server/assets/{router-CPdWGKQ5.js → router-BttfLktO.js} +185 -77
  117. package/dist/web/server/assets/{routes-BPloBDc8.js → routes-A7UcreVX.js} +3 -3
  118. package/dist/web/server/assets/{routes-Dw1K3TQw.js → routes-B9jw-MJ8.js} +1175 -321
  119. package/dist/web/server/assets/{routes-xDPesCQu.js → routes-BX2FV8rS.js} +3 -3
  120. package/dist/web/server/assets/{skills-D0xrNc2_.js → skills-BVAH93cd.js} +8 -6
  121. package/dist/web/server/assets/{skills-DWzlT_hC.js → skills-Cd5Cfdaz.js} +1 -1
  122. package/dist/web/server/assets/{skills-6VSpEORe.js → skills-y3GsyKce.js} +2 -2
  123. package/dist/web/server/assets/src-vrZVrV9u.js +103 -0
  124. package/dist/web/server/assets/{start-DhW7sy23.js → start-Dl8gQ-95.js} +1 -1
  125. package/dist/web/server/assets/{style-aMybyKzc.js → style-BQ3H9I7Y.js} +1 -1
  126. package/dist/web/server/assets/{system-B5sPgdQW.js → system-BJPKqM6b.js} +2 -2
  127. package/dist/web/server/assets/{system-CXmiWyDG.js → system-C7mejQSc.js} +3 -3
  128. package/dist/web/server/assets/{system-D3th6n2E.js → system-LsLcuVzY.js} +1 -1
  129. package/dist/web/server/assets/{teams-yF3I_Zjq.js → teams-B6gbflsZ.js} +10 -6
  130. package/dist/web/server/assets/{teams-iXiCnN2i.js → teams-C7kXMNgc.js} +10 -6
  131. package/dist/web/server/assets/{teams-BopOP4x7.js → teams-CPXoTggb.js} +1 -1
  132. package/dist/web/server/assets/{teams-70u1XQTr.js → teams-CeLLd2Mf.js} +1 -1
  133. package/dist/web/server/assets/{teams-ClRBVSYU.js → teams-CiX8LUQo.js} +2 -2
  134. package/dist/web/server/assets/{teams-Dq4RCxis.js → teams-D-XdIkCr.js} +2 -2
  135. package/dist/web/server/assets/{telegram-CGol0CKX2.js → telegram-D7TW3LNZ.js} +1 -1
  136. package/dist/web/server/assets/{telegram-DwEgyR1x.js → telegram-D8_V7_sW.js} +286 -272
  137. package/dist/web/server/assets/{telegram-D9U9c1MN.js → telegram-DA2dwLID.js} +2 -2
  138. package/dist/web/server/assets/{tools-VPIKjr3y.js → tools-CckcG9Jl.js} +5 -3
  139. package/dist/web/server/assets/{tools-DflVIdDd.js → tools-CluiJywK.js} +2 -2
  140. package/dist/web/server/assets/{tools-C-wwWjLI.js → tools-D1BBVkRh.js} +1 -1
  141. package/dist/web/server/assets/usage-CrYyvPgf.js +46 -0
  142. package/dist/web/server/assets/usage-PNNb3pPj.js +465 -0
  143. package/dist/web/server/assets/{use-resource-CbHGYti0.js → use-resource-BUA9qGGY.js} +1 -1
  144. package/dist/web/server/assets/{welcome-CxXMI4HI.js → welcome-CUTYf8UG.js} +1 -1
  145. package/dist/web/server/assets/{welcome-966nOyyK.js → welcome-CYhh3iUU.js} +8 -6
  146. package/dist/web/server/assets/{welcome-7DrYZVs6.js → welcome-CwzLt6Rp.js} +2 -2
  147. package/dist/web/server/assets/workspace-0XPILV1W.js +82 -0
  148. package/dist/web/server/server.js +20 -20
  149. package/dist/worker.js +27 -6
  150. package/dist/worker.js.map +1 -1
  151. package/package.json +1 -1
  152. package/dist/web/client/assets/AddProviderDialog-DfFOaCjC.js +0 -1
  153. package/dist/web/client/assets/AgentTemplateParts-IMJmAQjN.js +0 -1
  154. package/dist/web/client/assets/ConfigPage-CzLHZa5o.js +0 -1
  155. package/dist/web/client/assets/ConfirmDialog-Cu_evkgc.js +0 -1
  156. package/dist/web/client/assets/ConnectionsView-D7Fmutl2.js +0 -1
  157. package/dist/web/client/assets/ManagePage-BfvlCrmz.js +0 -1
  158. package/dist/web/client/assets/SkillsParts-BuTxcCam.js +0 -1
  159. package/dist/web/client/assets/SpawnTeamModal-B1UnOvtp.js +0 -1
  160. package/dist/web/client/assets/TeamForm-DbzxtRjj.js +0 -1
  161. package/dist/web/client/assets/TeamThread-jpsWq6vI.js +0 -1
  162. package/dist/web/client/assets/UnsavedChangesGuard-BfyU9v9i.js +0 -1
  163. package/dist/web/client/assets/_id-BCNBLF-2.js +0 -1
  164. package/dist/web/client/assets/_id-D8_H79U2.js +0 -1
  165. package/dist/web/client/assets/access-CDWe1Kwy.js +0 -1
  166. package/dist/web/client/assets/agents-sE686DTf.js +0 -1
  167. package/dist/web/client/assets/agents-yrur1NDa.js +0 -1
  168. package/dist/web/client/assets/arrow-right-U66krZnr.js +0 -1
  169. package/dist/web/client/assets/attention-DYEHDfmx.js +0 -1
  170. package/dist/web/client/assets/chevron-right-CuqJFXTe.js +0 -1
  171. package/dist/web/client/assets/config-BHv886pr.js +0 -1
  172. package/dist/web/client/assets/index-GOthyyE-.js +0 -14
  173. package/dist/web/client/assets/login-Dhe15Uuc.js +0 -1
  174. package/dist/web/client/assets/mcp-A_Eo7x3q.js +0 -1
  175. package/dist/web/client/assets/parts-CpIfn_BH.js +0 -41
  176. package/dist/web/client/assets/plus-CQPjc8uR.js +0 -1
  177. package/dist/web/client/assets/routes-CTg_yjbY.js +0 -85
  178. package/dist/web/client/assets/skills-CLjtYtkA.js +0 -1
  179. package/dist/web/client/assets/style-mjEbxhf5.js +0 -7
  180. package/dist/web/client/assets/styles-DzcEC3Rd.css +0 -2
  181. package/dist/web/client/assets/teams-Bhje5n2h.js +0 -1
  182. package/dist/web/client/assets/teams-Cbgw0Qhv.js +0 -1
  183. package/dist/web/client/assets/telegram-HtUczmaA.js +0 -1
  184. package/dist/web/client/assets/tools-BpjFvmoX.js +0 -1
  185. package/dist/web/client/assets/use-resource-BnvgCpBi.js +0 -1
  186. package/dist/web/client/assets/welcome-D47LKWYO.js +0 -1
  187. package/dist/web/server/assets/Rail-b6EbjBB-.js +0 -605
  188. package/dist/web/server/assets/SpawnDialog-3wNx0W1R.js +0 -1851
  189. package/dist/web/server/assets/_tanstack-start-manifest_v-kkY_s_uR.js +0 -256
  190. package/dist/web/server/assets/createSsrRpc-qesavJv-.js +0 -72
  191. package/dist/web/server/assets/public-origin-BpDkdS5Q.js +0 -34
@@ -1,85 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ConnectionsView-D7Fmutl2.js","assets/createLucideIcon-jxSFpY0Q.js","assets/index-GOthyyE-.js","assets/Button-bTJUy9Qf.js","assets/parts-CpIfn_BH.js","assets/index-Cofc7zhl.css","assets/ConfirmDialog-Cu_evkgc.js","assets/Segmented-oPkAHPO1.js","assets/UnsavedChangesGuard-BfyU9v9i.js","assets/TeamThread-jpsWq6vI.js","assets/SpawnTeamModal-B1UnOvtp.js","assets/manage-BaIU5zKy.js","assets/TeamForm-DbzxtRjj.js","assets/agent-actions-CUee6aJq.js","assets/use-resource-BnvgCpBi.js","assets/download-Dy88XavQ.js","assets/images-QBh_rL8b.js","assets/arrow-right-U66krZnr.js","assets/bot-BCone8es.js","assets/chevron-right-CuqJFXTe.js","assets/network-B3FA93gC.js","assets/plus-CQPjc8uR.js","assets/users-round-BElBVSnw.js","assets/style-mjEbxhf5.js","assets/style-DLioOiRN.css","assets/message-square-Bwf9cHOx.js"])))=>i.map(i=>d[i]);
2
- import{Q as e,a as t,c as n,et as r,f as i,g as a,i as o,o as s,r as c,s as l,t as u}from"./createLucideIcon-jxSFpY0Q.js";import{t as d}from"./UnsavedChangesGuard-BfyU9v9i.js";import{t as f}from"./Button-bTJUy9Qf.js";import{A as p,C as m,E as h,S as g,T as _,_ as v,a as y,b,c as x,d as S,f as C,g as w,h as T,i as E,it as D,j as ee,k as te,n as ne,nt as O,o as k,ot as re,p as ie,r as ae,st as A,v as oe,y as j}from"./parts-CpIfn_BH.js";import{t as se}from"./download-Dy88XavQ.js";import{n as ce,t as le}from"./images-QBh_rL8b.js";import{t as ue}from"./arrow-right-U66krZnr.js";import{t as de}from"./chevron-right-CuqJFXTe.js";import{_ as fe,a as pe,c as M,d as me,f as N,g as he,h as P,i as F,l as ge,m as _e,n as ve,o as ye,p as I,r as be,s as xe,t as Se,u as Ce,v as we}from"./TeamThread-jpsWq6vI.js";import{t as Te}from"./file-text-DPsZ8-h9.js";import{t as Ee}from"./list-checks-C9Q-bjEi.js";import{t as De}from"./message-square-Bwf9cHOx.js";import{n as Oe,t as ke}from"./wrench-DotqSqSm.js";import{t as Ae}from"./network-B3FA93gC.js";import{t as je}from"./plus-CQPjc8uR.js";import{i as Me,n as Ne,t as Pe}from"./SkillsParts-BuTxcCam.js";import{$ as Fe,A as L,At as Ie,B as Le,Ct as Re,D as ze,E as Be,G as Ve,M as He,N as Ue,O as We,Q as Ge,S as Ke,St as qe,W as Je,X as R,Y as Ye,_t as Xe,at as Ze,ct as Qe,dt as $e,et,gt as z,h as tt,ht as nt,it as rt,j as it,jt as at,k as ot,kt as st,lt as ct,mt as lt,nt as ut,ot as B,rt as dt,st as ft,tt as pt,ut as mt,v as ht,w as gt,wt as _t,x as vt,y as yt,yt as bt}from"./index-GOthyyE-.js";import{n as xt,r as V,t as St}from"./use-resource-BnvgCpBi.js";import{t as Ct}from"./ConfirmDialog-Cu_evkgc.js";import{t as wt}from"./Segmented-oPkAHPO1.js";import{i as Tt,n as Et,t as Dt}from"./agent-actions-CUee6aJq.js";import{S as Ot,_ as kt,x as At}from"./manage-BaIU5zKy.js";import{t as jt}from"./SpawnTeamModal-B1UnOvtp.js";var Mt=u(`arrow-left-right`,[[`path`,{d:`M8 3 4 7l4 4`,key:`9rb6wj`}],[`path`,{d:`M4 7h16`,key:`6tx8e3`}],[`path`,{d:`m16 21 4-4-4-4`,key:`siv7j2`}],[`path`,{d:`M20 17H4`,key:`h6l3hr`}]]),Nt=u(`book-open-check`,[[`path`,{d:`M12 21V7`,key:`gj6g52`}],[`path`,{d:`m16 12 2 2 4-4`,key:`mdajum`}],[`path`,{d:`M22 6V4a1 1 0 0 0-1-1h-5a4 4 0 0 0-4 4 4 4 0 0 0-4-4H3a1 1 0 0 0-1 1v13a1 1 0 0 0 1 1h6a3 3 0 0 1 3 3 3 3 0 0 1 3-3h6a1 1 0 0 0 1-1v-1.3`,key:`8arnkb`}]]),Pt=u(`book-open`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z`,key:`ruj8y`}]]),Ft=u(`calendar-clock`,[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5`,key:`1osxxc`}],[`path`,{d:`M3 10h5`,key:`r794hk`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]),It=u(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Lt=u(`columns-2`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M12 3v18`,key:`108xh3`}]]),Rt=u(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),zt=u(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),Bt=u(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),Vt=u(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),Ht=u(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),Ut=u(`inbox`,[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`,key:`o97t9d`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}]]),Wt=u(`layout-template`,[[`rect`,{width:`18`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`f1a2em`}],[`rect`,{width:`9`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`jqznyg`}],[`rect`,{width:`5`,height:`7`,x:`16`,y:`14`,rx:`1`,key:`q5h2i8`}]]),Gt=u(`lightbulb`,[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]),Kt=u(`notebook-text`,[[`path`,{d:`M2 6h4`,key:`aawbzj`}],[`path`,{d:`M2 10h4`,key:`l0bgd4`}],[`path`,{d:`M2 14h4`,key:`1gsvsf`}],[`path`,{d:`M2 18h4`,key:`1bu2t1`}],[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,key:`1nb95v`}],[`path`,{d:`M9.5 8h5`,key:`11mslq`}],[`path`,{d:`M9.5 12H16`,key:`ktog6x`}],[`path`,{d:`M9.5 16H14`,key:`p1seyn`}]]),qt=u(`octagon-x`,[[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z`,key:`2d38gg`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),Jt=u(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),Yt=u(`pencil-line`,[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),Xt=u(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),Zt=u(`sticky-note`,[[`path`,{d:`M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z`,key:`1dfntj`}],[`path`,{d:`M15 3v5a1 1 0 0 0 1 1h5`,key:`6s6qgf`}]]),Qt=u(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),$t=u(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),H=r(e(),1),en=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/;function tn(e){let t=[],n=[],r=0,i=0,a=!1,o=e.replace(/\n$/,``).split(`
3
- `);for(let e of o){let o=en.exec(e);o?(r=Number(o[1]),i=Number(o[2]),a=!0,n.push({kind:`hunk`,text:e})):a?e.startsWith(`+`)?n.push({kind:`add`,text:e.slice(1),newLine:i++}):e.startsWith(`-`)?n.push({kind:`remove`,text:e.slice(1),oldLine:r++}):e.startsWith(`\\`)?n.push({kind:`note`,text:e.slice(1).trim()}):n.push({kind:`context`,text:e.slice(1),oldLine:r++,newLine:i++}):t.push(e)}return{header:t,lines:n}}function nn(e){let t=[],n=[],r=[],i=()=>{for(let e=0;e<Math.max(n.length,r.length);e++)t.push({kind:`pair`,left:n[e]??null,right:r[e]??null});n=[],r=[]};for(let a of e)a.kind===`remove`?(r.length>0&&i(),n.push({line:a.oldLine,text:a.text,changed:!0})):a.kind===`add`?r.push({line:a.newLine,text:a.text,changed:!0}):(i(),a.kind===`context`?t.push({kind:`pair`,left:{line:a.oldLine,text:a.text,changed:!1},right:{line:a.newLine,text:a.text,changed:!1}}):t.push(a));return i(),t}function rn(e){switch(e){case`added`:return`added`;case`modified`:return`modified`;case`deleted`:return`deleted`;case`renamed`:return`renamed`;case`copied`:return`copied`;case`type_changed`:return`type changed`;case`unmerged`:return`unmerged`;case`untracked`:return`untracked`;default:return`changed`}}function an(e){let t=rn(e.status);return e.excludedReason===`credential_shaped`?`${t} · content withheld (credential-shaped)`:e.excludedReason===`bazilion_state`?`${t} · content withheld (Bazilion state)`:e.binary?`${t} · binary`:e.addedLines===null||e.deletedLines===null?t:`${t} · +${e.addedLines} −${e.deletedLines}`}function on(e,t){switch(e){case`not_repository`:return`This Team workspace is not a Git repository, so there are no changes to review.`;case`unsupported_layout`:return`${t} Bazilion does not widen mounts or run repository helpers to make inspection work; use a repository whose work tree and metadata are reachable from the Team root.`;case`invalid_base`:return`That comparison base is not a branch, tag, commit id or revision such as HEAD~1.`;case`unknown_base`:return`That comparison base does not name a commit in this repository.`;default:return t}}function sn(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function cn(e){if(Array.isArray(e))return e}function ln(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function un(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
4
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function dn(e,t){return cn(e)||ln(e,t)||fn(e,t)||un()}function fn(e,t){if(e){if(typeof e==`string`)return sn(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?sn(e,t):void 0}}var pn=Object.entries,mn=Object.setPrototypeOf,hn=Object.isFrozen,gn=Object.getPrototypeOf,_n=Object.getOwnPropertyDescriptor,U=Object.freeze,W=Object.seal,vn=Object.create,yn=typeof Reflect<`u`&&Reflect,bn=yn.apply,xn=yn.construct;U||=function(e){return e},W||=function(e){return e},bn||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},xn||=function(e){return new e(...[...arguments].slice(1))};var Sn=q(Array.prototype.forEach),Cn=q(Array.prototype.lastIndexOf),wn=q(Array.prototype.pop),Tn=q(Array.prototype.push),En=q(Array.prototype.splice),Dn=Array.isArray,On=q(String.prototype.toLowerCase),kn=q(String.prototype.toString),An=q(String.prototype.match),jn=q(String.prototype.replace),Mn=q(String.prototype.indexOf),Nn=q(String.prototype.trim),Pn=q(Number.prototype.toString),Fn=q(Boolean.prototype.toString),In=typeof BigInt>`u`?null:q(BigInt.prototype.toString),Ln=typeof Symbol>`u`?null:q(Symbol.prototype.toString),G=q(Object.prototype.hasOwnProperty),Rn=q(Object.prototype.toString),K=q(RegExp.prototype.test),zn=Bn(TypeError);function q(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return bn(e,t,n)}}function Bn(e){return function(){return xn(e,[...arguments])}}function J(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:On;if(mn&&mn(e,null),!Dn(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(hn(t)||(t[r]=e),i=e)}e[i]=!0}return e}function Vn(e){for(let t=0;t<e.length;t++)G(e,t)||(e[t]=null);return e}function Y(e){let t=vn(null);for(let r of pn(e)){var n=dn(r,2);let i=n[0],a=n[1];G(e,i)&&(Dn(a)?t[i]=Vn(a):a&&typeof a==`object`&&a.constructor===Object?t[i]=Y(a):t[i]=a)}return t}function Hn(e){switch(typeof e){case`string`:return e;case`number`:return Pn(e);case`boolean`:return Fn(e);case`bigint`:return In?In(e):`0`;case`symbol`:return Ln?Ln(e):`Symbol()`;case`undefined`:return Rn(e);case`function`:case`object`:{if(e===null)return Rn(e);let t=e,n=Un(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:Rn(e)}return Rn(e)}default:return Rn(e)}}function Un(e,t){for(;e!==null;){let n=_n(e,t);if(n){if(n.get)return q(n.get);if(typeof n.value==`function`)return q(n.value)}e=gn(e)}function n(){return null}return n}function Wn(e){try{return K(e,``),!0}catch{return!1}}var Gn=U(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),Kn=U(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),qn=U([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),Jn=U([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),Yn=U(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),Xn=U([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),Zn=U([`#text`]),Qn=U(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.command.commandfor.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),$n=U(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-rendering.textlength.type.u1.u2.unicode.values.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),er=U(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),tr=U([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),nr=W(/{{[\w\W]*|^[\w\W]*}}/g),rr=W(/<%[\w\W]*|^[\w\W]*%>/g),ir=W(/\${[\w\W]*/g),ar=W(/^data-[\-\w.\u00B7-\uFFFF]+$/),or=W(/^aria-[\-\w]+$/),sr=W(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),cr=W(/^(?:\w+script|data):/i),lr=W(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),ur=W(/^html$/i),dr=W(/^[a-z][.\w]*(-[.\w]+)+$/i),fr=W(/<[/\w!]/g),pr=W(/<[/\w]/g),mr=W(/<\/no(script|embed|frames)/i),hr=W(/\/>/i),gr={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},_r=function(){return typeof window>`u`?null:window},vr=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},yr=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},br=function(e,t,n,r){return G(e,t)&&Dn(e[t])?J(r.base?Y(r.base):{},e[t],r.transform):n};function xr(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:_r(),t=e=>xr(e);if(t.version=`3.4.11`,t.removed=[],!e||!e.document||e.document.nodeType!==gr.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=Un(d,`cloneNode`),p=Un(d,`remove`),m=Un(d,`nextSibling`),h=Un(d,`childNodes`),g=Un(d,`parentNode`),_=Un(d,`shadowRoot`),v=Un(d,`attributes`),y=o&&o.prototype?Un(o.prototype,`nodeType`):null,b=o&&o.prototype?Un(o.prototype,`nodeName`):null;if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let x,S=``,C,w=!1,T=0,E=function(){if(T>0)throw zn(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},D=function(e){E(),T++;try{return x.createHTML(e)}finally{T--}},ee=function(e){E(),T++;try{return x.createScriptURL(e)}finally{T--}},te=function(){return w||=(C=vr(u,i),!0),C},ne=n,O=ne.implementation,k=ne.createNodeIterator,re=ne.createDocumentFragment,ie=ne.getElementsByTagName,ae=r.importNode,A=yr();t.isSupported=typeof pn==`function`&&typeof g==`function`&&O&&O.createHTMLDocument!==void 0;let oe=nr,j=rr,se=ir,ce=ar,le=or,ue=cr,de=lr,fe=dr,pe=sr,M=null,me=J({},[...Gn,...Kn,...qn,...Yn,...Zn]),N=null,he=J({},[...Qn,...$n,...er,...tr]),P=Object.seal(vn(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),F=null,ge=null,_e=Object.seal(vn(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),ve=!0,ye=!0,I=!1,be=!0,xe=!1,Se=!0,Ce=!1,we=!1,Te=null,Ee=null,De=!1,Oe=!1,ke=!1,Ae=!1,je=!0,Me=!1,Ne=`user-content-`,Pe=!0,Fe=!1,L={},Ie=null,Le=J({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),Re=null,ze=J({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Be=null,Ve=J({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),He=`http://www.w3.org/1998/Math/MathML`,Ue=`http://www.w3.org/2000/svg`,We=`http://www.w3.org/1999/xhtml`,Ge=We,Ke=!1,qe=null,Je=J({},[He,Ue,We],kn),R=U([`mi`,`mo`,`mn`,`ms`,`mtext`]),Ye=J({},R),Xe=U([`annotation-xml`]),Ze=J({},Xe),Qe=J({},[`title`,`style`,`font`,`a`,`script`]),$e=null,et=[`application/xhtml+xml`,`text/html`],z=null,tt=null,nt=n.createElement(`form`),rt=function(e){return e instanceof RegExp||e instanceof Function},it=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(tt&&tt===e)return;(!e||typeof e!=`object`)&&(e={}),e=Y(e),$e=et.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,z=$e===`application/xhtml+xml`?kn:On,M=br(e,`ALLOWED_TAGS`,me,{transform:z}),N=br(e,`ALLOWED_ATTR`,he,{transform:z}),qe=br(e,`ALLOWED_NAMESPACES`,Je,{transform:kn}),Be=br(e,`ADD_URI_SAFE_ATTR`,Ve,{transform:z,base:Ve}),Re=br(e,`ADD_DATA_URI_TAGS`,ze,{transform:z,base:ze}),Ie=br(e,`FORBID_CONTENTS`,Le,{transform:z}),F=br(e,`FORBID_TAGS`,Y({}),{transform:z}),ge=br(e,`FORBID_ATTR`,Y({}),{transform:z}),L=G(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?Y(e.USE_PROFILES):e.USE_PROFILES:!1,ve=e.ALLOW_ARIA_ATTR!==!1,ye=e.ALLOW_DATA_ATTR!==!1,I=e.ALLOW_UNKNOWN_PROTOCOLS||!1,be=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,xe=e.SAFE_FOR_TEMPLATES||!1,Se=e.SAFE_FOR_XML!==!1,Ce=e.WHOLE_DOCUMENT||!1,Oe=e.RETURN_DOM||!1,ke=e.RETURN_DOM_FRAGMENT||!1,Ae=e.RETURN_TRUSTED_TYPE||!1,De=e.FORCE_BODY||!1,je=e.SANITIZE_DOM!==!1,Me=e.SANITIZE_NAMED_PROPS||!1,Pe=e.KEEP_CONTENT!==!1,Fe=e.IN_PLACE||!1,pe=Wn(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:sr,Ge=typeof e.NAMESPACE==`string`?e.NAMESPACE:We,Ye=G(e,`MATHML_TEXT_INTEGRATION_POINTS`)&&e.MATHML_TEXT_INTEGRATION_POINTS&&typeof e.MATHML_TEXT_INTEGRATION_POINTS==`object`?Y(e.MATHML_TEXT_INTEGRATION_POINTS):J({},R),Ze=G(e,`HTML_INTEGRATION_POINTS`)&&e.HTML_INTEGRATION_POINTS&&typeof e.HTML_INTEGRATION_POINTS==`object`?Y(e.HTML_INTEGRATION_POINTS):J({},Xe);let t=G(e,`CUSTOM_ELEMENT_HANDLING`)&&e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING==`object`?Y(e.CUSTOM_ELEMENT_HANDLING):vn(null);if(P=vn(null),G(t,`tagNameCheck`)&&rt(t.tagNameCheck)&&(P.tagNameCheck=t.tagNameCheck),G(t,`attributeNameCheck`)&&rt(t.attributeNameCheck)&&(P.attributeNameCheck=t.attributeNameCheck),G(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(P.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),W(P),xe&&(ye=!1),ke&&(Oe=!0),L&&(M=J({},Zn),N=vn(null),L.html===!0&&(J(M,Gn),J(N,Qn)),L.svg===!0&&(J(M,Kn),J(N,$n),J(N,tr)),L.svgFilters===!0&&(J(M,qn),J(N,$n),J(N,tr)),L.mathMl===!0&&(J(M,Yn),J(N,er),J(N,tr))),_e.tagCheck=null,_e.attributeCheck=null,G(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?_e.tagCheck=e.ADD_TAGS:Dn(e.ADD_TAGS)&&(M===me&&(M=Y(M)),J(M,e.ADD_TAGS,z))),G(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?_e.attributeCheck=e.ADD_ATTR:Dn(e.ADD_ATTR)&&(N===he&&(N=Y(N)),J(N,e.ADD_ATTR,z))),G(e,`ADD_URI_SAFE_ATTR`)&&Dn(e.ADD_URI_SAFE_ATTR)&&J(Be,e.ADD_URI_SAFE_ATTR,z),G(e,`FORBID_CONTENTS`)&&Dn(e.FORBID_CONTENTS)&&(Ie===Le&&(Ie=Y(Ie)),J(Ie,e.FORBID_CONTENTS,z)),G(e,`ADD_FORBID_CONTENTS`)&&Dn(e.ADD_FORBID_CONTENTS)&&(Ie===Le&&(Ie=Y(Ie)),J(Ie,e.ADD_FORBID_CONTENTS,z)),Pe&&(M[`#text`]=!0),Ce&&J(M,[`html`,`head`,`body`]),M.table&&(J(M,[`tbody`]),delete F.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw zn(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw zn(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=x;x=e.TRUSTED_TYPES_POLICY;try{S=D(``)}catch(e){throw x=t,e}}else e.TRUSTED_TYPES_POLICY===null?(x=void 0,S=``):(x===void 0&&(x=te()),x&&typeof S==`string`&&(S=D(``)));U&&U(e),tt=e},at=J({},[...Kn,...qn,...Jn]),ot=J({},[...Yn,...Xn]),st=function(e,t,n){return t.namespaceURI===We?e===`svg`:t.namespaceURI===He?e===`svg`&&(n===`annotation-xml`||Ye[n]):!!at[e]},ct=function(e,t,n){return t.namespaceURI===We?e===`math`:t.namespaceURI===Ue?e===`math`&&Ze[n]:!!ot[e]},lt=function(e,t,n){return t.namespaceURI===Ue&&!Ze[n]||t.namespaceURI===He&&!Ye[n]?!1:!ot[e]&&(Qe[e]||!at[e])},ut=function(e){let t=g(e);(!t||!t.tagName)&&(t={namespaceURI:Ge,tagName:`template`});let n=On(e.tagName),r=On(t.tagName);return qe[e.namespaceURI]?e.namespaceURI===Ue?st(n,t,r):e.namespaceURI===He?ct(n,t,r):e.namespaceURI===We?lt(n,t,r):!!($e===`application/xhtml+xml`&&qe[e.namespaceURI]):!1},B=function(e){Tn(t.removed,{element:e});try{g(e).removeChild(e)}catch{if(p(e),!g(e))throw zn(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},dt=function(e){let t=h(e);if(t){let e=[];Sn(t,t=>{Tn(e,t)}),Sn(e,e=>{try{p(e)}catch{}})}let n=v(e);if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;if(typeof i==`string`)try{e.removeAttribute(i)}catch{}}},ft=function(e,n){try{Tn(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch{Tn(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),e===`is`)if(Oe||ke)try{B(n)}catch{}else try{n.setAttribute(e,``)}catch{}},pt=function(e){let t=v(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;if(!(typeof i!=`string`||N[z(i)]))try{e.removeAttribute(i)}catch{}}},mt=function(e){let t=[e];for(;t.length>0;){let e=t.pop();(y?y(e):e.nodeType)===gr.element&&pt(e);let n=h(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},ht=function(e){let t=null,r=null;if(De)e=`<remove></remove>`+e;else{let t=An(e,/^[\r\n\t ]+/);r=t&&t[0]}$e===`application/xhtml+xml`&&Ge===We&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=x?D(e):e;if(Ge===We)try{t=new l().parseFromString(i,$e)}catch{}if(!t||!t.documentElement){t=O.createDocument(Ge,`template`,null);try{t.documentElement.innerHTML=Ke?S:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),Ge===We?ie.call(t,Ce?`html`:`body`)[0]:Ce?t.documentElement:a},gt=function(e){return k.call(e.ownerDocument||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},_t=function(e){return e=jn(e,oe,` `),e=jn(e,j,` `),e=jn(e,se,` `),e},vt=function(e){e.normalize();let t=k.call(e.ownerDocument||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),n=t.nextNode();for(;n;)n.data=_t(n.data),n=t.nextNode();let r=e.querySelectorAll?.call(e,`template`);r&&Sn(r,e=>{bt(e.content)&&vt(e.content)})},yt=function(e){let t=b?b(e):null;return typeof t!=`string`||z(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==v(e)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==y(e)||e.childNodes!==h(e)},bt=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return y(e)===gr.documentFragment}catch{return!1}},xt=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return typeof y(e)==`number`}catch{return!1}};function V(e,n,r){e.length!==0&&Sn(e,e=>{e.call(t,n,r,tt)})}let St=function(e,t){return!!(Se&&e.hasChildNodes()&&!xt(e.firstElementChild)&&K(fr,e.textContent)&&K(fr,e.innerHTML)||Se&&e.namespaceURI===We&&t===`style`&&xt(e.firstElementChild)||e.nodeType===gr.processingInstruction||Se&&e.nodeType===gr.comment&&K(pr,e.data))},Ct=function(e,t){if(!F[t]&&Dt(t)&&(P.tagNameCheck instanceof RegExp&&K(P.tagNameCheck,t)||P.tagNameCheck instanceof Function&&P.tagNameCheck(t)))return!1;if(Pe&&!Ie[t]){let t=g(e),n=h(e);if(n&&t){let r=n.length;for(let i=r-1;i>=0;--i){let r=Fe?n[i]:f(n[i],!0);t.insertBefore(r,m(e))}}}return B(e),!0},wt=function(e){if(V(A.beforeSanitizeElements,e,null),yt(e))return B(e),!0;let n=z(b?b(e):e.nodeName);if(V(A.uponSanitizeElement,e,{tagName:n,allowedTags:M}),St(e,n))return B(e),!0;if(F[n]||!(_e.tagCheck instanceof Function&&_e.tagCheck(n))&&!M[n])return Ct(e,n);if((y?y(e):e.nodeType)===gr.element&&!ut(e)||(n===`noscript`||n===`noembed`||n===`noframes`)&&K(mr,e.innerHTML))return B(e),!0;if(xe&&e.nodeType===gr.text){let n=_t(e.textContent);e.textContent!==n&&(Tn(t.removed,{element:e.cloneNode()}),e.textContent=n)}return V(A.afterSanitizeElements,e,null),!1},Tt=function(e,t,r){if(ge[t]||je&&(t===`id`||t===`name`)&&(r in n||r in nt))return!1;let i=N[t]||_e.attributeCheck instanceof Function&&_e.attributeCheck(t,e);if(!(ye&&K(ce,t))&&!(ve&&K(le,t))){if(!i){if(!(Dt(e)&&(P.tagNameCheck instanceof RegExp&&K(P.tagNameCheck,e)||P.tagNameCheck instanceof Function&&P.tagNameCheck(e))&&(P.attributeNameCheck instanceof RegExp&&K(P.attributeNameCheck,t)||P.attributeNameCheck instanceof Function&&P.attributeNameCheck(t,e))||t===`is`&&P.allowCustomizedBuiltInElements&&(P.tagNameCheck instanceof RegExp&&K(P.tagNameCheck,r)||P.tagNameCheck instanceof Function&&P.tagNameCheck(r))))return!1}else if(!Be[t]&&!K(pe,jn(r,de,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&Mn(r,`data:`)===0&&Re[e])&&!(I&&!K(ue,jn(r,de,``)))&&r)return!1}return!0},Et=J({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Dt=function(e){return!Et[On(e)]&&K(fe,e)},Ot=function(e,t,n,r){if(x&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return D(r);case`TrustedScriptURL`:return ee(r)}return r},kt=function(e,n,r,i){try{r?e.setAttributeNS(r,n,i):e.setAttribute(n,i),yt(e)?B(e):wn(t.removed)}catch{ft(n,e)}},At=function(e){V(A.beforeSanitizeAttributes,e,null);let t=e.attributes;if(!t||yt(e))return;let n={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:N,forceKeepAttr:void 0},r=t.length,i=z(e.nodeName);for(;r--;){let a=t[r],o=a.name,s=a.namespaceURI,c=a.value,l=z(o),u=c,d=o===`value`?u:Nn(u);if(n.attrName=l,n.attrValue=d,n.keepAttr=!0,n.forceKeepAttr=void 0,V(A.uponSanitizeAttribute,e,n),d=n.attrValue,Me&&(l===`id`||l===`name`)&&Mn(d,Ne)!==0&&(ft(o,e),d=Ne+d),Se&&K(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)){ft(o,e);continue}if(l===`attributename`&&An(d,`href`)){ft(o,e);continue}if(!n.forceKeepAttr){if(!n.keepAttr){ft(o,e);continue}if(!be&&K(hr,d)){ft(o,e);continue}if(xe&&(d=_t(d)),!Tt(i,l,d)){ft(o,e);continue}d=Ot(i,l,s,d),d!==u&&kt(e,o,s,d)}}V(A.afterSanitizeAttributes,e,null)},jt=function(e){let t=null,n=gt(e);for(V(A.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(V(A.uponSanitizeShadowNode,t,null),wt(t),At(t),bt(t.content)&&jt(t.content),(y?y(t):t.nodeType)===gr.element){let e=_(t);bt(e)&&(Mt(e),jt(e))}V(A.afterSanitizeShadowDOM,e,null)},Mt=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){jt(e.shadow);continue}let n=e.node,r=(y?y(n):n.nodeType)===gr.element,i=h(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=b?b(n):null;if(typeof e==`string`&&z(e)===`template`){let e=n.content;bt(e)&&t.push({node:e,shadow:null})}}if(r){let e=_(n);bt(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(Ke=!e,Ke&&(e=`<!-->`),typeof e!=`string`&&!xt(e)&&(e=Hn(e),typeof e!=`string`))throw zn(`dirty is not a string, aborting`);if(!t.isSupported)return e;we?(M=Te,N=Ee):it(n),(A.uponSanitizeElement.length>0||A.uponSanitizeAttribute.length>0)&&(M=Y(M)),A.uponSanitizeAttribute.length>0&&(N=Y(N)),t.removed=[];let c=Fe&&typeof e!=`string`&&xt(e);if(c){let t=b?b(e):e.nodeName;if(typeof t==`string`){let e=z(t);if(!M[e]||F[e])throw zn(`root node is forbidden and cannot be sanitized in-place`)}if(yt(e))throw zn(`root node is clobbered and cannot be sanitized in-place`);try{Mt(e)}catch(t){throw dt(e),t}}else if(xt(e))i=ht(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===gr.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),Mt(a);else{if(!Oe&&!xe&&!Ce&&e.indexOf(`<`)===-1)return x&&Ae?D(e):e;if(i=ht(e),!i)return Oe?null:Ae?S:``}i&&De&&B(i.firstChild);let l=gt(c?e:i);try{for(;o=l.nextNode();)wt(o),At(o),bt(o.content)&&jt(o.content)}catch(t){throw c&&dt(e),t}if(c)return Sn(t.removed,e=>{e.element&&mt(e.element)}),xe&&vt(e),e;if(Oe){if(xe&&vt(i),ke)for(s=re.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(N.shadowroot||N.shadowrootmode)&&(s=ae.call(r,s,!0)),s}let u=Ce?i.outerHTML:i.innerHTML;return Ce&&M[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&K(ur,i.ownerDocument.doctype.name)&&(u=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
5
- `+u),xe&&(u=_t(u)),x&&Ae?D(u):u},t.setConfig=function(){it(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}),we=!0,Te=M,Ee=N},t.clearConfig=function(){tt=null,we=!1,Te=null,Ee=null,x=C,S=``},t.isValidAttribute=function(e,t,n){return tt||it({}),Tt(z(e),z(t),n)},t.addHook=function(e,t){typeof t==`function`&&G(A,e)&&Tn(A[e],t)},t.removeHook=function(e,t){if(G(A,e)){if(t!==void 0){let n=Cn(A[e],t);return n===-1?void 0:En(A[e],n,1)[0]}return wn(A[e])}},t.removeHooks=function(e){G(A,e)&&(A[e]=[])},t.removeAllHooks=function(){A=yr()},t}var Sr=xr();function Cr(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var wr=Cr();function Tr(e){wr=e}var Er={exec:()=>null};function Dr(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function X(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(Z.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var Or=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),Z={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:Dr(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Dr(e=>RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:Dr(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:Dr(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:Dr(e=>RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,`i`)),blockquoteBeginRegex:Dr(e=>RegExp(`^ {0,${e}}>`))},kr=/^(?:[ \t]*(?:\n|$))+/,Ar=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,jr=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Mr=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Nr=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Pr=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Fr=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Ir=X(Fr).replace(/bull/g,Pr).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),Lr=X(Fr).replace(/bull/g,Pr).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Rr=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,zr=/^[^\n]+/,Br=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Vr=X(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,Br).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Hr=X(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Pr).getRegex(),Ur=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,Wr=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Gr=X(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,Wr).replace(`tag`,Ur).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Kr=X(Rr).replace(`hr`,Mr).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Ur).getRegex(),qr={blockquote:X(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Kr).getRegex(),code:Ar,def:Vr,fences:jr,heading:Nr,hr:Mr,html:Gr,lheading:Ir,list:Hr,newline:kr,paragraph:Kr,table:Er,text:zr},Jr=X(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,Mr).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Ur).getRegex(),Yr={...qr,lheading:Lr,table:Jr,paragraph:X(Rr).replace(`hr`,Mr).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,Jr).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Ur).getRegex()},Xr={...qr,html:X(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Wr).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Er,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:X(Rr).replace(`hr`,Mr).replace(`heading`,` *#{1,6} *[^
6
- ]`).replace(`lheading`,Ir).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},Zr=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Qr=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,$r=/^( {2,}|\\)\n(?!\s*$)/,ei=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,ti=/[\p{P}\p{S}]/u,ni=/[\s\p{P}\p{S}]/u,ri=/[^\s\p{P}\p{S}]/u,ii=X(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,ni).getRegex(),ai=/(?!~)[\p{P}\p{S}]/u,oi=/(?!~)[\s\p{P}\p{S}]/u,si=/(?:[^\s\p{P}\p{S}]|~)/u,ci=X(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,Or?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),li=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,ui=X(li,`u`).replace(/punct/g,ti).getRegex(),di=X(li,`u`).replace(/punct/g,ai).getRegex(),fi=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,pi=X(fi,`gu`).replace(/notPunctSpace/g,ri).replace(/punctSpace/g,ni).replace(/punct/g,ti).getRegex(),mi=X(fi,`gu`).replace(/notPunctSpace/g,si).replace(/punctSpace/g,oi).replace(/punct/g,ai).getRegex(),hi=X(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,ri).replace(/punctSpace/g,ni).replace(/punct/g,ti).getRegex(),gi=X(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,ti).getRegex(),_i=X(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,ri).replace(/punctSpace/g,ni).replace(/punct/g,ti).getRegex(),vi=X(/\\(punct)/,`gu`).replace(/punct/g,ti).getRegex(),yi=X(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),bi=X(Wr).replace(`(?:-->|$)`,`-->`).getRegex(),xi=X(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,bi).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Si=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Ci=X(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,Si).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),wi=X(/^!?\[(label)\]\[(ref)\]/).replace(`label`,Si).replace(`ref`,Br).getRegex(),Ti=X(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,Br).getRegex(),Ei=X(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,wi).replace(`nolink`,Ti).getRegex(),Di=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Oi={_backpedal:Er,anyPunctuation:vi,autolink:yi,blockSkip:ci,br:$r,code:Qr,del:Er,delLDelim:Er,delRDelim:Er,emStrongLDelim:ui,emStrongRDelimAst:pi,emStrongRDelimUnd:hi,escape:Zr,link:Ci,nolink:Ti,punctuation:ii,reflink:wi,reflinkSearch:Ei,tag:xi,text:ei,url:Er},ki={...Oi,link:X(/^!?\[(label)\]\((.*?)\)/).replace(`label`,Si).getRegex(),reflink:X(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,Si).getRegex()},Ai={...Oi,emStrongRDelimAst:mi,emStrongLDelim:di,delLDelim:gi,delRDelim:_i,url:X(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,Di).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:X(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,Di).getRegex()},ji={...Ai,br:X($r).replace(`{2,}`,`*`).getRegex(),text:X(Ai.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},Mi={normal:qr,gfm:Yr,pedantic:Xr},Ni={normal:Oi,gfm:Ai,breaks:ji,pedantic:ki},Pi={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},Fi=e=>Pi[e];function Ii(e,t){if(t){if(Z.escapeTest.test(e))return e.replace(Z.escapeReplace,Fi)}else if(Z.escapeTestNoEncode.test(e))return e.replace(Z.escapeReplaceNoEncode,Fi);return e}function Li(e){try{e=encodeURI(e).replace(Z.percentDecode,`%`)}catch{return null}return e}function Ri(e,t){let n=e.replace(Z.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(Z.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``);for(;r<n.length;r++)n[r]=n[r].trim().replace(Z.slashPipe,`|`);return n}function zi(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function Bi(e){let t=e.split(`
7
- `),n=t.length-1;for(;n>=0&&Z.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
8
- `)}function Vi(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function Hi(e,t=0){let n=t,r=``;for(let t of e)if(t===` `){let e=4-n%4;r+=` `.repeat(e),n+=e}else r+=t,n++;return r}function Ui(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`);r.state.inLink=!0;let c={type:e[0].charAt(0)===`!`?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,c}function Wi(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
9
- `).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return r.length>=i.length?e.slice(i.length):e}).join(`
10
- `)}var Gi=class{options;rules;lexer;constructor(e){this.options=e||wr}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=this.options.pedantic?t[0]:Bi(t[0]);return{type:`code`,raw:e,codeBlockStyle:`indented`,text:e.replace(this.rules.other.codeRemoveIndent,``)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=Wi(e,t[3]||``,this.rules);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=zi(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:zi(t[0],`
11
- `),depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:zi(t[0],`
12
- `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=zi(t[0],`
13
- `).split(`
14
- `),n=``,r=``,i=[];for(;e.length>0;){let t=!1,a=[],o;for(o=0;o<e.length;o++)if(this.rules.other.blockquoteStart.test(e[o]))a.push(e[o]),t=!0;else if(!t)a.push(e[o]);else break;e=e.slice(o);let s=a.join(`
15
- `),c=s.replace(this.rules.other.blockquoteSetextReplace,`
16
- $1`).replace(this.rules.other.blockquoteSetextReplace2,``);n=n?`${n}
17
- ${s}`:s,r=r?`${r}
18
- ${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(c,i,!0),this.lexer.state.top=l,e.length===0)break;let u=i.at(-1);if(u?.type===`code`)break;if(u?.type===`blockquote`){let t=u,a=t.raw+`
19
- `+e.join(`
20
- `),o=this.blockquote(a);i[i.length-1]=o,n=n.substring(0,n.length-t.raw.length)+o.raw,r=r.substring(0,r.length-t.text.length)+o.text;break}else if(u?.type===`list`){let t=u,a=t.raw+`
21
- `+e.join(`
22
- `),o=this.list(a);i[i.length-1]=o,n=n.substring(0,n.length-u.raw.length)+o.raw,r=r.substring(0,r.length-t.raw.length)+o.raw,e=a.substring(i.at(-1).raw.length).split(`
23
- `);continue}}return{type:`blockquote`,raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:`list`,raw:``,ordered:r,start:r?+n.slice(0,-1):``,loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:`[*+-]`);let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,r=``,s=``;if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let c=Hi(t[2].split(`
24
- `,1)[0],t[1].length),l=e.split(`
25
- `,1)[0],u=!c.trim(),d=0;if(this.options.pedantic?(d=2,s=c.trimStart()):u?d=t[1].length+1:(d=c.search(this.rules.other.nonSpaceChar),d=d>4?1:d,s=c.slice(d),d+=t[1].length),u&&this.rules.other.blankLine.test(l)&&(r+=l+`
26
- `,e=e.substring(l.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(d),n=this.rules.other.hrRegex(d),i=this.rules.other.fencesBeginRegex(d),a=this.rules.other.headingBeginRegex(d),o=this.rules.other.htmlBeginRegex(d),f=this.rules.other.blockquoteBeginRegex(d);for(;e;){let p=e.split(`
27
- `,1)[0],m;if(l=p,this.options.pedantic?(l=l.replace(this.rules.other.listReplaceNesting,` `),m=l):m=l.replace(this.rules.other.tabCharGlobal,` `),i.test(l)||a.test(l)||o.test(l)||f.test(l)||t.test(l)||n.test(l))break;if(m.search(this.rules.other.nonSpaceChar)>=d||!l.trim())s+=`
28
- `+m.slice(d);else{if(u||c.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||i.test(c)||a.test(c)||n.test(c))break;s+=`
29
- `+l}u=!l.trim(),r+=p+`
30
- `,e=e.substring(p.length+1),c=m.slice(d)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0)),i.items.push({type:`list_item`,raw:r,task:!!this.options.gfm&&this.rules.other.listIsTask.test(s),loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e of i.items){this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]);let t=e.tokens[0];if(e.task&&(t?.type===`text`||t?.type===`paragraph`)){e.text=e.text.replace(this.rules.other.listReplaceTask,``),t.raw=t.raw.replace(this.rules.other.listReplaceTask,``),t.text=t.text.replace(this.rules.other.listReplaceTask,``);for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,``);break}let n=this.rules.other.listTaskCheckbox.exec(e.raw);if(n){let t={type:`checkbox`,raw:n[0]+` `,checked:n[0]!==`[ ]`};e.checked=t.checked,i.loose?e.tokens[0]&&[`paragraph`,`text`].includes(e.tokens[0].type)&&`tokens`in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=t.raw+e.tokens[0].raw,e.tokens[0].text=t.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(t)):e.tokens.unshift({type:`paragraph`,raw:t.raw,text:t.raw,tokens:[t]}):e.tokens.unshift(t)}}else e.task&&=!1;if(!i.loose){let t=e.tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}}if(i.loose)for(let e of i.items){e.loose=!0;for(let t of e.tokens)t.type===`text`&&(t.type=`paragraph`)}return i}}html(e){let t=this.rules.block.html.exec(e);if(t){let e=Bi(t[0]);return{type:`html`,block:!0,raw:e,pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:e}}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal,` `),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:zi(t[0],`
31
- `),href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Ri(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
32
- `):[],a={type:`table`,raw:zi(t[0],`
33
- `),header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(Ri(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let e=t[1].trim();return{type:`heading`,raw:zi(t[0],`
34
- `),depth:t[2].charAt(0)===`=`?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
35
- `?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=zi(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=Vi(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let n=t[2],r=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):``;return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),Ui(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,`$1`),title:r&&r.replace(this.rules.inline.anyPunctuation,`$1`)},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `).toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return Ui(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=0,c=r[0][0]===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+n);(r=c.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=[...i].length,r[3]||r[4]){o+=a;continue}else if((r[5]||r[6])&&n%3&&!((n+a)%3)){s+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+s);let t=[...r[0]][0].length,c=e.slice(0,n+r.index+t+a);if(Math.min(n,a)%2){let e=c.slice(1,-1);return{type:`em`,raw:c,text:e,tokens:this.lexer.inlineTokens(e)}}let l=c.slice(2,-2);return{type:`strong`,raw:c,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e,t,n=``){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=this.rules.inline.delRDelim;for(s.lastIndex=0,t=t.slice(-1*e.length+n);(r=s.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(a=[...i].length,a!==n))continue;if(r[3]||r[4]){o+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o);let t=[...r[0]][0].length,s=e.slice(0,n+r.index+t+a),c=s.slice(n,-n);return{type:`del`,raw:s,text:c,tokens:this.lexer.inlineTokens(c)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:t[0],escaped:e}}}},Ki=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||wr,this.options.tokenizer=this.options.tokenizer||new Gi,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:Z,block:Mi.normal,inline:Ni.normal};this.options.pedantic?(t.block=Mi.pedantic,t.inline=Ni.pedantic):this.options.gfm&&(t.block=Mi.gfm,this.options.breaks?t.inline=Ni.breaks:t.inline=Ni.gfm),this.tokenizer.rules=t}static get rules(){return{block:Mi,inline:Ni}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(Z.carriageReturn,`
36
- `),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(Z.tabCharGlobal,` `).replace(Z.spaceLine,``));let r=1/0;for(;e;){if(e.length<r)r=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let i;if(this.options.extensions?.block?.some(n=>(i=n.call({lexer:this},e,t))?(e=e.substring(i.raw.length),t.push(i),!0):!1))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let n=t.at(-1);i.raw.length===1&&n!==void 0?n.raw+=`
37
- `:t.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
38
- `)?``:`
39
- `)+i.raw,n.text+=`
40
- `+i.text,this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(i=this.tokenizer.fences(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.heading(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.hr(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.blockquote(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.list(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.html(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
41
- `)?``:`
42
- `)+i.raw,n.text+=`
43
- `+i.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},t.push(i));continue}if(i=this.tokenizer.table(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.lheading(e)){e=e.substring(i.raw.length),t.push(i);continue}let a=e;if(this.options.extensions?.startBlock){let t=1/0,n=e.slice(1),r;this.options.extensions.startBlock.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(a=e.substring(0,t+1))}if(this.state.top&&(i=this.tokenizer.paragraph(a))){let r=t.at(-1);n&&r?.type===`paragraph`?(r.raw+=(r.raw.endsWith(`
44
- `)?``:`
45
- `)+i.raw,r.text+=`
46
- `+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(i),n=a.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`text`?(n.raw+=(n.raw.endsWith(`
47
- `)?``:`
48
- `)+i.raw,n.text+=`
49
- `+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n=e,r=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!==null;)e.includes(r[0].slice(r[0].lastIndexOf(`[`)+1,-1))&&(n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!==null;)n=n.slice(0,r.index)+`++`+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!==null;)i=r[2]?r[2].length:0,n=n.slice(0,r.index+i)+`[`+`a`.repeat(r[0].length-i-2)+`]`+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let a=!1,o=``,s=1/0;for(;e;){if(e.length<s)s=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}a||(o=``),a=!1;let r;if(this.options.extensions?.inline?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length);let n=t.at(-1);r.type===`text`&&n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(r=this.tokenizer.emStrong(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.del(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.autolink(e)){e=e.substring(r.raw.length),t.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e))){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(r=this.tokenizer.inlineText(i)){e=e.substring(r.raw.length),r.raw.slice(-1)!==`_`&&(o=r.raw.slice(-1)),a=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return t}infiniteLoopError(e){let t=`Infinite loop on byte: `+e;if(this.options.silent)console.error(t);else throw Error(t)}},qi=class{options;parser;constructor(e){this.options=e||wr}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(Z.notSpaceStart)?.[0],i=e.replace(Z.endingNewline,``)+`
50
- `;return r?`<pre><code class="language-`+Ii(r)+`">`+(n?i:Ii(i,!0))+`</code></pre>
51
- `:`<pre><code>`+(n?i:Ii(i,!0))+`</code></pre>
52
- `}blockquote({tokens:e}){return`<blockquote>
53
- ${this.parser.parse(e)}</blockquote>
54
- `}html({text:e}){return e}def(e){return``}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
55
- `}hr(e){return`<hr>
56
- `}list(e){let t=e.ordered,n=e.start,r=``;for(let t=0;t<e.items.length;t++){let n=e.items[t];r+=this.listitem(n)}let i=t?`ol`:`ul`,a=t&&n!==1?` start="`+n+`"`:``;return`<`+i+a+`>
57
- `+r+`</`+i+`>
58
- `}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
59
- `}checkbox({checked:e}){return`<input `+(e?`checked="" `:``)+`disabled="" type="checkbox"> `}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
60
- `}table(e){let t=``,n=``;for(let t=0;t<e.header.length;t++)n+=this.tablecell(e.header[t]);t+=this.tablerow({text:n});let r=``;for(let t=0;t<e.rows.length;t++){let i=e.rows[t];n=``;for(let e=0;e<i.length;e++)n+=this.tablecell(i[e]);r+=this.tablerow({text:n})}return r&&=`<tbody>${r}</tbody>`,`<table>
61
- <thead>
62
- `+t+`</thead>
63
- `+r+`</table>
64
- `}tablerow({text:e}){return`<tr>
65
- ${e}</tr>
66
- `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
67
- `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${Ii(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=Li(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+Ii(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=Li(e);if(i===null)return Ii(n);e=i;let a=`<img src="${e}" alt="${Ii(n)}"`;return t&&(a+=` title="${Ii(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:Ii(e.text)}},Ji=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},Yi=class e{options;renderer;textRenderer;constructor(e){this.options=e||wr,this.options.renderer=this.options.renderer||new qi,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Ji}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},Xi=class{options;block;constructor(e){this.options=e||wr}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?Ki.lex:Ki.lexInline}provideParser(e=this.block){return e?Yi.parse:Yi.parseInline}},Zi=new class{defaults=Cr();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Yi;Renderer=qi;TextRenderer=Ji;Lexer=Ki;Tokenizer=Gi;Hooks=Xi;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new qi(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new Gi(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new Xi;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];Xi.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&Xi.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:t[r]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Ki.lex(e,t??this.defaults)}parser(e,t){return Yi.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?Ki.lex:Ki.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?Yi.parse:Yi.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?Ki.lex:Ki.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?Yi.parse:Yi.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
68
- Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+Ii(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function Q(e,t){return Zi.parse(e,t)}Q.options=Q.setOptions=function(e){return Zi.setOptions(e),Q.defaults=Zi.defaults,Tr(Q.defaults),Q},Q.getDefaults=Cr,Q.defaults=wr,Q.use=function(...e){return Zi.use(...e),Q.defaults=Zi.defaults,Tr(Q.defaults),Q},Q.walkTokens=function(e,t){return Zi.walkTokens(e,t)},Q.parseInline=Zi.parseInline,Q.Parser=Yi,Q.parser=Yi.parse,Q.Renderer=qi,Q.TextRenderer=Ji,Q.Lexer=Ki,Q.lexer=Ki.lex,Q.Tokenizer=Gi,Q.Hooks=Xi,Q.parse=Q,Q.options,Q.setOptions,Q.use,Q.walkTokens,Q.parseInline,Yi.parse,Ki.lex;var Qi=!1;function $i(){Qi||=(Q.setOptions({breaks:!0,gfm:!0}),Sr.addHook(`afterSanitizeAttributes`,e=>{e.nodeName===`A`&&(e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`))}),!0)}function ea(e,t){if(!e)return``;if(!t||typeof window>`u`)return ta(e);try{$i();let t=Q.parse(e,{async:!1});return Sr.sanitize(t)}catch{return ta(e)}}function ta(e){return String(e).replaceAll(`&`,`&amp;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`)}var $=a(),na=e=>e?e.slice(0,7):`no commit`;function ra({changes:e,base:t,loading:n,onBase:r,onRefresh:i}){let[a,o]=(0,H.useState)(!1),[s,c]=(0,H.useState)(t),l=e?.identity,u=l?l.headState===`detached`?`detached at ${na(l.head)}`:l.branch??`unknown branch`:``;return a?(0,$.jsxs)(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),r(s.trim()),o(!1)},children:[(0,$.jsx)(`input`,{autoFocus:!0,"aria-label":`Comparison base`,placeholder:`HEAD, main, HEAD~1, a commit…`,value:s,onChange:e=>c(e.target.value),className:`min-h-9 min-w-0 flex-1 basis-40 py-1.5 font-mono text-xs`}),(0,$.jsx)(f,{variant:`primary`,type:`submit`,className:`min-h-9 px-3 py-1 text-xs`,children:`Compare`}),(0,$.jsx)(f,{variant:`ghost`,className:`min-h-9 px-3 py-1 text-xs`,onClick:()=>o(!1),children:`Cancel`}),(0,$.jsx)(`p`,{className:`m-0 basis-full text-xs text-muted-foreground`,children:`A branch name is pinned to its commit when the review loads. Empty means HEAD: what is not committed yet.`})]}):(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-xs`,children:[(0,$.jsx)(zt,{className:`size-3.5 shrink-0 text-mocha`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`min-w-0 truncate font-mono text-foreground`,title:u,children:u||`…`}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{c(t),o(!0)},title:`Change the comparison base`,className:`unstyled shrink-0 rounded-full border border-border bg-card px-2 py-0.5 font-mono text-mocha hover:border-sapphire-light hover:text-sapphire`,children:[`since `,e?e.base.requestedRef:t||`HEAD`,e?` (${na(e.base.resolvedOid)})`:``]}),(0,$.jsx)(`button`,{type:`button`,onClick:i,"aria-label":`Refresh the changes`,title:`Refresh`,className:`unstyled ml-auto flex size-7 shrink-0 items-center justify-center rounded-lg text-mocha hover:bg-muted hover:text-sapphire`,children:(0,$.jsx)(Xt,{className:`size-3.5 ${n?`animate-spin`:``}`,"aria-hidden":`true`})})]})}var ia=1500,aa=`select-none px-2 text-right text-xs leading-[1.6] text-mocha-light tabular-nums`,oa=`whitespace-pre-wrap px-2 leading-[1.6] [overflow-wrap:anywhere]`;function sa({line:e,active:t,onClick:n}){return n?(0,$.jsxs)(`button`,{type:`button`,onClick:n,title:`Comment on line ${e}`,"aria-label":`Comment on line ${e}`,className:`unstyled group/line relative ${aa} hover:bg-primary hover:text-primary-foreground ${t?`bg-primary text-primary-foreground`:``}`,children:[(0,$.jsx)(`span`,{className:`group-hover/line:invisible`,children:e}),(0,$.jsx)(qe,{className:`invisible absolute right-1.5 top-1/2 size-3.5 -translate-y-1/2 group-hover/line:visible`,"aria-hidden":`true`})]}):(0,$.jsx)(`span`,{className:aa,children:e})}function ca({line:e,onAdd:t,onCancel:n}){let[r,i]=(0,H.useState)(``),a=()=>{r.trim()&&t(r.trim())};return(0,$.jsxs)(`div`,{className:`border-y border-primary/30 bg-accent/40 px-3 py-2.5 font-body`,children:[(0,$.jsx)(`textarea`,{autoFocus:!0,"aria-label":`Comment on line ${e}`,placeholder:`What should change on line ${e}?`,rows:2,maxLength:2e3,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Escape`&&n(),e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&a()},className:`min-h-16 text-sm`}),(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(f,{variant:`primary`,className:`min-h-8 px-3 py-1 text-xs`,disabled:!r.trim(),onClick:a,children:`Add to the review`}),(0,$.jsx)(f,{variant:`ghost`,className:`min-h-8 px-3 py-1 text-xs`,onClick:n,children:`Cancel`})]})]})}function la({comments:e,onRemove:t}){return(0,$.jsx)(`div`,{className:`space-y-1.5 border-y border-primary/25 bg-accent/30 px-3 py-2 font-body`,children:e.map(e=>(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-[10px] border border-border bg-card px-2.5 py-1.5 text-sm`,children:[(0,$.jsx)(`p`,{className:`m-0 min-w-0 flex-1 whitespace-pre-wrap break-words text-chocolate`,children:e.note}),t&&(0,$.jsx)(`button`,{type:`button`,"aria-label":`Remove this comment`,onClick:()=>t(e.id),className:`unstyled flex size-6 shrink-0 items-center justify-center rounded-md text-mocha hover:bg-muted hover:text-danger`,children:(0,$.jsx)(O,{className:`size-3.5`,"aria-hidden":`true`})})]},e.id))})}function ua({comments:e,onAddComment:t,onRemoveComment:n}){let[r,i]=(0,H.useState)(null),a=(0,H.useMemo)(()=>{let t=new Map;for(let n of e)n.line!==void 0&&t.set(n.line,[...t.get(n.line)??[],n]);return t},[e]);return{composing:r,under:e=>{if(e===void 0)return null;let o=a.get(e);return!o&&r!==e?null:(0,$.jsxs)(`div`,{className:`col-span-full`,children:[o&&(0,$.jsx)(la,{comments:o,onRemove:n}),r===e&&t&&(0,$.jsx)(ca,{line:e,onAdd:n=>{t(e,n),i(null)},onCancel:()=>i(null)})]})},startOn:t?e=>()=>i(t=>t===e?null:e):()=>void 0}}function da({hidden:e,onShow:t}){return e<=0?null:(0,$.jsx)(`div`,{className:`col-span-full border-t border-frost/70 px-3 py-2 font-body`,children:(0,$.jsxs)(f,{variant:`ghost`,className:`min-h-8 px-3 py-1 text-xs`,onClick:t,children:[`Show `,e.toLocaleString(),` more line`,e===1?``:`s`]})})}var fa=`col-span-full bg-accent/50 px-3 py-0.5 text-xs text-accent-foreground`,pa=`col-span-full px-3 py-0.5 font-body text-xs italic text-mocha-light`;function ma(e){let t=(0,H.useMemo)(()=>tn(e.patch).lines,[e.patch]),[n,r]=(0,H.useState)(!1),{composing:i,under:a,startOn:o}=ua(e),s=n?t:t.slice(0,ia);return(0,$.jsxs)(`div`,{className:`grid grid-cols-[2.6rem_2.6rem_minmax(0,1fr)] font-mono text-xs text-chocolate`,children:[s.map((e,t)=>{if(e.kind===`hunk`)return(0,$.jsx)(`div`,{className:fa,children:e.text},t);if(e.kind===`note`)return(0,$.jsx)(`div`,{className:pa,children:e.text},t);let n=e.kind===`add`?`bg-success/[0.13]`:e.kind===`remove`?`bg-danger/[0.13]`:``,r=e.kind===`add`?`bg-success/20`:e.kind===`remove`?`bg-danger/20`:`bg-muted/60`,s=e.kind===`remove`?void 0:e.newLine;return(0,$.jsxs)(H.Fragment,{children:[(0,$.jsx)(`span`,{className:`${aa} ${r}`,children:e.kind===`add`?``:e.oldLine}),s===void 0?(0,$.jsx)(`span`,{className:`${aa} ${r}`}):(0,$.jsx)(`span`,{className:`grid ${r}`,children:(0,$.jsx)(sa,{line:s,active:i===s,onClick:o(s)})}),(0,$.jsxs)(`span`,{className:`${oa} ${n}`,children:[(0,$.jsx)(`span`,{className:`select-none text-mocha-light`,children:e.kind===`add`?`+`:e.kind===`remove`?`−`:` `}),e.text]}),a(s)]},t)}),(0,$.jsx)(da,{hidden:t.length-s.length,onShow:()=>r(!0)})]})}function ha(e){let t=(0,H.useMemo)(()=>nn(tn(e.patch).lines),[e.patch]),[n,r]=(0,H.useState)(!1),{composing:i,under:a,startOn:o}=ua(e),s=n?t:t.slice(0,ia);return(0,$.jsxs)(`div`,{className:`grid grid-cols-[2.8rem_minmax(0,1fr)_2.8rem_minmax(0,1fr)] font-mono text-xs text-chocolate`,children:[s.map((e,t)=>{if(e.kind===`hunk`)return(0,$.jsx)(`div`,{className:fa,children:e.text},t);if(e.kind===`note`)return(0,$.jsx)(`div`,{className:pa,children:e.text},t);let{left:n,right:r}=e,s=n?.changed?`bg-danger/[0.13]`:n?``:`bg-muted/50`,c=r?.changed?`bg-success/[0.13]`:r?``:`bg-muted/50`;return(0,$.jsxs)(H.Fragment,{children:[(0,$.jsx)(`span`,{className:`${aa} ${n?.changed?`bg-danger/20`:`bg-muted/60`}`,children:n?.line}),(0,$.jsx)(`span`,{className:`${oa} border-r border-frost/70 ${s}`,children:n?.text}),r?(0,$.jsx)(`span`,{className:`grid ${r.changed?`bg-success/20`:`bg-muted/60`}`,children:(0,$.jsx)(sa,{line:r.line,active:i===r.line,onClick:o(r.line)})}):(0,$.jsx)(`span`,{className:`${aa} bg-muted/60`}),(0,$.jsx)(`span`,{className:`${oa} ${c}`,children:r?.text}),a(r?.line)]},t)}),(0,$.jsx)(da,{hidden:t.length-s.length,onShow:()=>r(!0)})]})}var ga={base:``,comments:[],note:``},_a=(0,H.createContext)(null);function va({children:e}){let[t,n]=(0,H.useState)({}),r=(0,H.useRef)(0),i=(0,H.useCallback)((e,t)=>{n(n=>({...n,[e]:t(n[e]??ga)}))},[]),a=(0,H.useCallback)(()=>++r.current,[]),o=(0,H.useMemo)(()=>({sessions:t,update:i,nextId:a}),[t,i,a]);return(0,$.jsx)(_a.Provider,{value:o,children:e})}function ya(e){let t=(0,H.useContext)(_a);if(!t)throw Error(`useReviewSession needs a ReviewProvider`);let{sessions:n,update:r,nextId:i}=t,a=n[e]??ga;return(0,H.useMemo)(()=>({...a,setBase:t=>r(e,e=>({...e,base:t})),setNote:t=>r(e,e=>({...e,note:t})),addComment:t=>r(e,e=>({...e,comments:[...e.comments,{...t,id:i()}]})),removeComment:t=>r(e,e=>({...e,comments:e.comments.filter(e=>e.id!==t)})),clear:()=>r(e,e=>({...e,comments:[],note:``}))}),[a,e,r,i])}function ba(e,t){let n=new URLSearchParams(t).toString();return`/api/teams/${encodeURIComponent(e)}/review${n?`?${n}`:``}`}function xa(e,n){let{turnsEnded:r}=B();return V(async r=>{try{return{review:await t(ba(e,{authors:`1`,...n?{base:n}:{}}),{signal:r}),unavailable:null}}catch(e){if(!(e instanceof o)||r.aborted)throw e;return{review:null,unavailable:{code:e.code,message:l(e)}}}},[e,n,r])}function Sa(e,n,r,i){return V(async i=>{if(!r)return null;let a=(await t(ba(e,{patches:`1`,path:r,...n?{base:n}:{}}),{signal:i})).changes.changes.find(e=>e.path===r);return{path:r,patch:a?.patch??null,truncated:a?.patchTruncated??!1,omitted:a?.contentOmitted??null}},[e,n,r,i])}var Ca={added:`A`,modified:`M`,deleted:`D`,renamed:`R`,copied:`C`,type_changed:`T`,unmerged:`U`,untracked:`N`,unknown:`?`},wa={added:`bg-success/15 text-success`,untracked:`bg-success/15 text-success`,copied:`bg-success/15 text-success`,modified:`bg-accent text-accent-foreground`,renamed:`bg-accent text-accent-foreground`,type_changed:`bg-accent text-accent-foreground`,deleted:`bg-danger/15 text-danger`,unmerged:`bg-warning/15 text-warning`,unknown:`bg-frost text-mocha`};function Ta({status:e}){return(0,$.jsx)(`span`,{className:`inline-flex size-[18px] shrink-0 items-center justify-center rounded font-mono text-xs font-semibold ${wa[e]}`,"aria-hidden":`true`,children:Ca[e]})}function Ea(e){let t=e.lastIndexOf(`/`);return t<0?{dir:``,name:e}:{dir:e.slice(0,t+1),name:e.slice(t+1)}}function Da(e){return e.excludedReason?(0,$.jsx)(`span`,{className:`text-xs text-mocha`,children:`withheld`}):e.binary?(0,$.jsx)(`span`,{className:`text-xs text-mocha`,children:`binary`}):(0,$.jsxs)(`span`,{className:`flex shrink-0 gap-1.5 font-mono text-xs font-medium`,children:[e.addedLines?(0,$.jsxs)(`span`,{className:`text-success`,children:[`+`,e.addedLines]}):null,e.deletedLines?(0,$.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.deletedLines]}):null]})}function Oa({changes:e,authors:t,comments:n,selected:r,onSelect:i}){let{agentById:a}=I();return e.changes.length===0?(0,$.jsx)(`p`,{className:`m-0 rounded-2xl border border-dashed border-border bg-muted/40 px-3 py-4 text-sm text-muted-foreground`,children:`Nothing changed since this base.`}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`ul`,{className:`m-0 list-none divide-y divide-frost/70 overflow-hidden rounded-2xl border border-border p-0`,children:e.changes.map(e=>{let{dir:o,name:s}=Ea(e.path),c=t[e.path],l=n.filter(t=>t.path===e.path).length,u=e.path===r;return(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,"aria-current":u?`true`:void 0,onClick:()=>i(e.path),title:`${e.previousPath?`${e.previousPath} → `:``}${e.path} · ${an(e)}`,className:`unstyled flex min-h-10 w-full items-center gap-2 px-2.5 py-1.5 text-left hover:bg-accent/50 ${u?`bg-accent/60`:``}`,children:[(0,$.jsx)(Ta,{status:e.status}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:[(0,$.jsx)(`span`,{className:`text-mocha-light`,children:o}),(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:s})]}),l>0&&(0,$.jsxs)(`span`,{className:`flex shrink-0 items-center gap-0.5 text-xs font-semibold text-accent-foreground`,children:[(0,$.jsx)(De,{className:`size-3`,"aria-hidden":`true`}),l]}),Da(e),c&&(0,$.jsxs)(`span`,{title:`Last written by ${c.agentName}`,className:`shrink-0`,children:[(0,$.jsx)(R,{identity:a(c.agentId)?.identity,size:18}),(0,$.jsxs)(`span`,{className:`sr-only`,children:[`Last written by `,c.agentName]})]})]})},`${e.status}:${e.path}`)})}),e.truncated&&(0,$.jsx)(`p`,{className:`m-0 mt-2 text-xs text-warning`,children:`This list is incomplete: more files changed than a review shows.`}),(e.withheld.excluded>0||e.withheld.untracked>0)&&(0,$.jsxs)(`p`,{className:`m-0 mt-2 text-xs text-muted-foreground`,children:[`Not shown: `,e.withheld.excluded,` excluded and `,e.withheld.untracked,` untracked path`,e.withheld.excluded+e.withheld.untracked===1?``:`s`,`.`]}),e.issues.map(e=>(0,$.jsx)(`p`,{className:`m-0 mt-2 text-xs text-muted-foreground`,children:e.message},`${e.code}:${e.message}`))]})}var ka=20;function Aa(e,t,n,r){let i=new Map;for(let n of e.comments){let e=t[n.path]?.agentId;e&&i.set(e,(i.get(e)??0)+1)}let a=[...i].sort((e,t)=>t[1]-e[1])[0]?.[0],o=e=>n.some(t=>t.id===e);return o(a)?a:o(r)?r:n[0]?.id??``}function ja({teamId:e,session:r,authors:i,onOpenFile:a}){let{agents:s,agent:c,to:u}=I(),d=B(),p=s.filter(t=>t.teamId===e),[m,h]=(0,H.useState)(null),g=(0,H.useId)(),[_,v]=(0,H.useState)(!1),[y,b]=(0,H.useState)(``),[x,S]=(0,H.useState)(null),C=Aa(r,i,p,c?.agent.id),w=m&&p.some(e=>e.id===m)?m:C,T=r.comments.length;async function E(){v(!0),b(``);try{let n={agentId:w,comments:r.comments.map(({path:e,line:t,note:n})=>({path:e,...t===void 0?{}:{line:t},...n?{note:n}:{}})),...r.note.trim()?{note:r.note.trim()}:{},...r.base?{base:r.base}:{}};S({agentId:w,message:(await t(`/api/teams/${encodeURIComponent(e)}/review/feedback`,{body:n})).message}),r.clear(),d.refresh()}catch(e){b(on(e instanceof o?e.code:void 0,l(e)))}finally{v(!1)}}if(T===0){let e=x?p.find(e=>e.id===x.agentId):void 0;return x?(0,$.jsxs)(`div`,{role:`status`,className:`rounded-2xl border border-success/30 bg-success/[0.08] px-3 py-2.5 text-sm`,children:[(0,$.jsxs)(`p`,{className:`m-0 font-semibold text-foreground`,children:[`Sent to `,e?.name??`the Agent`,`. It runs the review as its next turn.`]}),(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[e&&(0,$.jsx)(n,{to:`/`,search:u({agent:e.id,view:void 0,file:void 0}),className:`ghost-btn min-h-8 px-3 py-1 text-xs`,children:`Open the conversation`}),(0,$.jsx)(f,{variant:`ghost`,className:`min-h-8 px-3 py-1 text-xs`,onClick:()=>S(null),children:`Dismiss`})]}),(0,$.jsxs)(`details`,{className:`mt-2`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-xs text-mocha`,children:`The message it received`}),(0,$.jsx)(`pre`,{className:`m-0 mt-1.5 max-h-56 overflow-auto whitespace-pre-wrap break-words rounded-[10px] bg-card p-2.5 font-mono text-xs`,children:x.message})]})]}):(0,$.jsx)(`p`,{className:`m-0 rounded-2xl border border-dashed border-border bg-muted/40 px-3 py-3 text-sm text-muted-foreground`,children:`No comments yet. Click a line number in a diff, or comment on a whole file. The comments go to one Agent together.`})}return(0,$.jsxs)(`div`,{className:`rounded-2xl border border-primary/25 bg-accent/25 p-3`,children:[(0,$.jsxs)(`p`,{className:`m-0 text-sm font-semibold text-foreground`,children:[`Your review · `,T,` comment`,T===1?``:`s`]}),(0,$.jsx)(`ul`,{className:`m-0 mt-2 list-none space-y-1.5 p-0`,children:r.comments.map(e=>{let{name:t}=Ea(e.path);return(0,$.jsxs)(`li`,{className:`flex items-start gap-2 rounded-[10px] border border-border bg-card px-2.5 py-1.5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>a?.(e.path),title:e.path,className:`unstyled block max-w-full truncate font-mono text-xs font-medium text-accent-foreground hover:underline`,children:[t,e.line===void 0?``:`:${e.line}`]}),(0,$.jsx)(`p`,{className:`m-0 mt-0.5 line-clamp-3 whitespace-pre-wrap break-words text-xs text-chocolate`,children:e.note||`No note: the Agent gets the file and its diff.`})]}),(0,$.jsx)(`button`,{type:`button`,"aria-label":`Remove this comment`,onClick:()=>r.removeComment(e.id),className:`unstyled flex size-6 shrink-0 items-center justify-center rounded-md text-mocha hover:bg-muted hover:text-danger`,children:(0,$.jsx)(O,{className:`size-3.5`,"aria-hidden":`true`})})]},e.id)})}),(0,$.jsxs)(`label`,{className:`mb-0 mt-2.5 text-xs`,children:[`About the review as a whole (optional)`,(0,$.jsx)(`textarea`,{rows:2,maxLength:2e3,value:r.note,onChange:e=>r.setNote(e.target.value),className:`min-h-14 text-sm`})]}),(0,$.jsxs)(`div`,{className:`mt-2.5 flex flex-wrap items-end gap-2`,children:[(0,$.jsxs)(`div`,{className:`m-0 min-w-0 flex-1 basis-40 text-xs`,children:[(0,$.jsx)(`span`,{id:g,className:`mb-1 block`,children:`Send to`}),(0,$.jsx)(ze,{labelledBy:g,value:w,options:p.map(e=>({value:e.id,label:e.name,hint:e.id===C&&r.comments.some(t=>i[t.path]?.agentId===e.id)?`wrote these files`:void 0})),onChange:h})]}),(0,$.jsx)(f,{variant:`primary`,disabled:_||!w||T>ka,onClick:()=>void E(),children:_?`Sending…`:`Send review`})]}),T>ka&&(0,$.jsxs)(`p`,{className:`m-0 mt-2 text-xs text-danger`,children:[`A review takes `,ka,` comments at most: remove `,T-ka,`.`]}),p.length===0&&(0,$.jsx)(`p`,{className:`m-0 mt-2 text-xs text-danger`,children:`This Team has no Agent to send a review to.`}),y&&(0,$.jsx)(`p`,{role:`alert`,className:`m-0 mt-2 text-xs text-danger`,children:y})]})}function Ma(e){let{turnsEnded:n}=B();return V(async n=>{if(!e)return{changes:null,files:null};let r=encodeURIComponent(e),[i,a]=await Promise.all([t(`/api/teams/${r}/review`,{signal:n}).then(e=>e.changes.changes.length).catch(()=>null),t(`/api/results?teamId=${r}&limit=1`,{signal:n}).then(e=>e.total).catch(()=>null)]);return{changes:i,files:a}},[e,n]).data??{changes:null,files:null}}function Na({agent:e}){let n=i(),r=V(e=>t(He,{signal:e}),[]),[a,o]=(0,H.useState)({model:e.agent.modelOverride??``,reasoning:e.reasoningLevel}),[s,c]=(0,H.useState)(!1),[u,d]=(0,H.useState)(null),[p,m]=(0,H.useState)(null);async function h(r,i){let s=a;o(r),c(!0),m(null);try{await t(`/api/agents/${encodeURIComponent(e.agent.id)}`,{method:`PATCH`,body:{modelOverride:r.model||null,reasoningLevel:r.reasoning}}),await n.invalidate({sync:!0}),d(i?{before:s,what:i}:null)}catch(e){o(s),m(l(e))}finally{c(!1)}}let g=e=>{if(e===``)return`the template’s model`;let t=r.data?.chat.find(t=>t.value===e);return t?Le(t):e};return(0,$.jsxs)(`div`,{className:`grid gap-3`,children:[(0,$.jsx)(Ue,{kit:!0,disabled:s,label:`Model`,value:a.model,onChange:e=>{e!==a.model&&h({...a,model:e},`Model set to ${g(e)}`)},models:r.data?.chat??[],inherited:{label:`The template’s model`,model:e.profile.defaultModel}}),(0,$.jsx)(Be,{label:`Reasoning`,value:a.reasoning,options:Ye.map(e=>({value:e,label:e})),disabled:s,className:`max-w-none`,onChange:e=>{e!==a.reasoning&&h({...a,reasoning:e},`Reasoning set to ${e}`)}}),(0,$.jsx)(`p`,{role:`status`,className:`m-0 flex min-h-8 flex-wrap items-center gap-x-2 text-sm ${p?`text-warning`:`text-success`}`,children:p?`Not saved: ${p}`:s?(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`Saving…`}):u?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{children:[u.what,`. It applies from the next turn.`]}),(0,$.jsx)(f,{variant:`ghost`,onClick:()=>void h(u.before,null),children:`Undo`})]}):(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`Changes apply from the next turn.`})}),r.error&&(0,$.jsxs)(`p`,{role:`alert`,className:`m-0 text-sm text-warning`,children:[`The models could not be loaded: `,r.error]})]})}function Pa({value:e,className:t,ariaLabel:n=`Copy to clipboard`,title:r=`Copy to clipboard`}){let[i,a]=(0,H.useState)(!1);async function o(){if(!e)return;let t=!1;try{navigator.clipboard?.writeText&&(await navigator.clipboard.writeText(e),t=!0)}catch{}if(!t){let n=document.createElement(`textarea`);n.value=e,n.setAttribute(`readonly`,``),n.style.position=`fixed`,n.style.opacity=`0`,document.body.appendChild(n),n.select();try{t=document.execCommand(`copy`)}catch{}n.remove()}t&&(a(!0),setTimeout(()=>a(!1),1e3))}return(0,$.jsx)(`button`,{type:`button`,onClick:o,title:r,"aria-label":n,className:`inline-flex h-[1.3rem] w-[1.6rem] items-center justify-center rounded-sm border border-transparent text-mocha-light transition-colors hover:border-frost hover:bg-snow hover:text-mocha ${i?`border-[#bcd9bc] bg-[#eef7ee] text-[#3b7a3b] hover:border-[#bcd9bc] hover:bg-[#eef7ee] hover:text-[#3b7a3b]`:``} ${t??``}`,children:i?`✓`:`⧉`})}var Fa=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`;function Ia({agent:e}){let{agent:r}=e,{teams:a,to:o,search:s}=I(),c=B(),u=i(),d=St(),[p,m]=(0,H.useState)(!1),[h,g]=(0,H.useState)(null),[_,v]=(0,H.useState)(null),y=r.status===`archived`,b=`/api/agents/${encodeURIComponent(r.id)}`,x=c.stateOf(r.id),S=c.byAgent.get(r.id)?.lastActivityAt??null,C=V(async e=>{let[n,r,i]=await Promise.all([t(`${b}/triggers`,{signal:e}),t(`${b}/lesson-proposals`,{signal:e}),t(`${b}/messages?unread=1`,{signal:e})]);return{schedules:n.triggers.filter(e=>e.enabled).length,schedulesOff:n.triggers.filter(e=>!e.enabled).length,proposals:r.proposals.filter(e=>e.status===`pending`).length,unread:i.messages.length}},[b,c.turnsEnded,s.section]),w=V(e=>t(`/api/config/telegram`,{signal:e}).catch(()=>({configured:!1})),[]);async function T(){v(null);try{await Tt(r.id),await u.invalidate()}catch(e){v(l(e))}}let E=C.data,D=[{section:`schedules`,icon:Ft,label:`Schedules`,detail:E?E.schedules+E.schedulesOff===0?`None`:`${E.schedules} on${E.schedulesOff?`, ${E.schedulesOff} off`:``}`:``},{section:`learning`,icon:Nt,label:`Learning`,detail:E?.proposals?`${Fa(E.proposals,`lesson`)} to review`:e.privateLessons.length?`${Fa(e.privateLessons.length,`lesson`)} applied`:r.reviewEnabled?`Reviews every ${r.reviewEveryNTurns} turns`:`Periodic review off`},{section:`mailbox`,icon:Ut,label:`Mailbox`,detail:E?E.unread?`${E.unread} unread`:`Nothing unread`:``},{section:`skills`,icon:Me,label:`Skills`,detail:e.profile.skillsMode===`all`&&e.skills.length===0?`From the template`:`${e.skills.length} attached`},...w.data?.configured?[{section:`telegram`,icon:P,label:`Telegram`,detail:r.telegramTopicId===null?`Not bound`:`Topic #${r.telegramTopicId}`}]:[],{section:`browser`,icon:Bt,label:`Browser`,detail:`Session and saved profile`}];return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,$.jsx)(R,{identity:r.identity,size:44}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-base font-semibold text-foreground`,children:r.name}),y&&(0,$.jsx)(st,{variant:`warning`,children:`Archived`})]}),(r.identity?.creature||r.identity?.vibe)&&(0,$.jsx)(`p`,{className:`m-0 truncate text-xs text-muted-foreground`,children:[r.identity?.creature,r.identity?.vibe].filter(Boolean).join(` · `)}),(0,$.jsxs)(`p`,{className:`m-0 mt-0.5 flex min-w-0 items-center gap-1.5 text-xs text-mocha`,children:[(0,$.jsx)(`span`,{className:`size-[7px] shrink-0 rounded-full ${M[x.kind]}`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:x.text}),d&&S!==null&&x.kind!==`working`&&(0,$.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[`· last active `,rt(S)]})]})]})]}),_&&(0,$.jsx)(`p`,{role:`alert`,className:`err mt-3`,children:_}),y&&(0,$.jsxs)(`div`,{className:`mt-3 rounded-[10px] border border-warning/30 bg-warning/[0.07] px-3 py-2 text-sm text-chocolate`,children:[`This Agent is archived: it is hidden from the list and receives no work.`,(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsx)(f,{variant:`ghost`,onClick:()=>void T(),children:`Restore`})})]}),(0,$.jsx)(_o,{children:`Model`}),(0,$.jsx)(Na,{agent:e}),(0,$.jsx)(_o,{children:`More about this Agent`}),(0,$.jsx)(vo,{children:D.map(({section:e,icon:t,label:r,detail:i})=>(0,$.jsxs)(n,{to:`/`,search:o({panel:`agent`,section:e}),className:`flex min-h-11 items-center gap-2.5 px-3 py-2 text-foreground hover:bg-accent/50`,children:[(0,$.jsx)(t,{className:`size-4 shrink-0 text-mocha`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`shrink-0 text-sm font-semibold`,children:r}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-right text-xs ${e===`learning`&&E?.proposals||e===`mailbox`&&E?.unread?`font-semibold text-warning`:`text-muted-foreground`}`,children:i}),(0,$.jsx)(de,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`})]},e))}),(0,$.jsx)(_o,{children:`Team`}),(0,$.jsx)(La,{agentId:r.id,teamId:e.team.id,teams:a},e.team.id),(0,$.jsx)(_o,{children:`Details`}),(0,$.jsxs)(`dl`,{className:`m-0 grid grid-cols-[max-content_minmax(0,1fr)] gap-x-3 gap-y-1.5 text-xs`,children:[(0,$.jsx)(`dt`,{className:`text-muted-foreground`,children:`Template`}),(0,$.jsx)(`dd`,{className:`m-0 min-w-0 truncate`,children:(0,$.jsx)(`a`,{href:`/templates/agents/${encodeURIComponent(e.profile.id)}`,children:e.profile.name||e.profile.id})}),(0,$.jsx)(`dt`,{className:`text-muted-foreground`,children:`ID`}),(0,$.jsxs)(`dd`,{className:`m-0 flex min-w-0 items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`min-w-0 select-all truncate font-mono text-mocha`,children:r.id}),(0,$.jsx)(Pa,{value:r.id,ariaLabel:`Copy the Agent's ID`,title:`Copy the ID`})]}),(0,$.jsx)(`dt`,{className:`text-muted-foreground`,children:`Files`}),(0,$.jsx)(`dd`,{className:`m-0 min-w-0 truncate font-mono text-mocha`,title:r.dir,children:r.dir})]}),(0,$.jsxs)(`div`,{className:`mt-5 flex flex-wrap gap-2`,children:[(0,$.jsx)(f,{variant:`ghost`,onClick:()=>m(!0),children:`Rename`}),!y&&(0,$.jsx)(f,{variant:`ghost`,onClick:()=>g(`archive`),children:`Archive`}),(0,$.jsx)(f,{variant:`danger`,onClick:()=>g(`delete`),children:`Delete`})]}),p&&(0,$.jsx)(xe,{agent:r,onClose:()=>m(!1),onRenamed:()=>u.invalidate()}),(0,$.jsx)(Ct,{open:h!==null,onOpenChange:e=>{e||g(null)},title:h===`delete`?`Delete ${r.name} permanently?`:`Archive ${r.name}?`,description:h===`delete`?(0,$.jsx)(`p`,{children:`This removes its conversations, messages, schedules, skill attachments and private files. Files it saved for the Team stay. This cannot be undone.`}):(0,$.jsx)(`p`,{children:`The Agent leaves the list and receives no work. Restore it later under Manage, Agents, with “Show archived”.`}),confirmLabel:h===`delete`?`Delete permanently`:`Archive agent`,confirmVariant:h===`delete`?`danger`:`primary`,onConfirm:async()=>{h===`delete`?await Et(r.id):await Dt(r.id),await u.navigate({to:`/`,search:{team:e.team.id}}),await u.invalidate()}})]})}function La({agentId:e,teamId:n,teams:r}){let a=i(),[o,s]=(0,H.useState)(n),[c,u]=(0,H.useState)(!1),[d,p]=(0,H.useState)(null);async function m(n){n.preventDefault(),u(!0),p(null);try{await t(`/api/agents/${encodeURIComponent(e)}/team`,{method:`PATCH`,body:{teamId:o}}),await a.invalidate({sync:!0})}catch(e){p(l(e))}finally{u(!1)}}return(0,$.jsxs)(`form`,{onSubmit:e=>void m(e),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(ze,{ariaLabel:`Team`,value:o,options:r.map(e=>({value:e.id,label:e.name,hint:e.id===n?`now`:void 0})),onChange:s,className:`min-w-0 flex-1`}),(0,$.jsx)(f,{variant:`primary`,type:`submit`,disabled:c||o===n,children:c?`Moving…`:`Move`})]}),o!==n&&(0,$.jsx)(`p`,{className:`m-0 mt-1.5 text-xs text-muted-foreground`,children:`Moving leaves this Agent's connections behind; it joins the other Team with none.`}),d&&(0,$.jsx)(`p`,{role:`alert`,className:`m-0 mt-1.5 text-xs text-danger`,children:d})]})}function Ra({team:e}){let{to:r,search:i,agentById:a}=I(),{turnsEnded:o}=B(),s=V(n=>t(`/api/teams/${encodeURIComponent(e.id)}/policy`,{signal:n}),[e.id,o,i.view]),c=ve(e.id);if(s.error)return(0,$.jsx)(`p`,{role:`alert`,className:`err`,children:s.error});if(!s.data)return(0,$.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted-foreground`,children:`Loading the connections…`});let{mode:l,edges:u}=s.data,d=s.data.members.filter(e=>e.status!==`archived`),f=pe(c.data??[]),p=(e,t)=>u.some(n=>n.from===e&&n.to===t);return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`rounded-2xl border border-border bg-muted/50 px-3 py-2.5`,children:[(0,$.jsx)(`p`,{className:`m-0 text-sm font-semibold text-foreground`,children:l===`open`?`Open Team`:`Restricted Team`}),(0,$.jsxs)(`p`,{className:`m-0 mt-0.5 text-xs leading-relaxed text-mocha`,children:[l===`open`?`Members message each other freely. A connection is only needed to reach other Teams.`:`A member can message a teammate only along a connection.`,` `,`You can always talk to every Agent.`]}),(0,$.jsxs)(n,{to:`/`,search:r({view:`connections`,section:void 0}),className:`btn-primary mt-2.5 min-h-9 w-full py-1.5 text-sm no-underline`,children:[(0,$.jsx)(Ae,{className:`size-4`,"aria-hidden":`true`}),`Open the map`]})]}),(0,$.jsx)(_o,{children:`Who can message whom`}),d.length===0?(0,$.jsx)(`p`,{className:`m-0 text-sm text-muted-foreground`,children:`This Team has no members yet.`}):(0,$.jsx)(vo,{children:d.map(e=>{let t=[...d.filter(t=>t.id!==e.id),null].flatMap(t=>{let n=t?.id??`outside`,r=p(e.id,n),i=p(n,e.id);return l===`open`&&t||!r&&!i?[]:[{id:n,name:t?.name??`Other teams`,out:r,back:i}]}),n=d.reduce((t,n)=>{if(n.id===e.id)return t;let r=f.get(F(e.id,n.id));return r?t+(e.id<n.id?r.forward:r.back):t},0);return(0,$.jsxs)(`div`,{className:`px-3 py-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(R,{identity:a(e.id)?.identity,size:22}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-foreground`,children:e.name}),n>0&&(0,$.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:[n,` sent`]})]}),(0,$.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap gap-1.5 pl-[30px]`,children:[l===`open`&&(0,$.jsx)(`span`,{className:`rounded-full bg-frost px-2 py-0.5 text-xs text-chocolate`,children:`Everyone in the Team`}),t.map(t=>(0,$.jsxs)(`span`,{title:t.out&&t.back?`${e.name} and ${t.name} can message each other`:t.out?`${e.name} can message ${t.name}`:`${t.name} can message ${e.name}`,className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs ${t.out?`bg-accent text-accent-foreground`:`bg-frost text-mocha`}`,children:[t.out&&t.back?(0,$.jsx)(Mt,{className:`size-3`,"aria-hidden":`true`}):t.out?(0,$.jsx)(ue,{className:`size-3`,"aria-hidden":`true`}):(0,$.jsx)(ue,{className:`size-3 rotate-180`,"aria-hidden":`true`}),t.name]},t.id)),l===`restricted`&&t.length===0&&(0,$.jsx)(`span`,{className:`rounded-full bg-warning/15 px-2 py-0.5 text-xs font-semibold text-warning`,children:`No connections: it can only talk to you`})]})]},e.id)})}),(0,$.jsx)(_o,{children:`Recent messages`}),c.error?(0,$.jsx)(`p`,{role:`alert`,className:`m-0 text-xs text-danger`,children:c.error}):(0,$.jsx)(Se,{messages:c.data??[],limit:12})]})}var za=[{id:`all`,label:`All`},{id:`pictures`,label:`Pictures`},{id:`documents`,label:`Documents`}],Ba=e=>e.mimeType.startsWith(`image/`);function Va(e){let{agents:t,agent:n,conversationId:r}=I(),[i,a]=(0,H.useState)(`all`),[o,s]=(0,H.useState)(`team`),c=n&&n.team.id===e.id?n.agent:null,l=[{value:`team`,label:`Everyone in ${e.name}`},...t.filter(t=>t.teamId===e.id).map(e=>({value:`agent:${e.id}`,label:e.name})),...c&&r?[{value:`conversation`,label:`This conversation`,hint:c.name}]:[]],u=l.some(e=>e.value===o)?o:`team`;return{kind:i,setKind:a,who:u,setWho:s,options:l,filter:u.startsWith(`agent:`)?{agentId:u.slice(6)}:u===`conversation`&&r?{sessionId:r}:{},narrowed:u!==`team`,matches:e=>i===`all`||i===`pictures`===Ba(e)}}function Ha({state:e}){return(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,$.jsx)(wt,{label:`Kind of file`,value:e.kind,options:za,onChange:e.setKind}),(0,$.jsx)(Ke,{label:`Whose files`,value:e.who,options:e.options,onChange:e.setWho})]})}var Ua=[`image/png`,`image/jpeg`,`image/gif`,`image/webp`],Wa=[`text/plain`,`text/markdown`];function Ga(e){return Ua.includes(e.mimeType)&&e.byteLength<=10*1024*1024}function Ka(e){return Wa.includes(e.mimeType)&&e.byteLength<=256*1024}function qa(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(+(e<10*1024))} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Ja(e,t){if(e.startsWith(`image/`))return`${e.slice(6).toUpperCase()} image`;if(e===`text/markdown`)return`Markdown`;if(e===`text/plain`)return`Text`;if(e===`application/pdf`)return`PDF`;let n=/\.([a-z0-9]{1,6})$/i.exec(t)?.[1];return n?n.toUpperCase():e}var Ya=(e,t)=>`/api/results/${encodeURIComponent(e)}${t?`/${t}`:``}`;function Xa(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))r&&t.set(n,r);return`/api/results/archive?${t}`}function Za({resultId:e,result:r,detail:i,open:a,selected:c=!1,compact:u=!1,onPick:d}){let[p,m]=(0,H.useState)(r??null),[h,g]=(0,H.useState)(``),[_,v]=(0,H.useState)(null);(0,H.useEffect)(()=>{if(r){m(r);return}let n=new AbortController;return t(Ya(e),{signal:n.signal}).then(e=>m(e.result)).catch(e=>{n.signal.aborted||g(e instanceof o&&e.status===404?`This saved file is unavailable (it may have been deleted).`:l(e))}),()=>n.abort()},[e,r]);async function y(){if(_!==null)return v(null);g(``);try{v(await(await s(Ya(e,`preview`))).text())}catch(e){g(l(e))}}if(!p)return(0,$.jsx)(`div`,{className:`rounded-[10px] border border-border bg-muted p-3 text-sm text-muted-foreground`,children:h?(0,$.jsx)(`span`,{role:`alert`,children:h}):(0,$.jsx)(`span`,{role:`status`,children:`Loading saved file…`})});let b=[qa(p.byteLength),Ja(p.mimeType,p.name),p.imageModel?`made with ${p.imageModel}`:null].filter(Boolean).join(` · `),x=(0,$.jsx)(`a`,{href:Ya(p.id,`download`),download:p.name,"aria-label":`Download ${p.name}`,title:`Download`,className:`flex size-8 shrink-0 items-center justify-center rounded-[10px] border border-border bg-card text-foreground hover:border-sapphire-light hover:text-sapphire`,children:(0,$.jsx)(se,{className:`size-[15px]`,"aria-hidden":`true`})}),S=`min-w-0 overflow-hidden rounded-[10px] border bg-muted ${c?`border-primary ring-1 ring-primary`:`border-border`}`;if(u){let e=Ga(p)?(0,$.jsx)(`img`,{src:Ya(p.id,`preview`),alt:p.name,loading:`lazy`,className:`block aspect-[4/3] w-full bg-card object-contain p-1.5`}):(0,$.jsxs)(`span`,{className:`flex aspect-[4/3] w-full flex-col items-center justify-center gap-1.5 bg-card text-mocha`,children:[(0,$.jsx)(Te,{className:`size-7`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`max-w-full truncate px-2 font-mono text-xs font-medium uppercase tracking-wide`,children:Ja(p.mimeType,p.name)})]});return(0,$.jsxs)(`figure`,{className:`m-0 ${S}`,children:[d?(0,$.jsx)(`button`,{type:`button`,onClick:d,"aria-label":`Choose ${p.name}`,"aria-pressed":c,className:`unstyled block w-full`,children:e}):a?(0,$.jsx)(n,{to:`/`,search:a,"aria-label":`Open ${p.name}`,"aria-current":c?`true`:void 0,className:`block`,children:e}):e,(0,$.jsxs)(`figcaption`,{className:`flex items-center gap-1.5 py-1.5 pl-2.5 pr-1.5`,children:[(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm font-semibold text-foreground`,title:p.name,children:p.name}),(0,$.jsx)(`span`,{className:`block truncate text-xs text-mocha`,children:i??b})]}),x]})]})}if(Ga(p)){let e=(0,$.jsx)(`img`,{src:Ya(p.id,`preview`),alt:p.name,loading:`lazy`,className:`block max-h-80 w-full bg-card object-contain`});return(0,$.jsxs)(`figure`,{className:`m-0 ${S}`,children:[a?(0,$.jsx)(n,{to:`/`,search:a,"aria-label":`Open ${p.name} in Files`,className:`block`,children:e}):e,(0,$.jsxs)(`figcaption`,{className:`flex items-center gap-2 py-1.5 pl-2.5 pr-1.5`,children:[(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm font-semibold text-foreground`,children:p.name}),(0,$.jsx)(`span`,{className:`block truncate text-xs text-mocha`,children:i??b})]}),x]})]})}return(0,$.jsxs)(`div`,{className:S,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5 py-2 pl-2.5 pr-1.5`,children:[(0,$.jsx)(Te,{className:`size-[18px] shrink-0 text-mocha`,"aria-hidden":`true`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[a?(0,$.jsx)(n,{to:`/`,search:a,className:`block truncate text-sm font-semibold text-foreground hover:text-sapphire`,children:p.name}):(0,$.jsx)(`span`,{className:`block truncate text-sm font-semibold text-foreground`,children:p.name}),(0,$.jsx)(`span`,{className:`block truncate text-xs text-mocha`,children:i??b})]}),Ka(p)&&(0,$.jsx)(f,{variant:`ghost`,className:`min-h-8 px-2.5 py-1 text-xs`,onClick:()=>void y(),children:_===null?`Preview`:`Hide`}),x]}),_!==null&&(0,$.jsx)(`pre`,{className:`m-0 max-h-80 overflow-auto whitespace-pre-wrap break-words border-t border-border bg-card p-3 text-xs`,children:_}),h&&(0,$.jsx)(`p`,{role:`alert`,className:`m-0 border-t border-border px-3 py-2 text-xs text-danger`,children:h})]})}var Qa=100;function $a(e,n,r=24){let{turnsEnded:i}=B(),[a,o]=(0,H.useState)(r),s=`${e}|${n.agentId??``}|${n.sessionId??``}`;(0,H.useEffect)(()=>o(r),[s,r]);let c=V(async r=>{let i=[],o=0;for(let s=0;s<a;s+=Qa){let c=new URLSearchParams({limit:String(Math.min(Qa,a-s)),offset:String(s)});e&&c.set(`teamId`,e),n.agentId&&c.set(`agentId`,n.agentId),n.sessionId&&c.set(`sessionId`,n.sessionId);let l=await t(`/api/results?${c}`,{signal:r});if(i.push(...l.results),o=l.total,i.length>=o)break}return{results:i,total:o}},[s,a,i]),l=c.data?.results??[],u=c.data?.total??0;return{results:l,total:u,loading:c.loading,error:c.error,hasMore:l.length<u,more:()=>o(e=>e+r),reload:c.reload}}var eo=`inline-flex h-7 items-center gap-1 rounded-[10px] border border-border bg-card px-2 text-xs font-semibold text-foreground hover:border-sapphire-light hover:text-sapphire`;function to({team:e}){let{agentById:t,to:r}=I(),i=St(),a=Va(e),{filter:o}=a,s=$a(e.id,o,12),c=s.results.filter(a.matches);return(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`mb-3`,children:(0,$.jsx)(Ha,{state:a})}),(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`m-0 text-xs text-muted-foreground`,children:s.loading&&s.results.length===0?`Loading…`:a.kind===`all`?`${s.total} saved file${s.total===1?``:`s`}`:`${c.length} of the ${s.results.length} loaded`}),(0,$.jsxs)(`div`,{className:`flex gap-1.5`,children:[s.total>0&&a.kind===`all`&&(0,$.jsxs)(`a`,{href:Xa({teamId:e.id,...o}),download:!0,className:eo,title:`Download these files as one zip`,children:[(0,$.jsx)(se,{className:`size-3.5`,"aria-hidden":`true`}),`All (.zip)`]}),(0,$.jsxs)(n,{to:`/`,search:r({view:`files`,section:void 0}),className:eo,children:[(0,$.jsx)(le,{className:`size-3.5`,"aria-hidden":`true`}),`Gallery`]})]})]}),s.error&&(0,$.jsx)(`p`,{role:`alert`,className:`err`,children:s.error}),!s.loading&&!s.error&&s.total===0&&(0,$.jsxs)(`p`,{className:`m-0 rounded-2xl border border-dashed border-border bg-muted/40 px-3 py-4 text-sm text-muted-foreground`,children:[`Nothing saved `,a.narrowed?`here`:`in this Team`,` yet. Files an Agent delivers or pictures it generates are kept here with their original contents.`]}),!s.loading&&s.total>0&&c.length===0&&(0,$.jsxs)(`p`,{className:`m-0 rounded-2xl border border-dashed border-border bg-muted/40 px-3 py-4 text-sm text-muted-foreground`,children:[`No `,a.kind===`pictures`?`pictures`:`documents`,` among the files loaded`,s.hasMore?`; Show more loads older ones.`:`.`]}),(0,$.jsx)(`div`,{className:`grid grid-cols-2 gap-2.5`,children:c.map(e=>{let n=t(e.agentId)?.name;return(0,$.jsx)(Za,{resultId:e.id,result:e,compact:!0,detail:[n,i?rt(e.createdAt):null].filter(Boolean).join(` · `),open:r({view:`files`,result:e.id,section:void 0})},e.id)})}),s.hasMore&&(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(f,{variant:`ghost`,className:`w-full`,disabled:s.loading,onClick:s.more,children:s.loading?`Loading…`:`Show more (${s.total-s.results.length} left)`})})]})}function no(e){return e.replace(/^\s{0,3}#{1,6}\s+/,``).replace(/^\s*>\s?/,``).replace(/^\s*(?:[-*+]|\d+[.)])\s+(?:\[[ xX]\]\s+)?/,``)}function ro(e){return e.replace(/!\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`).replace(/`([^`]*)`/g,`$1`).replace(/(^|[^\w*])\*\*([^*\s](?:.*?[^*\s])?)\*\*(?![\w*])/g,`$1$2`).replace(/(^|[^\w_])__([^_\s](?:.*?[^_\s])?)__(?![\w_.])/g,`$1$2`).replace(/(^|[^\w*])\*([^*\s](?:[^*]*?[^*\s])?)\*(?![\w*])/g,`$1$2`).replace(/(^|[^\w_])_([^_\s](?:[^_]*?[^_\s])?)_(?![\w_])/g,`$1$2`).replace(/~~(\S(?:.*?\S)?)~~/g,`$1`)}var io=e=>/^\s*([-*_])(\s*\1){2,}\s*$/.test(e),ao=e=>/^\s{0,3}#{1,6}\s/.test(e),oo=e=>/^\s*(`{3,}|~{3,})/.exec(e)?.[1]??null,so=/^\s*@@[^@]*@@\s*/;function co(e){for(let t of e.split(`
69
- `)){let e=t.replace(so,``);if(!e.trim())continue;let n=/^\s{0,3}#{1,6}\s+(.+)$/.exec(e);return n?.[1]&&ro(n[1]).trim()||null}return null}function lo(e,t=140){let n=[],r=[],i=null,a=()=>{r.length&&n.push(ro(r.join(` `))),r=[]};for(let o of e.split(`
70
- `)){let e=o.replace(so,``),s=oo(e);if(i){s&&s[0]===i[0]&&s.length>=i.length&&(i=null);continue}if(s){a(),i=s;continue}if(!e.trim()||io(e)||ao(e)){a();continue}if(/^\s*(?:[-*+]|\d+[.)])\s+/.test(e)&&a(),r.push(no(e).trim()),n.join(` `).length>t)break}a();let o=n.join(` `).replace(/\s+/g,` `).trim();if(o.length<=t)return o;let s=o.slice(0,t),c=s.lastIndexOf(` `);return`${(c>t*.6?s.slice(0,c):s).replace(/[\s,;:.–-]+$/,``)}…`}var uo=`inline-flex h-7 items-center gap-1 rounded-[10px] border border-border bg-card px-2 text-xs font-semibold text-foreground hover:border-sapphire-light hover:text-sapphire`;function fo({team:e}){let{agents:r,profiles:a,teams:o,teamTemplates:s,agent:c,to:l,search:u}=I(),{turnsEnded:d}=B(),f=V(n=>t(`/api/teams/${encodeURIComponent(e.id)}`,{signal:n}),[e.id,d,u.section]),p=f.data?.id===e.id?f.data.userMd:e.userMd,m=B(),h=i(),[g,_]=(0,H.useState)(!1),[v,y]=(0,H.useState)(null),b=r.filter(t=>t.teamId===e.id),x=s.filter(e=>e.slots.length>0),S=x.find(e=>e.id===v);return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate text-base font-semibold text-foreground`,children:e.name}),(0,$.jsx)(`p`,{className:`m-0 truncate font-mono text-xs text-muted-foreground`,title:e.path,children:e.path})]}),(0,$.jsx)(n,{to:`/`,search:l({panel:`connections`,section:void 0}),title:e.policyMode===`open`?`Members message each other freely`:`Members message each other only along connections`,className:`shrink-0 rounded-full border border-border bg-muted px-2 py-0.5 text-xs font-semibold text-mocha hover:border-sapphire-light hover:text-sapphire`,children:e.policyMode===`open`?`Open`:`Restricted`})]}),(c||b.length===0&&x.length>0)&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`mt-5 flex items-center justify-between gap-2`,children:[(0,$.jsxs)(_o,{children:[b.length,` member`,b.length===1?``:`s`]}),(0,$.jsxs)(`button`,{type:`button`,className:`unstyled ${uo}`,onClick:()=>_(!0),children:[(0,$.jsx)(je,{className:`size-3.5`,"aria-hidden":`true`}),`Add agent`]})]}),b.length===0?(0,$.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-border bg-muted/40 px-3 py-4 text-sm text-muted-foreground`,children:[(0,$.jsx)(`p`,{className:`m-0`,children:`No Agents in this Team yet.`}),x.length>0&&(0,$.jsxs)(`div`,{className:`mt-3`,children:[(0,$.jsx)(`span`,{className:`mb-1.5 block text-xs`,children:`Or start it from a Team template`}),(0,$.jsx)(ze,{ariaLabel:`Start from a Team template`,value:``,placeholder:`Choose a Team template…`,options:x.map(e=>({value:e.id,label:e.name,hint:`${e.slots.length} member${e.slots.length===1?``:`s`}`})),onChange:e=>y(e||null)})]})]}):(0,$.jsx)(vo,{children:b.map(e=>{let t=m.stateOf(e.id),r=e.id===c?.agent.id;return(0,$.jsxs)(n,{to:`/`,search:{agent:e.id,panel:`team`},"aria-current":r?`true`:void 0,className:`flex min-h-12 items-center gap-2.5 px-3 py-2 text-foreground hover:bg-accent/50 ${r?`bg-accent/40`:``}`,children:[(0,$.jsx)(R,{identity:e.identity,size:28}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm font-semibold`,children:e.name}),(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-xs text-mocha`,children:[(0,$.jsx)(`span`,{className:`size-[7px] shrink-0 rounded-full ${M[t.kind]}`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:t.text})]})]}),!r&&(0,$.jsx)(de,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`})]},e.id)})})]}),(0,$.jsxs)(`div`,{className:`mt-5 flex items-center justify-between gap-2`,children:[(0,$.jsx)(_o,{children:`About you · USER.md`}),(0,$.jsx)(n,{to:`/`,search:l({panel:`team`,section:`user-md`}),className:uo,children:`Edit`})]}),p.trim()?(0,$.jsx)(n,{to:`/`,search:l({panel:`team`,section:`user-md`}),className:`block rounded-2xl border border-border bg-muted/50 px-3 py-2.5 hover:border-sapphire-light`,children:(0,$.jsx)(`span`,{className:`line-clamp-4 break-words text-sm leading-relaxed text-chocolate`,children:lo(p,320)||p.trim()})}):(0,$.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-border bg-muted/40 px-3 py-3 text-sm text-muted-foreground`,children:[(0,$.jsx)(`p`,{className:`m-0`,children:`Tell this Team’s Agents who you are and how you like to work. Every member reads it on every turn, and fills it in as it learns about you.`}),(0,$.jsx)(n,{to:`/`,search:l({panel:`team`,section:`user-md`}),className:`mt-2.5 ${uo}`,children:`Write it`})]}),(0,$.jsx)(mo,{team:e},`${e.id}:${u.section??``}`),(0,$.jsx)(_o,{children:`Settings`}),(0,$.jsx)(vo,{children:(0,$.jsxs)(n,{to:`/`,search:l({panel:`team`,section:`settings`}),className:`flex min-h-11 items-center gap-2.5 px-3 py-2 text-foreground hover:bg-accent/50`,children:[(0,$.jsx)(bt,{className:`size-4 shrink-0 text-mocha`,"aria-hidden":`true`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block text-sm font-semibold`,children:`Workspace and templates`}),(0,$.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:`Sandbox defaults, Telegram topic names, save as a template`})]}),(0,$.jsx)(de,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`})]})}),g&&(0,$.jsx)(yt,{profiles:a,teams:o,teamId:e.id,onClose:()=>_(!1)}),S&&(0,$.jsx)(jt,{template:S,teams:[e],initialTeamId:e.id,onClose:()=>y(null),onSpawned:()=>{y(null),h.invalidate()}})]})}var po=(e,t)=>({key:e,title:co(t)??e.split(`/`).pop()?.replace(/\.md$/,``)??e,preview:lo(t,120)});function mo({team:e}){let{to:r}=I(),{turnsEnded:i}=B(),a=`/api/teams/${encodeURIComponent(e.id)}/memory`,[o,s]=(0,H.useState)(``),[c,l]=(0,H.useState)(``);(0,H.useEffect)(()=>{let e=setTimeout(()=>l(o.trim()),200);return()=>clearTimeout(e)},[o]);let u=V(async e=>{if(c)return{rows:(await t(`${a}/search?q=${encodeURIComponent(c)}&limit=8`,{signal:e})).map(e=>po(e.key,e.snippet)),total:null};let n=await t(a,{signal:e});return{rows:[...n].sort((e,t)=>t.updatedAt-e.updatedAt).slice(0,5).map(e=>po(e.key,e.content)),total:n.length}},[a,c,i]),d=u.data?.total;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`mt-5 flex items-center justify-between gap-2`,children:[(0,$.jsxs)(_o,{children:[`Shared memory`,typeof d==`number`?` · ${d} note${d===1?``:`s`}`:``]}),(0,$.jsx)(n,{to:`/`,search:r({panel:`team`,section:`memory`,note:void 0}),className:uo,children:`Open`})]}),(0,$.jsx)(oe,{label:`Search the Team's memory`,placeholder:`Search the notes`,value:o,onChange:s,className:`mb-2`}),u.error?(0,$.jsx)(`p`,{role:`alert`,className:`m-0 text-xs text-danger`,children:u.error}):u.data?u.data.rows.length===0?(0,$.jsx)(`p`,{className:`m-0 text-sm text-muted-foreground`,children:c?`No note matches.`:`No notes yet. Agents write here what the whole Team should remember.`}):(0,$.jsx)(vo,{children:u.data.rows.map(e=>(0,$.jsxs)(n,{to:`/`,search:r({panel:`team`,section:`memory`,note:e.key}),className:`block px-3 py-2 hover:bg-accent/50`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm font-semibold text-foreground`,children:e.title}),(0,$.jsx)(`span`,{className:`block truncate font-mono text-xs text-muted-foreground`,children:e.key}),e.preview&&(0,$.jsx)(`span`,{className:`mt-0.5 line-clamp-2 break-words text-xs leading-snug text-mocha`,children:e.preview})]},e.key))}):(0,$.jsx)(`p`,{role:`status`,className:`m-0 text-xs text-muted-foreground`,children:`Loading…`})]})}function ho({tab:e}){let{agent:t,team:r,to:i}=I(),a=Ma(r?.id),o={changes:a.changes,files:a.files};return(0,$.jsxs)(`aside`,{"aria-label":`About the work`,className:`flex h-full flex-col overflow-hidden rounded-[16px] border border-border bg-card shadow-baziu-sm`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border bg-muted/60 p-2`,children:[(0,$.jsx)(`div`,{role:`tablist`,"aria-label":`Side panel`,className:`flex min-w-0 flex-1 items-center gap-1 overflow-x-auto [scrollbar-width:none]`,children:Fe.map(t=>{let r=t===e,a=o[t];return(0,$.jsxs)(n,{to:`/`,search:i({panel:t,section:void 0}),role:`tab`,"aria-selected":r,className:`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-[10px] border px-2 text-sm font-semibold ${r?`border-border bg-card text-foreground shadow-baziu-sm`:`border-transparent text-mocha hover:bg-card/70 hover:text-foreground`}`,children:[Ge[t],typeof a==`number`&&a>0&&(0,$.jsx)(`span`,{className:`rounded-full bg-frost px-1.5 font-mono text-xs font-medium text-chocolate`,children:a})]},t)})}),(0,$.jsx)(n,{to:`/`,search:i({panel:`none`,section:void 0}),"aria-label":`Close the side panel`,className:`flex size-8 shrink-0 items-center justify-center rounded-[10px] text-mocha hover:bg-card hover:text-foreground xl:hidden`,children:(0,$.jsx)(O,{className:`size-4`,"aria-hidden":`true`})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 pb-5 pt-3.5`,children:e===`agent`?t?(0,$.jsx)(Ia,{agent:t},t.agent.id):(0,$.jsx)(go,{children:`Open an Agent's conversation to see its settings here.`}):r?e===`team`?(0,$.jsx)(fo,{team:r},r.id):e===`connections`?(0,$.jsx)(Ra,{team:r},r.id):e===`changes`?(0,$.jsx)(yo,{team:r},r.id):(0,$.jsx)(to,{team:r},r.id):(0,$.jsx)(go,{children:`Pick an Agent or a Team on the left.`})})]})}function go({children:e}){return(0,$.jsx)(`p`,{className:`m-0 py-10 text-center text-sm text-muted-foreground`,children:e})}function _o({children:e}){return(0,$.jsx)(`h2`,{className:`m-0 mb-1.5 mt-5 font-body text-xs font-bold uppercase tracking-[0.08em] text-muted-foreground first:mt-0`,children:e})}function vo({children:e}){return(0,$.jsx)(`div`,{className:`divide-y divide-frost/70 overflow-hidden rounded-2xl border border-border`,children:e})}function yo({team:e}){let{search:t,to:r}=I(),a=i(),o=ya(e.id),s=xa(e.id,o.base),c=s.data?.review?.changes??null,l=s.data?.review?.authors??{},u=c?.changes.find(e=>e.path===t.file)?.path??null,d=Sa(e.id,o.base,u,s.data),f=e=>void a.navigate({to:`/`,search:r({file:e}),replace:!0});return(0,$.jsxs)(`div`,{children:[(0,$.jsx)(ra,{changes:c,base:o.base,loading:s.loading,onBase:o.setBase,onRefresh:()=>void s.reload()}),s.error&&(0,$.jsx)(`p`,{role:`alert`,className:`err mt-3`,children:s.error}),s.data?.unavailable&&(0,$.jsx)(`p`,{role:`alert`,className:`m-0 mt-3 rounded-2xl border border-border bg-muted/50 px-3 py-3 text-sm`,children:on(s.data.unavailable.code,s.data.unavailable.message)}),!s.data&&!s.error&&(0,$.jsx)(`p`,{role:`status`,className:`m-0 mt-3 text-sm text-muted-foreground`,children:`Loading the changes…`}),c&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-2`,children:[(0,$.jsxs)(_o,{children:[c.changes.length,` changed file`,c.changes.length===1?``:`s`]}),c.changes.length>0&&(0,$.jsxs)(n,{to:`/`,search:r({view:`changes`,file:u??c.changes[0]?.path}),className:`inline-flex h-7 items-center gap-1 rounded-[10px] border border-border bg-card px-2 text-xs font-semibold text-foreground hover:border-sapphire-light hover:text-sapphire`,children:[(0,$.jsx)(Lt,{className:`size-3.5`,"aria-hidden":`true`}),`Side by side`]})]}),(0,$.jsx)(Oa,{changes:c,authors:l,comments:o.comments,selected:u,onSelect:e=>f(e===u?void 0:e)})]}),u&&(0,$.jsxs)(`section`,{"aria-label":`Diff of ${u}`,className:`mt-4`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,$.jsx)(`h3`,{className:`m-0 min-w-0 flex-1 truncate font-mono text-xs font-medium text-foreground`,title:u,children:Ea(u).name}),(0,$.jsx)(bo,{onAdd:e=>o.addComment({path:u,note:e})})]}),(0,$.jsx)(`div`,{className:`mt-2 max-h-[55vh] overflow-auto rounded-2xl border border-border bg-card`,children:d.error?(0,$.jsx)(`p`,{role:`alert`,className:`m-0 p-3 text-sm text-danger`,children:d.error}):d.data?d.data.patch===null?(0,$.jsxs)(`p`,{className:`m-0 p-3 text-sm text-muted-foreground`,children:[`No diff text for this file`,d.data.omitted?` (${d.data.omitted.replaceAll(`_`,` `)})`:``,`.`]}):(0,$.jsx)(ma,{patch:d.data.patch,comments:o.comments.filter(e=>e.path===u),onAddComment:(e,t)=>o.addComment({path:u,line:e,note:t}),onRemoveComment:o.removeComment}):(0,$.jsx)(`p`,{role:`status`,className:`m-0 p-3 text-sm text-muted-foreground`,children:`Loading the diff…`})}),d.data?.truncated&&(0,$.jsx)(`p`,{className:`m-0 mt-1.5 text-xs text-warning`,children:`This diff was cut: the file changed more.`})]}),c&&c.changes.length>0&&(0,$.jsx)(`div`,{className:`mt-4`,children:(0,$.jsx)(ja,{teamId:e.id,session:o,authors:l,onOpenFile:e=>f(e)})})]})}function bo({onAdd:e}){let[t,n]=(0,H.useState)(!1),[r,i]=(0,H.useState)(``);if(!t)return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(!0),className:`unstyled inline-flex h-7 shrink-0 items-center gap-1 rounded-[10px] border border-border bg-card px-2 text-xs font-semibold text-foreground hover:border-sapphire-light hover:text-sapphire`,children:[(0,$.jsx)(qe,{className:`size-3.5`,"aria-hidden":`true`}),`Comment on the file`]});let a=()=>{e(r.trim()),i(``),n(!1)};return(0,$.jsxs)(`div`,{className:`basis-full rounded-[10px] border border-primary/30 bg-accent/40 p-2.5`,children:[(0,$.jsx)(`textarea`,{autoFocus:!0,"aria-label":`Comment on the file`,placeholder:`What should change in this file? (optional: the Agent gets the diff either way)`,rows:2,maxLength:2e3,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Escape`&&n(!1),e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&a()},className:`min-h-16 text-sm`}),(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,$.jsx)(f,{variant:`primary`,className:`min-h-8 px-3 py-1 text-xs`,onClick:a,children:`Add to the review`}),(0,$.jsx)(f,{variant:`ghost`,className:`min-h-8 px-3 py-1 text-xs`,onClick:()=>n(!1),children:`Cancel`})]})]})}var xo=`bz_diff_layout`;function So({team:e}){let{search:t,to:r,agentById:a}=I(),o=i(),s=St(),c=ya(e.id),l=xa(e.id,c.base),u=l.data?.review?.changes??null,d=l.data?.review?.authors??{},f=u?.changes.find(e=>e.path===t.file)??u?.changes[0]??null,p=f?.path??null,m=Sa(e.id,c.base,p,l.data),h=p?d[p]:void 0,[g,_]=(0,H.useState)(`split`);(0,H.useEffect)(()=>{try{window.localStorage.getItem(xo)===`unified`&&_(`unified`)}catch{}},[]);let v=e=>{_(e);try{window.localStorage.setItem(xo,e)}catch{}},y=e=>void o.navigate({to:`/`,search:r({file:e}),replace:!0}),b=xt(`(min-width: 768px)`),x=f!==null&&[`added`,`deleted`,`untracked`].includes(f.status),S=g===`split`&&b&&!x?ha:ma,[C,w]=(0,H.useState)(!1);(0,H.useEffect)(()=>w(!1),[p]);let T=(f?.status===`added`||f?.status===`untracked`)&&/\.(md|markdown)$/i.test(f.path)&&m.data?.patch?tn(m.data.patch).lines.filter(e=>e.kind===`add`).map(e=>e.text).join(`
71
- `):null;return(0,$.jsx)(me,{view:`changes`,actions:b&&(0,$.jsx)(wt,{label:`Diff layout`,value:g,options:[{id:`split`,label:`Side by side`},{id:`unified`,label:`One column`}],onChange:v}),children:(0,$.jsxs)(`div`,{className:`grid h-full min-h-0 grid-cols-1 lg:grid-cols-[21rem_minmax(0,1fr)]`,children:[(0,$.jsxs)(`div`,{className:`min-h-0 space-y-3 overflow-y-auto border-border p-3 max-lg:max-h-[42vh] max-lg:border-b lg:border-r`,children:[(0,$.jsx)(ra,{changes:u,base:c.base,loading:l.loading,onBase:c.setBase,onRefresh:()=>void l.reload()}),l.error&&(0,$.jsx)(`p`,{role:`alert`,className:`err`,children:l.error}),l.data?.unavailable&&(0,$.jsx)(`p`,{role:`alert`,className:`m-0 rounded-2xl border border-border bg-muted/50 px-3 py-3 text-sm`,children:on(l.data.unavailable.code,l.data.unavailable.message)}),!l.data&&!l.error&&(0,$.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted-foreground`,children:`Loading the changes…`}),u&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Oa,{changes:u,authors:d,comments:c.comments,selected:p,onSelect:y}),u.changes.length>0&&(0,$.jsx)(ja,{teamId:e.id,session:c,authors:d,onOpenFile:y})]})]}),(0,$.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-col`,children:f&&p?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 border-b border-border px-3 py-2`,children:[(0,$.jsx)(Ta,{status:f.status}),(0,$.jsxs)(`h2`,{className:`m-0 min-w-0 flex-1 basis-48 break-all font-mono text-sm font-medium leading-snug text-foreground`,children:[f.previousPath?`${f.previousPath} → `:``,f.path]}),(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-mocha`,children:an(f)}),h&&(0,$.jsxs)(n,{to:`/`,search:{agent:h.agentId,conversation:h.conversationId,panel:`changes`,file:p},title:`Open the conversation this was written in`,className:`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-full border border-border bg-muted px-2 text-xs font-semibold text-mocha hover:border-sapphire-light hover:text-sapphire`,children:[(0,$.jsx)(R,{identity:a(h.agentId)?.identity,size:16}),h.agentName,s&&(0,$.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:rt(h.at)})]}),T!==null&&(0,$.jsx)(wt,{label:`Show the file as`,value:C?`preview`:`text`,options:[{id:`text`,label:`Text`},{id:`preview`,label:`Preview`}],onChange:e=>w(e===`preview`)}),(0,$.jsx)(bo,{onAdd:e=>c.addComment({path:p,note:e})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[m.error?(0,$.jsx)(`p`,{role:`alert`,className:`m-0 p-4 text-sm text-danger`,children:m.error}):m.data?m.data.patch===null?(0,$.jsxs)(`p`,{className:`m-0 p-4 text-sm text-muted-foreground`,children:[`No diff text for this file`,m.data.omitted?` (${m.data.omitted.replaceAll(`_`,` `)})`:``,`. A comment on the file still reaches the Agent.`]}):C&&T!==null?(0,$.jsx)(`div`,{className:`md-content mx-auto max-w-[50rem] px-5 py-4 leading-[1.6] text-chocolate`,dangerouslySetInnerHTML:{__html:ea(T,s)}}):(0,$.jsx)(S,{patch:m.data.patch,comments:c.comments.filter(e=>e.path===p),onAddComment:(e,t)=>c.addComment({path:p,line:e,note:t}),onRemoveComment:c.removeComment}):(0,$.jsx)(`p`,{role:`status`,className:`m-0 p-4 text-sm text-muted-foreground`,children:`Loading the diff…`}),m.data?.truncated&&(0,$.jsx)(`p`,{className:`m-0 border-t border-border px-4 py-2 text-xs text-warning`,children:`This diff was cut: the file changed more than a review shows.`})]})]}):(0,$.jsx)(`div`,{className:`flex min-h-40 flex-1 items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:u?`Nothing changed since this base.`:l.data?.unavailable?`There is nothing to compare.`:``})})]})})}function Co({agentId:e,agentName:n,refreshKey:r}){let[i,a]=(0,H.useState)([]);return(0,H.useEffect)(()=>{let n=new AbortController;return t(`/api/agents/${encodeURIComponent(e)}/questions`,{signal:n.signal}).then(e=>a(e.questions)).catch(()=>{}),()=>n.abort()},[e,r]),i.length?(0,$.jsx)(`section`,{"aria-label":`Agent questions`,className:`max-h-[45vh] min-w-0 shrink-0 space-y-3 overflow-y-auto border-t border-frost px-5 py-3`,children:i.map(e=>(0,$.jsx)(wo,{item:e,agentName:n},e.id))}):null}function wo({item:e,agentName:n}){let r=ft(),i=St(),[a,s]=(0,H.useState)(``),[c,u]=(0,H.useState)(!1),[d,p]=(0,H.useState)(null),[m,h]=(0,H.useState)(``);async function g(n,i){u(!0),h(``);try{await t(`/api/agents/${encodeURIComponent(e.agentId)}/questions/${encodeURIComponent(e.id)}/answer`,{body:{answer:n}}),p(i),r?.refresh()}catch(e){h(e instanceof o&&e.status===404?`This question is no longer open.`:l(e))}finally{u(!1)}}return d===null?(0,$.jsxs)(`article`,{className:`min-w-0 rounded-2xl border border-warning/35 bg-warning/[0.07] px-4 py-3.5`,children:[(0,$.jsxs)(`p`,{className:`m-0 flex items-center gap-2 text-xs font-bold uppercase tracking-[0.08em] text-warning`,children:[(0,$.jsx)(`span`,{className:`size-[7px] shrink-0 rounded-full bg-warning`,"aria-hidden":`true`}),n,` is waiting for you`]}),(0,$.jsx)(`p`,{className:`m-0 mt-1.5 break-words text-base font-semibold text-charcoal`,children:e.question.prompt}),(0,$.jsxs)(`fieldset`,{disabled:c,className:`m-0 mt-3 min-w-0 border-0 p-0`,children:[(0,$.jsx)(`legend`,{className:`sr-only`,children:`Answer this question`}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.question.choices.map((t,n)=>{let r=e.question.recommendedIndex===n;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void g({kind:`choice`,index:n},t.label),className:`unstyled min-h-[3.25rem] min-w-0 flex-1 basis-56 rounded-[10px] bg-card px-3 py-2 text-left transition-colors hover:bg-accent/60 disabled:opacity-60 ${r?`border-[1.5px] border-primary`:`border border-border`}`,children:[(0,$.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-sm font-bold ${r?`text-accent-foreground`:`text-foreground`}`,children:[(0,$.jsx)(`span`,{className:`min-w-0 break-words [overflow-wrap:anywhere]`,children:t.label}),r&&(0,$.jsx)(`span`,{className:`rounded-full bg-accent px-1.5 text-xs font-semibold`,children:`Suggested`})]}),t.description&&(0,$.jsx)(`span`,{className:`mt-0.5 block break-words text-sm text-mocha`,children:t.description})]},t.label)})}),(0,$.jsxs)(`form`,{className:`mt-2.5 flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),a.trim()&&g({kind:`text`,text:a},a.trim())},children:[(0,$.jsx)(`input`,{"aria-label":`Answer in your own words`,placeholder:`Or answer in your own words`,value:a,maxLength:4096,onChange:e=>s(e.target.value),className:`min-h-10 min-w-0 flex-1 basis-48 text-sm`}),a.trim()&&(0,$.jsx)(f,{variant:`primary`,type:`submit`,className:`min-h-10`,children:`Send answer`}),(0,$.jsx)(f,{variant:`ghost`,className:`min-h-10`,onClick:()=>void g({kind:`skip`},`Skipped`),children:`Skip`})]})]}),(0,$.jsxs)(`p`,{className:`m-0 mt-2 text-xs text-mocha`,children:[i?`Waiting until ${new Date(e.expiresAt).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}. `:``,`An answer is information only; it grants no permission.`]}),m&&(0,$.jsx)(`p`,{role:`alert`,className:`m-0 mt-2 text-sm text-danger`,children:m})]}):(0,$.jsxs)(`p`,{role:`status`,className:`m-0 flex flex-wrap items-center gap-2 rounded-[10px] border border-border bg-muted px-3 py-2 text-sm`,children:[(0,$.jsx)(`span`,{className:`text-mocha`,children:e.question.prompt}),(0,$.jsx)(`span`,{className:`font-semibold text-foreground`,children:d})]})}function To(e,t){return{message:e,attachments:t,bashApprovalMode:`interactive`,questionMode:`web`}}function Eo(e){return`/api/shell-approvals?agentId=${encodeURIComponent(e)}`}var Do=e=>e.startsWith(`image/`);function Oo(e){let t=[],n=null,r=()=>(n||(n={type:`tool`,items:[]},t.push(n)),n);for(let i of e)if(i.role===`user`)n=null,t.push({type:`user`,content:i.content,...i.images?.length?{images:i.images}:{}});else if(i.role===`assistant`){i.content&&(n=null,t.push({type:`assistant`,content:i.content}));for(let e of i.toolCalls??[])r().items.push({kind:`call`,id:e.id,name:e.name,body:e.arguments})}else if(i.role===`tool`){r().items.push({kind:/^error:/i.test(i.content)?`error`:`result`,id:i.toolCallId??``,name:i.toolName??``,body:i.content});for(let e of i.results??[])t.push({type:`result`,resultId:e.resultId}),n=null;i.images?.length&&(t.push({type:`images`,images:i.images}),n=null)}return t}function ko(e){let t=[],n=new Map;for(let r of e){let e=n.get(r.id);if(r.kind===`call`){let e={id:r.id,name:r.name,args:r.body,status:`running`,output:``};t.push(e),n.set(r.id,e)}else e?(r.kind===`progress`||(e.status=r.kind===`error`?`failed`:`done`),e.output=r.body):r.kind!==`progress`&&t.push({id:r.id,name:r.name,args:``,status:r.kind===`error`?`failed`:`done`,output:r.body})}return t}function Ao(e){let t=[],n=null;return e.forEach((e,r)=>{if(e.type===`tool`||e.type===`result`){n||(n={type:`work`,index:r,items:[],resultIds:[]},t.push(n)),e.type===`tool`?n.items.push(...e.items):n.resultIds.push(e.resultId);return}n=null,t.push({type:`entry`,index:r,entry:e})}),t}function jo(e,t){let n=e.findIndex(e=>e.type===`command_approval`&&e.approval.id===t.id);if(n===-1)return[...e,{type:`command_approval`,approval:t}];let r=[...e];return r[n]={type:`command_approval`,approval:t},r}function Mo(e,t){let n={kind:`progress`,id:t.id,name:t.name,body:t.output};for(let r=e.length-1;r>=0;r--){let i=e[r];if(i?.type!==`tool`)continue;let a=i.items.findIndex(e=>e.id===t.id);if(a<0)continue;let o=[...i.items],s=o.findIndex(e=>e.kind===`progress`&&e.id===t.id);s>=0?o[s]=n:o.splice(a+1,0,n);let c=[...e];return c[r]={type:`tool`,items:o},c}return No(e,n)}function No(e,t){let n=e[e.length-1];return n?.type===`tool`?[...e.slice(0,-1),{type:`tool`,items:[...n.items,t]}]:[...e,{type:`tool`,items:[t]}]}function Po(e,t){let n=e[e.length-1];return n?.type===`assistant`?[...e.slice(0,-1),{type:`assistant`,content:t(n.content)}]:[...e,{type:`assistant`,content:t(``)}]}function Fo(e,t){switch(t.type){case`assistant_delta`:return Po(e,e=>e+t.delta);case`assistant_message`:return Po(e,()=>t.text);case`command_approval`:return jo(e,t.approval);case`tool_progress`:return Mo(e,t);case`tool_call`:return No(e,{kind:`call`,id:t.id,name:t.name,body:t.arguments});case`tool_result`:case`tool_error`:{let n=No(e.map(e=>e.type===`tool`?{...e,items:e.items.filter(e=>!(e.kind===`progress`&&e.id===t.id))}:e),t.type===`tool_result`?{kind:`result`,id:t.id,name:t.name,body:t.result}:{kind:`error`,id:t.id,name:t.name,body:t.error});return t.type===`tool_result`&&t.images?.length?[...n,{type:`images`,images:t.images}]:n}case`file`:return[...e,{type:`result`,resultId:t.result.resultId}];case`error`:return[...e,{type:`error`,content:`[error] ${t.error}`}];default:return e}}function Io(e){return e.map(e=>e.type===`command_approval`&&e.approval.status===`pending`?{type:`command_approval`,approval:{...e.approval,status:`cancelled`}}:e)}async function*Lo(e){let t=e.getReader(),n=new TextDecoder,r=``;for(;;){let{done:e,value:i}=await t.read();r+=e?n.decode():n.decode(i,{stream:!0});let a=r.split(`
72
- `);r=e?``:a.pop()??``;for(let e of a)if(e.trim())try{yield JSON.parse(e)}catch{}if(e)return}}var Ro=200;function zo(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{let n=String(r.result);t({name:e.name,data:n.slice(n.indexOf(`,`)+1),mimeType:e.type||`application/octet-stream`})},r.onerror=()=>n(r.error),r.readAsDataURL(e)})}function Bo(e){return Promise.all(Array.from(e).map(zo))}function Vo({agentName:e,value:t,onChange:n,onSubmit:r,attachments:i,onAddFiles:a,onRemoveAttachment:o,editing:s,onCancelEdit:c,agentBusy:l,onStop:u,inputRef:d}){let p=(0,H.useRef)(null);return(0,H.useLayoutEffect)(()=>{let e=d.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,Ro)}px`)},[t]),(0,$.jsxs)($.Fragment,{children:[s&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-frost bg-sapphire-glow px-5 py-2 text-[0.85em] text-sapphire-deep`,children:[(0,$.jsx)(`span`,{children:`editing last message — submit to replace, or`}),(0,$.jsx)(`button`,{type:`button`,onClick:c,className:`ml-auto rounded-sm border border-sapphire-light bg-transparent px-2 py-0.5 text-[0.92em] text-sapphire-deep hover:bg-snow`,children:`cancel`})]}),i.length>0&&(0,$.jsx)(`div`,{className:`flex max-h-24 shrink-0 flex-wrap gap-2 overflow-y-auto border-t border-frost bg-ivory px-5 pt-3`,children:i.map((e,t)=>Do(e.mimeType)?(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:`pending attachment`,className:`h-16 w-16 rounded-md border border-frost object-cover`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>o(t),className:`absolute -right-1.5 -top-1.5 flex h-5 w-5 items-center justify-center rounded-full border border-frost bg-snow text-[0.7em] text-mocha hover:border-sapphire hover:text-sapphire`,"aria-label":`remove attachment`,children:`✕`})]},t):(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-md border border-frost bg-snow px-2 py-1 text-[0.82em] text-mocha`,children:[(0,$.jsx)(Te,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`max-w-[160px] truncate`,children:e.name??`file`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>o(t),className:`text-[0.85em] text-mocha hover:text-sapphire`,"aria-label":`remove attachment`,children:`✕`})]},t))}),(0,$.jsxs)(`form`,{className:`grid shrink-0 grid-cols-[auto_minmax(0,1fr)] items-end gap-2 border-t border-frost bg-ivory px-3 py-3 sm:grid-cols-[auto_minmax(0,1fr)_auto] sm:px-5`,onSubmit:e=>{e.preventDefault(),r()},children:[(0,$.jsx)(`input`,{ref:p,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{e.target.files&&a(e.target.files),e.target.value=``}}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>p.current?.click(),title:`attach images or files`,"aria-label":`attach files`,className:`flex h-11 items-center justify-center rounded-md border-[1.5px] border-frost bg-snow px-3 py-2 text-[1em] text-mocha transition-colors hover:border-sapphire hover:text-sapphire`,children:(0,$.jsx)(Jt,{className:`size-[18px]`,"aria-hidden":`true`})}),(0,$.jsx)(`textarea`,{ref:d,"data-composer":`true`,rows:1,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),r())},onPaste:e=>{let t=Array.from(e.clipboardData.files);t.some(e=>Do(e.type))&&(e.preventDefault(),a(t))},placeholder:`Message ${e}`,title:`Shift+Enter for a new line. Paste or attach files with the paperclip.`,autoComplete:`off`,"aria-label":`Message ${e}`,className:`max-h-[200px] min-h-11 min-w-0 flex-1 resize-none overflow-y-auto rounded-md border-[1.5px] border-frost bg-snow px-3 py-2 text-[0.93em] leading-[1.45] text-chocolate outline-none transition-colors focus:border-sapphire focus:shadow-[0_0_0_3px_var(--color-sapphire-glow)]`}),(0,$.jsxs)(`div`,{className:`col-span-2 flex flex-wrap justify-end gap-2 sm:col-span-1`,children:[(0,$.jsx)(f,{variant:`primary`,type:`submit`,className:`min-h-11 whitespace-normal text-center`,disabled:!t.trim()&&i.length===0,children:l?`Queue follow-up`:`Send`}),l&&(0,$.jsx)(f,{variant:`danger`,className:`min-h-11`,onClick:u,"aria-label":`Stop response`,children:`Stop`})]}),(0,$.jsx)(`p`,{className:`col-span-full m-0 hidden text-xs text-mocha-light sm:block`,children:`Enter sends · Shift+Enter adds a line · /help lists commands`})]})]})}function Ho({agentId:e,queue:n,onChanged:r,onViewConversation:i}){let[a,o]=(0,H.useState)(null),[s,c]=(0,H.useState)(!1),[u,d]=(0,H.useState)(``);if(!n||n.items.length===0&&!n.paused)return null;let p=`/api/agents/${encodeURIComponent(e)}/queue`;async function m(e,n){c(!0),d(``);try{await t(`${p}${e}`,n),o(null)}catch(e){d(l(e))}finally{c(!1),r()}}let h=n.items.some(e=>e.status===`pending`);return(0,$.jsxs)(`section`,{"aria-label":`Follow-up queue`,className:`max-h-[35%] min-w-0 shrink-0 space-y-3 overflow-y-auto border-t border-frost px-5 py-3 text-sm`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsxs)(`strong`,{children:[`Follow-ups`,n.paused?` · paused`:``]}),(n.paused||h)&&(0,$.jsx)(f,{variant:`ghost`,disabled:s,onClick:()=>void m(`/control`,{body:{paused:!n.paused}}),children:n.paused?`Resume queue`:`Pause queue`})]}),u&&(0,$.jsx)(`p`,{role:`alert`,className:`m-0 break-words text-danger`,children:u}),n.items.map(e=>(0,$.jsxs)(`article`,{className:`flex min-w-0 flex-col gap-2 rounded-lg border border-frost bg-ivory p-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`strong`,{className:`rounded-full bg-frost px-2 py-0.5 text-xs capitalize`,children:e.status}),(0,$.jsx)(`span`,{className:`text-xs text-mocha`,children:e.source===`telegram`?`Telegram`:`Web / API`}),(0,$.jsx)(f,{variant:`ghost`,className:`ml-auto`,onClick:()=>i(e.conversationId),children:`View conversation`})]}),a?.id===e.id?(0,$.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-2`,onSubmit:t=>{t.preventDefault(),m(`/${encodeURIComponent(e.id)}`,{method:`PATCH`,body:{message:a.text}})},children:[(0,$.jsx)(`textarea`,{"aria-label":`Edit follow-up`,rows:3,className:`w-full resize-y`,value:a.text,onChange:t=>o({id:e.id,text:t.target.value})}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(f,{variant:`primary`,type:`submit`,disabled:s,children:`Save`}),(0,$.jsx)(f,{variant:`ghost`,onClick:()=>o(null),children:`Cancel`})]})]}):(0,$.jsx)(`p`,{className:`m-0 whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:e.text}),e.attachments.map((e,t)=>(0,$.jsxs)(`p`,{className:`m-0 break-all text-xs text-mocha`,children:[e.name??`Attachment`,` · `,e.byteLength,` bytes`]},t)),e.diagnostic&&(0,$.jsx)(`p`,{className:`m-0 break-words`,children:e.diagnostic}),e.status!==`running`&&a?.id!==e.id&&(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.status===`pending`&&(0,$.jsx)(f,{variant:`ghost`,disabled:s,onClick:()=>o({id:e.id,text:e.text}),children:`Edit`}),(0,$.jsx)(f,{variant:`danger`,disabled:s,onClick:()=>void m(`/${encodeURIComponent(e.id)}`,{method:`DELETE`}),children:`Remove`})]})]},e.id))]})}function Uo(e){let t=e.split(`
73
- `).find(e=>e.startsWith(`--- from `));if(!t)return`Teammate update received`;let n=/^--- from (.+?) \(message [0-9a-f-]+(?:, reply to [0-9a-f-]+)?\) ---$/.exec(t);if(!n)return`Teammate update received`;let r=n[1]?.replace(/ \([0-9a-f-]{36}\)$/,``).trim();return!r||/^[0-9a-f-]{36}$/.test(r)?`Teammate update received`:`Update from ${r.slice(0,100)}`}var Wo={pending:`Waiting for a decision.`,allowed:`Allowed once — the command may run for this tool call only.`,denied:`Denied — the command was not run.`,auto_denied:`Automatically denied — no interactive approval path was available.`,expired:`Expired — the command was not run.`,cancelled:`Cancelled — the command was not run.`};function Go({approval:e,busy:t=!1,error:n,onDecision:r}){let i=e.status===`pending`;return(0,$.jsxs)(`section`,{className:`my-3 rounded-lg border border-danger/50 bg-danger/5 p-4 text-chocolate`,"aria-label":`Shell command approval`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`m-0 text-[0.72em] font-semibold uppercase tracking-wider text-danger`,children:`Shell command approval`}),(0,$.jsx)(`h2`,{className:`m-0 mt-1 font-body text-[0.95em] font-semibold`,children:i?`A risky command is waiting for you`:`Command decision recorded`})]}),(0,$.jsx)(`span`,{className:`rounded-full border border-danger/30 px-2 py-0.5 text-[0.75em] font-semibold uppercase tracking-wide text-danger`,children:e.status.replaceAll(`_`,` `)})]}),(0,$.jsx)(`pre`,{className:`mt-3 max-h-48 overflow-auto whitespace-pre-wrap break-words rounded-md border border-fawn bg-snow p-3 font-mono text-[0.82em] leading-[1.45] text-charcoal`,children:e.command}),(0,$.jsx)(`ul`,{className:`mt-3 space-y-1.5 pl-5 text-[0.84em] leading-[1.4] text-mocha`,children:e.risks.map(e=>(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`span`,{className:`font-medium text-chocolate`,children:e.message}),` `,(0,$.jsx)(`code`,{className:`text-[0.9em]`,children:e.code})]},`${e.code}:${e.span.start}:${e.span.end}`))}),i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`p`,{className:`mt-3 text-[0.78em] text-mocha-light`,children:[`This approval expires`,` `,(0,$.jsx)(`time`,{dateTime:new Date(e.expiresAt).toISOString(),children:new Date(e.expiresAt).toLocaleString()}),`. Deny blocks only this command; Stop ends the whole turn.`]}),n&&(0,$.jsx)(`p`,{role:`alert`,className:`mt-2 rounded-md bg-danger/10 px-3 py-2 text-[0.82em] text-danger`,children:n}),r&&(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,$.jsx)(f,{variant:`primary`,disabled:t,onClick:()=>r(e,`deny`),children:`Deny`}),(0,$.jsx)(f,{variant:`danger`,disabled:t,onClick:()=>r(e,`allow`),children:`Allow once`})]})]}):(0,$.jsx)(`p`,{role:`status`,className:`mt-3 text-[0.84em] font-medium text-mocha`,children:Wo[e.status]})]})}var Ko={terminal:Qt,read:Pt,write:Yt,search:D,web:Bt,message:De,file:Te,image:Ht,note:Zt,question:It,tool:ke},qo=6,Jo=40,Yo=6e3,Xo=`rounded-md bg-frost px-1.5 py-px font-mono text-[0.86em] text-chocolate [overflow-wrap:anywhere]`;function Zo({items:e,dimmed:t=!1}){let n=ko(e),r=n.filter(e=>e.name===`send_message`),i=n.filter(e=>e.name!==`send_message`),a=[...new Set(i.filter(e=>e.status===`done`&&(e.name===`write`||e.name===`edit`)).map(e=>mt(e.args)?.path).filter(e=>typeof e==`string`))];return(0,$.jsxs)(`div`,{className:t?`opacity-40`:void 0,children:[i.length>0&&(0,$.jsx)($o,{steps:i}),r.length>0&&(0,$.jsx)(as,{steps:r}),a.length>0&&(0,$.jsx)(os,{paths:a})]})}function Qo(){let e=_e(),t=ft(),n=e?.agent?.agent.id,r=n!==void 0&&t?.stateOf(n).kind===`needs`;return e=>r&&e.status===`running`&&(e.name===`ask_user`||e.name===`bash`)}function $o({steps:e}){let t=Qo(),n=e.some(t),r=e.some(e=>e.status===`running`),i=e.some(e=>e.status===`failed`),[a,o]=(0,H.useState)(null),s=a??(r||i||e.length<=qo),c=e.map(e=>Qe(e.name,mt(e.args)));return(0,$.jsxs)(`div`,{className:`my-3 overflow-hidden rounded-[10px] border border-border bg-muted text-sm`,children:[(0,$.jsxs)(`button`,{type:`button`,"aria-expanded":s,onClick:()=>o(!s),className:`unstyled flex min-h-9 w-full items-center gap-2 px-3 py-1.5 text-left text-mocha hover:bg-accent/50`,children:[(0,$.jsx)(Ee,{className:`size-[15px] shrink-0`,"aria-hidden":`true`}),(0,$.jsxs)(`span`,{className:`shrink-0 font-semibold text-foreground`,children:[e.length,` step`,e.length===1?``:`s`]}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[$e(c.map(e=>e.kind)),n?` · waiting for you`:r?` · running`:``]}),(0,$.jsx)(`span`,{className:`shrink-0 text-xs font-semibold text-accent-foreground`,children:s?`Hide`:`Show`})]}),s&&(0,$.jsx)(`ul`,{className:`m-0 list-none p-0`,children:e.map((e,n)=>(0,$.jsx)(es,{step:e,waiting:t(e)},n))})]})}function es({step:e,waiting:t}){let[n,r]=(0,H.useState)(!1),i=mt(e.args),a=Qe(e.name,i),o=Ko[a.icon],s=e.status===`done`?ct(e.name,i):null,c=e.status===`running`;return(0,$.jsxs)(`li`,{className:`border-t border-frost/70`,children:[(0,$.jsxs)(`button`,{type:`button`,"aria-expanded":n,onClick:()=>r(!n),className:`unstyled flex min-h-8 w-full items-center gap-2.5 px-3 py-1 text-left hover:bg-accent/40`,children:[(0,$.jsx)(o,{className:`size-[15px] shrink-0 text-mocha`,"aria-hidden":`true`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:[a.verb,a.target&&(0,$.jsxs)($.Fragment,{children:[` `,(0,$.jsx)(`code`,{className:Xo,children:a.target})]})]}),s&&s.added>0&&(0,$.jsxs)(`span`,{className:`shrink-0 font-mono text-xs font-medium text-success`,children:[`+`,s.added]}),s&&s.removed>0&&(0,$.jsxs)(`span`,{className:`shrink-0 font-mono text-xs font-medium text-danger`,children:[`−`,s.removed]}),c&&(t?(0,$.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-warning`,children:[(0,$.jsx)(`span`,{className:`size-[7px] rounded-full bg-warning`,"aria-hidden":`true`}),`waiting for you`]}):(0,$.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-success`,children:[(0,$.jsx)(`span`,{className:`size-[7px] animate-pulse rounded-full bg-success`,"aria-hidden":`true`}),`running`]})),e.status===`failed`&&(0,$.jsx)(`span`,{className:`shrink-0 text-xs font-semibold text-danger`,children:`failed`}),(0,$.jsx)(de,{className:`size-3.5 shrink-0 text-muted-foreground transition-transform ${n?`rotate-90`:``}`,"aria-hidden":`true`})]}),c&&e.output&&!n&&(0,$.jsx)(is,{output:e.output}),n&&(0,$.jsx)(rs,{step:e,args:i})]})}function ts(e,t=Jo){let n=e.replace(/\n$/,``).split(`
74
- `);return{lines:n.slice(0,t),more:Math.max(0,n.length-t)}}function ns({text:e,sign:t}){let{lines:n,more:r}=ts(e),i=t===`+`?`bg-success/15`:`bg-danger/15`;return(0,$.jsxs)($.Fragment,{children:[n.map((e,n)=>(0,$.jsxs)(`div`,{className:`whitespace-pre px-3 ${i}`,children:[t===`+`?`+`:`−`,e]},n)),r>0&&(0,$.jsxs)(`div`,{className:`px-3 text-mocha`,children:[` `,r,` more line`,r===1?``:`s`]})]})}function rs({step:e,args:t}){let n=e.output.length>Yo?`${e.output.slice(0,Yo)}\n…`:e.output,r=`overflow-x-auto border-t border-frost/70 bg-card font-mono text-xs leading-[1.55]`;if(e.status!==`failed`&&e.name===`write`&&typeof t?.content==`string`)return(0,$.jsx)(`div`,{className:r,children:(0,$.jsx)(ns,{text:t.content,sign:`+`})});if(e.status!==`failed`&&e.name===`edit`&&Array.isArray(t?.edits))return(0,$.jsx)(`div`,{className:r,children:t.edits.map((e,t)=>(0,$.jsxs)(`div`,{className:t>0?`border-t border-frost/70`:void 0,children:[typeof e?.oldText==`string`&&(0,$.jsx)(ns,{text:e.oldText,sign:`-`}),typeof e?.newText==`string`&&(0,$.jsx)(ns,{text:e.newText,sign:`+`})]},t))});let i=e.name===`bash`&&typeof t?.command==`string`?t.command:t?JSON.stringify(t,null,2):e.args;return(0,$.jsxs)(`div`,{className:`${r} max-h-72 overflow-y-auto`,children:[i&&(0,$.jsx)(`pre`,{className:`m-0 whitespace-pre-wrap break-words px-3 py-1.5 text-mocha`,children:i}),n&&(0,$.jsx)(`pre`,{className:`m-0 whitespace-pre-wrap break-words border-t border-frost/70 px-3 py-1.5 ${e.status===`failed`?`text-danger`:`text-chocolate`}`,children:n})]})}function is({output:e}){let t=(0,H.useRef)(null);return(0,H.useLayoutEffect)(()=>{t.current&&(t.current.scrollTop=t.current.scrollHeight)},[e]),(0,$.jsx)(`pre`,{ref:t,className:`m-0 max-h-48 overflow-auto whitespace-pre-wrap break-words border-t border-frost/70 bg-card px-3 py-1.5 font-mono text-xs text-mocha`,children:e})}function as({steps:e}){let t=_e(),r=ft();return(0,$.jsxs)(`div`,{className:`my-3 overflow-hidden rounded-[10px] border border-border bg-muted text-sm`,children:[(0,$.jsxs)(`div`,{className:`flex min-h-9 items-center gap-2 px-3 py-1.5 text-mocha`,children:[(0,$.jsx)(Mt,{className:`size-[15px] shrink-0`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.length===1?`Handed off to a teammate`:`Handed off to ${e.length} teammates`}),t?.team&&(0,$.jsx)(n,{to:`/`,search:t.to({panel:`connections`}),className:`ml-auto text-xs font-semibold`,children:`See connections`})]}),e.map((e,i)=>{let a=mt(e.args),o=typeof a?.to==`string`?a.to:``,s=t?.agentById(o),c=typeof a?.text==`string`?a.text:``,l=s?r?.stateOf(s.id):void 0;return(0,$.jsxs)(`details`,{className:`group border-t border-frost/70`,children:[(0,$.jsxs)(`summary`,{className:`flex min-h-11 cursor-pointer list-none items-center gap-2.5 px-3 py-1.5 [&::-webkit-details-marker]:hidden`,children:[(0,$.jsx)(R,{identity:s?.identity,size:24}),(0,$.jsx)(`span`,{className:`shrink-0 font-semibold text-foreground`,children:s?.name??(o?o.slice(0,8):`Teammate`)}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-mocha group-open:invisible`,children:c}),e.status===`failed`?(0,$.jsx)(`span`,{className:`shrink-0 text-xs font-semibold text-danger`,children:`not sent`}):e.status===`running`?(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-mocha`,children:`sending…`}):l&&(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-mocha`,children:l.text}),t&&s&&(0,$.jsx)(n,{to:`/`,search:{agent:s.id,...t.search.panel?{panel:t.search.panel}:{}},className:`flex h-7 shrink-0 items-center rounded-[10px] border border-border bg-card px-2.5 text-xs font-semibold text-foreground hover:border-sapphire-light hover:text-sapphire`,children:`Open`})]}),(0,$.jsx)(`p`,{className:`m-0 whitespace-pre-wrap break-words px-3 pb-2.5 pl-[3.1rem] text-chocolate`,children:c}),e.status===`failed`&&(0,$.jsx)(`p`,{className:`m-0 break-words px-3 pb-2.5 pl-[3.1rem] text-xs text-danger`,children:e.output})]},i)})]})}function os({paths:e}){let t=_e(),r=`${e.length} file${e.length===1?``:`s`} written`,i=e.map(e=>e.split(`/`).pop()??e).join(`, `),a=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(we,{className:`size-4 shrink-0 text-primary`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`shrink-0 font-semibold text-foreground`,children:r}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-mocha`,children:i})]}),o=`my-3 flex min-h-11 w-full items-center gap-2.5 rounded-[10px] border border-border bg-card px-3 py-2 text-sm`;return t?.team?(0,$.jsxs)(n,{to:`/`,search:t.to({panel:`changes`,file:e[0]}),className:`${o} text-foreground hover:border-sapphire-light`,children:[a,(0,$.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 font-semibold text-accent-foreground`,children:[`Review changes`,(0,$.jsx)(ue,{className:`size-3.5`,"aria-hidden":`true`})]})]}):(0,$.jsx)(`div`,{className:o,children:a})}var ss=`[[bazilion:inbox-wake]]
75
- `,cs=`[conversation summary]`,ls=()=>()=>{};function us(){return(0,H.useSyncExternalStore)(ls,()=>!0,()=>!1)}function ds({entry:e,markdownReady:t,onEdit:n,dropped:r=!1,approvals:i}){let a=r?`opacity-40 [&_.bubble-content]:line-through`:``;switch(e.type){case`user`:if(e.content.startsWith(ss)){let t=e.content.slice(24);return(0,$.jsxs)(`details`,{className:`my-3 rounded-lg border border-fawn bg-ivory px-3 py-2 text-sm text-mocha ${a}`,"aria-label":`Teammate update`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer font-medium`,children:Uo(t)}),(0,$.jsx)(`p`,{className:`mt-2 text-xs`,children:`Original message and Agent instructions`}),(0,$.jsx)(`pre`,{className:`mt-1 max-h-64 overflow-auto whitespace-pre-wrap break-words text-xs`,children:t})]})}return(0,$.jsxs)(`div`,{className:`group relative my-4 flex flex-col items-end ${a}`,children:[(0,$.jsx)(`span`,{className:`sr-only`,children:`you`}),e.images&&e.images.length>0&&(0,$.jsx)(`div`,{className:`mb-1 flex max-w-[85%] flex-wrap justify-end gap-1`,children:e.images.map((e,t)=>(0,$.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:`attachment`,className:`max-h-48 rounded-lg border border-sapphire-light`},t))}),e.files&&e.files.length>0&&(0,$.jsx)(`div`,{className:`mb-1 flex max-w-[85%] flex-wrap justify-end gap-1`,children:e.files.map((e,t)=>(0,$.jsxs)(`span`,{className:`flex items-center gap-1 rounded-md border border-sapphire-light bg-sapphire-glow px-2 py-1 text-[0.8em] text-chocolate`,children:[(0,$.jsx)(Te,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`max-w-[180px] truncate`,children:e.name})]},t))}),e.content&&(0,$.jsx)(hs,{content:e.content}),n&&(0,$.jsx)(`button`,{type:`button`,onClick:n,title:`Edit and resend: replaces the last turn`,className:`mt-1 rounded-md px-2 py-0.5 text-xs font-semibold text-mocha opacity-0 transition hover:bg-sapphire-glow hover:text-sapphire focus-visible:opacity-100 group-hover:opacity-100 group-focus-within:opacity-100 [@media(hover:none)]:opacity-100`,children:`Edit`})]});case`assistant`:if(e.content.startsWith(cs)){let n=e.content.slice(22).trim();return(0,$.jsx)(`div`,{className:`my-3 border-y border-dashed border-frost py-2 text-[0.85em] italic text-mocha-light ${a}`,children:(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{className:`cursor-pointer select-none text-center [&::-webkit-details-marker]:hidden`,children:`— conversation summary (click to expand) —`}),(0,$.jsx)(`div`,{className:`md-content mt-2 rounded-sm bg-frost/40 p-2 not-italic`,dangerouslySetInnerHTML:{__html:ea(n,t)}})]})})}return(0,$.jsxs)(`div`,{className:`my-4 flex flex-col items-start ${a}`,children:[(0,$.jsx)(`span`,{className:`sr-only`,children:`agent`}),(0,$.jsx)(`div`,{className:`md-content bubble-content w-full leading-[1.55] text-chocolate`,dangerouslySetInnerHTML:{__html:ea(e.content,t)}})]});case`images`:return(0,$.jsx)(`div`,{className:`my-2 space-y-2 ${a}`,children:e.images.map((e,t)=>(0,$.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:`screenshot`,className:`block max-w-full rounded-lg border border-fawn`},t))});case`command_approval`:return(0,$.jsx)(Go,{approval:e.approval,busy:i?.busy[e.approval.id]??!1,error:i?.errors[e.approval.id],onDecision:i?.decide});case`system`:return(0,$.jsxs)(`div`,{className:`my-3 rounded-r-sm border-l-[3px] border-sapphire bg-sapphire-glow px-3 py-1 font-mono text-[0.88em] text-sapphire-deep`,children:[(0,$.jsx)(`span`,{className:`mr-2 font-semibold uppercase tracking-wider opacity-80`,children:`system`}),(0,$.jsx)(`span`,{className:`whitespace-pre-wrap`,children:e.content})]});case`error`:return(0,$.jsx)(`div`,{className:`my-3 rounded-r-sm border-l-[3px] border-danger bg-danger/10 px-3 py-1 text-[0.92em] text-danger`,children:e.content})}}var fs=14,ps=1400,ms=8;function hs({content:e}){let[t,n]=(0,H.useState)(!1),r=e.split(`
76
- `),i=r.length>fs||e.length>ps;return(0,$.jsxs)(`div`,{className:`bubble-content max-w-[85%] rounded-[14px_14px_4px_14px] border border-sapphire-light bg-sapphire-glow px-3 py-2 text-chocolate`,children:[(0,$.jsxs)(`div`,{className:`whitespace-pre-wrap break-words`,children:[!i||t?e:r.slice(0,ms).join(`
77
- `).slice(0,ps/2),i&&!t?`…`:``]}),i&&(0,$.jsx)(`button`,{type:`button`,"aria-expanded":t,onClick:()=>n(!t),className:`unstyled mt-1.5 text-[0.82em] font-semibold text-sapphire-deep hover:underline`,children:t?`Show less`:`Show the whole message (${r.length} lines)`})]})}function gs({block:e,dropped:t}){let n=_e();return(0,$.jsxs)($.Fragment,{children:[e.items.length>0&&(0,$.jsx)(Zo,{items:e.items,dimmed:t}),e.resultIds.length>0&&(0,$.jsx)(`div`,{className:`my-3 grid grid-cols-[repeat(auto-fit,minmax(min(15rem,100%),1fr))] gap-3 ${t?`opacity-40`:``}`,children:e.resultIds.map(e=>(0,$.jsx)(Za,{resultId:e,...n?.team?{open:n.to({view:`files`,result:e})}:{}},e))})]})}function _s({entries:e,notes:t=[],markdownReady:n,editableEntry:r=-1,replacedFrom:i=-1,onEdit:a,approvals:o}){let s=[],c=0,l=e=>{for(;c<t.length&&(t[c]?.afterIndex??0)<=e;){let e=t[c];s.push((0,$.jsx)(ds,{entry:{type:`system`,content:e.content},markdownReady:n},`note-${e.id}`)),c++}};for(let t of Ao(e)){l(t.index);let e=i>=0&&t.index>=i;s.push(t.type===`work`?(0,$.jsx)(gs,{block:t,dropped:e},t.index):(0,$.jsx)(ds,{entry:t.entry,markdownReady:n,dropped:e,onEdit:t.index===r?a:void 0,approvals:o},t.index))}return l(1/0),(0,$.jsx)($.Fragment,{children:s})}function vs({messages:e}){let t=us();return(0,$.jsx)(`section`,{"aria-label":`Conversation history`,children:(0,$.jsx)(_s,{entries:Oo(e),markdownReady:t})})}var ys=[`slash commands:`,` /context — context breakdown (system prompt, tools, skills, history)`,` /compact [N] — summarize the head; keep the last N messages verbatim (default 10)`,` /new — open the list of conversations to start a new one`,` /help — show this list`].join(`
78
- `);function bs(e){let t=e.trim();if(!t.startsWith(`/`))return null;let[n=``,...r]=t.split(/\s+/);return{command:n.toLowerCase(),rest:r.join(` `)}}function xs(e){let t=Number(e.trim());return e.trim()&&Number.isFinite(t)&&t>=0?Math.floor(t):void 0}function Ss(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KiB`:`${(e/(1024*1024)).toFixed(2)} MiB`}function Cs(e){let t=(e,t)=>`${e.toLocaleString()} chars (~${t.toLocaleString()} tok)`,n=[`context for ${e.agentId}`,`model: ${e.model}`,``,`system prompt: ${t(e.systemPrompt.chars,e.systemPrompt.tokens)}`,...e.systemPrompt.files.map(e=>` - ${e.name}: ${e.chars.toLocaleString()} chars`),``,`tools: ${e.tools.count} (${e.tools.schemaChars.toLocaleString()} chars of schema)`,...e.tools.entries.slice(0,5).map(e=>` - ${e.name}: ${e.schemaChars.toLocaleString()} chars`)];if(e.skills.count>0){n.push(``,`skills: ${e.skills.count}`);for(let t of e.skills.entries.slice(0,10))n.push(` - ${t.name}: ${t.blockChars.toLocaleString()} chars`)}return n.push(``,`history: ${e.history.messageEntries} messages / ${e.history.compactionEntries} compactions`,` ${t(e.history.chars,e.history.tokensEstimate)}`,` bytes on disk: ${Ss(e.history.bytes)}`,``,`TOTAL: ${t(e.totals.chars,e.totals.tokens)}`),n.join(`
79
- `)}function ws(e){return`/compact: ${e.before} → ${e.after} entries (${e.summarized} summarized, ${e.keptTail} kept verbatim; ~${e.tokensBefore.toLocaleString()} → ~${e.tokensAfter.toLocaleString()} tok). reloading…`}var Ts=1e4,Es=5e3,Ds={file:null,size:0,conversationId:null};function Os(e){return e?.items.filter(e=>e.status===`pending`||e.status===`running`).length??0}function ks({agentId:e,initialMessages:n,initialSessionHead:r,onOpenLibrary:i,onConversation:a}){let u=`/api/agents/${encodeURIComponent(e)}`,[d,f]=(0,H.useState)(n),[p,m]=(0,H.useState)([]),[h,g]=(0,H.useState)([]),[_,v]=(0,H.useState)(!1),[y,b]=(0,H.useState)(!1),[x,S]=(0,H.useState)(!1),[C,w]=(0,H.useState)(!1),[T,E]=(0,H.useState)(!1),[D,ee]=(0,H.useState)(r?.unavailable??!1),[te,ne]=(0,H.useState)(null),[O,k]=(0,H.useState)(0),[re,ie]=(0,H.useState)({}),[ae,A]=(0,H.useState)({}),oe=(0,H.useRef)(null),j=(0,H.useRef)(!1),se=(0,H.useRef)(r??Ds),ce=(0,H.useRef)(null),le=(0,H.useRef)(0),ue=(0,H.useRef)(0),de=(0,H.useRef)(!1);de.current=y;let fe=(0,H.useRef)(T);fe.current=T;let pe=(0,H.useRef)(null),M=c(),me=y||x,N=me||!!te?.turnActive,he=te?.turnActive||te?.items.some(e=>e.status===`running`||e.status===`pending`&&!te.paused);function P(e){e.conversationId!==se.current.conversationId&&a?.(e.conversationId),se.current=e}function F(e){let t={id:le.current++,content:e,afterIndex:ue.current};g(e=>[...e,t])}async function ge(){if(!de.current)try{let e=await t(`${u}/sessions/messages`);ee(e.head.unavailable??!1),f(e.messages),m([]),w(!1),P(e.head),E(!1)}catch{F(`Conversation history is unavailable. Your draft is preserved.`)}}async function _e(){try{let e=await t(`${u}/sessions/head`),n=se.current.conversationId;if(n&&n!==e.conversationId){E(!0);return}ee(e.unavailable??!1),P(e)}catch{}}async function ve(){try{let e=await t(`${u}/queue`),n=Os(e)<Os(ce.current)&&!de.current;return n&&ge(),ce.current=e,ne(e),n}catch{return!1}}async function ye(){if(!(!r||fe.current||de.current))try{let e=await t(`${u}/sessions/head`),n=se.current;(!!e.unavailable!=!!n.unavailable||e.file!==n.file||e.size!==n.size)&&(E(!0),ve())}catch{}}(0,H.useEffect)(()=>()=>oe.current?.abort(),[]),(0,H.useEffect)(()=>{ve()},[]),(0,H.useEffect)(()=>M.subscribe(`activity`,t=>{let n=t.agents.find(t=>t.agentId===e)??null,r=pe.current;if(pe.current=n,!(!n||de.current)){if(!r)return void ye();if(n.working!==r.working||n.queuePaused!==r.queuePaused||n.followUps!==r.followUps){let e=r.working&&!n.working;ve().then(t=>{e&&!t&&ye()})}else !n.working&&n.lastActivityAt!==r.lastActivityAt&&ye()}}),[M.subscribe,e]),(0,H.useEffect)(()=>{if(!he||M.connected)return;let e=setInterval(()=>{document.hidden||ve()},Es);return()=>clearInterval(e)},[he,M.connected]),(0,H.useEffect)(()=>{if(!r||T||M.connected)return;let e=setInterval(()=>{document.hidden||ye()},Ts);return()=>clearInterval(e)},[u,r,T,M.connected]),(0,H.useEffect)(()=>{let n=new AbortController;return t(Eo(e),{signal:n.signal}).then(({approvals:t})=>{let n=t.filter(t=>t.agentId===e&&t.status===`pending`);n.length!==0&&(j.current=!0,m(e=>n.reduce(jo,e)),S(!0))}).catch(()=>{}),()=>n.abort()},[e]);async function I(e){try{return await t(`${u}/queue`,{body:{message:e.text,attachments:e.attachments}}),ve(),null}catch(t){return F(`The follow-up was not queued: ${l(t)}. Your draft is kept.`),e}}async function be(e){if(d.length<2){F(`/compact: need ≥2 messages to compact`);return}w(!1),b(!0),v(!0);try{F(ws(await t(`${u}/chat/compact`,{body:{keepTail:xs(e)}}))),setTimeout(()=>window.location.reload(),400)}catch(e){F(`/compact failed: ${l(e)}`)}finally{v(!1),b(!1)}}async function xe(e,n){switch(e){case`/help`:return F(ys),!0;case`/context`:try{F(Cs(await t(`${u}/chat/context`)))}catch(e){F(`/context failed: ${l(e)}`)}return!0;case`/new`:return i(),!0;case`/compact`:return await be(n),!0;default:return!1}}function Se(){return d.findLastIndex(e=>e.role===`user`)}function Ce(t){if(t.kind===`fatal`){j.current=!1,m(e=>[...Io(e),{type:`error`,content:`[fatal] ${t.error}`}]),S(!1);return}if(t.kind===`done`){j.current=!1,f(t.messages),m([]),S(!1),ie({}),A({});return}let n=t.event;if(n.type===`command_approval`){if(n.approval.agentId!==e)return;j.current=!0,v(n.approval.status!==`pending`&&n.approval.status!==`cancelled`)}else n.type===`agent_question`?k(e=>e+1):n.type===`assistant_delta`||n.type===`assistant_message`||n.type===`tool_call`?v(!1):(n.type===`tool_result`||n.type===`tool_error`)&&v(!0);m(e=>Fo(e,n))}async function we(e){let n=bs(e.text);if(n&&await xe(n.command,n.rest))return e.attachments.length>0?{text:``,attachments:e.attachments}:null;if(me)return C?(F(`Wait for the current turn to finish before replacing the last message.`),e):I(e);if(C){let n=Se();try{await t(`${u}/chat/truncate`,{body:{keepCount:n,conversationId:se.current.conversationId??void 0}})}catch(t){return F(`Could not replace the last turn: ${l(t)}`),e}f(e=>e.slice(0,n)),w(!1)}let r=e.attachments.filter(e=>Do(e.mimeType)),i=e.attachments.filter(e=>!Do(e.mimeType)).map(e=>({name:e.name??`file`}));m([{type:`user`,content:e.text,...r.length>0?{images:r}:{},...i.length>0?{files:i}:{}}]),S(!1),ie({}),A({}),j.current=!1;let a=new AbortController;oe.current=a,b(!0),v(!0);let c=!1,d=null;try{let t=await s(`${u}/chat`,{body:To(e.text,e.attachments),signal:a.signal});if(!t.body)throw Error(`the chat response has no body`);for await(let e of Lo(t.body))e.kind!==`event`&&(c=!0),Ce(e);await _e()}catch(t){t instanceof o?t.code===`agent_turn_active`?(m([]),d=await I(e)):(m([{type:`error`,content:`[error] ${t.message}`}]),d=e):t.name!==`AbortError`&&m(e=>[...e,{type:`error`,content:`[network error] ${l(t)}`}])}finally{oe.current===a&&(!c&&j.current&&S(!0),v(!1),b(!1),oe.current=null,ve(),k(e=>e+1))}return d}async function Te(){try{await t(`${u}/cancel`,{method:`POST`})}catch(e){e instanceof o&&e.status===409||F(`Stop was not confirmed; the response may still be running.`)}ve()}async function Ee(n){try{let{approvals:r}=await t(Eo(e)),i=r.find(t=>t.id===n&&t.agentId===e);return i&&m(e=>jo(e,i)),i??null}catch{return null}}async function De(n,r){if(!(n.agentId!==e||n.status!==`pending`)){ie(e=>({...e,[n.id]:!0})),A(({[n.id]:e,...t})=>t);try{let i=await t(`/api/shell-approvals/${encodeURIComponent(n.id)}`,{body:{decision:r}});i.approval.agentId===e&&m(e=>jo(e,i.approval))}catch(e){let t=await Ee(n.id);(!t||t.status===`pending`)&&A(t=>({...t,[n.id]:l(e)}))}finally{ie(e=>({...e,[n.id]:!1}))}}}function Oe(){if(p.length>0||me)return null;let e=Se();return e<0?null:(w(!0),d[e]?.content??null)}let ke=Oo(d),Ae=[...ke,...p];ue.current=Ae.length;let je=ke.findLastIndex(e=>e.type===`user`);return{entries:Ae,notes:h,replacedFrom:C?je:-1,editableEntry:!C&&p.length===0&&!me?je:-1,thinking:_,turnBusy:me,agentBusy:N,editing:C,stale:T,recoveredTurn:x,historyUnavailable:D,queue:te,questionsKey:O,approvals:{busy:re,errors:ae,decide:De},send:we,stop:Te,startEdit:Oe,cancelEdit:()=>w(!1),refreshHistory:ge,refreshQueue:ve,dismissStale:()=>E(!1)}}var As=40,js=`relative flex h-full flex-col overflow-hidden rounded-[16px] border border-frost bg-snow shadow-baziu-sm`;function Ms(e){return(0,$.jsx)(Ns,{...e},e.agentId)}function Ns({agentId:e,agentName:t,initialMessages:n,initialSessionHead:r,header:i,onViewConversation:a,onConversationChange:o}){let s=us(),c=ft(),[l,u]=(0,H.useState)(!1),d=ks({agentId:e,initialMessages:n,initialSessionHead:r,onOpenLibrary:()=>u(!0),onConversation:o}),[f,p]=(0,H.useState)(``),[m,h]=(0,H.useState)([]),[g,_]=(0,H.useState)(!1),v=(0,H.useRef)(null),y=(0,H.useRef)(null),b=(0,H.useRef)(!0);(0,H.useLayoutEffect)(()=>{let e=y.current;e&&b.current&&(e.scrollTop=e.scrollHeight)});async function x(e){let t=await Bo(e);h(e=>[...e,...t].slice(0,16))}async function S(){let e={text:f,attachments:m};if(!e.text.trim()&&e.attachments.length===0)return;p(``),h([]);let t=await d.send(e);c?.refresh(),t&&(p(e=>e||t.text),h(e=>e.length>0?e:t.attachments))}function C(){let e=d.startEdit();e!==null&&(p(e),v.current?.focus())}let w=!d.historyUnavailable&&d.entries.length===0&&d.notes.length===0,T=d.agentBusy&&!d.turnBusy,E=c?.stateOf(e),D=E?.kind===`working`?E.text.replace(/^Working:?\s*/,``):``,ee=E?.kind===`needs`;return(0,$.jsxs)(`section`,{"aria-label":`Chat with ${t}`,className:js,onDragOver:e=>{Array.from(e.dataTransfer.types).includes(`Files`)&&(e.preventDefault(),_(!0))},onDragLeave:e=>{e.currentTarget===e.target&&_(!1)},onDrop:e=>{e.dataTransfer.files.length!==0&&(e.preventDefault(),_(!1),x(e.dataTransfer.files))},children:[g&&(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-10 flex items-center justify-center rounded-[16px] border-2 border-dashed border-sapphire bg-sapphire-glow/80 text-[0.95em] font-medium text-sapphire-deep`,children:`drop images or files to attach`}),i?i({agentBusy:d.agentBusy,reload:d.refreshHistory,conversationsOpen:l,setConversationsOpen:u}):(0,$.jsx)(`div`,{className:`border-b border-frost px-4 py-2.5`,children:(0,$.jsx)(`h1`,{className:`m-0 truncate font-display text-xl text-charcoal`,children:t})}),d.historyUnavailable&&(0,$.jsx)(`p`,{role:`alert`,className:`mx-5 mt-2 text-sm`,children:`This conversation's history is unavailable. Start a new conversation from the list above; earlier conversations and their files stay listed.`}),d.stale&&(0,$.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`mx-5 mt-2 flex items-center gap-2 rounded-[10px] border border-sapphire-light bg-sapphire-glow px-3 py-2 text-[0.86em] text-sapphire-deep`,children:[(0,$.jsx)(`span`,{className:`h-2 w-2 flex-none rounded-full bg-sapphire`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`flex-1`,children:d.recoveredTurn?`The recovered turn has new activity.`:`There is new activity from another source (a follow-up, Telegram or a schedule).`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void d.refreshHistory(),className:`unstyled rounded-md bg-sapphire px-3 py-1 text-[0.92em] font-semibold text-snow hover:bg-sapphire-deep`,children:`Show it`}),(0,$.jsx)(`button`,{type:`button`,onClick:d.dismissStale,className:`unstyled px-1 text-sapphire-deep hover:opacity-70`,"aria-label":`Dismiss`,children:`×`})]}),(0,$.jsx)(`div`,{ref:y,onScroll:e=>{let t=e.currentTarget;b.current=t.scrollHeight-t.scrollTop-t.clientHeight<As},role:`log`,"aria-label":`Conversation with ${t}`,"aria-live":`polite`,"aria-relevant":`additions`,"aria-busy":d.turnBusy,className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,$.jsxs)(`div`,{className:`mx-auto max-w-[50rem]`,children:[w&&(0,$.jsxs)(`p`,{className:`py-12 text-center italic text-mocha-light`,children:[`Say what you need. `,t,` keeps this conversation between turns.`]}),(0,$.jsx)(_s,{entries:d.entries,notes:d.notes,markdownReady:s,editableEntry:d.editableEntry,replacedFrom:d.replacedFrom,onEdit:C,approvals:d.approvals}),(d.thinking||T)&&(0,$.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 px-1 py-1.5 text-[0.85em] ${ee?`text-warning`:`text-success`}`,children:[(0,$.jsx)(`span`,{className:`size-[7px] rounded-full ${ee?`bg-warning`:`animate-pulse bg-success`}`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{children:ee?`${t} is waiting for you`:`${t} is working${D?`: ${D}`:``}`})]})]})}),(0,$.jsx)(`p`,{className:`sr-only`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:d.turnBusy?`${t} is responding.`:`Conversation ready.`}),(0,$.jsx)(Ho,{agentId:e,queue:d.queue,onChanged:()=>void d.refreshQueue(),onViewConversation:e=>a?.(e)}),(0,$.jsx)(Co,{agentId:e,agentName:t,refreshKey:d.questionsKey}),(0,$.jsx)(Vo,{agentName:t,value:f,onChange:p,onSubmit:()=>void S(),attachments:m,onAddFiles:e=>void x(e),onRemoveAttachment:e=>h(t=>t.filter((t,n)=>n!==e)),editing:d.editing,onCancelEdit:d.cancelEdit,agentBusy:d.agentBusy,onStop:()=>void d.stop(),inputRef:v})]})}function Ps({team:e}){let{agentById:r,search:a,to:s}=I(),c=i(),l=St(),u=Va(e),[d,p]=(0,H.useState)(!1),[m,h]=(0,H.useState)(null),[g,_]=(0,H.useState)(null),v=$a(e.id,u.filter,48),y=v.results.filter(u.matches),b=a.result??null,x=v.results.find(e=>e.id===b),S=V(async e=>{if(!b||x)return null;try{return(await t(Ya(b),{signal:e})).result}catch(e){if(e instanceof o&&e.status===404)return null;throw e}},[b,!!x]),C=x??S.data??null,w=v.results.find(e=>e.id===m)??null,T=e=>void c.navigate({to:`/`,search:s({result:e}),replace:!0}),E=()=>{p(!1),h(null)};(0,H.useEffect)(E,[b]);let D=e=>r(e.agentId)?.name,ee=u.filter;return(0,$.jsxs)(me,{view:`files`,actions:v.total>0&&u.kind===`all`&&(0,$.jsxs)(`a`,{href:Xa({teamId:e.id,...ee}),download:!0,className:`ghost-btn min-h-8 px-3 py-1 text-xs`,children:[(0,$.jsx)(se,{className:`size-3.5`,"aria-hidden":`true`}),`Download `,u.narrowed?`these`:`all`,` `,v.total,` (.zip)`]}),children:[(0,$.jsxs)(`div`,{className:`grid h-full min-h-0 grid-cols-1 ${C?`lg:grid-cols-[minmax(0,1fr)_minmax(20rem,26rem)]`:``}`,children:[C&&w?(0,$.jsxs)(`div`,{className:`min-h-0 overflow-y-auto p-3 sm:p-4`,children:[(0,$.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(Lt,{className:`size-4 shrink-0 text-accent-foreground`,"aria-hidden":`true`}),(0,$.jsx)(`h2`,{className:`m-0 min-w-0 flex-1 font-body text-sm font-semibold text-foreground`,children:`Side by side`}),(0,$.jsx)(f,{variant:`ghost`,className:`min-h-8 px-3 py-1 text-xs`,onClick:E,children:`Stop comparing`})]}),(0,$.jsx)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:[C,w].map(e=>(0,$.jsxs)(`figure`,{className:`m-0 min-w-0`,children:[(0,$.jsx)(Fs,{result:e}),(0,$.jsxs)(`figcaption`,{className:`mt-1.5 flex items-center gap-2 text-xs text-mocha`,children:[(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.name,children:[(0,$.jsx)(`strong`,{className:`text-foreground`,children:e.name}),` ·`,` `,qa(e.byteLength),D(e)?` · ${D(e)}`:``]}),(0,$.jsx)(`a`,{href:Ya(e.id,`download`),download:e.name,className:`shrink-0 font-semibold`,children:`Download`})]})]},e.id))})]}):(0,$.jsxs)(`div`,{className:`min-h-0 overflow-y-auto p-3 sm:p-4 ${C?`hidden lg:block`:``}`,children:[(0,$.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(Ha,{state:u}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:v.loading&&v.results.length===0?`Loading…`:u.kind===`all`?`${v.total} file${v.total===1?``:`s`}`:`${y.length} of the ${v.results.length} loaded`})]}),d&&(0,$.jsxs)(`p`,{role:`status`,className:`mb-3 flex flex-wrap items-center gap-2 rounded-[10px] border border-primary/30 bg-accent/40 px-3 py-2 text-sm text-foreground`,children:[(0,$.jsx)(Lt,{className:`size-4 shrink-0 text-accent-foreground`,"aria-hidden":`true`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[`Choose the file to put beside `,(0,$.jsx)(`strong`,{children:C?.name}),`.`]}),(0,$.jsx)(f,{variant:`ghost`,className:`min-h-8 px-3 py-1 text-xs`,onClick:E,children:`Stop comparing`})]}),v.error&&(0,$.jsx)(`p`,{role:`alert`,className:`err`,children:v.error}),!v.loading&&!v.error&&y.length===0&&(0,$.jsx)(`p`,{className:`m-0 rounded-2xl border border-dashed border-border bg-muted/40 px-4 py-10 text-center text-sm text-muted-foreground`,children:v.total===0?`Nothing saved yet. Files an Agent delivers and pictures it generates are kept here with their original contents.`:`No file of this kind among the ones loaded.`}),(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(14rem,1fr))] gap-3`,children:y.map(e=>(0,$.jsx)(Za,{resultId:e.id,result:e,compact:!0,selected:e.id===b||e.id===m,detail:[D(e),l?rt(e.createdAt):null].filter(Boolean).join(` · `),open:s({result:e.id}),...d&&e.id!==b?{onPick:()=>h(e.id)}:{}},e.id))}),v.hasMore&&(0,$.jsx)(`div`,{className:`mt-4 text-center`,children:(0,$.jsx)(f,{variant:`ghost`,disabled:v.loading,onClick:v.more,children:v.loading?`Loading…`:`Show more (${v.total-v.results.length} left)`})})]}),C&&(0,$.jsxs)(`aside`,{"aria-label":`Details of ${C.name}`,className:`min-h-0 overflow-y-auto border-border p-3 sm:p-4 lg:border-l`,children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-start gap-2`,children:[(0,$.jsx)(`h2`,{className:`m-0 min-w-0 flex-1 break-words font-body text-base font-semibold leading-snug text-foreground`,children:C.name}),(0,$.jsx)(`button`,{type:`button`,"aria-label":`Close the details`,onClick:()=>T(void 0),className:`unstyled flex size-8 shrink-0 items-center justify-center rounded-[10px] text-mocha hover:bg-muted hover:text-foreground`,children:(0,$.jsx)(O,{className:`size-4`,"aria-hidden":`true`})})]}),(0,$.jsx)(Fs,{result:C}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,$.jsxs)(`a`,{href:Ya(C.id,`download`),download:C.name,className:`btn-primary min-h-9 px-3 py-1.5 text-sm no-underline`,children:[(0,$.jsx)(se,{className:`size-4`,"aria-hidden":`true`}),`Download`]}),w?(0,$.jsx)(f,{variant:`ghost`,className:`min-h-9`,onClick:E,children:`Stop comparing`}):(0,$.jsxs)(f,{variant:`ghost`,className:`min-h-9`,disabled:v.results.length<2,onClick:()=>p(!0),children:[(0,$.jsx)(Lt,{className:`size-4`,"aria-hidden":`true`}),`Compare`]}),(0,$.jsxs)(f,{variant:`danger`,className:`min-h-9`,onClick:()=>_(C),children:[(0,$.jsx)($t,{className:`size-4`,"aria-hidden":`true`}),`Delete`]})]}),(0,$.jsxs)(`dl`,{className:`m-0 mt-4 grid grid-cols-[max-content_minmax(0,1fr)] gap-x-3 gap-y-2 text-sm`,children:[(0,$.jsx)(`dt`,{className:`text-muted-foreground`,children:`Delivered by`}),(0,$.jsxs)(`dd`,{className:`m-0 flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(R,{identity:r(C.agentId)?.identity,size:18}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:D(C)??`An Agent that was deleted`})]}),(0,$.jsx)(`dt`,{className:`text-muted-foreground`,children:`Saved`}),(0,$.jsx)(`dd`,{className:`m-0`,children:l?new Date(C.createdAt).toLocaleString():``}),(0,$.jsx)(`dt`,{className:`text-muted-foreground`,children:`Kind`}),(0,$.jsxs)(`dd`,{className:`m-0`,children:[Ja(C.mimeType,C.name),` · `,qa(C.byteLength)]}),C.imageModel&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`dt`,{className:`text-muted-foreground`,children:`Made with`}),(0,$.jsx)(`dd`,{className:`m-0 break-all font-mono text-xs`,children:C.imageModel})]}),(0,$.jsx)(`dt`,{className:`text-muted-foreground`,children:`SHA-256`}),(0,$.jsxs)(`dd`,{className:`m-0 flex min-w-0 items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-mocha`,children:C.sha256}),(0,$.jsx)(Pa,{value:C.sha256,ariaLabel:`Copy the checksum`,title:`Copy`})]})]}),D(C)&&(0,$.jsxs)(n,{to:`/`,search:{agent:C.agentId,conversation:C.sessionId,panel:`files`},className:`ghost-btn mt-4 min-h-9 w-full text-sm`,children:[(0,$.jsx)(De,{className:`size-4`,"aria-hidden":`true`}),`Open the conversation it came from`]})]}),b&&!C&&!S.loading&&(0,$.jsx)(`p`,{role:`alert`,className:`m-0 p-4 text-sm text-muted-foreground`,children:`That saved file is not available any more.`})]}),(0,$.jsx)(Ct,{open:g!==null,title:`Delete ${g?.name??`this file`}?`,description:(0,$.jsx)(`p`,{children:`The saved copy is removed for good, and the conversation shows it as unavailable. A file of the same name in the Team's workspace, if there is one, is not touched.`}),confirmLabel:`Delete saved file`,onOpenChange:e=>{e||_(null)},onConfirm:async()=>{g&&(await t(Ya(g.id),{method:`DELETE`}),T(void 0),await v.reload())}})]})}function Fs({result:e}){let t=V(async t=>Ka(e)?(await s(Ya(e.id,`preview`),{signal:t})).text():null,[e.id]);return Ga(e)?(0,$.jsx)(`a`,{href:Ya(e.id,`preview`),target:`_blank`,rel:`noreferrer`,title:`Open at full size`,children:(0,$.jsx)(`img`,{src:Ya(e.id,`preview`),alt:e.name,className:`block max-h-[60vh] w-full rounded-[10px] border border-border bg-muted object-contain`})}):Ka(e)?(0,$.jsx)(`pre`,{className:`m-0 max-h-[60vh] overflow-auto whitespace-pre-wrap break-words rounded-[10px] border border-border bg-muted p-3 font-mono text-xs leading-relaxed`,children:t.error?l(t.error):t.data??`Loading…`}):(0,$.jsxs)(`p`,{className:`m-0 rounded-[10px] border border-dashed border-border bg-muted/50 px-3 py-8 text-center text-sm text-muted-foreground`,children:[`No preview for `,Ja(e.mimeType,e.name),` files. Download it to open it.`]})}var Is=`inline-flex h-[26px] shrink-0 items-center gap-1 rounded-full border border-border bg-muted px-2.5 text-xs font-semibold text-mocha hover:border-sapphire-light hover:text-sapphire`,Ls=`flex min-h-10 w-full cursor-pointer items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-sm text-foreground outline-none data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`;function Rs(e){let t=e.indexOf(`:`);return t>0?e.slice(t+1):e}function zs({agent:e,chat:t,panel:r,lastPanel:i}){let{to:a}=I();return(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-2 border-b border-frost px-3 py-2.5 sm:flex-nowrap sm:px-4`,children:[(0,$.jsx)(n,{to:`/`,search:{},"aria-label":`Back to the list of agents`,className:`flex size-8 shrink-0 items-center justify-center rounded-[10px] border border-border text-mocha lg:hidden`,children:(0,$.jsx)(ce,{className:`size-4`,"aria-hidden":`true`})}),(0,$.jsx)(R,{identity:e.agent.identity,size:32}),(0,$.jsx)(`h1`,{className:`m-0 min-w-0 truncate font-display text-xl leading-tight text-charcoal`,children:e.agent.name}),(0,$.jsx)(n,{to:`/`,search:a({panel:`team`,section:void 0}),className:Is,children:e.team.name}),(0,$.jsxs)(n,{to:`/`,search:a({panel:`agent`,section:void 0}),title:`Model: ${e.model}`,className:A(Is,`hidden font-mono font-normal sm:inline-flex`),children:[Rs(e.model),(0,$.jsx)(Re,{className:`size-[11px]`,"aria-hidden":`true`})]}),(0,$.jsxs)(`div`,{className:`ml-auto flex min-w-16 shrink items-center justify-end gap-1.5`,children:[(0,$.jsx)(Bs,{agentId:e.agent.id,chat:t}),(0,$.jsx)(n,{to:`/`,search:a({panel:r===`none`?i:`none`,section:void 0}),"aria-label":r===`none`?`Show the side panel`:`Hide the side panel`,title:r===`none`?`Show the side panel`:`Hide the side panel`,"aria-pressed":r!==`none`,className:`flex size-8 shrink-0 items-center justify-center rounded-[10px] border ${r===`none`?`border-border bg-card text-mocha hover:text-sapphire`:`border-primary/25 bg-accent text-accent-foreground`}`,children:(0,$.jsx)(fe,{className:`size-4`,"aria-hidden":`true`})})]})]})}function Bs({agentId:e,chat:r}){let{search:a,to:o}=I(),{turnsEnded:s}=B(),c=i(),u=St(),d=`/api/agents/${encodeURIComponent(e)}/conversations`,[f,v]=(0,H.useState)(!1),[y,b]=(0,H.useState)(null),[x,S]=(0,H.useState)(``),C=V(e=>t(`${d}?limit=20`,{signal:e}),[d,s]),w=r?r.conversationsOpen:f,T=r?r.setConversationsOpen:v,E=C.data?.conversations??[],D=C.data?.selectedId??null,ne=a.conversation??D,O=E.find(e=>e.id===ne);async function k(){S(``);try{await t(d,{body:{}}),r?await r.reload():(await c.invalidate({sync:!0}),await c.navigate({to:`/`,search:o({conversation:void 0})})),await C.reload()}catch(e){S(l(e)),T(!0)}}let ie=(0,H.useRef)(()=>{});return ie.current=()=>{if(r?.agentBusy){S(`Wait for the turn to end, or stop it, before starting a new conversation.`),T(!0);return}k()},(0,H.useEffect)(()=>{let t=t=>{t.detail?.agentId===e&&ie.current()};return window.addEventListener(lt,t),()=>window.removeEventListener(lt,t)},[e]),(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(te,{open:w,onOpenChange:e=>{T(e),e&&C.reload()},children:[(0,$.jsx)(ee,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,"aria-label":`Conversations`,className:`unstyled inline-flex h-8 min-w-0 max-w-[15rem] items-center gap-1.5 rounded-[10px] border border-border bg-card px-2.5 text-sm font-semibold text-foreground hover:border-sapphire-light`,children:[(0,$.jsx)(De,{className:`size-[15px] shrink-0 text-mocha`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:O?.title??`Conversations`}),(0,$.jsx)(Re,{className:`size-3 shrink-0 text-mocha`,"aria-hidden":`true`})]})}),(0,$.jsx)(h,{children:(0,$.jsxs)(g,{align:`end`,sideOffset:6,collisionPadding:12,className:`z-50 max-h-[70vh] w-[min(22rem,calc(100vw-1.5rem))] overflow-y-auto rounded-xl border border-border bg-popover p-1.5 text-popover-foreground shadow-baziu-lg outline-none`,children:[(0,$.jsx)(_,{className:`px-2.5 pb-1 pt-1.5 text-xs font-bold uppercase tracking-[0.08em] text-muted-foreground`,children:`Conversations`}),C.error&&(0,$.jsx)(`p`,{role:`alert`,className:`m-0 px-2.5 py-1.5 text-xs text-danger`,children:C.error}),x&&(0,$.jsx)(`p`,{role:`alert`,className:`m-0 px-2.5 py-1.5 text-xs text-danger`,children:x}),!C.data&&!C.error&&(0,$.jsx)(`p`,{role:`status`,className:`m-0 px-2.5 py-2 text-sm text-muted-foreground`,children:`Loading…`}),C.data&&E.length===0&&(0,$.jsx)(`p`,{className:`m-0 px-2.5 py-2 text-sm text-muted-foreground`,children:`The first message starts the first conversation.`}),E.map(e=>{let t=e.id===D,r=e.id===ne;return(0,$.jsx)(m,{asChild:!0,className:Ls,children:(0,$.jsxs)(n,{to:`/`,search:o({conversation:t?void 0:e.id}),"aria-current":r?`true`:void 0,className:r?`bg-accent/70 text-accent-foreground`:``,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:e.title}),t?(0,$.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-xs font-semibold text-success`,children:[(0,$.jsx)(re,{className:`size-3`,"aria-hidden":`true`}),`Active`]}):u&&(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:rt(e.createdAt)})]})},e.id)}),C.data&&C.data.total>E.length&&(0,$.jsxs)(`p`,{className:`m-0 px-2.5 py-1.5 text-xs text-muted-foreground`,children:[`The newest `,E.length,` of `,C.data.total,`.`,` `,(0,$.jsx)(`code`,{children:`bazilion conversation list`}),` shows them all.`]}),(0,$.jsx)(p,{className:`my-1.5 h-px bg-border`}),(0,$.jsxs)(m,{className:`${Ls} font-semibold`,disabled:r?.agentBusy??!1,onSelect:()=>void k(),children:[(0,$.jsx)(je,{className:`size-3.5`,"aria-hidden":`true`}),`New conversation`,r?.agentBusy&&(0,$.jsx)(`span`,{className:`ml-auto text-xs font-normal`,children:`after this turn`})]}),O&&(0,$.jsxs)(m,{className:Ls,onSelect:()=>b(O),children:[(0,$.jsx)(he,{className:`size-3.5`,"aria-hidden":`true`}),`Rename “`,O.title.length>24?`${O.title.slice(0,24)}…`:O.title,`”`]})]})})]}),y&&(0,$.jsx)(Vs,{base:d,conversation:y,onClose:()=>b(null),onRenamed:()=>C.reload()})]})}function Vs({base:e,conversation:n,onClose:r,onRenamed:i}){let[a,o]=(0,H.useState)(n.title),[s,c]=(0,H.useState)(!1),[u,d]=(0,H.useState)(``),p=!a.trim()||a.trim()===n.title;async function m(o){if(o.preventDefault(),!p){c(!0),d(``);try{await t(`${e}/${encodeURIComponent(n.id)}`,{method:`PATCH`,body:{title:a.trim()}}),await i(),r()}catch(e){d(l(e)),c(!1)}}}return(0,$.jsx)(Je,{title:`Rename the conversation`,busy:s,onClose:r,className:`max-w-md`,children:(0,$.jsxs)(`form`,{onSubmit:e=>void m(e),children:[(0,$.jsxs)(`label`,{children:[`Title`,(0,$.jsx)(`input`,{autoFocus:!0,value:a,maxLength:200,onChange:e=>o(e.target.value)})]}),u&&(0,$.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:u}),(0,$.jsx)(`div`,{className:`mt-4`,children:(0,$.jsxs)(Ve,{children:[(0,$.jsx)(f,{variant:`ghost`,disabled:s,onClick:r,children:`Cancel`}),(0,$.jsx)(f,{variant:`primary`,type:`submit`,disabled:s||p,children:s?`Renaming…`:`Rename`})]})})]})})}function Hs({agentId:e,agentName:r,conversationId:a,header:s}){let{to:c}=I(),u=i(),d=`/api/agents/${encodeURIComponent(e)}/conversations/${encodeURIComponent(a)}`,[p,m]=(0,H.useState)(!1),[h,g]=(0,H.useState)(``),_=V(async e=>{try{return await t(d,{signal:e})}catch(e){if(e instanceof o&&e.status===409)return{conversation:e.body.conversation??null,messages:null};throw e}},[d]);async function v(){m(!0),g(``);try{await t(`${d}/select`,{method:`POST`}),await u.invalidate({sync:!0}),await u.navigate({to:`/`,search:c({conversation:void 0})})}catch(e){g(l(e)),m(!1)}}let y=_.data?.conversation?.title;return(0,$.jsxs)(`section`,{"aria-label":`An earlier conversation with ${r}`,className:js,children:[s,(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-frost bg-muted px-4 py-2 text-sm`,children:[(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 basis-56 text-mocha`,children:[`You are reading`,` `,y?(0,$.jsx)(`strong`,{className:`text-foreground`,children:y}):`an earlier conversation`,`. New messages go to the active conversation.`]}),(0,$.jsx)(f,{variant:`primary`,className:`min-h-9`,disabled:p||!_.data?.messages,onClick:()=>void v(),children:p?`Switching…`:`Continue this conversation`}),(0,$.jsx)(n,{to:`/`,search:c({conversation:void 0}),className:`ghost-btn min-h-9`,children:`Back to the active one`})]}),h&&(0,$.jsx)(`p`,{role:`alert`,className:`m-0 px-5 pt-3 text-sm text-danger`,children:h}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,$.jsxs)(`div`,{className:`mx-auto max-w-[50rem]`,children:[_.error&&(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:_.error}),!_.data&&!_.error&&(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-mocha`,children:`Loading the conversation…`}),_.data&&(_.data.messages===null?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm`,children:`This conversation's history is unavailable, so it cannot be read or continued.`}):_.data.messages.length>0?(0,$.jsx)(vs,{messages:_.data.messages}):(0,$.jsx)(`p`,{className:`py-12 text-center italic text-mocha-light`,children:`This conversation is empty.`}))]})})]})}var Us=`m-0 mb-2 mt-7 font-body text-xs font-bold uppercase tracking-[0.08em] text-muted-foreground`,Ws=`flex min-h-14 items-center gap-3 rounded-2xl border border-border bg-card px-3.5 py-2 text-foreground shadow-baziu-sm hover:border-sapphire-light hover:bg-accent/30`,Gs=5,Ks=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`;function qs(){let{agents:e,teams:t,profiles:r,search:i}=I(),a=B(),o=at(),[s,c]=(0,H.useState)(!1),l=St(),u=$a(``,{},4),d=new Map(t.map(e=>[e.id,e.name])),p=new Map(e.map(e=>[e.id,a.stateOf(e.id)])),m=e=>p.get(e.id)??{kind:`idle`,text:``},h=e.filter(e=>m(e).kind===`needs`),g=e.filter(e=>m(e).kind===`working`),_=new Set([...h,...g].map(e=>e.id)),v=e.filter(e=>!_.has(e.id)).map(e=>({agent:e,at:a.byAgent.get(e.id)?.lastActivityAt??null})).filter(e=>e.at!==null).sort((e,t)=>t.at-e.at).slice(0,Gs),y=Math.max(o.open-o.agentWaits,0),b=Ze([...p.values()]),x=(e,t)=>{let r=m(e);return(0,$.jsx)(`li`,{children:(0,$.jsxs)(n,{to:`/`,search:{agent:e.id,...i.panel?{panel:i.panel}:{}},className:Ws,children:[(0,$.jsx)(R,{identity:e.identity,size:36}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`span`,{className:`block truncate text-base font-semibold`,children:[e.name,(0,$.jsxs)(`span`,{className:`font-normal text-mocha`,children:[` · `,d.get(e.teamId)]})]}),(0,$.jsxs)(`span`,{className:`mt-0.5 flex min-w-0 items-center gap-1.5 text-xs ${ge[r.kind]}`,children:[(0,$.jsx)(`span`,{className:`size-[7px] shrink-0 rounded-full ${M[r.kind]}`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:r.text})]})]}),t&&(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-mocha`,children:t}),(0,$.jsx)(`span`,{className:`shrink-0 text-xs font-semibold text-accent-foreground`,children:`Open`})]})},e.id)};return(0,$.jsxs)(`section`,{"aria-label":`Overview`,className:`flex h-full flex-col overflow-y-auto rounded-[16px] border border-border bg-card px-4 py-5 shadow-baziu-sm sm:px-8 sm:py-8`,children:[(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl`,children:[(0,$.jsx)(`h1`,{className:`m-0 font-display text-[1.9rem] leading-tight text-charcoal`,children:`Overview`}),(0,$.jsxs)(`p`,{className:`m-0 mt-1 text-sm text-mocha`,children:[Ks(e.length,`Agent`),` in `,Ks(t.length,`Team`),b?` · ${b}`:``]}),(0,$.jsx)(`h2`,{className:Us,children:`Waiting for you`}),h.length>0?(0,$.jsx)(`ul`,{className:`m-0 list-none space-y-2 p-0`,children:h.map(e=>x(e))}):(0,$.jsx)(`p`,{className:`m-0 rounded-2xl border border-dashed border-border bg-muted/40 px-4 py-3 text-sm text-muted-foreground`,children:`No Agent is waiting for you.`}),y>0&&(0,$.jsxs)(n,{to:`/attention`,className:`mt-2 inline-flex items-center gap-1.5 text-sm font-semibold`,children:[(0,$.jsx)(_t,{className:`size-3.5`,"aria-hidden":`true`}),Ks(y,`more item`),` in Attention`]}),g.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h2`,{className:Us,children:`Working now`}),(0,$.jsx)(`ul`,{className:`m-0 list-none space-y-2 p-0`,children:g.map(e=>x(e))})]}),(0,$.jsx)(`h2`,{className:Us,children:`Teams`}),(0,$.jsx)(`ul`,{className:`m-0 grid list-none grid-cols-1 gap-2 p-0 sm:grid-cols-2`,children:t.map(t=>(0,$.jsx)(Js,{team:t,members:e.filter(e=>e.teamId===t.id),summary:Ze(e.filter(e=>e.teamId===t.id).map(m))},t.id))}),e.length===0&&(0,$.jsx)(`div`,{className:`mt-4`,children:(0,$.jsxs)(f,{variant:`primary`,onClick:()=>c(!0),children:[(0,$.jsx)(je,{className:`size-4`,"aria-hidden":`true`}),`Add your first agent`]})}),u.results.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h2`,{className:Us,children:`Latest files`}),(0,$.jsx)(`div`,{className:`grid grid-cols-2 gap-2.5 sm:grid-cols-4`,children:u.results.map(t=>(0,$.jsx)(Za,{resultId:t.id,result:t,compact:!0,detail:e.find(e=>e.id===t.agentId)?.name,open:{team:t.teamId,view:`files`,result:t.id}},t.id))})]}),v.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h2`,{className:Us,children:`Recently active`}),(0,$.jsx)(`ul`,{className:`m-0 list-none space-y-2 p-0`,children:v.map(({agent:e,at:t})=>x(e,l?rt(t):void 0))})]})]}),s&&(0,$.jsx)(yt,{profiles:r,teams:t,teamId:t[0]?.id??`default`,onClose:()=>c(!1)})]})}function Js({team:e,members:t,summary:r}){return(0,$.jsx)(`li`,{children:(0,$.jsxs)(n,{to:`/`,search:{team:e.id},className:`flex h-full min-h-16 items-center gap-3 rounded-2xl border border-border bg-muted/40 px-3.5 py-2.5 text-foreground hover:border-sapphire-light hover:bg-accent/30`,children:[(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-base font-semibold`,children:e.name}),(0,$.jsxs)(`span`,{className:`block truncate text-xs text-mocha`,children:[Ks(t.length,`member`),r?` · ${r}`:``]})]}),(0,$.jsx)(`span`,{className:`flex shrink-0 -space-x-2`,"aria-hidden":`true`,children:t.slice(0,4).map(e=>(0,$.jsx)(`span`,{className:`rounded-full ring-2 ring-card`,children:(0,$.jsx)(R,{identity:e.identity,size:26})},e.id))})]})})}var Ys={headless:`without a window`,headed:`in a window`,attached:`your own, attached`};function Xs({agentId:e,agentName:n=`This Agent`}){let r=`/api/agents/${encodeURIComponent(e)}/browser`,[i,a]=(0,H.useState)(null),[o,s]=(0,H.useState)(!0),[c,u]=(0,H.useState)(null),[d,p]=(0,H.useState)(null),[m,h]=(0,H.useState)(!1),g=(0,H.useCallback)(async()=>{s(!0);try{a(await t(r))}catch(e){p(l(e))}finally{s(!1)}},[r]),_=(0,H.useCallback)(()=>{p(null),g()},[g]);(0,H.useEffect)(()=>{_()},[_]);async function v(e){u(e),p(null);try{e===`stop`?await t(`${r}/stop`,{method:`POST`}):await t(`${r}/profile`,{method:`DELETE`})}catch(e){p(l(e))}finally{await g(),u(null)}}let y=c!==null||o;return(0,$.jsxs)(j,{labelledBy:`agent-browser`,icon:(0,$.jsx)(Bt,{className:`size-5`}),title:`Browser`,description:`${n}’s own browser for pages that need one. It keeps its sign-ins between turns.`,action:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[i&&(i.running?(0,$.jsx)(S,{tone:`success`,children:`Running`}):(0,$.jsx)(S,{tone:`neutral`,children:`Stopped`})),(0,$.jsx)(f,{variant:`ghost`,disabled:y,onClick:_,children:o?`Checking…`:`Check again`})]}),children:[o&&!i&&(0,$.jsx)(ae,{children:(0,$.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted-foreground`,children:`Checking the browser…`})}),i&&(0,$.jsxs)(ie,{children:[(0,$.jsx)(C,{label:`Browser tools`,tone:i.enabled?void 0:`warning`,children:i.enabled?`On`:`Off in Setup → Tools`}),(0,$.jsx)(C,{label:`Saved sign-ins`,children:i.profilePresent?`Kept: cookies and sign-ins`:`None yet`}),(0,$.jsx)(C,{label:`Browser`,tone:i.browser?void 0:`warning`,children:i.browser?`${i.browser.name}, ${Ys[i.browser.mode]}`:`None found`})]}),(0,$.jsxs)(ae,{children:[i?.error&&(0,$.jsx)(w,{title:`The browser cannot run.`,children:(0,$.jsx)(`span`,{className:`whitespace-pre-wrap`,children:i.error})}),d&&(0,$.jsx)(w,{role:`alert`,title:`That did not work.`,children:d}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(f,{variant:`ghost`,disabled:y||!i?.running,onClick:()=>void v(`stop`),children:c===`stop`?`Stopping…`:`Stop it`}),(0,$.jsx)(f,{variant:`ghost`,disabled:y||!i?.profilePresent&&!i?.running,onClick:()=>h(!0),children:`Forget its sign-ins…`})]}),(0,$.jsx)(`p`,{className:`m-0 text-xs leading-5 text-muted-foreground`,children:`Stopping it, archiving the Agent or moving it to another Team keeps the sign-ins; forgetting them or deleting the Agent removes them. Backups leave them out.`})]}),(0,$.jsx)(Ct,{open:m,onOpenChange:h,title:`Forget ${n}’s sign-ins?`,description:(0,$.jsx)(`p`,{className:`m-0`,children:`The browser stops, and its cookies and sign-ins are deleted. The next page it opens starts signed out.`}),confirmLabel:`Forget the sign-ins`,onConfirm:()=>v(`reset`)})]})}function Zs({agentId:e,agentName:n,attached:r}){let i=V(e=>t(`/api/skills`,{signal:e}),[]);return i.data?(0,$.jsx)(Qs,{agentId:e,agentName:n,attached:new Set(r),all:i.data}):i.error?(0,$.jsx)(w,{role:`alert`,title:`The skills could not be loaded.`,children:i.error}):(0,$.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted-foreground`,children:`Loading the skills…`})}function Qs({agentId:e,agentName:n=`this Agent`,attached:r,all:a}){let o=i(),[s,c]=(0,H.useState)(null),[u,d]=(0,H.useState)(null),[f,p]=(0,H.useState)(null),[m,h]=(0,H.useState)(null),g=`/api/agents/${encodeURIComponent(e)}/skills`,_=a.filter(e=>r.has(e.name)).length;async function v(e,t){c(e),d(null);try{await t(),await o.invalidate()}catch(e){throw d(l(e)),e}finally{c(null)}}let y=e=>v(e.name,()=>t(g,{body:{skill:e.name,allowFindings:(e.scanFindings??[]).length>0}})),x=e=>v(e,()=>t(`${g}/${encodeURIComponent(e)}`,{method:`DELETE`}));return(0,$.jsxs)(j,{labelledBy:`agent-skills`,icon:(0,$.jsx)(Me,{className:`size-5`}),title:`Skills`,description:(0,$.jsxs)($.Fragment,{children:[`Instructions `,n,` follows on every turn. Install and remove skills under`,` `,(0,$.jsx)(`a`,{href:`/skills`,children:`Manage → Skills`}),`.`]}),action:(0,$.jsxs)(S,{tone:_>0?`success`:`neutral`,children:[_,` on`]}),children:[u&&(0,$.jsx)(`div`,{className:`border-t border-border px-4 py-3 sm:px-5`,children:(0,$.jsx)(w,{role:`alert`,title:`That did not work.`,children:u})}),a.length===0?(0,$.jsx)(E,{icon:(0,$.jsx)(Me,{className:`size-5`}),title:`No skills are installed`,children:`Import some under Manage → Skills, then switch them on here.`}):(0,$.jsx)(k,{children:a.map(e=>{let t=r.has(e.name),n=e.scanFindings??[],i=kt(e);return(0,$.jsx)(T,{inline:!0,title:(0,$.jsx)(`span`,{className:`font-mono text-[0.92em]`,children:e.name}),chip:i&&(0,$.jsx)(S,{tone:i.tone,children:i.label}),meta:(0,$.jsx)(`span`,{children:e.description||`No description.`}),actions:(0,$.jsx)(b,{label:`${e.name}: ${t?`on`:`off`}`,checked:t,disabled:s===e.name||!!e.parseError&&!t,onChange:()=>{t?h(e.name):n.length>0?p(e):y(e).catch(()=>{})}}),children:n.length>0&&(0,$.jsx)(Ne,{findings:n})},e.name)})}),(0,$.jsx)(Ct,{open:f!==null,onOpenChange:e=>{e||p(null)},title:`Switch on ${f?.name??`the skill`}?`,description:(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[(0,$.jsxs)(`p`,{className:`m-0`,children:[`The scan found something in it. Its text goes into `,n,`’s instructions, so read what was found first.`]}),(0,$.jsx)(`div`,{className:`text-sm`,children:(0,$.jsx)(Pe,{findings:f?.scanFindings??[]})})]}),confirmLabel:`Switch it on anyway`,onConfirm:async()=>{f&&await y(f)}}),(0,$.jsx)(Ct,{open:m!==null,onOpenChange:e=>{e||h(null)},title:`Switch off ${m??`the skill`}?`,description:(0,$.jsxs)(`p`,{className:`m-0`,children:[n,` stops following it from the next turn. The skill stays installed, and you can switch it on again.`]}),confirmVariant:`primary`,confirmLabel:`Switch it off`,onConfirm:async()=>{m&&await x(m)}})]})}var $s=[{value:`minimal`,label:`Its replies`},{value:`verbose`,label:`Its replies and every tool it uses`}];function ec({agent:e}){let n=i(),[r,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)(null),[c,u]=(0,H.useState)(e.telegramMirrorMode),[d,p]=(0,H.useState)(e.telegramIconEmoji??``),[m,h]=(0,H.useState)(!1),[g,_]=(0,H.useState)(!1),b=`/api/agents/${encodeURIComponent(e.id)}`,x=e.telegramTopicId!==null,T=d!==(e.telegramIconEmoji??``);async function E(e){a(!0),s(null);try{await e(),await n.invalidate()}catch(e){throw s(l(e)),e}finally{a(!1)}}async function D(){await E(async()=>{let{deepLink:e}=await t(`${b}/telegram/bind`,{method:`POST`});window.open(e,`_blank`,`noopener`)}).catch(()=>{})}async function ee(n){u(n),await E(()=>t(b,{method:`PATCH`,body:{telegramMirrorMode:n}})).catch(()=>u(e.telegramMirrorMode))}async function te(e){e.preventDefault(),await E(()=>t(b,{method:`PATCH`,body:{telegramIconEmoji:d.trim()||null}})).then(()=>h(!0)).catch(()=>{})}return(0,$.jsxs)(j,{labelledBy:`agent-telegram`,icon:(0,$.jsx)(Oe,{className:`size-5`}),title:`Telegram topic`,description:`${e.name}’s own topic in the Telegram group: its turns show there, and a message there starts one.`,action:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[x?(0,$.jsx)(S,{tone:`success`,children:`Has a topic`}):(0,$.jsx)(S,{tone:`neutral`,children:`No topic`}),x&&(0,$.jsx)(v,{label:`More for ${e.name}’s topic`,disabled:r,items:[{label:`Unbind…`,danger:!0,onSelect:()=>_(!0)}]})]}),children:[o&&(0,$.jsx)(`div`,{className:`border-t border-border px-4 py-3 sm:px-5`,children:(0,$.jsx)(w,{role:`alert`,title:`That did not work.`,children:o})}),(0,$.jsx)(ie,{children:(0,$.jsx)(C,{label:`Topic`,children:(0,$.jsxs)(`span`,{className:`flex flex-wrap items-center gap-3`,children:[(0,$.jsx)(`span`,{children:x?`Topic ${e.telegramTopicId}`:`None yet`}),(0,$.jsx)(f,{variant:`ghost`,onClick:()=>void D(),disabled:r,children:x?`Open in Telegram`:r?`Making it…`:`Make its topic`})]})})}),(0,$.jsxs)(y,{onSubmit:e=>void te(e),children:[(0,$.jsx)(Be,{label:`What shows in the topic`,value:c,options:$s,disabled:r,hint:`Changed at once.`,onChange:e=>void ee(e)}),(0,$.jsx)(L,{label:`Topic icon`,value:d,disabled:r,placeholder:`🦉`,hint:`An emoji; empty takes the template’s.`,className:`max-w-40`,onChange:e=>{p(e.slice(0,8)),h(!1)}}),(0,$.jsx)(gt,{busy:r,disabled:!T,label:`Save the icon`,status:it({dirty:T,saved:m,footnote:`On iOS, Telegram opens the list of topics rather than the topic.`})})]}),(0,$.jsx)(Ct,{open:g,onOpenChange:_,title:`Unbind ${e.name} from its topic?`,description:(0,$.jsx)(`p`,{className:`m-0`,children:`Its turns stop showing in the topic, and messages there no longer reach it. The topic stays in Telegram until you delete it there.`}),confirmLabel:`Unbind the topic`,onConfirm:()=>E(()=>t(`${b}/telegram/binding`,{method:`DELETE`}))})]})}function tc({agent:e}){let n=`/api/agents/${encodeURIComponent(e.id)}`,r=V(async e=>{let[r,i,a]=await Promise.all([t(`${n}/review-config`,{signal:e}),t(`${n}/reviews`,{signal:e}),t(`${n}/lesson-proposals`,{signal:e})]);return{config:r,reviews:i.reviews,proposals:a.proposals}},[n]),[i,a]=(0,H.useState)(null),[o,s]=(0,H.useState)(!1),c=St(),u=e=>c?new Date(e).toLocaleString():`…`,d=async(e,n)=>{a(null),s(!0);try{await t(e,n),await r.reload()}catch(e){throw a(l(e)),e}finally{s(!1)}};if(!r.data)return r.error?(0,$.jsx)(w,{role:`alert`,title:`Reviewed learning could not be loaded.`,children:r.error}):(0,$.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted-foreground`,children:`Loading reviewed learning…`});let{config:p,reviews:m,proposals:h}=r.data,g=h.filter(e=>e.status===`pending`),_=h.filter(e=>e.status!==`pending`);return(0,$.jsxs)(`div`,{className:`grid gap-5`,children:[i&&(0,$.jsx)(w,{role:`alert`,title:`That did not work.`,children:i}),(0,$.jsx)(j,{labelledBy:`agent-reviews`,icon:(0,$.jsx)(Nt,{className:`size-5`}),title:`Reviews`,description:`A review reads ${e.name}'s recent turns and proposes up to five lessons.`,action:(0,$.jsx)(f,{variant:`ghost`,disabled:o||e.status===`archived`,onClick:()=>void d(`${n}/reviews`,{method:`POST`}).catch(()=>{}),children:`Review now`}),children:(0,$.jsx)(nc,{config:p,disabled:o,onSave:async e=>{await t(`${n}/review-config`,{method:`PATCH`,body:e}),await r.reload()}})}),(0,$.jsx)(j,{labelledBy:`agent-lessons`,icon:(0,$.jsx)(Gt,{className:`size-5`}),title:`Lessons`,description:`What reviews proposed. A lesson applies only once you approve it.`,action:g.length>0&&(0,$.jsx)(S,{tone:`warning`,children:g.length===1?`1 to decide`:`${g.length} to decide`}),children:h.length===0?(0,$.jsx)(E,{icon:(0,$.jsx)(Gt,{className:`size-5`}),title:`No lessons yet`,children:`A review proposes lessons when it finds something worth keeping; it may also find nothing.`}):(0,$.jsxs)($.Fragment,{children:[g.map(e=>(0,$.jsx)(sc,{proposal:e,base:`${n}/lesson-proposals/${encodeURIComponent(e.id)}`,busy:o,act:d},`${e.id}:${e.version}`)),_.length>0&&(0,$.jsx)(k,{children:_.map(e=>(0,$.jsx)(lc,{proposal:e,base:`${n}/lesson-proposals/${encodeURIComponent(e.id)}`,busy:o,act:d},e.id))})]})}),(0,$.jsx)(j,{labelledBy:`agent-review-history`,icon:(0,$.jsx)(Vt,{className:`size-5`}),title:`Reviews so far`,description:`Each review, what started it, and what it found.`,children:m.length===0?(0,$.jsx)(E,{title:`No review has run yet`}):(0,$.jsx)(k,{children:m.map(e=>(0,$.jsx)(ic,{review:e,when:u(e.createdAt)},e.id))})})]})}function nc({config:e,disabled:n,onSave:r}){let i=V(e=>t(He,{signal:e}),[]),[a,o]=(0,H.useState)(e.enabled),[s,c]=(0,H.useState)(String(e.everyNTurns)),[u,d]=(0,H.useState)(e.model??``),[f,p]=(0,H.useState)(e.reasoningLevel),[m,h]=(0,H.useState)(!1),[g,_]=(0,H.useState)(!1),[v,b]=(0,H.useState)(null),x=Number(s),S=s!==``&&Number.isInteger(x)&&x>=1&&x<=100,C=a&&!S?`From 1 to 100 turns.`:void 0,w=S?x:e.everyNTurns,T=a!==e.enabled||w!==e.everyNTurns||u!==(e.model??``)||f!==e.reasoningLevel;async function E(e){if(e.preventDefault(),!C){h(!0),b(null);try{await r({enabled:a,everyNTurns:w,model:u||null,reasoningLevel:f}),_(!0)}catch(e){b(l(e))}finally{h(!1)}}}return(0,$.jsxs)(y,{onSubmit:e=>void E(e),children:[(0,$.jsx)(We,{label:`Review on its own`,description:a?`After every ${S?x:`…`} successful turns, reading at most the last 8 and 40,000 characters.`:`Off: a review runs only when you press Review now.`,checked:a,disabled:n,onChange:e=>{o(e),_(!1)}}),a&&(0,$.jsx)(L,{label:`Every how many turns`,value:s,inputMode:`numeric`,disabled:n,problem:C,className:`max-w-32`,onChange:e=>{c(e.replace(/\D/g,``)),_(!1)}}),(0,$.jsxs)(`div`,{className:`grid items-start gap-x-3 gap-y-4 sm:grid-cols-2`,children:[(0,$.jsx)(Ue,{kit:!0,disabled:n||m,label:`Model for reviews`,value:u,onChange:e=>{d(e),_(!1)},models:i.data?.chat??[],inherited:{label:`The Agent’s own model`}}),(0,$.jsx)(Be,{label:`Reasoning`,value:f,options:Ye.map(e=>({value:e,label:e})),disabled:n,className:`max-w-none`,onChange:e=>{p(e),_(!1)}})]}),(0,$.jsx)(gt,{busy:m,disabled:!T||n||!!C,status:it({error:v,dirty:T,saved:g,footnote:`${e.turnsSinceLast} successful turn${e.turnsSinceLast===1?``:`s`} since the last review.`})})]})}var rc={pending:{label:`Queued`,tone:`neutral`},running:{label:`Running`,tone:`success`},completed:{label:`Done`,tone:`success`},failed:{label:`Failed`,tone:`warning`},cancelled:{label:`Cancelled`,tone:`neutral`}};function ic({review:e,when:t}){let n=rc[e.status];return(0,$.jsx)(T,{inline:!0,title:t,chip:(0,$.jsx)(S,{tone:n.tone,children:n.label}),meta:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{children:e.trigger===`manual`?`Started by you`:`Ran on its own`}),(0,$.jsxs)(`span`,{children:[e.turnsReviewed,` turn`,e.turnsReviewed===1?``:`s`,` read`]}),(0,$.jsx)(`span`,{children:e.proposalCount===0?`no lessons`:`${e.proposalCount} lesson${e.proposalCount===1?``:`s`} proposed`})]}),children:e.lastError&&(0,$.jsx)(`p`,{className:`m-0 break-words text-sm text-danger`,children:e.lastError})})}function ac({proposal:e}){let t=e.evidence.filter(e=>e.excerpt);return t.length===0?null:(0,$.jsxs)(`details`,{className:`text-sm`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer font-semibold text-accent-foreground`,children:[`What it is based on (`,t.length,`)`]}),(0,$.jsx)(`ul`,{className:`m-0 mt-2 grid list-none gap-2 p-0`,children:t.map(e=>(0,$.jsx)(`li`,{className:`whitespace-pre-wrap break-words rounded-lg border-l-2 border-border bg-muted/40 px-3 py-2 text-muted-foreground`,children:e.excerpt},`${e.sessionId}:${e.entryOrdinal}`))})]})}var oc=[{value:`private`,label:`This Agent only`,hint:`Added to its own instructions, for its future turns.`},{value:`shared`,label:`The whole Team`,hint:`Kept in the Team’s shared memory, where every member can find it.`}];function sc({proposal:e,base:t,busy:n,act:r}){let[i,a]=(0,H.useState)(e.text),[o,s]=(0,H.useState)(e.scope),[c,l]=(0,H.useState)(!1),u={version:e.version},d=i!==e.text||o!==e.scope;async function p(){d?await r(t,{method:`PATCH`,body:{...u,text:i,scope:o}}):await r(`${t}/approve`,{body:u})}return(0,$.jsxs)(ae,{children:[(0,$.jsx)(ot,{label:`Proposed lesson`,value:i,rows:3,disabled:n,onChange:a}),(0,$.jsx)(vt,{legend:`If you approve it, it applies to`,name:`lesson-scope-${e.id}`,value:o,options:oc,disabled:n,onChange:s,notes:o===`shared`&&(0,$.jsx)(`span`,{className:`mt-1.5 block text-xs text-muted-foreground`,children:`Facts about you belong in the Team’s USER.md instead.`})}),(0,$.jsx)(ac,{proposal:e}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(f,{variant:`primary`,disabled:n,onClick:()=>void p().catch(()=>{}),children:d?`Save the edit`:`Approve`}),(0,$.jsx)(f,{variant:`ghost`,disabled:n,onClick:()=>l(!0),children:`Reject`}),d&&(0,$.jsx)(`span`,{className:`self-center text-sm text-warning`,children:`Edited: save it, then approve it.`})]}),c&&(0,$.jsx)(Ct,{open:!0,title:`Reject this lesson?`,description:(0,$.jsx)(`p`,{className:`m-0`,children:`It never reaches the Agent’s instructions or the Team’s memory, and it cannot be approved later. Unsaved edits are discarded.`}),confirmLabel:`Reject the lesson`,onOpenChange:e=>{e||l(!1)},onConfirm:()=>r(`${t}/reject`,{body:u})})]})}var cc={approved:{label:`Approved`,tone:`success`},rejected:{label:`Rejected`,tone:`neutral`},revoked:{label:`Revoked`,tone:`neutral`}};function lc({proposal:e,base:t,busy:n,act:r}){let[i,a]=(0,H.useState)(!1),o=cc[e.status];return(0,$.jsxs)(T,{inline:!0,title:(0,$.jsx)(`span`,{className:`font-normal`,children:e.text}),chip:(0,$.jsx)(S,{tone:o.tone,children:o.label}),meta:(0,$.jsx)(`span`,{children:e.scope===`shared`?`The whole Team`:`This Agent only`}),actions:e.status===`approved`&&(0,$.jsx)(v,{label:`More for this lesson`,disabled:n,items:[{label:`Revoke…`,danger:!0,onSelect:()=>a(!0)}]}),children:[(0,$.jsx)(ac,{proposal:e}),i&&(0,$.jsx)(Ct,{open:!0,title:`Revoke this lesson?`,description:(0,$.jsxs)(`p`,{className:`m-0`,children:[e.scope===`shared`?`Its note leaves the Team’s shared memory, so searches no longer find it.`:`It leaves the Agent’s instructions from the next turn; past conversations stay as they were.`,` `,`It stays listed here as revoked.`]}),confirmLabel:`Revoke the lesson`,onOpenChange:e=>{e||a(!1)},onConfirm:()=>r(`${t}/revoke`,{body:{version:e.version}})})]})}function uc({agent:e,agents:n}){let r=`/api/agents/${encodeURIComponent(e.id)}`,i=V(async e=>{let[i,a,o]=await Promise.all([t(`${r}/messages`,{signal:e}),t(`${r}/loop-breaks?limit=10`,{signal:e}),t(`/api/agents?includeArchived=true`,{signal:e}).catch(()=>n)]);return{messages:[...i.messages].reverse(),loopBreaks:a.events,agents:o}},[r]);return i.data?(0,$.jsx)(pc,{agent:e,...i.data,onChanged:i.reload}):i.error?(0,$.jsx)(w,{role:`alert`,title:`The mailbox could not be loaded.`,children:i.error}):(0,$.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted-foreground`,children:`Loading the mailbox…`})}function dc(e){let t=new Map(e.map(e=>[e.id,e])),n=new Map;for(let t of e)n.set(t.name,(n.get(t.name)??0)+1);return e=>{let r=t.get(e);if(!r)return`A deleted Agent`;let i=(n.get(r.name)??0)>1?`${r.name} (${e.slice(0,8)})`:r.name;return r.status===`archived`?`${i} (archived)`:i}}function fc(e,t){let n=dc(t);return t.filter(t=>t.status!==`archived`&&t.id!==e).map(e=>({value:e.id,label:n(e.id)}))}function pc({agent:e,agents:n,messages:r,loopBreaks:i,onChanged:a}){let[o,s]=(0,H.useState)(`all`),[c,u]=(0,H.useState)(null),[d,p]=(0,H.useState)(null),m=St(),h=e=>m?new Date(e).toLocaleString():``,g=r.filter(e=>e.readAt===null),_=o===`unread`?g:r,v=new Map(n.map(e=>[e.id,e])),y=dc(n),b=fc(e.id,n);async function C(e){u(e.id),p(null);try{await t(`/api/messages/${encodeURIComponent(e.id)}`,{method:`PATCH`,body:{read:!0}}),await a()}catch(e){p(l(e))}finally{u(null)}}return(0,$.jsxs)(`div`,{className:`grid gap-5`,children:[(0,$.jsxs)(j,{labelledBy:`agent-mailbox`,icon:(0,$.jsx)(Ut,{className:`size-5`}),title:`Messages`,description:`What other Agents sent ${e.name}. It reads the unread ones when it is next free.`,action:g.length>0?(0,$.jsxs)(S,{tone:`warning`,children:[g.length,` unread`]}):(0,$.jsx)(S,{tone:`neutral`,children:`0 unread`}),children:[r.length>0&&(0,$.jsx)(x,{children:(0,$.jsx)(wt,{label:`Which messages`,value:o,onChange:s,options:[{id:`all`,label:`All ${r.length}`},{id:`unread`,label:`Unread ${g.length}`}]})}),d&&(0,$.jsx)(`div`,{className:`border-t border-border px-4 py-3 sm:px-5`,children:(0,$.jsx)(w,{role:`alert`,title:`It could not be marked read.`,children:d})}),_.length===0?(0,$.jsx)(E,{icon:(0,$.jsx)(Ut,{className:`size-5`}),title:r.length===0?`No messages yet`:`Nothing unread`,children:r.length===0&&`Teammates write here with their messaging tool.`}):(0,$.jsx)(k,{children:_.map(e=>{let t=v.get(e.fromAgentId),n=e.readAt===null;return(0,$.jsx)(T,{inline:!0,leading:(0,$.jsx)(R,{identity:t?.identity,size:32}),title:`From ${y(e.fromAgentId)}`,chip:n&&(0,$.jsx)(S,{tone:`warning`,children:`Unread`}),meta:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{children:h(e.createdAt)}),e.replyTo&&(0,$.jsx)(`span`,{children:`A reply`})]}),actions:n&&(0,$.jsx)(f,{variant:`ghost`,disabled:c===e.id,"aria-label":`Mark the message from ${y(e.fromAgentId)} read`,onClick:()=>void C(e),children:`Mark read`}),children:(0,$.jsx)(`p`,{className:`m-0 whitespace-pre-wrap break-words rounded-xl bg-muted/50 px-3 py-2 text-sm text-foreground`,children:be(e.payload)})},e.id)})})]}),b.length>0&&(0,$.jsx)(mc,{agent:e,senders:b,onSent:()=>void a()}),(0,$.jsx)(j,{labelledBy:`agent-loop-breaks`,icon:(0,$.jsx)(qt,{className:`size-5`}),title:`Stopped chains`,description:`When Agents keep answering each other past the limit, the chain stops and shows here.`,children:i.length===0?(0,$.jsx)(E,{title:`No chain has been stopped`}):(0,$.jsx)(k,{children:i.map(e=>(0,$.jsx)(T,{inline:!0,title:`${y(e.fromAgentId)} → ${y(e.toAgentId)}`,meta:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{children:[`Stopped at message `,e.attemptedHop,`; the limit is `,e.maxHops]}),(0,$.jsx)(`span`,{children:h(e.createdAt)})]})},e.id))})})]})}function mc({agent:e,senders:n,onSent:r}){let[i,a]=(0,H.useState)(n[0]?.value??``),[o,s]=(0,H.useState)(``),[c,u]=(0,H.useState)(null),[d,p]=(0,H.useState)(!1),[m,h]=(0,H.useState)(!1);async function g(n){if(n.preventDefault(),o.trim()){u(null),h(!0);try{let n={from:i,payload:{text:o}};await t(`/api/agents/${encodeURIComponent(e.id)}/messages`,{body:n}),s(``),p(!0),r()}catch(e){u(l(e))}finally{h(!1)}}}return(0,$.jsx)(j,{labelledBy:`agent-mailbox-send`,icon:(0,$.jsx)(P,{className:`size-5`}),title:`Send a message to this Agent`,description:`Write to ${e.name} as one of its teammates, to see how it handles mail.`,children:(0,$.jsxs)(y,{onSubmit:e=>void g(e),children:[(0,$.jsx)(Be,{label:`From`,value:i,options:n,disabled:m,onChange:a}),(0,$.jsx)(ot,{label:`Message`,value:o,rows:3,disabled:m,onChange:e=>{s(e),p(!1)}}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[(0,$.jsx)(f,{variant:`primary`,type:`submit`,disabled:m||!o.trim(),children:m?`Sending…`:`Send`}),(0,$.jsx)(`p`,{role:`status`,className:`m-0 text-sm font-medium ${c?`text-warning`:`text-success`}`,children:c?`Not sent: ${c}`:d?`Sent. ${e.name} reads it when it is free.`:``})]})]})})}var hc=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],gc=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function _c(e){return e%86400==0?e===86400?`Every day`:`Every ${gc(e/86400,`day`)}`:e%3600==0?e===3600?`Every hour`:`Every ${gc(e/3600,`hour`)}`:e%60==0?e===60?`Every minute`:`Every ${gc(e/60,`minute`)}`:`Every ${gc(e,`second`)}`}var vc=e=>/^\d+$/.test(e)?Number(e):null,yc=(e,t)=>`${String(e).padStart(2,`0`)}:${String(t).padStart(2,`0`)}`;function bc(e){let t=e.trim().split(/\s+/);if(t.length!==5)return null;let[n=``,r=``,i=``,a=``,o=``]=t;if(i!==`*`||a!==`*`)return null;let s=/^\*\/(\d+)$/.exec(n);if(s&&r===`*`&&o===`*`)return _c(Number(s[1])*60);if(n===`*`&&r===`*`&&o===`*`)return`Every minute`;let c=vc(n);if(c===null||c>59)return null;if(r===`*`&&o===`*`)return c===0?`Every hour`:`Every hour at :${yc(0,c).slice(3)}`;let l=vc(r);if(l===null||l>23)return null;let u=yc(l,c);if(o===`*`)return`Every day at ${u}`;if(o===`1-5`)return`Weekdays at ${u}`;if(o===`0,6`||o===`6,0`)return`Weekends at ${u}`;let d=vc(o);return d!==null&&d<=7?`Every ${hc[d%7]} at ${u}`:null}function xc(e){if(e.kind===`interval`)return{text:_c(e.intervalSec??0),raw:!1};let t=e.cronExpr??``,n=bc(t);return n?{text:n,raw:!1}:{text:t,raw:!0}}var Sc=[{value:`minutes`,label:`Every few minutes`},{value:`hourly`,label:`Every hour`},{value:`daily`,label:`Every day`},{value:`weekdays`,label:`Every weekday`},{value:`weekly`,label:`Once a week`},{value:`cron`,label:`A cron expression`}],Cc=[1,2,3,4,5,6,0].map(e=>({value:String(e),label:hc[e]??``})),wc={repeat:`weekdays`,minutes:`30`,time:`09:00`,day:`1`,cron:``,message:``};function Tc(e){let t=e.message.trim(),n=(e,t)=>({request:null,problem:t,field:e}),r=e=>t?{request:{...e,message:t},problem:null,field:null}:n(`message`,`Write the message the Agent gets.`),i=/^(\d{1,2}):(\d{2})$/.exec(e.time),a=i?Number(i[1]):NaN,o=i?Number(i[2]):NaN,s=a>=0&&a<=23&&o>=0&&o<=59;switch(e.repeat){case`minutes`:{let t=Number(e.minutes);return!Number.isInteger(t)||t<1?n(`minutes`,`Give a whole number of minutes.`):r({kind:`interval`,intervalSec:t*60})}case`hourly`:return r({kind:`cron`,cronExpr:`0 * * * *`});case`daily`:case`weekdays`:case`weekly`:return s?r({kind:`cron`,cronExpr:`${o} ${a} * * ${e.repeat===`daily`?`*`:e.repeat===`weekdays`?`1-5`:e.day}`}):n(`time`,`Give a time of day, such as 09:00.`);case`cron`:{let t=e.cron.trim().replace(/\s+/g,` `);return t.split(` `).length===5?r({kind:`cron`,cronExpr:t}):n(`cron`,`A cron expression has five fields: minute, hour, day, month, weekday.`)}}}function Ec({agent:e}){let n=`/api/agents/${encodeURIComponent(e.id)}/triggers`,r=V(e=>t(n,{signal:e}),[n]);return r.data?(0,$.jsx)(Oc,{agentId:e.id,agentName:e.name,...r.data,onChanged:r.reload}):r.error?(0,$.jsx)(w,{role:`alert`,title:`The schedules could not be loaded.`,children:r.error}):(0,$.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted-foreground`,children:`Loading the schedules…`})}var Dc={pending:{label:`Waiting for the Agent`,tone:`neutral`},running:{label:`Running`,tone:`success`},succeeded:{label:`Done`,tone:`success`},failed:{label:`Failed`,tone:`warning`},cancelled:{label:`Cancelled`,tone:`neutral`}};function Oc({agentId:e,agentName:n=`The Agent`,triggers:r,dispatches:i,onChanged:a}){let[o,s]=(0,H.useState)(!1),[c,u]=(0,H.useState)(null),[d,p]=(0,H.useState)(null),[m,h]=(0,H.useState)(null),g=St(),_=e=>g?new Date(e).toLocaleString():``,y=new Map(r.map(e=>[e.id,e]));async function x(e){h(e.id),p(null);try{await t(`/api/triggers/${encodeURIComponent(e.id)}`,{method:`PATCH`,body:{enabled:!e.enabled}}),await a()}catch(e){p(l(e))}finally{h(null)}}return(0,$.jsxs)(`div`,{className:`grid gap-5`,children:[(0,$.jsxs)(j,{labelledBy:`agent-schedules`,icon:(0,$.jsx)(Ft,{className:`size-5`}),title:`Schedules`,description:`Each one sends ${n} its message at the times it says.`,action:r.length>0&&(0,$.jsxs)(f,{variant:`primary`,onClick:()=>s(!0),children:[(0,$.jsx)(je,{className:`size-4`,"aria-hidden":`true`}),`Add a schedule`]}),children:[d&&(0,$.jsx)(`div`,{className:`border-t border-border px-4 py-3 sm:px-5`,children:(0,$.jsx)(w,{role:`alert`,title:`That did not work.`,children:d})}),r.length===0?(0,$.jsxs)(E,{icon:(0,$.jsx)(Ft,{className:`size-5`}),title:`No schedules yet`,action:(0,$.jsxs)(f,{variant:`primary`,onClick:()=>s(!0),children:[(0,$.jsx)(je,{className:`size-4`,"aria-hidden":`true`}),`Add a schedule`]}),children:[`A schedule gives `,n,` a message at set times: a morning check, a weekly summary.`]}):(0,$.jsx)(k,{children:r.map(e=>{let t=xc(e);return(0,$.jsx)(T,{inline:!0,title:t.raw?(0,$.jsx)(`code`,{className:`font-mono text-[0.92em]`,children:t.text}):t.text,chip:e.enabled?(0,$.jsx)(S,{tone:`success`,children:`On`}):(0,$.jsx)(S,{tone:`neutral`,children:`Paused`}),meta:(0,$.jsx)(`span`,{children:e.lastFiredAt?`Last ran ${_(e.lastFiredAt)}`:`Has not run yet`}),actions:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(b,{label:`${t.text}: ${e.enabled?`on`:`paused`}`,checked:e.enabled,disabled:m===e.id,onChange:()=>void x(e)}),(0,$.jsx)(v,{label:`More for ${t.text}`,items:[{label:`Delete…`,danger:!0,onSelect:()=>u(e)}]})]}),children:(0,$.jsx)(`p`,{className:`m-0 whitespace-pre-wrap break-words rounded-xl bg-muted/50 px-3 py-2 text-sm text-foreground`,children:e.message})},e.id)})})]}),(0,$.jsx)(j,{labelledBy:`agent-schedule-runs`,icon:(0,$.jsx)(Vt,{className:`size-5`}),title:`Recent runs`,description:`Each time a schedule came due, and how it went.`,children:i.length===0?(0,$.jsx)(E,{title:`Nothing has run yet`,children:`A schedule's first run shows here once its time comes.`}):(0,$.jsx)(k,{children:i.map(e=>{let t=Dc[e.status],n=y.get(e.triggerId);return(0,$.jsx)(T,{inline:!0,title:_(e.scheduledAt)||`…`,chip:(0,$.jsx)(S,{tone:t.tone,children:t.label}),meta:(0,$.jsx)(`span`,{children:n?xc(n).text:`A deleted schedule`}),children:e.error&&(0,$.jsx)(`p`,{className:`m-0 break-words text-sm text-danger`,children:e.error})},e.id)})})}),o&&(0,$.jsx)(kc,{agentId:e,agentName:n,onClose:()=>s(!1),onAdded:async()=>{s(!1),await a()}}),(0,$.jsx)(Ct,{open:c!==null,title:`Delete this schedule?`,description:(0,$.jsxs)(`p`,{className:`m-0`,children:[c?xc(c).text:`The schedule`,` stops, and its run history goes with it. `,n,` and its conversations stay.`]}),confirmLabel:`Delete the schedule`,onConfirm:async()=>{c&&(await t(`/api/triggers/${encodeURIComponent(c.id)}`,{method:`DELETE`}),await a())},onOpenChange:e=>{e||u(null)}})]})}function kc({agentId:e,agentName:n,onClose:r,onAdded:i}){let[a,o]=(0,H.useState)(wc),[s,c]=(0,H.useState)(!1),[u,d]=(0,H.useState)(!1),[p,m]=(0,H.useState)(null),h=(e,t)=>{o(n=>({...n,[e]:t})),m(null)},g=Tc(a),_=Tc({...a,message:a.message.trim()||`…`}),v=_.request?xc(_.request):null,y=e=>s&&g.field===e?g.problem:void 0;async function b(n){if(n.preventDefault(),c(!0),g.request){d(!0);try{await t(`/api/agents/${encodeURIComponent(e)}/triggers`,{body:g.request}),await i()}catch(e){m(l(e)),d(!1)}}}return(0,$.jsx)(Je,{title:`Add a schedule`,description:`${n} gets the message at these times, as if you had written it.`,busy:u,onClose:r,children:(0,$.jsxs)(`form`,{onSubmit:e=>void b(e),className:`grid gap-4`,children:[(0,$.jsxs)(`div`,{className:`grid items-start gap-x-3 gap-y-4 sm:grid-cols-2`,children:[(0,$.jsx)(Be,{label:`Repeat`,value:a.repeat,options:Sc,disabled:u,onChange:e=>h(`repeat`,e),className:`max-w-none`}),a.repeat===`minutes`&&(0,$.jsx)(L,{label:`Every how many minutes`,value:a.minutes,inputMode:`numeric`,disabled:u,problem:y(`minutes`),className:`max-w-none`,onChange:e=>h(`minutes`,e.replace(/\D/g,``))}),(a.repeat===`daily`||a.repeat===`weekdays`)&&(0,$.jsx)(L,{label:`At`,type:`time`,value:a.time,problem:y(`time`),disabled:u,className:`max-w-none`,onChange:e=>h(`time`,e)}),a.repeat===`cron`&&(0,$.jsx)(L,{label:`Cron expression`,value:a.cron,problem:y(`cron`),mono:!0,placeholder:`*/15 9-17 * * 1-5`,disabled:u,className:`max-w-none`,hint:`Minute, hour, day of the month, month, day of the week.`,onChange:e=>h(`cron`,e)})]}),a.repeat===`weekly`&&(0,$.jsxs)(`div`,{className:`grid items-start gap-x-3 gap-y-4 sm:grid-cols-2`,children:[(0,$.jsx)(Be,{label:`On`,value:a.day,options:Cc,disabled:u,onChange:e=>h(`day`,e),className:`max-w-none`}),(0,$.jsx)(L,{label:`At`,type:`time`,value:a.time,problem:y(`time`),disabled:u,className:`max-w-none`,onChange:e=>h(`time`,e)})]}),(0,$.jsx)(ot,{label:`Message`,value:a.message,rows:3,disabled:u,placeholder:`Morning check: what is blocked, what ships today?`,problem:y(`message`),onChange:e=>h(`message`,e)}),v&&(0,$.jsx)(`p`,{className:`m-0 text-sm text-muted-foreground`,children:v.raw?(0,$.jsxs)($.Fragment,{children:[n,` gets it when `,(0,$.jsx)(`code`,{children:v.text}),` matches, on this computer's clock.`]}):(0,$.jsxs)($.Fragment,{children:[n,` gets it: `,v.text.charAt(0).toLowerCase()+v.text.slice(1),`, on this computer's clock.`]})}),p&&(0,$.jsx)(w,{role:`alert`,title:`The schedule was not added.`,children:p}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(f,{variant:`primary`,type:`submit`,disabled:u,children:u?`Adding…`:`Add the schedule`}),(0,$.jsx)(f,{variant:`ghost`,disabled:u,onClick:r,children:`Cancel`})]})]})})}function Ac(e,t){return{key:e,title:co(t)??e.split(`/`).pop()?.replace(/\.md$/,``)??e,preview:lo(t,110)}}function jc({team:e,openKey:n}){let r=`/api/teams/${encodeURIComponent(e.id)}/memory`,i=e=>`${r}/${e.split(`/`).map(encodeURIComponent).join(`/`)}`,a=St(),[o,s]=(0,H.useState)([]),[c,u]=(0,H.useState)(0),[p,m]=(0,H.useState)(!1),[h,g]=(0,H.useState)(``),[_,b]=(0,H.useState)({mode:`none`}),[S,C]=(0,H.useState)(!1),[T,D]=(0,H.useState)(!1),[ee,te]=(0,H.useState)(null),[O,k]=(0,H.useState)(null),[re,ie]=(0,H.useState)(null),[ae,se]=(0,H.useState)(null),ce=_.mode===`edit`&&_.draft!==_.content||_.mode===`new`&&(_.key.trim()!==``||_.draft!==``),le=_.mode===`read`||_.mode===`edit`?_.key:null;async function ue(e){try{if(e.trim())s((await t(`${r}/search?q=${encodeURIComponent(e)}&limit=50`)).map(e=>Ac(e.key,e.snippet))),m(!0);else{let e=await t(r);s(e.map(e=>Ac(e.key,e.content))),u(e.length),m(!1)}}catch(e){te(l(e))}}(0,H.useEffect)(()=>{let e=setTimeout(()=>void ue(h),200);return()=>clearTimeout(e)},[h]),(0,H.useEffect)(()=>{n&&fe(n)},[n]);function de(e){ce?k(()=>e):e()}async function fe(e){te(null),D(!1),se(e);try{let n=await t(i(e));b({mode:`read`,key:n.key,content:n.content??``})}catch(e){te(l(e))}finally{se(null)}}async function pe(e){if(e.preventDefault(),_.mode!==`edit`&&_.mode!==`new`)return;let n=_.key.trim();if(n){C(!0),te(null);try{await t(i(n),{method:`PUT`,body:{content:_.draft}}),b({mode:`read`,key:n,content:_.draft}),D(!0),await ue(h)}catch(e){te(l(e))}finally{C(!1)}}}let M=_.mode===`none`?null:_,me=M===null?``:M.mode===`new`?`A new note`:Ac(M.key,M.mode===`edit`?M.draft:M.content).title;return(0,$.jsxs)(`div`,{className:`grid items-start gap-5 lg:grid-cols-[minmax(0,21rem)_minmax(0,1fr)]`,children:[(0,$.jsx)(d,{when:ce,subject:`note`}),(0,$.jsxs)(j,{labelledBy:`team-notes`,icon:(0,$.jsx)(Kt,{className:`size-5`}),title:`Notes`,description:c===1?`1 note`:`${c} notes`,action:(0,$.jsxs)(f,{variant:`ghost`,onClick:()=>de(()=>{D(!1),b({mode:`new`,key:``,draft:``})}),children:[(0,$.jsx)(je,{className:`size-4`,"aria-hidden":`true`}),`New note`]}),children:[(0,$.jsx)(x,{children:(0,$.jsx)(oe,{label:`Search the notes`,placeholder:`Search the notes`,value:h,onChange:g,className:`flex-1`})}),o.length===0?(0,$.jsx)(E,{title:p?`No note matches`:`No notes yet`,children:p?`Try another word.`:`Agents keep here what the whole Team should remember; you can write notes too.`}):(0,$.jsx)(`ul`,{className:`m-0 max-h-[56dvh] list-none overflow-y-auto p-0`,children:o.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,"aria-current":e.key===le?`true`:void 0,onClick:()=>{e.key!==le&&de(()=>void fe(e.key))},className:A(ne,`unstyled block w-full py-2.5 text-left transition-colors hover:bg-accent/30`,e.key===le&&`bg-accent/50`),children:[(0,$.jsx)(`span`,{className:`block w-full truncate text-sm font-semibold text-foreground`,children:e.title}),(0,$.jsx)(`span`,{className:`block w-full truncate font-mono text-xs text-muted-foreground`,children:e.key}),e.preview&&(0,$.jsx)(`span`,{className:`mt-0.5 line-clamp-2 block w-full text-sm text-muted-foreground`,children:e.preview})]})},e.key))})]}),(0,$.jsxs)(`section`,{"aria-label":me||`Note`,className:`min-w-0 overflow-hidden rounded-2xl border border-border bg-card shadow-baziu-sm`,children:[ee&&(0,$.jsx)(`div`,{className:`px-4 pt-4 sm:px-5`,children:(0,$.jsx)(w,{role:`alert`,title:`That did not work.`,children:ee})}),ae===null?M===null?(0,$.jsx)(E,{icon:(0,$.jsx)(Kt,{className:`size-5`}),title:`Pick a note to read it`,children:`Or write a new one with New note.`}):M.mode===`read`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 px-4 py-4 sm:px-5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h3`,{className:`m-0 font-body text-lg font-semibold text-foreground`,children:me}),(0,$.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:M.key})]}),T&&(0,$.jsx)(`span`,{role:`status`,className:`text-sm font-medium text-success`,children:`Saved.`}),(0,$.jsx)(f,{variant:`ghost`,onClick:()=>{D(!1),b({...M,mode:`edit`,draft:M.content})},children:`Edit`}),(0,$.jsx)(v,{label:`More for ${me}`,items:[{label:`Delete…`,danger:!0,onSelect:()=>ie(M.key)}]})]}),(0,$.jsx)(`div`,{className:`md-content max-h-[60dvh] overflow-y-auto border-t border-border px-4 py-4 text-base leading-[1.6] text-chocolate sm:px-5`,dangerouslySetInnerHTML:{__html:ea(M.content,a)}})]}):(0,$.jsxs)(y,{onSubmit:e=>void pe(e),className:`border-t-0`,children:[M.mode===`new`?(0,$.jsx)(L,{label:`Name`,value:M.key,mono:!0,disabled:S,placeholder:`decisions/launch-date.md`,hint:`A path: folders group notes, such as people/sam.md.`,onChange:e=>b({...M,key:e})}):(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`m-0 font-body text-lg font-semibold text-foreground`,children:me}),(0,$.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:M.key})]}),(0,$.jsx)(ot,{label:`Text`,value:M.draft,rows:14,mono:!0,disabled:S,hint:`Markdown. A first line such as “# Launch date” names the note.`,onChange:e=>b({...M,draft:e})}),(0,$.jsx)(gt,{busy:S,disabled:!ce||!M.key.trim(),status:it({dirty:ce,saved:!1}),extra:(0,$.jsx)(f,{variant:`ghost`,disabled:S,onClick:()=>de(()=>M.mode===`edit`?b({mode:`read`,key:M.key,content:M.content}):b({mode:`none`})),children:`Cancel`})})]}):(0,$.jsxs)(`p`,{role:`status`,className:`m-0 px-4 py-6 text-sm text-muted-foreground sm:px-5`,children:[`Opening `,ae,`…`]})]}),(0,$.jsx)(Ct,{open:O!==null,title:`Drop your unsaved edit?`,description:(0,$.jsx)(`p`,{className:`m-0`,children:`What you changed in this note is lost.`}),confirmLabel:`Drop the edit`,onConfirm:()=>{let e=O;k(null),e?.()},onOpenChange:e=>{e||k(null)}}),(0,$.jsx)(Ct,{open:re!==null,title:`Delete this note?`,description:(0,$.jsxs)(`p`,{className:`m-0`,children:[(0,$.jsx)(`code`,{className:`font-mono`,children:re}),` leaves the Team’s shared memory, and searches no longer find it.`]}),confirmLabel:`Delete the note`,onConfirm:async()=>{re&&(await t(i(re),{method:`DELETE`}),b({mode:`none`}),await ue(h))},onOpenChange:e=>{e||ie(null)}})]})}function Mc(e,t){return{image:e.trim()||null,cwd:t.trim()||`.`}}function Nc({teamId:e}){let[n,r]=(0,H.useState)(null),[i,a]=(0,H.useState)(``),[o,s]=(0,H.useState)(`.`),[c,u]=(0,H.useState)(``),[d,f]=(0,H.useState)(!1),[p,m]=(0,H.useState)(!1),h=`/api/teams/${encodeURIComponent(e)}/coding-environment`,g=n!==null&&(i!==(n.image??``)||o!==n.cwd);function _(e){r(e),a(e.image??``),s(e.cwd)}(0,H.useEffect)(()=>{let e=new AbortController;return t(h,{signal:e.signal}).then(_).catch(t=>{e.signal.aborted||u(l(t))}),()=>e.abort()},[h]);async function v(e){e.preventDefault(),m(!0),u(``),f(!1);try{_(await t(h,{method:`PUT`,body:Mc(i,o)})),f(!0)}catch(e){u(l(e))}finally{m(!1)}}return n?(0,$.jsxs)(y,{onSubmit:e=>void v(e),children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`m-0 font-body text-sm font-semibold text-foreground`,children:`Commands in Docker`}),(0,$.jsxs)(`p`,{className:`m-0 text-sm text-muted-foreground`,children:[n.sandboxMode===`docker`?`Commands run in Docker now. `:`Commands run on this computer now; these apply once Setup → Tools runs them in Docker. `,`The image must already be on this computer: Bazilion never downloads one.`]})]}),(0,$.jsxs)(`div`,{className:`grid items-start gap-x-3 gap-y-4 sm:grid-cols-2`,children:[(0,$.jsx)(L,{label:`Image`,value:i,mono:!0,disabled:p,placeholder:n.defaultImage,hint:`Empty: the installation’s own.`,className:`max-w-none`,onChange:e=>{a(e),f(!1)}}),(0,$.jsx)(L,{label:`Folder they start in`,value:o,mono:!0,disabled:p,hint:`Inside the Team’s folder; “.” is the folder itself.`,className:`max-w-none`,onChange:e=>{s(e),f(!1)}})]}),(0,$.jsx)(gt,{busy:p,disabled:!g,status:it({error:c||null,dirty:g,saved:d})})]}):c?(0,$.jsx)(`div`,{className:`border-t border-border px-4 py-4 sm:px-5`,children:(0,$.jsx)(w,{role:`alert`,title:`The Docker defaults could not be loaded.`,children:c})}):null}function Pc({team:e,sampleAgent:t}){return(0,$.jsxs)(`div`,{className:`grid gap-5`,children:[(0,$.jsxs)(j,{labelledBy:`team-workspace`,icon:(0,$.jsx)(Rt,{className:`size-5`}),title:`Workspace`,description:`Where this Team’s Agents read and write files.`,children:[(0,$.jsx)(ie,{children:(0,$.jsx)(C,{label:`Folder`,children:(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`code`,{className:`min-w-0 break-all font-mono text-sm`,children:e.path}),(0,$.jsx)(Pa,{value:e.path,ariaLabel:`Copy the folder`,title:`Copy the folder`})]})})}),(0,$.jsx)(Nc,{teamId:e.id})]}),(0,$.jsx)(Fc,{team:e,sampleAgent:t}),(0,$.jsx)(Ic,{team:e})]})}function Fc({team:e,sampleAgent:n}){let r=i(),[a,o]=(0,H.useState)(e.telegramTopicNameFormat??``),[s,c]=(0,H.useState)(!1),[u,p]=(0,H.useState)(null),[m,h]=(0,H.useState)(!1),g=a.trim(),_=(e.telegramTopicNameFormat??``)!==a,v=g&&!g.includes(`{agent.name}`)?`Put {agent.name} in it, so each member’s topic has its own name.`:void 0,b=g?g.replaceAll(`{agent.name}`,n).replaceAll(`{team.name}`,e.name).replaceAll(`{team.slug}`,e.id):e.id==="default"?n:`${e.id} › ${n}`;async function x(n){c(!0),p(null);try{await t(`/api/teams/${encodeURIComponent(e.id)}/topic-format`,{method:`PUT`,body:{format:n?null:a}}),n&&o(``),await r.invalidate({sync:!0}),h(!0)}catch(e){p(l(e))}finally{c(!1)}}return(0,$.jsxs)(j,{labelledBy:`team-topic-names`,icon:(0,$.jsx)(Oe,{className:`size-5`}),title:`Telegram topic names`,description:`What each member’s forum topic is called in the Telegram group.`,children:[(0,$.jsx)(d,{when:_,subject:`topic name changes`}),(0,$.jsxs)(y,{onSubmit:e=>{e.preventDefault(),x(!1)},children:[(0,$.jsx)(L,{label:`Topic name`,value:a,mono:!0,disabled:s,placeholder:`{team.name} / {agent.name}`,problem:v,hint:(0,$.jsxs)($.Fragment,{children:[`Empty: the built-in name. Use `,(0,$.jsx)(`code`,{children:`{agent.name}`}),`,`,` `,(0,$.jsx)(`code`,{children:`{team.name}`}),` and `,(0,$.jsx)(`code`,{children:`{team.slug}`}),`. Saving renames the topics you have not renamed in Telegram yourself.`]}),onChange:e=>{o(e),h(!1)}}),(0,$.jsxs)(`p`,{className:`m-0 text-sm text-muted-foreground`,children:[n,`’s topic would read`,` `,(0,$.jsx)(`span`,{className:`font-semibold text-foreground`,children:b}),`.`]}),(0,$.jsx)(gt,{busy:s,disabled:!_||g.length===0||!!v,status:it({error:u,dirty:_,saved:m}),extra:e.telegramTopicNameFormat&&(0,$.jsx)(f,{variant:`ghost`,onClick:()=>void x(!0),disabled:s,children:`Use the built-in name`})})]})]})}function Ic({team:e}){let[n,r]=(0,H.useState)(`${e.name} template`),[i,a]=(0,H.useState)(``),[o,s]=(0,H.useState)(!1),[c,u]=(0,H.useState)(!1),[d,f]=(0,H.useState)(null),p=o?i:Ot(n),m=p?At(p):null;async function h(r){r.preventDefault(),u(!0),f(null);try{let r=await t(`/api/teams/${encodeURIComponent(e.id)}/policy/save-as-template`,{body:{id:p,name:n.trim()}});window.location.assign(`/templates/teams/${encodeURIComponent(r.id)}`)}catch(e){f(l(e)),u(!1)}}return(0,$.jsx)(j,{labelledBy:`team-save-template`,icon:(0,$.jsx)(Wt,{className:`size-5`}),title:`Save as a Team template`,description:`Its members, who may message whom, and USER.md, ready to start another Team.`,children:(0,$.jsxs)(y,{onSubmit:e=>void h(e),children:[(0,$.jsxs)(`div`,{className:`grid items-start gap-x-3 gap-y-4 sm:grid-cols-2`,children:[(0,$.jsx)(L,{label:`Template name`,value:n,disabled:c,className:`max-w-none`,onChange:r}),(0,$.jsx)(L,{label:`ID`,value:p,mono:!0,disabled:c,className:`max-w-none`,hint:`Used in commands; it cannot change later.`,problem:m??void 0,onChange:e=>{s(!0),a(e)}})]}),(0,$.jsx)(gt,{busy:c,disabled:!n.trim()||!p||!!m,label:`Save as a template`,busyLabel:`Saving…`,status:it({error:d,dirty:!1,saved:!1})})]})})}var Lc=12e3,Rc=e=>new TextEncoder().encode(e).length;function zc({team:e}){let n=i(),r=`/api/teams/${encodeURIComponent(e.id)}`,[a,s]=(0,H.useState)(null),[c,u]=(0,H.useState)(``),[p,m]=(0,H.useState)(!1),[h,g]=(0,H.useState)(null),[_,v]=(0,H.useState)(null),[b,x]=(0,H.useState)(!1),S=a!==null&&c!==a,C=Rc(c),T=C>Lc;async function E(){return(await t(r)).userMd}(0,H.useEffect)(()=>{let e=!0;return E().then(t=>{e&&(s(t),u(t))}).catch(t=>e&&g(l(t))),()=>{e=!1}},[r]);async function D(e){if(e.preventDefault(),a!==null){m(!0),g(null),v(null);try{let e={userMd:c,expected:a};await t(`${r}/user-md`,{method:`PUT`,body:e}),s(c),x(!0),await n.invalidate({sync:!0})}catch(e){e instanceof o&&e.code===`user_md_changed`?v(await E().catch(()=>null)):g(l(e))}finally{m(!1)}}}return(0,$.jsxs)(j,{labelledBy:`team-user-md`,icon:(0,$.jsx)(Xe,{className:`size-5`}),title:`About you`,description:`Who you are, how you like to work, what this Team is for. Its Agents add to it as they learn about you.`,children:[(0,$.jsx)(d,{when:S,subject:`USER.md changes`}),a===null?(0,$.jsx)(ae,{children:h?(0,$.jsx)(w,{role:`alert`,title:`USER.md could not be loaded.`,children:h}):(0,$.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted-foreground`,children:`Loading USER.md…`})}):(0,$.jsxs)(y,{onSubmit:e=>void D(e),children:[_!==null&&(0,$.jsx)(w,{role:`alert`,title:`An Agent changed USER.md since you opened it.`,actions:(0,$.jsx)(f,{variant:`ghost`,onClick:()=>{s(_),u(_),v(null)},children:`Load their version (drops your edit)`}),children:`Nothing was saved. Copy what you wrote if you want to keep it, then load their version and add it back.`}),(0,$.jsx)(ot,{label:`USER.md`,value:c,rows:16,mono:!0,disabled:p,placeholder:`# About me
80
-
81
- I run a small note-taking app. I like short answers.
82
-
83
- # This Team
84
-
85
- We ship version 2 on Friday.`,problem:T?`Keep it under ${Lc.toLocaleString()} bytes; it is ${C.toLocaleString()}.`:void 0,hint:`${C.toLocaleString()} of ${Lc.toLocaleString()} bytes. Markdown.`,onChange:e=>{u(e),x(!1)}}),(0,$.jsx)(gt,{busy:p,disabled:!S||T,status:it({error:h,dirty:S,saved:b,savedText:`Saved. Members read it from their next turn.`})})]})]})}function Bc({title:e,description:t,onClose:n,busy:r=!1,children:i}){return(0,$.jsx)(Je,{title:e,description:t,onClose:n,busy:r,className:`top-[4dvh] max-h-[92dvh] max-w-5xl translate-y-0 content-start`,children:(0,$.jsx)(`div`,{className:`min-w-0`,children:i})})}function Vc(){let{agent:e,team:t,agents:n,search:r,to:a}=I(),o=i(),s=r.section;if(!s)return null;let c=()=>void o.navigate({to:`/`,search:a({section:void 0,note:void 0})}),l,u;if(et(s)){if(!e)return null;let{name:t,id:r}=e.agent;switch(s){case`schedules`:l=`${t}’s schedules`,u=(0,$.jsx)(Ec,{agent:e.agent},r);break;case`learning`:l=`What ${t} has learned`,u=(0,$.jsx)(tc,{agent:e.agent},r);break;case`mailbox`:l=`${t}’s mailbox`,u=(0,$.jsx)(uc,{agent:e.agent,agents:n},r);break;case`skills`:l=`${t}’s skills`,u=(0,$.jsx)(Zs,{agentId:r,agentName:t,attached:e.skills},r);break;case`telegram`:l=`${t} on Telegram`,u=(0,$.jsx)(ec,{agent:e.agent},r);break;case`browser`:l=`${t}’s browser`,u=(0,$.jsx)(Xs,{agentId:r,agentName:t},r);break}}else if(pt(s)){if(!t)return null;switch(s){case`user-md`:l=`${t.name}: about you`,u=(0,$.jsx)(zc,{team:t},t.id);break;case`memory`:l=`${t.name}: shared memory`,u=(0,$.jsx)(jc,{team:t,openKey:r.note},t.id);break;case`settings`:l=`${t.name}: settings`,u=(0,$.jsx)(Pc,{team:t,sampleAgent:n.find(e=>e.teamId===t.id)?.name??`Researcher`},t.id);break}}else return null;return(0,$.jsx)(Bc,{title:l,onClose:c,children:u})}var Hc=[{view:`connections`,label:`Connections`,icon:Ae},{view:`changes`,label:`Changes`,icon:we},{view:`files`,label:`Files`,icon:le}],Uc=`m-0 mb-2 mt-7 font-body text-xs font-bold uppercase tracking-[0.08em] text-muted-foreground`;function Wc({team:e}){let{agents:t,profiles:r,teams:i,search:a}=I(),o=B(),[s,c]=(0,H.useState)(!1),l=t.filter(t=>t.teamId===e.id),u=Ze(l.map(e=>o.stateOf(e.id))),d=Ma(e.id),p=$a(e.id,{},4),m=ve(e.id,50);return(0,$.jsxs)(`section`,{"aria-label":e.name,className:`flex h-full flex-col overflow-y-auto rounded-[16px] border border-border bg-card px-4 py-5 shadow-baziu-sm sm:px-8 sm:py-8`,children:[(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl`,children:[(0,$.jsxs)(n,{to:`/`,search:{},className:`mb-4 inline-flex items-center gap-1.5 text-sm font-semibold lg:hidden`,children:[(0,$.jsx)(ce,{className:`size-3.5`,"aria-hidden":`true`}),`All teams`]}),(0,$.jsx)(`h1`,{className:`m-0 font-display text-[1.9rem] leading-tight text-charcoal`,children:e.name}),(0,$.jsxs)(`p`,{className:`m-0 mt-1 text-sm text-mocha`,children:[l.length,` member`,l.length===1?``:`s`,u?` · ${u}`:``]}),l.length===0?(0,$.jsxs)(`div`,{className:`mt-6 rounded-2xl border border-dashed border-border bg-muted/40 px-5 py-8 text-center`,children:[(0,$.jsx)(`p`,{className:`m-0 text-sm font-semibold text-foreground`,children:`No Agents in this Team yet`}),(0,$.jsx)(`p`,{className:`m-0 mt-1 text-sm text-muted-foreground`,children:`Add the first one to start a conversation.`}),(0,$.jsxs)(f,{variant:`primary`,className:`mt-4`,onClick:()=>c(!0),children:[(0,$.jsx)(je,{className:`size-4`,"aria-hidden":`true`}),`Add an agent`]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`ul`,{className:`m-0 mt-5 list-none space-y-2 p-0`,children:l.map(e=>{let t=o.stateOf(e.id);return(0,$.jsx)(`li`,{children:(0,$.jsxs)(n,{to:`/`,search:{agent:e.id,...a.panel?{panel:a.panel}:{}},className:`flex min-h-16 items-center gap-3 rounded-2xl border border-border bg-card px-3.5 py-2.5 text-foreground shadow-baziu-sm hover:border-sapphire-light hover:bg-accent/30`,children:[(0,$.jsx)(R,{identity:e.identity,size:40}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-base font-semibold`,children:e.name}),(0,$.jsxs)(`span`,{className:`mt-0.5 flex min-w-0 items-center gap-1.5 text-xs text-mocha`,children:[(0,$.jsx)(`span`,{className:`size-[7px] shrink-0 rounded-full ${M[t.kind]}`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:t.text})]})]}),(0,$.jsx)(`span`,{className:`shrink-0 text-xs font-semibold text-accent-foreground`,children:`Open`})]})},e.id)})}),(0,$.jsx)(`div`,{className:`mt-4`,children:(0,$.jsxs)(f,{variant:`ghost`,onClick:()=>c(!0),children:[(0,$.jsx)(je,{className:`size-4`,"aria-hidden":`true`}),`Add an agent`]})})]}),(0,$.jsx)(`div`,{className:`mt-8 grid grid-cols-1 gap-2 sm:grid-cols-3`,children:Hc.map(({view:t,label:r,icon:i})=>(0,$.jsxs)(n,{to:`/`,search:{team:e.id,view:t},className:`flex min-h-16 items-center gap-2.5 rounded-2xl border border-border bg-muted/50 px-3 py-2.5 text-foreground hover:border-sapphire-light hover:bg-accent/30`,children:[(0,$.jsx)(i,{className:`size-[18px] shrink-0 text-mocha`,"aria-hidden":`true`}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block text-sm font-semibold`,children:r}),(0,$.jsx)(`span`,{className:`block truncate text-xs text-mocha`,children:t===`connections`?`${e.policyMode===`open`?`Open`:`Restricted`} · ${m.data?.length?`${m.data.length} message${m.data.length===1?``:`s`}`:`no messages yet`}`:t===`changes`?d.changes===null?`Not a Git repository`:`${d.changes} changed file${d.changes===1?``:`s`}`:`${d.files??0} saved file${d.files===1?``:`s`}`})]})]},t))}),p.results.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h2`,{className:Uc,children:`Latest files`}),(0,$.jsx)(`div`,{className:`grid grid-cols-2 gap-2.5 sm:grid-cols-4`,children:p.results.map(n=>(0,$.jsx)(Za,{resultId:n.id,result:n,compact:!0,detail:t.find(e=>e.id===n.agentId)?.name,open:{team:e.id,view:`files`,result:n.id}},n.id))})]}),(m.data?.length??0)>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h2`,{className:Uc,children:`Lately between its Agents`}),(0,$.jsx)(Se,{messages:m.data??[],limit:4})]})]}),s&&(0,$.jsx)(yt,{profiles:r,teams:i,teamId:e.id,onClose:()=>c(!1)})]})}var Gc=3;function Kc({className:e=``}){let{agents:t,teams:r}=I(),i=B(),a=t.map(e=>({agent:e,state:i.stateOf(e.id)})).filter(e=>e.state.kind===`needs`);if(a.length===0)return null;let o=new Map(r.map(e=>[e.id,e.name])),s=a.length-Gc;return(0,$.jsxs)(`section`,{"aria-label":`Waiting for you`,className:`rounded-2xl border border-warning/40 bg-warning/10 px-3 py-2.5 shadow-baziu-sm ${e}`,children:[(0,$.jsxs)(`h2`,{className:`m-0 mb-1.5 flex items-center gap-1.5 font-body text-xs font-bold uppercase tracking-[0.08em] text-warning`,children:[(0,$.jsx)(_t,{className:`size-3.5`,"aria-hidden":`true`}),`Waiting for you`]}),(0,$.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0`,children:a.slice(0,Gc).map(({agent:e,state:t})=>(0,$.jsx)(`li`,{children:(0,$.jsx)(qc,{agent:e,team:o.get(e.teamId),text:t.text})},e.id))}),s>0&&(0,$.jsxs)(n,{to:`/attention`,className:`mt-1.5 inline-block text-sm font-semibold`,children:[s,` more in Attention`]})]})}function qc({agent:e,team:t,text:r}){return(0,$.jsxs)(n,{to:`/`,search:{agent:e.id},className:`flex min-h-11 items-center gap-2.5 rounded-xl px-1.5 py-1 text-foreground hover:bg-card/70`,children:[(0,$.jsx)(R,{identity:e.identity,size:28}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`span`,{className:`block truncate text-sm font-semibold`,children:[e.name,t&&(0,$.jsxs)(`span`,{className:`font-normal text-mocha`,children:[` · `,t]})]}),(0,$.jsx)(`span`,{className:`block truncate text-xs text-warning`,children:r})]}),(0,$.jsx)(`span`,{className:`shrink-0 text-xs font-semibold text-accent-foreground`,children:`Open`})]})}var Jc=(0,H.lazy)(()=>ht(()=>import(`./ConnectionsView-D7Fmutl2.js`).then(e=>({default:e.ConnectionsView})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25])));function Yc(){let e=tt.useLoaderData(),t=tt.useSearch(),r=i(),{agents:a,teams:o,selected:s}=e,c=s?.resolved??null,l=c?.team??o.find(e=>e.id===t.team)??null,u=l?t.view:void 0,d=(0,H.useMemo)(()=>new Map(a.map(e=>[e.id,e.name])),[a]);Ie(u&&l?`${Ge[u]} · ${l.name}`:c?[c.agent.name,l?.name].filter(Boolean).join(` · `):l?l.name:`Overview`);let[f,p]=(0,H.useState)(e.panel);(0,H.useEffect)(()=>{t.panel&&p(e=>{let n=t.panel===`none`?{open:!1,tab:e.tab}:{open:!0,tab:t.panel};return n.open===e.open&&n.tab===e.tab?e:(ut(n),n)})},[t.panel]);let m=t.panel??(f.open&&(c||l)?f.tab:`none`);(0,H.useEffect)(()=>{let e=e=>{if(e.defaultPrevented||document.querySelector(`[role="dialog"]`))return;let n=e.metaKey||e.ctrlKey;if(n&&e.key===`.`){e.preventDefault();let n=m!==`none`&&(h||window.matchMedia(`(min-width: 1280px)`).matches);r.navigate({to:`/`,search:{...t,panel:n?`none`:f.tab,section:void 0}});return}if(!(nt(e.target)||n)){if(e.key===`/`&&!e.altKey){let t=document.querySelector(`[data-composer]`);if(!t)return;e.preventDefault(),t.focus();return}if(e.altKey&&(e.key===`ArrowDown`||e.key===`ArrowUp`)){let n=z(o.flatMap(e=>a.filter(t=>t.teamId===e.id)),c?.agent.id,e.key===`ArrowDown`?1:-1);if(!n)return;e.preventDefault(),r.navigate({to:`/`,search:{agent:n.id,...t.panel?{panel:t.panel}:{}}})}}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)});let h=t.panel!==void 0&&t.panel!==`none`,[g,_]=(0,H.useState)(null),v=s?.head.conversationId??null,y=c&&g?.agentId===c.agent.id&&g.loaded===v?g.id:v,b=c&&t.conversation&&t.conversation!==y?t.conversation:null,x=c?b??y:null,S=(0,H.useMemo)(()=>({agents:a,teams:o,profiles:e.profiles,teamTemplates:e.teamTemplates,agent:c,team:l,conversationId:x,search:t}),[a,o,e.profiles,e.teamTemplates,c,l,x,t]),C=e=>c&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(zs,{agent:c,chat:e,panel:m,lastPanel:f.tab}),c.agent.status===`archived`&&(0,$.jsxs)(`p`,{className:`m-0 flex flex-wrap items-center gap-2 border-b border-frost bg-warning/[0.07] px-4 py-2 text-sm text-chocolate`,children:[(0,$.jsx)(st,{variant:`warning`,children:`Archived`}),`This Agent receives no work. Restore it from its settings to talk to it again.`,(0,$.jsx)(n,{to:`/`,search:{...t,panel:`agent`},className:`font-semibold`,children:`Agent settings`})]})]});return(0,$.jsx)(dt,{initial:e.activity,openAgentId:u?null:c?.agent.id??null,names:d,children:(0,$.jsx)(N,{value:S,children:(0,$.jsxs)(va,{children:[u&&l?(0,$.jsxs)(`div`,{className:`grid h-full min-h-0 grid-cols-1 gap-3 py-3 sm:grid-cols-[4rem_minmax(0,1fr)]`,children:[(0,$.jsx)(`div`,{className:`hidden min-h-0 sm:block`,children:(0,$.jsx)(Ce,{})}),(0,$.jsx)(`div`,{className:`min-h-0 min-w-0`,children:u===`connections`?(0,$.jsx)(H.Suspense,{fallback:(0,$.jsx)(me,{view:`connections`,children:(0,$.jsx)(`p`,{role:`status`,className:`m-4 text-sm text-muted-foreground`,children:`Loading the map…`})}),children:(0,$.jsx)(Jc,{team:l},l.id)}):u===`changes`?(0,$.jsx)(So,{team:l},l.id):(0,$.jsx)(Ps,{team:l},l.id)})]}):(0,$.jsxs)(`div`,{className:`grid h-full min-h-0 grid-cols-1 gap-3 py-3 lg:grid-cols-[18rem_minmax(0,1fr)] ${m===`none`?``:`xl:grid-cols-[18rem_minmax(0,1fr)_minmax(22rem,27rem)]`}`,children:[(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-3 ${c||l?`hidden lg:flex`:``}`,children:[(0,$.jsx)(Kc,{className:`lg:hidden`}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(ye,{initialOpenGroups:e.openGroups})})]}),(0,$.jsx)(`div`,{className:`min-h-0 min-w-0 ${c||l?``:`hidden lg:block`}`,children:c&&s?b?(0,$.jsx)(Hs,{agentId:c.agent.id,agentName:c.agent.name,conversationId:b,header:C()},`${c.agent.id}:${b}`):(0,$.jsx)(Ms,{agentId:c.agent.id,agentName:c.agent.name,initialMessages:s.messages,initialSessionHead:s.head,header:C,onViewConversation:e=>void r.navigate({to:`/`,search:{...t,conversation:e}}),onConversationChange:e=>_({agentId:c.agent.id,loaded:v,id:e})}):l?(0,$.jsx)(Wc,{team:l}):(0,$.jsx)(qs,{})}),m!==`none`&&(0,$.jsxs)($.Fragment,{children:[h&&(0,$.jsx)(n,{to:`/`,search:{...t,panel:`none`,section:void 0},"aria-label":`Close the side panel`,className:`fixed inset-0 z-30 bg-chocolate/30 xl:hidden`}),(0,$.jsx)(`div`,{className:h?`fixed inset-y-0 right-0 z-40 w-[min(27rem,100vw)] p-2 xl:static xl:z-auto xl:min-h-0 xl:w-auto xl:min-w-0 xl:p-0`:`hidden min-h-0 min-w-0 xl:block`,children:(0,$.jsx)(ho,{tab:m})})]})]}),(0,$.jsx)(Vc,{})]})})})}export{Yc as component};