pisper 0.6.35 → 0.6.36

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 (207) hide show
  1. package/lib/executor-node.mjs +31 -7
  2. package/package.json +6 -6
  3. package/web/.vite/manifest.json +1018 -826
  4. package/web/assets/{AppDialog-BIc2uEZh.js → AppDialog-C79lPTAo.js} +1 -1
  5. package/web/assets/{AppOverlays-BlJ0uL_P.js → AppOverlays-CcLTlcPI.js} +1 -1
  6. package/web/assets/AssetsPage-DItvQcTv.js +1 -0
  7. package/web/assets/AttachmentTray-DT4tuA-0.js +1 -0
  8. package/web/assets/BoardPage-BS2Mn5BB.js +3 -0
  9. package/web/assets/BotAvatar-DfRTuJjC.js +1 -0
  10. package/web/assets/{ChannelsPage-DgzuzmFL.js → ChannelsPage-HLl1Exdg.js} +1 -1
  11. package/web/assets/{ChatAppearancePage-98Sa8ZQW.js → ChatAppearancePage-COu9kuXs.js} +1 -1
  12. package/web/assets/ChatHistoryPage-DW7tD7eq.js +1 -0
  13. package/web/assets/ChatMessage-BA6Yf2bc.js +5 -0
  14. package/web/assets/ChatPage-Cz50Wq-F.js +553 -0
  15. package/web/assets/ConfigPage-BBU5Rrn1.js +7 -0
  16. package/web/assets/{DesktopWindowControls-BQ0OvDZ8.js → DesktopWindowControls-BJa4zqE2.js} +1 -1
  17. package/web/assets/{FeaturePage-C0bAQ4el.js → FeaturePage-D2NZ4cLC.js} +1 -1
  18. package/web/assets/{FileAttachmentPreview-BdMgsecO.js → FileAttachmentPreview-CFAdIi3l.js} +1 -1
  19. package/web/assets/{FloatingWidgets-DjMCcqln.js → FloatingWidgets-BzwWhwvZ.js} +1 -1
  20. package/web/assets/FocusRuntimeControls-eXxgJIFt.js +2 -0
  21. package/web/assets/{GitDiffViewer-hHSTzUJk.js → GitDiffViewer-DDd2yMvx.js} +3 -3
  22. package/web/assets/ManageProjectsDialog-Sf4KX5NQ.js +1 -0
  23. package/web/assets/{MarkdownMessage-CktdHgKM.js → MarkdownMessage-CggW-dCt.js} +1 -1
  24. package/web/assets/McpPage-CSaBHKz7.js +1 -0
  25. package/web/assets/{MemoryEvolution-DBjU-Nr7.js → MemoryEvolution-DV0LMrEd.js} +1 -1
  26. package/web/assets/MemoryPage-G0tvVhJb.js +2 -0
  27. package/web/assets/{MobileNavigation-B2NKM8rj.js → MobileNavigation-B1XfXR2s.js} +1 -1
  28. package/web/assets/{MorePage-xB2zBRtU.js → MorePage-DGYxdHLm.js} +1 -1
  29. package/web/assets/NewFolderDialog-CzgCnqfC.js +1 -0
  30. package/web/assets/{PageHeader-BN-qcxte.js → PageHeader-CQ4qg6wC.js} +1 -1
  31. package/web/assets/{PhoneDrawer-utEXi-yp.js → PhoneDrawer-CjUjF454.js} +1 -1
  32. package/web/assets/{PhoneMenuButton-uG_T93KL.js → PhoneMenuButton-DbsLKxdG.js} +1 -1
  33. package/web/assets/PhoneTopBar-DMMlJYcd.js +1 -0
  34. package/web/assets/PluginsPage-BnNOlT_w.js +1 -0
  35. package/web/assets/{SafeModePrompt-jV-PRvrW.js → SafeModePrompt-DpzPKu3D.js} +1 -1
  36. package/web/assets/{SchedulesPage-Diethe4H.js → SchedulesPage-Ds4Q6aNP.js} +1 -1
  37. package/web/assets/SessionBrowserPane-C0P_zk8r.js +2 -0
  38. package/web/assets/SessionContextPanel-CHOeF4Yg.js +2 -0
  39. package/web/assets/SessionHome-BVB1DziO.js +1 -0
  40. package/web/assets/SessionInspector-CI0yM7hn.js +1 -0
  41. package/web/assets/SessionShell-kd6S4sjr.js +1 -0
  42. package/web/assets/SettingsRow-CT0AZ7re.js +1 -0
  43. package/web/assets/{SettingsSidebar-CpAD5iSt.js → SettingsSidebar-Tef3Nnew.js} +1 -1
  44. package/web/assets/{ShortcutHelpDialog-C2QbSvui.js → ShortcutHelpDialog-C8XduaKQ.js} +1 -1
  45. package/web/assets/{ShortcutKeys-Dl4Suwhz.js → ShortcutKeys-CHOVA_5P.js} +1 -1
  46. package/web/assets/{SidebarUpdateStatus-DrS7u_v_.js → SidebarUpdateStatus-BNFx2j6q.js} +1 -1
  47. package/web/assets/{SkillsPage-CDoMtK-E.js → SkillsPage-TBWU04ie.js} +1 -1
  48. package/web/assets/{TaskProcessesPane-Z_9HeVX5.js → TaskProcessesPane-BHe6CquN.js} +1 -1
  49. package/web/assets/{TaskTerminalView-BTCVpAHF.js → TaskTerminalView-ByuB7q2B.js} +1 -1
  50. package/web/assets/{TerminalPanel-DuUtaPyf.js → TerminalPanel-FXsJQMsq.js} +1 -1
  51. package/web/assets/{WebDesktopPet-CWviMnct.js → WebDesktopPet-Bw-jipEg.js} +1 -1
  52. package/web/assets/{WorkflowsPage-CHvyXwCg.js → WorkflowsPage-COT3iS5m.js} +1 -1
  53. package/web/assets/{WorkspacePicker-D6FLo7O1.js → WorkspacePicker-DjW-sAP5.js} +1 -1
  54. package/web/assets/activity-BCxvXCG3.js +1 -0
  55. package/web/assets/alert-dialog-DiUitBB0.js +1 -0
  56. package/web/assets/{api-Cm58F7OP.js → api-BET28sp7.js} +1 -1
  57. package/web/assets/{app-primitives-Drz_SjnR.js → app-primitives-BskZ4ZJj.js} +1 -1
  58. package/web/assets/{app-update-KLjtuCDT.js → app-update-7n8nXaPd.js} +1 -1
  59. package/web/assets/{approval-confirm-BrorOUHg.js → approval-confirm-SBeU3s_9.js} +1 -1
  60. package/web/assets/assets-api-DOGSXB2A.js +1 -0
  61. package/web/assets/board-messages-DDVcGLQp.js +1 -0
  62. package/web/assets/board-projects-31Kch8Or.js +1 -0
  63. package/web/assets/bots-store-CgzHr2dN.js +1 -0
  64. package/web/assets/card-presentation-zU6WKfgu.js +2 -0
  65. package/web/assets/chat-api-DwR_1yAu.js +1 -0
  66. package/web/assets/chip-ZhnvFlFg.js +1 -0
  67. package/web/assets/{client-store-4G-xfNKc.js → client-store-Bv5fkPKC.js} +1 -1
  68. package/web/assets/{dist-DUSSw9eQ.js → collapsible-B-fc7n0u.js} +1 -1
  69. package/web/assets/command-DQJks9Cg.js +1 -0
  70. package/web/assets/{config-search-1BIdouae.js → config-search-1R0m2Dxn.js} +1 -1
  71. package/web/assets/corner-down-left-DalpwXuX.js +1 -0
  72. package/web/assets/{desktop-hosts-uMG7lFRY.js → desktop-hosts-DMZi66Qp.js} +2 -2
  73. package/web/assets/{dialog-D23yIdOZ.js → dialog-C6pJ93kY.js} +1 -1
  74. package/web/assets/{event-stream-BrDcABQx.js → event-stream-DujJnWl2.js} +1 -1
  75. package/web/assets/{events-BgEZwyTb.js → events-BrkEbuk_.js} +1 -1
  76. package/web/assets/folder-minus-BhfTnypT.js +1 -0
  77. package/web/assets/folder-paths-C8UCsQpi.js +1 -0
  78. package/web/assets/folder-plus-OPHZsJho.js +1 -0
  79. package/web/assets/{hosts-DljHKUSO.js → hosts-DCtZi0Vu.js} +1 -1
  80. package/web/assets/{http-DtkTCrZ4.js → http-Da7z8Zhw.js} +1 -1
  81. package/web/assets/http-response-DHqWBecB.js +1 -0
  82. package/web/assets/i18n-CYOV8NO5.js +1 -0
  83. package/web/assets/index-B446sLQy.js +2 -0
  84. package/web/assets/index-Fb-GT4ka.css +2 -0
  85. package/web/assets/list-todo-hpikYm6Q.js +1 -0
  86. package/web/assets/machine-messages-P6rRT5_Y.js +1 -0
  87. package/web/assets/machines-api-Cww34Att.js +1 -0
  88. package/web/assets/mcp-Cnn5t8jD.js +1 -0
  89. package/web/assets/mcp-DKnh78Cw.js +1 -0
  90. package/web/assets/{memory-api-DHLgFXzZ.js → memory-api-Bl58uVxS.js} +1 -1
  91. package/web/assets/mount-app-Dz4ohBAB.js +9 -0
  92. package/web/assets/{palette-navigation-BcPK8UF5.js → palette-navigation-DbWf-z0P.js} +1 -1
  93. package/web/assets/permission-rules-api-DKvt9Ijn.js +1 -0
  94. package/web/assets/{pick-system-directory-DS_-qn8W.js → pick-system-directory-BRdpqAVu.js} +1 -1
  95. package/web/assets/placements-DueXe1Zp.js +2 -0
  96. package/web/assets/popover-Bz5EGqVg.js +1 -0
  97. package/web/assets/public-CL4QGDNW.js +9 -0
  98. package/web/assets/public-C_3jqJ-h.js +2 -0
  99. package/web/assets/{public-B8mbf50i.js → public-WgIAq7m6.js} +1 -1
  100. package/web/assets/public-bzVRS_Ps.js +2 -0
  101. package/web/assets/{public-components-CMbKXCZU.js → public-components-CNnORHGF.js} +1 -1
  102. package/web/assets/public-diff-BiBx9iwa.js +1 -0
  103. package/web/assets/public-events-CUnBp7HK.js +1 -0
  104. package/web/assets/{public-flags-D8CxujmF.js → public-flags-ItOVvu41.js} +1 -1
  105. package/web/assets/{public-folder-dialog-Dnmn6DIU.js → public-folder-dialog-CooqqcGn.js} +1 -1
  106. package/web/assets/{public-greeting-Cs-sacVq.js → public-greeting-C9UC30cx.js} +1 -1
  107. package/web/assets/{public-session-DSLmbBcw.js → public-session-Cb2rGpEN.js} +1 -1
  108. package/web/assets/public-sidebar-DT8uieIs.js +1 -0
  109. package/web/assets/room-changes-DMfb5VNn.js +1 -0
  110. package/web/assets/{routes-DIeaqWVc.js → routes-BYsK6aeM.js} +1 -1
  111. package/web/assets/runtime-capabilities-CxyszNkG.js +1 -0
  112. package/web/assets/{runtime-capabilities-store-Y9MaywP8.js → runtime-capabilities-store-1qxTCxHV.js} +1 -1
  113. package/web/assets/{safe-mode-instance-CYIRMY5i.js → safe-mode-instance-DlkQOfml.js} +1 -1
  114. package/web/assets/safe-mode-sentinel-MZiIHVDW.js +1 -0
  115. package/web/assets/session-board-status-D_Tz3HJm.js +1 -0
  116. package/web/assets/{session-change-summary-api-Dp9vVPv_.js → session-change-summary-api-5OOAmNzo.js} +1 -1
  117. package/web/assets/{session-home-DqEkX19H.js → session-home-fCQ4eKhT.js} +1 -1
  118. package/web/assets/session-inspector-store-Dk8BXrxC.js +1 -0
  119. package/web/assets/session-questions-COno7uhe.js +1 -0
  120. package/web/assets/{session-scope-BJIZo6ty.js → session-scope-B13jJaQq.js} +1 -1
  121. package/web/assets/{session-tree-actions-B8GDKcGe.js → session-tree-actions-CS9J4Eer.js} +1 -1
  122. package/web/assets/session-tree-summary-_F4a4OX7.js +1 -0
  123. package/web/assets/session-web-preview-NBd9P7Kp.js +1 -0
  124. package/web/assets/{settings-navigation-C-nsUyew.js → settings-navigation-BEoTeOkB.js} +1 -1
  125. package/web/assets/{shortcuts-DRfz9B_B.js → shortcuts-CctXrljf.js} +1 -1
  126. package/web/assets/side-chat-context-oyi3ytlS.js +4 -0
  127. package/web/assets/{sidebar-DrzZKq2i.js → sidebar-B1PDwCql.js} +1 -1
  128. package/web/assets/{sidebar-store-BvZAgxJg.js → sidebar-store-D3ZnQB3e.js} +1 -1
  129. package/web/assets/{speech-session-DGkMojp3.js → speech-session-BwcPoFaK.js} +1 -1
  130. package/web/assets/{startup-queries-BjjeYiQ8.js → startup-queries-CNUOrW7A.js} +1 -1
  131. package/web/assets/subagent-view-store-BUvI8piR.js +1 -0
  132. package/web/assets/undo-2-ChaURM4t.js +1 -0
  133. package/web/assets/{use-i18n-8V6eRMcE.js → use-i18n-CbqEZb3r.js} +1 -1
  134. package/web/assets/use-open-bot-Dv66YK0n.js +1 -0
  135. package/web/assets/{use-studio-actions-BsdfCptK.js → use-studio-actions-GplOMwz9.js} +3 -3
  136. package/web/assets/useCatalogProjects-CtZwq4VJ.js +1 -0
  137. package/web/assets/{useMachines-BBeg2uOZ.js → useMachines-DHK5FVXC.js} +1 -1
  138. package/web/assets/useNewProjectPicker-Dum2z5eb.js +2 -0
  139. package/web/assets/useNow-Cm86munt.js +1 -0
  140. package/web/assets/{usePhoneShell-DRZTDDgZ.js → usePhoneShell-BDH8-EY7.js} +1 -1
  141. package/web/assets/useSessionListQuery-D8hWYbAp.js +2 -0
  142. package/web/assets/{useSessionRowActions-DBqnVodk.js → useSessionRowActions-D3-sAs-h.js} +1 -1
  143. package/web/assets/{useSidebarModel-DBH3JLQ1.js → useSidebarModel-CR0sLO4j.js} +1 -1
  144. package/web/assets/{workspace-folders-Bu3t-gEw.js → workspace-folders-DWoX16M_.js} +1 -1
  145. package/web/assets/workspace-order-store-CI03povy.js +1 -0
  146. package/web/index.html +2 -2
  147. package/web/assets/AssetsPage-B9lqKmXy.js +0 -1
  148. package/web/assets/BoardPage-BB_xAnQV.js +0 -3
  149. package/web/assets/BotAvatar-CNL-APwP.js +0 -1
  150. package/web/assets/ChatHistoryPage-BHsZFF4a.js +0 -1
  151. package/web/assets/ChatPage-C3NC9LNG.js +0 -553
  152. package/web/assets/ConfigPage-D3SyAsIs.js +0 -7
  153. package/web/assets/FocusRuntimeControls-DeSe12wJ.js +0 -2
  154. package/web/assets/ManageProjectsDialog-DVLX4ZBu.js +0 -1
  155. package/web/assets/McpPage-7wR_N0eS.js +0 -1
  156. package/web/assets/MemoryPage-DiO4GHc7.js +0 -2
  157. package/web/assets/NewFolderDialog-CjWMsY2Q.js +0 -1
  158. package/web/assets/PhoneTopBar-DuLewk2J.js +0 -1
  159. package/web/assets/PluginsPage-D0hAMgQ_.js +0 -1
  160. package/web/assets/SessionBrowserPane-y7gPArTV.js +0 -2
  161. package/web/assets/SessionContextPanel-Ckca3NrN.js +0 -2
  162. package/web/assets/SessionHome-CcjiU1fU.js +0 -1
  163. package/web/assets/SessionInspector-CNSyVYK6.js +0 -1
  164. package/web/assets/SessionShell-wOw-rTQD.js +0 -1
  165. package/web/assets/accordion-CiJMkjqX.js +0 -1
  166. package/web/assets/board-messages-3qT8nGsd.js +0 -1
  167. package/web/assets/board-projects-CeL6PPiY.js +0 -1
  168. package/web/assets/bots-store-CRGayU4z.js +0 -1
  169. package/web/assets/card-presentation-1oph2b8P.js +0 -2
  170. package/web/assets/chat-api-DQyHZl-V.js +0 -1
  171. package/web/assets/collapsible-Dcoy-qnz.js +0 -1
  172. package/web/assets/folder-paths-D0-7xV2n.js +0 -1
  173. package/web/assets/http-response-B2n7HFQ4.js +0 -1
  174. package/web/assets/i18n-B7QmqfvO.js +0 -1
  175. package/web/assets/index-79gEOxmD.js +0 -2
  176. package/web/assets/index-XwGsScbB.css +0 -2
  177. package/web/assets/machine-messages-Bd6JwiOe.js +0 -1
  178. package/web/assets/machines-api-Kg457H3y.js +0 -1
  179. package/web/assets/mcp-BcCwwm4p.js +0 -1
  180. package/web/assets/mcp-ZCMDzpoJ.js +0 -1
  181. package/web/assets/mount-app-BlaI2VZs.js +0 -9
  182. package/web/assets/permission-rules-api-BZn4yp-J.js +0 -1
  183. package/web/assets/placements-BMxzzGTX.js +0 -2
  184. package/web/assets/popover-C5U02alK.js +0 -1
  185. package/web/assets/public-Be05c5M9.js +0 -2
  186. package/web/assets/public-Bq1VrNr8.js +0 -2
  187. package/web/assets/public-DsjuTTt0.js +0 -3
  188. package/web/assets/public-diff-4sBkfeo8.js +0 -1
  189. package/web/assets/public-events-D2kHUhG2.js +0 -1
  190. package/web/assets/public-sidebar-UNJ9_fD1.js +0 -1
  191. package/web/assets/run-activity-CwfO0cui.js +0 -1
  192. package/web/assets/runtime-capabilities-CPDBo3tu.js +0 -1
  193. package/web/assets/safe-mode-sentinel-Bq9lNJoA.js +0 -1
  194. package/web/assets/session-board-status-D2lpFPiI.js +0 -1
  195. package/web/assets/session-inspector-store-D_mwa4K7.js +0 -1
  196. package/web/assets/session-organization-api-ibzfB8fg.js +0 -1
  197. package/web/assets/session-questions-94KACguh.js +0 -1
  198. package/web/assets/session-tree-summary-BTcPaCgY.js +0 -1
  199. package/web/assets/session-web-preview-guvsmkWE.js +0 -1
  200. package/web/assets/side-chat-context-CRQ33Q0D.js +0 -7
  201. package/web/assets/undo-2-C-xQ0UVT.js +0 -1
  202. package/web/assets/use-open-bot-BEhRmhru.js +0 -1
  203. package/web/assets/useCatalogProjects-DKjmAJ2x.js +0 -1
  204. package/web/assets/useNewProjectPicker-Cmw2SOhW.js +0 -2
  205. package/web/assets/useNow-D-gM4IXU.js +0 -1
  206. package/web/assets/useSessionListQuery-DtpEX8a5.js +0 -2
  207. package/web/assets/workspace-order-store-DmEFuNUL.js +0 -1
