@xopcai/xopc 0.0.86 → 0.0.87

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 (380) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/feishu/src/adapters/cli-login.js +3 -3
  3. package/dist/extensions/feishu/src/adapters/cli-login.js.map +1 -1
  4. package/dist/extensions/telegram/src/delivery-chat-id.d.ts +1 -1
  5. package/dist/extensions/telegram/src/delivery-chat-id.js +1 -1
  6. package/dist/extensions/telegram/src/delivery-chat-id.js.map +1 -1
  7. package/dist/extensions/telegram/src/routing-integration.js +1 -0
  8. package/dist/extensions/telegram/src/routing-integration.js.map +1 -1
  9. package/dist/extensions/telegram/xopc.extension.json +1 -1
  10. package/dist/extensions/weixin/src/__tests__/workflow-progress.test.js +2 -2
  11. package/dist/extensions/weixin/src/__tests__/workflow-progress.test.js.map +1 -1
  12. package/dist/extensions/weixin/src/api/api.js +2 -2
  13. package/dist/extensions/weixin/src/api/api.js.map +1 -1
  14. package/dist/extensions/weixin/src/auth/accounts.js +12 -12
  15. package/dist/extensions/weixin/src/auth/accounts.js.map +1 -1
  16. package/dist/extensions/weixin/src/delivery-to.js +2 -2
  17. package/dist/extensions/weixin/src/delivery-to.js.map +1 -1
  18. package/dist/extensions/weixin/src/messaging/debug-mode.js +5 -5
  19. package/dist/extensions/weixin/src/messaging/debug-mode.js.map +1 -1
  20. package/dist/extensions/weixin/src/messaging/inbound.js +11 -11
  21. package/dist/extensions/weixin/src/messaging/inbound.js.map +1 -1
  22. package/dist/extensions/weixin/src/storage/sync-buf.js +4 -4
  23. package/dist/extensions/weixin/src/storage/sync-buf.js.map +1 -1
  24. package/dist/extensions/weixin/src/workflow-progress.d.ts +1 -1
  25. package/dist/extensions/weixin/src/workflow-progress.js.map +1 -1
  26. package/dist/gateway/static/root/assets/{agents-mS3_HpRI.js → agents-BEAbXpuP.js} +6 -6
  27. package/dist/gateway/static/root/assets/{apps-page-DrfytjOb.js → apps-page-Dg8R-Szf.js} +1 -1
  28. package/dist/gateway/static/root/assets/{channels-settings-BG6b9KrW.js → channels-settings-yohw9YSu.js} +1 -1
  29. package/dist/gateway/static/root/assets/{channels-status-swr-Bs5kMCMI.js → channels-status-swr-BSHqqCF1.js} +1 -1
  30. package/dist/gateway/static/root/assets/{cron-api-BuVcZ5zR.js → cron-api-0h_QT8U3.js} +1 -1
  31. package/dist/gateway/static/root/assets/{cron-page-BMrloeFH.js → cron-page-BkfKFfFk.js} +1 -1
  32. package/dist/gateway/static/root/assets/{dist-CKU1OOTf.js → dist-Cmjp2APP.js} +1 -1
  33. package/dist/gateway/static/root/assets/{extension-debug-page-BdW_46sN.js → extension-debug-page-CFa9z_1N.js} +1 -1
  34. package/dist/gateway/static/root/assets/{extension-page-DW47KI82.js → extension-page-BI8eaTPq.js} +1 -1
  35. package/dist/gateway/static/root/assets/{extension-settings-page-B-W4x2xP.js → extension-settings-page-x4BB7q1X.js} +1 -1
  36. package/dist/gateway/static/root/assets/{fetch-B2MYHbWg.js → fetch-DRqwef_Q.js} +1 -1
  37. package/dist/gateway/static/root/assets/{field-primitives-DPG-oJmx.js → field-primitives-BiNHBo2Y.js} +1 -1
  38. package/dist/gateway/static/root/assets/{heartbeat-config-api-C8dNts9i.js → heartbeat-config-api-ZRb8qhuz.js} +1 -1
  39. package/dist/gateway/static/root/assets/{index-BmVYculr.js → index-Cu7bKuUi.js} +96 -94
  40. package/dist/gateway/static/root/assets/index-a5gWIdZQ.css +1 -0
  41. package/dist/gateway/static/root/assets/{logs-page-sTsVWz0X.js → logs-page-BFZ8GgCv.js} +1 -1
  42. package/dist/gateway/static/root/assets/{sessions-page-FaG_Vlkb.js → sessions-page-CD7AfB-2.js} +1 -1
  43. package/dist/gateway/static/root/assets/{settings-form-section-DuvRQW--.js → settings-form-section-DiqqVs6m.js} +1 -1
  44. package/dist/gateway/static/root/assets/{settings-page-Bet1OerL.js → settings-page-BBOjEQW3.js} +1 -1
  45. package/dist/gateway/static/root/assets/{share-preview-page-BtG2kLDh.js → share-preview-page-n1Gprylk.js} +1 -1
  46. package/dist/gateway/static/root/assets/{skills-page-DhUO235y.js → skills-page-CcN_gj--.js} +1 -1
  47. package/dist/gateway/static/root/assets/{theme-store-DryYl3qD.js → theme-store-CZOh1nT3.js} +1 -1
  48. package/dist/gateway/static/root/assets/url-Dd8Q7kZZ.js +3 -0
  49. package/dist/gateway/static/root/assets/{utils-BY7bU1DT.js → utils-CkWBfxs4.js} +1 -1
  50. package/dist/gateway/static/root/assets/{voice-api-key-field-CGEydndO.js → voice-api-key-field-O6awz9hi.js} +1 -1
  51. package/dist/gateway/static/root/index.html +5 -5
  52. package/dist/package.js +1 -1
  53. package/dist/src/agent/agent-scope.d.ts +4 -0
  54. package/dist/src/agent/agent-scope.js +53 -10
  55. package/dist/src/agent/agent-scope.js.map +1 -1
  56. package/dist/src/agent/bootstrap/filter-bootstrap-files.js +2 -1
  57. package/dist/src/agent/bootstrap/filter-bootstrap-files.js.map +1 -1
  58. package/dist/src/agent/embedded/session-tool-result-guard.js +2 -1
  59. package/dist/src/agent/embedded/session-tool-result-guard.js.map +1 -1
  60. package/dist/src/agent/embedded/tool-result-truncation.js +2 -1
  61. package/dist/src/agent/embedded/tool-result-truncation.js.map +1 -1
  62. package/dist/src/agent/fallback/candidates.js +2 -2
  63. package/dist/src/agent/fallback/candidates.js.map +1 -1
  64. package/dist/src/agent/goals/persistent-goal-apis.d.ts +0 -2
  65. package/dist/src/agent/goals/persistent-goal-service.js +0 -1
  66. package/dist/src/agent/goals/persistent-goal-service.js.map +1 -1
  67. package/dist/src/agent/image/generation/normalization.js +2 -12
  68. package/dist/src/agent/image/generation/normalization.js.map +1 -1
  69. package/dist/src/agent/image/generation/provider-registry.d.ts +4 -8
  70. package/dist/src/agent/image/generation/provider-registry.js.map +1 -1
  71. package/dist/src/agent/image/generation/runtime.d.ts +2 -2
  72. package/dist/src/agent/image/generation/runtime.js.map +1 -1
  73. package/dist/src/agent/image/generation/types.d.ts +0 -18
  74. package/dist/src/agent/image/image-helpers.js +6 -1
  75. package/dist/src/agent/image/image-helpers.js.map +1 -1
  76. package/dist/src/agent/image/index.d.ts +1 -1
  77. package/dist/src/agent/inbound/inbound-loop.d.ts +5 -0
  78. package/dist/src/agent/inbound/inbound-loop.js +41 -10
  79. package/dist/src/agent/inbound/inbound-loop.js.map +1 -1
  80. package/dist/src/agent/inbound/turn-dispatcher.d.ts +4 -0
  81. package/dist/src/agent/inbound/turn-dispatcher.js +6 -4
  82. package/dist/src/agent/inbound/turn-dispatcher.js.map +1 -1
  83. package/dist/src/agent/mcp/bundle-mcp-materialize.js +2 -1
  84. package/dist/src/agent/mcp/bundle-mcp-materialize.js.map +1 -1
  85. package/dist/src/agent/mcp/bundle-mcp-names.js +2 -1
  86. package/dist/src/agent/mcp/bundle-mcp-names.js.map +1 -1
  87. package/dist/src/agent/mcp/bundle-mcp-runtime.js +2 -1
  88. package/dist/src/agent/mcp/bundle-mcp-runtime.js.map +1 -1
  89. package/dist/src/agent/mcp/mcp-transport-config.js +2 -1
  90. package/dist/src/agent/mcp/mcp-transport-config.js.map +1 -1
  91. package/dist/src/agent/mcp/mcp-transport.js +2 -1
  92. package/dist/src/agent/mcp/mcp-transport.js.map +1 -1
  93. package/dist/src/agent/media-generation/runtime-shared.js +2 -9
  94. package/dist/src/agent/media-generation/runtime-shared.js.map +1 -1
  95. package/dist/src/agent/messaging/command-handler.d.ts +6 -0
  96. package/dist/src/agent/messaging/command-handler.js +5 -0
  97. package/dist/src/agent/messaging/command-handler.js.map +1 -1
  98. package/dist/src/agent/prompt/safety.d.ts +0 -7
  99. package/dist/src/agent/prompt/safety.js +1 -20
  100. package/dist/src/agent/prompt/safety.js.map +1 -1
  101. package/dist/src/agent/service/build-direct-message-content.js +1 -1
  102. package/dist/src/agent/service/build-direct-message-content.js.map +1 -1
  103. package/dist/src/agent/service/direct-turn-helpers.d.ts +3 -1
  104. package/dist/src/agent/service/direct-turn-helpers.js +6 -1
  105. package/dist/src/agent/service/direct-turn-helpers.js.map +1 -1
  106. package/dist/src/agent/service/process-direct-one-shot.d.ts +4 -0
  107. package/dist/src/agent/service/process-direct-one-shot.js +15 -2
  108. package/dist/src/agent/service/process-direct-one-shot.js.map +1 -1
  109. package/dist/src/agent/service/process-direct-streaming.d.ts +4 -0
  110. package/dist/src/agent/service/process-direct-streaming.js +34 -4
  111. package/dist/src/agent/service/process-direct-streaming.js.map +1 -1
  112. package/dist/src/agent/service/webchat-tts.js +1 -1
  113. package/dist/src/agent/service/webchat-tts.js.map +1 -1
  114. package/dist/src/agent/service.d.ts +8 -0
  115. package/dist/src/agent/service.js +21 -1
  116. package/dist/src/agent/service.js.map +1 -1
  117. package/dist/src/agent/tools/create-share-tool.js +27 -20
  118. package/dist/src/agent/tools/create-share-tool.js.map +1 -1
  119. package/dist/src/agent/tools/factory.js +1 -1
  120. package/dist/src/agent/tools/index.d.ts +0 -1
  121. package/dist/src/agent/tools/index.js +4 -5
  122. package/dist/src/agent/tools/shell.js +0 -13
  123. package/dist/src/agent/tools/shell.js.map +1 -1
  124. package/dist/src/agent/tools/workflow-tool.js +7 -1
  125. package/dist/src/agent/tools/workflow-tool.js.map +1 -1
  126. package/dist/src/agent/workflow/channel-capability.d.ts +3 -3
  127. package/dist/src/agent/workflow/lint.d.ts +38 -0
  128. package/dist/src/agent/workflow/lint.js +74 -0
  129. package/dist/src/agent/workflow/lint.js.map +1 -0
  130. package/dist/src/agent/workflow/parser.js +4 -1
  131. package/dist/src/agent/workflow/parser.js.map +1 -1
  132. package/dist/src/agent/workflow/runtime.d.ts +3 -0
  133. package/dist/src/agent/workflow/runtime.js +76 -3
  134. package/dist/src/agent/workflow/runtime.js.map +1 -1
  135. package/dist/src/agent/workflow/types.d.ts +3 -1
  136. package/dist/src/browser/index.js +4 -4
  137. package/dist/src/browser/manager.d.ts +1 -3
  138. package/dist/src/browser/manager.js +0 -6
  139. package/dist/src/browser/manager.js.map +1 -1
  140. package/dist/src/browser/providers/browser-ext-install.d.ts +4 -4
  141. package/dist/src/browser/providers/browser-ext-install.js +38 -85
  142. package/dist/src/browser/providers/browser-ext-install.js.map +1 -1
  143. package/dist/src/browser/providers/cloakbrowser.d.ts +0 -5
  144. package/dist/src/browser/providers/cloakbrowser.js +2 -55
  145. package/dist/src/browser/providers/cloakbrowser.js.map +1 -1
  146. package/dist/src/channels/attachments/voice-stt-webchat.js +10 -8
  147. package/dist/src/channels/attachments/voice-stt-webchat.js.map +1 -1
  148. package/dist/src/channels/pairing/allow-from-file.js +9 -9
  149. package/dist/src/channels/pairing/allow-from-file.js.map +1 -1
  150. package/dist/src/channels/pairing/pairing-store.js +6 -6
  151. package/dist/src/channels/pairing/pairing-store.js.map +1 -1
  152. package/dist/src/chat-commands/builtins/session.js +1 -1
  153. package/dist/src/chat-commands/builtins/session.js.map +1 -1
  154. package/dist/src/chat-commands/builtins/tts.js +2 -2
  155. package/dist/src/chat-commands/builtins/tts.js.map +1 -1
  156. package/dist/src/chat-commands/context.d.ts +3 -0
  157. package/dist/src/chat-commands/context.js +21 -3
  158. package/dist/src/chat-commands/context.js.map +1 -1
  159. package/dist/src/chat-commands/session-key.d.ts +4 -37
  160. package/dist/src/chat-commands/session-key.js +49 -85
  161. package/dist/src/chat-commands/session-key.js.map +1 -1
  162. package/dist/src/chat-commands/types.d.ts +2 -0
  163. package/dist/src/cli/commands/agent/interactive.js +2 -2
  164. package/dist/src/cli/commands/agent/interactive.js.map +1 -1
  165. package/dist/src/cli/commands/agent/sessions.js +2 -2
  166. package/dist/src/cli/commands/agent/sessions.js.map +1 -1
  167. package/dist/src/cli/commands/agent.js +4 -5
  168. package/dist/src/cli/commands/agent.js.map +1 -1
  169. package/dist/src/cli/commands/channels.js +1 -5
  170. package/dist/src/cli/commands/channels.js.map +1 -1
  171. package/dist/src/cli/commands/gateway/lifecycle-core.js +1 -1
  172. package/dist/src/cli/commands/gateway/lifecycle-core.js.map +1 -1
  173. package/dist/src/cli/commands/gateway/logs.d.ts +9 -0
  174. package/dist/src/cli/commands/gateway/logs.js +50 -17
  175. package/dist/src/cli/commands/gateway/logs.js.map +1 -1
  176. package/dist/src/cli/commands/image.js +22 -21
  177. package/dist/src/cli/commands/image.js.map +1 -1
  178. package/dist/src/cli/commands/session/utils.js +2 -2
  179. package/dist/src/cli/commands/session/utils.js.map +1 -1
  180. package/dist/src/cli/commands/update.js +26 -46
  181. package/dist/src/cli/commands/update.js.map +1 -1
  182. package/dist/src/cli/utils/session.d.ts +0 -5
  183. package/dist/src/cli/utils/session.js +1 -6
  184. package/dist/src/cli/utils/session.js.map +1 -1
  185. package/dist/src/commands/agents.config.js +1 -1
  186. package/dist/src/commands/agents.config.js.map +1 -1
  187. package/dist/src/config/agent-profile.js +5 -27
  188. package/dist/src/config/agent-profile.js.map +1 -1
  189. package/dist/src/config/index.js +2 -2
  190. package/dist/src/config/model-input.js +2 -5
  191. package/dist/src/config/model-input.js.map +1 -1
  192. package/dist/src/config/schema.d.ts +201 -217
  193. package/dist/src/config/schema.js +54 -39
  194. package/dist/src/config/schema.js.map +1 -1
  195. package/dist/src/config/workspace-path-helpers.d.ts +1 -2
  196. package/dist/src/config/workspace-path-helpers.js.map +1 -1
  197. package/dist/src/daemon/install-plan.js +25 -1
  198. package/dist/src/daemon/install-plan.js.map +1 -1
  199. package/dist/src/daemon/launchd.d.ts +8 -0
  200. package/dist/src/daemon/launchd.js +5 -12
  201. package/dist/src/daemon/launchd.js.map +1 -1
  202. package/dist/src/daemon/schtasks.d.ts +25 -0
  203. package/dist/src/daemon/schtasks.js +166 -46
  204. package/dist/src/daemon/schtasks.js.map +1 -1
  205. package/dist/src/daemon/service.js +5 -4
  206. package/dist/src/daemon/service.js.map +1 -1
  207. package/dist/src/daemon/systemd.d.ts +6 -0
  208. package/dist/src/daemon/systemd.js +18 -3
  209. package/dist/src/daemon/systemd.js.map +1 -1
  210. package/dist/src/extensions/activation-context.js +0 -1
  211. package/dist/src/extensions/activation-context.js.map +1 -1
  212. package/dist/src/extensions/normalize-manifest.js +0 -1
  213. package/dist/src/extensions/normalize-manifest.js.map +1 -1
  214. package/dist/src/extensions/types/manifest.d.ts +0 -2
  215. package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
  216. package/dist/src/gateway/agent-builtin-tools.js +1 -0
  217. package/dist/src/gateway/agent-builtin-tools.js.map +1 -1
  218. package/dist/src/gateway/agents-admin.js +10 -2
  219. package/dist/src/gateway/agents-admin.js.map +1 -1
  220. package/dist/src/gateway/heartbeat/service.js +2 -2
  221. package/dist/src/gateway/heartbeat/service.js.map +1 -1
  222. package/dist/src/gateway/hono/app.js +1 -1
  223. package/dist/src/gateway/hono/lib/agent-model.d.ts +18 -10
  224. package/dist/src/gateway/hono/lib/agent-model.js +24 -35
  225. package/dist/src/gateway/hono/lib/agent-model.js.map +1 -1
  226. package/dist/src/gateway/hono/lib/config-payload.js +1 -1
  227. package/dist/src/gateway/hono/lib/config-payload.js.map +1 -1
  228. package/dist/src/gateway/hono/lib/safe-voice-config.js +14 -53
  229. package/dist/src/gateway/hono/lib/safe-voice-config.js.map +1 -1
  230. package/dist/src/gateway/hono/routes/config-patch/agents.js +17 -5
  231. package/dist/src/gateway/hono/routes/config-patch/agents.js.map +1 -1
  232. package/dist/src/gateway/hono/routes/config-patch/channels.js +0 -11
  233. package/dist/src/gateway/hono/routes/config-patch/channels.js.map +1 -1
  234. package/dist/src/gateway/hono/routes/goals.js +1 -1
  235. package/dist/src/gateway/hono/routes/goals.js.map +1 -1
  236. package/dist/src/gateway/hono/routes/sessions.js +28 -7
  237. package/dist/src/gateway/hono/routes/sessions.js.map +1 -1
  238. package/dist/src/gateway/hono/routes/shares.js +14 -12
  239. package/dist/src/gateway/hono/routes/shares.js.map +1 -1
  240. package/dist/src/gateway/hono/routes/tunnel.js +1 -1
  241. package/dist/src/gateway/hono/routes/update.js +4 -2
  242. package/dist/src/gateway/hono/routes/update.js.map +1 -1
  243. package/dist/src/gateway/hono/sse.js +16 -33
  244. package/dist/src/gateway/hono/sse.js.map +1 -1
  245. package/dist/src/gateway/lock.js +10 -10
  246. package/dist/src/gateway/lock.js.map +1 -1
  247. package/dist/src/gateway/ports.js +6 -6
  248. package/dist/src/gateway/ports.js.map +1 -1
  249. package/dist/src/gateway/resolve-webchat-session-key.d.ts +19 -0
  250. package/dist/src/gateway/resolve-webchat-session-key.js +46 -0
  251. package/dist/src/gateway/resolve-webchat-session-key.js.map +1 -0
  252. package/dist/src/gateway/service/run-gateway-agent.js +27 -11
  253. package/dist/src/gateway/service/run-gateway-agent.js.map +1 -1
  254. package/dist/src/gateway/service/sessions-api.d.ts +3 -0
  255. package/dist/src/gateway/service/sessions-api.js +8 -0
  256. package/dist/src/gateway/service/sessions-api.js.map +1 -1
  257. package/dist/src/gateway/service.d.ts +0 -2
  258. package/dist/src/gateway/service.js +2 -7
  259. package/dist/src/gateway/service.js.map +1 -1
  260. package/dist/src/gateway/session-reset-service.d.ts +20 -0
  261. package/dist/src/gateway/session-reset-service.js +54 -0
  262. package/dist/src/gateway/session-reset-service.js.map +1 -0
  263. package/dist/src/gateway/startup-readiness.d.ts +1 -1
  264. package/dist/src/gateway/startup-readiness.js +1 -0
  265. package/dist/src/gateway/startup-readiness.js.map +1 -1
  266. package/dist/src/heartbeat/index.js +1 -1
  267. package/dist/src/infra/gateway-processes.js +2 -2
  268. package/dist/src/infra/gateway-processes.js.map +1 -1
  269. package/dist/src/infra/run-command.d.ts +16 -0
  270. package/dist/src/infra/run-command.js +67 -0
  271. package/dist/src/infra/run-command.js.map +1 -0
  272. package/dist/src/infra/update-global.d.ts +45 -0
  273. package/dist/src/infra/update-global.js +224 -0
  274. package/dist/src/infra/update-global.js.map +1 -0
  275. package/dist/src/mcp/channel-bridge.js +1 -1
  276. package/dist/src/mcp/channel-shared.js +2 -1
  277. package/dist/src/mcp/channel-shared.js.map +1 -1
  278. package/dist/src/providers/auth-runtime/auth-profile-store.js +1 -1
  279. package/dist/src/providers/auth-runtime/auth-profile-store.js.map +1 -1
  280. package/dist/src/providers/auth-runtime/resolve-auth.js +1 -12
  281. package/dist/src/providers/auth-runtime/resolve-auth.js.map +1 -1
  282. package/dist/src/providers/auth-runtime/types.d.ts +6 -12
  283. package/dist/src/routing/agent-session-key.d.ts +58 -0
  284. package/dist/src/routing/agent-session-key.js +164 -0
  285. package/dist/src/routing/agent-session-key.js.map +1 -0
  286. package/dist/src/routing/index.d.ts +1 -1
  287. package/dist/src/routing/index.js +4 -2
  288. package/dist/src/routing/index.js.map +1 -1
  289. package/dist/src/routing/resolve-route.d.ts +15 -0
  290. package/dist/src/routing/resolve-route.js +41 -20
  291. package/dist/src/routing/resolve-route.js.map +1 -1
  292. package/dist/src/routing/resolve-tui-session-key.d.ts +25 -0
  293. package/dist/src/routing/resolve-tui-session-key.js +54 -0
  294. package/dist/src/routing/resolve-tui-session-key.js.map +1 -0
  295. package/dist/src/routing/session-key-utils.d.ts +24 -0
  296. package/dist/src/routing/session-key-utils.js +92 -0
  297. package/dist/src/routing/session-key-utils.js.map +1 -0
  298. package/dist/src/routing/session-key.d.ts +19 -49
  299. package/dist/src/routing/session-key.js +143 -116
  300. package/dist/src/routing/session-key.js.map +1 -1
  301. package/dist/src/session/index.d.ts +6 -0
  302. package/dist/src/session/index.js +7 -1
  303. package/dist/src/session/init-session-turn.d.ts +30 -0
  304. package/dist/src/session/init-session-turn.js +102 -0
  305. package/dist/src/session/init-session-turn.js.map +1 -0
  306. package/dist/src/session/lifecycle-timestamps.d.ts +8 -0
  307. package/dist/src/session/lifecycle-timestamps.js +16 -0
  308. package/dist/src/session/lifecycle-timestamps.js.map +1 -0
  309. package/dist/src/session/manager.d.ts +7 -1
  310. package/dist/src/session/manager.js +8 -1
  311. package/dist/src/session/manager.js.map +1 -1
  312. package/dist/src/session/parity/transcript-paths.js +2 -2
  313. package/dist/src/session/parity/transcript-paths.js.map +1 -1
  314. package/dist/src/session/parity/xopc-session-disk-entry.d.ts +6 -0
  315. package/dist/src/session/reset-policy.d.ts +32 -0
  316. package/dist/src/session/reset-policy.js +65 -0
  317. package/dist/src/session/reset-policy.js.map +1 -0
  318. package/dist/src/session/reset-triggers.d.ts +20 -0
  319. package/dist/src/session/reset-triggers.js +63 -0
  320. package/dist/src/session/reset-triggers.js.map +1 -0
  321. package/dist/src/session/reset-type.d.ts +12 -0
  322. package/dist/src/session/reset-type.js +25 -0
  323. package/dist/src/session/reset-type.js.map +1 -0
  324. package/dist/src/session/resolve-session.d.ts +30 -0
  325. package/dist/src/session/resolve-session.js +93 -0
  326. package/dist/src/session/resolve-session.js.map +1 -0
  327. package/dist/src/session/session-title.js +3 -2
  328. package/dist/src/session/session-title.js.map +1 -1
  329. package/dist/src/session/store.d.ts +11 -4
  330. package/dist/src/session/store.js +57 -6
  331. package/dist/src/session/store.js.map +1 -1
  332. package/dist/src/session/transcript-events.js +2 -1
  333. package/dist/src/session/transcript-events.js.map +1 -1
  334. package/dist/src/share/share-url.d.ts +33 -0
  335. package/dist/src/share/share-url.js +56 -14
  336. package/dist/src/share/share-url.js.map +1 -1
  337. package/dist/src/tui/backends/embedded-backend.js +4 -9
  338. package/dist/src/tui/backends/embedded-backend.js.map +1 -1
  339. package/dist/src/tui/backends/gateway-sse-backend.js +1 -1
  340. package/dist/src/tui/backends/gateway-sse-backend.js.map +1 -1
  341. package/dist/src/tui/components/chat-log.js +3 -3
  342. package/dist/src/tui/components/chat-log.js.map +1 -1
  343. package/dist/src/tui/theme.d.ts +0 -2
  344. package/dist/src/tui/theme.js +1 -3
  345. package/dist/src/tui/theme.js.map +1 -1
  346. package/dist/src/tui/tui-commands.d.ts +3 -0
  347. package/dist/src/tui/tui-commands.js +45 -10
  348. package/dist/src/tui/tui-commands.js.map +1 -1
  349. package/dist/src/tui/tui-keybindings-file.js +1 -21
  350. package/dist/src/tui/tui-keybindings-file.js.map +1 -1
  351. package/dist/src/tui/tui-session-actions.d.ts +28 -0
  352. package/dist/src/tui/tui-session-actions.js +88 -0
  353. package/dist/src/tui/tui-session-actions.js.map +1 -0
  354. package/dist/src/tui/tui.js +52 -47
  355. package/dist/src/tui/tui.js.map +1 -1
  356. package/dist/src/utils/string-coerce.d.ts +2 -0
  357. package/dist/src/utils/string-coerce.js +10 -1
  358. package/dist/src/utils/string-coerce.js.map +1 -1
  359. package/dist/src/voice/stt/config-slice.d.ts +2 -5
  360. package/dist/src/voice/stt/config-slice.js +5 -26
  361. package/dist/src/voice/stt/config-slice.js.map +1 -1
  362. package/dist/src/voice/stt/types.d.ts +1 -18
  363. package/dist/src/voice/stt/types.js +4 -2
  364. package/dist/src/voice/stt/types.js.map +1 -1
  365. package/dist/src/voice/tts/config-slice.d.ts +3 -7
  366. package/dist/src/voice/tts/config-slice.js +7 -38
  367. package/dist/src/voice/tts/config-slice.js.map +1 -1
  368. package/dist/src/voice/tts/merge-config.js +2 -48
  369. package/dist/src/voice/tts/merge-config.js.map +1 -1
  370. package/dist/src/voice/tts/providers/alibaba-speech.js +1 -1
  371. package/dist/src/voice/tts/providers/alibaba-speech.js.map +1 -1
  372. package/dist/src/voice/tts/types.d.ts +1 -29
  373. package/dist/src/voice/tts/types.js +19 -17
  374. package/dist/src/voice/tts/types.js.map +1 -1
  375. package/package.json +1 -4
  376. package/dist/gateway/static/root/assets/index-ew_2L2We.css +0 -1
  377. package/dist/gateway/static/root/assets/url-BwNL6Rgk.js +0 -3
  378. package/dist/src/agent/tools/browser-legacy-tools.d.ts +0 -17
  379. package/dist/src/agent/tools/browser-legacy-tools.js +0 -766
  380. package/dist/src/agent/tools/browser-legacy-tools.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{i,o as a,t as o}from"./url-BwNL6Rgk.js";import{i as s}from"./vendor-swr-BIWyz7Rc.js";import{a as c,i as l,n as u,o as d,r as f,s as p,t as m}from"./dist-BTWC-BTN.js";import{i as h}from"./theme-store-DryYl3qD.js";import{a as g,n as _,t as v}from"./fetch-B2MYHbWg.js";import{$i as y,$n as b,$t as x,B as S,Bi as C,Bn as w,Bt as T,Ci as E,Di as D,Dr as O,F as k,G as A,Gi as j,Gn as M,Gt as N,H as P,Hr as F,Ht as I,I as ee,J as L,K as R,L as z,Li as B,Mi as V,Mn as H,Mr as U,Ni as W,Nn as te,Nr as ne,On as G,Or as K,P as q,Pi as re,Pn as ie,Pr as ae,Qt as oe,R as se,Ri as ce,Rr as le,Rt as ue,Sr as de,Ti as fe,Tr as pe,U as me,Un as he,Ur as ge,V as _e,Vi as ve,Vr as ye,Vt as be,W as xe,Wr as Se,Xi as Ce,Xt as we,Yt as Te,Zn as Ee,Zr as De,Zt as Oe,_i as ke,_n as Ae,a as je,ar as Me,br as Ne,c as Pe,cr as Fe,d as Ie,da as Le,dr as Re,ei as ze,en as J,er as Be,f as Ve,fi as He,fr as Ue,g as We,gn as Ge,h as Ke,i as qe,ia as Je,ii as Ye,in as Xe,ir as Ze,ji as Qe,jn as $e,ki as et,l as tt,la as nt,lr as rt,m as it,mi as at,mr as ot,nn as st,nr as Y,o as ct,oa as lt,oi as ut,or as dt,p as ft,pr as pt,q as mt,qi as ht,qr as gt,rn as _t,rr as vt,s as yt,si as bt,t as xt,tn as St,tr as Ct,u as wt,ua as Tt,ur as Et,v as Dt,vr as Ot,wr as kt,xi as At,xr as jt,y as Mt,yi as Nt,z as Pt,zi as Ft,zr as It,zt as Lt}from"./index-BmVYculr.js";import{n as Rt,t as zt}from"./settings-form-section-DuvRQW--.js";import{c as Bt,f as Vt,n as Ht,t as Ut}from"./cron-dreaming-jobs-DueM3rBz.js";import{i as Wt,l as Gt,m as Kt,n as qt,u as Jt}from"./cron-api-BuVcZ5zR.js";var X=n(),Z=r();function Yt(e){let t=(0,X.c)(40),{open:n,onOpenChange:r,busy:i,deletePurge:a,deleteTarget:o,deleteConfirmText:s,onDeleteConfirmTextChange:m,onConfirm:h,onCancel:g,a:_}=e,v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(l,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),t[0]=v):v=t[0];let y;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(y=Y(`fixed left-1/2 top-1/2 z-[81] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-panel p-4 shadow-popover`,`dark:border-edge`),t[1]=y):y=t[1];let b=a?_.purgeDisk:_.removeFromConfig,x;t[2]===b?x=t[3]:(x=(0,Z.jsx)(p,{className:`text-base font-semibold text-fg`,children:b}),t[2]=b,t[3]=x);let S=a?_.confirmDeletePurge:_.confirmDelete,C;t[4]===S?C=t[5]:(C=(0,Z.jsx)(f,{className:`mt-2 whitespace-pre-wrap text-sm leading-relaxed text-fg-muted`,children:S}),t[4]=S,t[5]=C);let w;t[6]!==_.purgeConfirmHint||t[7]!==_.purgeConfirmLabel||t[8]!==_.purgeConfirmPlaceholder||t[9]!==s||t[10]!==a||t[11]!==o||t[12]!==m?(w=a&&o?(0,Z.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,Z.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-fg`,htmlFor:`agent-delete-confirm`,children:_.purgeConfirmLabel}),(0,Z.jsx)(`input`,{id:`agent-delete-confirm`,type:`text`,autoComplete:`off`,spellCheck:!1,className:Y(`w-full rounded-md border border-edge bg-surface-panel px-3 py-1.5 font-mono text-xs text-fg`,`placeholder:text-fg-subtle`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`dark:border-edge`),placeholder:_.purgeConfirmPlaceholder.replace(`{{agentId}}`,o.id),value:s,onChange:e=>m(e.target.value)}),(0,Z.jsx)(`p`,{className:`pt-0.5 text-xs text-fg-muted`,children:_.purgeConfirmHint.replace(`{{agentId}}`,o.id)})]}):null,t[6]=_.purgeConfirmHint,t[7]=_.purgeConfirmLabel,t[8]=_.purgeConfirmPlaceholder,t[9]=s,t[10]=a,t[11]=o,t[12]=m,t[13]=w):w=t[13];let T;t[14]!==_.createModalCancel||t[15]!==i||t[16]!==g?(T=(0,Z.jsx)(Ct,{type:`button`,variant:`ghost`,disabled:i,onClick:g,children:_.createModalCancel}),t[14]=_.createModalCancel,t[15]=i,t[16]=g,t[17]=T):T=t[17];let E=a?`border-red-200 text-red-700 hover:bg-red-50 dark:border-red-900/60 dark:text-red-300 dark:hover:bg-red-950/40`:void 0,D;t[18]!==i||t[19]!==s||t[20]!==a||t[21]!==o?(D=i||!o||a&&s.trim().toLowerCase()!==o.id.toLowerCase(),t[18]=i,t[19]=s,t[20]=a,t[21]=o,t[22]=D):D=t[22];let O=a?_.purgeDisk:_.removeFromConfig,k;t[23]!==h||t[24]!==D||t[25]!==O||t[26]!==E?(k=(0,Z.jsx)(Ct,{type:`button`,variant:`secondary`,className:E,disabled:D,onClick:h,children:O}),t[23]=h,t[24]=D,t[25]=O,t[26]=E,t[27]=k):k=t[27];let A;t[28]!==k||t[29]!==T?(A=(0,Z.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-end gap-2 border-t border-edge-subtle/60 pt-3`,children:[T,k]}),t[28]=k,t[29]=T,t[30]=A):A=t[30];let j;t[31]!==A||t[32]!==x||t[33]!==C||t[34]!==w?(j=(0,Z.jsxs)(c,{children:[v,(0,Z.jsxs)(u,{className:y,onOpenAutoFocus:Xt,children:[x,C,w,A]})]}),t[31]=A,t[32]=x,t[33]=C,t[34]=w,t[35]=j):j=t[35];let M;return t[36]!==r||t[37]!==n||t[38]!==j?(M=(0,Z.jsx)(d,{open:n,onOpenChange:r,children:j}),t[36]=r,t[37]=n,t[38]=j,t[39]=M):M=t[39],M}function Xt(e){return e.preventDefault()}var Zt=[{id:`overview`,labelKey:`navIdentity`,icon:Fe},{id:`profile`,labelKey:`navProfile`,icon:Ft},{id:`tools`,labelKey:`navTools`,icon:Me},{id:`skills`,labelKey:`navSkills`,icon:It},{id:`files`,labelKey:`navCoreFiles`,icon:At}],Qt=[{id:`channels`,labelKey:`tabChannels`,icon:F},{id:`cron`,labelKey:`tabCron`,icon:re}];function $t(e){let t=(0,X.c)(20),{a:n,panel:r,onPanelChange:i}=e,a;t[0]!==i||t[1]!==r?(a=(e,t,n)=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>i(e),className:Y(`flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-left text-sm font-medium transition-colors`,Lt.press,r===e?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:[(0,Z.jsx)(n,{className:`size-4 shrink-0 opacity-90`,strokeWidth:2,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:t})]},e),t[0]=i,t[1]=r,t[2]=a):a=t[2];let o=a,s=n.editorNavAria,c;t[3]!==n||t[4]!==o?(c=Zt.map(e=>{let{id:t,labelKey:r,icon:i}=e;return o(t,n[r],i)}),t[3]=n,t[4]=o,t[5]=c):c=t[5];let l;t[6]===c?l=t[7]:(l=(0,Z.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:c}),t[6]=c,t[7]=l);let u;t[8]===n.navAdvanced?u=t[9]:(u=(0,Z.jsx)(`p`,{className:`mt-4 px-3 text-[10px] font-semibold uppercase tracking-wide text-fg-subtle`,children:n.navAdvanced}),t[8]=n.navAdvanced,t[9]=u);let d;t[10]!==n||t[11]!==o?(d=Qt.map(e=>{let{id:t,labelKey:r,icon:i}=e;return o(t,n[r],i)}),t[10]=n,t[11]=o,t[12]=d):d=t[12];let f;t[13]===d?f=t[14]:(f=(0,Z.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:d}),t[13]=d,t[14]=f);let p;return t[15]!==n.editorNavAria||t[16]!==l||t[17]!==u||t[18]!==f?(p=(0,Z.jsxs)(`nav`,{className:`flex w-full flex-col gap-1`,"aria-label":s,children:[l,u,f]}),t[15]=n.editorNavAria,t[16]=l,t[17]=u,t[18]=f,t[19]=p):p=t[19],p}function en(e){let t=(0,X.c)(49),{open:n,onOpenChange:r,a:i,title:a,subtitle:o,panel:s,onPanelChange:h,onFooterSave:g,footerSaveDisabled:_,footerSavedFlash:v,busy:y,children:b}=e,x;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Z.jsx)(l,{className:Y(`xopc-dialog-overlay fixed inset-0 bg-scrim`,We)}),t[0]=x):x=t[0];let S;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(S=Y(`xopc-dialog-content fixed flex flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover dark:border-edge`,Ke,`inset-4 h-[calc(100dvh-2rem)] max-h-[calc(100dvh-2rem)] min-h-0`,`sm:inset-auto sm:left-1/2 sm:top-1/2 sm:h-[min(88vh,48rem)] sm:max-h-[min(88vh,48rem)] sm:min-h-[32rem] sm:w-[min(100%-2rem,58rem)] sm:-translate-x-1/2 sm:-translate-y-1/2`),t[1]=S):S=t[1];let C;t[2]===a?C=t[3]:(C=(0,Z.jsx)(p,{className:`text-base font-semibold leading-snug text-fg`,children:a}),t[2]=a,t[3]=C);let w;t[4]===o?w=t[5]:(w=(0,Z.jsx)(f,{className:`mt-1 font-mono text-xs text-fg-muted`,children:o}),t[4]=o,t[5]=w);let T;t[6]!==C||t[7]!==w?(T=(0,Z.jsxs)(`div`,{className:`min-w-0 pr-2`,children:[C,w]}),t[6]=C,t[7]=w,t[8]=T):T=t[8];let E;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(E=Y(ue,`shrink-0 p-1.5 hover:bg-surface-base`),t[9]=E):E=t[9];let D;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Z.jsx)(Ze,{className:`size-4`,"aria-hidden":!0}),t[10]=D):D=t[10];let O;t[11]===i.closeDialogAria?O=t[12]:(O=(0,Z.jsx)(m,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:E,"aria-label":i.closeDialogAria,children:D})}),t[11]=i.closeDialogAria,t[12]=O);let k;t[13]!==T||t[14]!==O?(k=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-2 border-b border-edge-subtle px-4 pb-3 pt-4 dark:border-edge`,children:[T,O]}),t[13]=T,t[14]=O,t[15]=k):k=t[15];let A;t[16]!==i||t[17]!==h||t[18]!==s?(A=(0,Z.jsx)(`div`,{className:`shrink-0 border-b border-edge-subtle px-4 py-3 dark:border-edge sm:flex sm:w-56 sm:shrink-0 sm:flex-col sm:overflow-y-auto sm:border-b-0 sm:border-r sm:px-0 sm:py-4 sm:pl-4 sm:pr-3`,children:(0,Z.jsx)($t,{a:i,panel:s,onPanelChange:h})}),t[16]=i,t[17]=h,t[18]=s,t[19]=A):A=t[19];let j;t[20]===b?j=t[21]:(j=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden p-4 sm:pl-2 sm:pr-5`,children:b}),t[20]=b,t[21]=j);let M;t[22]!==i.footerSaveNotApplicable||t[23]!==i.personaSaved||t[24]!==_||t[25]!==v?(M=v?(0,Z.jsxs)(`p`,{className:`order-2 text-center text-xs font-medium text-green-600 sm:order-1 sm:mr-auto sm:text-left dark:text-green-400`,children:[`✓ `,i.personaSaved]}):_?(0,Z.jsx)(`p`,{className:`order-2 text-center text-xs text-fg-muted sm:order-1 sm:mr-auto sm:text-left`,children:i.footerSaveNotApplicable}):null,t[22]=i.footerSaveNotApplicable,t[23]=i.personaSaved,t[24]=_,t[25]=v,t[26]=M):M=t[26];let N=y||_,P;t[27]===g?P=t[28]:(P=()=>void g(),t[27]=g,t[28]=P);let F;t[29]!==i.save||t[30]!==N||t[31]!==P?(F=(0,Z.jsx)(Ct,{type:`button`,className:`order-1 w-full sm:order-2 sm:w-auto`,disabled:N,onClick:P,children:i.save}),t[29]=i.save,t[30]=N,t[31]=P,t[32]=F):F=t[32];let I;t[33]!==M||t[34]!==F?(I=(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-1 border-t border-edge-subtle px-4 py-3 dark:border-edge sm:flex-row sm:items-center sm:justify-end sm:gap-3`,children:[M,F]}),t[33]=M,t[34]=F,t[35]=I):I=t[35];let ee;t[36]!==j||t[37]!==I?(ee=(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[j,I]}),t[36]=j,t[37]=I,t[38]=ee):ee=t[38];let L;t[39]!==ee||t[40]!==A?(L=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col sm:flex-row sm:overflow-hidden`,children:[A,ee]}),t[39]=ee,t[40]=A,t[41]=L):L=t[41];let R;t[42]!==L||t[43]!==k?(R=(0,Z.jsxs)(c,{children:[x,(0,Z.jsx)(u,{className:S,onOpenAutoFocus:tn,children:(0,Z.jsxs)(Ie,{layer:`modal`,children:[k,L]})})]}),t[42]=L,t[43]=k,t[44]=R):R=t[44];let z;return t[45]!==r||t[46]!==n||t[47]!==R?(z=(0,Z.jsx)(d,{open:n,onOpenChange:r,children:R}),t[45]=r,t[46]=n,t[47]=R,t[48]=z):z=t[48],z}function tn(e){return e.preventDefault()}function nn(){return Y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Be,`dark:border-edge`)}function rn(e,t,n){let r=e.agentId?.trim().toLowerCase();return r?r===t.toLowerCase():t.toLowerCase()===n.toLowerCase()}function an(e){return[e.channel,e.accountId,e.peerKind,e.peerId].filter(e=>typeof e==`string`&&e.length>0).join(` · `)||e.channel}function on(e,t,n,r){let i=e.trim(),a=t.trim();if(a)return{channel:i,peerId:a};if(n!=null){let e=r[n];if(!e)return{channel:i};let t={channel:i};e.accountId?.trim()&&(t.accountId=e.accountId.trim()),e.peerKind?.trim()&&(t.peerKind=e.peerKind.trim());let a=e.peerId?.trim()||e.chatId?.trim();return a&&(t.peerId=a),t}return{channel:i}}var sn=Y(b,`w-full text-xs sm:w-auto sm:min-w-[11rem] sm:max-w-[17rem] sm:shrink-0`);function cn(e){let t=(0,X.c)(62),{a:n,busy:r,bindingsLoading:i,agentBindings:a,onRemoveBinding:o,onAddBinding:s,channelStatuses:c,channelsStatusLoading:l,useManualChannel:u,newBindChannel:d,setNewBindChannel:f,bindSessionChats:p,sessionsLoading:m,newBindSessionIdx:h,setNewBindSessionIdx:g,newBindCustomPeer:_,setNewBindCustomPeer:v,onRefreshSessions:y,lastActiveLabels:b,selectRecipient:x}=e,S=!l&&(u||c.length>0),C;t[0]!==n.channelsHint||t[1]!==n.channelsTitle?(C=(0,Z.jsx)(Rt,{className:`shrink-0`,icon:ut,title:n.channelsTitle,subtitle:n.channelsHint}),t[0]=n.channelsHint,t[1]=n.channelsTitle,t[2]=C):C=t[2];let w;t[3]!==n.channelsLoading||t[4]!==n.channelsNone||t[5]!==n.removeBinding||t[6]!==a||t[7]!==i||t[8]!==r||t[9]!==o?(w=i?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.channelsLoading}):a.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.channelsNone}):(0,Z.jsx)(`ul`,{className:`flex flex-col gap-2 text-sm`,children:a.map(e=>(0,Z.jsxs)(`li`,{className:`flex flex-wrap items-center justify-between gap-2 rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-xs`,children:an(e.match)}),(0,Z.jsx)(Ct,{type:`button`,variant:`secondary`,disabled:r,onClick:()=>void o(e),children:n.removeBinding})]},`${e.match.channel}-${an(e.match)}`))}),t[3]=n.channelsLoading,t[4]=n.channelsNone,t[5]=n.removeBinding,t[6]=a,t[7]=i,t[8]=r,t[9]=o,t[10]=w):w=t[10];let T;t[11]!==n.channelLabel||t[12]!==n.channelsDisabledSuffix||t[13]!==n.channelsLoadingChannels||t[14]!==n.channelsManualChannelHint||t[15]!==c||t[16]!==l||t[17]!==d||t[18]!==f||t[19]!==v||t[20]!==g||t[21]!==u?(T=l?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.channelsLoadingChannels}):u?(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:n.channelLabel}),(0,Z.jsx)(`input`,{className:nn(),value:d,onChange:e=>f(e.target.value),placeholder:`telegram`,autoComplete:`off`}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.channelsManualChannelHint})]}):(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:n.channelLabel}),(0,Z.jsx)(`select`,{className:Y(nn(),`py-2`),value:d,onChange:e=>{f(e.target.value),g(null),v(``)},children:c.map(e=>(0,Z.jsxs)(`option`,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:n.channelsDisabledSuffix]},e.name))})]}),t[11]=n.channelLabel,t[12]=n.channelsDisabledSuffix,t[13]=n.channelsLoadingChannels,t[14]=n.channelsManualChannelHint,t[15]=c,t[16]=l,t[17]=d,t[18]=f,t[19]=v,t[20]=g,t[21]=u,t[22]=T):T=t[22];let E;t[23]!==n.channelsCustomPeerHint||t[24]!==n.channelsCustomPeerPlaceholder||t[25]!==n.channelsLoadingSessions||t[26]!==n.channelsNoSessionsHint||t[27]!==n.channelsPeerAny||t[28]!==n.channelsPeerFromSessions||t[29]!==n.channelsRefreshSessions||t[30]!==n.channelsRefreshSessionsHint||t[31]!==n.channelsSessionLabel||t[32]!==n.peerIdLabel||t[33]!==p||t[34]!==r||t[35]!==b||t[36]!==d||t[37]!==_||t[38]!==h||t[39]!==y||t[40]!==x||t[41]!==m||t[42]!==v||t[43]!==g||t[44]!==S?(E=S&&d.trim()?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-edge-subtle pt-3 text-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:n.channelsSessionLabel}),(0,Z.jsxs)(Ct,{type:`button`,variant:`ghost`,className:`h-7 gap-1 px-2 text-xs`,disabled:r||m||!d.trim(),title:n.channelsRefreshSessionsHint,onClick:()=>y(),children:[(0,Z.jsx)(le,{className:Y(`size-3.5`,m&&`animate-spin`),strokeWidth:1.75}),n.channelsRefreshSessions]})]}),m&&p.length===0?(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.channelsLoadingSessions}):null,(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:n.channelsPeerFromSessions}),(0,Z.jsxs)(`select`,{className:Y(nn(),`py-2`),value:h==null?``:String(h),disabled:r||!d.trim()||!!_.trim(),onChange:e=>{let t=e.target.value;g(t===``?null:Number(t))},children:[(0,Z.jsx)(`option`,{value:``,children:n.channelsPeerAny}),p.map((e,t)=>(0,Z.jsx)(`option`,{value:String(t),children:Bt(e,b)},`${e.channel}-${e.chatId}`))]})]}),p.length===0&&d.trim()&&!m?(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.channelsNoSessionsHint}):null,(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:n.peerIdLabel}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch sm:gap-2`,children:[(0,Z.jsx)(`input`,{type:`text`,className:Y(nn(),`min-w-0 w-full sm:flex-1`),value:_,onChange:e=>{v(e.target.value),e.target.value.trim()&&g(null)},placeholder:n.channelsCustomPeerPlaceholder,autoComplete:`off`}),(0,Z.jsxs)(`select`,{className:sn,value:_,onChange:e=>{let t=e.target.value;v(t||``),g(null)},children:[(0,Z.jsx)(`option`,{value:``,children:x}),p.map(e=>(0,Z.jsx)(`option`,{value:e.chatId,children:Bt(e,b)},`${e.channel}-${e.chatId}`))]})]}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.channelsCustomPeerHint})]})]}):null,t[23]=n.channelsCustomPeerHint,t[24]=n.channelsCustomPeerPlaceholder,t[25]=n.channelsLoadingSessions,t[26]=n.channelsNoSessionsHint,t[27]=n.channelsPeerAny,t[28]=n.channelsPeerFromSessions,t[29]=n.channelsRefreshSessions,t[30]=n.channelsRefreshSessionsHint,t[31]=n.channelsSessionLabel,t[32]=n.peerIdLabel,t[33]=p,t[34]=r,t[35]=b,t[36]=d,t[37]=_,t[38]=h,t[39]=y,t[40]=x,t[41]=m,t[42]=v,t[43]=g,t[44]=S,t[45]=E):E=t[45];let D;t[46]!==r||t[47]!==l||t[48]!==d?(D=r||!d.trim()||l,t[46]=r,t[47]=l,t[48]=d,t[49]=D):D=t[49];let O;t[50]!==n.addBinding||t[51]!==D?(O=(0,Z.jsx)(`div`,{children:(0,Z.jsx)(Ct,{type:`submit`,disabled:D,children:n.addBinding})}),t[50]=n.addBinding,t[51]=D,t[52]=O):O=t[52];let k;t[53]!==s||t[54]!==T||t[55]!==E||t[56]!==O?(k=(0,Z.jsxs)(`form`,{className:`mt-4 flex flex-col gap-3`,onSubmit:s,children:[T,E,O]}),t[53]=s,t[54]=T,t[55]=E,t[56]=O,t[57]=k):k=t[57];let A;return t[58]!==C||t[59]!==w||t[60]!==k?(A=(0,Z.jsxs)(zt,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[C,w,k]}),t[58]=C,t[59]=w,t[60]=k,t[61]=A):A=t[61],A}function ln(e){let t=(0,X.c)(12),n;t[0]!==e.expression||t[1]!==e.kind||t[2]!==e.labels||t[3]!==e.locale||t[4]!==e.nextRun||t[5]!==e.presetLabels||t[6]!==e.timezone||t[7]!==e.valueMs?(n=e.kind===`cron`?Vt(e.expression,e.locale,e.labels,{timezone:e.timezone,nextRun:e.nextRun}):Ht(e.valueMs,e.locale,e.presetLabels),t[0]=e.expression,t[1]=e.kind,t[2]=e.labels,t[3]=e.locale,t[4]=e.nextRun,t[5]=e.presetLabels,t[6]=e.timezone,t[7]=e.valueMs,t[8]=n):n=t[8];let r=n,i;return t[9]!==e.className||t[10]!==r?(i=(0,Z.jsx)(`span`,{className:e.className,children:r}),t[9]=e.className,t[10]=r,t[11]=i):i=t[11],i}function un(e){let t=(0,X.c)(24),{a:n,data:r,busy:o,cronLoading:s,agentCronJobs:c,onSetCronJobAgent:l}=e,u=i(fn),d;t[0]===u?d=t[1]:(d=a(u),t[0]=u,t[1]=d);let f=d,p=u===`zh`?`zh-CN`:`en-US`,m=f.cron.scheduleBadge,h;t[2]!==n.cronHint||t[3]!==n.cronTitle?(h=(0,Z.jsx)(Rt,{className:`shrink-0`,icon:Je,title:n.cronTitle,subtitle:n.cronHint}),t[2]=n.cronHint,t[3]=n.cronTitle,t[4]=h):h=t[4];let g;t[5]!==n.cronAgentClear||t[6]!==n.cronAgentDefault||t[7]!==n.cronColAgent||t[8]!==n.cronColMessage||t[9]!==n.cronColSchedule||t[10]!==n.cronColSession||t[11]!==n.cronLoading||t[12]!==n.cronNone||t[13]!==c||t[14]!==o||t[15]!==s||t[16]!==r||t[17]!==p||t[18]!==l||t[19]!==m?(g=s?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.cronLoading}):c.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.cronNone}):(0,Z.jsx)(`div`,{className:`overflow-x-auto`,children:(0,Z.jsxs)(`table`,{className:`w-full min-w-[32rem] border-collapse text-left text-sm`,children:[(0,Z.jsx)(`thead`,{children:(0,Z.jsxs)(`tr`,{className:`border-b border-edge text-fg-muted`,children:[(0,Z.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:n.cronColSchedule}),(0,Z.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:n.cronColMessage}),(0,Z.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:n.cronColSession}),(0,Z.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:n.cronColAgent})]})}),(0,Z.jsx)(`tbody`,{children:c.map(e=>{let t=!e.agentId?.trim(),i=t?``:e.agentId.trim().toLowerCase();return(0,Z.jsxs)(`tr`,{className:`border-b border-edge-subtle`,children:[(0,Z.jsx)(`td`,{className:`py-2 pr-3`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Z.jsx)(ln,{kind:`cron`,expression:e.schedule,locale:p,labels:m,timezone:e.timezone,nextRun:e.next_run,className:`text-sm font-medium text-fg`}),(0,Z.jsx)(`span`,{className:`truncate font-mono text-[0.65rem] text-fg-subtle`,title:e.schedule,children:e.schedule})]})}),(0,Z.jsx)(`td`,{className:`max-w-[12rem] truncate py-2 pr-3 text-xs`,title:qt(e),children:qt(e)}),(0,Z.jsx)(`td`,{className:`py-2 pr-3 text-xs`,children:e.sessionTarget??`main`}),(0,Z.jsx)(`td`,{className:`py-2 pr-3`,children:(0,Z.jsxs)(`select`,{className:Y(nn(),`min-w-[8rem] py-1 text-xs`),value:i,disabled:o||e.sessionTarget!==`isolated`,onChange:t=>void l(e,t.target.value),children:[(0,Z.jsx)(`option`,{value:``,children:t?n.cronAgentDefault:n.cronAgentClear}),r.agents.map(dn)]})})]},e.id)})})]})}),t[5]=n.cronAgentClear,t[6]=n.cronAgentDefault,t[7]=n.cronColAgent,t[8]=n.cronColMessage,t[9]=n.cronColSchedule,t[10]=n.cronColSession,t[11]=n.cronLoading,t[12]=n.cronNone,t[13]=c,t[14]=o,t[15]=s,t[16]=r,t[17]=p,t[18]=l,t[19]=m,t[20]=g):g=t[20];let _;return t[21]!==h||t[22]!==g?(_=(0,Z.jsxs)(zt,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[h,g]}),t[21]=h,t[22]=g,t[23]=_):_=t[23],_}function dn(e){return(0,Z.jsx)(`option`,{value:e.id,children:e.id},e.id)}function fn(e){return e.language}function pn(e){let t=(0,X.c)(27),{a:n,filesLoading:r,files:i,activeFile:a,setActiveFile:o,filesViewMode:s,setFilesViewMode:c,fileDraft:l,setFileDraft:u,fileSaving:d,profileFileLoading:f,profileEditorNonce:p}=e,m=h(mn),g;t[0]===n.filesHint?g=t[1]:(g=(0,Z.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:n.filesHint}),t[0]=n.filesHint,t[1]=g);let _;t[2]!==n.filesAutoSaveHint||t[3]!==n.filesEmpty||t[4]!==n.filesLoading||t[5]!==n.filesMarkdownEdit||t[6]!==n.filesMarkdownPreview||t[7]!==n.filesSavingStatus||t[8]!==n.missing||t[9]!==n.navCoreFiles||t[10]!==n.pickFile||t[11]!==a||t[12]!==l||t[13]!==d||t[14]!==i||t[15]!==r||t[16]!==s||t[17]!==m||t[18]!==p||t[19]!==f||t[20]!==o||t[21]!==u||t[22]!==c?(_=r?(0,Z.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:n.filesLoading}):i?(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden`,children:[(0,Z.jsx)(`nav`,{className:`flex shrink-0 flex-row flex-wrap gap-x-0.5 gap-y-0 border-b border-edge-subtle`,"aria-label":n.navCoreFiles,children:i.files.map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:Y(`-mb-px shrink-0 border-b-2 border-transparent px-3 py-2 text-left font-mono text-xs whitespace-nowrap transition-colors`,Lt.press,a===e.name?`border-accent text-fg`:`text-fg-muted hover:border-edge-subtle hover:text-fg`,e.missing&&`opacity-60`),onClick:()=>o(e.name),children:[e.name,e.missing?` (${n.missing})`:``]},e.name))}),(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col gap-2 overflow-hidden`,children:a?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`inline-flex rounded-lg border border-edge bg-surface-panel p-0.5`,role:`group`,"aria-label":`${n.filesMarkdownEdit} / ${n.filesMarkdownPreview}`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:Y(`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium`,Lt.press,s===`edit`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`),onClick:()=>c(`edit`),children:[(0,Z.jsx)(jt,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),n.filesMarkdownEdit]}),(0,Z.jsxs)(`button`,{type:`button`,className:Y(`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium`,Lt.press,s===`preview`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`),onClick:()=>c(`preview`),children:[(0,Z.jsx)(E,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),n.filesMarkdownPreview]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[d?(0,Z.jsx)(`span`,{children:n.filesSavingStatus}):null,(0,Z.jsx)(`span`,{children:n.filesAutoSaveHint})]})]}),s===`edit`?(0,Z.jsx)(`div`,{className:Y(nn(),`flex min-h-0 flex-1 flex-col overflow-hidden p-0`,f&&`pointer-events-none opacity-60`),children:(0,Z.jsx)(be,{initialContent:l,onChange:u,isDark:m,className:`min-h-0 flex-1`},`${a??`file`}-${p}`)}):(0,Z.jsx)(`div`,{className:Y(nn(),`min-h-0 flex-1 overflow-y-auto text-sm`,f&&`pointer-events-none opacity-60`),children:(0,Z.jsx)(T,{content:l,className:`text-sm`})})]}):(0,Z.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:n.pickFile})})]}):(0,Z.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:n.filesEmpty}),t[2]=n.filesAutoSaveHint,t[3]=n.filesEmpty,t[4]=n.filesLoading,t[5]=n.filesMarkdownEdit,t[6]=n.filesMarkdownPreview,t[7]=n.filesSavingStatus,t[8]=n.missing,t[9]=n.navCoreFiles,t[10]=n.pickFile,t[11]=a,t[12]=l,t[13]=d,t[14]=i,t[15]=r,t[16]=s,t[17]=m,t[18]=p,t[19]=f,t[20]=o,t[21]=u,t[22]=c,t[23]=_):_=t[23];let v;return t[24]!==g||t[25]!==_?(v=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-hidden`,children:[g,_]}),t[24]=g,t[25]=_,t[26]=v):v=t[26],v}function mn(e){return e.resolved===`dark`}var Q=e(t(),1);function hn(e){let t=(0,X.c)(37),{value:n,onChange:r,disabled:i,wd:a,placeholder:o,inputClassName:s,trailing:c}=e,l;t[0]!==r||t[1]!==n?(l={initialPath:n,onPicked:r},t[0]=r,t[1]=n,t[2]=l):l=t[2];let u=Pe(l),d;t[3]===n?d=t[4]:(d=n.trim(),t[3]=n,t[4]=d);let f=d,p=f?`${f}\n${a.chooseFolder}`:`${o??a.notSet}\n${a.selectWorkingDirectory}`,m;t[5]===s?m=t[6]:(m=Y(`min-w-0 flex-1`,s),t[5]=s,t[6]=m);let h=i||u.picking,g;t[7]===r?g=t[8]:(g=e=>void r(e.target.value),t[7]=r,t[8]=g);let _=o??a.pathInputPlaceholder,v;t[9]!==m||t[10]!==h||t[11]!==g||t[12]!==_||t[13]!==n?(v=(0,Z.jsx)(`input`,{type:`text`,className:m,value:n,disabled:h,onChange:g,placeholder:_,autoComplete:`off`,spellCheck:!1}),t[9]=m,t[10]=h,t[11]=g,t[12]=_,t[13]=n,t[14]=v):v=t[14];let y=i||u.picking,b;t[15]!==p||t[16]!==u.pick||t[17]!==y||t[18]!==n||t[19]!==a.selectWorkingDirectory?(b=(0,Z.jsx)(tt,{compact:!0,value:n,onPick:u.pick,disabled:y,title:p,"aria-label":a.selectWorkingDirectory}),t[15]=p,t[16]=u.pick,t[17]=y,t[18]=n,t[19]=a.selectWorkingDirectory,t[20]=b):b=t[20];let x;t[21]!==b||t[22]!==c?(x=(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[b,c]}),t[21]=b,t[22]=c,t[23]=x):x=t[23];let S;t[24]!==x||t[25]!==v?(S=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[v,x]}),t[24]=x,t[25]=v,t[26]=S):S=t[26];let C;t[27]!==u.confirmPick||t[28]!==u.hasNativePicker||t[29]!==u.modalOpen||t[30]!==u.setModalOpen||t[31]!==f||t[32]!==a?(C=u.hasNativePicker?null:(0,Z.jsx)(qe,{open:u.modalOpen,onOpenChange:u.setModalOpen,initialAbsolutePath:f||void 0,onConfirm:u.confirmPick,wd:a}),t[27]=u.confirmPick,t[28]=u.hasNativePicker,t[29]=u.modalOpen,t[30]=u.setModalOpen,t[31]=f,t[32]=a,t[33]=C):C=t[33];let w;return t[34]!==S||t[35]!==C?(w=(0,Z.jsxs)(Z.Fragment,{children:[S,C]}),t[34]=S,t[35]=C,t[36]=w):w=t[36],w}function gn(e){let t=(0,X.c)(19),{label:n,mode:r,value:i,inheritedFrom:a,inheritLabel:o,overrideLabel:s}=e,c;t[0]===n?c=t[1]:(c=(0,Z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:n}),t[0]=n,t[1]=c);let l=i||`—`,u;t[2]===l?u=t[3]:(u=(0,Z.jsx)(`p`,{className:`mt-1 truncate text-sm font-medium text-fg`,children:l}),t[2]=l,t[3]=u);let d;t[4]!==a||t[5]!==r?(d=r===`inherit`&&a?(0,Z.jsx)(`p`,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:a}):null,t[4]=a,t[5]=r,t[6]=d):d=t[6];let f;t[7]!==c||t[8]!==u||t[9]!==d?(f=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[c,u,d]}),t[7]=c,t[8]=u,t[9]=d,t[10]=f):f=t[10];let p=r===`inherit`?`bg-surface-hover text-fg-muted`:`bg-accent-soft text-accent-fg`,m;t[11]===p?m=t[12]:(m=Y(`mt-2 inline-flex shrink-0 self-start rounded-full px-2.5 py-0.5 text-xs font-medium sm:mt-0`,p),t[11]=p,t[12]=m);let h=r===`inherit`?o:s,g;t[13]!==m||t[14]!==h?(g=(0,Z.jsx)(`span`,{className:m,children:h}),t[13]=m,t[14]=h,t[15]=g):g=t[15];let _;return t[16]!==f||t[17]!==g?(_=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-xl border border-edge-subtle bg-surface-panel px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[f,g]}),t[16]=f,t[17]=g,t[18]=_):_=t[18],_}function _n(e){let t=(0,X.c)(40),{a:n,defaultModel:r,defaultWorkspace:i,agentModel:a,agentWorkspace:o,settingsPath:s}=e,c=s===void 0?`/settings/agent-defaults`:s,l=n.inheritance,u;t[0]===a?u=t[1]:(u=a.trim(),t[0]=a,t[1]=u);let d=!u,f;t[2]!==o||t[3]!==i?(f=!o.trim()||i.trim().length>0&&o.trim()===i.trim(),t[2]=o,t[3]=i,t[4]=f):f=t[4];let p=f,m=d?r||l.unset:a,h=p?i||l.unset:o,g;t[5]!==l.editDefaultsLink||t[6]!==c?(g=(0,Z.jsx)(lt,{to:c,className:`text-xs font-medium text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:l.editDefaultsLink}),t[5]=l.editDefaultsLink,t[6]=c,t[7]=g):g=t[7];let _;t[8]!==l.subtitle||t[9]!==l.title||t[10]!==g?(_=(0,Z.jsx)(Rt,{icon:ut,title:l.title,subtitle:l.subtitle,trailing:g}),t[8]=l.subtitle,t[9]=l.title,t[10]=g,t[11]=_):_=t[11];let v=d?`inherit`:`override`,y;t[12]!==r||t[13]!==l.inheritsValue||t[14]!==d?(y=d&&r?l.inheritsValue.replace(`{{value}}`,r):void 0,t[12]=r,t[13]=l.inheritsValue,t[14]=d,t[15]=y):y=t[15];let b;t[16]!==m||t[17]!==l.badgeInherit||t[18]!==l.badgeOverride||t[19]!==l.modelLabel||t[20]!==v||t[21]!==y?(b=(0,Z.jsx)(gn,{label:l.modelLabel,mode:v,value:m,inheritedFrom:y,inheritLabel:l.badgeInherit,overrideLabel:l.badgeOverride}),t[16]=m,t[17]=l.badgeInherit,t[18]=l.badgeOverride,t[19]=l.modelLabel,t[20]=v,t[21]=y,t[22]=b):b=t[22];let x=p?`inherit`:`override`,S;t[23]!==i||t[24]!==l.inheritsValue||t[25]!==p?(S=p&&i?l.inheritsValue.replace(`{{value}}`,i):void 0,t[23]=i,t[24]=l.inheritsValue,t[25]=p,t[26]=S):S=t[26];let C;t[27]!==h||t[28]!==l.badgeInherit||t[29]!==l.badgeOverride||t[30]!==l.workspaceLabel||t[31]!==x||t[32]!==S?(C=(0,Z.jsx)(gn,{label:l.workspaceLabel,mode:x,value:h,inheritedFrom:S,inheritLabel:l.badgeInherit,overrideLabel:l.badgeOverride}),t[27]=h,t[28]=l.badgeInherit,t[29]=l.badgeOverride,t[30]=l.workspaceLabel,t[31]=x,t[32]=S,t[33]=C):C=t[33];let w;t[34]!==C||t[35]!==b?(w=(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[b,C]}),t[34]=C,t[35]=b,t[36]=w):w=t[36];let T;return t[37]!==w||t[38]!==_?(T=(0,Z.jsxs)(zt,{children:[_,w]}),t[37]=w,t[38]=_,t[39]=T):T=t[39],T}function vn(e,t){switch(e){case`adventurer`:return t.avatarStyleAdventurer;case`bottts`:return t.avatarStyleRobot;case`lorelei`:return t.avatarStyleLorelei;case`thumbs`:return t.avatarStyleThumbs;case`fun-emoji`:return t.avatarStyleFunEmoji;default:return e}}function yn(e){let{agentId:t,value:n,onChange:r,a:i,id:a}=e,o=(0,Q.useRef)(null),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(!1),p=(0,Q.useMemo)(()=>{let e=_t(n.trim());return e&&st(e.styleId)?e.styleId:oe[0]??`adventurer`},[n]),m=(0,Q.useCallback)(async(e,n)=>{try{await se(t)}catch{}r(J(e,n)),f(!1)},[t,r]),h=(0,Q.useCallback)(async e=>{let n=e.target.files?.[0];if(e.target.value=``,n){u(null),c(!0);try{await L(t,n),r(x)}catch(e){let t=e instanceof Error?e.message:``;u(t===`avatar_too_large`?i.avatarTooLarge:t===`unsupported_image_type`||t===`empty_file`?i.avatarInvalidImage:i.avatarUploadFailed)}finally{c(!1)}}},[i,t,r]),g=(e,t)=>{let r=_t(n.trim());return!!(r&&r.styleId===e&&r.seed===t)};return(0,Z.jsxs)(`div`,{...a?{id:a}:{},className:`flex flex-col gap-3 sm:col-span-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:i.avatarPickerTitle}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`input`,{ref:o,type:`file`,accept:`image/png,image/jpeg,image/webp,.png,.jpg,.jpeg,.webp`,className:`hidden`,onChange:e=>void h(e)}),(0,Z.jsxs)(Ct,{type:`button`,variant:`secondary`,className:`gap-1.5 px-2.5 py-1.5 text-xs`,disabled:s,onClick:()=>o.current?.click(),children:[(0,Z.jsx)(Et,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),s?i.avatarUploading:i.avatarUploadCustom]})]})]}),l?(0,Z.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:l}):null,(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:oe.map(e=>(0,Z.jsx)(`button`,{type:`button`,onClick:()=>void m(e,Oe[0]??t),className:Y(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,Lt.press,p===e?`border-fg bg-fg text-surface-base`:`border-edge-subtle bg-surface-panel text-fg hover:border-edge`),children:vn(e,i)},e))}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel/50 p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[Oe.map(e=>(0,Z.jsx)(`button`,{type:`button`,title:e,onClick:()=>void m(p,e),className:Y(`flex size-12 shrink-0 items-center justify-center rounded-full border-2 transition-colors`,Lt.press,g(p,e)?`border-accent ring-2 ring-accent/30`:`border-transparent hover:border-edge`),children:(0,Z.jsx)(`img`,{src:St(p,e,96),alt:``,width:44,height:44,className:`size-11 rounded-full object-cover`,draggable:!1})},e)),(0,Z.jsxs)(te,{open:d,onOpenChange:f,children:[(0,Z.jsx)(ie,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:Y(`flex size-12 shrink-0 items-center justify-center rounded-xl border border-edge-subtle bg-surface-base text-xs font-medium text-fg-muted hover:border-edge hover:text-fg`,Lt.press),children:i.avatarMore})}),(0,Z.jsx)(H,{children:(0,Z.jsxs)($e,{className:`z-[80] max-h-72 w-[min(22rem,calc(100vw-2rem))] overflow-y-auto rounded-xl border border-edge-subtle bg-surface-panel p-3 shadow-lg`,sideOffset:6,align:`end`,children:[(0,Z.jsx)(`p`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:vn(p,i)}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:we.map(e=>(0,Z.jsx)(`button`,{type:`button`,title:e,onClick:()=>void m(p,e),className:Y(`flex size-11 shrink-0 items-center justify-center rounded-full border-2 transition-colors`,Lt.press,g(p,e)?`border-accent ring-2 ring-accent/30`:`border-transparent hover:border-edge`),children:(0,Z.jsx)(`img`,{src:St(p,e,88),alt:``,width:40,height:40,className:`size-10 rounded-full object-cover`,draggable:!1})},e))})]})})]})]}),(0,Z.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t border-edge-subtle pt-3`,children:[(0,Z.jsx)(`span`,{className:`text-xs text-fg-muted`,children:i.personaAvatar}),(0,Z.jsx)(Te,{agentId:t,avatar:n,size:40}),n.trim()&&!_t(n.trim())&&n.trim()!==`xopc:custom`?(0,Z.jsx)(`span`,{className:`truncate font-mono text-[10px] text-fg-muted`,title:n,children:n}):null]})]})]})}var bn={name:``,creature:``,emoji:``,avatar:``};function xn(e){let t={...bn};if(!e.trim())return t;let n={name:`name`,creature:`creature`,emoji:`emoji`,avatar:`avatar`};for(let r of e.split(`
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{i,o as a,t as o}from"./url-Dd8Q7kZZ.js";import{i as s}from"./vendor-swr-BIWyz7Rc.js";import{a as c,i as l,n as u,o as d,r as f,s as p,t as m}from"./dist-BTWC-BTN.js";import{i as h}from"./theme-store-CZOh1nT3.js";import{a as g,n as _,t as v}from"./fetch-DRqwef_Q.js";import{$i as y,$n as b,$t as x,B as S,Bi as C,Bn as w,Bt as T,Ci as E,Di as D,Dr as O,F as k,G as A,Gi as j,Gn as M,Gt as N,H as P,Hr as F,Ht as I,I as ee,J as L,K as R,L as z,Li as B,Mi as V,Mn as H,Mr as U,Ni as W,Nn as te,Nr as ne,On as G,Or as K,P as q,Pi as re,Pn as ie,Pr as ae,Qt as oe,R as se,Ri as ce,Rr as le,Rt as ue,Sr as de,Ti as fe,Tr as pe,U as me,Un as he,Ur as ge,V as _e,Vi as ve,Vr as ye,Vt as be,W as xe,Wr as Se,Xi as Ce,Xt as we,Yt as Te,Zn as Ee,Zr as De,Zt as Oe,_i as ke,_n as Ae,a as je,ar as Me,br as Ne,c as Pe,cr as Fe,d as Ie,da as Le,dr as Re,ei as ze,en as J,er as Be,f as Ve,fi as He,fr as Ue,g as We,gn as Ge,h as Ke,i as qe,ia as Je,ii as Ye,in as Xe,ir as Ze,ji as Qe,jn as $e,ki as et,l as tt,la as nt,lr as rt,m as it,mi as at,mr as ot,nn as st,nr as Y,o as ct,oa as lt,oi as ut,or as dt,p as ft,pr as pt,q as mt,qi as ht,qr as gt,rn as _t,rr as vt,s as yt,si as bt,t as xt,tn as St,tr as Ct,u as wt,ua as Tt,ur as Et,v as Dt,vr as Ot,wr as kt,xi as At,xr as jt,y as Mt,yi as Nt,z as Pt,zi as Ft,zr as It,zt as Lt}from"./index-Cu7bKuUi.js";import{n as Rt,t as zt}from"./settings-form-section-DiqqVs6m.js";import{c as Bt,f as Vt,n as Ht,t as Ut}from"./cron-dreaming-jobs-DueM3rBz.js";import{i as Wt,l as Gt,m as Kt,n as qt,u as Jt}from"./cron-api-0h_QT8U3.js";var X=n(),Z=r();function Yt(e){let t=(0,X.c)(40),{open:n,onOpenChange:r,busy:i,deletePurge:a,deleteTarget:o,deleteConfirmText:s,onDeleteConfirmTextChange:m,onConfirm:h,onCancel:g,a:_}=e,v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(l,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),t[0]=v):v=t[0];let y;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(y=Y(`fixed left-1/2 top-1/2 z-[81] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-panel p-4 shadow-popover`,`dark:border-edge`),t[1]=y):y=t[1];let b=a?_.purgeDisk:_.removeFromConfig,x;t[2]===b?x=t[3]:(x=(0,Z.jsx)(p,{className:`text-base font-semibold text-fg`,children:b}),t[2]=b,t[3]=x);let S=a?_.confirmDeletePurge:_.confirmDelete,C;t[4]===S?C=t[5]:(C=(0,Z.jsx)(f,{className:`mt-2 whitespace-pre-wrap text-sm leading-relaxed text-fg-muted`,children:S}),t[4]=S,t[5]=C);let w;t[6]!==_.purgeConfirmHint||t[7]!==_.purgeConfirmLabel||t[8]!==_.purgeConfirmPlaceholder||t[9]!==s||t[10]!==a||t[11]!==o||t[12]!==m?(w=a&&o?(0,Z.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,Z.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-fg`,htmlFor:`agent-delete-confirm`,children:_.purgeConfirmLabel}),(0,Z.jsx)(`input`,{id:`agent-delete-confirm`,type:`text`,autoComplete:`off`,spellCheck:!1,className:Y(`w-full rounded-md border border-edge bg-surface-panel px-3 py-1.5 font-mono text-xs text-fg`,`placeholder:text-fg-subtle`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`dark:border-edge`),placeholder:_.purgeConfirmPlaceholder.replace(`{{agentId}}`,o.id),value:s,onChange:e=>m(e.target.value)}),(0,Z.jsx)(`p`,{className:`pt-0.5 text-xs text-fg-muted`,children:_.purgeConfirmHint.replace(`{{agentId}}`,o.id)})]}):null,t[6]=_.purgeConfirmHint,t[7]=_.purgeConfirmLabel,t[8]=_.purgeConfirmPlaceholder,t[9]=s,t[10]=a,t[11]=o,t[12]=m,t[13]=w):w=t[13];let T;t[14]!==_.createModalCancel||t[15]!==i||t[16]!==g?(T=(0,Z.jsx)(Ct,{type:`button`,variant:`ghost`,disabled:i,onClick:g,children:_.createModalCancel}),t[14]=_.createModalCancel,t[15]=i,t[16]=g,t[17]=T):T=t[17];let E=a?`border-red-200 text-red-700 hover:bg-red-50 dark:border-red-900/60 dark:text-red-300 dark:hover:bg-red-950/40`:void 0,D;t[18]!==i||t[19]!==s||t[20]!==a||t[21]!==o?(D=i||!o||a&&s.trim().toLowerCase()!==o.id.toLowerCase(),t[18]=i,t[19]=s,t[20]=a,t[21]=o,t[22]=D):D=t[22];let O=a?_.purgeDisk:_.removeFromConfig,k;t[23]!==h||t[24]!==D||t[25]!==O||t[26]!==E?(k=(0,Z.jsx)(Ct,{type:`button`,variant:`secondary`,className:E,disabled:D,onClick:h,children:O}),t[23]=h,t[24]=D,t[25]=O,t[26]=E,t[27]=k):k=t[27];let A;t[28]!==k||t[29]!==T?(A=(0,Z.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-end gap-2 border-t border-edge-subtle/60 pt-3`,children:[T,k]}),t[28]=k,t[29]=T,t[30]=A):A=t[30];let j;t[31]!==A||t[32]!==x||t[33]!==C||t[34]!==w?(j=(0,Z.jsxs)(c,{children:[v,(0,Z.jsxs)(u,{className:y,onOpenAutoFocus:Xt,children:[x,C,w,A]})]}),t[31]=A,t[32]=x,t[33]=C,t[34]=w,t[35]=j):j=t[35];let M;return t[36]!==r||t[37]!==n||t[38]!==j?(M=(0,Z.jsx)(d,{open:n,onOpenChange:r,children:j}),t[36]=r,t[37]=n,t[38]=j,t[39]=M):M=t[39],M}function Xt(e){return e.preventDefault()}var Zt=[{id:`overview`,labelKey:`navIdentity`,icon:Fe},{id:`profile`,labelKey:`navProfile`,icon:Ft},{id:`tools`,labelKey:`navTools`,icon:Me},{id:`skills`,labelKey:`navSkills`,icon:It},{id:`files`,labelKey:`navCoreFiles`,icon:At}],Qt=[{id:`channels`,labelKey:`tabChannels`,icon:F},{id:`cron`,labelKey:`tabCron`,icon:re}];function $t(e){let t=(0,X.c)(20),{a:n,panel:r,onPanelChange:i}=e,a;t[0]!==i||t[1]!==r?(a=(e,t,n)=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>i(e),className:Y(`flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-left text-sm font-medium transition-colors`,Lt.press,r===e?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:[(0,Z.jsx)(n,{className:`size-4 shrink-0 opacity-90`,strokeWidth:2,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:t})]},e),t[0]=i,t[1]=r,t[2]=a):a=t[2];let o=a,s=n.editorNavAria,c;t[3]!==n||t[4]!==o?(c=Zt.map(e=>{let{id:t,labelKey:r,icon:i}=e;return o(t,n[r],i)}),t[3]=n,t[4]=o,t[5]=c):c=t[5];let l;t[6]===c?l=t[7]:(l=(0,Z.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:c}),t[6]=c,t[7]=l);let u;t[8]===n.navAdvanced?u=t[9]:(u=(0,Z.jsx)(`p`,{className:`mt-4 px-3 text-[10px] font-semibold uppercase tracking-wide text-fg-subtle`,children:n.navAdvanced}),t[8]=n.navAdvanced,t[9]=u);let d;t[10]!==n||t[11]!==o?(d=Qt.map(e=>{let{id:t,labelKey:r,icon:i}=e;return o(t,n[r],i)}),t[10]=n,t[11]=o,t[12]=d):d=t[12];let f;t[13]===d?f=t[14]:(f=(0,Z.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:d}),t[13]=d,t[14]=f);let p;return t[15]!==n.editorNavAria||t[16]!==l||t[17]!==u||t[18]!==f?(p=(0,Z.jsxs)(`nav`,{className:`flex w-full flex-col gap-1`,"aria-label":s,children:[l,u,f]}),t[15]=n.editorNavAria,t[16]=l,t[17]=u,t[18]=f,t[19]=p):p=t[19],p}function en(e){let t=(0,X.c)(49),{open:n,onOpenChange:r,a:i,title:a,subtitle:o,panel:s,onPanelChange:h,onFooterSave:g,footerSaveDisabled:_,footerSavedFlash:v,busy:y,children:b}=e,x;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Z.jsx)(l,{className:Y(`xopc-dialog-overlay fixed inset-0 bg-scrim`,We)}),t[0]=x):x=t[0];let S;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(S=Y(`xopc-dialog-content fixed flex flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover dark:border-edge`,Ke,`inset-4 h-[calc(100dvh-2rem)] max-h-[calc(100dvh-2rem)] min-h-0`,`sm:inset-auto sm:left-1/2 sm:top-1/2 sm:h-[min(88vh,48rem)] sm:max-h-[min(88vh,48rem)] sm:min-h-[32rem] sm:w-[min(100%-2rem,58rem)] sm:-translate-x-1/2 sm:-translate-y-1/2`),t[1]=S):S=t[1];let C;t[2]===a?C=t[3]:(C=(0,Z.jsx)(p,{className:`text-base font-semibold leading-snug text-fg`,children:a}),t[2]=a,t[3]=C);let w;t[4]===o?w=t[5]:(w=(0,Z.jsx)(f,{className:`mt-1 font-mono text-xs text-fg-muted`,children:o}),t[4]=o,t[5]=w);let T;t[6]!==C||t[7]!==w?(T=(0,Z.jsxs)(`div`,{className:`min-w-0 pr-2`,children:[C,w]}),t[6]=C,t[7]=w,t[8]=T):T=t[8];let E;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(E=Y(ue,`shrink-0 p-1.5 hover:bg-surface-base`),t[9]=E):E=t[9];let D;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Z.jsx)(Ze,{className:`size-4`,"aria-hidden":!0}),t[10]=D):D=t[10];let O;t[11]===i.closeDialogAria?O=t[12]:(O=(0,Z.jsx)(m,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:E,"aria-label":i.closeDialogAria,children:D})}),t[11]=i.closeDialogAria,t[12]=O);let k;t[13]!==T||t[14]!==O?(k=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-2 border-b border-edge-subtle px-4 pb-3 pt-4 dark:border-edge`,children:[T,O]}),t[13]=T,t[14]=O,t[15]=k):k=t[15];let A;t[16]!==i||t[17]!==h||t[18]!==s?(A=(0,Z.jsx)(`div`,{className:`shrink-0 border-b border-edge-subtle px-4 py-3 dark:border-edge sm:flex sm:w-56 sm:shrink-0 sm:flex-col sm:overflow-y-auto sm:border-b-0 sm:border-r sm:px-0 sm:py-4 sm:pl-4 sm:pr-3`,children:(0,Z.jsx)($t,{a:i,panel:s,onPanelChange:h})}),t[16]=i,t[17]=h,t[18]=s,t[19]=A):A=t[19];let j;t[20]===b?j=t[21]:(j=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden p-4 sm:pl-2 sm:pr-5`,children:b}),t[20]=b,t[21]=j);let M;t[22]!==i.footerSaveNotApplicable||t[23]!==i.personaSaved||t[24]!==_||t[25]!==v?(M=v?(0,Z.jsxs)(`p`,{className:`order-2 text-center text-xs font-medium text-green-600 sm:order-1 sm:mr-auto sm:text-left dark:text-green-400`,children:[`✓ `,i.personaSaved]}):_?(0,Z.jsx)(`p`,{className:`order-2 text-center text-xs text-fg-muted sm:order-1 sm:mr-auto sm:text-left`,children:i.footerSaveNotApplicable}):null,t[22]=i.footerSaveNotApplicable,t[23]=i.personaSaved,t[24]=_,t[25]=v,t[26]=M):M=t[26];let N=y||_,P;t[27]===g?P=t[28]:(P=()=>void g(),t[27]=g,t[28]=P);let F;t[29]!==i.save||t[30]!==N||t[31]!==P?(F=(0,Z.jsx)(Ct,{type:`button`,className:`order-1 w-full sm:order-2 sm:w-auto`,disabled:N,onClick:P,children:i.save}),t[29]=i.save,t[30]=N,t[31]=P,t[32]=F):F=t[32];let I;t[33]!==M||t[34]!==F?(I=(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-1 border-t border-edge-subtle px-4 py-3 dark:border-edge sm:flex-row sm:items-center sm:justify-end sm:gap-3`,children:[M,F]}),t[33]=M,t[34]=F,t[35]=I):I=t[35];let ee;t[36]!==j||t[37]!==I?(ee=(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[j,I]}),t[36]=j,t[37]=I,t[38]=ee):ee=t[38];let L;t[39]!==ee||t[40]!==A?(L=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col sm:flex-row sm:overflow-hidden`,children:[A,ee]}),t[39]=ee,t[40]=A,t[41]=L):L=t[41];let R;t[42]!==L||t[43]!==k?(R=(0,Z.jsxs)(c,{children:[x,(0,Z.jsx)(u,{className:S,onOpenAutoFocus:tn,children:(0,Z.jsxs)(Ie,{layer:`modal`,children:[k,L]})})]}),t[42]=L,t[43]=k,t[44]=R):R=t[44];let z;return t[45]!==r||t[46]!==n||t[47]!==R?(z=(0,Z.jsx)(d,{open:n,onOpenChange:r,children:R}),t[45]=r,t[46]=n,t[47]=R,t[48]=z):z=t[48],z}function tn(e){return e.preventDefault()}function nn(){return Y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Be,`dark:border-edge`)}function rn(e,t,n){let r=e.agentId?.trim().toLowerCase();return r?r===t.toLowerCase():t.toLowerCase()===n.toLowerCase()}function an(e){return[e.channel,e.accountId,e.peerKind,e.peerId].filter(e=>typeof e==`string`&&e.length>0).join(` · `)||e.channel}function on(e,t,n,r){let i=e.trim(),a=t.trim();if(a)return{channel:i,peerId:a};if(n!=null){let e=r[n];if(!e)return{channel:i};let t={channel:i};e.accountId?.trim()&&(t.accountId=e.accountId.trim()),e.peerKind?.trim()&&(t.peerKind=e.peerKind.trim());let a=e.peerId?.trim()||e.chatId?.trim();return a&&(t.peerId=a),t}return{channel:i}}var sn=Y(b,`w-full text-xs sm:w-auto sm:min-w-[11rem] sm:max-w-[17rem] sm:shrink-0`);function cn(e){let t=(0,X.c)(62),{a:n,busy:r,bindingsLoading:i,agentBindings:a,onRemoveBinding:o,onAddBinding:s,channelStatuses:c,channelsStatusLoading:l,useManualChannel:u,newBindChannel:d,setNewBindChannel:f,bindSessionChats:p,sessionsLoading:m,newBindSessionIdx:h,setNewBindSessionIdx:g,newBindCustomPeer:_,setNewBindCustomPeer:v,onRefreshSessions:y,lastActiveLabels:b,selectRecipient:x}=e,S=!l&&(u||c.length>0),C;t[0]!==n.channelsHint||t[1]!==n.channelsTitle?(C=(0,Z.jsx)(Rt,{className:`shrink-0`,icon:ut,title:n.channelsTitle,subtitle:n.channelsHint}),t[0]=n.channelsHint,t[1]=n.channelsTitle,t[2]=C):C=t[2];let w;t[3]!==n.channelsLoading||t[4]!==n.channelsNone||t[5]!==n.removeBinding||t[6]!==a||t[7]!==i||t[8]!==r||t[9]!==o?(w=i?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.channelsLoading}):a.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.channelsNone}):(0,Z.jsx)(`ul`,{className:`flex flex-col gap-2 text-sm`,children:a.map(e=>(0,Z.jsxs)(`li`,{className:`flex flex-wrap items-center justify-between gap-2 rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-xs`,children:an(e.match)}),(0,Z.jsx)(Ct,{type:`button`,variant:`secondary`,disabled:r,onClick:()=>void o(e),children:n.removeBinding})]},`${e.match.channel}-${an(e.match)}`))}),t[3]=n.channelsLoading,t[4]=n.channelsNone,t[5]=n.removeBinding,t[6]=a,t[7]=i,t[8]=r,t[9]=o,t[10]=w):w=t[10];let T;t[11]!==n.channelLabel||t[12]!==n.channelsDisabledSuffix||t[13]!==n.channelsLoadingChannels||t[14]!==n.channelsManualChannelHint||t[15]!==c||t[16]!==l||t[17]!==d||t[18]!==f||t[19]!==v||t[20]!==g||t[21]!==u?(T=l?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.channelsLoadingChannels}):u?(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:n.channelLabel}),(0,Z.jsx)(`input`,{className:nn(),value:d,onChange:e=>f(e.target.value),placeholder:`telegram`,autoComplete:`off`}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.channelsManualChannelHint})]}):(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:n.channelLabel}),(0,Z.jsx)(`select`,{className:Y(nn(),`py-2`),value:d,onChange:e=>{f(e.target.value),g(null),v(``)},children:c.map(e=>(0,Z.jsxs)(`option`,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:n.channelsDisabledSuffix]},e.name))})]}),t[11]=n.channelLabel,t[12]=n.channelsDisabledSuffix,t[13]=n.channelsLoadingChannels,t[14]=n.channelsManualChannelHint,t[15]=c,t[16]=l,t[17]=d,t[18]=f,t[19]=v,t[20]=g,t[21]=u,t[22]=T):T=t[22];let E;t[23]!==n.channelsCustomPeerHint||t[24]!==n.channelsCustomPeerPlaceholder||t[25]!==n.channelsLoadingSessions||t[26]!==n.channelsNoSessionsHint||t[27]!==n.channelsPeerAny||t[28]!==n.channelsPeerFromSessions||t[29]!==n.channelsRefreshSessions||t[30]!==n.channelsRefreshSessionsHint||t[31]!==n.channelsSessionLabel||t[32]!==n.peerIdLabel||t[33]!==p||t[34]!==r||t[35]!==b||t[36]!==d||t[37]!==_||t[38]!==h||t[39]!==y||t[40]!==x||t[41]!==m||t[42]!==v||t[43]!==g||t[44]!==S?(E=S&&d.trim()?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-edge-subtle pt-3 text-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:n.channelsSessionLabel}),(0,Z.jsxs)(Ct,{type:`button`,variant:`ghost`,className:`h-7 gap-1 px-2 text-xs`,disabled:r||m||!d.trim(),title:n.channelsRefreshSessionsHint,onClick:()=>y(),children:[(0,Z.jsx)(le,{className:Y(`size-3.5`,m&&`animate-spin`),strokeWidth:1.75}),n.channelsRefreshSessions]})]}),m&&p.length===0?(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.channelsLoadingSessions}):null,(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:n.channelsPeerFromSessions}),(0,Z.jsxs)(`select`,{className:Y(nn(),`py-2`),value:h==null?``:String(h),disabled:r||!d.trim()||!!_.trim(),onChange:e=>{let t=e.target.value;g(t===``?null:Number(t))},children:[(0,Z.jsx)(`option`,{value:``,children:n.channelsPeerAny}),p.map((e,t)=>(0,Z.jsx)(`option`,{value:String(t),children:Bt(e,b)},`${e.channel}-${e.chatId}`))]})]}),p.length===0&&d.trim()&&!m?(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.channelsNoSessionsHint}):null,(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:n.peerIdLabel}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch sm:gap-2`,children:[(0,Z.jsx)(`input`,{type:`text`,className:Y(nn(),`min-w-0 w-full sm:flex-1`),value:_,onChange:e=>{v(e.target.value),e.target.value.trim()&&g(null)},placeholder:n.channelsCustomPeerPlaceholder,autoComplete:`off`}),(0,Z.jsxs)(`select`,{className:sn,value:_,onChange:e=>{let t=e.target.value;v(t||``),g(null)},children:[(0,Z.jsx)(`option`,{value:``,children:x}),p.map(e=>(0,Z.jsx)(`option`,{value:e.chatId,children:Bt(e,b)},`${e.channel}-${e.chatId}`))]})]}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.channelsCustomPeerHint})]})]}):null,t[23]=n.channelsCustomPeerHint,t[24]=n.channelsCustomPeerPlaceholder,t[25]=n.channelsLoadingSessions,t[26]=n.channelsNoSessionsHint,t[27]=n.channelsPeerAny,t[28]=n.channelsPeerFromSessions,t[29]=n.channelsRefreshSessions,t[30]=n.channelsRefreshSessionsHint,t[31]=n.channelsSessionLabel,t[32]=n.peerIdLabel,t[33]=p,t[34]=r,t[35]=b,t[36]=d,t[37]=_,t[38]=h,t[39]=y,t[40]=x,t[41]=m,t[42]=v,t[43]=g,t[44]=S,t[45]=E):E=t[45];let D;t[46]!==r||t[47]!==l||t[48]!==d?(D=r||!d.trim()||l,t[46]=r,t[47]=l,t[48]=d,t[49]=D):D=t[49];let O;t[50]!==n.addBinding||t[51]!==D?(O=(0,Z.jsx)(`div`,{children:(0,Z.jsx)(Ct,{type:`submit`,disabled:D,children:n.addBinding})}),t[50]=n.addBinding,t[51]=D,t[52]=O):O=t[52];let k;t[53]!==s||t[54]!==T||t[55]!==E||t[56]!==O?(k=(0,Z.jsxs)(`form`,{className:`mt-4 flex flex-col gap-3`,onSubmit:s,children:[T,E,O]}),t[53]=s,t[54]=T,t[55]=E,t[56]=O,t[57]=k):k=t[57];let A;return t[58]!==C||t[59]!==w||t[60]!==k?(A=(0,Z.jsxs)(zt,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[C,w,k]}),t[58]=C,t[59]=w,t[60]=k,t[61]=A):A=t[61],A}function ln(e){let t=(0,X.c)(12),n;t[0]!==e.expression||t[1]!==e.kind||t[2]!==e.labels||t[3]!==e.locale||t[4]!==e.nextRun||t[5]!==e.presetLabels||t[6]!==e.timezone||t[7]!==e.valueMs?(n=e.kind===`cron`?Vt(e.expression,e.locale,e.labels,{timezone:e.timezone,nextRun:e.nextRun}):Ht(e.valueMs,e.locale,e.presetLabels),t[0]=e.expression,t[1]=e.kind,t[2]=e.labels,t[3]=e.locale,t[4]=e.nextRun,t[5]=e.presetLabels,t[6]=e.timezone,t[7]=e.valueMs,t[8]=n):n=t[8];let r=n,i;return t[9]!==e.className||t[10]!==r?(i=(0,Z.jsx)(`span`,{className:e.className,children:r}),t[9]=e.className,t[10]=r,t[11]=i):i=t[11],i}function un(e){let t=(0,X.c)(24),{a:n,data:r,busy:o,cronLoading:s,agentCronJobs:c,onSetCronJobAgent:l}=e,u=i(fn),d;t[0]===u?d=t[1]:(d=a(u),t[0]=u,t[1]=d);let f=d,p=u===`zh`?`zh-CN`:`en-US`,m=f.cron.scheduleBadge,h;t[2]!==n.cronHint||t[3]!==n.cronTitle?(h=(0,Z.jsx)(Rt,{className:`shrink-0`,icon:Je,title:n.cronTitle,subtitle:n.cronHint}),t[2]=n.cronHint,t[3]=n.cronTitle,t[4]=h):h=t[4];let g;t[5]!==n.cronAgentClear||t[6]!==n.cronAgentDefault||t[7]!==n.cronColAgent||t[8]!==n.cronColMessage||t[9]!==n.cronColSchedule||t[10]!==n.cronColSession||t[11]!==n.cronLoading||t[12]!==n.cronNone||t[13]!==c||t[14]!==o||t[15]!==s||t[16]!==r||t[17]!==p||t[18]!==l||t[19]!==m?(g=s?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.cronLoading}):c.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.cronNone}):(0,Z.jsx)(`div`,{className:`overflow-x-auto`,children:(0,Z.jsxs)(`table`,{className:`w-full min-w-[32rem] border-collapse text-left text-sm`,children:[(0,Z.jsx)(`thead`,{children:(0,Z.jsxs)(`tr`,{className:`border-b border-edge text-fg-muted`,children:[(0,Z.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:n.cronColSchedule}),(0,Z.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:n.cronColMessage}),(0,Z.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:n.cronColSession}),(0,Z.jsx)(`th`,{className:`py-2 pr-3 font-medium`,children:n.cronColAgent})]})}),(0,Z.jsx)(`tbody`,{children:c.map(e=>{let t=!e.agentId?.trim(),i=t?``:e.agentId.trim().toLowerCase();return(0,Z.jsxs)(`tr`,{className:`border-b border-edge-subtle`,children:[(0,Z.jsx)(`td`,{className:`py-2 pr-3`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Z.jsx)(ln,{kind:`cron`,expression:e.schedule,locale:p,labels:m,timezone:e.timezone,nextRun:e.next_run,className:`text-sm font-medium text-fg`}),(0,Z.jsx)(`span`,{className:`truncate font-mono text-[0.65rem] text-fg-subtle`,title:e.schedule,children:e.schedule})]})}),(0,Z.jsx)(`td`,{className:`max-w-[12rem] truncate py-2 pr-3 text-xs`,title:qt(e),children:qt(e)}),(0,Z.jsx)(`td`,{className:`py-2 pr-3 text-xs`,children:e.sessionTarget??`main`}),(0,Z.jsx)(`td`,{className:`py-2 pr-3`,children:(0,Z.jsxs)(`select`,{className:Y(nn(),`min-w-[8rem] py-1 text-xs`),value:i,disabled:o||e.sessionTarget!==`isolated`,onChange:t=>void l(e,t.target.value),children:[(0,Z.jsx)(`option`,{value:``,children:t?n.cronAgentDefault:n.cronAgentClear}),r.agents.map(dn)]})})]},e.id)})})]})}),t[5]=n.cronAgentClear,t[6]=n.cronAgentDefault,t[7]=n.cronColAgent,t[8]=n.cronColMessage,t[9]=n.cronColSchedule,t[10]=n.cronColSession,t[11]=n.cronLoading,t[12]=n.cronNone,t[13]=c,t[14]=o,t[15]=s,t[16]=r,t[17]=p,t[18]=l,t[19]=m,t[20]=g):g=t[20];let _;return t[21]!==h||t[22]!==g?(_=(0,Z.jsxs)(zt,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[h,g]}),t[21]=h,t[22]=g,t[23]=_):_=t[23],_}function dn(e){return(0,Z.jsx)(`option`,{value:e.id,children:e.id},e.id)}function fn(e){return e.language}function pn(e){let t=(0,X.c)(27),{a:n,filesLoading:r,files:i,activeFile:a,setActiveFile:o,filesViewMode:s,setFilesViewMode:c,fileDraft:l,setFileDraft:u,fileSaving:d,profileFileLoading:f,profileEditorNonce:p}=e,m=h(mn),g;t[0]===n.filesHint?g=t[1]:(g=(0,Z.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:n.filesHint}),t[0]=n.filesHint,t[1]=g);let _;t[2]!==n.filesAutoSaveHint||t[3]!==n.filesEmpty||t[4]!==n.filesLoading||t[5]!==n.filesMarkdownEdit||t[6]!==n.filesMarkdownPreview||t[7]!==n.filesSavingStatus||t[8]!==n.missing||t[9]!==n.navCoreFiles||t[10]!==n.pickFile||t[11]!==a||t[12]!==l||t[13]!==d||t[14]!==i||t[15]!==r||t[16]!==s||t[17]!==m||t[18]!==p||t[19]!==f||t[20]!==o||t[21]!==u||t[22]!==c?(_=r?(0,Z.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:n.filesLoading}):i?(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden`,children:[(0,Z.jsx)(`nav`,{className:`flex shrink-0 flex-row flex-wrap gap-x-0.5 gap-y-0 border-b border-edge-subtle`,"aria-label":n.navCoreFiles,children:i.files.map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:Y(`-mb-px shrink-0 border-b-2 border-transparent px-3 py-2 text-left font-mono text-xs whitespace-nowrap transition-colors`,Lt.press,a===e.name?`border-accent text-fg`:`text-fg-muted hover:border-edge-subtle hover:text-fg`,e.missing&&`opacity-60`),onClick:()=>o(e.name),children:[e.name,e.missing?` (${n.missing})`:``]},e.name))}),(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col gap-2 overflow-hidden`,children:a?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`inline-flex rounded-lg border border-edge bg-surface-panel p-0.5`,role:`group`,"aria-label":`${n.filesMarkdownEdit} / ${n.filesMarkdownPreview}`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:Y(`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium`,Lt.press,s===`edit`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`),onClick:()=>c(`edit`),children:[(0,Z.jsx)(jt,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),n.filesMarkdownEdit]}),(0,Z.jsxs)(`button`,{type:`button`,className:Y(`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium`,Lt.press,s===`preview`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`),onClick:()=>c(`preview`),children:[(0,Z.jsx)(E,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),n.filesMarkdownPreview]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[d?(0,Z.jsx)(`span`,{children:n.filesSavingStatus}):null,(0,Z.jsx)(`span`,{children:n.filesAutoSaveHint})]})]}),s===`edit`?(0,Z.jsx)(`div`,{className:Y(nn(),`flex min-h-0 flex-1 flex-col overflow-hidden p-0`,f&&`pointer-events-none opacity-60`),children:(0,Z.jsx)(be,{initialContent:l,onChange:u,isDark:m,className:`min-h-0 flex-1`},`${a??`file`}-${p}`)}):(0,Z.jsx)(`div`,{className:Y(nn(),`min-h-0 flex-1 overflow-y-auto text-sm`,f&&`pointer-events-none opacity-60`),children:(0,Z.jsx)(T,{content:l,className:`text-sm`})})]}):(0,Z.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:n.pickFile})})]}):(0,Z.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:n.filesEmpty}),t[2]=n.filesAutoSaveHint,t[3]=n.filesEmpty,t[4]=n.filesLoading,t[5]=n.filesMarkdownEdit,t[6]=n.filesMarkdownPreview,t[7]=n.filesSavingStatus,t[8]=n.missing,t[9]=n.navCoreFiles,t[10]=n.pickFile,t[11]=a,t[12]=l,t[13]=d,t[14]=i,t[15]=r,t[16]=s,t[17]=m,t[18]=p,t[19]=f,t[20]=o,t[21]=u,t[22]=c,t[23]=_):_=t[23];let v;return t[24]!==g||t[25]!==_?(v=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-hidden`,children:[g,_]}),t[24]=g,t[25]=_,t[26]=v):v=t[26],v}function mn(e){return e.resolved===`dark`}var Q=e(t(),1);function hn(e){let t=(0,X.c)(37),{value:n,onChange:r,disabled:i,wd:a,placeholder:o,inputClassName:s,trailing:c}=e,l;t[0]!==r||t[1]!==n?(l={initialPath:n,onPicked:r},t[0]=r,t[1]=n,t[2]=l):l=t[2];let u=Pe(l),d;t[3]===n?d=t[4]:(d=n.trim(),t[3]=n,t[4]=d);let f=d,p=f?`${f}\n${a.chooseFolder}`:`${o??a.notSet}\n${a.selectWorkingDirectory}`,m;t[5]===s?m=t[6]:(m=Y(`min-w-0 flex-1`,s),t[5]=s,t[6]=m);let h=i||u.picking,g;t[7]===r?g=t[8]:(g=e=>void r(e.target.value),t[7]=r,t[8]=g);let _=o??a.pathInputPlaceholder,v;t[9]!==m||t[10]!==h||t[11]!==g||t[12]!==_||t[13]!==n?(v=(0,Z.jsx)(`input`,{type:`text`,className:m,value:n,disabled:h,onChange:g,placeholder:_,autoComplete:`off`,spellCheck:!1}),t[9]=m,t[10]=h,t[11]=g,t[12]=_,t[13]=n,t[14]=v):v=t[14];let y=i||u.picking,b;t[15]!==p||t[16]!==u.pick||t[17]!==y||t[18]!==n||t[19]!==a.selectWorkingDirectory?(b=(0,Z.jsx)(tt,{compact:!0,value:n,onPick:u.pick,disabled:y,title:p,"aria-label":a.selectWorkingDirectory}),t[15]=p,t[16]=u.pick,t[17]=y,t[18]=n,t[19]=a.selectWorkingDirectory,t[20]=b):b=t[20];let x;t[21]!==b||t[22]!==c?(x=(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[b,c]}),t[21]=b,t[22]=c,t[23]=x):x=t[23];let S;t[24]!==x||t[25]!==v?(S=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[v,x]}),t[24]=x,t[25]=v,t[26]=S):S=t[26];let C;t[27]!==u.confirmPick||t[28]!==u.hasNativePicker||t[29]!==u.modalOpen||t[30]!==u.setModalOpen||t[31]!==f||t[32]!==a?(C=u.hasNativePicker?null:(0,Z.jsx)(qe,{open:u.modalOpen,onOpenChange:u.setModalOpen,initialAbsolutePath:f||void 0,onConfirm:u.confirmPick,wd:a}),t[27]=u.confirmPick,t[28]=u.hasNativePicker,t[29]=u.modalOpen,t[30]=u.setModalOpen,t[31]=f,t[32]=a,t[33]=C):C=t[33];let w;return t[34]!==S||t[35]!==C?(w=(0,Z.jsxs)(Z.Fragment,{children:[S,C]}),t[34]=S,t[35]=C,t[36]=w):w=t[36],w}function gn(e){let t=(0,X.c)(19),{label:n,mode:r,value:i,inheritedFrom:a,inheritLabel:o,overrideLabel:s}=e,c;t[0]===n?c=t[1]:(c=(0,Z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:n}),t[0]=n,t[1]=c);let l=i||`—`,u;t[2]===l?u=t[3]:(u=(0,Z.jsx)(`p`,{className:`mt-1 truncate text-sm font-medium text-fg`,children:l}),t[2]=l,t[3]=u);let d;t[4]!==a||t[5]!==r?(d=r===`inherit`&&a?(0,Z.jsx)(`p`,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:a}):null,t[4]=a,t[5]=r,t[6]=d):d=t[6];let f;t[7]!==c||t[8]!==u||t[9]!==d?(f=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[c,u,d]}),t[7]=c,t[8]=u,t[9]=d,t[10]=f):f=t[10];let p=r===`inherit`?`bg-surface-hover text-fg-muted`:`bg-accent-soft text-accent-fg`,m;t[11]===p?m=t[12]:(m=Y(`mt-2 inline-flex shrink-0 self-start rounded-full px-2.5 py-0.5 text-xs font-medium sm:mt-0`,p),t[11]=p,t[12]=m);let h=r===`inherit`?o:s,g;t[13]!==m||t[14]!==h?(g=(0,Z.jsx)(`span`,{className:m,children:h}),t[13]=m,t[14]=h,t[15]=g):g=t[15];let _;return t[16]!==f||t[17]!==g?(_=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-xl border border-edge-subtle bg-surface-panel px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[f,g]}),t[16]=f,t[17]=g,t[18]=_):_=t[18],_}function _n(e){let t=(0,X.c)(40),{a:n,defaultModel:r,defaultWorkspace:i,agentModel:a,agentWorkspace:o,settingsPath:s}=e,c=s===void 0?`/settings/agent-defaults`:s,l=n.inheritance,u;t[0]===a?u=t[1]:(u=a.trim(),t[0]=a,t[1]=u);let d=!u,f;t[2]!==o||t[3]!==i?(f=!o.trim()||i.trim().length>0&&o.trim()===i.trim(),t[2]=o,t[3]=i,t[4]=f):f=t[4];let p=f,m=d?r||l.unset:a,h=p?i||l.unset:o,g;t[5]!==l.editDefaultsLink||t[6]!==c?(g=(0,Z.jsx)(lt,{to:c,className:`text-xs font-medium text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:l.editDefaultsLink}),t[5]=l.editDefaultsLink,t[6]=c,t[7]=g):g=t[7];let _;t[8]!==l.subtitle||t[9]!==l.title||t[10]!==g?(_=(0,Z.jsx)(Rt,{icon:ut,title:l.title,subtitle:l.subtitle,trailing:g}),t[8]=l.subtitle,t[9]=l.title,t[10]=g,t[11]=_):_=t[11];let v=d?`inherit`:`override`,y;t[12]!==r||t[13]!==l.inheritsValue||t[14]!==d?(y=d&&r?l.inheritsValue.replace(`{{value}}`,r):void 0,t[12]=r,t[13]=l.inheritsValue,t[14]=d,t[15]=y):y=t[15];let b;t[16]!==m||t[17]!==l.badgeInherit||t[18]!==l.badgeOverride||t[19]!==l.modelLabel||t[20]!==v||t[21]!==y?(b=(0,Z.jsx)(gn,{label:l.modelLabel,mode:v,value:m,inheritedFrom:y,inheritLabel:l.badgeInherit,overrideLabel:l.badgeOverride}),t[16]=m,t[17]=l.badgeInherit,t[18]=l.badgeOverride,t[19]=l.modelLabel,t[20]=v,t[21]=y,t[22]=b):b=t[22];let x=p?`inherit`:`override`,S;t[23]!==i||t[24]!==l.inheritsValue||t[25]!==p?(S=p&&i?l.inheritsValue.replace(`{{value}}`,i):void 0,t[23]=i,t[24]=l.inheritsValue,t[25]=p,t[26]=S):S=t[26];let C;t[27]!==h||t[28]!==l.badgeInherit||t[29]!==l.badgeOverride||t[30]!==l.workspaceLabel||t[31]!==x||t[32]!==S?(C=(0,Z.jsx)(gn,{label:l.workspaceLabel,mode:x,value:h,inheritedFrom:S,inheritLabel:l.badgeInherit,overrideLabel:l.badgeOverride}),t[27]=h,t[28]=l.badgeInherit,t[29]=l.badgeOverride,t[30]=l.workspaceLabel,t[31]=x,t[32]=S,t[33]=C):C=t[33];let w;t[34]!==C||t[35]!==b?(w=(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[b,C]}),t[34]=C,t[35]=b,t[36]=w):w=t[36];let T;return t[37]!==w||t[38]!==_?(T=(0,Z.jsxs)(zt,{children:[_,w]}),t[37]=w,t[38]=_,t[39]=T):T=t[39],T}function vn(e,t){switch(e){case`adventurer`:return t.avatarStyleAdventurer;case`bottts`:return t.avatarStyleRobot;case`lorelei`:return t.avatarStyleLorelei;case`thumbs`:return t.avatarStyleThumbs;case`fun-emoji`:return t.avatarStyleFunEmoji;default:return e}}function yn(e){let{agentId:t,value:n,onChange:r,a:i,id:a}=e,o=(0,Q.useRef)(null),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(!1),p=(0,Q.useMemo)(()=>{let e=_t(n.trim());return e&&st(e.styleId)?e.styleId:oe[0]??`adventurer`},[n]),m=(0,Q.useCallback)(async(e,n)=>{try{await se(t)}catch{}r(J(e,n)),f(!1)},[t,r]),h=(0,Q.useCallback)(async e=>{let n=e.target.files?.[0];if(e.target.value=``,n){u(null),c(!0);try{await L(t,n),r(x)}catch(e){let t=e instanceof Error?e.message:``;u(t===`avatar_too_large`?i.avatarTooLarge:t===`unsupported_image_type`||t===`empty_file`?i.avatarInvalidImage:i.avatarUploadFailed)}finally{c(!1)}}},[i,t,r]),g=(e,t)=>{let r=_t(n.trim());return!!(r&&r.styleId===e&&r.seed===t)};return(0,Z.jsxs)(`div`,{...a?{id:a}:{},className:`flex flex-col gap-3 sm:col-span-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:i.avatarPickerTitle}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`input`,{ref:o,type:`file`,accept:`image/png,image/jpeg,image/webp,.png,.jpg,.jpeg,.webp`,className:`hidden`,onChange:e=>void h(e)}),(0,Z.jsxs)(Ct,{type:`button`,variant:`secondary`,className:`gap-1.5 px-2.5 py-1.5 text-xs`,disabled:s,onClick:()=>o.current?.click(),children:[(0,Z.jsx)(Et,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),s?i.avatarUploading:i.avatarUploadCustom]})]})]}),l?(0,Z.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:l}):null,(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:oe.map(e=>(0,Z.jsx)(`button`,{type:`button`,onClick:()=>void m(e,Oe[0]??t),className:Y(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,Lt.press,p===e?`border-fg bg-fg text-surface-base`:`border-edge-subtle bg-surface-panel text-fg hover:border-edge`),children:vn(e,i)},e))}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel/50 p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[Oe.map(e=>(0,Z.jsx)(`button`,{type:`button`,title:e,onClick:()=>void m(p,e),className:Y(`flex size-12 shrink-0 items-center justify-center rounded-full border-2 transition-colors`,Lt.press,g(p,e)?`border-accent ring-2 ring-accent/30`:`border-transparent hover:border-edge`),children:(0,Z.jsx)(`img`,{src:St(p,e,96),alt:``,width:44,height:44,className:`size-11 rounded-full object-cover`,draggable:!1})},e)),(0,Z.jsxs)(te,{open:d,onOpenChange:f,children:[(0,Z.jsx)(ie,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:Y(`flex size-12 shrink-0 items-center justify-center rounded-xl border border-edge-subtle bg-surface-base text-xs font-medium text-fg-muted hover:border-edge hover:text-fg`,Lt.press),children:i.avatarMore})}),(0,Z.jsx)(H,{children:(0,Z.jsxs)($e,{className:`z-[80] max-h-72 w-[min(22rem,calc(100vw-2rem))] overflow-y-auto rounded-xl border border-edge-subtle bg-surface-panel p-3 shadow-lg`,sideOffset:6,align:`end`,children:[(0,Z.jsx)(`p`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:vn(p,i)}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:we.map(e=>(0,Z.jsx)(`button`,{type:`button`,title:e,onClick:()=>void m(p,e),className:Y(`flex size-11 shrink-0 items-center justify-center rounded-full border-2 transition-colors`,Lt.press,g(p,e)?`border-accent ring-2 ring-accent/30`:`border-transparent hover:border-edge`),children:(0,Z.jsx)(`img`,{src:St(p,e,88),alt:``,width:40,height:40,className:`size-10 rounded-full object-cover`,draggable:!1})},e))})]})})]})]}),(0,Z.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t border-edge-subtle pt-3`,children:[(0,Z.jsx)(`span`,{className:`text-xs text-fg-muted`,children:i.personaAvatar}),(0,Z.jsx)(Te,{agentId:t,avatar:n,size:40}),n.trim()&&!_t(n.trim())&&n.trim()!==`xopc:custom`?(0,Z.jsx)(`span`,{className:`truncate font-mono text-[10px] text-fg-muted`,title:n,children:n}):null]})]})]})}var bn={name:``,creature:``,emoji:``,avatar:``};function xn(e){let t={...bn};if(!e.trim())return t;let n={name:`name`,creature:`creature`,emoji:`emoji`,avatar:`avatar`};for(let r of e.split(`
2
2
  `)){let e=r.match(/^[-*]\s+\*\*(\w+):\*\*\s*(.*)/i);if(!e)continue;let i=n[e[1].toLowerCase()];if(!i)continue;let a=e[2].trim();/^_\(.*\)_$/.test(a)&&(a=``),t[i]=a}return t}function Sn(e){return[`# IDENTITY.md - Who Am I?`,``,`- **Name:** ${e.name}`,`- **Creature:** ${e.creature}`,`- **Emoji:** ${e.emoji}`,`- **Avatar:** ${e.avatar}`,``].join(`
3
3
  `)}var Cn={callName:``,pronouns:``,timezone:``,notes:``};function wn(e){let t={...Cn};if(!e.trim())return t;let n={name:`callName`,"what to call them":`callName`,pronouns:`pronouns`,timezone:`timezone`,notes:`notes`},r=e.split(`
4
4
  `),i=-1;for(let e=0;e<r.length;e++){let a=r[e];if(/^##\s+Context/i.test(a)){i=e+1;continue}let o=a.match(/^[-*]\s+\*\*(.+?):\*\*\s*(.*)/i);if(!o)continue;let s=n[o[1].toLowerCase().trim()];if(!s)continue;let c=o[2].trim();/^_\(.*\)_$/.test(c)&&(c=``),t[s]=c}if(i>0){let e=r.slice(i).join(`
@@ -67,7 +67,7 @@ Warm, friendly, and a little playful. Like a helpful friend who happens to know
67
67
 
68
68
  ## Vibe
69
69
 
70
- Sharp, direct, slightly nerdy. The kind of engineer you'd want on your team — competent, opinionated, and occasionally funny.`},{id:`custom`,labelEn:`Custom`,labelZh:`自定义`,emoji:`✍️`,content:``}];function Dn(e){let t=e.trimStart();if(!t.startsWith(`---`))return e;let n=t.indexOf(`---`,3);return n===-1?e:t.slice(n+3).trimStart()}function On(e){let t=Dn(e).trim();if(!t)return`professional`;for(let e of En)if(e.id!==`custom`&&(t===e.content.trim()||An(t,e.id)>=2))return e.id;return`custom`}var kn={professional:/precise and efficient|Value the user's time|actionable answers/g,casual:/good friend|corporate drone|a little playful/g,geeky:/Precision over politeness|Go deep|slightly nerdy/g};function An(e,t){let n=kn[t];if(!n)return 0;let r=new RegExp(n.source,`g`),i=new Set,a;for(;(a=r.exec(e))!==null;)if(i.add(a[0]),i.size>=2)return i.size;return i.size}var jn=[{value:``,labelEn:`Not set`,labelZh:`未设置`},{value:`Asia/Shanghai`,labelEn:`Asia/Shanghai (CST, UTC+8)`,labelZh:`亚洲/上海 (北京时间, UTC+8)`},{value:`Asia/Tokyo`,labelEn:`Asia/Tokyo (JST, UTC+9)`,labelZh:`亚洲/东京 (日本时间, UTC+9)`},{value:`Asia/Seoul`,labelEn:`Asia/Seoul (KST, UTC+9)`,labelZh:`亚洲/首尔 (韩国时间, UTC+9)`},{value:`Asia/Singapore`,labelEn:`Asia/Singapore (SGT, UTC+8)`,labelZh:`亚洲/新加坡 (UTC+8)`},{value:`Asia/Hong_Kong`,labelEn:`Asia/Hong Kong (HKT, UTC+8)`,labelZh:`亚洲/香港 (UTC+8)`},{value:`Asia/Taipei`,labelEn:`Asia/Taipei (CST, UTC+8)`,labelZh:`亚洲/台北 (UTC+8)`},{value:`Asia/Kolkata`,labelEn:`Asia/Kolkata (IST, UTC+5:30)`,labelZh:`亚洲/加尔各答 (印度时间, UTC+5:30)`},{value:`Asia/Dubai`,labelEn:`Asia/Dubai (GST, UTC+4)`,labelZh:`亚洲/迪拜 (UTC+4)`},{value:`Europe/London`,labelEn:`Europe/London (GMT/BST)`,labelZh:`欧洲/伦敦 (格林尼治时间)`},{value:`Europe/Paris`,labelEn:`Europe/Paris (CET, UTC+1)`,labelZh:`欧洲/巴黎 (中欧时间, UTC+1)`},{value:`Europe/Berlin`,labelEn:`Europe/Berlin (CET, UTC+1)`,labelZh:`欧洲/柏林 (中欧时间, UTC+1)`},{value:`Europe/Moscow`,labelEn:`Europe/Moscow (MSK, UTC+3)`,labelZh:`欧洲/莫斯科 (UTC+3)`},{value:`America/New_York`,labelEn:`America/New York (EST, UTC-5)`,labelZh:`美国/纽约 (东部时间, UTC-5)`},{value:`America/Chicago`,labelEn:`America/Chicago (CST, UTC-6)`,labelZh:`美国/芝加哥 (中部时间, UTC-6)`},{value:`America/Denver`,labelEn:`America/Denver (MST, UTC-7)`,labelZh:`美国/丹佛 (山地时间, UTC-7)`},{value:`America/Los_Angeles`,labelEn:`America/Los Angeles (PST, UTC-8)`,labelZh:`美国/洛杉矶 (太平洋时间, UTC-8)`},{value:`America/Sao_Paulo`,labelEn:`America/São Paulo (BRT, UTC-3)`,labelZh:`美洲/圣保罗 (巴西时间, UTC-3)`},{value:`Australia/Sydney`,labelEn:`Australia/Sydney (AEST, UTC+10)`,labelZh:`澳大利亚/悉尼 (UTC+10)`},{value:`Pacific/Auckland`,labelEn:`Pacific/Auckland (NZST, UTC+12)`,labelZh:`太平洋/奥克兰 (新西兰时间, UTC+12)`}];function Mn(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return``}}var Nn=[{value:`先生`,labelEn:`Mr.`,labelZh:`先生`},{value:`女士`,labelEn:`Ms.`,labelZh:`女士`},{value:`同学`,labelEn:`Colleague`,labelZh:`同学`},{value:`老师`,labelEn:`Teacher`,labelZh:`老师`},{value:`老板`,labelEn:`Boss`,labelZh:`老板`},{value:`朋友`,labelEn:`Friend`,labelZh:`朋友`}],Pn=[{value:`AI assistant`,labelEn:`AI Assistant`,labelZh:`AI 助手`},{value:`robot`,labelEn:`Robot`,labelZh:`机器人`},{value:`familiar`,labelEn:`Familiar`,labelZh:`精灵`},{value:`ghost in the machine`,labelEn:`Ghost in the machine`,labelZh:`机器幽灵`},{value:`digital companion`,labelEn:`Digital Companion`,labelZh:`数字伙伴`}];function Fn(e){let t=(0,X.c)(208),{a:n,chat:r,selected:a,busy:o,editName:s,setEditName:g,editDescription:_,setEditDescription:v,editWorkspace:y,setEditWorkspace:b,editModel:x,setEditModel:S,onSetDefault:C,onSaveAgentEdits:w,onDelete:D,hideInlineSave:O,profileMarkdownLoading:k,profileDraft:A,updateIdentity:j,handleSoulTemplateChange:M,handleSoulContentChange:N,setAvatarDialogOpen:P,toggleSoulPreviewMode:F,defaultModel:I,defaultWorkspace:ee}=e,L=I===void 0?``:I,R=ee===void 0?``:ee,z=i(Rn),B=h(Ln),V;t[0]===A?.identity?V=t[1]:(V=A?.identity??{name:``,creature:``,emoji:``,avatar:``},t[0]=A?.identity,t[1]=V);let H=V,U=A?.soulTemplate??`professional`,W=A?.soulCustomContent??``,te=A?.soulEditorNonce??0,ne=A?.soulPreviewMode??!1,G=A?.avatarDialogOpen??!1,K;t[2]===z?K=t[3]:(K=(e,t)=>z===`zh`?t:e,t[2]=z,t[3]=K);let q=K,re;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(re=nn(),t[4]=re):re=t[4];let ie=re;if(!a){let e;return t[5]===n.selectAgentHint?e=t[6]:(e=(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.selectAgentHint}),t[5]=n.selectAgentHint,t[6]=e),e}let ae;t[7]!==n||t[8]!==L||t[9]!==R||t[10]!==x||t[11]!==y?(ae=(0,Z.jsx)(_n,{a:n,defaultModel:L,defaultWorkspace:R,agentModel:x,agentWorkspace:y}),t[7]=n,t[8]=L,t[9]=R,t[10]=x,t[11]=y,t[12]=ae):ae=t[12];let oe;t[13]!==H.avatar||t[14]!==a.id?(oe=(0,Z.jsx)(Te,{agentId:a.id,avatar:H.avatar,size:36,className:`size-9 rounded-lg`}),t[13]=H.avatar,t[14]=a.id,t[15]=oe):oe=t[15];let se;t[16]===P?se=t[17]:(se=()=>P(!0),t[16]=P,t[17]=se);let ce;t[18]!==n.avatarOpenSettingsAria||t[19]!==se?(ce={onClick:se,ariaLabel:n.avatarOpenSettingsAria,id:`agent-avatar-settings`},t[18]=n.avatarOpenSettingsAria,t[19]=se,t[20]=ce):ce=t[20];let le;t[21]!==n.setDefault||t[22]!==o||t[23]!==C||t[24]!==a.isDefault?(le=a.isDefault?null:(0,Z.jsx)(Ct,{type:`button`,variant:`secondary`,className:`text-xs`,disabled:o,onClick:()=>void C(),children:n.setDefault}),t[21]=n.setDefault,t[22]=o,t[23]=C,t[24]=a.isDefault,t[25]=le):le=t[25];let fe;t[26]!==n.personaSectionIdentity||t[27]!==n.personaSectionIdentityHint||t[28]!==oe||t[29]!==ce||t[30]!==le?(fe=(0,Z.jsx)(Rt,{icon:de,title:n.personaSectionIdentity,subtitle:n.personaSectionIdentityHint,iconLeading:oe,iconInteractive:ce,trailing:le}),t[26]=n.personaSectionIdentity,t[27]=n.personaSectionIdentityHint,t[28]=oe,t[29]=ce,t[30]=le,t[31]=fe):fe=t[31];let pe;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,Z.jsx)(l,{className:Y(`fixed inset-0 bg-scrim backdrop-blur-[2px]`,We)}),t[32]=pe):pe=t[32];let me;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(me=Y(`fixed left-1/2 top-1/2 w-[min(calc(100vw-2rem),26rem)] max-h-[min(90dvh,36rem)] -translate-x-1/2 -translate-y-1/2 overflow-y-auto rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`,Ke),t[33]=me):me=t[33];let he;t[34]===n.avatarPickerTitle?he=t[35]:(he=(0,Z.jsx)(p,{className:`text-base font-semibold text-fg`,children:n.avatarPickerTitle}),t[34]=n.avatarPickerTitle,t[35]=he);let ge;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(ge=Y(ue,`shrink-0 p-1.5 hover:bg-surface-base`),t[36]=ge):ge=t[36];let _e;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,Z.jsx)(Ze,{className:`size-4`,"aria-hidden":!0}),t[37]=_e):_e=t[37];let ve;t[38]===n.closeDialogAria?ve=t[39]:(ve=(0,Z.jsx)(m,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:ge,"aria-label":n.closeDialogAria,children:_e})}),t[38]=n.closeDialogAria,t[39]=ve);let ye;t[40]!==he||t[41]!==ve?(ye=(0,Z.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-2`,children:[he,ve]}),t[40]=he,t[41]=ve,t[42]=ye):ye=t[42];let xe;t[43]===n.avatarRowHint?xe=t[44]:(xe=(0,Z.jsx)(f,{className:`sr-only`,children:n.avatarRowHint}),t[43]=n.avatarRowHint,t[44]=xe);let Se;t[45]===j?Se=t[46]:(Se=e=>j({avatar:e}),t[45]=j,t[46]=Se);let Ce;t[47]!==n||t[48]!==H.avatar||t[49]!==a.id||t[50]!==Se?(Ce=(0,Z.jsx)(yn,{agentId:a.id,value:H.avatar,onChange:Se,a:n}),t[47]=n,t[48]=H.avatar,t[49]=a.id,t[50]=Se,t[51]=Ce):Ce=t[51];let we;t[52]!==ye||t[53]!==xe||t[54]!==Ce?(we=(0,Z.jsxs)(c,{children:[pe,(0,Z.jsxs)(u,{className:me,onOpenAutoFocus:In,children:[ye,xe,Ce]})]}),t[52]=ye,t[53]=xe,t[54]=Ce,t[55]=we):we=t[55];let Ee;t[56]!==G||t[57]!==P||t[58]!==we?(Ee=(0,Z.jsx)(d,{open:G,onOpenChange:P,children:we}),t[56]=G,t[57]=P,t[58]=we,t[59]=Ee):Ee=t[59];let De;t[60]===n.displayName?De=t[61]:(De=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:n.displayName}),t[60]=n.displayName,t[61]=De);let Oe;t[62]!==g||t[63]!==j?(Oe=e=>{g(e.target.value),j({name:e.target.value})},t[62]=g,t[63]=j,t[64]=Oe):Oe=t[64];let ke;t[65]!==n.personaNamePlaceholder||t[66]!==s||t[67]!==Oe?(ke=(0,Z.jsx)(`input`,{className:ie,value:s,onChange:Oe,placeholder:n.personaNamePlaceholder,autoComplete:`off`}),t[65]=n.personaNamePlaceholder,t[66]=s,t[67]=Oe,t[68]=ke):ke=t[68];let Ae;t[69]!==De||t[70]!==ke?(Ae=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[De,ke]}),t[69]=De,t[70]=ke,t[71]=Ae):Ae=t[71];let je;t[72]===n.personaEmoji?je=t[73]:(je=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:n.personaEmoji}),t[72]=n.personaEmoji,t[73]=je);let Me;t[74]===j?Me=t[75]:(Me=e=>j({emoji:e.target.value}),t[74]=j,t[75]=Me);let Ne;t[76]!==n.personaEmojiPlaceholder||t[77]!==H.emoji||t[78]!==Me?(Ne=(0,Z.jsx)(`input`,{className:ie,value:H.emoji,onChange:Me,placeholder:n.personaEmojiPlaceholder,autoComplete:`off`}),t[76]=n.personaEmojiPlaceholder,t[77]=H.emoji,t[78]=Me,t[79]=Ne):Ne=t[79];let Pe;t[80]!==je||t[81]!==Ne?(Pe=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[je,Ne]}),t[80]=je,t[81]=Ne,t[82]=Pe):Pe=t[82];let Ie;t[83]===n.agentDescription?Ie=t[84]:(Ie=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:n.agentDescription}),t[83]=n.agentDescription,t[84]=Ie);let Le;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(Le=Y(ie,`min-h-16 resize-y text-sm leading-relaxed`),t[85]=Le):Le=t[85];let Re;t[86]===v?Re=t[87]:(Re=e=>v(e.target.value),t[86]=v,t[87]=Re);let ze;t[88]!==n.agentDescriptionPlaceholder||t[89]!==_||t[90]!==Re?(ze=(0,Z.jsx)(`textarea`,{className:Le,value:_,onChange:Re,placeholder:n.agentDescriptionPlaceholder,maxLength:4e3,rows:3,spellCheck:!0}),t[88]=n.agentDescriptionPlaceholder,t[89]=_,t[90]=Re,t[91]=ze):ze=t[91];let J;t[92]!==Ie||t[93]!==ze?(J=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[Ie,ze]}),t[92]=Ie,t[93]=ze,t[94]=J):J=t[94];let Be;t[95]===n.personaCreature?Be=t[96]:(Be=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:n.personaCreature}),t[95]=n.personaCreature,t[96]=Be);let Ve;t[97]===H.creature?Ve=t[98]:(Ve=Pn.some(e=>e.value===H.creature)?H.creature:`__custom__`,t[97]=H.creature,t[98]=Ve);let He;t[99]===j?He=t[100]:(He=e=>{if(e.target.value===`__custom__`){j({creature:``});return}j({creature:e.target.value})},t[99]=j,t[100]=He);let Ge;t[101]===q?Ge=t[102]:(Ge=Pn.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:q(e.labelEn,e.labelZh)},e.value)),t[101]=q,t[102]=Ge);let qe;t[103]===q?qe=t[104]:(qe=q(`Custom…`,`自定义…`),t[103]=q,t[104]=qe);let Je;t[105]===qe?Je=t[106]:(Je=(0,Z.jsx)(`option`,{value:`__custom__`,children:qe}),t[105]=qe,t[106]=Je);let Ye;t[107]!==Ve||t[108]!==He||t[109]!==Ge||t[110]!==Je?(Ye=(0,Z.jsxs)(`select`,{className:ie,value:Ve,onChange:He,children:[Ge,Je]}),t[107]=Ve,t[108]=He,t[109]=Ge,t[110]=Je,t[111]=Ye):Ye=t[111];let Xe;t[112]!==n.personaCreaturePlaceholder||t[113]!==H.creature||t[114]!==j?(Xe=Pn.some(e=>e.value===H.creature)?null:(0,Z.jsx)(`input`,{className:Y(ie,`mt-1 text-xs`),value:H.creature,onChange:e=>j({creature:e.target.value}),placeholder:n.personaCreaturePlaceholder,autoComplete:`off`}),t[112]=n.personaCreaturePlaceholder,t[113]=H.creature,t[114]=j,t[115]=Xe):Xe=t[115];let $e;t[116]!==Be||t[117]!==Ye||t[118]!==Xe?($e=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm`,children:[Be,Ye,Xe]}),t[116]=Be,t[117]=Ye,t[118]=Xe,t[119]=$e):$e=t[119];let et;t[120]!==Ae||t[121]!==Pe||t[122]!==J||t[123]!==$e?(et=(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[Ae,Pe,J,$e]}),t[120]=Ae,t[121]=Pe,t[122]=J,t[123]=$e,t[124]=et):et=t[124];let tt;t[125]!==fe||t[126]!==Ee||t[127]!==et?(tt=(0,Z.jsxs)(zt,{children:[fe,Ee,et]}),t[125]=fe,t[126]=Ee,t[127]=et,t[128]=tt):tt=t[128];let nt;t[129]!==n.editAgent||t[130]!==n.editAgentHint?(nt=(0,Z.jsx)(Rt,{icon:Qe,title:n.editAgent,subtitle:n.editAgentHint}),t[129]=n.editAgent,t[130]=n.editAgentHint,t[131]=nt):nt=t[131];let rt;t[132]===n.modelPrimary?rt=t[133]:(rt=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:n.modelPrimary}),t[132]=n.modelPrimary,t[133]=rt);let it;t[134]===S?it=t[135]:(it=e=>S(e),t[134]=S,t[135]=it);let at;t[136]!==o||t[137]!==r.modelNoMatches||t[138]!==r.modelPlaceholder||t[139]!==r.modelSearchPlaceholder||t[140]!==x||t[141]!==it?(at=(0,Z.jsx)(wt,{className:`min-w-0 flex-1`,value:x,disabled:o,placeholder:r.modelPlaceholder,searchPlaceholder:r.modelSearchPlaceholder,noMatches:r.modelNoMatches,onChange:it}),t[136]=o,t[137]=r.modelNoMatches,t[138]=r.modelPlaceholder,t[139]=r.modelSearchPlaceholder,t[140]=x,t[141]=it,t[142]=at):at=t[142];let ot;t[143]!==n.modelClear||t[144]!==o||t[145]!==x||t[146]!==S?(ot=x.trim()?(0,Z.jsx)(Ct,{type:`button`,variant:`secondary`,className:`shrink-0`,disabled:o,onClick:()=>S(``),children:n.modelClear}):null,t[143]=n.modelClear,t[144]=o,t[145]=x,t[146]=S,t[147]=ot):ot=t[147];let st;t[148]!==at||t[149]!==ot?(st=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[at,ot]}),t[148]=at,t[149]=ot,t[150]=st):st=t[150];let ct;t[151]!==rt||t[152]!==st?(ct=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[rt,st]}),t[151]=rt,t[152]=st,t[153]=ct):ct=t[153];let lt;t[154]===n.workspacePath?lt=t[155]:(lt=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:n.workspacePath}),t[154]=n.workspacePath,t[155]=lt);let ut=r.workingDirectory,dt=r.workingDirectory.notSet,ft;t[156]===Symbol.for(`react.memo_cache_sentinel`)?(ft=Y(ie,`font-mono text-xs`),t[156]=ft):ft=t[156];let mt;t[157]!==o||t[158]!==r.workingDirectory||t[159]!==y||t[160]!==b?(mt=(0,Z.jsx)(hn,{value:y,onChange:b,disabled:o,wd:ut,placeholder:dt,inputClassName:ft}),t[157]=o,t[158]=r.workingDirectory,t[159]=y,t[160]=b,t[161]=mt):mt=t[161];let ht;t[162]!==lt||t[163]!==mt?(ht=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[lt,mt]}),t[162]=lt,t[163]=mt,t[164]=ht):ht=t[164];let _t;t[165]!==ct||t[166]!==ht?(_t=(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[ct,ht]}),t[165]=ct,t[166]=ht,t[167]=_t):_t=t[167];let vt;t[168]!==n.save||t[169]!==o||t[170]!==O||t[171]!==w?(vt=O?null:(0,Z.jsx)(`div`,{className:`mt-4`,children:(0,Z.jsx)(Ct,{type:`button`,disabled:o,onClick:()=>void w(),children:n.save})}),t[168]=n.save,t[169]=o,t[170]=O,t[171]=w,t[172]=vt):vt=t[172];let yt;t[173]!==nt||t[174]!==_t||t[175]!==vt?(yt=(0,Z.jsxs)(zt,{children:[nt,_t,vt]}),t[173]=nt,t[174]=_t,t[175]=vt,t[176]=yt):yt=t[176];let bt;t[177]!==n.loading||t[178]!==n.personaSectionSoul||t[179]!==n.personaSectionSoulHint||t[180]!==n.personaSoulCustomEdit||t[181]!==n.personaSoulEdit||t[182]!==n.personaSoulPreview||t[183]!==n.personaSoulTemplate||t[184]!==N||t[185]!==M||t[186]!==B||t[187]!==q||t[188]!==k||t[189]!==W||t[190]!==te||t[191]!==ne||t[192]!==U||t[193]!==F?(bt=k?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.loading}):(0,Z.jsxs)(zt,{children:[(0,Z.jsx)(Rt,{icon:Fe,title:n.personaSectionSoul,subtitle:n.personaSectionSoulHint}),(0,Z.jsxs)(`div`,{className:`mb-4 flex flex-col gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.personaSoulTemplate}),(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-4`,children:En.map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:Y(`flex flex-col items-center gap-1.5 rounded-xl border-2 p-3 text-center transition-all`,Lt.pressCard,U===e.id?`border-accent bg-accent-soft/40 shadow-sm`:`border-edge hover:border-accent/40 hover:bg-surface-hover`),onClick:()=>M(e.id),children:[(0,Z.jsx)(`span`,{className:`text-xl`,children:e.emoji}),(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:q(e.labelEn,e.labelZh)})]},e.id))})]}),U===`custom`?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.personaSoulCustomEdit}),(0,Z.jsx)(`button`,{type:`button`,className:Y(ue,`inline-flex size-9 shrink-0 items-center justify-center rounded-md p-0 hover:bg-surface-hover`),title:ne?n.personaSoulEdit:n.personaSoulPreview,"aria-label":ne?n.personaSoulEdit:n.personaSoulPreview,onClick:F,children:ne?(0,Z.jsx)(gt,{className:`size-4`,"aria-hidden":!0}):(0,Z.jsx)(E,{className:`size-4`,"aria-hidden":!0})})]}),(0,Z.jsx)(`div`,{className:Y(ie,`flex min-h-64 flex-col overflow-hidden p-0`),children:ne?(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:(0,Z.jsx)(T,{content:W})}):(0,Z.jsx)(be,{initialContent:W,onChange:N,isDark:B,className:`min-h-0 flex-1`},`soul-${te}`)})]}):null]}),t[177]=n.loading,t[178]=n.personaSectionSoul,t[179]=n.personaSectionSoulHint,t[180]=n.personaSoulCustomEdit,t[181]=n.personaSoulEdit,t[182]=n.personaSoulPreview,t[183]=n.personaSoulTemplate,t[184]=N,t[185]=M,t[186]=B,t[187]=q,t[188]=k,t[189]=W,t[190]=te,t[191]=ne,t[192]=U,t[193]=F,t[194]=bt):bt=t[194];let xt;t[195]!==n.purgeDisk||t[196]!==n.removeFromConfig||t[197]!==o||t[198]!==q||t[199]!==D||t[200]!==a.id?(xt=a.id===`main`?null:(0,Z.jsxs)(zt,{children:[(0,Z.jsx)(Rt,{icon:Ue,title:q(`Danger Zone`,`危险操作`),subtitle:q(`Actions that cannot be undone. Be careful.`,`以下操作不可撤销,请谨慎操作。`)}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsxs)(Ct,{type:`button`,variant:`secondary`,disabled:o,onClick:()=>void D(!1),children:[(0,Z.jsx)(pt,{className:`mr-1 size-4`,"aria-hidden":!0}),n.removeFromConfig]}),(0,Z.jsx)(Ct,{type:`button`,variant:`secondary`,className:`border-red-200 text-red-700 hover:bg-red-50 dark:border-red-900/60 dark:text-red-300 dark:hover:bg-red-950/40`,disabled:o,onClick:()=>void D(!0),children:n.purgeDisk})]})]}),t[195]=n.purgeDisk,t[196]=n.removeFromConfig,t[197]=o,t[198]=q,t[199]=D,t[200]=a.id,t[201]=xt):xt=t[201];let St;return t[202]!==tt||t[203]!==ae||t[204]!==yt||t[205]!==bt||t[206]!==xt?(St=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-8 overflow-y-auto`,children:[ae,tt,yt,bt,xt]}),t[202]=tt,t[203]=ae,t[204]=yt,t[205]=bt,t[206]=xt,t[207]=St):St=t[207],St}function In(e){return e.preventDefault()}function Ln(e){return e.resolved===`dark`}function Rn(e){return e.language}function zn(e){let t=!e.pronouns||Nn.some(t=>t.value===e.pronouns),n=jn.some(t=>t.value===e.timezone);return{showCustomPronouns:!!(e.pronouns&&!t),showCustomTimezone:!!(e.timezone&&!n),customTimezone:e.timezone&&!n?e.timezone:``}}function Bn(e,t){switch(t.type){case`load`:{let e=zn(t.user),n=JSON.stringify(t.user);return{user:t.user,snapshot:n,...e}}case`patch`:{let n={...e.user,...t.patch};return{...e,user:n}}case`setShowCustomPronouns`:return{...e,showCustomPronouns:t.value};case`setShowCustomTimezone`:return{...e,showCustomTimezone:t.value};case`setCustomTimezone`:return{...e,customTimezone:t.value};case`saved`:return{...e,snapshot:JSON.stringify(e.user)}}}var Vn={callName:``,pronouns:``,timezone:``,notes:``},Hn={user:Vn,showCustomPronouns:!1,showCustomTimezone:!1,customTimezone:``,snapshot:JSON.stringify(Vn)};function Un({a:e,agentId:t,saveRef:n,onDirtyChange:r}){let a=i(e=>e.language),[o,s]=(0,Q.useReducer)(Bn,Hn),c=(0,Q.useRef)(t);c.current=t;let l=(0,Q.useRef)(r);l.current=r;let u=G(async()=>{let e=wn(await S(t,`USER.md`).catch(()=>``));if(!e.timezone){let t=Mn();if(t)return{...e,timezone:t}}return e},[t],{enabled:!!t,initial:null,errorData:Vn}),d=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{u.loading||!u.data||d.current!==t&&(d.current=t,s({type:`load`,user:u.data}),l.current?.(!1))},[t,u.loading,u.data]);let f=(0,Q.useCallback)(async e=>{await R(c.current,`USER.md`,e)},[]),p=(0,Q.useRef)(o.user);p.current=o.user,(0,Q.useEffect)(()=>{if(n)return n.current=async()=>{await f(Tn(p.current)),s({type:`saved`}),l.current?.(!1)},()=>{n.current=null}},[n,f]);let m=(0,Q.useCallback)(e=>{s({type:`patch`,patch:e});let t={...p.current,...e};l.current?.(JSON.stringify(t)!==o.snapshot)},[o.snapshot]),h=(0,Q.useCallback)(e=>{if(e===`__custom__`){s({type:`setShowCustomTimezone`,value:!0});return}s({type:`setShowCustomTimezone`,value:!1}),s({type:`setCustomTimezone`,value:``}),m({timezone:e})},[m]),g=(0,Q.useCallback)(e=>{s({type:`setCustomTimezone`,value:e}),m({timezone:e})},[m]),_=(0,Q.useCallback)(()=>{let e=Mn();e&&(jn.some(t=>t.value===e)?(s({type:`setShowCustomTimezone`,value:!1}),s({type:`setCustomTimezone`,value:``})):(s({type:`setShowCustomTimezone`,value:!0}),s({type:`setCustomTimezone`,value:e})),m({timezone:e}))},[m]),v=o.showCustomTimezone?`__custom__`:jn.some(e=>e.value===o.user.timezone)?o.user.timezone:`__custom__`,y=(0,Q.useCallback)((e,t)=>a===`zh`?t:e,[a]);if(u.loading)return(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.loading});let b=nn(),{user:x,showCustomPronouns:C,showCustomTimezone:w,customTimezone:T}=o;return(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-6 overflow-y-auto`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.personaSectionUserHint}),(0,Z.jsxs)(zt,{children:[(0,Z.jsx)(Rt,{icon:Ft,title:e.personaSectionUser,subtitle:e.personaSectionUserHint}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:e.personaCallName}),(0,Z.jsx)(`input`,{className:b,value:x.callName,onChange:e=>m({callName:e.target.value}),placeholder:e.personaCallNamePlaceholder,autoComplete:`off`})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:e.personaPronouns}),(0,Z.jsxs)(`select`,{className:b,value:Nn.some(e=>e.value===x.pronouns)?x.pronouns:`__custom__`,onChange:e=>{if(e.target.value===`__custom__`){s({type:`setShowCustomPronouns`,value:!0});return}s({type:`setShowCustomPronouns`,value:!1}),m({pronouns:e.target.value})},children:[(0,Z.jsx)(`option`,{value:``,disabled:!0,children:e.personaPronounsPlaceholder}),Nn.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:y(e.labelEn,e.labelZh)},e.value)),(0,Z.jsx)(`option`,{value:`__custom__`,children:y(`Custom…`,`自定义…`)})]}),C?(0,Z.jsx)(`input`,{className:Y(b,`mt-1 text-xs`),value:Nn.some(e=>e.value===x.pronouns)?``:x.pronouns,onChange:e=>m({pronouns:e.target.value}),placeholder:e.personaPronounsPlaceholder,autoComplete:`off`}):null]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:e.personaTimezone}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[(0,Z.jsxs)(`select`,{className:Y(b,`min-w-0 flex-1`),value:v,onChange:e=>h(e.target.value),children:[jn.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:y(e.labelEn,e.labelZh)},e.value)),(0,Z.jsx)(`option`,{value:`__custom__`,children:e.personaTimezoneCustom})]}),(0,Z.jsx)(`button`,{type:`button`,className:Y(`shrink-0 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,Lt.press),onClick:_,children:e.personaTimezoneDetect})]}),w?(0,Z.jsx)(`input`,{className:Y(b,`mt-1 font-mono text-xs`),value:T,onChange:e=>g(e.target.value),placeholder:`e.g. Asia/Shanghai`,autoComplete:`off`}):null]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:e.personaNotes}),(0,Z.jsx)(`textarea`,{className:Y(b,`min-h-16 resize-y text-sm leading-relaxed`),value:x.notes,onChange:e=>m({notes:e.target.value}),placeholder:e.personaNotesPlaceholder,rows:3,spellCheck:!0})]})]}),(0,Z.jsxs)(`div`,{className:`mt-3 flex items-start gap-2 rounded-lg bg-accent-soft/30 px-3 py-2.5 text-xs text-fg-muted`,children:[(0,Z.jsx)(at,{className:`mt-0.5 size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:e.personaMemoryNote})]})]})]})}function Wn(e){let t=(0,X.c)(2),n;return t[0]===e?n=t[1]:(n=(0,Z.jsx)(Un,{...e},e.agentId),t[0]=e,t[1]=n),n}function Gn(e){let t=(0,X.c)(65),{a:n,selected:r,busy:i,skillsCatalogLoading:a,catalogForPick:o,skillsInherit:s,setSkillsInherit:c,skillsPick:l,setSkillsPick:u,onSaveSkills:d,hideInlineSave:f}=e,p;t[0]===r.skills.effectiveAllowlist?p=t[1]:(p=function(e){let t=r.skills.effectiveAllowlist;return t===void 0?!0:t.length===0?!1:t.includes(e)},t[0]=r.skills.effectiveAllowlist,t[1]=p);let m=p,h;t[2]!==o||t[3]!==r.skills.effectiveAllowlist?(h=function(){let e=r.skills.effectiveAllowlist;return e===void 0?new Set(o.map(Kn)):new Set(e)},t[2]=o,t[3]=r.skills.effectiveAllowlist,t[4]=h):h=t[4];let g=h,_;t[5]!==n.skillsHint||t[6]!==n.skillsTitle?(_=(0,Z.jsx)(Rt,{className:`shrink-0`,icon:y,title:n.skillsTitle,subtitle:n.skillsHint}),t[5]=n.skillsHint,t[6]=n.skillsTitle,t[7]=_):_=t[7];let v;t[8]===c?v=t[9]:(v=()=>c(!0),t[8]=c,t[9]=v);let b;t[10]!==n.skillsInherit||t[11]!==i||t[12]!==v?(b=(0,Z.jsx)(Ct,{type:`button`,variant:`secondary`,disabled:i,onClick:v,children:n.skillsInherit}),t[10]=n.skillsInherit,t[11]=i,t[12]=v,t[13]=b):b=t[13];let x;t[14]!==g||t[15]!==c||t[16]!==u?(x=()=>{c(!1),u(g())},t[14]=g,t[15]=c,t[16]=u,t[17]=x):x=t[17];let S;t[18]!==n.skillsCustomize||t[19]!==i||t[20]!==x?(S=(0,Z.jsx)(Ct,{type:`button`,variant:`secondary`,disabled:i,onClick:x,children:n.skillsCustomize}),t[18]=n.skillsCustomize,t[19]=i,t[20]=x,t[21]=S):S=t[21];let C;t[22]!==b||t[23]!==S?(C=(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[b,S]}),t[22]=b,t[23]=S,t[24]=C):C=t[24];let w;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(w=M(`skills`),t[25]=w):w=t[25];let T;t[26]===n.skillsLibraryLink?T=t[27]:(T=(0,Z.jsx)(lt,{to:w,className:`shrink-0 text-xs font-medium text-accent-fg hover:underline`,children:n.skillsLibraryLink}),t[26]=n.skillsLibraryLink,t[27]=T);let E;t[28]!==C||t[29]!==T?(E=(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3`,children:[C,T]}),t[28]=C,t[29]=T,t[30]=E):E=t[30];let D;t[31]===r.skills.defaults?D=t[32]:(D=r.skills.defaults.length?r.skills.defaults.join(`, `):`—`,t[31]=r.skills.defaults,t[32]=D);let O;t[33]!==n.skillsDefaultsLabel||t[34]!==D?(O=(0,Z.jsxs)(`p`,{className:`mt-2 shrink-0 text-xs text-fg-muted`,children:[n.skillsDefaultsLabel,` `,D]}),t[33]=n.skillsDefaultsLabel,t[34]=D,t[35]=O):O=t[35];let k;t[36]!==n.skillsAllFromCatalog||t[37]!==r.skills.effectiveAllowlist?(k=r.skills.effectiveAllowlist?.length?r.skills.effectiveAllowlist.join(`, `):n.skillsAllFromCatalog,t[36]=n.skillsAllFromCatalog,t[37]=r.skills.effectiveAllowlist,t[38]=k):k=t[38];let A;t[39]!==n.skillsEffectiveLabel||t[40]!==k?(A=(0,Z.jsxs)(`p`,{className:`shrink-0 text-xs text-fg-muted`,children:[n.skillsEffectiveLabel,` `,k]}),t[39]=n.skillsEffectiveLabel,t[40]=k,t[41]=A):A=t[41];let j;t[42]!==n.skillsCatalogLoading||t[43]!==n.skillsEmptyCatalog||t[44]!==n.skillsNoDescription||t[45]!==i||t[46]!==o||t[47]!==m||t[48]!==u||t[49]!==a||t[50]!==s||t[51]!==l?(j=a?(0,Z.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:n.skillsCatalogLoading}):o.length===0?(0,Z.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:n.skillsEmptyCatalog}):(0,Z.jsx)(`div`,{className:Y(`mt-3 min-h-0 flex-1 overflow-y-auto overscroll-contain pr-0.5`,s&&`opacity-50`),children:(0,Z.jsx)(`ul`,{className:`flex flex-col gap-2.5 text-sm`,children:o.map(e=>{let t=e.name||e.directoryId,r=s?m(t):l.has(t),a=typeof e.description==`string`?e.description.trim():``,o=a||n.skillsNoDescription;return(0,Z.jsx)(`li`,{className:`h-16 shrink-0 overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel/60 px-3 dark:border-edge-subtle`,children:(0,Z.jsxs)(`label`,{className:`flex h-full cursor-pointer items-center gap-3 text-sm`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`shrink-0 rounded border-edge`,checked:r,disabled:s||i,onChange:()=>{u(e=>{let n=new Set(e);return r?n.delete(t):n.add(t),n})},"aria-label":t}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:[(0,Z.jsx)(`div`,{className:`truncate font-mono text-xs font-medium text-fg`,title:t,children:t}),(0,Z.jsx)(`p`,{className:Y(`mt-0.5 truncate text-xs leading-tight text-fg-muted`,!a&&`italic text-fg-subtle`),title:o,children:o})]})]})},t)})})}),t[42]=n.skillsCatalogLoading,t[43]=n.skillsEmptyCatalog,t[44]=n.skillsNoDescription,t[45]=i,t[46]=o,t[47]=m,t[48]=u,t[49]=a,t[50]=s,t[51]=l,t[52]=j):j=t[52];let N;t[53]!==n.skillsSave||t[54]!==i||t[55]!==f||t[56]!==d?(N=f?null:(0,Z.jsx)(`div`,{className:`mt-4 shrink-0`,children:(0,Z.jsx)(Ct,{type:`button`,disabled:i,onClick:()=>void d(),children:n.skillsSave})}),t[53]=n.skillsSave,t[54]=i,t[55]=f,t[56]=d,t[57]=N):N=t[57];let P;return t[58]!==E||t[59]!==O||t[60]!==A||t[61]!==j||t[62]!==N||t[63]!==_?(P=(0,Z.jsxs)(zt,{className:`flex min-h-0 flex-1 flex-col`,children:[_,E,O,A,j,N]}),t[58]=E,t[59]=O,t[60]=A,t[61]=j,t[62]=N,t[63]=_,t[64]=P):P=t[64],P}function Kn(e){return e.name||e.directoryId}var qn=[{key:`workspace`,toolIds:[`read_file`,`write_file`,`edit_file`,`list_dir`,`grep`,`find`]},{key:`execution`,toolIds:[`shell`]},{key:`web`,toolIds:[`web_search`,`web_fetch`]},{key:`messaging`,toolIds:[`send_message`,`send_media`]},{key:`memory`,toolIds:[`memory_search`,`memory_get`,`curated_memory`,`session_search`]},{key:`media`,toolIds:[`image`,`image_generate`]},{key:`extensions`,toolIds:[`extensions`]},{key:`mcp`,toolIds:[`bundle-mcp`]}],Jn=new Set(qn.flatMap(e=>[...e.toolIds].map(e=>String(e))));function Yn(e){return e.filter(e=>e&&!Jn.has(e)).sort((e,t)=>e.localeCompare(t))}function Xn(){return Y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Be,`dark:border-edge`)}function Zn(){return Y(b,Ee)}var Qn=`h-auto shrink-0 px-2.5 py-1.5 text-xs font-medium`,$n=[`write_file`,`edit_file`,`shell`],er=[`shell`,`image_generate`,`extensions`],tr=[`send_message`,`send_media`];function nr(e){let t=(0,X.c)(88),{mode:n,builtinToolIds:r,loading:i,disableSet:a,onDisableSetChange:o,defaultsDisableSet:s,unknownDisabledIds:c,getToolDescription:l,getGroupTitle:u,labels:d,quickActionsDisabled:f}=e,p;t[0]===c?p=t[1]:(p=c===void 0?[]:c,t[0]=c,t[1]=p);let m=p,h=f===void 0?!1:f,g;t[2]===r?g=t[3]:(g=new Set(r),t[2]=r,t[3]=g);let _=g,v;t[4]===s?v=t[5]:(v=s??new Set,t[4]=s,t[5]=v);let y=v,b;t[6]!==y||t[7]!==a||t[8]!==n||t[9]!==o?(b=(e,t)=>{if(n===`agentEntry`&&t&&y.has(e))return;let r=new Set(a);t?r.delete(e):r.add(e),o(r)},t[6]=y,t[7]=a,t[8]=n,t[9]=o,t[10]=b):b=t[10];let x=b,S;t[11]!==_||t[12]!==o?(S=e=>{let t=new Set;for(let n of e)_.has(n)&&t.add(n);o(t)},t[11]=_,t[12]=o,t[13]=S):S=t[13];let C=S,w;t[14]===o?w=t[15]:(w=()=>{o(new Set)},t[14]=o,t[15]=w);let T=w,E;t[16]!==r||t[17]!==o||t[18]!==m?(E=()=>{o(new Set([...r,...m]))},t[16]=r,t[17]=o,t[18]=m,t[19]=E):E=t[19];let D=E,O;t[20]===r?O=t[21]:(O=Yn(r),t[20]=r,t[21]=O);let k=O,A;if(t[22]!==_||t[23]!==k||t[24]!==n||t[25]!==m){if(A=[],n===`defaults`&&m.length>0){let e;t[27]===m?e=t[28]:(e=m.toSorted(ir),t[27]=m,t[28]=e);let n;t[29]===e?n=t[30]:(n={key:`unknown`,ids:e},t[29]=e,t[30]=n),A.push(n)}for(let e of qn){let t=e.toolIds.filter(e=>_.has(e));t.length>0&&A.push({key:e.key,ids:[...t]})}if(k.length>0){let e;t[31]===k?e=t[32]:(e={key:`misc`,ids:k},t[31]=k,t[32]=e),A.push(e)}t[22]=_,t[23]=k,t[24]=n,t[25]=m,t[26]=A}else A=t[26];let j=A,M=j.some(rr),N=h||i,P;t[33]===d.quickActionsLabel?P=t[34]:(P=(0,Z.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:d.quickActionsLabel}),t[33]=d.quickActionsLabel,t[34]=P);let F=N||r.length===0&&m.length===0,I;t[35]!==T||t[36]!==d.quickEnableAll||t[37]!==F?(I=(0,Z.jsx)(Ct,{type:`button`,variant:`secondary`,className:Qn,disabled:F,onClick:T,children:d.quickEnableAll}),t[35]=T,t[36]=d.quickEnableAll,t[37]=F,t[38]=I):I=t[38];let ee=N||r.length===0&&m.length===0,L;t[39]!==D||t[40]!==d.quickDisableAll||t[41]!==ee?(L=(0,Z.jsx)(Ct,{type:`button`,variant:`secondary`,className:Qn,disabled:ee,onClick:D,children:d.quickDisableAll}),t[39]=D,t[40]=d.quickDisableAll,t[41]=ee,t[42]=L):L=t[42];let R=N||r.length===0,z;t[43]===C?z=t[44]:(z=()=>C($n),t[43]=C,t[44]=z);let B;t[45]!==d.quickReadOnlyWorkspace||t[46]!==R||t[47]!==z?(B=(0,Z.jsx)(Ct,{type:`button`,variant:`secondary`,className:Qn,disabled:R,onClick:z,children:d.quickReadOnlyWorkspace}),t[45]=d.quickReadOnlyWorkspace,t[46]=R,t[47]=z,t[48]=B):B=t[48];let V=N||r.length===0,H;t[49]===C?H=t[50]:(H=()=>C(er),t[49]=C,t[50]=H);let U;t[51]!==d.quickHighRiskOff||t[52]!==V||t[53]!==H?(U=(0,Z.jsx)(Ct,{type:`button`,variant:`secondary`,className:Qn,disabled:V,onClick:H,children:d.quickHighRiskOff}),t[51]=d.quickHighRiskOff,t[52]=V,t[53]=H,t[54]=U):U=t[54];let W=N||r.length===0,te;t[55]===C?te=t[56]:(te=()=>C(tr),t[55]=C,t[56]=te);let ne;t[57]!==d.quickNoOutbound||t[58]!==W||t[59]!==te?(ne=(0,Z.jsx)(Ct,{type:`button`,variant:`secondary`,className:Qn,disabled:W,onClick:te,children:d.quickNoOutbound}),t[57]=d.quickNoOutbound,t[58]=W,t[59]=te,t[60]=ne):ne=t[60];let G;t[61]!==I||t[62]!==L||t[63]!==B||t[64]!==U||t[65]!==ne?(G=(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[I,L,B,U,ne]}),t[61]=I,t[62]=L,t[63]=B,t[64]=U,t[65]=ne,t[66]=G):G=t[66];let K;t[67]!==P||t[68]!==G?(K=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[P,G]}),t[67]=P,t[68]=G,t[69]=K):K=t[69];let q;t[70]!==y||t[71]!==a||t[72]!==u||t[73]!==l||t[74]!==j||t[75]!==M||t[76]!==d.emptyBuiltin||t[77]!==d.loadingBuiltin||t[78]!==d.lockedByDefaults||t[79]!==d.notInBuiltin||t[80]!==i||t[81]!==n||t[82]!==N||t[83]!==x?(q=i?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:d.loadingBuiltin}):M?(0,Z.jsx)(`div`,{className:`max-h-[min(50vh,22rem)] overflow-y-auto overscroll-contain pr-0.5`,children:(0,Z.jsx)(`div`,{className:`flex flex-col gap-5 pr-1`,children:j.map(e=>{let{key:t,ids:r}=e;return(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:u(t)}),(0,Z.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:r.map(e=>{let r=n===`defaults`&&t===`unknown`,i=n===`agentEntry`&&y.has(e),o=a.has(e),s=i?!1:!o,c=l(e);return(0,Z.jsx)(`li`,{className:Y(`rounded-xl border border-edge-subtle bg-surface-panel/60 px-3 py-2.5 dark:border-edge-subtle`,r&&`border-dashed`,i&&`opacity-60`),children:(0,Z.jsxs)(`label`,{className:Y(`flex gap-3 text-sm`,i?`cursor-not-allowed`:`cursor-pointer`),children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`mt-1 shrink-0 rounded border-edge`,checked:s,disabled:i||N,onChange:()=>x(e,!s)}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-xs font-medium text-fg`,children:e}),r?(0,Z.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[`(`,d.notInBuiltin,`)`]}):null,i?(0,Z.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[`(`,d.lockedByDefaults,`)`]}):null]}),c?(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:c}):null]})]})},e)})})]},t)})})}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:d.emptyBuiltin}),t[70]=y,t[71]=a,t[72]=u,t[73]=l,t[74]=j,t[75]=M,t[76]=d.emptyBuiltin,t[77]=d.loadingBuiltin,t[78]=d.lockedByDefaults,t[79]=d.notInBuiltin,t[80]=i,t[81]=n,t[82]=N,t[83]=x,t[84]=q):q=t[84];let re;return t[85]!==K||t[86]!==q?(re=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[K,q]}),t[85]=K,t[86]=q,t[87]=re):re=t[87],re}function rr(e){return e.ids.length>0}function ir(e,t){return e.localeCompare(t)}function ar(e){let t=(0,X.c)(51),{a:n,data:r,selected:o,busy:s,toolEntryDisable:c,setToolEntryDisable:l,onSaveTools:u,onClearToolsEntry:d,hideInlineSave:f}=e,p=i(sr),m;t[0]===p?m=t[1]:(m=a(p),t[0]=p,t[1]=m);let h=m.agentSettings.advanced,g;t[2]===o.tools.defaultsDisable?g=t[3]:(g=new Set(o.tools.defaultsDisable.flatMap(or)),t[2]=o.tools.defaultsDisable,t[3]=g);let _=g,v;t[4]===l?v=t[5]:(v=e=>{l(e)},t[4]=l,t[5]=v);let y=v,b=n.toolsDisableGroups,x;t[6]===b?x=t[7]:(x=e=>b[e],t[6]=b,t[7]=x);let S=x,C;t[8]===n.toolDescriptions?C=t[9]:(C=e=>e in n.toolDescriptions?n.toolDescriptions[e]:``,t[8]=n.toolDescriptions,t[9]=C);let w=C,T;t[10]!==n.toolsHint||t[11]!==n.toolsTitle?(T=(0,Z.jsx)(Rt,{className:`shrink-0`,icon:Me,title:n.toolsTitle,subtitle:n.toolsHint}),t[10]=n.toolsHint,t[11]=n.toolsTitle,t[12]=T):T=t[12];let E;t[13]!==n.toolsLockedByDefaults||t[14]!==h.toolsDisableEmptyBuiltin||t[15]!==h.toolsDisableLoadingBuiltin||t[16]!==h.toolsDisableNotInBuiltin||t[17]!==h.toolsDisableQuickActionsLabel||t[18]!==h.toolsDisableQuickDisableAll||t[19]!==h.toolsDisableQuickEnableAll||t[20]!==h.toolsDisableQuickHighRiskOff||t[21]!==h.toolsDisableQuickNoOutbound||t[22]!==h.toolsDisableQuickReadOnlyWorkspace?(E={loadingBuiltin:h.toolsDisableLoadingBuiltin,emptyBuiltin:h.toolsDisableEmptyBuiltin,quickActionsLabel:h.toolsDisableQuickActionsLabel,quickEnableAll:h.toolsDisableQuickEnableAll,quickDisableAll:h.toolsDisableQuickDisableAll,quickReadOnlyWorkspace:h.toolsDisableQuickReadOnlyWorkspace,quickHighRiskOff:h.toolsDisableQuickHighRiskOff,quickNoOutbound:h.toolsDisableQuickNoOutbound,notInBuiltin:h.toolsDisableNotInBuiltin,lockedByDefaults:n.toolsLockedByDefaults},t[13]=n.toolsLockedByDefaults,t[14]=h.toolsDisableEmptyBuiltin,t[15]=h.toolsDisableLoadingBuiltin,t[16]=h.toolsDisableNotInBuiltin,t[17]=h.toolsDisableQuickActionsLabel,t[18]=h.toolsDisableQuickDisableAll,t[19]=h.toolsDisableQuickEnableAll,t[20]=h.toolsDisableQuickHighRiskOff,t[21]=h.toolsDisableQuickNoOutbound,t[22]=h.toolsDisableQuickReadOnlyWorkspace,t[23]=E):E=t[23];let D;t[24]!==s||t[25]!==r.builtinToolIds||t[26]!==_||t[27]!==S||t[28]!==w||t[29]!==y||t[30]!==E||t[31]!==c?(D=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Z.jsx)(nr,{mode:`agentEntry`,builtinToolIds:r.builtinToolIds,loading:!1,disableSet:c,onDisableSetChange:y,defaultsDisableSet:_,getToolDescription:w,getGroupTitle:S,quickActionsDisabled:s,labels:E})}),t[24]=s,t[25]=r.builtinToolIds,t[26]=_,t[27]=S,t[28]=w,t[29]=y,t[30]=E,t[31]=c,t[32]=D):D=t[32];let O;t[33]!==n.toolsSave||t[34]!==s||t[35]!==f||t[36]!==u?(O=f?null:(0,Z.jsx)(Ct,{type:`button`,disabled:s,onClick:()=>void u(),children:n.toolsSave}),t[33]=n.toolsSave,t[34]=s,t[35]=f,t[36]=u,t[37]=O):O=t[37];let k;t[38]===d?k=t[39]:(k=()=>void d(),t[38]=d,t[39]=k);let A;t[40]!==n.toolsClearEntry||t[41]!==s||t[42]!==k?(A=(0,Z.jsx)(Ct,{type:`button`,variant:`secondary`,disabled:s,onClick:k,children:n.toolsClearEntry}),t[40]=n.toolsClearEntry,t[41]=s,t[42]=k,t[43]=A):A=t[43];let j;t[44]!==A||t[45]!==O?(j=(0,Z.jsxs)(`div`,{className:`mt-4 flex shrink-0 flex-wrap gap-2`,children:[O,A]}),t[44]=A,t[45]=O,t[46]=j):j=t[46];let M;return t[47]!==j||t[48]!==T||t[49]!==D?(M=(0,Z.jsxs)(zt,{className:`flex min-h-0 flex-1 flex-col`,children:[T,D,j]}),t[47]=j,t[48]=T,t[49]=D,t[50]=M):M=t[50],M}function or(e){let t=String(e).trim();return t?[t]:[]}function sr(e){return e.language}function cr(e){let t=(0,X.c)(96),{a:n,chat:r,cCron:i,selected:a,panel:o,data:s,busy:c,editName:l,setEditName:u,editDescription:d,setEditDescription:f,editWorkspace:p,setEditWorkspace:m,editModel:h,setEditModel:g,defaultModel:_,defaultWorkspace:v,onSetDefault:y,onSaveAgentEdits:b,onDelete:x,profileSaveRef:S,overviewProfile:C,setProfileDirty:w,filesLoading:T,files:E,activeFile:D,setActiveFile:O,filesViewMode:k,setFilesViewMode:A,fileDraft:j,setFileDraft:M,fileSaving:N,profileFileLoading:P,profileEditorNonce:F,toolEntryDisable:I,setToolEntryDisable:ee,onSaveTools:L,onClearToolsEntry:R,skillsCatalogLoading:z,catalogForPick:B,skillsInherit:V,setSkillsInherit:H,skillsPick:U,setSkillsPick:W,onSaveSkills:te,bindingsLoading:ne,agentBindings:G,bindChannelStatuses:K,bindChannelsLoading:q,useManualChannel:re,newBindChannel:ie,setNewBindChannel:ae,bindSessionChats:oe,bindSessionsLoading:se,newBindSessionIdx:ce,setNewBindSessionIdx:le,newBindCustomPeer:ue,setNewBindCustomPeer:de,refreshBindSessions:fe,onRemoveBinding:pe,onAddBinding:me,cronLoading:he,agentCronJobs:ge,onSetCronJobAgent:_e}=e;if(!a){let e;return t[0]===n.selectAgentHint?e=t[1]:(e=(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.selectAgentHint}),t[0]=n.selectAgentHint,t[1]=e),e}if(o===`overview`){let e;return t[2]!==n||t[3]!==c||t[4]!==r||t[5]!==_||t[6]!==v||t[7]!==d||t[8]!==h||t[9]!==l||t[10]!==p||t[11]!==x||t[12]!==b||t[13]!==y||t[14]!==C.draft||t[15]!==C.handleSoulContentChange||t[16]!==C.handleSoulTemplateChange||t[17]!==C.profileMarkdownLoading||t[18]!==C.setAvatarDialogOpen||t[19]!==C.toggleSoulPreviewMode||t[20]!==C.updateIdentity||t[21]!==a||t[22]!==f||t[23]!==g||t[24]!==u||t[25]!==m?(e=(0,Z.jsx)(Fn,{a:n,chat:r,selected:a,busy:c,editName:l,setEditName:u,editDescription:d,setEditDescription:f,editWorkspace:p,setEditWorkspace:m,editModel:h,setEditModel:g,onSetDefault:y,onSaveAgentEdits:b,onDelete:x,hideInlineSave:!0,profileMarkdownLoading:C.profileMarkdownLoading,profileDraft:C.draft,updateIdentity:C.updateIdentity,handleSoulTemplateChange:C.handleSoulTemplateChange,handleSoulContentChange:C.handleSoulContentChange,setAvatarDialogOpen:C.setAvatarDialogOpen,toggleSoulPreviewMode:C.toggleSoulPreviewMode,defaultModel:_,defaultWorkspace:v}),t[2]=n,t[3]=c,t[4]=r,t[5]=_,t[6]=v,t[7]=d,t[8]=h,t[9]=l,t[10]=p,t[11]=x,t[12]=b,t[13]=y,t[14]=C.draft,t[15]=C.handleSoulContentChange,t[16]=C.handleSoulTemplateChange,t[17]=C.profileMarkdownLoading,t[18]=C.setAvatarDialogOpen,t[19]=C.toggleSoulPreviewMode,t[20]=C.updateIdentity,t[21]=a,t[22]=f,t[23]=g,t[24]=u,t[25]=m,t[26]=e):e=t[26],e}if(o===`profile`){let e;return t[27]!==n||t[28]!==S||t[29]!==a.id||t[30]!==w?(e=(0,Z.jsx)(Wn,{a:n,agentId:a.id,saveRef:S,onDirtyChange:w}),t[27]=n,t[28]=S,t[29]=a.id,t[30]=w,t[31]=e):e=t[31],e}if(o===`files`){let e;return t[32]!==n||t[33]!==D||t[34]!==j||t[35]!==N||t[36]!==E||t[37]!==T||t[38]!==k||t[39]!==F||t[40]!==P||t[41]!==O||t[42]!==M||t[43]!==A?(e=(0,Z.jsx)(pn,{a:n,filesLoading:T,files:E,activeFile:D,setActiveFile:O,filesViewMode:k,setFilesViewMode:A,fileDraft:j,setFileDraft:M,fileSaving:N,profileFileLoading:P,profileEditorNonce:F}),t[32]=n,t[33]=D,t[34]=j,t[35]=N,t[36]=E,t[37]=T,t[38]=k,t[39]=F,t[40]=P,t[41]=O,t[42]=M,t[43]=A,t[44]=e):e=t[44],e}if(o===`tools`){let e;return t[45]!==n||t[46]!==c||t[47]!==s||t[48]!==R||t[49]!==L||t[50]!==a||t[51]!==ee||t[52]!==I?(e=(0,Z.jsx)(ar,{a:n,data:s,selected:a,busy:c,toolEntryDisable:I,setToolEntryDisable:ee,onSaveTools:L,onClearToolsEntry:R,hideInlineSave:!0}),t[45]=n,t[46]=c,t[47]=s,t[48]=R,t[49]=L,t[50]=a,t[51]=ee,t[52]=I,t[53]=e):e=t[53],e}if(o===`skills`){let e;return t[54]!==n||t[55]!==c||t[56]!==B||t[57]!==te||t[58]!==a||t[59]!==H||t[60]!==W||t[61]!==z||t[62]!==V||t[63]!==U?(e=(0,Z.jsx)(Gn,{a:n,selected:a,busy:c,skillsCatalogLoading:z,catalogForPick:B,skillsInherit:V,setSkillsInherit:H,skillsPick:U,setSkillsPick:W,onSaveSkills:te,hideInlineSave:!0}),t[54]=n,t[55]=c,t[56]=B,t[57]=te,t[58]=a,t[59]=H,t[60]=W,t[61]=z,t[62]=V,t[63]=U,t[64]=e):e=t[64],e}if(o===`channels`){let e;return t[65]!==n||t[66]!==G||t[67]!==K||t[68]!==q||t[69]!==oe||t[70]!==se||t[71]!==ne||t[72]!==c||t[73]!==i.lastActiveLabels||t[74]!==i.selectRecipient||t[75]!==ie||t[76]!==ue||t[77]!==ce||t[78]!==me||t[79]!==pe||t[80]!==fe||t[81]!==ae||t[82]!==de||t[83]!==le||t[84]!==re?(e=(0,Z.jsx)(cn,{a:n,busy:c,bindingsLoading:ne,agentBindings:G,channelStatuses:K,channelsStatusLoading:q,useManualChannel:re,newBindChannel:ie,setNewBindChannel:ae,bindSessionChats:oe,sessionsLoading:se,newBindSessionIdx:ce,setNewBindSessionIdx:le,newBindCustomPeer:ue,setNewBindCustomPeer:de,onRefreshSessions:fe,lastActiveLabels:i.lastActiveLabels,selectRecipient:i.selectRecipient,onRemoveBinding:pe,onAddBinding:me}),t[65]=n,t[66]=G,t[67]=K,t[68]=q,t[69]=oe,t[70]=se,t[71]=ne,t[72]=c,t[73]=i.lastActiveLabels,t[74]=i.selectRecipient,t[75]=ie,t[76]=ue,t[77]=ce,t[78]=me,t[79]=pe,t[80]=fe,t[81]=ae,t[82]=de,t[83]=le,t[84]=re,t[85]=e):e=t[85],e}if(o===`cron`&&s){let e;return t[86]!==n||t[87]!==ge||t[88]!==c||t[89]!==he||t[90]!==s||t[91]!==_e||t[92]!==a?(e=(0,Z.jsx)(un,{a:n,data:s,selected:a,busy:c,cronLoading:he,agentCronJobs:ge,onSetCronJobAgent:_e}),t[86]=n,t[87]=ge,t[88]=c,t[89]=he,t[90]=s,t[91]=_e,t[92]=a,t[93]=e):e=t[93],e}let ve;return t[94]===n.selectAgentHint?ve=t[95]:(ve=(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.selectAgentHint}),t[94]=n.selectAgentHint,t[95]=ve),ve}function lr(e,t,n){let r=t.trim().toLowerCase();return r?e.filter(e=>{let t=k(e,n).toLowerCase(),i=e.id.toLowerCase(),a=e.workspace.toLowerCase(),o=(e.description??``).toLowerCase(),s=q(e,n).toLowerCase();return t.includes(r)||i.includes(r)||a.includes(r)||o.includes(r)||s.includes(r)}):e}function ur(e){let t=(0,X.c)(10),{a:n,busy:r,onNewAgent:i}=e,a;t[0]===i?a=t[1]:(a=()=>i(),t[0]=i,t[1]=a);let o,s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=Y(`flex h-full min-h-[7.5rem] w-full flex-col items-center justify-center gap-2 rounded-xl border-2 border-dashed border-edge-subtle bg-surface-panel/40 px-4 py-6 text-sm font-medium text-fg-muted transition-colors`,`hover:border-accent/50 hover:bg-surface-hover hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,`disabled:pointer-events-none disabled:opacity-50`,Lt.pressCard),s=(0,Z.jsx)(ye,{className:`size-8 shrink-0 opacity-80`,strokeWidth:1.75,"aria-hidden":!0}),t[2]=o,t[3]=s):(o=t[2],s=t[3]);let c;t[4]===n.listNewAgentCard?c=t[5]:(c=(0,Z.jsx)(`span`,{children:n.listNewAgentCard}),t[4]=n.listNewAgentCard,t[5]=c);let l;return t[6]!==r||t[7]!==a||t[8]!==c?(l=(0,Z.jsxs)(`button`,{type:`button`,disabled:r,onClick:a,className:o,children:[s,c]}),t[6]=r,t[7]=a,t[8]=c,t[9]=l):l=t[9],l}function dr(e){let t=(0,X.c)(42),{a:n,agents:r,searchQuery:i,onOpenAgent:a,onChatWithAgent:o,onNewAgent:s,busy:c}=e,l,u,d,f,p,m;if(t[0]!==n||t[1]!==r||t[2]!==c||t[3]!==o||t[4]!==s||t[5]!==a||t[6]!==i){m=Symbol.for(`react.early_return_sentinel`);bb0:{let e=lr(r,i,n),h=r.length>0&&e.length===0&&i.trim().length>0;if(r.length===0){let e;t[13]===n.listNoAgentsYet?e=t[14]:(e=(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.listNoAgentsYet}),t[13]=n.listNoAgentsYet,t[14]=e);let r;t[15]!==n||t[16]!==c||t[17]!==s?(r=(0,Z.jsx)(`div`,{className:`max-w-sm`,children:(0,Z.jsx)(ur,{a:n,busy:c,onNewAgent:s})}),t[15]=n,t[16]=c,t[17]=s,t[18]=r):r=t[18];let i;t[19]!==e||t[20]!==r?(i=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[e,r]}),t[19]=e,t[20]=r,t[21]=i):i=t[21],m=i;break bb0}f=`flex flex-col gap-4`,t[22]!==n||t[23]!==h?(p=h?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.listEmpty}):null,t[22]=n,t[23]=h,t[24]=p):p=t[24],l=`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,t[25]!==n||t[26]!==c||t[27]!==s?(u=(0,Z.jsx)(`li`,{className:`h-full min-h-0`,children:(0,Z.jsx)(ur,{a:n,busy:c,onNewAgent:s})}),t[25]=n,t[26]=c,t[27]=s,t[28]=u):u=t[28];let g;t[29]!==n||t[30]!==c||t[31]!==o||t[32]!==a?(g=e=>{let t=k(e,n),r=e.id,i=q(e,n);return(0,Z.jsx)(`li`,{className:`h-full min-h-0`,children:(0,Z.jsxs)(`div`,{className:Y(`flex h-full min-h-0 flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-panel p-4 shadow-sm transition-colors`,`hover:border-edge`),children:[(0,Z.jsxs)(`button`,{type:`button`,disabled:c,onClick:()=>a(e.id),className:Y(`flex shrink-0 w-full flex-col gap-2 text-left transition-colors`,`rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,`disabled:pointer-events-none disabled:opacity-50`,Lt.pressCard),children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Z.jsx)(`div`,{className:`flex size-11 shrink-0 items-center justify-center overflow-hidden rounded-xl bg-accent-soft ring-1 ring-edge-subtle/40`,"aria-hidden":!0,children:(0,Z.jsx)(Te,{agentId:e.id,avatar:e.avatar,size:44,className:`size-full`})}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[(0,Z.jsx)(`span`,{className:`truncate font-semibold text-fg`,children:t}),e.isDefault?(0,Z.jsx)(`span`,{className:`shrink-0 rounded-md bg-surface-base px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:n.defaultBadge}):null]}),(0,Z.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-xs text-fg-muted`,title:r,children:r})]})]}),(0,Z.jsx)(`p`,{className:Y(`line-clamp-1 min-h-[1.3125rem] text-xs leading-relaxed`,i?`text-fg`:`text-fg-muted/25`),title:i||void 0,children:i||`\xA0`})]}),(0,Z.jsxs)(`button`,{type:`button`,disabled:c,onClick:()=>o(e.id),className:Y(`flex w-full shrink-0 items-center justify-center gap-2 rounded-full px-4 py-2.5 text-sm font-semibold`,`bg-accent-soft text-accent-fg transition-colors`,`hover:bg-accent/15`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,`disabled:pointer-events-none disabled:opacity-50`,Lt.press),children:[(0,Z.jsx)(ze,{className:`size-4 shrink-0`,strokeWidth:2,"aria-hidden":!0}),n.listChatWithAgent]})]})},e.id)},t[29]=n,t[30]=c,t[31]=o,t[32]=a,t[33]=g):g=t[33],d=e.map(g)}t[0]=n,t[1]=r,t[2]=c,t[3]=o,t[4]=s,t[5]=a,t[6]=i,t[7]=l,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m}else l=t[7],u=t[8],d=t[9],f=t[10],p=t[11],m=t[12];if(m!==Symbol.for(`react.early_return_sentinel`))return m;let h;t[34]!==l||t[35]!==u||t[36]!==d?(h=(0,Z.jsxs)(`ul`,{className:l,children:[u,d]}),t[34]=l,t[35]=u,t[36]=d,t[37]=h):h=t[37];let g;return t[38]!==f||t[39]!==p||t[40]!==h?(g=(0,Z.jsxs)(`div`,{className:f,children:[p,h]}),t[38]=f,t[39]=p,t[40]=h,t[41]=g):g=t[41],g}function fr(e){let t=(0,X.c)(7),{a:n}=e,r;t[0]===n.title?r=t[1]:(r=(0,Z.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight text-fg`,children:n.title}),t[0]=n.title,t[1]=r);let i;t[2]===n.subtitle?i=t[3]:(i=(0,Z.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:n.subtitle}),t[2]=n.subtitle,t[3]=i);let a;return t[4]!==r||t[5]!==i?(a=(0,Z.jsx)(`header`,{className:`flex flex-col gap-4`,children:(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[r,i]})}),t[4]=r,t[5]=i,t[6]=a):a=t[6],a}function pr(e){let t=(0,X.c)(122),{open:n,onOpenChange:r,a:i,chat:a,busy:o,modalError:s,createDisplayName:h,setCreateDisplayName:g,createAgentId:_,setCreateAgentId:v,createDescription:y,setCreateDescription:b,createWorkspace:x,setCreateWorkspace:S,createModel:C,setCreateModel:w,onCreate:T,onSuggestWorkspace:E}=e,D;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Z.jsx)(l,{className:Y(`xopc-dialog-overlay fixed inset-0 bg-scrim`,We)}),t[0]=D):D=t[0];let O;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(O=Y(`xopc-dialog-content fixed left-1/2 top-1/2 max-h-[min(90vh,640px)] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,Ke,`overflow-y-auto rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`),t[1]=O):O=t[1];let k;t[2]===i.addAgent?k=t[3]:(k=(0,Z.jsx)(p,{className:`text-base font-semibold text-fg`,children:i.addAgent}),t[2]=i.addAgent,t[3]=k);let A;t[4]===i.addAgentHint?A=t[5]:(A=(0,Z.jsx)(f,{className:`mt-0.5 text-xs text-fg-muted`,children:i.addAgentHint}),t[4]=i.addAgentHint,t[5]=A);let j;t[6]!==k||t[7]!==A?(j=(0,Z.jsxs)(`div`,{className:`min-w-0 pr-2`,children:[k,A]}),t[6]=k,t[7]=A,t[8]=j):j=t[8];let M;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(M=Y(ue,`shrink-0 p-1.5 hover:bg-surface-base`),t[9]=M):M=t[9];let N;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Z.jsx)(Ze,{className:`size-4`,"aria-hidden":!0}),t[10]=N):N=t[10];let P;t[11]===i.closeDialogAria?P=t[12]:(P=(0,Z.jsx)(m,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:M,"aria-label":i.closeDialogAria,children:N})}),t[11]=i.closeDialogAria,t[12]=P);let F;t[13]!==j||t[14]!==P?(F=(0,Z.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-2`,children:[j,P]}),t[13]=j,t[14]=P,t[15]=F):F=t[15];let I;t[16]===s?I=t[17]:(I=s?(0,Z.jsx)(`div`,{role:`alert`,className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:s}):null,t[16]=s,t[17]=I);let ee;t[18]===i.newAgentLabel?ee=t[19]:(ee=(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:i.newAgentLabel}),t[18]=i.newAgentLabel,t[19]=ee);let L;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(L=nn(),t[20]=L):L=t[20];let R;t[21]===g?R=t[22]:(R=e=>g(e.target.value),t[21]=g,t[22]=R);let z;t[23]===E?z=t[24]:(z=()=>E(),t[23]=E,t[24]=z);let B;t[25]!==h||t[26]!==R||t[27]!==z?(B=(0,Z.jsx)(`input`,{className:L,value:h,onChange:R,onBlur:z,required:!0,autoComplete:`off`}),t[25]=h,t[26]=R,t[27]=z,t[28]=B):B=t[28];let V;t[29]!==ee||t[30]!==B?(V=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[ee,B]}),t[29]=ee,t[30]=B,t[31]=V):V=t[31];let H;t[32]===i.newAgentIdOptional?H=t[33]:(H=(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:i.newAgentIdOptional}),t[32]=i.newAgentIdOptional,t[33]=H);let U;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(U=Y(nn(),`font-mono text-xs`),t[34]=U):U=t[34];let W;t[35]===v?W=t[36]:(W=e=>v(e.target.value),t[35]=v,t[36]=W);let te;t[37]===E?te=t[38]:(te=()=>E(),t[37]=E,t[38]=te);let ne;t[39]!==i.newAgentIdPlaceholder||t[40]!==i.newAgentIdRules||t[41]!==_||t[42]!==W||t[43]!==te?(ne=(0,Z.jsx)(`input`,{className:U,value:_,onChange:W,onBlur:te,placeholder:i.newAgentIdPlaceholder,autoComplete:`off`,spellCheck:!1,maxLength:64,pattern:`[A-Za-z0-9][A-Za-z0-9_-]{0,63}`,title:i.newAgentIdRules}),t[39]=i.newAgentIdPlaceholder,t[40]=i.newAgentIdRules,t[41]=_,t[42]=W,t[43]=te,t[44]=ne):ne=t[44];let G;t[45]===i.newAgentIdRules?G=t[46]:(G=(0,Z.jsx)(`span`,{className:`text-xs text-fg-muted`,children:i.newAgentIdRules}),t[45]=i.newAgentIdRules,t[46]=G);let K;t[47]!==H||t[48]!==ne||t[49]!==G?(K=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[H,ne,G]}),t[47]=H,t[48]=ne,t[49]=G,t[50]=K):K=t[50];let q;t[51]===i.agentDescription?q=t[52]:(q=(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:i.agentDescription}),t[51]=i.agentDescription,t[52]=q);let re;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(re=Y(nn(),`min-h-[4.5rem] resize-y font-sans text-sm leading-relaxed`),t[53]=re):re=t[53];let ie;t[54]===b?ie=t[55]:(ie=e=>b(e.target.value),t[54]=b,t[55]=ie);let ae;t[56]!==i.agentDescriptionPlaceholder||t[57]!==y||t[58]!==ie?(ae=(0,Z.jsx)(`textarea`,{className:re,value:y,onChange:ie,placeholder:i.agentDescriptionPlaceholder,maxLength:4e3,rows:3,spellCheck:!0}),t[56]=i.agentDescriptionPlaceholder,t[57]=y,t[58]=ie,t[59]=ae):ae=t[59];let oe;t[60]!==q||t[61]!==ae?(oe=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[q,ae]}),t[60]=q,t[61]=ae,t[62]=oe):oe=t[62];let se;t[63]===i.newWorkspace?se=t[64]:(se=(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:i.newWorkspace}),t[63]=i.newWorkspace,t[64]=se);let ce;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(ce=Y(nn(),`font-mono text-xs`),t[65]=ce):ce=t[65];let le;t[66]===S?le=t[67]:(le=e=>S(e.target.value),t[66]=S,t[67]=le);let de;t[68]!==x||t[69]!==le?(de=(0,Z.jsx)(`input`,{className:ce,value:x,onChange:le,required:!0,autoComplete:`off`}),t[68]=x,t[69]=le,t[70]=de):de=t[70];let fe;t[71]!==se||t[72]!==de?(fe=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[se,de]}),t[71]=se,t[72]=de,t[73]=fe):fe=t[73];let pe;t[74]===i.newModelOptional?pe=t[75]:(pe=(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:i.newModelOptional}),t[74]=i.newModelOptional,t[75]=pe);let me;t[76]===w?me=t[77]:(me=e=>w(e),t[76]=w,t[77]=me);let he;t[78]!==o||t[79]!==a.modelNoMatches||t[80]!==a.modelPlaceholder||t[81]!==a.modelSearchPlaceholder||t[82]!==C||t[83]!==me?(he=(0,Z.jsx)(wt,{className:`min-w-0 flex-1`,value:C,disabled:o,placeholder:a.modelPlaceholder,searchPlaceholder:a.modelSearchPlaceholder,noMatches:a.modelNoMatches,onChange:me}),t[78]=o,t[79]=a.modelNoMatches,t[80]=a.modelPlaceholder,t[81]=a.modelSearchPlaceholder,t[82]=C,t[83]=me,t[84]=he):he=t[84];let ge;t[85]!==i.modelClear||t[86]!==o||t[87]!==C||t[88]!==w?(ge=C.trim()?(0,Z.jsx)(Ct,{type:`button`,variant:`secondary`,className:`shrink-0`,disabled:o,onClick:()=>w(``),children:i.modelClear}):null,t[85]=i.modelClear,t[86]=o,t[87]=C,t[88]=w,t[89]=ge):ge=t[89];let _e;t[90]!==he||t[91]!==ge?(_e=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[he,ge]}),t[90]=he,t[91]=ge,t[92]=_e):_e=t[92];let ve;t[93]!==pe||t[94]!==_e?(ve=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 text-sm`,children:[pe,_e]}),t[93]=pe,t[94]=_e,t[95]=ve):ve=t[95];let ye;t[96]!==i.createModalCancel||t[97]!==o?(ye=(0,Z.jsx)(m,{asChild:!0,children:(0,Z.jsx)(Ct,{type:`button`,variant:`secondary`,disabled:o,children:i.createModalCancel})}),t[96]=i.createModalCancel,t[97]=o,t[98]=ye):ye=t[98];let be;t[99]===Symbol.for(`react.memo_cache_sentinel`)?(be=(0,Z.jsx)(rt,{className:`mr-1 size-4`,"aria-hidden":!0}),t[99]=be):be=t[99];let xe;t[100]!==i.create||t[101]!==o?(xe=(0,Z.jsxs)(Ct,{type:`submit`,disabled:o,children:[be,i.create]}),t[100]=i.create,t[101]=o,t[102]=xe):xe=t[102];let Se;t[103]!==ye||t[104]!==xe?(Se=(0,Z.jsxs)(`div`,{className:`mt-1 flex justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[ye,xe]}),t[103]=ye,t[104]=xe,t[105]=Se):Se=t[105];let Ce;t[106]!==T||t[107]!==V||t[108]!==K||t[109]!==oe||t[110]!==fe||t[111]!==ve||t[112]!==Se||t[113]!==I?(Ce=(0,Z.jsxs)(`form`,{className:`grid gap-3`,onSubmit:T,children:[I,V,K,oe,fe,ve,Se]}),t[106]=T,t[107]=V,t[108]=K,t[109]=oe,t[110]=fe,t[111]=ve,t[112]=Se,t[113]=I,t[114]=Ce):Ce=t[114];let we;t[115]!==Ce||t[116]!==F?(we=(0,Z.jsxs)(c,{children:[D,(0,Z.jsx)(u,{className:O,onOpenAutoFocus:mr,children:(0,Z.jsxs)(Ie,{layer:`modal`,children:[F,Ce]})})]}),t[115]=Ce,t[116]=F,t[117]=we):we=t[117];let Te;return t[118]!==r||t[119]!==n||t[120]!==we?(Te=(0,Z.jsx)(d,{open:n,onOpenChange:r,children:we}),t[118]=r,t[119]=n,t[120]=we,t[121]=Te):Te=t[121],Te}function mr(e){return e.preventDefault()}var hr=`xopc-preset-agents-skipped`,gr=[{id:`coder`,name:`Coder`,emoji:`💻`,descriptionEn:`Software development assistant — precise, pragmatic, and code-focused.`,descriptionZh:`软件开发助手 — 精确、务实、专注代码。`,toolsDisable:[`image_generate`],identityMd:`# IDENTITY.md - Who Am I?
70
+ Sharp, direct, slightly nerdy. The kind of engineer you'd want on your team — competent, opinionated, and occasionally funny.`},{id:`custom`,labelEn:`Custom`,labelZh:`自定义`,emoji:`✍️`,content:``}];function Dn(e){let t=e.trimStart();if(!t.startsWith(`---`))return e;let n=t.indexOf(`---`,3);return n===-1?e:t.slice(n+3).trimStart()}function On(e){let t=Dn(e).trim();if(!t)return`professional`;for(let e of En)if(e.id!==`custom`&&(t===e.content.trim()||An(t,e.id)>=2))return e.id;return`custom`}var kn={professional:/precise and efficient|Value the user's time|actionable answers/g,casual:/good friend|corporate drone|a little playful/g,geeky:/Precision over politeness|Go deep|slightly nerdy/g};function An(e,t){let n=kn[t];if(!n)return 0;let r=new RegExp(n.source,`g`),i=new Set,a;for(;(a=r.exec(e))!==null;)if(i.add(a[0]),i.size>=2)return i.size;return i.size}var jn=[{value:``,labelEn:`Not set`,labelZh:`未设置`},{value:`Asia/Shanghai`,labelEn:`Asia/Shanghai (CST, UTC+8)`,labelZh:`亚洲/上海 (北京时间, UTC+8)`},{value:`Asia/Tokyo`,labelEn:`Asia/Tokyo (JST, UTC+9)`,labelZh:`亚洲/东京 (日本时间, UTC+9)`},{value:`Asia/Seoul`,labelEn:`Asia/Seoul (KST, UTC+9)`,labelZh:`亚洲/首尔 (韩国时间, UTC+9)`},{value:`Asia/Singapore`,labelEn:`Asia/Singapore (SGT, UTC+8)`,labelZh:`亚洲/新加坡 (UTC+8)`},{value:`Asia/Hong_Kong`,labelEn:`Asia/Hong Kong (HKT, UTC+8)`,labelZh:`亚洲/香港 (UTC+8)`},{value:`Asia/Taipei`,labelEn:`Asia/Taipei (CST, UTC+8)`,labelZh:`亚洲/台北 (UTC+8)`},{value:`Asia/Kolkata`,labelEn:`Asia/Kolkata (IST, UTC+5:30)`,labelZh:`亚洲/加尔各答 (印度时间, UTC+5:30)`},{value:`Asia/Dubai`,labelEn:`Asia/Dubai (GST, UTC+4)`,labelZh:`亚洲/迪拜 (UTC+4)`},{value:`Europe/London`,labelEn:`Europe/London (GMT/BST)`,labelZh:`欧洲/伦敦 (格林尼治时间)`},{value:`Europe/Paris`,labelEn:`Europe/Paris (CET, UTC+1)`,labelZh:`欧洲/巴黎 (中欧时间, UTC+1)`},{value:`Europe/Berlin`,labelEn:`Europe/Berlin (CET, UTC+1)`,labelZh:`欧洲/柏林 (中欧时间, UTC+1)`},{value:`Europe/Moscow`,labelEn:`Europe/Moscow (MSK, UTC+3)`,labelZh:`欧洲/莫斯科 (UTC+3)`},{value:`America/New_York`,labelEn:`America/New York (EST, UTC-5)`,labelZh:`美国/纽约 (东部时间, UTC-5)`},{value:`America/Chicago`,labelEn:`America/Chicago (CST, UTC-6)`,labelZh:`美国/芝加哥 (中部时间, UTC-6)`},{value:`America/Denver`,labelEn:`America/Denver (MST, UTC-7)`,labelZh:`美国/丹佛 (山地时间, UTC-7)`},{value:`America/Los_Angeles`,labelEn:`America/Los Angeles (PST, UTC-8)`,labelZh:`美国/洛杉矶 (太平洋时间, UTC-8)`},{value:`America/Sao_Paulo`,labelEn:`America/São Paulo (BRT, UTC-3)`,labelZh:`美洲/圣保罗 (巴西时间, UTC-3)`},{value:`Australia/Sydney`,labelEn:`Australia/Sydney (AEST, UTC+10)`,labelZh:`澳大利亚/悉尼 (UTC+10)`},{value:`Pacific/Auckland`,labelEn:`Pacific/Auckland (NZST, UTC+12)`,labelZh:`太平洋/奥克兰 (新西兰时间, UTC+12)`}];function Mn(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return``}}var Nn=[{value:`先生`,labelEn:`Mr.`,labelZh:`先生`},{value:`女士`,labelEn:`Ms.`,labelZh:`女士`},{value:`同学`,labelEn:`Colleague`,labelZh:`同学`},{value:`老师`,labelEn:`Teacher`,labelZh:`老师`},{value:`老板`,labelEn:`Boss`,labelZh:`老板`},{value:`朋友`,labelEn:`Friend`,labelZh:`朋友`}],Pn=[{value:`AI assistant`,labelEn:`AI Assistant`,labelZh:`AI 助手`},{value:`robot`,labelEn:`Robot`,labelZh:`机器人`},{value:`familiar`,labelEn:`Familiar`,labelZh:`精灵`},{value:`ghost in the machine`,labelEn:`Ghost in the machine`,labelZh:`机器幽灵`},{value:`digital companion`,labelEn:`Digital Companion`,labelZh:`数字伙伴`}];function Fn(e){let t=(0,X.c)(208),{a:n,chat:r,selected:a,busy:o,editName:s,setEditName:g,editDescription:_,setEditDescription:v,editWorkspace:y,setEditWorkspace:b,editModel:x,setEditModel:S,onSetDefault:C,onSaveAgentEdits:w,onDelete:D,hideInlineSave:O,profileMarkdownLoading:k,profileDraft:A,updateIdentity:j,handleSoulTemplateChange:M,handleSoulContentChange:N,setAvatarDialogOpen:P,toggleSoulPreviewMode:F,defaultModel:I,defaultWorkspace:ee}=e,L=I===void 0?``:I,R=ee===void 0?``:ee,z=i(Rn),B=h(Ln),V;t[0]===A?.identity?V=t[1]:(V=A?.identity??{name:``,creature:``,emoji:``,avatar:``},t[0]=A?.identity,t[1]=V);let H=V,U=A?.soulTemplate??`professional`,W=A?.soulCustomContent??``,te=A?.soulEditorNonce??0,ne=A?.soulPreviewMode??!1,G=A?.avatarDialogOpen??!1,K;t[2]===z?K=t[3]:(K=(e,t)=>z===`zh`?t:e,t[2]=z,t[3]=K);let q=K,re;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(re=nn(),t[4]=re):re=t[4];let ie=re;if(!a){let e;return t[5]===n.selectAgentHint?e=t[6]:(e=(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.selectAgentHint}),t[5]=n.selectAgentHint,t[6]=e),e}let ae;t[7]!==n||t[8]!==L||t[9]!==R||t[10]!==x||t[11]!==y?(ae=(0,Z.jsx)(_n,{a:n,defaultModel:L,defaultWorkspace:R,agentModel:x,agentWorkspace:y}),t[7]=n,t[8]=L,t[9]=R,t[10]=x,t[11]=y,t[12]=ae):ae=t[12];let oe;t[13]!==H.avatar||t[14]!==a.id?(oe=(0,Z.jsx)(Te,{agentId:a.id,avatar:H.avatar,size:36,className:`size-9 rounded-lg`}),t[13]=H.avatar,t[14]=a.id,t[15]=oe):oe=t[15];let se;t[16]===P?se=t[17]:(se=()=>P(!0),t[16]=P,t[17]=se);let ce;t[18]!==n.avatarOpenSettingsAria||t[19]!==se?(ce={onClick:se,ariaLabel:n.avatarOpenSettingsAria,id:`agent-avatar-settings`},t[18]=n.avatarOpenSettingsAria,t[19]=se,t[20]=ce):ce=t[20];let le;t[21]!==n.setDefault||t[22]!==o||t[23]!==C||t[24]!==a.isDefault?(le=a.isDefault?null:(0,Z.jsx)(Ct,{type:`button`,variant:`secondary`,className:`text-xs`,disabled:o,onClick:()=>void C(),children:n.setDefault}),t[21]=n.setDefault,t[22]=o,t[23]=C,t[24]=a.isDefault,t[25]=le):le=t[25];let fe;t[26]!==n.personaSectionIdentity||t[27]!==n.personaSectionIdentityHint||t[28]!==oe||t[29]!==ce||t[30]!==le?(fe=(0,Z.jsx)(Rt,{icon:de,title:n.personaSectionIdentity,subtitle:n.personaSectionIdentityHint,iconLeading:oe,iconInteractive:ce,trailing:le}),t[26]=n.personaSectionIdentity,t[27]=n.personaSectionIdentityHint,t[28]=oe,t[29]=ce,t[30]=le,t[31]=fe):fe=t[31];let pe;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,Z.jsx)(l,{className:Y(`fixed inset-0 bg-scrim backdrop-blur-[2px]`,We)}),t[32]=pe):pe=t[32];let me;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(me=Y(`fixed left-1/2 top-1/2 w-[min(calc(100vw-2rem),26rem)] max-h-[min(90dvh,36rem)] -translate-x-1/2 -translate-y-1/2 overflow-y-auto rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`,Ke),t[33]=me):me=t[33];let he;t[34]===n.avatarPickerTitle?he=t[35]:(he=(0,Z.jsx)(p,{className:`text-base font-semibold text-fg`,children:n.avatarPickerTitle}),t[34]=n.avatarPickerTitle,t[35]=he);let ge;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(ge=Y(ue,`shrink-0 p-1.5 hover:bg-surface-base`),t[36]=ge):ge=t[36];let _e;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,Z.jsx)(Ze,{className:`size-4`,"aria-hidden":!0}),t[37]=_e):_e=t[37];let ve;t[38]===n.closeDialogAria?ve=t[39]:(ve=(0,Z.jsx)(m,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:ge,"aria-label":n.closeDialogAria,children:_e})}),t[38]=n.closeDialogAria,t[39]=ve);let ye;t[40]!==he||t[41]!==ve?(ye=(0,Z.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-2`,children:[he,ve]}),t[40]=he,t[41]=ve,t[42]=ye):ye=t[42];let xe;t[43]===n.avatarRowHint?xe=t[44]:(xe=(0,Z.jsx)(f,{className:`sr-only`,children:n.avatarRowHint}),t[43]=n.avatarRowHint,t[44]=xe);let Se;t[45]===j?Se=t[46]:(Se=e=>j({avatar:e}),t[45]=j,t[46]=Se);let Ce;t[47]!==n||t[48]!==H.avatar||t[49]!==a.id||t[50]!==Se?(Ce=(0,Z.jsx)(yn,{agentId:a.id,value:H.avatar,onChange:Se,a:n}),t[47]=n,t[48]=H.avatar,t[49]=a.id,t[50]=Se,t[51]=Ce):Ce=t[51];let we;t[52]!==ye||t[53]!==xe||t[54]!==Ce?(we=(0,Z.jsxs)(c,{children:[pe,(0,Z.jsxs)(u,{className:me,onOpenAutoFocus:In,children:[ye,xe,Ce]})]}),t[52]=ye,t[53]=xe,t[54]=Ce,t[55]=we):we=t[55];let Ee;t[56]!==G||t[57]!==P||t[58]!==we?(Ee=(0,Z.jsx)(d,{open:G,onOpenChange:P,children:we}),t[56]=G,t[57]=P,t[58]=we,t[59]=Ee):Ee=t[59];let De;t[60]===n.displayName?De=t[61]:(De=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:n.displayName}),t[60]=n.displayName,t[61]=De);let Oe;t[62]!==g||t[63]!==j?(Oe=e=>{g(e.target.value),j({name:e.target.value})},t[62]=g,t[63]=j,t[64]=Oe):Oe=t[64];let ke;t[65]!==n.personaNamePlaceholder||t[66]!==s||t[67]!==Oe?(ke=(0,Z.jsx)(`input`,{className:ie,value:s,onChange:Oe,placeholder:n.personaNamePlaceholder,autoComplete:`off`}),t[65]=n.personaNamePlaceholder,t[66]=s,t[67]=Oe,t[68]=ke):ke=t[68];let Ae;t[69]!==De||t[70]!==ke?(Ae=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[De,ke]}),t[69]=De,t[70]=ke,t[71]=Ae):Ae=t[71];let je;t[72]===n.personaEmoji?je=t[73]:(je=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:n.personaEmoji}),t[72]=n.personaEmoji,t[73]=je);let Me;t[74]===j?Me=t[75]:(Me=e=>j({emoji:e.target.value}),t[74]=j,t[75]=Me);let Ne;t[76]!==n.personaEmojiPlaceholder||t[77]!==H.emoji||t[78]!==Me?(Ne=(0,Z.jsx)(`input`,{className:ie,value:H.emoji,onChange:Me,placeholder:n.personaEmojiPlaceholder,autoComplete:`off`}),t[76]=n.personaEmojiPlaceholder,t[77]=H.emoji,t[78]=Me,t[79]=Ne):Ne=t[79];let Pe;t[80]!==je||t[81]!==Ne?(Pe=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[je,Ne]}),t[80]=je,t[81]=Ne,t[82]=Pe):Pe=t[82];let Ie;t[83]===n.agentDescription?Ie=t[84]:(Ie=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:n.agentDescription}),t[83]=n.agentDescription,t[84]=Ie);let Le;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(Le=Y(ie,`min-h-16 resize-y text-sm leading-relaxed`),t[85]=Le):Le=t[85];let Re;t[86]===v?Re=t[87]:(Re=e=>v(e.target.value),t[86]=v,t[87]=Re);let ze;t[88]!==n.agentDescriptionPlaceholder||t[89]!==_||t[90]!==Re?(ze=(0,Z.jsx)(`textarea`,{className:Le,value:_,onChange:Re,placeholder:n.agentDescriptionPlaceholder,maxLength:4e3,rows:3,spellCheck:!0}),t[88]=n.agentDescriptionPlaceholder,t[89]=_,t[90]=Re,t[91]=ze):ze=t[91];let J;t[92]!==Ie||t[93]!==ze?(J=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[Ie,ze]}),t[92]=Ie,t[93]=ze,t[94]=J):J=t[94];let Be;t[95]===n.personaCreature?Be=t[96]:(Be=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:n.personaCreature}),t[95]=n.personaCreature,t[96]=Be);let Ve;t[97]===H.creature?Ve=t[98]:(Ve=Pn.some(e=>e.value===H.creature)?H.creature:`__custom__`,t[97]=H.creature,t[98]=Ve);let He;t[99]===j?He=t[100]:(He=e=>{if(e.target.value===`__custom__`){j({creature:``});return}j({creature:e.target.value})},t[99]=j,t[100]=He);let Ge;t[101]===q?Ge=t[102]:(Ge=Pn.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:q(e.labelEn,e.labelZh)},e.value)),t[101]=q,t[102]=Ge);let qe;t[103]===q?qe=t[104]:(qe=q(`Custom…`,`自定义…`),t[103]=q,t[104]=qe);let Je;t[105]===qe?Je=t[106]:(Je=(0,Z.jsx)(`option`,{value:`__custom__`,children:qe}),t[105]=qe,t[106]=Je);let Ye;t[107]!==Ve||t[108]!==He||t[109]!==Ge||t[110]!==Je?(Ye=(0,Z.jsxs)(`select`,{className:ie,value:Ve,onChange:He,children:[Ge,Je]}),t[107]=Ve,t[108]=He,t[109]=Ge,t[110]=Je,t[111]=Ye):Ye=t[111];let Xe;t[112]!==n.personaCreaturePlaceholder||t[113]!==H.creature||t[114]!==j?(Xe=Pn.some(e=>e.value===H.creature)?null:(0,Z.jsx)(`input`,{className:Y(ie,`mt-1 text-xs`),value:H.creature,onChange:e=>j({creature:e.target.value}),placeholder:n.personaCreaturePlaceholder,autoComplete:`off`}),t[112]=n.personaCreaturePlaceholder,t[113]=H.creature,t[114]=j,t[115]=Xe):Xe=t[115];let $e;t[116]!==Be||t[117]!==Ye||t[118]!==Xe?($e=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm`,children:[Be,Ye,Xe]}),t[116]=Be,t[117]=Ye,t[118]=Xe,t[119]=$e):$e=t[119];let et;t[120]!==Ae||t[121]!==Pe||t[122]!==J||t[123]!==$e?(et=(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[Ae,Pe,J,$e]}),t[120]=Ae,t[121]=Pe,t[122]=J,t[123]=$e,t[124]=et):et=t[124];let tt;t[125]!==fe||t[126]!==Ee||t[127]!==et?(tt=(0,Z.jsxs)(zt,{children:[fe,Ee,et]}),t[125]=fe,t[126]=Ee,t[127]=et,t[128]=tt):tt=t[128];let nt;t[129]!==n.editAgent||t[130]!==n.editAgentHint?(nt=(0,Z.jsx)(Rt,{icon:Qe,title:n.editAgent,subtitle:n.editAgentHint}),t[129]=n.editAgent,t[130]=n.editAgentHint,t[131]=nt):nt=t[131];let rt;t[132]===n.modelPrimary?rt=t[133]:(rt=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:n.modelPrimary}),t[132]=n.modelPrimary,t[133]=rt);let it;t[134]===S?it=t[135]:(it=e=>S(e),t[134]=S,t[135]=it);let at;t[136]!==o||t[137]!==r.modelNoMatches||t[138]!==r.modelPlaceholder||t[139]!==r.modelSearchPlaceholder||t[140]!==x||t[141]!==it?(at=(0,Z.jsx)(wt,{className:`min-w-0 flex-1`,value:x,disabled:o,placeholder:r.modelPlaceholder,searchPlaceholder:r.modelSearchPlaceholder,noMatches:r.modelNoMatches,onChange:it}),t[136]=o,t[137]=r.modelNoMatches,t[138]=r.modelPlaceholder,t[139]=r.modelSearchPlaceholder,t[140]=x,t[141]=it,t[142]=at):at=t[142];let ot;t[143]!==n.modelClear||t[144]!==o||t[145]!==x||t[146]!==S?(ot=x.trim()?(0,Z.jsx)(Ct,{type:`button`,variant:`secondary`,className:`shrink-0`,disabled:o,onClick:()=>S(``),children:n.modelClear}):null,t[143]=n.modelClear,t[144]=o,t[145]=x,t[146]=S,t[147]=ot):ot=t[147];let st;t[148]!==at||t[149]!==ot?(st=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[at,ot]}),t[148]=at,t[149]=ot,t[150]=st):st=t[150];let ct;t[151]!==rt||t[152]!==st?(ct=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[rt,st]}),t[151]=rt,t[152]=st,t[153]=ct):ct=t[153];let lt;t[154]===n.workspacePath?lt=t[155]:(lt=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:n.workspacePath}),t[154]=n.workspacePath,t[155]=lt);let ut=r.workingDirectory,dt=r.workingDirectory.notSet,ft;t[156]===Symbol.for(`react.memo_cache_sentinel`)?(ft=Y(ie,`font-mono text-xs`),t[156]=ft):ft=t[156];let mt;t[157]!==o||t[158]!==r.workingDirectory||t[159]!==y||t[160]!==b?(mt=(0,Z.jsx)(hn,{value:y,onChange:b,disabled:o,wd:ut,placeholder:dt,inputClassName:ft}),t[157]=o,t[158]=r.workingDirectory,t[159]=y,t[160]=b,t[161]=mt):mt=t[161];let ht;t[162]!==lt||t[163]!==mt?(ht=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[lt,mt]}),t[162]=lt,t[163]=mt,t[164]=ht):ht=t[164];let _t;t[165]!==ct||t[166]!==ht?(_t=(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[ct,ht]}),t[165]=ct,t[166]=ht,t[167]=_t):_t=t[167];let vt;t[168]!==n.save||t[169]!==o||t[170]!==O||t[171]!==w?(vt=O?null:(0,Z.jsx)(`div`,{className:`mt-4`,children:(0,Z.jsx)(Ct,{type:`button`,disabled:o,onClick:()=>void w(),children:n.save})}),t[168]=n.save,t[169]=o,t[170]=O,t[171]=w,t[172]=vt):vt=t[172];let yt;t[173]!==nt||t[174]!==_t||t[175]!==vt?(yt=(0,Z.jsxs)(zt,{children:[nt,_t,vt]}),t[173]=nt,t[174]=_t,t[175]=vt,t[176]=yt):yt=t[176];let bt;t[177]!==n.loading||t[178]!==n.personaSectionSoul||t[179]!==n.personaSectionSoulHint||t[180]!==n.personaSoulCustomEdit||t[181]!==n.personaSoulEdit||t[182]!==n.personaSoulPreview||t[183]!==n.personaSoulTemplate||t[184]!==N||t[185]!==M||t[186]!==B||t[187]!==q||t[188]!==k||t[189]!==W||t[190]!==te||t[191]!==ne||t[192]!==U||t[193]!==F?(bt=k?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.loading}):(0,Z.jsxs)(zt,{children:[(0,Z.jsx)(Rt,{icon:Fe,title:n.personaSectionSoul,subtitle:n.personaSectionSoulHint}),(0,Z.jsxs)(`div`,{className:`mb-4 flex flex-col gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.personaSoulTemplate}),(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-4`,children:En.map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:Y(`flex flex-col items-center gap-1.5 rounded-xl border-2 p-3 text-center transition-all`,Lt.pressCard,U===e.id?`border-accent bg-accent-soft/40 shadow-sm`:`border-edge hover:border-accent/40 hover:bg-surface-hover`),onClick:()=>M(e.id),children:[(0,Z.jsx)(`span`,{className:`text-xl`,children:e.emoji}),(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:q(e.labelEn,e.labelZh)})]},e.id))})]}),U===`custom`?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.personaSoulCustomEdit}),(0,Z.jsx)(`button`,{type:`button`,className:Y(ue,`inline-flex size-9 shrink-0 items-center justify-center rounded-md p-0 hover:bg-surface-hover`),title:ne?n.personaSoulEdit:n.personaSoulPreview,"aria-label":ne?n.personaSoulEdit:n.personaSoulPreview,onClick:F,children:ne?(0,Z.jsx)(gt,{className:`size-4`,"aria-hidden":!0}):(0,Z.jsx)(E,{className:`size-4`,"aria-hidden":!0})})]}),(0,Z.jsx)(`div`,{className:Y(ie,`flex min-h-64 flex-col overflow-hidden p-0`),children:ne?(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:(0,Z.jsx)(T,{content:W})}):(0,Z.jsx)(be,{initialContent:W,onChange:N,isDark:B,className:`min-h-0 flex-1`},`soul-${te}`)})]}):null]}),t[177]=n.loading,t[178]=n.personaSectionSoul,t[179]=n.personaSectionSoulHint,t[180]=n.personaSoulCustomEdit,t[181]=n.personaSoulEdit,t[182]=n.personaSoulPreview,t[183]=n.personaSoulTemplate,t[184]=N,t[185]=M,t[186]=B,t[187]=q,t[188]=k,t[189]=W,t[190]=te,t[191]=ne,t[192]=U,t[193]=F,t[194]=bt):bt=t[194];let xt;t[195]!==n.purgeDisk||t[196]!==n.removeFromConfig||t[197]!==o||t[198]!==q||t[199]!==D||t[200]!==a.id?(xt=a.id===`main`?null:(0,Z.jsxs)(zt,{children:[(0,Z.jsx)(Rt,{icon:Ue,title:q(`Danger Zone`,`危险操作`),subtitle:q(`Actions that cannot be undone. Be careful.`,`以下操作不可撤销,请谨慎操作。`)}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsxs)(Ct,{type:`button`,variant:`secondary`,disabled:o,onClick:()=>void D(!1),children:[(0,Z.jsx)(pt,{className:`mr-1 size-4`,"aria-hidden":!0}),n.removeFromConfig]}),(0,Z.jsx)(Ct,{type:`button`,variant:`secondary`,className:`border-red-200 text-red-700 hover:bg-red-50 dark:border-red-900/60 dark:text-red-300 dark:hover:bg-red-950/40`,disabled:o,onClick:()=>void D(!0),children:n.purgeDisk})]})]}),t[195]=n.purgeDisk,t[196]=n.removeFromConfig,t[197]=o,t[198]=q,t[199]=D,t[200]=a.id,t[201]=xt):xt=t[201];let St;return t[202]!==tt||t[203]!==ae||t[204]!==yt||t[205]!==bt||t[206]!==xt?(St=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-8 overflow-y-auto`,children:[ae,tt,yt,bt,xt]}),t[202]=tt,t[203]=ae,t[204]=yt,t[205]=bt,t[206]=xt,t[207]=St):St=t[207],St}function In(e){return e.preventDefault()}function Ln(e){return e.resolved===`dark`}function Rn(e){return e.language}function zn(e){let t=!e.pronouns||Nn.some(t=>t.value===e.pronouns),n=jn.some(t=>t.value===e.timezone);return{showCustomPronouns:!!(e.pronouns&&!t),showCustomTimezone:!!(e.timezone&&!n),customTimezone:e.timezone&&!n?e.timezone:``}}function Bn(e,t){switch(t.type){case`load`:{let e=zn(t.user),n=JSON.stringify(t.user);return{user:t.user,snapshot:n,...e}}case`patch`:{let n={...e.user,...t.patch};return{...e,user:n}}case`setShowCustomPronouns`:return{...e,showCustomPronouns:t.value};case`setShowCustomTimezone`:return{...e,showCustomTimezone:t.value};case`setCustomTimezone`:return{...e,customTimezone:t.value};case`saved`:return{...e,snapshot:JSON.stringify(e.user)}}}var Vn={callName:``,pronouns:``,timezone:``,notes:``},Hn={user:Vn,showCustomPronouns:!1,showCustomTimezone:!1,customTimezone:``,snapshot:JSON.stringify(Vn)};function Un({a:e,agentId:t,saveRef:n,onDirtyChange:r}){let a=i(e=>e.language),[o,s]=(0,Q.useReducer)(Bn,Hn),c=(0,Q.useRef)(t);c.current=t;let l=(0,Q.useRef)(r);l.current=r;let u=G(async()=>{let e=wn(await S(t,`USER.md`).catch(()=>``));if(!e.timezone){let t=Mn();if(t)return{...e,timezone:t}}return e},[t],{enabled:!!t,initial:null,errorData:Vn}),d=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{u.loading||!u.data||d.current!==t&&(d.current=t,s({type:`load`,user:u.data}),l.current?.(!1))},[t,u.loading,u.data]);let f=(0,Q.useCallback)(async e=>{await R(c.current,`USER.md`,e)},[]),p=(0,Q.useRef)(o.user);p.current=o.user,(0,Q.useEffect)(()=>{if(n)return n.current=async()=>{await f(Tn(p.current)),s({type:`saved`}),l.current?.(!1)},()=>{n.current=null}},[n,f]);let m=(0,Q.useCallback)(e=>{s({type:`patch`,patch:e});let t={...p.current,...e};l.current?.(JSON.stringify(t)!==o.snapshot)},[o.snapshot]),h=(0,Q.useCallback)(e=>{if(e===`__custom__`){s({type:`setShowCustomTimezone`,value:!0});return}s({type:`setShowCustomTimezone`,value:!1}),s({type:`setCustomTimezone`,value:``}),m({timezone:e})},[m]),g=(0,Q.useCallback)(e=>{s({type:`setCustomTimezone`,value:e}),m({timezone:e})},[m]),_=(0,Q.useCallback)(()=>{let e=Mn();e&&(jn.some(t=>t.value===e)?(s({type:`setShowCustomTimezone`,value:!1}),s({type:`setCustomTimezone`,value:``})):(s({type:`setShowCustomTimezone`,value:!0}),s({type:`setCustomTimezone`,value:e})),m({timezone:e}))},[m]),v=o.showCustomTimezone?`__custom__`:jn.some(e=>e.value===o.user.timezone)?o.user.timezone:`__custom__`,y=(0,Q.useCallback)((e,t)=>a===`zh`?t:e,[a]);if(u.loading)return(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.loading});let b=nn(),{user:x,showCustomPronouns:C,showCustomTimezone:w,customTimezone:T}=o;return(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-6 overflow-y-auto`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.personaSectionUserHint}),(0,Z.jsxs)(zt,{children:[(0,Z.jsx)(Rt,{icon:Ft,title:e.personaSectionUser,subtitle:e.personaSectionUserHint}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:e.personaCallName}),(0,Z.jsx)(`input`,{className:b,value:x.callName,onChange:e=>m({callName:e.target.value}),placeholder:e.personaCallNamePlaceholder,autoComplete:`off`})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:e.personaPronouns}),(0,Z.jsxs)(`select`,{className:b,value:Nn.some(e=>e.value===x.pronouns)?x.pronouns:`__custom__`,onChange:e=>{if(e.target.value===`__custom__`){s({type:`setShowCustomPronouns`,value:!0});return}s({type:`setShowCustomPronouns`,value:!1}),m({pronouns:e.target.value})},children:[(0,Z.jsx)(`option`,{value:``,disabled:!0,children:e.personaPronounsPlaceholder}),Nn.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:y(e.labelEn,e.labelZh)},e.value)),(0,Z.jsx)(`option`,{value:`__custom__`,children:y(`Custom…`,`自定义…`)})]}),C?(0,Z.jsx)(`input`,{className:Y(b,`mt-1 text-xs`),value:Nn.some(e=>e.value===x.pronouns)?``:x.pronouns,onChange:e=>m({pronouns:e.target.value}),placeholder:e.personaPronounsPlaceholder,autoComplete:`off`}):null]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:e.personaTimezone}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[(0,Z.jsxs)(`select`,{className:Y(b,`min-w-0 flex-1`),value:v,onChange:e=>h(e.target.value),children:[jn.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:y(e.labelEn,e.labelZh)},e.value)),(0,Z.jsx)(`option`,{value:`__custom__`,children:e.personaTimezoneCustom})]}),(0,Z.jsx)(`button`,{type:`button`,className:Y(`shrink-0 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,Lt.press),onClick:_,children:e.personaTimezoneDetect})]}),w?(0,Z.jsx)(`input`,{className:Y(b,`mt-1 font-mono text-xs`),value:T,onChange:e=>g(e.target.value),placeholder:`e.g. Asia/Shanghai`,autoComplete:`off`}):null]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:e.personaNotes}),(0,Z.jsx)(`textarea`,{className:Y(b,`min-h-16 resize-y text-sm leading-relaxed`),value:x.notes,onChange:e=>m({notes:e.target.value}),placeholder:e.personaNotesPlaceholder,rows:3,spellCheck:!0})]})]}),(0,Z.jsxs)(`div`,{className:`mt-3 flex items-start gap-2 rounded-lg bg-accent-soft/30 px-3 py-2.5 text-xs text-fg-muted`,children:[(0,Z.jsx)(at,{className:`mt-0.5 size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:e.personaMemoryNote})]})]})]})}function Wn(e){let t=(0,X.c)(2),n;return t[0]===e?n=t[1]:(n=(0,Z.jsx)(Un,{...e},e.agentId),t[0]=e,t[1]=n),n}function Gn(e){let t=(0,X.c)(65),{a:n,selected:r,busy:i,skillsCatalogLoading:a,catalogForPick:o,skillsInherit:s,setSkillsInherit:c,skillsPick:l,setSkillsPick:u,onSaveSkills:d,hideInlineSave:f}=e,p;t[0]===r.skills.effectiveAllowlist?p=t[1]:(p=function(e){let t=r.skills.effectiveAllowlist;return t===void 0?!0:t.length===0?!1:t.includes(e)},t[0]=r.skills.effectiveAllowlist,t[1]=p);let m=p,h;t[2]!==o||t[3]!==r.skills.effectiveAllowlist?(h=function(){let e=r.skills.effectiveAllowlist;return e===void 0?new Set(o.map(Kn)):new Set(e)},t[2]=o,t[3]=r.skills.effectiveAllowlist,t[4]=h):h=t[4];let g=h,_;t[5]!==n.skillsHint||t[6]!==n.skillsTitle?(_=(0,Z.jsx)(Rt,{className:`shrink-0`,icon:y,title:n.skillsTitle,subtitle:n.skillsHint}),t[5]=n.skillsHint,t[6]=n.skillsTitle,t[7]=_):_=t[7];let v;t[8]===c?v=t[9]:(v=()=>c(!0),t[8]=c,t[9]=v);let b;t[10]!==n.skillsInherit||t[11]!==i||t[12]!==v?(b=(0,Z.jsx)(Ct,{type:`button`,variant:`secondary`,disabled:i,onClick:v,children:n.skillsInherit}),t[10]=n.skillsInherit,t[11]=i,t[12]=v,t[13]=b):b=t[13];let x;t[14]!==g||t[15]!==c||t[16]!==u?(x=()=>{c(!1),u(g())},t[14]=g,t[15]=c,t[16]=u,t[17]=x):x=t[17];let S;t[18]!==n.skillsCustomize||t[19]!==i||t[20]!==x?(S=(0,Z.jsx)(Ct,{type:`button`,variant:`secondary`,disabled:i,onClick:x,children:n.skillsCustomize}),t[18]=n.skillsCustomize,t[19]=i,t[20]=x,t[21]=S):S=t[21];let C;t[22]!==b||t[23]!==S?(C=(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[b,S]}),t[22]=b,t[23]=S,t[24]=C):C=t[24];let w;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(w=M(`skills`),t[25]=w):w=t[25];let T;t[26]===n.skillsLibraryLink?T=t[27]:(T=(0,Z.jsx)(lt,{to:w,className:`shrink-0 text-xs font-medium text-accent-fg hover:underline`,children:n.skillsLibraryLink}),t[26]=n.skillsLibraryLink,t[27]=T);let E;t[28]!==C||t[29]!==T?(E=(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3`,children:[C,T]}),t[28]=C,t[29]=T,t[30]=E):E=t[30];let D;t[31]===r.skills.defaults?D=t[32]:(D=r.skills.defaults.length?r.skills.defaults.join(`, `):`—`,t[31]=r.skills.defaults,t[32]=D);let O;t[33]!==n.skillsDefaultsLabel||t[34]!==D?(O=(0,Z.jsxs)(`p`,{className:`mt-2 shrink-0 text-xs text-fg-muted`,children:[n.skillsDefaultsLabel,` `,D]}),t[33]=n.skillsDefaultsLabel,t[34]=D,t[35]=O):O=t[35];let k;t[36]!==n.skillsAllFromCatalog||t[37]!==r.skills.effectiveAllowlist?(k=r.skills.effectiveAllowlist?.length?r.skills.effectiveAllowlist.join(`, `):n.skillsAllFromCatalog,t[36]=n.skillsAllFromCatalog,t[37]=r.skills.effectiveAllowlist,t[38]=k):k=t[38];let A;t[39]!==n.skillsEffectiveLabel||t[40]!==k?(A=(0,Z.jsxs)(`p`,{className:`shrink-0 text-xs text-fg-muted`,children:[n.skillsEffectiveLabel,` `,k]}),t[39]=n.skillsEffectiveLabel,t[40]=k,t[41]=A):A=t[41];let j;t[42]!==n.skillsCatalogLoading||t[43]!==n.skillsEmptyCatalog||t[44]!==n.skillsNoDescription||t[45]!==i||t[46]!==o||t[47]!==m||t[48]!==u||t[49]!==a||t[50]!==s||t[51]!==l?(j=a?(0,Z.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:n.skillsCatalogLoading}):o.length===0?(0,Z.jsx)(`p`,{className:`shrink-0 text-sm text-fg-muted`,children:n.skillsEmptyCatalog}):(0,Z.jsx)(`div`,{className:Y(`mt-3 min-h-0 flex-1 overflow-y-auto overscroll-contain pr-0.5`,s&&`opacity-50`),children:(0,Z.jsx)(`ul`,{className:`flex flex-col gap-2.5 text-sm`,children:o.map(e=>{let t=e.name||e.directoryId,r=s?m(t):l.has(t),a=typeof e.description==`string`?e.description.trim():``,o=a||n.skillsNoDescription;return(0,Z.jsx)(`li`,{className:`h-16 shrink-0 overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel/60 px-3 dark:border-edge-subtle`,children:(0,Z.jsxs)(`label`,{className:`flex h-full cursor-pointer items-center gap-3 text-sm`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`shrink-0 rounded border-edge`,checked:r,disabled:s||i,onChange:()=>{u(e=>{let n=new Set(e);return r?n.delete(t):n.add(t),n})},"aria-label":t}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:[(0,Z.jsx)(`div`,{className:`truncate font-mono text-xs font-medium text-fg`,title:t,children:t}),(0,Z.jsx)(`p`,{className:Y(`mt-0.5 truncate text-xs leading-tight text-fg-muted`,!a&&`italic text-fg-subtle`),title:o,children:o})]})]})},t)})})}),t[42]=n.skillsCatalogLoading,t[43]=n.skillsEmptyCatalog,t[44]=n.skillsNoDescription,t[45]=i,t[46]=o,t[47]=m,t[48]=u,t[49]=a,t[50]=s,t[51]=l,t[52]=j):j=t[52];let N;t[53]!==n.skillsSave||t[54]!==i||t[55]!==f||t[56]!==d?(N=f?null:(0,Z.jsx)(`div`,{className:`mt-4 shrink-0`,children:(0,Z.jsx)(Ct,{type:`button`,disabled:i,onClick:()=>void d(),children:n.skillsSave})}),t[53]=n.skillsSave,t[54]=i,t[55]=f,t[56]=d,t[57]=N):N=t[57];let P;return t[58]!==E||t[59]!==O||t[60]!==A||t[61]!==j||t[62]!==N||t[63]!==_?(P=(0,Z.jsxs)(zt,{className:`flex min-h-0 flex-1 flex-col`,children:[_,E,O,A,j,N]}),t[58]=E,t[59]=O,t[60]=A,t[61]=j,t[62]=N,t[63]=_,t[64]=P):P=t[64],P}function Kn(e){return e.name||e.directoryId}var qn=[{key:`workspace`,toolIds:[`read_file`,`write_file`,`edit_file`,`list_dir`,`grep`,`find`]},{key:`execution`,toolIds:[`shell`]},{key:`messaging`,toolIds:[`send_message`,`send_media`]},{key:`memory`,toolIds:[`memory_search`,`memory_get`,`curated_memory`,`session_search`]},{key:`media`,toolIds:[`image`,`image_generate`]},{key:`web`,toolIds:[`web_search`,`web_fetch`,`browser_use`]},{key:`extensions`,toolIds:[`extensions`]},{key:`mcp`,toolIds:[`bundle-mcp`]}],Jn=new Set(qn.flatMap(e=>[...e.toolIds].map(e=>String(e))));function Yn(e){return e.filter(e=>e&&!Jn.has(e)).sort((e,t)=>e.localeCompare(t))}function Xn(){return Y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Be,`dark:border-edge`)}function Zn(){return Y(b,Ee)}var Qn=`h-auto shrink-0 px-2.5 py-1.5 text-xs font-medium`,$n=[`write_file`,`edit_file`,`shell`],er=[`shell`,`image_generate`,`extensions`],tr=[`send_message`,`send_media`];function nr(e){let t=(0,X.c)(88),{mode:n,builtinToolIds:r,loading:i,disableSet:a,onDisableSetChange:o,defaultsDisableSet:s,unknownDisabledIds:c,getToolDescription:l,getGroupTitle:u,labels:d,quickActionsDisabled:f}=e,p;t[0]===c?p=t[1]:(p=c===void 0?[]:c,t[0]=c,t[1]=p);let m=p,h=f===void 0?!1:f,g;t[2]===r?g=t[3]:(g=new Set(r),t[2]=r,t[3]=g);let _=g,v;t[4]===s?v=t[5]:(v=s??new Set,t[4]=s,t[5]=v);let y=v,b;t[6]!==y||t[7]!==a||t[8]!==n||t[9]!==o?(b=(e,t)=>{if(n===`agentEntry`&&t&&y.has(e))return;let r=new Set(a);t?r.delete(e):r.add(e),o(r)},t[6]=y,t[7]=a,t[8]=n,t[9]=o,t[10]=b):b=t[10];let x=b,S;t[11]!==_||t[12]!==o?(S=e=>{let t=new Set;for(let n of e)_.has(n)&&t.add(n);o(t)},t[11]=_,t[12]=o,t[13]=S):S=t[13];let C=S,w;t[14]===o?w=t[15]:(w=()=>{o(new Set)},t[14]=o,t[15]=w);let T=w,E;t[16]!==r||t[17]!==o||t[18]!==m?(E=()=>{o(new Set([...r,...m]))},t[16]=r,t[17]=o,t[18]=m,t[19]=E):E=t[19];let D=E,O;t[20]===r?O=t[21]:(O=Yn(r),t[20]=r,t[21]=O);let k=O,A;if(t[22]!==_||t[23]!==k||t[24]!==n||t[25]!==m){if(A=[],n===`defaults`&&m.length>0){let e;t[27]===m?e=t[28]:(e=m.toSorted(ir),t[27]=m,t[28]=e);let n;t[29]===e?n=t[30]:(n={key:`unknown`,ids:e},t[29]=e,t[30]=n),A.push(n)}for(let e of qn){let t=e.toolIds.filter(e=>_.has(e));t.length>0&&A.push({key:e.key,ids:[...t]})}if(k.length>0){let e;t[31]===k?e=t[32]:(e={key:`misc`,ids:k},t[31]=k,t[32]=e),A.push(e)}t[22]=_,t[23]=k,t[24]=n,t[25]=m,t[26]=A}else A=t[26];let j=A,M=j.some(rr),N=h||i,P;t[33]===d.quickActionsLabel?P=t[34]:(P=(0,Z.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:d.quickActionsLabel}),t[33]=d.quickActionsLabel,t[34]=P);let F=N||r.length===0&&m.length===0,I;t[35]!==T||t[36]!==d.quickEnableAll||t[37]!==F?(I=(0,Z.jsx)(Ct,{type:`button`,variant:`secondary`,className:Qn,disabled:F,onClick:T,children:d.quickEnableAll}),t[35]=T,t[36]=d.quickEnableAll,t[37]=F,t[38]=I):I=t[38];let ee=N||r.length===0&&m.length===0,L;t[39]!==D||t[40]!==d.quickDisableAll||t[41]!==ee?(L=(0,Z.jsx)(Ct,{type:`button`,variant:`secondary`,className:Qn,disabled:ee,onClick:D,children:d.quickDisableAll}),t[39]=D,t[40]=d.quickDisableAll,t[41]=ee,t[42]=L):L=t[42];let R=N||r.length===0,z;t[43]===C?z=t[44]:(z=()=>C($n),t[43]=C,t[44]=z);let B;t[45]!==d.quickReadOnlyWorkspace||t[46]!==R||t[47]!==z?(B=(0,Z.jsx)(Ct,{type:`button`,variant:`secondary`,className:Qn,disabled:R,onClick:z,children:d.quickReadOnlyWorkspace}),t[45]=d.quickReadOnlyWorkspace,t[46]=R,t[47]=z,t[48]=B):B=t[48];let V=N||r.length===0,H;t[49]===C?H=t[50]:(H=()=>C(er),t[49]=C,t[50]=H);let U;t[51]!==d.quickHighRiskOff||t[52]!==V||t[53]!==H?(U=(0,Z.jsx)(Ct,{type:`button`,variant:`secondary`,className:Qn,disabled:V,onClick:H,children:d.quickHighRiskOff}),t[51]=d.quickHighRiskOff,t[52]=V,t[53]=H,t[54]=U):U=t[54];let W=N||r.length===0,te;t[55]===C?te=t[56]:(te=()=>C(tr),t[55]=C,t[56]=te);let ne;t[57]!==d.quickNoOutbound||t[58]!==W||t[59]!==te?(ne=(0,Z.jsx)(Ct,{type:`button`,variant:`secondary`,className:Qn,disabled:W,onClick:te,children:d.quickNoOutbound}),t[57]=d.quickNoOutbound,t[58]=W,t[59]=te,t[60]=ne):ne=t[60];let G;t[61]!==I||t[62]!==L||t[63]!==B||t[64]!==U||t[65]!==ne?(G=(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[I,L,B,U,ne]}),t[61]=I,t[62]=L,t[63]=B,t[64]=U,t[65]=ne,t[66]=G):G=t[66];let K;t[67]!==P||t[68]!==G?(K=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[P,G]}),t[67]=P,t[68]=G,t[69]=K):K=t[69];let q;t[70]!==y||t[71]!==a||t[72]!==u||t[73]!==l||t[74]!==j||t[75]!==M||t[76]!==d.emptyBuiltin||t[77]!==d.loadingBuiltin||t[78]!==d.lockedByDefaults||t[79]!==d.notInBuiltin||t[80]!==i||t[81]!==n||t[82]!==N||t[83]!==x?(q=i?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:d.loadingBuiltin}):M?(0,Z.jsx)(`div`,{className:`max-h-[min(50vh,22rem)] overflow-y-auto overscroll-contain pr-0.5`,children:(0,Z.jsx)(`div`,{className:`flex flex-col gap-5 pr-1`,children:j.map(e=>{let{key:t,ids:r}=e;return(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:u(t)}),(0,Z.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:r.map(e=>{let r=n===`defaults`&&t===`unknown`,i=n===`agentEntry`&&y.has(e),o=a.has(e),s=i?!1:!o,c=l(e);return(0,Z.jsx)(`li`,{className:Y(`rounded-xl border border-edge-subtle bg-surface-panel/60 px-3 py-2.5 dark:border-edge-subtle`,r&&`border-dashed`,i&&`opacity-60`),children:(0,Z.jsxs)(`label`,{className:Y(`flex gap-3 text-sm`,i?`cursor-not-allowed`:`cursor-pointer`),children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`mt-1 shrink-0 rounded border-edge`,checked:s,disabled:i||N,onChange:()=>x(e,!s)}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-xs font-medium text-fg`,children:e}),r?(0,Z.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[`(`,d.notInBuiltin,`)`]}):null,i?(0,Z.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[`(`,d.lockedByDefaults,`)`]}):null]}),c?(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:c}):null]})]})},e)})})]},t)})})}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:d.emptyBuiltin}),t[70]=y,t[71]=a,t[72]=u,t[73]=l,t[74]=j,t[75]=M,t[76]=d.emptyBuiltin,t[77]=d.loadingBuiltin,t[78]=d.lockedByDefaults,t[79]=d.notInBuiltin,t[80]=i,t[81]=n,t[82]=N,t[83]=x,t[84]=q):q=t[84];let re;return t[85]!==K||t[86]!==q?(re=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[K,q]}),t[85]=K,t[86]=q,t[87]=re):re=t[87],re}function rr(e){return e.ids.length>0}function ir(e,t){return e.localeCompare(t)}function ar(e){let t=(0,X.c)(51),{a:n,data:r,selected:o,busy:s,toolEntryDisable:c,setToolEntryDisable:l,onSaveTools:u,onClearToolsEntry:d,hideInlineSave:f}=e,p=i(sr),m;t[0]===p?m=t[1]:(m=a(p),t[0]=p,t[1]=m);let h=m.agentSettings.advanced,g;t[2]===o.tools.defaultsDisable?g=t[3]:(g=new Set(o.tools.defaultsDisable.flatMap(or)),t[2]=o.tools.defaultsDisable,t[3]=g);let _=g,v;t[4]===l?v=t[5]:(v=e=>{l(e)},t[4]=l,t[5]=v);let y=v,b=n.toolsDisableGroups,x;t[6]===b?x=t[7]:(x=e=>b[e],t[6]=b,t[7]=x);let S=x,C;t[8]===n.toolDescriptions?C=t[9]:(C=e=>e in n.toolDescriptions?n.toolDescriptions[e]:``,t[8]=n.toolDescriptions,t[9]=C);let w=C,T;t[10]!==n.toolsHint||t[11]!==n.toolsTitle?(T=(0,Z.jsx)(Rt,{className:`shrink-0`,icon:Me,title:n.toolsTitle,subtitle:n.toolsHint}),t[10]=n.toolsHint,t[11]=n.toolsTitle,t[12]=T):T=t[12];let E;t[13]!==n.toolsLockedByDefaults||t[14]!==h.toolsDisableEmptyBuiltin||t[15]!==h.toolsDisableLoadingBuiltin||t[16]!==h.toolsDisableNotInBuiltin||t[17]!==h.toolsDisableQuickActionsLabel||t[18]!==h.toolsDisableQuickDisableAll||t[19]!==h.toolsDisableQuickEnableAll||t[20]!==h.toolsDisableQuickHighRiskOff||t[21]!==h.toolsDisableQuickNoOutbound||t[22]!==h.toolsDisableQuickReadOnlyWorkspace?(E={loadingBuiltin:h.toolsDisableLoadingBuiltin,emptyBuiltin:h.toolsDisableEmptyBuiltin,quickActionsLabel:h.toolsDisableQuickActionsLabel,quickEnableAll:h.toolsDisableQuickEnableAll,quickDisableAll:h.toolsDisableQuickDisableAll,quickReadOnlyWorkspace:h.toolsDisableQuickReadOnlyWorkspace,quickHighRiskOff:h.toolsDisableQuickHighRiskOff,quickNoOutbound:h.toolsDisableQuickNoOutbound,notInBuiltin:h.toolsDisableNotInBuiltin,lockedByDefaults:n.toolsLockedByDefaults},t[13]=n.toolsLockedByDefaults,t[14]=h.toolsDisableEmptyBuiltin,t[15]=h.toolsDisableLoadingBuiltin,t[16]=h.toolsDisableNotInBuiltin,t[17]=h.toolsDisableQuickActionsLabel,t[18]=h.toolsDisableQuickDisableAll,t[19]=h.toolsDisableQuickEnableAll,t[20]=h.toolsDisableQuickHighRiskOff,t[21]=h.toolsDisableQuickNoOutbound,t[22]=h.toolsDisableQuickReadOnlyWorkspace,t[23]=E):E=t[23];let D;t[24]!==s||t[25]!==r.builtinToolIds||t[26]!==_||t[27]!==S||t[28]!==w||t[29]!==y||t[30]!==E||t[31]!==c?(D=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Z.jsx)(nr,{mode:`agentEntry`,builtinToolIds:r.builtinToolIds,loading:!1,disableSet:c,onDisableSetChange:y,defaultsDisableSet:_,getToolDescription:w,getGroupTitle:S,quickActionsDisabled:s,labels:E})}),t[24]=s,t[25]=r.builtinToolIds,t[26]=_,t[27]=S,t[28]=w,t[29]=y,t[30]=E,t[31]=c,t[32]=D):D=t[32];let O;t[33]!==n.toolsSave||t[34]!==s||t[35]!==f||t[36]!==u?(O=f?null:(0,Z.jsx)(Ct,{type:`button`,disabled:s,onClick:()=>void u(),children:n.toolsSave}),t[33]=n.toolsSave,t[34]=s,t[35]=f,t[36]=u,t[37]=O):O=t[37];let k;t[38]===d?k=t[39]:(k=()=>void d(),t[38]=d,t[39]=k);let A;t[40]!==n.toolsClearEntry||t[41]!==s||t[42]!==k?(A=(0,Z.jsx)(Ct,{type:`button`,variant:`secondary`,disabled:s,onClick:k,children:n.toolsClearEntry}),t[40]=n.toolsClearEntry,t[41]=s,t[42]=k,t[43]=A):A=t[43];let j;t[44]!==A||t[45]!==O?(j=(0,Z.jsxs)(`div`,{className:`mt-4 flex shrink-0 flex-wrap gap-2`,children:[O,A]}),t[44]=A,t[45]=O,t[46]=j):j=t[46];let M;return t[47]!==j||t[48]!==T||t[49]!==D?(M=(0,Z.jsxs)(zt,{className:`flex min-h-0 flex-1 flex-col`,children:[T,D,j]}),t[47]=j,t[48]=T,t[49]=D,t[50]=M):M=t[50],M}function or(e){let t=String(e).trim();return t?[t]:[]}function sr(e){return e.language}function cr(e){let t=(0,X.c)(96),{a:n,chat:r,cCron:i,selected:a,panel:o,data:s,busy:c,editName:l,setEditName:u,editDescription:d,setEditDescription:f,editWorkspace:p,setEditWorkspace:m,editModel:h,setEditModel:g,defaultModel:_,defaultWorkspace:v,onSetDefault:y,onSaveAgentEdits:b,onDelete:x,profileSaveRef:S,overviewProfile:C,setProfileDirty:w,filesLoading:T,files:E,activeFile:D,setActiveFile:O,filesViewMode:k,setFilesViewMode:A,fileDraft:j,setFileDraft:M,fileSaving:N,profileFileLoading:P,profileEditorNonce:F,toolEntryDisable:I,setToolEntryDisable:ee,onSaveTools:L,onClearToolsEntry:R,skillsCatalogLoading:z,catalogForPick:B,skillsInherit:V,setSkillsInherit:H,skillsPick:U,setSkillsPick:W,onSaveSkills:te,bindingsLoading:ne,agentBindings:G,bindChannelStatuses:K,bindChannelsLoading:q,useManualChannel:re,newBindChannel:ie,setNewBindChannel:ae,bindSessionChats:oe,bindSessionsLoading:se,newBindSessionIdx:ce,setNewBindSessionIdx:le,newBindCustomPeer:ue,setNewBindCustomPeer:de,refreshBindSessions:fe,onRemoveBinding:pe,onAddBinding:me,cronLoading:he,agentCronJobs:ge,onSetCronJobAgent:_e}=e;if(!a){let e;return t[0]===n.selectAgentHint?e=t[1]:(e=(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.selectAgentHint}),t[0]=n.selectAgentHint,t[1]=e),e}if(o===`overview`){let e;return t[2]!==n||t[3]!==c||t[4]!==r||t[5]!==_||t[6]!==v||t[7]!==d||t[8]!==h||t[9]!==l||t[10]!==p||t[11]!==x||t[12]!==b||t[13]!==y||t[14]!==C.draft||t[15]!==C.handleSoulContentChange||t[16]!==C.handleSoulTemplateChange||t[17]!==C.profileMarkdownLoading||t[18]!==C.setAvatarDialogOpen||t[19]!==C.toggleSoulPreviewMode||t[20]!==C.updateIdentity||t[21]!==a||t[22]!==f||t[23]!==g||t[24]!==u||t[25]!==m?(e=(0,Z.jsx)(Fn,{a:n,chat:r,selected:a,busy:c,editName:l,setEditName:u,editDescription:d,setEditDescription:f,editWorkspace:p,setEditWorkspace:m,editModel:h,setEditModel:g,onSetDefault:y,onSaveAgentEdits:b,onDelete:x,hideInlineSave:!0,profileMarkdownLoading:C.profileMarkdownLoading,profileDraft:C.draft,updateIdentity:C.updateIdentity,handleSoulTemplateChange:C.handleSoulTemplateChange,handleSoulContentChange:C.handleSoulContentChange,setAvatarDialogOpen:C.setAvatarDialogOpen,toggleSoulPreviewMode:C.toggleSoulPreviewMode,defaultModel:_,defaultWorkspace:v}),t[2]=n,t[3]=c,t[4]=r,t[5]=_,t[6]=v,t[7]=d,t[8]=h,t[9]=l,t[10]=p,t[11]=x,t[12]=b,t[13]=y,t[14]=C.draft,t[15]=C.handleSoulContentChange,t[16]=C.handleSoulTemplateChange,t[17]=C.profileMarkdownLoading,t[18]=C.setAvatarDialogOpen,t[19]=C.toggleSoulPreviewMode,t[20]=C.updateIdentity,t[21]=a,t[22]=f,t[23]=g,t[24]=u,t[25]=m,t[26]=e):e=t[26],e}if(o===`profile`){let e;return t[27]!==n||t[28]!==S||t[29]!==a.id||t[30]!==w?(e=(0,Z.jsx)(Wn,{a:n,agentId:a.id,saveRef:S,onDirtyChange:w}),t[27]=n,t[28]=S,t[29]=a.id,t[30]=w,t[31]=e):e=t[31],e}if(o===`files`){let e;return t[32]!==n||t[33]!==D||t[34]!==j||t[35]!==N||t[36]!==E||t[37]!==T||t[38]!==k||t[39]!==F||t[40]!==P||t[41]!==O||t[42]!==M||t[43]!==A?(e=(0,Z.jsx)(pn,{a:n,filesLoading:T,files:E,activeFile:D,setActiveFile:O,filesViewMode:k,setFilesViewMode:A,fileDraft:j,setFileDraft:M,fileSaving:N,profileFileLoading:P,profileEditorNonce:F}),t[32]=n,t[33]=D,t[34]=j,t[35]=N,t[36]=E,t[37]=T,t[38]=k,t[39]=F,t[40]=P,t[41]=O,t[42]=M,t[43]=A,t[44]=e):e=t[44],e}if(o===`tools`){let e;return t[45]!==n||t[46]!==c||t[47]!==s||t[48]!==R||t[49]!==L||t[50]!==a||t[51]!==ee||t[52]!==I?(e=(0,Z.jsx)(ar,{a:n,data:s,selected:a,busy:c,toolEntryDisable:I,setToolEntryDisable:ee,onSaveTools:L,onClearToolsEntry:R,hideInlineSave:!0}),t[45]=n,t[46]=c,t[47]=s,t[48]=R,t[49]=L,t[50]=a,t[51]=ee,t[52]=I,t[53]=e):e=t[53],e}if(o===`skills`){let e;return t[54]!==n||t[55]!==c||t[56]!==B||t[57]!==te||t[58]!==a||t[59]!==H||t[60]!==W||t[61]!==z||t[62]!==V||t[63]!==U?(e=(0,Z.jsx)(Gn,{a:n,selected:a,busy:c,skillsCatalogLoading:z,catalogForPick:B,skillsInherit:V,setSkillsInherit:H,skillsPick:U,setSkillsPick:W,onSaveSkills:te,hideInlineSave:!0}),t[54]=n,t[55]=c,t[56]=B,t[57]=te,t[58]=a,t[59]=H,t[60]=W,t[61]=z,t[62]=V,t[63]=U,t[64]=e):e=t[64],e}if(o===`channels`){let e;return t[65]!==n||t[66]!==G||t[67]!==K||t[68]!==q||t[69]!==oe||t[70]!==se||t[71]!==ne||t[72]!==c||t[73]!==i.lastActiveLabels||t[74]!==i.selectRecipient||t[75]!==ie||t[76]!==ue||t[77]!==ce||t[78]!==me||t[79]!==pe||t[80]!==fe||t[81]!==ae||t[82]!==de||t[83]!==le||t[84]!==re?(e=(0,Z.jsx)(cn,{a:n,busy:c,bindingsLoading:ne,agentBindings:G,channelStatuses:K,channelsStatusLoading:q,useManualChannel:re,newBindChannel:ie,setNewBindChannel:ae,bindSessionChats:oe,sessionsLoading:se,newBindSessionIdx:ce,setNewBindSessionIdx:le,newBindCustomPeer:ue,setNewBindCustomPeer:de,onRefreshSessions:fe,lastActiveLabels:i.lastActiveLabels,selectRecipient:i.selectRecipient,onRemoveBinding:pe,onAddBinding:me}),t[65]=n,t[66]=G,t[67]=K,t[68]=q,t[69]=oe,t[70]=se,t[71]=ne,t[72]=c,t[73]=i.lastActiveLabels,t[74]=i.selectRecipient,t[75]=ie,t[76]=ue,t[77]=ce,t[78]=me,t[79]=pe,t[80]=fe,t[81]=ae,t[82]=de,t[83]=le,t[84]=re,t[85]=e):e=t[85],e}if(o===`cron`&&s){let e;return t[86]!==n||t[87]!==ge||t[88]!==c||t[89]!==he||t[90]!==s||t[91]!==_e||t[92]!==a?(e=(0,Z.jsx)(un,{a:n,data:s,selected:a,busy:c,cronLoading:he,agentCronJobs:ge,onSetCronJobAgent:_e}),t[86]=n,t[87]=ge,t[88]=c,t[89]=he,t[90]=s,t[91]=_e,t[92]=a,t[93]=e):e=t[93],e}let ve;return t[94]===n.selectAgentHint?ve=t[95]:(ve=(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.selectAgentHint}),t[94]=n.selectAgentHint,t[95]=ve),ve}function lr(e,t,n){let r=t.trim().toLowerCase();return r?e.filter(e=>{let t=k(e,n).toLowerCase(),i=e.id.toLowerCase(),a=e.workspace.toLowerCase(),o=(e.description??``).toLowerCase(),s=q(e,n).toLowerCase();return t.includes(r)||i.includes(r)||a.includes(r)||o.includes(r)||s.includes(r)}):e}function ur(e){let t=(0,X.c)(10),{a:n,busy:r,onNewAgent:i}=e,a;t[0]===i?a=t[1]:(a=()=>i(),t[0]=i,t[1]=a);let o,s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=Y(`flex h-full min-h-[7.5rem] w-full flex-col items-center justify-center gap-2 rounded-xl border-2 border-dashed border-edge-subtle bg-surface-panel/40 px-4 py-6 text-sm font-medium text-fg-muted transition-colors`,`hover:border-accent/50 hover:bg-surface-hover hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,`disabled:pointer-events-none disabled:opacity-50`,Lt.pressCard),s=(0,Z.jsx)(ye,{className:`size-8 shrink-0 opacity-80`,strokeWidth:1.75,"aria-hidden":!0}),t[2]=o,t[3]=s):(o=t[2],s=t[3]);let c;t[4]===n.listNewAgentCard?c=t[5]:(c=(0,Z.jsx)(`span`,{children:n.listNewAgentCard}),t[4]=n.listNewAgentCard,t[5]=c);let l;return t[6]!==r||t[7]!==a||t[8]!==c?(l=(0,Z.jsxs)(`button`,{type:`button`,disabled:r,onClick:a,className:o,children:[s,c]}),t[6]=r,t[7]=a,t[8]=c,t[9]=l):l=t[9],l}function dr(e){let t=(0,X.c)(42),{a:n,agents:r,searchQuery:i,onOpenAgent:a,onChatWithAgent:o,onNewAgent:s,busy:c}=e,l,u,d,f,p,m;if(t[0]!==n||t[1]!==r||t[2]!==c||t[3]!==o||t[4]!==s||t[5]!==a||t[6]!==i){m=Symbol.for(`react.early_return_sentinel`);bb0:{let e=lr(r,i,n),h=r.length>0&&e.length===0&&i.trim().length>0;if(r.length===0){let e;t[13]===n.listNoAgentsYet?e=t[14]:(e=(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.listNoAgentsYet}),t[13]=n.listNoAgentsYet,t[14]=e);let r;t[15]!==n||t[16]!==c||t[17]!==s?(r=(0,Z.jsx)(`div`,{className:`max-w-sm`,children:(0,Z.jsx)(ur,{a:n,busy:c,onNewAgent:s})}),t[15]=n,t[16]=c,t[17]=s,t[18]=r):r=t[18];let i;t[19]!==e||t[20]!==r?(i=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[e,r]}),t[19]=e,t[20]=r,t[21]=i):i=t[21],m=i;break bb0}f=`flex flex-col gap-4`,t[22]!==n||t[23]!==h?(p=h?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.listEmpty}):null,t[22]=n,t[23]=h,t[24]=p):p=t[24],l=`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,t[25]!==n||t[26]!==c||t[27]!==s?(u=(0,Z.jsx)(`li`,{className:`h-full min-h-0`,children:(0,Z.jsx)(ur,{a:n,busy:c,onNewAgent:s})}),t[25]=n,t[26]=c,t[27]=s,t[28]=u):u=t[28];let g;t[29]!==n||t[30]!==c||t[31]!==o||t[32]!==a?(g=e=>{let t=k(e,n),r=e.id,i=q(e,n);return(0,Z.jsx)(`li`,{className:`h-full min-h-0`,children:(0,Z.jsxs)(`div`,{className:Y(`flex h-full min-h-0 flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-panel p-4 shadow-sm transition-colors`,`hover:border-edge`),children:[(0,Z.jsxs)(`button`,{type:`button`,disabled:c,onClick:()=>a(e.id),className:Y(`flex shrink-0 w-full flex-col gap-2 text-left transition-colors`,`rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,`disabled:pointer-events-none disabled:opacity-50`,Lt.pressCard),children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Z.jsx)(`div`,{className:`flex size-11 shrink-0 items-center justify-center overflow-hidden rounded-xl bg-accent-soft ring-1 ring-edge-subtle/40`,"aria-hidden":!0,children:(0,Z.jsx)(Te,{agentId:e.id,avatar:e.avatar,size:44,className:`size-full`})}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[(0,Z.jsx)(`span`,{className:`truncate font-semibold text-fg`,children:t}),e.isDefault?(0,Z.jsx)(`span`,{className:`shrink-0 rounded-md bg-surface-base px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:n.defaultBadge}):null]}),(0,Z.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-xs text-fg-muted`,title:r,children:r})]})]}),(0,Z.jsx)(`p`,{className:Y(`line-clamp-1 min-h-[1.3125rem] text-xs leading-relaxed`,i?`text-fg`:`text-fg-muted/25`),title:i||void 0,children:i||`\xA0`})]}),(0,Z.jsxs)(`button`,{type:`button`,disabled:c,onClick:()=>o(e.id),className:Y(`flex w-full shrink-0 items-center justify-center gap-2 rounded-full px-4 py-2.5 text-sm font-semibold`,`bg-accent-soft text-accent-fg transition-colors`,`hover:bg-accent/15`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,`disabled:pointer-events-none disabled:opacity-50`,Lt.press),children:[(0,Z.jsx)(ze,{className:`size-4 shrink-0`,strokeWidth:2,"aria-hidden":!0}),n.listChatWithAgent]})]})},e.id)},t[29]=n,t[30]=c,t[31]=o,t[32]=a,t[33]=g):g=t[33],d=e.map(g)}t[0]=n,t[1]=r,t[2]=c,t[3]=o,t[4]=s,t[5]=a,t[6]=i,t[7]=l,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m}else l=t[7],u=t[8],d=t[9],f=t[10],p=t[11],m=t[12];if(m!==Symbol.for(`react.early_return_sentinel`))return m;let h;t[34]!==l||t[35]!==u||t[36]!==d?(h=(0,Z.jsxs)(`ul`,{className:l,children:[u,d]}),t[34]=l,t[35]=u,t[36]=d,t[37]=h):h=t[37];let g;return t[38]!==f||t[39]!==p||t[40]!==h?(g=(0,Z.jsxs)(`div`,{className:f,children:[p,h]}),t[38]=f,t[39]=p,t[40]=h,t[41]=g):g=t[41],g}function fr(e){let t=(0,X.c)(7),{a:n}=e,r;t[0]===n.title?r=t[1]:(r=(0,Z.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight text-fg`,children:n.title}),t[0]=n.title,t[1]=r);let i;t[2]===n.subtitle?i=t[3]:(i=(0,Z.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:n.subtitle}),t[2]=n.subtitle,t[3]=i);let a;return t[4]!==r||t[5]!==i?(a=(0,Z.jsx)(`header`,{className:`flex flex-col gap-4`,children:(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[r,i]})}),t[4]=r,t[5]=i,t[6]=a):a=t[6],a}function pr(e){let t=(0,X.c)(122),{open:n,onOpenChange:r,a:i,chat:a,busy:o,modalError:s,createDisplayName:h,setCreateDisplayName:g,createAgentId:_,setCreateAgentId:v,createDescription:y,setCreateDescription:b,createWorkspace:x,setCreateWorkspace:S,createModel:C,setCreateModel:w,onCreate:T,onSuggestWorkspace:E}=e,D;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Z.jsx)(l,{className:Y(`xopc-dialog-overlay fixed inset-0 bg-scrim`,We)}),t[0]=D):D=t[0];let O;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(O=Y(`xopc-dialog-content fixed left-1/2 top-1/2 max-h-[min(90vh,640px)] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,Ke,`overflow-y-auto rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`),t[1]=O):O=t[1];let k;t[2]===i.addAgent?k=t[3]:(k=(0,Z.jsx)(p,{className:`text-base font-semibold text-fg`,children:i.addAgent}),t[2]=i.addAgent,t[3]=k);let A;t[4]===i.addAgentHint?A=t[5]:(A=(0,Z.jsx)(f,{className:`mt-0.5 text-xs text-fg-muted`,children:i.addAgentHint}),t[4]=i.addAgentHint,t[5]=A);let j;t[6]!==k||t[7]!==A?(j=(0,Z.jsxs)(`div`,{className:`min-w-0 pr-2`,children:[k,A]}),t[6]=k,t[7]=A,t[8]=j):j=t[8];let M;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(M=Y(ue,`shrink-0 p-1.5 hover:bg-surface-base`),t[9]=M):M=t[9];let N;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Z.jsx)(Ze,{className:`size-4`,"aria-hidden":!0}),t[10]=N):N=t[10];let P;t[11]===i.closeDialogAria?P=t[12]:(P=(0,Z.jsx)(m,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:M,"aria-label":i.closeDialogAria,children:N})}),t[11]=i.closeDialogAria,t[12]=P);let F;t[13]!==j||t[14]!==P?(F=(0,Z.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-2`,children:[j,P]}),t[13]=j,t[14]=P,t[15]=F):F=t[15];let I;t[16]===s?I=t[17]:(I=s?(0,Z.jsx)(`div`,{role:`alert`,className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:s}):null,t[16]=s,t[17]=I);let ee;t[18]===i.newAgentLabel?ee=t[19]:(ee=(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:i.newAgentLabel}),t[18]=i.newAgentLabel,t[19]=ee);let L;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(L=nn(),t[20]=L):L=t[20];let R;t[21]===g?R=t[22]:(R=e=>g(e.target.value),t[21]=g,t[22]=R);let z;t[23]===E?z=t[24]:(z=()=>E(),t[23]=E,t[24]=z);let B;t[25]!==h||t[26]!==R||t[27]!==z?(B=(0,Z.jsx)(`input`,{className:L,value:h,onChange:R,onBlur:z,required:!0,autoComplete:`off`}),t[25]=h,t[26]=R,t[27]=z,t[28]=B):B=t[28];let V;t[29]!==ee||t[30]!==B?(V=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[ee,B]}),t[29]=ee,t[30]=B,t[31]=V):V=t[31];let H;t[32]===i.newAgentIdOptional?H=t[33]:(H=(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:i.newAgentIdOptional}),t[32]=i.newAgentIdOptional,t[33]=H);let U;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(U=Y(nn(),`font-mono text-xs`),t[34]=U):U=t[34];let W;t[35]===v?W=t[36]:(W=e=>v(e.target.value),t[35]=v,t[36]=W);let te;t[37]===E?te=t[38]:(te=()=>E(),t[37]=E,t[38]=te);let ne;t[39]!==i.newAgentIdPlaceholder||t[40]!==i.newAgentIdRules||t[41]!==_||t[42]!==W||t[43]!==te?(ne=(0,Z.jsx)(`input`,{className:U,value:_,onChange:W,onBlur:te,placeholder:i.newAgentIdPlaceholder,autoComplete:`off`,spellCheck:!1,maxLength:64,pattern:`[A-Za-z0-9][A-Za-z0-9_-]{0,63}`,title:i.newAgentIdRules}),t[39]=i.newAgentIdPlaceholder,t[40]=i.newAgentIdRules,t[41]=_,t[42]=W,t[43]=te,t[44]=ne):ne=t[44];let G;t[45]===i.newAgentIdRules?G=t[46]:(G=(0,Z.jsx)(`span`,{className:`text-xs text-fg-muted`,children:i.newAgentIdRules}),t[45]=i.newAgentIdRules,t[46]=G);let K;t[47]!==H||t[48]!==ne||t[49]!==G?(K=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[H,ne,G]}),t[47]=H,t[48]=ne,t[49]=G,t[50]=K):K=t[50];let q;t[51]===i.agentDescription?q=t[52]:(q=(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:i.agentDescription}),t[51]=i.agentDescription,t[52]=q);let re;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(re=Y(nn(),`min-h-[4.5rem] resize-y font-sans text-sm leading-relaxed`),t[53]=re):re=t[53];let ie;t[54]===b?ie=t[55]:(ie=e=>b(e.target.value),t[54]=b,t[55]=ie);let ae;t[56]!==i.agentDescriptionPlaceholder||t[57]!==y||t[58]!==ie?(ae=(0,Z.jsx)(`textarea`,{className:re,value:y,onChange:ie,placeholder:i.agentDescriptionPlaceholder,maxLength:4e3,rows:3,spellCheck:!0}),t[56]=i.agentDescriptionPlaceholder,t[57]=y,t[58]=ie,t[59]=ae):ae=t[59];let oe;t[60]!==q||t[61]!==ae?(oe=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[q,ae]}),t[60]=q,t[61]=ae,t[62]=oe):oe=t[62];let se;t[63]===i.newWorkspace?se=t[64]:(se=(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:i.newWorkspace}),t[63]=i.newWorkspace,t[64]=se);let ce;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(ce=Y(nn(),`font-mono text-xs`),t[65]=ce):ce=t[65];let le;t[66]===S?le=t[67]:(le=e=>S(e.target.value),t[66]=S,t[67]=le);let de;t[68]!==x||t[69]!==le?(de=(0,Z.jsx)(`input`,{className:ce,value:x,onChange:le,required:!0,autoComplete:`off`}),t[68]=x,t[69]=le,t[70]=de):de=t[70];let fe;t[71]!==se||t[72]!==de?(fe=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[se,de]}),t[71]=se,t[72]=de,t[73]=fe):fe=t[73];let pe;t[74]===i.newModelOptional?pe=t[75]:(pe=(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:i.newModelOptional}),t[74]=i.newModelOptional,t[75]=pe);let me;t[76]===w?me=t[77]:(me=e=>w(e),t[76]=w,t[77]=me);let he;t[78]!==o||t[79]!==a.modelNoMatches||t[80]!==a.modelPlaceholder||t[81]!==a.modelSearchPlaceholder||t[82]!==C||t[83]!==me?(he=(0,Z.jsx)(wt,{className:`min-w-0 flex-1`,value:C,disabled:o,placeholder:a.modelPlaceholder,searchPlaceholder:a.modelSearchPlaceholder,noMatches:a.modelNoMatches,onChange:me}),t[78]=o,t[79]=a.modelNoMatches,t[80]=a.modelPlaceholder,t[81]=a.modelSearchPlaceholder,t[82]=C,t[83]=me,t[84]=he):he=t[84];let ge;t[85]!==i.modelClear||t[86]!==o||t[87]!==C||t[88]!==w?(ge=C.trim()?(0,Z.jsx)(Ct,{type:`button`,variant:`secondary`,className:`shrink-0`,disabled:o,onClick:()=>w(``),children:i.modelClear}):null,t[85]=i.modelClear,t[86]=o,t[87]=C,t[88]=w,t[89]=ge):ge=t[89];let _e;t[90]!==he||t[91]!==ge?(_e=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[he,ge]}),t[90]=he,t[91]=ge,t[92]=_e):_e=t[92];let ve;t[93]!==pe||t[94]!==_e?(ve=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 text-sm`,children:[pe,_e]}),t[93]=pe,t[94]=_e,t[95]=ve):ve=t[95];let ye;t[96]!==i.createModalCancel||t[97]!==o?(ye=(0,Z.jsx)(m,{asChild:!0,children:(0,Z.jsx)(Ct,{type:`button`,variant:`secondary`,disabled:o,children:i.createModalCancel})}),t[96]=i.createModalCancel,t[97]=o,t[98]=ye):ye=t[98];let be;t[99]===Symbol.for(`react.memo_cache_sentinel`)?(be=(0,Z.jsx)(rt,{className:`mr-1 size-4`,"aria-hidden":!0}),t[99]=be):be=t[99];let xe;t[100]!==i.create||t[101]!==o?(xe=(0,Z.jsxs)(Ct,{type:`submit`,disabled:o,children:[be,i.create]}),t[100]=i.create,t[101]=o,t[102]=xe):xe=t[102];let Se;t[103]!==ye||t[104]!==xe?(Se=(0,Z.jsxs)(`div`,{className:`mt-1 flex justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[ye,xe]}),t[103]=ye,t[104]=xe,t[105]=Se):Se=t[105];let Ce;t[106]!==T||t[107]!==V||t[108]!==K||t[109]!==oe||t[110]!==fe||t[111]!==ve||t[112]!==Se||t[113]!==I?(Ce=(0,Z.jsxs)(`form`,{className:`grid gap-3`,onSubmit:T,children:[I,V,K,oe,fe,ve,Se]}),t[106]=T,t[107]=V,t[108]=K,t[109]=oe,t[110]=fe,t[111]=ve,t[112]=Se,t[113]=I,t[114]=Ce):Ce=t[114];let we;t[115]!==Ce||t[116]!==F?(we=(0,Z.jsxs)(c,{children:[D,(0,Z.jsx)(u,{className:O,onOpenAutoFocus:mr,children:(0,Z.jsxs)(Ie,{layer:`modal`,children:[F,Ce]})})]}),t[115]=Ce,t[116]=F,t[117]=we):we=t[117];let Te;return t[118]!==r||t[119]!==n||t[120]!==we?(Te=(0,Z.jsx)(d,{open:n,onOpenChange:r,children:we}),t[118]=r,t[119]=n,t[120]=we,t[121]=Te):Te=t[121],Te}function mr(e){return e.preventDefault()}var hr=`xopc-preset-agents-skipped`,gr=[{id:`coder`,name:`Coder`,emoji:`💻`,descriptionEn:`Software development assistant — precise, pragmatic, and code-focused.`,descriptionZh:`软件开发助手 — 精确、务实、专注代码。`,toolsDisable:[`image_generate`],identityMd:`# IDENTITY.md - Who Am I?
71
71
 
72
72
  - **Name:** Coder
73
73
  - **Creature:** code architect
@@ -96,7 +96,7 @@ Sharp, direct, slightly nerdy. The kind of engineer you'd want on your team —
96
96
  ## Vibe
97
97
 
98
98
  Precise, pragmatic, and competent. Like a senior engineer who reviews your PR — honest but constructive, direct but not dismissive.
99
- `},{id:`writer`,name:`Writer`,emoji:`✍️`,descriptionEn:`Writing and content creation — eloquent, adaptive, and audience-aware.`,descriptionZh:`写作与内容创作 — 文笔流畅、风格多变、关注读者。`,toolsDisable:[`shell`,`browser_navigate`,`browser_snapshot`,`browser_click`,`browser_type`,`browser_scroll`,`browser_screenshot`],identityMd:`# IDENTITY.md - Who Am I?
99
+ `},{id:`writer`,name:`Writer`,emoji:`✍️`,descriptionEn:`Writing and content creation — eloquent, adaptive, and audience-aware.`,descriptionZh:`写作与内容创作 — 文笔流畅、风格多变、关注读者。`,toolsDisable:[`shell`,`browser_use`],identityMd:`# IDENTITY.md - Who Am I?
100
100
 
101
101
  - **Name:** Writer
102
102
  - **Creature:** wordsmith
@@ -154,7 +154,7 @@ Eloquent, adaptive, and invisible. Like the best editors — the writing looks e
154
154
  ## Vibe
155
155
 
156
156
  Thorough, curious, and intellectually honest. Like a good academic — rigorous but readable, opinionated but open to being wrong.
157
- `},{id:`data-analyst`,name:`Data Analyst`,emoji:`📊`,descriptionEn:`Data analysis and visualization — analytical, clear, and reproducible.`,descriptionZh:`数据分析与可视化 — 严谨分析、清晰表达、可复现。`,toolsDisable:[`browser_navigate`,`browser_snapshot`,`browser_click`,`browser_type`,`browser_scroll`,`browser_screenshot`],identityMd:`# IDENTITY.md - Who Am I?
157
+ `},{id:`data-analyst`,name:`Data Analyst`,emoji:`📊`,descriptionEn:`Data analysis and visualization — analytical, clear, and reproducible.`,descriptionZh:`数据分析与可视化 — 严谨分析、清晰表达、可复现。`,toolsDisable:[`browser_use`],identityMd:`# IDENTITY.md - Who Am I?
158
158
 
159
159
  - **Name:** Data Analyst
160
160
  - **Creature:** data interpreter
@@ -212,9 +212,9 @@ Analytical, clear, and methodical. Like a good data scientist — lets the numbe
212
212
  ## Vibe
213
213
 
214
214
  Bold, aesthetic, and thoughtful. Like a creative director who has opinions but listens — pushes for better while respecting what the client actually needs.
215
- `}];function _r(e){let t=(0,X.c)(27),{existingAgentIds:n,onComplete:r,onSkip:o}=e,s=i(br),c=a(s).agentsSettings,l;t[0]===n?l=t[1]:(l=gr.filter(e=>!n.has(e.id)),t[0]=n,t[1]=l);let u=l,[d,f]=(0,Q.useState)(vr),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(null),y;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>{f(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},t[2]=y):y=t[2];let b=y,x=async()=>{let e=u.filter(e=>d.has(e.id));if(e.length===0){r();return}m(!0),v(null),g({current:0,total:e.length});try{await z(e.map(e=>({name:e.name,id:e.id,workspace:`~/.xopc/workspace/${e.id}`,description:s===`zh`?e.descriptionZh:e.descriptionEn,profileFiles:{"IDENTITY.md":e.identityMd,"SOUL.md":e.soulMd},...e.toolsDisable&&e.toolsDisable.length>0?{toolsDisable:e.toolsDisable}:{}}))),g({current:e.length,total:e.length})}catch(t){let n=t,r=n instanceof Error?n.message:String(n);if(!r.toLowerCase().includes(`already exists`)){let t=e[0];v(c.presetCreateFailed.replace(`{{name}}`,t?.name??``).replace(`{{message}}`,r)),m(!1);return}}m(!1),r()},S;t[3]===o?S=t[4]:(S=()=>{localStorage.setItem(hr,`true`),o()},t[3]=o,t[4]=S);let C=S;if(u.length===0)return null;let w;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Z.jsx)(de,{className:`size-4`,"aria-hidden":!0}),t[5]=w):w=t[5];let T;if(t[6]!==u||t[7]!==p||t[8]!==s||t[9]!==d){let e;t[11]!==p||t[12]!==s||t[13]!==d?(e=e=>(0,Z.jsx)(xr,{preset:e,checked:d.has(e.id),disabled:p,language:s,onToggle:()=>b(e.id)},e.id),t[11]=p,t[12]=s,t[13]=d,t[14]=e):e=t[14],T=u.map(e),t[6]=u,t[7]=p,t[8]=s,t[9]=d,t[10]=T}else T=t[10];let E;t[15]===T?E=t[16]:(E=(0,Z.jsx)(`div`,{className:`w-full space-y-3`,children:T}),t[15]=T,t[16]=E);let D;t[17]===_?D=t[18]:(D=_?(0,Z.jsx)(`div`,{role:`alert`,className:`w-full rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:_}):null,t[17]=_,t[18]=D);let O;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Z.jsx)(pe,{className:`size-4`,"aria-hidden":!0}),t[19]=O):O=t[19];let k=Ct,A=p||d.size===0,j=()=>void x(),M;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Z.jsx)(de,{className:`size-4`,"aria-hidden":!0}),t[20]=M):M=t[20];let N=p?c.presetCreating:c.presetCreateSelected.replace(`{{count}}`,String(d.size)),P;return t[21]!==k||t[22]!==A||t[23]!==j||t[24]!==M||t[25]!==N?(P=(0,Z.jsxs)(k,{type:`button`,variant:`primary`,className:`gap-2`,disabled:A,onClick:j,children:[M,N]}),t[21]=k,t[22]=A,t[23]=j,t[24]=M,t[25]=N,t[26]=P):P=t[26],(0,Z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-2xl flex-col items-center gap-6 px-4 py-12`,children:[(0,Z.jsxs)(`div`,{className:`text-center`,children:[(0,Z.jsxs)(`div`,{className:`mb-3 inline-flex items-center gap-2 rounded-full bg-accent/10 px-3 py-1.5 text-sm font-medium text-accent`,children:[w,c.presetSetupBadge]}),(0,Z.jsx)(`h2`,{className:`text-xl font-semibold text-fg`,children:c.presetSetupTitle}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:c.presetSetupSubtitle})]}),E,D,h&&p?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:c.presetCreatingProgress.replace(`{{current}}`,String(h.current)).replace(`{{total}}`,String(h.total))}):null,(0,Z.jsxs)(`div`,{className:`flex w-full items-center justify-between border-t border-edge-subtle pt-4`,children:[(0,Z.jsxs)(Ct,{type:`button`,variant:`ghost`,className:`gap-2 text-fg-muted`,disabled:p,onClick:C,children:[O,c.presetSkip]}),P]})]})}function vr(){return new Set(gr.map(yr))}function yr(e){return e.id}function br(e){return e.language}function xr(e){let t=(0,X.c)(24),{preset:n,checked:r,disabled:i,language:a,onToggle:o}=e,s=a===`zh`?n.descriptionZh:n.descriptionEn,c=r?`border-accent/50 bg-accent/5`:`border-edge-subtle bg-surface-panel/40`,l=i&&`pointer-events-none opacity-50`,u;t[0]!==c||t[1]!==l?(u=Y(`flex cursor-pointer items-start gap-3 rounded-xl border px-4 py-3 transition-colors`,c,l),t[0]=c,t[1]=l,t[2]=u):u=t[2];let d;t[3]!==r||t[4]!==i||t[5]!==o||t[6]!==n.name?(d=(0,Z.jsx)(`input`,{type:`checkbox`,checked:r,disabled:i,onChange:o,className:`mt-1 shrink-0 accent-accent`,"aria-label":n.name}),t[3]=r,t[4]=i,t[5]=o,t[6]=n.name,t[7]=d):d=t[7];let f;t[8]===n.emoji?f=t[9]:(f=(0,Z.jsx)(`span`,{className:`text-lg`,"aria-hidden":!0,children:n.emoji}),t[8]=n.emoji,t[9]=f);let p;t[10]===n.name?p=t[11]:(p=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:n.name}),t[10]=n.name,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;t[15]===s?h=t[16]:(h=(0,Z.jsx)(`p`,{className:`mt-0.5 text-sm text-fg-muted`,children:s}),t[15]=s,t[16]=h);let g;t[17]!==m||t[18]!==h?(g=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[m,h]}),t[17]=m,t[18]=h,t[19]=g):g=t[19];let _;return t[20]!==u||t[21]!==d||t[22]!==g?(_=(0,Z.jsxs)(`label`,{className:u,children:[d,g]}),t[20]=u,t[21]=d,t[22]=g,t[23]=_):_=t[23],_}var Sr={enabled:!0,mode:`default`,reserveTokens:8e3,triggerThreshold:.8,minMessagesBeforeCompact:10,keepRecentMessages:5,evictionWindow:.2,retentionWindow:6},Cr={enabled:!0,maxToolResultChars:1e4,headKeepRatio:.3,tailKeepRatio:.3},wr={enabled:!0,useEnhancedSystem:!0,userProfileEnabled:!0,provider:``,injectionFrequency:``,memoryCharLimit:void 0,userCharLimit:void 0,contextCadence:void 0,dialecticCadence:void 0},Tr={summaryModel:``},Er={enabled:!1,memoryNudgeInterval:10,skillNudgeInterval:10,maxToolRounds:8,maxHistoryMessages:80,maxDurationMs:12e4},Dr={model:``,maxLength:void 0};function Or(e){if(e==null)return``;if(typeof e==`string`)return e;if(typeof e==`object`&&e&&`primary`in e){let t=e.primary;return typeof t==`string`?t:``}return``}function kr(e){if(typeof e!=`object`||!e||!(`fallbacks`in e))return[];let t=e.fallbacks;return Array.isArray(t)?t.filter(e=>typeof e==`string`&&e.trim().length>0):[]}function Ar(e){if(!e||typeof e!=`object`)return;let t=e,n=t.payload;if(n&&typeof n==`object`&&`config`in n)return n.config;if(`config`in t)return t.config}function jr(e){return e===!0||e===`true`||e===1}function Mr(e){let t=e.browser;if(!t||typeof t!=`object`||Array.isArray(t))return{browserEnabled:!1,browserHeadless:!1,browserAllowPrivateUrls:!1,browserCommandTimeout:void 0,browserBackend:`extension`,browserCloudProvider:`local`,browserCloudApiKey:``,browserCloudProjectId:``,browserCloudRegion:``,browserCdpUrl:``,browserExtensionPort:void 0,browserExtensionHost:`127.0.0.1`,browserExtensionConnectionTimeout:void 0,browserCloakKeepOpen:!0,browserCloakTemporaryProfile:!1,browserCloakCacheDir:``,browserCloakBinaryPath:``,browserCloakTimezone:``,browserCloakLocale:``,browserCloakWebrtcIp:``,browserCloakFingerprintPlatform:``,browserCloakExtraArgs:``,browserHumanize:!0,browserHumanPreset:`careful`,browserDialogPolicy:`auto_dismiss`,browserDialogTimeout:void 0};let n=t,r=jr(n.enabled),i=n.headless,a=i===!0||i===`true`||i===1,o=jr(n.allowPrivateUrls),s=typeof n.commandTimeout==`number`&&Number.isFinite(n.commandTimeout)&&n.commandTimeout>=5?Math.floor(n.commandTimeout):void 0,c=n.backend,l=c===`local`||c===`cdp`||c===`cloud`||c===`extension`||c===`cloakbrowser`?c:`extension`,u=n.cloudProvider,d=u===`browserbase`||u===`browser-use`?u:`local`,f=typeof n.cloud==`object`&&n.cloud&&!Array.isArray(n.cloud)?n.cloud:{},p=typeof f.apiKey==`string`?f.apiKey:``,m=typeof f.projectId==`string`?f.projectId:``,h=typeof f.region==`string`?f.region:``,g=typeof n.cdpUrl==`string`?n.cdpUrl:``,_=typeof n.extension==`object`&&n.extension&&!Array.isArray(n.extension)?n.extension:{},v=typeof _.port==`number`&&Number.isFinite(_.port)&&_.port>=1024&&_.port<=65535?Math.floor(_.port):void 0,y=typeof _.host==`string`&&_.host?_.host:`127.0.0.1`,b=typeof _.connectionTimeout==`number`&&Number.isFinite(_.connectionTimeout)&&_.connectionTimeout>=1e3?Math.floor(_.connectionTimeout):void 0,x=typeof n.cloakbrowser==`object`&&n.cloakbrowser&&!Array.isArray(n.cloakbrowser)?n.cloakbrowser:{},S=n.humanPreset===`default`?`default`:`careful`,C=n.dialogPolicy,w=C===`must_respond`||C===`auto_accept`?C:`auto_dismiss`,T=typeof n.dialogTimeoutSeconds==`number`&&Number.isFinite(n.dialogTimeoutSeconds)&&n.dialogTimeoutSeconds>=1?Math.floor(n.dialogTimeoutSeconds):void 0;return{browserEnabled:r,browserHeadless:a,browserAllowPrivateUrls:o,browserCommandTimeout:s,browserBackend:l,browserCloudProvider:d,browserCloudApiKey:p,browserCloudProjectId:m,browserCloudRegion:h,browserCdpUrl:g,browserExtensionPort:v,browserExtensionHost:y,browserExtensionConnectionTimeout:b,browserCloakKeepOpen:x.keepOpen!==!1,browserCloakTemporaryProfile:x.temporaryProfile===!0,browserCloakCacheDir:typeof x.cacheDir==`string`?x.cacheDir:``,browserCloakBinaryPath:typeof x.binaryPath==`string`?x.binaryPath:``,browserCloakTimezone:typeof x.timezone==`string`?x.timezone:``,browserCloakLocale:typeof x.locale==`string`?x.locale:``,browserCloakWebrtcIp:typeof x.webrtcIp==`string`?x.webrtcIp:``,browserCloakFingerprintPlatform:typeof x.fingerprintPlatform==`string`?x.fingerprintPlatform:``,browserCloakExtraArgs:Array.isArray(x.extraArgs)?x.extraArgs.filter(e=>typeof e==`string`&&e.trim().length>0).join(`
215
+ `}];function _r(e){let t=(0,X.c)(27),{existingAgentIds:n,onComplete:r,onSkip:o}=e,s=i(br),c=a(s).agentsSettings,l;t[0]===n?l=t[1]:(l=gr.filter(e=>!n.has(e.id)),t[0]=n,t[1]=l);let u=l,[d,f]=(0,Q.useState)(vr),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(null),y;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>{f(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},t[2]=y):y=t[2];let b=y,x=async()=>{let e=u.filter(e=>d.has(e.id));if(e.length===0){r();return}m(!0),v(null),g({current:0,total:e.length});try{await z(e.map(e=>({name:e.name,id:e.id,workspace:`~/.xopc/workspace/${e.id}`,description:s===`zh`?e.descriptionZh:e.descriptionEn,profileFiles:{"IDENTITY.md":e.identityMd,"SOUL.md":e.soulMd},...e.toolsDisable&&e.toolsDisable.length>0?{toolsDisable:e.toolsDisable}:{}}))),g({current:e.length,total:e.length})}catch(t){let n=t,r=n instanceof Error?n.message:String(n);if(!r.toLowerCase().includes(`already exists`)){let t=e[0];v(c.presetCreateFailed.replace(`{{name}}`,t?.name??``).replace(`{{message}}`,r)),m(!1);return}}m(!1),r()},S;t[3]===o?S=t[4]:(S=()=>{localStorage.setItem(hr,`true`),o()},t[3]=o,t[4]=S);let C=S;if(u.length===0)return null;let w;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Z.jsx)(de,{className:`size-4`,"aria-hidden":!0}),t[5]=w):w=t[5];let T;if(t[6]!==u||t[7]!==p||t[8]!==s||t[9]!==d){let e;t[11]!==p||t[12]!==s||t[13]!==d?(e=e=>(0,Z.jsx)(xr,{preset:e,checked:d.has(e.id),disabled:p,language:s,onToggle:()=>b(e.id)},e.id),t[11]=p,t[12]=s,t[13]=d,t[14]=e):e=t[14],T=u.map(e),t[6]=u,t[7]=p,t[8]=s,t[9]=d,t[10]=T}else T=t[10];let E;t[15]===T?E=t[16]:(E=(0,Z.jsx)(`div`,{className:`w-full space-y-3`,children:T}),t[15]=T,t[16]=E);let D;t[17]===_?D=t[18]:(D=_?(0,Z.jsx)(`div`,{role:`alert`,className:`w-full rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:_}):null,t[17]=_,t[18]=D);let O;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Z.jsx)(pe,{className:`size-4`,"aria-hidden":!0}),t[19]=O):O=t[19];let k=Ct,A=p||d.size===0,j=()=>void x(),M;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Z.jsx)(de,{className:`size-4`,"aria-hidden":!0}),t[20]=M):M=t[20];let N=p?c.presetCreating:c.presetCreateSelected.replace(`{{count}}`,String(d.size)),P;return t[21]!==k||t[22]!==A||t[23]!==j||t[24]!==M||t[25]!==N?(P=(0,Z.jsxs)(k,{type:`button`,variant:`primary`,className:`gap-2`,disabled:A,onClick:j,children:[M,N]}),t[21]=k,t[22]=A,t[23]=j,t[24]=M,t[25]=N,t[26]=P):P=t[26],(0,Z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-2xl flex-col items-center gap-6 px-4 py-12`,children:[(0,Z.jsxs)(`div`,{className:`text-center`,children:[(0,Z.jsxs)(`div`,{className:`mb-3 inline-flex items-center gap-2 rounded-full bg-accent/10 px-3 py-1.5 text-sm font-medium text-accent`,children:[w,c.presetSetupBadge]}),(0,Z.jsx)(`h2`,{className:`text-xl font-semibold text-fg`,children:c.presetSetupTitle}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:c.presetSetupSubtitle})]}),E,D,h&&p?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:c.presetCreatingProgress.replace(`{{current}}`,String(h.current)).replace(`{{total}}`,String(h.total))}):null,(0,Z.jsxs)(`div`,{className:`flex w-full items-center justify-between border-t border-edge-subtle pt-4`,children:[(0,Z.jsxs)(Ct,{type:`button`,variant:`ghost`,className:`gap-2 text-fg-muted`,disabled:p,onClick:C,children:[O,c.presetSkip]}),P]})]})}function vr(){return new Set(gr.map(yr))}function yr(e){return e.id}function br(e){return e.language}function xr(e){let t=(0,X.c)(24),{preset:n,checked:r,disabled:i,language:a,onToggle:o}=e,s=a===`zh`?n.descriptionZh:n.descriptionEn,c=r?`border-accent/50 bg-accent/5`:`border-edge-subtle bg-surface-panel/40`,l=i&&`pointer-events-none opacity-50`,u;t[0]!==c||t[1]!==l?(u=Y(`flex cursor-pointer items-start gap-3 rounded-xl border px-4 py-3 transition-colors`,c,l),t[0]=c,t[1]=l,t[2]=u):u=t[2];let d;t[3]!==r||t[4]!==i||t[5]!==o||t[6]!==n.name?(d=(0,Z.jsx)(`input`,{type:`checkbox`,checked:r,disabled:i,onChange:o,className:`mt-1 shrink-0 accent-accent`,"aria-label":n.name}),t[3]=r,t[4]=i,t[5]=o,t[6]=n.name,t[7]=d):d=t[7];let f;t[8]===n.emoji?f=t[9]:(f=(0,Z.jsx)(`span`,{className:`text-lg`,"aria-hidden":!0,children:n.emoji}),t[8]=n.emoji,t[9]=f);let p;t[10]===n.name?p=t[11]:(p=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:n.name}),t[10]=n.name,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;t[15]===s?h=t[16]:(h=(0,Z.jsx)(`p`,{className:`mt-0.5 text-sm text-fg-muted`,children:s}),t[15]=s,t[16]=h);let g;t[17]!==m||t[18]!==h?(g=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[m,h]}),t[17]=m,t[18]=h,t[19]=g):g=t[19];let _;return t[20]!==u||t[21]!==d||t[22]!==g?(_=(0,Z.jsxs)(`label`,{className:u,children:[d,g]}),t[20]=u,t[21]=d,t[22]=g,t[23]=_):_=t[23],_}var Sr={enabled:!0,mode:`default`,reserveTokens:8e3,triggerThreshold:.8,minMessagesBeforeCompact:10,keepRecentMessages:5,evictionWindow:.2,retentionWindow:6},Cr={enabled:!0,maxToolResultChars:1e4,headKeepRatio:.3,tailKeepRatio:.3},wr={enabled:!0,useEnhancedSystem:!0,userProfileEnabled:!0,provider:``,injectionFrequency:``,memoryCharLimit:void 0,userCharLimit:void 0,contextCadence:void 0,dialecticCadence:void 0},Tr={summaryModel:``},Er={enabled:!1,memoryNudgeInterval:10,skillNudgeInterval:10,maxToolRounds:8,maxHistoryMessages:80,maxDurationMs:12e4},Dr={model:``,maxLength:void 0};function Or(e){if(!e)return``;if(typeof e==`string`)return e;if(typeof e==`object`&&!Array.isArray(e)){let t=e.primary;return typeof t==`string`?t:``}return``}function kr(e){if(typeof e!=`object`||!e||!(`fallbacks`in e))return[];let t=e.fallbacks;return Array.isArray(t)?t.filter(e=>typeof e==`string`&&e.trim().length>0):[]}function Ar(e){if(!e||typeof e!=`object`)return;let t=e,n=t.payload;if(n&&typeof n==`object`&&`config`in n)return n.config;if(`config`in t)return t.config}function jr(e){return e===!0||e===`true`||e===1}function Mr(e){let t=e.browser;if(!t||typeof t!=`object`||Array.isArray(t))return{browserEnabled:!0,browserHeadless:!1,browserAllowPrivateUrls:!1,browserCommandTimeout:void 0,browserBackend:`extension`,browserCloudProvider:`local`,browserCloudApiKey:``,browserCloudProjectId:``,browserCloudRegion:``,browserCdpUrl:``,browserExtensionPort:void 0,browserExtensionHost:`127.0.0.1`,browserExtensionConnectionTimeout:void 0,browserCloakKeepOpen:!0,browserCloakTemporaryProfile:!1,browserCloakCacheDir:``,browserCloakBinaryPath:``,browserCloakTimezone:``,browserCloakLocale:``,browserCloakWebrtcIp:``,browserCloakFingerprintPlatform:``,browserCloakExtraArgs:``,browserHumanize:!0,browserHumanPreset:`careful`,browserDialogPolicy:`auto_dismiss`,browserDialogTimeout:void 0};let n=t,r=jr(n.enabled),i=n.headless,a=i===!0||i===`true`||i===1,o=jr(n.allowPrivateUrls),s=typeof n.commandTimeout==`number`&&Number.isFinite(n.commandTimeout)&&n.commandTimeout>=5?Math.floor(n.commandTimeout):void 0,c=n.backend,l=c===`local`||c===`cdp`||c===`cloud`||c===`extension`||c===`cloakbrowser`?c:`extension`,u=n.cloudProvider,d=u===`browserbase`||u===`browser-use`?u:`local`,f=typeof n.cloud==`object`&&n.cloud&&!Array.isArray(n.cloud)?n.cloud:{},p=typeof f.apiKey==`string`?f.apiKey:``,m=typeof f.projectId==`string`?f.projectId:``,h=typeof f.region==`string`?f.region:``,g=typeof n.cdpUrl==`string`?n.cdpUrl:``,_=typeof n.extension==`object`&&n.extension&&!Array.isArray(n.extension)?n.extension:{},v=typeof _.port==`number`&&Number.isFinite(_.port)&&_.port>=1024&&_.port<=65535?Math.floor(_.port):void 0,y=typeof _.host==`string`&&_.host?_.host:`127.0.0.1`,b=typeof _.connectionTimeout==`number`&&Number.isFinite(_.connectionTimeout)&&_.connectionTimeout>=1e3?Math.floor(_.connectionTimeout):void 0,x=typeof n.cloakbrowser==`object`&&n.cloakbrowser&&!Array.isArray(n.cloakbrowser)?n.cloakbrowser:{},S=n.humanPreset===`default`?`default`:`careful`,C=n.dialogPolicy,w=C===`must_respond`||C===`auto_accept`?C:`auto_dismiss`,T=typeof n.dialogTimeoutSeconds==`number`&&Number.isFinite(n.dialogTimeoutSeconds)&&n.dialogTimeoutSeconds>=1?Math.floor(n.dialogTimeoutSeconds):void 0;return{browserEnabled:r,browserHeadless:a,browserAllowPrivateUrls:o,browserCommandTimeout:s,browserBackend:l,browserCloudProvider:d,browserCloudApiKey:p,browserCloudProjectId:m,browserCloudRegion:h,browserCdpUrl:g,browserExtensionPort:v,browserExtensionHost:y,browserExtensionConnectionTimeout:b,browserCloakKeepOpen:x.keepOpen!==!1,browserCloakTemporaryProfile:x.temporaryProfile===!0,browserCloakCacheDir:typeof x.cacheDir==`string`?x.cacheDir:``,browserCloakBinaryPath:typeof x.binaryPath==`string`?x.binaryPath:``,browserCloakTimezone:typeof x.timezone==`string`?x.timezone:``,browserCloakLocale:typeof x.locale==`string`?x.locale:``,browserCloakWebrtcIp:typeof x.webrtcIp==`string`?x.webrtcIp:``,browserCloakFingerprintPlatform:typeof x.fingerprintPlatform==`string`?x.fingerprintPlatform:``,browserCloakExtraArgs:Array.isArray(x.extraArgs)?x.extraArgs.filter(e=>typeof e==`string`&&e.trim().length>0).join(`
216
216
  `):``,browserHumanize:n.humanize!==!1,browserHumanPreset:S,browserDialogPolicy:w,browserDialogTimeout:T}}function Nr(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...Sr};let t=e;return{enabled:typeof t.enabled==`boolean`?t.enabled:Sr.enabled,mode:t.mode===`safeguard`?`safeguard`:`default`,reserveTokens:typeof t.reserveTokens==`number`&&Number.isFinite(t.reserveTokens)?Math.floor(t.reserveTokens):Sr.reserveTokens,triggerThreshold:typeof t.triggerThreshold==`number`&&Number.isFinite(t.triggerThreshold)?t.triggerThreshold:Sr.triggerThreshold,minMessagesBeforeCompact:typeof t.minMessagesBeforeCompact==`number`&&Number.isFinite(t.minMessagesBeforeCompact)?Math.floor(t.minMessagesBeforeCompact):Sr.minMessagesBeforeCompact,keepRecentMessages:typeof t.keepRecentMessages==`number`&&Number.isFinite(t.keepRecentMessages)?Math.floor(t.keepRecentMessages):Sr.keepRecentMessages,evictionWindow:typeof t.evictionWindow==`number`&&Number.isFinite(t.evictionWindow)?t.evictionWindow:Sr.evictionWindow,retentionWindow:typeof t.retentionWindow==`number`&&Number.isFinite(t.retentionWindow)?Math.floor(t.retentionWindow):Sr.retentionWindow}}function Pr(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...Cr};let t=e;return{enabled:typeof t.enabled==`boolean`?t.enabled:Cr.enabled,maxToolResultChars:typeof t.maxToolResultChars==`number`&&Number.isFinite(t.maxToolResultChars)?Math.floor(t.maxToolResultChars):Cr.maxToolResultChars,headKeepRatio:typeof t.headKeepRatio==`number`&&Number.isFinite(t.headKeepRatio)?t.headKeepRatio:Cr.headKeepRatio,tailKeepRatio:typeof t.tailKeepRatio==`number`&&Number.isFinite(t.tailKeepRatio)?t.tailKeepRatio:Cr.tailKeepRatio}}function Fr(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...wr};let t=e,n=t.provider,r=n===`none`||n===`stub`?n:``,i=t.injectionFrequency,a=i===`every-turn`||i===`first-turn`?i:``;return{enabled:typeof t.enabled==`boolean`?t.enabled:wr.enabled,useEnhancedSystem:typeof t.useEnhancedSystem==`boolean`?t.useEnhancedSystem:wr.useEnhancedSystem,userProfileEnabled:typeof t.userProfileEnabled==`boolean`?t.userProfileEnabled:wr.userProfileEnabled,provider:r,injectionFrequency:a,memoryCharLimit:typeof t.memoryCharLimit==`number`&&t.memoryCharLimit>0?Math.floor(t.memoryCharLimit):void 0,userCharLimit:typeof t.userCharLimit==`number`&&t.userCharLimit>0?Math.floor(t.userCharLimit):void 0,contextCadence:typeof t.contextCadence==`number`&&t.contextCadence>=1?Math.floor(t.contextCadence):void 0,dialecticCadence:typeof t.dialecticCadence==`number`&&t.dialecticCadence>=1?Math.floor(t.dialecticCadence):void 0}}function Ir(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...Tr};let t=e;return{summaryModel:typeof t.summaryModel==`string`?t.summaryModel:``}}function Lr(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...Er};let t=e;return{enabled:typeof t.enabled==`boolean`?t.enabled:Er.enabled,memoryNudgeInterval:typeof t.memoryNudgeInterval==`number`&&t.memoryNudgeInterval>=0?Math.floor(t.memoryNudgeInterval):Er.memoryNudgeInterval,skillNudgeInterval:typeof t.skillNudgeInterval==`number`&&t.skillNudgeInterval>=0?Math.floor(t.skillNudgeInterval):Er.skillNudgeInterval,maxToolRounds:typeof t.maxToolRounds==`number`&&t.maxToolRounds>=1&&t.maxToolRounds<=32?Math.floor(t.maxToolRounds):Er.maxToolRounds,maxHistoryMessages:typeof t.maxHistoryMessages==`number`&&t.maxHistoryMessages>=10&&t.maxHistoryMessages<=200?Math.floor(t.maxHistoryMessages):Er.maxHistoryMessages,maxDurationMs:typeof t.maxDurationMs==`number`&&t.maxDurationMs>=3e4&&t.maxDurationMs<=6e5?Math.floor(t.maxDurationMs):Er.maxDurationMs}}function Rr(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...Dr};let t=e;return{model:typeof t.model==`string`?t.model:``,maxLength:typeof t.maxLength==`number`&&t.maxLength>0?t.maxLength:void 0}}function zr(e,t){if(!e||typeof e!=`object`||Array.isArray(e))return{enabled:t};let n=e;return{enabled:typeof n.enabled==`boolean`?n.enabled:t}}function Br(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function Vr(e){if(e==null)return``;if(typeof e==`string`){let t=e.trim();if(!t)return``;try{let e=JSON.parse(t);if(typeof e==`object`&&e&&!Array.isArray(e))return JSON.stringify(e,null,2)}catch{return t}return``}if(typeof e==`object`&&!Array.isArray(e))try{return JSON.stringify(e,null,2)}catch{return``}return``}function Hr(e){let t=e.imageGenerationModelTimeoutMs;if(typeof t==`number`&&Number.isFinite(t)&&t>0)return Math.floor(t);let n=e.imageGenerationModel;if(n&&typeof n==`object`&&!Array.isArray(n)){let e=n.timeoutMs;if(typeof e==`number`&&Number.isFinite(e)&&e>0)return Math.floor(e)}return null}function Ur(e){if(e.imageGenerationModelAutoProviderFallback===!0)return!0;let t=e.imageGenerationModel;return t&&typeof t==`object`&&!Array.isArray(t)?t.autoProviderFallback===!0:!1}function Wr(e){let t=e&&typeof e==`object`&&!Array.isArray(e)&&`agents`in e?e.agents:void 0,n=t&&typeof t==`object`&&!Array.isArray(t)&&`defaults`in t?t.defaults:void 0,r=n&&typeof n==`object`&&!Array.isArray(n)?n:{},i=r.modelFallbacks,a=Array.isArray(i)&&i.every(e=>typeof e==`string`)?i:kr(r.model),o=r.imageModelFallbacks,s=Array.isArray(o)&&o.every(e=>typeof e==`string`)?o:kr(r.imageModel),c=r.imageGenerationModelFallbacks,l=Array.isArray(c)&&c.every(e=>typeof e==`string`)?c:kr(r.imageGenerationModel),u=Mr(r),d=typeof r.maxTaskDurationMs==`number`&&Number.isFinite(r.maxTaskDurationMs)?r.maxTaskDurationMs:void 0,f=d===void 0?void 0:Math.round(d/6e4);return{model:Or(r.model),modelFallbacks:a,imageModel:Or(r.imageModel),imageModelFallbacks:s,imageGenerationModel:Or(r.imageGenerationModel),imageGenerationModelFallbacks:l,imageGenerationModelTimeoutMs:Hr(r),imageGenerationModelAutoProviderFallback:Ur(r),mediaMaxMb:typeof r.mediaMaxMb==`number`&&!Number.isNaN(r.mediaMaxMb)?r.mediaMaxMb:void 0,maxTokens:typeof r.maxTokens==`number`?r.maxTokens:8192,temperature:typeof r.temperature==`number`?r.temperature:.7,maxToolIterations:typeof r.maxToolIterations==`number`?r.maxToolIterations:20,maxTaskDurationMinutes:f,maxRequestsPerTurn:typeof r.maxRequestsPerTurn==`number`?r.maxRequestsPerTurn:50,maxToolFailuresPerTurn:typeof r.maxToolFailuresPerTurn==`number`?r.maxToolFailuresPerTurn:3,workspace:typeof r.workspace==`string`?r.workspace:`~/.xopc/workspace`,...u,thinkingDefault:typeof r.thinkingDefault==`string`?r.thinkingDefault:`medium`,reasoningDefault:typeof r.reasoningDefault==`string`?r.reasoningDefault:`stream`,verboseDefault:typeof r.verboseDefault==`string`?r.verboseDefault:`full`,compaction:Nr(r.compaction),pruning:Pr(r.pruning),memory:Fr(r.memory),sessionSearch:Ir(r.sessionSearch),backgroundReview:Lr(r.backgroundReview),webExtract:Rr(r.webExtract),delegate:zr(r.delegate,!1),executeCode:zr(r.executeCode,!1),systemPromptOverride:typeof r.systemPromptOverride==`string`?r.systemPromptOverride:``,skillsAllowlist:Br(r.skills),toolsDisable:(()=>{let e=r.tools;if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=e.disable;return Br(t)})(),paramsJson:Vr(r.params)}}function Gr(e){let t={enabled:e.enabled,useEnhancedSystem:e.useEnhancedSystem,userProfileEnabled:e.userProfileEnabled};return e.provider===`none`||e.provider===`stub`?t.provider=e.provider:t.provider=null,e.injectionFrequency===`every-turn`||e.injectionFrequency===`first-turn`?t.injectionFrequency=e.injectionFrequency:t.injectionFrequency=null,t.memoryCharLimit=e.memoryCharLimit??null,t.userCharLimit=e.userCharLimit??null,t.contextCadence=e.contextCadence??null,t.dialecticCadence=e.dialecticCadence??null,t}function Kr(e){let t=e.trim();if(!t)return null;let n=JSON.parse(t);if(n===null)return null;if(typeof n!=`object`||Array.isArray(n))throw Error(`params must be a JSON object`);return n}function qr(e){return{enabled:e.browserEnabled,headless:e.browserHeadless,allowPrivateUrls:e.browserAllowPrivateUrls,commandTimeout:e.browserCommandTimeout??null,backend:e.browserBackend===`extension`?null:e.browserBackend,cloudProvider:e.browserCloudProvider===`local`?null:e.browserCloudProvider,cloud:e.browserBackend===`cloud`?{apiKey:e.browserCloudApiKey.trim()||null,projectId:e.browserCloudProjectId.trim()||null,region:e.browserCloudRegion.trim()||null}:null,cdpUrl:e.browserCdpUrl.trim()||null,extension:e.browserBackend===`extension`?{port:e.browserExtensionPort??null,host:e.browserExtensionHost.trim()||null,connectionTimeout:e.browserExtensionConnectionTimeout??null}:null,cloakbrowser:e.browserBackend===`cloakbrowser`?{keepOpen:e.browserCloakKeepOpen,temporaryProfile:e.browserCloakTemporaryProfile,cacheDir:e.browserCloakCacheDir.trim()||null,binaryPath:e.browserCloakBinaryPath.trim()||null,timezone:e.browserCloakTimezone.trim()||null,locale:e.browserCloakLocale.trim()||null,webrtcIp:e.browserCloakWebrtcIp.trim()||null,fingerprintPlatform:e.browserCloakFingerprintPlatform.trim()||null,extraArgs:(()=>{let t=e.browserCloakExtraArgs.split(`
217
- `).map(e=>e.trim()).filter(Boolean);return t.length>0?t:null})()}:null,humanize:e.browserBackend===`cloakbrowser`?e.browserHumanize:null,humanPreset:e.browserBackend===`cloakbrowser`?e.browserHumanPreset:null,dialogPolicy:e.browserDialogPolicy===`auto_dismiss`?null:e.browserDialogPolicy,dialogTimeoutSeconds:e.browserDialogTimeout??null}}async function Jr(){return Wr(Ar(await _(o(`/api/config`)))??{})}async function Yr(e){let t=e.modelFallbacks.flatMap(e=>{let t=e.trim();return t?[t]:[]}),n=t.length>0?{primary:e.model,fallbacks:t}:e.model,r=e.imageModelFallbacks.flatMap(e=>{let t=e.trim();return t?[t]:[]}),i=r.length>0&&e.imageModel.trim()?{primary:e.imageModel.trim(),fallbacks:r}:e.imageModel||``,a=e.imageGenerationModelFallbacks.flatMap(e=>{let t=e.trim();return t?[t]:[]}),s=e.imageGenerationModel.trim(),c=typeof e.imageGenerationModelTimeoutMs==`number`&&e.imageGenerationModelTimeoutMs>0?Math.floor(e.imageGenerationModelTimeoutMs):null,l=e.imageGenerationModelAutoProviderFallback===!0,u=(()=>{let e={};return s&&(e.primary=s),a.length>0&&(e.fallbacks=a),c&&(e.timeoutMs=c),l&&(e.autoProviderFallback=!0),Object.keys(e).length===0?``:Object.keys(e).length===1&&typeof e.primary==`string`?e.primary:e})(),d=e.maxTaskDurationMinutes===void 0||e.maxTaskDurationMinutes===null?null:(()=>{let t=Math.floor(e.maxTaskDurationMinutes)*6e4;return t<6e4||t>144e5?null:t})(),f=e.skillsAllowlist.flatMap(e=>{let t=e.trim();return t?[t]:[]}),p=e.toolsDisable.flatMap(e=>{let t=e.trim();return t?[t]:[]}),m=Kr(e.paramsJson),h=m===null||Object.keys(m).length===0?null:m,g={model:n,imageModel:i,imageGenerationModel:u,mediaMaxMb:e.mediaMaxMb??null,maxTokens:e.maxTokens,temperature:e.temperature,maxToolIterations:e.maxToolIterations,maxTaskDurationMs:d,maxRequestsPerTurn:e.maxRequestsPerTurn,maxToolFailuresPerTurn:e.maxToolFailuresPerTurn,workspace:e.workspace,browser:qr(e),thinkingDefault:e.thinkingDefault,reasoningDefault:e.reasoningDefault,verboseDefault:e.verboseDefault,compaction:{...e.compaction},pruning:{...e.pruning},memory:Gr(e.memory),sessionSearch:{summaryModel:e.sessionSearch.summaryModel.trim()||null},backgroundReview:{enabled:e.backgroundReview.enabled,memoryNudgeInterval:e.backgroundReview.memoryNudgeInterval,skillNudgeInterval:e.backgroundReview.skillNudgeInterval,maxToolRounds:e.backgroundReview.maxToolRounds,maxHistoryMessages:e.backgroundReview.maxHistoryMessages,maxDurationMs:e.backgroundReview.maxDurationMs},webExtract:{model:e.webExtract.model.trim()||null,maxLength:e.webExtract.maxLength??null},delegate:{enabled:e.delegate.enabled},executeCode:{enabled:e.executeCode.enabled},systemPromptOverride:e.systemPromptOverride.trim()||null,skills:f.length>0?f:null,tools:{disable:p.length>0?p:null},params:h};await _(o(`/api/config`),{method:`PATCH`,body:JSON.stringify({agents:{defaults:g}})}),Ge()}var Xr=`main`,Zr=/^[a-z0-9][a-z0-9_-]{0,63}$/i,Qr=/[^a-z0-9_-]+/g,$r=/^-+/,ei=/-+$/,ti=/^[a-z0-9][a-z0-9_-]{0,63}$/,ni=new Set([`con`,`prn`,`aux`,`nul`,`com1`,`com2`,`com3`,`com4`,`com5`,`com6`,`com7`,`com8`,`com9`,`lpt1`,`lpt2`,`lpt3`,`lpt4`,`lpt5`,`lpt6`,`lpt7`,`lpt8`,`lpt9`]);function ri(e){let t=e.trim();if(!t)return Xr;let n=t.toLowerCase();return Zr.test(t)?n:n.replace(Qr,`-`).replace($r,``).replace(ei,``).slice(0,64)||Xr}function ii(e,t){let n=e?.trim();if(n){let e=n.toLowerCase();return ti.test(e)?e===Xr?{ok:!1,error:`"${Xr}" is reserved`}:ni.has(e)?{ok:!1,error:`Agent id "${e}" is reserved (Windows device name).`}:{ok:!0,agentId:e}:{ok:!1,error:`Invalid agent id: use 1–64 characters; letters, digits, underscores, and hyphens only; start with a letter or digit.`}}let r=ri(t.trim());return r===Xr?{ok:!1,error:`Display name cannot produce a valid agent folder id. Set an explicit Agent id (letters, digits, underscores, hyphens only).`}:ni.has(r)?{ok:!1,error:`That display name resolves to "${r}", which is reserved. Use a different display name or set an explicit Agent id.`}:ti.test(r)?{ok:!0,agentId:r}:{ok:!1,error:`Could not derive a folder-safe agent id from the display name. Set an explicit Agent id (letters, digits, underscores, hyphens only).`}}var ai=`~/.xopc/workspace`;function oi(e){let t=e.trim();return t?`${ai}/${ri(t)}`:``}function si(e){let t=(0,X.c)(18),{a:n,busy:r,listSearchQuery:i,onListSearchQueryChange:a,onAddAgent:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(U,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=s):s=t[0];let c;t[1]===a?c=t[2]:(c=e=>a(e.target.value),t[1]=a,t[2]=c);let l;t[3]!==n.listSearchPlaceholder||t[4]!==i||t[5]!==c?(l=(0,Z.jsxs)(`label`,{className:`relative flex min-h-9 min-w-0 max-w-sm cursor-text items-center rounded-pill border border-edge bg-surface-base py-1.5 pl-9 pr-3 shadow-surface dark:bg-surface-hover/40 sm:max-w-md`,children:[s,(0,Z.jsx)(`input`,{type:`search`,enterKeyHint:`search`,value:i,onChange:c,placeholder:n.listSearchPlaceholder,autoComplete:`off`,spellCheck:!1,"aria-label":n.listSearchPlaceholder,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent py-0.5 text-sm leading-normal text-fg caret-current placeholder:text-fg-disabled focus:border-0 focus:shadow-none focus:outline-none focus:ring-0 focus-visible:outline-none`})]}),t[3]=n.listSearchPlaceholder,t[4]=i,t[5]=c,t[6]=l):l=t[6];let u;t[7]===o?u=t[8]:(u=()=>o(),t[7]=o,t[8]=u);let d;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(ye,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[9]=d):d=t[9];let f;t[10]!==n.addAgent||t[11]!==n.addAgentAria||t[12]!==r||t[13]!==u?(f=(0,Z.jsxs)(Ct,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,"aria-label":n.addAgentAria,disabled:r,onClick:u,children:[d,n.addAgent]}),t[10]=n.addAgent,t[11]=n.addAgentAria,t[12]=r,t[13]=u,t[14]=f):f=t[14];let p;return t[15]!==l||t[16]!==f?(p=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[l,f]}),t[15]=l,t[16]=f,t[17]=p):p=t[17],p}function ci(e){return{...e,soulEditorNonce:0,soulPreviewMode:!1,avatarDialogOpen:!1}}function li(e){let{agentId:t,enabled:n,saveRef:r}=e,i=G(async()=>{if(!t)return null;let[e,n]=await Promise.all([S(t,`IDENTITY.md`).catch(()=>``),S(t,`SOUL.md`).catch(()=>``)]),r=xn(e);return{identity:r,soulTemplate:On(n),soulCustomContent:n,identityBaseline:JSON.stringify(r),soulBaseline:n}},[t],{enabled:n&&!!t,initial:null,errorData:null}),a=i.data,o=i.loading,s=(0,Q.useRef)(!1),[c,l]=(0,Q.useState)(null),u=t??``,d=(0,Q.useRef)(u);d.current!==u&&(d.current=u,s.current=!1,l(null));let f=c??(a?ci(a):null),p=(0,Q.useMemo)(()=>f?JSON.stringify(f.identity)!==f.identityBaseline||f.soulCustomContent!==f.soulBaseline:!1,[f]),m=(0,Q.useRef)(t);m.current=t;let h=(0,Q.useCallback)(e=>{s.current=!0,l(t=>{let n=t??(a?ci(a):null);return n?e(n):null})},[a]),g=(0,Q.useCallback)(e=>{h(t=>({...t,identity:{...t.identity,...e}}))},[h]),_=(0,Q.useCallback)(e=>{h(t=>{if(e===`custom`)return{...t,soulTemplate:`custom`};let n=En.find(t=>t.id===e);return n?.content?{...t,soulTemplate:e,soulCustomContent:n.content,soulEditorNonce:t.soulEditorNonce+1}:{...t,soulTemplate:e}})},[h]),v=(0,Q.useCallback)(e=>{h(t=>({...t,soulCustomContent:e,soulTemplate:`custom`}))},[h]),y=(0,Q.useCallback)(e=>{h(t=>({...t,avatarDialogOpen:e}))},[h]),b=(0,Q.useCallback)(()=>{h(e=>({...e,soulPreviewMode:!e.soulPreviewMode}))},[h]),x=(0,Q.useCallback)(async()=>{let e=m.current;!e||!f||(await Promise.all([R(e,`IDENTITY.md`,Sn(f.identity)),R(e,`SOUL.md`,f.soulCustomContent)]),s.current=!1,l(e=>{let t=e??f;return{...t,identityBaseline:JSON.stringify(t.identity),soulBaseline:t.soulCustomContent}}))},[f]);return(0,Q.useLayoutEffect)(()=>{if(r)return r.current=x,()=>{r.current=null}},[x,r]),{profileMarkdownLoading:o,draft:f,dirty:p,updateIdentity:g,handleSoulTemplateChange:_,handleSoulContentChange:v,setAvatarDialogOpen:y,toggleSoulPreviewMode:b}}var ui={draft:``,editorNonce:0,loadedKey:``};function di(e,t){switch(t.type){case`load`:return{draft:t.content,editorNonce:e.editorNonce+1,loadedKey:t.key};case`setDraft`:return{...e,draft:t.value};case`clear`:return{draft:``,editorNonce:e.editorNonce,loadedKey:``};case`resetViewMode`:return e}}function fi(e){let{panel:t,selectedId:n,hasToken:r,dataAgentsLength:i,saveErrorMessage:a,setError:o}=e,s=G(()=>n?_e(n):Promise.resolve(null),[t,n,r,i],{enabled:t===`files`&&!!n&&r,initial:null,errorData:null}),c=s.data,l=s.setData,u=s.loading,[d,f]=(0,Q.useState)(null),[p,m]=(0,Q.useReducer)(di,ui),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(`edit`),y=p.draft,b=p.editorNonce,x=(0,Q.useRef)(y);x.current=y;let C=(0,Q.useRef)(n);C.current=n;let w=(0,Q.useRef)(d);w.current=d;let T=(0,Q.useRef)(null),E=(0,Q.useRef)(``),D=(0,Q.useRef)(``),O=(0,Q.useRef)(``),k=(0,Q.useRef)(()=>{}),A=G(()=>d&&n?S(n,d).catch(()=>``):Promise.resolve(``),[d,n,r],{enabled:!!(d&&n&&r),initial:``,errorData:``}),j=A.loading,M=I(async()=>{let e=C.current,t=w.current;if(!e||!t||`${e}:${t}`!==E.current)return;let n=x.current;if(n!==D.current){g(!0),o(null);try{await R(e,t,n),D.current=n,l(n=>!n||n.agentId!==e?n:{...n,files:n.files.map(e=>e.name===t?{...e,missing:!1}:e)})}catch(e){o(e instanceof Error?e.message:a)}finally{g(!1)}}},800);k.current=M.flush,(0,Q.useEffect)(()=>()=>{k.current()},[]);let N=(0,Q.useRef)(t);N.current!==t&&(N.current===`files`&&k.current(),N.current=t);let P=d&&n?`${n}:${d}`:``;P!==O.current&&(k.current(),O.current=P),P?!j&&p.loadedKey!==P&&(E.current=P,D.current=A.data,m({type:`load`,key:P,content:A.data})):p.loadedKey!==``&&m({type:`clear`});let F=(0,Q.useRef)({activeFile:d,selectedId:n});return(F.current.activeFile!==d||F.current.selectedId!==n)&&(F.current={activeFile:d,selectedId:n},v(`edit`)),{files:c,setFiles:l,filesLoading:u,activeFile:d,setActiveFile:(0,Q.useCallback)(e=>{k.current(),f(e)},[]),fileDraft:y,setFileDraft:(0,Q.useCallback)(e=>{m({type:`setDraft`,value:typeof e==`function`?e(x.current):e}),M()},[M]),fileSaving:h,filesViewMode:_,setFilesViewMode:v,profileFileLoading:j,profileEditorNonce:b,overviewSaveProfileMarkdownRef:T,saveProfileMarkdownDebounced:M}}function pi(e){let{panel:t,hasToken:n,bindingsFromConfig:r,gatewayCfgLoading:i,selected:a,saveErrorMessage:o,setBusy:s,setError:c}=e,l=(0,Q.useRef)(!1),[u,d]=(0,Q.useState)(null),f=(0,Q.useRef)(r);t===`channels`&&n&&!l.current&&f.current!==r&&(f.current=r,d(r));let p=u??r,m=t===`channels`&&n,h=G(()=>Wt(),[t,n],{enabled:m,initial:[],errorData:[]}),g=h.data,_=h.loading,v=(0,Q.useMemo)(()=>_||g.length===0?``:g[0]?.name??``,[g,_]),[y,b]=(0,Q.useState)(``),x=(0,Q.useRef)(v);t===`channels`&&!_&&v&&x.current!==v&&(!y||!g.some(e=>e.name===y))&&(x.current=v,b(v)),x.current=v;let S=y.trim(),C=m&&S.length>0,w=G(()=>Gt(S),[t,n,S],{enabled:C,initial:[],errorData:[]}),T=w.data,E=w.loading,D=w.setData,[O,k]=(0,Q.useState)(null),[j,M]=(0,Q.useState)(``),N=(0,Q.useRef)(S);N.current!==S&&(N.current=S,k(null));let P=(0,Q.useMemo)(()=>a?p.filter(e=>e.agentId.toLowerCase()===a.id.toLowerCase()):[],[p,a?.id]),F=(0,Q.useCallback)(()=>{let e=y.trim();e&&Gt(e).then(e=>{D(e),k(t=>t!=null&&t<e.length?t:null)}).catch(()=>{D([]),k(null)})},[y,D]),I=!_&&g.length===0,ee=t===`channels`&&n&&i,L=(0,Q.useCallback)(async e=>{s(!0),c(null);try{let t=p.filter(t=>t!==e);await A(t),l.current=!0,d(t)}catch(e){c(e instanceof Error?e.message:o)}finally{s(!1)}},[p,o,s,c]);return{agentBindings:P,allBindings:p,bindChannelStatuses:g,bindChannelsLoading:_,bindSessionChats:T,bindSessionsLoading:E,bindingsLoading:ee,newBindChannel:y,setNewBindChannel:b,newBindSessionIdx:O,setNewBindSessionIdx:k,newBindCustomPeer:j,setNewBindCustomPeer:M,onAddBinding:(0,Q.useCallback)(async e=>{if(e.preventDefault(),!a||!y.trim())return;let t=on(y,j,O,T),n=[...p,{agentId:a.id,priority:100,enabled:!0,match:t}];s(!0),c(null);try{await A(n),l.current=!0,d(n),k(null),M(``)}catch(e){c(e instanceof Error?e.message:o)}finally{s(!1)}},[p,T,y,j,O,o,a,s,c]),onRemoveBinding:L,refreshBindSessions:F,useManualChannel:I}}function mi(e){let{panel:t,hasToken:n,data:r,selected:i,saveErrorMessage:a,setBusy:o,setError:s}=e,{data:c,loading:l}=G(()=>Jt(),[t,n],{enabled:t===`cron`&&n,initial:[],errorData:[]}),[u,d]=(0,Q.useState)(null),f=u??c,p=(0,Q.useMemo)(()=>!r||!i?[]:f.filter(e=>!Ut(e)&&rn(e,i.id,r.defaultId)),[f,r,i]);async function m(e,t){o(!0),s(null);try{await Kt(e.id,{agentId:t===``?null:t}),d(await Jt())}catch(e){s(e instanceof Error?e.message:a)}finally{o(!1)}}return{agentCronJobs:p,cronJobs:f,cronLoading:l,onSetCronJobAgent:m}}function hi(e,t){let n=(0,X.c)(13),r;n[0]!==e||n[1]!==t?(r=[e,t],n[0]=e,n[1]=t,n[2]=r):r=n[2];let i=e&&t,a;n[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=[],n[3]=a):a=n[3];let o;n[4]===Symbol.for(`react.memo_cache_sentinel`)?(o=[],n[4]=o):o=n[4];let s;n[5]===i?s=n[6]:(s={enabled:i,initial:a,errorData:o},n[5]=i,n[6]=s);let{data:c,loading:l}=G(_i,r,s),u;n[7]===c?u=n[8]:(u=c.filter(gi),n[7]=c,n[8]=u);let d=u,f;return n[9]!==d||n[10]!==c||n[11]!==l?(f={catalogForPick:d,skillCatalog:c,skillsCatalogLoading:l},n[9]=d,n[10]=c,n[11]=l,n[12]=f):f=n[12],f}function gi(e){return e.enabled!==!1}function _i(){return me()}function vi(e){return hi(e.panel===`skills`,e.hasToken)}function yi(e){return new Set(e.tools.entryDisable)}function bi(e){return e.skills.entry===void 0?{inherit:!0,pick:new Set(e.skills.effectiveAllowlist??[])}:{inherit:!1,pick:new Set(e.skills.entry??[])}}function xi(e){let{panel:t,selected:n}=e,r=`${t}:${n?.id??``}`,i=(0,Q.useRef)(r),[a,o]=(0,Q.useState)(()=>new Set),[s,c]=(0,Q.useState)(()=>new Set),[l,u]=(0,Q.useState)(!0);if(i.current!==r&&(i.current=r,n&&t===`tools`&&o(yi(n)),n&&t===`skills`)){let e=bi(n);u(e.inherit),c(e.pick)}return{toolEntryDisable:a,setToolEntryDisable:o,skillsPick:s,setSkillsPick:c,skillsInherit:l,setSkillsInherit:u}}function Si(){let e=i(e=>e.language),t=a(e),n=t.agentsSettings,[r,o]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(``),m=t.cron,h=t.chat,_=!!g(e=>e.token),[v,y]=Le(),b=nt(),{agentId:x}=Tt(),S=w(e=>e.setPageHeader),C=w(e=>e.clearPageHeader),{data:T,error:E,isLoading:D,mutate:O}=s(_?`settings-gateway-agents`:null,P,{revalidateOnFocus:!1}),{data:A}=Ae(_),j=(0,Q.useMemo)(()=>xe(A?.payload?.config??{}),[A]),M=(0,Q.useMemo)(()=>Wr(A?.payload?.config??{}),[A]),N=T??null,F=!!(_&&D),[I,L]=(0,Q.useState)(null),R=E instanceof Error?E.message:E?n.loadError:null,z=I??R,[B,V]=(0,Q.useState)(null),[H,U]=(0,Q.useState)(()=>localStorage.getItem(hr)===`true`),[W,te]=(0,Q.useState)(`overview`),[ne,G]=(0,Q.useState)(``),[K,q]=(0,Q.useState)(``),[re,ie]=(0,Q.useState)(``),[ae,oe]=(0,Q.useState)(``),[se,ce]=(0,Q.useState)(``),[le,ue]=(0,Q.useState)(null),[de,fe]=(0,Q.useState)(!1),pe=(0,Q.useRef)(``),[me,he]=(0,Q.useState)(!1),[ge,_e]=(0,Q.useState)(``),[ve,ye]=(0,Q.useState)(``),[be,Se]=(0,Q.useState)(``),[Ce,we]=(0,Q.useState)(``),[Te,Ee]=(0,Q.useState)(``),De=(0,Q.useRef)(null),Oe=(0,Q.useRef)(null),[ke,je]=(0,Q.useState)(!1),[Me,Ne]=(0,Q.useState)(!1),Pe=(0,Q.useRef)({data:null,routeAgentId:void 0});N&&(N!==Pe.current.data||x!==Pe.current.routeAgentId)&&(Pe.current={data:N,routeAgentId:x},x&&N.agents.some(e=>e.id===x)?V(x):V(e=>e&&N.agents.some(t=>t.id===e)?e:N.defaultId));let Fe=N!=null&&N.agents.length<=1&&N.agents.every(e=>e.id===N.defaultId),Ie=!!(N&&!F&&Fe&&!H),Re=(0,Q.useCallback)(()=>{U(!0),O()},[O]),ze=(0,Q.useCallback)(()=>{localStorage.setItem(hr,`true`),U(!0)},[]);(0,Q.useEffect)(()=>{!N||!x||N.agents.some(e=>e.id===x)||b(ft,{replace:!0})},[N,x,b]),(0,Q.useEffect)(()=>{x&&te(`overview`)},[x]),(0,Q.useEffect)(()=>{v.get(`panel`)===`defaults`&&b(`/settings/agent-defaults?tab=chat`,{replace:!0,state:{[Ve]:ft}})},[v,b]),(0,Q.useEffect)(()=>{if(v.get(`focus`)!==`avatar`||!x||(te(`overview`),F||!N?.agents.some(e=>e.id===x)))return;let e=window.setTimeout(()=>{document.getElementById(`agent-avatar-settings`)?.scrollIntoView({behavior:`smooth`,block:`center`}),y(e=>{let t=new URLSearchParams(e);return t.delete(`focus`),t},{replace:!0})},220);return()=>window.clearTimeout(e)},[v,x,F,N,y]);let J=(0,Q.useMemo)(()=>N?.agents.find(e=>e.id===B)??null,[N,B]),Be=(0,Q.useRef)(null);J&&Be.current!==J.id?(Be.current=J.id,ye(J.workspace),Se(J.model?.primary??``),we(k(J,a(e).agentsSettings)),Ee(J.description?.trim()??``)):!J&&Be.current!==null&&(Be.current=null,ye(``),Se(``),we(``),Ee(``));let He=li({agentId:J?.id??null,enabled:W===`overview`&&!!J,saveRef:Oe}),Ue=fi({panel:W,selectedId:B,hasToken:_,dataAgentsLength:N?.agents.length,saveErrorMessage:n.saveError,setError:L}),We=xi({panel:W,selected:J}),Ge=pi({panel:W,hasToken:_,bindingsFromConfig:j,gatewayCfgLoading:A===void 0,selected:J,saveErrorMessage:n.saveError,setBusy:he,setError:L}),Ke=mi({panel:W,hasToken:_,data:N,selected:J,saveErrorMessage:n.saveError,setBusy:he,setError:L}),qe=vi({panel:W,hasToken:_}),Je=(0,Q.useCallback)(()=>{let e=oi(K.trim()||ne);oe(t=>t===``||t===pe.current?(pe.current=e,e):t)},[K,ne]),Ye=(0,Q.useCallback)(()=>{pe.current=``,G(``),q(``),ie(``),oe(``),ce(``),ue(null),fe(!0)},[]),Xe=(0,Q.useMemo)(()=>(0,Z.jsx)(si,{a:n,busy:me,listSearchQuery:ge,onListSearchQueryChange:_e,onAddAgent:()=>Ye()}),[n,me,ge,Ye]);(0,Q.useLayoutEffect)(()=>_?(S({startExtra:null,main:null,end:Xe}),()=>C()):(C(),()=>C()),[Xe,C,_,S]);async function Ze(e){e.preventDefault();let t=ne.trim();if(!t)return;let r=ii(K,t);if(r.ok===!1){ue(r.error);return}let i=ae.trim()||oi(K.trim()||t);if(i){he(!0),ue(null);try{let e=re.trim(),{createdAgentId:n,...r}=await ee({name:t,workspace:i,...K.trim()?{id:K.trim()}:{},...se.trim()?{model:se.trim()}:{},...e?{description:e}:{}});O(r,{revalidate:!1}),G(``),q(``),ie(``),oe(``),ce(``),ue(null),fe(!1),V(n),b(it(n))}catch(e){ue(e instanceof Error?e.message:n.saveError)}finally{he(!1)}}}async function Qe(){if(J){he(!0),L(null);try{let e=Te.trim();O(await mt(J.id,{name:Ce.trim()||void 0,description:e.length>0?e:null,workspace:ve.trim()||void 0,model:be.trim()||null}),{revalidate:!1})}catch(e){L(e instanceof Error?e.message:n.saveError)}finally{he(!1)}}}async function $e(e){he(!0),L(null);try{O(await mt(e.id,{setDefault:!0}),{revalidate:!1}),V(e.id)}catch(e){L(e instanceof Error?e.message:n.saveError)}finally{he(!1)}}async function et(e,t){he(!0),L(null);try{let n=await Pt(e.id,t);O(n,{revalidate:!1}),V(n.defaultId),te(`overview`),x===e.id&&b(ft,{replace:!0}),o(!1),l(null),p(``)}catch(e){L(e instanceof Error?e.message:n.saveError)}finally{he(!1)}}function tt(e,t){e.id!==`main`&&(l(e),d(t),p(``),o(!0))}async function rt(){if(J){he(!0),L(null);try{let e=Array.from(We.toolEntryDisable).toSorted((e,t)=>e.localeCompare(t));O(await mt(J.id,{toolsDisable:e}),{revalidate:!1})}catch(e){L(e instanceof Error?e.message:n.saveError)}finally{he(!1)}}}async function at(){if(J){he(!0),L(null);try{O(await mt(J.id,{toolsDisable:null}),{revalidate:!1}),We.setToolEntryDisable(new Set)}catch(e){L(e instanceof Error?e.message:n.saveError)}finally{he(!1)}}}async function ot(){if(J){he(!0),L(null);try{O(await mt(J.id,{skills:We.skillsInherit?null:[...We.skillsPick].toSorted((e,t)=>e.localeCompare(t))}),{revalidate:!1})}catch(e){L(e instanceof Error?e.message:n.saveError)}finally{he(!1)}}}let st=W===`channels`||W===`cron`,Y=(()=>{if(!J||W!==`overview`)return!1;let e=k(J,n),t=J.description?.trim()??``,r=J.workspace,i=J.model?.primary??``;return Ce.trim()!==e||Te.trim()!==t||ve.trim()!==r||be.trim()!==i})(),ct=(()=>{if(st)return!1;switch(W){case`overview`:return Y||He.dirty;case`profile`:return ke;default:return!0}})(),lt=st||!ct;function ut(){Ne(!0),setTimeout(()=>Ne(!1),2e3)}async function dt(){switch(W){case`overview`:await Promise.all([Qe(),Oe.current?.()??Promise.resolve()]),ut();break;case`profile`:await De.current?.(),ut();break;case`tools`:await rt(),ut();break;case`skills`:await ot(),ut();break;case`files`:Ue.saveProfileMarkdownDebounced.flush(),ut();break;default:break}}function pt(e){e||b(ft)}return{hasToken:_,a:n,chat:h,language:e,data:N,loading:F,displayError:z,navigate:b,routeAgentId:x,showPresetSetup:Ie,onPresetSetupComplete:Re,onPresetSetupSkip:ze,busy:me,listSearchQuery:ge,openAddAgentModal:Ye,panel:W,setPanel:te,modalTitle:J?Ce.trim()||k(J,n):x??``,modalSubtitle:J?.id??x??``,footerSaveDisabled:lt,savedFlash:Me,handleModalFooterSave:dt,onAgentModalOpenChange:pt,addAgentModalOpen:de,setAddAgentModalOpen:fe,createWorkspaceSuggestedRef:pe,createModalError:le,setCreateModalError:ue,createDisplayName:ne,setCreateDisplayName:G,createAgentId:K,setCreateAgentId:q,createDescription:re,setCreateDescription:ie,createWorkspace:ae,setCreateWorkspace:oe,createModel:se,setCreateModel:ce,onCreate:Ze,applyCreateWorkspaceSuggestion:Je,deleteDialogOpen:r,setDeleteDialogOpen:o,deletePurge:u,deleteTarget:c,setDeleteTarget:l,deleteConfirmText:f,setDeleteConfirmText:p,performDelete:et,editorPanelProps:{a:n,chat:h,cCron:m,selected:J,panel:W,data:N,busy:me,editName:Ce,setEditName:we,editDescription:Te,setEditDescription:Ee,editWorkspace:ve,setEditWorkspace:ye,editModel:be,setEditModel:Se,defaultModel:M.model,defaultWorkspace:M.workspace,onSetDefault:()=>{J&&$e(J)},onSaveAgentEdits:()=>void Qe(),onDelete:e=>{J&&tt(J,e)},overviewSaveProfileMarkdownRef:Oe,profileSaveRef:De,overviewProfile:He,setProfileDirty:je,filesLoading:Ue.filesLoading,files:Ue.files,activeFile:Ue.activeFile,setActiveFile:Ue.setActiveFile,filesViewMode:Ue.filesViewMode,setFilesViewMode:Ue.setFilesViewMode,fileDraft:Ue.fileDraft,setFileDraft:Ue.setFileDraft,fileSaving:Ue.fileSaving,profileFileLoading:Ue.profileFileLoading,profileEditorNonce:Ue.profileEditorNonce,toolEntryDisable:We.toolEntryDisable,setToolEntryDisable:We.setToolEntryDisable,onSaveTools:()=>void rt(),onClearToolsEntry:()=>void at(),skillsCatalogLoading:qe.skillsCatalogLoading,catalogForPick:qe.catalogForPick,skillsInherit:We.skillsInherit,setSkillsInherit:We.setSkillsInherit,skillsPick:We.skillsPick,setSkillsPick:We.setSkillsPick,onSaveSkills:()=>void ot(),bindingsLoading:Ge.bindingsLoading,agentBindings:Ge.agentBindings,bindChannelStatuses:Ge.bindChannelStatuses,bindChannelsLoading:Ge.bindChannelsLoading,useManualChannel:Ge.useManualChannel,newBindChannel:Ge.newBindChannel,setNewBindChannel:Ge.setNewBindChannel,bindSessionChats:Ge.bindSessionChats,bindSessionsLoading:Ge.bindSessionsLoading,newBindSessionIdx:Ge.newBindSessionIdx,setNewBindSessionIdx:Ge.setNewBindSessionIdx,newBindCustomPeer:Ge.newBindCustomPeer,setNewBindCustomPeer:Ge.setNewBindCustomPeer,refreshBindSessions:Ge.refreshBindSessions,onRemoveBinding:e=>void Ge.onRemoveBinding(e),onAddBinding:Ge.onAddBinding,cronLoading:Ke.cronLoading,agentCronJobs:Ke.agentCronJobs,onSetCronJobAgent:(e,t)=>void Ke.onSetCronJobAgent(e,t)}}}function Ci(){let e=Si();if(!e.hasToken)return(0,Z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,Z.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:e.a.title}),(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.a.needToken})]});if(e.showPresetSetup&&e.data){let t=new Set(e.data.agents.map(e=>e.id));if(gr.some(e=>!t.has(e.id)))return(0,Z.jsx)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col px-4 py-8`,children:(0,Z.jsx)(_r,{existingAgentIds:t,onComplete:e.onPresetSetupComplete,onSkip:e.onPresetSetupSkip})})}return(0,Z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-8`,children:[(0,Z.jsx)(fr,{a:e.a}),e.displayError?(0,Z.jsx)(`div`,{className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:e.displayError}):null,e.loading?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.a.loading}):e.data?(0,Z.jsx)(dr,{a:e.a,agents:e.data.agents,searchQuery:e.listSearchQuery,onOpenAgent:t=>e.navigate(it(t)),onChatWithAgent:t=>{let n=t.trim().toLowerCase();try{globalThis.localStorage?.setItem(Xe,n)}catch{}e.navigate(`/chat/new`,{state:{agentId:n}})},onNewAgent:e.openAddAgentModal,busy:e.busy}):null,e.routeAgentId&&e.hasToken?(0,Z.jsx)(en,{open:!!e.routeAgentId,onOpenChange:e.onAgentModalOpenChange,a:e.a,title:e.modalTitle,subtitle:e.modalSubtitle,panel:e.panel,onPanelChange:e.setPanel,onFooterSave:()=>void e.handleModalFooterSave(),footerSaveDisabled:e.footerSaveDisabled,footerSavedFlash:e.savedFlash,busy:e.busy,children:e.loading||!e.data?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.a.loading}):(0,Z.jsx)(cr,{...e.editorPanelProps})}):null,(0,Z.jsx)(pr,{open:e.addAgentModalOpen,onOpenChange:t=>{e.setAddAgentModalOpen(t),t||(e.createWorkspaceSuggestedRef.current=``,e.setCreateDisplayName(``),e.setCreateAgentId(``),e.setCreateDescription(``),e.setCreateWorkspace(``),e.setCreateModel(``),e.setCreateModalError(null))},a:e.a,chat:e.chat,busy:e.busy,modalError:e.createModalError,createDisplayName:e.createDisplayName,setCreateDisplayName:e.setCreateDisplayName,createAgentId:e.createAgentId,setCreateAgentId:e.setCreateAgentId,createDescription:e.createDescription,setCreateDescription:e.setCreateDescription,createWorkspace:e.createWorkspace,setCreateWorkspace:e.setCreateWorkspace,createModel:e.createModel,setCreateModel:e.setCreateModel,onCreate:e.onCreate,onSuggestWorkspace:()=>e.applyCreateWorkspaceSuggestion()}),(0,Z.jsx)(Yt,{open:e.deleteDialogOpen,onOpenChange:t=>{e.setDeleteDialogOpen(t),t||(e.setDeleteTarget(null),e.setDeleteConfirmText(``))},busy:e.busy,deletePurge:e.deletePurge,deleteTarget:e.deleteTarget,deleteConfirmText:e.deleteConfirmText,onDeleteConfirmTextChange:e.setDeleteConfirmText,onConfirm:()=>{e.deleteTarget&&e.performDelete(e.deleteTarget,e.deletePurge)},onCancel:()=>e.setDeleteDialogOpen(!1),a:e.a})]})}function $(e){let t=(0,X.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}),t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function wi(e){switch(e){case`ready`:return`bg-emerald-500`;case`not_installed`:case`checking`:return`bg-amber-500`;case`error`:return`bg-red-500`;default:return`bg-fg-subtle/60`}}function Ti(e){let t=(0,X.c)(28),{value:n,onChange:r,onOpenConfig:i,options:a,m:o}=e,s;if(t[0]!==o.browserGoToConfigure||t[1]!==o.browserPickerSubtitle||t[2]!==o.browserPickerTitle||t[3]!==r||t[4]!==i||t[5]!==a||t[6]!==n){let e=a.find(e=>e.value===n)??a[0],c;t[8]===o.browserPickerTitle?c=t[9]:(c=(0,Z.jsx)(`label`,{htmlFor:`browser-backend-select`,className:`text-sm font-medium text-fg`,children:o.browserPickerTitle}),t[8]=o.browserPickerTitle,t[9]=c);let l;t[10]===o.browserPickerSubtitle?l=t[11]:(l=(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:o.browserPickerSubtitle}),t[10]=o.browserPickerSubtitle,t[11]=l);let u;t[12]!==c||t[13]!==l?(u=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[c,l]}),t[12]=c,t[13]=l,t[14]=u):u=t[14];let d;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(d=Y(Zn(),`min-w-0 flex-1 sm:max-w-md`),t[15]=d):d=t[15];let f;t[16]===r?f=t[17]:(f=e=>r(e.target.value),t[16]=r,t[17]=f);let p=o.browserPickerTitle,m;t[18]===a?m=t[19]:(m=a.map(Ei),t[18]=a,t[19]=m);let h;t[20]!==o.browserPickerTitle||t[21]!==f||t[22]!==m||t[23]!==n?(h=(0,Z.jsx)(`select`,{id:`browser-backend-select`,className:d,value:n,onChange:f,"aria-label":p,children:m}),t[20]=o.browserPickerTitle,t[21]=f,t[22]=m,t[23]=n,t[24]=h):h=t[24];let g=i?(0,Z.jsxs)(`button`,{type:`button`,className:Y(`inline-flex shrink-0 items-center justify-center gap-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-xs font-medium text-accent`,`transition-colors hover:border-edge-strong hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),onClick:()=>i(n),"aria-label":`${e?.name??n} — ${o.browserGoToConfigure}`,children:[(0,Z.jsx)(`span`,{children:o.browserGoToConfigure}),(0,Z.jsx)(j,{className:`size-4 shrink-0`,"aria-hidden":!0})]}):null,_;t[25]!==g||t[26]!==h?(_=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:gap-2`,children:[h,g]}),t[25]=g,t[26]=h,t[27]=_):_=t[27],s=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[u,_,e?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2.5`,children:[(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e.statusLabel?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[11px] font-medium text-fg-muted`,"aria-label":e.statusLabel,children:[(0,Z.jsx)(`span`,{className:Y(`inline-block size-1.5 rounded-full`,wi(e.status)),"aria-hidden":!0}),e.statusLabel]}):null}),(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:e.tagline})]}):null]}),t[0]=o.browserGoToConfigure,t[1]=o.browserPickerSubtitle,t[2]=o.browserPickerTitle,t[3]=r,t[4]=i,t[5]=a,t[6]=n,t[7]=s}else s=t[7];return s}function Ei(e){return(0,Z.jsx)(`option`,{value:e.value,children:e.name},e.value)}function Di(e){return`browser-focus-${e}`}function Oi(e){switch(e){case`connection`:case`extension`:case`local`:case`cloak`:case`cdp`:case`cloud`:case`runtime`:case`security`:return e;default:return null}}function ki(e){let t=(0,X.c)(89),{a:n,form:r,update:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=Di(`runtime`),t[0]=a):a=t[0];let o;t[1]===n.browserBehaviorShow?o=t[2]:(o=(0,Z.jsx)(Rt,{icon:kt,title:n.browserBehaviorShow}),t[1]=n.browserBehaviorShow,t[2]=o);let s;t[3]===i?s=t[4]:(s=e=>i({browserHeadless:e.target.checked}),t[3]=i,t[4]=s);let c;t[5]!==r.browserHeadless||t[6]!==s?(c=(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.browserHeadless,onChange:s}),t[5]=r.browserHeadless,t[6]=s,t[7]=c):c=t[7];let l;t[8]===n.browserHeadlessOn?l=t[9]:(l=(0,Z.jsx)(`span`,{children:n.browserHeadlessOn}),t[8]=n.browserHeadlessOn,t[9]=l);let u;t[10]!==c||t[11]!==l?(u=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[c,l]}),t[10]=c,t[11]=l,t[12]=u):u=t[12];let d;t[13]!==n.desc.browserHeadless||t[14]!==n.label.browserHeadless||t[15]!==u?(d=(0,Z.jsx)($,{label:n.label.browserHeadless,description:n.desc.browserHeadless,children:u}),t[13]=n.desc.browserHeadless,t[14]=n.label.browserHeadless,t[15]=u,t[16]=d):d=t[16];let f=n.label.browserDialogPolicy,p=n.desc.browserDialogPolicy,m;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(m=Zn(),t[17]=m):m=t[17];let h;t[18]===i?h=t[19]:(h=e=>i({browserDialogPolicy:e.target.value}),t[18]=i,t[19]=h);let g;t[20]===n.browserDialogPolicyMustRespond?g=t[21]:(g=(0,Z.jsx)(`option`,{value:`must_respond`,children:n.browserDialogPolicyMustRespond}),t[20]=n.browserDialogPolicyMustRespond,t[21]=g);let _;t[22]===n.browserDialogPolicyAutoDismiss?_=t[23]:(_=(0,Z.jsx)(`option`,{value:`auto_dismiss`,children:n.browserDialogPolicyAutoDismiss}),t[22]=n.browserDialogPolicyAutoDismiss,t[23]=_);let v;t[24]===n.browserDialogPolicyAutoAccept?v=t[25]:(v=(0,Z.jsx)(`option`,{value:`auto_accept`,children:n.browserDialogPolicyAutoAccept}),t[24]=n.browserDialogPolicyAutoAccept,t[25]=v);let y;t[26]!==r.browserDialogPolicy||t[27]!==h||t[28]!==g||t[29]!==_||t[30]!==v?(y=(0,Z.jsxs)(`select`,{className:m,value:r.browserDialogPolicy,onChange:h,children:[g,_,v]}),t[26]=r.browserDialogPolicy,t[27]=h,t[28]=g,t[29]=_,t[30]=v,t[31]=y):y=t[31];let b;t[32]!==n.desc.browserDialogPolicy||t[33]!==n.label.browserDialogPolicy||t[34]!==y?(b=(0,Z.jsx)($,{label:f,description:p,children:y}),t[32]=n.desc.browserDialogPolicy,t[33]=n.label.browserDialogPolicy,t[34]=y,t[35]=b):b=t[35];let x=n.label.browserDialogTimeout,S=n.desc.browserDialogTimeout,C;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(C=Xn(),t[36]=C):C=t[36];let w=r.browserDialogTimeout??``,T;t[37]===i?T=t[38]:(T=e=>{let t=e.target.value;i({browserDialogTimeout:t===``?void 0:Number.parseInt(t,10)})},t[37]=i,t[38]=T);let E;t[39]!==w||t[40]!==T?(E=(0,Z.jsx)(`input`,{type:`number`,className:C,min:1,value:w,placeholder:`300`,onChange:T}),t[39]=w,t[40]=T,t[41]=E):E=t[41];let D;t[42]!==n.desc.browserDialogTimeout||t[43]!==n.label.browserDialogTimeout||t[44]!==E?(D=(0,Z.jsx)($,{label:x,description:S,children:E}),t[42]=n.desc.browserDialogTimeout,t[43]=n.label.browserDialogTimeout,t[44]=E,t[45]=D):D=t[45];let O;t[46]!==b||t[47]!==D||t[48]!==d?(O=(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[d,b,D]}),t[46]=b,t[47]=D,t[48]=d,t[49]=O):O=t[49];let k;t[50]!==o||t[51]!==O?(k=(0,Z.jsx)(`div`,{id:a,className:`scroll-mt-24`,children:(0,Z.jsxs)(zt,{children:[o,O]})}),t[50]=o,t[51]=O,t[52]=k):k=t[52];let A;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(A=Di(`security`),t[53]=A):A=t[53];let j;t[54]===n.browserSecurityShow?j=t[55]:(j=(0,Z.jsx)(Rt,{icon:K,title:n.browserSecurityShow}),t[54]=n.browserSecurityShow,t[55]=j);let M;t[56]===i?M=t[57]:(M=e=>i({browserAllowPrivateUrls:e.target.checked}),t[56]=i,t[57]=M);let N;t[58]!==r.browserAllowPrivateUrls||t[59]!==M?(N=(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.browserAllowPrivateUrls,onChange:M}),t[58]=r.browserAllowPrivateUrls,t[59]=M,t[60]=N):N=t[60];let P;t[61]===n.browserAllowPrivateOn?P=t[62]:(P=(0,Z.jsx)(`span`,{children:n.browserAllowPrivateOn}),t[61]=n.browserAllowPrivateOn,t[62]=P);let F;t[63]!==N||t[64]!==P?(F=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[N,P]}),t[63]=N,t[64]=P,t[65]=F):F=t[65];let I;t[66]!==n.desc.browserAllowPrivateUrls||t[67]!==n.label.browserAllowPrivateUrls||t[68]!==F?(I=(0,Z.jsx)($,{label:n.label.browserAllowPrivateUrls,description:n.desc.browserAllowPrivateUrls,children:F}),t[66]=n.desc.browserAllowPrivateUrls,t[67]=n.label.browserAllowPrivateUrls,t[68]=F,t[69]=I):I=t[69];let ee=n.label.browserCommandTimeout,L=n.desc.browserCommandTimeout,R;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(R=Xn(),t[70]=R):R=t[70];let z=r.browserCommandTimeout??``,B;t[71]===i?B=t[72]:(B=e=>{let t=e.target.value;i({browserCommandTimeout:t===``?void 0:Number.parseInt(t,10)})},t[71]=i,t[72]=B);let V;t[73]!==z||t[74]!==B?(V=(0,Z.jsx)(`input`,{type:`number`,className:R,min:5,value:z,placeholder:`30`,onChange:B}),t[73]=z,t[74]=B,t[75]=V):V=t[75];let H;t[76]!==n.desc.browserCommandTimeout||t[77]!==n.label.browserCommandTimeout||t[78]!==V?(H=(0,Z.jsx)($,{label:ee,description:L,children:V}),t[76]=n.desc.browserCommandTimeout,t[77]=n.label.browserCommandTimeout,t[78]=V,t[79]=H):H=t[79];let U;t[80]!==I||t[81]!==H?(U=(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[I,H]}),t[80]=I,t[81]=H,t[82]=U):U=t[82];let W;t[83]!==j||t[84]!==U?(W=(0,Z.jsx)(`div`,{id:A,className:`scroll-mt-24`,children:(0,Z.jsxs)(zt,{className:`border border-amber-500/20`,children:[j,U]})}),t[83]=j,t[84]=U,t[85]=W):W=t[85];let te;return t[86]!==k||t[87]!==W?(te=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[k,W]}),t[86]=k,t[87]=W,t[88]=te):te=t[88],te}function Ai(e){let t=(0,X.c)(9),{language:n,label:r,className:i}=e,a;t[0]===n?a=t[1]:(a=he(n),t[0]=n,t[1]=a);let o;t[2]===i?o=t[3]:(o=Y(`inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,i),t[2]=i,t[3]=o);let s;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(fe,{className:`size-3 shrink-0`,"aria-hidden":!0}),t[4]=s):s=t[4];let c;return t[5]!==r||t[6]!==a||t[7]!==o?(c=(0,Z.jsxs)(`a`,{href:a,target:`_blank`,rel:`noreferrer`,className:o,children:[r,s]}),t[5]=r,t[6]=a,t[7]=o,t[8]=c):c=t[8],c}function ji(e){let t=(0,X.c)(27),{title:n,description:r,recommended:i,recommendedLabel:a,icon:o,onSelect:s,selectLabel:c}=e,l=`${n} — ${c}`,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=Y(`group flex w-full flex-col rounded-xl border border-edge bg-surface-panel px-3 py-3 text-left transition-colors`,`hover:border-edge-strong hover:bg-surface-hover/40`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),t[0]=u):u=t[0];let d;t[1]===o?d=t[2]:(d=(0,Z.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover text-fg-muted`,children:(0,Z.jsx)(o,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[1]=o,t[2]=d);let f;t[3]===n?f=t[4]:(f=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[3]=n,t[4]=f);let p;t[5]!==i||t[6]!==a?(p=i&&a?(0,Z.jsx)(`span`,{className:`rounded-full bg-accent/15 px-2 py-0.5 text-[10px] font-medium text-accent`,children:a}):null,t[5]=i,t[6]=a,t[7]=p):p=t[7];let m;t[8]!==f||t[9]!==p?(m=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f,p]}),t[8]=f,t[9]=p,t[10]=m):m=t[10];let h;t[11]===r?h=t[12]:(h=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:r}),t[11]=r,t[12]=h);let g;t[13]!==m||t[14]!==h?(g=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[m,h]}),t[13]=m,t[14]=h,t[15]=g):g=t[15];let _;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Z.jsx)(j,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0}),t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==g?(v=(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[d,g,_]}),t[17]=d,t[18]=g,t[19]=v):v=t[19];let y;t[20]===c?y=t[21]:(y=(0,Z.jsx)(`span`,{className:`mt-2 text-[11px] font-medium text-accent`,children:c}),t[20]=c,t[21]=y);let b;return t[22]!==s||t[23]!==l||t[24]!==v||t[25]!==y?(b=(0,Z.jsxs)(`button`,{type:`button`,onClick:s,"aria-label":l,className:u,children:[v,y]}),t[22]=s,t[23]=l,t[24]=v,t[25]=y,t[26]=b):b=t[26],b}function Mi(e){let t=(0,X.c)(28),{m:n,onStart:r}=e,i;t[0]!==n.browserSetupExtDesc||t[1]!==n.browserSetupExtTitle?(i={id:`extension`,icon:It,title:n.browserSetupExtTitle,description:n.browserSetupExtDesc,recommended:!0},t[0]=n.browserSetupExtDesc,t[1]=n.browserSetupExtTitle,t[2]=i):i=t[2];let a;t[3]!==n.browserSetupLocalDesc||t[4]!==n.browserSetupLocalTitle?(a={id:`local`,icon:De,title:n.browserSetupLocalTitle,description:n.browserSetupLocalDesc},t[3]=n.browserSetupLocalDesc,t[4]=n.browserSetupLocalTitle,t[5]=a):a=t[5];let o;t[6]!==n.browserSetupCloudDesc||t[7]!==n.browserSetupCloudTitle?(o={id:`cloud`,icon:W,title:n.browserSetupCloudTitle,description:n.browserSetupCloudDesc},t[6]=n.browserSetupCloudDesc,t[7]=n.browserSetupCloudTitle,t[8]=o):o=t[8];let s;t[9]!==i||t[10]!==a||t[11]!==o?(s=[i,a,o],t[9]=i,t[10]=a,t[11]=o,t[12]=s):s=t[12];let c=s,l;t[13]===n.browserSetupTitle?l=t[14]:(l=(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.browserSetupTitle}),t[13]=n.browserSetupTitle,t[14]=l);let u;t[15]===n.browserSetupSubtitle?u=t[16]:(u=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:n.browserSetupSubtitle}),t[15]=n.browserSetupSubtitle,t[16]=u);let d;t[17]!==l||t[18]!==u?(d=(0,Z.jsxs)(`div`,{children:[l,u]}),t[17]=l,t[18]=u,t[19]=d):d=t[19];let f;t[20]!==n.browserSetupRecommended||t[21]!==n.browserSetupSelect||t[22]!==c||t[23]!==r?(f=(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:c.map(e=>(0,Z.jsx)(ji,{icon:e.icon,title:e.title,description:e.description,recommended:e.recommended,recommendedLabel:n.browserSetupRecommended,selectLabel:n.browserSetupSelect,onSelect:()=>r(e.id)},e.id))}),t[20]=n.browserSetupRecommended,t[21]=n.browserSetupSelect,t[22]=c,t[23]=r,t[24]=f):f=t[24];let p;return t[25]!==d||t[26]!==f?(p=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-base px-4 py-4`,children:[d,f]}),t[25]=d,t[26]=f,t[27]=p):p=t[27],p}function Ni(e){if(e.kind===`loading`)return`checking`;if(e.kind===`error`)return`error`;if(e.kind===`ok`)return e.data.installed?`ready`:`not_installed`}function Pi(e,t){if(e)return{ready:t.browserStatusReady,not_installed:t.browserStatusNotInstalled,checking:t.browserStatusChecking,unknown:t.browserStatusUnknown,error:t.browserStatusError}[e]}function Fi(e){if(e.kind!==`idle`)return e.kind===`loading`?`checking`:e.kind===`error`?`error`:e.data.connected?`ready`:(e.data.running,`not_installed`)}function Ii(e,t){if(e.kind!==`idle`)return e.kind===`loading`?t.browserStatusChecking:e.kind===`error`?t.browserStatusError:e.data.connected?t.browserExtensionConnected:e.data.running?t.browserExtensionWaiting:t.browserExtensionServerOff}var Li=[`overview`,`extension`,`local`,`cloakbrowser`,`cdp`,`cloud`],Ri=[`extension`,`local`,`cloakbrowser`,`cdp`,`cloud`],zi={connection:`overview`,extension:`extension`,local:`local`,cloak:`cloakbrowser`,cdp:`cdp`,cloud:`cloud`,runtime:`overview`,security:`overview`};function Bi(e){let t=(e??``).trim();return t===`behavior`?`overview`:Li.includes(t)?t:`overview`}function Vi(e){return Ri.includes(e)}function Hi(e){let t=(0,X.c)(46),{icon:n,title:r,description:i,status:a,statusDetail:o,primaryAction:s,children:c,advanced:l,m:u,embedded:d,sectionTitle:f,advancedTitle:p}=e,m=d===void 0?!1:d,h;t[0]!==l||t[1]!==p?(h=l?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[p?(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:p}):null,l]}):null,t[0]=l,t[1]=p,t[2]=h):h=t[2];let g=h;if(m){let e;t[3]!==i||t[4]!==f?(e=f?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:f}),i?(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:i}):null]}):null,t[3]=i,t[4]=f,t[5]=e):e=t[5];let n;t[6]!==u||t[7]!==s||t[8]!==a||t[9]!==o?(n=a||s?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[a?(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(Ui,{kind:a,detail:o,m:u})}):(0,Z.jsx)(`span`,{}),s?(0,Z.jsx)(`div`,{className:`shrink-0`,children:s}):null]}):null,t[6]=u,t[7]=s,t[8]=a,t[9]=o,t[10]=n):n=t[10];let r;t[11]===c?r=t[12]:(r=c?(0,Z.jsx)(`div`,{className:`flex flex-col gap-4`,children:c}):null,t[11]=c,t[12]=r);let l;return t[13]!==g||t[14]!==e||t[15]!==n||t[16]!==r?(l=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[e,n,r,g]}),t[13]=g,t[14]=e,t[15]=n,t[16]=r,t[17]=l):l=t[17],l}let _;t[18]===n?_=t[19]:(_=(0,Z.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover text-fg-muted`,children:(0,Z.jsx)(n,{className:`size-4`,strokeWidth:1.75})}),t[18]=n,t[19]=_);let v;t[20]===r?v=t[21]:(v=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:r}),t[20]=r,t[21]=v);let y;t[22]!==u||t[23]!==a||t[24]!==o?(y=a?(0,Z.jsx)(Ui,{kind:a,detail:o,m:u}):null,t[22]=u,t[23]=a,t[24]=o,t[25]=y):y=t[25];let b;t[26]!==v||t[27]!==y?(b=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[v,y]}),t[26]=v,t[27]=y,t[28]=b):b=t[28];let x;t[29]===i?x=t[30]:(x=(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:i}),t[29]=i,t[30]=x);let S;t[31]!==b||t[32]!==x?(S=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[b,x]}),t[31]=b,t[32]=x,t[33]=S):S=t[33];let C;t[34]===s?C=t[35]:(C=s?(0,Z.jsx)(`div`,{className:`shrink-0`,children:s}):null,t[34]=s,t[35]=C);let w;t[36]!==_||t[37]!==S||t[38]!==C?(w=(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[_,S,C]}),t[36]=_,t[37]=S,t[38]=C,t[39]=w):w=t[39];let T;t[40]===c?T=t[41]:(T=c?(0,Z.jsx)(`div`,{className:`flex flex-col gap-4`,children:c}):null,t[40]=c,t[41]=T);let E;return t[42]!==g||t[43]!==w||t[44]!==T?(E=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl border border-edge bg-surface-panel p-4`,children:[w,T,g]}),t[42]=g,t[43]=w,t[44]=T,t[45]=E):E=t[45],E}function Ui(e){let t=(0,X.c)(27),{kind:n,detail:r,m:i}=e,a,o,s,c;if(t[0]!==n||t[1]!==i.browserStatusChecking||t[2]!==i.browserStatusError||t[3]!==i.browserStatusNotInstalled||t[4]!==i.browserStatusReady||t[5]!==i.browserStatusUnknown){let{icon:e,color:r,label:l}={ready:{icon:ve,color:`text-green-600 dark:text-green-400`,label:i.browserStatusReady},not_installed:{icon:Ue,color:`text-amber-600 dark:text-amber-400`,label:i.browserStatusNotInstalled},checking:{icon:Ye,color:`text-fg-muted`,label:i.browserStatusChecking},unknown:{icon:C,color:`text-fg-muted`,label:i.browserStatusUnknown},error:{icon:ce,color:`text-red-600 dark:text-red-400`,label:i.browserStatusError}}[n];a=e,o=l,c=`inline-flex min-w-0 flex-col items-start gap-1`,s=Y(`inline-flex shrink-0 items-center gap-1 whitespace-nowrap text-xs font-medium`,r),t[0]=n,t[1]=i.browserStatusChecking,t[2]=i.browserStatusError,t[3]=i.browserStatusNotInstalled,t[4]=i.browserStatusReady,t[5]=i.browserStatusUnknown,t[6]=a,t[7]=o,t[8]=s,t[9]=c}else a=t[6],o=t[7],s=t[8],c=t[9];let l=n===`checking`&&`animate-spin`,u;t[10]===l?u=t[11]:(u=Y(`size-3.5 shrink-0`,l),t[10]=l,t[11]=u);let d;t[12]!==a||t[13]!==u?(d=(0,Z.jsx)(a,{className:u}),t[12]=a,t[13]=u,t[14]=d):d=t[14];let f;t[15]===o?f=t[16]:(f=(0,Z.jsx)(`span`,{children:o}),t[15]=o,t[16]=f);let p;t[17]!==s||t[18]!==d||t[19]!==f?(p=(0,Z.jsxs)(`span`,{className:s,children:[d,f]}),t[17]=s,t[18]=d,t[19]=f,t[20]=p):p=t[20];let m;t[21]===r?m=t[22]:(m=r?(0,Z.jsx)(`span`,{className:`break-all font-mono text-[11px] leading-snug text-fg-subtle`,children:r}):null,t[21]=r,t[22]=m);let h;return t[23]!==c||t[24]!==p||t[25]!==m?(h=(0,Z.jsxs)(`span`,{className:c,children:[p,m]}),t[23]=c,t[24]=p,t[25]=m,t[26]=h):h=t[26],h}function Wi(e){let t=(0,X.c)(5),{kind:n,message:r}=e,i=n===`success`?`border-green-500/30 bg-green-500/10 text-green-700 dark:text-green-300`:`border-red-500/30 bg-red-500/10 text-red-600 dark:text-red-300`,a;t[0]===i?a=t[1]:(a=Y(`rounded-lg border px-3 py-2 text-xs leading-relaxed`,i),t[0]=i,t[1]=a);let o;return t[2]!==r||t[3]!==a?(o=(0,Z.jsx)(`div`,{className:a,children:r}),t[2]=r,t[3]=a,t[4]=o):o=t[4],o}var Gi={instances:[],launchStatus:`idle`,launchMessage:null,testStatus:`idle`,testMessage:null,executablePath:``};function Ki({m:e,cdpUrl:t,onCdpUrlChange:n,launch:r,stop:i,listInstances:a,ping:o,embedded:s=!1}){let[c,l]=(0,Q.useReducer)(yt,Gi),{instances:u,launchStatus:d,launchMessage:f,testStatus:p,testMessage:m,executablePath:h}=c,g=(0,Q.useCallback)(async()=>{try{l({type:`patch`,patch:{instances:await a()}})}catch{}},[a]);(0,Q.useEffect)(()=>{g();let e=setInterval(()=>void g(),8e3);return()=>clearInterval(e)},[g]);let _=(0,Q.useCallback)(async()=>{if(d!==`pending`){l({type:`patch`,patch:{launchStatus:`pending`,launchMessage:null}});try{let t=await r(h.trim()||void 0);l({type:`patch`,patch:{launchStatus:`ok`,launchMessage:e.browserCdpLaunchedAtPort.replace(`{{port}}`,String(t.port))}}),n(t.wsEndpoint),await g()}catch(e){l({type:`patch`,patch:{launchStatus:`error`,launchMessage:e instanceof Error?e.message:String(e)}})}}},[h,r,d,e.browserCdpLaunchedAtPort,n,g]),v=(0,Q.useCallback)(async e=>{await i(e),await g()},[g,i]),y=(0,Q.useCallback)(async()=>{if(t.trim()){l({type:`patch`,patch:{testStatus:`pending`,testMessage:null}});try{let n=await o(t.trim());n.reachable?l({type:`patch`,patch:{testStatus:`ok`,testMessage:e.browserCdpReachable.replace(`{{browser}}`,n.browser??`—`)}}):l({type:`patch`,patch:{testStatus:`error`,testMessage:e.browserCdpUnreachable.replace(`{{error}}`,n.error??`—`)}})}catch(t){l({type:`patch`,patch:{testStatus:`error`,testMessage:e.browserCdpUnreachable.replace(`{{error}}`,t instanceof Error?t.message:String(t))}})}}},[t,e.browserCdpReachable,e.browserCdpUnreachable,o]);return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsxs)(Hi,{icon:ge,title:e.browserCdpLaunchLocal,description:e.browserCdpLaunchLocalDesc,m:e,embedded:s,sectionTitle:s?e.browserCdpLaunchLocal:void 0,primaryAction:(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:d===`pending`,onClick:()=>void _(),children:[d===`pending`?(0,Z.jsx)(Ye,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(ge,{className:`size-3.5`}),d===`pending`?e.browserCdpLaunching:e.browserCdpLaunchLocal]}),children:[f?(0,Z.jsx)(Wi,{kind:d===`error`?`error`:`success`,message:f}):null,(0,Z.jsx)($,{label:e.browserCdpChromePath,description:e.browserCdpChromePathDesc,children:(0,Z.jsx)(`input`,{type:`text`,className:Xn(),value:h,placeholder:`/Applications/Google Chrome.app/Contents/MacOS/Google Chrome`,onChange:e=>l({type:`patch`,patch:{executablePath:e.target.value}}),autoComplete:`off`})}),u.length>0?(0,Z.jsx)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge bg-surface-base p-3 text-xs`,children:u.map(t=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,Z.jsxs)(`span`,{className:`font-mono text-fg`,children:[`port `,t.port,` · pid `,t.pid]}),(0,Z.jsx)(`span`,{className:`truncate text-fg-subtle`,children:t.wsEndpoint})]}),(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs font-medium text-fg hover:bg-surface-raised`,onClick:()=>void v(t.port),children:[(0,Z.jsx)(Ne,{className:`size-3`}),e.browserCdpStopLocal]})]},t.port))}):null]}),(0,Z.jsxs)(Hi,{icon:dt,title:e.label.browserCdpUrl,description:e.desc.browserCdpUrl,m:e,embedded:s,sectionTitle:s?e.label.browserCdpUrl:void 0,primaryAction:(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:!t.trim()||p===`pending`,onClick:()=>void y(),children:[p===`pending`?(0,Z.jsx)(Ye,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(F,{className:`size-3.5`}),p===`pending`?e.browserCdpTesting:e.browserCdpTestConnection]}),children:[(0,Z.jsx)(`input`,{type:`text`,className:Xn(),value:t,placeholder:`ws://127.0.0.1:9222`,onChange:e=>n(e.target.value),autoComplete:`off`}),(0,Z.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:e.browserCdpLoopbackOnly}),m?(0,Z.jsx)(Wi,{kind:p===`error`?`error`:`success`,message:m}):null]})]})}function qi(e,t){let n=t.phase;if(!n)return e.browserInstallPhaseStarting;if(n===`downloading`)return t.percent==null?e.browserInstallPhaseDownloading:e.browserInstallPhaseDownloadingPercent.replace(`{{percent}}`,String(t.percent));switch(n){case`starting`:return e.browserInstallPhaseStarting;case`verifying`:return e.browserInstallPhaseVerifying;case`extracting`:return e.browserInstallPhaseExtracting;case`running`:return t.message??e.browserInstallPhaseRunning;case`ready`:return e.browserInstallPhaseReady;default:return t.message??e.browserInstallPhaseRunning}}function Ji(e){let t=(0,X.c)(32),{m:n,progress:r,showLogs:i,onCancel:a,cancelling:o}=e,s=i===void 0?!1:i,c=o===void 0?!1:o;if(!r.phase)return null;let l;t[0]!==n||t[1]!==r?(l=qi(n,r),t[0]=n,t[1]=r,t[2]=l):l=t[2];let u=l,d=r.percent==null?(r.phase===`extracting`||r.phase===`verifying`||r.phase===`running`||r.phase,null):Math.min(100,Math.max(0,r.percent)),f;t[3]===u?f=t[4]:(f=(0,Z.jsx)(`span`,{className:`text-fg`,children:u}),t[3]=u,t[4]=f);let p;t[5]===d?p=t[6]:(p=d==null?null:(0,Z.jsxs)(`span`,{className:`tabular-nums`,children:[d,`%`]}),t[5]=d,t[6]=p);let m;t[7]!==c||t[8]!==n||t[9]!==a?(m=a?(0,Z.jsx)(`button`,{type:`button`,className:`rounded-md border border-edge px-2 py-0.5 text-[11px] font-medium text-fg-muted hover:bg-surface-raised hover:text-fg disabled:cursor-not-allowed disabled:opacity-60`,disabled:c,onClick:()=>void a(),children:c?n.browserInstallCancelling:n.browserInstallCancel}):null,t[7]=c,t[8]=n,t[9]=a,t[10]=m):m=t[10];let h;t[11]!==p||t[12]!==m?(h=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[p,m]}),t[11]=p,t[12]=m,t[13]=h):h=t[13];let g;t[14]!==f||t[15]!==h?(g=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs text-fg-muted`,children:[f,h]}),t[14]=f,t[15]=h,t[16]=g):g=t[16];let _;t[17]===d?_=t[18]:(_=(0,Z.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-surface-raised`,children:d==null?(0,Z.jsx)(`div`,{className:`h-full w-1/3 animate-pulse rounded-full bg-accent/70`}):(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-[width] duration-300 ease-out`,style:{width:`${d}%`}})}),t[17]=d,t[18]=_);let v;t[19]!==r.lines||t[20]!==s?(v=s&&r.lines.length>0?(0,Z.jsx)(`div`,{className:`max-h-28 overflow-y-auto rounded-md border border-edge bg-surface-panel px-2 py-1.5 font-mono text-[10px] leading-relaxed text-fg-muted`,children:r.lines.map(Yi)}):null,t[19]=r.lines,t[20]=s,t[21]=v):v=t[21];let y;t[22]!==r.message||t[23]!==r.percent||t[24]!==r.phase||t[25]!==s?(y=!s&&r.phase===`downloading`&&r.message&&r.percent==null?(0,Z.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:r.message}):null,t[22]=r.message,t[23]=r.percent,t[24]=r.phase,t[25]=s,t[26]=y):y=t[26];let b;return t[27]!==v||t[28]!==y||t[29]!==g||t[30]!==_?(b=(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-edge bg-surface-base px-3 py-2.5`,children:[g,_,v,y]}),t[27]=v,t[28]=y,t[29]=g,t[30]=_,t[31]=b):b=t[31],b}function Yi(e,t){return(0,Z.jsx)(`div`,{className:`truncate`,children:e},`${t}-${e.slice(0,24)}`)}var Xi={confirmOpen:!1,installStatus:`idle`,installMessage:null,openStatus:`idle`,openMessage:null,runtime:null};function Zi({m:e,doctor:t,refetch:n,applyDoctor:r,installStream:i,fetchRuntimeStatus:a,launchCloak:o,form:s,onChange:c,embedded:l=!1}){let[u,d]=(0,Q.useReducer)(yt,Xi),{confirmOpen:f,installStatus:p,installMessage:m,openStatus:h,openMessage:g,runtime:_}=u,{progress:v,running:y,cancelling:b,run:x,reset:S,cancel:C}=i,w=t.kind===`ok`?t.data:null,T=w?.installed===!0,E=p===`installing`||y,k=(0,Q.useCallback)(async()=>{if(T)try{d({type:`patch`,patch:{runtime:await a()}})}catch{}},[a,T]);(0,Q.useEffect)(()=>{if(!T){d({type:`patch`,patch:{runtime:null}});return}k();let e=setInterval(()=>void k(),8e3);return()=>clearInterval(e)},[T,k]);let A=(0,Q.useCallback)(async()=>{d({type:`patch`,patch:{confirmOpen:!1,installStatus:`installing`,installMessage:null}}),S();let t=await x({body:{cacheDir:s.cacheDir.trim()||void 0,binaryPath:s.binaryPath.trim()||void 0},fallbackError:e.browserCloakInstallFailed});if(!t.ok){if(t.error===`busy`){d({type:`patch`,patch:{installStatus:`installing`}});return}if(t.error===`cancelled`){d({type:`patch`,patch:{installStatus:`idle`,installMessage:null}}),S();return}d({type:`patch`,patch:{installStatus:`failed`,installMessage:t.errorMessage??e.browserCloakInstallFailed}});return}t.payload&&r?.(t.payload),d({type:`patch`,patch:{installStatus:`installed`,installMessage:t.payload?.binaryPath?`${e.browserCloakInstalled}: ${t.payload.binaryPath}`:e.browserCloakInstalled}}),await n({cacheDir:s.cacheDir,binaryPath:s.binaryPath}),await k()},[r,s.binaryPath,s.cacheDir,e.browserCloakInstallFailed,e.browserCloakInstalled,n,k,S,x]),j=(0,Q.useCallback)(async()=>{if(h!==`pending`){d({type:`patch`,patch:{openStatus:`pending`,openMessage:null}});try{let t=await o();d({type:`patch`,patch:{openStatus:`ok`,openMessage:t.reused?e.browserCloakOpenReused.replace(`{{port}}`,String(t.port)):e.browserCloakOpenLaunched.replace(`{{port}}`,String(t.port)),runtime:t}})}catch(e){d({type:`patch`,patch:{openStatus:`error`,openMessage:e instanceof Error?e.message:String(e)}})}}},[o,e.browserCloakOpenLaunched,e.browserCloakOpenReused,h]),M=t.kind===`loading`?`checking`:t.kind===`error`?`error`:T?`ready`:`not_installed`,N=T&&w?.version?`v${w.version} (${w.platform})`:void 0;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Hi,{icon:O,title:e.browserCloakGuideTitle,description:e.browserCloakGuideDesc,status:M,statusDetail:N,m:e,embedded:l,primaryAction:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[T?(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:h===`pending`,onClick:()=>void j(),children:[h===`pending`?(0,Z.jsx)(Ye,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(ge,{className:`size-3.5`}),h===`pending`?e.browserCloakOpening:e.browserCloakOpen]}):null,(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:E,onClick:()=>d({type:`patch`,patch:{confirmOpen:!0}}),children:[E?(0,Z.jsx)(Ye,{className:`size-3.5 animate-spin`}):T?(0,Z.jsx)(le,{className:`size-3.5`}):p===`installed`?(0,Z.jsx)(ve,{className:`size-3.5 text-green-500`}):(0,Z.jsx)(D,{className:`size-3.5`}),E?e.browserCloakInstalling:T?e.browserReinstall:e.browserCloakDownload]})]}),children:[y?(0,Z.jsx)(Ji,{m:e,progress:v,cancelling:b,onCancel:()=>void C()}):null,m?(0,Z.jsx)(Wi,{kind:p===`failed`?`error`:`success`,message:m}):null,g?(0,Z.jsx)(Wi,{kind:h===`error`?`error`:`success`,message:g}):null,T&&_?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge bg-surface-base p-3 text-xs`,children:[(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:_.running?e.browserCloakRuntimeRunning.replace(`{{port}}`,String(_.port)):e.browserCloakRuntimeOff})}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Z.jsx)(`span`,{className:`text-fg-subtle`,children:e.browserCloakProfileLabel}),(0,Z.jsx)(`span`,{className:`break-all font-mono text-[11px] text-fg-muted`,children:_.userDataDir})]}),(0,Z.jsx)(`p`,{className:`text-[11px] leading-relaxed text-fg-subtle`,children:e.browserCloakProfileAgentHint}),_.temporaryProfile?(0,Z.jsx)(`p`,{className:`text-[11px] text-amber-600 dark:text-amber-400`,children:e.browserCloakTemporaryProfileHint}):null]}):null,(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsx)($,{label:e.label.browserCloakKeepOpen,description:e.desc.browserCloakKeepOpen,children:(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:s.keepOpen,onChange:e=>c({keepOpen:e.target.checked})}),(0,Z.jsx)(`span`,{children:e.browserCloakKeepOpenOn})]})}),(0,Z.jsx)($,{label:e.label.browserCloakTemporaryProfile,description:e.desc.browserCloakTemporaryProfile,children:(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:s.temporaryProfile,onChange:e=>c({temporaryProfile:e.target.checked})}),(0,Z.jsx)(`span`,{children:e.browserCloakTemporaryProfileOn})]})}),(0,Z.jsx)($,{label:e.label.browserHumanize,description:e.desc.browserHumanize,children:(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:s.humanize,onChange:e=>c({humanize:e.target.checked})}),(0,Z.jsx)(`span`,{children:e.browserHumanizeOn})]})}),(0,Z.jsx)($,{label:e.label.browserHumanPreset,description:e.desc.browserHumanPreset,children:(0,Z.jsxs)(`select`,{className:Zn(),value:s.humanPreset,onChange:e=>c({humanPreset:e.target.value}),children:[(0,Z.jsx)(`option`,{value:`careful`,children:e.browserHumanPresetCareful}),(0,Z.jsx)(`option`,{value:`default`,children:e.browserHumanPresetDefault})]})})]})]}),(0,Z.jsxs)(zt,{className:`mt-4 border border-edge-subtle`,children:[(0,Z.jsx)(Rt,{icon:O,title:e.browserCloakAdvancedShow}),(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsxs)($,{label:e.label.browserCloakCacheDir,description:e.desc.browserCloakCacheDir,children:[(0,Z.jsx)(`input`,{type:`text`,className:Xn(),value:s.cacheDir,placeholder:`~/.xopc/bin/cloakbrowser`,onChange:e=>c({cacheDir:e.target.value}),autoComplete:`off`}),(0,Z.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:e.browserCacheDirHomeOnly})]}),(0,Z.jsxs)($,{label:e.label.browserCloakBinaryPath,description:e.desc.browserCloakBinaryPath,children:[(0,Z.jsx)(`input`,{type:`text`,className:Xn(),value:s.binaryPath,placeholder:`~/.xopc/bin/cloakbrowser/chromium-v.../Chromium.app/Contents/MacOS/Chromium`,onChange:e=>c({binaryPath:e.target.value}),autoComplete:`off`}),s.binaryPath.trim()?(0,Z.jsx)(`p`,{className:`text-[11px] text-amber-600 dark:text-amber-400`,children:e.browserBinaryPathWarning}):null]}),(0,Z.jsx)($,{label:e.label.browserCloakTimezone,description:e.desc.browserCloakTimezone,children:(0,Z.jsx)(`input`,{type:`text`,className:Xn(),value:s.timezone,placeholder:`America/New_York`,onChange:e=>c({timezone:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)($,{label:e.label.browserCloakLocale,description:e.desc.browserCloakLocale,children:(0,Z.jsx)(`input`,{type:`text`,className:Xn(),value:s.locale,placeholder:`en-US`,onChange:e=>c({locale:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)($,{label:e.label.browserCloakWebrtcIp,description:e.desc.browserCloakWebrtcIp,children:(0,Z.jsx)(`input`,{type:`text`,className:Xn(),value:s.webrtcIp,placeholder:`203.0.113.10`,onChange:e=>c({webrtcIp:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)($,{label:e.label.browserCloakFingerprintPlatform,description:e.desc.browserCloakFingerprintPlatform,children:(0,Z.jsx)(`input`,{type:`text`,className:Xn(),value:s.fingerprintPlatform,placeholder:`macos`,onChange:e=>c({fingerprintPlatform:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)(`div`,{className:`sm:col-span-2`,children:(0,Z.jsx)($,{label:e.label.browserCloakExtraArgs,description:e.desc.browserCloakExtraArgs,children:(0,Z.jsx)(`textarea`,{className:Qi(),value:s.extraArgs,placeholder:`--disable-dev-shm-usage`,rows:3,onChange:e=>c({extraArgs:e.target.value})})})})]})]}),(0,Z.jsx)(xt,{open:f,title:e.browserConfirmDownloadTitle,description:$i(e,w),confirmLabel:e.browserConfirmDownloadConfirm,cancelLabel:e.browserConfirmDownloadCancel,onConfirm:()=>void A(),onCancel:()=>d({type:`patch`,patch:{confirmOpen:!1}})})]})}function Qi(){return`${Xn()} min-h-[4.5rem] resize-y font-mono text-xs`}function $i(e,t){if(!t)return e.browserConfirmDownloadBody;let n=[e.browserConfirmDownloadBody.replace(`{{version}}`,t.version??`—`).replace(`{{platform}}`,t.platform).replace(`{{url}}`,t.downloadUrl||`—`)];return t.expectedSha256?n.push(`SHA-256: ${t.expectedSha256.slice(0,16)}…`):n.push(e.browserCloakSha256Skipped),n.join(`
217
+ `).map(e=>e.trim()).filter(Boolean);return t.length>0?t:null})()}:null,humanize:e.browserBackend===`cloakbrowser`?e.browserHumanize:null,humanPreset:e.browserBackend===`cloakbrowser`?e.browserHumanPreset:null,dialogPolicy:e.browserDialogPolicy===`auto_dismiss`?null:e.browserDialogPolicy,dialogTimeoutSeconds:e.browserDialogTimeout??null}}async function Jr(){return Wr(Ar(await _(o(`/api/config`)))??{})}async function Yr(e){let t=e.modelFallbacks.flatMap(e=>{let t=e.trim();return t?[t]:[]}),n=e.model.trim(),r=n?t.length>0?{primary:n,fallbacks:t}:{primary:n}:null,i=e.imageModelFallbacks.flatMap(e=>{let t=e.trim();return t?[t]:[]}),a=e.imageModel.trim(),s=a?i.length>0?{primary:a,fallbacks:i}:{primary:a}:null,c=e.imageGenerationModelFallbacks.flatMap(e=>{let t=e.trim();return t?[t]:[]}),l=e.imageGenerationModel.trim(),u=typeof e.imageGenerationModelTimeoutMs==`number`&&e.imageGenerationModelTimeoutMs>0?Math.floor(e.imageGenerationModelTimeoutMs):null,d=e.imageGenerationModelAutoProviderFallback===!0,f=l?{primary:l,...c.length>0?{fallbacks:c}:{},...u?{timeoutMs:u}:{},...d?{autoProviderFallback:!0}:{}}:null,p=e.maxTaskDurationMinutes===void 0||e.maxTaskDurationMinutes===null?null:(()=>{let t=Math.floor(e.maxTaskDurationMinutes)*6e4;return t<6e4||t>144e5?null:t})(),m=e.skillsAllowlist.flatMap(e=>{let t=e.trim();return t?[t]:[]}),h=e.toolsDisable.flatMap(e=>{let t=e.trim();return t?[t]:[]}),g=Kr(e.paramsJson),v=g===null||Object.keys(g).length===0?null:g,y={model:r,imageModel:s,imageGenerationModel:f,mediaMaxMb:e.mediaMaxMb??null,maxTokens:e.maxTokens,temperature:e.temperature,maxToolIterations:e.maxToolIterations,maxTaskDurationMs:p,maxRequestsPerTurn:e.maxRequestsPerTurn,maxToolFailuresPerTurn:e.maxToolFailuresPerTurn,workspace:e.workspace,browser:qr(e),thinkingDefault:e.thinkingDefault,reasoningDefault:e.reasoningDefault,verboseDefault:e.verboseDefault,compaction:{...e.compaction},pruning:{...e.pruning},memory:Gr(e.memory),sessionSearch:{summaryModel:e.sessionSearch.summaryModel.trim()||null},backgroundReview:{enabled:e.backgroundReview.enabled,memoryNudgeInterval:e.backgroundReview.memoryNudgeInterval,skillNudgeInterval:e.backgroundReview.skillNudgeInterval,maxToolRounds:e.backgroundReview.maxToolRounds,maxHistoryMessages:e.backgroundReview.maxHistoryMessages,maxDurationMs:e.backgroundReview.maxDurationMs},webExtract:{model:e.webExtract.model.trim()||null,maxLength:e.webExtract.maxLength??null},delegate:{enabled:e.delegate.enabled},executeCode:{enabled:e.executeCode.enabled},systemPromptOverride:e.systemPromptOverride.trim()||null,skills:m.length>0?m:null,tools:{disable:h.length>0?h:null},params:v};await _(o(`/api/config`),{method:`PATCH`,body:JSON.stringify({agents:{defaults:y}})}),Ge()}var Xr=`main`,Zr=/^[a-z0-9][a-z0-9_-]{0,63}$/i,Qr=/[^a-z0-9_-]+/g,$r=/^-+/,ei=/-+$/,ti=/^[a-z0-9][a-z0-9_-]{0,63}$/,ni=new Set([`con`,`prn`,`aux`,`nul`,`com1`,`com2`,`com3`,`com4`,`com5`,`com6`,`com7`,`com8`,`com9`,`lpt1`,`lpt2`,`lpt3`,`lpt4`,`lpt5`,`lpt6`,`lpt7`,`lpt8`,`lpt9`]);function ri(e){let t=e.trim();if(!t)return Xr;let n=t.toLowerCase();return Zr.test(t)?n:n.replace(Qr,`-`).replace($r,``).replace(ei,``).slice(0,64)||Xr}function ii(e,t){let n=e?.trim();if(n){let e=n.toLowerCase();return ti.test(e)?e===Xr?{ok:!1,error:`"${Xr}" is reserved`}:ni.has(e)?{ok:!1,error:`Agent id "${e}" is reserved (Windows device name).`}:{ok:!0,agentId:e}:{ok:!1,error:`Invalid agent id: use 1–64 characters; letters, digits, underscores, and hyphens only; start with a letter or digit.`}}let r=ri(t.trim());return r===Xr?{ok:!1,error:`Display name cannot produce a valid agent folder id. Set an explicit Agent id (letters, digits, underscores, hyphens only).`}:ni.has(r)?{ok:!1,error:`That display name resolves to "${r}", which is reserved. Use a different display name or set an explicit Agent id.`}:ti.test(r)?{ok:!0,agentId:r}:{ok:!1,error:`Could not derive a folder-safe agent id from the display name. Set an explicit Agent id (letters, digits, underscores, hyphens only).`}}var ai=`~/.xopc/workspace`;function oi(e){let t=e.trim();return t?`${ai}/${ri(t)}`:``}function si(e){let t=(0,X.c)(18),{a:n,busy:r,listSearchQuery:i,onListSearchQueryChange:a,onAddAgent:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(U,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=s):s=t[0];let c;t[1]===a?c=t[2]:(c=e=>a(e.target.value),t[1]=a,t[2]=c);let l;t[3]!==n.listSearchPlaceholder||t[4]!==i||t[5]!==c?(l=(0,Z.jsxs)(`label`,{className:`relative flex min-h-9 min-w-0 max-w-sm cursor-text items-center rounded-pill border border-edge bg-surface-base py-1.5 pl-9 pr-3 shadow-surface dark:bg-surface-hover/40 sm:max-w-md`,children:[s,(0,Z.jsx)(`input`,{type:`search`,enterKeyHint:`search`,value:i,onChange:c,placeholder:n.listSearchPlaceholder,autoComplete:`off`,spellCheck:!1,"aria-label":n.listSearchPlaceholder,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent py-0.5 text-sm leading-normal text-fg caret-current placeholder:text-fg-disabled focus:border-0 focus:shadow-none focus:outline-none focus:ring-0 focus-visible:outline-none`})]}),t[3]=n.listSearchPlaceholder,t[4]=i,t[5]=c,t[6]=l):l=t[6];let u;t[7]===o?u=t[8]:(u=()=>o(),t[7]=o,t[8]=u);let d;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)(ye,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[9]=d):d=t[9];let f;t[10]!==n.addAgent||t[11]!==n.addAgentAria||t[12]!==r||t[13]!==u?(f=(0,Z.jsxs)(Ct,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,"aria-label":n.addAgentAria,disabled:r,onClick:u,children:[d,n.addAgent]}),t[10]=n.addAgent,t[11]=n.addAgentAria,t[12]=r,t[13]=u,t[14]=f):f=t[14];let p;return t[15]!==l||t[16]!==f?(p=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[l,f]}),t[15]=l,t[16]=f,t[17]=p):p=t[17],p}function ci(e){return{...e,soulEditorNonce:0,soulPreviewMode:!1,avatarDialogOpen:!1}}function li(e){let{agentId:t,enabled:n,saveRef:r}=e,i=G(async()=>{if(!t)return null;let[e,n]=await Promise.all([S(t,`IDENTITY.md`).catch(()=>``),S(t,`SOUL.md`).catch(()=>``)]),r=xn(e);return{identity:r,soulTemplate:On(n),soulCustomContent:n,identityBaseline:JSON.stringify(r),soulBaseline:n}},[t],{enabled:n&&!!t,initial:null,errorData:null}),a=i.data,o=i.loading,s=(0,Q.useRef)(!1),[c,l]=(0,Q.useState)(null),u=t??``,d=(0,Q.useRef)(u);d.current!==u&&(d.current=u,s.current=!1,l(null));let f=c??(a?ci(a):null),p=(0,Q.useMemo)(()=>f?JSON.stringify(f.identity)!==f.identityBaseline||f.soulCustomContent!==f.soulBaseline:!1,[f]),m=(0,Q.useRef)(t);m.current=t;let h=(0,Q.useCallback)(e=>{s.current=!0,l(t=>{let n=t??(a?ci(a):null);return n?e(n):null})},[a]),g=(0,Q.useCallback)(e=>{h(t=>({...t,identity:{...t.identity,...e}}))},[h]),_=(0,Q.useCallback)(e=>{h(t=>{if(e===`custom`)return{...t,soulTemplate:`custom`};let n=En.find(t=>t.id===e);return n?.content?{...t,soulTemplate:e,soulCustomContent:n.content,soulEditorNonce:t.soulEditorNonce+1}:{...t,soulTemplate:e}})},[h]),v=(0,Q.useCallback)(e=>{h(t=>({...t,soulCustomContent:e,soulTemplate:`custom`}))},[h]),y=(0,Q.useCallback)(e=>{h(t=>({...t,avatarDialogOpen:e}))},[h]),b=(0,Q.useCallback)(()=>{h(e=>({...e,soulPreviewMode:!e.soulPreviewMode}))},[h]),x=(0,Q.useCallback)(async()=>{let e=m.current;!e||!f||(await Promise.all([R(e,`IDENTITY.md`,Sn(f.identity)),R(e,`SOUL.md`,f.soulCustomContent)]),s.current=!1,l(e=>{let t=e??f;return{...t,identityBaseline:JSON.stringify(t.identity),soulBaseline:t.soulCustomContent}}))},[f]);return(0,Q.useLayoutEffect)(()=>{if(r)return r.current=x,()=>{r.current=null}},[x,r]),{profileMarkdownLoading:o,draft:f,dirty:p,updateIdentity:g,handleSoulTemplateChange:_,handleSoulContentChange:v,setAvatarDialogOpen:y,toggleSoulPreviewMode:b}}var ui={draft:``,editorNonce:0,loadedKey:``};function di(e,t){switch(t.type){case`load`:return{draft:t.content,editorNonce:e.editorNonce+1,loadedKey:t.key};case`setDraft`:return{...e,draft:t.value};case`clear`:return{draft:``,editorNonce:e.editorNonce,loadedKey:``};case`resetViewMode`:return e}}function fi(e){let{panel:t,selectedId:n,hasToken:r,dataAgentsLength:i,saveErrorMessage:a,setError:o}=e,s=G(()=>n?_e(n):Promise.resolve(null),[t,n,r,i],{enabled:t===`files`&&!!n&&r,initial:null,errorData:null}),c=s.data,l=s.setData,u=s.loading,[d,f]=(0,Q.useState)(null),[p,m]=(0,Q.useReducer)(di,ui),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(`edit`),y=p.draft,b=p.editorNonce,x=(0,Q.useRef)(y);x.current=y;let C=(0,Q.useRef)(n);C.current=n;let w=(0,Q.useRef)(d);w.current=d;let T=(0,Q.useRef)(null),E=(0,Q.useRef)(``),D=(0,Q.useRef)(``),O=(0,Q.useRef)(``),k=(0,Q.useRef)(()=>{}),A=G(()=>d&&n?S(n,d).catch(()=>``):Promise.resolve(``),[d,n,r],{enabled:!!(d&&n&&r),initial:``,errorData:``}),j=A.loading,M=I(async()=>{let e=C.current,t=w.current;if(!e||!t||`${e}:${t}`!==E.current)return;let n=x.current;if(n!==D.current){g(!0),o(null);try{await R(e,t,n),D.current=n,l(n=>!n||n.agentId!==e?n:{...n,files:n.files.map(e=>e.name===t?{...e,missing:!1}:e)})}catch(e){o(e instanceof Error?e.message:a)}finally{g(!1)}}},800);k.current=M.flush,(0,Q.useEffect)(()=>()=>{k.current()},[]);let N=(0,Q.useRef)(t);N.current!==t&&(N.current===`files`&&k.current(),N.current=t);let P=d&&n?`${n}:${d}`:``;P!==O.current&&(k.current(),O.current=P),P?!j&&p.loadedKey!==P&&(E.current=P,D.current=A.data,m({type:`load`,key:P,content:A.data})):p.loadedKey!==``&&m({type:`clear`});let F=(0,Q.useRef)({activeFile:d,selectedId:n});return(F.current.activeFile!==d||F.current.selectedId!==n)&&(F.current={activeFile:d,selectedId:n},v(`edit`)),{files:c,setFiles:l,filesLoading:u,activeFile:d,setActiveFile:(0,Q.useCallback)(e=>{k.current(),f(e)},[]),fileDraft:y,setFileDraft:(0,Q.useCallback)(e=>{m({type:`setDraft`,value:typeof e==`function`?e(x.current):e}),M()},[M]),fileSaving:h,filesViewMode:_,setFilesViewMode:v,profileFileLoading:j,profileEditorNonce:b,overviewSaveProfileMarkdownRef:T,saveProfileMarkdownDebounced:M}}function pi(e){let{panel:t,hasToken:n,bindingsFromConfig:r,gatewayCfgLoading:i,selected:a,saveErrorMessage:o,setBusy:s,setError:c}=e,l=(0,Q.useRef)(!1),[u,d]=(0,Q.useState)(null),f=(0,Q.useRef)(r);t===`channels`&&n&&!l.current&&f.current!==r&&(f.current=r,d(r));let p=u??r,m=t===`channels`&&n,h=G(()=>Wt(),[t,n],{enabled:m,initial:[],errorData:[]}),g=h.data,_=h.loading,v=(0,Q.useMemo)(()=>_||g.length===0?``:g[0]?.name??``,[g,_]),[y,b]=(0,Q.useState)(``),x=(0,Q.useRef)(v);t===`channels`&&!_&&v&&x.current!==v&&(!y||!g.some(e=>e.name===y))&&(x.current=v,b(v)),x.current=v;let S=y.trim(),C=m&&S.length>0,w=G(()=>Gt(S),[t,n,S],{enabled:C,initial:[],errorData:[]}),T=w.data,E=w.loading,D=w.setData,[O,k]=(0,Q.useState)(null),[j,M]=(0,Q.useState)(``),N=(0,Q.useRef)(S);N.current!==S&&(N.current=S,k(null));let P=(0,Q.useMemo)(()=>a?p.filter(e=>e.agentId.toLowerCase()===a.id.toLowerCase()):[],[p,a?.id]),F=(0,Q.useCallback)(()=>{let e=y.trim();e&&Gt(e).then(e=>{D(e),k(t=>t!=null&&t<e.length?t:null)}).catch(()=>{D([]),k(null)})},[y,D]),I=!_&&g.length===0,ee=t===`channels`&&n&&i,L=(0,Q.useCallback)(async e=>{s(!0),c(null);try{let t=p.filter(t=>t!==e);await A(t),l.current=!0,d(t)}catch(e){c(e instanceof Error?e.message:o)}finally{s(!1)}},[p,o,s,c]);return{agentBindings:P,allBindings:p,bindChannelStatuses:g,bindChannelsLoading:_,bindSessionChats:T,bindSessionsLoading:E,bindingsLoading:ee,newBindChannel:y,setNewBindChannel:b,newBindSessionIdx:O,setNewBindSessionIdx:k,newBindCustomPeer:j,setNewBindCustomPeer:M,onAddBinding:(0,Q.useCallback)(async e=>{if(e.preventDefault(),!a||!y.trim())return;let t=on(y,j,O,T),n=[...p,{agentId:a.id,priority:100,enabled:!0,match:t}];s(!0),c(null);try{await A(n),l.current=!0,d(n),k(null),M(``)}catch(e){c(e instanceof Error?e.message:o)}finally{s(!1)}},[p,T,y,j,O,o,a,s,c]),onRemoveBinding:L,refreshBindSessions:F,useManualChannel:I}}function mi(e){let{panel:t,hasToken:n,data:r,selected:i,saveErrorMessage:a,setBusy:o,setError:s}=e,{data:c,loading:l}=G(()=>Jt(),[t,n],{enabled:t===`cron`&&n,initial:[],errorData:[]}),[u,d]=(0,Q.useState)(null),f=u??c,p=(0,Q.useMemo)(()=>!r||!i?[]:f.filter(e=>!Ut(e)&&rn(e,i.id,r.defaultId)),[f,r,i]);async function m(e,t){o(!0),s(null);try{await Kt(e.id,{agentId:t===``?null:t}),d(await Jt())}catch(e){s(e instanceof Error?e.message:a)}finally{o(!1)}}return{agentCronJobs:p,cronJobs:f,cronLoading:l,onSetCronJobAgent:m}}function hi(e,t){let n=(0,X.c)(13),r;n[0]!==e||n[1]!==t?(r=[e,t],n[0]=e,n[1]=t,n[2]=r):r=n[2];let i=e&&t,a;n[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=[],n[3]=a):a=n[3];let o;n[4]===Symbol.for(`react.memo_cache_sentinel`)?(o=[],n[4]=o):o=n[4];let s;n[5]===i?s=n[6]:(s={enabled:i,initial:a,errorData:o},n[5]=i,n[6]=s);let{data:c,loading:l}=G(_i,r,s),u;n[7]===c?u=n[8]:(u=c.filter(gi),n[7]=c,n[8]=u);let d=u,f;return n[9]!==d||n[10]!==c||n[11]!==l?(f={catalogForPick:d,skillCatalog:c,skillsCatalogLoading:l},n[9]=d,n[10]=c,n[11]=l,n[12]=f):f=n[12],f}function gi(e){return e.enabled!==!1}function _i(){return me()}function vi(e){return hi(e.panel===`skills`,e.hasToken)}function yi(e){return new Set(e.tools.entryDisable)}function bi(e){return e.skills.entry===void 0?{inherit:!0,pick:new Set(e.skills.effectiveAllowlist??[])}:{inherit:!1,pick:new Set(e.skills.entry??[])}}function xi(e){let{panel:t,selected:n}=e,r=`${t}:${n?.id??``}`,i=(0,Q.useRef)(r),[a,o]=(0,Q.useState)(()=>new Set),[s,c]=(0,Q.useState)(()=>new Set),[l,u]=(0,Q.useState)(!0);if(i.current!==r&&(i.current=r,n&&t===`tools`&&o(yi(n)),n&&t===`skills`)){let e=bi(n);u(e.inherit),c(e.pick)}return{toolEntryDisable:a,setToolEntryDisable:o,skillsPick:s,setSkillsPick:c,skillsInherit:l,setSkillsInherit:u}}function Si(){let e=i(e=>e.language),t=a(e),n=t.agentsSettings,[r,o]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(``),m=t.cron,h=t.chat,_=!!g(e=>e.token),[v,y]=Le(),b=nt(),{agentId:x}=Tt(),S=w(e=>e.setPageHeader),C=w(e=>e.clearPageHeader),{data:T,error:E,isLoading:D,mutate:O}=s(_?`settings-gateway-agents`:null,P,{revalidateOnFocus:!1}),{data:A}=Ae(_),j=(0,Q.useMemo)(()=>xe(A?.payload?.config??{}),[A]),M=(0,Q.useMemo)(()=>Wr(A?.payload?.config??{}),[A]),N=T??null,F=!!(_&&D),[I,L]=(0,Q.useState)(null),R=E instanceof Error?E.message:E?n.loadError:null,z=I??R,[B,V]=(0,Q.useState)(null),[H,U]=(0,Q.useState)(()=>localStorage.getItem(hr)===`true`),[W,te]=(0,Q.useState)(`overview`),[ne,G]=(0,Q.useState)(``),[K,q]=(0,Q.useState)(``),[re,ie]=(0,Q.useState)(``),[ae,oe]=(0,Q.useState)(``),[se,ce]=(0,Q.useState)(``),[le,ue]=(0,Q.useState)(null),[de,fe]=(0,Q.useState)(!1),pe=(0,Q.useRef)(``),[me,he]=(0,Q.useState)(!1),[ge,_e]=(0,Q.useState)(``),[ve,ye]=(0,Q.useState)(``),[be,Se]=(0,Q.useState)(``),[Ce,we]=(0,Q.useState)(``),[Te,Ee]=(0,Q.useState)(``),De=(0,Q.useRef)(null),Oe=(0,Q.useRef)(null),[ke,je]=(0,Q.useState)(!1),[Me,Ne]=(0,Q.useState)(!1),Pe=(0,Q.useRef)({data:null,routeAgentId:void 0});N&&(N!==Pe.current.data||x!==Pe.current.routeAgentId)&&(Pe.current={data:N,routeAgentId:x},x&&N.agents.some(e=>e.id===x)?V(x):V(e=>e&&N.agents.some(t=>t.id===e)?e:N.defaultId));let Fe=N!=null&&N.agents.length<=1&&N.agents.every(e=>e.id===N.defaultId),Ie=!!(N&&!F&&Fe&&!H),Re=(0,Q.useCallback)(()=>{U(!0),O()},[O]),ze=(0,Q.useCallback)(()=>{localStorage.setItem(hr,`true`),U(!0)},[]);(0,Q.useEffect)(()=>{!N||!x||N.agents.some(e=>e.id===x)||b(ft,{replace:!0})},[N,x,b]),(0,Q.useEffect)(()=>{x&&te(`overview`)},[x]),(0,Q.useEffect)(()=>{v.get(`panel`)===`defaults`&&b(`/settings/agent-defaults?tab=chat`,{replace:!0,state:{[Ve]:ft}})},[v,b]),(0,Q.useEffect)(()=>{if(v.get(`focus`)!==`avatar`||!x||(te(`overview`),F||!N?.agents.some(e=>e.id===x)))return;let e=window.setTimeout(()=>{document.getElementById(`agent-avatar-settings`)?.scrollIntoView({behavior:`smooth`,block:`center`}),y(e=>{let t=new URLSearchParams(e);return t.delete(`focus`),t},{replace:!0})},220);return()=>window.clearTimeout(e)},[v,x,F,N,y]);let J=(0,Q.useMemo)(()=>N?.agents.find(e=>e.id===B)??null,[N,B]),Be=(0,Q.useRef)(null);J&&Be.current!==J.id?(Be.current=J.id,ye(J.workspace),Se(J.model?.primary??``),we(k(J,a(e).agentsSettings)),Ee(J.description?.trim()??``)):!J&&Be.current!==null&&(Be.current=null,ye(``),Se(``),we(``),Ee(``));let He=li({agentId:J?.id??null,enabled:W===`overview`&&!!J,saveRef:Oe}),Ue=fi({panel:W,selectedId:B,hasToken:_,dataAgentsLength:N?.agents.length,saveErrorMessage:n.saveError,setError:L}),We=xi({panel:W,selected:J}),Ge=pi({panel:W,hasToken:_,bindingsFromConfig:j,gatewayCfgLoading:A===void 0,selected:J,saveErrorMessage:n.saveError,setBusy:he,setError:L}),Ke=mi({panel:W,hasToken:_,data:N,selected:J,saveErrorMessage:n.saveError,setBusy:he,setError:L}),qe=vi({panel:W,hasToken:_}),Je=(0,Q.useCallback)(()=>{let e=oi(K.trim()||ne);oe(t=>t===``||t===pe.current?(pe.current=e,e):t)},[K,ne]),Ye=(0,Q.useCallback)(()=>{pe.current=``,G(``),q(``),ie(``),oe(``),ce(``),ue(null),fe(!0)},[]),Xe=(0,Q.useMemo)(()=>(0,Z.jsx)(si,{a:n,busy:me,listSearchQuery:ge,onListSearchQueryChange:_e,onAddAgent:()=>Ye()}),[n,me,ge,Ye]);(0,Q.useLayoutEffect)(()=>_?(S({startExtra:null,main:null,end:Xe}),()=>C()):(C(),()=>C()),[Xe,C,_,S]);async function Ze(e){e.preventDefault();let t=ne.trim();if(!t)return;let r=ii(K,t);if(r.ok===!1){ue(r.error);return}let i=ae.trim()||oi(K.trim()||t);if(i){he(!0),ue(null);try{let e=re.trim(),{createdAgentId:n,...r}=await ee({name:t,workspace:i,...K.trim()?{id:K.trim()}:{},...se.trim()?{model:se.trim()}:{},...e?{description:e}:{}});O(r,{revalidate:!1}),G(``),q(``),ie(``),oe(``),ce(``),ue(null),fe(!1),V(n),b(it(n))}catch(e){ue(e instanceof Error?e.message:n.saveError)}finally{he(!1)}}}async function Qe(){if(J){he(!0),L(null);try{let e=Te.trim();O(await mt(J.id,{name:Ce.trim()||void 0,description:e.length>0?e:null,workspace:ve.trim()||void 0,model:be.trim()||null}),{revalidate:!1})}catch(e){L(e instanceof Error?e.message:n.saveError)}finally{he(!1)}}}async function $e(e){he(!0),L(null);try{O(await mt(e.id,{setDefault:!0}),{revalidate:!1}),V(e.id)}catch(e){L(e instanceof Error?e.message:n.saveError)}finally{he(!1)}}async function et(e,t){he(!0),L(null);try{let n=await Pt(e.id,t);O(n,{revalidate:!1}),V(n.defaultId),te(`overview`),x===e.id&&b(ft,{replace:!0}),o(!1),l(null),p(``)}catch(e){L(e instanceof Error?e.message:n.saveError)}finally{he(!1)}}function tt(e,t){e.id!==`main`&&(l(e),d(t),p(``),o(!0))}async function rt(){if(J){he(!0),L(null);try{let e=Array.from(We.toolEntryDisable).toSorted((e,t)=>e.localeCompare(t));O(await mt(J.id,{toolsDisable:e}),{revalidate:!1})}catch(e){L(e instanceof Error?e.message:n.saveError)}finally{he(!1)}}}async function at(){if(J){he(!0),L(null);try{O(await mt(J.id,{toolsDisable:null}),{revalidate:!1}),We.setToolEntryDisable(new Set)}catch(e){L(e instanceof Error?e.message:n.saveError)}finally{he(!1)}}}async function ot(){if(J){he(!0),L(null);try{O(await mt(J.id,{skills:We.skillsInherit?null:[...We.skillsPick].toSorted((e,t)=>e.localeCompare(t))}),{revalidate:!1})}catch(e){L(e instanceof Error?e.message:n.saveError)}finally{he(!1)}}}let st=W===`channels`||W===`cron`,Y=(()=>{if(!J||W!==`overview`)return!1;let e=k(J,n),t=J.description?.trim()??``,r=J.workspace,i=J.model?.primary??``;return Ce.trim()!==e||Te.trim()!==t||ve.trim()!==r||be.trim()!==i})(),ct=(()=>{if(st)return!1;switch(W){case`overview`:return Y||He.dirty;case`profile`:return ke;default:return!0}})(),lt=st||!ct;function ut(){Ne(!0),setTimeout(()=>Ne(!1),2e3)}async function dt(){switch(W){case`overview`:await Promise.all([Qe(),Oe.current?.()??Promise.resolve()]),ut();break;case`profile`:await De.current?.(),ut();break;case`tools`:await rt(),ut();break;case`skills`:await ot(),ut();break;case`files`:Ue.saveProfileMarkdownDebounced.flush(),ut();break;default:break}}function pt(e){e||b(ft)}return{hasToken:_,a:n,chat:h,language:e,data:N,loading:F,displayError:z,navigate:b,routeAgentId:x,showPresetSetup:Ie,onPresetSetupComplete:Re,onPresetSetupSkip:ze,busy:me,listSearchQuery:ge,openAddAgentModal:Ye,panel:W,setPanel:te,modalTitle:J?Ce.trim()||k(J,n):x??``,modalSubtitle:J?.id??x??``,footerSaveDisabled:lt,savedFlash:Me,handleModalFooterSave:dt,onAgentModalOpenChange:pt,addAgentModalOpen:de,setAddAgentModalOpen:fe,createWorkspaceSuggestedRef:pe,createModalError:le,setCreateModalError:ue,createDisplayName:ne,setCreateDisplayName:G,createAgentId:K,setCreateAgentId:q,createDescription:re,setCreateDescription:ie,createWorkspace:ae,setCreateWorkspace:oe,createModel:se,setCreateModel:ce,onCreate:Ze,applyCreateWorkspaceSuggestion:Je,deleteDialogOpen:r,setDeleteDialogOpen:o,deletePurge:u,deleteTarget:c,setDeleteTarget:l,deleteConfirmText:f,setDeleteConfirmText:p,performDelete:et,editorPanelProps:{a:n,chat:h,cCron:m,selected:J,panel:W,data:N,busy:me,editName:Ce,setEditName:we,editDescription:Te,setEditDescription:Ee,editWorkspace:ve,setEditWorkspace:ye,editModel:be,setEditModel:Se,defaultModel:M.model,defaultWorkspace:M.workspace,onSetDefault:()=>{J&&$e(J)},onSaveAgentEdits:()=>void Qe(),onDelete:e=>{J&&tt(J,e)},overviewSaveProfileMarkdownRef:Oe,profileSaveRef:De,overviewProfile:He,setProfileDirty:je,filesLoading:Ue.filesLoading,files:Ue.files,activeFile:Ue.activeFile,setActiveFile:Ue.setActiveFile,filesViewMode:Ue.filesViewMode,setFilesViewMode:Ue.setFilesViewMode,fileDraft:Ue.fileDraft,setFileDraft:Ue.setFileDraft,fileSaving:Ue.fileSaving,profileFileLoading:Ue.profileFileLoading,profileEditorNonce:Ue.profileEditorNonce,toolEntryDisable:We.toolEntryDisable,setToolEntryDisable:We.setToolEntryDisable,onSaveTools:()=>void rt(),onClearToolsEntry:()=>void at(),skillsCatalogLoading:qe.skillsCatalogLoading,catalogForPick:qe.catalogForPick,skillsInherit:We.skillsInherit,setSkillsInherit:We.setSkillsInherit,skillsPick:We.skillsPick,setSkillsPick:We.setSkillsPick,onSaveSkills:()=>void ot(),bindingsLoading:Ge.bindingsLoading,agentBindings:Ge.agentBindings,bindChannelStatuses:Ge.bindChannelStatuses,bindChannelsLoading:Ge.bindChannelsLoading,useManualChannel:Ge.useManualChannel,newBindChannel:Ge.newBindChannel,setNewBindChannel:Ge.setNewBindChannel,bindSessionChats:Ge.bindSessionChats,bindSessionsLoading:Ge.bindSessionsLoading,newBindSessionIdx:Ge.newBindSessionIdx,setNewBindSessionIdx:Ge.setNewBindSessionIdx,newBindCustomPeer:Ge.newBindCustomPeer,setNewBindCustomPeer:Ge.setNewBindCustomPeer,refreshBindSessions:Ge.refreshBindSessions,onRemoveBinding:e=>void Ge.onRemoveBinding(e),onAddBinding:Ge.onAddBinding,cronLoading:Ke.cronLoading,agentCronJobs:Ke.agentCronJobs,onSetCronJobAgent:(e,t)=>void Ke.onSetCronJobAgent(e,t)}}}function Ci(){let e=Si();if(!e.hasToken)return(0,Z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,Z.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:e.a.title}),(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.a.needToken})]});if(e.showPresetSetup&&e.data){let t=new Set(e.data.agents.map(e=>e.id));if(gr.some(e=>!t.has(e.id)))return(0,Z.jsx)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col px-4 py-8`,children:(0,Z.jsx)(_r,{existingAgentIds:t,onComplete:e.onPresetSetupComplete,onSkip:e.onPresetSetupSkip})})}return(0,Z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-8`,children:[(0,Z.jsx)(fr,{a:e.a}),e.displayError?(0,Z.jsx)(`div`,{className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:e.displayError}):null,e.loading?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.a.loading}):e.data?(0,Z.jsx)(dr,{a:e.a,agents:e.data.agents,searchQuery:e.listSearchQuery,onOpenAgent:t=>e.navigate(it(t)),onChatWithAgent:t=>{let n=t.trim().toLowerCase();try{globalThis.localStorage?.setItem(Xe,n)}catch{}e.navigate(`/chat/new`,{state:{agentId:n}})},onNewAgent:e.openAddAgentModal,busy:e.busy}):null,e.routeAgentId&&e.hasToken?(0,Z.jsx)(en,{open:!!e.routeAgentId,onOpenChange:e.onAgentModalOpenChange,a:e.a,title:e.modalTitle,subtitle:e.modalSubtitle,panel:e.panel,onPanelChange:e.setPanel,onFooterSave:()=>void e.handleModalFooterSave(),footerSaveDisabled:e.footerSaveDisabled,footerSavedFlash:e.savedFlash,busy:e.busy,children:e.loading||!e.data?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.a.loading}):(0,Z.jsx)(cr,{...e.editorPanelProps})}):null,(0,Z.jsx)(pr,{open:e.addAgentModalOpen,onOpenChange:t=>{e.setAddAgentModalOpen(t),t||(e.createWorkspaceSuggestedRef.current=``,e.setCreateDisplayName(``),e.setCreateAgentId(``),e.setCreateDescription(``),e.setCreateWorkspace(``),e.setCreateModel(``),e.setCreateModalError(null))},a:e.a,chat:e.chat,busy:e.busy,modalError:e.createModalError,createDisplayName:e.createDisplayName,setCreateDisplayName:e.setCreateDisplayName,createAgentId:e.createAgentId,setCreateAgentId:e.setCreateAgentId,createDescription:e.createDescription,setCreateDescription:e.setCreateDescription,createWorkspace:e.createWorkspace,setCreateWorkspace:e.setCreateWorkspace,createModel:e.createModel,setCreateModel:e.setCreateModel,onCreate:e.onCreate,onSuggestWorkspace:()=>e.applyCreateWorkspaceSuggestion()}),(0,Z.jsx)(Yt,{open:e.deleteDialogOpen,onOpenChange:t=>{e.setDeleteDialogOpen(t),t||(e.setDeleteTarget(null),e.setDeleteConfirmText(``))},busy:e.busy,deletePurge:e.deletePurge,deleteTarget:e.deleteTarget,deleteConfirmText:e.deleteConfirmText,onDeleteConfirmTextChange:e.setDeleteConfirmText,onConfirm:()=>{e.deleteTarget&&e.performDelete(e.deleteTarget,e.deletePurge)},onCancel:()=>e.setDeleteDialogOpen(!1),a:e.a})]})}function $(e){let t=(0,X.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}),t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function wi(e){switch(e){case`ready`:return`bg-emerald-500`;case`not_installed`:case`checking`:return`bg-amber-500`;case`error`:return`bg-red-500`;default:return`bg-fg-subtle/60`}}function Ti(e){let t=(0,X.c)(28),{value:n,onChange:r,onOpenConfig:i,options:a,m:o}=e,s;if(t[0]!==o.browserGoToConfigure||t[1]!==o.browserPickerSubtitle||t[2]!==o.browserPickerTitle||t[3]!==r||t[4]!==i||t[5]!==a||t[6]!==n){let e=a.find(e=>e.value===n)??a[0],c;t[8]===o.browserPickerTitle?c=t[9]:(c=(0,Z.jsx)(`label`,{htmlFor:`browser-backend-select`,className:`text-sm font-medium text-fg`,children:o.browserPickerTitle}),t[8]=o.browserPickerTitle,t[9]=c);let l;t[10]===o.browserPickerSubtitle?l=t[11]:(l=(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:o.browserPickerSubtitle}),t[10]=o.browserPickerSubtitle,t[11]=l);let u;t[12]!==c||t[13]!==l?(u=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[c,l]}),t[12]=c,t[13]=l,t[14]=u):u=t[14];let d;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(d=Y(Zn(),`min-w-0 flex-1 sm:max-w-md`),t[15]=d):d=t[15];let f;t[16]===r?f=t[17]:(f=e=>r(e.target.value),t[16]=r,t[17]=f);let p=o.browserPickerTitle,m;t[18]===a?m=t[19]:(m=a.map(Ei),t[18]=a,t[19]=m);let h;t[20]!==o.browserPickerTitle||t[21]!==f||t[22]!==m||t[23]!==n?(h=(0,Z.jsx)(`select`,{id:`browser-backend-select`,className:d,value:n,onChange:f,"aria-label":p,children:m}),t[20]=o.browserPickerTitle,t[21]=f,t[22]=m,t[23]=n,t[24]=h):h=t[24];let g=i?(0,Z.jsxs)(`button`,{type:`button`,className:Y(`inline-flex shrink-0 items-center justify-center gap-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-xs font-medium text-accent`,`transition-colors hover:border-edge-strong hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),onClick:()=>i(n),"aria-label":`${e?.name??n} — ${o.browserGoToConfigure}`,children:[(0,Z.jsx)(`span`,{children:o.browserGoToConfigure}),(0,Z.jsx)(j,{className:`size-4 shrink-0`,"aria-hidden":!0})]}):null,_;t[25]!==g||t[26]!==h?(_=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:gap-2`,children:[h,g]}),t[25]=g,t[26]=h,t[27]=_):_=t[27],s=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[u,_,e?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2.5`,children:[(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e.statusLabel?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[11px] font-medium text-fg-muted`,"aria-label":e.statusLabel,children:[(0,Z.jsx)(`span`,{className:Y(`inline-block size-1.5 rounded-full`,wi(e.status)),"aria-hidden":!0}),e.statusLabel]}):null}),(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:e.tagline})]}):null]}),t[0]=o.browserGoToConfigure,t[1]=o.browserPickerSubtitle,t[2]=o.browserPickerTitle,t[3]=r,t[4]=i,t[5]=a,t[6]=n,t[7]=s}else s=t[7];return s}function Ei(e){return(0,Z.jsx)(`option`,{value:e.value,children:e.name},e.value)}function Di(e){return`browser-focus-${e}`}function Oi(e){switch(e){case`connection`:case`extension`:case`local`:case`cloak`:case`cdp`:case`cloud`:case`runtime`:case`security`:return e;default:return null}}function ki(e){let t=(0,X.c)(89),{a:n,form:r,update:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=Di(`runtime`),t[0]=a):a=t[0];let o;t[1]===n.browserBehaviorShow?o=t[2]:(o=(0,Z.jsx)(Rt,{icon:kt,title:n.browserBehaviorShow}),t[1]=n.browserBehaviorShow,t[2]=o);let s;t[3]===i?s=t[4]:(s=e=>i({browserHeadless:e.target.checked}),t[3]=i,t[4]=s);let c;t[5]!==r.browserHeadless||t[6]!==s?(c=(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.browserHeadless,onChange:s}),t[5]=r.browserHeadless,t[6]=s,t[7]=c):c=t[7];let l;t[8]===n.browserHeadlessOn?l=t[9]:(l=(0,Z.jsx)(`span`,{children:n.browserHeadlessOn}),t[8]=n.browserHeadlessOn,t[9]=l);let u;t[10]!==c||t[11]!==l?(u=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[c,l]}),t[10]=c,t[11]=l,t[12]=u):u=t[12];let d;t[13]!==n.desc.browserHeadless||t[14]!==n.label.browserHeadless||t[15]!==u?(d=(0,Z.jsx)($,{label:n.label.browserHeadless,description:n.desc.browserHeadless,children:u}),t[13]=n.desc.browserHeadless,t[14]=n.label.browserHeadless,t[15]=u,t[16]=d):d=t[16];let f=n.label.browserDialogPolicy,p=n.desc.browserDialogPolicy,m;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(m=Zn(),t[17]=m):m=t[17];let h;t[18]===i?h=t[19]:(h=e=>i({browserDialogPolicy:e.target.value}),t[18]=i,t[19]=h);let g;t[20]===n.browserDialogPolicyMustRespond?g=t[21]:(g=(0,Z.jsx)(`option`,{value:`must_respond`,children:n.browserDialogPolicyMustRespond}),t[20]=n.browserDialogPolicyMustRespond,t[21]=g);let _;t[22]===n.browserDialogPolicyAutoDismiss?_=t[23]:(_=(0,Z.jsx)(`option`,{value:`auto_dismiss`,children:n.browserDialogPolicyAutoDismiss}),t[22]=n.browserDialogPolicyAutoDismiss,t[23]=_);let v;t[24]===n.browserDialogPolicyAutoAccept?v=t[25]:(v=(0,Z.jsx)(`option`,{value:`auto_accept`,children:n.browserDialogPolicyAutoAccept}),t[24]=n.browserDialogPolicyAutoAccept,t[25]=v);let y;t[26]!==r.browserDialogPolicy||t[27]!==h||t[28]!==g||t[29]!==_||t[30]!==v?(y=(0,Z.jsxs)(`select`,{className:m,value:r.browserDialogPolicy,onChange:h,children:[g,_,v]}),t[26]=r.browserDialogPolicy,t[27]=h,t[28]=g,t[29]=_,t[30]=v,t[31]=y):y=t[31];let b;t[32]!==n.desc.browserDialogPolicy||t[33]!==n.label.browserDialogPolicy||t[34]!==y?(b=(0,Z.jsx)($,{label:f,description:p,children:y}),t[32]=n.desc.browserDialogPolicy,t[33]=n.label.browserDialogPolicy,t[34]=y,t[35]=b):b=t[35];let x=n.label.browserDialogTimeout,S=n.desc.browserDialogTimeout,C;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(C=Xn(),t[36]=C):C=t[36];let w=r.browserDialogTimeout??``,T;t[37]===i?T=t[38]:(T=e=>{let t=e.target.value;i({browserDialogTimeout:t===``?void 0:Number.parseInt(t,10)})},t[37]=i,t[38]=T);let E;t[39]!==w||t[40]!==T?(E=(0,Z.jsx)(`input`,{type:`number`,className:C,min:1,value:w,placeholder:`300`,onChange:T}),t[39]=w,t[40]=T,t[41]=E):E=t[41];let D;t[42]!==n.desc.browserDialogTimeout||t[43]!==n.label.browserDialogTimeout||t[44]!==E?(D=(0,Z.jsx)($,{label:x,description:S,children:E}),t[42]=n.desc.browserDialogTimeout,t[43]=n.label.browserDialogTimeout,t[44]=E,t[45]=D):D=t[45];let O;t[46]!==b||t[47]!==D||t[48]!==d?(O=(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[d,b,D]}),t[46]=b,t[47]=D,t[48]=d,t[49]=O):O=t[49];let k;t[50]!==o||t[51]!==O?(k=(0,Z.jsx)(`div`,{id:a,className:`scroll-mt-24`,children:(0,Z.jsxs)(zt,{children:[o,O]})}),t[50]=o,t[51]=O,t[52]=k):k=t[52];let A;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(A=Di(`security`),t[53]=A):A=t[53];let j;t[54]===n.browserSecurityShow?j=t[55]:(j=(0,Z.jsx)(Rt,{icon:K,title:n.browserSecurityShow}),t[54]=n.browserSecurityShow,t[55]=j);let M;t[56]===i?M=t[57]:(M=e=>i({browserAllowPrivateUrls:e.target.checked}),t[56]=i,t[57]=M);let N;t[58]!==r.browserAllowPrivateUrls||t[59]!==M?(N=(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.browserAllowPrivateUrls,onChange:M}),t[58]=r.browserAllowPrivateUrls,t[59]=M,t[60]=N):N=t[60];let P;t[61]===n.browserAllowPrivateOn?P=t[62]:(P=(0,Z.jsx)(`span`,{children:n.browserAllowPrivateOn}),t[61]=n.browserAllowPrivateOn,t[62]=P);let F;t[63]!==N||t[64]!==P?(F=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[N,P]}),t[63]=N,t[64]=P,t[65]=F):F=t[65];let I;t[66]!==n.desc.browserAllowPrivateUrls||t[67]!==n.label.browserAllowPrivateUrls||t[68]!==F?(I=(0,Z.jsx)($,{label:n.label.browserAllowPrivateUrls,description:n.desc.browserAllowPrivateUrls,children:F}),t[66]=n.desc.browserAllowPrivateUrls,t[67]=n.label.browserAllowPrivateUrls,t[68]=F,t[69]=I):I=t[69];let ee=n.label.browserCommandTimeout,L=n.desc.browserCommandTimeout,R;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(R=Xn(),t[70]=R):R=t[70];let z=r.browserCommandTimeout??``,B;t[71]===i?B=t[72]:(B=e=>{let t=e.target.value;i({browserCommandTimeout:t===``?void 0:Number.parseInt(t,10)})},t[71]=i,t[72]=B);let V;t[73]!==z||t[74]!==B?(V=(0,Z.jsx)(`input`,{type:`number`,className:R,min:5,value:z,placeholder:`30`,onChange:B}),t[73]=z,t[74]=B,t[75]=V):V=t[75];let H;t[76]!==n.desc.browserCommandTimeout||t[77]!==n.label.browserCommandTimeout||t[78]!==V?(H=(0,Z.jsx)($,{label:ee,description:L,children:V}),t[76]=n.desc.browserCommandTimeout,t[77]=n.label.browserCommandTimeout,t[78]=V,t[79]=H):H=t[79];let U;t[80]!==I||t[81]!==H?(U=(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[I,H]}),t[80]=I,t[81]=H,t[82]=U):U=t[82];let W;t[83]!==j||t[84]!==U?(W=(0,Z.jsx)(`div`,{id:A,className:`scroll-mt-24`,children:(0,Z.jsxs)(zt,{className:`border border-amber-500/20`,children:[j,U]})}),t[83]=j,t[84]=U,t[85]=W):W=t[85];let te;return t[86]!==k||t[87]!==W?(te=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[k,W]}),t[86]=k,t[87]=W,t[88]=te):te=t[88],te}function Ai(e){let t=(0,X.c)(9),{language:n,label:r,className:i}=e,a;t[0]===n?a=t[1]:(a=he(n),t[0]=n,t[1]=a);let o;t[2]===i?o=t[3]:(o=Y(`inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,i),t[2]=i,t[3]=o);let s;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(fe,{className:`size-3 shrink-0`,"aria-hidden":!0}),t[4]=s):s=t[4];let c;return t[5]!==r||t[6]!==a||t[7]!==o?(c=(0,Z.jsxs)(`a`,{href:a,target:`_blank`,rel:`noreferrer`,className:o,children:[r,s]}),t[5]=r,t[6]=a,t[7]=o,t[8]=c):c=t[8],c}function ji(e){let t=(0,X.c)(27),{title:n,description:r,recommended:i,recommendedLabel:a,icon:o,onSelect:s,selectLabel:c}=e,l=`${n} — ${c}`,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=Y(`group flex w-full flex-col rounded-xl border border-edge bg-surface-panel px-3 py-3 text-left transition-colors`,`hover:border-edge-strong hover:bg-surface-hover/40`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),t[0]=u):u=t[0];let d;t[1]===o?d=t[2]:(d=(0,Z.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover text-fg-muted`,children:(0,Z.jsx)(o,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[1]=o,t[2]=d);let f;t[3]===n?f=t[4]:(f=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[3]=n,t[4]=f);let p;t[5]!==i||t[6]!==a?(p=i&&a?(0,Z.jsx)(`span`,{className:`rounded-full bg-accent/15 px-2 py-0.5 text-[10px] font-medium text-accent`,children:a}):null,t[5]=i,t[6]=a,t[7]=p):p=t[7];let m;t[8]!==f||t[9]!==p?(m=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f,p]}),t[8]=f,t[9]=p,t[10]=m):m=t[10];let h;t[11]===r?h=t[12]:(h=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:r}),t[11]=r,t[12]=h);let g;t[13]!==m||t[14]!==h?(g=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[m,h]}),t[13]=m,t[14]=h,t[15]=g):g=t[15];let _;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Z.jsx)(j,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0}),t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==g?(v=(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[d,g,_]}),t[17]=d,t[18]=g,t[19]=v):v=t[19];let y;t[20]===c?y=t[21]:(y=(0,Z.jsx)(`span`,{className:`mt-2 text-[11px] font-medium text-accent`,children:c}),t[20]=c,t[21]=y);let b;return t[22]!==s||t[23]!==l||t[24]!==v||t[25]!==y?(b=(0,Z.jsxs)(`button`,{type:`button`,onClick:s,"aria-label":l,className:u,children:[v,y]}),t[22]=s,t[23]=l,t[24]=v,t[25]=y,t[26]=b):b=t[26],b}function Mi(e){let t=(0,X.c)(28),{m:n,onStart:r}=e,i;t[0]!==n.browserSetupExtDesc||t[1]!==n.browserSetupExtTitle?(i={id:`extension`,icon:It,title:n.browserSetupExtTitle,description:n.browserSetupExtDesc,recommended:!0},t[0]=n.browserSetupExtDesc,t[1]=n.browserSetupExtTitle,t[2]=i):i=t[2];let a;t[3]!==n.browserSetupLocalDesc||t[4]!==n.browserSetupLocalTitle?(a={id:`local`,icon:De,title:n.browserSetupLocalTitle,description:n.browserSetupLocalDesc},t[3]=n.browserSetupLocalDesc,t[4]=n.browserSetupLocalTitle,t[5]=a):a=t[5];let o;t[6]!==n.browserSetupCloudDesc||t[7]!==n.browserSetupCloudTitle?(o={id:`cloud`,icon:W,title:n.browserSetupCloudTitle,description:n.browserSetupCloudDesc},t[6]=n.browserSetupCloudDesc,t[7]=n.browserSetupCloudTitle,t[8]=o):o=t[8];let s;t[9]!==i||t[10]!==a||t[11]!==o?(s=[i,a,o],t[9]=i,t[10]=a,t[11]=o,t[12]=s):s=t[12];let c=s,l;t[13]===n.browserSetupTitle?l=t[14]:(l=(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.browserSetupTitle}),t[13]=n.browserSetupTitle,t[14]=l);let u;t[15]===n.browserSetupSubtitle?u=t[16]:(u=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:n.browserSetupSubtitle}),t[15]=n.browserSetupSubtitle,t[16]=u);let d;t[17]!==l||t[18]!==u?(d=(0,Z.jsxs)(`div`,{children:[l,u]}),t[17]=l,t[18]=u,t[19]=d):d=t[19];let f;t[20]!==n.browserSetupRecommended||t[21]!==n.browserSetupSelect||t[22]!==c||t[23]!==r?(f=(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:c.map(e=>(0,Z.jsx)(ji,{icon:e.icon,title:e.title,description:e.description,recommended:e.recommended,recommendedLabel:n.browserSetupRecommended,selectLabel:n.browserSetupSelect,onSelect:()=>r(e.id)},e.id))}),t[20]=n.browserSetupRecommended,t[21]=n.browserSetupSelect,t[22]=c,t[23]=r,t[24]=f):f=t[24];let p;return t[25]!==d||t[26]!==f?(p=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-base px-4 py-4`,children:[d,f]}),t[25]=d,t[26]=f,t[27]=p):p=t[27],p}function Ni(e){if(e.kind===`loading`)return`checking`;if(e.kind===`error`)return`error`;if(e.kind===`ok`)return e.data.installed?`ready`:`not_installed`}function Pi(e,t){if(e)return{ready:t.browserStatusReady,not_installed:t.browserStatusNotInstalled,checking:t.browserStatusChecking,unknown:t.browserStatusUnknown,error:t.browserStatusError}[e]}function Fi(e){if(e.kind!==`idle`)return e.kind===`loading`?`checking`:e.kind===`error`?`error`:e.data.connected?`ready`:(e.data.running,`not_installed`)}function Ii(e,t){if(e.kind!==`idle`)return e.kind===`loading`?t.browserStatusChecking:e.kind===`error`?t.browserStatusError:e.data.connected?t.browserExtensionConnected:e.data.running?t.browserExtensionWaiting:t.browserExtensionServerOff}var Li=[`overview`,`extension`,`local`,`cloakbrowser`,`cdp`,`cloud`],Ri=[`extension`,`local`,`cloakbrowser`,`cdp`,`cloud`],zi={connection:`overview`,extension:`extension`,local:`local`,cloak:`cloakbrowser`,cdp:`cdp`,cloud:`cloud`,runtime:`overview`,security:`overview`};function Bi(e){let t=(e??``).trim();return t===`behavior`?`overview`:Li.includes(t)?t:`overview`}function Vi(e){return Ri.includes(e)}function Hi(e){let t=(0,X.c)(46),{icon:n,title:r,description:i,status:a,statusDetail:o,primaryAction:s,children:c,advanced:l,m:u,embedded:d,sectionTitle:f,advancedTitle:p}=e,m=d===void 0?!1:d,h;t[0]!==l||t[1]!==p?(h=l?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[p?(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:p}):null,l]}):null,t[0]=l,t[1]=p,t[2]=h):h=t[2];let g=h;if(m){let e;t[3]!==i||t[4]!==f?(e=f?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:f}),i?(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:i}):null]}):null,t[3]=i,t[4]=f,t[5]=e):e=t[5];let n;t[6]!==u||t[7]!==s||t[8]!==a||t[9]!==o?(n=a||s?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[a?(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(Ui,{kind:a,detail:o,m:u})}):(0,Z.jsx)(`span`,{}),s?(0,Z.jsx)(`div`,{className:`shrink-0`,children:s}):null]}):null,t[6]=u,t[7]=s,t[8]=a,t[9]=o,t[10]=n):n=t[10];let r;t[11]===c?r=t[12]:(r=c?(0,Z.jsx)(`div`,{className:`flex flex-col gap-4`,children:c}):null,t[11]=c,t[12]=r);let l;return t[13]!==g||t[14]!==e||t[15]!==n||t[16]!==r?(l=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[e,n,r,g]}),t[13]=g,t[14]=e,t[15]=n,t[16]=r,t[17]=l):l=t[17],l}let _;t[18]===n?_=t[19]:(_=(0,Z.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover text-fg-muted`,children:(0,Z.jsx)(n,{className:`size-4`,strokeWidth:1.75})}),t[18]=n,t[19]=_);let v;t[20]===r?v=t[21]:(v=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:r}),t[20]=r,t[21]=v);let y;t[22]!==u||t[23]!==a||t[24]!==o?(y=a?(0,Z.jsx)(Ui,{kind:a,detail:o,m:u}):null,t[22]=u,t[23]=a,t[24]=o,t[25]=y):y=t[25];let b;t[26]!==v||t[27]!==y?(b=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[v,y]}),t[26]=v,t[27]=y,t[28]=b):b=t[28];let x;t[29]===i?x=t[30]:(x=(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:i}),t[29]=i,t[30]=x);let S;t[31]!==b||t[32]!==x?(S=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[b,x]}),t[31]=b,t[32]=x,t[33]=S):S=t[33];let C;t[34]===s?C=t[35]:(C=s?(0,Z.jsx)(`div`,{className:`shrink-0`,children:s}):null,t[34]=s,t[35]=C);let w;t[36]!==_||t[37]!==S||t[38]!==C?(w=(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[_,S,C]}),t[36]=_,t[37]=S,t[38]=C,t[39]=w):w=t[39];let T;t[40]===c?T=t[41]:(T=c?(0,Z.jsx)(`div`,{className:`flex flex-col gap-4`,children:c}):null,t[40]=c,t[41]=T);let E;return t[42]!==g||t[43]!==w||t[44]!==T?(E=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl border border-edge bg-surface-panel p-4`,children:[w,T,g]}),t[42]=g,t[43]=w,t[44]=T,t[45]=E):E=t[45],E}function Ui(e){let t=(0,X.c)(27),{kind:n,detail:r,m:i}=e,a,o,s,c;if(t[0]!==n||t[1]!==i.browserStatusChecking||t[2]!==i.browserStatusError||t[3]!==i.browserStatusNotInstalled||t[4]!==i.browserStatusReady||t[5]!==i.browserStatusUnknown){let{icon:e,color:r,label:l}={ready:{icon:ve,color:`text-green-600 dark:text-green-400`,label:i.browserStatusReady},not_installed:{icon:Ue,color:`text-amber-600 dark:text-amber-400`,label:i.browserStatusNotInstalled},checking:{icon:Ye,color:`text-fg-muted`,label:i.browserStatusChecking},unknown:{icon:C,color:`text-fg-muted`,label:i.browserStatusUnknown},error:{icon:ce,color:`text-red-600 dark:text-red-400`,label:i.browserStatusError}}[n];a=e,o=l,c=`inline-flex min-w-0 flex-col items-start gap-1`,s=Y(`inline-flex shrink-0 items-center gap-1 whitespace-nowrap text-xs font-medium`,r),t[0]=n,t[1]=i.browserStatusChecking,t[2]=i.browserStatusError,t[3]=i.browserStatusNotInstalled,t[4]=i.browserStatusReady,t[5]=i.browserStatusUnknown,t[6]=a,t[7]=o,t[8]=s,t[9]=c}else a=t[6],o=t[7],s=t[8],c=t[9];let l=n===`checking`&&`animate-spin`,u;t[10]===l?u=t[11]:(u=Y(`size-3.5 shrink-0`,l),t[10]=l,t[11]=u);let d;t[12]!==a||t[13]!==u?(d=(0,Z.jsx)(a,{className:u}),t[12]=a,t[13]=u,t[14]=d):d=t[14];let f;t[15]===o?f=t[16]:(f=(0,Z.jsx)(`span`,{children:o}),t[15]=o,t[16]=f);let p;t[17]!==s||t[18]!==d||t[19]!==f?(p=(0,Z.jsxs)(`span`,{className:s,children:[d,f]}),t[17]=s,t[18]=d,t[19]=f,t[20]=p):p=t[20];let m;t[21]===r?m=t[22]:(m=r?(0,Z.jsx)(`span`,{className:`break-all font-mono text-[11px] leading-snug text-fg-subtle`,children:r}):null,t[21]=r,t[22]=m);let h;return t[23]!==c||t[24]!==p||t[25]!==m?(h=(0,Z.jsxs)(`span`,{className:c,children:[p,m]}),t[23]=c,t[24]=p,t[25]=m,t[26]=h):h=t[26],h}function Wi(e){let t=(0,X.c)(5),{kind:n,message:r}=e,i=n===`success`?`border-green-500/30 bg-green-500/10 text-green-700 dark:text-green-300`:`border-red-500/30 bg-red-500/10 text-red-600 dark:text-red-300`,a;t[0]===i?a=t[1]:(a=Y(`rounded-lg border px-3 py-2 text-xs leading-relaxed`,i),t[0]=i,t[1]=a);let o;return t[2]!==r||t[3]!==a?(o=(0,Z.jsx)(`div`,{className:a,children:r}),t[2]=r,t[3]=a,t[4]=o):o=t[4],o}var Gi={instances:[],launchStatus:`idle`,launchMessage:null,testStatus:`idle`,testMessage:null,executablePath:``};function Ki({m:e,cdpUrl:t,onCdpUrlChange:n,launch:r,stop:i,listInstances:a,ping:o,embedded:s=!1}){let[c,l]=(0,Q.useReducer)(yt,Gi),{instances:u,launchStatus:d,launchMessage:f,testStatus:p,testMessage:m,executablePath:h}=c,g=(0,Q.useCallback)(async()=>{try{l({type:`patch`,patch:{instances:await a()}})}catch{}},[a]);(0,Q.useEffect)(()=>{g();let e=setInterval(()=>void g(),8e3);return()=>clearInterval(e)},[g]);let _=(0,Q.useCallback)(async()=>{if(d!==`pending`){l({type:`patch`,patch:{launchStatus:`pending`,launchMessage:null}});try{let t=await r(h.trim()||void 0);l({type:`patch`,patch:{launchStatus:`ok`,launchMessage:e.browserCdpLaunchedAtPort.replace(`{{port}}`,String(t.port))}}),n(t.wsEndpoint),await g()}catch(e){l({type:`patch`,patch:{launchStatus:`error`,launchMessage:e instanceof Error?e.message:String(e)}})}}},[h,r,d,e.browserCdpLaunchedAtPort,n,g]),v=(0,Q.useCallback)(async e=>{await i(e),await g()},[g,i]),y=(0,Q.useCallback)(async()=>{if(t.trim()){l({type:`patch`,patch:{testStatus:`pending`,testMessage:null}});try{let n=await o(t.trim());n.reachable?l({type:`patch`,patch:{testStatus:`ok`,testMessage:e.browserCdpReachable.replace(`{{browser}}`,n.browser??`—`)}}):l({type:`patch`,patch:{testStatus:`error`,testMessage:e.browserCdpUnreachable.replace(`{{error}}`,n.error??`—`)}})}catch(t){l({type:`patch`,patch:{testStatus:`error`,testMessage:e.browserCdpUnreachable.replace(`{{error}}`,t instanceof Error?t.message:String(t))}})}}},[t,e.browserCdpReachable,e.browserCdpUnreachable,o]);return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsxs)(Hi,{icon:ge,title:e.browserCdpLaunchLocal,description:e.browserCdpLaunchLocalDesc,m:e,embedded:s,sectionTitle:s?e.browserCdpLaunchLocal:void 0,primaryAction:(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:d===`pending`,onClick:()=>void _(),children:[d===`pending`?(0,Z.jsx)(Ye,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(ge,{className:`size-3.5`}),d===`pending`?e.browserCdpLaunching:e.browserCdpLaunchLocal]}),children:[f?(0,Z.jsx)(Wi,{kind:d===`error`?`error`:`success`,message:f}):null,(0,Z.jsx)($,{label:e.browserCdpChromePath,description:e.browserCdpChromePathDesc,children:(0,Z.jsx)(`input`,{type:`text`,className:Xn(),value:h,placeholder:`/Applications/Google Chrome.app/Contents/MacOS/Google Chrome`,onChange:e=>l({type:`patch`,patch:{executablePath:e.target.value}}),autoComplete:`off`})}),u.length>0?(0,Z.jsx)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge bg-surface-base p-3 text-xs`,children:u.map(t=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,Z.jsxs)(`span`,{className:`font-mono text-fg`,children:[`port `,t.port,` · pid `,t.pid]}),(0,Z.jsx)(`span`,{className:`truncate text-fg-subtle`,children:t.wsEndpoint})]}),(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs font-medium text-fg hover:bg-surface-raised`,onClick:()=>void v(t.port),children:[(0,Z.jsx)(Ne,{className:`size-3`}),e.browserCdpStopLocal]})]},t.port))}):null]}),(0,Z.jsxs)(Hi,{icon:dt,title:e.label.browserCdpUrl,description:e.desc.browserCdpUrl,m:e,embedded:s,sectionTitle:s?e.label.browserCdpUrl:void 0,primaryAction:(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:!t.trim()||p===`pending`,onClick:()=>void y(),children:[p===`pending`?(0,Z.jsx)(Ye,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(F,{className:`size-3.5`}),p===`pending`?e.browserCdpTesting:e.browserCdpTestConnection]}),children:[(0,Z.jsx)(`input`,{type:`text`,className:Xn(),value:t,placeholder:`ws://127.0.0.1:9222`,onChange:e=>n(e.target.value),autoComplete:`off`}),(0,Z.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:e.browserCdpLoopbackOnly}),m?(0,Z.jsx)(Wi,{kind:p===`error`?`error`:`success`,message:m}):null]})]})}function qi(e,t){let n=t.phase;if(!n)return e.browserInstallPhaseStarting;if(n===`downloading`)return t.percent==null?e.browserInstallPhaseDownloading:e.browserInstallPhaseDownloadingPercent.replace(`{{percent}}`,String(t.percent));switch(n){case`starting`:return e.browserInstallPhaseStarting;case`verifying`:return e.browserInstallPhaseVerifying;case`extracting`:return e.browserInstallPhaseExtracting;case`running`:return t.message??e.browserInstallPhaseRunning;case`ready`:return e.browserInstallPhaseReady;default:return t.message??e.browserInstallPhaseRunning}}function Ji(e){let t=(0,X.c)(32),{m:n,progress:r,showLogs:i,onCancel:a,cancelling:o}=e,s=i===void 0?!1:i,c=o===void 0?!1:o;if(!r.phase)return null;let l;t[0]!==n||t[1]!==r?(l=qi(n,r),t[0]=n,t[1]=r,t[2]=l):l=t[2];let u=l,d=r.percent==null?(r.phase===`extracting`||r.phase===`verifying`||r.phase===`running`||r.phase,null):Math.min(100,Math.max(0,r.percent)),f;t[3]===u?f=t[4]:(f=(0,Z.jsx)(`span`,{className:`text-fg`,children:u}),t[3]=u,t[4]=f);let p;t[5]===d?p=t[6]:(p=d==null?null:(0,Z.jsxs)(`span`,{className:`tabular-nums`,children:[d,`%`]}),t[5]=d,t[6]=p);let m;t[7]!==c||t[8]!==n||t[9]!==a?(m=a?(0,Z.jsx)(`button`,{type:`button`,className:`rounded-md border border-edge px-2 py-0.5 text-[11px] font-medium text-fg-muted hover:bg-surface-raised hover:text-fg disabled:cursor-not-allowed disabled:opacity-60`,disabled:c,onClick:()=>void a(),children:c?n.browserInstallCancelling:n.browserInstallCancel}):null,t[7]=c,t[8]=n,t[9]=a,t[10]=m):m=t[10];let h;t[11]!==p||t[12]!==m?(h=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[p,m]}),t[11]=p,t[12]=m,t[13]=h):h=t[13];let g;t[14]!==f||t[15]!==h?(g=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs text-fg-muted`,children:[f,h]}),t[14]=f,t[15]=h,t[16]=g):g=t[16];let _;t[17]===d?_=t[18]:(_=(0,Z.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-surface-raised`,children:d==null?(0,Z.jsx)(`div`,{className:`h-full w-1/3 animate-pulse rounded-full bg-accent/70`}):(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-[width] duration-300 ease-out`,style:{width:`${d}%`}})}),t[17]=d,t[18]=_);let v;t[19]!==r.lines||t[20]!==s?(v=s&&r.lines.length>0?(0,Z.jsx)(`div`,{className:`max-h-28 overflow-y-auto rounded-md border border-edge bg-surface-panel px-2 py-1.5 font-mono text-[10px] leading-relaxed text-fg-muted`,children:r.lines.map(Yi)}):null,t[19]=r.lines,t[20]=s,t[21]=v):v=t[21];let y;t[22]!==r.message||t[23]!==r.percent||t[24]!==r.phase||t[25]!==s?(y=!s&&r.phase===`downloading`&&r.message&&r.percent==null?(0,Z.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:r.message}):null,t[22]=r.message,t[23]=r.percent,t[24]=r.phase,t[25]=s,t[26]=y):y=t[26];let b;return t[27]!==v||t[28]!==y||t[29]!==g||t[30]!==_?(b=(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-edge bg-surface-base px-3 py-2.5`,children:[g,_,v,y]}),t[27]=v,t[28]=y,t[29]=g,t[30]=_,t[31]=b):b=t[31],b}function Yi(e,t){return(0,Z.jsx)(`div`,{className:`truncate`,children:e},`${t}-${e.slice(0,24)}`)}var Xi={confirmOpen:!1,installStatus:`idle`,installMessage:null,openStatus:`idle`,openMessage:null,runtime:null};function Zi({m:e,doctor:t,refetch:n,applyDoctor:r,installStream:i,fetchRuntimeStatus:a,launchCloak:o,form:s,onChange:c,embedded:l=!1}){let[u,d]=(0,Q.useReducer)(yt,Xi),{confirmOpen:f,installStatus:p,installMessage:m,openStatus:h,openMessage:g,runtime:_}=u,{progress:v,running:y,cancelling:b,run:x,reset:S,cancel:C}=i,w=t.kind===`ok`?t.data:null,T=w?.installed===!0,E=p===`installing`||y,k=(0,Q.useCallback)(async()=>{if(T)try{d({type:`patch`,patch:{runtime:await a()}})}catch{}},[a,T]);(0,Q.useEffect)(()=>{if(!T){d({type:`patch`,patch:{runtime:null}});return}k();let e=setInterval(()=>void k(),8e3);return()=>clearInterval(e)},[T,k]);let A=(0,Q.useCallback)(async()=>{d({type:`patch`,patch:{confirmOpen:!1,installStatus:`installing`,installMessage:null}}),S();let t=await x({body:{cacheDir:s.cacheDir.trim()||void 0,binaryPath:s.binaryPath.trim()||void 0},fallbackError:e.browserCloakInstallFailed});if(!t.ok){if(t.error===`busy`){d({type:`patch`,patch:{installStatus:`installing`}});return}if(t.error===`cancelled`){d({type:`patch`,patch:{installStatus:`idle`,installMessage:null}}),S();return}d({type:`patch`,patch:{installStatus:`failed`,installMessage:t.errorMessage??e.browserCloakInstallFailed}});return}t.payload&&r?.(t.payload),d({type:`patch`,patch:{installStatus:`installed`,installMessage:t.payload?.binaryPath?`${e.browserCloakInstalled}: ${t.payload.binaryPath}`:e.browserCloakInstalled}}),await n({cacheDir:s.cacheDir,binaryPath:s.binaryPath}),await k()},[r,s.binaryPath,s.cacheDir,e.browserCloakInstallFailed,e.browserCloakInstalled,n,k,S,x]),j=(0,Q.useCallback)(async()=>{if(h!==`pending`){d({type:`patch`,patch:{openStatus:`pending`,openMessage:null}});try{let t=await o();d({type:`patch`,patch:{openStatus:`ok`,openMessage:t.reused?e.browserCloakOpenReused.replace(`{{port}}`,String(t.port)):e.browserCloakOpenLaunched.replace(`{{port}}`,String(t.port)),runtime:t}})}catch(e){d({type:`patch`,patch:{openStatus:`error`,openMessage:e instanceof Error?e.message:String(e)}})}}},[o,e.browserCloakOpenLaunched,e.browserCloakOpenReused,h]),M=t.kind===`loading`?`checking`:t.kind===`error`?`error`:T?`ready`:`not_installed`,N=T&&w?.version?`v${w.version} (${w.platform})`:void 0;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Hi,{icon:O,title:e.browserCloakGuideTitle,description:e.browserCloakGuideDesc,status:M,statusDetail:N,m:e,embedded:l,primaryAction:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[T?(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:h===`pending`,onClick:()=>void j(),children:[h===`pending`?(0,Z.jsx)(Ye,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(ge,{className:`size-3.5`}),h===`pending`?e.browserCloakOpening:e.browserCloakOpen]}):null,(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:E,onClick:()=>d({type:`patch`,patch:{confirmOpen:!0}}),children:[E?(0,Z.jsx)(Ye,{className:`size-3.5 animate-spin`}):T?(0,Z.jsx)(le,{className:`size-3.5`}):p===`installed`?(0,Z.jsx)(ve,{className:`size-3.5 text-green-500`}):(0,Z.jsx)(D,{className:`size-3.5`}),E?e.browserCloakInstalling:T?e.browserReinstall:e.browserCloakDownload]})]}),children:[y?(0,Z.jsx)(Ji,{m:e,progress:v,cancelling:b,onCancel:()=>void C()}):null,m?(0,Z.jsx)(Wi,{kind:p===`failed`?`error`:`success`,message:m}):null,g?(0,Z.jsx)(Wi,{kind:h===`error`?`error`:`success`,message:g}):null,T&&_?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge bg-surface-base p-3 text-xs`,children:[(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:_.running?e.browserCloakRuntimeRunning.replace(`{{port}}`,String(_.port)):e.browserCloakRuntimeOff})}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Z.jsx)(`span`,{className:`text-fg-subtle`,children:e.browserCloakProfileLabel}),(0,Z.jsx)(`span`,{className:`break-all font-mono text-[11px] text-fg-muted`,children:_.userDataDir})]}),(0,Z.jsx)(`p`,{className:`text-[11px] leading-relaxed text-fg-subtle`,children:e.browserCloakProfileAgentHint}),_.temporaryProfile?(0,Z.jsx)(`p`,{className:`text-[11px] text-amber-600 dark:text-amber-400`,children:e.browserCloakTemporaryProfileHint}):null]}):null,(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsx)($,{label:e.label.browserCloakKeepOpen,description:e.desc.browserCloakKeepOpen,children:(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:s.keepOpen,onChange:e=>c({keepOpen:e.target.checked})}),(0,Z.jsx)(`span`,{children:e.browserCloakKeepOpenOn})]})}),(0,Z.jsx)($,{label:e.label.browserCloakTemporaryProfile,description:e.desc.browserCloakTemporaryProfile,children:(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:s.temporaryProfile,onChange:e=>c({temporaryProfile:e.target.checked})}),(0,Z.jsx)(`span`,{children:e.browserCloakTemporaryProfileOn})]})}),(0,Z.jsx)($,{label:e.label.browserHumanize,description:e.desc.browserHumanize,children:(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:s.humanize,onChange:e=>c({humanize:e.target.checked})}),(0,Z.jsx)(`span`,{children:e.browserHumanizeOn})]})}),(0,Z.jsx)($,{label:e.label.browserHumanPreset,description:e.desc.browserHumanPreset,children:(0,Z.jsxs)(`select`,{className:Zn(),value:s.humanPreset,onChange:e=>c({humanPreset:e.target.value}),children:[(0,Z.jsx)(`option`,{value:`careful`,children:e.browserHumanPresetCareful}),(0,Z.jsx)(`option`,{value:`default`,children:e.browserHumanPresetDefault})]})})]})]}),(0,Z.jsxs)(zt,{className:`mt-4 border border-edge-subtle`,children:[(0,Z.jsx)(Rt,{icon:O,title:e.browserCloakAdvancedShow}),(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsxs)($,{label:e.label.browserCloakCacheDir,description:e.desc.browserCloakCacheDir,children:[(0,Z.jsx)(`input`,{type:`text`,className:Xn(),value:s.cacheDir,placeholder:`~/.xopc/bin/cloakbrowser`,onChange:e=>c({cacheDir:e.target.value}),autoComplete:`off`}),(0,Z.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:e.browserCacheDirHomeOnly})]}),(0,Z.jsxs)($,{label:e.label.browserCloakBinaryPath,description:e.desc.browserCloakBinaryPath,children:[(0,Z.jsx)(`input`,{type:`text`,className:Xn(),value:s.binaryPath,placeholder:`~/.xopc/bin/cloakbrowser/chromium-v.../Chromium.app/Contents/MacOS/Chromium`,onChange:e=>c({binaryPath:e.target.value}),autoComplete:`off`}),s.binaryPath.trim()?(0,Z.jsx)(`p`,{className:`text-[11px] text-amber-600 dark:text-amber-400`,children:e.browserBinaryPathWarning}):null]}),(0,Z.jsx)($,{label:e.label.browserCloakTimezone,description:e.desc.browserCloakTimezone,children:(0,Z.jsx)(`input`,{type:`text`,className:Xn(),value:s.timezone,placeholder:`America/New_York`,onChange:e=>c({timezone:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)($,{label:e.label.browserCloakLocale,description:e.desc.browserCloakLocale,children:(0,Z.jsx)(`input`,{type:`text`,className:Xn(),value:s.locale,placeholder:`en-US`,onChange:e=>c({locale:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)($,{label:e.label.browserCloakWebrtcIp,description:e.desc.browserCloakWebrtcIp,children:(0,Z.jsx)(`input`,{type:`text`,className:Xn(),value:s.webrtcIp,placeholder:`203.0.113.10`,onChange:e=>c({webrtcIp:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)($,{label:e.label.browserCloakFingerprintPlatform,description:e.desc.browserCloakFingerprintPlatform,children:(0,Z.jsx)(`input`,{type:`text`,className:Xn(),value:s.fingerprintPlatform,placeholder:`macos`,onChange:e=>c({fingerprintPlatform:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)(`div`,{className:`sm:col-span-2`,children:(0,Z.jsx)($,{label:e.label.browserCloakExtraArgs,description:e.desc.browserCloakExtraArgs,children:(0,Z.jsx)(`textarea`,{className:Qi(),value:s.extraArgs,placeholder:`--disable-dev-shm-usage`,rows:3,onChange:e=>c({extraArgs:e.target.value})})})})]})]}),(0,Z.jsx)(xt,{open:f,title:e.browserConfirmDownloadTitle,description:$i(e,w),confirmLabel:e.browserConfirmDownloadConfirm,cancelLabel:e.browserConfirmDownloadCancel,onConfirm:()=>void A(),onCancel:()=>d({type:`patch`,patch:{confirmOpen:!1}})})]})}function Qi(){return`${Xn()} min-h-[4.5rem] resize-y font-mono text-xs`}function $i(e,t){if(!t)return e.browserConfirmDownloadBody;let n=[e.browserConfirmDownloadBody.replace(`{{version}}`,t.version??`—`).replace(`{{platform}}`,t.platform).replace(`{{url}}`,t.downloadUrl||`—`)];return t.expectedSha256?n.push(`SHA-256: ${t.expectedSha256.slice(0,16)}…`):n.push(e.browserCloakSha256Skipped),n.join(`
218
218
  `)}function ea({m:e,form:t,onChange:n,testCloud:r,embedded:i=!1}){let[a,o]=(0,Q.useState)(`idle`),[s,c]=(0,Q.useState)(null),l=t.provider===`local`?`browserbase`:t.provider,u=(0,Q.useCallback)(async()=>{o(`pending`),c(null);try{let n=await r(l,t.apiKey);n.reachable?(o(`ok`),c(e.browserCloudTestOk)):(o(`error`),c(e.browserCloudTestFailed.replace(`{{error}}`,n.error??`—`)))}catch(t){o(`error`),c(e.browserCloudTestFailed.replace(`{{error}}`,t instanceof Error?t.message:String(t)))}},[t.apiKey,e.browserCloudTestFailed,e.browserCloudTestOk,l,r]);return(0,Z.jsxs)(Hi,{icon:W,title:e.label.browserCloudProvider,description:e.desc.browserCloudProvider,m:e,embedded:i,primaryAction:(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:a===`pending`,onClick:()=>void u(),children:[a===`pending`?(0,Z.jsx)(Ye,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(F,{className:`size-3.5`}),e.browserCloudTestConnection]}),children:[(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsx)($,{label:e.label.browserCloudProvider,description:e.desc.browserCloudProvider,children:(0,Z.jsxs)(`select`,{className:Zn(),value:l,onChange:e=>n({provider:e.target.value}),children:[(0,Z.jsx)(`option`,{value:`browserbase`,children:e.browserCloudProviderBrowserbase}),(0,Z.jsx)(`option`,{value:`browser-use`,children:e.browserCloudProviderBrowserUse})]})}),(0,Z.jsx)($,{label:e.label.browserCloudApiKey,description:e.desc.browserCloudApiKey,children:(0,Z.jsx)(`input`,{type:`password`,className:Xn(),value:t.apiKey===`***`?``:t.apiKey,placeholder:t.apiKey===`***`?`••••••••`:l===`browserbase`?`BROWSERBASE_API_KEY`:`BROWSER_USE_API_KEY`,onChange:e=>n({apiKey:e.target.value}),autoComplete:`off`})}),l===`browserbase`?(0,Z.jsx)($,{label:e.label.browserCloudProjectId,description:e.desc.browserCloudProjectId,children:(0,Z.jsx)(`input`,{type:`text`,className:Xn(),value:t.projectId,placeholder:`BROWSERBASE_PROJECT_ID`,onChange:e=>n({projectId:e.target.value}),autoComplete:`off`})}):null,(0,Z.jsx)($,{label:e.label.browserCloudRegion,description:e.desc.browserCloudRegion,children:(0,Z.jsx)(`input`,{type:`text`,className:Xn(),value:t.region,placeholder:`us-west-2`,onChange:e=>n({region:e.target.value}),autoComplete:`off`})})]}),s?(0,Z.jsx)(Wi,{kind:a===`error`?`error`:`success`,message:s}):null]})}function ta(e){let t=(0,X.c)(45),{m:n,installed:r,extensionDir:i,connected:a,busy:o,onOpenChrome:s,onRevealFolder:c,folderBusy:l}=e,u;t[0]!==r||t[1]!==n.browserExtensionInstallStep1?(u={id:`install`,label:n.browserExtensionInstallStep1,done:r},t[0]=r,t[1]=n.browserExtensionInstallStep1,t[2]=u):u=t[2];let d=!!i&&a,f;t[3]!==o||t[4]!==i||t[5]!==l||t[6]!==n.browserExtensionInstallStep2FolderLabel||t[7]!==n.browserExtensionInstalling||t[8]!==n.browserExtensionOpenChrome||t[9]!==n.browserExtensionRevealFolder||t[10]!==s||t[11]!==c?(f=i?(0,Z.jsxs)(`div`,{className:`mt-2 rounded-md border border-edge bg-surface-raised px-2.5 py-2`,children:[(0,Z.jsx)(`p`,{className:`text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:n.browserExtensionInstallStep2FolderLabel}),(0,Z.jsx)(`p`,{className:`mt-1 break-all font-mono text-[11px] text-fg`,children:i}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-3`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-[11px] text-accent hover:underline disabled:opacity-60`,disabled:o,onClick:s,children:n.browserExtensionOpenChrome}),(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-[11px] text-accent hover:underline disabled:opacity-60`,disabled:o,onClick:c,title:i,children:l?n.browserExtensionInstalling:n.browserExtensionRevealFolder})]})]}):null,t[3]=o,t[4]=i,t[5]=l,t[6]=n.browserExtensionInstallStep2FolderLabel,t[7]=n.browserExtensionInstalling,t[8]=n.browserExtensionOpenChrome,t[9]=n.browserExtensionRevealFolder,t[10]=s,t[11]=c,t[12]=f):f=t[12];let p;t[13]!==n.browserExtensionInstallStep2||t[14]!==d||t[15]!==f?(p={id:`load`,label:n.browserExtensionInstallStep2,done:d,detail:f},t[13]=n.browserExtensionInstallStep2,t[14]=d,t[15]=f,t[16]=p):p=t[16];let m;t[17]!==a||t[18]!==n.browserExtensionInstallStep3?(m={id:`connect`,label:n.browserExtensionInstallStep3,done:a},t[17]=a,t[18]=n.browserExtensionInstallStep3,t[19]=m):m=t[19];let h;t[20]!==u||t[21]!==p||t[22]!==m?(h=[u,p,m],t[20]=u,t[21]=p,t[22]=m,t[23]=h):h=t[23];let g=h,_;t[24]===g?_=t[25]:(_=g.filter(na),t[24]=g,t[25]=_);let v=_.length,y=n.browserExtensionInstallGuideTitle,b;t[26]===n.browserExtensionInstallGuideTitle?b=t[27]:(b=(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:n.browserExtensionInstallGuideTitle}),t[26]=n.browserExtensionInstallGuideTitle,t[27]=b);let x;t[28]!==v||t[29]!==n.browserExtensionChecklistProgress||t[30]!==g.length?(x=n.browserExtensionChecklistProgress.replace(`{{done}}`,String(v)).replace(`{{total}}`,String(g.length)),t[28]=v,t[29]=n.browserExtensionChecklistProgress,t[30]=g.length,t[31]=x):x=t[31];let S;t[32]===x?S=t[33]:(S=(0,Z.jsx)(`span`,{className:`ml-auto text-xs font-normal text-fg-muted`,children:x}),t[32]=x,t[33]=S);let C;t[34]!==S||t[35]!==b?(C=(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[b,S]}),t[34]=S,t[35]=b,t[36]=C):C=t[36];let w;t[37]!==n.browserExtensionChecklistDone||t[38]!==n.browserExtensionChecklistPending||t[39]!==g?(w=(0,Z.jsx)(`ol`,{className:`flex flex-col gap-3`,children:g.map((e,t)=>(0,Z.jsxs)(`li`,{className:`flex gap-2.5`,children:[(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0`,"aria-hidden":!0,children:e.done?(0,Z.jsx)(ve,{className:`size-4 text-emerald-500`,strokeWidth:2}):(0,Z.jsx)(B,{className:`size-4 text-fg-subtle`,strokeWidth:1.75})}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`p`,{className:Y(`text-[11px] leading-relaxed`,e.done?`text-fg-muted line-through decoration-fg-subtle/60`:`text-fg`),children:[(0,Z.jsxs)(`span`,{className:`sr-only`,children:[e.done?n.browserExtensionChecklistDone:n.browserExtensionChecklistPending,` `]}),t+1,`. `,e.label]}),e.detail]})]},e.id))}),t[37]=n.browserExtensionChecklistDone,t[38]=n.browserExtensionChecklistPending,t[39]=g,t[40]=w):w=t[40];let T;return t[41]!==n.browserExtensionInstallGuideTitle||t[42]!==C||t[43]!==w?(T=(0,Z.jsxs)(`div`,{"aria-label":y,className:`rounded-xl border border-edge bg-surface-base px-3 py-3`,children:[C,w]}),t[41]=n.browserExtensionInstallGuideTitle,t[42]=C,t[43]=w,t[44]=T):T=t[44],T}function na(e){return e.done}var ra=19820,ia=3e4;function aa({m:e,probe:t,artifacts:n,onChange:r,startBridge:i,stopBridge:a,disconnectExtension:o,installArtifacts:s,refetchArtifacts:c,openExtensionChrome:l,revealExtensionFolder:u,form:d,embedded:f=!1}){let[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(null),y=d.port??ra,b=d.host||`127.0.0.1`,x=`ws://${b}:${y}/browser-ext`,S=t.kind===`ok`&&t.data.running,C=t.kind===`ok`&&t.data.connected,w=t.kind===`ok`&&t.data.bridgeHeld===!0,T=t.kind===`ok`&&t.data.portConflict===!0,E=S||w,O=n.kind===`ok`?n.data:t.kind===`ok`?t.data.artifacts:void 0,k=O?.installed===!0,A=O?.extensionDir,j=O?.needsChromeReload===!0,M=t.kind===`ok`?C?{icon:Se,color:`text-green-500`,label:e.browserExtensionConnected}:S?{icon:F,color:`text-amber-500`,label:e.browserExtensionWaiting}:{icon:Re,color:`text-fg-muted`,label:e.browserExtensionServerOff}:{icon:Re,color:`text-fg-muted`,label:`…`},P=M.icon,I=(0,Q.useCallback)(async()=>{if(!p){m(`start`),g(null);try{await i({host:b,port:y})}catch(e){g(e instanceof Error?e.message:String(e))}finally{m(null)}}},[p,b,y,i]),ee=(0,Q.useCallback)(async()=>{if(!p){m(`stop`),g(null);try{await a()}catch(e){g(e instanceof Error?e.message:String(e))}finally{m(null)}}},[p,a]),L=(0,Q.useCallback)(async()=>{if(!p){m(`disconnect`),g(null);try{await o()}catch(e){g(e instanceof Error?e.message:String(e))}finally{m(null)}}},[p,o]),R=(0,Q.useCallback)(async()=>{if(!p){m(`install`),g(null),v(null);try{let t=await s({force:k});t?.extensionDir?v(`${e.browserExtensionInstalled}: ${t.extensionDir}`):v(e.browserExtensionInstalled),await c()}catch(e){g(e instanceof Error?e.message:String(e))}finally{m(null)}}},[p,s,k,e.browserExtensionInstalled,c]),z=(0,Q.useCallback)(async()=>{if(!p){m(`open`),g(null);try{await l()}catch(e){g(e instanceof Error?e.message:String(e))}finally{m(null)}}},[p,l]),B=(0,Q.useCallback)(async()=>{if(!(!A||p)){m(`folder`),g(null),v(null);try{let t=await N(A);await u(),v(t?e.browserExtensionPathCopied:e.browserExtensionFolderOpened)}catch(e){g(e instanceof Error?e.message:String(e))}finally{m(null)}}},[p,A,e.browserExtensionFolderOpened,e.browserExtensionPathCopied,u]),V=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:p!==null,onClick:()=>void R(),children:[p===`install`?(0,Z.jsx)(Ye,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(D,{className:`size-3.5`}),p===`install`?e.browserExtensionInstalling:e.browserExtensionInstall]}),E?(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:p!==null,onClick:()=>void ee(),children:[p===`stop`?(0,Z.jsx)(Ye,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(Ne,{className:`size-3.5`}),e.browserExtensionStopBridge]}):(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:p!==null,onClick:()=>void I(),children:[p===`start`?(0,Z.jsx)(Ye,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(ge,{className:`size-3.5`}),p===`start`?e.browserExtensionStarting:e.browserExtensionStartBridge]}),C?(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:p!==null,onClick:()=>void L(),children:[p===`disconnect`?(0,Z.jsx)(Ye,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(Re,{className:`size-3.5`}),e.browserExtensionDisconnect]}):null]});return(0,Z.jsx)(Hi,{icon:It,title:e.browserBackendExtension,description:e.browserExtensionDownloadHint,m:e,embedded:f,primaryAction:V,advancedTitle:e.browserAdvancedShow,advanced:(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsx)($,{label:e.label.browserExtensionPort,description:e.desc.browserExtensionPort,children:(0,Z.jsx)(`input`,{type:`number`,className:Xn(),min:1024,max:65535,value:d.port??``,placeholder:String(ra),onChange:e=>{let t=e.target.value;r({port:t===``?void 0:Number.parseInt(t,10)})}})}),(0,Z.jsx)($,{label:e.label.browserExtensionHost,description:e.desc.browserExtensionHost,children:(0,Z.jsx)(`input`,{type:`text`,className:Xn(),value:d.host,placeholder:`127.0.0.1`,onChange:e=>r({host:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)($,{label:e.label.browserExtensionConnectionTimeout,description:e.desc.browserExtensionConnectionTimeout,children:(0,Z.jsx)(`input`,{type:`number`,className:Xn(),min:1,step:1,value:d.connectionTimeoutMs==null?``:Math.round(d.connectionTimeoutMs/1e3),placeholder:String(ia/1e3),onChange:e=>{let t=e.target.value;r({connectionTimeoutMs:t===``?void 0:Math.max(1,Number.parseInt(t,10))*1e3})}})})]}),children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-xs text-fg-muted`,children:x}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs ${M.color}`,children:[(0,Z.jsx)(P,{className:`size-3.5`}),(0,Z.jsx)(`span`,{children:M.label})]})]}),(0,Z.jsx)(ta,{m:e,installed:k,extensionDir:A,connected:C,busy:p!==null,folderBusy:p===`folder`,onOpenChrome:()=>void z(),onRevealFolder:()=>void B()}),j?(0,Z.jsx)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-relaxed text-amber-800 dark:text-amber-200`,children:e.browserExtensionNeedsChromeReload}):null,T?(0,Z.jsx)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-relaxed text-amber-800 dark:text-amber-200`,children:e.browserExtensionPortConflict.replace(`{{port}}`,String(y))}):null,_?(0,Z.jsx)(Wi,{kind:`success`,message:_}):null,h?(0,Z.jsx)(Wi,{kind:`error`,message:h}):null]})})}function oa(e){let t=(0,X.c)(41),{m:n,doctor:r,refetch:i,applyDoctor:a,installStream:o,embedded:s}=e,c=s===void 0?!1:s,[l,u]=(0,Q.useState)(`idle`),[d,f]=(0,Q.useState)(null),{progress:p,running:m,cancelling:h,run:g,reset:_,cancel:v}=o,y;t[0]!==a||t[1]!==n.browserPlaywrightInstallFailed||t[2]!==n.browserPlaywrightInstalled||t[3]!==i||t[4]!==_||t[5]!==g?(y=async()=>{u(`installing`),f(null),_();let e=await g({fallbackError:n.browserPlaywrightInstallFailed});if(!e.ok){if(e.error===`busy`){u(`installing`);return}if(e.error===`cancelled`){u(`idle`),f(null),_();return}u(`failed`),f(e.errorMessage??n.browserPlaywrightInstallFailed);return}e.payload&&a?.(e.payload),u(`installed`),f(e.payload?.executablePath?`${n.browserPlaywrightInstalled}: ${e.payload.executablePath}`:n.browserPlaywrightInstalled),await i()},t[0]=a,t[1]=n.browserPlaywrightInstallFailed,t[2]=n.browserPlaywrightInstalled,t[3]=i,t[4]=_,t[5]=g,t[6]=y):y=t[6];let b=y,x=r.kind===`loading`?`checking`:r.kind===`error`?`error`:r.kind===`ok`?r.data.installed?`ready`:`not_installed`:`unknown`,S=r.kind===`ok`&&r.data.installed&&r.data.executablePath?r.data.executablePath:void 0,C=r.kind===`ok`&&r.data.installed,w=l===`installing`||m,T;t[7]===b?T=t[8]:(T=()=>void b(),t[7]=b,t[8]=T);let E;t[9]!==C||t[10]!==w||t[11]!==l?(E=w?(0,Z.jsx)(Ye,{className:`size-3.5 animate-spin`}):C?(0,Z.jsx)(le,{className:`size-3.5`}):l===`installed`?(0,Z.jsx)(ve,{className:`size-3.5 text-green-500`}):(0,Z.jsx)(D,{className:`size-3.5`}),t[9]=C,t[10]=w,t[11]=l,t[12]=E):E=t[12];let O=w?n.browserPlaywrightInstalling:C?n.browserReinstall:n.browserPlaywrightInstall,k;t[13]!==w||t[14]!==T||t[15]!==E||t[16]!==O?(k=(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:w,onClick:T,children:[E,O]}),t[13]=w,t[14]=T,t[15]=E,t[16]=O,t[17]=k):k=t[17];let A;t[18]===n.browserPlaywrightManualInstall?A=t[19]:(A=(0,Z.jsx)(`p`,{className:`text-fg-muted`,children:n.browserPlaywrightManualInstall}),t[18]=n.browserPlaywrightManualInstall,t[19]=A);let j;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,Z.jsx)(`code`,{className:`mt-2 block w-fit rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg`,children:`node node_modules/playwright-core/cli.js install chromium`}),t[20]=j):j=t[20];let M;t[21]===A?M=t[22]:(M=(0,Z.jsxs)(`div`,{className:`text-xs`,children:[A,j]}),t[21]=A,t[22]=M);let N;t[23]!==v||t[24]!==h||t[25]!==n||t[26]!==p||t[27]!==m?(N=m?(0,Z.jsx)(Ji,{m:n,progress:p,showLogs:!0,cancelling:h,onCancel:()=>void v()}):null,t[23]=v,t[24]=h,t[25]=n,t[26]=p,t[27]=m,t[28]=N):N=t[28];let P;t[29]!==d||t[30]!==l?(P=d?(0,Z.jsx)(Wi,{kind:l===`failed`?`error`:`success`,message:d}):null,t[29]=d,t[30]=l,t[31]=P):P=t[31];let F;return t[32]!==c||t[33]!==n||t[34]!==S||t[35]!==x||t[36]!==N||t[37]!==P||t[38]!==k||t[39]!==M?(F=(0,Z.jsxs)(Hi,{icon:De,title:n.browserPlaywrightGuideTitle,description:n.browserPlaywrightGuideDesc,status:x,statusDetail:S,m:n,embedded:c,primaryAction:k,children:[M,N,P]}),t[32]=c,t[33]=n,t[34]=S,t[35]=x,t[36]=N,t[37]=P,t[38]=k,t[39]=M,t[40]=F):F=t[40],F}async function sa(e){let t=await v(e),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1){let e=typeof n.error==`string`?n.error:n.error?.message;throw Error(e||`Request failed: ${t.status}`)}if(n.payload===void 0)throw Error(`Empty payload`);return n.payload}async function ca(e,t){let n=await v(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t??{})}),r=await n.json().catch(()=>({}));if(!n.ok||r.ok===!1){let e=typeof r.error==`string`?r.error:r.error?.message;throw Error(e||`Request failed: ${n.status}`)}if(r.payload===void 0)throw Error(`Empty payload`);return r.payload}var la={playwright:{kind:`idle`},cloak:{kind:`idle`},extension:{kind:`idle`},extensionArtifacts:{kind:`idle`}};function ua(e,t){switch(t.type){case`playwright`:return{...e,playwright:t.state};case`cloak`:return{...e,cloak:t.state};case`extension`:return{...e,extension:t.state};case`extension-artifacts`:return{...e,extensionArtifacts:t.state};case`playwright-idle`:return{...e,playwright:{kind:`idle`}};case`cloak-idle`:return{...e,cloak:{kind:`idle`}};case`extension-idle`:return{...e,extension:{kind:`idle`},extensionArtifacts:{kind:`idle`}};case`extension-start-probe`:return{...e,extension:e.extension.kind===`ok`?e.extension:{kind:`loading`}};case`extension-artifacts-start-probe`:return{...e,extensionArtifacts:e.extensionArtifacts.kind===`ok`?e.extensionArtifacts:{kind:`loading`}}}}function da(e){let[t,n]=(0,Q.useReducer)(ua,la),{playwright:r,cloak:i,extension:a,extensionArtifacts:s}=t,c=(0,Q.useCallback)(async()=>{n({type:`playwright`,state:{kind:`loading`}});try{n({type:`playwright`,state:{kind:`ok`,data:await sa(o(`/api/browser/playwright/doctor`))}})}catch(e){n({type:`playwright`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}})}},[]),l=(0,Q.useCallback)(async t=>{n({type:`cloak`,state:{kind:`loading`}});let r=(t?.cacheDir??e.cacheDir??``).trim(),i=(t?.binaryPath??e.binaryPath??``).trim(),a=new URLSearchParams;r&&a.set(`cacheDir`,r),i&&a.set(`binaryPath`,i);try{let e=await sa(o(`/api/browser/cloakbrowser/doctor${a.size?`?${a}`:``}`));return n({type:`cloak`,state:{kind:`ok`,data:e}}),e}catch(e){return n({type:`cloak`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}}),null}},[e.binaryPath,e.cacheDir]),u=(0,Q.useCallback)(e=>{n({type:`playwright`,state:{kind:`ok`,data:e}})},[]),d=(0,Q.useCallback)(e=>{n({type:`cloak`,state:{kind:`ok`,data:e}})},[]),f=(0,Q.useCallback)(async()=>sa(o(`/api/browser/cloakbrowser/status`)),[]),p=(0,Q.useCallback)(async()=>ca(o(`/api/browser/cloakbrowser/launch`),{}),[]),m=e.browserEnabled===!0&&e.probeExtension===!0,h=e.browserEnabled===!0&&e.probeLocal===!0,g=e.browserEnabled===!0&&e.probeCloak===!0,{extensionHost:_,extensionPort:y}=e,b=(0,Q.useCallback)(async()=>{let e=new URLSearchParams({probe:`1`});_&&e.set(`host`,_),y!==void 0&&e.set(`port`,String(y)),n({type:`extension-start-probe`});try{let t=await v(o(`/api/browser/extension-status?${e}`),{signal:AbortSignal.timeout(3e3)}),r=await t.json().catch(()=>({}));if(!t.ok){n({type:`extension`,state:{kind:`error`,message:`HTTP ${t.status}`}});return}n({type:`extension`,state:{kind:`ok`,data:{running:r.running===!0,connected:r.connected===!0,backend:r.backend,artifacts:r.artifacts,bridgeHeld:r.bridgeHeld===!0,refCount:typeof r.refCount==`number`?r.refCount:void 0,manualBridge:r.manualBridge===!0,portConflict:r.portConflict===!0}}})}catch(e){n({type:`extension`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}})}},[_,y]),x=(0,Q.useCallback)(async()=>{n({type:`extension-artifacts-start-probe`});try{let e=await sa(o(`/api/browser/extension/doctor`));return n({type:`extension-artifacts`,state:{kind:`ok`,data:e}}),e}catch(e){return n({type:`extension-artifacts`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}}),null}},[]),S=(0,Q.useCallback)(async e=>{let t=(await ca(o(`/api/browser/extension/install`),{force:e?.force??!1})).doctor;return n({type:`extension-artifacts`,state:{kind:`ok`,data:t}}),await b(),t},[b]),C=(0,Q.useCallback)(async()=>{await ca(o(`/api/browser/extension/open`),{action:`chrome`})},[]),w=(0,Q.useCallback)(async()=>{await ca(o(`/api/browser/extension/open`),{action:`folder`})},[]);(0,Q.useEffect)(()=>{if(!h){n({type:`playwright-idle`});return}c()},[h,c]),(0,Q.useEffect)(()=>{if(!g){n({type:`cloak-idle`});return}l()},[g,l]);let T=(0,Q.useRef)(m);T.current!==m&&(T.current=m,m||n({type:`extension-idle`})),(0,Q.useEffect)(()=>{if(!m)return;b(),x();let e=setInterval(()=>void b(),5e3);return()=>clearInterval(e)},[m,b,x]);let E=(0,Q.useCallback)(async e=>{await ca(o(`/api/browser/extension/start`),{host:e?.host??_,port:e?.port??y}),await b()},[_,y,b]),D=(0,Q.useCallback)(async()=>{await ca(o(`/api/browser/extension/stop`),{}),await b()},[b]),O=(0,Q.useCallback)(async()=>{await ca(o(`/api/browser/extension/disconnect`),{}),await b()},[b]),k=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{if(!m||e.activeBackend!==`extension`){k.current=null;return}if(a.kind!==`ok`||a.data.running||a.data.bridgeHeld)return;let t=`${_}:${y??19820}`;k.current!==t&&(k.current=t,E({host:_,port:y}).catch(()=>{k.current=null}))},[m,a,_,y,e.activeBackend,E]),{playwright:r,cloak:i,extension:a,extensionArtifacts:s,refetchPlaywright:c,applyPlaywrightDoctor:u,refetchCloak:l,applyCloakDoctor:d,fetchCloakRuntimeStatus:f,launchCloak:p,refetchExtension:b,refetchExtensionArtifacts:x,installExtensionArtifacts:S,openExtensionChrome:C,revealExtensionFolder:w,pingCdp:(0,Q.useCallback)(async e=>ca(o(`/api/browser/cdp/ping`),{cdpUrl:e}),[]),testCloud:(0,Q.useCallback)(async(e,t)=>ca(o(`/api/browser/cloud/test-connection`),{provider:e,apiKey:t}),[]),launchCdp:(0,Q.useCallback)(async e=>ca(o(`/api/browser/cdp/launch`),{executablePath:e}),[]),stopCdp:(0,Q.useCallback)(async e=>{await ca(o(`/api/browser/cdp/stop`),{port:e})},[]),listCdpInstances:(0,Q.useCallback)(async()=>(await sa(o(`/api/browser/cdp/instances`))).instances,[]),startExtensionBridge:E,stopExtensionBridge:D,disconnectExtension:O}}var fa=`
219
219
 
220
220
  `,pa=/\r\n/g,ma={playwright:`/api/browser/playwright/install/stream`,cloakbrowser:`/api/browser/cloakbrowser/install/stream`},ha={playwright:`/api/browser/playwright/install/cancel`,cloakbrowser:`/api/browser/cloakbrowser/install/cancel`},ga=8;function _a(){return{phase:null,message:null,percent:null,lines:[]}}function va(e,t){let n={phase:t.phase,message:t.message??t.line??e.message,percent:t.percent??e.percent,lines:e.lines};if(t.line){let r=[...e.lines,t.line];n.lines=r.length>ga?r.slice(-8):r}return n}async function ya(e,t,n){let r=e.getReader(),i=new TextDecoder,a=``,o=null,s=e=>{let n=``,r=``;for(let t of e.split(`