botmux 3.16.0 → 3.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (619) hide show
  1. package/dist/.runtime-build-id +1 -1
  2. package/dist/adapters/backend/riff-backend.d.ts +84 -1
  3. package/dist/adapters/backend/riff-backend.d.ts.map +1 -1
  4. package/dist/adapters/backend/riff-backend.js +202 -19
  5. package/dist/adapters/backend/riff-backend.js.map +1 -1
  6. package/dist/adapters/backend/sandbox.d.ts +8 -0
  7. package/dist/adapters/backend/sandbox.d.ts.map +1 -1
  8. package/dist/adapters/backend/sandbox.js +15 -0
  9. package/dist/adapters/backend/sandbox.js.map +1 -1
  10. package/dist/adapters/backend/tmux-backend.d.ts +61 -7
  11. package/dist/adapters/backend/tmux-backend.d.ts.map +1 -1
  12. package/dist/adapters/backend/tmux-backend.js +80 -9
  13. package/dist/adapters/backend/tmux-backend.js.map +1 -1
  14. package/dist/adapters/backend/tmux-pipe-backend.d.ts +62 -4
  15. package/dist/adapters/backend/tmux-pipe-backend.d.ts.map +1 -1
  16. package/dist/adapters/backend/tmux-pipe-backend.js +240 -27
  17. package/dist/adapters/backend/tmux-pipe-backend.js.map +1 -1
  18. package/dist/adapters/cli/claude-code.d.ts.map +1 -1
  19. package/dist/adapters/cli/claude-code.js +4 -2
  20. package/dist/adapters/cli/claude-code.js.map +1 -1
  21. package/dist/adapters/cli/coco.d.ts.map +1 -1
  22. package/dist/adapters/cli/coco.js +27 -0
  23. package/dist/adapters/cli/coco.js.map +1 -1
  24. package/dist/adapters/cli/codex-app.d.ts.map +1 -1
  25. package/dist/adapters/cli/codex-app.js +28 -0
  26. package/dist/adapters/cli/codex-app.js.map +1 -1
  27. package/dist/adapters/cli/codex.d.ts.map +1 -1
  28. package/dist/adapters/cli/codex.js +51 -23
  29. package/dist/adapters/cli/codex.js.map +1 -1
  30. package/dist/adapters/cli/dsh-tui.d.ts +24 -0
  31. package/dist/adapters/cli/dsh-tui.d.ts.map +1 -0
  32. package/dist/adapters/cli/dsh-tui.js +99 -0
  33. package/dist/adapters/cli/dsh-tui.js.map +1 -0
  34. package/dist/adapters/cli/dsh.d.ts.map +1 -1
  35. package/dist/adapters/cli/dsh.js +15 -9
  36. package/dist/adapters/cli/dsh.js.map +1 -1
  37. package/dist/adapters/cli/fs-policy.d.ts +98 -1
  38. package/dist/adapters/cli/fs-policy.d.ts.map +1 -1
  39. package/dist/adapters/cli/fs-policy.js +182 -7
  40. package/dist/adapters/cli/fs-policy.js.map +1 -1
  41. package/dist/adapters/cli/grok.js +16 -18
  42. package/dist/adapters/cli/grok.js.map +1 -1
  43. package/dist/adapters/cli/model-catalog-json.d.ts +17 -0
  44. package/dist/adapters/cli/model-catalog-json.d.ts.map +1 -0
  45. package/dist/adapters/cli/model-catalog-json.js +43 -0
  46. package/dist/adapters/cli/model-catalog-json.js.map +1 -0
  47. package/dist/adapters/cli/oh-my-pi.d.ts +2 -0
  48. package/dist/adapters/cli/oh-my-pi.d.ts.map +1 -1
  49. package/dist/adapters/cli/oh-my-pi.js +45 -13
  50. package/dist/adapters/cli/oh-my-pi.js.map +1 -1
  51. package/dist/adapters/cli/opencode.js +1 -1
  52. package/dist/adapters/cli/opencode.js.map +1 -1
  53. package/dist/adapters/cli/registry.d.ts +2 -1
  54. package/dist/adapters/cli/registry.d.ts.map +1 -1
  55. package/dist/adapters/cli/registry.js +6 -1
  56. package/dist/adapters/cli/registry.js.map +1 -1
  57. package/dist/adapters/cli/relay.d.ts.map +1 -1
  58. package/dist/adapters/cli/relay.js +7 -0
  59. package/dist/adapters/cli/relay.js.map +1 -1
  60. package/dist/adapters/cli/seed.d.ts.map +1 -1
  61. package/dist/adapters/cli/seed.js +6 -0
  62. package/dist/adapters/cli/seed.js.map +1 -1
  63. package/dist/adapters/cli/shared-hints.d.ts.map +1 -1
  64. package/dist/adapters/cli/shared-hints.js +20 -14
  65. package/dist/adapters/cli/shared-hints.js.map +1 -1
  66. package/dist/adapters/cli/traex.d.ts +4 -0
  67. package/dist/adapters/cli/traex.d.ts.map +1 -1
  68. package/dist/adapters/cli/traex.js +153 -0
  69. package/dist/adapters/cli/traex.js.map +1 -1
  70. package/dist/adapters/cli/types.d.ts +42 -1
  71. package/dist/adapters/cli/types.d.ts.map +1 -1
  72. package/dist/autostart.d.ts +6 -0
  73. package/dist/autostart.d.ts.map +1 -1
  74. package/dist/autostart.js +21 -1
  75. package/dist/autostart.js.map +1 -1
  76. package/dist/bot-registry.d.ts +27 -0
  77. package/dist/bot-registry.d.ts.map +1 -1
  78. package/dist/bot-registry.js +62 -2
  79. package/dist/bot-registry.js.map +1 -1
  80. package/dist/cli/vc-agent.d.ts.map +1 -1
  81. package/dist/cli/vc-agent.js +21 -3
  82. package/dist/cli/vc-agent.js.map +1 -1
  83. package/dist/cli.d.ts.map +1 -1
  84. package/dist/cli.js +92 -1
  85. package/dist/cli.js.map +1 -1
  86. package/dist/codex-app-runner.js +28 -0
  87. package/dist/codex-app-runner.js.map +1 -1
  88. package/dist/core/bot-steer-directive.d.ts +25 -0
  89. package/dist/core/bot-steer-directive.d.ts.map +1 -0
  90. package/dist/core/bot-steer-directive.js +47 -0
  91. package/dist/core/bot-steer-directive.js.map +1 -0
  92. package/dist/core/command-handler.d.ts.map +1 -1
  93. package/dist/core/command-handler.js +102 -18
  94. package/dist/core/command-handler.js.map +1 -1
  95. package/dist/core/dashboard-ipc-server.d.ts.map +1 -1
  96. package/dist/core/dashboard-ipc-server.js +53 -13
  97. package/dist/core/dashboard-ipc-server.js.map +1 -1
  98. package/dist/core/dashboard-rows.d.ts +3 -0
  99. package/dist/core/dashboard-rows.d.ts.map +1 -1
  100. package/dist/core/dashboard-rows.js +26 -5
  101. package/dist/core/dashboard-rows.js.map +1 -1
  102. package/dist/core/dashboard-url.d.ts +10 -1
  103. package/dist/core/dashboard-url.d.ts.map +1 -1
  104. package/dist/core/dashboard-url.js +12 -2
  105. package/dist/core/dashboard-url.js.map +1 -1
  106. package/dist/core/dispatch.d.ts.map +1 -1
  107. package/dist/core/dispatch.js +5 -4
  108. package/dist/core/dispatch.js.map +1 -1
  109. package/dist/core/existing-app-server.d.ts +22 -0
  110. package/dist/core/existing-app-server.d.ts.map +1 -0
  111. package/dist/core/existing-app-server.js +85 -0
  112. package/dist/core/existing-app-server.js.map +1 -0
  113. package/dist/core/native-topic-id.d.ts +9 -0
  114. package/dist/core/native-topic-id.d.ts.map +1 -0
  115. package/dist/core/native-topic-id.js +14 -0
  116. package/dist/core/native-topic-id.js.map +1 -0
  117. package/dist/core/per-bot-env.d.ts.map +1 -1
  118. package/dist/core/per-bot-env.js +10 -0
  119. package/dist/core/per-bot-env.js.map +1 -1
  120. package/dist/core/plugins/mcp/gateway.d.ts +27 -3
  121. package/dist/core/plugins/mcp/gateway.d.ts.map +1 -1
  122. package/dist/core/plugins/mcp/gateway.js +272 -26
  123. package/dist/core/plugins/mcp/gateway.js.map +1 -1
  124. package/dist/core/plugins/mcp/host.d.ts +18 -0
  125. package/dist/core/plugins/mcp/host.d.ts.map +1 -1
  126. package/dist/core/plugins/mcp/host.js +80 -16
  127. package/dist/core/plugins/mcp/host.js.map +1 -1
  128. package/dist/core/plugins/mcp/launch-record.d.ts +14 -0
  129. package/dist/core/plugins/mcp/launch-record.d.ts.map +1 -0
  130. package/dist/core/plugins/mcp/launch-record.js +63 -0
  131. package/dist/core/plugins/mcp/launch-record.js.map +1 -0
  132. package/dist/core/session-activity.d.ts +11 -0
  133. package/dist/core/session-activity.d.ts.map +1 -1
  134. package/dist/core/session-activity.js +23 -0
  135. package/dist/core/session-activity.js.map +1 -1
  136. package/dist/core/session-group-birth.d.ts.map +1 -1
  137. package/dist/core/session-group-birth.js +23 -8
  138. package/dist/core/session-group-birth.js.map +1 -1
  139. package/dist/core/session-manager.d.ts +1 -4
  140. package/dist/core/session-manager.d.ts.map +1 -1
  141. package/dist/core/session-manager.js +16 -20
  142. package/dist/core/session-manager.js.map +1 -1
  143. package/dist/core/shared-adopt.d.ts +20 -0
  144. package/dist/core/shared-adopt.d.ts.map +1 -0
  145. package/dist/core/shared-adopt.js +26 -0
  146. package/dist/core/shared-adopt.js.map +1 -0
  147. package/dist/core/skills/customize-command.d.ts +7 -0
  148. package/dist/core/skills/customize-command.d.ts.map +1 -0
  149. package/dist/core/skills/customize-command.js +303 -0
  150. package/dist/core/skills/customize-command.js.map +1 -0
  151. package/dist/core/terminal-write-auth.d.ts +15 -0
  152. package/dist/core/terminal-write-auth.d.ts.map +1 -1
  153. package/dist/core/terminal-write-auth.js +15 -0
  154. package/dist/core/terminal-write-auth.js.map +1 -1
  155. package/dist/core/terminal-write-frame.d.ts +30 -0
  156. package/dist/core/terminal-write-frame.d.ts.map +1 -0
  157. package/dist/core/terminal-write-frame.js +44 -0
  158. package/dist/core/terminal-write-frame.js.map +1 -0
  159. package/dist/core/types.d.ts +14 -4
  160. package/dist/core/types.d.ts.map +1 -1
  161. package/dist/core/types.js +6 -8
  162. package/dist/core/types.js.map +1 -1
  163. package/dist/core/worker-pool.d.ts +31 -6
  164. package/dist/core/worker-pool.d.ts.map +1 -1
  165. package/dist/core/worker-pool.js +444 -102
  166. package/dist/core/worker-pool.js.map +1 -1
  167. package/dist/core/worker-startup-retry.d.ts +52 -0
  168. package/dist/core/worker-startup-retry.d.ts.map +1 -0
  169. package/dist/core/worker-startup-retry.js +68 -0
  170. package/dist/core/worker-startup-retry.js.map +1 -0
  171. package/dist/daemon.d.ts +9 -8
  172. package/dist/daemon.d.ts.map +1 -1
  173. package/dist/daemon.js +467 -171
  174. package/dist/daemon.js.map +1 -1
  175. package/dist/dashboard/autostart-api.d.ts +26 -0
  176. package/dist/dashboard/autostart-api.d.ts.map +1 -0
  177. package/dist/dashboard/autostart-api.js +88 -0
  178. package/dist/dashboard/autostart-api.js.map +1 -0
  179. package/dist/dashboard/bot-payload.d.ts +5 -0
  180. package/dist/dashboard/bot-payload.d.ts.map +1 -1
  181. package/dist/dashboard/bot-payload.js +2 -0
  182. package/dist/dashboard/bot-payload.js.map +1 -1
  183. package/dist/dashboard/control-csrf.d.ts +29 -1
  184. package/dist/dashboard/control-csrf.d.ts.map +1 -1
  185. package/dist/dashboard/control-csrf.js +49 -10
  186. package/dist/dashboard/control-csrf.js.map +1 -1
  187. package/dist/dashboard/customization-api.d.ts +23 -0
  188. package/dist/dashboard/customization-api.d.ts.map +1 -0
  189. package/dist/dashboard/customization-api.js +198 -0
  190. package/dist/dashboard/customization-api.js.map +1 -0
  191. package/dist/dashboard/debug-terminal.d.ts +13 -1
  192. package/dist/dashboard/debug-terminal.d.ts.map +1 -1
  193. package/dist/dashboard/debug-terminal.js +18 -4
  194. package/dist/dashboard/debug-terminal.js.map +1 -1
  195. package/dist/dashboard/settings-write-applier.d.ts +0 -23
  196. package/dist/dashboard/settings-write-applier.d.ts.map +1 -1
  197. package/dist/dashboard/settings-write-applier.js +7 -28
  198. package/dist/dashboard/settings-write-applier.js.map +1 -1
  199. package/dist/dashboard/terminal-control-route.d.ts +32 -0
  200. package/dist/dashboard/terminal-control-route.d.ts.map +1 -0
  201. package/dist/dashboard/terminal-control-route.js +70 -0
  202. package/dist/dashboard/terminal-control-route.js.map +1 -0
  203. package/dist/dashboard/terminal-control.d.ts +64 -13
  204. package/dist/dashboard/terminal-control.d.ts.map +1 -1
  205. package/dist/dashboard/terminal-control.js +77 -14
  206. package/dist/dashboard/terminal-control.js.map +1 -1
  207. package/dist/dashboard/terminal-front-proxy.d.ts.map +1 -1
  208. package/dist/dashboard/terminal-front-proxy.js +41 -9
  209. package/dist/dashboard/terminal-front-proxy.js.map +1 -1
  210. package/dist/dashboard/vc-consumer-profiles-api.d.ts +69 -18
  211. package/dist/dashboard/vc-consumer-profiles-api.d.ts.map +1 -1
  212. package/dist/dashboard/vc-consumer-profiles-api.js +149 -29
  213. package/dist/dashboard/vc-consumer-profiles-api.js.map +1 -1
  214. package/dist/dashboard/web/agent-workbench-api.d.ts +34 -2
  215. package/dist/dashboard/web/agent-workbench-api.d.ts.map +1 -1
  216. package/dist/dashboard/web/agent-workbench-api.js +39 -4
  217. package/dist/dashboard/web/agent-workbench-api.js.map +1 -1
  218. package/dist/dashboard/web/agent-workbench-appearance.d.ts +6 -3
  219. package/dist/dashboard/web/agent-workbench-appearance.d.ts.map +1 -1
  220. package/dist/dashboard/web/agent-workbench-appearance.js +7 -4
  221. package/dist/dashboard/web/agent-workbench-appearance.js.map +1 -1
  222. package/dist/dashboard/web/agent-workbench-model.d.ts +2 -0
  223. package/dist/dashboard/web/agent-workbench-model.d.ts.map +1 -1
  224. package/dist/dashboard/web/agent-workbench-model.js.map +1 -1
  225. package/dist/dashboard/web/agent-workbench-page.js +2 -2
  226. package/dist/dashboard/web/agent-workbench-page.js.map +1 -1
  227. package/dist/dashboard/web/agent-workbench-panes.d.ts +59 -4
  228. package/dist/dashboard/web/agent-workbench-panes.d.ts.map +1 -1
  229. package/dist/dashboard/web/agent-workbench-panes.js +493 -85
  230. package/dist/dashboard/web/agent-workbench-panes.js.map +1 -1
  231. package/dist/dashboard/web/agent-workbench-session-list.d.ts +11 -7
  232. package/dist/dashboard/web/agent-workbench-session-list.d.ts.map +1 -1
  233. package/dist/dashboard/web/agent-workbench-session-list.js +24 -31
  234. package/dist/dashboard/web/agent-workbench-session-list.js.map +1 -1
  235. package/dist/dashboard/web/agent-workbench-terminal-control.d.ts +198 -0
  236. package/dist/dashboard/web/agent-workbench-terminal-control.d.ts.map +1 -0
  237. package/dist/dashboard/web/agent-workbench-terminal-control.js +292 -0
  238. package/dist/dashboard/web/agent-workbench-terminal-control.js.map +1 -0
  239. package/dist/dashboard/web/agent-workbench-view.d.ts +3 -2
  240. package/dist/dashboard/web/agent-workbench-view.d.ts.map +1 -1
  241. package/dist/dashboard/web/agent-workbench-view.js +69 -50
  242. package/dist/dashboard/web/agent-workbench-view.js.map +1 -1
  243. package/dist/dashboard/web/app.d.ts.map +1 -1
  244. package/dist/dashboard/web/app.js +58 -7
  245. package/dist/dashboard/web/app.js.map +1 -1
  246. package/dist/dashboard/web/bot-defaults-page.d.ts +24 -0
  247. package/dist/dashboard/web/bot-defaults-page.d.ts.map +1 -1
  248. package/dist/dashboard/web/bot-defaults-page.js +191 -16
  249. package/dist/dashboard/web/bot-defaults-page.js.map +1 -1
  250. package/dist/dashboard/web/bot-defaults.d.ts +17 -0
  251. package/dist/dashboard/web/bot-defaults.d.ts.map +1 -1
  252. package/dist/dashboard/web/bot-defaults.js +51 -2
  253. package/dist/dashboard/web/bot-defaults.js.map +1 -1
  254. package/dist/dashboard/web/bot-onboarding.d.ts.map +1 -1
  255. package/dist/dashboard/web/bot-onboarding.js +32 -8
  256. package/dist/dashboard/web/bot-onboarding.js.map +1 -1
  257. package/dist/dashboard/web/confirm-modal.d.ts +35 -0
  258. package/dist/dashboard/web/confirm-modal.d.ts.map +1 -0
  259. package/dist/dashboard/web/confirm-modal.js +111 -0
  260. package/dist/dashboard/web/confirm-modal.js.map +1 -0
  261. package/dist/dashboard/web/connectors-page.d.ts.map +1 -1
  262. package/dist/dashboard/web/connectors-page.js +2 -1
  263. package/dist/dashboard/web/connectors-page.js.map +1 -1
  264. package/dist/dashboard/web/customization-page.d.ts +3 -0
  265. package/dist/dashboard/web/customization-page.d.ts.map +1 -0
  266. package/dist/dashboard/web/customization-page.js +315 -0
  267. package/dist/dashboard/web/customization-page.js.map +1 -0
  268. package/dist/dashboard/web/dashboard-routes.d.ts.map +1 -1
  269. package/dist/dashboard/web/dashboard-routes.js +1 -0
  270. package/dist/dashboard/web/dashboard-routes.js.map +1 -1
  271. package/dist/dashboard/web/groups-page.d.ts.map +1 -1
  272. package/dist/dashboard/web/groups-page.js +11 -9
  273. package/dist/dashboard/web/groups-page.js.map +1 -1
  274. package/dist/dashboard/web/i18n.d.ts.map +1 -1
  275. package/dist/dashboard/web/i18n.js +226 -42
  276. package/dist/dashboard/web/i18n.js.map +1 -1
  277. package/dist/dashboard/web/monitor-room.d.ts.map +1 -1
  278. package/dist/dashboard/web/monitor-room.js +3 -2
  279. package/dist/dashboard/web/monitor-room.js.map +1 -1
  280. package/dist/dashboard/web/overview-page.d.ts.map +1 -1
  281. package/dist/dashboard/web/overview-page.js +98 -63
  282. package/dist/dashboard/web/overview-page.js.map +1 -1
  283. package/dist/dashboard/web/roles-page.d.ts.map +1 -1
  284. package/dist/dashboard/web/roles-page.js +4 -3
  285. package/dist/dashboard/web/roles-page.js.map +1 -1
  286. package/dist/dashboard/web/schedules-page.d.ts.map +1 -1
  287. package/dist/dashboard/web/schedules-page.js +165 -18
  288. package/dist/dashboard/web/schedules-page.js.map +1 -1
  289. package/dist/dashboard/web/sessions-kanban.d.ts +2 -0
  290. package/dist/dashboard/web/sessions-kanban.d.ts.map +1 -1
  291. package/dist/dashboard/web/sessions-kanban.js +142 -24
  292. package/dist/dashboard/web/sessions-kanban.js.map +1 -1
  293. package/dist/dashboard/web/sessions-page.d.ts.map +1 -1
  294. package/dist/dashboard/web/sessions-page.js +177 -94
  295. package/dist/dashboard/web/sessions-page.js.map +1 -1
  296. package/dist/dashboard/web/sessions.d.ts.map +1 -1
  297. package/dist/dashboard/web/sessions.js +5 -4
  298. package/dist/dashboard/web/sessions.js.map +1 -1
  299. package/dist/dashboard/web/settings-page.d.ts +0 -8
  300. package/dist/dashboard/web/settings-page.d.ts.map +1 -1
  301. package/dist/dashboard/web/settings-page.js +185 -65
  302. package/dist/dashboard/web/settings-page.js.map +1 -1
  303. package/dist/dashboard/web/skills/skill-library-tab.d.ts +2 -0
  304. package/dist/dashboard/web/skills/skill-library-tab.d.ts.map +1 -1
  305. package/dist/dashboard/web/skills/skill-library-tab.js +15 -1
  306. package/dist/dashboard/web/skills/skill-library-tab.js.map +1 -1
  307. package/dist/dashboard/web/skills-page.d.ts.map +1 -1
  308. package/dist/dashboard/web/skills-page.js +5 -4
  309. package/dist/dashboard/web/skills-page.js.map +1 -1
  310. package/dist/dashboard/web/store.d.ts +5 -0
  311. package/dist/dashboard/web/store.d.ts.map +1 -1
  312. package/dist/dashboard/web/store.js +4 -0
  313. package/dist/dashboard/web/store.js.map +1 -1
  314. package/dist/dashboard/web/team-federation-page.d.ts.map +1 -1
  315. package/dist/dashboard/web/team-federation-page.js +3 -2
  316. package/dist/dashboard/web/team-federation-page.js.map +1 -1
  317. package/dist/dashboard/web/toast.d.ts +15 -0
  318. package/dist/dashboard/web/toast.d.ts.map +1 -0
  319. package/dist/dashboard/web/toast.js +70 -0
  320. package/dist/dashboard/web/toast.js.map +1 -0
  321. package/dist/dashboard/web/v3-components.d.ts.map +1 -1
  322. package/dist/dashboard/web/v3-components.js +2 -1
  323. package/dist/dashboard/web/v3-components.js.map +1 -1
  324. package/dist/dashboard/web/vc-consumer-profiles-section.d.ts +10 -12
  325. package/dist/dashboard/web/vc-consumer-profiles-section.d.ts.map +1 -1
  326. package/dist/dashboard/web/vc-consumer-profiles-section.js +219 -200
  327. package/dist/dashboard/web/vc-consumer-profiles-section.js.map +1 -1
  328. package/dist/dashboard/web/whiteboards-page.d.ts.map +1 -1
  329. package/dist/dashboard/web/whiteboards-page.js +2 -1
  330. package/dist/dashboard/web/whiteboards-page.js.map +1 -1
  331. package/dist/dashboard-web/app.js +1 -1
  332. package/dist/dashboard-web/chunks/agent-workbench-dock-page-LZSUOCEQ.js +1 -0
  333. package/dist/dashboard-web/chunks/agent-workbench-page-YONDRJU7.js +1 -0
  334. package/dist/dashboard-web/chunks/bot-defaults-page-X7LV6373.js +1 -0
  335. package/dist/dashboard-web/chunks/chunk-2PVRDXEL.js +1 -0
  336. package/dist/dashboard-web/chunks/chunk-53JUKBU2.js +10 -0
  337. package/dist/dashboard-web/chunks/{chunk-5CJMHTT4.js → chunk-5QX4OYOR.js} +1 -1
  338. package/dist/dashboard-web/chunks/{chunk-NACP7BMR.js → chunk-5VRVJFQR.js} +1 -1
  339. package/dist/dashboard-web/chunks/{chunk-FDZ7WOBW.js → chunk-6ROOZWYV.js} +1 -1
  340. package/dist/dashboard-web/chunks/{chunk-F6KNPF4R.js → chunk-CK22743G.js} +15 -19
  341. package/dist/dashboard-web/chunks/chunk-CVNIMUPY.js +25 -0
  342. package/dist/dashboard-web/chunks/chunk-GJC2TMWS.js +2 -0
  343. package/dist/dashboard-web/chunks/chunk-OT6L6G7R.js +1 -0
  344. package/dist/dashboard-web/chunks/chunk-QITAMHW6.js +1 -0
  345. package/dist/dashboard-web/chunks/chunk-RHVFZC5Z.js +1 -0
  346. package/dist/dashboard-web/chunks/chunk-SOBMN2VY.js +1 -0
  347. package/dist/dashboard-web/chunks/chunk-SZOB6VK2.js +1 -0
  348. package/dist/dashboard-web/chunks/chunk-XVIXNQGC.js +44 -0
  349. package/dist/dashboard-web/chunks/chunk-YUJF34ME.js +1 -0
  350. package/dist/dashboard-web/chunks/connectors-page-LB2HEJ7F.js +1 -0
  351. package/dist/dashboard-web/chunks/customization-page-4GXBYLG6.js +105 -0
  352. package/dist/dashboard-web/chunks/feedback-page-IZQ7VLDG.js +1 -0
  353. package/dist/dashboard-web/chunks/groups-page-4WCP5OEV.js +8 -0
  354. package/dist/dashboard-web/chunks/{insights-page-HJFDYR5N.js → insights-page-TXQHIPQL.js} +1 -1
  355. package/dist/dashboard-web/chunks/{monitor-room-V7PCP47V.js → monitor-room-VBRVWXCM.js} +8 -8
  356. package/dist/dashboard-web/chunks/monitoring-page-QDDZWERE.js +2 -0
  357. package/dist/dashboard-web/chunks/office-page-PENFNYPG.js +1 -0
  358. package/dist/dashboard-web/chunks/overview-page-BZQDP6MP.js +1 -0
  359. package/dist/dashboard-web/chunks/plugin-page-JX4GSWZS.js +1 -0
  360. package/dist/dashboard-web/chunks/roles-page-VPNINZNK.js +1 -0
  361. package/dist/dashboard-web/chunks/schedules-page-BITO6HEA.js +1 -0
  362. package/dist/dashboard-web/chunks/sessions-page-ZKCOVTD2.js +8 -0
  363. package/dist/dashboard-web/chunks/settings-page-UT6JDTS6.js +2 -0
  364. package/dist/dashboard-web/chunks/skills-page-GULXVAJY.js +4 -0
  365. package/dist/dashboard-web/chunks/team-federation-page-CUUJWGEG.js +1 -0
  366. package/dist/dashboard-web/chunks/v3-page-5WVJ5AUR.js +94 -0
  367. package/dist/dashboard-web/chunks/whiteboards-page-FZ2CME4H.js +1 -0
  368. package/dist/dashboard-web/design-tokens.css +236 -0
  369. package/dist/dashboard-web/index.html +1 -0
  370. package/dist/dashboard-web/style.css +1930 -114
  371. package/dist/dashboard.js +360 -279
  372. package/dist/dashboard.js.map +1 -1
  373. package/dist/desktop/renderer/app.js +6 -0
  374. package/dist/desktop/renderer/app.js.map +1 -1
  375. package/dist/dsh-runner.js +139 -17
  376. package/dist/dsh-runner.js.map +1 -1
  377. package/dist/global-config.d.ts +33 -2
  378. package/dist/global-config.d.ts.map +1 -1
  379. package/dist/global-config.js +62 -0
  380. package/dist/global-config.js.map +1 -1
  381. package/dist/i18n/en.d.ts.map +1 -1
  382. package/dist/i18n/en.js +13 -4
  383. package/dist/i18n/en.js.map +1 -1
  384. package/dist/i18n/index.d.ts +27 -3
  385. package/dist/i18n/index.d.ts.map +1 -1
  386. package/dist/i18n/index.js +33 -4
  387. package/dist/i18n/index.js.map +1 -1
  388. package/dist/i18n/zh.d.ts.map +1 -1
  389. package/dist/i18n/zh.js +13 -4
  390. package/dist/i18n/zh.js.map +1 -1
  391. package/dist/im/lark/card-builder.d.ts +2 -0
  392. package/dist/im/lark/card-builder.d.ts.map +1 -1
  393. package/dist/im/lark/card-builder.js +7 -4
  394. package/dist/im/lark/card-builder.js.map +1 -1
  395. package/dist/im/lark/card-handler.d.ts.map +1 -1
  396. package/dist/im/lark/card-handler.js +135 -20
  397. package/dist/im/lark/card-handler.js.map +1 -1
  398. package/dist/im/lark/event-dispatcher.d.ts +38 -3
  399. package/dist/im/lark/event-dispatcher.d.ts.map +1 -1
  400. package/dist/im/lark/event-dispatcher.js +163 -13
  401. package/dist/im/lark/event-dispatcher.js.map +1 -1
  402. package/dist/im/lark/v3-blocked-card-handler.d.ts.map +1 -1
  403. package/dist/im/lark/v3-blocked-card-handler.js +2 -1
  404. package/dist/im/lark/v3-blocked-card-handler.js.map +1 -1
  405. package/dist/im/lark/v3-blocked-card.d.ts +1 -1
  406. package/dist/im/lark/v3-blocked-card.d.ts.map +1 -1
  407. package/dist/im/lark/v3-blocked-card.js +14 -0
  408. package/dist/im/lark/v3-blocked-card.js.map +1 -1
  409. package/dist/index-core-only.js +2 -0
  410. package/dist/index-core-only.js.map +1 -1
  411. package/dist/index-daemon.js +3 -0
  412. package/dist/index-daemon.js.map +1 -1
  413. package/dist/platform/binding.d.ts +37 -0
  414. package/dist/platform/binding.d.ts.map +1 -1
  415. package/dist/platform/binding.js +15 -0
  416. package/dist/platform/binding.js.map +1 -1
  417. package/dist/services/bridge-turn-journal.d.ts +63 -0
  418. package/dist/services/bridge-turn-journal.d.ts.map +1 -0
  419. package/dist/services/bridge-turn-journal.js +149 -0
  420. package/dist/services/bridge-turn-journal.js.map +1 -0
  421. package/dist/services/bridge-turn-queue.d.ts +8 -1
  422. package/dist/services/bridge-turn-queue.d.ts.map +1 -1
  423. package/dist/services/bridge-turn-queue.js +2 -1
  424. package/dist/services/bridge-turn-queue.js.map +1 -1
  425. package/dist/services/codex-app-runner-protocol.d.ts +5 -0
  426. package/dist/services/codex-app-runner-protocol.d.ts.map +1 -1
  427. package/dist/services/codex-app-runner-protocol.js +5 -0
  428. package/dist/services/codex-app-runner-protocol.js.map +1 -1
  429. package/dist/services/customization-store.d.ts +93 -0
  430. package/dist/services/customization-store.d.ts.map +1 -0
  431. package/dist/services/customization-store.js +542 -0
  432. package/dist/services/customization-store.js.map +1 -0
  433. package/dist/services/file-bridge-path.d.ts.map +1 -1
  434. package/dist/services/file-bridge-path.js +3 -0
  435. package/dist/services/file-bridge-path.js.map +1 -1
  436. package/dist/services/grok-transcript.d.ts.map +1 -1
  437. package/dist/services/grok-transcript.js +44 -9
  438. package/dist/services/grok-transcript.js.map +1 -1
  439. package/dist/services/local-cli-opener.d.ts.map +1 -1
  440. package/dist/services/local-cli-opener.js +12 -3
  441. package/dist/services/local-cli-opener.js.map +1 -1
  442. package/dist/services/model-catalog.d.ts +54 -0
  443. package/dist/services/model-catalog.d.ts.map +1 -0
  444. package/dist/services/model-catalog.js +147 -0
  445. package/dist/services/model-catalog.js.map +1 -0
  446. package/dist/services/omp-transcript.d.ts +27 -0
  447. package/dist/services/omp-transcript.d.ts.map +1 -0
  448. package/dist/services/omp-transcript.js +214 -0
  449. package/dist/services/omp-transcript.js.map +1 -0
  450. package/dist/services/platform-team-store.d.ts +16 -8
  451. package/dist/services/platform-team-store.d.ts.map +1 -1
  452. package/dist/services/platform-team-store.js +17 -10
  453. package/dist/services/platform-team-store.js.map +1 -1
  454. package/dist/services/project-scanner.d.ts.map +1 -1
  455. package/dist/services/project-scanner.js +13 -8
  456. package/dist/services/project-scanner.js.map +1 -1
  457. package/dist/services/resumable-session-discovery.d.ts.map +1 -1
  458. package/dist/services/resumable-session-discovery.js +117 -35
  459. package/dist/services/resumable-session-discovery.js.map +1 -1
  460. package/dist/services/structured-bridge-clis.d.ts +5 -3
  461. package/dist/services/structured-bridge-clis.d.ts.map +1 -1
  462. package/dist/services/structured-bridge-clis.js +5 -1
  463. package/dist/services/structured-bridge-clis.js.map +1 -1
  464. package/dist/services/vc-meeting-action-gate.d.ts.map +1 -1
  465. package/dist/services/vc-meeting-action-gate.js +15 -4
  466. package/dist/services/vc-meeting-action-gate.js.map +1 -1
  467. package/dist/services/vc-meeting-consumer-profile-bootstrap.d.ts +46 -66
  468. package/dist/services/vc-meeting-consumer-profile-bootstrap.d.ts.map +1 -1
  469. package/dist/services/vc-meeting-consumer-profile-bootstrap.js +33 -292
  470. package/dist/services/vc-meeting-consumer-profile-bootstrap.js.map +1 -1
  471. package/dist/services/vc-meeting-consumer-profile-templates.js +3 -3
  472. package/dist/services/vc-meeting-consumer-profile-templates.js.map +1 -1
  473. package/dist/services/vc-meeting-delivery-store.d.ts +18 -0
  474. package/dist/services/vc-meeting-delivery-store.d.ts.map +1 -1
  475. package/dist/services/vc-meeting-delivery-store.js +55 -0
  476. package/dist/services/vc-meeting-delivery-store.js.map +1 -1
  477. package/dist/services/vc-meeting-send-policy.d.ts +21 -1
  478. package/dist/services/vc-meeting-send-policy.d.ts.map +1 -1
  479. package/dist/services/vc-meeting-send-policy.js +30 -2
  480. package/dist/services/vc-meeting-send-policy.js.map +1 -1
  481. package/dist/services/vc-meeting-shared-consumer-catalog-store.d.ts +78 -0
  482. package/dist/services/vc-meeting-shared-consumer-catalog-store.d.ts.map +1 -0
  483. package/dist/services/vc-meeting-shared-consumer-catalog-store.js +227 -0
  484. package/dist/services/vc-meeting-shared-consumer-catalog-store.js.map +1 -0
  485. package/dist/services/vc-meeting-shared-consumer-catalog.d.ts +53 -0
  486. package/dist/services/vc-meeting-shared-consumer-catalog.d.ts.map +1 -0
  487. package/dist/services/vc-meeting-shared-consumer-catalog.js +161 -0
  488. package/dist/services/vc-meeting-shared-consumer-catalog.js.map +1 -0
  489. package/dist/setup/bot-config-editor.d.ts.map +1 -1
  490. package/dist/setup/bot-config-editor.js +1 -0
  491. package/dist/setup/bot-config-editor.js.map +1 -1
  492. package/dist/setup/open-platform-automation.d.ts +20 -0
  493. package/dist/setup/open-platform-automation.d.ts.map +1 -1
  494. package/dist/setup/open-platform-automation.js +27 -0
  495. package/dist/setup/open-platform-automation.js.map +1 -1
  496. package/dist/skills/customization-bundle.d.ts +83 -0
  497. package/dist/skills/customization-bundle.d.ts.map +1 -0
  498. package/dist/skills/customization-bundle.js +214 -0
  499. package/dist/skills/customization-bundle.js.map +1 -0
  500. package/dist/skills/definitions.d.ts.map +1 -1
  501. package/dist/skills/definitions.js +10 -3
  502. package/dist/skills/definitions.js.map +1 -1
  503. package/dist/skills/effective-builtins.d.ts +38 -0
  504. package/dist/skills/effective-builtins.d.ts.map +1 -0
  505. package/dist/skills/effective-builtins.js +96 -0
  506. package/dist/skills/effective-builtins.js.map +1 -0
  507. package/dist/skills/injection-mode.d.ts +4 -1
  508. package/dist/skills/injection-mode.d.ts.map +1 -1
  509. package/dist/skills/injection-mode.js +11 -3
  510. package/dist/skills/injection-mode.js.map +1 -1
  511. package/dist/skills/installer.d.ts.map +1 -1
  512. package/dist/skills/installer.js +24 -1
  513. package/dist/skills/installer.js.map +1 -1
  514. package/dist/skills/prompt-fragments.d.ts +58 -0
  515. package/dist/skills/prompt-fragments.d.ts.map +1 -0
  516. package/dist/skills/prompt-fragments.js +88 -0
  517. package/dist/skills/prompt-fragments.js.map +1 -0
  518. package/dist/types.d.ts +51 -0
  519. package/dist/types.d.ts.map +1 -1
  520. package/dist/utils/cli-usage-limit.d.ts +50 -0
  521. package/dist/utils/cli-usage-limit.d.ts.map +1 -1
  522. package/dist/utils/cli-usage-limit.js +43 -0
  523. package/dist/utils/cli-usage-limit.js.map +1 -1
  524. package/dist/utils/idle-detector.d.ts +12 -0
  525. package/dist/utils/idle-detector.d.ts.map +1 -1
  526. package/dist/utils/idle-detector.js +88 -2
  527. package/dist/utils/idle-detector.js.map +1 -1
  528. package/dist/utils/stuck-detector.d.ts +5 -0
  529. package/dist/utils/stuck-detector.d.ts.map +1 -1
  530. package/dist/utils/stuck-detector.js +41 -0
  531. package/dist/utils/stuck-detector.js.map +1 -1
  532. package/dist/utils/usage-limit-tracker.d.ts +46 -0
  533. package/dist/utils/usage-limit-tracker.d.ts.map +1 -0
  534. package/dist/utils/usage-limit-tracker.js +91 -0
  535. package/dist/utils/usage-limit-tracker.js.map +1 -0
  536. package/dist/utils/user-token.js +1 -1
  537. package/dist/utils/user-token.js.map +1 -1
  538. package/dist/worker.js +812 -125
  539. package/dist/worker.js.map +1 -1
  540. package/dist/workflows/definition.d.ts +14 -14
  541. package/dist/workflows/events/payloads.d.ts +12 -12
  542. package/dist/workflows/events/schema.d.ts +164 -164
  543. package/dist/workflows/migration/v2-to-v3.js +1 -1
  544. package/dist/workflows/migration/v2-to-v3.js.map +1 -1
  545. package/dist/workflows/v3/architect.d.ts.map +1 -1
  546. package/dist/workflows/v3/architect.js +11 -5
  547. package/dist/workflows/v3/architect.js.map +1 -1
  548. package/dist/workflows/v3/artifact-contract-declarations.d.ts +22 -0
  549. package/dist/workflows/v3/artifact-contract-declarations.d.ts.map +1 -0
  550. package/dist/workflows/v3/artifact-contract-declarations.js +95 -0
  551. package/dist/workflows/v3/artifact-contract-declarations.js.map +1 -0
  552. package/dist/workflows/v3/contract.d.ts +1 -0
  553. package/dist/workflows/v3/contract.d.ts.map +1 -1
  554. package/dist/workflows/v3/contract.js.map +1 -1
  555. package/dist/workflows/v3/daemon-run.d.ts +2 -2
  556. package/dist/workflows/v3/daemon-run.d.ts.map +1 -1
  557. package/dist/workflows/v3/daemon-run.js +4 -0
  558. package/dist/workflows/v3/daemon-run.js.map +1 -1
  559. package/dist/workflows/v3/dag.d.ts +7 -0
  560. package/dist/workflows/v3/dag.d.ts.map +1 -1
  561. package/dist/workflows/v3/dag.js +69 -8
  562. package/dist/workflows/v3/dag.js.map +1 -1
  563. package/dist/workflows/v3/ephemeral-pool.js +1 -1
  564. package/dist/workflows/v3/ephemeral-pool.js.map +1 -1
  565. package/dist/workflows/v3/event-contract.d.ts +3 -1
  566. package/dist/workflows/v3/event-contract.d.ts.map +1 -1
  567. package/dist/workflows/v3/host.d.ts.map +1 -1
  568. package/dist/workflows/v3/host.js +5 -1
  569. package/dist/workflows/v3/host.js.map +1 -1
  570. package/dist/workflows/v3/journal.d.ts +1 -1
  571. package/dist/workflows/v3/journal.d.ts.map +1 -1
  572. package/dist/workflows/v3/journal.js.map +1 -1
  573. package/dist/workflows/v3/library-materialize.d.ts.map +1 -1
  574. package/dist/workflows/v3/library-materialize.js +9 -1
  575. package/dist/workflows/v3/library-materialize.js.map +1 -1
  576. package/dist/workflows/v3/library-schema.d.ts +3 -1
  577. package/dist/workflows/v3/library-schema.d.ts.map +1 -1
  578. package/dist/workflows/v3/library-schema.js +20 -4
  579. package/dist/workflows/v3/library-schema.js.map +1 -1
  580. package/dist/workflows/v3/library-store.d.ts.map +1 -1
  581. package/dist/workflows/v3/library-store.js +15 -3
  582. package/dist/workflows/v3/library-store.js.map +1 -1
  583. package/dist/workflows/v3/run-envelope.d.ts +16 -16
  584. package/dist/workflows/v3/shared-node-runtime.d.ts +2 -1
  585. package/dist/workflows/v3/shared-node-runtime.d.ts.map +1 -1
  586. package/dist/workflows/v3/shared-node-runtime.js +48 -7
  587. package/dist/workflows/v3/shared-node-runtime.js.map +1 -1
  588. package/package.json +2 -1
  589. package/dist/dashboard-web/chunks/agent-workbench-dock-page-IKAC5CFL.js +0 -1
  590. package/dist/dashboard-web/chunks/agent-workbench-page-M53UN5EB.js +0 -1
  591. package/dist/dashboard-web/chunks/bot-defaults-page-YKE5SDZF.js +0 -10
  592. package/dist/dashboard-web/chunks/chunk-22WIADUT.js +0 -2
  593. package/dist/dashboard-web/chunks/chunk-24ONYQMR.js +0 -1
  594. package/dist/dashboard-web/chunks/chunk-2W6SCN3M.js +0 -1
  595. package/dist/dashboard-web/chunks/chunk-4XNJX6B3.js +0 -1
  596. package/dist/dashboard-web/chunks/chunk-5THX4DI2.js +0 -66
  597. package/dist/dashboard-web/chunks/chunk-7SZRL6FY.js +0 -1
  598. package/dist/dashboard-web/chunks/chunk-AGCPF6MT.js +0 -1
  599. package/dist/dashboard-web/chunks/chunk-FXW3V4JR.js +0 -1
  600. package/dist/dashboard-web/chunks/chunk-SYC6D5XU.js +0 -1
  601. package/dist/dashboard-web/chunks/connectors-page-VOISXXII.js +0 -1
  602. package/dist/dashboard-web/chunks/feedback-page-RN6HRZMS.js +0 -1
  603. package/dist/dashboard-web/chunks/groups-page-UQT6DCB7.js +0 -8
  604. package/dist/dashboard-web/chunks/monitoring-page-NKEKVQAP.js +0 -2
  605. package/dist/dashboard-web/chunks/office-page-GVJF73XW.js +0 -1
  606. package/dist/dashboard-web/chunks/overview-page-KHLV6VTI.js +0 -1
  607. package/dist/dashboard-web/chunks/plugin-page-J3OF5IY4.js +0 -1
  608. package/dist/dashboard-web/chunks/roles-page-WQIRSOLZ.js +0 -1
  609. package/dist/dashboard-web/chunks/schedules-page-J2DEY2X6.js +0 -1
  610. package/dist/dashboard-web/chunks/sessions-page-7BQFEA5P.js +0 -8
  611. package/dist/dashboard-web/chunks/settings-page-BJEIOFJH.js +0 -2
  612. package/dist/dashboard-web/chunks/skills-page-HGIFR3IU.js +0 -4
  613. package/dist/dashboard-web/chunks/team-federation-page-MR5ZPL4B.js +0 -1
  614. package/dist/dashboard-web/chunks/v3-page-GBR5JWPE.js +0 -94
  615. package/dist/dashboard-web/chunks/whiteboards-page-QAZM4BN3.js +0 -1
  616. package/dist/services/vc-meeting-consumer-profile-store.d.ts +0 -39
  617. package/dist/services/vc-meeting-consumer-profile-store.d.ts.map +0 -1
  618. package/dist/services/vc-meeting-consumer-profile-store.js +0 -191
  619. package/dist/services/vc-meeting-consumer-profile-store.js.map +0 -1