@@ -0,0 +1,9 @@
1
+ import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{f as t,m as n,n as r,r as i,u as a}from"./vendor-router-CSN_DGvx.js";import{i as o,r as s}from"./vendor-react-DwNgTV1j.js";import{f as c,h as l,r as u}from"./routes-BYsK6aeM.js";import{t as d}from"./use-i18n-CbqEZb3r.js";import{a as f,t as p}from"./http-response-DHqWBecB.js";import{n as m}from"./http-Da7z8Zhw.js";import{t as h}from"./runtime-capabilities-store-1qxTCxHV.js";import{t as g}from"./usePhoneShell-BDH8-EY7.js";import{t as _}from"./createLucideIcon-Cd-3GVxJ.js";import{t as v}from"./arrow-down-CDGua-ue.js";import{t as y}from"./arrow-up-DST6-qVQ.js";import{t as b}from"./calendar-clock-VIxTaqqy.js";import{t as x}from"./check-2vYc6QaP.js";import{t as S}from"./chevron-down-CxtxIjiP.js";import{t as C}from"./chevron-left-BAtyp3_6.js";import{t as w}from"./chevron-right-C3t2Rckj.js";import{t as T}from"./copy-DHmIFc52.js";import{t as E}from"./ellipsis-CfGKfbq6.js";import{S as D,b as O,d as ee}from"./FocusRuntimeControls-eXxgJIFt.js";import{t as k}from"./WorkspacePicker-DjW-sAP5.js";import{t as A}from"./folder-open-FIShC5Qk.js";import{n as j}from"./ChatMessage-BA6Yf2bc.js";import{t as M}from"./undo-2-ChaURM4t.js";import{t as N}from"./message-circle-D-XrK6Ft.js";import{t as te}from"./monitor-ORxecA9m.js";import{t as ne}from"./panel-right-BSUtqUd8.js";import{t as re}from"./paperclip-BCXrwYpb.js";import{t as P}from"./pencil-U08v_vV9.js";import{t as ie}from"./pin-CU0FG0lI.js";import{t as ae}from"./plus-fQbSqB1n.js";import{C as oe,D as F,E as I,O as L,S as se,T as R,_ as ce,a as le,b as ue,c as de,d as fe,f as z,g as pe,h as me,i as he,m as ge,n as _e,o as ve,p as B,s as ye,t as be,u as xe,v as Se,w as Ce,x as we,y as Te}from"./use-open-bot-Dv66YK0n.js";import{t as Ee}from"./sparkles-S_eeuqn9.js";import{t as De}from"./square-bHHVTT3G.js";import{i as Oe,r as ke,t as Ae}from"./AttachmentTray-DT4tuA-0.js";import{t as je}from"./trash-2-CNrPOoPR.js";import{t as Me}from"./users-CCtFZzwl.js";import{t as Ne}from"./x-07u4-129.js";import{a as Pe,c as Fe,i as Ie,n as Le,o as Re,r as ze,s as Be,t as Ve}from"./alert-dialog-DiUitBB0.js";import{c as He,i as V,p as Ue,r as We,t as Ge}from"./dropdown-menu-Ds0gD8S8.js";import{n as Ke,r as qe,t as Je}from"./popover-Bz5EGqVg.js";import{t as H}from"./switch-D_G8wFhs.js";import{t as U}from"./segmented-control-xkrEOP_d.js";import{t as W}from"./utils-C8uzG5AZ.js";import{n as G,t as K}from"./button-CCcCN8tE.js";import{n as Ye,o as Xe,r as Ze,t as Qe}from"./sheet-BTaIEX4w.js";import{T as $e}from"./useSessionListQuery-D8hWYbAp.js";import{i as et,r as tt}from"./room-changes-DMfb5VNn.js";import{a as nt,o as rt,t as it}from"./command-DQJks9Cg.js";import{a as at,i as ot,l as st,o as ct,s as lt,t as ut}from"./dialog-C6pJ93kY.js";import{t as q}from"./input-CPw-zkYh.js";import{t as dt}from"./textarea-DmATpOqT.js";import{t as ft}from"./model-display-kDwvtxrW.js";import"./public-bzVRS_Ps.js";import{t as pt}from"./pick-system-directory-BRdpqAVu.js";import{n as mt,t as ht}from"./PageState-Cz6vFMXv.js";import{n as gt}from"./field-DoLEb0np.js";import{n as _t,t as vt}from"./assets-api-DOGSXB2A.js";import{t as yt}from"./MarkdownMessage-CggW-dCt.js";import{a as bt,t as J}from"./BotAvatar-DfRTuJjC.js";import{t as Y}from"./AppSelect-DQYKUW5E.js";import{D as xt,E as St,M as Ct,O as wt,S as Tt,T as Et,_ as Dt,a as Ot,b as kt,d as At,f as jt,g as Mt,h as Nt,i as Pt,j as Ft,k as It,l as Lt,m as Rt,n as X,o as zt,p as Bt,r as Vt,s as Ht,t as Ut,u as Wt,v as Gt,w as Kt,x as qt,y as Jt}from"./bots-store-CgzHr2dN.js";import{t as Yt}from"./public-flags-ItOVvu41.js";import{n as Xt,t as Z}from"./SettingsRow-CT0AZ7re.js";import{t as Zt}from"./chip-ZhnvFlFg.js";var Qt=_(`at-sign`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`,key:`7n84p3`}]]),$t=_(`circle-dashed`,[[`path`,{d:`M10.1 2.182a10 10 0 0 1 3.8 0`,key:`5ilxe3`}],[`path`,{d:`M13.9 21.818a10 10 0 0 1-3.8 0`,key:`11zvb9`}],[`path`,{d:`M17.609 3.721a10 10 0 0 1 2.69 2.7`,key:`1iw5b2`}],[`path`,{d:`M2.182 13.9a10 10 0 0 1 0-3.8`,key:`c0bmvh`}],[`path`,{d:`M20.279 17.609a10 10 0 0 1-2.7 2.69`,key:`1ruxm7`}],[`path`,{d:`M21.818 10.1a10 10 0 0 1 0 3.8`,key:`qkgqxc`}],[`path`,{d:`M3.721 6.391a10 10 0 0 1 2.7-2.69`,key:`1mcia2`}],[`path`,{d:`M6.391 20.279a10 10 0 0 1-2.69-2.7`,key:`1fvljs`}]]),en=_(`corner-up-left`,[[`path`,{d:`M20 20v-7a4 4 0 0 0-4-4H4`,key:`1nkjon`}],[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}]]),tn=_(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),nn=_(`list-tree`,[[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`M3 10a2 2 0 0 0 2 2h3`,key:`1npucw`}],[`path`,{d:`M3 5v12a2 2 0 0 0 2 2h3`,key:`x1gjn2`}]]),rn=_(`notebook-pen`,[[`path`,{d:`M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4`,key:`re6nr2`}],[`path`,{d:`M2 6h4`,key:`aawbzj`}],[`path`,{d:`M2 10h4`,key:`l0bgd4`}],[`path`,{d:`M2 14h4`,key:`1gsvsf`}],[`path`,{d:`M2 18h4`,key:`1bu2t1`}],[`path`,{d:`M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z`,key:`pqwjuv`}]]),Q=e(o(),1),$=s();function an({bot:e,initiallyOpen:t=!1,onDeleted:n,onError:r}){let{t:i}=d(),a=X(e=>e.remove),[o,s]=(0,Q.useState)(t),[c,l]=(0,Q.useState)(!1),u=async()=>{l(!0);try{await At(e.id),a(e.id),s(!1),n()}catch(e){r(e instanceof Error?e.message:String(e))}finally{l(!1)}};return(0,$.jsxs)(Xt,{title:i(`bots:delete.section`),className:`mt-4`,children:[(0,$.jsx)(Z,{title:i(`bots:delete.title`),description:i(`bots:delete.hint`),control:(0,$.jsxs)(K,{type:`button`,variant:`destructive`,size:`sm`,"data-bot-delete":e.id,onClick:()=>s(!0),children:[(0,$.jsx)(je,{"aria-hidden":`true`}),i(`bots:delete.action`)]})}),(0,$.jsx)(Ve,{open:o,onOpenChange:e=>!c&&s(e),children:(0,$.jsxs)(Ie,{children:[(0,$.jsxs)(Be,{children:[(0,$.jsx)(Fe,{children:i(`bots:delete.confirmTitle`,{name:e.name})}),(0,$.jsx)(Pe,{children:i(`bots:delete.confirmDescription`)})]}),(0,$.jsxs)(Re,{children:[(0,$.jsx)(ze,{disabled:c,children:i(`common:ui.cancel`)}),(0,$.jsxs)(Le,{variant:`destructive`,disabled:c,onClick:e=>{e.preventDefault(),u()},children:[c&&(0,$.jsx)(G,{className:`text-current`}),i(`bots:delete.action`)]})]})]})})]})}function on(e,t){return!t||t.kind===`local`?e(`bots:computer.local`):t.name||e(`bots:computer.unnamed`)}function sn(e,t){return[`npx pisper executor pair --brain ${e.remote.endpoints[0]||t.brain} --fingerprint ${e.remote.fingerprint||t.fingerprint} --code ${e.code} --root ${t.root}`,`npx pisper executor`]}function cn({environment:e,onRemoved:t,onError:n}){let{t:r}=d(),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(!1),c=async()=>{s(!0);try{await Kt(e.id),t()}catch(e){n(e instanceof Error?e.message:String(e)),a(!1)}finally{s(!1)}};return(0,$.jsxs)(`li`,{"data-environment":e.id,className:`flex flex-col gap-1 py-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:W(`size-2 flex-none rounded-full`,e.online?`bg-success`:`bg-content-faint`)}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-content`,children:on(r,e)}),(0,$.jsx)(`span`,{className:`text-xs text-content-muted`,children:e.online?r(`bots:computer.online`):r(`bots:computer.offline`)}),e.kind===`node`&&(i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K,{size:`sm`,variant:`ghost`,disabled:o,onClick:()=>a(!1),children:r(`bots:computer.cancel`)}),(0,$.jsx)(K,{size:`sm`,variant:`destructive`,disabled:o,onClick:()=>void c(),children:r(`bots:computer.confirmRemove`)})]}):(0,$.jsx)(K,{size:`sm`,variant:`ghost`,onClick:()=>a(!0),children:r(`bots:computer.remove`)}))]}),e.roots.length>0&&(0,$.jsx)(`p`,{className:`truncate pl-4 font-mono text-xs text-content-muted`,children:e.roots.join(` · `)}),e.usedBy.length>0&&(0,$.jsx)(`p`,{className:`pl-4 text-xs text-content-muted`,children:r(`bots:computer.usedBy`,{names:e.usedBy.map(e=>e.name).join(`、`)})})]})}function ln({pairing:e,onDone:t}){let{t:n}=d(),r=a(),[i,o]=(0,Q.useState)(!1),s=sn(e,{brain:n(`bots:computer.brainPlaceholder`),fingerprint:`SHA256:…`,root:n(`bots:computer.rootPlaceholder`)}),c=async()=>{try{await navigator.clipboard.writeText(s.join(`
2
+ `)),o(!0)}catch{o(!1)}};return(0,$.jsxs)(`section`,{"aria-label":n(`bots:computer.addTitle`),className:`mt-2 rounded-xl border border-stroke bg-surface-subtle p-3 text-sm`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`h4`,{className:`font-semibold text-content`,children:n(`bots:computer.addTitle`)}),(0,$.jsx)(K,{size:`sm`,variant:`ghost`,onClick:t,children:n(`bots:computer.done`)})]}),(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-content-muted`,children:[n(`bots:computer.code`),` `,(0,$.jsx)(`b`,{"data-pairing-code":!0,className:`font-mono text-content`,children:e.code}),` `,`· `,n(`bots:computer.codeHint`)]}),!e.remote.enabled&&(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 rounded-lg border border-st-attn-border bg-surface-raised px-2.5 py-2 text-xs text-content-secondary`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1`,children:n(`bots:computer.remoteOff`)}),(0,$.jsx)(K,{size:`sm`,variant:`outline`,onClick:()=>r(`/config/remote-access`),children:n(`bots:computer.openRemote`)})]}),(0,$.jsx)(`p`,{className:`mt-2 text-xs text-content-muted`,children:n(`bots:computer.runThere`)}),(0,$.jsx)(`pre`,{className:`mt-1 max-h-40 overflow-auto rounded-lg bg-surface-raised p-2.5 font-mono text-xs whitespace-pre-wrap break-all text-content-secondary`,children:s.join(`
3
+ `)}),(0,$.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-content-muted`,children:n(`bots:computer.rootHint`)}),(0,$.jsxs)(K,{size:`sm`,variant:`outline`,onClick:()=>void c(),children:[(0,$.jsx)(T,{"aria-hidden":`true`}),n(i?`bots:computer.copied`:`bots:computer.copy`)]})]})]})}function un({bot:e,environments:t,onEnvironmentsChanged:n,onError:r}){let{t:i}=d(),a=X(e=>e.upsert),[o,s]=(0,Q.useState)(e.workspace.environmentId),[c,l]=(0,Q.useState)(e.workspace.cwd),[u,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{s(e.workspace.environmentId),l(e.workspace.cwd)},[e.id,e.workspace.environmentId,e.workspace.cwd]);let y=t.find(e=>e.id===o),b=o===`local`,x=o!==e.workspace.environmentId||c.trim()!==e.workspace.cwd,S=async t=>{g(!0);try{a(await St(e.id,{workspace:{...e.workspace,...t}})),n()}catch(e){r(e instanceof Error?e.message:String(e))}finally{g(!1)}},C=async()=>{if(!u){if(!b){m(!0);return}f(!0);try{let t=await pt(c||e.workspace.cwd,i(`bots:computer.folder`));t.status===`picked`?l(t.path):t.status===`unavailable`&&m(!0)}catch(e){r(e instanceof Error?e.message:String(e))}finally{f(!1)}}},w=async()=>{try{v(await Wt())}catch(e){r(e instanceof Error?e.message:String(e))}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`p`,{className:`text-xs text-content-muted`,children:i(`bots:computer.description`)}),(0,$.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-sm`,children:[(0,$.jsx)(`span`,{className:`flex-none`,children:i(`bots:computer.runsOn`)}),(0,$.jsxs)(Y,{value:o,className:`w-48`,"aria-label":i(`bots:computer.runsOn`),disabled:h,onChange:t=>{s(t.target.value),l(t.target.value===e.workspace.environmentId?e.workspace.cwd:``)},children:[t.length===0&&(0,$.jsx)(`option`,{value:`local`,children:i(`bots:computer.local`)}),t.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.kind===`local`?i(`bots:computer.local`):i(`bots:computer.option`,{name:on(i,e),state:e.online?i(`bots:computer.online`):i(`bots:computer.offline`)})},e.id))]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-content-muted`,children:i(`bots:computer.folder`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(te,{className:`size-3.5 flex-none text-content-muted`,"aria-hidden":`true`}),(0,$.jsx)(q,{value:c,className:`font-mono text-xs`,"aria-label":i(`bots:computer.folder`),placeholder:b?i(`bots:computer.folderPlaceholder`):y?.roots[0]??i(`bots:computer.folderPlaceholder`),disabled:h,onChange:e=>l(e.target.value)}),(b||y)&&(0,$.jsx)(K,{size:`sm`,variant:`outline`,disabled:h||u,onClick:()=>void C(),children:i(`bots:new.pick`)})]}),!b&&y&&(0,$.jsx)(`p`,{className:`text-xs text-content-muted`,children:i(`bots:computer.folderInRoots`,{roots:y.roots.join(`、`)})}),x&&(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(K,{size:`sm`,disabled:h||!c.trim(),onClick:()=>void S({environmentId:o,cwd:c.trim()}),children:i(`bots:computer.switch`)})})]}),(0,$.jsxs)(`section`,{"aria-label":i(`bots:computer.listTitle`),className:`border-t border-stroke pt-3`,children:[(0,$.jsx)(`h4`,{className:`text-xs font-medium text-content-muted`,children:i(`bots:computer.listTitle`)}),(0,$.jsx)(`ul`,{role:`list`,className:`m-0 list-none divide-y divide-stroke p-0`,children:t.map(e=>(0,$.jsx)(cn,{environment:e,onRemoved:n,onError:r},e.id))}),_?(0,$.jsx)(ln,{pairing:_,onDone:()=>{v(null),n()}}):(0,$.jsxs)(K,{size:`sm`,variant:`outline`,className:`mt-1`,onClick:()=>void w(),children:[(0,$.jsx)(ae,{"aria-hidden":`true`}),i(`bots:computer.add`)]})]}),(0,$.jsx)(k,{open:p,initialPath:c,onOpenChange:m,listFolders:(e,t)=>Tt(o,e,t),onSelect:e=>{l(e),m(!1)}})]})}function dn(e){return`ref`in e?`ref:${e.ref}`:`tier:${e.tier}`}function fn(e){return e.startsWith(`ref:`)?{ref:e.slice(4)}:{tier:Vt.find(t=>`tier:${t}`===e)??`standard`}}function pn({bot:e,saving:t,onSave:n}){let{t:r}=d(),[i,a]=(0,Q.useState)([]);(0,Q.useEffect)(()=>{let e=!0;return Dt().then(t=>e&&a(t)).catch(()=>e&&a([])),()=>{e=!1}},[]);let o=i.map(e=>e.name),s=dn(e.model);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{title:r(`bots:model.model`),description:r(`bots:model.hint`),control:(0,$.jsxs)(Y,{value:s,className:`w-48`,"aria-label":r(`bots:model.model`),disabled:t,onChange:e=>n({model:fn(e.target.value)}),children:[Vt.map(e=>(0,$.jsx)(`option`,{value:`tier:${e}`,children:se(r,{tier:e})},e)),`ref`in e.model&&!i.some(e=>`ref:${e.ref}`===s)&&(0,$.jsx)(`option`,{value:s,children:e.model.ref}),i.map(e=>(0,$.jsx)(`option`,{value:`ref:${e.ref}`,children:`${ft(e.name,o)} · ${e.providerName}`},e.ref))]})}),(0,$.jsx)(Z,{title:r(`bots:model.thinking`),control:(0,$.jsxs)(Y,{value:e.thinking??``,className:`w-48`,"aria-label":r(`bots:model.thinking`),disabled:t,onChange:e=>n({thinking:zt.find(t=>t===e.target.value)??null}),children:[(0,$.jsx)(`option`,{value:``,children:r(`bots:model.thinkingDefault`)}),zt.map(e=>(0,$.jsx)(`option`,{value:e,children:oe(r,e)},e))]})})]})}function mn({bot:e,saving:t=!1,onError:n,onCount:r,onReadGlobalChange:i}){let{t:a}=d(),[o,s]=(0,Q.useState)(null),[c,l]=(0,Q.useState)(``),[u,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let t=new AbortController;return Mt(e.id,t.signal).then(e=>s(e)).catch(e=>{t.signal.aborted||(s([]),n(e instanceof Error?e.message:String(e)))}),()=>t.abort()},[e.id,n]),(0,Q.useEffect)(()=>{o&&r?.(o.length)},[o,r]);let h=async e=>{m(!0);try{await e()}catch(e){n(e instanceof Error?e.message:String(e))}finally{m(!1)}},g=()=>h(async()=>{let t=await Ht(e.id,c);s(e=>[...(e||[]).filter(e=>e.id!==t.id),t]),l(``)}),_=()=>h(async()=>{if(!u)return;let t=await Nt(e.id,u.id,u.text);s(e=>(e||[]).map(e=>e.id===t.id?t:e)),f(null)}),v=t=>h(async()=>{await jt(e.id,t),s(e=>(e||[]).filter(e=>e.id!==t))});return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`p`,{className:`m-0 text-xs text-content-muted`,children:a(`bots:memory.hint`,{name:e.name})}),i&&(0,$.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-sm`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{children:a(`bots:memory.readGlobal`)}),(0,$.jsx)(`span`,{className:`text-xs text-content-muted`,children:a(`bots:memory.readGlobalHint`)})]}),(0,$.jsx)(H,{checked:e.readGlobalMemory,disabled:t,onCheckedChange:i})]}),o&&!o.length&&(0,$.jsx)(ht,{compact:!0,title:a(`bots:memory.empty`,{name:e.name})}),o&&o.length>0&&(0,$.jsx)(`ul`,{role:`list`,className:`m-0 flex list-none flex-col gap-1.5 p-0`,children:[...o].reverse().map(e=>u?.id===e.id?(0,$.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(q,{value:u.text,maxLength:500,"aria-label":a(`bots:memory.editLabel`),onChange:t=>f({id:e.id,text:t.target.value}),onKeyDown:e=>{e.key===`Enter`&&u.text.trim()&&_(),e.key===`Escape`&&f(null)}}),(0,$.jsx)(K,{size:`sm`,disabled:p||!u.text.trim(),onClick:()=>void _(),children:a(`bots:memory.save`)}),(0,$.jsx)(K,{size:`sm`,variant:`ghost`,onClick:()=>f(null),children:a(`bots:memory.cancel`)})]},e.id):(0,$.jsxs)(`li`,{"data-bot-memory":e.id,className:`group flex items-start gap-2 rounded-lg bg-surface-subtle px-2.5 py-2 text-[13px]`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-content`,children:e.text}),(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon-xs`,className:`flex-none pointer-coarse:size-11`,"aria-label":a(`bots:memory.edit`),title:a(`bots:memory.edit`),disabled:p,onClick:()=>f({id:e.id,text:e.text}),children:(0,$.jsx)(P,{"aria-hidden":`true`})}),(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon-xs`,className:`flex-none pointer-coarse:size-11`,"aria-label":a(`bots:memory.delete`),title:a(`bots:memory.delete`),disabled:p,onClick:()=>void v(e.id),children:(0,$.jsx)(je,{"aria-hidden":`true`})})]},e.id))}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(q,{value:c,maxLength:500,"aria-label":a(`bots:memory.addLabel`),placeholder:a(`bots:memory.addPlaceholder`),onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&c.trim()&&g()}}),(0,$.jsx)(K,{size:`sm`,variant:`outline`,disabled:p||!c.trim(),onClick:()=>void g(),children:a(`bots:memory.add`)})]})]})}var hn=[`feishu`,`weixin`,`qq`,`telegram`],gn=e=>hn.includes(e);function _n(e){let t=e&&typeof e==`object`?e:null,n=t?.connections;if(!n||typeof n!=`object`||Array.isArray(n))throw p();let r=hn.flatMap(e=>{let t=n[e];if(!t||typeof t!=`object`)return[];let{enabled:r,ownerConfigured:i}=t;return r===!1?[]:[{platform:e,ownerConfigured:i===!0}]}),i=new Set(r.map(e=>e.platform));return{channels:r,groups:(Array.isArray(t.scopes)?t.scopes:[]).flatMap(e=>{let t=e&&typeof e==`object`?e:{},n=e=>typeof e==`string`?e.trim():``,r=n(t.peerId);return t.chatType!==`group`||!gn(t.platform)||!r||!i.has(t.platform)?[]:[{platform:t.platform,peerId:r,title:n(t.title)||r,lastMessage:n(t.lastMessage)}]})}}function vn(e){return m(`/api/channels`,{signal:e,parse:_n})}function yn(e,t){return e.some(e=>e.platform===t.platform&&e.chatType===t.chatType&&e.senderIds.length===0&&(e.peerIds===null||t.peerIds!==null&&t.peerIds.every(t=>e.peerIds?.includes(t))))}function bn({bot:e,onError:t}){let{t:n}=d(),i=X(e=>e.upsert),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),[l,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(`feishu`),[y,b]=(0,Q.useState)(`p2p`),[x,S]=(0,Q.useState)(``),[C,w]=(0,Q.useState)(``),[T,E]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let e=new AbortController;return g(``),vn(e.signal).then(t=>{e.signal.aborted||m(t)},t=>{e.signal.aborted||g(t instanceof Error?t.message:String(t))}),()=>e.abort()},[a]);let D=async n=>{f(!0);try{return i(await St(e.id,{channels:n})),!0}catch(e){return t(e instanceof Error?e.message:String(e)),!1}finally{f(!1)}},O=()=>{o(!1),c(!1),S(``),w(``),E(!1)},ee=async t=>{await D([...e.channels,t])&&O()},k=()=>{let e=F(x);ee({platform:_,chatType:y,peerIds:e.length?e:null,senderIds:F(C),everyone:T})},A=p?[...p.channels.map(e=>({key:`${e.platform}:p2p`,title:n(`bots:triggers.pickP2p`,{platform:R(n,e.platform)}),detail:e.ownerConfigured?n(`bots:triggers.ownerOnly`):n(`bots:triggers.ownerMissing`),channel:{platform:e.platform,chatType:`p2p`,peerIds:null,senderIds:[],everyone:!1},unavailable:!e.ownerConfigured})),...p.groups.map(e=>{let t=p.channels.find(t=>t.platform===e.platform);return{key:`${e.platform}:group:${e.peerId}`,title:e.title,detail:[n(`bots:triggers.pickGroup`,{platform:R(n,e.platform)}),e.lastMessage].filter(Boolean).join(` · `),channel:{platform:e.platform,chatType:`group`,peerIds:[e.peerId],senderIds:[],everyone:!1},unavailable:!t?.ownerConfigured}})]:[];return(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs text-content-muted`,children:n(`bots:triggers.chatsHint`,{name:e.name})}),e.channels.length>0&&(0,$.jsx)(`ul`,{role:`list`,className:`m-0 mb-2 flex list-none flex-col gap-1.5 p-0`,children:e.channels.map((t,r)=>(0,$.jsxs)(`li`,{"data-bot-channel":t.platform,className:`flex items-start gap-2 rounded-lg bg-surface-subtle px-2.5 py-2 text-xs`,children:[(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`b`,{className:`font-medium text-content`,children:[R(n,t.platform),` ·`,` `,t.chatType===`group`?n(`bots:triggers.group`):n(`bots:triggers.p2p`)]}),(0,$.jsxs)(`span`,{className:`block truncate text-content-muted`,children:[t.peerIds?n(`bots:triggers.peers`,{ids:t.peerIds.map(e=>p?.groups.find(n=>n.platform===t.platform&&n.peerId===e)?.title||e).join(`、`)}):n(`bots:triggers.allPeers`),` · `,t.senderIds.length?n(`bots:triggers.adminsWith`,{ids:t.senderIds.join(`、`)}):n(`bots:triggers.admins`)]}),(0,$.jsxs)(`label`,{className:`mt-1.5 flex items-center gap-2 text-content-secondary`,children:[(0,$.jsx)(H,{size:`sm`,checked:t.everyone,disabled:l,onCheckedChange:t=>void D(e.channels.map((e,n)=>n===r?{...e,everyone:t}:e))}),n(`bots:triggers.everyone`)]})]}),(0,$.jsx)(K,{size:`sm`,variant:`ghost`,disabled:l,onClick:()=>void D(e.channels.filter((e,t)=>t!==r)),children:n(`bots:triggers.remove`)})]},`${t.platform}-${r}`))}),a?(0,$.jsxs)(`div`,{"data-bot-channel-picker":!0,className:`flex flex-col gap-2 rounded-lg border border-stroke p-2.5`,children:[s?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`m-0 text-xs text-content-muted`,children:n(`bots:triggers.manualHint`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Y,{value:_,className:`w-32`,"aria-label":n(`bots:triggers.platform`),onChange:e=>v(e.target.value),children:Pt.map(e=>(0,$.jsx)(`option`,{value:e,children:R(n,e)},e))}),(0,$.jsx)(U,{value:y,onValueChange:e=>b(e),options:[{value:`p2p`,label:n(`bots:triggers.p2p`)},{value:`group`,label:n(`bots:triggers.group`)}]})]}),(0,$.jsx)(q,{value:x,"aria-label":n(`bots:triggers.peerIds`),placeholder:n(`bots:triggers.peerIdsPlaceholder`),onChange:e=>S(e.target.value)}),(0,$.jsx)(q,{value:C,"aria-label":n(`bots:triggers.senderIds`),placeholder:n(`bots:triggers.senderIdsPlaceholder`),onChange:e=>w(e.target.value)}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-content-secondary`,children:[(0,$.jsx)(H,{size:`sm`,checked:T,onCheckedChange:E}),n(`bots:triggers.everyone`)]})]}):h?(0,$.jsx)(`p`,{role:`alert`,className:`m-0 text-xs text-destructive`,children:h}):p?A.length===0?(0,$.jsx)(ht,{compact:!0,icon:N,title:n(`bots:triggers.noChannels`),description:n(`bots:triggers.noChannelsHint`),action:(0,$.jsx)(K,{asChild:!0,size:`sm`,variant:`outline`,children:(0,$.jsx)(r,{to:u.channels,children:n(`bots:triggers.openChannels`)})})}):(0,$.jsx)(`ul`,{role:`list`,"aria-label":n(`bots:triggers.pickTitle`),className:`m-0 flex list-none flex-col p-0`,children:A.map(t=>{let r=yn(e.channels,t.channel),i=t.channel.chatType===`group`?Me:N;return(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,"data-bot-chat-option":t.key,className:`flex min-h-11 w-full min-w-0 items-center gap-2.5 rounded-md px-2 py-1.5 text-left outline-none hover:bg-surface-hover focus-visible:ring-3 focus-visible:ring-focus-ring disabled:cursor-not-allowed disabled:opacity-50`,disabled:l||r||t.unavailable,onClick:()=>void ee(t.channel),children:[(0,$.jsx)(i,{className:`size-4 flex-none text-content-muted`,"aria-hidden":`true`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm text-content`,children:t.title}),(0,$.jsx)(`span`,{className:`block truncate text-xs text-content-muted`,children:t.detail})]}),r?(0,$.jsx)(`span`,{className:`flex-none text-xs text-content-muted`,children:n(`bots:triggers.added`)}):(0,$.jsx)(ae,{className:`size-4 flex-none text-content-muted`,"aria-hidden":`true`})]})},t.key)})}):(0,$.jsx)(`div`,{role:`status`,className:`grid min-h-16 place-items-center`,children:(0,$.jsx)(G,{className:`size-4`})}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[s?(0,$.jsx)(`span`,{}):(0,$.jsx)(K,{size:`sm`,variant:`ghost`,onClick:()=>c(!0),children:n(`bots:triggers.manual`)}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(K,{size:`sm`,variant:`ghost`,onClick:O,children:n(`bots:triggers.cancel`)}),s&&(0,$.jsx)(K,{size:`sm`,disabled:l,onClick:k,children:n(`bots:triggers.add`)})]})]})]}):(0,$.jsx)(K,{size:`sm`,variant:`outline`,className:`self-start`,onClick:()=>o(!0),children:n(`bots:triggers.addChat`)})]})}var xn=[1,2,3,4,5,6,0];function Sn(){let e=new Date,t=e=>String(e).padStart(2,`0`);return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`}function Cn({bot:e,initialMessage:t=``,onCancel:n,onCreated:r,onError:i}){let{t:a}=d(),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(t),[u,f]=(0,Q.useState)(t?`weekly`:`daily`),[p,m]=(0,Q.useState)(`09:00`),[h,g]=(0,Q.useState)(Sn),[_,v]=(0,Q.useState)(t?5:1),y=async()=>{let t=c.trim();s(!0);try{await Lt({botId:e.id,name:`${e.name}:${t.slice(0,40)}`,botMessage:t,frequency:u,time:p,date:u===`once`?h:``,dayOfWeek:_,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone||`Asia/Hong_Kong`}),r()}catch(e){i(e instanceof Error?e.message:String(e))}finally{s(!1)}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-stroke p-2.5`,children:[(0,$.jsx)(q,{value:c,maxLength:12e3,"aria-label":a(`bots:triggers.scheduleMessage`),placeholder:a(`bots:triggers.scheduleMessagePlaceholder`),onChange:e=>l(e.target.value)}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(Y,{value:u,className:`w-28`,"aria-label":a(`bots:triggers.frequency`),onChange:e=>f(e.target.value),children:[(0,$.jsx)(`option`,{value:`daily`,children:a(`bots:triggers.daily`)}),(0,$.jsx)(`option`,{value:`weekly`,children:a(`bots:triggers.weekly`)}),(0,$.jsx)(`option`,{value:`once`,children:a(`bots:triggers.once`)})]}),u===`weekly`&&(0,$.jsx)(Y,{value:String(_),className:`w-24`,"aria-label":a(`bots:triggers.weekday`),onChange:e=>v(Number(e.target.value)),children:xn.map(e=>(0,$.jsx)(`option`,{value:e,children:L(a,e)},e))}),u===`once`&&(0,$.jsx)(q,{type:`date`,value:h,className:`w-40`,"aria-label":a(`bots:triggers.date`),onChange:e=>g(e.target.value)}),(0,$.jsx)(q,{type:`time`,value:p,className:`w-28`,"aria-label":a(`bots:triggers.time`),onChange:e=>m(e.target.value)})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(K,{size:`sm`,variant:`ghost`,onClick:n,children:a(`bots:triggers.cancel`)}),(0,$.jsx)(K,{size:`sm`,disabled:o||!c.trim(),onClick:()=>void y(),children:a(`bots:triggers.add`)})]})]})}function wn({bot:e,onError:t,onCount:n}){let{t:r}=d(),[i,a]=(0,Q.useState)([]),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(!1),u=(0,Q.useCallback)(async()=>{try{let t=await Gt(e.id);a(t),n?.(t.length)}catch{}},[e.id,n]);(0,Q.useEffect)(()=>{u()},[u]);let f=async e=>{l(!0);try{await e(),await u()}catch(e){t(e instanceof Error?e.message:String(e))}finally{l(!1)}};return(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[i.length>0&&(0,$.jsx)(`ul`,{role:`list`,className:`m-0 mb-2 flex list-none flex-col gap-1.5 p-0`,children:i.map(e=>(0,$.jsxs)(`li`,{"data-bot-schedule":e.id,className:`flex items-center gap-2 rounded-lg bg-surface-subtle px-2.5 py-2 text-xs`,children:[(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`b`,{className:`block truncate font-medium text-content`,children:e.botMessage}),(0,$.jsx)(`span`,{className:`text-content-muted`,children:I(r,e)})]}),(0,$.jsx)(H,{checked:e.enabled,disabled:c,"aria-label":r(`bots:triggers.scheduleEnabled`),onCheckedChange:t=>void f(()=>Et(e.id,t))}),(0,$.jsx)(K,{size:`sm`,variant:`ghost`,disabled:c,onClick:()=>void f(()=>Bt(e.id)),children:r(`bots:triggers.remove`)})]},e.id))}),o?(0,$.jsx)(Cn,{bot:e,onCancel:()=>s(!1),onCreated:()=>{s(!1),u()},onError:t}):(0,$.jsx)(K,{size:`sm`,variant:`outline`,className:`self-start`,onClick:()=>s(!0),children:r(`bots:triggers.addSchedule`)})]})}function Tn({bot:e,onError:t,onCount:n}){let{t:r}=d(),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(null),[c,l]=(0,Q.useState)(``),[u,f]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let n=new AbortController;return kt(e.id,n.signal).then(e=>a(e)).catch(e=>{n.signal.aborted||(a([]),t(e instanceof Error?e.message:String(e)))}),()=>n.abort()},[e.id,t]),(0,Q.useEffect)(()=>{i&&n?.(i.length)},[i,n]);let p=n=>{if(o?.name===n){s(null);return}s({name:n,body:null}),Jt(e.id,n).then(e=>s(t=>t?.name===n?{name:n,body:e.body}:t)).catch(e=>{s(null),t(e instanceof Error?e.message:String(e))})},m=async n=>{f(!0);try{await Rt(e.id,n),a(e=>(e||[]).filter(e=>e.name!==n)),o?.name===n&&s(null)}catch(e){t(e instanceof Error?e.message:String(e))}finally{f(!1)}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`p`,{className:`m-0 text-xs text-content-muted`,children:r(`bots:skills.hint`,{name:e.name})}),i&&!i.length&&(0,$.jsx)(ht,{compact:!0,title:r(`bots:skills.empty`,{name:e.name})}),i&&i.length>0&&(0,$.jsx)(`ul`,{role:`list`,className:`m-0 flex list-none flex-col gap-1.5 p-0`,children:i.map(n=>{let i=o?.name===n.name;return(0,$.jsxs)(`li`,{"data-bot-skill":n.name,className:`flex flex-col gap-2 rounded-lg bg-surface-subtle px-2.5 py-2 text-[13px]`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-start gap-1.5 text-left`,"aria-expanded":i,onClick:()=>p(n.name),children:[i?(0,$.jsx)(S,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 flex-none`}):(0,$.jsx)(w,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 flex-none`}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`b`,{className:`block truncate font-medium text-content`,children:n.name}),(0,$.jsx)(`span`,{className:`block text-xs text-content-muted`,children:n.description})]})]}),(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon-xs`,className:`flex-none pointer-coarse:size-11`,"aria-label":r(`bots:skills.schedule`),title:r(`bots:skills.schedule`),disabled:u,onClick:()=>l(e=>e===n.name?``:n.name),children:(0,$.jsx)(b,{"aria-hidden":`true`})}),(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon-xs`,className:`flex-none pointer-coarse:size-11`,"aria-label":r(`bots:skills.delete`),title:r(`bots:skills.delete`),disabled:u,onClick:()=>void m(n.name),children:(0,$.jsx)(je,{"aria-hidden":`true`})})]}),i&&(0,$.jsx)(`pre`,{className:`m-0 max-h-72 overflow-auto rounded-md bg-surface px-2.5 py-2 text-xs whitespace-pre-wrap text-content`,children:o.body??r(`bots:skills.loading`)}),c===n.name&&(0,$.jsx)(Cn,{bot:e,initialMessage:r(`bots:skills.scheduleMessage`,{name:n.name}),onCancel:()=>l(``),onCreated:()=>l(``),onError:t})]},n.name)})})]})}function En({bot:e,saving:t,onSave:n}){let{t:r}=d(),[i,a]=(0,Q.useState)(e.proactive.briefAt);return(0,Q.useEffect)(()=>a(e.proactive.briefAt),[e.id,e.proactive.briefAt]),(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{title:r(`bots:proactive.check`),description:r(`bots:proactive.checkHint`,{name:e.name}),control:(0,$.jsx)(H,{checked:e.proactive.enabled,disabled:t,"aria-label":r(`bots:proactive.check`),onCheckedChange:e=>n({enabled:e})})}),e.proactive.enabled&&(0,$.jsx)(Z,{nested:!0,title:r(`bots:proactive.every`),control:(0,$.jsx)(Y,{value:String(e.proactive.everyHours),className:`w-48`,"aria-label":r(`bots:proactive.every`),disabled:t,onChange:e=>n({everyHours:Number(e.target.value)}),children:Ot.map(e=>(0,$.jsx)(`option`,{value:e,children:r(`bots:proactive.everyHours`,{count:e})},e))})}),(0,$.jsx)(Z,{title:r(`bots:proactive.brief`),description:r(`bots:proactive.briefHint`),control:(0,$.jsx)(H,{checked:e.proactive.brief,disabled:t,"aria-label":r(`bots:proactive.brief`),onCheckedChange:e=>n({brief:e})})}),e.proactive.brief&&(0,$.jsx)(Z,{nested:!0,title:r(`bots:proactive.briefAt`),control:(0,$.jsx)(q,{type:`time`,value:i,className:`w-48`,"aria-label":r(`bots:proactive.briefAt`),disabled:t,onChange:e=>a(e.target.value),onBlur:()=>{/^\d{2}:\d{2}$/.test(i)&&i!==e.proactive.briefAt&&n({briefAt:i})}})})]})}var Dn={name:``,kind:`task`,text:``,audience:`admins`,allowExtra:!1};function On({initial:e,saving:t,onCancel:n,onSave:r}){let{t:i}=d(),[a,o]=(0,Q.useState)(e),s=e=>o(t=>({...t,...e})),c=a.kind===`task`;return(0,$.jsxs)(`form`,{"data-bot-command-form":!0,className:`flex flex-col gap-2 rounded-lg border border-stroke p-2.5`,onSubmit:e=>{e.preventDefault(),r({...a,name:a.name.trim(),text:a.text.trim()})},children:[(0,$.jsx)(q,{value:a.name,autoFocus:!0,maxLength:24,"aria-label":i(`bots:commands.name`),placeholder:i(`bots:commands.namePlaceholder`),onChange:e=>s({name:e.target.value})}),(0,$.jsx)(U,{value:a.kind,onValueChange:e=>s({kind:e,allowExtra:e===`task`&&a.allowExtra}),options:[{value:`task`,label:i(`bots:commands.task`)},{value:`reply`,label:i(`bots:commands.reply`)}]}),(0,$.jsx)(dt,{value:a.text,rows:3,maxLength:4e3,"aria-label":i(c?`bots:commands.taskText`:`bots:commands.replyText`),placeholder:i(c?`bots:commands.taskPlaceholder`:`bots:commands.replyPlaceholder`),onChange:e=>s({text:e.target.value})}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-sm`,children:[(0,$.jsx)(`span`,{className:`text-content-secondary`,children:i(`bots:commands.audience`)}),(0,$.jsx)(U,{value:a.audience,onValueChange:e=>s({audience:e}),options:[{value:`admins`,label:i(`bots:commands.admins`)},{value:`everyone`,label:i(`bots:commands.everyone`)}]})]}),c&&(0,$.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-sm`,children:[(0,$.jsx)(`span`,{className:`text-content-secondary`,children:i(`bots:commands.allowExtra`)}),(0,$.jsx)(H,{checked:a.allowExtra,onCheckedChange:e=>s({allowExtra:e})})]}),c&&a.allowExtra&&a.audience===`everyone`&&(0,$.jsx)(`p`,{className:`m-0 text-xs text-content-muted`,children:i(`bots:commands.extraNote`)}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(K,{type:`button`,size:`sm`,variant:`ghost`,onClick:n,children:i(`bots:triggers.cancel`)}),(0,$.jsx)(K,{type:`submit`,size:`sm`,disabled:t||!a.name.trim()||!a.text.trim(),children:i(`bots:commands.save`)})]})]})}function kn({bot:e,onError:t}){let{t:n}=d(),r=X(e=>e.upsert),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(!1),c=async n=>{s(!0);try{return r(await St(e.id,{commands:n})),!0}catch(e){return t(e instanceof Error?e.message:String(e)),!1}finally{s(!1)}},l=(t,n)=>{let r=[...e.commands],[i]=r.splice(t,1);r.splice(t+n,0,i),c(r)},u=e.channels.some(e=>e.everyone);return(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs text-content-muted`,children:n(`bots:commands.hint`,{name:e.name})}),e.commands.some(e=>e.audience===`everyone`)&&!u&&(0,$.jsx)(`p`,{className:`mb-2 text-xs text-content-muted`,children:n(`bots:commands.noEveryoneChat`)}),e.commands.length>0&&(0,$.jsx)(`ol`,{className:`m-0 mb-2 flex list-none flex-col gap-1.5 p-0`,children:e.commands.map((t,r)=>i===r?(0,$.jsx)(`li`,{children:(0,$.jsx)(On,{initial:t,saving:o,onCancel:()=>a(null),onSave:async t=>{await c(e.commands.map((e,n)=>n===r?t:e))&&a(null)}})},t.name):(0,$.jsxs)(`li`,{"data-bot-command":t.name,className:`flex items-start gap-2 rounded-lg bg-surface-subtle px-2.5 py-2 text-xs`,children:[(0,$.jsx)(`span`,{className:`w-4 flex-none pt-px text-right font-mono text-content-muted`,children:r+1}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`b`,{className:`block truncate font-medium text-content`,children:t.name}),(0,$.jsx)(`span`,{className:`block truncate text-content-muted`,children:[t.audience===`everyone`?n(`bots:commands.everyone`):n(`bots:commands.admins`),t.kind===`reply`?n(`bots:commands.reply`):n(`bots:commands.task`),t.allowExtra?n(`bots:commands.extraAllowed`):``,t.text].filter(Boolean).join(` · `)})]}),(0,$.jsx)(K,{size:`icon-sm`,variant:`ghost`,"aria-label":n(`bots:commands.moveUp`),disabled:o||i!==null||r===0,onClick:()=>l(r,-1),children:(0,$.jsx)(y,{})}),(0,$.jsx)(K,{size:`icon-sm`,variant:`ghost`,"aria-label":n(`bots:commands.moveDown`),disabled:o||i!==null||r===e.commands.length-1,onClick:()=>l(r,1),children:(0,$.jsx)(v,{})}),(0,$.jsx)(K,{size:`sm`,variant:`ghost`,disabled:o||i!==null,onClick:()=>a(r),children:n(`bots:commands.edit`)}),(0,$.jsx)(K,{size:`sm`,variant:`ghost`,disabled:o||i!==null,onClick:()=>void c(e.commands.filter((e,t)=>t!==r)),children:n(`bots:triggers.remove`)})]},t.name))}),i===-1?(0,$.jsx)(On,{initial:Dn,saving:o,onCancel:()=>a(null),onSave:async t=>{await c([...e.commands,t])&&a(null)}}):(0,$.jsx)(K,{size:`sm`,variant:`outline`,className:`self-start`,disabled:i!==null||e.commands.length>=20,onClick:()=>a(-1),children:n(`bots:commands.add`)})]})}function An({id:e,title:t,summary:n,open:r,onToggle:i,children:a}){let{t:o}=d(),s=(0,Q.useId)();return(0,$.jsx)(Z,{"data-bot-setting":e,"data-state":r?`open`:`closed`,title:t,description:n,control:(0,$.jsxs)(K,{variant:`ghost`,size:`sm`,"aria-expanded":r,"aria-controls":r?s:void 0,onClick:i,children:[o(r?`bots:settings.collapse`:`bots:settings.manage`),(0,$.jsx)(w,{"aria-hidden":`true`,className:W(`transition-transform motion-reduce:transition-none`,r&&`rotate-90`)})]}),children:r&&(0,$.jsx)(`div`,{id:s,className:`mt-3`,children:a})})}function jn({bot:e,environment:t,saving:n,onSave:r}){let{t:i}=d(),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),l=async()=>{let t=s?.trim()??``;if(!t||t===e.name){c(null);return}await r({name:t})&&c(null)},u=[wt(i,e),i(`bots:settings.computerSummary`,{computer:on(i,t),folder:Ft(e.workspace.cwd)}),se(i,e.model)].join(` · `);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,$.jsxs)(`button`,{type:`button`,"aria-label":i(`bots:settings.changeLook`),"aria-expanded":a,title:i(`bots:settings.changeLook`),className:`relative flex-none rounded-[16px] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus`,onClick:()=>o(e=>!e),children:[(0,$.jsx)(J,{avatar:e.avatar,state:It(e),size:56}),(0,$.jsx)(`span`,{className:`absolute -right-1 -bottom-1 grid size-6 place-items-center rounded-full border border-stroke bg-solid text-content-muted shadow-edge`,children:(0,$.jsx)(P,{className:`size-3`,"aria-hidden":`true`})})]}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[s===null?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[(0,$.jsx)(`h2`,{className:`m-0 truncate text-lg font-semibold text-content`,children:e.name}),(0,$.jsx)(K,{variant:`ghost`,size:`icon-xs`,"aria-label":i(`bots:settings.rename`),title:i(`bots:settings.rename`),onClick:()=>c(e.name),children:(0,$.jsx)(P,{})})]}):(0,$.jsxs)(`form`,{className:`flex items-center gap-2`,onSubmit:e=>{e.preventDefault(),l()},children:[(0,$.jsx)(q,{autoFocus:!0,value:s,maxLength:24,"aria-label":i(`bots:new.name`),disabled:n,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Escape`&&c(null)}}),(0,$.jsx)(K,{type:`submit`,size:`sm`,disabled:n||!s.trim(),children:i(`bots:details.save`)}),(0,$.jsx)(K,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>c(null),children:i(`common:ui.cancel`)})]}),(0,$.jsxs)(`p`,{className:`m-0 mt-0.5 flex min-w-0 items-center gap-1.5 text-xs text-content-muted`,children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:W(`size-1.5 flex-none rounded-full`,e.enabled?`bg-success`:`bg-content-faint`)}),(0,$.jsx)(`span`,{className:`truncate`,children:u})]})]}),(0,$.jsxs)(`label`,{className:`flex flex-none items-center gap-2 text-[13px] text-content-secondary`,title:i(`bots:details.acceptsWork`),children:[i(`bots:settings.accepting`),(0,$.jsx)(H,{checked:e.enabled,disabled:n,"aria-label":i(`bots:details.acceptsWork`),onCheckedChange:e=>void r({enabled:e})})]})]}),a&&(0,$.jsx)(we,{value:e.avatar,disabled:n,onChange:e=>void r({avatar:e})})]})}function Mn({bot:e,environments:t,openSection:n,onEnvironmentsChanged:r,onError:i}){let{t:a}=d(),o=X(e=>e.upsert),[s,c]=(0,Q.useState)(e.instructions),[l,u]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(()=>new Set(n?[n]:[])),[m,h]=(0,Q.useState)({memory:null,skills:null,schedules:null});(0,Q.useEffect)(()=>c(e.instructions),[e.id,e.instructions]),(0,Q.useEffect)(()=>{let t=new AbortController,n=(e,t)=>t.then(t=>h(n=>({...n,[e]:t.length}))).catch(()=>{});return n(`memory`,Mt(e.id,t.signal)),n(`skills`,kt(e.id,t.signal)),n(`schedules`,Gt(e.id,t.signal)),()=>t.abort()},[e.id]);let g=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{n&&g.current?.querySelector(`[data-bot-setting="${CSS.escape(n)}"]`)?.scrollIntoView()},[n]);let _=async t=>{u(!0);try{return o(await St(e.id,t)),!0}catch(e){return i(e instanceof Error?e.message:String(e)),!1}finally{u(!1)}},v=e=>p(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),y=e=>({id:e,open:f.has(e),onToggle:()=>v(e)}),b=m.memory===null?``:a(`bots:memory.count`,{count:m.memory}),x=m.skills===null?``:a(`bots:skills.count`,{count:m.skills}),S=m.schedules===null?``:m.schedules?a(`bots:settings.schedulesCount`,{count:m.schedules}):a(`bots:settings.notSet`),C=(0,Q.useMemo)(()=>{let e=e=>t=>h(n=>n[e]===t?n:{...n,[e]:t});return{memory:e(`memory`),skills:e(`skills`),schedules:e(`schedules`)}},[]),w=t.find(t=>t.id===e.workspace.environmentId),T=e.commands.filter(e=>e.audience===`everyone`).length;return(0,$.jsxs)(`div`,{ref:g,className:`flex flex-col gap-8 pb-4`,children:[(0,$.jsx)(jn,{bot:e,environment:w,saving:l,onSave:_}),(0,$.jsxs)(`section`,{"aria-labelledby":`bot-instructions-title`,className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`h2`,{id:`bot-instructions-title`,className:`m-0 text-[15px] leading-6 font-medium text-content`,children:a(`bots:details.instructions`)}),(0,$.jsx)(dt,{value:s,rows:3,maxLength:12e3,"aria-labelledby":`bot-instructions-title`,placeholder:a(`bots:details.instructionsPlaceholder`),onChange:e=>c(e.target.value)}),s!==e.instructions&&(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(K,{size:`sm`,disabled:l,onClick:()=>void _({instructions:s}),children:a(`bots:details.save`)})})]}),(0,$.jsxs)(Xt,{title:a(`bots:settings.groupWork`),children:[(0,$.jsx)(An,{...y(`computer`),title:a(`bots:settings.computer`),summary:a(`bots:settings.computerSummary`,{computer:on(a,w),folder:Ft(e.workspace.cwd)}),children:(0,$.jsx)(un,{bot:e,environments:t,onEnvironmentsChanged:r,onError:i})}),(0,$.jsx)(pn,{bot:e,saving:l,onSave:e=>void _(e)}),(0,$.jsx)(Z,{title:a(`bots:details.permission`),description:a(`bots:details.permissionHint`),control:(0,$.jsx)(Y,{value:e.executionMode,className:`w-48`,"aria-label":a(`bots:details.permission`),disabled:l,onChange:e=>void _({executionMode:e.target.value}),children:[`approval-required`,`workspace-write`,`full-access`].map(e=>(0,$.jsx)(`option`,{value:e,children:Ce(a,e)},e))})}),(0,$.jsx)(Z,{title:a(`bots:details.tools`),description:a(`bots:details.toolsHint`),control:(0,$.jsxs)(Y,{value:Ct(e.tools),className:`w-48`,"aria-label":a(`bots:details.tools`),disabled:l,onChange:e=>void _({tools:e.target.value===`read-only`?[...xt]:null}),children:[(0,$.jsx)(`option`,{value:`all`,children:a(`bots:details.toolsAll`)}),(0,$.jsx)(`option`,{value:`read-only`,children:a(`bots:details.toolsReadOnly`)}),Ct(e.tools)===`custom`&&(0,$.jsx)(`option`,{value:`custom`,disabled:!0,children:a(`bots:details.toolsCustom`,{count:e.tools?.length??0})})]})}),(0,$.jsx)(Z,{title:a(`bots:details.parallel`),description:a(`bots:details.parallelHint`),control:(0,$.jsx)(Y,{value:String(e.maxParallelAgents),className:`w-48`,"aria-label":a(`bots:details.parallel`),disabled:l,onChange:e=>void _({maxParallelAgents:Number(e.target.value)}),children:[1,2,3,4,5,6].map(e=>(0,$.jsx)(`option`,{value:e,children:a(`bots:details.parallelCount`,{count:e})},e))})})]}),(0,$.jsxs)(Xt,{title:a(`bots:settings.groupReach`),children:[(0,$.jsx)(An,{...y(`chats`),title:a(`bots:settings.chats`),summary:e.channels.length?a(`bots:settings.chatsCount`,{count:e.channels.length}):a(`bots:settings.notSet`),children:(0,$.jsx)(bn,{bot:e,onError:i})}),(0,$.jsx)(An,{...y(`commands`),title:a(`bots:commands.title`),summary:e.commands.length?a(`bots:commands.count`,{count:e.commands.length,open:T}):a(`bots:settings.notSet`),children:(0,$.jsx)(kn,{bot:e,onError:i})})]}),(0,$.jsxs)(Xt,{title:a(`bots:settings.groupOwn`),children:[(0,$.jsx)(En,{bot:e,saving:l,onSave:e=>void _({proactive:e})}),(0,$.jsx)(An,{...y(`schedules`),title:a(`bots:settings.schedules`),summary:S,children:(0,$.jsx)(wn,{bot:e,onError:i,onCount:C.schedules})})]}),(0,$.jsxs)(Xt,{title:a(`bots:settings.groupMemory`),children:[(0,$.jsx)(An,{...y(`memory`),title:a(`bots:memory.title`),summary:b,children:(0,$.jsx)(mn,{bot:e,onError:i,onCount:C.memory})}),(0,$.jsx)(Z,{title:a(`bots:memory.readGlobal`),description:a(`bots:memory.readGlobalHint`),control:(0,$.jsx)(H,{checked:e.readGlobalMemory,disabled:l,"aria-label":a(`bots:memory.readGlobal`),onCheckedChange:e=>void _({readGlobalMemory:e})})}),(0,$.jsx)(An,{...y(`skills`),title:a(`bots:skills.title`),summary:x,children:(0,$.jsx)(Tn,{bot:e,onError:i,onCount:C.skills})})]})]})}var Nn={enabled:!1,endpoints:[],fingerprint:null};function Pn(){let[e,t]=(0,Q.useState)([]),[n,r]=(0,Q.useState)(Nn),[i,a]=(0,Q.useState)(!1),o=(0,Q.useRef)(0),s=(0,Q.useCallback)(async()=>{let e=++o.current;try{let n=await qt();if(e!==o.current)return;t(n.environments),r(n.remote)}catch{}finally{e===o.current&&a(!0)}},[]);return(0,Q.useEffect)(()=>{s();let e=window.setInterval(()=>{document.visibilityState===`visible`&&s()},1e4);return()=>{window.clearInterval(e),o.current+=1}},[s]),{environments:e,remote:n,loaded:i,refresh:s}}var Fn=`flex h-[52px] flex-none items-center gap-2 border-b border-stroke px-3 max-[650px]:h-[calc(52px+var(--pisper-safe-area-top,0px))] max-[650px]:px-2 max-[650px]:pt-[var(--pisper-safe-area-top,0px)] [[data-custom-titlebar]_&]:pr-[144px]`;function In({notify:e,phoneLeading:n}){let{t:r}=d(),o=g(),s=Yt(`bots`),{botId:c=``}=t(),l=a(),u=X(e=>e.bots),f=X(e=>e.loaded),[p,m]=(0,Q.useState)(!1),h=(0,Q.useCallback)(t=>e(t,`error`),[e]),_=be(h);Ut(s);let v=u.find(e=>e.id===c)??null,y=e=>o&&c?(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-col`,children:[(0,$.jsx)(`header`,{className:Fn,children:n}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:e})]}):e;return s?f?!c&&u[0]?(0,$.jsx)(i,{to:`/bots/${encodeURIComponent(u[0].id)}`,replace:!0}):v?(0,$.jsx)(Ln,{botId:v.id,phoneLeading:o?n:null,onOpenChat:()=>void _(v),onDeleted:()=>{e(r(`bots:delete.deleted`,{name:v.name})),l(`/`,{replace:!0})},onError:h},v.id):y((0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(mt,{kind:`empty`,title:u.length?r(`bots:page.notFound`):r(`bots:page.emptyTitle`),description:r(`bots:page.emptyDescription`),action:(0,$.jsxs)(K,{onClick:()=>m(!0),children:[(0,$.jsx)(ae,{"aria-hidden":`true`}),r(`bots:sidebar.newBot`)]})}),(0,$.jsx)(ue,{open:p,onOpenChange:m,onCreated:e=>void _(e)})]})):y((0,$.jsx)(mt,{kind:`loading`,title:r(`bots:page.loading`)})):y((0,$.jsx)(mt,{kind:`empty`,title:r(`bots:page.disabledTitle`),description:r(`bots:page.disabledDescription`),action:(0,$.jsx)(K,{onClick:()=>l(`/config/labs`),children:r(`bots:page.openLabs`)})}))}function Ln({botId:e,phoneLeading:t,onOpenChat:r,onDeleted:i,onError:a}){let{t:o}=d(),s=X(t=>t.bots.find(t=>t.id===e)),c=X(e=>e.load),l=Pn(),[u]=n(),f=u.get(`section`)===`chats`?`chats`:void 0,p=u.get(`action`)===`delete`;return s?(0,$.jsxs)(`div`,{"data-bot-settings":s.id,className:`flex h-full min-h-0 w-full min-w-0 flex-col`,children:[(0,$.jsxs)(`header`,{"data-window-drag-region":!0,className:`flex h-[52px] flex-none items-center gap-2 border-b border-stroke px-3 max-[650px]:h-[calc(52px+var(--pisper-safe-area-top,0px))] max-[650px]:px-2 max-[650px]:pt-[var(--pisper-safe-area-top,0px)] [[data-custom-titlebar]_&]:pr-[144px]`,children:[t,(0,$.jsxs)(K,{variant:`ghost`,size:`sm`,onClick:r,children:[(0,$.jsx)(C,{"aria-hidden":`true`}),o(`bots:settingsPage.backToChat`,{name:s.name})]}),(0,$.jsx)(`h1`,{className:`sr-only`,children:o(`bots:settingsPage.title`,{name:s.name})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,$.jsxs)(`div`,{className:`mx-auto w-[min(640px,calc(100%-32px))] py-6`,children:[(0,$.jsx)(Mn,{bot:s,environments:l.environments,openSection:f,onEnvironmentsChanged:()=>{l.refresh(),c()},onError:a}),(0,$.jsx)(an,{bot:s,initiallyOpen:p,onDeleted:i,onError:a})]})})]}):null}function Rn(e,t=new Map){if(/(^|[^\p{L}\p{N}_])@(所有人|all|everyone)(?![\p{L}\p{N}_])/iu.test(e.text))return!0;let n=e.replyTo?t.get(e.replyTo)?.author.kind===`bot`:!1;return e.recipients===`all`&&!e.mentions?.length&&!n}function zn(e){let t=new Map(e.map(e=>[e.id,e])),n=new Map;for(let r of e){let e=r.turn;if(!e||r.author.kind!==`bot`)continue;let i=r.author.botId;for(let r of[...e.triggers,...e.alsoAnswered]){let a=t.get(r);if(!a||a.author.kind!==`user`||!Rn(a,t))continue;let o=n.get(r)||[];o.some(e=>e.botId===i)||(o.push({botId:i,state:e.state===`skipped`?`skipped`:e.state===`running`||e.state===`waiting`?`working`:`replied`}),n.set(r,o))}}let r=[];for(let i of e){if(i.recalled){r.push({kind:`recalled`,message:i});continue}if(i.author.kind===`system`){r.push({kind:`system`,message:i});continue}if(i.author.kind===`user`){r.push({kind:`user`,message:i,round:n.get(i.id)||null});continue}if(!i.turn){r.push({kind:`post`,message:i});continue}if(i.turn.state===`skipped`)continue;let e=i.turn.triggers.map(e=>t.get(e)).find(Boolean);r.push({kind:`card`,message:i,handoff:e?.author.kind===`bot`?{from:e.author.botId,hop:Math.max(2,i.chainHop)}:null})}return r}function Bn(e,t){let n=t.filter(e=>e.name).sort((e,t)=>t.name.length-e.name.length),r=[],i=``,a=0;for(;a<e.length;){if(e[a]===`@`){let t=e.slice(a+1),o=n.find(e=>{if(!t.toLowerCase().startsWith(e.name.toLowerCase()))return!1;let n=t.charAt(e.name.length);return!n||!/[\p{L}\p{N}_-]/u.test(n)}),s=/[\p{L}\p{N}_]/u.test(e.charAt(a-1))?null:/^(所有人|all|everyone)(?![\p{L}\p{N}_])/iu.exec(t);if(o||s){i&&r.push({text:i}),i=``;let t=o?o.name.length:s[0].length;r.push({text:e.slice(a,a+1+t),...o?{memberId:o.id}:{everyone:!0}}),a+=1+t;continue}}i+=e[a],a+=1}return i&&r.push({text:i}),r}function Vn(e,t){let n=e.slice(0,t),r=n.lastIndexOf(`@`);if(r<0||r>0&&/[\p{L}\p{N}_]/u.test(n[r-1]))return null;let i=n.slice(r+1);return/\s/.test(i)||i.length>24?null:{start:r,query:i}}function Hn(e,t){return[...new Set(Bn(e,t).map(e=>e.memberId).filter(e=>!!e))]}function Un(e){let t=Hn(e.text,e.members),n=Bn(e.text,e.members).some(e=>e.everyone),r=t.length>0||n||!!e.repliedBot,i=n?e.members.map(e=>e.id):r?[...t,...e.repliedBot?[e.repliedBot]:[]]:e.chosen;return{addressed:r,mentionsAll:n,targets:[...new Set(i)]}}function Wn(e){return e>=1e6?`${(e/1e6).toFixed(1).replace(/\.0$/,``)}M`:e>=1e3?`${(e/1e3).toFixed(1).replace(/\.0$/,``)}K`:String(Math.max(0,Math.round(e)))}function Gn(e,t){let n=e.owner===`user`?`@me `:e.owner?`@${t.find(t=>t.id===e.owner)?.name||``} `:``;return`${e.done?`[x] `:``}${n}${e.text}`}function Kn(e,t){let n=e.trim();if(!n)return null;let r=!1,i=/^\[(x|X| )\]\s*/.exec(n);i&&(r=i[1].toLowerCase()===`x`,n=n.slice(i[0].length));let a=``;if(n.startsWith(`@`)){let e=t.filter(e=>e.name).sort((e,t)=>t.name.length-e.name.length).find(e=>n.slice(1).startsWith(e.name));e?(a=e.id,n=n.slice(e.name.length+1).trim()):/^@me\b/i.test(n)&&(a=`user`,n=n.slice(3).trim())}return n?{text:n,owner:a,done:r}:null}function qn(e){return e.map(e=>e.kind===`path`?{id:`path:${e.path}`,kind:`path`,name:e.name,path:e.path}:{id:e.id,kind:e.kind,name:e.name,mimeType:e.mimeType,size:e.size,downloadUrl:vt(e.id),...e.kind===`image`?{url:_t(e.id)}:{}})}function Jn(e){if(e.kind===`user`)return!0;if(e.kind!==`card`)return!1;let t=e.message.turn?.state;return t!==`running`&&t!==`waiting`}function Yn(e,t,n,r,i){if(e.altKey||e.ctrlKey||e.metaKey||r<=0)return null;let a=r-1;return e.key===`ArrowDown`?{type:`move`,index:Math.min(a,n+1)}:e.key===`ArrowUp`?{type:`move`,index:Math.max(0,n-1)}:e.key===`Home`?{type:`move`,index:0}:e.key===`End`?{type:`move`,index:a}:i?(e.key===`r`||e.key===`R`)&&Jn(t)?{type:`reply`}:e.key===`Delete`&&Jn(t)?{type:`recall`}:e.key===`Enter`&&t.kind===`card`&&t.message.turn?.sessionId?{type:`process`}:null:null}function Xn(e){return e.turn?.state===`running`||e.turn?.state===`waiting`}function Zn(e){let t=[];for(let n of e){let e=n.turn;!e||n.author.kind!==`bot`||n.recalled||(e.state===`running`||e.state===`waiting`?t.push({message:n,botId:n.author.botId,waiting:e.state===`waiting`?e.waiting||`approval`:null,approval:e.state===`waiting`?e.approval:null,pending:!1}):e.pending&&t.push({message:n,botId:n.author.botId,waiting:e.pending.waiting,approval:e.pending.approval,pending:!0}))}return t}function Qn(e,t){if(!e||e.recalled||t.replyTo||e.author.kind!==t.author.kind||t.author.kind===`bot`&&(e.author.kind!==`bot`||e.author.botId!==t.author.botId)||t.author.kind===`system`)return!1;let n=Date.parse(t.at)-Date.parse(e.at);return Number.isFinite(n)&&n>=0&&n<=12e4}function $n(e){let t=new Date(e);return Number.isNaN(t.getTime())?``:`${t.getFullYear()}-${t.getMonth()+1}-${t.getDate()}`}function er(e){if(e.maintained)return null;let t=Math.max(e.brief?.upToSeq||0,e.skipUpTo||0),n=Math.max(0,e.lastSeq-t),r=e.messages.filter(e=>e.seq>t&&!e.recalled).reduce((e,t)=>e+t.text.length,0);return n>0&&r>=24e3?{count:n,chars:r}:null}var tr=`relative pointer-coarse:after:absolute pointer-coarse:after:inset-x-0 pointer-coarse:after:-inset-y-2.5`,nr=12e3,rr=`@everyone`,ir=[`所有人`,`all`,`everyone`];function ar({roomId:e,cwd:t,members:n,recipients:r,onRecipientsChange:i,replyTo:a,replyName:o,onCancelReply:s,onSend:c,placeholder:l,idleLabel:u,idleHint:f}){let{t:p}=d(),m=(0,Q.useId)(),h=(0,Q.useRef)(!1),[g,_]=(0,Q.useState)(``),[v,y]=(0,Q.useState)(0),[b,x]=(0,Q.useState)(``),[S,C]=(0,Q.useState)(-1),[w,T]=(0,Q.useState)(!1),[E,k]=(0,Q.useState)(!1),A=(0,Q.useRef)(!1),j=(0,Q.useRef)(null),M=n.filter(e=>!e.deleted),N=D([],void 0,e),te=ke({cwd:t,selection:N}),ne=N.attachments.length>0,P=N.preparingAttachments.length>0,ie=!!(g.trim()||ne)&&!P&&!w,oe=a?.id;(0,Q.useEffect)(()=>{oe&&j.current?.focus()},[oe]);let F=Vn(g,v),I=p(`bots:room.composer.everyone`),L=(0,Q.useMemo)(()=>{if(!F)return[];let e=F.query.toLowerCase(),t=M.filter(t=>t.name.toLowerCase().includes(e)).slice(0,8).map(e=>({id:e.id,name:e.name,member:e}));return M.length>1&&[I,...ir].some(t=>t.toLowerCase().startsWith(e))&&t.push({id:rr,name:I}),t},[M,F,I]),se=!!(F&&L.length&&S!==F.start),R=L.find(e=>e.id===b)||L[0],ce=r===`all`||!u&&!M.some(e=>r.includes(e.id)),le=ce?M.map(e=>e.id):r,ue=M.filter(e=>le.includes(e.id)),{addressed:de,mentionsAll:fe,targets:z}=Un({text:g,members:M,chosen:le,repliedBot:a?.author.kind===`bot`?a.author.botId:``}),pe=new Set(M.filter(e=>e.enabled).map(e=>e.id)),me=z.filter(e=>pe.has(e)).length,he=!u&&!de&&ce&&me>=2,ge=e=>{if(!F)return;let t=g.slice(0,F.start),n=g.slice(v),r=`${t}@${e.name} ${n}`,i=t.length+e.name.length+2;_(r),y(i),window.requestAnimationFrame(()=>{j.current?.focus(),j.current?.setSelectionRange(i,i)})},_e=()=>{let e=j.current?.selectionStart??g.length,t=g.slice(0,e),n=t&&!/\s$/.test(t)?` @`:`@`,r=`${t}${n}${g.slice(e)}`,i=e+n.length;_(r),y(i),C(-1),window.requestAnimationFrame(()=>{j.current?.focus(),j.current?.setSelectionRange(i,i)})},ve=e=>{let t=e.currentTarget;t.scrollWidth<=t.clientWidth||Math.abs(e.deltaX)>Math.abs(e.deltaY)||(t.scrollLeft+=e.deltaY)},B=(e,t)=>{let n=ce?M.map(e=>e.id):r,a=t?[...new Set([...n,e])]:n.filter(t=>t!==e);i(a.length===M.length&&M.length>1||!a.length&&!u?`all`:a)},ye=async()=>{let e=g.trim();if(ie){T(!0);try{await c(e,Hn(e,M),N.attachments)&&(_(``),y(0),N.clearAttachments(),j.current&&(j.current.style.height=`auto`))}finally{T(!1)}}},be=e=>{if(!(A.current||e.nativeEvent.isComposing)){if(se&&R){let t=L.indexOf(R);if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let n=e.key===`ArrowDown`?1:-1;x(L[(t+n+L.length)%L.length].id);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),ge(R);return}if(e.key===`Escape`){e.preventDefault(),C(F.start);return}}if(e.key===`Escape`&&a){e.preventDefault(),s();return}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),ye())}},xe=e=>{O(e.dataTransfer)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`,k(!0))};return(0,$.jsxs)(Je,{open:se,children:[N.attachmentError&&(0,$.jsx)(`p`,{role:`alert`,className:`m-0 mb-2 text-[13px] text-danger`,children:N.attachmentError}),(0,$.jsx)(Ke,{asChild:!0,children:(0,$.jsxs)(`form`,{"data-room-composer":!0,onSubmit:e=>{e.preventDefault(),ye()},className:W(`relative flex min-w-0 flex-col rounded-[var(--composer-radius,22px)] border border-control bg-solid shadow-composer transition-[border-color,box-shadow] duration-(--d-fast) has-[textarea:focus]:border-focus has-[textarea:focus]:ring-3 has-[textarea:focus]:ring-focus-ring max-[650px]:rounded-[28px] max-[650px]:border-stroke-strong max-[650px]:shadow-none max-[650px]:has-[textarea:focus]:border-control max-[650px]:has-[textarea:focus]:ring-0 [&>.attachment-tray]:px-3 [&>.attachment-tray]:pt-3`,E&&`border-focus ring-3 ring-focus-ring`),onDragEnter:xe,onDragOver:xe,onDragLeave:e=>{let t=e.relatedTarget;t instanceof Node&&e.currentTarget.contains(t)||k(!1)},onDrop:e=>{k(!1),N.dropFiles(e)},children:[E&&(0,$.jsx)(`div`,{role:`status`,className:`pointer-events-none absolute inset-0 z-10 grid place-items-center rounded-[inherit] border border-dashed border-focus bg-panel px-4 text-center text-sm text-content`,children:p(`chat:focusSession.dropAttachment`)}),a&&(0,$.jsxs)(`div`,{className:`mx-3 mt-2.5 flex min-w-0 items-center gap-2 rounded-lg bg-surface-subtle px-2.5 py-1.5 text-[12.5px] text-content-secondary`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:p(`bots:room.replyTo`,{name:o,text:a.text.replace(/\s+/g,` `)||a.attachments.map(e=>e.name).join(`、`)||`…`})}),(0,$.jsx)(K,{variant:`ghost`,size:`icon-xs`,"aria-label":p(`bots:room.composer.cancelReply`),onClick:s,children:(0,$.jsx)(Ne,{})})]}),(0,$.jsx)(Ae,{attachments:N.attachments,preparing:N.preparingAttachments,onRemove:N.removeAttachment}),(0,$.jsx)(`textarea`,{ref:j,rows:1,value:g,maxLength:nr,"aria-label":p(`bots:room.composer.label`),"aria-autocomplete":`list`,"aria-expanded":se,placeholder:l,enterKeyHint:`send`,className:`max-h-[220px] min-h-11 w-full min-w-0 resize-none overflow-y-auto border-0 bg-transparent px-4 pt-3 pb-1 text-[length:calc(var(--app-message-font-size)*.9375)] leading-5 text-content [font-family:var(--font-content-family)] [outline:0] placeholder:text-content-muted max-[650px]:px-3.5 max-[650px]:text-[length:var(--app-message-font-size)]`,onChange:e=>{_(e.target.value),y(e.target.selectionStart??e.target.value.length),e.currentTarget.style.height=`auto`,e.currentTarget.style.height=`${Math.min(e.currentTarget.scrollHeight,220)}px`},onSelect:e=>y(e.currentTarget.selectionStart??0),onPaste:N.pasteFiles,onCompositionStart:()=>A.current=!0,onCompositionEnd:()=>window.setTimeout(()=>A.current=!1,0),onKeyDown:be}),(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1 px-2 pt-1 pb-2 max-[650px]:gap-2 max-[650px]:pb-3`,children:[te.input,(0,$.jsxs)(Ge,{children:[(0,$.jsx)(Ue,{asChild:!0,children:(0,$.jsx)(K,{variant:`ghost`,size:`icon-sm`,className:`rounded-full`,"aria-label":p(`bots:room.composer.add`),title:p(`bots:room.composer.add`),children:(0,$.jsx)(ae,{})})}),(0,$.jsxs)(We,{align:`start`,side:`top`,className:`w-52`,onCloseAutoFocus:e=>{h.current&&(h.current=!1,e.preventDefault())},children:[(0,$.jsxs)(V,{onSelect:()=>void te.choose(),children:[(0,$.jsx)(re,{"aria-hidden":`true`}),p(`chat:focusSession.addAttachment`)]}),(0,$.jsxs)(V,{onSelect:()=>{h.current=!0,_e()},children:[(0,$.jsx)(Qt,{"aria-hidden":`true`}),p(`bots:room.composer.mentionMember`)]})]})]}),(0,$.jsx)(K,{variant:`ghost`,size:`icon-sm`,className:`rounded-full max-[650px]:hidden`,"aria-label":p(`chat:focusSession.addAttachment`),title:p(`chat:focusSession.addAttachment`),onClick:()=>void te.choose(),children:(0,$.jsx)(re,{})}),(0,$.jsx)(`span`,{id:m,className:`ml-1 flex-none text-[12.5px] text-content-muted`,children:p(`bots:room.composer.sendToLabel`)}),(0,$.jsxs)(`div`,{role:`group`,"aria-labelledby":m,"data-room-recipients":!0,onWheel:ve,className:`flex min-w-0 flex-1 items-center gap-1 overflow-x-auto overscroll-x-contain [scrollbar-width:none] pointer-coarse:-my-2.5 pointer-coarse:py-2.5 [&::-webkit-scrollbar]:hidden`,children:[M.map(e=>{let t=le.includes(e.id);return(0,$.jsxs)(Zt,{size:`sm`,"aria-pressed":t,disabled:!e.enabled,className:tr,onClick:()=>B(e.id,!t),children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 rounded-full`,style:{background:bt(e.avatar.color).shade}}),e.name,!e.enabled&&(0,$.jsxs)(`span`,{className:`font-normal text-content-muted`,children:[`· `,p(`bots:room.paused`)]})]},e.id)}),M.length>1&&(0,$.jsx)(Zt,{size:`sm`,"data-room-recipients-everyone":!0,"aria-pressed":ce,className:tr,onClick:()=>{ce?u&&i([]):i(`all`)},children:p(`bots:room.composer.everyone`)})]}),he?(0,$.jsx)(`span`,{"data-room-triage-hint":!0,className:`max-w-[40%] min-w-0 flex-none truncate px-1 text-[12px] text-content-muted max-[650px]:hidden`,children:p(`bots:room.composer.triageHint`)}):me>=3?(0,$.jsx)(`span`,{className:`flex-none px-1 text-[12px] text-content-muted max-[650px]:hidden`,children:p(`bots:room.composer.wakes`,{count:me})}):de&&!fe&&ue.length>0?(0,$.jsx)(`span`,{"data-room-addressed-only":!0,className:`max-w-[40%] min-w-0 flex-none truncate px-1 text-[12px] text-content-muted max-[650px]:hidden`,children:p(`bots:room.composer.addressedOnly`)}):f&&!de&&ue.length===0?(0,$.jsx)(`span`,{className:`max-w-[40%] min-w-0 flex-none truncate px-1 text-[12px] text-content-muted max-[650px]:hidden`,children:f}):null,(0,$.jsx)(ee,{queueing:!1,submitting:w,preparing:P,hasDraft:!!(g.trim()||ne),disabled:!ie})]})]})}),(0,$.jsx)(qe,{side:`top`,align:`start`,className:`w-64 p-1`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),children:(0,$.jsx)(it,{value:R?.id||``,shouldFilter:!1,"aria-label":p(`bots:room.composer.mentionList`),children:(0,$.jsx)(rt,{children:L.map(e=>(0,$.jsxs)(nt,{value:e.id,"data-room-mention-everyone":e.member?void 0:``,onMouseEnter:()=>x(e.id),onSelect:()=>ge(e),children:[e.member?(0,$.jsx)(J,{avatar:e.member.avatar,size:18,animate:!1}):(0,$.jsx)(Me,{"aria-hidden":`true`,className:`size-[18px] p-0.5 text-content-muted`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name})]},e.id))})})})]})}function or({open:e,onOpenChange:t,brief:n,members:r,onSave:i}){let{t:a}=d(),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(``),[u,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(``),h=(0,Q.useRef)(!1);return(0,Q.useEffect)(()=>{e&&!h.current&&(s((n?.decisions||[]).join(`
4
+ `)),l((n?.todos||[]).map(e=>Gn(e,r)).join(`
5
+ `)),m(``)),h.current=e},[e,n,r]),(0,$.jsx)(ut,{open:e,onOpenChange:t,children:(0,$.jsx)(ot,{className:`sm:max-w-lg`,children:(0,$.jsxs)(`form`,{onSubmit:async e=>{e.preventDefault(),f(!0),m(``);try{await i({decisions:o.split(`
6
+ `).map(e=>e.trim()).filter(Boolean),todos:c.split(`
7
+ `).map(e=>Kn(e,r)).filter(e=>!!e)}),t(!1)}catch(e){m(e instanceof Error?e.message:String(e))}finally{f(!1)}},className:`contents`,children:[(0,$.jsxs)(lt,{children:[(0,$.jsx)(st,{children:a(`bots:room.brief.editTitle`)}),(0,$.jsx)(at,{children:a(`bots:room.brief.editDescription`)})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(gt,{htmlFor:`room-brief-decisions`,children:a(`bots:room.brief.decisionsLabel`)}),(0,$.jsx)(dt,{id:`room-brief-decisions`,rows:4,value:o,onChange:e=>s(e.target.value)})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(gt,{htmlFor:`room-brief-todos`,children:a(`bots:room.brief.todosLabel`)}),(0,$.jsx)(dt,{id:`room-brief-todos`,rows:5,value:c,onChange:e=>l(e.target.value)})]}),p&&(0,$.jsx)(`p`,{role:`alert`,className:`m-0 text-sm text-destructive`,children:p})]}),(0,$.jsxs)(ct,{children:[(0,$.jsx)(K,{type:`button`,variant:`outline`,onClick:()=>t(!1),children:a(`common:ui.cancel`)}),(0,$.jsx)(K,{type:`submit`,disabled:u,children:a(`bots:room.brief.save`)})]})]})})})}var sr=8;function cr({member:e}){let{t}=d(),{status:n}=e;return e.deleted?(0,$.jsx)($.Fragment,{children:t(`bots:room.removedBot`)}):e.enabled?n.waiting===`approval`?(0,$.jsx)($.Fragment,{children:t(`bots:room.member.approval`)}):n.waiting===`question`?(0,$.jsx)($.Fragment,{children:t(`bots:room.member.question`)}):n.state===`running`?n.current?(0,$.jsx)($.Fragment,{children:t(`bots:room.member.runningStep`,{step:n.current})}):(0,$.jsx)($.Fragment,{children:t(`bots:room.member.running`)}):e.unread>0?(0,$.jsx)($.Fragment,{children:t(`bots:room.member.unread`,{count:e.unread})}):(0,$.jsx)($.Fragment,{children:t(`bots:room.member.idle`)}):(0,$.jsx)($.Fragment,{children:t(`bots:room.member.paused`)})}function lr({detail:e,briefing:t,onTidy:n,onEditBrief:r}){let{t:i}=d(),{brief:a,members:o,room:s}=e,c=new Map(o.map(e=>[e.id,e])),l=s.briefBotId?c.get(s.briefBotId):null,u=Math.max(0,e.lastSeq-(a?.upToSeq||0)),f=l?(0,$.jsxs)(K,{variant:`ghost`,size:`xs`,disabled:t||!u,onClick:()=>n(),children:[t?(0,$.jsx)(G,{className:`size-3`}):(0,$.jsx)(Ee,{"aria-hidden":`true`}),i(t?`bots:room.brief.tidying`:`bots:room.brief.tidy`)]}):(0,$.jsxs)(Ge,{children:[(0,$.jsx)(Ue,{asChild:!0,children:(0,$.jsxs)(K,{variant:`ghost`,size:`xs`,disabled:t||!u,children:[t?(0,$.jsx)(G,{className:`size-3`}):(0,$.jsx)(Ee,{"aria-hidden":`true`}),i(t?`bots:room.brief.tidying`:`bots:room.brief.tidy`)]})}),(0,$.jsx)(We,{align:`end`,children:o.filter(e=>!e.deleted&&e.enabled).map(e=>(0,$.jsxs)(V,{onSelect:()=>n(e.id),children:[(0,$.jsx)(J,{avatar:e.avatar,size:16,animate:!1}),e.name]},e.id))})]});return(0,$.jsxs)(`section`,{"aria-labelledby":`room-brief-title`,className:`rounded-xl border border-stroke-soft bg-solid p-3 shadow-edge`,children:[(0,$.jsxs)(`header`,{className:`mb-2 flex items-center gap-1.5 text-[12.5px] font-semibold text-content`,children:[(0,$.jsx)(ie,{className:`size-3.5 text-content-muted`,"aria-hidden":`true`}),(0,$.jsx)(`h2`,{id:`room-brief-title`,className:`m-0 text-[12.5px] font-semibold`,children:i(`bots:room.brief`)}),(0,$.jsx)(`span`,{className:`flex-1`}),a?.by&&(0,$.jsx)(`span`,{className:`flex min-w-0 items-center gap-1 truncate text-[11.5px] font-normal text-content-muted`,children:a.by===`user`?i(`bots:room.brief.byYou`):(0,$.jsxs)($.Fragment,{children:[c.get(a.by)&&(0,$.jsx)(J,{avatar:c.get(a.by).avatar,size:12,animate:!1}),i(`bots:room.brief.by`,{name:c.get(a.by)?.name||i(`bots:room.removedBot`)})]})}),(0,$.jsx)(K,{variant:`ghost`,size:`icon-xs`,"aria-label":i(`bots:room.brief.edit`),title:i(`bots:room.brief.edit`),onClick:r,children:(0,$.jsx)(P,{})})]}),s.goal&&(0,$.jsxs)(`p`,{className:`m-0 mb-2 flex min-w-0 items-start gap-1.5 text-[12.5px] text-content-secondary`,children:[(0,$.jsx)(Oe,{className:`mt-0.5 size-3.5 flex-none text-content-muted`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`min-w-0`,children:s.goal})]}),a&&(a.decisions.length||a.todos.length)?(0,$.jsxs)($.Fragment,{children:[a.decisions.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h3`,{className:`m-0 pt-1 pb-1 text-[11.5px] font-medium text-content-muted`,children:i(`bots:room.brief.decided`)}),(0,$.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0 text-[12.5px] text-content-secondary`,children:a.decisions.map((e,t)=>(0,$.jsxs)(`li`,{children:[`· `,e]},t))})]}),a.todos.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h3`,{className:`m-0 pt-3 pb-1 text-[11.5px] font-medium text-content-muted`,children:i(`bots:room.brief.todo`)}),(0,$.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1.5 p-0 text-[12.5px]`,children:a.todos.map((e,t)=>{let n=e.owner&&e.owner!==`user`?c.get(e.owner):null;return(0,$.jsxs)(`li`,{className:`flex items-center gap-2`,children:[e.done?(0,$.jsx)(x,{className:`size-3.5 flex-none text-content-muted`,"aria-label":i(`bots:room.brief.done`)}):(0,$.jsx)($t,{className:`size-3.5 flex-none text-content-muted`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:W(`min-w-0 flex-1 truncate`,e.done?`text-content-muted line-through`:`text-content`),children:e.text}),n?(0,$.jsx)(`span`,{title:n.name,children:(0,$.jsx)(J,{avatar:n.avatar,size:14,animate:!1})}):e.owner===`user`?(0,$.jsx)(`span`,{className:`text-[11px] text-content-muted`,children:i(`bots:room.you`)}):null]},t)})})]})]}):(0,$.jsx)(ht,{compact:!0,title:i(`bots:room.brief.empty`),description:l?i(`bots:room.brief.emptyWithBot`,{name:l.name}):i(`bots:room.brief.emptyHint`)}),(0,$.jsxs)(`footer`,{className:`mt-3 flex items-center gap-2 border-t border-stroke-soft pt-2 text-[11.5px] text-content-muted`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1`,children:a?.upToSeq?u?i(`bots:room.brief.coverage`,{seq:a.upToSeq,count:u}):i(`bots:room.brief.upToDate`):l?i(`bots:room.brief.by`,{name:l.name}):i(`bots:room.brief.noMaintainer`)}),f]})]})}function ur({detail:e,bots:t,hostAvailable:n,onOpenMember:r,onSave:i,onAnswerModeChange:a,onDelete:o,onError:s}){let{t:c}=d(),{members:l,room:u}=e,[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(!1),S=l.filter(e=>!e.deleted),C=t.filter(e=>!u.members.includes(e.id)),w=e=>e===`host`?S.some(e=>e.id===u.hostBotId)?u.hostBotId:S[0]?.id||``:u.hostBotId,T=async e=>{p(!0);try{return await i(e)}finally{p(!1)}},D=e=>void T({members:e,briefBotId:e.includes(u.briefBotId)?u.briefBotId:``,...n?{answerMode:u.answerMode,hostBotId:e.includes(u.hostBotId)?u.hostBotId:u.answerMode===`host`&&e[0]||``}:{}}),O=(e,t)=>async n=>{n.preventDefault();let r=t?.trim()??``;e===`name`&&!r||(r===u[e]||await T({[e]:r}))&&(e===`name`?h:_)(null)},ee=async()=>{if(!v){y(!0);try{let e=await pt(u.cwd,c(`bots:room.settings.folder`));e.status===`picked`?T({cwd:e.path}):e.status===`unavailable`&&x(!0)}catch(e){s(e)}finally{y(!1)}}},j=u.cwd.split(/[\\/]/).filter(Boolean).at(-1)||u.cwd;return(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`section`,{"aria-labelledby":`room-info-title`,className:`px-2`,children:[m===null?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[(0,$.jsx)(`h2`,{id:`room-info-title`,className:`m-0 min-w-0 flex-1 truncate text-[15px] font-semibold text-content`,children:u.name}),(0,$.jsx)(K,{variant:`ghost`,size:`icon-xs`,"aria-label":c(`bots:room.info.rename`),title:c(`bots:room.info.rename`),onClick:()=>h(u.name),children:(0,$.jsx)(P,{})})]}):(0,$.jsxs)(`form`,{className:`flex items-center gap-1.5`,onSubmit:O(`name`,m),children:[(0,$.jsx)(q,{autoFocus:!0,value:m,maxLength:40,"aria-label":c(`bots:room.new.name`),disabled:f,onChange:e=>h(e.target.value),onKeyDown:e=>e.key===`Escape`&&h(null)}),(0,$.jsx)(K,{type:`submit`,size:`sm`,disabled:f||!m.trim(),children:c(`bots:room.settings.save`)})]}),g===null?(0,$.jsx)(`button`,{type:`button`,className:`mt-0.5 flex w-full min-w-0 items-start gap-1.5 rounded-[var(--r-sm)] text-left text-[12.5px] text-content-muted hover:text-content focus-visible:outline-2 focus-visible:outline-focus`,onClick:()=>_(u.goal),children:u.goal?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Oe,{className:`mt-0.5 size-3.5 flex-none`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`min-w-0`,children:u.goal})]}):c(`bots:room.info.addGoal`)}):(0,$.jsxs)(`form`,{className:`mt-1.5 flex items-center gap-1.5`,onSubmit:O(`goal`,g),children:[(0,$.jsx)(q,{autoFocus:!0,value:g,maxLength:200,"aria-label":c(`bots:room.new.goal`),placeholder:c(`bots:room.new.goalPlaceholder`),disabled:f,onChange:e=>_(e.target.value),onKeyDown:e=>e.key===`Escape`&&_(null)}),(0,$.jsx)(K,{type:`submit`,size:`sm`,disabled:f,children:c(`bots:room.settings.save`)})]})]}),(0,$.jsx)(dr,{title:c(`bots:room.members.title`,{count:u.members.length,max:sr}),action:(0,$.jsxs)(Ge,{children:[(0,$.jsx)(Ue,{asChild:!0,children:(0,$.jsxs)(K,{variant:`ghost`,size:`xs`,disabled:f||!C.length||u.members.length>=sr,children:[(0,$.jsx)(ae,{"aria-hidden":`true`}),c(`bots:room.info.add`)]})}),(0,$.jsx)(We,{align:`end`,children:C.map(e=>(0,$.jsxs)(V,{onSelect:()=>D([...u.members,e.id]),children:[(0,$.jsx)(J,{avatar:e.avatar,size:16,animate:!1}),e.name]},e.id))})]}),children:(0,$.jsx)(`ul`,{className:`m-0 list-none p-0`,children:l.map(e=>{let t=!!e.status.waiting;return(0,$.jsxs)(`li`,{className:`flex items-center gap-0.5`,children:[(0,$.jsxs)(`button`,{type:`button`,disabled:!e.sessionId,title:e.sessionId?c(`bots:room.member.open`):void 0,onClick:()=>r(e),className:`flex min-w-0 flex-1 items-start gap-2.5 rounded-[var(--r-md)] px-2 py-1.5 text-left enabled:hover:bg-surface-hover focus-visible:outline-2 focus-visible:outline-focus`,children:[(0,$.jsx)(J,{avatar:e.avatar,size:22,animate:e.status.state!==`idle`,state:t?`need`:e.status.state===`running`?`running`:`idle`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-[13px] text-content`,children:e.name||c(`bots:room.removedBot`)}),(0,$.jsx)(`span`,{className:W(`block truncate text-[11.5px]`,t?`font-medium text-st-attn`:`text-content-muted`),children:(0,$.jsx)(cr,{member:e})})]})]}),(0,$.jsxs)(Ge,{children:[(0,$.jsx)(Ue,{asChild:!0,children:(0,$.jsx)(K,{variant:`ghost`,size:`icon-xs`,className:`flex-none text-content-muted`,"aria-label":c(`bots:room.info.memberMenu`,{name:e.name||c(`bots:room.removedBot`)}),children:(0,$.jsx)(E,{})})}),(0,$.jsxs)(We,{align:`end`,children:[(0,$.jsx)(V,{disabled:!e.sessionId,onSelect:()=>r(e),children:c(`bots:room.member.open`)}),(0,$.jsx)(He,{}),(0,$.jsx)(V,{variant:`destructive`,disabled:f||u.members.length<=1,onSelect:()=>D(u.members.filter(t=>t!==e.id)),children:c(`bots:room.info.removeMember`)})]})]})]},e.id)})})}),n&&(0,$.jsx)(dr,{title:c(`bots:room.settings.answerMode`),titleId:`room-answer-title`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 px-2`,children:[(0,$.jsx)(U,{size:`sm`,"aria-labelledby":`room-answer-title`,value:u.answerMode,onValueChange:e=>a(e,w(e)),options:[{value:`mention`,label:c(`bots:room.settings.answerMention`)},{value:`host`,label:c(`bots:room.settings.answerHost`)}]}),u.answerMode===`host`&&(0,$.jsx)(Y,{"aria-label":c(`bots:room.settings.host`),value:w(`host`),onChange:e=>a(`host`,e.target.value),children:S.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id))}),(0,$.jsx)(`p`,{className:`m-0 text-xs text-content-muted`,children:u.answerMode===`host`?c(`bots:room.settings.answerHostHint`):c(`bots:room.settings.answerMentionHint`)})]})}),(0,$.jsxs)(dr,{title:c(`bots:room.info.folder`),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2`,children:[(0,$.jsx)(A,{className:`size-3.5 flex-none text-content-muted`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:W(`min-w-0 flex-1 truncate text-[12.5px]`,u.cwd?`font-mono text-content-secondary`:`text-content-muted`),title:u.cwd||void 0,children:u.cwd?j:c(`bots:room.info.folderNone`)}),u.cwd&&(0,$.jsx)(K,{variant:`ghost`,size:`icon-xs`,"aria-label":c(`bots:room.info.folderClear`),title:c(`bots:room.info.folderClear`),disabled:f,onClick:()=>void T({cwd:``}),children:(0,$.jsx)(Ne,{})}),(0,$.jsx)(K,{variant:`ghost`,size:`xs`,disabled:f||v,onClick:()=>void ee(),children:c(`bots:room.info.folderChange`)})]}),(0,$.jsx)(`p`,{className:`m-0 mt-1 px-2 text-xs text-content-muted`,children:c(`bots:room.settings.folderHint`)})]}),(0,$.jsx)(dr,{title:c(`bots:room.settings.briefBot`),titleId:`room-brief-bot-title`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 px-2`,children:[(0,$.jsxs)(Y,{"aria-labelledby":`room-brief-bot-title`,value:u.briefBotId,disabled:f,onChange:e=>void T({briefBotId:e.target.value}),children:[(0,$.jsx)(`option`,{value:``,children:c(`bots:room.settings.briefBotNone`)}),S.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,$.jsx)(`p`,{className:`m-0 text-xs text-content-muted`,children:c(`bots:room.settings.briefBotHint`)})]})}),(0,$.jsx)(`div`,{className:`border-t border-stroke-soft px-2 pt-3`,children:(0,$.jsxs)(K,{variant:`ghost`,size:`xs`,className:`text-destructive`,onClick:o,children:[(0,$.jsx)(je,{"aria-hidden":`true`}),c(`bots:room.delete`)]})}),(0,$.jsx)(k,{open:b,initialPath:u.cwd,onOpenChange:x,onSelect:e=>{x(!1),T({cwd:e})}})]})}function dr({title:e,titleId:t,action:n,children:r}){return(0,$.jsxs)(`section`,{"aria-labelledby":t,children:[(0,$.jsxs)(`div`,{className:`mb-1 flex h-7 items-center gap-1.5 px-2`,children:[(0,$.jsx)(`h3`,{id:t,className:`m-0 min-w-0 flex-1 text-[12.5px] font-semibold text-content`,children:e}),n]}),r]})}function fr({entries:e,members:t,modeLabel:n,onOpenProcess:r,onApprove:i,onStop:a}){let{t:o}=d();return(0,$.jsx)(`div`,{"aria-live":`polite`,className:`mb-1.5 flex flex-col gap-0.5 empty:hidden`,children:e.map(e=>{let s=t.get(e.botId),c=e.message.turn,l=!!e.waiting,u=n(e.botId),d=e.approval?(e.approval.argsPreview.split(`
8
+ `).find(e=>e.trim())||``).trim()||e.approval.toolName:``,f=e.waiting?e.waiting===`approval`?d?o(`bots:room.status.wantsToRun`,{what:d}):``:c.current||o(`bots:room.card.questionHint`):c.current||(c.steps.at(-1)?`${c.steps.at(-1).name} ${c.steps.at(-1).summary}`.trim():o(`bots:room.card.reading`)),p=e.waiting?e.waiting===`question`?o(`bots:room.card.waitingQuestion`):o(`bots:room.card.waitingApproval`):o(`bots:room.status.working`),m=()=>c.sessionId&&r(c.sessionId),h=e.waiting===`approval`?e.approval:null;return(0,$.jsxs)(`div`,{"data-room-status":e.waiting||`running`,className:W(`flex min-w-0 items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-[13px]`,l&&`bg-st-attn-soft max-[650px]:flex-wrap`),children:[s&&(0,$.jsx)(J,{avatar:s.avatar,state:l?`need`:`running`,size:22}),(0,$.jsx)(`span`,{className:`flex-none font-medium text-content`,children:s?.name||o(`bots:room.removedBot`)}),(0,$.jsx)(`span`,{className:W(`flex-none`,l?`font-medium text-st-attn`:`text-content-muted`),children:p}),u&&(0,$.jsxs)(`span`,{className:`flex-none text-content-muted max-[650px]:hidden`,children:[`· `,u]}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[12px] text-content-secondary`,title:e.pending?o(`bots:room.card.pendingApproval`):void 0,children:f}),l?(0,$.jsxs)(`span`,{className:`flex flex-none items-center gap-2.5 max-[650px]:basis-full max-[650px]:justify-end`,children:[h&&h.severity!==`critical`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K,{size:`sm`,variant:`outline`,onClick:()=>i(e.message,h.id,!0),children:o(`bots:room.card.approve`)}),(0,$.jsx)(K,{size:`sm`,variant:`outline`,onClick:()=>i(e.message,h.id,!1),children:o(`bots:room.card.deny`)})]}),(0,$.jsx)(K,{size:`sm`,variant:`outline`,disabled:!c.sessionId,title:h?.severity===`critical`?o(`bots:room.card.critical`):o(`bots:room.card.processHint`),onClick:m,children:o(`bots:room.status.view`)})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K,{variant:`ghost`,size:`icon-sm`,"aria-label":o(`bots:room.card.stop`),title:o(`bots:room.card.stop`),onClick:()=>a(e.message),children:(0,$.jsx)(De,{})}),c.sessionId&&(0,$.jsx)(K,{variant:`ghost`,size:`icon-sm`,"aria-label":o(`bots:room.viewProcess`),title:o(`bots:room.viewProcess`),onClick:m,children:(0,$.jsx)(nn,{})})]})]},e.message.id)})})}function pr({count:e,chars:t,members:n,phone:r,onPick:i,onWrite:a,onLater:o,onSkip:s,onOpen:c}){let{t:l}=d();return r?(0,$.jsxs)(`button`,{type:`button`,onClick:c,className:`mb-2 flex w-full items-center gap-2 rounded-xl border border-stroke-soft bg-surface-subtle px-3 py-2.5 text-left text-[13px] text-content-secondary focus-visible:outline-2 focus-visible:outline-focus`,children:[(0,$.jsx)(rn,{className:`size-4 flex-none text-content-muted`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:l(`bots:room.briefPrompt.short`,{count:e})}),(0,$.jsx)(`span`,{className:`flex-none font-medium text-content`,children:l(`bots:room.briefPrompt.shortAction`)})]}):(0,$.jsxs)(`div`,{role:`region`,"aria-label":l(`bots:room.briefPrompt.ask`),className:`mb-2 rounded-xl border border-stroke-soft bg-surface-subtle px-3 py-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(rn,{className:`mt-0.5 size-4 flex-none text-content-muted`,"aria-hidden":`true`}),(0,$.jsxs)(`p`,{className:`m-0 flex-1 text-[13px] text-content-secondary`,children:[l(`bots:room.briefPrompt.text`,{count:e,thousands:Math.round(t/1e3)}),(0,$.jsx)(`span`,{className:`font-medium text-content`,children:l(`bots:room.briefPrompt.ask`)})]}),(0,$.jsx)(K,{variant:`ghost`,size:`icon-xs`,"aria-label":l(`bots:room.briefPrompt.close`),onClick:o,children:(0,$.jsx)(Ne,{})})]}),(0,$.jsxs)(`div`,{className:`mt-2 flex items-center gap-1.5 pl-6`,children:[(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,children:n.filter(e=>!e.deleted&&e.enabled).map(e=>(0,$.jsxs)(Zt,{size:`sm`,onClick:()=>i(e.id),children:[(0,$.jsx)(J,{avatar:e.avatar,size:14,animate:!1}),e.name]},e.id))}),(0,$.jsx)(K,{variant:`ghost`,size:`xs`,onClick:a,children:l(`bots:room.briefPrompt.write`)}),(0,$.jsx)(K,{variant:`ghost`,size:`xs`,onClick:o,children:l(`bots:room.briefPrompt.later`)}),(0,$.jsx)(K,{variant:`ghost`,size:`xs`,onClick:s,children:l(`bots:room.briefPrompt.skip`)})]})]})}var mr=8,hr=600;function gr(e){let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function _r(e,t){let n=new Date(e);if(Number.isNaN(n.getTime()))return``;let r=new Date,i=new Date(r.getFullYear(),r.getMonth(),r.getDate()-1),a=$n(e);return a===$n(r.toISOString())?t(`bots:room.day.today`):a===$n(i.toISOString())?t(`bots:room.day.yesterday`):n.toLocaleDateString([],{month:`long`,day:`numeric`,...n.getFullYear()===r.getFullYear()?{}:{year:`numeric`}})}function vr({text:e,members:t}){let n=[...t.values()];return(0,$.jsx)($.Fragment,{children:Bn(e,n).map((e,n)=>{let r=e.memberId?t.get(e.memberId):null;if(!r&&!e.everyone)return(0,$.jsx)(`span`,{children:e.text},n);let i=r?bt(r.avatar.color):null;return(0,$.jsx)(`span`,{className:W(`rounded-[4px] px-0.5 font-medium`,!i&&`bg-surface-active`),style:i?{color:i.shade,background:i.tile}:void 0,children:e.text},n)})})}function yr({label:e}){return(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-7 flex-none place-items-center rounded-full bg-content text-[12px] font-semibold text-panel`,children:Array.from(e)[0]||``})}function br({message:e,members:t,onJump:n}){let{t:r}=d(),i=e.author.kind===`bot`?t.get(e.author.botId)?.name||r(`bots:room.removedBot`):r(`bots:room.you`),a=e.recalled?r(`bots:room.recalledShort`):e.text.replace(/\s+/g,` `)||e.attachments.map(e=>e.name).join(`、`);return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),className:`mb-1 flex max-w-full min-w-0 items-center gap-1.5 rounded-sm border-l-2 border-stroke-strong py-0.5 pl-2 text-left text-[12.5px] text-content-muted hover:text-content-secondary focus-visible:outline-2 focus-visible:outline-focus`,children:[(0,$.jsx)(en,{className:`size-3 flex-none`,"aria-hidden":`true`}),(0,$.jsxs)(`span`,{className:`truncate`,children:[r(`bots:room.quote.prefix`),(0,$.jsx)(`span`,{className:`font-medium text-content-secondary`,children:i}),r(`bots:room.quote.separator`),a]})]})}function xr({children:e,className:t}){return(0,$.jsx)(`p`,{className:W(`m-0 my-2 text-center text-[12px] text-content-muted`,t),children:e})}function Sr(e,t,n){return n(`bots:room.round.line`,{parts:e.map(e=>e.state===`skipped`?n(`bots:room.round.skippedBy`,{name:t(e.botId)}):e.state===`working`?n(`bots:room.round.workingBy`,{name:t(e.botId)}):n(`bots:room.round.repliedBy`,{name:t(e.botId)})).join(` · `)})}function Cr(e,t,n){if(e.type===`triaged`){let r=e.note;if(!e.bots.length)return r?n(`bots:room.system.triagedNobody`,{reason:r}):n(`bots:room.system.triagedNobodyPlain`);let i=e.bots.map(t).join(`、`);return r?n(`bots:room.system.triaged`,{names:i,reason:r}):n(`bots:room.system.triagedPlain`,{names:i})}let r=t(e.botId);if(e.type===`route_failed`)return e.reason===`host_paused`?n(`bots:room.system.routeHostPaused`,{host:r}):n(`bots:room.system.routeFailed`,{host:r});if(e.type!==`routed`)return``;let i=e.note;if(!e.bots.length)return i?n(`bots:room.system.routedNobody`,{host:r,reason:i}):n(`bots:room.system.routedNobodyPlain`,{host:r});let a=e.bots.map(t).join(`、`);return i?n(`bots:room.system.routed`,{host:r,names:a,reason:i}):n(`bots:room.system.routedPlain`,{host:r,names:a})}function wr({icon:e,children:t,...n}){return(0,$.jsxs)(K,{variant:`ghost`,size:`xs`,className:`text-content-muted hover:text-content`,...n,children:[e,t]})}function Tr({items:e,messages:t,members:n,modelLabel:r,actions:i}){let{t:a}=d(),o=new Map(t.map(e=>[e.id,e])),s=e=>n.get(e)?.name||a(`bots:room.removedBot`),c=a(`bots:room.you`),l=(0,Q.useRef)(null),u=(0,Q.useId)(),[f,p]=(0,Q.useState)(new Set),m=e=>{let t=e.event;return t?.type===`paused`?a(`bots:room.system.paused`,{name:s(t.botId)}):t?.type===`chain_stopped`?a(`bots:room.system.chainStopped`,{from:s(t.from),to:s(t.to),reason:t.reason===`hops`?a(`bots:room.system.reason.hops`):t.reason===`rate`?a(`bots:room.system.reason.rate`):a(`bots:room.system.reason.total`)}):t?.type===`wake_failed`?t.reason===`attachment`?a(`bots:room.system.wakeFailedAttachment`,{name:s(t.botId)}):t.reason===`model`?a(`bots:room.system.wakeFailedModel`,{name:s(t.botId)}):a(`bots:room.system.wakeFailed`,{name:s(t.botId)}):t?Cr(t,s,a):``},h=e.filter(e=>!(e.kind===`card`&&Xn(e.message))&&(e.kind!==`system`||m(e.message))),[g,_]=(0,Q.useState)(``),v=h.some(e=>e.message.id===g)?g:h.at(-1)?.message.id||``,y=e=>{let t=h[e]?.message.id,n=t?l.current?.querySelector(`[data-room-message="${CSS.escape(t)}"]`):null;n instanceof HTMLElement&&(n.focus({preventScroll:!0}),n.scrollIntoView({block:`nearest`}))},b=e=>{let t=e.target;if(!(t instanceof HTMLElement))return;let n=t.closest(`[data-room-message]`);if(!(n instanceof HTMLElement)||!l.current?.contains(n)||t.closest(`input, textarea, select, [contenteditable="true"]`))return;let r=t===n||!t.closest(`button, a, [role="button"]`),a=h.findIndex(e=>e.message.id===n.dataset.roomMessage);if(a<0)return;let o=Yn(e,h[a],a,h.length,r);if(!o)return;e.preventDefault();let{message:s}=h[a];o.type===`move`?y(o.index):o.type===`reply`?i.onReply(s):o.type===`recall`?i.onRecall(s):s.turn?.sessionId&&i.onOpenProcess(s.turn.sessionId)},x=(e,t,n,r,i=``)=>{let o=h[t-1]?.message,s=$n(e.at),c=s&&(!o||$n(o.at)!==s);return(0,$.jsxs)(`article`,{"data-room-message":e.id,tabIndex:e.id===v?0:-1,"aria-label":n,"aria-posinset":t+1,"aria-setsize":h.length,onFocus:()=>_(e.id),className:W(`group/msg rounded-lg outline-none focus-visible:ring-2 focus-visible:ring-focus-ring focus-visible:ring-offset-2 focus-visible:ring-offset-panel`,i),children:[c&&(0,$.jsxs)(`div`,{"aria-hidden":`true`,className:`my-3 flex items-center gap-3 text-[12px] text-content-muted`,children:[(0,$.jsx)(`span`,{className:`h-px flex-1 bg-stroke-soft`}),_r(e.at,a),(0,$.jsx)(`span`,{className:`h-px flex-1 bg-stroke-soft`})]}),r]},e.id)},C=({avatar:e,author:t,meta:n,at:r,right:i,merged:a,children:o})=>(0,$.jsxs)(`div`,{className:W(`-mx-3 flex gap-3 rounded-lg px-3 transition-colors group-hover/msg:bg-surface-subtle`,a?`py-1`:`py-2.5`),children:[(0,$.jsx)(`div`,{className:`w-7 flex-none pt-0.5`,children:!a&&e}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[!a&&(0,$.jsxs)(`header`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-[13.5px] font-semibold text-content`,children:t}),n,(0,$.jsx)(`time`,{dateTime:r,className:`text-[12px] text-content-muted tabular-nums`,children:gr(r)}),(0,$.jsx)(`span`,{className:`flex-1`}),i]}),(0,$.jsx)(`div`,{className:`mt-0.5 text-[length:calc(var(--app-message-font-size)*.9375)] leading-[1.65] break-words text-content [font-family:var(--font-content-family)]`,children:o})]})]}),w=(e,t)=>(0,$.jsxs)(`div`,{className:`mt-1 -ml-2 flex flex-wrap items-center gap-0.5`,children:[e,t&&(0,$.jsx)(`span`,{className:`hidden items-center gap-0.5 group-focus-within/msg:flex group-hover/msg:flex`,children:t})]}),T=e=>p(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),E=e=>{let t=e.text.length>hr||e.text.split(`
9
+ `).length>mr,n=f.has(e.id);return{long:t,open:n,body:(0,$.jsxs)(`div`,{className:W(`relative`,t&&!n&&`max-h-[9.9em] overflow-hidden`),children:[(0,$.jsx)(yt,{children:e.text}),t&&!n&&(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 h-12 bg-gradient-to-t from-[var(--main-surface-bg,var(--panel))] to-transparent group-hover/msg:from-surface-subtle`})]})}},D=e=>{let t=r(e),i=n.get(e);if(!t||!i)return null;let a=bt(i.avatar.color);return(0,$.jsx)(`span`,{className:`max-w-40 flex-none truncate rounded-[4px] px-1.5 py-px text-[11px] font-medium`,style:{color:a.shade,background:a.tile},children:t})};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{id:u,className:`sr-only`,children:a(`bots:room.timeline.hint`)}),(0,$.jsx)(`div`,{ref:l,role:`feed`,"aria-label":a(`bots:room.timeline.label`),"aria-describedby":u,className:`flex flex-col`,onKeyDown:b,children:h.map((e,t)=>{let{message:r}=e,l=r.replyTo?o.get(r.replyTo):null,u=gr(r.at),d=h[t-1],f=!!d&&(d.kind===`user`||d.kind===`post`)&&(e.kind===`user`||e.kind===`post`)&&Qn(d.message,r);if(e.kind===`system`){let e=m(r);return e?x(r,t,e,(0,$.jsx)(xr,{children:e})):null}if(e.kind===`recalled`){let e=r.recalled?.seenBy.map(s)||[],n=r.author.kind===`user`?a(`bots:room.recalledMine`):a(`bots:room.recalledBot`,{name:r.author.kind===`bot`?s(r.author.botId):``});return x(r,t,n,(0,$.jsxs)(xr,{className:`my-3`,children:[n,e.length>0&&` · ${a(`bots:room.seenBy`,{names:e.join(`、`)})}`]}))}if(e.kind===`user`)return x(r,t,[a(`bots:room.a11y.message`,{name:c,time:u}),r.attachments.length?a(`bots:room.a11y.attachments`,{count:r.attachments.length}):``].filter(Boolean).join(` · `),(0,$.jsxs)($.Fragment,{children:[C({avatar:(0,$.jsx)(yr,{label:c}),author:c,at:r.at,merged:f,children:(0,$.jsxs)($.Fragment,{children:[l&&(0,$.jsx)(br,{message:l,members:n,onJump:i.onJump}),r.text&&(0,$.jsx)(`div`,{className:`whitespace-pre-wrap`,children:(0,$.jsx)(vr,{text:r.text,members:n})}),r.attachments.length>0&&(0,$.jsx)(`div`,{className:`mt-1.5`,children:(0,$.jsx)(j,{attachments:qn(r.attachments),compact:!0})}),w(null,(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(wr,{icon:(0,$.jsx)(en,{}),"aria-keyshortcuts":`R`,onClick:()=>i.onReply(r),children:a(`bots:room.reply`)}),(0,$.jsx)(wr,{icon:(0,$.jsx)(M,{}),"aria-keyshortcuts":`Delete`,onClick:()=>i.onRecall(r),children:a(`bots:room.recall`)})]}))]})}),e.round&&(0,$.jsx)(xr,{children:Sr(e.round,s,a)})]}));if(e.kind===`post`){let e=r.author.kind===`bot`?r.author.botId:``,o=n.get(e),{long:c,open:d,body:p}=E(r);return x(r,t,a(`bots:room.a11y.message`,{name:s(e),time:u}),C({avatar:o&&(0,$.jsx)(J,{avatar:o.avatar,size:28,animate:!1}),author:s(e),meta:D(e),at:r.at,merged:f,children:(0,$.jsxs)($.Fragment,{children:[l&&(0,$.jsx)(br,{message:l,members:n,onJump:i.onJump}),p,c&&w((0,$.jsx)(wr,{icon:(0,$.jsx)(S,{className:W(d&&`rotate-180`)}),"aria-expanded":d,onClick:()=>T(r.id),children:a(d?`bots:room.card.collapse`:`bots:room.card.expand`)}),null)]})}))}let p=r.author.kind===`bot`?r.author.botId:``,g=n.get(p),_=r.turn,v=e.handoff?(0,$.jsx)(xr,{children:a(`bots:room.handoff.line`,{from:s(e.handoff.from),to:s(p),hop:e.handoff.hop})}):null;if(_.state===`error`||_.state===`stopped`){let e=_.state===`error`?_.error?a(`bots:room.turn.errorLine`,{name:s(p),error:_.error}):a(`bots:room.turn.errorLinePlain`,{name:s(p)}):a(`bots:room.turn.stoppedLine`,{name:s(p)});return x(r,t,e,(0,$.jsxs)($.Fragment,{children:[v,(0,$.jsx)(xr,{children:e})]}))}let y=(_.alsoAnswered||[]).map(e=>o.get(e)).filter(e=>!!e),{long:b,open:O,body:ee}=E(r);return x(r,t,a(`bots:room.a11y.message`,{name:s(p),time:u}),(0,$.jsxs)($.Fragment,{children:[v,C({avatar:g&&(0,$.jsx)(J,{avatar:g.avatar,size:28,animate:!1}),author:s(p),meta:D(p),at:r.at,right:(0,$.jsx)(`span`,{className:`flex-none rounded-full border border-stroke-soft px-1.5 py-px text-[11px] text-content-muted`,children:a(`bots:room.turnEnded`)}),merged:!1,children:(0,$.jsxs)($.Fragment,{children:[l&&(0,$.jsx)(br,{message:l,members:n,onJump:i.onJump}),y.length>0&&(0,$.jsxs)(`p`,{className:`m-0 mb-1 text-[12px] text-content-muted`,children:[a(`bots:room.alsoAnsweredPrefix`),y.map((e,t)=>(0,$.jsxs)(`span`,{children:[t>0&&`、`,(0,$.jsxs)(`button`,{type:`button`,className:`underline decoration-stroke-strong underline-offset-2 hover:text-content-secondary focus-visible:outline-2 focus-visible:outline-focus`,onClick:()=>i.onJump(e.id),children:[`#`,e.seq]})]},e.id))]}),r.text?ee:(0,$.jsx)(`p`,{className:`m-0 text-[13px] text-content-muted`,children:a(`bots:room.card.emptyReply`)}),w((0,$.jsxs)($.Fragment,{children:[b&&(0,$.jsx)(wr,{icon:(0,$.jsx)(S,{className:W(O&&`rotate-180`)}),"aria-expanded":O,onClick:()=>T(r.id),children:a(O?`bots:room.card.collapse`:`bots:room.card.expand`)}),_.sessionId&&(0,$.jsx)(wr,{icon:(0,$.jsx)(nn,{}),title:a(`bots:room.card.processHint`),onClick:()=>i.onOpenProcess(_.sessionId),children:a(`bots:room.viewProcess`)}),(0,$.jsx)(wr,{icon:(0,$.jsx)(en,{}),"aria-keyshortcuts":`R`,onClick:()=>i.onReply(r),children:a(`bots:room.reply`)})]}),(0,$.jsx)(wr,{icon:(0,$.jsx)(tn,{}),"aria-keyshortcuts":`Delete`,onClick:()=>i.onRecall(r),children:a(`bots:room.hide`)}))]})})]}))})})]})}function Er(e,t,n){if(!t.length)return e;let r=new Map(e.map(e=>[e.id,e])),i=!1;for(let e of t){if(n.has(e.id)&&!e.recalled)continue;let t=r.get(e.id);t&&JSON.stringify(t)===JSON.stringify(e)||(r.set(e.id,e),i=!0)}return i?[...r.values()].sort((e,t)=>e.seq-t.seq):e}function Dr(e,t){return!!e&&JSON.stringify(e)===JSON.stringify(t)}function Or(e){return e.turn?.state===`running`||e.turn?.state===`waiting`}function kr(e){let[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)([]),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!0),[l,u]=(0,Q.useState)(``),[d,p]=(0,Q.useState)(!1),m=(0,Q.useRef)(0),g=(0,Q.useRef)(0),_=(0,Q.useRef)(null),v=(0,Q.useRef)(!1),y=(0,Q.useRef)(!1),b=(0,Q.useRef)({timer:0,detail:!1}),x=(0,Q.useRef)(0),S=(0,Q.useRef)(new Set),C=(0,Q.useRef)([]),w=(0,Q.useRef)(0);C.current=r;let T=(t?.activity.working??0)>0||r.some(Or),E=h(e=>e.capabilities.features[`rooms.events`]===!0);(0,Q.useEffect)(()=>E?$e():void 0,[E]);let D=(0,Q.useCallback)(async({detail:t=!0}={})=>{let r=g.current,a=!1;if(_.current)return v.current=!0,t&&(y.current=!0),_.current;x.current=Date.now(),_.current=Promise.all([t?z(e):null,B(e,{after:m.current,watch:C.current.filter(Or).map(e=>e.id)})]).then(([e,t])=>{if(r!==g.current)return;e&&n(t=>Dr(t,e)?t:e),i(e=>Er(e,t.messages,S.current)),a=t.hasMore&&t.messages.length>0;let o=a?Math.max(...t.messages.map(e=>e.seq)):t.lastSeq;m.current=Math.max(m.current,o),u(``)}).catch(e=>{r===g.current&&(e instanceof f&&e.status===404&&p(!0),u(e instanceof Error?e.message:String(e)))}).finally(()=>{_.current=null}),await _.current;let o=a||v.current,s=y.current;v.current=!1,y.current=!1,o&&r===g.current&&await D({detail:s})},[e]);return(0,Q.useEffect)(()=>{g.current+=1;let t=g.current,r=new AbortController;return n(null),i([]),o(!1),c(!0),u(``),p(!1),m.current=0,S.current=new Set,Promise.all([z(e,r.signal),B(e,{},r.signal)]).then(([e,r])=>{t===g.current&&(n(e),i(r.messages),o(r.hasMore),m.current=r.lastSeq)}).catch(e=>{t===g.current&&!r.signal.aborted&&u(e instanceof Error?e.message:String(e))}).finally(()=>{t===g.current&&c(!1)}),()=>{r.abort(),window.clearTimeout(w.current)}},[e]),(0,Q.useEffect)(()=>{if(s||d)return;let t=()=>document.visibilityState===`visible`,n=()=>{t()&&D()},r=window.setInterval(()=>{if(!t())return;let e=de({push:E,alive:tt(),busy:T});Date.now()-x.current>=e&&D()},le);document.addEventListener(`visibilitychange`,n);let i=b.current,a=E?et(n=>{!ve(n,e)||!t()||(ye(n)&&(i.detail=!0),!i.timer&&(i.timer=window.setTimeout(()=>{i.timer=0;let e=i.detail;i.detail=!1,D({detail:e})},350)))}):()=>{};return()=>{window.clearInterval(r),document.removeEventListener(`visibilitychange`,n),a(),window.clearTimeout(i.timer),i.timer=0}},[T,d,s,D,E,e]),{detail:t,messages:r,hasMore:a,loading:s,error:l,gone:d,busy:T,poll:D,pollSoon:(0,Q.useCallback)(()=>{D(),window.clearTimeout(w.current),w.current=window.setTimeout(()=>void D(),700)},[D]),loadOlder:(0,Q.useCallback)(async()=>{let t=C.current[0];if(!t)return;let n=g.current,r=await B(e,{before:t.seq});n===g.current&&(i(e=>Er(e,r.messages,S.current)),o(r.hasMore))},[e]),replace:(0,Q.useCallback)(e=>{e.recalled&&S.current.add(e.id),i(t=>Er(t,[e],S.current))},[])}}function Ar(e){let n=String(t().roomId||``);return(0,$.jsx)(jr,{roomId:n,...e},n)}function jr({roomId:e,notify:t,phoneLeading:n}){let{t:r}=d(),i=a(),o=Yt(`bots`),s=g();Ut(o);let u=X(e=>e.bots),f=he(e=>e.upsert),p=he(e=>e.remove),m=h(e=>e.capabilities.features[`rooms.host`]===!0),_=kr(e),{detail:v,messages:y}=_,[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(null),[D,O]=(0,Q.useState)(`brief`),[ee,k]=(0,Q.useState)(!1),[A,j]=(0,Q.useState)(0),[M,N]=(0,Q.useState)(!1),[te,re]=(0,Q.useState)(!1),[P,ie]=(0,Q.useState)(!1),[ae,oe]=(0,Q.useState)(null),F=(0,Q.useRef)(new Set),I=(0,Q.useRef)(null),L=(0,Q.useRef)(null),R=(0,Q.useMemo)(()=>{let e=new Map((v?.members||[]).map(e=>[e.id,e]));for(let t of u)e.has(t.id)||e.set(t.id,{id:t.id,name:t.name,avatar:t.avatar,enabled:t.enabled,deleted:!1,sessionId:``,readSeq:0,unread:0,status:{state:`idle`,waiting:null,current:``}});return e},[v?.members,u]),le=(0,Q.useMemo)(()=>zn(y),[y]),ue=(0,Q.useMemo)(()=>Zn(y),[y]),de=(0,Q.useMemo)(()=>new Map(u.map(e=>[e.id,e])),[u]),z=(0,Q.useCallback)(e=>t(e instanceof Error?e.message:String(e),`error`),[t]),ve=y.at(-1)?.id,B=(0,Q.useRef)(!0),ye=(0,Q.useCallback)(e=>{I.current=e,e&&B.current&&(e.scrollTop=e.scrollHeight)},[ve,_.loading]),be=v?.room.name||``;(0,Q.useEffect)(()=>{_.gone&&(p(e),t(r(`bots:room.gone`,{name:be}),`error`),i(c(`bots`),{replace:!0}))},[be,_.gone,i,t,p,e,r]);let we=(e,t)=>{F.current.has(e)||(F.current.add(e),t().then(()=>_.poll()).catch(z).finally(()=>F.current.delete(e)))},Ee=e=>e.kind===`bot`?R.get(e.botId)?.name||r(`bots:room.removedBot`):r(`bots:room.you`),De={onReply:e=>x(e),onRecall:e=>{L.current={node:document.activeElement instanceof HTMLElement?document.activeElement:null,id:e.id},C(e)},onOpenProcess:e=>i(l(e)),onJump:e=>{let t=I.current?.querySelector(`[data-room-message="${CSS.escape(e)}"]`);t instanceof HTMLElement&&(t.focus({preventScroll:!0}),t.scrollIntoView({block:`center`,behavior:`smooth`}),t.classList.add(`ring-2`,`ring-focus-ring`),window.setTimeout(()=>t.classList.remove(`ring-2`,`ring-focus-ring`),1200))}},Oe=async(t,n,r)=>{if(!v)return!1;try{let i=await ge(e,{text:t,...r.length?{attachments:r}:{},mentions:n,recipients:ae??v.room.recipients,...b?{replyTo:b.id}:{}});return _.replace(i.message),x(null),B.current=!0,_.pollSoon(),!0}catch(e){return z(e),!1}},ke=t=>{v&&(oe(t),Te(e,{recipients:t}).then(f).catch(e=>{oe(null),z(e)}))},Ae=async()=>{let n=S;if(C(null),n)try{let i=await me(e,n.id);_.replace({...n,text:``,attachments:[],mentions:[],recalled:{seenBy:i.seenBy}}),i.briefMayContain&&t(r(`bots:room.recall.briefNote`)),i.attachmentsKept>0&&t(r(`bots:room.recall.attachmentsKept`,{count:i.attachmentsKept}))}catch(e){z(e)}},je=async t=>{ie(!0);try{await pe(e,t),await _.poll()}catch(e){z(e)}finally{ie(!1)}},Ne=(t,n,r)=>we(`approval:${n}`,()=>ce(e,t.id,n,r)),Ke=(t,n)=>{Te(e,{answerMode:t,hostBotId:n}).then(e=>(oe(null),f(e),_.poll())).catch(z)},qe=e=>{O(e),T(t=>t===e?null:e)},Je=async t=>{try{return f(await Te(e,t)),await _.poll(),!0}catch(e){return z(e),!1}},H=async()=>{re(!1);try{await xe(e),p(e),t(r(`bots:room.deleted`,{name:v?.room.name||``})),i(c(`bots`))}catch(e){z(e)}};if(!o)return(0,$.jsx)(mt,{kind:`empty`,title:r(`bots:room.labsOff`),description:r(`bots:room.labsOffHint`)});if(_.loading)return(0,$.jsx)(mt,{kind:`loading`,title:r(`bots:room.loading`)});if(!v)return(0,$.jsx)(mt,{kind:`error`,title:r(`bots:room.loadFailed`),description:_.error,action:(0,$.jsx)(K,{variant:`outline`,onClick:()=>i(c(`bots`)),children:r(`bots:room.backToBots`)})});let{room:U}=v,G=v.members.filter(e=>!e.deleted),$e=m&&U.answerMode===`host`?R.get(U.hostBotId)?.name||r(`bots:room.removedBot`):``,et=w===`members`?(0,$.jsx)(ur,{detail:v,bots:u,hostAvailable:m,onOpenMember:e=>e.sessionId&&i(l(e.sessionId)),onSave:Je,onAnswerModeChange:Ke,onDelete:()=>re(!0),onError:z}):(0,$.jsx)(lr,{detail:v,briefing:P||v.briefing,onTidy:e=>void je(e),onEditBrief:()=>N(!0)}),tt=r(w===`members`?`bots:room.header.info`:`bots:room.brief`),nt=ee||P||v.briefing?null:er({messages:y,brief:v.brief,lastSeq:v.lastSeq,maintained:!!U.briefBotId,skipUpTo:A}),rt=U.cwd.split(/[\\/]/).filter(Boolean).at(-1)||``,it=e=>{let t=de.get(e);return t?se(r,t.model):``},at=e=>{let t=de.get(e);return t?Ce(r,t.executionMode):``},ot=S&&!S.turn?v.members.filter(e=>e.readSeq>=S.seq).map(e=>e.name):S?v.members.filter(e=>e.readSeq>=S.seq&&(S.author.kind!==`bot`||S.author.botId!==e.id)).map(e=>e.name):[];return(0,$.jsxs)(`div`,{"data-room-page":U.id,className:`flex h-full min-h-0 bg-[var(--main-surface-bg,var(--panel))]`,children:[(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,$.jsxs)(`header`,{className:W(`flex h-[52px] flex-none items-center gap-2 px-4 max-[650px]:h-[calc(52px+var(--pisper-safe-area-top,0px))] max-[650px]:px-2 max-[650px]:pt-[var(--pisper-safe-area-top,0px)]`,!(w&&!s)&&`[[data-custom-titlebar]_&]:pr-[144px]`),children:[s&&n,(0,$.jsx)(_e,{avatars:G.map(e=>e.avatar)}),(0,$.jsx)(`h1`,{className:`m-0 min-w-0 truncate text-[15px] font-semibold text-content`,children:U.name}),(0,$.jsx)(`span`,{className:`flex-none text-[13px] text-content-muted max-[650px]:hidden`,children:rt?r(`bots:room.header.summaryWithFolder`,{count:G.length,folder:rt}):r(`bots:room.header.summary`,{count:G.length})}),(0,$.jsx)(`span`,{className:`flex-1`}),v.totalTokens>0&&(0,$.jsx)(`span`,{className:`flex-none text-[12px] text-content-muted tabular-nums max-[650px]:hidden`,children:r(`bots:room.usage`,{tokens:Wn(v.totalTokens)})}),!s&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(K,{variant:`ghost`,size:`sm`,"aria-pressed":w===`brief`,onClick:()=>qe(`brief`),children:[(0,$.jsx)(rn,{}),r(`bots:room.brief`)]}),(0,$.jsxs)(K,{variant:`ghost`,size:`sm`,"aria-pressed":w===`members`,onClick:()=>qe(`members`),children:[(0,$.jsx)(Me,{}),r(`bots:room.header.info`)]})]}),(0,$.jsxs)(Ge,{children:[(0,$.jsx)(Ue,{asChild:!0,children:(0,$.jsx)(K,{variant:`ghost`,size:`icon-sm`,"aria-label":r(`bots:room.more`),children:(0,$.jsx)(E,{})})}),(0,$.jsxs)(We,{align:`end`,children:[s&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(V,{onSelect:()=>T(`brief`),children:[(0,$.jsx)(rn,{"aria-hidden":`true`}),r(`bots:room.brief`)]}),(0,$.jsxs)(V,{onSelect:()=>T(`members`),children:[(0,$.jsx)(Me,{"aria-hidden":`true`}),r(`bots:room.header.info`)]}),(0,$.jsx)(He,{})]}),(0,$.jsx)(V,{onSelect:()=>N(!0),children:r(`bots:room.brief.edit`)}),(0,$.jsx)(He,{}),(0,$.jsx)(V,{variant:`destructive`,onSelect:()=>re(!0),children:r(`bots:room.delete`)})]})]}),!s&&(0,$.jsx)(K,{variant:`ghost`,size:`icon-sm`,"aria-label":r(`bots:room.toggleRail`),"aria-pressed":!!w,onClick:()=>T(w?null:D),children:(0,$.jsx)(ne,{})})]}),(0,$.jsx)(`div`,{ref:ye,"data-room-timeline":!0,className:`min-h-0 flex-1 overflow-y-auto`,onScroll:e=>{let t=e.currentTarget;B.current=t.scrollHeight-t.scrollTop-t.clientHeight<80},children:(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-[768px] px-6 pt-2 pb-4 max-[650px]:px-4`,children:[_.hasMore&&(0,$.jsx)(`div`,{className:`flex justify-center`,children:(0,$.jsx)(K,{variant:`ghost`,size:`sm`,onClick:()=>void _.loadOlder().catch(z),children:r(`bots:room.loadOlder`)})}),le.length?(0,$.jsx)(Tr,{items:le,messages:y,members:R,modelLabel:it,actions:De}):(0,$.jsx)(mt,{kind:`empty`,title:r(`bots:room.empty.title`),description:r(`bots:room.empty.description`)})]})}),(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-[816px] flex-none px-6 pb-4 max-[650px]:px-3 max-[650px]:pb-[calc(12px+var(--pisper-safe-area-bottom,0px))]`,children:[_.error&&(0,$.jsx)(`p`,{role:`status`,className:`m-0 mb-2 text-center text-[12px] text-content-muted`,children:r(`bots:room.reconnecting`)}),(0,$.jsx)(fr,{entries:ue,members:R,modeLabel:at,onOpenProcess:e=>i(l(e)),onApprove:Ne,onStop:t=>we(`stop:${t.id}`,()=>Se(e,t.id))}),nt&&(0,$.jsx)(pr,{count:nt.count,chars:nt.chars,members:G,phone:s,onPick:e=>void je(e),onWrite:()=>N(!0),onLater:()=>k(!0),onSkip:()=>j(v.lastSeq),onOpen:()=>T(`brief`)}),(0,$.jsx)(ar,{roomId:U.id,cwd:U.cwd||void 0,members:G,recipients:ae??U.recipients,onRecipientsChange:ke,replyTo:b,replyName:b?Ee(b.author):``,onCancelReply:()=>x(null),onSend:Oe,placeholder:$e?r(s?`bots:room.composer.placeholderHostPhone`:`bots:room.composer.placeholderHost`,{name:$e}):r(s?`bots:room.composer.placeholderPhone`:`bots:room.composer.placeholder`),idleLabel:$e?r(`bots:room.composer.toHost`):void 0,idleHint:$e?r(`bots:room.composer.hostHint`,{name:$e}):void 0})]})]}),!s&&w&&(0,$.jsx)(`aside`,{"aria-label":tt,className:`w-[288px] flex-none overflow-y-auto border-l border-stroke-soft px-3 py-3 [[data-custom-titlebar]_&]:pt-[52px]`,children:et}),s&&(0,$.jsx)(Qe,{open:!!w,onOpenChange:e=>!e&&T(null),children:(0,$.jsxs)(Ye,{side:`bottom`,className:`max-h-[85dvh] overflow-y-auto px-4 pt-12 pb-[calc(16px+var(--pisper-safe-area-bottom,0px))]`,children:[(0,$.jsx)(Xe,{className:`sr-only`,children:tt}),(0,$.jsx)(Ze,{className:`sr-only`,children:U.name}),et]})}),(0,$.jsx)(or,{open:M,onOpenChange:N,brief:v.brief,members:G,onSave:async t=>{await fe(e,t),await _.poll()}}),(0,$.jsx)(Ve,{open:!!S,onOpenChange:e=>!e&&C(null),children:(0,$.jsxs)(Ie,{onCloseAutoFocus:e=>{let t=L.current;L.current=null;let n=t?.node?.isConnected?t.node:t?I.current?.querySelector(`[data-room-message="${CSS.escape(t.id)}"]`):null;n instanceof HTMLElement&&(e.preventDefault(),n.focus({preventScroll:!0}))},children:[(0,$.jsxs)(Be,{children:[(0,$.jsx)(Fe,{children:S?.author.kind===`bot`?r(`bots:room.recallConfirm.hideTitle`):r(`bots:room.recallConfirm.title`)}),(0,$.jsxs)(Pe,{children:[r(`bots:room.recallConfirm.description`),ot.length>0&&(0,$.jsxs)($.Fragment,{children:[` `,r(`bots:room.recallConfirm.seen`,{names:ot.join(`、`)})]}),ot.length>0&&!!S?.attachments.length&&(0,$.jsxs)($.Fragment,{children:[` `,r(`bots:room.recallConfirm.attachments`)]})]})]}),(0,$.jsxs)(Re,{children:[(0,$.jsx)(ze,{children:r(`common:ui.cancel`)}),(0,$.jsx)(Le,{onClick:()=>void Ae(),children:S?.author.kind===`bot`?r(`bots:room.hide`):r(`bots:room.recall`)})]})]})}),(0,$.jsx)(Ve,{open:te,onOpenChange:re,children:(0,$.jsxs)(Ie,{children:[(0,$.jsxs)(Be,{children:[(0,$.jsx)(Fe,{children:r(`bots:room.deleteConfirm.title`,{name:U.name})}),(0,$.jsx)(Pe,{children:r(`bots:room.deleteConfirm.description`)})]}),(0,$.jsxs)(Re,{children:[(0,$.jsx)(ze,{children:r(`common:ui.cancel`)}),(0,$.jsx)(Le,{variant:`destructive`,onClick:()=>void H(),children:r(`bots:room.delete`)})]})]})})]})}export{In as BotsPage,Ar as RoomPage};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/public-diff-BiBx9iwa.js","assets/GitDiffViewer-DDd2yMvx.js","assets/rolldown-runtime-B0Z9INg1.js","assets/vendor-react-DwNgTV1j.js","assets/use-i18n-CbqEZb3r.js","assets/i18n-CYOV8NO5.js","assets/vendor-router-CSN_DGvx.js","assets/index-B446sLQy.js","assets/index-Fb-GT4ka.css","assets/storage-DtvZ_lEu.js","assets/vendor-state-GkUciC5H.js","assets/createLucideIcon-Cd-3GVxJ.js","assets/x-07u4-129.js","assets/utils-C8uzG5AZ.js","assets/vendor-ui-DvrYggeS.js","assets/button-CCcCN8tE.js","assets/dist-41X0pdUs.js","assets/events-BrkEbuk_.js","assets/esm-DCV8yILT.js"])))=>i.map(i=>d[i]);
2
+ import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{h as t,l as n,n as r,u as i}from"./vendor-router-CSN_DGvx.js";import{i as a,r as o}from"./vendor-react-DwNgTV1j.js";import{h as s,o as c,r as l}from"./routes-BYsK6aeM.js";import{t as u}from"./use-i18n-CbqEZb3r.js";import{r as d,t as f}from"./useQuery-DfOU-27z.js";import{n as p}from"./component-changes-Q9Bf64Ob.js";import{T as m,g as h,i as g,j as _,n as v,o as y,v as b}from"./session-scope-B13jJaQq.js";import{c as x,d as S,l as C,t as w,u as T}from"./placements-DueXe1Zp.js";import{t as ee}from"./usePhoneShell-BDH8-EY7.js";import{t as E}from"./createLucideIcon-Cd-3GVxJ.js";import{t as te}from"./app-window-CPNdvYNt.js";import{t as D}from"./arrow-up-right-B6l8qFZz.js";import{t as O}from"./blocks-Olsdp5Lp.js";import{t as ne}from"./check-2vYc6QaP.js";import{t as re}from"./chevron-down-CxtxIjiP.js";import{t as ie}from"./chevron-left-BAtyp3_6.js";import{t as ae}from"./chevron-right-C3t2Rckj.js";import{t as k}from"./code-xml-BrUXrBax.js";import{t as oe}from"./copy-DHmIFc52.js";import{t as se}from"./download-BCfIiuaL.js";import{t as ce}from"./ellipsis-CfGKfbq6.js";import{t as le}from"./panel-right-BSUtqUd8.js";import{t as ue}from"./plus-fQbSqB1n.js";import{t as de}from"./rotate-ccw-clock-CO6Bw-sF.js";import{t as fe}from"./search-D0mqDaf_.js";import{t as A}from"./settings-2-CXJjXJS9.js";import{t as pe}from"./shield-alert-oZqX6MNu.js";import{t as me}from"./sparkles-S_eeuqn9.js";import{t as j}from"./trash-2-CNrPOoPR.js";import{t as he}from"./x-07u4-129.js";import{t as ge}from"./checkbox-BrEHgFV0.js";import{a as _e,c as ve,i as M,p as ye,r as be,t as xe}from"./dropdown-menu-Ds0gD8S8.js";import{t as Se}from"./label-CVWjEcfV.js";import{a as N,i as Ce,n as we,r as Te,t as Ee}from"./select-Bbk9bmXO.js";import{t as De}from"./switch-D_G8wFhs.js";import{t as P}from"./segmented-control-xkrEOP_d.js";import{t as F}from"./utils-C8uzG5AZ.js";import{r as Oe,t as I}from"./button-CCcCN8tE.js";import{t as ke}from"./kbd-CAufZTkl.js";import{t as Ae}from"./shortcuts-CctXrljf.js";import{a as je,i as Me,n as Ne,o as Pe,r as Fe,t as Ie}from"./sheet-BTaIEX4w.js";import{t as Le}from"./sidebar-store-D3ZnQB3e.js";import{s as Re}from"./useNewProjectPicker-Dum2z5eb.js";import{a as ze,n as Be}from"./format-DMJQzoZ7.js";import{a as L,i as R,l as z,n as Ve,o as B,s as V,t as H}from"./dialog-C6pJ93kY.js";import{t as U}from"./input-CPw-zkYh.js";import{t as He}from"./textarea-DmATpOqT.js";import"./public-bzVRS_Ps.js";import{n as W,t as G}from"./PageState-Cz6vFMXv.js";import{t as K}from"./useOverlayFocusReturn-NkxBSSjb.js";import{t as Ue}from"./chip-ZhnvFlFg.js";import{t as We}from"./badge-CWB3lj2H.js";import{A as Ge,B as Ke,C as qe,G as Je,H as Ye,I as Xe,J as Ze,K as Qe,L as q,M as $e,N as et,P as tt,R as nt,S as rt,T as it,U as at,V as ot,W as st,X as ct,Y as lt,Z as ut,_ as dt,a as ft,b as pt,c as mt,f as ht,g as gt,h as _t,i as J,j as vt,k as yt,l as bt,m as xt,n as St,o as Ct,p as Y,q as wt,r as Tt,s as Et,t as Dt,u as Ot,v as kt,w as At,x as jt,y as Mt,z as Nt}from"./use-studio-actions-GplOMwz9.js";import{t as X}from"./PageFrame-DNwGZ-Dz.js";var Pt=E(`file-archive`,[[`path`,{d:`M13.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v11.5`,key:`4pqfef`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 12v-1`,key:`1ej8lb`}],[`path`,{d:`M8 18v-2`,key:`qcmpov`}],[`path`,{d:`M8 7V6`,key:`1nbb54`}],[`circle`,{cx:`8`,cy:`20`,r:`2`,key:`ckkr5m`}]]),Ft=E(`git-compare`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`path`,{d:`M11 18H8a2 2 0 0 1-2-2V9`,key:`19pyzm`}]]),It=E(`layout-dashboard`,[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]),Z=e(a(),1);function Lt(){let e=null,t=new Set;return{set(n){let r=Math.round(n*10)/10;if(r!==e){e=r;for(let e of[...t])e()}},get:()=>e,subscribe(e){return t.add(e),()=>{t.delete(e)}}}}var Q=o();function Rt({manifest:e,target:t,window:n,phone:r=!1,onTarget:i,onWindow:a}){let{t:o}=u(),s=Mt(e);return(0,Q.jsxs)(`div`,{"data-studio-preview-bar":!0,className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 text-xs text-content-muted`,children:[(0,Q.jsx)(`span`,{className:F(r&&`sr-only`),children:o(`custom-ui:studio.previewPlacement`)}),(0,Q.jsx)(P,{size:`sm`,"aria-label":o(`custom-ui:studio.previewPlacement`),value:t,onValueChange:i,className:F(`max-w-full overflow-x-auto`,r&&`w-full`),options:s.map(e=>({value:e,label:ft(e,o)}))}),!r&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`ml-auto`,children:o(`custom-ui:studio.previewWindow`)}),(0,Q.jsx)(P,{size:`sm`,"aria-label":o(`custom-ui:studio.previewWindow`),value:n,onValueChange:a,options:[{value:`standard`,label:o(`custom-ui:studio.windowStandard`)},{value:`min`,label:o(`custom-ui:studio.windowMin`)}]}),(0,Q.jsx)(`span`,{className:`rounded-sm border border-stroke px-2 py-1 text-content-secondary`,title:o(`custom-ui:studio.themeFollowHint`),children:o(`custom-ui:studio.themeFollow`)})]})]})}function zt({activeSessionId:e=``,row:t,target:n,window:r,instanceId:i,title:a,props:o,phone:s=!1,notify:c,commits:l}){let{t:d}=u(),f=Ot(t,c),p=kt(n,t.manifest,s?`standard`:r),m=At(n),h=p.width===`fill`||s?`100%`:p.width,g=p.width===`fill`||s&&m===`overview-card`?`100%`:p.width,_=p.height===`fill`;return(0,Q.jsxs)(`div`,{"data-component-preview":!0,"data-component-preview-target":n,className:F(`flex min-h-0 min-w-0 flex-1 flex-col gap-2 overflow-auto rounded-[var(--r-lg)] border border-stroke bg-surface-subtle bg-[radial-gradient(var(--stroke-strong)_1px,transparent_1px)] [background-size:16px_16px]`,s?`min-h-[min(420px,55dvh)] p-3`:`p-5`),children:[(0,Q.jsxs)(`p`,{className:`flex flex-none items-baseline gap-2 text-xs text-content-muted`,children:[(0,Q.jsx)(`span`,{className:`text-content-secondary`,children:J(m,d)}),p.label&&(0,Q.jsx)(`span`,{"data-component-preview-size":!0,className:`font-mono tabular-nums`,children:s&&m===`overview-card`?p.label.split(` · `)[0]:p.label})]}),(0,Q.jsx)(`div`,{"data-component-preview-frame":!0,className:F(`flex min-w-0 flex-col overflow-hidden rounded-[var(--r-lg)] bg-panel shadow-edge ring-1 ring-stroke`,_?`min-h-[320px] flex-1`:`flex-none`),style:{width:h,maxWidth:g,minWidth:s||p.width===`fill`?void 0:p.width,height:_?void 0:p.height},children:(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(Ge,{component:t,instance:{instanceId:i??`preview:${t.id}`,surface:m,title:a,props:o,size:qe(n)},preview:!0,session:e?{id:e,title:``,cwd:``,status:`idle`}:void 0,notify:e=>c(e),onRequestFix:f,onCommitSample:e=>l.set(e),className:`h-full animate-[fade-in_120ms_var(--ease-enter)] [:root[data-motion=reduced]_&]:animate-none motion-reduce:[:root:not([data-motion=full])_&]:animate-none`},`${t.id}@${t.rev}:${n}:${i??``}`)})})]})}function Bt({componentId:e,errors:t,commits:n}){let{t:r}=u(),i=(0,Z.useSyncExternalStore)(n.subscribe,n.get,n.get),a=tt(),o=(0,Z.useSyncExternalStore)(a.subscribe,()=>a.reloadRecommended(e),()=>!1),s=(0,Z.useMemo)(()=>t?.entries.filter(e=>e.level===`error`).length??0,[t]),c=Object.keys(t?.network.hosts??{});return(0,Q.jsxs)(`p`,{"data-studio-status":!0,className:`flex min-w-0 flex-none flex-wrap items-center gap-x-3 gap-y-1 text-xs text-content-muted`,children:[(0,Q.jsx)(`span`,{"data-studio-status-errors":!0,className:F(s>0&&`text-content`),children:r(`custom-ui:studio.statusErrors`,{count:s})}),(0,Q.jsx)(`span`,{className:`font-mono tabular-nums`,children:i===null?r(`custom-ui:studio.statusRenderNone`):r(`custom-ui:studio.statusRender`,{ms:i})}),(0,Q.jsxs)(`span`,{className:`min-w-0 truncate`,children:[r(`custom-ui:studio.statusNetwork`,{count:t?.network.count??0}),c.length>0&&(0,Q.jsxs)(`span`,{className:`font-mono`,children:[` · `,c.slice(0,3).join(`, `)]})]}),o&&(0,Q.jsx)(`span`,{className:`text-content`,children:r(`custom-ui:studio.reloadRecommended`)}),(0,Q.jsx)(`span`,{className:`ml-auto`,children:r(`custom-ui:studio.statusHotReload`)})]})}function Vt({onCreate:e,phone:t=!1,className:n}){let{t:r}=u(),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(!1),p=(0,Z.useRef)(null),m=K(i,p),h=(0,Z.useId)(),g=(0,Z.useId)(),_=async(t,n,r)=>{f(!0);try{await e(t,n,r)&&(a(!1),s(``),l(``))}finally{f(!1)}},v=o.trim(),y=c.trim(),b=()=>{v&&_(`blank`,v,y||void 0)},x=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Se,{htmlFor:h,className:`-mb-1.5 text-xs text-content-secondary`,children:r(`custom-ui:studio.componentName`)}),(0,Q.jsx)(U,{id:h,autoFocus:!0,value:o,maxLength:120,placeholder:r(`custom-ui:studio.componentNamePlaceholder`),"data-component-new-name":!0,className:t?`min-h-11`:void 0,onChange:e=>s(e.target.value)}),(0,Q.jsx)(Se,{htmlFor:g,className:`-mb-1.5 text-xs text-content-secondary`,children:r(`custom-ui:agent.newPromptLabel`)}),(0,Q.jsx)(He,{id:g,rows:3,value:c,maxLength:Et,placeholder:r(`custom-ui:agent.newPromptPlaceholder`),"data-component-new-prompt":!0,className:`max-h-48 resize-none`,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key!==`Enter`||!(e.metaKey||e.ctrlKey)||e.nativeEvent.isComposing||(e.preventDefault(),b())}})]}),S=r(y?`custom-ui:agent.createAndGenerate`:`custom-ui:studio.create`);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(xe,{children:[(0,Q.jsx)(ye,{asChild:!0,children:(0,Q.jsxs)(I,{ref:p,size:`sm`,variant:`secondary`,disabled:d,"data-component-new":!0,className:F(n),children:[(0,Q.jsx)(ue,{}),r(`custom-ui:studio.new`),(0,Q.jsx)(re,{className:`text-content-muted`})]})}),(0,Q.jsxs)(be,{align:`end`,className:`w-56`,children:[(0,Q.jsx)(M,{"data-component-new-blank":!0,onSelect:()=>a(!0),children:r(`custom-ui:studio.newBlank`)}),(0,Q.jsx)(ve,{}),(0,Q.jsx)(_e,{className:`text-xs font-normal text-content-muted`,children:r(`custom-ui:studio.fromTemplate`)}),(0,Q.jsx)(M,{"data-component-new-template":`usage-today`,onSelect:()=>void _(`usage-today`),children:r(`custom-ui:studio.templateUsageToday`)}),(0,Q.jsx)(M,{"data-component-new-template":`notes`,onSelect:()=>void _(`notes`),children:r(`custom-ui:studio.templateNotes`)})]})]}),t?(0,Q.jsx)(Ie,{open:i,onOpenChange:e=>!d&&a(e),children:(0,Q.jsx)(Ne,{side:`bottom`,onCloseAutoFocus:m,"data-component-new-sheet":!0,className:`gap-0 rounded-t-[var(--r-lg)] p-0`,children:(0,Q.jsxs)(`form`,{className:`flex flex-col gap-3 px-4 pt-4 pb-[max(16px,env(safe-area-inset-bottom))]`,onSubmit:e=>{e.preventDefault(),b()},children:[(0,Q.jsxs)(je,{className:`p-0`,children:[(0,Q.jsx)(Pe,{children:r(`custom-ui:studio.newBlankTitle`)}),(0,Q.jsx)(Fe,{children:r(`custom-ui:studio.newBlankHint`)})]}),x,(0,Q.jsxs)(Me,{className:`flex-row p-0`,children:[(0,Q.jsx)(I,{type:`button`,variant:`outline`,className:`min-h-11 flex-1`,disabled:d,onClick:()=>a(!1),children:r(`custom-ui:studio.cancel`)}),(0,Q.jsx)(I,{type:`submit`,className:`min-h-11 flex-1`,disabled:d||!v,children:S})]})]})})}):(0,Q.jsx)(H,{open:i,onOpenChange:e=>!d&&a(e),children:(0,Q.jsx)(R,{onCloseAutoFocus:m,children:(0,Q.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault(),b()},children:[(0,Q.jsxs)(V,{children:[(0,Q.jsx)(z,{children:r(`custom-ui:studio.newBlankTitle`)}),(0,Q.jsx)(L,{children:r(`custom-ui:studio.newBlankHint`)})]}),x,(0,Q.jsxs)(B,{children:[(0,Q.jsx)(I,{type:`button`,variant:`outline`,disabled:d,onClick:()=>a(!1),children:r(`custom-ui:studio.cancel`)}),(0,Q.jsx)(I,{type:`submit`,disabled:d||!v,children:S})]})]})})})]})}function Ht(e,t){return e.length?e.map(e=>{let n=J(e.surface,t);if(e.surface!==`overview-card`)return n;let r=e.sizes.join(`/`),i=r?`${n} ${r}`:n;return e.count>1?`${i} ×${e.count}`:i}).join(` · `):t(`custom-ui:studio.notPlaced`)}function Ut(e,t,n){if(e.kind===`broken`||e.status!==`ready`){let t=e.errors[0];return t?q(t.code,n,t.params):n(`custom-ui:studio.statusInvalid`)}return Ht(dt(e.id,t),n)}function Wt(e,t){return e.kind===`broken`?t(`custom-ui:studio.statusBroken`):e.status===`ready`?e.enabled?null:t(`custom-ui:studio.statusDisabled`):t(`custom-ui:studio.statusInvalid`)}function Gt({row:e,instances:t,active:n,phone:r=!1,onSelect:i}){let{t:a,language:o}=u(),s=Wt(e,a);return(0,Q.jsxs)(`button`,{type:`button`,"data-component-row":e.id,"data-component-kind":e.kind,"aria-current":n||void 0,onClick:i,className:F(`flex w-full min-w-0 items-center gap-3 text-left transition-colors duration-(--d-fast) focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-focus`,r?`min-h-14 px-3.5 py-2 hover:bg-surface-hover active:bg-surface-hover`:F(`rounded-[var(--r-md)] px-2.5 py-2`,n?`bg-surface-active`:`hover:bg-surface-hover`)),children:[(0,Q.jsx)(`span`,{className:F(`grid flex-none place-items-center rounded-[var(--r-md)] border border-stroke bg-solid text-content-secondary`,r?`size-9`:`size-8`),children:(0,Q.jsx)(O,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Q.jsx)(`strong`,{className:`min-w-0 truncate text-sm font-medium text-content`,children:Y(e,o)}),e.version&&(0,Q.jsxs)(`span`,{className:`flex-none font-mono text-xs text-content-muted tabular-nums`,children:[`v`,e.version]}),s&&(0,Q.jsx)(We,{className:`ml-auto flex-none text-content-secondary`,children:s})]}),(0,Q.jsx)(`small`,{className:`truncate text-xs text-content-muted`,"data-component-row-detail":!0,children:Ut(e,t,a)})]}),r&&(0,Q.jsx)(ae,{className:`size-4 flex-none text-content-muted`,"aria-hidden":`true`})]})}function Kt({componentId:e,onOpenLogs:t,onReload:n,onRequestFix:r}){let{t:i}=u(),a=et(),o=(0,Z.useSyncExternalStore)(e=>a.subscribe(e),()=>{let t=a.read(e);for(let e=t.length-1;e>=0;--e)if(t[e].level===`error`)return t[e];return null}),s=o?.message??``;return(0,Q.jsxs)(`div`,{role:`status`,"data-component-crash":e,className:`mx-1 mt-1 mb-1.5 flex flex-col gap-1.5 rounded-[var(--r-md)] border border-stroke bg-surface-subtle px-2.5 py-2`,children:[(0,Q.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs font-medium text-st-fail`,children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 rounded-full bg-st-fail`}),i(`custom-ui:host.renderErrorTitle`)]}),s&&(0,Q.jsx)(`p`,{className:`truncate font-mono text-xs text-content-secondary`,title:s,children:s}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[(0,Q.jsx)(I,{size:`xs`,variant:`ghost`,onClick:t,children:i(`custom-ui:host.viewError`)}),(0,Q.jsx)(I,{size:`xs`,variant:`secondary`,onClick:n,children:i(`custom-ui:host.reload`)}),r&&s&&(0,Q.jsx)(I,{size:`xs`,variant:`ghost`,"data-component-crash-fix":e,onClick:()=>r(Xe(s,o?.stack)),children:i(`custom-ui:host.askAgentFix`)})]})]})}function qt({rows:e,allCount:t,counts:n,instances:r,selectedId:i,troubled:a,filter:o,query:s,root:c,onFilter:l,onQuery:d,onSelect:f,onCreate:p,onOpenLogs:m,onReload:h,onRequestFix:g,importButton:_,staged:v,footer:y}){let{t:b}=u();return(0,Q.jsxs)(`section`,{"data-studio-library":!0,"aria-label":b(`custom-ui:studio.library`),className:`flex min-h-0 min-w-0 flex-col border-r border-stroke`,children:[(0,Q.jsxs)(`header`,{className:`flex flex-col gap-2.5 px-3 pt-3.5 pb-2.5`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Q.jsxs)(`h2`,{className:`mr-auto flex min-w-0 items-baseline gap-1.5 truncate text-base font-semibold`,children:[b(`custom-ui:studio.libraryTitle`),(0,Q.jsx)(`span`,{className:`text-sm font-normal text-content-muted tabular-nums`,children:t})]}),_,(0,Q.jsx)(Vt,{onCreate:p})]}),(0,Q.jsxs)(`label`,{className:`relative block`,children:[(0,Q.jsx)(fe,{"aria-hidden":!0,className:`pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2 text-content-muted`}),(0,Q.jsx)(U,{type:`search`,value:s,placeholder:b(`custom-ui:studio.search`),"aria-label":b(`custom-ui:studio.search`),className:`pl-8`,onChange:e=>d(e.target.value)})]}),(0,Q.jsx)(P,{size:`sm`,"aria-label":b(`custom-ui:studio.filter`),value:o,onValueChange:l,className:`w-full [&>*]:flex-1`,options:[{value:`all`,label:b(`custom-ui:studio.filterAll`)},{value:`enabled`,label:b(`custom-ui:studio.filterEnabled`),count:n.enabled},{value:`attention`,label:b(`custom-ui:studio.filterAttention`),count:n.attention}]})]}),(0,Q.jsxs)(`ul`,{className:`flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto px-2 pb-2`,children:[v&&(0,Q.jsx)(`li`,{className:`flex flex-col gap-1.5 pb-1`,children:v}),e.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(Gt,{row:e,instances:r,active:e.id===i,onSelect:()=>f(e.id)}),a.has(e.id)&&(0,Q.jsx)(Kt,{componentId:e.id,onOpenLogs:()=>m(e.id),onReload:()=>h(e.id),onRequestFix:g&&(t=>g(e,t))})]},e.id)),!e.length&&!v&&(0,Q.jsx)(`li`,{className:`px-2.5 py-6 text-center text-sm text-content-muted`,children:b(`custom-ui:studio.noMatches`)})]}),y,(0,Q.jsxs)(`p`,{"data-studio-hot-reload":!0,className:`flex flex-none flex-col gap-0.5 border-t border-stroke px-3.5 py-2.5 text-xs text-content-muted`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 text-content-secondary`,children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 rounded-full bg-content-muted`}),b(`custom-ui:studio.hotReloadOn`)]}),(0,Q.jsx)(`span`,{className:`break-all`,children:b(`custom-ui:studio.directory`,{path:c})})]})]})}function Jt(e,t,n){let r=e.i18n?.[n];return{label:r?.title||e.title||t,description:r?.description||e.description||``}}function Yt(e,t){if(!e||typeof e.properties!=`object`||!e.properties)return[];let n=new Set(Array.isArray(e.required)?e.required:[]),r=[];for(let[i,a]of Object.entries(e.properties)){if(!a||typeof a!=`object`)continue;let e={key:i,...Jt(a,i,t),required:n.has(i)};switch(a.type){case`string`:Array.isArray(a.enum)&&a.enum.length?r.push({...e,kind:a.enum.length<=4?`segmented`:`select`,options:[...a.enum],...a.default===void 0?{}:{defaultValue:a.default}}):r.push({...e,kind:a.format===`textarea`||a.format===`url`||a.format===`color`?a.format:`text`,maxLength:a.maxLength,...a.default===void 0?{}:{defaultValue:a.default}});break;case`number`:case`integer`:r.push({...e,kind:`number`,integer:a.type===`integer`,...a.minimum===void 0?{}:{min:a.minimum},...a.maximum===void 0?{}:{max:a.maximum},...a.step===void 0?{}:{step:a.step},unit:a.unit||``,...a.default===void 0?{}:{defaultValue:a.default}});break;case`boolean`:r.push({...e,kind:`switch`,...a.default===void 0?{}:{defaultValue:a.default}});break;case`array`:r.push({...e,kind:`tags`,maxItems:a.maxItems,itemMaxLength:a.itemMaxLength,...a.default===void 0?{}:{defaultValue:[...a.default]}})}}return r}function Xt(e,t){let n={};for(let r of e){let e=t&&Object.hasOwn(t,r.key)?t[r.key]:r.defaultValue;switch(r.kind){case`switch`:n[r.key]=e===!0;break;case`tags`:n[r.key]=Array.isArray(e)?e.filter(e=>typeof e==`string`):[];break;case`number`:n[r.key]=typeof e==`number`&&Number.isFinite(e)?String(e):``;break;default:n[r.key]=typeof e==`string`?e:``}}return n}function Zt(e,t){let n={};for(let r of e){let e=t[r.key];switch(r.kind){case`switch`:n[r.key]=e===!0;break;case`tags`:Array.isArray(e)&&e.length&&(n[r.key]=[...e]);break;case`number`:{let t=typeof e==`string`?e.trim():``;if(!t)break;let i=Number(t);n[r.key]=Number.isFinite(i)?i:t;break}case`segmented`:case`select`:typeof e==`string`&&e&&(n[r.key]=e);break;default:typeof e==`string`&&e&&(n[r.key]=e)}}return n}function Qt(e,t){let n=[...e];for(let e of t.split(/[,,\n]/)){let t=e.trim();t&&!n.includes(t)&&n.push(t)}return n}function $t(e){let t={};for(let n of e){let e=/^props(?:\.([^.]+))?/.exec(n.path||``),r=e?e[1]??``:``;Object.hasOwn(t,r)||(t[r]=n.params?{code:n.code,params:n.params}:{code:n.code})}return t}function en(e,t){let n=new Set([...Object.keys(e),...Object.keys(t)]);for(let r of n){let n=e[r],i=t[r];if(Array.isArray(n)||Array.isArray(i)){if(!Array.isArray(n)||!Array.isArray(i)||n.length!==i.length||n.some((e,t)=>e!==i[t]))return!1}else if(n!==i)return!1}return!0}function tn({id:e,label:t,description:n,error:r,required:i,children:a,inline:o=!1}){return(0,Q.jsxs)(`div`,{className:F(`flex min-w-0 gap-1.5`,o?`items-center justify-between`:`flex-col`),"data-props-field":e,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,Q.jsxs)(`label`,{htmlFor:e,className:`text-sm text-content`,children:[t,i&&(0,Q.jsx)(`span`,{className:`ml-0.5 text-content-muted`,children:`*`})]}),n&&(0,Q.jsx)(`span`,{id:`${e}-hint`,className:`text-xs text-content-muted`,children:n})]}),a,r&&(0,Q.jsx)(`p`,{id:`${e}-error`,role:`alert`,"data-props-error":!0,className:`text-xs text-danger`,children:r})]})}function nn({id:e,value:t,invalid:n,disabled:r,describedBy:i,onChange:a}){let{t:o}=u(),[s,c]=(0,Z.useState)(``),l=()=>{s.trim()&&(a(Qt(t,s)),c(``))};return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[t.length>0&&(0,Q.jsx)(`ul`,{className:`flex flex-wrap gap-1`,children:t.map(e=>(0,Q.jsxs)(`li`,{className:`inline-flex max-w-full items-center gap-1 rounded-sm border border-stroke-strong bg-solid py-0.5 pr-0.5 pl-2 text-xs`,children:[(0,Q.jsx)(`span`,{className:`truncate`,children:e}),(0,Q.jsx)(`button`,{type:`button`,disabled:r,"aria-label":o(`custom-ui:studio.removeTag`,{tag:e}),className:`grid size-5 place-items-center rounded-xs text-content-muted hover:bg-surface-hover hover:text-content`,onClick:()=>a(t.filter(t=>t!==e)),children:(0,Q.jsx)(he,{className:`size-3`})})]},e))}),(0,Q.jsx)(U,{id:e,value:s,disabled:r,"aria-invalid":n||void 0,"aria-describedby":i,placeholder:o(`custom-ui:studio.tagsPlaceholder`),onChange:e=>c(e.target.value),onBlur:l,onKeyDown:e=>{e.key===`Enter`||e.key===`,`?(e.preventDefault(),l()):e.key===`Backspace`&&!s&&t.length&&a(t.slice(0,-1))}})]})}function rn({field:e,id:t,value:n,error:r,disabled:i,onChange:a}){let{t:o}=u(),s=[e.description?`${t}-hint`:``,r?`${t}-error`:``].filter(Boolean).join(` `)||void 0,c={id:t,disabled:i,"aria-invalid":r?!0:void 0,"aria-describedby":s};switch(e.kind){case`switch`:return(0,Q.jsx)(De,{...c,checked:n===!0,onCheckedChange:e=>a(e)});case`segmented`:return(0,Q.jsx)(P,{size:`sm`,"aria-label":e.label,disabled:i,value:typeof n==`string`&&n?n:e.defaultValue??``,onValueChange:e=>a(e),options:e.options.map(e=>({value:e,label:e}))});case`select`:return(0,Q.jsxs)(Ee,{value:typeof n==`string`&&n?n:void 0,disabled:i,onValueChange:e=>a(e),children:[(0,Q.jsx)(Ce,{...c,className:`w-full`,children:(0,Q.jsx)(N,{placeholder:o(`custom-ui:studio.selectPlaceholder`)})}),(0,Q.jsx)(we,{children:e.options.map(e=>(0,Q.jsx)(Te,{value:e,children:e},e))})]});case`tags`:return(0,Q.jsx)(nn,{id:t,value:Array.isArray(n)?n:[],invalid:!!r,disabled:i,describedBy:s,onChange:a});case`textarea`:return(0,Q.jsx)(He,{...c,rows:3,maxLength:e.maxLength,value:typeof n==`string`?n:``,onChange:e=>a(e.target.value)});case`number`:return(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(U,{...c,inputMode:e.integer?`numeric`:`decimal`,value:typeof n==`string`?n:``,placeholder:e.defaultValue===void 0?void 0:String(e.defaultValue),className:`font-mono tabular-nums`,onChange:e=>a(e.target.value)}),e.unit&&(0,Q.jsx)(`span`,{className:`flex-none text-xs text-content-muted`,children:e.unit})]});case`color`:return(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`size-6 flex-none rounded-sm border border-stroke-strong`,style:{background:typeof n==`string`&&n?n:`transparent`}}),(0,Q.jsx)(U,{...c,maxLength:e.maxLength,value:typeof n==`string`?n:``,placeholder:`#RRGGBB`,className:`font-mono`,onChange:e=>a(e.target.value)})]});default:return(0,Q.jsx)(U,{...c,type:e.kind===`url`?`url`:`text`,maxLength:e.maxLength,value:typeof n==`string`?n:``,className:F(e.kind===`url`&&`font-mono`),onChange:e=>a(e.target.value)})}}function an({row:e,instance:t,notify:n,onPreview:r,onSave:i}){let{t:a,language:o}=u(),s=(0,Z.useId)(),c=e.manifest?.props,l=(0,Z.useMemo)(()=>Yt(c,o),[o,c]),d=(0,Z.useMemo)(()=>Xt(l,t?.props),[l,t]),[f,p]=(0,Z.useState)(d),[m,h]=(0,Z.useState)(t?.title??``),[_,v]=(0,Z.useState)({}),[b,x]=(0,Z.useState)(``),[S,C]=(0,Z.useState)(!1),w=!en(f,d)||m!==(t?.title??``);(0,Z.useEffect)(()=>{let e=yt(c,Zt(l,f));e.errors.length||r({title:m,props:e.value})},[l,r,c,m,f]);let T=(e,t)=>{p(n=>({...n,[e]:t})),v(t=>{if(!Object.hasOwn(t,e))return t;let n={...t};return delete n[e],n})},ee=async()=>{if(t){C(!0),v({}),x(``);try{await i(t,{title:m.trim(),props:Zt(l,f)}),n(a(`custom-ui:studio.propsSaved`))}catch(e){let t=g(e);if(t===`component_props_invalid`){let t=$t(y(e));v(t);let n=l.find(e=>Object.hasOwn(t,e.key));n&&document.getElementById(`${s}-${n.key}`)?.focus()}else t===`component_title_invalid`?x(q(t,a)):n(t?`${a(`custom-ui:studio.saveFailed`)} ${q(t,a)}`:a(`custom-ui:studio.saveFailed`))}finally{C(!1)}}},E=e=>{let t=_[e];return t?q(t.code,a,t.params):void 0},te=l.some(e=>e.kind===`url`||e.kind===`textarea`),D=`${s}-title`;return(0,Q.jsxs)(`form`,{"data-props-form":t?.instanceId??`preview`,className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),ee()},children:[!t&&(0,Q.jsx)(`p`,{className:`text-xs text-content-muted`,children:a(`custom-ui:studio.previewPropsHint`)}),(0,Q.jsx)(tn,{id:D,label:a(`custom-ui:studio.cardTitle`),error:b,children:(0,Q.jsx)(U,{id:D,value:m,maxLength:80,disabled:S,"aria-invalid":b?!0:void 0,placeholder:a(`custom-ui:studio.cardTitlePlaceholder`),onChange:e=>{h(e.target.value),x(``)}})}),l.map(e=>{let t=`${s}-${e.key}`,n=E(e.key);return(0,Q.jsx)(tn,{id:t,label:e.label,description:e.description,required:e.required,error:n,inline:e.kind===`switch`,children:(0,Q.jsx)(rn,{field:e,id:t,value:f[e.key]??``,error:n,disabled:S,onChange:t=>T(e.key,t)})},e.key)}),_[``]&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:q(_[``].code,a,_[``].params)}),te&&(0,Q.jsx)(`p`,{className:`text-xs text-content-muted`,children:a(`custom-ui:studio.propsPlaintext`)}),t&&(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(I,{type:`button`,size:`sm`,variant:`ghost`,disabled:S||!w,onClick:()=>{p(d),h(t.title),v({}),x(``)},children:a(`custom-ui:studio.propsReset`)}),(0,Q.jsx)(I,{type:`submit`,size:`sm`,disabled:S||!w,"data-props-save":!0,children:a(`custom-ui:studio.propsSave`)})]})]})}function on({title:e,aside:t,children:n,className:r}){return(0,Q.jsxs)(`section`,{className:F(`flex flex-col gap-2.5`,r),children:[(0,Q.jsxs)(`header`,{className:`flex items-baseline justify-between gap-2`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-content`,children:e}),t&&(0,Q.jsx)(`span`,{className:`text-xs text-content-muted`,children:t})]}),n]})}function sn(e,t){return f({queryKey:_.versions(e),queryFn:({signal:t})=>st(e,t),enabled:t&&!!e,retry:!1,staleTime:1e4,refetchOnWindowFocus:!1})}function cn(e,t){return f({queryKey:_.usage(e),queryFn:({signal:t})=>ot(e,t),enabled:t&&!!e,retry:!1,refetchInterval:15e3,refetchOnWindowFocus:!1})}function ln(e){return f({queryKey:_.trash(),queryFn:({signal:e})=>at(e),enabled:e,retry:!1,refetchOnWindowFocus:!1})}function un(e){return f({queryKey:_.staged(e),queryFn:({signal:t})=>Ye(e,t),enabled:!!e,retry:!1,refetchOnWindowFocus:!1,staleTime:1/0})}function dn(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.click(),window.setTimeout(()=>URL.revokeObjectURL(n),1e3)}function fn(e){let t=d(),{t:n}=u();return(0,Z.useMemo)(()=>{let r=()=>t.invalidateQueries({queryKey:_.all}),i=async(t,i)=>{try{let e=await t();return await r(),e}catch(t){let r=g(t);return e(r?`${i} ${q(r,n)}`:i),null}};return{notify:e,restoreVersion:async(t,r)=>{let a=await i(()=>wt(t.id,r),n(`custom-ui:versions.restoreFailed`));return a&&e(n(`custom-ui:versions.restored`,{n:r})),a},exportZip:async t=>{try{dn(await Ke(t.id),`${t.id}.zip`),e(n(`custom-ui:exporting.done`,{name:t.name}))}catch(t){let r=g(t);e(r?`${n(`custom-ui:exporting.failed`)} ${q(r,n)}`:n(`custom-ui:exporting.failed`))}},stageImport:e=>i(()=>ct(e),n(`custom-ui:importing.stageFailed`)),trust:async t=>{let r=await i(()=>ut(t),n(`custom-ui:importing.trustFailed`));return r&&e(r.replaced?n(`custom-ui:importing.replaced`,{name:r.component.name}):n(`custom-ui:importing.trusted`,{name:r.component.name})),r},discard:async t=>{let r=await i(()=>Nt(t).then(()=>!0),n(`custom-ui:importing.discardFailed`));return r&&e(n(`custom-ui:importing.discarded`)),r},restoreTrash:async t=>{let r=await i(()=>Ze(t.entry),n(`custom-ui:trash.restoreFailed`));return r&&e(n(`custom-ui:trash.restored`,{name:t.name})),r},purgeTrash:async t=>{let r=await i(()=>Je(t.entry).then(()=>!0),n(`custom-ui:trash.purgeFailed`));return r&&e(n(`custom-ui:trash.purged`,{name:t.name})),r},setRevoked:(e,t)=>i(()=>lt(e.id,t),n(`custom-ui:usage.revokeFailed`))}},[t,e,n])}var pn=(0,Z.lazy)(()=>t(()=>import(`./public-diff-BiBx9iwa.js`).then(e=>({default:e.InlineGitDiff})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18])));function mn({version:e}){let{t}=u();return!e.files.length&&!e.deleted.length?null:(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-wrap gap-1`,"data-version-files":!0,children:[e.files.map(e=>(0,Q.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1 rounded-sm border border-stroke bg-surface-subtle px-1.5 font-mono text-[11px] text-content-secondary`,children:[(0,Q.jsx)(`span`,{className:`truncate`,children:e.path}),e.added>0&&(0,Q.jsxs)(`span`,{className:`text-st-done tabular-nums`,children:[`+`,e.added]}),e.removed>0&&(0,Q.jsxs)(`span`,{className:`text-st-fail tabular-nums`,children:[`−`,e.removed]})]},e.path)),e.deleted.map(e=>(0,Q.jsx)(`span`,{className:`inline-flex max-w-full items-center gap-1 rounded-sm border border-stroke px-1.5 font-mono text-[11px] text-content-muted line-through`,title:t(`custom-ui:versions.deletedFile`),children:e},`deleted:${e}`))]})}function hn(e,t,n){return[Ct(e,t),e.summary,e.at?ze(e.at,n):``].filter(Boolean).join(` · `)}function gn({row:e,enabled:t,notify:n,actions:r}){let{t:i,language:a}=u(),o=sn(e.id,t),[s,c]=(0,Z.useState)(null),[l,d]=(0,Z.useState)(0),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(!1),_=(0,Z.useRef)(null),v=K(!!f);if(!t)return null;let y=o.data,b=async(t,r)=>{_.current=r,d(t.n);try{c({...await nt(e.id,t.n),n:t.n})}catch(e){let t=g(e);n(t?`${i(`custom-ui:versions.diffFailed`)} ${q(t,i)}`:i(`custom-ui:versions.diffFailed`))}finally{d(0)}},x=async()=>{if(!f)return;h(!0);let t=await r.restoreVersion(e,f.n);h(!1),t&&p(null)};return(0,Q.jsxs)(on,{title:i(`custom-ui:versions.title`),aside:y?i(`custom-ui:versions.keep`,{count:y.max}):void 0,children:[o.isPending?(0,Q.jsx)(`p`,{className:`text-xs text-content-muted`,children:i(`custom-ui:versions.loading`)}):o.error||!y?(0,Q.jsx)(`p`,{className:`text-xs text-content-muted`,children:i(`custom-ui:versions.failed`)}):(0,Q.jsxs)(`ol`,{"data-component-versions":!0,className:`overflow-hidden rounded-[var(--r-md)] border border-stroke`,children:[(0,Q.jsxs)(`li`,{"data-component-version":y.current.n,"data-version-current":!0,className:`flex min-w-0 flex-col gap-1 border-b border-stroke px-3 py-2 last:border-b-0`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2 text-sm`,children:[(0,Q.jsxs)(`strong`,{className:`font-mono font-medium tabular-nums`,children:[`v`,y.current.n]}),(0,Q.jsx)(`span`,{className:`text-xs text-content-secondary`,children:i(`custom-ui:versions.current`)}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-xs text-content-muted`,children:hn(y.current,i,a)})]}),(0,Q.jsx)(mn,{version:y.current})]}),y.versions.map(e=>(0,Q.jsxs)(`li`,{"data-component-version":e.n,className:`flex min-w-0 items-center gap-2 border-b border-stroke px-3 py-1.5 last:border-b-0`,children:[(0,Q.jsxs)(`strong`,{className:`flex-none font-mono text-sm font-medium tabular-nums`,children:[`v`,e.n]}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-content-muted`,children:hn(e,i,a)||i(`custom-ui:versions.noSummary`)}),(0,Q.jsxs)(I,{size:`xs`,variant:`ghost`,disabled:l===e.n,"data-version-compare":e.n,onClick:t=>void b(e,t.currentTarget),children:[(0,Q.jsx)(Ft,{}),i(`custom-ui:versions.compare`)]}),(0,Q.jsxs)(I,{size:`xs`,variant:`ghost`,"data-version-restore":e.n,onClick:t=>{_.current=t.currentTarget,p(e)},children:[(0,Q.jsx)(de,{}),i(`custom-ui:versions.restore`)]})]},e.n)),!y.versions.length&&(0,Q.jsx)(`li`,{className:`px-3 py-2 text-xs text-content-muted`,children:i(`custom-ui:versions.onlyCurrent`)})]}),(0,Q.jsx)(H,{open:!!f,onOpenChange:e=>!e&&!m&&p(null),children:(0,Q.jsxs)(R,{onCloseAutoFocus:v,children:[(0,Q.jsxs)(V,{children:[(0,Q.jsx)(z,{children:i(`custom-ui:versions.restoreTitle`,{n:f?.n??0})}),(0,Q.jsx)(L,{children:i(`custom-ui:versions.restoreHint`,{n:f?.n??0,next:(y?.current.n??0)+1,current:y?.current.n??0})})]}),(0,Q.jsxs)(B,{children:[(0,Q.jsx)(I,{variant:`outline`,disabled:m,onClick:()=>p(null),children:i(`custom-ui:studio.cancel`)}),(0,Q.jsx)(I,{disabled:m,"data-version-restore-confirm":!0,onClick:()=>void x(),children:i(`custom-ui:versions.restoreConfirm`,{n:f?.n??0})})]})]})}),(0,Q.jsx)(H,{open:!!s,onOpenChange:e=>!e&&c(null),children:(0,Q.jsxs)(R,{"data-version-diff":s?.n,scrollMode:`body`,className:`h-[min(760px,calc(100dvh-2rem))] max-w-[min(960px,calc(100vw-2rem))]`,onCloseAutoFocus:e=>{e.preventDefault(),_.current?.focus()},children:[(0,Q.jsxs)(V,{children:[(0,Q.jsx)(z,{children:i(`custom-ui:versions.diffTitle`,{n:s?.n??0,current:y?.current.n??0})}),(0,Q.jsx)(L,{children:s?.files.length?s.files.map(e=>e.path).join(` · `):i(`custom-ui:versions.noDiff`)})]}),(0,Q.jsx)(Ve,{className:`-mx-4 border-t border-stroke`,children:s&&s.files.length>0&&(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(pn,{diff:s.diff,truncated:s.truncated,mode:`unified`})})})]})})]})}var _n=[`overview-card`,`session-panel`,`feature-page`,`floating`],vn={"overview-card":It,"session-panel":le,"feature-page":te,floating:O};function yn(e,t){return e.source===`agent`?t(`custom-ui:studio.sourceAgent`):e.source===`template`?t(`custom-ui:studio.sourceTemplate`):e.source===`import`?t(`custom-ui:studio.sourceImport`):t(`custom-ui:studio.sourceLocal`)}function bn(e,t){let n=J(e.surface,t),r=e.size?`${n} ${e.size}`:n;return e.title?`${r} · ${e.title}`:r}function xn(e){let t=e.replace(/[\\/]+$/,``).split(/[\\/]/);return t[t.length-1]||e}function Sn({row:e,actions:t}){let{t:n,language:r}=u(),[i,a]=(0,Z.useState)(!1);return(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Q.jsx)(`span`,{className:`grid size-10 flex-none place-items-center rounded-[var(--r-md)] border border-stroke bg-solid text-content-secondary`,children:(0,Q.jsx)(O,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0})}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,Q.jsx)(`strong`,{className:`truncate text-[15px] font-semibold`,children:Y(e,r)}),(0,Q.jsx)(`span`,{className:`truncate text-xs text-content-muted`,children:[e.version?`v${e.version}`:``,e.kind===`broken`?n(`custom-ui:studio.statusBroken`):n(`custom-ui:studio.nativeComponent`),e.kind===`native`?yn(e,n):``].filter(Boolean).join(` · `)})]}),e.kind===`native`&&(0,Q.jsxs)(`label`,{className:`inline-flex flex-none items-center gap-2 text-xs text-content-secondary`,children:[n(`custom-ui:studio.enable`),(0,Q.jsx)(De,{checked:e.enabled,disabled:i,"aria-label":n(`custom-ui:studio.enable`),"data-component-enable":!0,onCheckedChange:async n=>{a(!0),await t.setEnabled(e,n),a(!1)}})]})]})}function Cn({row:e}){let{t}=u();return e.errors.length?(0,Q.jsx)(`ul`,{"data-component-errors":!0,className:`flex flex-col gap-1 rounded-[var(--r-md)] border border-stroke bg-surface-subtle px-3 py-2 text-xs text-content-secondary`,children:e.errors.map(e=>(0,Q.jsxs)(`li`,{className:`min-w-0 break-all`,children:[e.path&&(0,Q.jsx)(`code`,{className:`mr-1.5 font-mono`,children:e.path}),q(e.code,t,e.params)]},`${e.path}:${e.code}`))}):null}function wn({row:e,instances:t,selectedInstanceId:n,notify:r,actions:i,onSelectInstance:a,onPreview:o}){let{t:s}=u(),c=t.filter(t=>t.componentId===e.id),l=c.find(e=>e.instanceId===n)??null;return(0,Q.jsxs)(on,{title:s(`custom-ui:studio.props`),aside:s(`custom-ui:studio.propsPerInstance`),children:[c.length>0&&(0,Q.jsxs)(Ee,{value:l?.instanceId??`preview`,onValueChange:e=>a(e===`preview`?null:e),children:[(0,Q.jsx)(Ce,{className:`w-full`,"aria-label":s(`custom-ui:studio.editingInstance`),"data-props-instance":!0,children:(0,Q.jsx)(N,{})}),(0,Q.jsxs)(we,{children:[(0,Q.jsx)(Te,{value:`preview`,children:s(`custom-ui:studio.previewProps`)}),c.map(e=>(0,Q.jsxs)(Te,{value:e.instanceId,children:[bn(e,s),!e.enabled&&` · ${s(`custom-ui:studio.instanceClosed`)}`]},e.instanceId))]})]}),(0,Q.jsx)(an,{row:e,instance:l,notify:r,onPreview:o,onSave:i.saveProps},l?.instanceId??`preview:${e.id}`)]})}function Tn({row:e,usageEnabled:t=!1,canRevoke:n=!1,lifecycle:r}){let{t:i,language:a}=u(),o=e.manifest?.capabilities??{},s=cn(e.id,t),[c,l]=(0,Z.useState)(``),d=[`network`,`notify`,`sessions.read`,`sessions.open`,`storage`,`provider.request`].filter(e=>o[e]),f=[`sessions.read`,`notify`,`network`,`storage`,`provider.request`].filter(e=>!o[e]).map(e=>St(e,i)),p=r?.notify??(()=>void 0),m=async(t,n)=>{if(!r)return;l(t);let a=n?[...new Set([...e.revoked,t])]:e.revoked.filter(e=>e!==t),o=await r.setRevoked(e,a);l(``),o&&p(i(n?`custom-ui:usage.revoked`:`custom-ui:usage.unrevoked`,{capability:St(t,i)}))};return(0,Q.jsxs)(on,{title:i(`custom-ui:studio.capabilities`),children:[d.length?(0,Q.jsx)(`ul`,{"data-component-capabilities":!0,className:`overflow-hidden rounded-[var(--r-md)] border border-stroke`,children:d.map(l=>{let u=o[l],d=e.revoked.includes(l),f=s.data?.usage[l],p=l===`network`?Tt(o.network):l===`storage`?i(`custom-ui:studio.capStorageQuota`,{kb:o.storage?.quotaKb??0}):l===`provider.request`?`${o[`provider.request`]?.methods.join(`/`)} ${o[`provider.request`]?.paths.join(`, `)}`:``;return(0,Q.jsxs)(`li`,{"data-component-capability":l,"data-capability-revoked":d||void 0,className:`flex min-w-0 items-start gap-2 border-b border-stroke px-3 py-2 last:border-b-0`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2 text-sm`,children:[(0,Q.jsx)(`span`,{className:F(d&&`text-content-muted line-through`),children:St(l,i)}),p&&(0,Q.jsx)(`code`,{title:p,className:`min-w-0 truncate font-mono text-xs text-content-secondary`,children:p}),l===`network`&&o.network?.privateOrigins?.length?(0,Q.jsx)(We,{className:`flex-none text-content-secondary`,children:i(`custom-ui:studio.capNetworkPrivate`)}):null,d&&(0,Q.jsx)(We,{className:`flex-none text-content-secondary`,children:i(`custom-ui:usage.revokedBadge`)})]}),u?.reason&&(0,Q.jsx)(`span`,{className:`text-xs text-content-muted`,children:u.reason}),t&&(0,Q.jsx)(`span`,{className:`text-xs text-content-muted`,"data-capability-usage":!0,children:f?[i(`custom-ui:usage.last`,{time:ze(f.lastAt,a)}),f.target,i(`custom-ui:usage.today`,{count:f.today})].filter(Boolean).join(` · `):i(`custom-ui:usage.never`)})]}),n&&r&&(0,Q.jsx)(I,{size:`xs`,variant:`ghost`,disabled:c===l,"data-capability-toggle":l,className:`flex-none`,onClick:()=>void m(l,!d),children:i(d?`custom-ui:usage.restore`:`custom-ui:usage.revoke`)})]},l)})}):(0,Q.jsx)(`p`,{className:`text-xs text-content-muted`,children:i(`custom-ui:studio.capNone`)}),(0,Q.jsx)(`p`,{className:`text-xs text-content-muted`,children:i(`custom-ui:studio.capUndeclared`,{list:[...f,i(`custom-ui:studio.capFiles`),i(`custom-ui:studio.capClipboard`)].join(` · `)})}),(0,Q.jsx)(`p`,{className:`text-xs leading-relaxed text-content-muted`,children:i(`custom-ui:studio.capExplainer`)})]})}function En({value:e,disabled:t,onChange:n}){let{t:r}=u(),{projects:i}=Re(),a=i.filter(e=>e.cwd),o=e.type===`project`?e.cwd:`*`;return e.type===`project`&&!a.some(t=>t.cwd===e.cwd)&&a.push({key:e.cwd,cwd:e.cwd,count:0}),(0,Q.jsxs)(Ee,{value:o,disabled:t,onValueChange:e=>n(e===`*`?{type:`all`}:{type:`project`,cwd:e}),children:[(0,Q.jsx)(Ce,{size:`sm`,className:`w-full min-w-0`,"aria-label":r(`custom-ui:studio.scope`),"data-placement-scope":!0,children:(0,Q.jsx)(N,{})}),(0,Q.jsxs)(we,{children:[(0,Q.jsx)(Te,{value:`*`,children:r(`custom-ui:studio.scopeAll`)}),a.map(e=>(0,Q.jsx)(Te,{value:e.cwd,children:r(`custom-ui:studio.scopeProject`,{name:xn(e.cwd)})},e.cwd))]})]})}function Dn({row:e,instances:t,actions:n}){let{t:r}=u(),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(xt(e.manifest)),[c,l]=(0,Z.useState)({type:`all`}),[d,f]=(0,Z.useState)(null),p=K(d!==null),m=ht(e),h=t.filter(t=>t.componentId===e.id),g=e.manifest?.placements.find(e=>e.surface===`overview-card`)?.sizes??[`S`,`M`],_=async e=>{a(!0);try{await e()}finally{a(!1)}};return(0,Q.jsxs)(on,{title:r(`custom-ui:studio.placements`),aside:!m&&e.kind===`native`?r(`custom-ui:studio.placeNeedsEnable`):void 0,children:[(0,Q.jsx)(`ul`,{className:`grid grid-cols-1 gap-2 min-[360px]:grid-cols-2`,"data-component-placements":!0,children:_n.map(a=>{let u=vn[a],d=h.filter(e=>e.surface===a),p=d.filter(e=>e.enabled),v=p.length>0,y=rt(e.manifest,a),b=i||!m||!y,x=a===`overview-card`&&p.length===1?p[0]:null,S=()=>{v?p.length>1?f(p):_(()=>n.unplace(p[0])):_(()=>n.place(e,t,{surface:a,...a===`overview-card`?{size:o}:{},...a===`session-panel`?{scope:c}:{}}))},C=d[0];return(0,Q.jsxs)(`li`,{"data-placement-tile":a,"data-placement-checked":v||void 0,className:F(`flex min-w-0 flex-col gap-2 rounded-[var(--r-md)] border px-2.5 py-2`,v?`border-stroke-strong bg-surface-subtle`:`border-stroke`,!y&&`opacity-60`),children:[(0,Q.jsxs)(`label`,{className:`flex min-w-0 items-center gap-2 text-sm pointer-coarse:min-h-11`,children:[(0,Q.jsx)(ge,{checked:v,disabled:b,"aria-describedby":y?void 0:`placement-${a}-hint`,onCheckedChange:S}),(0,Q.jsx)(u,{className:`size-3.5 flex-none text-content-muted`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:J(a,r)}),a===`overview-card`&&p.length>1&&(0,Q.jsxs)(We,{className:`flex-none`,children:[`×`,p.length]})]}),!y&&(0,Q.jsx)(`span`,{id:`placement-${a}-hint`,className:`text-xs text-content-muted`,children:r(`custom-ui:studio.placeUndeclared`)}),y&&a===`overview-card`&&(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[g.length>1&&(0,Q.jsx)(P,{size:`sm`,"aria-label":r(`custom-ui:studio.cardSize`),disabled:b,value:x?.size??o,onValueChange:e=>{s(e),x&&_(()=>n.patchInstance(x,{size:e}))},options:g.map(e=>({value:e,label:e}))}),v&&(0,Q.jsx)(I,{size:`xs`,variant:`ghost`,disabled:b,title:r(`custom-ui:studio.addCard`),"aria-label":r(`custom-ui:studio.addCard`),onClick:()=>void _(()=>n.place(e,t,{surface:a,size:o})),children:(0,Q.jsx)(ue,{})})]}),y&&a===`session-panel`&&(0,Q.jsx)(En,{value:C?.scope??c,disabled:b,onChange:e=>{l(e),C&&_(()=>n.patchInstance(C,{scope:e}))}}),y&&a===`floating`&&(0,Q.jsx)(`span`,{className:`text-xs text-content-muted`,children:r(`custom-ui:studio.floatingPhoneHint`)})]},a)})}),(0,Q.jsx)(H,{open:d!==null,onOpenChange:e=>!e&&f(null),children:(0,Q.jsxs)(R,{onCloseAutoFocus:p,children:[(0,Q.jsxs)(V,{children:[(0,Q.jsx)(z,{children:r(`custom-ui:studio.unplaceAllTitle`,{count:d?.length??0})}),(0,Q.jsx)(L,{children:r(`custom-ui:studio.unplaceAllHint`)})]}),(0,Q.jsxs)(B,{children:[(0,Q.jsx)(I,{variant:`outline`,onClick:()=>f(null),children:r(`custom-ui:studio.cancel`)}),(0,Q.jsx)(I,{variant:`destructive`,disabled:i,onClick:()=>{let e=d??[];f(null),_(async()=>{for(let t of e)await n.unplace(t)})},children:r(`custom-ui:studio.unplaceAll`)})]})]})})]})}function On({row:e,instances:t,actions:n,className:r}){let{t:i}=u(),a=ht(e);return(0,Q.jsxs)(xe,{children:[(0,Q.jsx)(ye,{asChild:!0,children:(0,Q.jsxs)(I,{size:`sm`,disabled:!a,"data-component-place":!0,className:r,children:[i(`custom-ui:studio.placeTo`),(0,Q.jsx)(re,{})]})}),(0,Q.jsx)(be,{align:`start`,className:`w-56`,children:_n.map(r=>{let a=rt(e.manifest,r),o=r!==`overview-card`&&t.some(t=>t.componentId===e.id&&t.surface===r&&t.enabled);return(0,Q.jsxs)(M,{disabled:!a||o,"data-component-place-item":r,onSelect:()=>void n.place(e,t,{surface:r,...r===`overview-card`?{size:xt(e.manifest)}:{}}),children:[J(r,i),(0,Q.jsx)(`span`,{className:`ml-auto text-xs text-content-muted`,children:a?o?i(`custom-ui:studio.placed`):``:i(`custom-ui:studio.placeUndeclaredShort`)})]},r)})})]})}function kn({row:e,actions:t,onDeleted:n,variant:r=`menu`}){let{t:i,language:a}=u(),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),d=(0,Z.useRef)(null),f=K(o,d),p=Y(e,a),m=async()=>{l(!0);let r=await t.remove(e);l(!1),r&&(s(!1),n())};return(0,Q.jsxs)(Q.Fragment,{children:[r===`menu`?(0,Q.jsxs)(xe,{children:[(0,Q.jsx)(ye,{asChild:!0,children:(0,Q.jsx)(I,{ref:d,size:`icon-sm`,variant:`ghost`,"aria-label":i(`custom-ui:studio.more`),"data-component-more":!0,children:(0,Q.jsx)(ce,{})})}),(0,Q.jsx)(be,{align:`end`,children:(0,Q.jsxs)(M,{variant:`destructive`,"data-component-delete":!0,onSelect:()=>s(!0),children:[(0,Q.jsx)(j,{}),i(`custom-ui:studio.deleteComponent`)]})})]}):(0,Q.jsxs)(I,{variant:`ghost`,size:`sm`,className:`text-danger`,"data-component-delete":!0,onClick:()=>s(!0),children:[(0,Q.jsx)(j,{}),i(`custom-ui:studio.deleteComponent`)]}),(0,Q.jsx)(H,{open:o,onOpenChange:e=>!e&&!c&&s(!1),children:(0,Q.jsxs)(R,{onCloseAutoFocus:f,children:[(0,Q.jsxs)(V,{children:[(0,Q.jsx)(z,{children:i(`custom-ui:studio.deleteTitle`,{name:p})}),(0,Q.jsx)(L,{children:i(`custom-ui:studio.deleteHint`)})]}),(0,Q.jsxs)(B,{children:[(0,Q.jsx)(I,{variant:`outline`,disabled:c,onClick:()=>s(!1),children:i(`custom-ui:studio.cancel`)}),(0,Q.jsx)(I,{variant:`destructive`,disabled:c,"data-component-delete-confirm":!0,onClick:()=>void m(),children:i(`custom-ui:studio.delete`)})]})]})})]})}function An({row:e,lifecycle:t,className:n}){let{t:r}=u(),[i,a]=(0,Z.useState)(!1);return(0,Q.jsxs)(I,{size:`sm`,variant:`secondary`,disabled:i,"data-component-export":!0,className:n,onClick:async()=>{a(!0),await t.exportZip(e),a(!1)},children:[(0,Q.jsx)(se,{}),r(`custom-ui:exporting.button`)]})}function jn({row:e,instances:t,selectedInstanceId:n,canDelete:r,features:i,notify:a,actions:o,lifecycle:s,onSelectInstance:c,onPreview:l,onViewSource:d,onDeleted:f}){let{t:p}=u(),m=e.kind===`native`&&e.status===`ready`&&!!e.manifest;return(0,Q.jsxs)(`div`,{"data-studio-settings":!0,className:`flex h-full min-h-0 flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-5 overflow-y-auto px-4 pt-4 pb-5`,children:[(0,Q.jsx)(Sn,{row:e,actions:o}),(0,Q.jsx)(Cn,{row:e}),m&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(wn,{row:e,instances:t,selectedInstanceId:n,notify:a,actions:o,onSelectInstance:c,onPreview:l}),(0,Q.jsx)(Tn,{row:e,usageEnabled:i.usage,canRevoke:i.revoke,lifecycle:s}),(0,Q.jsx)(Dn,{row:e,instances:t,actions:o})]}),e.kind===`native`&&(0,Q.jsx)(gn,{row:e,enabled:i.versions,notify:a,actions:s})]}),(0,Q.jsxs)(`footer`,{className:`flex flex-none items-center gap-2 border-t border-stroke bg-panel px-4 py-2.5`,children:[m&&(0,Q.jsx)(On,{row:e,instances:t,actions:o}),(0,Q.jsxs)(I,{size:`sm`,variant:`secondary`,onClick:d,"data-component-view-source":!0,children:[(0,Q.jsx)(k,{}),p(`custom-ui:studio.viewSource`)]}),i.export&&e.kind===`native`&&(0,Q.jsx)(An,{row:e,lifecycle:s}),r&&(0,Q.jsx)(`span`,{className:`ml-auto`,children:(0,Q.jsx)(kn,{row:e,actions:o,onDeleted:f})})]})]})}var Mn=(0,Z.createContext)({code:``}),Nn=({code:e,language:t,className:n,showLineNumbers:r=!1,children:i,...a})=>{let o={code:e};return(0,Q.jsx)(Mn.Provider,{value:o,children:(0,Q.jsxs)(`div`,{className:F(`group relative w-full overflow-hidden rounded-md border bg-background text-foreground`,n),"data-language":t,...a,children:[(0,Q.jsx)(`div`,{className:`relative overflow-auto`,children:(0,Q.jsx)(`pre`,{className:`m-0 p-4 text-sm leading-relaxed`,children:(0,Q.jsx)(`code`,{className:`font-mono whitespace-pre`,children:e})})}),i]})})},Pn=({onCopy:e,onError:t,timeout:n=2e3,children:r,className:i,...a})=>{let[o,s]=(0,Z.useState)(!1),{code:c}=(0,Z.useContext)(Mn),l=async()=>{if(typeof window>`u`||!navigator?.clipboard?.writeText){t?.(Error(`Clipboard API not available`));return}try{await navigator.clipboard.writeText(c),s(!0),e?.(),setTimeout(()=>s(!1),n)}catch(e){t?.(e)}},u=o?ne:oe;return(0,Q.jsx)(I,{className:F(`shrink-0`,i),onClick:l,size:`icon`,variant:`ghost`,...a,children:r??(0,Q.jsx)(u,{size:14})})},Fn=(0,Z.lazy)(()=>t(()=>import(`./public-diff-BiBx9iwa.js`).then(e=>({default:e.InlineGitDiff})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]))),In=/\.(?:m?js|css|json|svg|md|txt)$/i;function Ln(e){return/\.m?js$/i.test(e)?`javascript`:/\.css$/i.test(e)?`css`:/\.json$/i.test(e)?`json`:/\.svg$/i.test(e)?`xml`:`text`}function Rn({enabled:e,lifecycle:t,onStaged:n,className:r}){let{t:i}=u(),a=(0,Z.useRef)(null),[o,s]=(0,Z.useState)(!1);return!e||!t?(0,Q.jsxs)(I,{size:`sm`,variant:`ghost`,"aria-disabled":`true`,title:i(`custom-ui:importing.unsupported`),"aria-label":`${i(`custom-ui:studio.importZip`)} · ${i(`custom-ui:importing.unsupported`)}`,"data-component-import":!0,className:r,onClick:e=>e.preventDefault(),children:[(0,Q.jsx)(Pt,{}),i(`custom-ui:studio.importZip`)]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(I,{size:`sm`,variant:`ghost`,disabled:o,"data-component-import":!0,className:r,onClick:()=>a.current?.click(),children:[(0,Q.jsx)(Pt,{}),i(o?`custom-ui:importing.staging`:`custom-ui:studio.importZip`)]}),(0,Q.jsx)(`input`,{ref:a,type:`file`,accept:`.zip,application/zip`,hidden:!0,"data-component-import-input":!0,onChange:async e=>{let r=e.target.files?.[0];if(e.target.value=``,!r)return;s(!0);let i=await t.stageImport(r);s(!1),i&&n?.(i)}})]})}function zn({staged:e,phone:t=!1,onReview:n}){let{t:r}=u();return(0,Q.jsxs)(`div`,{"data-staged-row":e.stageId,className:F(`flex flex-col gap-1.5 rounded-[var(--r-md)] border border-dashed border-st-attn-border bg-st-attn-soft px-2.5 py-2`,t&&`px-3.5 py-3`),children:[(0,Q.jsxs)(`p`,{className:`flex min-w-0 items-center gap-1.5 text-sm`,children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 flex-none rounded-full bg-st-attn-fill`}),(0,Q.jsx)(`strong`,{className:`min-w-0 truncate font-medium`,children:e.fileName}),(0,Q.jsx)(`span`,{className:`flex-none text-xs text-content-muted`,children:r(`custom-ui:importing.shared`)})]}),(0,Q.jsx)(`p`,{className:`text-xs text-content-secondary`,children:r(`custom-ui:importing.needsReview`)}),(0,Q.jsxs)(I,{size:t?`sm`:`xs`,variant:`secondary`,className:F(`w-fit`,t&&`min-h-11`),"data-staged-review":e.stageId,onClick:n,children:[(0,Q.jsx)(pe,{}),r(`custom-ui:importing.review`)]})]})}function Bn(e){return e===`danger`?`text-st-fail`:`text-content-secondary`}function Vn(e,t){switch(e){case`fetch`:return t(`custom-ui:scan.ruleFetch`);case`xhr`:return t(`custom-ui:scan.ruleXhr`);case`websocket`:return t(`custom-ui:scan.ruleWebsocket`);case`eval`:return t(`custom-ui:scan.ruleEval`);case`function`:return t(`custom-ui:scan.ruleFunction`);case`cookie`:return t(`custom-ui:scan.ruleCookie`);case`local-storage`:return t(`custom-ui:scan.ruleLocalStorage`);case`app-api`:return t(`custom-ui:scan.ruleAppApi`);case`dynamic-import`:return t(`custom-ui:scan.ruleDynamicImport`);default:return e}}function Hn({scan:e}){let{t}=u();if(e.status!==`ok`)return(0,Q.jsx)(`p`,{className:`text-xs text-content-muted`,children:t(`custom-ui:scan.unsupported`)});let n=!e.findings.length&&!e.summary.undeclaredHosts;return(0,Q.jsxs)(`div`,{"data-component-scan":!0,className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`p`,{className:F(`text-xs`,e.summary.danger||e.summary.undeclaredHosts?`text-st-fail`:`text-content-secondary`),"data-scan-summary":!0,children:n?t(`custom-ui:scan.clean`):t(`custom-ui:scan.summary`,{danger:e.summary.danger,warn:e.summary.warn+e.summary.info,hosts:e.summary.undeclaredHosts})}),e.hosts.length>0&&(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5 text-xs`,"data-scan-hosts":!0,children:e.hosts.map(e=>(0,Q.jsxs)(`li`,{"data-scan-host":e.host,"data-declared":e.declared,className:`flex min-w-0 items-baseline gap-2`,children:[(0,Q.jsx)(`code`,{className:F(`min-w-0 truncate font-mono`,e.declared?`text-content-secondary`:`text-st-fail`),children:e.host}),(0,Q.jsx)(`span`,{className:e.declared?`text-content-muted`:`text-st-fail`,children:e.declared?t(`custom-ui:scan.hostDeclared`):t(`custom-ui:scan.hostUndeclared`)})]},e.host))}),e.findings.length>0&&(0,Q.jsx)(`ul`,{className:`flex flex-col gap-1.5`,"data-scan-findings":!0,children:e.findings.map((e,n)=>(0,Q.jsxs)(`li`,{"data-scan-finding":e.rule,"data-severity":e.severity,className:`flex min-w-0 flex-col gap-0.5 text-xs`,children:[(0,Q.jsxs)(`span`,{className:F(`flex items-center gap-1.5`,Bn(e.severity)),children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:F(`size-1.5 flex-none rounded-full`,e.severity===`danger`?`bg-st-fail`:`bg-content-muted`)}),Vn(e.rule,t),(0,Q.jsxs)(`code`,{className:`ml-auto flex-none font-mono text-content-muted`,children:[e.file,`:`,e.line]})]}),e.excerpt&&(0,Q.jsx)(`code`,{className:`block truncate rounded-sm bg-surface-subtle px-1.5 py-0.5 font-mono text-[11px] text-content-secondary`,children:e.excerpt})]},`${e.file}:${e.line}:${e.rule}:${n}`))}),e.truncated&&(0,Q.jsx)(`p`,{className:`text-xs text-content-muted`,children:t(`custom-ui:scan.truncated`)})]})}function Un({title:e,children:t}){return(0,Q.jsxs)(`section`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`h3`,{className:`text-xs font-semibold text-content-secondary`,children:e}),t]})}function Wn({stageId:e,lifecycle:t,onClose:n,onTrusted:r}){let{t:i}=u(),a=un(e),[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(``),[d,p]=(0,Z.useState)(!1),m=(0,Z.useId)(),h=a.data,g=(h?.files??[]).filter(e=>In.test(e.path)),v=h?.manifest?.entry??``,y=g.find(e=>e.path===o)?.path??g.find(e=>e.path===v)?.path??g[0]?.path??``;(0,Z.useEffect)(()=>{s(``),p(!1)},[e]);let b=f({queryKey:[..._.staged(e),`file`,y],queryFn:({signal:t})=>Qe(e,y,t),enabled:!!(e&&y),retry:!1,staleTime:1/0,refetchOnWindowFocus:!1}),x=h?.staged,S=h?.manifest?.capabilities??{},C=[`network`,`notify`,`sessions.read`,`sessions.open`,`storage`,`provider.request`].filter(e=>S[e]),w=async()=>{l(`trust`);let n=await t.trust(e);l(``),n&&r(n.component)},T=async()=>{l(`discard`);let r=await t.discard(e);l(``),r&&n()};return(0,Q.jsx)(H,{open:!!e,onOpenChange:e=>!e&&!c&&n(),children:(0,Q.jsxs)(R,{"data-trust-dialog":e,scrollMode:`body`,className:`h-[min(820px,calc(100dvh-2rem))] max-w-[min(1040px,calc(100vw-2rem))]`,children:[(0,Q.jsxs)(V,{children:[(0,Q.jsx)(z,{children:x?i(`custom-ui:importing.reviewTitle`,{name:h?.manifest?.name||x.name,version:x.version?` v${x.version}`:``}):i(`custom-ui:importing.reviewLoading`)}),(0,Q.jsx)(L,{className:`flex flex-wrap gap-x-2 gap-y-0.5 font-mono text-xs`,children:x&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{children:x.fileName}),(0,Q.jsx)(`span`,{children:Be(x.bytes)}),(0,Q.jsxs)(`span`,{className:`break-all`,"data-trust-sha256":!0,children:[`sha256 `,x.sha256]})]})})]}),(0,Q.jsx)(Ve,{className:`-mx-4 border-y border-stroke`,children:a.isPending?(0,Q.jsx)(`p`,{className:`p-4 text-sm text-content-muted`,children:i(`custom-ui:importing.reviewLoading`)}):a.error||!h?(0,Q.jsx)(`p`,{className:`p-4 text-sm text-content-muted`,children:i(`custom-ui:importing.reviewFailed`)}):(0,Q.jsxs)(`div`,{className:`grid min-h-full grid-cols-1 md:grid-cols-[minmax(0,1fr)_320px]`,children:[(0,Q.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-col gap-2 p-4 md:border-r md:border-stroke`,children:[(0,Q.jsx)(`div`,{role:`group`,id:m,"aria-label":i(`custom-ui:importing.files`),className:`flex flex-wrap gap-1`,"data-trust-files":!0,children:h.files.map(e=>In.test(e.path)?(0,Q.jsxs)(Ue,{size:`sm`,"aria-pressed":e.path===y,"data-trust-file":e.path,className:`font-mono`,onClick:()=>{p(!1),s(e.path)},children:[e.path,(0,Q.jsx)(`span`,{className:`text-content-muted`,children:Be(e.size)})]},e.path):(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-1.5 font-mono text-xs text-content-muted`,children:[e.path,` · `,Be(e.size)]},e.path))}),d&&h.diff?(0,Q.jsx)(`div`,{"data-trust-diff-view":!0,className:`min-h-[240px] flex-1 overflow-auto rounded-[var(--r-md)] border border-stroke`,children:(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(Fn,{diff:h.diff.diff,truncated:h.diff.truncated,mode:`unified`})})}):y&&b.data?(0,Q.jsx)(Nn,{code:b.data.content,language:Ln(y),"data-trust-source":y,className:`min-h-[240px] flex-1 overflow-auto bg-code [&>div]:h-full`}):(0,Q.jsx)(`p`,{className:`text-xs text-content-muted`,children:b.isPending&&y?i(`custom-ui:studio.sourceLoading`):i(`custom-ui:studio.sourceUnavailable`)}),b.data?.truncated&&(0,Q.jsx)(`p`,{className:`text-xs text-content-muted`,children:i(`custom-ui:importing.truncated`)})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4 p-4`,children:[h.installed&&(0,Q.jsxs)(`div`,{"data-trust-replaces":!0,className:`flex flex-col gap-1.5 rounded-[var(--r-md)] border border-stroke bg-surface-subtle px-3 py-2 text-xs text-content-secondary`,children:[(0,Q.jsx)(`p`,{children:i(`custom-ui:importing.replaces`,{version:h.installed.version?`v${h.installed.version}`:``})}),h.diff&&h.diff.files.length>0&&(0,Q.jsxs)(I,{size:`xs`,variant:`secondary`,className:`w-fit`,"data-trust-diff":!0,"aria-pressed":d,onClick:()=>p(e=>!e),children:[(0,Q.jsx)(Ft,{}),d?i(`custom-ui:importing.hideDiff`):i(`custom-ui:importing.viewDiff`,{count:h.diff.files.length})]})]}),(0,Q.jsx)(Un,{title:i(`custom-ui:importing.manifest`),children:h.manifest?(0,Q.jsxs)(`dl`,{className:`grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-0.5 text-xs`,children:[(0,Q.jsx)(`dt`,{className:`text-content-muted`,children:`id`}),(0,Q.jsx)(`dd`,{className:`truncate font-mono`,children:h.manifest.id}),(0,Q.jsx)(`dt`,{className:`text-content-muted`,children:i(`custom-ui:importing.entry`)}),(0,Q.jsx)(`dd`,{className:`truncate font-mono`,children:h.manifest.entry}),(0,Q.jsx)(`dt`,{className:`text-content-muted`,children:i(`custom-ui:studio.placements`)}),(0,Q.jsx)(`dd`,{children:h.manifest.placements.map(e=>J(e.surface,i)).join(` · `)||`—`})]}):(0,Q.jsx)(`p`,{className:`text-xs text-st-fail`,children:i(`custom-ui:importing.manifestInvalid`)})}),(0,Q.jsx)(Un,{title:i(`custom-ui:importing.capabilities`),children:C.length?(0,Q.jsx)(`ul`,{className:`flex flex-col gap-1 text-xs`,"data-trust-capabilities":!0,children:C.map(e=>(0,Q.jsxs)(`li`,{className:`flex min-w-0 flex-col`,children:[(0,Q.jsxs)(`span`,{children:[St(e,i),e===`provider.request`&&(0,Q.jsxs)(`code`,{className:`ml-1 break-all font-mono text-content-secondary`,children:[S[`provider.request`]?.methods.join(`/`),` `,S[`provider.request`]?.paths.join(`, `)]}),e===`network`&&(0,Q.jsx)(`code`,{className:`ml-1.5 break-all font-mono text-content-secondary`,children:Tt(S.network)})]}),e===`network`&&(S.network?.privateOrigins?.length??0)>0&&(0,Q.jsx)(`span`,{className:`text-content-secondary`,"data-trust-private-network":!0,children:i(`custom-ui:importing.privateNetwork`)}),S[e]?.reason&&(0,Q.jsx)(`span`,{className:`text-content-muted`,children:S[e]?.reason})]},e))}):(0,Q.jsx)(`p`,{className:`text-xs text-content-muted`,children:i(`custom-ui:studio.capNone`)})}),(0,Q.jsx)(Un,{title:i(`custom-ui:importing.scan`),children:(0,Q.jsx)(Hn,{scan:h.scan})}),(0,Q.jsx)(`p`,{className:`text-xs leading-relaxed text-content-muted`,children:i(`custom-ui:importing.explainer`)})]})]})}),(0,Q.jsxs)(B,{className:`flex-row flex-wrap items-center gap-2 sm:justify-between`,children:[(0,Q.jsx)(I,{variant:`ghost`,size:`sm`,className:`text-danger`,disabled:!!c,"data-trust-discard":!0,onClick:()=>void T(),children:i(`custom-ui:importing.discard`)}),(0,Q.jsxs)(`span`,{className:`ml-auto flex gap-2`,children:[(0,Q.jsx)(I,{variant:`outline`,size:`sm`,disabled:!!c,onClick:n,children:i(`custom-ui:studio.cancel`)}),(0,Q.jsx)(I,{size:`sm`,disabled:!!c||!h?.manifest,"data-trust-confirm":!0,onClick:()=>void w(),children:i(`custom-ui:importing.trust`)})]})]})]})})}var Gn=864e5;function Kn({enabled:e,lifecycle:t,onRestored:n,className:r}){let{t:i,language:a}=u(),o=ln(e),[s,c]=(0,Z.useState)(!1),[l,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(null);if(!e)return null;let m=o.data?.entries??[],h=async e=>{d(e.entry);let r=await t.restoreTrash(e);d(``),r&&(c(!1),n?.(r.component))},g=async()=>{if(!f)return;d(f.entry);let e=await t.purgeTrash(f);d(``),e&&p(null)},_=e=>{if(!e.expiresAt)return i(`custom-ui:trash.keptLegacy`);let t=Math.max(0,Math.ceil((Date.parse(e.expiresAt)-Date.now())/Gn));return i(`custom-ui:trash.expiresIn`,{count:t})};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(I,{size:`xs`,variant:`ghost`,"data-component-trash":!0,className:r,onClick:()=>c(!0),children:[(0,Q.jsx)(j,{}),i(`custom-ui:trash.button`),m.length>0&&(0,Q.jsx)(`span`,{className:`tabular-nums`,children:m.length})]}),(0,Q.jsx)(H,{open:s,onOpenChange:e=>!l&&c(e),children:(0,Q.jsxs)(R,{size:`wide`,scrollMode:`body`,"data-trash-dialog":!0,children:[(0,Q.jsxs)(V,{children:[(0,Q.jsx)(z,{children:i(`custom-ui:trash.title`)}),(0,Q.jsx)(L,{children:i(`custom-ui:trash.hint`,{days:o.data?.retentionDays??7})})]}),(0,Q.jsx)(Ve,{className:`-mx-4 border-t border-stroke`,children:o.isPending?(0,Q.jsx)(`p`,{className:`p-4 text-sm text-content-muted`,children:i(`custom-ui:trash.loading`)}):o.error?(0,Q.jsx)(`p`,{className:`p-4 text-sm text-content-muted`,children:i(`custom-ui:trash.failed`)}):m.length?(0,Q.jsx)(`ul`,{className:`flex flex-col`,children:m.map(e=>(0,Q.jsxs)(`li`,{"data-trash-entry":e.entry,className:`flex min-w-0 items-center gap-3 border-b border-stroke px-4 py-2.5 last:border-b-0`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-1.5 text-sm`,children:[(0,Q.jsx)(`strong`,{className:`min-w-0 truncate font-medium`,children:e.name}),e.version&&(0,Q.jsxs)(`span`,{className:`flex-none font-mono text-xs text-content-muted`,children:[`v`,e.version]})]}),(0,Q.jsx)(`span`,{className:`truncate text-xs text-content-muted`,children:[e.reason===`legacy-retired`?i(`custom-ui:trash.legacyRetired`):i(`custom-ui:trash.deletedAt`,{time:ze(e.deletedAt,a)}),e.instances?i(`custom-ui:trash.instances`,{count:e.instances}):``,_(e)].filter(Boolean).join(` · `)})]}),e.kind===`native`&&(0,Q.jsx)(I,{size:`xs`,variant:`secondary`,disabled:!!l,"data-trash-restore":e.entry,onClick:()=>void h(e),children:i(`custom-ui:trash.restore`)}),(0,Q.jsx)(I,{size:`xs`,variant:`ghost`,className:`text-danger`,disabled:!!l,"data-trash-purge":e.entry,onClick:()=>p(e),children:i(`custom-ui:trash.purge`)})]},e.entry))}):(0,Q.jsx)(`p`,{className:`p-4 text-sm text-content-muted`,children:i(`custom-ui:trash.empty`)})})]})}),(0,Q.jsx)(H,{open:!!f,onOpenChange:e=>!e&&!l&&p(null),children:(0,Q.jsxs)(R,{size:`compact`,surface:`confirmation`,children:[(0,Q.jsxs)(V,{children:[(0,Q.jsx)(z,{children:i(`custom-ui:trash.purgeTitle`,{name:f?.name??``})}),(0,Q.jsx)(L,{children:i(`custom-ui:trash.purgeHint`)})]}),(0,Q.jsxs)(B,{children:[(0,Q.jsx)(I,{variant:`outline`,disabled:!!l,onClick:()=>p(null),children:i(`custom-ui:studio.cancel`)}),(0,Q.jsx)(I,{variant:`destructive`,disabled:!!l,"data-trash-purge-confirm":!0,onClick:()=>void g(),children:i(`custom-ui:trash.purgeConfirm`)})]})]})})]})}function qn(e){let t=et(),[n,r]=(0,Z.useState)(()=>t.read(e));return(0,Z.useEffect)(()=>(r(t.read(e)),t.subscribe(n=>{n===e&&r(t.read(e))})),[t,e]),n}function Jn(e){let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleTimeString(void 0,{hour12:!1})}function Yn({at:e,level:t,kind:n,message:r,stack:i}){return(0,Q.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-0.5 border-b border-stroke px-3 py-2 last:border-b-0`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2 font-mono text-xs`,children:[(0,Q.jsx)(`span`,{className:`flex-none text-content-muted tabular-nums`,children:Jn(e)}),(0,Q.jsx)(`span`,{className:F(`flex-none uppercase`,t===`error`?`text-st-fail font-medium`:`text-content-muted`),children:t}),(0,Q.jsx)(`span`,{className:`flex-none text-content-muted`,children:n}),(0,Q.jsx)(`span`,{className:`min-w-0 break-all text-content`,children:r})]}),i&&(0,Q.jsx)(`pre`,{className:`max-h-28 overflow-auto font-mono text-xs whitespace-pre-wrap text-content-muted`,children:i})]})}function Xn({componentId:e,errors:t,errorsFailed:n}){let{t:r}=u(),i=et(),a=qn(e),o=t?.entries??[];return(0,Q.jsxs)(`div`,{"data-studio-logs":!0,className:`flex min-h-0 min-w-0 flex-1 flex-col gap-3 overflow-y-auto`,children:[(0,Q.jsxs)(`section`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsxs)(`header`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`h3`,{className:`text-xs font-medium text-content-secondary`,children:r(`custom-ui:studio.logsLocal`)}),a.length>0&&(0,Q.jsx)(I,{size:`xs`,variant:`ghost`,onClick:()=>i.clear(e),children:r(`custom-ui:studio.logsClear`)})]}),a.length?(0,Q.jsx)(`ul`,{className:`overflow-hidden rounded-[var(--r-md)] border border-stroke bg-panel`,children:[...a].reverse().map((e,t)=>(0,Q.jsx)(Yn,{...e},`${e.at}:${t}`))}):(0,Q.jsx)(`p`,{className:`text-xs text-content-muted`,children:r(`custom-ui:studio.logsLocalEmpty`)})]}),(0,Q.jsxs)(`section`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsxs)(`h3`,{className:`text-xs font-medium text-content-secondary`,children:[r(`custom-ui:studio.logsRuntime`),t&&t.dropped>0&&(0,Q.jsx)(`span`,{className:`ml-2 font-normal text-content-muted`,children:r(`custom-ui:studio.logsDropped`,{count:t.dropped})})]}),n?(0,Q.jsx)(`p`,{className:`text-xs text-content-muted`,children:r(`custom-ui:studio.logsRuntimeFailed`)}):o.length?(0,Q.jsx)(`ul`,{"data-studio-runtime-logs":!0,className:`overflow-hidden rounded-[var(--r-md)] border border-stroke bg-panel`,children:[...o].reverse().map((e,t)=>(0,Q.jsx)(Yn,{...e},`${e.at}:${t}`))}):(0,Q.jsx)(`p`,{className:`text-xs text-content-muted`,children:r(`custom-ui:studio.logsRuntimeEmpty`)})]})]})}function Zn(e,t){let n=d(),r=f({queryKey:_.errors(e),queryFn:({signal:t})=>b(e,t),enabled:t,retry:!1,refetchInterval:15e3,refetchOnWindowFocus:!1});return(0,Z.useEffect)(()=>{if(!t)return;let r=null,i=et().subscribe(t=>{t===e&&r===null&&(r=window.setTimeout(()=>{r=null,n.invalidateQueries({queryKey:_.errors(e)})},800))});return()=>{i(),r!==null&&window.clearTimeout(r)}},[n,e,t]),r}var Qn=new Map;function $n({sessionId:e,onOpen:t}){let{t:n}=u(),r=Re({doneWindow:`today`}).all.find(t=>t.id===e)?.lane,i=n(r===`running`?`custom-ui:agent.statusRunning`:r===`attention`?`custom-ui:agent.statusAttention`:r===`queued`?`custom-ui:agent.statusQueued`:r===`done`?`custom-ui:agent.statusDone`:`custom-ui:agent.statusSent`);return(0,Q.jsxs)(`span`,{"data-component-agent-status":r??`sent`,className:`flex min-w-0 items-center gap-1.5 text-xs text-content-muted`,children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:F(`size-1.5 flex-none rounded-full`,r===`attention`?`bg-st-attn`:r===`running`?`bg-st-run`:`bg-st-done`)}),(0,Q.jsx)(`span`,{className:`truncate`,children:i}),(0,Q.jsxs)(I,{size:`xs`,variant:`ghost`,"data-component-agent-open":e,className:`flex-none`,onClick:t,children:[n(`custom-ui:agent.openSession`),(0,Q.jsx)(D,{})]})]})}function er({row:e,notify:t,autoFocus:n=!1,onSent:r,className:a}){let{t:o,language:c}=u(),l=i(),d=(0,Z.useId)(),p=f(v()),m=sn(e.id,p.data?.features.versions===!0).data?.current,h=m?.source===`agent`?m:null,g=mt(t),{pending:_,sessionId:y}=bt(e.id),[b,x]=(0,Z.useState)(()=>Qn.get(e.id)??``),S=t=>{t?Qn.set(e.id,t):Qn.delete(e.id),x(t)},C=b.trim(),w=async()=>{if(!C||_)return;let t=await g.generate(e,C);t&&(S(``),r?.(t))};return(0,Q.jsxs)(`form`,{"data-component-prompt":e.id,className:F(`flex flex-col gap-2 rounded-[var(--r-lg)] border border-stroke bg-panel p-3`,a),onSubmit:e=>{e.preventDefault(),w()},children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`label`,{htmlFor:d,className:`mr-auto text-xs font-medium text-content-secondary`,children:o(`custom-ui:agent.promptTitle`)}),m&&(0,Q.jsx)(Ue,{asChild:!0,size:`sm`,className:`hover:bg-solid hover:text-content-secondary`,children:(0,Q.jsx)(`span`,{"data-prompt-base":m.n,children:o(`custom-ui:agent.basedOn`,{n:m.n})})})]}),(0,Q.jsx)(He,{id:d,autoFocus:n,rows:2,value:b,maxLength:Et,placeholder:o(`custom-ui:agent.promptPlaceholder`),"aria-keyshortcuts":`Meta+Enter Control+Enter`,"data-component-prompt-input":!0,className:`max-h-40 min-h-14 resize-none`,onChange:e=>S(e.target.value),onKeyDown:e=>{e.key!==`Enter`||!(e.metaKey||e.ctrlKey)||e.nativeEvent.isComposing||(e.preventDefault(),w())}}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[y?(0,Q.jsx)($n,{sessionId:y,onOpen:()=>l(s(y))}):(0,Q.jsx)(`span`,{className:`text-xs text-content-muted`,children:o(`custom-ui:agent.promptHint`)}),(0,Q.jsxs)(I,{type:`submit`,size:`sm`,disabled:!C||_,"aria-keyshortcuts":`Meta+Enter Control+Enter`,"data-component-generate":!0,className:`ml-auto`,children:[_&&(0,Q.jsx)(Oe,{}),o(_?`custom-ui:agent.sending`:`custom-ui:agent.generate`),!_&&(0,Q.jsx)(ke,{className:`bg-transparent text-current`,children:Ae(`Mod+Enter`)})]})]}),h&&(0,Q.jsxs)(`div`,{"data-prompt-result":h.n,className:`flex min-w-0 flex-col gap-1`,children:[(0,Q.jsx)(`p`,{className:`truncate text-xs text-content-muted`,children:[o(`custom-ui:agent.generatedVersion`,{n:h.n}),h.files.length?o(`custom-ui:agent.wrote`,{files:h.files.map(e=>e.path).join(` `)}):``,o(`custom-ui:versions.sourceAgent`),h.at?ze(h.at,c):``].filter(Boolean).join(` · `)}),(0,Q.jsx)(mn,{version:h})]})]})}var $=`manifest.json`,tr=/\.(?:m?js|css|json|svg|txt|md)$/i;function nr(e){return/\.m?js$/i.test(e)?`javascript`:/\.css$/i.test(e)?`css`:/\.json$/i.test(e)?`json`:/\.svg$/i.test(e)?`xml`:`text`}function rr({row:e}){let{t}=u(),n=f({queryKey:_.describe(e.id),queryFn:({signal:t})=>h(e.id,t),retry:!1,refetchOnWindowFocus:!1}),r=(n.data?.files??[]).map(e=>e.path).filter(e=>e===$||tr.test(e)&&e.split(`/`).length<=3),i=[...r.filter(t=>t===e.entry),...r.filter(t=>t!==e.entry)],[a,o]=(0,Z.useState)(``),s=i.includes(a)?a:i[0]??``;(0,Z.useEffect)(()=>o(``),[e.id]);let c=f({queryKey:[..._.describe(e.id),`source`,e.rev??``,s],queryFn:({signal:t})=>m(e.id,e.rev??``,s,t),enabled:!!(s&&s!==$&&e.rev),retry:!1,refetchOnWindowFocus:!1,staleTime:1/0});if(n.isPending)return(0,Q.jsx)(`p`,{className:`p-4 text-sm text-content-muted`,children:t(`custom-ui:studio.sourceLoading`)});if(n.error||!i.length)return(0,Q.jsx)(G,{className:`flex-1`,title:t(`custom-ui:studio.sourceUnavailable`)});let l=JSON.stringify(e.manifest??{errors:e.errors},null,2),d=s===$?l:c.data===void 0?``:c.data;return(0,Q.jsxs)(`div`,{"data-studio-source":!0,className:`flex min-h-0 min-w-0 flex-1 flex-col gap-2`,children:[(0,Q.jsx)(`div`,{role:`group`,"aria-label":t(`custom-ui:studio.sourceFiles`),className:`flex flex-none flex-wrap gap-1`,children:i.map(e=>(0,Q.jsx)(Ue,{size:`sm`,"aria-pressed":e===s,"data-studio-source-file":e,className:`font-mono`,onClick:()=>o(e),children:e},e))}),s===$&&(0,Q.jsx)(`p`,{className:`text-xs text-content-muted`,children:t(`custom-ui:studio.sourceManifestHint`)}),s!==$&&!e.rev?(0,Q.jsx)(G,{className:`flex-1`,title:t(`custom-ui:studio.sourceNotReady`)}):c.error&&s!==$?(0,Q.jsx)(G,{className:`flex-1`,title:t(`custom-ui:studio.sourceUnavailable`)}):(0,Q.jsx)(Nn,{code:d,language:nr(s),"data-studio-source-code":s,className:`min-h-0 flex-1 overflow-auto bg-code [&>div]:h-full`,children:(0,Q.jsx)(Pn,{"aria-label":t(`custom-ui:studio.copySource`),title:t(`custom-ui:studio.copySource`),className:`absolute top-1.5 right-1.5`})})]})}function ir(e){let[t,n]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>(n(null),p(t=>{t.id===e&&t.reason===`files`&&n(Date.now())})),[e]),t}function ar({at:e}){let{t}=u(),[n,r]=(0,Z.useState)(()=>Date.now());(0,Z.useEffect)(()=>{let e=window.setInterval(()=>r(Date.now()),1e3);return()=>window.clearInterval(e)},[]);let i=Math.max(0,Math.round((n-e)/1e3));return(0,Q.jsxs)(`span`,{"data-studio-reloaded":!0,className:`flex items-center gap-1.5 text-xs text-content-muted`,children:[(0,Q.jsxs)(`span`,{"aria-hidden":!0,className:`relative flex size-1.5 flex-none`,children:[(0,Q.jsx)(`span`,{className:`absolute inset-0 rounded-full bg-content-muted animate-[ping_700ms_cubic-bezier(0,0,0.2,1)_1] [:root[data-motion=reduced]_&]:animate-none motion-reduce:[:root:not([data-motion=full])_&]:animate-none`},e),(0,Q.jsx)(`span`,{className:`relative size-1.5 rounded-full bg-content-muted`})]}),(0,Q.jsx)(`span`,{children:i<60?t(`custom-ui:studio.reloadedSeconds`,{count:i}):t(`custom-ui:studio.reloadedMinutes`,{count:Math.floor(i/60)})})]})}function or({activeSessionId:e=``,row:t,tab:n,target:r,window:i,instanceId:a,draft:o,notify:s,commits:c,settingsButton:l,onTab:d,onTarget:f,onWindow:p}){let{t:m,language:h}=u(),g=t.kind===`native`&&t.status===`ready`&&!!(t.manifest&&t.rev),_=ir(t.id),v=Zn(t.id,t.kind===`native`);return(0,Q.jsxs)(`section`,{"data-studio-workbench":!0,"data-component-stage":t.id,"data-component-kind":t.kind,"aria-label":m(`custom-ui:studio.workbench`),className:`flex min-h-0 min-w-0 flex-col`,children:[(0,Q.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 border-b border-stroke px-5 py-3`,children:[(0,Q.jsxs)(`h2`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-base font-semibold`,children:Y(t,h)}),t.version&&(0,Q.jsxs)(`span`,{className:`flex-none font-mono text-xs text-content-muted tabular-nums`,children:[`v`,t.version]})]}),_!==null&&(0,Q.jsx)(ar,{at:_}),(0,Q.jsxs)(`span`,{className:`ml-auto flex items-center gap-2`,children:[(0,Q.jsx)(P,{size:`sm`,"aria-label":m(`custom-ui:studio.workbenchView`),value:n,onValueChange:d,options:[{value:`preview`,label:m(`custom-ui:studio.tabPreview`)},{value:`source`,label:m(`custom-ui:studio.tabSource`)},{value:`logs`,label:m(`custom-ui:studio.tabLogs`)}]}),l]})]}),(0,Q.jsxs)(`div`,{className:F(`flex min-h-0 flex-1 flex-col gap-3 px-5 pt-4 pb-3`),children:[t.kind===`native`&&(0,Q.jsx)(er,{row:t,notify:s,className:`flex-none`}),n===`source`?(0,Q.jsx)(rr,{row:t}):n===`logs`?(0,Q.jsx)(Xn,{componentId:t.id,errors:v.data,errorsFailed:!!v.error}):g?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Rt,{manifest:t.manifest,target:r,window:i,onTarget:f,onWindow:p}),(0,Q.jsx)(zt,{activeSessionId:e,row:t,target:r,window:i,instanceId:a,title:o.title,props:o.props,notify:s,commits:c}),(0,Q.jsx)(Bt,{componentId:t.id,errors:v.data,commits:c})]}):(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto`,children:[(0,Q.jsx)(Cn,{row:t}),(0,Q.jsx)(G,{className:`flex-1`,title:t.kind===`broken`?m(`custom-ui:studio.brokenTitle`):m(`custom-ui:studio.invalidTitle`),description:t.kind===`broken`?m(`custom-ui:studio.brokenHint`):m(`custom-ui:studio.invalidHint`)})]})]})]})}function sr({onOpen:e}){let{t}=u();return(0,Q.jsxs)(I,{size:`sm`,variant:`secondary`,"data-studio-settings-open":!0,"aria-label":t(`custom-ui:studio.openSettings`),onClick:e,children:[(0,Q.jsx)(A,{}),t(`custom-ui:studio.settings`)]})}var cr=``,lr=[],ur=[],dr={import:!1,versions:!1,export:!1,trash:`none`,trashRestore:!1,usage:!1,revoke:!1};function fr({children:e}){let t=(0,Z.useRef)(null),n=vt(t),r=n.measured&&n.width>=1360;return(0,Q.jsx)(X,{variant:`workbench`,children:(0,Q.jsx)(`div`,{ref:t,"data-component-studio":!0,"data-studio-settings-mode":r?`inline`:`drawer`,className:`h-full min-h-0`,children:e(r)})})}function pr(e){(0,Z.useLayoutEffect)(()=>{if(e)return Le.getState().enterRouteRail(),()=>Le.getState().leaveRouteRail()},[e])}function mr(e,t){let n=$e(),[r,i]=(0,Z.useState)(()=>n.version());(0,Z.useEffect)(()=>n.subscribe(()=>i(n.version())),[n]);let a=(0,Z.useRef)(new Map);return(0,Z.useEffect)(()=>{for(let t of e){let e=a.current.get(t.id);e&&t.rev&&e!==t.rev&&n.resume(`preview:${t.id}`),t.rev&&a.current.set(t.id,t.rev)}},[n,e]),(0,Z.useMemo)(()=>{let r=new Set;for(let i of e)(n.hasTrouble(`preview:${i.id}`,i.rev)||t.some(e=>e.componentId===i.id&&n.hasTrouble(e.instanceId,i.rev)))&&r.add(i.id);return r},[n,t,e,r])}function hr(e){if(typeof e!=`object`||!e)return``;let t=e.componentInstanceId;return typeof t==`string`&&t.length<=64?t:``}function gr(e,t,n){let[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)({id:``,instanceId:null}),[s,c]=(0,Z.useState)(`standard`),l=e?.id??``;(0,Z.useEffect)(()=>{!l||!n||(o({id:l,instanceId:n}),i(null))},[n,l]);let u=Mt(e?.manifest),d=e?t.filter(t=>t.componentId===e.id):[],f=e&&a.id===e.id?a.instanceId:void 0,p=f===null?null:f&&d.some(e=>e.instanceId===f)?f:d[0]?.instanceId??null,m=d.find(e=>e.instanceId===p)??null,h=e&&r?.id===e.id&&u.includes(r.target)?r.target:m&&u.includes(gt(m))?gt(m):u[0]??`feature-page`,g=`${e?.id??``}:${p??`preview`}`,[_,v]=(0,Z.useState)({key:``,title:``,props:{}}),y=(0,Z.useCallback)(e=>v({key:g,...e}),[g]);return{target:h,window:s,instanceId:p,draft:_.key===g?_:{title:m?.title??``,props:m?.props??{}},onPreview:y,setWindow:c,setTarget:t=>e&&i({id:e.id,target:t}),selectInstance:t=>{if(!e)return;o({id:e.id,instanceId:t});let n=d.find(e=>e.instanceId===t);n&&u.includes(gt(n))&&i({id:e.id,target:gt(n)})}}}function _r({activeSessionId:e=``,notify:t,selectedId:r=``,onSelect:i}){let{t:a,language:o}=u(),s=ee(),c=S(),l=x(),d=C().data?.instances??lr,f=Dt(t),p=fn(t),m=mt(t),[h,g]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(!1),y=K(_),b=(0,Z.useMemo)(()=>it(l.data?.components??[]),[l.data]),w=l.data?.root||``,T=l.data?.features??dr,E=T.trash===`move`,te=l.data?.staged??ur,[D,O]=(0,Z.useState)(`all`),[ne,re]=(0,Z.useState)(``),[ae,k]=(0,Z.useState)(`preview`),[oe,se]=(0,Z.useState)(!1),ce=K(oe),[le,ue]=(0,Z.useState)(0),[de]=(0,Z.useState)(Lt),fe=mr(b,d),A=s?b.find(e=>e.id===r)??null:pt(b,r,cr),pe=A?.id??``;(0,Z.useEffect)(()=>{pe&&(cr=pe)},[pe]);let j=gr(A,d,hr(n().state));pr(!s&&c&&!l.data?.legacyShape);let ge=e=>{k(`preview`),i(e,!0)},_e=async(e,n,r)=>{let c=await f.createFromTemplate(e,n);return c&&(O(`all`),re(``),i(c.id,!s),r?.trim()?m.generate(c,r):t(a(`custom-ui:studio.created`,{name:Y(c,o)}))),c};if(!c||l.data?.legacyShape)return(0,Q.jsx)(X,{variant:`collection`,children:(0,Q.jsx)(W,{kind:`empty`,title:a(`custom-ui:studio.unsupportedTitle`),description:a(`custom-ui:studio.unsupportedHint`)})});if(l.isPending)return(0,Q.jsx)(W,{kind:`loading`,title:a(`custom-ui:customUiPage.loading`)});if(l.error&&!l.data)return(0,Q.jsx)(X,{variant:`collection`,children:(0,Q.jsx)(W,{kind:`error`,title:a(`custom-ui:widget.catalogFailed`),action:(0,Q.jsx)(I,{variant:`secondary`,size:`sm`,onClick:()=>void l.refetch(),children:a(`custom-ui:widget.retry`)})})});let ve=jt(b,fe),M={...ve,attention:ve.attention+te.length},ye=_t(b,{filter:D,query:ne,language:o,troubled:fe}),be=te.length>0&&D!==`enabled`,xe=e=>be?te.map(t=>(0,Q.jsx)(zn,{staged:t,phone:e,onReview:()=>g(t.stageId)},t.stageId)):null,Se=e=>(0,Q.jsx)(Rn,{enabled:T.import,lifecycle:p,className:e,onStaged:e=>g(e.stageId)}),N=(0,Q.jsx)(Wn,{stageId:h,lifecycle:p,onClose:()=>g(``),onTrusted:e=>{g(``),O(`all`),re(``),i(e.id,!s)}}),Ce=(0,Q.jsxs)(Q.Fragment,{children:[a(`custom-ui:customUiPage.emptyHint`),w&&(0,Q.jsx)(`code`,{className:`mx-auto mt-2 block max-w-full rounded-xs bg-inline-code px-2 py-1 font-mono text-xs break-all text-content-secondary`,children:w}),(0,Q.jsx)(`span`,{className:`mt-2 block`,children:a(`custom-ui:customUiPage.directoryLocationHint`)})]});if(s){let n=()=>i(``,!1);return r?(0,Q.jsx)(X,{variant:`collection`,children:(0,Q.jsxs)(`div`,{"data-components-phone":`detail`,className:`flex min-w-0 flex-col gap-4`,children:[(0,Q.jsxs)(I,{variant:`ghost`,className:`-ml-2 min-h-11 w-fit px-2 text-content-secondary`,onClick:n,children:[(0,Q.jsx)(ie,{"aria-hidden":`true`}),a(`custom-ui:phone.allComponents`)]}),A?(0,Q.jsxs)(`div`,{"data-component-stage":A.id,"data-component-kind":A.kind,className:`flex min-w-0 flex-col gap-5`,children:[(0,Q.jsx)(Sn,{row:A,actions:f}),(0,Q.jsx)(Cn,{row:A}),A.kind===`native`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(I,{variant:`secondary`,"data-component-prompt-open":!0,className:`min-h-11 w-full`,onClick:()=>v(!0),children:[(0,Q.jsx)(me,{}),a(`custom-ui:agent.editWithPrompt`)]}),(0,Q.jsx)(Ie,{open:_,onOpenChange:v,children:(0,Q.jsxs)(Ne,{side:`bottom`,onCloseAutoFocus:y,"data-component-prompt-sheet":!0,className:`gap-0 rounded-t-[var(--r-lg)] p-0`,children:[(0,Q.jsxs)(je,{className:`px-4 pt-4 pb-0`,children:[(0,Q.jsx)(Pe,{children:Y(A,o)}),(0,Q.jsx)(Fe,{className:`sr-only`,children:a(`custom-ui:agent.promptTitle`)})]}),(0,Q.jsx)(`div`,{className:`px-4 pt-3 pb-[max(16px,env(safe-area-inset-bottom))]`,children:(0,Q.jsx)(er,{row:A,notify:t,autoFocus:!0,className:`border-0 bg-transparent p-0`,onSent:()=>v(!1)})})]})})]}),A.kind===`native`&&A.status===`ready`&&A.manifest&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(Rt,{manifest:A.manifest,target:j.target,window:`standard`,phone:!0,onTarget:j.setTarget,onWindow:j.setWindow}),(0,Q.jsx)(zt,{activeSessionId:e,row:A,target:j.target,window:`standard`,instanceId:j.instanceId,title:j.draft.title,props:j.draft.props,phone:!0,notify:t,commits:de},le)]}),(0,Q.jsx)(wn,{row:A,instances:d,selectedInstanceId:j.instanceId,notify:t,actions:f,onSelectInstance:j.selectInstance,onPreview:j.onPreview}),(0,Q.jsx)(Tn,{row:A,usageEnabled:T.usage,canRevoke:T.revoke,lifecycle:p}),(0,Q.jsx)(Dn,{row:A,instances:d,actions:f})]}),A.kind===`native`&&(0,Q.jsx)(gn,{row:A,enabled:T.versions,notify:t,actions:p}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[T.export&&A.kind===`native`&&(0,Q.jsx)(An,{row:A,lifecycle:p,className:`min-h-11`}),E&&(0,Q.jsx)(kn,{row:A,actions:f,variant:`button`,onDeleted:n})]})]}):(0,Q.jsx)(W,{kind:`empty`,title:a(`custom-ui:phone.missingTitle`),description:a(`custom-ui:phone.missingHint`),action:(0,Q.jsx)(I,{variant:`secondary`,className:`min-h-11`,onClick:n,children:a(`custom-ui:phone.allComponents`)})})]})}):(0,Q.jsxs)(X,{variant:`collection`,children:[(0,Q.jsxs)(`div`,{"data-components-phone":`list`,className:`flex min-w-0 flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`mr-auto text-sm font-medium text-content-secondary tabular-nums`,children:a(`custom-ui:customUiPage.installedComponents`,{count:b.length})}),Se(`min-h-11`),(0,Q.jsx)(Vt,{onCreate:_e,phone:!0,className:`min-h-11`})]}),be&&(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:xe(!0)}),b.length?(0,Q.jsx)(`ul`,{className:`flex flex-col divide-y divide-stroke overflow-hidden rounded-[var(--r-lg)] border border-stroke bg-panel`,children:b.map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsx)(Gt,{row:e,instances:d,active:!1,phone:!0,onSelect:()=>i(e.id,!1)})},e.id))}):(0,Q.jsx)(G,{title:a(`custom-ui:customUiPage.emptyTitle`),description:Ce}),(0,Q.jsx)(Kn,{enabled:T.trashRestore,lifecycle:p,className:`min-h-11 w-fit`,onRestored:e=>i(e.id,!1)}),(0,Q.jsx)(`p`,{className:`text-xs leading-relaxed break-all text-content-muted`,children:a(`custom-ui:customUiPage.directoryHint`,{path:w})})]}),N]})}let we=A&&(0,Q.jsx)(jn,{row:A,instances:d,selectedInstanceId:j.instanceId,canDelete:E,features:T,notify:t,actions:f,lifecycle:p,onSelectInstance:j.selectInstance,onPreview:j.onPreview,onViewSource:()=>{k(`source`),se(!1)},onDeleted:()=>i(``,!0)},A.id);return(0,Q.jsx)(fr,{children:n=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{"data-studio-columns":!0,className:n?`grid h-full min-h-0 grid-cols-[284px_minmax(0,1fr)_372px]`:`grid h-full min-h-0 grid-cols-[284px_minmax(0,1fr)]`,children:[(0,Q.jsx)(qt,{rows:ye,allCount:b.length,counts:M,instances:d,selectedId:A?.id??``,troubled:fe,filter:D,query:ne,root:w,onFilter:O,onQuery:re,onSelect:ge,onCreate:_e,importButton:Se(),staged:xe(!1),footer:T.trashRestore?(0,Q.jsx)(`div`,{className:`flex flex-none border-t border-stroke px-2 py-1.5`,children:(0,Q.jsx)(Kn,{enabled:!0,lifecycle:p,onRestored:e=>i(e.id,!0)})}):void 0,onOpenLogs:e=>{i(e,!0),k(`logs`)},onRequestFix:(e,t)=>void m.fix(e,t),onReload:e=>{$e().resume(`preview:${e}`),ue(e=>e+1),k(`preview`),i(e,!0)}}),A?(0,Q.jsx)(or,{activeSessionId:e,row:A,tab:ae,target:j.target,window:j.window,instanceId:j.instanceId,draft:j.draft,notify:t,commits:de,settingsButton:!n&&(0,Q.jsx)(sr,{onOpen:()=>se(!0)}),onTab:k,onTarget:j.setTarget,onWindow:j.setWindow},`${A.id}#${le}`):(0,Q.jsx)(G,{className:`min-h-0`,title:b.length?a(`custom-ui:phone.missingTitle`):a(`custom-ui:customUiPage.emptyTitle`),description:b.length?a(`custom-ui:phone.missingHint`):Ce}),n&&A&&(0,Q.jsx)(`aside`,{"aria-label":a(`custom-ui:studio.settings`),className:`flex min-h-0 min-w-0 flex-col border-l border-stroke`,children:we})]}),!n&&(0,Q.jsx)(Ie,{open:oe&&!!A,onOpenChange:se,children:(0,Q.jsxs)(Ne,{side:`right`,showCloseButton:!1,onCloseAutoFocus:ce,"data-studio-settings-drawer":!0,className:`w-[372px] max-w-[calc(100vw-48px)] gap-0 p-0 sm:max-w-[372px]`,children:[(0,Q.jsxs)(je,{className:`flex-row items-center justify-between border-b border-stroke px-4 py-2.5`,children:[(0,Q.jsx)(Pe,{className:`text-sm`,children:a(`custom-ui:studio.settings`)}),(0,Q.jsx)(Fe,{className:`sr-only`,children:a(`custom-ui:studio.settingsHint`)}),(0,Q.jsx)(I,{size:`icon-sm`,variant:`ghost`,"aria-label":a(`custom-ui:studio.closeSettings`),onClick:()=>se(!1),children:(0,Q.jsx)(he,{})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1`,children:we})]})}),N]})})}function vr({activeSessionId:e,component:t,instance:n,notify:r}){let i=Ot(t,r);return(0,Q.jsx)(w,{component:t,instance:{instanceId:n.instanceId,surface:`feature-page`,title:n.title,props:n.props},session:e?{id:e,title:``,cwd:``,status:`idle`}:void 0,notify:e=>r(e),onRequestFix:i,className:`h-full`})}function yr({componentId:e,activeSessionId:t=``,notify:n}){let{t:i}=u(),a=T(`feature-page`),o=a.placed.find(t=>t.component.id===e),s=c(e);return(0,Q.jsx)(X,{variant:`workbench`,children:(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex min-h-11 shrink-0 flex-wrap items-center gap-1 border-b border-stroke-soft px-2 py-1.5`,children:[o&&(0,Q.jsx)(`strong`,{className:`min-w-0 flex-1 truncate px-1 text-sm font-medium`,children:o.instance.title||o.component.manifest?.name||o.component.name}),(0,Q.jsx)(I,{variant:`ghost`,size:`sm`,className:`ml-auto max-[650px]:h-11`,asChild:!0,children:(0,Q.jsxs)(r,{to:l.components,children:[(0,Q.jsx)(A,{}),i(`custom-ui:tool.openSettings`)]})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-hidden`,"data-feature-page-host":e,children:o?(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(W,{kind:`loading`,title:i(`custom-ui:customUiPage.loading`)}),children:(0,Q.jsx)(vr,{activeSessionId:t,component:o.component,instance:o.instance,notify:n},o.instance.instanceId)}):a.isLoading?(0,Q.jsx)(W,{kind:`loading`,title:i(`custom-ui:customUiPage.loading`)}):a.error?(0,Q.jsx)(W,{kind:`error`,title:i(`custom-ui:widget.catalogFailed`),action:(0,Q.jsx)(I,{variant:`secondary`,onClick:a.refetch,children:i(`custom-ui:widget.retry`)})}):(0,Q.jsx)(W,{kind:`empty`,title:i(`custom-ui:tool.notPlacedTitle`),description:i(`custom-ui:tool.notPlacedHint`),action:(0,Q.jsx)(I,{variant:`secondary`,asChild:!0,children:(0,Q.jsx)(r,{to:s,children:i(`custom-ui:tool.openInStudio`)})})})})]})})}export{_r as CustomUiPage,yr as CustomUiToolPage};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,r as n}from"./vendor-react-DwNgTV1j.js";import{S as r}from"./events-BgEZwyTb.js";import"./public-events-D2kHUhG2.js";import{t as i}from"./terminal-context-aIsIJPn8.js";var a=e(t(),1),o=2097152,s=524288;function c(){let e=new TextDecoder,t=`text`;return n=>{let r=``;for(let i of e.decode(n,{stream:!0})){let e=i.codePointAt(0);t===`text`?e===27?t=`escape`:e===155?t=`csi`:e===157?t=`osc`:(e===9||e===10||e===13||e>=32&&e!==127)&&(r+=i):t===`escape`?t=i===`[`?`csi`:i===`]`?`osc`:`()*+`.includes(i)?`charset`:`text`:t===`csi`?e>=64&&e<=126&&(t=`text`):t===`charset`?t=`text`:t===`osc`?e===7?t=`text`:e===27&&(t=`osc-escape`):t===`osc-escape`&&(t=i===`\\`?`text`:e===27?`osc-escape`:`osc`)}return r}}function l(e){let t=new Map,n=new Map,r=new Set,i=new Map,a=new Map,l=new Set,u=new Set,d=new Map,f=!1,p,m=e=>(d.has(e)||d.set(e,[...t.values()].filter(t=>e===void 0||t.sessionId===e)),d.get(e)),h=()=>{for(let[e,n]of d){let r=[...t.values()].filter(t=>e===void 0||t.sessionId===e);(r.length!==n.length||r.some((e,t)=>e!==n[t]))&&d.set(e,r)}for(let e of l)e()},g=(e,n)=>{let r=t.get(e);r&&(t.set(e,{...r,...n}),h())},_=(e,i)=>{if(!(f||i.terminalId!==e||!r.has(e))){if(i.type===`output`){if(!Array.isArray(i.data)||i.data.some(e=>!Number.isInteger(e)||e<0||e>255))return;let r=n.get(e),a=Uint8Array.from(i.data.slice(-2097152));r.chunks.push({sequence:++r.sequence,data:a}),r.bytes+=a.length;let c=t.get(e).truncated||i.data.length>o;for(;r.bytes>o&&r.chunks.length>1;)r.bytes-=r.chunks.shift().data.length,c=!0;r.text+=r.decoder(a),r.text.length>s&&(r.text=r.text.slice(-524288).replace(/^[\uDC00-\uDFFF]/,``),c=!0),g(e,{output:r.text,truncated:c})}else i.type===`exit`?(r.delete(e),g(e,{status:`exited`,exitCode:i.code,error:``})):i.type===`error`&&g(e,{status:`error`,error:i.message});for(let e of u)e(i)}},v=async(a,o,s)=>{if(f)throw Error(`Terminal registry disposed`);let l=`terminal-${crypto.randomUUID()}`;t.set(l,{id:l,sessionId:a,cwd:o,profileId:s,orphaned:!1,status:`starting`,exitCode:null,error:``,output:``,truncated:!1}),n.set(l,{chunks:[],bytes:0,sequence:0,decoder:c(),text:``}),r.add(l),h();let u=(async()=>{try{let n=await e.terminalCreate({terminalId:l,profileId:s,cwd:o,cols:100,rows:24},e=>_(l,e));if(n.terminalId!==l)throw Error(`Terminal creation returned a different identity`);return g(l,{cwd:n.cwd,profileId:n.profileId,...!f&&t.get(l)?.status===`starting`?{status:`running`}:{}}),l}catch(e){throw g(l,{status:`error`,error:e instanceof Error?e.message:String(e)}),e}finally{i.delete(l)}})();return i.set(l,u),u},y=t=>{let n=a.get(t);if(n)return n;if(!r.has(t))return Promise.resolve();g(t,{status:`stopping`,error:``});let o=(async()=>{try{let n=i.get(t);if(n&&await n.catch(()=>void 0),!r.has(t))return;await e.terminalClose(t),r.delete(t),g(t,{status:`exited`,exitCode:null,error:``})}catch(e){throw g(t,{status:`error`,error:e instanceof Error?e.message:String(e)}),e}finally{a.delete(t)}})();return a.set(t,o),o};return{create:v,stop:y,snapshot:m,subscribe(e){return l.add(e),()=>{l.delete(e)}},subscribeEvents(e){return u.add(e),()=>{u.delete(e)}},outputChunks(e){return n.get(e)?.chunks||[]},async write(t,n){if(f||!r.has(t))throw Error(`Terminal is not running`);await e.terminalWrite(t,n)},async resize(t,n,i){f||!r.has(t)||!Number.isInteger(n)||!Number.isInteger(i)||n<1||i<1||await e.terminalResize(t,n,i)},orphan(e){let n=new Set(e);for(let e of t.values())n.has(e.sessionId)&&!e.orphaned&&t.set(e.id,{...e,orphaned:!0});h()},dispose(){return p||(f=!0,p=(async()=>{let e=await Promise.allSettled([...r].map(y));l.clear(),u.clear();let t=e.find(e=>e.status===`rejected`);if(t?.status===`rejected`)throw t.reason})(),p)}}}var u=n();function d({bridge:e,children:t}){let[n,o]=(0,a.useState)(null);return(0,a.useEffect)(()=>{if(!e?.terminalCreate||!e.terminalWrite||!e.terminalResize||!e.terminalClose||!e.terminalProfiles){o(null);return}let t=l({terminalCreate:e.terminalCreate,terminalWrite:e.terminalWrite,terminalResize:e.terminalResize,terminalClose:e.terminalClose}),n=new Map,i,a=e.terminalProfiles;o({registry:t,profiles:()=>i||=a().catch(e=>{throw i=void 0,e}),renderer:(e,t)=>(n.has(e)||n.set(e,t()),n.get(e))});let s=r(window,({deletedIds:e})=>t.orphan(e)),c=()=>{for(let e of n.values())e.dispose();n.clear(),t.dispose().catch(()=>{})};return window.addEventListener(`pagehide`,c),()=>{s(),window.removeEventListener(`pagehide`,c),c()}},[e]),(0,u.jsx)(i.Provider,{value:n,children:t})}export{d as t};
1
+ import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,r as n}from"./vendor-react-DwNgTV1j.js";import{S as r}from"./events-BrkEbuk_.js";import"./public-events-CUnBp7HK.js";import{t as i}from"./terminal-context-aIsIJPn8.js";var a=e(t(),1),o=2097152,s=524288;function c(){let e=new TextDecoder,t=`text`;return n=>{let r=``;for(let i of e.decode(n,{stream:!0})){let e=i.codePointAt(0);t===`text`?e===27?t=`escape`:e===155?t=`csi`:e===157?t=`osc`:(e===9||e===10||e===13||e>=32&&e!==127)&&(r+=i):t===`escape`?t=i===`[`?`csi`:i===`]`?`osc`:`()*+`.includes(i)?`charset`:`text`:t===`csi`?e>=64&&e<=126&&(t=`text`):t===`charset`?t=`text`:t===`osc`?e===7?t=`text`:e===27&&(t=`osc-escape`):t===`osc-escape`&&(t=i===`\\`?`text`:e===27?`osc-escape`:`osc`)}return r}}function l(e){let t=new Map,n=new Map,r=new Set,i=new Map,a=new Map,l=new Set,u=new Set,d=new Map,f=!1,p,m=e=>(d.has(e)||d.set(e,[...t.values()].filter(t=>e===void 0||t.sessionId===e)),d.get(e)),h=()=>{for(let[e,n]of d){let r=[...t.values()].filter(t=>e===void 0||t.sessionId===e);(r.length!==n.length||r.some((e,t)=>e!==n[t]))&&d.set(e,r)}for(let e of l)e()},g=(e,n)=>{let r=t.get(e);r&&(t.set(e,{...r,...n}),h())},_=(e,i)=>{if(!(f||i.terminalId!==e||!r.has(e))){if(i.type===`output`){if(!Array.isArray(i.data)||i.data.some(e=>!Number.isInteger(e)||e<0||e>255))return;let r=n.get(e),a=Uint8Array.from(i.data.slice(-2097152));r.chunks.push({sequence:++r.sequence,data:a}),r.bytes+=a.length;let c=t.get(e).truncated||i.data.length>o;for(;r.bytes>o&&r.chunks.length>1;)r.bytes-=r.chunks.shift().data.length,c=!0;r.text+=r.decoder(a),r.text.length>s&&(r.text=r.text.slice(-524288).replace(/^[\uDC00-\uDFFF]/,``),c=!0),g(e,{output:r.text,truncated:c})}else i.type===`exit`?(r.delete(e),g(e,{status:`exited`,exitCode:i.code,error:``})):i.type===`error`&&g(e,{status:`error`,error:i.message});for(let e of u)e(i)}},v=async(a,o,s)=>{if(f)throw Error(`Terminal registry disposed`);let l=`terminal-${crypto.randomUUID()}`;t.set(l,{id:l,sessionId:a,cwd:o,profileId:s,orphaned:!1,status:`starting`,exitCode:null,error:``,output:``,truncated:!1}),n.set(l,{chunks:[],bytes:0,sequence:0,decoder:c(),text:``}),r.add(l),h();let u=(async()=>{try{let n=await e.terminalCreate({terminalId:l,profileId:s,cwd:o,cols:100,rows:24},e=>_(l,e));if(n.terminalId!==l)throw Error(`Terminal creation returned a different identity`);return g(l,{cwd:n.cwd,profileId:n.profileId,...!f&&t.get(l)?.status===`starting`?{status:`running`}:{}}),l}catch(e){throw g(l,{status:`error`,error:e instanceof Error?e.message:String(e)}),e}finally{i.delete(l)}})();return i.set(l,u),u},y=t=>{let n=a.get(t);if(n)return n;if(!r.has(t))return Promise.resolve();g(t,{status:`stopping`,error:``});let o=(async()=>{try{let n=i.get(t);if(n&&await n.catch(()=>void 0),!r.has(t))return;await e.terminalClose(t),r.delete(t),g(t,{status:`exited`,exitCode:null,error:``})}catch(e){throw g(t,{status:`error`,error:e instanceof Error?e.message:String(e)}),e}finally{a.delete(t)}})();return a.set(t,o),o};return{create:v,stop:y,snapshot:m,subscribe(e){return l.add(e),()=>{l.delete(e)}},subscribeEvents(e){return u.add(e),()=>{u.delete(e)}},outputChunks(e){return n.get(e)?.chunks||[]},async write(t,n){if(f||!r.has(t))throw Error(`Terminal is not running`);await e.terminalWrite(t,n)},async resize(t,n,i){f||!r.has(t)||!Number.isInteger(n)||!Number.isInteger(i)||n<1||i<1||await e.terminalResize(t,n,i)},orphan(e){let n=new Set(e);for(let e of t.values())n.has(e.sessionId)&&!e.orphaned&&t.set(e.id,{...e,orphaned:!0});h()},dispose(){return p||(f=!0,p=(async()=>{let e=await Promise.allSettled([...r].map(y));l.clear(),u.clear();let t=e.find(e=>e.status===`rejected`);if(t?.status===`rejected`)throw t.reason})(),p)}}}var u=n();function d({bridge:e,children:t}){let[n,o]=(0,a.useState)(null);return(0,a.useEffect)(()=>{if(!e?.terminalCreate||!e.terminalWrite||!e.terminalResize||!e.terminalClose||!e.terminalProfiles){o(null);return}let t=l({terminalCreate:e.terminalCreate,terminalWrite:e.terminalWrite,terminalResize:e.terminalResize,terminalClose:e.terminalClose}),n=new Map,i,a=e.terminalProfiles;o({registry:t,profiles:()=>i||=a().catch(e=>{throw i=void 0,e}),renderer:(e,t)=>(n.has(e)||n.set(e,t()),n.get(e))});let s=r(window,({deletedIds:e})=>t.orphan(e)),c=()=>{for(let e of n.values())e.dispose();n.clear(),t.dispose().catch(()=>{})};return window.addEventListener(`pagehide`,c),()=>{s(),window.removeEventListener(`pagehide`,c),c()}},[e]),(0,u.jsx)(i.Provider,{value:n,children:t})}export{d as t};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/public-folder-dialog-CooqqcGn.js","assets/rolldown-runtime-B0Z9INg1.js","assets/vendor-react-DwNgTV1j.js","assets/use-i18n-CbqEZb3r.js","assets/i18n-CYOV8NO5.js","assets/vendor-router-CSN_DGvx.js","assets/index-B446sLQy.js","assets/index-Fb-GT4ka.css","assets/storage-DtvZ_lEu.js","assets/vendor-state-GkUciC5H.js","assets/server-BgNvmqwJ.js","assets/createLucideIcon-Cd-3GVxJ.js","assets/triangle-alert-CE1q54ci.js","assets/button-CCcCN8tE.js","assets/vendor-ui-DvrYggeS.js","assets/dist-41X0pdUs.js","assets/utils-C8uzG5AZ.js","assets/dialog-C6pJ93kY.js","assets/x-07u4-129.js","assets/dist-BHkR6BLP.js","assets/dist-BsRXXcSL.js","assets/es2015-DTZdOI9P.js","assets/input-CPw-zkYh.js","assets/machines-api-Cww34Att.js","assets/http-response-DHqWBecB.js","assets/http-Da7z8Zhw.js","assets/abort-signal-f4JsiYKX.js","assets/alert-DRIrgNI4.js","assets/field-DoLEb0np.js","assets/label-CVWjEcfV.js","assets/separator-BPh_qxvc.js","assets/machine-messages-P6rRT5_Y.js"])))=>i.map(i=>d[i]);
2
+ import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{h as t,u as n}from"./vendor-router-CSN_DGvx.js";import{i as r,r as i}from"./vendor-react-DwNgTV1j.js";import{t as a}from"./use-i18n-CbqEZb3r.js";import{t as o}from"./useQuery-DfOU-27z.js";import{a as s,i as c,o as l}from"./startup-queries-CNUOrW7A.js";import{a as u}from"./http-response-DHqWBecB.js";import{n as d}from"./http-Da7z8Zhw.js";import{t as f}from"./runtime-capabilities-store-1qxTCxHV.js";import{t as ee}from"./chevron-down-CxtxIjiP.js";import{o as te}from"./FocusRuntimeControls-eXxgJIFt.js";import{t as p}from"./folder-open-FIShC5Qk.js";import{t as m}from"./folder-plus-OPHZsJho.js";import{t as ne}from"./folder-DPM8D8cf.js";import{n as re,t as h}from"./useMachines-DHK5FVXC.js";import{t as g}from"./plus-fQbSqB1n.js";import{t as _}from"./server-BgNvmqwJ.js";import{a as v,c as y,i as b,o as x,p as ie,r as S,s as C,t as ae}from"./dropdown-menu-Ds0gD8S8.js";import{t as w}from"./utils-C8uzG5AZ.js";import{u as T}from"./events-BrkEbuk_.js";import{t as E}from"./chat-api-DwR_1yAu.js";import{_ as D,d as O,l as k,t as A,u as j,v as M,x as N,y as P}from"./useSessionListQuery-D8hWYbAp.js";import"./useNow-Cm86munt.js";import{a as F,i as I,n as L,t as oe}from"./useNewProjectPicker-Dum2z5eb.js";import{a as se}from"./card-presentation-zU6WKfgu.js";import"./useSidebarModel-CR0sLO4j.js";import{o as ce}from"./format-DMJQzoZ7.js";import{n as R,t as z}from"./workspace-order-store-CI03povy.js";import{r as B,t as V}from"./board-projects-31Kch8Or.js";var H=e(r(),1),U=class extends Error{stage;cause;sessionId;code=`board_launch_failed`;constructor(e,t,n=``){super(t instanceof Error?t.message:String(t||`launch failed`)),this.stage=e,this.cause=t,this.sessionId=n}},W=1e5,G=5e3;function K(e){if(!e||typeof e!=`object`)return!1;let t=e;return Array.isArray(t.messages)&&t.messages.length===0&&t.streaming===!1&&t.configurationBusy!==!0&&(t.queuedInputs===void 0||Array.isArray(t.queuedInputs)&&t.queuedInputs.length===0)}function q(e){return e instanceof u?`${e.kind||`error`}:${e.status??`-`}`:`error`}async function J(e){let t=`/api/sessions/${encodeURIComponent(e)}`;try{if(!K(await E.getLiveSession(e,{timeout:G})))return!1;await d(t,{method:`DELETE`,timeout:G})}catch(e){return console.warn(`[board] 派发失败后未能清理空会话(${q(e)})`),!1}return s.setQueryData(k,t=>t&&{...t,sessions:t.sessions.filter(t=>t.id!==e)}),T({deletedIds:[e]}),!0}function Y(e){s.setQueryData(k,t=>t&&!t.sessions.some(t=>t.id===e.id)?{...t,sessions:[e,...t.sessions]}:t),c(`sessions`)}function le(e){let t=e.indexOf(`/`);return t>0?{provider:e.slice(0,t),modelId:e.slice(t+1)}:null}async function ue(e,t,n){let r=le(n.model);r&&n.model!==t.model&&await E.updateModel(e,r.provider,r.modelId),n.thinkingLevel&&n.thinkingLevel!==t.thinkingLevel&&await E.setThinkingLevel(e,n.thinkingLevel),n.executionMode&&n.executionMode!==t.executionMode&&await E.updateExecutionMode(e,n.executionMode),n.runMode!==`plan`&&n.runMode!==t.runMode&&await E.updateRunMode(e,n.runMode)}async function de(e){if(!e.prompt.trim().slice(0,W))throw new U(`create`,Error(`empty prompt`));let t;try{t=await E.createSession(``,e.cwd,{projectless:e.projectless===!0,machine:e.machine??null})}catch(e){throw new U(`create`,e)}let n=t.id;try{await ue(n,t,e)}catch(e){throw await J(n),new U(`configure`,e,n)}return{session:t}}var fe=/^\/[a-z][a-z0-9:-]{0,63}$/;async function pe(e){let{sessionId:t}=e,n=e.prompt.trim().slice(0,W);if(!t||!n)throw new U(`send`,Error(`empty prompt`),t);let r=e.commandWhenEmpty?.trim()??``;if(r&&!fe.test(r))throw new U(`send`,Error(`invalid command`),t);let i;try{i=await E.getLiveSession(t)}catch(e){throw new U(`send`,e,t)}let a=i&&typeof i==`object`?i:{},o=Array.isArray(a.messages)&&a.messages.length===0&&r?`${r} ${n}`:n,l=async()=>{try{await E.queueInput(t,o,[],`followUp`)}catch(e){throw new U(`send`,e,t)}return{sessionId:t,queued:!0}};if(a.streaming===!0)return l();e.created?.id===t?Y({...e.created,firstMessage:n,messageCount:1}):s.getQueryData(k)?.sessions.some(e=>e.id===t)||c(`sessions`);let u=O(t,{streaming:!0});try{await N(t,`launch`,(e,n)=>E.openStream({sessionId:t,message:o,attachments:[],goalMode:!1,teamMode:!1},e,{signal:n}))}catch(e){if(D(t,u),e instanceof j)return l();throw P().catch(()=>void 0),new U(`send`,e,t)}return M(t,e=>!!e).catch(()=>void 0).finally(()=>D(t,u)),{sessionId:t,queued:!1}}function X(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function Z(e){return typeof e==`string`?e:``}function me(e){return(Array.isArray(X(e).providers)?X(e).providers:[]).flatMap(e=>{let t=X(e),n=Z(t.id);return!n||t.configured!==!0||t.enabled===!1?[]:(Array.isArray(t.models)?t.models:[]).flatMap(e=>{let r=X(e),i=Z(r.id);return!i||r.kind!==`chat`?[]:[{key:`${n}/${i}`,label:Z(r.name)||i,providerName:Z(t.name)||n,thinkingLevels:Array.isArray(r.thinkingLevels)?r.thinkingLevels.filter(e=>typeof e==`string`):[]}]})})}function he(){let e=o(l(`config`)),t=A(),n=z(e=>e.names),r=R(e=>e.projects),i=f(e=>e.capabilities.features),a=(0,H.useMemo)(()=>me(e.data),[e.data]),s=e.data?.provider&&e.data?.model?`${e.data.provider}/${e.data.model}`:``,c=t.data?.sessions,u=(0,H.useMemo)(()=>B(c??[],r,n),[c,n,r]),d=(0,H.useMemo)(()=>V(c??[],u),[c,u]);return{models:a,defaultModel:s,defaultThinkingLevel:Z(e.data?.thinkingLevel)||`medium`,projects:u,defaultCwd:d,goalsAvailable:i.goals!==!1,teamAvailable:i.goals!==!1&&i.multiAgent!==!1,loading:e.isPending,error:e.error??null}}var Q=i(),ge=(0,H.lazy)(()=>t(()=>import(`./public-folder-dialog-CooqqcGn.js`).then(e=>({default:e.MachineFolderDialog})),__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,26,27,28,29,30,31]))),$=`\0no-project`;function _e(e){return e===`full-access`||L.includes(e)}function ve(e){return e===`plan`||e===`goal`||e===`team`}function ye({onError:e}){let{t,language:r}=a(),i=n(),o=he(),s=h(),[c,l]=(0,H.useState)(null),u=I(),[d,T]=(0,H.useState)(!1),E=(0,H.useRef)(null),D=oe({onProjectChosen:()=>void 0,onError:e}),O=f(e=>e.capabilities.features.workspaceFolders),k=o.models.some(e=>e.key===u.model),A=k?u.model:o.defaultModel,j=o.models.find(e=>e.key===A)?.thinkingLevels??[],M=j.includes(u.thinkingLevel)?u.thinkingLevel:``,N=M||(j.includes(o.defaultThinkingLevel)?o.defaultThinkingLevel:``),P=d?`full-access`:u.executionMode||`approval-required`,L=u.runMode===`team`&&!o.teamAvailable||u.runMode===`goal`&&!o.goalsAvailable?`plan`:u.runMode,R=(0,H.useMemo)(()=>{if(!u.cwd||o.projects.some(e=>e.cwd===u.cwd))return o.projects;let e=u.cwd.replace(/[\\/]+$/,``).split(/[\\/]/).pop()||u.cwd;return[{key:u.cwd,cwd:u.cwd,label:e},...o.projects]},[u.cwd,o.projects]),z=(0,H.useMemo)(()=>se(R),[R]),B=u.projectless,V=!!u.machineId,U=s.machines.find(e=>e.id===u.machineId),{rememberLaunch:W}=u;(0,H.useEffect)(()=>{V&&s.loaded&&!U&&W({machineId:``,machineCwd:``})},[U,V,s.loaded,W]);let G=V||B?``:u.cwd||o.defaultCwd||R[0]?.cwd||``,K=V||B?void 0:R.find(e=>e.cwd===G),q=`${U?.name??``}:${ce(u.machineCwd,r)}`,J=V?q:K?.label||t(B?`board:launch.noProject`:`board:launch.defaultProject`),Y=t(`board:launch.projectLabel`,{project:K?z.get(K.key)?`${K.label} (${z.get(K.key)})`:K.label:J});return{cwd:G,model:A,thinkingLevel:N,availableThinkingLevels:j,executionMode:P,runMode:L,onModelChange:e=>u.rememberLaunch({model:e,thinkingLevel:``}),onThinkingLevelChange:e=>u.rememberLaunch({thinkingLevel:e}),onExecutionModeChange:e=>_e(e)?(T(e===`full-access`),e!==`full-access`&&u.rememberLaunch({executionMode:e}),!0):!1,onRunModeChange:e=>ve(e)?(u.rememberLaunch({runMode:e}),!0):!1,renderProjectControl:e=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(ae,{children:[(0,Q.jsx)(ie,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:e===`header`?`relative inline-flex h-6 max-w-full min-w-0 cursor-pointer items-center gap-1 rounded-full px-2 text-xs leading-4 text-content-muted outline-none after:absolute after:-inset-x-1 after:-inset-y-2.5 after:content-[""] focus-visible:outline-2 focus-visible:outline-focus active:bg-surface-hover aria-expanded:bg-surface-hover`:w(te,`max-w-[24ch] max-[650px]:max-w-[14ch]`),title:V?`${U?.name??``}:${u.machineCwd}`:K?.cwd||void 0,"aria-label":Y,"data-new-task-project":V?`machine:${u.machineId}`:B?`none`:G||`default`,children:[V?(0,Q.jsx)(_,{size:e===`header`?12:14,className:`shrink-0`,"aria-hidden":`true`}):(0,Q.jsx)(ne,{size:e===`header`?12:14,className:`shrink-0`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:w(`min-w-0 truncate`,(K?.label||V)&&`font-mono`),children:J}),(0,Q.jsx)(ee,{size:e===`header`?12:14,className:w(`shrink-0 opacity-70`,e===`chip`&&`max-[650px]:hidden`),"aria-hidden":`true`})]})}),(0,Q.jsxs)(S,{align:e===`header`?`center`:`start`,side:e===`header`?`bottom`:`top`,className:`max-h-[min(24rem,var(--radix-dropdown-menu-content-available-height))] w-64 overflow-y-auto`,onCloseAutoFocus:e=>{let t=E.current;t&&(E.current=null,e.preventDefault(),t())},children:[(0,Q.jsxs)(x,{value:V?``:B?$:G,onValueChange:e=>u.rememberLaunch(e===$?{projectless:!0}:{cwd:e}),children:[(0,Q.jsx)(C,{value:$,children:(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:t(`board:launch.noProject`)})}),(0,Q.jsx)(y,{}),(0,Q.jsx)(v,{children:t(`board:launch.projects`)}),R.length===0&&(0,Q.jsx)(C,{value:``,children:t(`board:launch.defaultProject`)}),R.map(e=>(0,Q.jsxs)(C,{value:e.cwd,title:e.cwd,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:e.label}),z.get(e.key)&&(0,Q.jsx)(`span`,{className:`ml-auto min-w-0 truncate pl-2 font-mono text-xs text-content-muted`,children:z.get(e.key)})]},e.key))]}),(0,Q.jsx)(y,{}),(0,Q.jsxs)(b,{disabled:D.picking,"data-launch-new-project":!0,onSelect:()=>E.current=()=>void D.newProject(),children:[(0,Q.jsx)(p,{"aria-hidden":`true`}),t(`board:launch.chooseFolder`)]}),O&&(0,Q.jsxs)(b,{"data-launch-new-folder":!0,onSelect:()=>E.current=()=>D.newFolder(G||o.defaultCwd),children:[(0,Q.jsx)(m,{"aria-hidden":`true`}),t(`board:launch.newFolder`)]}),s.available&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(y,{}),(0,Q.jsx)(v,{children:t(`board:launch.machines`)}),s.machines.map(e=>(0,Q.jsxs)(b,{"data-launch-machine":e.id,onSelect:()=>E.current=()=>l(e),children:[e.kind===`ssh`?(0,Q.jsx)(_,{"aria-hidden":`true`}):(0,Q.jsx)(re,{"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:w(`ml-auto size-2 flex-none rounded-full`,e.online?`bg-success`:`bg-content-faint`)})]},e.id)),(0,Q.jsxs)(b,{"data-launch-add-machine":!0,onSelect:()=>i(`/config/remote-access`),children:[(0,Q.jsx)(g,{"aria-hidden":`true`}),t(`board:launch.addMachine`)]})]})]})]}),(0,Q.jsx)(F,{picker:D.picker,folderDialog:D.folderDialog}),c&&(0,Q.jsx)(H.Suspense,{fallback:null,children:(0,Q.jsx)(ge,{machine:c,initialCwd:c?.id===u.machineId?u.machineCwd:c?.defaultCwd??``,onOpenChange:e=>{e||l(null)},onChosen:(e,t)=>{W({machineId:e.id,machineCwd:t}),l(null)}})})]}),prepare:e=>de({prompt:e,cwd:G,projectless:B,machine:V?{id:u.machineId,cwd:u.machineCwd}:null,model:k?A:``,thinkingLevel:M,executionMode:P,runMode:L}),onSent:()=>{T(!1)}}}export{pe as n,ye as t};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,r as n}from"./vendor-react-DwNgTV1j.js";import{t as r}from"./use-i18n-8V6eRMcE.js";import{t as i}from"./runtime-capabilities-store-Y9MaywP8.js";import{t as a}from"./arrow-right-DqLOhpA2.js";import{t as o}from"./download-BCfIiuaL.js";import{t as s}from"./key-round-C29uZbsf.js";import{t as c}from"./search-D0mqDaf_.js";import{t as l}from"./server-BgNvmqwJ.js";import{t as u}from"./x-07u4-129.js";import{t as d}from"./utils-C8uzG5AZ.js";import{t as f}from"./button-CCcCN8tE.js";import{t as p}from"./kbd-CAufZTkl.js";import{n as m,r as h}from"./config-search-1BIdouae.js";import{s as g}from"./shortcuts-DRfz9B_B.js";import{a as _,i as v,l as y,o as b,s as x,t as S}from"./dialog-D23yIdOZ.js";import{t as C}from"./input-CPw-zkYh.js";import{t as w}from"./BrandLogo-k3CvJjd4.js";var T=e(t(),1),E=n();function D({query:e,onQueryChange:t,onSelect:n,inputRef:a,placement:o=`toolbar`}){let{t:s,language:l}=r(),[u,f]=(0,T.useState)(!1),[_,v]=(0,T.useState)(0),y=(0,T.useRef)(null),b=i(e=>e.capabilities),x=g(`focusSearch`),S=(0,T.useMemo)(()=>h(e,l,{capabilities:b,mobileApp:!!window.__PISPER_MOBILE_APP__}),[l,e,b]);(0,T.useEffect)(()=>v(0),[e]),(0,T.useEffect)(()=>{if(!u)return;let e=e=>{y.current&&!y.current.contains(e.target)&&f(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[u]);let w=e=>{if(f(!1),t(``),e.entry.card===`interface-custom-ui`){n(e.entry.section,`widgets`);return}m(e.entry.card,e.entry.section,{targetId:e.entry.targetId,targetText:e.title,expandGroup:e.entry.expandGroup}),n(e.entry.section)},D=u&&e.trim().length>0;return(0,E.jsxs)(`div`,{ref:y,className:d(`relative`,o===`sidebar`?`w-full`:`w-[min(250px,24vw)] max-[900px]:w-[190px] max-[650px]:col-start-1 max-[650px]:row-start-1 max-[650px]:w-full max-[650px]:min-w-0`),children:[(0,E.jsx)(c,{size:15,"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-2.5 -translate-y-1/2 text-content-muted`}),(0,E.jsx)(C,{ref:a,value:e,title:s(`navigation:pageHeader.search`),"aria-label":s(`navigation:pageHeader.search`),className:d(`pl-8 text-sm`,o!==`sidebar`&&`max-[650px]:h-11 max-[650px]:text-[16px]`,o===`sidebar`&&`h-8 border-key-border bg-key pr-9 text-ellipsis shadow-key`),placeholder:s(o===`sidebar`?`config:configSearch.placeholderShort`:`config:configSearch.placeholder`),onChange:e=>{t(e.target.value),f(!0)},onFocus:()=>{e.trim()&&f(!0)},onKeyDown:e=>{e.key===`Escape`?(e.stopPropagation(),t(``),f(!1)):e.key===`ArrowDown`?(e.preventDefault(),v(e=>Math.min(e+1,S.length-1))):e.key===`ArrowUp`?(e.preventDefault(),v(e=>Math.max(e-1,0))):e.key===`Enter`&&S[_]&&(e.preventDefault(),w(S[_]))}}),o===`sidebar`&&x&&!e&&(0,E.jsx)(p,{className:`absolute top-1/2 right-2 -translate-y-1/2 pointer-coarse:hidden`,children:x}),D&&(0,E.jsx)(`div`,{className:`absolute top-full left-0 z-50 mt-1.5 w-full overflow-hidden rounded-md bg-solid shadow-float`,children:S.length===0?(0,E.jsx)(`p`,{role:`status`,className:`px-3 py-3 text-xs text-content-muted`,children:s(`config:configSearch.noResults`)}):(0,E.jsx)(`ul`,{className:`max-h-[280px] overflow-auto py-1`,children:S.map((e,t)=>(0,E.jsx)(`li`,{children:(0,E.jsxs)(`button`,{type:`button`,className:d(`flex w-full flex-col gap-0.5 px-3 py-1.5 text-left pointer-coarse:min-h-11`,t===_?`bg-surface-hover`:`hover:bg-surface-subtle`),onMouseEnter:()=>v(t),onClick:()=>w(e),children:[(0,E.jsx)(`span`,{className:`text-sm text-content`,children:e.title}),(0,E.jsx)(`span`,{className:`text-xs text-content-muted`,children:e.sectionTitle})]})},e.entry.id))})})]})}function O({open:e,onDismiss:t,onOpenImport:n,onOpenSettings:i}){let{t:c}=r();return(0,E.jsx)(S,{open:e,onOpenChange:e=>!e&&t(),children:(0,E.jsxs)(v,{showCloseButton:!1,overlayClassName:`z-[220]`,className:`z-[220] gap-0 rounded-[var(--r-lg)] border border-stroke bg-solid p-0`,style:{maxWidth:`min(28rem, calc(100vw - max(1rem, env(safe-area-inset-left), env(safe-area-inset-right)) - max(1rem, env(safe-area-inset-left), env(safe-area-inset-right))))`,maxHeight:`calc(100dvh - max(1rem, env(safe-area-inset-top), env(safe-area-inset-bottom)) - max(1rem, env(safe-area-inset-top), env(safe-area-inset-bottom)))`},"aria-describedby":`model-onboarding-description`,children:[(0,E.jsxs)(`div`,{className:`relative px-5 pt-5 pb-2 max-[650px]:px-4 max-[650px]:pt-4`,children:[(0,E.jsxs)(x,{className:`gap-3 pr-9 text-left`,children:[(0,E.jsx)(`span`,{"aria-hidden":`true`,className:`w-fit rounded-[13px] shadow-raise`,children:(0,E.jsx)(w,{size:44})}),(0,E.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,E.jsx)(`p`,{className:`text-xs font-medium text-content-muted`,children:c(`config:modelOnboarding.eyebrow`)}),(0,E.jsx)(y,{className:`text-[length:calc(var(--ui-font-size)*10/7)] leading-[1.3] font-semibold tracking-[-.015em]`,children:c(`config:modelOnboarding.title`)}),(0,E.jsx)(_,{id:`model-onboarding-description`,className:`leading-6`,children:c(`config:modelOnboarding.description`)})]})]}),(0,E.jsx)(f,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`absolute top-3 right-3 pointer-coarse:size-11`,"aria-label":c(`common:ui.closeDialog`),title:c(`common:ui.closeDialog`),onClick:t,children:(0,E.jsx)(u,{})})]}),(0,E.jsxs)(`div`,{className:`grid gap-3 px-5 pt-2 pb-4 max-[650px]:px-4`,children:[(0,E.jsx)(`ol`,{className:`m-0 list-none divide-y divide-stroke-soft border-y border-stroke-soft p-0`,children:[{Icon:l,title:c(`config:modelOnboarding.connectionTitle`),description:c(`config:modelOnboarding.connectionDescription`)},{Icon:s,title:c(`config:modelOnboarding.modelTitle`),description:c(`config:modelOnboarding.modelDescription`)}].map(({Icon:e,title:t,description:n},r)=>(0,E.jsxs)(`li`,{className:`flex items-start gap-3 py-3`,children:[(0,E.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-7 shrink-0 place-items-center rounded-full bg-surface-subtle text-xs font-medium text-content-secondary tabular-nums`,children:r+1}),(0,E.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,E.jsxs)(`strong`,{className:`flex items-center gap-1.5 text-sm font-medium text-content`,children:[(0,E.jsx)(e,{className:`size-3.5 text-content-muted`,"aria-hidden":`true`}),t]}),(0,E.jsx)(`p`,{className:`text-xs leading-5 text-content-muted`,children:n})]})]},t))}),(0,E.jsxs)(f,{type:`button`,variant:`secondary`,className:`w-full max-[650px]:h-11`,onClick:n,children:[(0,E.jsx)(o,{}),c(`config:modelOnboarding.findExisting`)]})]}),(0,E.jsxs)(b,{className:`m-0 rounded-none px-5 pt-3 max-[650px]:px-4`,style:{paddingBottom:`max(env(safe-area-inset-bottom), 1rem)`},children:[(0,E.jsx)(f,{type:`button`,variant:`ghost`,className:`max-[650px]:h-11`,onClick:t,children:c(`config:modelOnboarding.later`)}),(0,E.jsxs)(f,{type:`button`,className:`max-[650px]:h-11`,onClick:i,children:[c(`config:modelOnboarding.openSettings`),(0,E.jsx)(a,{})]})]})]})})}export{D as ConfigSearchBox,O as ModelOnboardingDialog};
1
+ import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,r as n}from"./vendor-react-DwNgTV1j.js";import{t as r}from"./use-i18n-CbqEZb3r.js";import{t as i}from"./runtime-capabilities-store-1qxTCxHV.js";import{t as a}from"./arrow-right-DqLOhpA2.js";import{t as o}from"./download-BCfIiuaL.js";import{t as s}from"./key-round-C29uZbsf.js";import{t as c}from"./search-D0mqDaf_.js";import{t as l}from"./server-BgNvmqwJ.js";import{t as u}from"./x-07u4-129.js";import{t as d}from"./utils-C8uzG5AZ.js";import{t as f}from"./button-CCcCN8tE.js";import{t as p}from"./kbd-CAufZTkl.js";import{n as m,r as h}from"./config-search-1R0m2Dxn.js";import{s as g}from"./shortcuts-CctXrljf.js";import{a as _,i as v,l as y,o as b,s as x,t as S}from"./dialog-C6pJ93kY.js";import{t as C}from"./input-CPw-zkYh.js";import{t as w}from"./BrandLogo-k3CvJjd4.js";var T=e(t(),1),E=n();function D({query:e,onQueryChange:t,onSelect:n,inputRef:a,placement:o=`toolbar`}){let{t:s,language:l}=r(),[u,f]=(0,T.useState)(!1),[_,v]=(0,T.useState)(0),y=(0,T.useRef)(null),b=i(e=>e.capabilities),x=g(`focusSearch`),S=(0,T.useMemo)(()=>h(e,l,{capabilities:b,mobileApp:!!window.__PISPER_MOBILE_APP__}),[l,e,b]);(0,T.useEffect)(()=>v(0),[e]),(0,T.useEffect)(()=>{if(!u)return;let e=e=>{y.current&&!y.current.contains(e.target)&&f(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[u]);let w=e=>{if(f(!1),t(``),e.entry.card===`interface-custom-ui`){n(e.entry.section,`widgets`);return}m(e.entry.card,e.entry.section,{targetId:e.entry.targetId,targetText:e.title,expandGroup:e.entry.expandGroup}),n(e.entry.section)},D=u&&e.trim().length>0;return(0,E.jsxs)(`div`,{ref:y,className:d(`relative`,o===`sidebar`?`w-full`:`w-[min(250px,24vw)] max-[900px]:w-[190px] max-[650px]:col-start-1 max-[650px]:row-start-1 max-[650px]:w-full max-[650px]:min-w-0`),children:[(0,E.jsx)(c,{size:15,"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-2.5 -translate-y-1/2 text-content-muted`}),(0,E.jsx)(C,{ref:a,value:e,title:s(`navigation:pageHeader.search`),"aria-label":s(`navigation:pageHeader.search`),className:d(`pl-8 text-sm`,o!==`sidebar`&&`max-[650px]:h-11 max-[650px]:text-[16px]`,o===`sidebar`&&`h-8 border-key-border bg-key pr-9 text-ellipsis shadow-key`),placeholder:s(o===`sidebar`?`config:configSearch.placeholderShort`:`config:configSearch.placeholder`),onChange:e=>{t(e.target.value),f(!0)},onFocus:()=>{e.trim()&&f(!0)},onKeyDown:e=>{e.key===`Escape`?(e.stopPropagation(),t(``),f(!1)):e.key===`ArrowDown`?(e.preventDefault(),v(e=>Math.min(e+1,S.length-1))):e.key===`ArrowUp`?(e.preventDefault(),v(e=>Math.max(e-1,0))):e.key===`Enter`&&S[_]&&(e.preventDefault(),w(S[_]))}}),o===`sidebar`&&x&&!e&&(0,E.jsx)(p,{className:`absolute top-1/2 right-2 -translate-y-1/2 pointer-coarse:hidden`,children:x}),D&&(0,E.jsx)(`div`,{className:`absolute top-full left-0 z-50 mt-1.5 w-full overflow-hidden rounded-md bg-solid shadow-float`,children:S.length===0?(0,E.jsx)(`p`,{role:`status`,className:`px-3 py-3 text-xs text-content-muted`,children:s(`config:configSearch.noResults`)}):(0,E.jsx)(`ul`,{className:`max-h-[280px] overflow-auto py-1`,children:S.map((e,t)=>(0,E.jsx)(`li`,{children:(0,E.jsxs)(`button`,{type:`button`,className:d(`flex w-full flex-col gap-0.5 px-3 py-1.5 text-left pointer-coarse:min-h-11`,t===_?`bg-surface-hover`:`hover:bg-surface-subtle`),onMouseEnter:()=>v(t),onClick:()=>w(e),children:[(0,E.jsx)(`span`,{className:`text-sm text-content`,children:e.title}),(0,E.jsx)(`span`,{className:`text-xs text-content-muted`,children:e.sectionTitle})]})},e.entry.id))})})]})}function O({open:e,onDismiss:t,onOpenImport:n,onOpenSettings:i}){let{t:c}=r();return(0,E.jsx)(S,{open:e,onOpenChange:e=>!e&&t(),children:(0,E.jsxs)(v,{showCloseButton:!1,overlayClassName:`z-[220]`,className:`z-[220] gap-0 rounded-[var(--r-lg)] border border-stroke bg-solid p-0`,style:{maxWidth:`min(28rem, calc(100vw - max(1rem, env(safe-area-inset-left), env(safe-area-inset-right)) - max(1rem, env(safe-area-inset-left), env(safe-area-inset-right))))`,maxHeight:`calc(100dvh - max(1rem, env(safe-area-inset-top), env(safe-area-inset-bottom)) - max(1rem, env(safe-area-inset-top), env(safe-area-inset-bottom)))`},"aria-describedby":`model-onboarding-description`,children:[(0,E.jsxs)(`div`,{className:`relative px-5 pt-5 pb-2 max-[650px]:px-4 max-[650px]:pt-4`,children:[(0,E.jsxs)(x,{className:`gap-3 pr-9 text-left`,children:[(0,E.jsx)(`span`,{"aria-hidden":`true`,className:`w-fit rounded-[13px] shadow-raise`,children:(0,E.jsx)(w,{size:44})}),(0,E.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,E.jsx)(`p`,{className:`text-xs font-medium text-content-muted`,children:c(`config:modelOnboarding.eyebrow`)}),(0,E.jsx)(y,{className:`text-[length:calc(var(--ui-font-size)*10/7)] leading-[1.3] font-semibold tracking-[-.015em]`,children:c(`config:modelOnboarding.title`)}),(0,E.jsx)(_,{id:`model-onboarding-description`,className:`leading-6`,children:c(`config:modelOnboarding.description`)})]})]}),(0,E.jsx)(f,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`absolute top-3 right-3 pointer-coarse:size-11`,"aria-label":c(`common:ui.closeDialog`),title:c(`common:ui.closeDialog`),onClick:t,children:(0,E.jsx)(u,{})})]}),(0,E.jsxs)(`div`,{className:`grid gap-3 px-5 pt-2 pb-4 max-[650px]:px-4`,children:[(0,E.jsx)(`ol`,{className:`m-0 list-none divide-y divide-stroke-soft border-y border-stroke-soft p-0`,children:[{Icon:l,title:c(`config:modelOnboarding.connectionTitle`),description:c(`config:modelOnboarding.connectionDescription`)},{Icon:s,title:c(`config:modelOnboarding.modelTitle`),description:c(`config:modelOnboarding.modelDescription`)}].map(({Icon:e,title:t,description:n},r)=>(0,E.jsxs)(`li`,{className:`flex items-start gap-3 py-3`,children:[(0,E.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-7 shrink-0 place-items-center rounded-full bg-surface-subtle text-xs font-medium text-content-secondary tabular-nums`,children:r+1}),(0,E.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,E.jsxs)(`strong`,{className:`flex items-center gap-1.5 text-sm font-medium text-content`,children:[(0,E.jsx)(e,{className:`size-3.5 text-content-muted`,"aria-hidden":`true`}),t]}),(0,E.jsx)(`p`,{className:`text-xs leading-5 text-content-muted`,children:n})]})]},t))}),(0,E.jsxs)(f,{type:`button`,variant:`secondary`,className:`w-full max-[650px]:h-11`,onClick:n,children:[(0,E.jsx)(o,{}),c(`config:modelOnboarding.findExisting`)]})]}),(0,E.jsxs)(b,{className:`m-0 rounded-none px-5 pt-3 max-[650px]:px-4`,style:{paddingBottom:`max(env(safe-area-inset-bottom), 1rem)`},children:[(0,E.jsx)(f,{type:`button`,variant:`ghost`,className:`max-[650px]:h-11`,onClick:t,children:c(`config:modelOnboarding.later`)}),(0,E.jsxs)(f,{type:`button`,className:`max-[650px]:h-11`,onClick:i,children:[c(`config:modelOnboarding.openSettings`),(0,E.jsx)(a,{})]})]})]})})}export{D as ConfigSearchBox,O as ModelOnboardingDialog};
@@ -0,0 +1 @@
1
+ import{r as e}from"./GitDiffViewer-DDd2yMvx.js";export{e as InlineGitDiff};
@@ -0,0 +1 @@
1
+ import"./events-BrkEbuk_.js";