@@ -1 +0,0 @@
1
- import{a as q,b as V}from"./chunk-EVK77ASG.js";import{a as ce}from"./chunk-ZJVTGU5X.js";import{a as ie,c as de,g as Se,l as T,q as ue}from"./chunk-5CJMHTT4.js";import{d as _}from"./chunk-FXW3V4JR.js";import"./chunk-24ONYQMR.js";import"./chunk-F6KNPF4R.js";import{a as re}from"./chunk-SYC6D5XU.js";import{a as Pe,d as le}from"./chunk-5THX4DI2.js";import{c as j}from"./chunk-7SZRL6FY.js";var i=j(Pe(),1);var p=j(Pe(),1);var n=j(le(),1),Ge=50,Ne={total:0,ok:0,error:0,successRate:0};function We(o,e=Date.now()){if(o==="all")return;let s=o==="24h"?24:o==="7d"?168:720;return new Date(e-s*60*60*1e3).toISOString()}function _e(o,e=0){let s=new URLSearchParams({limit:String(Ge),offset:String(e)});o.connectorId&&s.set("connectorId",o.connectorId),o.status&&s.set("status",o.status);let d=We(o.timeWindow);return d&&s.set("since",d),o.query.trim()&&s.set("q",o.query.trim()),s}function Fe(o){if(!o)return"\u2014";let e=new Date(o);return Number.isFinite(e.getTime())?e.toLocaleString():o}function ge(o){return o===void 0||!Number.isFinite(o)?"\u2014":o<1e3?`${Math.round(o)} ms`:o<6e4?`${(o/1e3).toFixed(o<1e4?1:0)} s`:`${(o/6e4).toFixed(1)} min`}function Ue(o){return o===void 0?"\u2014":o<1024?`${o} B`:o<1024*1024?`${(o/1024).toFixed(1)} KB`:`${(o/1024/1024).toFixed(1)} MB`}function Le(o){return o.value===void 0||o.value===null?(0,n.jsx)("p",{className:"webhook-log-detail-empty",children:o.empty}):typeof o.value=="object"&&!Array.isArray(o.value)&&Object.keys(o.value).length===0?(0,n.jsx)("p",{className:"webhook-log-detail-empty",children:o.empty}):(0,n.jsx)("pre",{className:`webhook-log-json${o.fullHeight?" full-height":""}`,children:(0,n.jsx)("code",{children:JSON.stringify(o.value,null,2)})})}function Je(o){let e=[["kind",o.value?.kind],["mode",o.value?.mode],["botId",o.value?.botId],["chatId",o.value?.chatId],["sessionId",o.value?.sessionId],["rootMessageId",o.value?.rootMessageId],["workflowId",o.value?.workflowId]].filter(([,s])=>s!=null&&s!=="");return e.length?(0,n.jsx)("dl",{className:"webhook-log-target-facts",children:e.map(([s,d])=>(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{children:s}),(0,n.jsx)("dd",{children:(0,n.jsx)("code",{children:String(d)})})]},s))}):(0,n.jsx)("p",{className:"webhook-log-detail-empty",children:"\u2014"})}function Ie(o){return(0,n.jsx)(ue,{id:o.id,className:"webhook-log-filter-menu",ariaLabel:o.label,style:{width:"100%",minWidth:0},value:o.value,label:ie(o.options,o.value),options:o.options,onChange:o.onChange})}function me(o){return(0,n.jsxs)("article",{className:`card webhook-log-metric${o.tone?` ${o.tone}`:""}`,children:[(0,n.jsx)("span",{children:o.label}),(0,n.jsx)("strong",{children:o.value}),(0,n.jsx)("small",{children:o.hint||"\xA0"})]})}function Ee(o={}){let e=_(),s=(0,p.useRef)(!1),d=(0,p.useRef)([]),[f,N]=(0,p.useState)([]),[y,I]=(0,p.useState)([]),[k,R]=(0,p.useState)(Ne),[L,$]=(0,p.useState)({connectorId:"",status:"",timeWindow:"7d",query:""}),[u,r]=(0,p.useState)(null),[E,U]=(0,p.useState)(!0),[w,J]=(0,p.useState)(!1),[A,X]=(0,p.useState)(!1),[Y,Z]=(0,p.useState)(0),[B,x]=(0,p.useState)(""),[K,ee]=(0,p.useState)(!1),M=(0,p.useMemo)(()=>new Map(f.map(c=>[c.id,c.name])),[f]),g=(0,p.useMemo)(()=>y.find(c=>c.triggerId===u)??y[0]??null,[y,u]),te=(0,p.useMemo)(()=>[{value:"",label:e("webhookLogs.allConnectors")},...f.map(c=>({value:c.id,label:c.name}))],[f,e]),G=(0,p.useMemo)(()=>[{value:"",label:e("webhookLogs.allStatuses")},{value:"ok",label:e("webhookLogs.success")},{value:"error",label:e("webhookLogs.failed")}],[e]),fe=(0,p.useMemo)(()=>[{value:"24h",label:e("webhookLogs.last24h")},{value:"7d",label:e("webhookLogs.last7d")},{value:"30d",label:e("webhookLogs.last30d")},{value:"all",label:e("webhookLogs.allTime")}],[e]),H=(0,p.useCallback)(async(c=!1,v=!1)=>{v?J(!0):U(!0),x("");let Q=c?d.current.length:0,oe=_e(L,Q),h=new URLSearchParams(oe);h.delete("limit"),h.delete("offset");try{let[S,ne]=await Promise.all([q(`/api/trigger-logs?${oe}`),c?Promise.resolve(null):q(`/api/trigger-logs/summary?${h}`)]);if(!s.current)return;if(S.status!==200)throw new Error(String(S.body?.error||S.status));let P=Array.isArray(S.body?.logs)?S.body.logs:[],ae=c?[...d.current,...P]:P;d.current=ae,I(ae),Z(Number(S.body?.total??P.length)),X(S.body?.hasMore===!0),c||(R(ne?.status===200?ne.body?.summary??Ne:Ne),r(se=>P.some(ve=>ve.triggerId===se)?se:P[0]?.triggerId??null))}catch(S){s.current&&x(S?.message||e("webhookLogs.loadFailed"))}finally{s.current&&(U(!1),J(!1))}},[L,e]);(0,p.useEffect)(()=>(s.current=!0,q("/api/connectors").then(c=>{s.current&&c.status===200&&N(Array.isArray(c.body?.connectors)?c.body.connectors:[])}),()=>{s.current=!1}),[]),(0,p.useEffect)(()=>{let c=setTimeout(()=>{H(!1)},L.query?260:0);return()=>clearTimeout(c)},[L,H]),(0,p.useEffect)(()=>{let c=setInterval(()=>{H(!1,!0)},15e3);return()=>clearInterval(c)},[H]);async function ye(){!g||!await ce(JSON.stringify(g,null,2),e("webhookLogs.copyJson"))||(ee(!0),setTimeout(()=>s.current&&ee(!1),1200))}let ke=g?.request?.payloadOmittedReason==="disabled"?e("webhookLogs.payloadDisabled"):g?.request?.payloadOmittedReason==="too_large"?e("webhookLogs.payloadTooLarge"):e("webhookLogs.payloadUnavailable"),z=(0,n.jsxs)(n.Fragment,{children:[o.embedded?null:(0,n.jsxs)("div",{className:"page-heading",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"eyebrow",children:e("nav.connectors")}),(0,n.jsx)("h1",{children:e("nav.webhookLogs")}),(0,n.jsx)("p",{className:"webhook-log-heading-copy",children:e("webhookLogs.subtitle")})]}),(0,n.jsxs)("div",{className:"page-heading-actions",children:[(0,n.jsxs)("span",{className:`webhook-log-live${w?" refreshing":""}`,children:[(0,n.jsx)("i",{}),e("webhookLogs.autoRefresh")]}),(0,n.jsx)("a",{className:"button page-primary-action",href:"#/connectors",children:e("webhookLogs.manage")})]})]}),(0,n.jsxs)("section",{className:"webhook-log-metrics","aria-label":e("webhookLogs.summary"),children:[(0,n.jsx)(me,{label:e("webhookLogs.total"),value:k.total,hint:e("webhookLogs.filteredRange")}),(0,n.jsx)(me,{label:e("webhookLogs.successRate"),value:`${k.successRate.toFixed(k.successRate%1?1:0)}%`,tone:"ok",hint:`${k.ok} ${e("webhookLogs.calls")}`}),(0,n.jsx)(me,{label:e("webhookLogs.failures"),value:k.error,tone:k.error?"error":void 0,hint:k.error?e("webhookLogs.needsReview"):e("webhookLogs.noFailures")}),(0,n.jsx)(me,{label:e("webhookLogs.p95"),value:ge(k.p95DurationMs),hint:`${e("webhookLogs.average")} ${ge(k.avgDurationMs)}`})]}),(0,n.jsxs)("form",{className:"filters dashboard-toolbar webhook-log-toolbar",onSubmit:c=>c.preventDefault(),children:[(0,n.jsx)("input",{type:"search",name:"q","aria-label":e("webhookLogs.search"),placeholder:e("webhookLogs.searchPlaceholder"),value:L.query,onChange:c=>{let v=c.currentTarget.value;$(Q=>({...Q,query:v}))}}),(0,n.jsx)(Ie,{id:"webhook-log-connector",label:e("webhookLogs.connector"),value:L.connectorId,options:te,onChange:c=>$(v=>({...v,connectorId:c}))}),(0,n.jsx)(Ie,{id:"webhook-log-status",label:e("webhookLogs.status"),value:L.status,options:G,onChange:c=>$(v=>({...v,status:c}))}),(0,n.jsx)(Ie,{id:"webhook-log-window",label:e("webhookLogs.timeRange"),value:L.timeWindow,options:fe,onChange:c=>$(v=>({...v,timeWindow:c}))}),(0,n.jsx)("button",{type:"button",className:"ghost webhook-log-refresh",disabled:w,onClick:()=>{H(!1,!0)},children:e("webhookLogs.refresh")})]}),B?(0,n.jsxs)("p",{className:"err webhook-log-error",children:[e("webhookLogs.loadFailed"),": ",B]}):null,(0,n.jsxs)("section",{className:"webhook-log-workspace",children:[(0,n.jsxs)("article",{className:"card webhook-log-list-panel",children:[(0,n.jsx)("header",{className:"webhook-log-panel-head",children:(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:e("webhookLogs.records")}),(0,n.jsx)("span",{children:e("webhookLogs.matching",{count:Y})})]})}),E&&!y.length?(0,n.jsx)(de,{label:e("webhookLogs.loading"),compact:!0}):null,!E&&!y.length?(0,n.jsxs)("div",{className:"webhook-log-empty",children:[(0,n.jsx)("span",{"aria-hidden":"true",children:"\u25CE"}),(0,n.jsx)("strong",{children:e("webhookLogs.empty")}),(0,n.jsx)("p",{children:e("webhookLogs.emptyHint")})]}):null,(0,n.jsx)("div",{className:"webhook-log-list",role:"listbox","aria-label":e("webhookLogs.records"),children:y.map(c=>{let v=g?.triggerId===c.triggerId;return(0,n.jsxs)("button",{type:"button",role:"option","aria-selected":v,className:`webhook-log-row${v?" active":""}`,onClick:()=>r(c.triggerId),children:[(0,n.jsx)("span",{className:`webhook-log-status-dot ${c.status}`,"aria-hidden":"true"}),(0,n.jsxs)("span",{className:"webhook-log-row-main",children:[(0,n.jsxs)("span",{className:"webhook-log-row-title",children:[(0,n.jsx)("strong",{children:M.get(c.connectorId||"")||c.connectorId||e("webhookLogs.unknownConnector")}),(0,n.jsx)("code",{children:c.request?.method||"POST"})]}),(0,n.jsxs)("span",{className:"webhook-log-row-meta",children:[(0,n.jsx)("span",{children:Fe(c.createdAt)}),(0,n.jsx)("span",{children:c.errorCode||c.action})]})]}),(0,n.jsxs)("span",{className:"webhook-log-row-result",children:[(0,n.jsx)("b",{className:c.status,children:c.response?.httpStatus??(c.status==="ok"?"2xx":"ERR")}),(0,n.jsx)("small",{children:ge(c.response?.durationMs)})]})]},`${c.triggerId}-${c.createdAt}`)})}),A?(0,n.jsx)("button",{type:"button",className:"ghost webhook-log-more",disabled:E,onClick:()=>{H(!0)},children:e("webhookLogs.loadMore")}):null]}),(0,n.jsx)("article",{className:"card webhook-log-detail-panel",children:g?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("header",{className:"webhook-log-detail-head",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{className:`webhook-log-result-pill ${g.status}`,children:g.status==="ok"?e("webhookLogs.success"):e("webhookLogs.failed")}),(0,n.jsx)("h2",{children:M.get(g.connectorId||"")||g.connectorId||e("webhookLogs.unknownConnector")}),(0,n.jsxs)("p",{children:[Fe(g.createdAt)," \xB7 ",g.request?.method||"POST"," ",g.request?.path||"/webhook/\u2026"]})]}),(0,n.jsx)("button",{type:"button",className:"ghost",onClick:()=>{ye()},children:e(K?"webhookLogs.copied":"webhookLogs.copyJson")})]}),g.error?(0,n.jsxs)("div",{className:"webhook-log-failure",children:[(0,n.jsx)("strong",{children:g.errorCode||e("webhookLogs.failureReason")}),(0,n.jsx)("span",{children:g.error})]}):null,(0,n.jsxs)("section",{className:"webhook-log-detail-section",children:[(0,n.jsx)("h3",{children:e("webhookLogs.overview")}),(0,n.jsxs)("dl",{className:"webhook-log-facts",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{children:e("webhookLogs.httpStatus")}),(0,n.jsx)("dd",{children:g.response?.httpStatus??"\u2014"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{children:e("webhookLogs.duration")}),(0,n.jsx)("dd",{children:ge(g.response?.durationMs)})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{children:e("webhookLogs.action")}),(0,n.jsx)("dd",{children:g.action})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{children:e("webhookLogs.bodySize")}),(0,n.jsx)("dd",{children:Ue(g.request?.bodyBytes)})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{children:"Trigger ID"}),(0,n.jsx)("dd",{children:(0,n.jsx)("code",{children:g.triggerId})})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{children:"Request ID"}),(0,n.jsx)("dd",{children:(0,n.jsx)("code",{children:g.requestId||"\u2014"})})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{children:e("webhookLogs.remoteAddress")}),(0,n.jsx)("dd",{children:(0,n.jsx)("code",{children:g.request?.remoteAddress||"\u2014"})})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{children:e("webhookLogs.target")}),(0,n.jsx)("dd",{children:(0,n.jsx)("code",{children:g.target?.chatId||g.target?.sessionId||g.response?.chatId||"\u2014"})})]})]})]}),(0,n.jsxs)("section",{className:"webhook-log-detail-section",children:[(0,n.jsx)("h3",{children:e("webhookLogs.queryParams")}),(0,n.jsx)(Le,{value:g.request?.query,empty:e("webhookLogs.none")})]}),(0,n.jsxs)("section",{className:"webhook-log-detail-section",children:[(0,n.jsxs)("h3",{children:[e("webhookLogs.headers"),(0,n.jsx)("small",{children:e("webhookLogs.redacted")})]}),(0,n.jsx)(Le,{value:g.request?.headers,empty:e("webhookLogs.headersNotStored")})]}),(0,n.jsxs)("section",{className:"webhook-log-detail-section",children:[(0,n.jsxs)("h3",{children:[e("webhookLogs.payload"),(0,n.jsx)("small",{children:e("webhookLogs.redacted")})]}),g.request?.payloadStored?(0,n.jsx)(Le,{value:g.request.payload,empty:e("webhookLogs.none")}):(0,n.jsx)("p",{className:"webhook-log-detail-empty",children:ke})]}),(0,n.jsxs)("section",{className:"webhook-log-detail-section",children:[(0,n.jsx)("h3",{children:e("webhookLogs.routeTarget")}),(0,n.jsx)(Je,{value:g.target})]})]}):(0,n.jsx)("div",{className:"webhook-log-empty",children:(0,n.jsx)("strong",{children:e("webhookLogs.selectRecord")})})})]})]});return o.embedded?(0,n.jsx)("section",{className:"webhook-logs-content webhook-logs-panel",children:z}):(0,n.jsx)("section",{className:"page webhook-logs-content webhook-logs-page",children:z})}var t=j(le(),1);function Xe(o,e){return o.map(s=>s.id===e.id?e:s)}var Re={name:"",botId:"",kind:"turn",workflowId:"",mode:"dynamic",chatId:"",manualChat:!1,manualChatId:"",allowChats:[],deduplicate:!1,dedup:"",instruction:"",topicMessageMode:"default",topicMessageText:"",topicMessageExtractors:"{}",suppressFinalOutput:!1,verify:"token",secret:"",storePayload:!0};function ut(o,e){return{promptEnvelope:{sourceName:o.promptEnvelope?.sourceName||o.name,instruction:e}}}function Ke(o,e,s){let d=e.trim();if(o!=="template")return{ok:!0,value:o==="custom"?{mode:o,text:d}:{mode:o}};try{let f=JSON.parse(s);return!f||typeof f!="object"||Array.isArray(f)?{ok:!1,error:"connectors.errTopicExtractors"}:{ok:!0,value:{mode:o,text:d,extractors:f}}}catch{return{ok:!1,error:"connectors.errTopicExtractors"}}}function je(o){return[{value:"turn",label:o("connectors.kindTurn")},{value:"workflow",label:o("connectors.kindWorkflowRetiring"),disabled:!0}]}function be(o){return`${location.origin}/webhook/${encodeURIComponent(o)}`}function pe(o){return(0,t.jsx)(ue,{id:o.id,className:"connector-form-menu",ariaLabel:o.label,value:o.value,label:ie(o.options,o.value),options:o.options,onChange:o.onChange})}function De(o){let e=(0,i.useRef)(null),[s,d]=(0,i.useState)(!1),[f,N]=(0,i.useState)(""),y=Array.isArray(o.value)?o.value:o.value?[o.value]:[],I=(0,i.useMemo)(()=>new Set(y),[y]),k=f.trim().toLocaleLowerCase(),R=(0,i.useMemo)(()=>k?o.groups.filter(u=>`${u.name} ${u.chatId}`.toLocaleLowerCase().includes(k)):o.groups,[k,o.groups]),L=o.multiple?y.length===0?o.allLabel||o.placeholder:o.selectedCountLabel(y.length):o.groups.find(u=>u.chatId===y[0])?.name||y[0]||o.placeholder;(0,i.useEffect)(()=>{if(!s)return;let u=r=>{e.current?.contains(r.target)||d(!1)};return document.addEventListener("pointerdown",u),()=>document.removeEventListener("pointerdown",u)},[s]);function $(u){if(!o.multiple){o.onChange(u),d(!1),N("");return}o.onChange(I.has(u)?y.filter(r=>r!==u):[...y,u])}return(0,t.jsxs)("div",{ref:e,className:`connector-group-picker${s?" open":""}`,children:[(0,t.jsxs)("button",{id:o.id,type:"button",className:"connector-group-picker-trigger","aria-label":o.label,"aria-haspopup":"listbox","aria-expanded":s,onClick:()=>d(u=>!u),children:[(0,t.jsx)("span",{className:y.length||o.multiple&&o.allLabel?"":"muted",children:L}),(0,t.jsx)("span",{className:"connector-group-picker-chevron","aria-hidden":"true"})]}),s?(0,t.jsxs)("div",{className:"connector-group-picker-popover",children:[(0,t.jsxs)("label",{className:"connector-group-search",htmlFor:`${o.id}-search`,children:[(0,t.jsx)("span",{className:"connector-group-search-icon","aria-hidden":"true"}),(0,t.jsx)("input",{id:`${o.id}-search`,type:"search",autoComplete:"off",autoFocus:!0,value:f,placeholder:o.searchPlaceholder,onChange:u=>N(u.currentTarget.value),onKeyDown:u=>{u.key==="Escape"&&(u.preventDefault(),d(!1))}})]}),(0,t.jsxs)("div",{className:"connector-group-options",role:"listbox","aria-label":o.label,"aria-multiselectable":o.multiple||void 0,children:[o.multiple&&o.allLabel&&!k?(0,t.jsxs)("button",{type:"button",className:`connector-group-option connector-group-option-all${y.length===0?" selected":""}`,role:"option","aria-selected":y.length===0,onClick:()=>o.onChange([]),children:[(0,t.jsx)("span",{className:"connector-group-check","aria-hidden":"true"}),(0,t.jsxs)("span",{children:[(0,t.jsx)("b",{children:o.allLabel}),(0,t.jsx)("small",{children:o.placeholder})]})]}):null,R.map(u=>{let r=I.has(u.chatId);return(0,t.jsxs)("button",{type:"button",className:`connector-group-option${r?" selected":""}`,role:"option","aria-selected":r,onClick:()=>$(u.chatId),children:[(0,t.jsx)("span",{className:"connector-group-check","aria-hidden":"true"}),(0,t.jsxs)("span",{children:[(0,t.jsx)("b",{children:u.name||u.chatId}),u.name?(0,t.jsx)("small",{children:u.chatId}):null]})]},u.chatId)}),R.length?null:(0,t.jsx)("p",{className:"connector-group-empty",children:o.emptyLabel})]})]}):null]})}function he(o,e){return o.filter(s=>s.bots.includes(e))}function ze(o,e){let s=o.target.chatId||"",d=s&&he(e,o.target.botId).some(f=>f.chatId===s);return{name:o.name,botId:o.target.botId,kind:o.target.kind,workflowId:o.target.workflowId||"",mode:o.target.mode,chatId:d?s:"",manualChat:!!(s&&!d),manualChatId:d?"":s,allowChats:o.target.allowChats||[],deduplicate:!!o.lifecycleExtractors?.dedupKey,dedup:o.lifecycleExtractors?.dedupKey||"",instruction:o.promptEnvelope?.instruction||"",topicMessageMode:o.topicMessage?.mode||"default",topicMessageText:o.topicMessage?.text||"",topicMessageExtractors:JSON.stringify(o.topicMessage?.extractors||{},null,2),suppressFinalOutput:o.suppressFinalOutput===!0,verify:o.verify?.type||"token",secret:"",storePayload:o.loggingPolicy?.storePayload!==!1}}function Qe(o){let e=_(),s=o.active==="webhooks",d=o.active==="logs";return(0,t.jsxs)("nav",{className:"connectors-subnav-slot connectors-subnav insight-tabs",role:"tablist","aria-label":e("nav.connectors"),children:[(0,t.jsx)("a",{href:"#/connectors",className:`itab${s?" on":""}`,role:"tab","aria-selected":s,children:e("connectors.tabWebhooks")}),(0,t.jsx)("a",{href:"#/connectors/logs",className:`itab${d?" on":""}`,role:"tab","aria-selected":d,children:e("connectors.tabLogs")})]})}function Oe(o){let e=_(),s=(0,i.useRef)(!1),d=(0,i.useRef)(null),f=(0,i.useRef)(null),[N,y]=(0,i.useState)([]),[I,k]=(0,i.useState)([]),[R,L]=(0,i.useState)([]),[$,u]=(0,i.useState)(!0),[r,E]=(0,i.useState)(Re),[U,w]=(0,i.useState)(null),[J,A]=(0,i.useState)(null),[X,Y]=(0,i.useState)(!1),[Z,B]=(0,i.useState)(!1),[x,K]=(0,i.useState)(null),[ee,M]=(0,i.useState)(null),[g,te]=(0,i.useState)(null),G=(0,i.useMemo)(()=>he(I,r.botId),[I,r.botId]),fe=(0,i.useMemo)(()=>N.length?N.map(a=>({value:a.larkAppId,label:a.botName})):[{value:"",label:e("connectors.noOnlineBots")}],[N,e]),H=(0,i.useMemo)(()=>je(e),[e]),ye=(0,i.useMemo)(()=>[{value:"dynamic",label:e("connectors.modeDynamic")},{value:"fixed",label:e("connectors.modeFixed")},{value:"new-group",label:e("connectors.modeNewGroup")}],[e]),ke=(0,i.useMemo)(()=>[{value:"token",label:e("connectors.verifyToken")},{value:"hmac-sha256",label:e("connectors.verifyHmac")}],[e]),z=(0,i.useCallback)(a=>I.find(b=>b.chatId===a)?.name||a,[I]),c=(0,i.useCallback)((a,l)=>{E(b=>{let F=b.botId&&a.some(O=>O.larkAppId===b.botId)?b.botId:a[0]?.larkAppId??"",C=he(l,F),m=b.chatId&&C.some(O=>O.chatId===b.chatId)?b.chatId:C[0]?.chatId??"",D=new Set(C.map(O=>O.chatId));return{...b,botId:F,chatId:m,allowChats:b.allowChats.filter(O=>D.has(O))}})},[]),v=(0,i.useCallback)(async()=>{u(!0);try{let[a,l,b]=await Promise.all([q("/api/bots"),q("/api/connectors"),q("/api/groups")]);if(!s.current)return;let F=(a.body?.bots||[]).map(m=>({larkAppId:m.larkAppId,botName:m.botName||m.larkAppId})),C=(b.body?.chats||[]).map(m=>({chatId:m.chatId,name:m.name||"",bots:(m.memberBots||[]).filter(D=>D.inChat).map(D=>D.larkAppId)}));y(F),k(C),L(Array.isArray(l.body?.connectors)?l.body.connectors:[]),c(F,C)}finally{s.current&&u(!1)}},[c]);(0,i.useEffect)(()=>(s.current=!0,v(),()=>{s.current=!1,d.current&&clearTimeout(d.current)}),[v]),(0,i.useEffect)(()=>{let a=new Set(G.map(l=>l.chatId));E(l=>({...l,chatId:l.chatId&&a.has(l.chatId)?l.chatId:G[0]?.chatId??"",allowChats:l.allowChats.filter(b=>a.has(b))}))},[G]),(0,i.useEffect)(()=>{let a=f.current;if(a)if(Z){if(!a.open)try{a.showModal()}catch{}let l=a.querySelector(".connector-modal-body");l&&(l.scrollTop=0)}else a.open&&a.close()},[Z]),(0,i.useEffect)(()=>()=>{let a=f.current;a?.open&&a.close()},[]);function Q(a){return e(a==="fixed"?"connectors.modeLabelFixed":a==="new-group"?"connectors.modeLabelNewGroup":"connectors.modeLabelDynamic")}function oe(a){return e(a==="workflow"?"connectors.kindLabelWorkflow":"connectors.kindLabelTurn")}function h(a){E(l=>({...l,...a}))}function S(){w(null),A(null),K(null),E(a=>{let l=a.botId||N[0]?.larkAppId||"";return{...Re,botId:l,chatId:he(I,l)[0]?.chatId||""}}),B(!0)}function ne(a){w(null),A(null),M(null),K(a),E(ze(a,I)),B(!0)}function P(){X||(B(!1),w(null),A(null),K(null))}async function ae(){w(null),A(null);let a=r.name.trim(),l=r.botId;if(!a){w({text:e("connectors.errName"),error:!0});return}if(!l){w({text:e("connectors.errBot"),error:!0});return}if(r.kind==="workflow"){w({text:e("connectors.errLegacyWorkflowRetired"),error:!0});return}let b=r.topicMessageText.trim();if((r.topicMessageMode==="custom"||r.topicMessageMode==="template")&&!b){w({text:e("connectors.errTopicMessage"),error:!0});return}let F=Ke(r.topicMessageMode,b,r.topicMessageExtractors);if(!F.ok){w({text:e(F.error),error:!0});return}let C={name:a,enabled:x?.enabled??!0,target:{kind:r.kind,mode:r.mode,botId:l},promptEnvelope:{sourceName:a,instruction:r.instruction.trim()},topicMessage:F.value,suppressFinalOutput:r.suppressFinalOutput,verify:{type:r.verify},loggingPolicy:{storePayload:r.storePayload,storeHeaders:!0,retentionDays:14}};if(r.mode==="fixed"){let m=r.manualChat?r.manualChatId.trim():r.chatId;if(!m){w({text:e("connectors.errChat"),error:!0});return}C.target.chatId=m}else r.mode==="dynamic"&&(C.target.allowChats=r.allowChats);if(r.mode==="new-group"){let m=r.dedup.trim();if(r.deduplicate&&!m){w({text:e("connectors.errDedup"),error:!0});return}C.lifecycleExtractors=r.deduplicate?{dedupKey:m}:null}else C.lifecycleExtractors=null;r.secret.trim()&&(C.secret=r.secret.trim()),Y(!0),w({text:e(x?"connectors.saving":"connectors.creating")});try{let m=await V(x?"PUT":"POST",x?`/api/connectors/${encodeURIComponent(x.id)}`:"/api/connectors",C);if(!s.current)return;if((m.status===201||m.status===200)&&m.body?.ok){if(x){let we=x.id,W=m.body.connector;L(Ce=>Xe(Ce,W));let Te=m.body.secret??C.secret;if(Te){let Ce=m.body.webhookUrl||be(W.id),qe=(W.verify?.type??"token")==="token",xe=W.target.mode==="dynamic",Be=xe?W.target.allowChats?.[0]||"<chatId>":"";w(null),A({name:a,mode:W.target.mode,chatId:W.target.chatId,url:Ce,secret:Te,isToken:qe,isDynamic:xe,exampleChat:Be,rotated:!0}),await v();return}M({id:we,text:e("connectors.updated")}),B(!1),K(null);return}let D=m.body.webhookUrl||be(m.body.connector.id),O=(m.body.connector?.verify?.type??"token")==="token",Me=r.mode==="dynamic",He=Me?C.target.allowChats?.[0]||"<chatId>":"";w(null),A({name:a,mode:r.mode,chatId:C.target.chatId,url:D,secret:m.body.secret,isToken:O,isDynamic:Me,exampleChat:He}),E(we=>({...we,name:"",workflowId:"",manualChatId:"",dedup:"",secret:"",instruction:"",topicMessageMode:"default",topicMessageText:"",topicMessageExtractors:"{}",suppressFinalOutput:!1,allowChats:[],storePayload:!0})),await v()}else{let D=m.body?.error||m.status;w({text:e("connectors.createFailed",{error:String(D)}),error:!0})}}finally{s.current&&Y(!1)}}async function se(a){M({id:a.id,text:e(a.enabled?"connectors.disabling":"connectors.enabling")});let l=await V("PATCH",`/api/connectors/${encodeURIComponent(a.id)}`,{enabled:!a.enabled});if(s.current)if(l.status===200&&l.body?.ok)M(null),await v();else{let b=l.body?.error||l.status;M({id:a.id,text:e("connectors.toggleFailed",{error:String(b)}),error:!0})}}async function ve(a){let l=a.loggingPolicy?.storePayload!==!1;M({id:a.id,text:e("connectors.saving")});let b=await V("PUT",`/api/connectors/${encodeURIComponent(a.id)}`,{loggingPolicy:{storePayload:!l,storeHeaders:a.loggingPolicy?.storeHeaders!==!1,retentionDays:a.loggingPolicy?.retentionDays??14}});if(s.current)if(b.status===200&&b.body?.ok)M(null),await v();else{let F=b.body?.error||b.status;M({id:a.id,text:e("connectors.saveFailed",{error:String(F)}),error:!0})}}async function $e(a){if(!confirm(e("connectors.delConfirm")))return;M({id:a.id,text:e("connectors.deleting")});let l=await V("DELETE",`/api/connectors/${encodeURIComponent(a.id)}`);if(s.current)if(l.status===200&&l.body?.ok)M(null),await v();else{let b=l.body?.error||l.status;M({id:a.id,text:e("connectors.deleteFailed",{error:String(b)}),error:!0})}}function Ae(a){ce(be(a.id),e("connectors.copy")).then(l=>{!l||!s.current||(te(a.id),d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{s.current&&te(null)},1200))})}return(0,t.jsxs)("section",{className:"page connectors-page",children:[(0,t.jsxs)("div",{className:"page-heading",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"eyebrow",children:e("nav.connectors")}),(0,t.jsx)("h1",{children:e("nav.connectors")})]}),(0,t.jsx)("div",{className:"page-heading-actions",children:o.tab==="webhooks"?(0,t.jsx)(Se,{className:"page-primary-action connector-create-trigger",onClick:S,children:e("connectors.createTitle")}):(0,t.jsx)("a",{className:"button page-primary-action",href:"#/connectors",children:e("webhookLogs.manage")})})]}),(0,t.jsx)(Qe,{active:o.tab}),o.tab==="webhooks"?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("dialog",{ref:f,className:"connector-create-modal",onCancel:a=>{a.preventDefault(),P()},onClose:P,onClick:a=>{a.target===a.currentTarget&&P()},children:(0,t.jsxs)("article",{className:"connector-modal-card",children:[(0,t.jsxs)("header",{className:"connector-modal-header",children:[(0,t.jsx)("h3",{children:e(x?"connectors.editTitle":"connectors.createTitle")}),(0,t.jsx)("button",{type:"button",className:"connector-modal-close","aria-label":e("connectors.close"),title:e("connectors.close"),disabled:X,onClick:P,children:(0,t.jsx)("span",{"aria-hidden":"true",children:"\xD7"})})]}),(0,t.jsx)("div",{className:"connector-modal-body",children:J?(0,t.jsx)(Ve,{created:J,groupName:z}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"cn-form",children:[(0,t.jsxs)("label",{className:"cn-field",htmlFor:"cn-name",children:[(0,t.jsx)(T,{children:e("connectors.fName")}),(0,t.jsx)("input",{id:"cn-name",value:r.name,onChange:a=>h({name:a.currentTarget.value}),placeholder:e("connectors.fNamePh")})]}),(0,t.jsxs)("div",{className:"cn-field",children:[(0,t.jsx)(T,{children:e("connectors.fBot")}),(0,t.jsx)(pe,{id:"cn-bot",label:e("connectors.fBot"),value:r.botId,options:fe,onChange:a=>h({botId:a})})]}),(0,t.jsxs)("div",{className:"cn-field",children:[(0,t.jsx)(T,{children:e("connectors.fKind")}),(0,t.jsx)(pe,{id:"cn-kind",label:e("connectors.fKind"),value:r.kind,options:H,onChange:a=>h({kind:a})})]}),r.kind==="workflow"?(0,t.jsxs)("label",{className:"cn-field",htmlFor:"cn-wf",children:[(0,t.jsx)(T,{children:e("connectors.fWf")}),(0,t.jsx)("input",{id:"cn-wf",value:r.workflowId,onChange:a=>h({workflowId:a.currentTarget.value}),placeholder:"workflowId"})]}):null,(0,t.jsxs)("div",{className:"cn-field",children:[(0,t.jsx)(T,{children:e("connectors.fMode")}),(0,t.jsx)(pe,{id:"cn-mode",label:e("connectors.fMode"),value:r.mode,options:ye,onChange:a=>h({mode:a})})]}),r.mode==="fixed"?(0,t.jsxs)("div",{className:"cn-field cn-field-wide",children:[(0,t.jsx)(T,{children:e("connectors.fFixedChat")}),(0,t.jsxs)("div",{className:"connector-chat-control",children:[r.manualChat?(0,t.jsx)("input",{id:"cn-chat",value:r.manualChatId,onChange:a=>h({manualChatId:a.currentTarget.value}),placeholder:e("connectors.fChatManualPh")}):(0,t.jsx)(De,{id:"cn-chat-sel",label:e("connectors.fFixedChat"),groups:G,value:r.chatId,placeholder:e("connectors.groupPickerPlaceholder"),searchPlaceholder:e("connectors.groupSearchPlaceholder"),emptyLabel:e("connectors.groupNoMatches"),selectedCountLabel:a=>e("connectors.groupSelectedCount",{count:a}),onChange:a=>h({chatId:a})}),(0,t.jsx)("button",{type:"button",className:"ghost connector-inline-link",onClick:()=>h({manualChat:!r.manualChat}),children:r.manualChat?e("connectors.chatListLink"):e("connectors.chatManualLink")})]})]}):r.mode==="dynamic"?(0,t.jsxs)("div",{className:"cn-field cn-field-wide",children:[(0,t.jsxs)(T,{help:e("connectors.allowHint"),children:[e("connectors.fAllow"),(0,t.jsx)("span",{className:"muted cn-optional",children:e("connectors.optional")})]}),(0,t.jsx)(De,{id:"cn-allow-chats",label:e("connectors.fAllow"),groups:G,value:r.allowChats,multiple:!0,allLabel:e("connectors.allowAll"),placeholder:e("connectors.allowAllHint"),searchPlaceholder:e("connectors.groupSearchPlaceholder"),emptyLabel:e("connectors.groupNoMatches"),selectedCountLabel:a=>e("connectors.groupSelectedCount",{count:a}),onChange:a=>h({allowChats:a})})]}):null,r.mode==="dynamic"?(0,t.jsx)("div",{className:"cn-field-wide",children:(0,t.jsx)("div",{className:"muted connector-form-hint",dangerouslySetInnerHTML:{__html:e("connectors.dynamicHint")}})}):null,r.mode==="new-group"?(0,t.jsxs)("div",{className:"cn-field cn-field-wide connector-new-group-config",children:[(0,t.jsx)(T,{children:e("connectors.newGroupStrategy")}),(0,t.jsxs)("div",{className:"connector-strategy-options",role:"radiogroup","aria-label":e("connectors.newGroupStrategy"),children:[(0,t.jsxs)("button",{type:"button",role:"radio","aria-checked":!r.deduplicate,className:`connector-strategy-option${r.deduplicate?"":" selected"}`,onClick:()=>h({deduplicate:!1}),children:[(0,t.jsx)("span",{className:"connector-strategy-radio","aria-hidden":"true"}),(0,t.jsxs)("span",{children:[(0,t.jsx)("b",{children:e("connectors.newGroupFresh")}),(0,t.jsx)("small",{children:e("connectors.newGroupFreshHint")})]})]}),(0,t.jsxs)("button",{type:"button",role:"radio","aria-checked":r.deduplicate,className:`connector-strategy-option${r.deduplicate?" selected":""}`,onClick:()=>h({deduplicate:!0}),children:[(0,t.jsx)("span",{className:"connector-strategy-radio","aria-hidden":"true"}),(0,t.jsxs)("span",{children:[(0,t.jsx)("b",{children:e("connectors.newGroupReuse")}),(0,t.jsx)("small",{children:e("connectors.newGroupReuseHint")})]})]})]}),r.deduplicate?(0,t.jsxs)("label",{className:"connector-dedup-field",htmlFor:"cn-dedup",children:[(0,t.jsx)(T,{help:(0,t.jsx)("span",{dangerouslySetInnerHTML:{__html:e("connectors.dedupHint")}}),children:e("connectors.fDedup")}),(0,t.jsx)("input",{id:"cn-dedup",value:r.dedup,onChange:a=>h({dedup:a.currentTarget.value}),placeholder:e("connectors.fDedupPh")})]}):null,(0,t.jsx)("p",{className:"connector-new-group-note",children:e("connectors.newGroupNotice")})]}):null,(0,t.jsxs)("label",{className:"cn-field cn-field-wide",htmlFor:"cn-instruction",children:[(0,t.jsxs)(T,{help:e("connectors.fInstructionPh"),children:[e("connectors.fInstruction"),(0,t.jsx)("span",{className:"muted cn-optional",children:e("connectors.optional")})]}),(0,t.jsx)("textarea",{id:"cn-instruction",rows:3,value:r.instruction,onChange:a=>h({instruction:a.currentTarget.value}),placeholder:e("connectors.fInstructionPh")})]}),(0,t.jsxs)("div",{className:"cn-field cn-field-wide connector-topic-message-config",children:[(0,t.jsx)(T,{help:e("connectors.topicMessageHint"),children:e("connectors.topicMessage")}),(0,t.jsx)("div",{className:"connector-topic-message-options",role:"radiogroup","aria-label":e("connectors.topicMessage"),children:["default","custom","template","none"].map(a=>{let l=a==="default"?"Default":a==="custom"?"Custom":a==="template"?"Template":"None";return(0,t.jsxs)("button",{type:"button",role:"radio","aria-checked":r.topicMessageMode===a,className:`connector-topic-message-option${r.topicMessageMode===a?" selected":""}`,onClick:()=>h({topicMessageMode:a}),children:[(0,t.jsx)("span",{className:"connector-strategy-radio","aria-hidden":"true"}),(0,t.jsxs)("span",{children:[(0,t.jsx)("b",{children:e(`connectors.topicMessage${l}`)}),(0,t.jsx)("small",{children:e(`connectors.topicMessage${l}Hint`)})]})]},a)})}),r.topicMessageMode==="custom"||r.topicMessageMode==="template"?(0,t.jsxs)("div",{className:"connector-topic-message-input",children:[(0,t.jsx)("input",{id:"cn-topic-message",type:"text",maxLength:200,value:r.topicMessageText,onChange:a=>h({topicMessageText:a.currentTarget.value}),"aria-label":e(r.topicMessageMode==="template"?"connectors.topicMessageTemplate":"connectors.topicMessageCustom"),placeholder:e(r.topicMessageMode==="template"?"connectors.topicMessageTemplatePh":"connectors.topicMessageCustomPh")}),(0,t.jsxs)("small",{children:[e(r.topicMessageMode==="template"?"connectors.topicMessageTemplateHelp":"connectors.topicMessageCustomHelp"),(0,t.jsxs)("span",{children:[Array.from(r.topicMessageText).length,"/200"]})]}),r.topicMessageMode==="template"?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("textarea",{id:"cn-topic-message-extractors",className:"connector-topic-message-extractors",rows:8,value:r.topicMessageExtractors,onChange:a=>h({topicMessageExtractors:a.currentTarget.value}),placeholder:e("connectors.topicMessageExtractorsPh"),"aria-label":e("connectors.topicMessageExtractors")}),(0,t.jsx)("small",{children:e("connectors.topicMessageExtractorsHelp")})]}):null]}):(0,t.jsx)("p",{className:`connector-topic-message-preview${r.topicMessageMode==="none"?" muted":""}`,children:r.topicMessageMode==="none"?e("connectors.topicMessageNonePreview"):e("connectors.topicMessagePreview",{source:r.name.trim()||e("connectors.topicMessageSourceFallback")})})]}),(0,t.jsxs)("label",{className:"connector-log-policy cn-field-wide",htmlFor:"cn-store-payload",children:[(0,t.jsx)("input",{id:"cn-store-payload",type:"checkbox",checked:r.storePayload,onChange:a=>h({storePayload:a.currentTarget.checked})}),(0,t.jsxs)("span",{children:[(0,t.jsx)("strong",{children:e("connectors.storePayload")}),(0,t.jsx)("small",{children:e("connectors.storePayloadHint")})]})]}),(0,t.jsxs)("label",{className:"connector-log-policy cn-field-wide",htmlFor:"cn-suppress-final",children:[(0,t.jsx)("input",{id:"cn-suppress-final",type:"checkbox",checked:r.suppressFinalOutput,onChange:a=>h({suppressFinalOutput:a.currentTarget.checked})}),(0,t.jsxs)("span",{children:[(0,t.jsx)("strong",{children:e("connectors.suppressFinalOutput")}),(0,t.jsx)("small",{children:e("connectors.suppressFinalOutputHint")})]})]}),(0,t.jsxs)("div",{className:"cn-field",children:[(0,t.jsx)(T,{children:e("connectors.fVerify")}),(0,t.jsx)(pe,{id:"cn-verify",label:e("connectors.fVerify"),value:r.verify,options:ke,onChange:a=>h({verify:a})})]}),(0,t.jsxs)("label",{className:"cn-field",htmlFor:"cn-secret",children:[(0,t.jsx)(T,{children:e("connectors.fSecret")}),(0,t.jsx)("input",{id:"cn-secret",value:r.secret,onChange:a=>h({secret:a.currentTarget.value}),placeholder:e(x?"connectors.fSecretEditPh":"connectors.fSecretPh")})]})]}),U?(0,t.jsx)("p",{className:`connector-create-message${U.error?" err":""}`,children:U.text}):null]})}),(0,t.jsx)("footer",{className:"connector-modal-actions",children:J?(0,t.jsx)("button",{type:"button",className:"primary",onClick:P,children:e("connectors.close")}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{type:"button",disabled:X,onClick:P,children:e("connectors.cancel")}),(0,t.jsx)("button",{id:"cn-create",type:"button",className:"primary",disabled:X,onClick:()=>{ae()},children:e(x?"connectors.btnSave":"connectors.btnCreate")})]})})]})}),(0,t.jsx)("section",{className:"overview-block connector-section connector-list-section",children:(0,t.jsx)("div",{className:"card connector-list-card",children:$?(0,t.jsx)(de,{className:"connector-list-loading",label:e("connectors.loading"),compact:!0}):(0,t.jsx)(Ye,{connectors:R,bots:N,copiedId:g,editMsg:ee,groupName:z,modeLabel:Q,kindLabel:oe,onCopy:Ae,onEdit:ne,onToggle:a=>{se(a)},onTogglePayloadLogging:a=>{ve(a)},onDelete:a=>{$e(a)}})})})]}):(0,t.jsx)(Ee,{embedded:!0})]})}function Ve(o){let e=_(),s=o.created,d=s.isDynamic?`${s.url}?chatId=${s.exampleChat}`:s.url,f=s.exampleChat!=="<chatId>"?`\uFF08${o.groupName(s.exampleChat)}\uFF09`:"";return(0,t.jsx)("div",{className:"connector-created-wrap",children:(0,t.jsxs)("div",{className:"card connector-created-card",children:[(0,t.jsxs)("p",{className:"connector-created-title ok",children:[e(s.rotated?"connectors.rotatedPrefix":"connectors.createdPrefix",{name:s.name}),s.mode==="fixed"&&s.chatId?(0,t.jsxs)("span",{className:"muted",children:[" \xB7 ",e("connectors.createdDest",{name:o.groupName(s.chatId)})]}):null]}),(0,t.jsxs)("p",{className:"connector-created-line",children:[(0,t.jsx)("span",{className:"muted",children:e("connectors.webhookUrl")}),(0,t.jsx)("code",{children:s.url})]}),s.secret?(0,t.jsxs)("p",{className:"connector-created-line",children:[(0,t.jsxs)("span",{className:"muted",children:[s.isToken?e("connectors.tokenLabel"):e("connectors.signLabel"),e("connectors.secretOnce")]}),(0,t.jsx)("code",{children:s.secret})]}):null,s.isToken&&s.isDynamic?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:"muted connector-created-help",children:e("connectors.usageDynamicLede",{gn:f})}),(0,t.jsx)("pre",{children:(0,t.jsx)("code",{children:`curl -X POST '${d}' -H 'content-type: application/json' -d '{}'`})}),(0,t.jsx)("p",{className:"muted connector-created-help",dangerouslySetInnerHTML:{__html:e("connectors.usageDynamicNote")}})]}):s.isToken?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:"muted connector-created-help",children:e("connectors.usageTokenLede")}),(0,t.jsx)("pre",{children:(0,t.jsx)("code",{children:`curl -X POST '${d}' -H 'content-type: application/json' -d '{}'`})}),(0,t.jsx)("p",{className:"muted connector-created-help",dangerouslySetInnerHTML:{__html:e("connectors.usageTokenNote")}})]}):(0,t.jsx)("p",{className:"muted connector-created-help",dangerouslySetInnerHTML:{__html:e("connectors.usageHmac")+(s.isDynamic?e("connectors.usageHmacDynamic"):"")}})]})})}function Ye(o){let e=_();return o.connectors.length?(0,t.jsx)(t.Fragment,{children:o.connectors.map(s=>{let d=o.bots.find(L=>L.larkAppId===s.target.botId),f=be(s.id),N=(s.verify?.type??"token")==="token",y=e(N?"connectors.badgeToken":"connectors.badgeSign"),I=s.target.mode==="fixed"&&s.target.chatId?e("connectors.dest",{name:o.groupName(s.target.chatId)}):"",k=o.editMsg?.id===s.id?o.editMsg:null,R=o.copiedId===s.id;return(0,t.jsxs)("div",{className:"card connector-item-card",children:[(0,t.jsxs)("div",{className:"connector-item-head",children:[(0,t.jsxs)("div",{className:"connector-item-main",children:[(0,t.jsxs)("div",{className:"connector-item-title",children:[(0,t.jsx)("b",{children:s.name}),(0,t.jsx)("span",{className:s.enabled?"connector-status-pill ok":"connector-status-pill muted",children:s.enabled?e("connectors.enabled"):e("connectors.disabled")})]}),(0,t.jsxs)("div",{className:"connector-item-meta",children:[(0,t.jsx)("span",{children:d?.botName||s.target.botId}),(0,t.jsx)("span",{children:o.kindLabel(s.target.kind)}),(0,t.jsx)("span",{children:o.modeLabel(s.target.mode)}),I?(0,t.jsx)("span",{children:I}):null,(0,t.jsx)("span",{children:y}),(0,t.jsx)("span",{children:s.loggingPolicy?.storePayload!==!1?e("connectors.payloadLogged",{days:s.loggingPolicy?.retentionDays??14}):e("connectors.metadataOnly")})]})]}),(0,t.jsx)("button",{className:`ghost connector-copy-button${R?" copied":""}`,type:"button",onClick:()=>o.onCopy(s),children:e(R?"connectors.copied":"connectors.copy")})]}),(0,t.jsxs)("div",{className:"connector-url-row",children:[(0,t.jsx)("span",{className:"muted",children:e("connectors.webhookUrl")}),(0,t.jsxs)("code",{children:[f,N?"/<token>":""]})]}),N?(0,t.jsx)("div",{className:"muted connector-item-note",dangerouslySetInnerHTML:{__html:e("connectors.tokenHint")}}):null,s.target.kind==="workflow"?(0,t.jsx)("div",{className:"muted connector-item-note",children:e("connectors.legacyWorkflowNote")}):null,s.target.mode==="dynamic"?(0,t.jsx)("div",{className:"muted connector-item-note",dangerouslySetInnerHTML:{__html:e("connectors.dynamicReqHint")}}):null,s.promptEnvelope?.instruction?(0,t.jsxs)("div",{className:"muted connector-item-note",children:[e("connectors.instructionPrefix"),s.promptEnvelope.instruction]}):null,(0,t.jsx)("div",{className:"muted connector-item-note",children:s.topicMessage?.mode==="none"?e("connectors.topicMessageListNone"):s.topicMessage?.mode==="custom"||s.topicMessage?.mode==="template"?e("connectors.topicMessageListCustom",{text:s.topicMessage.text||""}):e("connectors.topicMessageListDefault")}),k?(0,t.jsx)("div",{className:k.error?"err connector-item-note":"muted connector-item-note",children:k.text}):null,(0,t.jsxs)("div",{className:"connector-item-actions",children:[(0,t.jsx)("button",{className:"ghost",type:"button",onClick:()=>o.onEdit(s),children:e("connectors.btnEdit")}),(0,t.jsx)("button",{className:"ghost",type:"button",onClick:()=>o.onTogglePayloadLogging(s),children:s.loggingPolicy?.storePayload!==!1?e("connectors.btnDisablePayloadLog"):e("connectors.btnEnablePayloadLog")}),(0,t.jsx)("button",{className:"ghost",type:"button",onClick:()=>o.onToggle(s),children:s.enabled?e("connectors.btnDisable"):e("connectors.btnEnable")}),(0,t.jsx)("button",{className:"ghost",type:"button",onClick:()=>o.onDelete(s),children:e("connectors.btnDel")})]})]},s.id)})}):(0,t.jsx)("p",{className:"muted connector-list-empty",children:e("connectors.empty")})}function gt(o){return re(o,(0,t.jsx)(Oe,{tab:"webhooks"}))}function mt(o){return re(o,(0,t.jsx)(Oe,{tab:"logs"}))}export{ut as buildConnectorInstructionUpdateBody,je as buildConnectorKindOptions,Ke as buildConnectorTopicMessageConfig,mt as renderConnectorsLogsPage,gt as renderConnectorsPage,Xe as replaceConnectorById};
@@ -1 +0,0 @@
1
- import{x as n}from"./chunk-F6KNPF4R.js";import{a as v}from"./chunk-SYC6D5XU.js";import{a as F,d as f}from"./chunk-5THX4DI2.js";import{c as m}from"./chunk-7SZRL6FY.js";var r=m(F(),1);var e=m(f(),1);function C(){let s=new Date,o=new Date(s.getTime()-30*864e5);return new URLSearchParams({from:o.toISOString(),to:s.toISOString()})}async function c(s,o){let i=await fetch(`${s}?${o}`);if(!i.ok)throw new Error(await i.text());return i.json()}function E(){let[s,o]=(0,r.useState)(),[i,k]=(0,r.useState)([]),[l,y]=(0,r.useState)([]),[h,S]=(0,r.useState)([]),[u,R]=(0,r.useState)(),[b,p]=(0,r.useState)(""),g=async a=>{try{p("");let t=C(),[I,D,T,d]=await Promise.all([c("/api/feedback/analytics/summary",t),c("/api/feedback/analytics/trend",t),c("/api/feedback/analytics/reasons",t),c("/api/feedback/analytics/deliveries",new URLSearchParams([...t,["limit","25"],...a?[["cursor",a]]:[]]))]);o(I),k(D.items),y(T.items),S(x=>a?[...x,...d.items]:d.items),R(d.nextCursor)}catch(t){p(t instanceof Error?t.message:String(t))}};(0,r.useEffect)(()=>{g()},[]);let N=Math.max(1,...i.map(a=>a.ratings)),P=Math.max(1,...l.map(a=>a.count));return(0,e.jsxs)("div",{className:"page feedback-page",children:[(0,e.jsx)("header",{className:"sect-header",children:(0,e.jsxs)("div",{children:[(0,e.jsx)("h1",{children:n("feedback.title")}),(0,e.jsx)("p",{children:n("feedback.subtitle")})]})}),b&&(0,e.jsx)("p",{className:"error-banner",children:b}),(0,e.jsx)("section",{className:"feedback-kpis",children:[["feedback.delivered",s?.delivered],["feedback.rated",s?.ratedDeliveries],["feedback.coverage",s?`${Math.round(s.ratingCoverage*100)}%`:void 0],["feedback.positiveRate",s?`${Math.round(s.positiveRate*100)}%`:void 0],["feedback.deliveryFailures",s?.deliveryFailures],["feedback.outboxFailures",s?.outboxFailures]].map(([a,t])=>(0,e.jsxs)("article",{children:[(0,e.jsx)("span",{children:n(String(a))}),(0,e.jsx)("strong",{children:t??"\u2014"})]},String(a)))}),(0,e.jsxs)("div",{className:"feedback-grid",children:[(0,e.jsxs)("section",{className:"panel",children:[(0,e.jsx)("h2",{children:n("feedback.trend")}),i.map(a=>(0,e.jsxs)("div",{className:"feedback-bar",children:[(0,e.jsx)("span",{children:a.bucket}),(0,e.jsx)("i",{style:{width:`${a.ratings/N*100}%`}}),(0,e.jsxs)("b",{children:[a.positive,"/",a.ratings]})]},a.bucket))]}),(0,e.jsxs)("section",{className:"panel",children:[(0,e.jsx)("h2",{children:n("feedback.reasons")}),l.map(a=>(0,e.jsxs)("div",{className:"feedback-bar negative",children:[(0,e.jsx)("span",{children:a.reasonKey}),(0,e.jsx)("i",{style:{width:`${a.count/P*100}%`}}),(0,e.jsx)("b",{children:a.count})]},a.reasonKey))]})]}),(0,e.jsxs)("section",{className:"panel",children:[(0,e.jsx)("h2",{children:n("feedback.deliveries")}),(0,e.jsx)("div",{className:"feedback-deliveries",children:h.map(a=>(0,e.jsxs)("div",{children:[(0,e.jsx)("code",{children:a.deliveryId}),(0,e.jsx)("span",{children:a.createdAt}),(0,e.jsxs)("span",{children:[a.botAppId??"\u2014"," \xB7 ",a.model??a.cliId??"\u2014"]}),(0,e.jsx)("b",{children:a.semantic??a.status??"unrated"})]},a.deliveryId))}),u&&(0,e.jsx)("button",{className:"btn-link feedback-more",onClick:()=>{g(u)},children:n("feedback.loadMore")})]})]})}function w(s){return v(s,(0,e.jsx)(E,{}))}export{w as renderFeedbackPage};
@@ -1,8 +0,0 @@
1
- import{a as ke,b as Se,c as Pe,d as Ie}from"./chunk-R3FXBFQH.js";import{c as oe,d as ye,e as we}from"./chunk-4XNJX6B3.js";import{a as pe}from"./chunk-ZJVTGU5X.js";import{c as Q,g as ee,h as fe,m as te,n as me,o as he,p as ve,q as be}from"./chunk-5CJMHTT4.js";import{d as de}from"./chunk-FXW3V4JR.js";import"./chunk-24ONYQMR.js";import{A as le,D as ce,a as z,b as K,x as Z}from"./chunk-F6KNPF4R.js";import{a as ue}from"./chunk-SYC6D5XU.js";import{a as Ue,d as ge}from"./chunk-5THX4DI2.js";import{c as Y}from"./chunk-7SZRL6FY.js";var l=Y(Ue(),1);var He=/^[A-Za-z0-9._-]{1,64}$/,Ne=6,Ce=30;function re(o,t){return Pe(o,t)}function Ge(o,t,r=Ce){let n=Number.isFinite(r)?Math.max(1,Math.floor(r)):Ce,a=o.length,c=Math.max(1,Math.ceil(a/n)),s=Number.isFinite(t)?Math.floor(t):1,p=Math.min(c,Math.max(1,s)),v=(p-1)*n,x=Math.min(a,v+n);return{rows:o.slice(v,x),page:p,totalPages:c,from:a===0?0:v+1,to:x,total:a}}async function Re(o,t,r){if(o.length===0)return[];let n=new Array(o.length),a=0,c=Math.min(Math.max(1,t),o.length);return await Promise.all(Array.from({length:c},async()=>{for(;a<o.length;){let s=a++;n[s]=await r(o[s])}})),n}function ne(o){return He.test(o)&&o!=="."&&o!==".."}function ae(o){let t=String(o??"").trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64);return ne(t)?t:"profile"}async function X(){let t=await(await fetch("/api/role-profiles")).json().catch(()=>({}));return Array.isArray(t.profiles)?t.profiles:[]}async function xe(o){let t=await X(),r=await Re(t,Ne,async s=>{try{let v=await(await fetch(`/api/role-profiles/${encodeURIComponent(s.profileId)}`)).json().catch(()=>({}));return[s.profileId,Array.isArray(v.entries)?v.entries:[]]}catch{return[s.profileId,[]]}}),n=new Set,a=[];for(let s of o.chats??[])for(let p of s.memberBots??[]){if(!p?.inChat||!p?.hasRole||!p?.larkAppId)continue;let v=re(p.larkAppId,s.chatId);n.has(v)||(n.add(v),a.push({chatId:s.chatId,larkAppId:p.larkAppId}))}let c=await Ie(a);return{profiles:t,entriesById:new Map(r),groupRoleContentByBot:c,loaded:!0}}async function Ae(o){let t=(o.memberBots??[]).filter(r=>r?.inChat&&r?.larkAppId);return Re(t,Ne,async r=>{try{let a=await(await fetch(`/api/roles/${encodeURIComponent(r.larkAppId)}/${encodeURIComponent(o.chatId)}`)).json().catch(()=>({})),c=a?.hasEffectiveRole??a?.hasRole,s="effectiveContent"in a?a.effectiveContent:a.content,p=c?String(s??"").trim():"",v=a?.effectiveSource==="chat"||a?.effectiveSource==="team"?a.effectiveSource:null;return{larkAppId:r.larkAppId,botName:r.botName,content:p,status:p?v??"chat":"empty"}}catch{return{larkAppId:r.larkAppId,botName:r.botName,content:"",status:"error"}}})}function Be(o,t){return o.filter(r=>!t||!t.has(r.larkAppId))}function Te(o,t){let r=t.q.trim().toLowerCase();return o.filter(n=>!r||(n.name??"").toLowerCase().includes(r)||n.chatId.toLowerCase().includes(r)||(n.ownerId??"").toLowerCase().includes(r)).filter(n=>!t.missingOnly||(n.memberBots??[]).some(a=>!a.inChat))}function Ee(o,t){if(t.size===0)return!0;let r=o?.memberBots??[];for(let n of t)if(!r.some(a=>a.larkAppId===n&&a.inChat))return!1;return!0}function $e(o){let t=Array.isArray(o)?o:[],r=t.filter(n=>!!n?.ok).length;return{rows:t,okCount:r,failed:t.length-r}}function Le(o,t,r){let n=String(o??"").trim();if(!n)return null;if(r)return{kind:"warn",text:Z("groups.roleProfileBootstrapFailed",{name:n,reason:String(r)})};let a=typeof t=="string"&&t.trim()?t.trim():"";return a?{kind:"ok",text:Z("groups.roleProfileBootstrapSent",{name:n,messageId:a})}:{kind:"ok",text:Z("groups.roleProfileBootstrapDone",{name:n})}}function Me(o,t,r,n,a){let c=new Set(n);a&&c.add(a);let s={chatId:t,name:r,ownerId:a??null,memberBots:o.bots.map(p=>({larkAppId:p.larkAppId,botName:p.botName,inChat:c.has(p.larkAppId),oncallChat:null}))};return{bots:o.bots,chats:[s,...o.chats.filter(p=>p.chatId!==t)]}}var e=Y(ge(),1);function Oe(){return{profiles:[],entriesById:new Map,groupRoleContentByBot:new Map,loaded:!1}}function _e(o){let t={};for(let r of le(o).split(";")){if(!r)continue;let n=r.indexOf(":");n<=0||(t[r.slice(0,n)]=r.slice(n+1))}return t}function We(o){let t=o.chat,r=t.avatar??ce(t.chatId),[n,a]=(0,l.useState)(!1);(0,l.useEffect)(()=>{a(!1)},[r]);let c=t.name??t.chatId,s=!!r&&!n;return(0,e.jsx)("span",{className:`orb-avatar orb-square orb-avatar-sm${s?" orb-has-img":""}`,style:_e(c),"aria-hidden":"true",children:s?(0,e.jsx)("img",{className:"orb-img",src:r,alt:"",decoding:"async",referrerPolicy:"no-referrer",onError:()=>a(!0)}):null})}function se(o){return(0,e.jsxs)("p",{className:"hint-warn",children:[(0,e.jsx)("strong",{children:o.title}),(0,e.jsx)("br",{}),(0,e.jsx)("small",{children:String(o.reason??"unknown")})]})}function Fe(o){let t=Be(o.bots,o.excludeIds),r=o.tr;return(0,e.jsx)(we,{bots:t,selected:o.selected,onToggle:o.onToggle,searchPlaceholder:r("botPicker.searchPlaceholder"),noMatchLabel:r("botPicker.noMatch"),emptyLabel:r("botPicker.empty"),selectedCountLabel:n=>r("botPicker.selectedCount",{n:String(n)})})}function Je(o){let t=o.summary;return t.rows.length?(0,e.jsxs)("div",{className:t.failed?"hint-warn":"hint-ok",children:[(0,e.jsxs)("strong",{children:["\u6DFB\u52A0\u7ED3\u679C\uFF1A\u6210\u529F ",t.okCount,"/",t.rows.length,t.failed?`\uFF0C\u5931\u8D25 ${t.failed}`:""]}),(0,e.jsx)("ul",{children:t.rows.map((r,n)=>{let a=String(r?.id??"?");return(0,e.jsxs)("li",{children:[(0,e.jsx)("code",{children:a}),": ",r?.ok?"OK":`failed (${String(r?.error??"unknown")})`]},`${a}-${n}`)})})]}):(0,e.jsx)("p",{className:"hint-warn",children:"\u6CA1\u6709\u8FD4\u56DE\u6DFB\u52A0\u7ED3\u679C\u3002"})}function qe(o){let{chat:t,context:r,tr:n}=o;if(!r.profiles.length||!r.loaded)return null;let a=new Map;for(let v of t.memberBots??[])v?.inChat&&a.set(v.larkAppId,r.groupRoleContentByBot.get(re(v.larkAppId,t.chatId))??null);if(!ke(a))return null;let s=Se(t.memberBots??[],r.profiles,r.entriesById,a)[0];if(!s)return(0,e.jsx)("div",{className:"g-profile-status muted",children:n("groups.profileStatusUnmatched")});let p=s.kind==="full"?"groups.profileStatusFullChat":"groups.profileStatusPartial";return(0,e.jsx)("div",{className:`g-profile-status ${s.kind}`,children:n(p,{name:s.profileId,matched:s.matched,total:s.total,chat:s.chatMatched})})}function ze(o){return o?o.error?"error":o.inChat?"in":"out":"unknown"}function Ve(o,t){switch(o){case"in":return t("groups.botStatusIn");case"out":return t("groups.botStatusOut");case"error":return t("groups.botStatusError");default:return t("groups.botStatusUnknown")}}function Ke(o){let t=new Map((o.chat.memberBots??[]).map(r=>[r.larkAppId,r]));return(0,e.jsx)("div",{className:"groups-bot-strip","aria-label":o.tr("groups.botCoverage"),children:o.bots.map(r=>{let n=t.get(r.larkAppId),a=ze(n),c=Ve(a,o.tr),s=r.botName??r.larkAppId;return(0,e.jsxs)("span",{className:`groups-bot-pill groups-bot-${a}`,title:`${s}: ${c}${n?.error?` (${String(n.error)})`:""}`,children:[(0,e.jsx)("i",{"aria-hidden":"true"}),(0,e.jsx)("span",{className:"groups-bot-name",children:s}),(0,e.jsx)("span",{className:"groups-bot-state",children:c})]},r.larkAppId)})})}var De=(0,l.memo)(function(t){let{chat:r,tr:n}=t,c=(r.memberBots??[]).filter(s=>s.inChat).length;return(0,e.jsxs)(me,{kind:"group",className:"groups-list-row","data-chat":r.chatId,children:[(0,e.jsx)(We,{chat:r}),(0,e.jsxs)(he,{children:[(0,e.jsxs)("div",{className:"groups-row-head",children:[(0,e.jsx)("b",{children:r.name??r.chatId}),(0,e.jsxs)("span",{className:"groups-row-meta",children:[(0,e.jsx)("span",{className:"groups-row-tag",children:(0,e.jsx)("code",{children:r.chatId})}),r.ownerId?(0,e.jsxs)("span",{className:"groups-row-tag groups-row-owner-tag",children:[(0,e.jsx)("span",{children:n("groups.owner")}),(0,e.jsx)("code",{children:r.ownerId})]}):null]})]}),(0,e.jsx)(qe,{chat:r,context:t.roleContext,tr:n})]}),(0,e.jsx)("span",{className:"groups-row-count",children:n("groups.memberSummary",{count:c,total:t.bots.length})}),(0,e.jsxs)("div",{className:"groups-row-lower",children:[(0,e.jsx)(Ke,{chat:r,bots:t.bots,tr:n}),(0,e.jsxs)(ve,{children:[(0,e.jsx)(ee,{className:"add-bots",onClick:()=>t.onAddBots(r),children:n("groups.addBots")}),(0,e.jsx)("button",{className:"save-profile",type:"button",onClick:()=>t.onSaveProfile(r),children:n("groups.saveAsProfile")}),(0,e.jsx)("button",{className:"manage-chat",type:"button",onClick:()=>t.onManage(r),children:n("groups.manage")})]})]})]})});function Ze(o){let{tr:t}=o,[r,n]=(0,l.useState)(!1),[a,c]=(0,l.useState)(null),[s,p]=(0,l.useState)(null),[v,x]=(0,l.useState)(!1),[g,C]=(0,l.useState)(new Set),[I,u]=(0,l.useState)(""),[k,m]=(0,l.useState)([]),[S,T]=(0,l.useState)(""),[A,E]=(0,l.useState)(""),[N,U]=(0,l.useState)(""),[M,J]=(0,l.useState)(!0),[B,$]=(0,l.useState)(""),[D,q]=(0,l.useState)(!1),[F,O]=(0,l.useState)(""),[d,w]=(0,l.useState)("");(0,l.useEffect)(()=>{let f=!0;return fetch("/api/feed-groups").then(async b=>{let P=await b.json().catch(()=>({}));if(!b.ok||!P.ok)throw new Error(P.message??P.error??`HTTP ${b.status}`);f&&(m(Array.isArray(P.groups)?P.groups:[]),T(typeof P.larkAppId=="string"?P.larkAppId:""))}).catch(b=>{f&&$(b instanceof Error?b.message:String(b))}).finally(()=>{f&&J(!1)}),()=>{f=!1}},[]),(0,l.useEffect)(()=>{if(!F)return;let f=!0,b=window.setInterval(()=>{fetch("/api/feed-groups").then(async P=>{let G=await P.json().catch(()=>({}));!P.ok||!G.ok||!f||(m(Array.isArray(G.groups)?G.groups:[]),T(typeof G.larkAppId=="string"?G.larkAppId:""),$(""),O(""),w(""))}).catch(()=>{})},1e3);return()=>{f=!1,window.clearInterval(b)}},[F]);async function j(){let f=S?`?larkAppId=${encodeURIComponent(S)}`:"",b=await fetch(`/api/feed-groups/auth-url${f}`),P=await b.json().catch(()=>({}));if(!b.ok||!P.authUrl){c({title:"\u65E0\u6CD5\u53D1\u8D77\u6807\u7B7E\u6388\u6743",reason:P.error??`HTTP ${b.status}`});return}O(String(P.authUrl)),w("")}async function H(f){q(!0);try{let b=await fetch("/api/feed-groups/oauth-callback",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({callbackUrl:f.trim()})}),P=await b.json().catch(()=>({}));if(!b.ok||!P.ok)throw new Error(P.message??P.error??`HTTP ${b.status}`);let G=await fetch("/api/feed-groups"),i=await G.json().catch(()=>({}));if(!G.ok||!i.ok)throw new Error(i.message??i.error??`HTTP ${G.status}`);m(Array.isArray(i.groups)?i.groups:[]),T(typeof i.larkAppId=="string"?i.larkAppId:""),$(""),O(""),w("")}catch(b){c({title:"\u6807\u7B7E\u6388\u6743\u5931\u8D25",reason:b instanceof Error?b.message:String(b)})}finally{q(!1)}}async function _(f){f.preventDefault();let b=new FormData(f.currentTarget),P=String(b.get("name")??"").trim(),G=String(b.get("bindWorkingDir")??"").trim(),i=String(b.get("roleProfileId")??"").trim(),h=[...g];if(h.length===0){c({title:"\u8BF7\u9009\u62E9 bot",reason:"\u81F3\u5C11\u9009\u62E9\u4E00\u4E2A bot \u540E\u518D\u521B\u5EFA\u7FA4\u804A\u3002"});return}n(!0),c(null);try{let y=await fetch("/api/groups/create",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({name:P||void 0,larkAppIds:h,bindWorkingDir:G||void 0,roleProfileId:i||void 0,feedGroupId:A||void 0,newFeedGroupName:N||void 0,feedGroupAppId:A||N?S:void 0})}),R=await y.json().catch(()=>({ok:!1,error:`HTTP ${y.status}`}));R.ok&&R.chatId?(p(R),o.onCreated(R,h,P)):(c({title:"\u521B\u5EFA\u5931\u8D25",reason:R.error??`HTTP ${y.status}`}),n(!1))}catch(y){c({title:"\u7F51\u7EDC\u9519\u8BEF",reason:y}),n(!1)}}if(s){let f=String(s.chatId),b=typeof s.shareLink=="string"&&s.shareLink?s.shareLink:`https://applink.feishu.cn/client/chat/open?openChatId=${encodeURIComponent(f)}`,P=s.invalidBotIds??[],G=s.invalidUserIds??[],i=Array.isArray(s.oncallBindings)?s.oncallBindings:[],h=i.filter(L=>L?.ok).length,y=i.filter(L=>!L?.ok),R=Le(typeof s.roleProfileId=="string"?s.roleProfileId:"",s.roleProfileBootstrapMessageId,s.roleProfileBootstrapError);return(0,e.jsxs)("article",{className:"g-create-dialog g-create-success",children:[(0,e.jsx)("header",{children:(0,e.jsx)("h3",{children:t("groups.successTitle")})}),(0,e.jsxs)("p",{children:[(0,e.jsx)("b",{children:"chatId:"})," ",(0,e.jsx)("code",{children:f})," ",(0,e.jsx)("button",{type:"button","data-copy":f,onClick:()=>{pe(f,t("sessions.copy")).then(L=>{L&&(x(!0),o.setTimer(()=>x(!1),800))})},children:t(v?"sessions.copied":"sessions.copy")})]}),(0,e.jsxs)("p",{children:[(0,e.jsx)("b",{children:"\u521B\u5EFA\u8005:"})," ",(0,e.jsx)("code",{children:String(s.creator??"?")})]}),s.feedGroupId?(0,e.jsxs)("p",{className:"hint-ok",children:["\u5DF2\u52A0\u5165\u98DE\u4E66\u6807\u7B7E",s.feedGroupName?`\u300C${String(s.feedGroupName)}\u300D`:"","\u3002"]}):null,s.feedGroupError?(0,e.jsxs)("p",{className:"hint-warn",children:["\u7FA4\u804A\u5DF2\u521B\u5EFA\uFF0C\u4F46\u6807\u7B7E\u8BBE\u7F6E\u5931\u8D25\uFF1A",String(s.feedGroupError)]}):null,(0,e.jsx)(Xe,{resp:s}),i.length>0?y.length===0?(0,e.jsxs)("p",{className:"hint-ok",children:["\u5DF2\u7ED1\u5B9A\u76EE\u5F55\uFF1A",(0,e.jsx)("code",{children:String(s.bindResolvedPath??"")}),"\uFF08",h,"/",i.length," bots\uFF09"]}):(0,e.jsxs)("p",{className:"hint-warn",children:["\u76EE\u5F55\u7ED1\u5B9A\u90E8\u5206\u5931\u8D25\uFF1A\u6210\u529F ",h,"/",i.length,"\u3002",y.map((L,W)=>(0,e.jsxs)("span",{children:[(0,e.jsx)("br",{}),(0,e.jsx)("code",{children:String(L?.larkAppId??"?")}),": ",String(L?.error??"unknown")]},`${L?.larkAppId??"?"}-${W}`))]}):null,R?(0,e.jsx)("p",{className:R.kind==="ok"?"hint-ok":"hint-warn",children:R.text}):null,P.length||G.length?(0,e.jsxs)("ul",{children:[P.length?(0,e.jsxs)("li",{children:["\u65E0\u6548 bot id: ",(0,e.jsx)("code",{children:P.join(", ")})]}):null,G.length?(0,e.jsxs)("li",{children:["\u65E0\u6548\u7528\u6237 open_id: ",(0,e.jsx)("code",{children:G.join(", ")})]}):null]}):null,(0,e.jsxs)("div",{className:"actions",children:[(0,e.jsx)("button",{type:"button",id:"g-create-close",onClick:o.onClose,children:t("sessions.dismiss")}),(0,e.jsx)("a",{className:"btn-link primary",href:b,target:"_blank",rel:"noopener",children:t("groups.openGroup")})]})]})}return(0,e.jsxs)("article",{className:"g-create-dialog",children:[(0,e.jsxs)("header",{className:"g-create-head",children:[(0,e.jsx)("h3",{children:t("groups.createTitle")}),(0,e.jsx)("p",{children:t("groups.createHelp")})]}),(0,e.jsxs)("form",{id:"g-createform",className:"g-create-form",onSubmit:f=>{_(f)},children:[(0,e.jsxs)("fieldset",{className:"g-modal-field g-create-bots",children:[(0,e.jsx)("legend",{children:t("groups.botPicker")}),(0,e.jsx)("div",{className:"g-bot-picker",children:(0,e.jsx)(Fe,{bots:o.bots,tr:t,selected:g,onToggle:(f,b)=>C(P=>{let G=new Set(P);return b?G.add(f):G.delete(f),G})})})]}),(0,e.jsxs)("div",{className:"g-create-fields",children:[(0,e.jsxs)("fieldset",{className:"g-modal-field",children:[(0,e.jsx)("legend",{children:t("groups.name")}),(0,e.jsx)("input",{type:"text",name:"name",placeholder:t("groups.namePlaceholder"),maxLength:60})]}),(0,e.jsxs)("fieldset",{className:"g-modal-field",children:[(0,e.jsx)("legend",{children:t("groups.bindDir")}),(0,e.jsx)("input",{type:"text",name:"bindWorkingDir",placeholder:"e.g. ~/projects/botmux"}),(0,e.jsx)("small",{children:t("groups.bindDirHelp")})]}),(0,e.jsxs)("fieldset",{className:"g-modal-field g-profile-field",children:[(0,e.jsx)("legend",{children:t("groups.roleProfile")}),(0,e.jsx)("input",{type:"hidden",name:"roleProfileId",value:I}),(0,e.jsx)(be,{className:"g-profile-menu",ariaLabel:t("groups.roleProfile"),label:I||t("groups.roleProfileNone"),value:I,options:[{value:"",label:t("groups.roleProfileNone")},...o.roleProfiles.map(f=>({value:f.profileId,label:f.profileId}))],onChange:u}),(0,e.jsx)("small",{children:t("groups.roleProfileHelp")})]}),(0,e.jsxs)("fieldset",{className:"g-modal-field g-feed-group-field",children:[(0,e.jsx)("legend",{children:"\u98DE\u4E66\u6807\u7B7E\uFF08\u53EF\u9009\uFF09"}),(0,e.jsx)("input",{type:"hidden",name:"feedGroupId",value:A}),(0,e.jsx)(ye,{groups:k,selectedId:A,newName:N,disabled:M||!!B,onChange:(f,b)=>{E(f),U(b)}}),(0,e.jsx)("small",{children:"\u5C55\u5F00\u540E\u53EF\u5728\u7B2C\u4E00\u884C\u8F93\u5165\u65B0\u6807\u7B7E\u540D\u79F0\uFF0C\u6216\u9009\u62E9\u4E0B\u65B9\u5DF2\u6709\u6807\u7B7E\u3002"}),M?(0,e.jsx)("small",{children:"\u6B63\u5728\u8BFB\u53D6\u98DE\u4E66\u6807\u7B7E\u2026"}):null,B?(0,e.jsxs)("div",{className:"hint-warn-inline",children:[(0,e.jsx)("small",{children:B})," ",(0,e.jsx)("button",{type:"button",disabled:D,onClick:()=>{j()},children:D?"\u6B63\u5728\u5B8C\u6210\u6388\u6743\u2026":"\u7ACB\u5373\u6388\u6743"}),(0,e.jsx)("small",{children:" \u6388\u6743\u540E\u4F1A\u5F39\u7A97\u63D0\u793A\u4F60\u7C98\u8D34\u56DE\u8C03\u5730\u5740\u3002"})]}):null,!M&&!B&&k.length===0?(0,e.jsx)("small",{children:"\u5F53\u524D\u6CA1\u6709\u6807\u7B7E\uFF0C\u53EF\u76F4\u63A5\u521B\u5EFA\u4E00\u4E2A\u3002"}):null]})]}),F?(0,e.jsx)("div",{className:"feed-group-auth-overlay",children:(0,e.jsxs)("section",{className:"feed-group-auth-card",role:"dialog","aria-modal":"true","aria-labelledby":"feed-group-auth-title",children:[(0,e.jsx)("h3",{id:"feed-group-auth-title",children:"\u6388\u6743\u98DE\u4E66\u6807\u7B7E"}),(0,e.jsxs)("p",{children:["\u70B9\u51FB\u4E0B\u9762\u7684\u6309\u94AE\uFF0C\u5728\u98DE\u4E66\u9875\u9762\u786E\u8BA4\u6388\u6743\u3002\u5982\u679C BotMux \u4E0E\u6D4F\u89C8\u5668\u5728\u540C\u4E00\u53F0\u7535\u8111\uFF0C\u786E\u8BA4\u540E\u4F1A\u81EA\u52A8\u5B8C\u6210\u6388\u6743\u3002\u5982\u679C BotMux \u8FD0\u884C\u5728\u8FDC\u7A0B\u865A\u62DF\u673A\u4E0A\uFF0C\u6D4F\u89C8\u5668\u4F1A\u56E0\u65E0\u6CD5\u8BBF\u95EE\u672C\u673A\u5730\u5740 ",(0,e.jsx)("code",{children:"127.0.0.1:9768"})," \u800C\u663E\u793A\u201C\u65E0\u6CD5\u8BBF\u95EE\u201D\uFF1B\u6B64\u65F6\u8BF7\u590D\u5236\u5730\u5740\u680F\u4E2D\u7684\u5B8C\u6574\u94FE\u63A5\u5E76\u7C98\u8D34\u5230\u4E0B\u65B9\u3002"]}),(0,e.jsx)("button",{type:"button",className:"primary feed-group-auth-open",onClick:()=>window.open(F,"_blank","noopener"),children:"\u8DF3\u8F6C\u98DE\u4E66\u6388\u6743"}),(0,e.jsxs)("label",{children:[(0,e.jsx)("span",{children:"\u8BF7\u628A\u70B9\u51FB\u6388\u6743\u540E\u7684\u5B8C\u6574\u94FE\u63A5\u7C98\u8D34\u5728\u8FD9\u91CC"}),(0,e.jsx)("input",{type:"url",value:d,placeholder:"http://127.0.0.1:9768/callback?code=\u2026&state=\u2026",onChange:f=>w(f.currentTarget.value)})]}),(0,e.jsxs)("div",{className:"actions",children:[(0,e.jsx)("button",{type:"button",onClick:()=>{O(""),w("")},children:"\u53D6\u6D88"}),(0,e.jsx)("button",{type:"button",className:"primary",disabled:!d.trim()||D,onClick:()=>{H(d)},children:D?"\u6B63\u5728\u5B8C\u6210\u6388\u6743\u2026":"\u5B8C\u6210\u6388\u6743"})]})]})}):null,(0,e.jsx)("div",{className:"g-create-status","data-create-status":!0,"aria-live":"polite",children:a?(0,e.jsx)(se,{...a}):null}),(0,e.jsxs)("div",{className:"actions g-create-actions",children:[(0,e.jsx)("button",{type:"button",id:"g-create-cancel",onClick:o.onClose,children:t("groups.cancel")}),(0,e.jsx)("button",{type:"submit",className:"primary",disabled:r,children:r?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("i",{className:"button-spinner","aria-hidden":"true"}),t("groups.createSubmitting")]}):t("groups.createSubmit")})]})]})]})}function Xe(o){let t=o.resp,r=t.autoInvitedOpenId,n=!!t.autoInviteRejected,a=t.ownerTransferredTo,c=t.transferError,s=t.notifyMessageId,p=t.notifyError;return r?(0,e.jsxs)("p",{className:"hint-ok",children:["\u5DF2\u81EA\u52A8\u9080\u8BF7\u4F60\uFF08",(0,e.jsx)("code",{children:r}),"\uFF09\u4F5C\u4E3A\u6210\u5458\u3002",a?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("br",{}),(0,e.jsx)("small",{children:"\u7FA4\u4E3B\u5DF2\u4ECE\u673A\u5668\u4EBA\u8F6C\u8BA9\u7ED9\u4F60\u3002"})]}):null,c?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("br",{}),(0,e.jsxs)("small",{className:"hint-warn-inline",children:["\u26A0 \u81EA\u52A8\u8F6C\u8BA9\u7FA4\u4E3B\u5931\u8D25\uFF08",c,"\uFF09\uFF0C\u4F60\u73B0\u5728\u662F\u6210\u5458\u4F46\u7FA4\u4E3B\u4ECD\u662F\u673A\u5668\u4EBA\u3002"]})]}):null,s?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("br",{}),(0,e.jsxs)("small",{children:["\u673A\u5668\u4EBA\u5DF2\u5728\u7FA4\u91CC @ \u4E86\u4F60\uFF08\u6D88\u606F id ",(0,e.jsx)("code",{children:s}),"\uFF09\uFF0C\u770B\u98DE\u4E66\u901A\u77E5\u5C31\u80FD\u8FDB\u7FA4\u3002"]})]}):null,p?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("br",{}),(0,e.jsxs)("small",{className:"hint-warn-inline",children:["\u26A0 \u81EA\u52A8 @ \u901A\u77E5\u5931\u8D25\uFF08",p,"\uFF09\uFF0C\u65B0\u7FA4\u53EF\u80FD\u4E0D\u4F1A\u4E3B\u52A8\u51FA\u73B0\u5728\u4F60\u4FA7\u8FB9\u680F\uFF0C\u5EFA\u8BAE\u4ECE\u4E0B\u9762\u6309\u94AE\u8DF3\u8FDB\u53BB\u3002"]})]}):null]}):n?(0,e.jsxs)("p",{className:"hint-warn",children:["\u98DE\u4E66\u62D2\u7EDD\u4E86\u81EA\u52A8\u9080\u8BF7\uFF08\u4F60\u7684 open_id \u5728\u521B\u5EFA\u8005 bot \u7684 scope \u4E0B\u4E0D\u53EF\u7528\uFF09\u3002",(0,e.jsx)("strong",{children:"\u4F60\u76EE\u524D\u4E0D\u662F\u65B0\u7FA4\u6210\u5458"}),"\uFF0C\u9700\u8981\u8BA9\u7FA4\u91CC\u7684\u67D0\u4E2A\u673A\u5668\u4EBA\u624B\u52A8\u628A\u4F60\u52A0\u8FDB\u6765\u3002"]}):(0,e.jsxs)("p",{className:"hint-warn",children:["\u6CA1\u5728 dashboard \u7F13\u5B58\u91CC\u627E\u5230 ownerOpenId\uFF0C",(0,e.jsx)("strong",{children:"\u6CA1\u6709\u81EA\u52A8\u9080\u8BF7\u4F60"}),"\u3002\u70B9\u5F00\u4E0B\u9762\u94FE\u63A5\u524D\uFF0C\u5148\u8BA9\u7FA4\u91CC\u4EFB\u4E00\u673A\u5668\u4EBA\u624B\u52A8\u628A\u4F60\u52A0\u8FDB\u53BB\u3002"]})}function Ye(o){let{chat:t,tr:r}=o,[n,a]=(0,l.useState)(!1),[c,s]=(0,l.useState)(null),[p,v]=(0,l.useState)(null),[x,g]=(0,l.useState)(new Set),C=(0,l.useMemo)(()=>new Set((t.memberBots??[]).filter(u=>u.inChat).map(u=>u.larkAppId)),[t]);async function I(u){u.preventDefault();let k=[...x];if(k.length===0){s({title:"\u8BF7\u9009\u62E9 bot",reason:"\u81F3\u5C11\u9009\u62E9\u4E00\u4E2A bot \u540E\u518D\u6DFB\u52A0\u3002"}),v(null);return}a(!0),s(null),v(null);try{let S=await(await fetch(`/api/groups/${encodeURIComponent(t.chatId)}/add-bots`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({larkAppIds:k})})).json();if(S.error==="no_proxy_bot")s({title:"\u65E0\u6CD5\u6DFB\u52A0 bot",reason:"\u5F53\u524D\u7FA4\u91CC\u6CA1\u6709\u53EF\u4EE3\u7406\u64CD\u4F5C\u7684 bot\u3002\u8BF7\u5148\u5728\u98DE\u4E66\u91CC\u624B\u52A8\u62C9\u5165\u4E00\u4E2A bot\uFF0C\u7136\u540E\u91CD\u8BD5\u3002"});else if(S.result){let T=$e(S.result);try{await o.onReloadGroups({force:!0}),v({result:T})}catch(A){v({result:T,refreshError:`\u6DFB\u52A0\u7ED3\u679C\u5DF2\u8FD4\u56DE\uFF0C\u4F46\u5237\u65B0\u7FA4\u7EC4\u5217\u8868\u5931\u8D25\uFF1A${A}`})}}else s({title:"\u54CD\u5E94\u5F02\u5E38",reason:JSON.stringify(S)})}catch(m){s({title:"\u7F51\u7EDC\u9519\u8BEF",reason:m})}finally{a(!1)}}return(0,e.jsxs)("article",{className:"g-add-bots-dialog",children:[(0,e.jsx)("header",{children:(0,e.jsxs)("h3",{children:[r("groups.addBots")," \xB7 ",t.name??t.chatId]})}),(0,e.jsx)("p",{children:r("groups.createHelp")}),(0,e.jsxs)("form",{id:"g-addform",onSubmit:u=>{I(u)},children:[(0,e.jsx)(Fe,{bots:o.bots,excludeIds:C,tr:r,selected:x,onToggle:(u,k)=>g(m=>{let S=new Set(m);return k?S.add(u):S.delete(u),S})}),(0,e.jsxs)("div",{"data-add-status":!0,"aria-live":"polite",children:[c?(0,e.jsx)(se,{...c}):null,p?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(Je,{summary:p.result}),p.refreshError?(0,e.jsx)(se,{title:"\u5237\u65B0\u5931\u8D25",reason:p.refreshError}):null]}):null]}),(0,e.jsxs)("div",{className:"actions",children:[(0,e.jsx)("button",{type:"button",id:"g-cancel",onClick:o.onClose,children:r("groups.cancel")}),(0,e.jsx)("button",{type:"submit",className:"primary",disabled:n,children:n?"Adding...":r("groups.addBots")})]})]})]})}function Qe(o){let{tr:t}=o,[r,n]=(0,l.useState)([]),[a,c]=(0,l.useState)([]),[s,p]=(0,l.useState)(!0),[v,x]=(0,l.useState)(null),g=(0,l.useMemo)(()=>[...a].sort((d,w)=>d.profileId.localeCompare(w.profileId)),[a]),C=g.length>0,I=r.filter(d=>d.status==="empty").length,u=r.filter(d=>d.status==="error").length,k=!s&&!v&&r.length>0&&u===0,[m,S]=(0,l.useState)("new"),[T,A]=(0,l.useState)(o.suggestedProfileId),[E,N]=(0,l.useState)(""),[U,M]=(0,l.useState)(!1),[J,B]=(0,l.useState)(null),$=m==="overwrite"?E:T.trim(),D=t(m==="overwrite"?"groups.saveProfileOverwriteSubmit":"groups.saveProfileSubmit"),q=v||(s?t("groups.saveProfilePreparing"):u?t("groups.saveProfileFailedLoadSummary",{count:u}):r.length?I?t("groups.saveProfileEntrySummaryWithEmpty",{count:r.length,emptyCount:I}):t("groups.saveProfileEntrySummary",{count:r.length}):t("groups.saveProfileNoRoles"));(0,l.useEffect)(()=>{let d=!0;return p(!0),x(null),B(null),(async()=>{try{let[w,j]=await Promise.all([Ae(o.chat),X().catch(()=>[])]);if(!d)return;let H=[...j].sort((_,f)=>_.profileId.localeCompare(f.profileId));n(w),c(j),N(_=>H.some(f=>f.profileId===_)?_:H[0]?.profileId??"")}catch(w){if(!d)return;n([]),c([]),N(""),x(w instanceof Error?w.message:String(w))}finally{d&&p(!1)}})(),()=>{d=!1}},[o.chat]);async function F(d){if(d.preventDefault(),!!k){if(!ne($)){B({text:t("groups.saveProfileInvalid"),className:"error"});return}M(!0),B({text:t("groups.saveProfileSaving")});try{let j=(await Promise.all(r.map(async H=>(await fetch(`/api/role-profiles/${encodeURIComponent($)}/${encodeURIComponent(H.larkAppId)}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({content:H.content,allowEmpty:!0})})).ok))).filter(Boolean).length;if(j!==r.length){B({text:t("groups.saveProfileFailed",{saved:j,total:r.length}),className:"error"}),M(!1);return}B({text:t("groups.saveProfileDone",{name:$,count:j}),className:"ok"}),await o.onRefreshRoleContext(),o.setTimer(o.onClose,700)}catch(w){B({text:String(w),className:"error"}),M(!1)}}}function O(d){d==="overwrite"&&!C||(S(d),B(null))}return(0,e.jsxs)("article",{className:"g-save-profile-dialog",children:[(0,e.jsxs)("header",{children:[(0,e.jsx)("h3",{children:t("groups.saveProfileTitle")}),(0,e.jsx)("p",{children:t("groups.saveProfileIntro",{name:o.chat.name??o.chat.chatId,count:s?"-":r.length})})]}),(0,e.jsxs)("form",{id:"g-save-profile-form",onSubmit:d=>{F(d)},children:[(0,e.jsxs)("section",{className:"g-save-profile-panel",children:[(0,e.jsxs)("div",{className:"g-save-profile-section-head",children:[(0,e.jsx)("span",{children:t("groups.saveProfileScope")}),(0,e.jsx)("small",{children:t("groups.saveProfileScopeHelp")})]}),(0,e.jsxs)("div",{className:"g-save-profile-stats",children:[(0,e.jsxs)("span",{children:[t("groups.saveProfileBotCount")," ",(0,e.jsx)("strong",{children:s?"-":r.length})]}),u?(0,e.jsxs)("span",{className:"warn",children:[t("groups.saveProfileLoadFailed")," ",(0,e.jsx)("strong",{children:u})]}):null]}),(0,e.jsx)("div",{className:"g-save-profile-entry-list",children:s?(0,e.jsx)("div",{className:"g-save-profile-loading",children:(0,e.jsx)(Q,{label:t("common.loading")})}):v?(0,e.jsx)("div",{className:"g-save-profile-empty",children:v}):r.length?r.map(d=>(0,e.jsxs)("div",{className:`g-save-profile-entry ${d.status==="error"?"error":""}`,children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("strong",{children:d.botName??d.larkAppId}),(0,e.jsx)("code",{children:d.larkAppId})]}),(0,e.jsx)("span",{className:`g-save-profile-entry-status ${d.status==="error"?"error":"ok"}`,children:t(d.status==="error"?"groups.saveProfileStatus.error":"groups.saveProfileStatus.entry")})]},d.larkAppId)):(0,e.jsx)("div",{className:"g-save-profile-empty",children:t("groups.saveProfileNoRoles")})})]}),(0,e.jsxs)("div",{className:"form-row",children:[(0,e.jsx)("span",{children:t("groups.saveProfileMode")}),(0,e.jsxs)("div",{className:"g-save-profile-switch",role:"tablist","aria-label":t("groups.saveProfileMode"),children:[(0,e.jsx)("button",{type:"button",className:m==="new"?"active":"","data-save-profile-mode":"new","aria-pressed":m==="new",onClick:()=>O("new"),children:t("groups.saveProfileNew")}),(0,e.jsx)("button",{type:"button",className:m==="overwrite"?"active":"","data-save-profile-mode":"overwrite","aria-pressed":m==="overwrite",disabled:!C,onClick:()=>O("overwrite"),children:t("groups.saveProfileOverwrite")})]})]}),(0,e.jsxs)("label",{className:"form-row","data-profile-mode-row":"new",hidden:m!=="new",children:[(0,e.jsx)("span",{children:t("groups.saveProfileIdLabel")}),(0,e.jsx)("input",{type:"text",name:"profileId",value:T,maxLength:64,autoComplete:"off",onChange:d=>{A(d.currentTarget.value),B(null)}}),(0,e.jsx)("small",{children:t("groups.saveProfileInvalid")})]}),(0,e.jsxs)("div",{className:"form-row","data-profile-mode-row":"overwrite",hidden:m!=="overwrite",children:[(0,e.jsx)("span",{children:t("groups.saveProfileExistingLabel")}),C?(0,e.jsx)("div",{className:"g-save-profile-picker",children:g.map(d=>(0,e.jsxs)("button",{type:"button",className:`g-save-profile-pick ${d.profileId===E?"selected":""}`,"data-profile-id":d.profileId,"aria-pressed":d.profileId===E,onClick:()=>{N(d.profileId),S("overwrite"),B(null)},children:[(0,e.jsx)("span",{children:d.profileId}),(0,e.jsx)("small",{children:t("groups.saveProfileExistingMeta",{count:d.entryCount??0})})]},d.profileId))}):(0,e.jsx)("div",{className:"g-save-profile-summary warn",children:t("groups.saveProfileExistingEmpty")}),(0,e.jsx)("small",{children:t("groups.saveProfileOverwriteHelp")})]}),(0,e.jsxs)("div",{className:"g-save-profile-target",children:[(0,e.jsx)("span",{children:t("groups.saveProfileTarget")}),(0,e.jsx)("code",{"data-save-profile-target":!0,children:$||"-"}),(0,e.jsx)("small",{"data-save-profile-target-mode":!0,children:t(m==="overwrite"?"groups.saveProfileTargetOverwrite":"groups.saveProfileTargetNew")})]}),(0,e.jsx)("div",{className:`g-save-profile-summary ${k?"":"warn"}`,children:q}),(0,e.jsx)("div",{className:`g-save-profile-status ${J?.className??""}`,"data-save-profile-status":!0,children:J?.text??""}),(0,e.jsxs)("div",{className:"actions",children:[(0,e.jsx)("button",{type:"button",id:"g-save-profile-cancel",onClick:o.onClose,children:t("groups.cancel")}),(0,e.jsx)("button",{type:"submit",className:"primary",disabled:!k||U||m==="overwrite"&&!E,children:U?t("groups.saveProfileSaving"):D})]})]})]})}function et(o){let{member:t,tr:r}=o,n=(0,l.useRef)(null),[a,c]=(0,l.useState)(!!t.oncallChat),[s,p]=(0,l.useState)(t.oncallChat?.workingDir??""),[v,x]=(0,l.useState)(!1),[g,C]=(0,l.useState)(null);async function I(){C(null);let u=s.trim();if(a&&!u){C({text:r("groups.needWorkingDir"),className:"hint-warn-inline"});return}x(!0);try{let k=`/api/groups/${encodeURIComponent(o.chat.chatId)}/oncall/${encodeURIComponent(t.larkAppId)}`,m=a?await fetch(k,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({workingDir:u})}):await fetch(k,{method:"DELETE"}),S=await m.json().catch(()=>({}));if(m.ok&&S.ok){C({text:a?`\u2713 \u5DF2\u7ED1\u5B9A \u2192 ${S.resolvedPath??u}`:"\u2713 \u5DF2\u89E3\u7ED1",className:"hint-ok"});try{await o.onSaved()}catch{}}else C({text:`\u2717 ${S.error??m.status}`,className:"hint-warn-inline"})}catch(k){C({text:`\u2717 ${k?.message??k}`,className:"hint-warn-inline"})}finally{x(!1)}}return(0,e.jsxs)("div",{className:"oncall-row","data-bot":t.larkAppId,children:[(0,e.jsxs)("label",{className:"checkbox-row",children:[(0,e.jsx)("input",{type:"checkbox","data-action":"toggle",checked:a,onChange:u=>{c(u.currentTarget.checked),u.currentTarget.checked&&window.setTimeout(()=>n.current?.focus(),0)}}),(0,e.jsx)("strong",{children:t.botName??t.larkAppId}),(0,e.jsxs)("small",{children:["(",t.larkAppId,")"]})]}),(0,e.jsxs)("div",{className:"oncall-row-body",children:[(0,e.jsx)("input",{ref:n,type:"text","data-input":"workingDir",placeholder:"e.g. /root/iserver/botmux",value:s,disabled:!a,onChange:u=>p(u.currentTarget.value)}),(0,e.jsx)("button",{type:"button","data-action":"save",disabled:v,onClick:()=>{I()},children:r("groups.save")}),(0,e.jsx)("span",{className:`oncall-status ${g?.className??""}`,"data-status":!0,children:g?.text??""})]})]})}function tt(o){let{chat:t,tr:r}=o,n=(t.memberBots??[]).filter(g=>g.inChat),a=typeof t.ownerId=="string"?t.ownerId:"",[c,s]=(0,l.useState)(()=>new Set);function p(g,C){s(I=>{let u=new Set(I);return C?u.add(g):u.delete(g),u})}async function v(){let g=[...c];if(g.length===0){alert("\u81F3\u5C11\u9009\u4E00\u4E2A\u673A\u5668\u4EBA");return}if(confirm(`\u786E\u5B9A\u8BA9 ${g.length} \u4E2A\u673A\u5668\u4EBA\u9000\u51FA\u7FA4\u804A\uFF1F\u8BE5 bot \u5728\u6B64\u7FA4\u7684\u4F1A\u8BDD\u4F1A\u4E00\u5E76\u5173\u95ED\u3002`))try{let I=await(await fetch(`/api/groups/${encodeURIComponent(t.chatId)}/leave`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({larkAppIds:g})})).json(),u=(I.result??[]).map(k=>{if(!k.ok)return`${k.larkAppId}: \u5931\u8D25 (${k.error??"unknown"})`;let m=k.closedSessions??[],S=m.filter(N=>!N.ok).length,T=m.length-S,A=m.filter(N=>N.ok&&N.residual).map(N=>oe(N.residual)),E=m.length===0?"":`\uFF08\u5173\u95ED ${T} \u4E2A\u4F1A\u8BDD${S?`\uFF0C${S} \u4E2A\u5931\u8D25`:""}${A.length?`\uFF0C${A.length} \u4E2A\u6709\u6B8B\u7559\u9700\u4EBA\u5DE5\u6E05\u7406\uFF1A${A.join(", ")}`:""}\uFF09`;return`${k.larkAppId}: OK${E}`}).join(`
2
- `);alert(u||`Unexpected: ${JSON.stringify(I)}`),await o.onReloadGroups({force:!0})}catch(C){alert("Network error: "+C)}finally{o.onClose()}}async function x(){if(n.length===0||!confirm(`\u786E\u5B9A\u89E3\u6563\u7FA4\u804A\u300C${t.name??t.chatId}\u300D\uFF1F\u6B64\u64CD\u4F5C\u4E0D\u53EF\u6062\u590D\uFF0C\u672C\u7FA4\u6240\u6709\u673A\u5668\u4EBA\u4F1A\u8BDD\u4E5F\u4F1A\u4E00\u5E76\u5173\u95ED\u3002`))return;let g=[...n].sort((I,u)=>(u.larkAppId===a?1:0)-(I.larkAppId===a?1:0)),C=[];for(let I of g)try{let u=await fetch(`/api/groups/${encodeURIComponent(t.chatId)}/disband`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({larkAppId:I.larkAppId})}),k=await u.json();if(k.ok){let m=k.closedSessions??[],S=m.filter(N=>!N.ok).length,T=m.length-S,A=m.filter(N=>N.ok&&N.residual).map(N=>oe(N.residual)),E=m.length===0?"":`
3
- \u5173\u95ED\u4E86 ${T} \u4E2A\u4F1A\u8BDD${S?`\uFF0C${S} \u4E2A\u4F1A\u8BDD\u5173\u95ED\u5931\u8D25`:""}${A.length?`
4
- \u26A0\uFE0F ${A.length} \u4E2A\u6709\u6B8B\u7559\u9700\u4EBA\u5DE5\u6E05\u7406\uFF1A${A.join(", ")}`:""}\u3002`;alert(`\u5DF2\u89E3\u6563\uFF08\u7531 ${I.botName??I.larkAppId} \u6267\u884C\uFF09${E}`),await o.onReloadGroups({force:!0}),o.onClose();return}C.push(`${I.botName??I.larkAppId}: ${k.error??u.status}`)}catch(u){C.push(`${I.botName??I.larkAppId}: ${u}`)}alert(`\u6240\u6709\u5728\u7FA4\u673A\u5668\u4EBA\u5747\u65E0\u6CD5\u89E3\u6563\uFF1A
5
- ${C.join(`
6
- `)}
7
-
8
- \u5EFA\u8BAE\u6539\u7528\u300C\u9000\u51FA\u7FA4\u804A\u300D\u3002`)}return(0,e.jsxs)("article",{className:"g-manage-dialog",children:[(0,e.jsx)("header",{children:(0,e.jsx)("h3",{children:r("groups.manageTitle",{name:t.name??t.chatId})})}),(0,e.jsxs)("div",{className:"g-manage-meta",children:[(0,e.jsxs)("span",{children:[(0,e.jsx)("b",{children:"chatId"}),(0,e.jsx)("code",{children:t.chatId})]}),(0,e.jsxs)("span",{children:[(0,e.jsx)("b",{children:r("groups.owner")}),(0,e.jsx)("code",{children:t.ownerId??r("common.unknown")})]})]}),(0,e.jsxs)("fieldset",{children:[(0,e.jsx)("legend",{children:r("groups.oncall")}),(0,e.jsx)("p",{children:(0,e.jsx)("small",{children:r("groups.oncallHelp")})}),n.length===0?(0,e.jsx)("p",{className:"empty",children:"\u6CA1\u6709\u673A\u5668\u4EBA\u5728\u7FA4\u91CC"}):n.map(g=>(0,e.jsx)(et,{chat:t,member:g,tr:r,onSaved:async()=>{await o.onReloadGroups({force:!0})}},g.larkAppId))]}),(0,e.jsxs)("fieldset",{children:[(0,e.jsx)("legend",{children:r("groups.leaveTitle")}),n.length===0?(0,e.jsx)("p",{className:"empty",children:"\u6CA1\u6709\u673A\u5668\u4EBA\u5728\u7FA4\u91CC"}):(0,e.jsx)("div",{className:"g-leave-picker",children:n.map(g=>(0,e.jsxs)("label",{className:"checkbox-row",children:[(0,e.jsx)("input",{type:"checkbox",name:"leave-bot",value:g.larkAppId,checked:c.has(g.larkAppId),onChange:C=>p(g.larkAppId,C.currentTarget.checked)}),(0,e.jsxs)("span",{className:"checkbox-row-main",children:[(0,e.jsx)("strong",{children:g.botName??g.larkAppId}),g.larkAppId===a?(0,e.jsx)("small",{children:"\xB7 \u7FA4\u4E3B"}):null]})]},g.larkAppId))})]}),(0,e.jsx)("p",{className:"g-manage-danger-hint",children:r("groups.dangerHint")}),(0,e.jsxs)("div",{className:"actions",children:[(0,e.jsx)("button",{type:"button",onClick:o.onClose,children:r("sessions.dismiss")}),(0,e.jsx)("button",{id:"g-leave-btn",type:"button",disabled:n.length===0,onClick:()=>{v()},children:r("groups.leaveSelected")}),(0,e.jsx)("button",{id:"g-disband-btn",type:"button",className:"contrast",disabled:n.length===0,onClick:()=>{x()},children:r("groups.disband")})]})]})}function ot(o){let t=(0,l.useRef)(null);(0,l.useEffect)(()=>{let a=t.current;if(!a)return;let c=()=>o.onClose();return a.addEventListener("close",c),()=>a.removeEventListener("close",c)},[o.onClose]),(0,l.useEffect)(()=>{let a=t.current;a&&(o.dialog&&!a.open&&a.showModal(),!o.dialog&&a.open&&a.close())},[o.dialog]);let r=null;o.dialog?.type==="create"?r=(0,e.jsx)(Ze,{bots:o.snapshot.bots,roleProfiles:o.dialog.roleProfiles,tr:o.tr,onClose:o.onClose,onCreated:o.onCreated,setTimer:o.setTimer}):o.dialog?.type==="add-bots"?r=(0,e.jsx)(Ye,{chat:o.dialog.chat,bots:o.snapshot.bots,tr:o.tr,onClose:o.onClose,onReloadGroups:o.onReloadGroups}):o.dialog?.type==="save-profile"?r=(0,e.jsx)(Qe,{chat:o.dialog.chat,suggestedProfileId:o.dialog.suggestedProfileId,tr:o.tr,onClose:o.onClose,onRefreshRoleContext:o.onRefreshRoleContext,setTimer:o.setTimer}):o.dialog?.type==="manage"&&(r=(0,e.jsx)(tt,{chat:o.dialog.chat,tr:o.tr,onClose:o.onClose,onReloadGroups:o.onReloadGroups}));let n=o.dialog?.type==="create"?"groups-create-modal":void 0;return(0,e.jsx)("dialog",{id:"g-drawer",className:n,ref:t,onMouseDown:a=>{a.target===a.currentTarget&&a.currentTarget.close()},children:r})}function rt(){let o=de(),t=(0,l.useRef)(!1),r=(0,l.useRef)(z),n=(0,l.useRef)(new Set),a=(0,l.useRef)(new Map),c=(0,l.useRef)(0),[s,p]=(0,l.useState)(z),[v,x]=(0,l.useState)(()=>Oe()),[g,C]=(0,l.useState)({q:"",missingOnly:!1}),[I,u]=(0,l.useState)(!0),[k,m]=(0,l.useState)(null),[S,T]=(0,l.useState)(!1),[A,E]=(0,l.useState)(null),[N,U]=(0,l.useState)(1),M=(0,l.useCallback)(i=>{p(h=>{let y=typeof i=="function"?i(h):i;return r.current=y,y})},[]),J=(0,l.useCallback)((i,h)=>{let y=window.setTimeout(()=>{n.current.delete(y),t.current&&i()},h);return n.current.add(y),y},[]),B=(0,l.useCallback)(i=>new Promise(h=>{let y=window.setTimeout(()=>{n.current.delete(y),a.current.delete(y),h()},i);n.current.add(y),a.current.set(y,h)}),[]),$=(0,l.useCallback)(async i=>{let h=++c.current;try{let y=await xe(i??r.current);t.current&&h===c.current&&x(y)}catch{t.current&&h===c.current&&x({...Oe(),loaded:!0})}},[]),D=(0,l.useCallback)(async i=>{let h=await K({force:i?.force});return t.current&&(M(h),m(null),$(h)),h},[$,M]),q=(0,l.useCallback)(async(i,h)=>{let y=[600,1200,1200,1200,1200,1200];for(let R of y){if(await B(R),!t.current)return;let L;try{L=await K({force:!0})}catch{continue}if(!t.current)return;let W=(L.chats??[]).find(V=>V.chatId===i);if(W&&Ee(W,h)){M(L),$(L);return}}},[B,$,M]);(0,l.useEffect)(()=>(t.current=!0,(async()=>{u(!0);try{await D()}catch(i){t.current&&(M(z),m(i instanceof Error?i.message:String(i)),$(z))}finally{t.current&&u(!1)}})(),()=>{t.current=!1,c.current+=1;for(let i of n.current)window.clearTimeout(i);n.current.clear();for(let i of a.current.values())i();a.current.clear()}),[D]);let F=(0,l.useMemo)(()=>Te(s.chats,g),[s.chats,g]),O=(0,l.useMemo)(()=>F.filter(i=>!i.sessionGroup),[F]),d=(0,l.useMemo)(()=>F.filter(i=>i.sessionGroup),[F]),w=(0,l.useMemo)(()=>Ge(O,N),[O,N]);(0,l.useEffect)(()=>{N!==w.page&&U(w.page)},[N,w.page]);async function j(){T(!0);try{await D({force:!0})}catch(i){m(i instanceof Error?i.message:String(i))}finally{t.current&&T(!1)}}async function H(){if(r.current.bots.length===0){alert(o("groups.noBotsOnline"));return}let i=[];try{i=await X()}catch{}t.current&&E({type:"create",roleProfiles:i})}function _(i,h,y){let R=String(i.chatId),L=Array.isArray(i.invalidBotIds)?i.invalidBotIds:[],W=h.filter(je=>!L.includes(je)),V=new Set(W);typeof i.creator=="string"&&i.creator&&V.add(i.creator);let ie=Me(r.current,R,y||R,W,i.creator);M(ie),$(ie),q(R,V).catch(()=>{})}let f=(0,l.useCallback)(i=>{let h=new Set((i.memberBots??[]).filter(R=>R.inChat).map(R=>R.larkAppId));if(!r.current.bots.filter(R=>!h.has(R.larkAppId)).length){alert("All configured bots are already in this chat.");return}E({type:"add-bots",chat:i})},[]),b=(0,l.useCallback)(i=>{let h=ae(i.name??""),y=h==="profile"?ae(i.chatId):h;E({type:"save-profile",chat:i,suggestedProfileId:y})},[]),P=(0,l.useCallback)(i=>{E({type:"manage",chat:i})},[]);function G(i){let h=document.getElementById("g-body");h&&(h.scrollTop=0),U(i)}return(0,e.jsxs)("section",{className:"page groups-page",children:[(0,e.jsxs)("div",{className:"page-heading",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"eyebrow",children:o("nav.groups")}),(0,e.jsx)("h1",{children:o("groups.title")})]}),(0,e.jsx)("div",{className:"page-heading-actions",children:(0,e.jsx)(ee,{id:"g-create",className:"page-primary-action",onClick:()=>{H()},children:o("groups.create")})})]}),(0,e.jsxs)("form",{id:"g-filters",className:"filters dashboard-toolbar groups-toolbar",onSubmit:i=>i.preventDefault(),children:[(0,e.jsx)("input",{type:"search",name:"q",placeholder:o("groups.search"),value:g.q,onChange:i=>{let h=i.currentTarget.value;U(1),C(y=>({...y,q:h}))}}),(0,e.jsxs)("label",{className:"filter-toggle",children:[(0,e.jsx)("input",{type:"checkbox",name:"missing",checked:g.missingOnly,onChange:i=>{let h=i.currentTarget.checked;U(1),C(y=>({...y,missingOnly:h}))}}),(0,e.jsx)("span",{className:"filter-toggle-label",children:o("groups.missingOnly")}),(0,e.jsx)("span",{className:"filter-toggle-switch","aria-hidden":"true"})]}),(0,e.jsx)("span",{className:"groups-toolbar-spacer","aria-hidden":"true"}),(0,e.jsxs)("span",{className:"groups-toolbar-count",children:[o("groups.matrixTitle")," ",I?"-/-":`${O.length}/${s.chats.length}`]}),(0,e.jsx)(fe,{id:"g-refresh",label:o("groups.refresh"),busy:S,disabled:S,onClick:()=>{j()}})]}),k?(0,e.jsxs)("p",{className:"hint-warn",children:["\u52A0\u8F7D\u7FA4\u7EC4\u5931\u8D25\uFF1A",k]}):null,(0,e.jsx)("section",{className:"overview-block groups-matrix-section",children:I?(0,e.jsx)("div",{id:"g-loading",children:(0,e.jsx)(Q,{label:o("common.loading")})}):(0,e.jsxs)("div",{className:"groups-list-wrap",id:"g-table-wrap",children:[O.length===0?(0,e.jsx)("div",{className:"empty groups-list-empty",id:"g-body",children:o("groups.empty")}):(0,e.jsx)(te,{id:"g-body",className:"groups-list",children:w.rows.map(i=>(0,e.jsx)(De,{chat:i,bots:s.bots,roleContext:v,tr:o,onAddBots:f,onSaveProfile:b,onManage:P},i.chatId))}),O.length>0&&w.totalPages>1?(0,e.jsxs)("nav",{className:"groups-pagination","aria-label":o("groups.paginationLabel"),children:[(0,e.jsx)("span",{className:"groups-pagination-status","aria-live":"polite",children:o("groups.pageStatus",{page:w.page,pages:w.totalPages,from:w.from,to:w.to,total:w.total})}),(0,e.jsxs)("div",{className:"groups-pagination-actions",children:[(0,e.jsx)("button",{type:"button",disabled:w.page<=1,onClick:()=>G(w.page-1),children:o("groups.prevPage")}),(0,e.jsx)("button",{type:"button",disabled:w.page>=w.totalPages,onClick:()=>G(w.page+1),children:o("groups.nextPage")})]})]}):null]})}),!I&&d.length>0?(0,e.jsxs)("details",{className:"overview-block groups-session-section",open:!!g.q,"data-session-groups":!0,children:[(0,e.jsxs)("summary",{style:{cursor:"pointer",padding:"10px 4px",fontWeight:600,opacity:.85},children:["\u{1F916} ",o("groups.sessionSection"),"\uFF08",d.length,"\uFF09",(0,e.jsx)("span",{style:{fontWeight:400,opacity:.7,marginLeft:8},children:o("groups.sessionSectionHint")})]}),(0,e.jsx)(te,{id:"g-session-body",className:"groups-list",children:d.map(i=>(0,e.jsx)(De,{chat:i,bots:s.bots,roleContext:v,tr:o,onAddBots:f,onSaveProfile:b,onManage:P},i.chatId))})]}):null,(0,e.jsx)(ot,{dialog:A,snapshot:s,tr:o,onClose:()=>E(null),onCreated:_,onReloadGroups:D,onRefreshRoleContext:()=>$(),setTimer:J})]})}function bt(o){return ue(o,(0,e.jsx)(rt,{}))}export{Ye as AddBotsDialog,bt as renderGroupsPage};
@@ -1,2 +0,0 @@
1
- import{c as G,d as f,j as _,m as H,n as T,o as D,p as A}from"./chunk-5CJMHTT4.js";import{d as k}from"./chunk-FXW3V4JR.js";import"./chunk-24ONYQMR.js";import"./chunk-F6KNPF4R.js";import{a as U}from"./chunk-SYC6D5XU.js";import{a as Y,d as K}from"./chunk-5THX4DI2.js";import{c as $}from"./chunk-7SZRL6FY.js";var g=$(Y(),1);var e=$(K(),1);function b(n){let s=Number(n);return!Number.isFinite(s)||s<=0?"-":s>=1024**3?`${(s/1024**3).toFixed(1)} GiB`:s>=1024**2?`${(s/1024**2).toFixed(0)} MiB`:`${Math.max(1,Math.round(s/1024))} KiB`}function N(n){let s=Number(n);return Number.isFinite(s)?`${s.toFixed(1)}%`:"-"}function S(n,s){return s?N(n):"-"}function q(n){return n?.cpuReady!==!1}function d(n){let s=Number(n);return Number.isFinite(s)?String(s):"-"}function E(n){let s=Number(n);if(!Number.isFinite(s)||s<0)return"-";if(s===0)return"0s";if(s<6e4)return`${Math.max(1,Math.floor(s/1e3))}s`;let r=Math.floor(s/6e4);if(r<60)return`${Math.max(1,r)}m`;let t=Math.floor(r/60),o=r%60;return o?`${t}h ${o}m`:`${t}h`}function Z(n){return n==="fresh"||n==="stale"||n==="unsupported"?n:"unknown"}function j(n){return n?`${n.botName||"-"} \xB7 ${n.title||n.sessionId}`:"-"}function W(n,s){return s==="cpu"?Number(n.current?.cpu1mPct??n.current?.cpuPct??0):s==="rss"?Number(n.current?.rssBytes??0):s==="growth"?Number(n.current?.rssGrowth5mBytes??0):s==="bot"?n.botName??"":n.status??""}function ee(n,s){return[...n].sort((r,t)=>{let o=W(r,s),u=W(t,s);return typeof o=="number"&&typeof u=="number"?u-o||r.sessionId.localeCompare(t.sessionId):String(o).localeCompare(String(u))||r.sessionId.localeCompare(t.sessionId)})}function V(n,s){return s==="bytes"?b(n):N(n)}function F(n,s,r){let t=(n??[]).filter(Number.isFinite);if(t.length<2)return r("monitoring.chartNoData");let o=t[0],u=Number.isFinite(s)?Number(s):Date.now(),a=Math.max(0,u-o),m=Math.max(1,Math.round(a/6e4));if(m<60)return r("monitoring.chartMinutesAgo",{value:m});let p=Math.round(m/60);return p<48?r("monitoring.chartHoursAgo",{value:p}):r("monitoring.chartDaysAgo",{value:Math.round(p/24)})}function C(n){let s=(n??[]).filter(Number.isFinite);return s.length?s[s.length-1]:void 0}function R({values:n,timestamps:s,unit:r="pct",startLabel:t,endLabel:o,emptyLabel:u,className:a}){let m=(n??[]).filter(Number.isFinite),p=m.length?Math.min(...m):0,x=m.length?Math.max(...m):0,w=x-p,c=m.length>1?m.map((L,i)=>{let l=i/(m.length-1)*100,h=w>0?100-(L-p)/w*100:50;return`${l},${h}`}).join(" "):"",P=c?`0,100 ${c} 100,100`:"",B=c?c.split(" "):[],v=B.length?B[B.length-1].split(",").map(Number):null;return(0,e.jsxs)("div",{className:["resource-chart",a].filter(Boolean).join(" "),children:[(0,e.jsxs)("div",{className:"resource-chart-y","aria-hidden":"true",children:[(0,e.jsx)("span",{children:m.length?V(x,r):"-"}),(0,e.jsx)("span",{children:m.length?V(p,r):"-"})]}),(0,e.jsxs)("div",{className:"resource-chart-plot",children:[(0,e.jsxs)("div",{className:"resource-spark-wrap",children:[(0,e.jsxs)("svg",{className:"resource-spark",viewBox:"0 0 100 100",preserveAspectRatio:"none","aria-label":m.length>1?void 0:u,children:[(0,e.jsx)("line",{x1:"0",y1:"12",x2:"100",y2:"12",className:"resource-grid-line"}),(0,e.jsx)("line",{x1:"0",y1:"50",x2:"100",y2:"50",className:"resource-grid-line"}),(0,e.jsx)("line",{x1:"0",y1:"88",x2:"100",y2:"88",className:"resource-grid-line"}),P?(0,e.jsx)("polygon",{className:"resource-spark-area",points:P}):null,c?(0,e.jsx)("polyline",{points:c}):null]}),v&&Number.isFinite(v[0])&&Number.isFinite(v[1])?(0,e.jsx)("span",{className:"resource-spark-dot","aria-hidden":"true",style:{left:`${v[0]}%`,top:`${v[1]}%`}}):null]}),(0,e.jsxs)("div",{className:"resource-chart-x","aria-hidden":"true",children:[(0,e.jsx)("span",{children:m.length>1?t:u}),(0,e.jsx)("span",{children:m.length>1?o:""})]})]})]})}function I(n){let s=r=>r instanceof Element&&!!r.closest(".ui-info-tip");return(0,e.jsx)("section",{className:"metric-card","data-resource-expandable":"",role:"button",tabIndex:0,"aria-label":n.label,onClick:r=>{s(r.target)||n.onOpen()},onKeyDown:r=>{s(r.target)||r.key!=="Enter"&&r.key!==" "||(r.preventDefault(),n.onOpen())},children:n.children})}function M(n){return(0,e.jsx)("article",{className:"resource-trend-cell","data-resource-expandable":"",role:"button",tabIndex:0,"aria-label":n.label,onClick:n.onOpen,onKeyDown:s=>{s.key!=="Enter"&&s.key!==" "||(s.preventDefault(),n.onOpen())},children:n.children})}function te(n){let s=k(),r=(0,g.useRef)(null);return(0,g.useEffect)(()=>{let t=r.current;if(t)if(n.detail){if(!t.open)try{t.showModal()}catch{}}else t.open&&t.close()},[n.detail]),(0,g.useEffect)(()=>()=>{let t=r.current;t?.open&&t.close()},[]),(0,e.jsx)("dialog",{ref:r,className:"resource-detail-modal",onCancel:t=>{t.preventDefault(),n.onClose()},onClose:n.onClose,onClick:t=>{t.target===t.currentTarget&&n.onClose()},children:n.detail?(0,e.jsxs)("article",{className:"resource-detail-modal-card",children:[(0,e.jsxs)("header",{className:"resource-detail-modal-head",children:[(0,e.jsx)("h3",{children:n.detail.title}),(0,e.jsx)("button",{type:"button",className:"resource-detail-modal-close","aria-label":s("monitoring.modalClose"),title:s("monitoring.modalClose"),onClick:n.onClose})]}),(0,e.jsxs)("div",{className:"resource-detail-modal-body",children:[(0,e.jsxs)("section",{className:"resource-detail-summary",children:[(0,e.jsx)("strong",{children:n.detail.value}),(0,e.jsx)("p",{children:n.detail.detail})]}),n.detail.chart?(0,e.jsx)(R,{className:"resource-detail-chart",values:n.detail.chart.values,timestamps:n.detail.chart.timestamps,unit:n.detail.chart.unit,startLabel:n.detail.chart.startLabel,endLabel:n.detail.chart.endLabel,emptyLabel:n.detail.chart.emptyLabel}):(0,e.jsx)("p",{className:"resource-detail-empty",children:n.detail.emptyText})]})]}):null})}function ne({reasons:n}){return(0,e.jsx)("span",{className:"resource-reasons",children:(n??[]).join(", ")||"-"})}function y({label:n,value:s,tone:r}){return(0,e.jsxs)("span",{className:`resource-pill${r?` ${r}`:""}`,children:[(0,e.jsx)("span",{children:n}),(0,e.jsx)("b",{children:s})]})}function se({bots:n,cpuReady:s=!0}){let r=k();return(0,e.jsx)("div",{className:"resource-list-shell",children:(0,e.jsx)(H,{className:"resource-runtime-list",children:n.length?n.map(t=>{let o=t.runtime?.sessions,u=t.runtime?.daemonStatus??t.daemonStatus??"unknown",a=u==="online"?"ok":u==="offline"?"off":"warn";return(0,e.jsxs)(T,{className:"resource-list-item resource-bot-item",children:[(0,e.jsxs)(D,{children:[(0,e.jsx)("strong",{title:t.botName,children:t.botName}),(0,e.jsxs)("span",{children:[r("monitoring.sessionsCount")," ",d(o?.total??t.sessions?.count)]})]}),(0,e.jsx)(A,{children:(0,e.jsxs)("div",{className:"resource-pill-group",children:[(0,e.jsx)(y,{label:r("monitoring.daemon"),value:u,tone:a}),(0,e.jsx)(y,{label:r("monitoring.working"),value:d(o?.working),tone:"accent"}),(0,e.jsx)(y,{label:r("monitoring.starting"),value:d(o?.starting)}),(0,e.jsx)(y,{label:r("monitoring.cpu"),value:S(t.total?.cpuPct,s)}),(0,e.jsx)(y,{label:r("monitoring.rss"),value:b(t.total?.rssBytes)})]})})]},t.larkAppId)}):(0,e.jsx)("li",{className:"empty",children:r("overview.noSessions")})})})}function re({sessions:n,cpuReady:s=!0}){let r=k();return(0,e.jsx)("div",{className:"resource-list-shell resource-session-shell",children:(0,e.jsx)(H,{className:"resource-runtime-list resource-session-list",children:n.length?n.map(t=>(0,e.jsxs)(T,{className:`resource-list-item resource-session-item${t.tracked?" is-tracked":""}`,children:[(0,e.jsxs)(D,{children:[(0,e.jsx)("strong",{title:t.title||t.sessionId,children:t.title||t.sessionId}),(0,e.jsxs)("span",{title:t.sessionId,children:[t.botName," \xB7 ",t.sessionId]})]}),(0,e.jsx)(A,{children:(0,e.jsxs)("div",{className:"resource-pill-group",children:[(0,e.jsx)(y,{label:r("monitoring.cpu"),value:S(t.current?.cpu1mPct??t.current?.cpuPct,s),tone:"accent"}),(0,e.jsx)(y,{label:r("monitoring.rss"),value:b(t.current?.rssBytes)}),(0,e.jsx)(y,{label:r("monitoring.growth"),value:b(t.current?.rssGrowth5mBytes)}),(0,e.jsx)(y,{label:r("monitoring.confidence"),value:t.confidence??"unknown",tone:t.tracked?"ok":void 0}),(0,e.jsxs)("span",{className:"resource-pill resource-rank-pill",children:[(0,e.jsx)("span",{children:r("monitoring.rank")}),(0,e.jsx)(ne,{reasons:t.rankReasons})]})]})})]},t.sessionId)):(0,e.jsx)("li",{className:"empty",children:r("overview.noSessions")})})})}function oe({current:n}){let s=k(),r=n.runtime,t=q(n),o=Z(r?.sampleHealth?.status),u=r?.daemons?.total,a=r?.daemons?.online,m=r?.daemons?.offline??(Number.isFinite(Number(u))&&Number.isFinite(Number(a))?Math.max(0,Number(u)-Number(a)):void 0),p=r?.sessions?.total,x=r?.sessions?.working,w=r?.sessions?.starting;return(0,e.jsxs)("section",{className:"overview-block resource-block",children:[(0,e.jsx)(f,{title:s("monitoring.runtimeHealth")}),(0,e.jsx)("section",{className:"panel runtime-health-panel",children:(0,e.jsxs)("div",{className:"runtime-health-grid",children:[(0,e.jsxs)("section",{className:"metric-card runtime-health-card",children:[(0,e.jsx)("span",{children:s("monitoring.sampleHealth")}),(0,e.jsx)("strong",{children:(0,e.jsx)("span",{className:`runtime-status-pill ${o}`,children:s(`monitoring.sample.${o}`)})}),(0,e.jsxs)("small",{children:[s("monitoring.sampleAge")," ",E(r?.sampleHealth?.ageMs)]})]}),(0,e.jsxs)("section",{className:"metric-card runtime-health-card",children:[(0,e.jsx)("span",{children:s("monitoring.daemonHealth")}),(0,e.jsxs)("strong",{children:[d(a),"/",d(u)]}),(0,e.jsxs)("small",{children:[d(m)," ",s("monitoring.offline")]})]}),(0,e.jsxs)("section",{className:"metric-card runtime-health-card",children:[(0,e.jsx)("span",{children:s("monitoring.sessionHealth")}),(0,e.jsx)("strong",{children:d(p)}),(0,e.jsxs)("small",{children:[s("monitoring.working")," ",d(x)," \xB7 ",s("monitoring.starting")," ",d(w)]})]}),(0,e.jsxs)("section",{className:"metric-card runtime-health-card",children:[(0,e.jsx)("span",{children:s("monitoring.resourcePressure")}),(0,e.jsx)("strong",{children:S(n.host?.cpuPct,t)}),(0,e.jsxs)("small",{children:[s("monitoring.hostMemory")," ",N(n.host?.memUsedPct)," \xB7 RSS ",b(n.botmux?.rssBytes)]})]})]})})]})}function ae({runtime:n}){let s=k(),r=n?.sessions,t=r?.longestRunning,o=r?.longestWaiting;return(0,e.jsxs)("section",{className:"overview-block resource-block",children:[(0,e.jsx)(f,{title:s("monitoring.sessionPressure")}),(0,e.jsx)("section",{className:"panel runtime-session-pressure",children:(0,e.jsxs)("div",{className:"runtime-session-grid",children:[(0,e.jsxs)("section",{className:"metric-card runtime-session-card",children:[(0,e.jsx)("span",{children:s("monitoring.statusDistribution")}),(0,e.jsx)("strong",{children:d(r?.total)}),(0,e.jsxs)("small",{children:[s("monitoring.working")," ",d(r?.working)," \xB7 ",s("monitoring.starting")," ",d(r?.starting)," \xB7 ",s("monitoring.waiting")," ",d(r?.waiting)," \xB7 ",s("monitoring.idle")," ",d(r?.idle)," \xB7 ",s("monitoring.unknown")," ",d(r?.unknown)]})]}),(0,e.jsxs)("section",{className:"metric-card runtime-session-card",children:[(0,e.jsx)("span",{children:s("monitoring.longestRunning")}),(0,e.jsx)("strong",{children:j(t)}),(0,e.jsx)("small",{children:E(t?.durationMs)})]}),(0,e.jsxs)("section",{className:"metric-card runtime-session-card",children:[(0,e.jsx)("span",{children:s("monitoring.longestWaiting")}),(0,e.jsx)("strong",{children:j(o)}),(0,e.jsx)("small",{children:E(o?.durationMs)})]}),(0,e.jsxs)("section",{className:"metric-card runtime-session-card",children:[(0,e.jsx)("span",{children:s("monitoring.unattributedSessions")}),(0,e.jsx)("strong",{children:d(r?.unattributed)}),(0,e.jsx)("small",{children:s("monitoring.unattributedHint")})]})]})})]})}function ie({initialCurrent:n=null,initialHistory:s=null,poll:r=!0}={}){let t=k(),[o,u]=(0,g.useState)(n),[a,m]=(0,g.useState)(s),[p,x]=(0,g.useState)("cpu"),[w,c]=(0,g.useState)(null);(0,g.useEffect)(()=>{if(!r)return;let l=!1;async function h(){try{let[z,J]=await Promise.all([fetch("/api/resources/current",{cache:"no-store"}),fetch("/api/resources/history?range=3h",{cache:"no-store"})]),[Q,X]=await Promise.all([z.json(),J.json()]);l||(u(Q),m(X))}catch{l||(u({supported:!1,reason:"fetch_failed",bots:[],sessions:[]}),m({supported:!1,bots:[],sessions:[]}))}}h();let O=window.setInterval(()=>{h()},1e4);return()=>{l=!0,window.clearInterval(O)}},[r]);let P=o!==null&&a!==null,B=(0,g.useMemo)(()=>ee(o?.sessions??[],p),[o?.sessions,p]),v=o?.supported!==!1,L=q(o),i={hostStartLabel:F(a?.host?.timestamps,o?.sampledAt,t),botmuxStartLabel:F(a?.botmux?.timestamps,o?.sampledAt,t),endLabel:t("monitoring.chartNow"),emptyLabel:t("monitoring.chartNoData")};return(0,e.jsxs)("section",{className:"page resource-page",children:[(0,e.jsx)("div",{className:"page-heading",children:(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"eyebrow",children:t("monitoring.eyebrow")}),(0,e.jsx)("h1",{children:t("monitoring.runtimeTitle")})]})}),P?null:(0,e.jsx)(G,{label:t("common.loading")}),P?(0,e.jsxs)(e.Fragment,{children:[o?(0,e.jsx)(oe,{current:o}):null,v?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("section",{className:"overview-block resource-block resource-pressure-block",children:[(0,e.jsx)(f,{title:t("monitoring.resourcePressure")}),(0,e.jsx)("section",{className:"panel resource-pressure",children:(0,e.jsxs)("div",{className:"resource-metrics runtime-pressure-grid",children:[(0,e.jsxs)(I,{label:t("monitoring.hostCpu"),onOpen:()=>c({title:t("monitoring.hostCpu"),value:S(o?.host?.cpuPct,L),detail:`load ${Number(o?.host?.load1??0).toFixed(2)}`,chart:{values:a?.host?.cpuPct,timestamps:a?.host?.timestamps,unit:"pct",startLabel:i.hostStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel}}),children:[(0,e.jsx)("span",{children:t("monitoring.hostCpu")}),(0,e.jsx)("strong",{children:S(o?.host?.cpuPct,L)}),(0,e.jsxs)("small",{children:["load ",Number(o?.host?.load1??0).toFixed(2)]})]}),(0,e.jsxs)(I,{label:t("monitoring.hostMemory"),onOpen:()=>c({title:t("monitoring.hostMemory"),value:N(o?.host?.memUsedPct),detail:t("monitoring.memoryOnly"),chart:{values:a?.host?.memUsedPct,timestamps:a?.host?.timestamps,unit:"pct",startLabel:i.hostStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel}}),children:[(0,e.jsx)("span",{children:t("monitoring.hostMemory")}),(0,e.jsx)("strong",{children:N(o?.host?.memUsedPct)}),(0,e.jsx)("small",{children:t("monitoring.memoryOnly")})]}),(0,e.jsxs)(I,{label:t("monitoring.botmuxRss"),onOpen:()=>c({title:t("monitoring.botmuxRss"),value:b(o?.botmux?.rssBytes),detail:o?.botmuxBreakdown?`${t("monitoring.botmuxSelf")} ${b((o.botmuxBreakdown.daemon.rssBytes??0)+(o.botmuxBreakdown.worker.rssBytes??0))}
2
- ${t("monitoring.botmuxCli")} ${b(o.botmuxBreakdown.cli.rssBytes)}`:S(o?.botmux?.cpuPct,L),chart:{values:a?.botmux?.rssBytes,timestamps:a?.botmux?.timestamps,unit:"bytes",startLabel:i.botmuxStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel}}),children:[(0,e.jsxs)("div",{className:"metric-label-with-help",children:[(0,e.jsx)("span",{children:t("monitoring.botmuxRss")}),(0,e.jsx)(_,{label:t("monitoring.rssHelpLabel"),children:t("monitoring.rssHelp")})]}),(0,e.jsx)("strong",{children:b(o?.botmux?.rssBytes)}),o?.botmuxBreakdown&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("small",{className:"metric-breakdown",children:[t("monitoring.botmuxSelf")," ",b((o.botmuxBreakdown.daemon.rssBytes??0)+(o.botmuxBreakdown.worker.rssBytes??0)),(0,e.jsxs)("span",{className:"metric-breakdown-detail",children:[" (",t("monitoring.botmuxDaemon")," ",b(o.botmuxBreakdown.daemon.rssBytes)," \xB7 ",t("monitoring.botmuxWorker")," ",b(o.botmuxBreakdown.worker.rssBytes),")"]})]}),(0,e.jsxs)("small",{className:"metric-breakdown",children:[t("monitoring.botmuxCli")," ",b(o.botmuxBreakdown.cli.rssBytes)]})]})]}),(0,e.jsxs)(I,{label:t("monitoring.trackedSessions"),onOpen:()=>c({title:t("monitoring.trackedSessions"),value:d(o?.rankings?.tracked?.length),detail:`${t("monitoring.currentSessions")} ${(o?.sessions??[]).length}`,emptyText:t("monitoring.trackedSessionHint")}),children:[(0,e.jsx)("span",{children:t("monitoring.trackedSessions")}),(0,e.jsx)("strong",{children:o?.rankings?.tracked?.length??0}),(0,e.jsxs)("small",{children:[t("monitoring.currentSessions")," ",(o?.sessions??[]).length]})]})]})})]}),(0,e.jsxs)("section",{className:"overview-block resource-block",children:[(0,e.jsx)(f,{title:t("monitoring.trends")}),(0,e.jsx)("section",{className:"panel resource-trends",children:(0,e.jsxs)("div",{className:"resource-trend-grid",children:[(0,e.jsxs)(M,{label:t("monitoring.trendHostCpu"),onOpen:()=>c({title:t("monitoring.trendHostCpu"),value:N(C(a?.host?.cpuPct)),detail:`load ${Number(o?.host?.load1??0).toFixed(2)}`,chart:{values:a?.host?.cpuPct,timestamps:a?.host?.timestamps,unit:"pct",startLabel:i.hostStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel}}),children:[(0,e.jsx)("b",{children:t("monitoring.trendHostCpu")}),(0,e.jsx)(R,{values:a?.host?.cpuPct,timestamps:a?.host?.timestamps,unit:"pct",startLabel:i.hostStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel})]}),(0,e.jsxs)(M,{label:t("monitoring.trendHostMemory"),onOpen:()=>c({title:t("monitoring.trendHostMemory"),value:N(C(a?.host?.memUsedPct)),detail:t("monitoring.memoryOnly"),chart:{values:a?.host?.memUsedPct,timestamps:a?.host?.timestamps,unit:"pct",startLabel:i.hostStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel}}),children:[(0,e.jsx)("b",{children:t("monitoring.trendHostMemory")}),(0,e.jsx)(R,{values:a?.host?.memUsedPct,timestamps:a?.host?.timestamps,unit:"pct",startLabel:i.hostStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel})]}),(0,e.jsxs)(M,{label:t("monitoring.trendBotmuxCpu"),onOpen:()=>c({title:t("monitoring.trendBotmuxCpu"),value:N(C(a?.botmux?.cpuPct)),detail:t("monitoring.botRuntime"),chart:{values:a?.botmux?.cpuPct,timestamps:a?.botmux?.timestamps,unit:"pct",startLabel:i.botmuxStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel}}),children:[(0,e.jsx)("b",{children:t("monitoring.trendBotmuxCpu")}),(0,e.jsx)(R,{values:a?.botmux?.cpuPct,timestamps:a?.botmux?.timestamps,unit:"pct",startLabel:i.botmuxStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel})]}),(0,e.jsxs)(M,{label:t("monitoring.botmuxRss"),onOpen:()=>c({title:t("monitoring.botmuxRss"),value:b(C(a?.botmux?.rssBytes)),detail:t("monitoring.memoryOnly"),chart:{values:a?.botmux?.rssBytes,timestamps:a?.botmux?.timestamps,unit:"bytes",startLabel:i.botmuxStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel}}),children:[(0,e.jsx)("b",{children:t("monitoring.botmuxRss")}),(0,e.jsx)(R,{values:a?.botmux?.rssBytes,timestamps:a?.botmux?.timestamps,unit:"bytes",startLabel:i.botmuxStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel})]})]})})]})]}):(0,e.jsx)("section",{className:"panel resource-unavailable",children:(0,e.jsxs)("div",{className:"resource-unavailable-card",children:[(0,e.jsx)("span",{className:"resource-unavailable-status","aria-hidden":"true"}),(0,e.jsxs)("div",{className:"resource-unavailable-copy",children:[(0,e.jsx)("span",{children:t("monitoring.unsupportedKicker")}),(0,e.jsx)("h2",{children:t("monitoring.unsupportedTitle")}),(0,e.jsx)("p",{children:t("monitoring.unsupportedHint")})]}),(0,e.jsxs)("div",{className:"resource-unavailable-tags","aria-label":t("monitoring.unsupported"),children:[(0,e.jsx)("span",{children:t("monitoring.unsupportedRuntimeOk")}),(0,e.jsx)("span",{children:t("monitoring.unsupportedResourceOnly")})]})]})}),o?(0,e.jsx)(ae,{runtime:o.runtime}):null,v?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("section",{className:"overview-block resource-block",children:[(0,e.jsx)(f,{title:t("monitoring.botRuntime")}),(0,e.jsx)("section",{className:"panel",children:(0,e.jsx)(se,{bots:o?.bots??[],cpuReady:L})})]}),(0,e.jsxs)("section",{className:"overview-block resource-block",children:[(0,e.jsx)(f,{title:t("monitoring.sessions"),children:(0,e.jsx)("div",{className:"resource-sortbar resource-sortbar-inline dashboard-toolbar",role:"group","aria-label":t("monitoring.sort"),children:(0,e.jsx)("div",{className:"segmented resource-sort-switch",children:["cpu","rss","growth","bot","status"].map(l=>(0,e.jsx)("button",{type:"button",className:p===l?"active":void 0,"aria-pressed":p===l,onClick:()=>x(l),children:t(`monitoring.sort.${l}`)},l))})})}),(0,e.jsx)("section",{className:"panel",children:(0,e.jsx)(re,{sessions:B,cpuReady:L})})]}),(0,e.jsxs)("section",{className:"overview-block resource-block",children:[(0,e.jsx)(f,{title:t("monitoring.trackedSessionTrends")}),(0,e.jsx)("section",{className:"panel",children:(0,e.jsxs)("div",{className:"resource-trend-grid",children:[(a?.sessions??[]).map(l=>{let h=`${l.botName} \xB7 ${l.title||l.sessionId}`,O=F(l.series?.timestamps,o?.sampledAt,t);return(0,e.jsxs)(M,{label:h,onOpen:()=>c({title:h,value:b(C(l.series?.rssBytes)),detail:l.sessionId,chart:{values:l.series?.rssBytes,timestamps:l.series?.timestamps,unit:"bytes",startLabel:O,endLabel:i.endLabel,emptyLabel:i.emptyLabel}}),children:[(0,e.jsx)("b",{title:h,children:h}),(0,e.jsx)(R,{values:l.series?.rssBytes,timestamps:l.series?.timestamps,unit:"bytes",startLabel:O,endLabel:i.endLabel,emptyLabel:i.emptyLabel})]},l.sessionId)}),(a?.sessions??[]).length?null:(0,e.jsx)("div",{className:"empty",children:t("monitoring.noTrackedHistory")})]})})]})]}):null]}):null,(0,e.jsx)(te,{detail:w,onClose:()=>c(null)})]})}function ce(n){return U(n,(0,e.jsx)(ie,{}))}export{ie as MonitoringPage,re as SessionResourceTable,ce as renderMonitoringPage};
@@ -1 +0,0 @@
1
- import{d as x}from"./chunk-FXW3V4JR.js";import"./chunk-24ONYQMR.js";import"./chunk-F6KNPF4R.js";import{a as p}from"./chunk-SYC6D5XU.js";import{a as S,d as w}from"./chunk-5THX4DI2.js";import{c as g}from"./chunk-7SZRL6FY.js";var n=g(S(),1);var e=g(w(),1),u=78222186;function y(t){return(t/1048576).toFixed(0)}function T(){let t=x(),[i,a]=(0,n.useState)(null),[c,l]=(0,n.useState)(""),[m,h]=(0,n.useState)(!1),d=(0,n.useRef)(null),r=(0,n.useRef)(!1),v=()=>{d.current&&(clearTimeout(d.current),d.current=null)};async function f(){if(!r.current)try{let s=await fetch("/api/game/status");if(r.current)return;if(!s.ok){a({state:"absent",received:0,total:u});return}let o=await s.json();if(r.current)return;a(o),typeof o.proxy=="string"&&l(o.proxy),o.state==="downloading"&&(d.current=setTimeout(()=>{f()},700))}catch{r.current||(d.current=setTimeout(()=>{f()},1500))}}(0,n.useEffect)(()=>(r.current=!1,f(),()=>{r.current=!0,v()}),[]);async function b(){v(),h(!0),a({state:"downloading",received:0,total:u});try{let s=await fetch("/api/game/download",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({proxy:c.trim()})});if(r.current)return;if(!s.ok)throw new Error(`HTTP ${s.status}`);let o=await s.json();if(r.current)return;a(o),typeof o.proxy=="string"&&l(o.proxy),o.state==="downloading"&&(d.current=setTimeout(()=>{f()},700))}catch(s){if(r.current)return;a({state:"error",received:0,total:u,error:s instanceof Error?s.message:String(s)})}finally{r.current||h(!1)}}return i?.state==="ready"?(0,e.jsx)("div",{className:"office-frame-shell",children:(0,e.jsx)("iframe",{className:"office-game-frame",src:"/game/index.html",title:"HD2D Office",allow:"autoplay"})}):(0,e.jsx)(P,{status:i??{state:"absent",received:0,total:u},title:t("nav.office"),proxy:c,starting:m,onProxyChange:l,onStart:()=>{b()}})}function P(t){let i=t.status.total||u,a=(0,n.useMemo)(()=>i?Math.min(100,Math.round(t.status.received/i*100)):0,[t.status.received,i]),c=t.status.state==="downloading",l=t.status.state==="error";return(0,e.jsxs)("div",{style:{margin:"auto",textAlign:"center",maxWidth:440,padding:32,color:"var(--fg,#e6e6e6)"},children:[(0,e.jsx)("h1",{style:{fontSize:18,fontWeight:600,lineHeight:1.2,margin:"0 0 8px"},children:t.title}),(0,e.jsxs)("div",{style:{fontSize:13,opacity:.7,lineHeight:1.7,marginBottom:20},children:["\u628A\u6BCF\u4E2A\u4F1A\u8BDD\u53D8\u6210\u529E\u516C\u5BA4\u91CC\u7684\u4E00\u4E2A\u673A\u5668\u4EBA\uFF0C\u5B9E\u65F6\u6620\u5C04\u5C4F\u5E55\u72B6\u6001\u3002",(0,e.jsx)("br",{}),"\u9996\u6B21\u8FDB\u5165\u9700\u4E0B\u8F7D\u7EA6 ",y(i)," MB \u6E38\u620F\u8D44\u6E90\uFF08\u4EC5\u4E00\u6B21\uFF0C\u4E4B\u540E\u672C\u5730\u7F13\u5B58\uFF09\u3002"]}),l?(0,e.jsxs)("div",{style:{color:"#e06c75",fontSize:12,marginBottom:14},children:["\u4E0A\u6B21\u4E0B\u8F7D\u5931\u8D25\uFF1A",t.status.error??"\u672A\u77E5\u9519\u8BEF",(0,e.jsx)("br",{}),(0,e.jsx)("span",{style:{opacity:.7},children:"\u586B\u4EE3\u7406\u540E\u70B9\u91CD\u8BD5"})]}):null,c?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{style:{background:"var(--surface-muted)",borderRadius:"var(--radius-lg)",height:10,overflow:"hidden",marginBottom:10},children:(0,e.jsx)("div",{style:{height:"100%",width:`${a}%`,background:"var(--accent)",transition:"width .3s"}})}),(0,e.jsxs)("div",{style:{fontSize:12,opacity:.7},children:["\u4E0B\u8F7D\u4E2D... ",y(t.status.received)," / ",y(i)," MB\uFF08",a,"%\uFF09"]})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("input",{id:"hd2d-proxy",className:"office-proxy-input",type:"text",value:t.proxy,onChange:m=>t.onProxyChange(m.currentTarget.value),placeholder:"HTTP \u4EE3\u7406\uFF08\u53EF\u9009\uFF0C\u5982 http://127.0.0.1:7890\uFF09"}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.5,marginBottom:14,textAlign:"left"},children:"\u8FDE\u4E0D\u4E0A GitHub \u65F6\u586B\u4EE3\u7406\uFF08\u4EC5\u7528\u4E8E\u4E0B\u8F7D\u672C\u8D44\u6E90\uFF0C\u4F1A\u8BB0\u4F4F\uFF09\u3002\u7559\u7A7A\u8D70\u76F4\u8FDE/\u7CFB\u7EDF\u4EE3\u7406\u73AF\u5883\u53D8\u91CF\u3002"}),(0,e.jsxs)("button",{id:"hd2d-load",type:"button",className:"page-primary-action office-load-button",disabled:t.starting,onClick:t.onStart,children:[l?"\u91CD\u8BD5":"\u52A0\u8F7D\u529E\u516C\u5BA4","\uFF08\u7EA6 ",y(i)," MB\uFF09"]})]})]})}function B(t){let i={maxWidth:t.style.maxWidth,padding:t.style.padding,flex:t.style.flex,minHeight:t.style.minHeight,minWidth:t.style.minWidth,display:t.style.display,overflow:t.style.overflow};t.style.maxWidth="none",t.style.padding="0",t.style.flex="1 1 auto",t.style.minHeight="0",t.style.minWidth="0",t.style.display="flex",t.style.overflow="hidden";let a=p(t,(0,e.jsx)(T,{}));return()=>{a(),t.style.maxWidth=i.maxWidth,t.style.padding=i.padding,t.style.flex=i.flex,t.style.minHeight=i.minHeight,t.style.minWidth=i.minWidth,t.style.display=i.display,t.style.overflow=i.overflow}}export{B as renderOfficePage};
@@ -1 +0,0 @@
1
- import{a as Q,b as ee}from"./chunk-NACP7BMR.js";import{b as x,d as T,e as k,f as I,k as G,m as O,n as P,o as _,p as J,r as j}from"./chunk-5CJMHTT4.js";import{b as K,d as N}from"./chunk-FXW3V4JR.js";import"./chunk-24ONYQMR.js";import{B as $,C,G as q,I as H,J as V,K as M,L as g,M as A,z as L}from"./chunk-F6KNPF4R.js";import{a as W}from"./chunk-SYC6D5XU.js";import{a as le,d as X}from"./chunk-5THX4DI2.js";import{c as E}from"./chunk-7SZRL6FY.js";var r=E(le(),1);var t=E(X(),1),ce=new Set(["working","analyzing","active","starting"]),ve=new Set(["idle","dormant"]),te="botmux.overview.teamExpanded",ne="botmux.overview.activeSort",z=5,B=1,de=260;function me(){try{return window.localStorage.getItem(te)==="1"}catch{return!1}}function ue(e){try{window.localStorage.setItem(te,e?"1":"0")}catch{}}function we(e){return e==="attention"?"attention":"time"}function pe(){try{return we(window.localStorage.getItem(ne))}catch{return"time"}}function fe(e){try{window.localStorage.setItem(ne,e)}catch{}}function ge(e,s){let o=(i,a)=>Number(a.lastMessageAt??0)-Number(i.lastMessageAt??0);return s==="attention"?[...e].sort((i,a)=>{let v=g(i)?0:1,c=g(a)?0:1;if(v!==c)return v-c;if(v===0){let d=A(i)-A(a);if(d!==0)return d}return o(i,a)}):[...e].sort(o)}function be(e){return String(e??"unknown").toLowerCase().replace(/[^a-z0-9_-]/g,"-")}function he(e,s){let o=String(e??"unknown"),i=`sessions.status.${o}`,a=s(i);return a===i?o:a}function Se(e){if(!e)return B*z;let s=window.getComputedStyle(e).gridTemplateColumns.split(/\s+/).filter(i=>Number.parseFloat(i)>0);return Math.max(1,s.length||z)*B}function Ae(e,s){if(!e)return;let o=document.querySelector(".sidebar");if(!o||window.matchMedia("(max-width: 980px)").matches){e.style.removeProperty(s);return}let i=o.getBoundingClientRect().bottom,a=e.getBoundingClientRect().top,c=`${Math.max(de,Math.round(i-a))}px`;e.style.getPropertyValue(s)!==c&&e.style.setProperty(s,c)}function Ne({card:e}){let s=N(),o=$(e.larkAppId,e.brand),i=!e.online&&e.active.length===0,a=e.attention.length>0,v=e.busy.length>0,c=a?"warn":v?"busy":i?"off":"ok",d;if(a){let u=[...e.attention].sort((h,f)=>A(h)-A(f))[0];d=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{children:(M(u.title)||u.sessionId).slice(0,60)})," \xB7 ",g(u)??""]})}else if(v){let u=[...e.busy].sort((h,f)=>Number(f.lastMessageAt??0)-Number(h.lastMessageAt??0))[0];d=(0,t.jsx)("b",{children:(M(u.title)||u.sessionId).slice(0,60)})}else i?d=s("overview.botOffline"):d=s("overview.botIdle");let b=a?(0,t.jsx)("span",{className:"tag tag-warn",children:s("overview.botNeedsYou")}):v?(0,t.jsx)("span",{className:"tag tag-run",children:s("overview.botBusy",{count:e.busy.length})}):i?(0,t.jsx)("span",{className:"tag tag-off",children:s("overview.botOff")}):(0,t.jsx)("span",{className:"tag tag-ok",children:s("overview.botReady")});return(0,t.jsxs)("article",{className:`mate${a?" mate-attn":""}${i?" mate-off":""}`,children:[o?(0,t.jsx)("a",{className:"mate-console",href:o,target:"_blank",rel:"noopener noreferrer","data-tip":s("overview.botConsole"),"aria-label":s("overview.botConsole"),children:(0,t.jsx)("svg",{viewBox:"0 0 24 24",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M7 17 17 7M9 7h8v8"})})}):null,(0,t.jsxs)("div",{className:"mate-top",children:[(0,t.jsx)(x,{html:C({name:e.botName,larkAppId:e.larkAppId,avatarUrl:e.botAvatarUrl,dot:c})}),(0,t.jsxs)("div",{className:"mate-id",children:[(0,t.jsx)("b",{children:e.botName}),(0,t.jsx)("span",{className:"mate-role",children:e.cliId})]})]}),(0,t.jsx)("div",{className:"mate-task",children:d}),(0,t.jsxs)("div",{className:"mate-foot",children:[b,(0,t.jsx)("span",{children:e.lastActiveAt?s("overview.lastActive",{time:L(e.lastActiveAt)}):s("common.never")})]})]})}function ye({session:e}){let s=N(),o=H(e),i=String(e.status??"unknown"),a=g(e);return(0,t.jsxs)(P,{kind:"session",children:[(0,t.jsx)(x,{html:C({name:o,larkAppId:e.larkAppId,size:"sm"})}),(0,t.jsxs)(_,{children:[(0,t.jsx)("b",{children:(M(e.title)||e.sessionId).slice(0,64)}),(0,t.jsxs)("span",{children:[o," \xB7 ",V(e)??e.cliId??"unknown"," \xB7 ",L(e.lastMessageAt)]})]}),(0,t.jsx)(J,{children:a?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("a",{className:"overview-list-action",href:"#/sessions",children:s("strip.handle")}),(0,t.jsx)("span",{className:"status overview-list-status status-attention",children:a})]}):(0,t.jsx)("span",{className:`status overview-list-status status-${be(i)}`,children:he(i,s)})})]})}function Me({schedule:e,timeZone:s}){let o=e.nextRunAt?new Date(e.nextRunAt).toLocaleString(void 0,s?{timeZone:s,timeZoneName:"short"}:void 0):"-";return(0,t.jsxs)(P,{kind:"schedule",children:[(0,t.jsxs)(_,{children:[(0,t.jsx)("strong",{children:e.name??e.id}),(0,t.jsxs)("span",{children:[H(e)," \xB7 ",e.parsed?.display??""]})]}),(0,t.jsx)("span",{className:"overview-list-meta",children:(0,t.jsx)(G,{text:o,showPopover:!1,durationMs:2600})})]})}function Te({mode:e,onModeChange:s}){let o=N(),i=o(e==="attention"?"overview.sortAttentionFirst":"overview.sortByTime");return(0,t.jsx)(j,{className:"overview-active-sort-menu",label:i,value:e,options:[{value:"time",label:o("overview.sortByTime")},{value:"attention",label:o("overview.sortAttentionFirst")}],onChange:s})}function ke(){let e=N(),s=(0,r.useRef)(null),o=(0,r.useRef)(null),i=(0,r.useRef)(null),[a,v]=(0,r.useState)(me),[c,d]=(0,r.useState)(pe),[b,u]=(0,r.useState)(B*z),[h,f]=(0,r.useState)(0),{sessions:y,schedules:D,scheduleTimeZone:se,schedulesAvailable:oe}=K(n=>({sessions:[...n.sessions.values()],schedules:[...n.schedules.values()],scheduleTimeZone:n.scheduleTimeZone,schedulesAvailable:n.schedulesAvailable}));(0,r.useEffect)(()=>{let n=0,m=()=>{window.cancelAnimationFrame(n),n=window.requestAnimationFrame(()=>{let p=Se(s.current);u(l=>l===p?l:p)})};m();let w=typeof ResizeObserver>"u"||!s.current?null:new ResizeObserver(m);return w&&s.current&&w.observe(s.current),window.addEventListener("resize",m),()=>{window.cancelAnimationFrame(n),w?.disconnect(),window.removeEventListener("resize",m)}},[]),(0,r.useEffect)(()=>{Q().then(()=>f(n=>n+1)),q().then(()=>f(n=>n+1))},[]);let F=(0,r.useMemo)(()=>y.filter(n=>n.status!=="closed"),[y]),S=(0,r.useMemo)(()=>ee(y),[y,h]),U=a?S:S.slice(0,b),Y=(0,r.useMemo)(()=>ge(F.filter(n=>g(n)||ce.has(n.status)||ve.has(n.status)),c).slice(0,7),[F,c]),R=(0,r.useMemo)(()=>D.filter(n=>n.nextRunAt).sort((n,m)=>Date.parse(n.nextRunAt)-Date.parse(m.nextRunAt)).slice(0,5),[D]);(0,r.useEffect)(()=>{let n=[{el:o.current,propertyName:"--active-sessions-min-height"},{el:i.current,propertyName:"--schedules-panel-min-height"}].filter(l=>!!l.el);if(!n.length)return;let m=0,w=()=>{window.cancelAnimationFrame(m),m=window.requestAnimationFrame(()=>{for(let l of n)Ae(l.el,l.propertyName)})};w();let p=typeof ResizeObserver>"u"?null:new ResizeObserver(w);if(p){for(let re of n)p.observe(re.el);let l=document.querySelector(".sidebar"),Z=n[0].el.closest(".page");l&&p.observe(l),Z&&p.observe(Z)}return window.addEventListener("resize",w),()=>{window.cancelAnimationFrame(m),p?.disconnect(),window.removeEventListener("resize",w);for(let l of n)l.el.style.removeProperty(l.propertyName)}},[a,b,S.length,R.length]);let ie=()=>{v(n=>(ue(!n),!n))},ae=n=>{d(n),fe(n)};return(0,t.jsxs)("section",{className:"page hero-page",children:[(0,t.jsx)("div",{className:"page-heading",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"eyebrow",children:e("app.subtitle")}),(0,t.jsx)("h1",{children:e("overview.title")})]})}),(0,t.jsxs)("div",{className:"overview-layout",children:[(0,t.jsxs)("div",{className:"overview-main",children:[(0,t.jsxs)("section",{className:"overview-block team-section",children:[(0,t.jsx)(T,{title:e("overview.team"),count:e("overview.teamCount",{count:S.length}),hint:e("overview.teamHint"),children:(0,t.jsx)(I,{children:(0,t.jsx)(k,{href:"#/bot-defaults",children:e("overview.viewAllPlain")})})}),(0,t.jsx)("div",{className:"team-grid",id:"team-grid",ref:s,children:U.length?U.map(n=>(0,t.jsx)(Ne,{card:n},n.larkAppId??n.botName)):(0,t.jsx)("div",{className:"empty",children:e("overview.noSessions")})}),S.length>b?(0,t.jsx)("button",{type:"button",className:"team-toggle",id:"team-toggle",onClick:ie,children:e(a?"overview.teamCollapse":"overview.teamExpand")}):null]}),(0,t.jsxs)("section",{className:"overview-block",children:[(0,t.jsx)(T,{title:e("overview.activeSessions"),children:(0,t.jsxs)(I,{children:[(0,t.jsx)(Te,{mode:c,onModeChange:ae}),(0,t.jsx)(k,{href:"#/sessions",children:e("overview.viewAllPlain")})]})}),(0,t.jsx)("section",{className:"panel active-sessions-panel",ref:o,children:(0,t.jsx)(O,{id:"recent-sessions",children:Y.length?Y.map(n=>(0,t.jsx)(ye,{session:n},n.sessionId)):(0,t.jsx)("li",{className:"empty",children:e("overview.noSessions")})})})]})]}),oe?(0,t.jsx)("aside",{className:"overview-side",children:(0,t.jsxs)("section",{className:"overview-block",children:[(0,t.jsx)(T,{title:e("overview.nextSchedules"),children:(0,t.jsx)(k,{href:"#/schedules",children:e("overview.viewAllPlain")})}),(0,t.jsx)("section",{className:"panel schedules-panel",ref:i,children:(0,t.jsx)(O,{id:"next-schedules",children:R.length?R.map(n=>(0,t.jsx)(Me,{schedule:n,timeZone:se},n.id)):(0,t.jsx)("li",{className:"empty",children:e("overview.noSchedules")})})})]})}):null]})]})}function xe(e){e.classList.add("overview-root");let s=W(e,(0,t.jsx)(ke,{}));return()=>{s(),e.classList.remove("overview-root")}}export{xe as renderOverviewPage};
@@ -1 +0,0 @@
1
- import{a as H}from"./chunk-BD3PZGH2.js";import{a as G}from"./chunk-SYC6D5XU.js";import{a as W,d as U}from"./chunk-5THX4DI2.js";import{c as $}from"./chunk-7SZRL6FY.js";var r=$(W(),1);var n=$(U(),1);async function q(){let e=await fetch("/api/plugins/dashboard");if(!e.ok)throw new Error(`HTTP ${e.status}`);let a=await e.json();return Array.isArray(a?.plugins)?a.plugins:[]}function M(e){return{plugins:Array.isArray(e?.plugins)?e.plugins:[],globalPlugins:Array.isArray(e?.globalPlugins)?e.globalPlugins:[],bots:Array.isArray(e?.bots)?e.bots:[],gatewayAdapters:Array.isArray(e?.gatewayAdapters)?e.gatewayAdapters:[]}}async function _(){let e=await fetch("/api/plugins");if(!e.ok)throw new Error(`HTTP ${e.status}`);return M(await e.json())}async function z(e,a,t){let i=t==="global"?"global":`bots/${encodeURIComponent(t)}`,g=await fetch(`/api/plugins/${encodeURIComponent(e)}/${i}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({enabled:a})}),l=await g.json().catch(()=>({}));if(!g.ok)throw new Error(typeof l?.error=="string"?l.error:`HTTP ${g.status}`);return M(l)}async function Q(e,a){let t=await fetch(`/api/plugins/${encodeURIComponent(e)}/pin`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({pinned:a})});if(!t.ok)throw new Error(`HTTP ${t.status}`);return M(await t.json())}async function A(e,a){let t=await fetch(`/api/plugins/${encodeURIComponent(e)}/services/${a}`,{method:"POST"});if(!t.ok)throw new Error(`HTTP ${t.status}`);return M(await t.json())}function k(e){return e.values?.length?(0,n.jsx)(n.Fragment,{children:e.values.map(a=>(0,n.jsx)("span",{className:"plugin-chip",children:a},a))}):(0,n.jsx)("span",{className:"plugin-muted",children:"-"})}function y(e){return(0,n.jsx)("code",{className:"plugin-inline-code",children:e.children})}function N(e){return e.rows.length===0?(0,n.jsx)("div",{className:"plugin-empty-state",children:"\u6682\u65E0\u5185\u5BB9"}):(0,n.jsx)("div",{className:"plugin-info-table",children:e.rows.map((a,t)=>(0,n.jsxs)("div",{className:"plugin-info-row",children:[(0,n.jsx)("span",{children:a.label}),(0,n.jsx)("div",{children:a.content})]},`${a.label}:${t}`))})}function C(e){return(0,n.jsxs)("div",{className:"plugin-tab-panel-head",children:[(0,n.jsx)("h3",{children:e.title}),(0,n.jsx)("p",{children:e.description})]})}function T(e){return(0,n.jsx)("div",{className:"plugin-empty-state",children:e.children})}function j(e){return e?e.status||e.action:"unknown"}function B(e){let a=j(e);return a==="online"||a==="started"||a==="already-running"?"\u8FD0\u884C\u4E2D":a==="stopped"||a==="not-running"?"\u5DF2\u505C\u6B62":a==="failed"?"\u5F02\u5E38":"\u672A\u77E5"}function Y(e){return e.mode==="manual"?"\u4E0D\u968F botmux start/stop/restart \u81EA\u52A8\u5F00\u5173\uFF1B\u4ECD\u53EF\u5728\u8FD9\u91CC\u624B\u52A8\u542F\u52A8\u3001\u505C\u6B62\u3001\u91CD\u542F":e.mode==="auto"?"botmux start/restart \u540E\u81EA\u52A8\u786E\u4FDD\u8FD0\u884C\uFF1B\u9ED8\u8BA4 restart \u4E0D\u5148\u505C\u6B62\uFF0C--with-plugin \u624D\u4F1A\u5148\u505C\u518D\u542F\u52A8":"\u672A\u77E5\u751F\u547D\u5468\u671F\u7B56\u7565"}function J(e){return e.mode==="manual"?"\u624B\u52A8\u5F00\u5173":e.mode==="auto"?"\u542F\u52A8\u540E\u786E\u4FDD\u8FD0\u884C":"\u672A\u77E5\u6A21\u5F0F"}function X(e){let a=j(e);return a==="online"||a==="started"||a==="already-running"?"plugin-status-ok":a==="stopped"||a==="not-running"?"plugin-status-idle":a==="failed"?"plugin-status-bad":"plugin-status-muted"}function I(e){return e.url?(0,n.jsx)("a",{className:`plugin-link${e.health?"":" plugin-service-url"}`,href:e.url,target:"_blank",rel:"noreferrer",children:e.health?"\u5065\u5EB7\u68C0\u67E5":e.url}):(0,n.jsx)("span",{className:"plugin-muted",children:e.health?"\u65E0\u5065\u5EB7\u68C0\u67E5":"\u6682\u65E0\u8BBF\u95EE\u5730\u5740"})}function Z(e){let{plugin:a}=e;if(!a.service)return(0,n.jsx)(T,{children:"\u8FD9\u4E2A\u63D2\u4EF6\u6CA1\u6709\u9700\u8981\u5355\u72EC\u542F\u52A8\u7684\u540E\u53F0\u8FDB\u7A0B\u3002"});let t=a.serviceReport,i=[{label:"\u72B6\u6001",content:(0,n.jsx)("span",{className:`plugin-status ${X(t)}`,children:B(t)})},{label:"\u6A21\u5F0F",content:(0,n.jsx)(k,{values:[J(a.service)]})},{label:"\u751F\u547D\u5468\u671F",content:(0,n.jsx)("span",{children:Y(a.service)})},{label:"\u7AEF\u53E3",content:t?.port?(0,n.jsx)(y,{children:t.port}):(0,n.jsx)("span",{className:"plugin-muted",children:"\u672A\u4E0A\u62A5"})},{label:"PID",content:t?.pid?(0,n.jsx)(y,{children:t.pid}):(0,n.jsx)("span",{className:"plugin-muted",children:"\u672A\u4E0A\u62A5"})},{label:"\u8BBF\u95EE\u5730\u5740",content:(0,n.jsx)(I,{url:t?.openUrl})},{label:"\u5065\u5EB7\u68C0\u67E5",content:(0,n.jsx)(I,{url:t?.healthUrl,health:!0})}];return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(N,{rows:i}),t?.warning?(0,n.jsx)("div",{className:"plugin-warning",children:t.warning}):null]})}function nn(e){let{plugin:a}=e;if(!a.service)return null;let t=a.serviceReport;return(0,n.jsxs)("section",{className:"plugin-action-group",children:[(0,n.jsxs)("div",{className:"plugin-action-head",children:[(0,n.jsx)("span",{children:"Service"}),(0,n.jsx)("strong",{children:J(a.service)}),(0,n.jsx)("span",{className:`plugin-status ${X(t)}`,children:B(t)})]}),(0,n.jsxs)("div",{className:"plugin-action-meta",children:[t?.port?(0,n.jsxs)("span",{children:["\u7AEF\u53E3 ",t.port]}):null,t?.pid?(0,n.jsxs)("span",{children:["PID ",t.pid]}):null,(0,n.jsx)(I,{url:t?.openUrl})]}),(0,n.jsx)("div",{className:"plugin-service-actions",children:["start","stop","restart"].map(i=>(0,n.jsx)("button",{type:"button",className:"btn-link","data-plugin-service":a.id,"data-action":i,disabled:e.busy,onClick:()=>e.onAction(i),children:i==="start"?"\u542F\u52A8":i==="stop"?"\u505C\u6B62":"\u91CD\u542F"},i))})]})}function en(e){let a=e.plugin.dashboard??[];return a.length===0?null:(0,n.jsxs)("section",{className:"plugin-action-group",children:[(0,n.jsxs)("div",{className:"plugin-action-head",children:[(0,n.jsx)("span",{children:"Dashboard"}),(0,n.jsxs)("strong",{children:[a.length," \u4E2A\u9875\u9762"]})]}),(0,n.jsx)("div",{className:"plugin-action-links",children:a.map(t=>(0,n.jsxs)("a",{className:"btn-link primary",href:t.route,children:["\u6253\u5F00 ",t.id]},t.id))})]})}function an(e){let a=!!e.plugin.service,t=(e.plugin.dashboard?.length??0)>0;return!a&&!t?null:(0,n.jsxs)("div",{className:"plugin-action-area","aria-label":`${e.plugin.id} \u63D2\u4EF6\u64CD\u4F5C`,children:[(0,n.jsxs)("div",{className:"plugin-action-title",children:[(0,n.jsx)("span",{children:"\u64CD\u4F5C"}),(0,n.jsx)("small",{children:"\u56FA\u5B9A\u64CD\u4F5C\u533A\uFF0C\u4E0B\u9762\u7684 tab \u53EA\u5C55\u793A\u4FE1\u606F"})]}),(0,n.jsxs)("div",{className:"plugin-action-grid",children:[(0,n.jsx)(nn,{plugin:e.plugin,busy:e.busy,onAction:e.onServiceAction}),(0,n.jsx)(en,{plugin:e.plugin})]})]})}function R(e){return(0,n.jsx)("section",{className:`plugin-tab-panel${e.active?" is-active":""}`,role:"tabpanel","data-plugin-panel":e.id,children:e.children})}function tn(e){let t=(e.plugin.contributions?.skills??[]).map(i=>({label:i.name||i.path||"skill",content:i.path?(0,n.jsx)(y,{children:i.path}):(0,n.jsx)("span",{className:"plugin-muted",children:"\u672A\u58F0\u660E\u8DEF\u5F84"})}));return(0,n.jsxs)(R,{id:"skills",active:e.active,children:[(0,n.jsx)(C,{title:"Skills",description:"\u6BCF\u6B21\u771F\u6B63\u542F\u52A8\u6216\u91CD\u542F CLI \u8FDB\u7A0B\u65F6\uFF0C\u90FD\u4F1A\u6309\u5F53\u524D Bot \u7684\u6709\u6548\u63D2\u4EF6\u96C6\u5237\u65B0\u8FD9\u4E9B\u6280\u80FD\uFF1B\u8FD0\u884C\u4E2D\u7684 CLI \u4E0D\u70ED\u66F4\u65B0\u3002"}),t.length>0?(0,n.jsx)(N,{rows:t}):(0,n.jsx)(T,{children:"\u8FD9\u4E2A\u63D2\u4EF6\u6CA1\u6709\u63D0\u4F9B Skills\u3002"})]})}function ln(e){let a=e.plugin,t=a.contributions?.mcp,i=t?[{label:t.name||"mcp",content:(0,n.jsxs)("div",{className:"plugin-info-stack",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{children:"\u4F20\u8F93"}),(0,n.jsx)(k,{values:[t.transport||"stdio"]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{children:"\u8FD0\u884C\u914D\u7F6E"}),(0,n.jsx)(k,{values:["\u53D7\u4FDD\u62A4\uFF0C\u7531 Gateway \u6309\u4F1A\u8BDD\u52A0\u8F7D"]})]})]})}]:[],g=(a.gatewayAdapters??[]).map(s=>({label:s.cliId,content:(0,n.jsxs)("div",{className:"plugin-info-stack",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{children:"Gateway"}),(0,n.jsx)(k,{values:[s.state==="configured"||s.state==="unchanged"||s.state==="installed"?"\u5DF2\u63A5\u5165":s.state==="adapter-required"?"\u5F85\u9002\u914D":"\u672A\u5199\u5165"]})]}),s.configPath?(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{children:"\u914D\u7F6E\u76EE\u6807"}),(0,n.jsx)(y,{children:s.configPath})]}):null,s.warning?(0,n.jsx)("div",{className:"plugin-warning",children:s.warning}):null]})})),l=(a.mcpDiagnostics??[]).map(s=>({label:s.serverName,content:(0,n.jsxs)("div",{className:"plugin-info-stack",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{children:"\u6700\u8FD1\u8FDE\u63A5"}),(0,n.jsx)(k,{values:[s.status==="connected"?"\u6B63\u5E38":"\u5931\u8D25",s.transport]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{children:"\u80FD\u529B\u6570\u91CF"}),(0,n.jsx)(k,{values:[`Tools ${s.tools??0}`,`Prompts ${s.prompts??0}`,`Resources ${s.resources??0}`]})]}),s.sessionId?(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{children:"\u4F1A\u8BDD"}),(0,n.jsx)(y,{children:s.sessionId})]}):null,s.error?(0,n.jsx)("div",{className:"plugin-warning",children:s.error}):null]})}));return(0,n.jsxs)(R,{id:"mcp",active:e.active,children:[(0,n.jsx)(C,{title:"MCP",description:"CLI \u53EA\u8FDE\u63A5\u4E00\u4E2A Botmux Gateway\uFF1B\u6BCF\u4E00\u4EE3 CLI \u8FDB\u7A0B\u6309\u542F\u52A8\u65F6\u6E05\u5355\u8FDE\u63A5\u8FD9\u4E9B\u4E0B\u6E38 MCP\u3002"}),g.length>0?(0,n.jsx)(N,{rows:g}):null,l.length>0?(0,n.jsx)(N,{rows:l}):null,i.length>0?(0,n.jsx)(N,{rows:i}):(0,n.jsx)(T,{children:"\u8FD9\u4E2A\u63D2\u4EF6\u6CA1\u6709\u63D0\u4F9B MCP server\u3002"})]})}function sn(e){let a=e.plugin.contributions?.cli,t=[...a?.entry?[{label:"\u5165\u53E3\u6587\u4EF6",content:(0,n.jsx)(y,{children:a.entry})}]:[],...(a?.commands??[]).map(i=>({label:i.name,content:i.description?(0,n.jsx)("span",{children:i.description}):(0,n.jsx)("span",{className:"plugin-muted",children:"\u65E0\u63CF\u8FF0"})}))];return(0,n.jsxs)(R,{id:"cli",active:e.active,children:[(0,n.jsx)(C,{title:"CLI \u547D\u4EE4",description:"\u542F\u7528\u63D2\u4EF6\u540E\uFF0C\u8FD9\u4E9B\u547D\u4EE4\u4F1A\u8FDB\u5165 botmux \u7684\u547D\u4EE4\u8DEF\u7531\u3002"}),t.length>0?(0,n.jsx)(N,{rows:t}):(0,n.jsx)(T,{children:"\u8FD9\u4E2A\u63D2\u4EF6\u6CA1\u6709\u63D0\u4F9B CLI \u547D\u4EE4\u3002"})]})}function on(e){let a=(e.plugin.dashboard??[]).map(t=>({label:t.id,content:(0,n.jsxs)("div",{className:"plugin-info-stack",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{children:"\u8DEF\u7531"}),(0,n.jsx)(y,{children:t.route})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{children:"\u5165\u53E3"}),(0,n.jsx)(y,{children:t.entry})]})]})}));return(0,n.jsxs)(R,{id:"dashboard",active:e.active,children:[(0,n.jsx)(C,{title:"Dashboard",description:"\u63D2\u4EF6\u81EA\u5DF1\u7684\u53EF\u89C6\u5316\u9875\u9762\u4F1A\u5728\u8FD9\u91CC\u66B4\u9732\u5165\u53E3\u3002"}),a.length>0?(0,n.jsx)(N,{rows:a}):(0,n.jsx)(T,{children:"\u8FD9\u4E2A\u63D2\u4EF6\u6CA1\u6709\u63D0\u4F9B Dashboard \u9875\u9762\u3002"})]})}function rn(e){return(0,n.jsxs)(R,{id:"service",active:e.active,children:[(0,n.jsx)(C,{title:"Service",description:"\u63D2\u4EF6\u540E\u53F0\u670D\u52A1\u7684\u58F0\u660E\u3001\u5F53\u524D\u72B6\u6001\u548C\u8BBF\u95EE\u5730\u5740\u3002\u542F\u52A8\u3001\u505C\u6B62\u3001\u91CD\u542F\u5728\u4E0A\u65B9\u64CD\u4F5C\u533A\u5904\u7406\u3002"}),(0,n.jsx)(Z,{plugin:e.plugin})]})}function cn(e){let a=e.plugin.contributions?.cli?.commands??[],t=(0,r.useMemo)(()=>[{id:"skills",label:"Skills",count:e.plugin.skillsCount??0,hint:"\u4F1A\u8BDD\u52A0\u8F7D"},{id:"mcp",label:"MCP",count:e.plugin.mcpCount??0,hint:"Gateway \u805A\u5408"},{id:"cli",label:"CLI \u547D\u4EE4",count:a.length,hint:"\u547D\u4EE4\u8DEF\u7531"},{id:"dashboard",label:"Dashboard",count:e.plugin.dashboard?.length??0,hint:"\u9875\u9762\u5165\u53E3"},{id:"service",label:"Service",count:e.plugin.service?1:0,hint:e.plugin.service?J(e.plugin.service):"\u65E0\u540E\u53F0\u8FDB\u7A0B"}],[a.length,e.plugin.dashboard?.length,e.plugin.mcpCount,e.plugin.service,e.plugin.skillsCount]),[i,g]=(0,r.useState)(()=>t.find(l=>l.count>0)?.id??"skills");return(0,n.jsxs)("div",{className:"plugin-tabs",children:[(0,n.jsx)("div",{className:"plugin-tab-list",role:"tablist","aria-label":`${e.plugin.id} \u63D2\u4EF6\u80FD\u529B`,children:t.map(l=>(0,n.jsxs)("button",{type:"button",className:`plugin-tab-button${i===l.id?" is-active":""}`,role:"tab","aria-selected":i===l.id,"data-plugin-tab":l.id,onClick:()=>g(l.id),children:[(0,n.jsx)("strong",{children:l.count}),(0,n.jsx)("span",{children:l.label}),(0,n.jsx)("small",{children:l.hint})]},l.id))}),(0,n.jsxs)("div",{className:"plugin-tab-panels",children:[(0,n.jsx)(tn,{plugin:e.plugin,active:i==="skills"}),(0,n.jsx)(ln,{plugin:e.plugin,active:i==="mcp"}),(0,n.jsx)(sn,{plugin:e.plugin,active:i==="cli"}),(0,n.jsx)(on,{plugin:e.plugin,active:i==="dashboard"}),(0,n.jsx)(rn,{plugin:e.plugin,active:i==="service"})]})]})}function x(e,a){return`${e}:${a}`}function w(e,a,t){let i=t.get(x(e.id,a));return i!==void 0?i:a==="global"?e.enabledGlobal===!0:e.enabledByBot?.[a]===!0}function gn(e){return(0,n.jsxs)("label",{className:"toggle-row plugin-enable-row",children:[(0,n.jsxs)("span",{className:"plugin-enable-copy",children:[(0,n.jsx)("strong",{children:e.label}),(0,n.jsx)("small",{children:e.hint})]}),(0,n.jsx)("input",{type:"checkbox","data-plugin-toggle":e.scope,"data-plugin-id":e.plugin.id,checked:e.checked,disabled:e.busy,onChange:a=>e.onToggle(e.scope,a.currentTarget.checked)}),(0,n.jsx)("span",{className:"switch","aria-hidden":"true"})]})}function un(e){let a=w(e.plugin,"global",e.pendingToggles);return(0,n.jsxs)("label",{className:"toggle-row plugin-global-setting",children:[(0,n.jsxs)("span",{className:"plugin-global-setting-copy",children:[(0,n.jsx)("strong",{children:"\u5168\u5C40\u542F\u7528"}),(0,n.jsx)("small",{children:a?`\u5DF2\u5BF9\u5168\u90E8 ${e.bots.length} \u4E2A Bot \u542F\u7528`:"\u5173\u95ED\u65F6\u53EF\u5C55\u5F00\u5361\u7247\uFF0C\u6309 Bot \u5355\u72EC\u542F\u7528"})]}),(0,n.jsx)("input",{type:"checkbox","data-plugin-toggle":"global","data-plugin-id":e.plugin.id,checked:a,disabled:e.busy,onChange:t=>e.onToggle("global",t.currentTarget.checked)}),(0,n.jsx)("span",{className:"switch","aria-hidden":"true"})]})}function dn(e){let{plugin:a,bots:t,pendingToggles:i}=e,g=t.filter(l=>w(a,l.id,i)).length;return(0,n.jsxs)("section",{className:"plugin-enable-panel","aria-label":`${a.displayName||a.id} \u6309 Bot \u542F\u7528`,children:[(0,n.jsxs)("div",{className:"plugin-enable-panel-head",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"\u6309 Bot \u542F\u7528"}),(0,n.jsx)("small",{children:"\u5168\u5C40\u5173\u95ED\u65F6\uFF0C\u53EF\u4E3A\u9700\u8981\u6B64\u63D2\u4EF6\u7684 Bot \u5355\u72EC\u5F00\u542F\uFF1B\u65B0\u542F\u52A8\u7684 CLI \u4F1A\u8BDD\u751F\u6548\u3002"})]}),(0,n.jsxs)("span",{children:[g,"/",t.length," \u4E2A Bot \u5DF2\u542F\u7528"]})]}),(0,n.jsxs)("div",{className:"plugin-enable-list",children:[t.map(l=>{let s=w(a,l.id,i),p=s?"\u5DF2\u542F\u7528":"\u672A\u542F\u7528";return(0,n.jsx)(gn,{plugin:a,scope:l.id,label:l.name,hint:`\u5F53\u524D${p}`,checked:s,busy:e.busy,onToggle:e.onToggle},l.id)}),t.length===0?(0,n.jsx)("div",{className:"plugin-enable-empty",children:"\u6682\u65E0\u5DF2\u914D\u7F6E Bot"}):null]})]})}function pn(e){let a=e.plugin.contributions?.cli?.commands??[],t=[{label:"Skills",count:e.plugin.skillsCount??0},{label:"MCP",count:e.plugin.mcpCount??0},{label:"\u547D\u4EE4",count:a.length},{label:"Dashboard",count:e.plugin.dashboard?.length??0}].filter(i=>i.count>0);return(0,n.jsxs)("div",{className:"plugin-card-summary",children:[(0,n.jsxs)("div",{className:"plugin-capability-summary","aria-label":"\u63D2\u4EF6\u80FD\u529B\u6458\u8981",children:[t.map(i=>(0,n.jsxs)("span",{className:"plugin-capability-chip",children:[(0,n.jsx)("strong",{children:i.count}),i.label]},i.label)),e.plugin.service?(0,n.jsxs)("span",{className:`plugin-capability-chip ${X(e.plugin.serviceReport)}`,children:["Service ",B(e.plugin.serviceReport)]}):null,t.length===0&&!e.plugin.service?(0,n.jsx)("span",{className:"plugin-muted",children:"\u672A\u58F0\u660E\u6269\u5C55\u80FD\u529B"}):null]}),(0,n.jsx)("span",{className:"plugin-scope-summary",children:e.globalEnabled?`\u5168\u90E8 ${e.botCount} \u4E2A Bot`:`${e.enabledBotCount}/${e.botCount} \u4E2A Bot \u5355\u72EC\u542F\u7528`})]})}function bn(e){let a=(0,r.useRef)(null);return(0,r.useEffect)(()=>{let t=a.current;if(t)if(e.feedback&&!t.open)try{t.showModal()}catch{t.setAttribute("open","")}else!e.feedback&&t.open&&t.close()},[e.feedback]),(0,n.jsx)("dialog",{className:"plugin-feedback-dialog","data-plugin-feedback-dialog":!0,ref:a,onClose:e.onClose,onClick:t=>{t.target===t.currentTarget&&e.onClose()},children:(0,n.jsxs)("article",{children:[(0,n.jsxs)("header",{children:[(0,n.jsx)("span",{className:"plugin-feedback-mark","aria-hidden":"true",children:"!"}),(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{children:"\u63D2\u4EF6\u8BBE\u7F6E\u672A\u4FDD\u5B58"}),(0,n.jsx)("h2",{"data-plugin-feedback-title":!0,children:e.feedback?.title??"\u64CD\u4F5C\u5931\u8D25"})]})]}),(0,n.jsx)("p",{className:"plugin-feedback-message","data-plugin-feedback-message":!0,children:e.feedback?.message}),(0,n.jsx)("footer",{children:(0,n.jsx)("button",{type:"button",className:"btn-link","data-plugin-feedback-close":!0,onClick:e.onClose,children:"\u77E5\u9053\u4E86"})})]})})}function mn(e){let{plugin:a}=e,[t,i]=(0,r.useState)(!1),g=a.displayName||a.id,l=a.dependencies??[],s=w(a,"global",e.pendingToggles),p=e.bots.filter(d=>w(a,d.id,e.pendingToggles)).length,S=s||p>0,b=e.pendingToggles.has(x(a.id,"global")),f=(a.dashboard?.length??0)>0,m=e.pendingPin??a.pinnedToSidebar===!0,P=`plugin-details-${a.id}`;return(0,n.jsxs)("article",{className:`bd-card plugin-card${t?" is-expanded":" is-collapsed"}`,"data-plugin-card":a.id,children:[(0,n.jsxs)("header",{className:"plugin-card-head",children:[(0,n.jsxs)("div",{className:"plugin-title-block",children:[(0,n.jsxs)("div",{className:"plugin-title-row",children:[(0,n.jsx)("h2",{children:g}),(0,n.jsx)("span",{className:`plugin-status ${S?"plugin-status-ok":"plugin-status-idle"}`,children:s?"\u5168\u5C40\u5DF2\u542F\u7528":p>0?`${p} \u4E2A Bot \u5DF2\u542F\u7528`:"\u672A\u542F\u7528"})]}),(0,n.jsxs)("p",{children:[(0,n.jsx)("code",{children:a.id}),(0,n.jsxs)("span",{children:[a.packageName,"@",a.version]}),l.length>0?(0,n.jsxs)("span",{children:["\u4F9D\u8D56 ",l.join(", ")]}):null]})]}),(0,n.jsx)("button",{type:"button",className:"btn-link plugin-expand-button","data-plugin-expand":a.id,"aria-expanded":t,"aria-controls":P,onClick:()=>i(d=>!d),children:t?"\u6536\u8D77\u8BE6\u60C5":"\u5C55\u5F00\u8BE6\u60C5"})]}),(0,n.jsx)(un,{plugin:a,bots:e.bots,pendingToggles:e.pendingToggles,busy:e.busy,onToggle:e.onToggle}),(0,n.jsx)(pn,{plugin:a,globalEnabled:s,enabledBotCount:p,botCount:e.bots.length}),t?(0,n.jsxs)("div",{className:"plugin-card-expanded",id:P,children:[!s&&!b?(0,n.jsx)(dn,{plugin:a,bots:e.bots,pendingToggles:e.pendingToggles,busy:e.busy,onToggle:e.onToggle}):null,b?(0,n.jsx)("div",{className:"plugin-settings-pending",children:"\u6B63\u5728\u66F4\u65B0\u5168\u5C40\u8BBE\u7F6E..."}):null,f?(0,n.jsx)("div",{className:"plugin-card-controls",children:(0,n.jsxs)("label",{className:"toggle-row plugin-pin-toggle",children:[(0,n.jsx)("input",{type:"checkbox","data-plugin-pin":a.id,checked:m,disabled:e.busy,onChange:d=>e.onPin(d.currentTarget.checked)}),(0,n.jsx)("span",{className:"switch"}),(0,n.jsxs)("span",{className:"toggle-tx",children:[(0,n.jsx)("strong",{children:"Pin \u5230\u4FA7\u680F"}),(0,n.jsx)("small",{children:m?"\u5DF2\u56FA\u5B9A\uFF0C\u53EF\u4ECE\u4E3B\u83DC\u5355\u5FEB\u901F\u6253\u5F00":"\u56FA\u5B9A\u540E\u53EF\u4ECE\u4E3B\u83DC\u5355\u5FEB\u901F\u6253\u5F00"})]})]})}):null,(0,n.jsx)(an,{plugin:a,busy:e.busy,onServiceAction:e.onServiceAction}),(0,n.jsx)("div",{className:"plugin-card-body",children:(0,n.jsx)(cn,{plugin:a})})]}):null]})}function E(e,a,t){let i=new Map(e);return t===void 0?i.delete(a):i.set(a,t),i}function vn(e,a,t){let i=new Set(e);return t?i.add(a):i.delete(a),i}function hn(){let[e,a]=(0,r.useState)(null),[t,i]=(0,r.useState)(null),[g,l]=(0,r.useState)(!1),[s,p]=(0,r.useState)(()=>new Set),[S,b]=(0,r.useState)(()=>new Map),[f,m]=(0,r.useState)(()=>new Map),[P,d]=(0,r.useState)(null),D=(0,r.useCallback)(async()=>{l(!0),i(null);try{a(await _())}catch(o){i(o instanceof Error?o.message:String(o))}finally{l(!1)}},[]);(0,r.useEffect)(()=>{D()},[D]);let v=(0,r.useCallback)((o,u)=>{p(c=>vn(c,o,u))},[]),F=(0,r.useCallback)(async(o,u,c)=>{let L=x(o,u);b(h=>E(h,L,c)),v(o,!0);try{let h=await z(o,c,u);a(h)}catch(h){d({title:c?"\u65E0\u6CD5\u542F\u7528\u63D2\u4EF6":"\u65E0\u6CD5\u7981\u7528\u63D2\u4EF6",message:h instanceof Error?h.message:String(h)})}finally{b(h=>E(h,L,void 0)),v(o,!1)}},[v]),K=(0,r.useCallback)(async(o,u)=>{m(c=>E(c,o,u)),v(o,!0);try{let c=await Q(o,u);a(c),window.dispatchEvent(new Event(H))}catch(c){d({title:"\u65E0\u6CD5\u66F4\u65B0\u4FA7\u680F\u56FA\u5B9A",message:c instanceof Error?c.message:String(c)})}finally{m(c=>E(c,o,void 0)),v(o,!1)}},[v]),V=(0,r.useCallback)(async(o,u)=>{v(o,!0);try{let c=await A(o,u);a(c)}catch(c){d({title:"Service \u64CD\u4F5C\u5931\u8D25",message:c instanceof Error?c.message:String(c)})}finally{v(o,!1)}},[v]);if(!e&&!t)return(0,n.jsx)("section",{className:"page",children:(0,n.jsx)("div",{className:"empty",children:"Loading plugins..."})});if(!e)return(0,n.jsx)("section",{className:"page",children:(0,n.jsxs)("div",{className:"bd-card empty",children:["\u63D2\u4EF6\u5217\u8868\u52A0\u8F7D\u5931\u8D25\uFF1A",t]})});let O=e.plugins.filter(o=>w(o,"global",S)).length;return(0,n.jsxs)("section",{className:"page plugin-management-page",children:[(0,n.jsxs)("div",{className:"page-heading",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h1",{children:"\u63D2\u4EF6"}),(0,n.jsx)("p",{children:"\u5361\u7247\u9ED8\u8BA4\u5C55\u793A\u542F\u7528\u8303\u56F4\u4E0E\u80FD\u529B\u6458\u8981\uFF1B\u5C55\u5F00\u540E\u53EF\u7BA1\u7406\u5355\u4E2A Bot\u3001Service \u548C\u8BE6\u7EC6\u80FD\u529B\u3002\u5168\u5C40\u542F\u7528\u5BF9\u6240\u6709 Bot \u751F\u6548\uFF0C\u6539\u52A8\u5728\u65B0\u542F\u52A8\u7684 CLI \u4F1A\u8BDD\u4E2D\u751F\u6548\u3002"})]}),(0,n.jsx)("div",{className:"plugin-heading-actions",children:(0,n.jsx)("button",{type:"button",className:"btn-link","data-plugin-refresh":!0,disabled:g,onClick:()=>{D()},children:g?"\u5237\u65B0\u4E2D...":"\u5237\u65B0"})})]}),(0,n.jsxs)("div",{className:"plugin-summary-grid",children:[(0,n.jsxs)("div",{className:"bd-card plugin-summary-card",children:[(0,n.jsx)("span",{children:"\u5DF2\u5B89\u88C5"}),(0,n.jsx)("strong",{children:e.plugins.length})]}),(0,n.jsxs)("div",{className:"bd-card plugin-summary-card",children:[(0,n.jsx)("span",{children:"\u5168\u5C40\u542F\u7528"}),(0,n.jsx)("strong",{"data-plugin-summary-enabled":!0,children:O})]})]}),e.plugins.length===0?(0,n.jsxs)("div",{className:"bd-card empty",children:["\u6682\u65E0\u5DF2\u5B89\u88C5\u63D2\u4EF6\u3002\u7528 ",(0,n.jsx)("code",{children:"botmux plugin install"})," \u5B89\u88C5\u540E\u4F1A\u51FA\u73B0\u5728\u8FD9\u91CC\u3002"]}):(0,n.jsx)("div",{className:"plugin-card-list",children:e.plugins.map(o=>(0,n.jsx)(mn,{plugin:o,bots:e.bots,pendingToggles:S,pendingPin:f.get(o.id),busy:s.has(o.id),onToggle:(u,c)=>{F(o.id,u,c)},onPin:u=>{K(o.id,u)},onServiceAction:u=>{V(o.id,u)}},o.id))}),(0,n.jsx)(bn,{feedback:P,onClose:()=>d(null)})]})}function fn(e){return{async getServiceStatus(){return(await _()).plugins.find(t=>t.id===e)?.serviceReport},async startService(){return A(e,"start")},async stopService(){return A(e,"stop")},async restartService(){return A(e,"restart")}}}function yn(e){let[a,t]=(0,r.useState)(null),[i,g]=(0,r.useState)(null),[l,s]=(0,r.useState)(null);(0,r.useEffect)(()=>{let b=!1;return t(null),g(null),s(null),(async()=>{try{let m=(await q()).find(d=>e.hash===d.route||e.hash.startsWith(`${d.route}/`)||e.hash.startsWith(`${d.route}?`));if(!m)throw new Error(`Plugin page not found: ${e.hash}`);let P=await import(m.url);if(typeof P.default!="function")throw new Error("plugin_dashboard_default_export_not_function");if(b)return;t(m),g(()=>P.default)}catch(f){b||s(f instanceof Error?f.message:String(f))}})(),()=>{b=!0}},[e.hash]);let p=(0,r.useMemo)(()=>a?fn(a.pluginId):null,[a]);if(l)return(0,n.jsx)("section",{className:"page",children:(0,n.jsxs)("div",{className:"bd-card empty",children:["\u63D2\u4EF6 Dashboard \u52A0\u8F7D\u5931\u8D25\uFF1A",l]})});if(!a||!i||!p)return(0,n.jsx)("section",{className:"page",children:(0,n.jsx)("div",{className:"empty",children:"Loading plugin..."})});let S=a.displayName||a.pluginId;return(0,n.jsx)("section",{className:"page plugin-page",children:(0,n.jsxs)("div",{className:"plugin-dashboard-shell",children:[(0,n.jsx)("div",{className:"plugin-dashboard-toolbar",children:(0,n.jsx)("a",{className:"btn-link plugin-dashboard-back",href:"#/plugins",children:"\u8FD4\u56DE\u63D2\u4EF6\u5217\u8868"})}),(0,n.jsx)("div",{className:"page-heading plugin-dashboard-heading",children:(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"plugin-dashboard-kicker",children:"Plugin Dashboard"}),(0,n.jsx)("h1",{children:S}),(0,n.jsxs)("p",{children:[(0,n.jsx)("code",{children:a.pluginId}),(0,n.jsx)("span",{children:"/"}),(0,n.jsx)("code",{children:a.id})]})]})}),(0,n.jsx)("div",{className:"plugin-dashboard-content","data-plugin-dashboard-root":!0,children:(0,n.jsx)(i,{pluginId:a.pluginId,api:p})})]})})}function Pn(){let e=location.hash||"#/plugins";return e==="#/plugins"||e.startsWith("#/plugins?")?(0,n.jsx)(hn,{}):(0,n.jsx)(yn,{hash:e})}function kn(e){return G(e,(0,n.jsx)(Pn,{}))}export{kn as renderPluginPage};