@xopcai/xopc 0.0.339 → 0.0.340

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 (373) 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/outbound/media-load.js +1 -1
  4. package/dist/extensions/telegram/src/inbound-processor.js +2 -2
  5. package/dist/extensions/telegram/src/outbound-sender.js +1 -1
  6. package/dist/extensions/telegram/src/plugin.js +2 -2
  7. package/dist/extensions/telegram/xopc.extension.json +1 -1
  8. package/dist/extensions/weixin/src/api/api.js +2 -2
  9. package/dist/extensions/weixin/src/auth/accounts.js +12 -12
  10. package/dist/extensions/weixin/src/messaging/debug-mode.js +5 -5
  11. package/dist/extensions/weixin/src/messaging/inbound.js +11 -11
  12. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-Cc_FeKSx.js → agent-avatar-dicebear-CZsW4B_4.js} +1 -1
  13. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-C_56_X-e.js +1 -0
  14. package/dist/gateway/static/root/assets/{agent-plugin-dialog-DoC_yH9K.js → agent-plugin-dialog-DPil7wFb.js} +1 -1
  15. package/dist/gateway/static/root/assets/agents-DXcxDhxl.js +70 -0
  16. package/dist/gateway/static/root/assets/{agents-admin-api-C82B1W9Z.js → agents-admin-api-9hEICfl6.js} +1 -1
  17. package/dist/gateway/static/root/assets/{app-management-settings-panel-BquxFv-S.js → app-management-settings-panel-B6_Ocd3H.js} +1 -1
  18. package/dist/gateway/static/root/assets/{appearance-settings-CZYqmnu6.js → appearance-settings-CYk3wLnQ.js} +1 -1
  19. package/dist/gateway/static/root/assets/{apps-page-jIVrH3te.js → apps-page-DOteYBc9.js} +1 -1
  20. package/dist/gateway/static/root/assets/{archive-plugin-B0vUM0zp.js → archive-plugin-Cq8nfXI4.js} +1 -1
  21. package/dist/gateway/static/root/assets/{automations-page-B0Y5BNRb.js → automations-page-D3dSY_dy.js} +1 -1
  22. package/dist/gateway/static/root/assets/automations-workspace-DuULlur3.js +7 -0
  23. package/dist/gateway/static/root/assets/{binary-plugins-NBJu1CLg.js → binary-plugins-BKqt6Et6.js} +1 -1
  24. package/dist/gateway/static/root/assets/{block-editor-TXHouZOO.js → block-editor-H3ijAjys.js} +3 -3
  25. package/dist/gateway/static/root/assets/{browser-automation-inputs-CLOq1KtH.js → browser-automation-inputs-cnvnVaXG.js} +1 -1
  26. package/dist/gateway/static/root/assets/{browser-automations-page-BqMknmu3.js → browser-automations-page-CjIhwapc.js} +2 -2
  27. package/dist/gateway/static/root/assets/{browser-settings-page-GRFXQqKe.js → browser-settings-page-DvMsxdHZ.js} +2 -2
  28. package/dist/gateway/static/root/assets/{capabilities-BfHgt4uk.js → capabilities-CE5NAPxj.js} +1 -1
  29. package/dist/gateway/static/root/assets/{capabilities-page-DmJDCbYN.js → capabilities-page-CM55DJos.js} +2 -2
  30. package/dist/gateway/static/root/assets/capabilities-settings-panel-3kh-Ox8d.js +8 -0
  31. package/dist/gateway/static/root/assets/{capability-header-actions-BF9_u3xd.js → capability-header-actions-DRdadVwO.js} +1 -1
  32. package/dist/gateway/static/root/assets/{channels-BG-1mvQi.js → channels-BU6w4j04.js} +1 -1
  33. package/dist/gateway/static/root/assets/{chat-terminal-dock-DYysZFAt.js → chat-terminal-dock-bMULpQTT.js} +1 -1
  34. package/dist/gateway/static/root/assets/{computer-settings-page-DI3Ek853.js → computer-settings-page-T4wZrdXv.js} +1 -1
  35. package/dist/gateway/static/root/assets/{connector-service-page-BWkcwg_D.js → connector-service-page-f6kDBxXv.js} +1 -1
  36. package/dist/gateway/static/root/assets/connectors-page-BZ2oIRzn.js +2 -0
  37. package/dist/gateway/static/root/assets/{date-picker-Di84qsYg.js → date-picker-BxODmHib.js} +1 -1
  38. package/dist/gateway/static/root/assets/{dependency-picker-BfxDCpmT.js → dependency-picker-BNPg7CKM.js} +1 -1
  39. package/dist/gateway/static/root/assets/{desktop-pet-BRTL_oOb.js → desktop-pet-I6v0yXqp.js} +1 -1
  40. package/dist/gateway/static/root/assets/{desktop-pet-settings-BNVH1m1M.js → desktop-pet-settings-tSuk-nRY.js} +1 -1
  41. package/dist/gateway/static/root/assets/device-pairing-wizard-Dka3NDC5.js +1 -0
  42. package/dist/gateway/static/root/assets/{directory-picker-path-field-BpuRd-vD.js → directory-picker-path-field-BvrnQNVH.js} +1 -1
  43. package/dist/gateway/static/root/assets/{extension-debug-page-mQPbBDJQ.js → extension-debug-page-BU56INhZ.js} +1 -1
  44. package/dist/gateway/static/root/assets/{extension-page-BHSB_YFM.js → extension-page-DQu5R6aV.js} +1 -1
  45. package/dist/gateway/static/root/assets/{extension-settings-page-IoBTZ9jq.js → extension-settings-page-oL7xkRyC.js} +1 -1
  46. package/dist/gateway/static/root/assets/{gateway-config-swr-Hn1vj6uI.js → gateway-config-swr-BdBCP9uF.js} +1 -1
  47. package/dist/gateway/static/root/assets/{gateway-realtime-vOLum3RR.js → gateway-realtime-MiR9DJIf.js} +1 -1
  48. package/dist/gateway/static/root/assets/gateway-realtime-store-Cj-byMay.js +1 -0
  49. package/dist/gateway/static/root/assets/gateway-settings-Kp84CfNh.js +1 -0
  50. package/dist/gateway/static/root/assets/{gateway-startup-retry-CtTVgB7_.js → gateway-startup-retry-B8XTENLw.js} +1 -1
  51. package/dist/gateway/static/root/assets/home-page-CtjDNSNA.js +1 -0
  52. package/dist/gateway/static/root/assets/{image-generation-api-DBA-bdEM.js → image-generation-api-DufKsb8h.js} +1 -1
  53. package/dist/gateway/static/root/assets/{imports-page-DLJp26Cn.js → imports-page-CKj_w0ri.js} +1 -1
  54. package/dist/gateway/static/root/assets/{index-CdvabjRm.js → index-b_BtpHlo.js} +20 -20
  55. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-YnkILLU1.js → keyboard-shortcuts-settings-BUqFy1Mk.js} +1 -1
  56. package/dist/gateway/static/root/assets/{local-app-workbench-page-C4d2T20s.js → local-app-workbench-page-Uo5UKdF8.js} +1 -1
  57. package/dist/gateway/static/root/assets/{local-apps-page-DfOhJ8iP.js → local-apps-page-DoxtxoTl.js} +1 -1
  58. package/dist/gateway/static/root/assets/{local-session-drafts-Byxxogdc.js → local-session-drafts-Bwxng2U0.js} +1 -1
  59. package/dist/gateway/static/root/assets/{locale-store-7F4l6DRV.js → locale-store-GbEE8D1I.js} +1 -1
  60. package/dist/gateway/static/root/assets/{logs-page-Ds6pm2I7.js → logs-page-NHrVWElJ.js} +2 -2
  61. package/dist/gateway/static/root/assets/{management-settings-D0kBRnl2.js → management-settings-BDnKvfCl.js} +1 -1
  62. package/dist/gateway/static/root/assets/{markdown-view-bxpOryax.js → markdown-view-DtEVIWB3.js} +1 -1
  63. package/dist/gateway/static/root/assets/{media-plugins-vBKV9GvC.js → media-plugins-Gt-PA4Fe.js} +1 -1
  64. package/dist/gateway/static/root/assets/{messages-DsUnS7rn.js → messages-DvcSrOiI.js} +2 -2
  65. package/dist/gateway/static/root/assets/note-detail-panel-ddFcoIGv.js +5 -0
  66. package/dist/gateway/static/root/assets/notes-page-DHY9KaXz.js +8 -0
  67. package/dist/gateway/static/root/assets/{page-context-capture-button-DvMerCk-.js → page-context-capture-button-CZ-NyERX.js} +1 -1
  68. package/dist/gateway/static/root/assets/{page-tabs-Bp0yPTYw.js → page-tabs-7u-lmA1o.js} +1 -1
  69. package/dist/gateway/static/root/assets/{preview-open-alternatives-CQO4X4dH.js → preview-open-alternatives-Bolgk7cf.js} +1 -1
  70. package/dist/gateway/static/root/assets/{product-open-page-BQ4vLqay.js → product-open-page-CJEViLcx.js} +1 -1
  71. package/dist/gateway/static/root/assets/project-detail-page-BcikJ4wu.js +1 -0
  72. package/dist/gateway/static/root/assets/{projects-page-EvaT-KoY.js → projects-page-DFZXCRc2.js} +1 -1
  73. package/dist/gateway/static/root/assets/{registry-api-DU915Prn.js → registry-api-DTHBAr2T.js} +1 -1
  74. package/dist/gateway/static/root/assets/remote-access-hub-Dr2FLBo-.js +1 -0
  75. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-POD_UkI6.js → runtime-tools-settings-panel-BKus_7qQ.js} +1 -1
  76. package/dist/gateway/static/root/assets/scenes-page-Sp5hozOY.js +2 -0
  77. package/dist/gateway/static/root/assets/{schema-form-DDjuoH6S.js → schema-form-DvkI2pYT.js} +1 -1
  78. package/dist/gateway/static/root/assets/{session-api-C7i3UFhq.js → session-api-Bb2zLVED.js} +1 -1
  79. package/dist/gateway/static/root/assets/{session-manager-g96pFnRm.js → session-manager-9M-yBtb4.js} +1 -1
  80. package/dist/gateway/static/root/assets/sessions-page-Cm4j_l7t.js +1 -0
  81. package/dist/gateway/static/root/assets/settings-advanced-gate-CpD6cRcO.js +1 -0
  82. package/dist/gateway/static/root/assets/{settings-form-section-DziWi7ar.js → settings-form-section-BzC6oYCR.js} +1 -1
  83. package/dist/gateway/static/root/assets/{settings-page-DieZ7WKk.js → settings-page-DpEe6N0D.js} +1 -1
  84. package/dist/gateway/static/root/assets/setup-status-panel-CfuLya7v.js +1 -0
  85. package/dist/gateway/static/root/assets/{share-preview-page-CKuGdvQ1.js → share-preview-page-DAE82vq9.js} +1 -1
  86. package/dist/gateway/static/root/assets/shares-settings-Bqkvdt3m.js +1 -0
  87. package/dist/gateway/static/root/assets/{skill-api-CEaxaT32.js → skill-api-DkZFVXn8.js} +1 -1
  88. package/dist/gateway/static/root/assets/skill-reload-api-rA2myUNh.js +1 -0
  89. package/dist/gateway/static/root/assets/{skills-page-C4z5rpJp.js → skills-page-CrTKXe6r.js} +1 -1
  90. package/dist/gateway/static/root/assets/{system-settings-panel-DqFk7NdF.js → system-settings-panel-BWVB47be.js} +1 -1
  91. package/dist/gateway/static/root/assets/{task-detail-page-BIA_56uP.js → task-detail-page-DcsgbSjp.js} +1 -1
  92. package/dist/gateway/static/root/assets/{tunnel-api-mpYTR5df.js → tunnel-api-D1I9v9nz.js} +1 -1
  93. package/dist/gateway/static/root/assets/{usage-page-CBew7QUj.js → usage-page-DyKTK2iS.js} +1 -1
  94. package/dist/gateway/static/root/assets/{use-autosave-CujxcROb.js → use-autosave-G5bltEoh.js} +1 -1
  95. package/dist/gateway/static/root/assets/user-model-page-7tObyrXy.js +2 -0
  96. package/dist/gateway/static/root/assets/{voice-api-key-field-BAewnwoh.js → voice-api-key-field-C2Q5SXkb.js} +1 -1
  97. package/dist/gateway/static/root/assets/{voice-config-api-LKFent6f.js → voice-config-api-DIBe0AZN.js} +1 -1
  98. package/dist/gateway/static/root/assets/{work-discovery-overlay-Bgtzc3ng.js → work-discovery-overlay-J-w4XEEK.js} +1 -1
  99. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-ONIY4un8.js → workflow-run-setup-panel-CmZCSCBe.js} +2 -2
  100. package/dist/gateway/static/root/assets/workflows-page-DcXyKH2p.js +6 -0
  101. package/dist/gateway/static/root/index.html +14 -14
  102. package/dist/package.js +1 -1
  103. package/dist/src/agent/agent-manager.js +13 -13
  104. package/dist/src/agent/agent-scope.js +2 -2
  105. package/dist/src/agent/background-review/prompts.js +1 -1
  106. package/dist/src/agent/background-review/run-background-review.js +3 -3
  107. package/dist/src/agent/coding/repository-instructions.js +1 -1
  108. package/dist/src/agent/context/coordinator.js +2 -2
  109. package/dist/src/agent/context/execution-context.js +4 -4
  110. package/dist/src/agent/context/execution-scope.js +2 -2
  111. package/dist/src/agent/context/project-context.js +3 -3
  112. package/dist/src/agent/data-acquisition/service.js +1 -1
  113. package/dist/src/agent/embedded/index.js +2 -2
  114. package/dist/src/agent/embedded/model-runtime.js +1 -1
  115. package/dist/src/agent/embedded/run-for-session.js +4 -4
  116. package/dist/src/agent/embedded/run-turn.js +4 -4
  117. package/dist/src/agent/embedded/session-tool-result-guard.js +3 -3
  118. package/dist/src/agent/embedded/tool-result-truncation.js +1 -1
  119. package/dist/src/agent/external-tools/cliProvider.js +3 -3
  120. package/dist/src/agent/external-tools/composio-provider.js +3 -3
  121. package/dist/src/agent/external-tools/gateway-tools.js +1 -1
  122. package/dist/src/agent/external-tools/mcp-provider.js +3 -3
  123. package/dist/src/agent/image/generation/openai-images-provider.js +1 -1
  124. package/dist/src/agent/image/generation/providers/dashscope.js +1 -1
  125. package/dist/src/agent/image/generation/providers/fal.js +1 -1
  126. package/dist/src/agent/image/generation/providers/google.js +1 -1
  127. package/dist/src/agent/image/generation/runtime.js +1 -1
  128. package/dist/src/agent/image/index.js +1 -1
  129. package/dist/src/agent/image/load-image-media.js +1 -1
  130. package/dist/src/agent/image/tool-model-config.js +1 -1
  131. package/dist/src/agent/inbound/attachment-pipeline.js +1 -1
  132. package/dist/src/agent/inbound/inbound-loop.js +2 -2
  133. package/dist/src/agent/index.js +1 -1
  134. package/dist/src/agent/mcp/bundle-mcp-config.js +1 -1
  135. package/dist/src/agent/mcp/bundle-mcp-gateway.js +1 -1
  136. package/dist/src/agent/mcp/bundle-mcp-runtime.js +2 -2
  137. package/dist/src/agent/mcp/index.js +2 -2
  138. package/dist/src/agent/mcp/mcp-transport.js +1 -1
  139. package/dist/src/agent/mcp/oauth/mcp-oauth-manager.js +1 -1
  140. package/dist/src/agent/mcp/plugin-http-fetch.js +1 -1
  141. package/dist/src/agent/memory/context-recovery.js +1 -1
  142. package/dist/src/agent/memory/index.js +1 -1
  143. package/dist/src/agent/messaging/outbound-coordinator.js +1 -1
  144. package/dist/src/agent/orchestration/agent-orchestrator.js +1 -1
  145. package/dist/src/agent/prompt/service-prompt-builder.js +2 -2
  146. package/dist/src/agent/sandbox/exec-policy.js +1 -1
  147. package/dist/src/agent/service/direct-turn-helpers.js +4 -4
  148. package/dist/src/agent/service/process-direct-one-shot.js +1 -1
  149. package/dist/src/agent/service/process-direct-streaming.js +5 -5
  150. package/dist/src/agent/service/webchat-tts.js +2 -2
  151. package/dist/src/agent/service.js +19 -19
  152. package/dist/src/agent/session/session-inspector.js +1 -1
  153. package/dist/src/agent/source-context/index.js +2 -2
  154. package/dist/src/agent/tasks/task-judge-service.js +4 -4
  155. package/dist/src/agent/tools/create-share-tool.js +3 -3
  156. package/dist/src/agent/tools/dataBatch.js +1 -1
  157. package/dist/src/agent/tools/delegate-tool.js +3 -3
  158. package/dist/src/agent/tools/delegation-parent-policy.js +1 -1
  159. package/dist/src/agent/tools/executor.js +1 -1
  160. package/dist/src/agent/tools/factory.js +16 -16
  161. package/dist/src/agent/tools/fetch-text.js +1 -1
  162. package/dist/src/agent/tools/image-generate-tool.js +3 -3
  163. package/dist/src/agent/tools/index.js +6 -6
  164. package/dist/src/agent/tools/list-dir.js +1 -1
  165. package/dist/src/agent/tools/publish-artifacts.js +2 -2
  166. package/dist/src/agent/tools/read.js +2 -2
  167. package/dist/src/agent/tools/review-workspace.js +1 -1
  168. package/dist/src/agent/tools/send-media.js +2 -2
  169. package/dist/src/agent/tools/skills-tools.js +1 -1
  170. package/dist/src/agent/tools/tts-tool.js +1 -1
  171. package/dist/src/agent/tools/user-context-tool.js +1 -1
  172. package/dist/src/agent/tools/write.js +2 -2
  173. package/dist/src/agent/workflow/subagent-runner.js +1 -1
  174. package/dist/src/ai-assist/text-assist.js +1 -1
  175. package/dist/src/auth/credentials.js +1 -1
  176. package/dist/src/auth/sync-provider-auth.js +1 -1
  177. package/dist/src/automations/domain/index.js +2 -2
  178. package/dist/src/automations/index.js +4 -4
  179. package/dist/src/automations/service/automation-service.js +2 -2
  180. package/dist/src/browser/native-messaging-host.js +1 -1
  181. package/dist/src/channels/attachments/voice-stt-webchat.js +2 -2
  182. package/dist/src/channels/index.js +2 -2
  183. package/dist/src/channels/outbound-sender.js +1 -1
  184. package/dist/src/channels/pairing/allow-from-file.js +9 -9
  185. package/dist/src/channels/pairing/pairing-store.js +6 -6
  186. package/dist/src/chat-commands/builtins/config.js +3 -3
  187. package/dist/src/chat-commands/builtins/review.js +1 -1
  188. package/dist/src/chat-commands/builtins/session.js +1 -1
  189. package/dist/src/chat-commands/builtins/thinking.js +1 -1
  190. package/dist/src/chat-commands/builtins/tts.js +1 -1
  191. package/dist/src/chat-commands/builtins/understanding.js +1 -1
  192. package/dist/src/chat-commands/builtins/workflow.js +2 -2
  193. package/dist/src/chat-commands/context.js +3 -3
  194. package/dist/src/chat-commands/index.js +3 -3
  195. package/dist/src/cli/commands/agent.js +6 -6
  196. package/dist/src/cli/commands/config.js +1 -1
  197. package/dist/src/cli/commands/connectors.js +1 -1
  198. package/dist/src/cli/commands/doctor/checks/channel-plugins.js +1 -1
  199. package/dist/src/cli/commands/doctor/checks/gateway-health.js +1 -1
  200. package/dist/src/cli/commands/doctor/checks/provider-auth.js +2 -2
  201. package/dist/src/cli/commands/doctor/checks/tool-runtimes.js +1 -1
  202. package/dist/src/cli/commands/extension-agent-plugin.js +2 -2
  203. package/dist/src/cli/commands/extension-dev.js +1 -1
  204. package/dist/src/cli/commands/extension-marketplace.js +2 -2
  205. package/dist/src/cli/commands/extension.js +4 -4
  206. package/dist/src/cli/commands/gateway/shared.js +1 -1
  207. package/dist/src/cli/commands/gateway/token.js +1 -1
  208. package/dist/src/cli/commands/image.js +1 -1
  209. package/dist/src/cli/commands/init.js +1 -1
  210. package/dist/src/cli/commands/onboard/channels/registry.js +1 -1
  211. package/dist/src/cli/commands/onboard.js +1 -1
  212. package/dist/src/cli/commands/project.js +2 -2
  213. package/dist/src/cli/commands/runtime.js +1 -1
  214. package/dist/src/cli/commands/skills.js +2 -2
  215. package/dist/src/cli/commands/tunnel.js +4 -4
  216. package/dist/src/cli/extension-cli-register.js +4 -4
  217. package/dist/src/cli/utils/gateway-client.js +1 -1
  218. package/dist/src/cli/utils/init-workspace-core.js +1 -1
  219. package/dist/src/cli/utils/session.js +1 -1
  220. package/dist/src/computer/runtime.js +2 -2
  221. package/dist/src/config/index.js +4 -4
  222. package/dist/src/config/loader.js +1 -1
  223. package/dist/src/connectors/cli/authorization.js +1 -1
  224. package/dist/src/connectors/cli/runtime.js +1 -1
  225. package/dist/src/connectors/composio-sessions.js +1 -1
  226. package/dist/src/connectors/composio.js +1 -1
  227. package/dist/src/connectors/connected-source-understanding.js +3 -3
  228. package/dist/src/connectors/connection-recovery-service.js +5 -5
  229. package/dist/src/connectors/health.js +1 -1
  230. package/dist/src/connectors/plugin-mcp-recovery.js +1 -1
  231. package/dist/src/discussions/live-worker.js +1 -1
  232. package/dist/src/discussions/recording.js +1 -1
  233. package/dist/src/discussions/sealer.js +1 -1
  234. package/dist/src/extensions/activation-context.js +3 -3
  235. package/dist/src/extensions/api.js +4 -4
  236. package/dist/src/extensions/bundled-extension-activation.js +1 -1
  237. package/dist/src/extensions/index.js +3 -3
  238. package/dist/src/extensions/install.js +1 -1
  239. package/dist/src/extensions/loader.js +2 -2
  240. package/dist/src/extensions/sdk/index.js +1 -1
  241. package/dist/src/extensions/sdk/media.js +1 -1
  242. package/dist/src/extensions/update.js +1 -1
  243. package/dist/src/gateway/agents-admin.js +1 -1
  244. package/dist/src/gateway/device-routes.js +2 -2
  245. package/dist/src/gateway/file-path-classifier.js +1 -1
  246. package/dist/src/gateway/global-defaults-admin.js +1 -1
  247. package/dist/src/gateway/hono/app.js +3 -3
  248. package/dist/src/gateway/hono/lib/config-payload.js +3 -3
  249. package/dist/src/gateway/hono/routes/agents.js +1 -1
  250. package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
  251. package/dist/src/gateway/hono/routes/browser.js +1 -1
  252. package/dist/src/gateway/hono/routes/commands-skills.js +4 -4
  253. package/dist/src/gateway/hono/routes/config-patch/gateway.js +1 -1
  254. package/dist/src/gateway/hono/routes/home.js +1 -1
  255. package/dist/src/gateway/hono/routes/mcp.js +2 -2
  256. package/dist/src/gateway/hono/routes/media.js +1 -1
  257. package/dist/src/gateway/hono/routes/models.js +5 -5
  258. package/dist/src/gateway/hono/routes/notes.js +1 -1
  259. package/dist/src/gateway/hono/routes/projects.js +2 -2
  260. package/dist/src/gateway/hono/routes/session-command-handler.js +1 -1
  261. package/dist/src/gateway/hono/routes/session-input-handler.js +2 -2
  262. package/dist/src/gateway/hono/routes/sessions.js +1 -1
  263. package/dist/src/gateway/hono/routes/shares.js +3 -3
  264. package/dist/src/gateway/hono/routes/site-shares.js +1 -1
  265. package/dist/src/gateway/hono/routes/user-model-refresh.js +1 -1
  266. package/dist/src/gateway/hono/routes/user-model.js +5 -5
  267. package/dist/src/gateway/hono/routes/voice.js +6 -6
  268. package/dist/src/gateway/hono/routes/workflows.js +2 -2
  269. package/dist/src/gateway/image-generation-setup.js +1 -1
  270. package/dist/src/gateway/index.js +1 -1
  271. package/dist/src/gateway/lock.js +11 -11
  272. package/dist/src/gateway/media-access.js +1 -1
  273. package/dist/src/gateway/mobile-privacy.js +2 -2
  274. package/dist/src/gateway/ports.js +6 -6
  275. package/dist/src/gateway/run-loop.js +1 -1
  276. package/dist/src/gateway/scenes/mailContext.js +1 -1
  277. package/dist/src/gateway/scenes/slackThreadSource.js +1 -1
  278. package/dist/src/gateway/server.js +1 -1
  279. package/dist/src/gateway/service/config-coordinator.js +3 -3
  280. package/dist/src/gateway/service/run-gateway-agent.js +3 -3
  281. package/dist/src/gateway/service/session-input-coordinator.js +2 -2
  282. package/dist/src/gateway/service/sessions-api.js +1 -1
  283. package/dist/src/gateway/service.js +35 -35
  284. package/dist/src/gateway/session-context-summary.js +1 -1
  285. package/dist/src/gateway/workspace-editor-path.js +2 -2
  286. package/dist/src/home-intelligence/generator.js +1 -1
  287. package/dist/src/infra/gateway-processes.js +2 -2
  288. package/dist/src/infra/path-env.js +3 -3
  289. package/dist/src/infra/update-global.js +10 -10
  290. package/dist/src/local-apps/service.js +1 -1
  291. package/dist/src/mcp/gateway-http-client.js +1 -1
  292. package/dist/src/media-understanding/openai-compatible-audio.js +1 -1
  293. package/dist/src/notes/agent-context.js +4 -4
  294. package/dist/src/notes/index.js +1 -1
  295. package/dist/src/notes/service.js +1 -1
  296. package/dist/src/notes/store.js +1 -1
  297. package/dist/src/providers/auth-runtime/resolve-auth.js +1 -1
  298. package/dist/src/providers/index.js +2 -2
  299. package/dist/src/providers/model-reference-auditor.js +1 -1
  300. package/dist/src/providers/register-runtime-providers.js +1 -1
  301. package/dist/src/remote-access/exposure-manager.js +1 -1
  302. package/dist/src/scenes/taskFollowUp/agentExecutor.js +4 -4
  303. package/dist/src/scenes/taskFollowUp/resources.js +1 -1
  304. package/dist/src/scenes/taskFollowUp/service.js +4 -4
  305. package/dist/src/session/index.js +2 -2
  306. package/dist/src/session/session-title.js +1 -1
  307. package/dist/src/session/store.js +4 -4
  308. package/dist/src/session/thinking-resolve.js +1 -1
  309. package/dist/src/share/share-store.js +1 -1
  310. package/dist/src/share/share-thumbnail.js +1 -1
  311. package/dist/src/share/site-proxy.js +1 -1
  312. package/dist/src/share/site-share-store.js +1 -1
  313. package/dist/src/storage/sqlite/connection.js +9 -9
  314. package/dist/src/tasks/capabilities/read.js +2 -2
  315. package/dist/src/tasks/capabilities/write.js +1 -1
  316. package/dist/src/tasks/execution-context.js +1 -1
  317. package/dist/src/tasks/home-query-service.js +3 -3
  318. package/dist/src/tasks/index.js +4 -4
  319. package/dist/src/tasks/task-application-service.js +1 -1
  320. package/dist/src/tasks/task-context-assembler.js +1 -1
  321. package/dist/src/tasks/task-handoff-service.js +1 -1
  322. package/dist/src/tui/backends/embedded-backend.js +9 -9
  323. package/dist/src/tui/backends/gateway-realtime-backend.js +1 -1
  324. package/dist/src/tui/extension-host/load-extensions.js +1 -1
  325. package/dist/src/tui/tui-command-formatters.js +1 -1
  326. package/dist/src/tui/tui-commands.js +5 -5
  327. package/dist/src/tui/tui-picker-overlay.js +1 -1
  328. package/dist/src/tui/tui-skills-autocomplete.js +1 -1
  329. package/dist/src/tui/tui-startup-resources.js +4 -4
  330. package/dist/src/tui/tui.js +6 -6
  331. package/dist/src/tunnel/gateway-lifecycle.js +1 -1
  332. package/dist/src/voice/realtime/memory-context.js +3 -3
  333. package/dist/src/voice/realtime/runtime.js +3 -3
  334. package/dist/src/voice/stt/index.js +2 -2
  335. package/dist/src/voice/stt/preflight.js +1 -1
  336. package/dist/src/voice/stt/providers/alibaba-transcription.js +1 -1
  337. package/dist/src/voice/stt/providers/xopc-cloud-transcription.js +1 -1
  338. package/dist/src/voice/stt/transcribe-core.js +1 -1
  339. package/dist/src/voice/tts/index.js +3 -3
  340. package/dist/src/voice/tts/merge-config.js +1 -1
  341. package/dist/src/voice/tts/payload.js +1 -1
  342. package/dist/src/voice/tts/providers/xopc-cloud-speech.js +1 -1
  343. package/dist/src/voice/tts/speak-core.js +1 -1
  344. package/dist/src/work-discovery/incremental-repository.js +1 -1
  345. package/dist/src/work-discovery/index.js +1 -1
  346. package/dist/src/work-discovery/service.js +5 -5
  347. package/dist/src/workflows/engine/workflow-engine.js +1 -1
  348. package/dist/src/workflows/service/workflow-run-service.js +8 -8
  349. package/dist/src/workflows/service/workflow-session-bridge.js +1 -1
  350. package/package.json +3 -3
  351. package/skills/THIRD_PARTY_NOTICES.md +6 -0
  352. package/skills/engineering/design-recurring-work/SKILL.md +75 -0
  353. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-s5yXNGQE.js +0 -1
  354. package/dist/gateway/static/root/assets/agents-HRZFsjeH.js +0 -70
  355. package/dist/gateway/static/root/assets/automations-workspace-8OSlJ6lL.js +0 -7
  356. package/dist/gateway/static/root/assets/capabilities-settings-panel-D8kedO-n.js +0 -8
  357. package/dist/gateway/static/root/assets/connectors-page-DBTyibaI.js +0 -2
  358. package/dist/gateway/static/root/assets/device-pairing-wizard-C3S9vWJ1.js +0 -1
  359. package/dist/gateway/static/root/assets/gateway-realtime-store-DytaaEu8.js +0 -1
  360. package/dist/gateway/static/root/assets/gateway-settings-9HNthvnR.js +0 -1
  361. package/dist/gateway/static/root/assets/home-page-B_NubC1h.js +0 -1
  362. package/dist/gateway/static/root/assets/note-detail-panel-CSdLXt8V.js +0 -5
  363. package/dist/gateway/static/root/assets/notes-page-CIQEybLR.js +0 -8
  364. package/dist/gateway/static/root/assets/project-detail-page-DGRQilZq.js +0 -1
  365. package/dist/gateway/static/root/assets/remote-access-hub-D6EmYuZ9.js +0 -1
  366. package/dist/gateway/static/root/assets/scenes-page-gpgblOWJ.js +0 -2
  367. package/dist/gateway/static/root/assets/sessions-page-D7QQpt4W.js +0 -1
  368. package/dist/gateway/static/root/assets/settings-advanced-gate-CPyqCG90.js +0 -1
  369. package/dist/gateway/static/root/assets/setup-status-panel-aGTS3JX2.js +0 -1
  370. package/dist/gateway/static/root/assets/shares-settings-B2oqZsDF.js +0 -1
  371. package/dist/gateway/static/root/assets/skill-reload-api-BAzfIHkQ.js +0 -1
  372. package/dist/gateway/static/root/assets/user-model-page-DhMojGHW.js +0 -2
  373. package/dist/gateway/static/root/assets/workflows-page-DcVuZjq_.js +0 -6
@@ -1,2 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,i as n,n as r,t as i}from"./vendor-react-BOUWij0V.js";import{c as a,d as o,f as s,g as c,l,m as u,t as d,u as f}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{n as p,r as m,t as h}from"./popover-select-0p9PIHRy.js";import{t as g}from"./x-B_N4OPjy.js";import{a as _,c as v,n as y,r as b}from"./locale-store-7F4l6DRV.js";import{a as x,i as S,n as C,o as w,r as T,s as E,t as D}from"./dist-BGTk37IG.js";import{a as O,i as k,n as A}from"./vendor-swr-BIWyz7Rc.js";import{t as j}from"./button-CS04eWY9.js";import{a as M}from"./gateway-realtime-vOLum3RR.js";import{t as N}from"./skeleton-BwbyijEw.js";import{Au as P,Hc as F,Ic as I,Ka as ee,Oc as L,Ru as te,Zt as ne,_o as R,ed as z,nn as B,xa as V,zl as re}from"./index-CdvabjRm.js";import{t as ie}from"./page-context-capture-button-DvMerCk-.js";var H=e(t(),1),U=r(),W=e=>_(b(`/api/scenes${e}`)),G=(e,t,n,r)=>_(b(`/api/scenes${e}`),{method:t,body:n===void 0?void 0:JSON.stringify(n),headers:{"Idempotency-Key":r??crypto.randomUUID()}});function K(e,t){let n=e?.status;return n===401?t?`登录已失效,请重新登录后查看智能关注。`:`Your session expired. Sign in again to view monitors.`:n===503?t?`智能关注服务暂不可用,请检查服务状态后重试。`:`The monitor service is unavailable. Check the Gateway and retry.`:n===409?t?`内容已被更新,请刷新后重新确认。`:`This content changed. Refresh and review it before trying again.`:(e?.body?.missing)?.some(e=>e.startsWith(`model_`))?t?`请先在模型设置中选择可用模型并配置凭据,然后重试。`:`Choose an available model and configure its credentials in model settings, then retry.`:n===422?t?`设置或授权不完整,请检查数据来源和范围。`:`Setup or permission is incomplete. Check the source and scope.`:n===404?t?`找不到这项关注或结果,请返回智能关注列表。`:`Monitor or result not found. Return to the monitors list.`:t?`操作未完成,请检查连接后重试。你的输入仍保留在当前页面。`:`Could not finish. Check your connection and retry. Your input is still on this page.`}var q=i();function ae(e){let t=(0,U.c)(39),{activationId:n,zh:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={refreshInterval:15e3},t[0]=i):i=t[0];let a=k(`/diagnostics`,W,i),o,s,c,l,u,f,p,m,h,g,_;if(t[1]!==n||t[2]!==a.data||t[3]!==r){c=Symbol.for(`react.early_return_sentinel`);bb0:{let e=a.data?.activations.find(e=>e.id===n);if(!e){c=null;break bb0}let i;t[15]===r?i=t[16]:(i=e=>e==null?r?`未设置`:`Not scheduled`:new Date(e).toLocaleString(r?`zh-CN`:`en`),t[15]=r,t[16]=i);let v=i,y;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(y={needs_permission:[`邮件授权已失效,请重新连接账号。`,`Mail permission expired. Reconnect the account.`],source_rate_limited:[`邮件服务暂时限流,将自动重试。`,`Mail service rate limited. A retry is scheduled.`],source_timeout:[`读取邮件超时,将自动重试。`,`Mail read timed out. A retry is scheduled.`],unchanged_result:[`资料未变化,已保留原成果和反馈。`,`Context unchanged. The existing result and feedback were preserved.`],source_not_ready:[`来源暂不可用,请检查连接授权;稍后会重试。`,`Source unavailable. Check connection access; a retry is scheduled.`],daily_budget:[`已达每日模型调用上限,将在预算恢复后继续。`,`Daily model limit reached. Checks resume after the budget resets.`],execution_failed:[`检查失败,请检查模型凭据和服务连接,再点“现在检查”。`,`Check failed. Verify model credentials and connectivity, then check again.`],invalid_model_result:[`模型返回的格式不符合这项关注的要求,结果未发布;请重试或更换模型。`,`The model returned an unsupported result for this monitor. Nothing was published; retry or choose another model.`],empty_input:[`请先填写安排和约束。`,`Provide arrangements and constraints first.`],source_changed:[`来源已变化,旧草稿未发布;可重新检查。`,`Source changed. The stale draft was withheld; check again.`],execution_aborted:[`检查已中断,可在服务恢复后重新检查。`,`Check interrupted. Retry after the service resumes.`]},t[17]=y):y=t[17];let b=y,x=[e.next_schedule_at,e.next_deadline_check_at,e.retry_at].filter(oe),S=e.source_reason??e.last_reason;l=`space-y-2 rounded-xl border border-edge p-4 text-sm text-fg-muted`,u=(0,q.jsxs)(`p`,{children:[r?`最近发起检查`:`Last check started`,`: `,e.last_check_at==null?r?`尚未检查`:`Not checked yet`:v(e.last_check_at)]});let C=r?`下次定时检查`:`Next scheduled check`,w=e.status!==`active`||a.data?.checksPaused?r?`当前不会自动检查`:`Automatic checks inactive`:x.length?`${Math.min(...x)<=Date.now()?r?`等待执行,原定 `:`Pending, scheduled for `:``}${v(Math.min(...x))}`:r?`暂无待执行检查`:`No check scheduled`;t[18]!==C||t[19]!==w?(f=(0,q.jsxs)(`p`,{children:[C,`: `,w]}),t[18]=C,t[19]=w,t[20]=f):f=t[20],p=e.deadline_at!=null&&(0,q.jsxs)(`p`,{children:[r?`邮件跟进截止时间`:`Mail follow-up deadline`,`: `,v(e.deadline_at)]}),m=e.source_reason&&e.source_attempt_at!=null&&(0,q.jsxs)(`p`,{children:[r?`最近尝试读取邮件`:`Last mail read attempt`,`: `,v(e.source_attempt_at),` · `,r?`连续失败`:`Consecutive failures`,`: `,e.source_failures]}),h=e.source_reason&&(0,q.jsx)(d,{to:`/capabilities/connectors`,className:`inline-block text-accent underline`,children:r?`检查连接授权`:`Check connection access`}),g=e.source_success_at!=null&&(0,q.jsxs)(`p`,{children:[r?`最近成功读取邮件`:`Last successful mail read`,`: `,v(e.source_success_at)]}),_=S&&b[S]&&(0,q.jsx)(`p`,{role:`status`,children:b[S][+!r]});let T=r?`当前关注使用的模型`:`Current monitor model`,E=a.data.currentModel??(r?`配置不可用`:`Configuration unavailable`);t[21]!==T||t[22]!==E?(o=(0,q.jsxs)(`p`,{children:[T,`: `,E]}),t[21]=T,t[22]=E,t[23]=o):o=t[23],s=e.source_reason&&e.status===`active`&&!a.data?.checksPaused&&e.source_retry_at!=null&&(0,q.jsxs)(`p`,{children:[r?`来源重试时间`:`Source retry`,`: `,v(e.source_retry_at)]})}t[1]=n,t[2]=a.data,t[3]=r,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=f,t[10]=p,t[11]=m,t[12]=h,t[13]=g,t[14]=_}else o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],f=t[9],p=t[10],m=t[11],h=t[12],g=t[13],_=t[14];if(c!==Symbol.for(`react.early_return_sentinel`))return c;let v=r?`所有智能关注待检查`:`Pending checks across monitors`,y;t[24]!==a.data.pendingChecks||t[25]!==v?(y=(0,q.jsxs)(`p`,{children:[v,`: `,a.data.pendingChecks]}),t[24]=a.data.pendingChecks,t[25]=v,t[26]=y):y=t[26];let b;return t[27]!==o||t[28]!==s||t[29]!==y||t[30]!==l||t[31]!==u||t[32]!==f||t[33]!==p||t[34]!==m||t[35]!==h||t[36]!==g||t[37]!==_?(b=(0,q.jsxs)(`section`,{className:l,children:[u,f,p,m,h,g,_,o,s,y]}),t[27]=o,t[28]=s,t[29]=y,t[30]=l,t[31]=u,t[32]=f,t[33]=p,t[34]=m,t[35]=h,t[36]=g,t[37]=_,t[38]=b):b=t[38],b}function oe(e){return e!=null}function J(e){let t=(0,U.c)(13),{dirty:n,zh:r}=e,i;t[0]===n?i=t[1]:(i=e=>{n&&(e.preventDefault(),e.returnValue=``)},t[0]=n,t[1]=i),a(i);let o=l(n),s=o.state===`blocked`,c=r?`放弃未保存的更改?`:`Discard unsaved changes?`,u=r?`当前内容尚未保存,现在离开将丢失这些更改。`:`Your changes have not been saved. Leaving now will discard them.`,d=r?`放弃并离开`:`Discard and leave`,f=r?`继续编辑`:`Keep editing`,p,m;t[2]===o?(p=t[3],m=t[4]):(p=()=>{o.state===`blocked`&&o.proceed()},m=()=>{o.state===`blocked`&&o.reset()},t[2]=o,t[3]=p,t[4]=m);let h;return t[5]!==s||t[6]!==c||t[7]!==u||t[8]!==d||t[9]!==f||t[10]!==p||t[11]!==m?(h=(0,q.jsx)(V,{open:s,title:c,description:u,confirmLabel:d,cancelLabel:f,destructive:!0,overlayClassName:`z-[100]`,contentClassName:`z-[101]`,onConfirm:p,onCancel:m}),t[5]=s,t[6]=c,t[7]=u,t[8]=d,t[9]=f,t[10]=p,t[11]=m,t[12]=h):h=t[12],h}function se({zh:e}){let[t,n]=(0,H.useState)(!1),[r,i]=(0,H.useState)(!1),[a,o]=(0,H.useState)(),[s,c]=(0,H.useState)(!1);async function l(){n(!0),o(void 0),c(!1);try{if(await Notification.requestPermission()!==`granted`){c(!0);return}let{publicKey:t}=await G(`/browser/prepare`,`POST`);await navigator.serviceWorker.register(`/notification-sw.js`);let n=await navigator.serviceWorker.ready,r=Uint8Array.from(atob(t.replace(/-/g,`+`).replace(/_/g,`/`)),e=>e.charCodeAt(0)),a=await n.pushManager.getSubscription(),o=a?.options.applicationServerKey;a&&(!o||!new Uint8Array(o).every((e,t)=>e===r[t])||o.byteLength!==r.byteLength)&&(await a.unsubscribe(),a=null),a??=await n.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:r}),await G(`/browser/subscriptions`,`POST`,{...a.toJSON(),expirationTime:a.expirationTime,language:e?`zh`:`en`}),i(!0)}catch(e){o(e)}finally{n(!1)}}let u=ne()&&`PushManager`in window;return(0,q.jsxs)(`div`,{className:`space-y-2 border-t border-edge pt-3`,children:[(0,q.jsx)(j,{disabled:t||!u,onClick:()=>void l(),children:r?e?`刷新此浏览器提醒订阅`:`Refresh this browser subscription`:e?`开启页面关闭后的浏览器提醒`:`Enable reminders when this page is closed`}),r&&(0,q.jsx)(`p`,{role:`status`,children:e?`此浏览器已订阅。服务需持续运行;送达取决于浏览器和系统权限。`:`Subscribed. The Gateway must remain running; delivery depends on browser and system permissions.`}),(!u||s)&&(0,q.jsx)(`p`,{className:`text-fg-muted`,children:e?`当前环境或通知权限不支持后台提醒。成果仍会保留在智能关注收件箱;可在支持推送的 HTTPS 浏览器中开启。`:`Background reminders are unavailable here. Results remain in your monitor inbox. Use a push-capable HTTPS browser and allow notifications.`}),a!=null&&(0,q.jsx)(`p`,{role:`alert`,className:`text-danger`,children:K(a,e)})]})}function ce(e){let t=(0,U.c)(23),{zh:n,open:r,onOpenChange:i,onCloseAutoFocus:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,q.jsx)(x,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),t[0]=o):o=t[0];let s;t[1]===a?s=t[2]:(s=e=>{e.preventDefault(),a()},t[1]=a,t[2]=s);let c=n?`检查与提醒设置`:`Checks and reminders`,l;t[3]===c?l=t[4]:(l=(0,q.jsx)(E,{className:`text-base font-semibold text-fg`,children:c}),t[3]=c,t[4]=l);let u=n?`适用于所有智能关注,设置更改后自动保存。`:`Applies to all monitors. Changes are saved automatically.`,d;t[5]===u?d=t[6]:(d=(0,q.jsx)(S,{className:`mt-1 text-sm text-fg-muted`,children:u}),t[5]=u,t[6]=d);let f;t[7]!==l||t[8]!==d?(f=(0,q.jsxs)(`div`,{className:`shrink-0 border-b border-edge p-4 sm:px-6`,children:[l,d]}),t[7]=l,t[8]=d,t[9]=f):f=t[9];let p;t[10]===n?p=t[11]:(p=(0,q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4 sm:p-6`,children:(0,q.jsx)(le,{zh:n})}),t[10]=n,t[11]=p);let m=n?`关闭`:`Close`,h;t[12]===m?h=t[13]:(h=(0,q.jsx)(`div`,{className:`flex shrink-0 justify-end border-t border-edge p-4 sm:px-6`,children:(0,q.jsx)(C,{asChild:!0,children:(0,q.jsx)(j,{type:`button`,variant:`secondary`,children:m})})}),t[12]=m,t[13]=h);let g;t[14]!==h||t[15]!==s||t[16]!==f||t[17]!==p?(g=(0,q.jsxs)(w,{children:[o,(0,q.jsxs)(T,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(40rem,calc(100dvh-2rem))] w-[min(36rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-float focus:outline-none`,onCloseAutoFocus:s,children:[f,p,h]})]}),t[14]=h,t[15]=s,t[16]=f,t[17]=p,t[18]=g):g=t[18];let _;return t[19]!==i||t[20]!==r||t[21]!==g?(_=(0,q.jsx)(D,{open:r,onOpenChange:i,children:g}),t[19]=i,t[20]=r,t[21]=g,t[22]=_):_=t[22],_}function le({zh:e}){let t=k(`/preferences`,W),[n,r]=(0,H.useState)(!1),[i,a]=(0,H.useState)();async function o(e,i=t.data?.revision){if(!t.data||n||i===void 0)return!1;r(!0),a(void 0);try{let n=await G(`/preferences`,`PATCH`,{...e,expectedRevision:i});return await t.mutate(n,!1),!0}catch(e){return a(e),await t.mutate(),!1}finally{r(!1)}}if(!t.data)return t.error?(0,q.jsx)(`p`,{role:`alert`,children:K(t.error,e)}):(0,q.jsx)(N,{className:`h-32 w-full`});let s=t.data,c=`w-24 rounded-md border border-edge bg-surface-panel px-2 py-1 text-fg`;return(0,q.jsxs)(`div`,{className:`space-y-4 text-sm`,children:[(0,q.jsx)(`p`,{className:`text-fg-muted`,children:e?`设备休眠或服务关闭时不会检查;服务恢复后继续。草稿不会自动发送。`:`Checks require the device and Gateway to stay running. Drafts are never sent automatically.`}),[[`checksPaused`,e?`暂停所有检查`:`Pause all checks`],[`notificationsMuted`,e?`静音提醒(继续检查并保留成果)`:`Mute reminders (continue checks and keep results)`],[`suppressWhileViewing`,e?`查看成果时不重复提醒`:`Avoid reminders while viewing a result`],[`digestEnabled`,e?`汇总为每日摘要`:`Use a daily digest`]].map(([e,t])=>(0,q.jsxs)(`label`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:s[e],disabled:n,onChange:t=>void o({[e]:t.target.checked})}),t]},e)),(0,q.jsxs)(`label`,{className:`flex flex-wrap items-center gap-2`,children:[e?`时区`:`Timezone`,(0,q.jsx)(ue,{value:s.timezone,revision:s.revision,disabled:n,className:`${c} w-48`,zh:e,onSave:(e,t)=>o({timezone:String(e)},t)})]}),[[`quietStartHour`,e?`免打扰开始(小时)`:`Quiet hours start`,23],[`quietEndHour`,e?`免打扰结束(小时)`:`Quiet hours end`,23],[`dailyNotificationLimit`,e?`每日提醒上限`:`Daily reminder limit`,30],...s.digestEnabled?[[`digestHour`,e?`摘要时间(小时)`:`Digest hour`,23],[`digestMinute`,e?`摘要时间(分钟)`:`Digest minute`,59]]:[]].map(([t,r,i])=>(0,q.jsxs)(`label`,{className:`flex flex-wrap items-center gap-2`,children:[r,(0,q.jsx)(ue,{value:s[t],revision:s.revision,max:i,disabled:n,className:c,zh:e,onSave:(e,n)=>o({[t]:Number(e)},n)})]},t)),(0,q.jsxs)(`label`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`input`,{type:`checkbox`,disabled:n,checked:s.preferredChannel===`browser`,onChange:e=>void o({preferredChannel:e.target.checked?`browser`:`in_app`})}),e?`允许浏览器后台提醒`:`Allow background browser reminders`]}),(0,q.jsx)(se,{zh:e}),i!=null&&(0,q.jsx)(`p`,{role:`alert`,className:`text-danger`,children:K(i,e)}),s.checksPausedUntil&&(0,q.jsx)(j,{disabled:n,onClick:()=>void o({checksPausedUntil:null}),children:e?`取消定时暂停`:`Clear timed pause`})]})}function ue(e){let t=(0,U.c)(26),{value:n,revision:r,max:i,disabled:a,className:o,zh:s,onSave:c}=e,[l,u]=(0,H.useState)(null),d;t[0]!==l||t[1]!==i||t[2]!==c||t[3]!==n?(d=async()=>{if(!l||l.value===String(n))return;let e=i===void 0?l.value:Number(l.value);!l.value||typeof e==`number`&&(!Number.isInteger(e)||e<0||e>i)||await c(e,l.revision)&&u(null)},t[0]=l,t[1]=i,t[2]=c,t[3]=n,t[4]=d):d=t[4];let f=d,p=i===void 0?`text`:`number`,m=i===void 0?void 0:0,h=l?.value??n,g;t[5]===r?g=t[6]:(g=e=>u(t=>({value:e.target.value,revision:t?.revision??r})),t[5]=r,t[6]=g);let _;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(_=e=>{e.key===`Escape`&&u(null)},t[7]=_):_=t[7];let v;t[8]===f?v=t[9]:(v=e=>{e.relatedTarget instanceof HTMLElement&&e.relatedTarget.hasAttribute(`data-discard-preference`)||f()},t[8]=f,t[9]=v);let y;t[10]!==o||t[11]!==a||t[12]!==i||t[13]!==p||t[14]!==m||t[15]!==h||t[16]!==g||t[17]!==v?(y=(0,q.jsx)(`input`,{type:p,min:m,max:i,value:h,disabled:a,className:o,onChange:g,onKeyDown:_,onBlur:v}),t[10]=o,t[11]=a,t[12]=i,t[13]=p,t[14]=m,t[15]=h,t[16]=g,t[17]=v,t[18]=y):y=t[18];let b;t[19]!==a||t[20]!==l||t[21]!==s?(b=l&&(0,q.jsx)(j,{"data-discard-preference":!0,type:`button`,variant:`ghost`,disabled:a,onPointerDown:de,onClick:()=>u(null),children:s?`放弃修改`:`Discard edits`}),t[19]=a,t[20]=l,t[21]=s,t[22]=b):b=t[22];let x;return t[23]!==y||t[24]!==b?(x=(0,q.jsxs)(q.Fragment,{children:[y,b]}),t[23]=y,t[24]=b,t[25]=x):x=t[25],x}function de(e){return e.preventDefault()}function fe({item:e,zh:t,onChange:n}){let r=(0,H.useRef)(null);(0,H.useEffect)(()=>{let t=crypto.randomUUID(),n=!1,i=()=>{G(`/presence`,`POST`,{clientId:t,surface:`web`,presentationId:e.id,visible:n&&document.visibilityState===`visible`&&document.hasFocus()}).catch(()=>void 0)},a=new IntersectionObserver(([e])=>{n=e.isIntersecting,i()},{threshold:.5});r.current&&a.observe(r.current);let o=setInterval(i,2e4);return document.addEventListener(`visibilitychange`,i),window.addEventListener(`focus`,i),window.addEventListener(`blur`,i),()=>{a.disconnect(),clearInterval(o),document.removeEventListener(`visibilitychange`,i),window.removeEventListener(`focus`,i),window.removeEventListener(`blur`,i),n=!1,i()}},[e.id]);let[i,a]=(0,H.useState)(!1),o=`/presentations/${encodeURIComponent(e.id)}`,s=k(e.readOnly?null:`${o}/feedback`,W),{mutate:c}=O(),[l,u]=(0,H.useState)(!1),[d,f]=(0,H.useState)(),p=async e=>{if(s.data){u(!0),f(void 0);try{let t=s.data.feedback?.note??``,n=await G(`${o}/feedback`,`POST`,{expectedRevision:s.data.feedback?.revision??0,rating:e});await s.mutate({feedback:{rating:e,note:t,revision:n.revision}},{revalidate:!1}),c(`/metrics`)}catch(e){f(e),s.mutate()}finally{u(!1)}}},m=async()=>{u(!0),f(void 0);try{await G(o,`PATCH`,{read:e.status!==`read`}),n()}catch(e){f(e)}finally{u(!1)}};return(0,q.jsxs)(`article`,{ref:r,className:`space-y-3 rounded-xl border border-edge bg-surface-panel p-4 sm:p-6`,children:[e.createdAt!=null&&(0,q.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[t?`生成于`:`Generated`,` `,new Date(e.createdAt).toLocaleString(t?`zh-CN`:`en`)]}),e.sourceHealth?.reason&&(0,q.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t?`邮件来源暂不可用,这份成果尚未核实最新邮件,请检查连接授权后重试。`:`Mail is unavailable. This result has not been checked against the latest messages. Check connection access and retry.`}),(0,q.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm leading-relaxed text-fg`,children:e.content.summary}),(0,q.jsx)(j,{variant:`ghost`,onClick:()=>{navigator.clipboard.writeText(e.content.summary).then(()=>a(!0)).catch(f)},children:i?t?`已复制`:`Copied`:t?`复制成果`:`Copy result`}),(0,q.jsx)(`div`,{className:`space-y-1 text-xs text-fg-muted`,children:e.sources?.length?e.sources.map(e=>(0,q.jsxs)(`p`,{children:[(0,q.jsx)(`a`,{className:`text-accent underline`,href:e.href,target:e.kind===`mail`?`_blank`:void 0,rel:`noreferrer`,children:e.kind===`notes`?t?`查看关注资料`:`View monitor notes`:e.title||(t?`查看原邮件`:`View original email`)}),e.sender&&` · ${e.sender}`]},e.href)):(0,q.jsx)(`p`,{children:t?`来源详情暂不可用`:`Source details unavailable`})}),e.readOnly?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t?`这份成果已结束、过期或延后,仅供查阅。`:`This result is resolved, expired or snoozed, and is available for reference.`}):(0,q.jsxs)(q.Fragment,{children:[s.error?(0,q.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[K(s.error,t),(0,q.jsx)(j,{onClick:()=>void s.mutate(),children:t?`重新加载`:`Reload`})]}):s.data?(0,q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:[`useful`,`not_useful`].map(e=>(0,q.jsx)(j,{disabled:l,"aria-pressed":s.data?.feedback?.rating===e,onClick:()=>void p(e),children:e===`useful`?t?`对我有帮助`:`Helpful`:t?`没有帮助`:`Not helpful`},e))}):(0,q.jsx)(N,{className:`h-11 w-48`}),(0,q.jsx)(j,{disabled:l,variant:`ghost`,onClick:()=>void m(),children:e.status===`read`?t?`标为未读`:`Mark unread`:t?`标为已读`:`Mark read`})]}),!!d&&(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:K(d,t)})]})}var pe=`min-h-11 w-full rounded-md border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`;function me({activation:e,zh:t,onDirty:n,onChanged:r}){let i=`/activations/${e.id}/schedules`,a=k(i,W),o=k(`/templates/${e.templateKey}/versions/${e.templateVersion}`,W),[s,c]=(0,H.useState)(null),[l,u]=(0,H.useState)(),d=()=>{a.mutate(),o.mutate()};if(a.error||o.error)return(0,q.jsxs)(`div`,{role:`alert`,children:[(0,q.jsx)(`p`,{children:K(a.error??o.error,t)}),(0,q.jsx)(j,{onClick:d,children:t?`重新加载`:`Reload`})]});if(!a.data||!o.data)return(0,q.jsx)(N,{className:`h-32 w-full`});let f=o.data.template.triggers.find(e=>e.type===`schedule`);if(!f)return null;let p=a.data.schedules.find(e=>e.triggerKey===f.id);return(0,q.jsxs)(`section`,{className:`space-y-3 rounded-xl border border-edge p-4 sm:p-6`,children:[(0,q.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t?`检查时间`:`Review schedule`}),p?(0,q.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[e.status===`active`?t?`下次检查:`:`Next check: `:t?`当前不会定时检查。已保存时间:`:`Not scheduling while inactive. Saved time: `,new Intl.DateTimeFormat(t?`zh-CN`:`en`,{dateStyle:`medium`,timeStyle:`short`,timeZone:p.schedule.timeZone}).format(p.nextDueAt),` · `,p.schedule.timeZone]}):(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t?`尚未设置定时检查。只有你点“现在检查”才会执行周期复盘。`:`No recurring schedule yet. Use Check now for a manual review.`}),!!l&&(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:K(l,t)}),s?(0,q.jsx)(he,{initial:s.cursor,zh:t,onCancel:()=>{c(null),n(!1)},onSave:async e=>{u(void 0);try{await G(`${i}/${encodeURIComponent(f.id)}`,`PATCH`,{expectedRevision:s.cursor?.revision??0,schedule:e}),c(null),n(!1),await a.mutate(),r?.()}catch(e){throw u(e),e}}}):(0,q.jsx)(j,{disabled:e.status!==`active`,onClick:()=>{u(void 0),c({cursor:p}),n(!0)},children:p?t?`修改时间`:`Edit schedule`:t?`设置时间`:`Set schedule`}),(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t?`没有值得关注的新变化时保持安静。暂停关注会停止定时检查。`:`Stays quiet when there is no useful change. Pause the monitor to stop scheduled checks.`})]})}function he({initial:e,zh:t,onSave:n,onCancel:r}){let[i,a]=(0,H.useState)(e?.schedule.weekdays??[0]),[o,s]=(0,H.useState)(`${String(e?.schedule.hour??18).padStart(2,`0`)}:${String(e?.schedule.minute??0).padStart(2,`0`)}`),[c,l]=(0,H.useState)(e?.schedule.timeZone??Intl.DateTimeFormat().resolvedOptions().timeZone),[u,d]=(0,H.useState)(!1),[f,p]=(0,H.useState)(!1),m=async e=>{e.preventDefault();try{new Intl.DateTimeFormat(`en`,{timeZone:c})}catch{p(!0);return}if(!i.length||!/^\d{2}:\d{2}$/.test(o)){p(!0);return}p(!1),d(!0);try{let[e,t]=o.split(`:`).map(Number);await n({weekdays:i,hour:e,minute:t,timeZone:c})}catch{}finally{d(!1)}};return(0,q.jsx)(`form`,{onSubmit:e=>void m(e),children:(0,q.jsxs)(`fieldset`,{disabled:u,className:`space-y-4`,children:[(0,q.jsxs)(`fieldset`,{children:[(0,q.jsx)(`legend`,{className:`mb-2 text-sm font-medium text-fg`,children:t?`每周检查日`:`Days of the week`}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(t?[`周日`,`周一`,`周二`,`周三`,`周四`,`周五`,`周六`]:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`]).map((e,t)=>(0,q.jsxs)(`label`,{className:`flex min-h-11 items-center gap-2 rounded-md border border-edge px-3 text-sm text-fg`,children:[(0,q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:i.includes(t),onChange:e=>a(n=>e.target.checked?[...n,t].sort():n.filter(e=>e!==t))}),e]},t))})]}),(0,q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,q.jsxs)(`label`,{className:`grid gap-2 text-sm font-medium text-fg`,children:[t?`当地时间`:`Local time`,(0,q.jsx)(`input`,{type:`time`,required:!0,value:o,onChange:e=>s(e.target.value),className:pe})]}),(0,q.jsxs)(`label`,{className:`grid gap-2 text-sm font-medium text-fg`,children:[t?`时区(例如 Asia/Shanghai)`:`Time zone (for example Asia/Shanghai)`,(0,q.jsx)(`input`,{required:!0,maxLength:100,value:c,onChange:e=>l(e.target.value),className:pe,spellCheck:!1})]})]}),f&&(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:t?`请选择至少一天,并填写有效时间和时区。`:`Choose at least one day and enter a valid time and time zone.`}),(0,q.jsxs)(`div`,{className:`flex gap-3`,children:[(0,q.jsx)(j,{type:`submit`,disabled:u,children:u?t?`正在保存…`:`Saving…`:t?`保存时间`:`Save schedule`}),(0,q.jsx)(j,{type:`button`,onClick:r,children:t?`取消`:`Cancel`})]})]})})}function ge({value:e,disabled:t,zh:n,onChange:r}){let i=k(`/sources/mail/accounts`,W),[a,o]=(0,H.useState)(``),[s,c]=(0,H.useState)(``),[l,u]=(0,H.useState)([]),[f,p]=(0,H.useState)(!1),[m,g]=(0,H.useState)(!1),[_,v]=(0,H.useState)(),y=a||i.data?.accounts[0]?.id||``;async function b(){p(!0),v(void 0),u([]),g(!0),r({id:``,accountId:``,subject:``,sender:``});try{u((await G(`/sources/mail/search`,`POST`,{accountId:y,query:s})).sources)}catch(e){v(e)}finally{p(!1)}}if(i.error)return(0,q.jsxs)(`div`,{role:`alert`,className:`space-y-2 text-sm text-danger`,children:[(0,q.jsx)(`p`,{children:K(i.error,n)}),(0,q.jsx)(j,{onClick:()=>void i.mutate(),children:n?`重新加载`:`Reload`})]});if(!i.data)return(0,q.jsx)(N,{className:`h-24 w-full`});let x=e=>`${e.subject||(n?`无主题邮件`:`Untitled mail`)} · ${e.sender||e.accountId}`;return(0,q.jsxs)(`div`,{className:`space-y-3`,children:[(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`搜索会读取所选 Gmail 账号的匹配邮件;开启后只持续跟进选定线程,不发送邮件,也不需要开启后台学习。`:`Search reads matching mail in your selected Gmail account. The monitor follows only the selected thread, never sends mail, and requires no background learning.`}),(0,q.jsx)(h,{value:y,disabled:t||f,ariaLabel:n?`邮箱账号`:`Mail account`,placeholder:n?`选择账号`:`Choose account`,allowEmpty:!1,options:i.data.accounts.map(e=>({value:e.id,label:e.label})),onChange:e=>{o(e),u([]),r({id:``,accountId:``,subject:``,sender:``})}}),(0,q.jsxs)(`label`,{className:`grid gap-2 text-sm`,children:[n?`主题、发件人或 Gmail 搜索条件`:`Subject, sender, or Gmail query`,(0,q.jsx)(`input`,{value:s,maxLength:500,disabled:t||f,onChange:e=>c(e.target.value),className:`rounded-md border border-edge bg-surface-panel px-3 py-2`,placeholder:n?`例如 from:alice@example.com`:`e.g. from:alice@example.com`})]}),(0,q.jsx)(j,{type:`button`,disabled:t||f||!y||!s.trim(),onClick:()=>void b(),children:f?n?`正在搜索…`:`Searching…`:n?`搜索邮件`:`Search mail`}),(0,q.jsx)(h,{value:e,disabled:t||f,ariaLabel:n?`要跟进的邮件`:`Mail to follow`,placeholder:n?`选择邮件线程`:`Choose a thread`,allowEmpty:!1,options:l.map(e=>({value:e.id,label:x(e)})),onChange:e=>{let t=l.find(t=>t.id===e);t&&r(t)}}),!i.data.accounts.length&&(0,q.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[n?`请连接 Gmail,并允许读取及后台检查;要求每次确认或仅限指定 Agent 的账号暂不支持。`:`Connect Gmail and allow background reads. Accounts requiring confirmation for every read or restricted to specific agents are not supported yet.`,` `,(0,q.jsx)(d,{className:`text-accent underline`,to:`/capabilities/connectors`,children:n?`管理连接`:`Manage connections`})]}),m&&!f&&!_&&!l.length&&(0,q.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:n?`没有找到匹配线程,请调整搜索条件。`:`No matching threads. Try a different query.`}),_!=null&&(0,q.jsx)(`p`,{role:`alert`,className:`text-danger`,children:K(_,n)})]})}function _e({activation:e,zh:t,onDirty:n,onChanged:r}){let i=`/activations/${e.id}/work-items`,a=k(i,W),[o,s]=(0,H.useState)(null),[c,l]=(0,H.useState)(),[u,d]=(0,H.useState)(!1),f=()=>{s(null),n(!1),a.mutate(),r()};if(a.error)return(0,q.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[K(a.error,t),(0,q.jsx)(j,{onClick:()=>void a.mutate(),children:t?`重新加载`:`Reload`})]});if(!a.data)return(0,q.jsx)(N,{className:`h-32 w-full`});let p=a.data.workItems[0],m=async e=>{if(p){d(!0),l(void 0);try{await G(`/work-items/${p.id}`,`PATCH`,{expectedRevision:p.revision,status:e}),f()}catch(e){l(e)}finally{d(!1)}}};return(0,q.jsxs)(`section`,{className:`space-y-3 rounded-xl border border-edge p-4 sm:p-6`,children:[(0,q.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t?`这封邮件的跟进时间`:`Follow-up deadline`}),(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:p?`${p.status===`watching`?t?`留意回复,到时检查`:`Watching replies; check at deadline`:p.status===`paused`?t?`已暂停跟进`:`Follow-up paused`:t?`已结束跟进`:`Follow-up ended`} · ${new Intl.DateTimeFormat(t?`zh-CN`:`en`,{dateStyle:`medium`,timeStyle:`short`}).format(p.dueAt)}`:t?`设置一个时间;此前有新回复时会重新判断是否还需要跟进。`:`Choose a deadline. New replies before then trigger a review of whether follow-up is still needed.`}),!!c&&(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:K(c,t)}),o?(0,q.jsx)(ve,{initial:o.item?.dueAt,zh:t,onCancel:()=>{s(null),n(!1)},onSave:async t=>{l(void 0);try{o.item?await G(`/work-items/${o.item.id}`,`PATCH`,{expectedRevision:o.item.revision,dueAt:t,status:`watching`}):e.scope.kind===`objects`&&await G(i,`POST`,{subjectId:e.scope.ids[0],accountId:e.permissions.accountIds[0],dueAt:t}),f()}catch(e){throw l(e),e}}}):(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[p?.status!==`completed`&&(0,q.jsx)(j,{disabled:u||e.status!==`active`,onClick:()=>{s({item:p}),n(!0),l(void 0)},children:p?t?`重新设置跟进时间`:`Reschedule follow-up`:t?`设置跟进时间`:`Set deadline`}),p?.status===`watching`&&(0,q.jsx)(j,{disabled:u,onClick:()=>void m(`paused`),children:t?`暂停这次跟进`:`Pause follow-up`}),p&&p.status!==`completed`&&(0,q.jsx)(j,{disabled:u,onClick:()=>void m(`completed`),children:t?`结束这次跟进`:`End follow-up`})]}),(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t?`结束跟进只停止检查,不表示邮件已发送或事情已经解决。`:`Ending stops checks; it does not mean a message was sent or the matter resolved.`})]})}function ve({initial:e,zh:t,onSave:n,onCancel:r}){let[i,a]=(0,H.useState)(()=>{if(!e)return``;let t=new Date(e);return new Date(e-t.getTimezoneOffset()*6e4).toISOString().slice(0,16)}),[o,s]=(0,H.useState)(!1),[c,l]=(0,H.useState)(!1),u=async e=>{e.preventDefault();let t=new Date(i).getTime();if(!Number.isFinite(t)||t<=Date.now()){l(!0);return}l(!1),s(!0);try{await n(t)}catch{}finally{s(!1)}};return(0,q.jsx)(`form`,{onSubmit:e=>void u(e),children:(0,q.jsxs)(`fieldset`,{disabled:o,className:`space-y-3`,children:[(0,q.jsxs)(`label`,{className:`grid gap-2 text-sm font-medium text-fg`,children:[t?`跟进时间(当前设备时区)`:`Deadline (device time zone)`,(0,q.jsx)(`input`,{required:!0,type:`datetime-local`,value:i,onChange:e=>a(e.target.value),className:`min-h-11 w-full min-w-0 rounded-md border border-edge bg-surface-panel px-3 py-2 text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`})]}),c&&(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:t?`请选择未来的有效时间。`:`Choose a valid future time.`}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(j,{type:`submit`,disabled:o,children:o?t?`正在保存…`:`Saving…`:t?`保存跟进时间`:`Save deadline`}),(0,q.jsx)(j,{type:`button`,onClick:r,children:t?`取消`:`Cancel`})]})]})})}var ye=e(n(),1),Y=`min-h-11 w-full rounded-md border border-edge bg-surface-panel px-3 py-2 text-base text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent sm:text-sm`,X=`min-w-0 space-y-4 rounded-xl border border-edge bg-surface-panel p-4`;function be(e,t,n){return e===`none`?[]:[`workspace.read`,...t?[`workspace.write`]:[],...e===`worktree`&&n.trim()?[`verification.run`]:[]]}function xe({template:e}){let t=y(e=>e.language)===`zh`,n=(e,n)=>t?e:n,r=s(),i=k(`/source-providers`,W),[a,o]=(0,H.useState)(``),c=a||i.data?.providers[0]?.id||``,l=k(c?`/source-providers/${encodeURIComponent(c)}/accounts`:null,W),u=k(`follow-up-projects`,()=>ee({limit:100})),[f,h]=(0,H.useState)(``),[g,_]=(0,H.useState)(``),[v,b]=(0,H.useState)(``),[x,S]=(0,H.useState)(``),[C,w]=(0,H.useState)(``),[T,E]=(0,H.useState)(`none`),[D,O]=(0,H.useState)(!1),[A,M]=(0,H.useState)(``),[P,F]=(0,H.useState)(!1),[I,L]=(0,H.useState)(``),[te,ne]=(0,H.useState)(!1),R=(0,H.useRef)(null),z=u.data?.items.filter(e=>e.workspaceRoot)??[],B=f||(l.data?.accounts.length===1?l.data.accounts[0].id:``),V=g||(z.length===1?z[0].id:``);async function re(i){if(i.preventDefault(),!P){F(!0),L(``);try{let{source:t}=await G(`/source-providers/${encodeURIComponent(c)}/resolve-link`,`POST`,{accountId:B,url:v}),i={source:t,sourceUrl:v,goal:x,instruction:C,resource:T,...T===`worktree`?{projectId:V}:{},capabilities:be(T,D,A),...T===`worktree`&&A.trim()?{verificationCommand:A.trim()}:{}},a={templateKey:e.key,templateVersion:e.version,configuration:i},o=await G(`/preflight`,`POST`,a);if(!o.ready){let e={verification_backend:n(`可选验证需要配置隔离后端;也可清空验证命令,先生成修改。`,`Optional verification needs an isolation backend. Clear the command to proceed without running tests.`),verification_backend_unavailable:n(`验证后端不可用;检查配置或清空验证命令。`,`Verification backend unavailable. Check settings or clear the command.`),clean_base_checkout:n(`项目基础工作区有未提交改动,请先整理。`,`The project base checkout has uncommitted changes.`),source_read_permission:n(`来源读取权限不足,请检查连接。`,`Source read permission is missing. Check the connection.`),model_credentials:n(`请配置模型凭据。`,`Configure model credentials.`),model_configuration:n(`请选择可用模型。`,`Choose an available model.`)};L(o.missing.map(t=>e[t]??t).join(` `));return}let s=await G(`/activations`,`POST`,a);(0,ye.flushSync)(()=>ne(!0)),r(`/scenes/${s.activation.id}`,{replace:!0})}catch(e){L(K(e,t))}finally{F(!1),setTimeout(()=>R.current?.focus(),0)}}}return i.error||l.error||u.error?(0,q.jsx)(`p`,{role:`alert`,children:K(i.error??l.error??u.error,t)}):!i.data||!u.data||c&&!l.data?(0,q.jsxs)(`div`,{"aria-busy":`true`,children:[(0,q.jsx)(N,{className:`h-12`}),(0,q.jsx)(N,{className:`mt-4 h-32`})]}):(0,q.jsxs)(`form`,{className:`space-y-5`,onSubmit:re,children:[(0,q.jsx)(J,{dirty:!te&&!!(v||x||C),zh:t}),(0,q.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:e.title}),(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.description}),(0,q.jsxs)(`fieldset`,{disabled:P,className:`space-y-5`,children:[(0,q.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[n(`来源`,`Source`),(0,q.jsx)(p,{"aria-label":n(`来源`,`Source`),value:c,onChange:e=>{o(e.target.value),h(``)},required:!0,children:i.data.providers.map(e=>(0,q.jsx)(m,{value:e.id,children:e.label},e.id))})]}),!l.data?.accounts.length&&(0,q.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[n(`请先连接可读取的账号。`,`Connect an account with read access first.`),` `,(0,q.jsx)(d,{className:`text-accent-fg`,to:`/capabilities/connectors`,children:n(`连接`,`Connections`)})]}),(0,q.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[n(`账号`,`Account`),(0,q.jsxs)(p,{"aria-label":n(`账号`,`Account`),value:B,onChange:e=>h(e.target.value),required:!0,children:[(0,q.jsx)(m,{value:``,children:n(`选择账号`,`Choose an account`)}),l.data?.accounts.map(e=>(0,q.jsx)(m,{value:e.id,children:e.label},e.id))]})]}),(0,q.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[n(`来源链接`,`Source link`),(0,q.jsx)(`input`,{className:Y,type:`url`,required:!0,maxLength:2e3,value:v,onChange:e=>b(e.target.value)})]}),(0,q.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[n(`你希望完成什么?`,`What should be accomplished?`),(0,q.jsx)(`textarea`,{className:Y,required:!0,maxLength:6e3,rows:3,value:x,onChange:e=>S(e.target.value)})]}),(0,q.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[n(`处理指令(可选)`,`Instructions (optional)`),(0,q.jsx)(`textarea`,{className:Y,rows:3,maxLength:12e3,value:C,onChange:e=>w(e.target.value),placeholder:n(`例如:持续更新决策记录;有冲突时向我确认。`,`For example: keep a decision log updated; ask me about conflicts.`)})]}),(0,q.jsxs)(`section`,{className:X,children:[(0,q.jsx)(`h3`,{className:`font-medium text-fg`,children:n(`资源与权限`,`Resources and permissions`)}),(0,q.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[n(`工作资源`,`Workspace resource`),(0,q.jsxs)(p,{"aria-label":n(`工作资源`,`Workspace resource`),value:T,onChange:e=>{E(e.target.value),M(``),O(!1)},children:[(0,q.jsx)(m,{value:`none`,children:n(`无文件资源 · 分析与建议`,`No files · analysis and recommendations`)}),(0,q.jsx)(m,{value:`artifacts`,children:n(`任务产物目录 · 文档等文件`,`Task artifact folder · documents and files`)}),(0,q.jsx)(m,{value:`worktree`,children:n(`Git worktree · 项目修改`,`Git worktree · project changes`)})]})]}),T===`worktree`&&(0,q.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[n(`项目`,`Project`),(0,q.jsxs)(p,{"aria-label":n(`项目`,`Project`),required:!0,value:V,onChange:e=>_(e.target.value),children:[(0,q.jsx)(m,{value:``,children:n(`选择本地 Git 项目`,`Choose a local Git project`)}),z.map(e=>(0,q.jsx)(m,{value:e.id,children:e.name},e.id))]})]}),T!==`none`&&(0,q.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm text-fg`,children:[(0,q.jsx)(`input`,{className:`ui-checkbox`,type:`checkbox`,checked:D,onChange:e=>O(e.target.checked)}),n(`允许创建和修改此任务工作区内的文件`,`Allow creating and editing files in this task workspace`)]}),T===`worktree`&&(0,q.jsxs)(`details`,{className:`space-y-3`,children:[(0,q.jsx)(`summary`,{className:`cursor-pointer text-sm text-fg`,children:n(`可选:授权运行验证命令`,`Optional: authorize a verification command`)}),(0,q.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[n(`固定验证命令(留空则不执行命令)`,`Fixed verification command (blank means no commands)`),(0,q.jsx)(`input`,{className:Y,maxLength:2e3,value:A,onChange:e=>M(e.target.value),placeholder:`pnpm test`})]}),(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n(`仅此可选工具需要已配置的隔离后端。留空也能修改文件,但结果会标记未验证。不会自动改为宿主机执行。`,`Only this optional tool needs a configured isolation backend. File edits work without it and remain unverified. No automatic host execution.`)}),(0,q.jsx)(d,{to:`/settings/agent-defaults`,className:`text-sm text-accent-fg`,children:n(`查看执行设置`,`Execution settings`)})]}),(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n(`不会提交、推送、部署或对外发消息。约每分钟检查一次,Gateway 需要保持在线。`,`No commits, pushes, deployment or outgoing messages. Checks about once a minute while the Gateway is online.`)})]}),I&&(0,q.jsx)(`p`,{ref:R,tabIndex:-1,role:`alert`,className:`text-sm text-danger`,children:I}),(0,q.jsx)(j,{variant:`primary`,type:`submit`,disabled:P||!B||T===`worktree`&&!V,children:P?n(`正在检查并开启…`,`Checking and starting…`):n(`确认范围并开始跟进`,`Confirm scope and start following`)})]})]})}function Se({id:e,initial:t}){let[n,r]=(0,H.useState)(!1),i=y(e=>e.language)===`zh`,a=(e,t)=>i?e:t,o=`/activations/${encodeURIComponent(e)}`,s=k(o,W,{refreshInterval:5e3,fallbackData:{details:t}}),[c,l]=(0,H.useState)(!1),[u,f]=(0,H.useState)(``);async function p(e){l(!0),f(``);try{await G(o,`PATCH`,{expectedRevision:s.data.details.activation.revision,status:e}),await s.mutate()}catch(e){f(K(e,i))}finally{l(!1)}}if(s.error)return(0,q.jsx)(`p`,{role:`alert`,children:K(s.error,i)});if(!s.data)return(0,q.jsx)(`div`,{"aria-busy":`true`,children:(0,q.jsx)(N,{className:`h-48`})});let m=s.data.details,h=m.processedRevision>0&&m.processedRevision===m.observedRevision;return(0,q.jsxs)(`div`,{className:`space-y-5`,children:[(0,q.jsx)(`h2`,{className:`break-words text-lg font-semibold text-fg`,children:m.activation.goal}),(0,q.jsx)(ie,{resource:{kind:`scene`,id:m.activation.id,revision:String(m.activation.revision)},disabled:c||n}),(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,role:`status`,children:m.activation.status===`archived`?a(`已停止跟进,任务与产物已保留`,`Stopped following; task and artifacts retained`):m.lastError||m.activation.status===`needs_setup`||m.receipt?.needsUser?a(`需要你处理`,`Needs your attention`):m.activation.status===`paused`?a(`已暂停`,`Paused`):m.run?.status===`running`?a(`正在处理`,`Working`):h?a(`已处理当前来源版本,继续观察变化`,`Current source revision processed; watching for updates`):a(`正在跟进`,`Following updates`)}),(0,q.jsxs)(`section`,{className:X,children:[(0,q.jsx)(`h3`,{className:`font-medium text-fg`,children:a(`来源 → 任务 → 产物`,`Source → task → artifacts`)}),(0,q.jsx)(`p`,{className:`break-words text-sm text-fg-muted`,children:m.input.source.provider}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-4`,children:[(0,q.jsx)(d,{className:`text-sm text-accent-fg`,to:`/tasks/${m.task.id}`,children:a(`打开关联任务`,`Open linked task`)}),m.input.sourceUrl&&(0,q.jsx)(`a`,{className:`text-sm text-accent-fg`,href:m.input.sourceUrl,target:`_blank`,rel:`noopener noreferrer`,children:a(`打开原讨论`,`Open source`)})]}),(0,q.jsxs)(`dl`,{className:`grid grid-cols-1 gap-3 text-sm sm:grid-cols-3`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`dt`,{className:`text-fg-muted`,children:a(`已观察版本`,`Observed revision`)}),(0,q.jsx)(`dd`,{children:m.observedRevision})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`dt`,{className:`text-fg-muted`,children:a(`已交付版本`,`Delivered revision`)}),(0,q.jsx)(`dd`,{children:m.deliveredRevision})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`dt`,{className:`text-fg-muted`,children:a(`已处理版本`,`Processed revision`)}),(0,q.jsx)(`dd`,{children:m.processedRevision||`—`})]})]}),(m.environment||m.artifactPath)&&(0,q.jsxs)(`div`,{className:`space-y-2 break-all text-sm text-fg-muted`,children:[m.environment?.branchRef&&(0,q.jsxs)(`p`,{children:[a(`任务分支:`,`Task branch: `),m.environment.branchRef]}),(0,q.jsxs)(`p`,{children:[a(`产物位置:`,`Artifact location: `),m.environment?.rootPath??m.artifactPath]})]}),(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a(`已处理不代表通过验收。验证状态以工具证据为准。`,`Processed does not mean accepted. Verification status comes from tool evidence.`)})]}),m.lastError&&(0,q.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-danger`,children:m.lastError}),m.receipt&&(0,q.jsxs)(`section`,{className:X,children:[(0,q.jsx)(`h3`,{className:`font-medium text-fg`,children:a(`最近结果`,`Latest result`)}),(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:m.receipt.verification.status===`passed`?a(`已授权命令通过;仍需审阅业务结果`,`Approved command passed; review the outcome`):a(`未验证:没有当前版本的通过证据`,`Unverified: no passing evidence for the current revision`)}),(0,q.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm text-fg`,children:m.receipt.summary}),m.receipt.remainingWork.map((e,t)=>(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e},t)),(0,q.jsxs)(`details`,{children:[(0,q.jsx)(`summary`,{className:`cursor-pointer text-sm text-fg`,children:a(`产物与验证证据`,`Artifacts and verification evidence`)}),[...m.receipt.changes,...m.receipt.evidence].map((e,t)=>(0,q.jsxs)(`pre`,{className:`mt-3 max-h-64 overflow-y-auto whitespace-pre-wrap break-words text-xs text-fg-muted`,children:[e.title,`
2
- `,e.summary]},t))]})]}),m.input.resource===`worktree`&&m.input.projectId&&(0,q.jsx)(we,{projectId:m.input.projectId,taskId:m.task.id}),m.activation.status===`paused`&&(0,q.jsx)(Ce,{item:m,onSaved:()=>s.mutate(),onDirty:r},m.activation.id),u&&(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:u}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-3`,children:m.activation.status!==`archived`&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(j,{variant:`secondary`,disabled:c,onClick:()=>void p(m.activation.status===`active`?`paused`:`active`),children:c?a(`处理中…`,`Working…`):m.activation.status===`active`?a(`暂停跟进与执行`,`Pause observation and execution`):a(`确认后恢复`,`Resume after review`)}),(0,q.jsx)(j,{variant:`ghost`,disabled:c,onClick:()=>void p(`archived`),children:a(`停止跟进(保留产物)`,`Stop following (keep artifacts)`)})]})})]})}function Ce({item:e,onSaved:t,onDirty:n}){let r=y(e=>e.language)===`zh`,i=(e,t)=>r?e:t,[a,o]=(0,H.useState)(null),s=a??{base:e,instruction:e.input.instruction,writable:e.input.capabilities.includes(`workspace.write`),command:e.input.verificationCommand??``},{instruction:c,writable:l,command:u}=s,d=e=>o(t=>({...t??s,...e})),[f,p]=(0,H.useState)(!1),[m,h]=(0,H.useState)(``),g=c!==e.input.instruction||l!==e.input.capabilities.includes(`workspace.write`)||u!==(e.input.verificationCommand??``);(0,H.useEffect)(()=>(n(g||f),()=>n(!1)),[g,f,n]);async function _(n){n.preventDefault(),p(!0),h(``);try{let n=s.base;await G(`/activations/${e.activation.id}`,`PATCH`,{expectedRevision:n.activation.revision,configuration:{...n.input,instruction:c,capabilities:be(n.input.resource,l,u),verificationCommand:u.trim()||void 0}}),await t(),o(null)}catch(e){h(K(e,r))}finally{p(!1)}}return(0,q.jsxs)(`details`,{className:X,children:[(0,q.jsx)(`summary`,{className:`cursor-pointer text-sm text-fg`,children:i(`调整指令与授权`,`Edit instructions and permissions`)}),(0,q.jsx)(J,{dirty:g,zh:r}),(0,q.jsxs)(`form`,{className:`space-y-3`,onSubmit:_,children:[(0,q.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[i(`处理指令`,`Instructions`),(0,q.jsx)(`textarea`,{disabled:f,className:Y,rows:4,maxLength:12e3,value:c,onChange:e=>d({instruction:e.target.value})})]}),s.base.input.resource!==`none`&&(0,q.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm text-fg`,children:[(0,q.jsx)(`input`,{disabled:f,type:`checkbox`,className:`ui-checkbox`,checked:l,onChange:e=>d({writable:e.target.checked})}),i(`允许修改任务工作区文件`,`Allow task workspace file edits`)]}),s.base.input.resource===`worktree`&&(0,q.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[i(`验证命令(可选;留空不执行)`,`Verification command (optional; blank disables execution)`),(0,q.jsx)(`input`,{disabled:f,className:Y,maxLength:2e3,value:u,onChange:e=>d({command:e.target.value})})]}),(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:i(`保存后仍保持暂停。确认授权范围后再恢复。`,`Saving keeps the monitor paused. Review permissions before resuming.`)}),m&&(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:m}),(0,q.jsx)(j,{type:`submit`,disabled:f||!g,children:f?i(`正在保存…`,`Saving…`):i(`保存指令与授权`,`Save instructions and permissions`)}),a&&(0,q.jsx)(j,{type:`button`,variant:`ghost`,disabled:f,onClick:()=>{o(null),h(``)},children:i(`放弃修改`,`Discard edits`)})]})]})}function we({projectId:e,taskId:t}){let n=y(e=>e.language)===`zh`,[r,i]=(0,H.useState)(!1),[a,o]=(0,H.useState)(``),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(``),f=k(r?`/resources/projects/${encodeURIComponent(e)}/branches`:null,W),h=f.data?.branches.find(e=>e.ref===a);async function g(){if(h){c(!0),u(``);try{await G(`/resources/branch-links`,`POST`,{projectId:e,taskId:t,branchRef:h.ref,expectedSha:h.sha}),await f.mutate()}catch(e){u(K(e,n))}finally{c(!1)}}}return(0,q.jsxs)(`details`,{className:X,open:r,onToggle:e=>i(e.currentTarget.open),children:[(0,q.jsx)(`summary`,{className:`cursor-pointer text-sm text-fg`,children:n?`已有分支与需求关联`:`Existing branches and requirements`}),(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`只读盘点。确认关联仅记录归属,不接管该分支,也不修改、重命名或清理代码。`:`Read-only inventory. Confirming records ownership only: no takeover, edits, renaming or cleanup.`}),f.error?(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:K(f.error,n)}):f.data?(0,q.jsxs)(q.Fragment,{children:[f.data.checkoutDirty&&(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`基础工作区存在未提交改动,已保留。`:`The base checkout has uncommitted changes; they are preserved.`}),(0,q.jsxs)(p,{"aria-label":n?`选择已有分支`:`Choose an existing branch`,value:a,onChange:e=>o(e.target.value),children:[(0,q.jsx)(m,{value:``,children:n?`选择分支查看归属`:`Choose a branch to inspect`}),f.data.branches.map(e=>(0,q.jsx)(m,{value:e.ref,children:e.ref.replace(`refs/heads/`,``)},e.ref))]}),h&&(0,q.jsxs)(`div`,{className:`space-y-3 break-all text-sm text-fg`,children:[(0,q.jsx)(`p`,{children:h.subject}),(0,q.jsx)(`p`,{className:`text-fg-muted`,children:h.sha}),h.worktree&&(0,q.jsx)(`p`,{className:`text-fg-muted`,children:h.worktree}),h.taskId?(0,q.jsx)(d,{className:`text-accent-fg`,to:h.activationId?`/scenes/${h.activationId}`:`/tasks/${h.taskId}`,children:n?`查看对应事项`:`Open associated work`}):(0,q.jsx)(j,{variant:`secondary`,disabled:s,onClick:()=>void g(),children:s?n?`关联中…`:`Linking…`:n?`确认关联到当前任务`:`Confirm association with this task`}),h.changedSinceConfirmation&&(0,q.jsx)(`p`,{className:`text-fg-muted`,children:n?`该分支在确认关联后已有新提交。`:`This branch has new commits since confirmation.`})]})]}):(0,q.jsx)(N,{className:`h-24`}),l&&(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:l})]})}function Te(){let{mutate:e}=O();(0,H.useEffect)(()=>{let t=0,n,r,i=()=>{r===void 0&&(r=setTimeout(()=>{r=void 0,e(()=>!0)},50))},a=B(e=>{e.kind===`scene`&&i()}),o=async()=>{let o=++t;n?.(),n=void 0;try{let{capabilities:s}=await _(b(`/api/capabilities/operations`));if(o!==t)return;if(!s.some(e=>e.id===`xopc.scenes.list`)){r!==void 0&&clearTimeout(r),r=void 0,e(()=>!0,void 0,{revalidate:!0});return}n=M(`resources:scenes`,{onEvent:e=>{e.event===`resource.changed`&&a(e.topic,e.data)},onGap:i},0),i()}catch{}},s=()=>{o()};return window.addEventListener(`gateway-realtime-connected`,s),o(),()=>{t++,n?.(),r!==void 0&&clearTimeout(r),window.removeEventListener(`gateway-realtime-connected`,s)}},[e])}var Ee=`min-h-11 w-full rounded-md border border-edge bg-surface-panel px-3 py-2 text-base text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent sm:text-sm`,Z=`min-w-0 rounded-xl border border-edge bg-surface-panel p-4 sm:p-6`,De=`grid gap-2 text-sm font-medium text-fg`;function Oe(e,t){return{needs_setup:[`待完成设置`,`Finish setup`],active:[`已开启`,`Active`],paused:[`已暂停`,`Paused`],completed:[`已完成`,`Completed`],archived:[`已归档`,`Archived`],running:[`正在检查`,`Checking`],succeeded:[`已准备成果`,`Result ready`],skipped:[`无需新行动`,`No new action`],retry_wait:[`等待来源或预算`,`Waiting for source or budget`],failed:[`检查失败`,`Check failed`],cancelled:[`已取消`,`Cancelled`]}[e]?.[+!t]??e}function Q(){let e=(0,U.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,q.jsxs)(`div`,{className:`space-y-4`,"aria-busy":`true`,children:[(0,q.jsx)(N,{className:`h-8 w-48`}),(0,q.jsx)(N,{className:`h-40 w-full`}),(0,q.jsx)(N,{className:`h-32 w-full`})]}),e[0]=t):t=e[0],t}function $(e){let t=(0,U.c)(24),{error:n,retry:r}=e,i=y(ke)===`zh`;if(n?.status===503){let e=i?`智能关注尚未开放`:`Monitors are not available yet`,r;t[0]===e?r=t[1]:(r=(0,q.jsx)(`h1`,{className:`text-xl font-semibold text-fg`,children:e}),t[0]=e,t[1]=r);let a;t[2]!==n||t[3]!==i?(a=K(n,i),t[2]=n,t[3]=i,t[4]=a):a=t[4];let o;t[5]===a?o=t[6]:(o=(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a}),t[5]=a,t[6]=o);let s=i?`返回对话`:`Back to chat`,c;t[7]===s?c=t[8]:(c=(0,q.jsx)(j,{asChild:!0,children:(0,q.jsx)(d,{to:`/chat`,children:s})}),t[7]=s,t[8]=c);let l;return t[9]!==r||t[10]!==o||t[11]!==c?(l=(0,q.jsxs)(`section`,{className:`${Z} space-y-3`,children:[r,o,c]}),t[9]=r,t[10]=o,t[11]=c,t[12]=l):l=t[12],l}let a;t[13]!==n||t[14]!==i?(a=K(n,i),t[13]=n,t[14]=i,t[15]=a):a=t[15];let o;t[16]===a?o=t[17]:(o=(0,q.jsx)(`p`,{className:`text-sm text-danger`,children:a}),t[16]=a,t[17]=o);let s;t[18]!==r||t[19]!==i?(s=r&&(0,q.jsxs)(j,{onClick:r,children:[(0,q.jsx)(F,{size:16,"aria-hidden":`true`}),i?`重新加载`:`Reload`]}),t[18]=r,t[19]=i,t[20]=s):s=t[20];let c;return t[21]!==o||t[22]!==s?(c=(0,q.jsxs)(`div`,{role:`alert`,className:`space-y-3 rounded-xl border border-edge p-4`,children:[o,s]}),t[21]=o,t[22]=s,t[23]=c):c=t[23],c}function ke(e){return e.language}function Ae(){let e=(0,U.c)(5),t=v(Ne);if(v(Me)){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,q.jsx)($,{error:{status:401}}),e[0]=t):t=e[0],t}let n=t??`anonymous`,r,i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r={provider:je},i=(0,q.jsx)(Pe,{}),e[1]=r,e[2]=i):(r=e[1],i=e[2]);let a;return e[3]===n?a=e[4]:(a=(0,q.jsx)(A,{value:r,children:i},n),e[3]=n,e[4]=a),a}function je(){return new Map}function Me(e){return e.tokenExpired}function Ne(e){return e.conversationId}function Pe(){let e=(0,U.c)(20);Te();let{activationId:t,templateKey:n}=u(),r=o(`/scenes/inbox`),i=y(Le)===`zh`,[a,s]=(0,H.useState)(!1),l=(0,H.useRef)(null),p=f(),[m]=c(),h=t&&p.state?.fromSceneInbox===!0?`/scenes/inbox${typeof p.state.inboxSearch==`string`?p.state.inboxSearch:``}`:void 0,g=R(Ie),_=R(Fe),v,b;e[0]!==_||e[1]!==g||e[2]!==i?(v=()=>{let e=i?`把需要持续留意的事交给 AI,把时间留给自己。`:`Let AI look after recurring needs, leaving more time for you.`,t=i?`查看全部成果`:`View all results`,n=i?`检查与提醒设置`:`Checks and reminders`;return g({startExtra:null,main:(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:i?`智能关注`:`Monitors`}),(0,q.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,title:e,children:e})]}),end:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(j,{asChild:!0,variant:`secondary`,className:`h-9`,children:(0,q.jsxs)(d,{"data-scene-inbox":!0,to:`/scenes/inbox`,"aria-label":t,title:t,children:[(0,q.jsx)(re,{className:`size-4`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`hidden sm:inline`,children:t})]})}),(0,q.jsx)(j,{ref:l,type:`button`,variant:`ghost`,className:`size-9 p-0`,"aria-label":n,title:n,"aria-haspopup":`dialog`,onClick:()=>s(!0),children:(0,q.jsx)(I,{className:`size-4`,"aria-hidden":`true`})})]})}),()=>_()},b=[_,g,i],e[0]=_,e[1]=g,e[2]=i,e[3]=v,e[4]=b):(v=e[3],b=e[4]),(0,H.useLayoutEffect)(v,b);let x;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,q.jsx)(`main`,{className:`h-full overflow-y-auto bg-surface-panel`,children:(0,q.jsx)(`div`,{className:`mx-auto w-full max-w-7xl space-y-6 px-4 py-7 sm:px-6 lg:px-8 lg:py-9`,children:(0,q.jsx)(ze,{})})}),e[5]=x):x=e[5];let S;e[6]!==t||e[7]!==r||e[8]!==h||e[9]!==m||e[10]!==n||e[11]!==i?(S=(t||n||r)&&(0,q.jsx)(Re,{titleText:r?m.has(`digest`)?i?`摘要中的成果`:`Results in this digest`:i?`关注成果`:`Monitor results`:t?i?`关注详情`:`Monitor details`:i?`了解并开启`:`Explore and start`,closeLabel:r?i?`关闭关注成果`:`Close monitor results`:t?i?`关闭关注详情`:`Close monitor details`:i?`关闭关注设置`:`Close monitor setup`,backTo:h,backLabel:i?`返回成果`:`Back to results`,restoreSelector:r?`[data-scene-inbox]`:t?`[data-scene-id="${CSS.escape(t)}"]`:`[data-scene-template="${CSS.escape(n)}"]`,children:r?(0,q.jsx)(He,{}):t?(0,q.jsx)(Ke,{id:t}):(0,q.jsx)(We,{templateKey:n})},t??n??`inbox`),e[6]=t,e[7]=r,e[8]=h,e[9]=m,e[10]=n,e[11]=i,e[12]=S):S=e[12];let C;e[13]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>l.current?.focus(),e[13]=C):C=e[13];let w;e[14]!==a||e[15]!==i?(w=(0,q.jsx)(ce,{zh:i,open:a,onOpenChange:s,onCloseAutoFocus:C}),e[14]=a,e[15]=i,e[16]=w):w=e[16];let T;return e[17]!==S||e[18]!==w?(T=(0,q.jsxs)(q.Fragment,{children:[x,S,w]}),e[17]=S,e[18]=w,e[19]=T):T=e[19],T}function Fe(e){return e.clearPageHeader}function Ie(e){return e.setPageHeader}function Le(e){return e.language}function Re(e){let t=(0,U.c)(29),{titleText:n,closeLabel:r,restoreSelector:i,backTo:a,backLabel:o,children:c}=e,l=s(),u=(0,H.useRef)(null),f;t[0]===l?f=t[1]:(f=()=>l(`/scenes`,{replace:!0}),t[0]=l,t[1]=f);let p=f,m;t[2]===p?m=t[3]:(m=e=>{e||p()},t[2]=p,t[3]=m);let h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,q.jsx)(x,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),t[4]=h):h=t[4];let _;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(_=e=>{e.preventDefault(),u.current?.focus()},t[5]=_):_=t[5];let v;t[6]===i?v=t[7]:(v=e=>{e.preventDefault(),document.querySelector(i)?.focus()},t[6]=i,t[7]=v);let y;t[8]!==o||t[9]!==a?(y=a&&(0,q.jsx)(j,{asChild:!0,variant:`ghost`,className:`size-9 shrink-0 p-0`,children:(0,q.jsx)(d,{to:a,replace:!0,"aria-label":o,title:o,children:(0,q.jsx)(z,{size:18,"aria-hidden":`true`})})}),t[8]=o,t[9]=a,t[10]=y):y=t[10];let b;t[11]===n?b=t[12]:(b=(0,q.jsx)(E,{ref:u,tabIndex:-1,className:`min-w-0 flex-1 text-base font-semibold text-fg outline-none`,children:n}),t[11]=n,t[12]=b);let S;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,q.jsx)(g,{size:18,"aria-hidden":`true`}),t[13]=S):S=t[13];let O;t[14]===r?O=t[15]:(O=(0,q.jsx)(C,{asChild:!0,children:(0,q.jsx)(j,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":r,title:r,children:S})}),t[14]=r,t[15]=O);let k;t[16]!==y||t[17]!==b||t[18]!==O?(k=(0,q.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-edge px-4 py-3 sm:px-6`,children:[y,b,O]}),t[16]=y,t[17]=b,t[18]=O,t[19]=k):k=t[19];let A;t[20]===c?A=t[21]:(A=(0,q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-4 sm:p-6`,children:(0,q.jsx)(`div`,{className:`space-y-6`,children:c})}),t[20]=c,t[21]=A);let M;t[22]!==k||t[23]!==A||t[24]!==v?(M=(0,q.jsxs)(w,{children:[h,(0,q.jsxs)(T,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(52rem,calc(100dvh-2rem))] w-[min(52rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-float focus:outline-none`,"aria-describedby":void 0,onOpenAutoFocus:_,onCloseAutoFocus:v,children:[k,A]})]}),t[22]=k,t[23]=A,t[24]=v,t[25]=M):M=t[25];let N;return t[26]!==M||t[27]!==m?(N=(0,q.jsx)(D,{open:!0,onOpenChange:m,children:M}),t[26]=M,t[27]=m,t[28]=N):N=t[28],N}function ze(){let e=(0,U.c)(48),{activationId:t}=u(),n=y(Be)===`zh`,[r,i]=c(),a;e[0]===r?a=e[1]:(a=r.get(`after`)??``,e[0]=r,e[1]=a);let o=a,s=k(`/templates`,W),l=k(`/activations?limit=20&afterId=${encodeURIComponent(o)}`,W),f=l.mutate,p,m;if(e[2]!==t||e[3]!==f?(p=()=>{t||f()},m=[t,f],e[2]=t,e[3]=f,e[4]=p,e[5]=m):(p=e[4],m=e[5]),(0,H.useEffect)(p,m),s.error||l.error){let t=s.error??l.error,n;e[6]!==l||e[7]!==s?(n=()=>{s.mutate(),l.mutate()},e[6]=l,e[7]=s,e[8]=n):n=e[8];let r;return e[9]!==t||e[10]!==n?(r=(0,q.jsx)($,{error:t,retry:n}),e[9]=t,e[10]=n,e[11]=r):r=e[11],r}if(!s.data||!l.data){let t;return e[12]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,q.jsx)(Q,{}),e[12]=t):t=e[12],t}let h=n?`你想先轻松一点的事`:`Where could you use a little help?`,g;e[13]===h?g=e[14]:(g=(0,q.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:h}),e[13]=h,e[14]=g);let _;if(e[15]!==s.data.templates||e[16]!==n){let t;e[18]===n?t=e[19]:(t=e=>(0,q.jsxs)(`article`,{className:`${Z} space-y-3`,children:[(0,q.jsx)(L,{className:`text-fg-muted`,size:20,"aria-hidden":`true`}),(0,q.jsx)(`h3`,{className:`text-balance font-medium text-fg`,children:e.title}),(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.description}),(0,q.jsx)(j,{asChild:!0,children:(0,q.jsx)(d,{"data-scene-template":e.key,to:`/scenes/new/${encodeURIComponent(e.key)}?version=${encodeURIComponent(e.version)}`,children:n?`了解并开启`:`Explore and start`})})]},`${e.key}:${e.version}`),e[18]=n,e[19]=t),_=s.data.templates.map(t),e[15]=s.data.templates,e[16]=n,e[17]=_}else _=e[17];let v;e[20]===_?v=e[21]:(v=(0,q.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:_}),e[20]=_,e[21]=v);let b;e[22]!==g||e[23]!==v?(b=(0,q.jsxs)(`section`,{className:`space-y-3`,children:[g,v]}),e[22]=g,e[23]=v,e[24]=b):b=e[24];let x=n?`我的关注`:`My monitors`,S;e[25]===x?S=e[26]:(S=(0,q.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:x}),e[25]=x,e[26]=S);let C;e[27]!==l.data.activations||e[28]!==n?(C=l.data.activations.length?l.data.activations.map(e=>(0,q.jsxs)(d,{to:`/scenes/${e.id}`,"data-scene-id":e.id,className:`${Z} block space-y-2 transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,q.jsx)(`p`,{className:`break-words font-medium text-fg`,children:e.goal}),(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:Oe(e.status===`active`&&e.setupMissing?.length?`needs_setup`:e.status,n)})]},e.id)):(0,q.jsxs)(`div`,{className:`${Z} space-y-2`,children:[(0,q.jsx)(te,{"aria-hidden":`true`,className:`text-fg-muted`}),(0,q.jsx)(`p`,{className:`text-fg`,children:n?`还没有开启智能关注`:`No monitors yet`}),(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`从上面选择一件你希望 AI 帮忙照看的事。`:`Choose something above that you would like AI to monitor.`})]}),e[27]=l.data.activations,e[28]=n,e[29]=C):C=e[29];let w;e[30]!==o||e[31]!==i||e[32]!==n?(w=o&&(0,q.jsx)(j,{onClick:()=>i({}),children:n?`返回第一页`:`First page`}),e[30]=o,e[31]=i,e[32]=n,e[33]=w):w=e[33];let T;e[34]!==l.data.nextCursor||e[35]!==i||e[36]!==n?(T=l.data.nextCursor&&(0,q.jsx)(j,{onClick:()=>i({after:l.data.nextCursor}),children:n?`下一页`:`Next page`}),e[34]=l.data.nextCursor,e[35]=i,e[36]=n,e[37]=T):T=e[37];let E;e[38]!==w||e[39]!==T?(E=(0,q.jsxs)(`div`,{className:`flex gap-3`,children:[w,T]}),e[38]=w,e[39]=T,e[40]=E):E=e[40];let D;e[41]!==C||e[42]!==E||e[43]!==S?(D=(0,q.jsxs)(`section`,{className:`space-y-3`,children:[S,C,E]}),e[41]=C,e[42]=E,e[43]=S,e[44]=D):D=e[44];let O;return e[45]!==D||e[46]!==b?(O=(0,q.jsxs)(q.Fragment,{children:[b,D]}),e[45]=D,e[46]=b,e[47]=O):O=e[47],O}function Be(e){return e.language}function Ve(e){let t=(0,U.c)(20),{zh:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={refreshInterval:15e3,shouldRetryOnError:!1},t[0]=r):r=t[0];let i=k(`/metrics`,W,r),a;t[1]===n?a=t[2]:(a=n?[`有帮助的成果`,`没有帮助的成果`,`带来帮助的关注`]:[`Helpful results`,`Unhelpful results`,`Monitors that helped`],t[1]=n,t[2]=a);let o=a,s,c,l,u;if(t[3]!==o||t[4]!==i||t[5]!==n){let e=i.data?[i.data.usefulOutcomes,i.data.unhelpfulOutcomes,i.data.scenesWithUsefulOutcomes]:[],r=new Intl.NumberFormat(n?`zh-CN`:`en`);s=`${Z} space-y-3`,c=n?`反馈概览`:`Feedback overview`;let a=n?`最近 7 天的反馈`:`Feedback in the last 7 days`;t[10]===a?l=t[11]:(l=(0,q.jsx)(`h2`,{className:`text-balance text-base font-semibold text-fg`,children:a}),t[10]=a,t[11]=l),u=i.error?(0,q.jsxs)(`div`,{role:`alert`,className:`space-y-2`,children:[(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`暂时无法加载统计,仍可查看和评价成果。`:`Stats are unavailable. You can still view and rate results.`}),(0,q.jsx)(j,{disabled:i.isValidating,onClick:()=>void i.mutate(),children:n?`重新加载统计`:`Reload stats`})]}):(0,q.jsx)(`dl`,{className:`grid gap-4 sm:grid-cols-3`,"aria-busy":!i.data,children:o.map((t,n)=>(0,q.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,q.jsx)(`dt`,{className:`text-sm text-fg-muted`,children:t}),(0,q.jsx)(`dd`,{className:`text-xl font-semibold tabular-nums text-fg`,children:i.data?r.format(e[n]):(0,q.jsx)(N,{className:`h-7 w-12`})})]},t))}),t[3]=o,t[4]=i,t[5]=n,t[6]=s,t[7]=c,t[8]=l,t[9]=u}else s=t[6],c=t[7],l=t[8],u=t[9];let d=n?`按你这段时间的明确反馈统计,每份成果取最新评价。已读和检查成功不计入,也不代表已采纳或节省时间。`:`Counts your explicit feedback during this period, using the latest rating per result. Reads and successful checks do not count. This does not measure adoption or time saved.`,f;t[12]===d?f=t[13]:(f=(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:d}),t[12]=d,t[13]=f);let p;return t[14]!==s||t[15]!==c||t[16]!==l||t[17]!==u||t[18]!==f?(p=(0,q.jsxs)(`section`,{className:s,"aria-label":c,children:[l,u,f]}),t[14]=s,t[15]=c,t[16]=l,t[17]=u,t[18]=f,t[19]=p):p=t[19],p}function He(){let e=(0,U.c)(42),t=y(Ue)===`zh`,[n,r]=c(),i;e[0]===n?i=e[1]:(i=n.get(`after`)??``,e[0]=n,e[1]=i);let a=i,o;e[2]===n?o=e[3]:(o=n.get(`digest`),e[2]=n,e[3]=o);let s=o,l;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(l={refreshInterval:15e3},e[4]=l):l=e[4];let u=k(`${s?`/digests/${encodeURIComponent(s)}`:`/outcomes`}?limit=20&afterId=${encodeURIComponent(a)}`,W,l);if(u.error){let t;e[5]===u?t=e[6]:(t=()=>void u.mutate(),e[5]=u,e[6]=t);let n;return e[7]!==u.error||e[8]!==t?(n=(0,q.jsx)($,{error:u.error,retry:t}),e[7]=u.error,e[8]=t,e[9]=n):n=e[9],n}if(!u.data){let t;return e[10]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,q.jsx)(Q,{}),e[10]=t):t=e[10],t}let f=t?`集中查看各项智能关注准备的成果,告诉 AI 哪些对你有帮助。`:`Review results across your monitors and tell AI what helps.`,p;e[11]===f?p=e[12]:(p=(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:f}),e[11]=f,e[12]=p);let m;e[13]===t?m=e[14]:(m=(0,q.jsx)(Ve,{zh:t}),e[13]=t,e[14]=m);let h=t?`成果列表`:`Results list`,g;e[15]!==s||e[16]!==n||e[17]!==u||e[18]!==t?(g=u.data.outcomes.length?u.data.outcomes.map(e=>(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsx)(fe,{item:e,zh:t,onChange:()=>void u.mutate()}),(0,q.jsx)(j,{asChild:!0,variant:`ghost`,children:(0,q.jsx)(d,{state:{fromSceneInbox:!0,inboxSearch:`?${n.toString()}`},to:`/scenes/${encodeURIComponent(e.activationId)}`,children:t?`查看所属关注`:`View monitor`})})]},e.id)):(0,q.jsxs)(`div`,{className:`${Z} space-y-3`,children:[(0,q.jsx)(re,{size:32,"aria-hidden":`true`,className:`text-fg-muted`}),(0,q.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t?`这里还没有成果`:`No results here yet`}),(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:s?t?`这份摘要中的成果目前不可查看,可能已被撤回。`:`Results in this digest are currently unavailable and may have been withdrawn.`:t?`回到智能关注,提供资料并检查一次;有新成果时会出现在这里。`:`Open a monitor, provide context and run a check. New results will appear here.`})]}),e[15]=s,e[16]=n,e[17]=u,e[18]=t,e[19]=g):g=e[19];let _;e[20]!==h||e[21]!==g?(_=(0,q.jsx)(`section`,{className:`space-y-4`,"aria-label":h,children:g}),e[20]=h,e[21]=g,e[22]=_):_=e[22];let v=t?`成果分页`:`Results pages`,b;e[23]!==a||e[24]!==s||e[25]!==r||e[26]!==t?(b=a&&(0,q.jsx)(j,{onClick:()=>r(s?{digest:s}:{}),children:t?`返回第一页`:`First page`}),e[23]=a,e[24]=s,e[25]=r,e[26]=t,e[27]=b):b=e[27];let x;e[28]!==s||e[29]!==u.data.nextCursor||e[30]!==r||e[31]!==t?(x=u.data.nextCursor&&(0,q.jsx)(j,{onClick:()=>r({...s?{digest:s}:{},after:u.data.nextCursor}),children:t?`下一页`:`Next page`}),e[28]=s,e[29]=u.data.nextCursor,e[30]=r,e[31]=t,e[32]=x):x=e[32];let S;e[33]!==b||e[34]!==x||e[35]!==v?(S=(0,q.jsxs)(`nav`,{className:`flex flex-wrap gap-3`,"aria-label":v,children:[b,x]}),e[33]=b,e[34]=x,e[35]=v,e[36]=S):S=e[36];let C;return e[37]!==S||e[38]!==p||e[39]!==m||e[40]!==_?(C=(0,q.jsxs)(q.Fragment,{children:[p,m,_,S]}),e[37]=S,e[38]=p,e[39]=m,e[40]=_,e[41]=C):C=e[41],C}function Ue(e){return e.language}function We(e){let t=(0,U.c)(10),{templateKey:n}=e,[r]=c(),i;t[0]===r?i=t[1]:(i=r.get(`version`)??`1.0.0`,t[0]=r,t[1]=i);let a=k(`/templates/${encodeURIComponent(n)}/versions/${encodeURIComponent(i)}`,W);if(a.error){let e;t[2]===a?e=t[3]:(e=()=>void a.mutate(),t[2]=a,t[3]=e);let n;return t[4]!==e||t[5]!==a.error?(n=(0,q.jsx)($,{error:a.error,retry:e}),t[4]=e,t[5]=a.error,t[6]=n):n=t[6],n}if(!a.data){let e;return t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,q.jsx)(Q,{}),t[7]=e):e=t[7],e}let o=a.data.template,s;return t[8]===o?s=t[9]:(s=o.execution.kind===`task`?(0,q.jsx)(xe,{template:o}):(0,q.jsx)(Ge,{manifest:o}),t[8]=o,t[9]=s),s}function Ge({manifest:e}){let t=y(e=>e.language)===`zh`,n=s(),[r,i]=(0,H.useState)(``),[a,o]=(0,H.useState)(``),[c,l]=(0,H.useState)(``),[u,d]=(0,H.useState)(!1),[f,p]=(0,H.useState)(!1),[m,h]=(0,H.useState)(),[g,_]=(0,H.useState)(!1),v=(0,H.useRef)({content:``,id:``}),b=(0,H.useRef)(``),x=!!(r||c||u)&&!g;(0,H.useEffect)(()=>{g&&n(b.current,{replace:!0})},[g,n]);let S=e.contextProviders.includes(`mail`),C=async t=>{t.preventDefault(),p(!0),h(void 0);let n={templateKey:e.key,templateVersion:e.version,goal:r,scope:S?{kind:`objects`,ids:[c.trim()]}:{kind:`personal`},permissions:{accountIds:S?[a.trim()]:[],contextProviders:e.contextProviders,effectHandlers:[]}},i=JSON.stringify(n);v.current.content!==i&&(v.current={content:i,id:crypto.randomUUID()});try{b.current=`/scenes/${(await G(`/activations`,`POST`,n,v.current.id)).activation.id}`,_(!0)}catch(e){h(e)}finally{p(!1)}};return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(J,{dirty:x,zh:t}),(0,q.jsxs)(`header`,{children:[(0,q.jsx)(`h1`,{className:`text-wrap text-xl font-semibold text-fg`,children:e.title}),(0,q.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:e.description})]}),(0,q.jsx)(`form`,{onSubmit:e=>void C(e),className:`${Z} space-y-5`,children:(0,q.jsxs)(`fieldset`,{disabled:f||g,className:`space-y-5`,children:[(0,q.jsxs)(`label`,{className:De,children:[t?`希望它持续帮你做好什么?`:`What should it keep helping you with?`,(0,q.jsx)(`textarea`,{required:!0,maxLength:4e3,rows:3,value:r,onChange:e=>i(e.target.value),className:Ee,autoComplete:`off`})]}),S&&(0,q.jsx)(ge,{value:c,disabled:f||g,zh:t,onChange:e=>{o(e.accountId),l(e.id),d(!1)}}),(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t?`只准备草稿和建议,不发送消息、不执行外部写操作。下一步需补齐资料和检查时间;完成后才会自动检查。`:`Prepares drafts and suggestions only. No messages or external writes. Next, complete the context and timing settings for automatic checks.`}),(0,q.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm text-fg`,children:[(0,q.jsx)(`input`,{required:!0,type:`checkbox`,className:`ui-checkbox`,checked:u,onChange:e=>d(e.target.checked)}),t?`确认以上范围,允许读取我提供的资料。`:`I confirm this scope and allow reading the information I provide.`]}),!!m&&(0,q.jsx)($,{error:m}),(0,q.jsx)(j,{type:`submit`,variant:`primary`,disabled:f||g||S&&!c,children:f?t?`正在开启…`:`Starting…`:t?`继续设置`:`Continue setup`})]})})]})}function Ke(e){let t=(0,U.c)(7),{id:n}=e,r=k(`/activations/${encodeURIComponent(n)}`,W);if(r.error){let e;return t[0]===r.error?e=t[1]:(e=(0,q.jsx)($,{error:r.error}),t[0]=r.error,t[1]=e),e}if(!r.data){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,q.jsx)(Q,{}),t[2]=e):e=t[2],e}let i;return t[3]!==r.data.details||t[4]!==r.data.template.execution.kind||t[5]!==n?(i=r.data.template.execution.kind===`task`&&r.data.details?(0,q.jsx)(Se,{id:n,initial:r.data.details}):(0,q.jsx)(qe,{id:n}),t[3]=r.data.details,t[4]=r.data.template.execution.kind,t[5]=n,t[6]=i):i=t[6],i}function qe({id:e}){let t=y(e=>e.language)===`zh`,[n]=c(),r=n.get(`result`),i=`/activations/${encodeURIComponent(e)}`,[a,o]=(0,H.useState)(``),[s,l]=(0,H.useState)(``),u=k(i,W,{refreshInterval:15e3}),d=k(`${i}/runs?limit=20&afterId=${encodeURIComponent(a)}`,W,{refreshInterval:5e3}),f=k(`/outcomes?limit=20&activationId=${encodeURIComponent(e)}&afterId=${encodeURIComponent(s)}`,W,{refreshInterval:5e3}),[p,m]=(0,H.useState)(!1),[h,g]=(0,H.useState)(),[_,v]=(0,H.useState)(!1),b=(0,H.useRef)(null),[x,S]=(0,H.useState)(!1),[C,w]=(0,H.useState)(!1),[T,E]=(0,H.useState)(!1),D=x||C||T,O=async e=>{if(u.data){m(!0),g(void 0),v(!1);try{e?(b.current??=crypto.randomUUID(),await G(`${i}/checks`,`POST`,void 0,b.current),b.current=null,v(!0),o(``),l(``)):await G(i,`PATCH`,{expectedRevision:u.data.activation.revision,status:u.data.activation.status===`active`?`paused`:`active`}),await Promise.all([u.mutate(),d.mutate(),f.mutate()])}catch(e){g(e)}finally{m(!1)}}};if(u.error)return(0,q.jsx)($,{error:u.error,retry:()=>void u.mutate()});if(!u.data)return(0,q.jsx)(Q,{});let A=u.data.activation;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(J,{dirty:D,zh:t}),(0,q.jsxs)(`header`,{className:`space-y-3`,children:[(0,q.jsx)(`h1`,{className:`break-words text-wrap text-xl font-semibold text-fg`,children:A.goal}),(0,q.jsx)(ie,{resource:{kind:`scene`,id:A.id,revision:String(A.revision)},disabled:D||p}),(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:Oe(A.status===`active`&&A.setupMissing?.length?`needs_setup`:A.status,t)}),(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t?`只准备建议和成果,不自动发送或写入外部系统。`:`Prepares suggestions and results. Does not send or write to external systems.`}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,q.jsx)(j,{variant:`primary`,disabled:p||A.status!==`active`,onClick:()=>void O(!0),children:p?t?`处理中…`:`Working…`:t?`现在检查`:`Check now`}),[`active`,`paused`,`needs_setup`].includes(A.status)&&(0,q.jsxs)(j,{disabled:p,onClick:()=>void O(!1),children:[(0,q.jsx)(P,{size:16,"aria-hidden":`true`}),A.status===`active`?t?`暂停关注`:`Pause monitor`:t?`检查设置并恢复`:`Review setup and resume`]})]}),[`active`,`paused`].includes(A.status)&&(0,q.jsx)(j,{disabled:p,variant:`ghost`,onClick:()=>{m(!0),G(i,`PATCH`,{expectedRevision:A.revision,status:`completed`}).then(()=>Promise.all([u.mutate(),f.mutate(),d.mutate()])).catch(g).finally(()=>m(!1))},children:t?`结束关注(保留成果)`:`End monitor (keep results)`}),_&&(0,q.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t?`检查已排队;没有新变化时不会生成新卡片。`:`Check queued. No new card is created when nothing has changed.`})]}),h&&(0,q.jsx)($,{error:h,retry:()=>{u.mutate(),g(void 0)}}),A.status===`active`&&!!A.setupMissing?.length&&(0,q.jsxs)(`section`,{role:`status`,className:Z,children:[(0,q.jsx)(`h2`,{className:`font-medium text-fg`,children:t?`完成以下设置后,这项关注才会自动检查`:`Complete setup for automatic checks`}),(0,q.jsx)(`ul`,{className:`mt-2 list-inside list-disc text-sm text-fg-muted`,children:A.setupMissing.map(e=>(0,q.jsx)(`li`,{children:{notes:t?`填写安排和约束`:`Provide arrangements and constraints`,schedule:t?`设置周期检查时间`:`Set a recurring review time`,deadline:t?`设置邮件跟进截止时间`:`Set a mail follow-up deadline`}[e]},e))})]}),(0,q.jsx)(ae,{activationId:e,zh:t}),[`active`,`paused`,`needs_setup`].includes(A.status)&&(0,q.jsx)(Je,{activation:A,zh:t,onDirty:E,onSaved:()=>{u.mutate(),f.mutate(),d.mutate()}},A.id),A.permissions.contextProviders.includes(`user_notes`)&&(0,q.jsx)(Xe,{path:i,zh:t,onDirty:S,onSaved:()=>{u.mutate(),f.mutate(),d.mutate()}}),A.permissions.contextProviders.includes(`mail`)?(0,q.jsx)(_e,{activation:A,zh:t,onDirty:w,onChanged:()=>{u.mutate(),f.mutate(),d.mutate()}}):(0,q.jsx)(me,{activation:A,zh:t,onDirty:w,onChanged:()=>void u.mutate()}),r&&(0,q.jsx)(Ye,{activationId:e,presentationId:r,zh:t}),(0,q.jsxs)(`section`,{className:`space-y-3`,children:[(0,q.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t?`最近成果`:`Recent results`}),f.error?(0,q.jsx)($,{error:f.error,retry:()=>void f.mutate()}):f.data?f.data.outcomes.filter(t=>t.activationId===e).length===0?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t?`还没有新成果。提供资料后,可以先检查一次。`:`No new results yet. Provide context and try a check.`}):f.data.outcomes.map(e=>(0,q.jsx)(fe,{item:e,zh:t,onChange:()=>void f.mutate()},e.id)):(0,q.jsx)(Q,{}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[s&&(0,q.jsx)(j,{onClick:()=>l(``),children:t?`最近成果`:`Latest results`}),f.data?.nextCursor&&(0,q.jsx)(j,{onClick:()=>l(f.data.nextCursor),children:t?`更早成果`:`Earlier results`})]})]}),(0,q.jsxs)(`section`,{className:`space-y-3`,children:[(0,q.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t?`检查记录`:`Check history`}),d.error?(0,q.jsx)($,{error:d.error,retry:()=>void d.mutate()}):d.data?d.data.runs.length===0?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t?`尚未执行检查。`:`No checks yet.`}):(0,q.jsx)(`ul`,{className:`divide-y divide-edge`,children:d.data.runs.map(e=>(0,q.jsxs)(`li`,{className:`flex flex-wrap justify-between gap-2 py-3 text-sm`,children:[(0,q.jsxs)(`span`,{className:`text-fg`,children:[Oe(e.status,t),e.reason===`empty_input`?t?`:请先提供资料`:`: provide context first`:``]}),(0,q.jsx)(`time`,{className:`text-fg-muted`,dateTime:new Date(e.createdAt).toISOString(),children:new Intl.DateTimeFormat(t?`zh-CN`:`en`,{dateStyle:`medium`,timeStyle:`short`}).format(e.createdAt)})]},e.id))}):(0,q.jsx)(Q,{}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[a&&(0,q.jsx)(j,{onClick:()=>o(``),children:t?`最近检查`:`Latest checks`}),d.data?.nextCursor&&(0,q.jsx)(j,{onClick:()=>o(d.data.nextCursor),children:t?`更早检查`:`Earlier checks`})]})]})]})}function Je(e){let t=(0,U.c)(45),{activation:n,zh:r,onDirty:i,onSaved:a}=e,[o,s]=(0,H.useState)(null),c=o?.goal??n.goal,[l,u]=(0,H.useState)(!1),[d,f]=(0,H.useState)(),p,m;t[0]!==n.goal||t[1]!==c||t[2]!==i?(p=()=>(i(c!==n.goal),()=>i(!1)),m=[c,n.goal,i],t[0]=n.goal,t[1]=c,t[2]=i,t[3]=p,t[4]=m):(p=t[3],m=t[4]),(0,H.useEffect)(p,m);let h=r?`修改目标`:`Edit goal`,g;t[5]===h?g=t[6]:(g=(0,q.jsx)(`summary`,{className:`cursor-pointer`,children:h}),t[5]=h,t[6]=g);let _=r?`保存后暂停检查并撤回旧建议。确认设置后恢复;邮件跟进时间需另行恢复。`:`Saving pauses checks and withdraws previous suggestions. Review settings before resuming, including mail deadlines.`,v;t[7]===_?v=t[8]:(v=(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:_}),t[7]=_,t[8]=v);let y=r?`新目标`:`New goal`,b;t[9]===n?b=t[10]:(b=e=>s(t=>({base:t?.base??n,goal:e.target.value})),t[9]=n,t[10]=b);let x;t[11]!==l||t[12]!==c||t[13]!==b?(x=(0,q.jsx)(`textarea`,{disabled:l,value:c,maxLength:4e3,onChange:b,className:Ee}),t[11]=l,t[12]=c,t[13]=b,t[14]=x):x=t[14];let S;t[15]!==y||t[16]!==x?(S=(0,q.jsxs)(`label`,{className:De,children:[y,x]}),t[15]=y,t[16]=x,t[17]=S):S=t[17];let C;t[18]!==n.goal||t[19]!==l||t[20]!==c?(C=l||!c.trim()||c===n.goal,t[18]=n.goal,t[19]=l,t[20]=c,t[21]=C):C=t[21];let w;t[22]!==n||t[23]!==o?.base||t[24]!==c||t[25]!==a?(w=()=>{u(!0),f(void 0);let e=o?.base??n;G(`/activations/${n.id}`,`PATCH`,{expectedRevision:e.revision,goal:c,scope:e.scope,permissions:e.permissions}).then(()=>{s(null),a()}).catch(f).finally(()=>u(!1))},t[22]=n,t[23]=o?.base,t[24]=c,t[25]=a,t[26]=w):w=t[26];let T=r?`保存目标`:`Save goal`,E;t[27]!==C||t[28]!==w||t[29]!==T?(E=(0,q.jsx)(j,{disabled:C,onClick:w,children:T}),t[27]=C,t[28]=w,t[29]=T,t[30]=E):E=t[30];let D;t[31]!==l||t[32]!==o||t[33]!==r?(D=o&&(0,q.jsx)(j,{type:`button`,variant:`ghost`,disabled:l,onClick:()=>{s(null),f(void 0)},children:r?`放弃修改`:`Discard edits`}),t[31]=l,t[32]=o,t[33]=r,t[34]=D):D=t[34];let O;t[35]!==d||t[36]!==r?(O=d!=null&&(0,q.jsx)(`p`,{role:`alert`,className:`text-danger`,children:K(d,r)}),t[35]=d,t[36]=r,t[37]=O):O=t[37];let k;return t[38]!==S||t[39]!==E||t[40]!==D||t[41]!==O||t[42]!==g||t[43]!==v?(k=(0,q.jsxs)(`details`,{className:`${Z} space-y-3`,children:[g,v,S,E,D,O]}),t[38]=S,t[39]=E,t[40]=D,t[41]=O,t[42]=g,t[43]=v,t[44]=k):k=t[44],k}function Ye(e){let t=(0,U.c)(15),{activationId:n,presentationId:r,zh:i}=e,a=k(`/presentations/${encodeURIComponent(r)}`,W);if(a.error){let e;return t[0]===a.error?e=t[1]:(e=(0,q.jsx)($,{error:a.error}),t[0]=a.error,t[1]=e),e}if(!a.data){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,q.jsx)(Q,{}),t[2]=e):e=t[2],e}if(a.data.outcome.activationId!==n){let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,q.jsx)($,{error:{status:404}}),t[3]=e):e=t[3],e}let o=i?`通知中的成果`:`Result from notification`,s;t[4]===o?s=t[5]:(s=(0,q.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:o}),t[4]=o,t[5]=s);let c;t[6]===a?c=t[7]:(c=()=>void a.mutate(),t[6]=a,t[7]=c);let l;t[8]!==a.data.outcome||t[9]!==c||t[10]!==i?(l=(0,q.jsx)(fe,{item:a.data.outcome,zh:i,onChange:c},a.data.outcome.id),t[8]=a.data.outcome,t[9]=c,t[10]=i,t[11]=l):l=t[11];let u;return t[12]!==s||t[13]!==l?(u=(0,q.jsxs)(`section`,{className:`space-y-3`,children:[s,l]}),t[12]=s,t[13]=l,t[14]=u):u=t[14],u}function Xe({path:e,zh:t,onSaved:n,onDirty:r}){let i=k(`${e}/notes`,W,{revalidateOnFocus:!1}),[a,o]=(0,H.useState)(null),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(),d=a!==null&&a.content!==i.data?.notes.content;if((0,H.useEffect)(()=>(r(d),()=>r(!1)),[d,r]),i.error)return(0,q.jsx)($,{error:i.error,retry:()=>void i.mutate()});if(!i.data)return(0,q.jsx)(Q,{});let f=async t=>{t.preventDefault(),c(!0),u(void 0);try{let{content:t,revision:r,validUntil:s}=a??i.data.notes,c=await G(`${e}/notes`,`PATCH`,{expectedRevision:r,content:t,validUntil:s});await i.mutate({notes:{content:t.trim(),revision:c.revision,validUntil:s}},{revalidate:!1}),o(null),n()}catch(e){u(e)}finally{c(!1)}};return(0,q.jsxs)(`form`,{onSubmit:e=>void f(e),className:`${Z} space-y-3`,children:[(0,q.jsxs)(`label`,{className:De,children:[t?`你愿意提供的安排和约束`:`Arrangements and constraints you choose to share`,(0,q.jsx)(`textarea`,{disabled:s,rows:5,maxLength:32e3,className:Ee,value:a?.content??i.data.notes.content,onChange:e=>o(t=>({...t??i.data.notes,content:e.target.value})),autoComplete:`off`})]}),(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t?`只用于这项关注,不会因此访问其他家庭成员的数据。修改资料会撤回旧计划。`:`Used only by this monitor. Does not grant access to other family members. Editing withdraws the previous plan.`}),!!l&&(0,q.jsx)($,{error:l}),(0,q.jsx)(j,{type:`submit`,disabled:s||!d,children:s?t?`正在保存…`:`Saving…`:t?`保存资料`:`Save context`}),d&&(0,q.jsx)(j,{type:`button`,disabled:s,variant:`ghost`,onClick:()=>{o(null),u(void 0),i.mutate()},children:t?`放弃修改并重新加载`:`Discard edits and reload`})]})}export{Ae as ScenesPage};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{g as i}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{n as a,r as o}from"./popover-select-0p9PIHRy.js";import{t as s}from"./download-Dk-ZjtO6.js";import{t as c}from"./folder-open-CyzJ19I9.js";import{t as l}from"./minimize-2-DtOGrlpo.js";import{t as u}from"./plus-Q2yW6OE7.js";import{t as d}from"./search-DA7gz22f.js";import{t as f}from"./x-B_N4OPjy.js";import{t as p}from"./messages-DsUnS7rn.js";import{t as m}from"./cn-JdwAhgNB.js";import{a as h,c as g,n as _,r as v}from"./locale-store-7F4l6DRV.js";import{a as ee,n as y,o as b,r as x,s as S,t as te}from"./dist-BGTk37IG.js";import{a as C,c as w,f as T,n as E,o as D,p as O,r as k,s as A,t as j}from"./session-api-C7i3UFhq.js";import{i as M}from"./vendor-swr-BIWyz7Rc.js";import{t as N}from"./button-CS04eWY9.js";import{n as P,r as F}from"./gateway-config-swr-Hn1vj6uI.js";import{n as I,t as L}from"./registry-api-DU915Prn.js";import{t as R}from"./skeleton-BwbyijEw.js";import{i as ne,o as re}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{$c as z,Aa as B,Al as V,Ca as H,Ds as U,Eu as ie,Fc as W,Jt as ae,L as oe,Mo as G,Na as se,Nl as ce,Oi as le,Os as K,Pa as ue,Qc as q,Ta as de,_u as fe,fu as pe,jl as me,ml as he,nd as ge,pc as _e,qt as ve,rd as ye,wa as J}from"./index-CdvabjRm.js";import{t as be}from"./page-tabs-Bp0yPTYw.js";import{n as xe,r as Se}from"./settings-page-layout-X1x-2Cp9.js";import{n as Ce,t as Y}from"./settings-form-section-DziWi7ar.js";import{n as we,t as Te}from"./use-autosave-CujxcROb.js";import{t as Ee}from"./settings-advanced-gate-CPyqCG90.js";var X=e(t(),1),De=n(),Z=r();function Oe(e){let t=new Date(e),n=Math.floor((new Date().getTime()-t.getTime())/(1e3*60*60*24));return n===0?t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):n===1?`Yesterday`:n<7?t.toLocaleDateString([],{weekday:`short`}):t.toLocaleDateString([],{month:`short`,day:`numeric`})}function ke(e,t){return new Intl.NumberFormat(t===`zh`?`zh-CN`:`en-US`).format(e)}function Ae(e){return`$${Number(e).toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:6})}`}function je(e){let t=(0,De.c)(124),{session:n,variant:r,labels:i,sessionAgentId:a,sessionAgentAvatar:o,onOpen:c,onAction:l}=e,u;t[0]!==i.unnamedSession||t[1]!==n.name?(u=n.name?.trim()||i.unnamedSession,t[0]=i.unnamedSession,t[1]=n.name,t[2]=u):u=t[2];let d=u,f=_(Fe),h;t[3]!==f||t[4]!==n?(h=ue(n,p(f).sidebar.sessionFilters),t[3]=f,t[4]=n,t[5]=h):h=t[5];let g=h,v;t[6]===n.name?v=t[7]:(v=n.name?.trim(),t[6]=n.name,t[7]=v);let ee=!!v,y=n.status===`archived`,b=n.status===`pinned`,x=n.usage,S;t[8]!==i.costUnknown||t[9]!==i.noUsage||t[10]!==x?(S=x?.calls?x.costCompleteness===`unknown`?i.costUnknown:`${x.costCompleteness===`partial`?`≥ `:`≈ `}${Ae(x.knownCostUsd)}`:i.noUsage,t[8]=i.costUnknown,t[9]=i.noUsage,t[10]=x,t[11]=S):S=t[11];let te=S,C=x?.calls?x.costCompleteness===`partial`?i.costPartial:x.costCompleteness===`unknown`?i.costUnknown:i.cost:i.noUsage,w=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,T;t[12]===w?T=t[13]:(T=m(`group flex min-w-0 w-full max-w-full cursor-pointer flex-col rounded-xl bg-surface-base text-left transition-colors duration-150 ease-out`,`hover:bg-surface-hover active:scale-[0.99]`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,w),t[12]=w,t[13]=T);let E;t[14]===c?E=t[15]:(E=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},t[14]=c,t[15]=E);let D=r===`list`&&`sm:py-3`,O;t[16]===D?O=t[17]:(O=m(`flex min-w-0 items-start justify-between gap-2 bg-surface-hover/35 px-3 py-2 dark:bg-surface-hover/25`,D),t[16]=D,t[17]=O);let k;t[18]===n?k=t[19]:(k=(0,Z.jsx)(se,{sourceChannel:n.sourceChannel,session:n,className:`size-3.5`}),t[18]=n,t[19]=k);let A;t[20]===g?A=t[21]:(A=(0,Z.jsx)(`span`,{className:`truncate text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:g}),t[20]=g,t[21]=A);let j;t[22]!==k||t[23]!==A?(j=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[k,A]}),t[22]=k,t[23]=A,t[24]=j):j=t[24];let M;t[25]===b?M=t[26]:(M=b?(0,Z.jsx)(z,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[25]=b,t[26]=M);let N;t[27]===n.updatedAt?N=t[28]:(N=Oe(n.updatedAt),t[27]=n.updatedAt,t[28]=N);let P;t[29]===N?P=t[30]:(P=(0,Z.jsx)(`span`,{children:N}),t[29]=N,t[30]=P);let F;t[31]!==M||t[32]!==P?(F=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,children:[M,P]}),t[31]=M,t[32]=P,t[33]=F):F=t[33];let I;t[34]!==j||t[35]!==F||t[36]!==O?(I=(0,Z.jsxs)(`div`,{className:O,children:[j,F]}),t[34]=j,t[35]=F,t[36]=O,t[37]=I):I=t[37];let L=r===`list`&&`sm:py-3`,R;t[38]===L?R=t[39]:(R=m(`min-w-0 flex-1 px-3 py-2`,L),t[38]=L,t[39]=R);let ne=r===`list`&&`sm:items-start`,re;t[40]===ne?re=t[41]:(re=m(`flex gap-3`,ne),t[40]=ne,t[41]=re);let B;t[42]!==o||t[43]!==a?(B=(0,Z.jsx)(oe,{agentId:a,avatar:o,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}),t[42]=o,t[43]=a,t[44]=B):B=t[44];let V;t[45]===d?V=t[46]:(V=(0,Z.jsx)(`div`,{className:`min-w-0 max-w-full truncate text-sm font-semibold text-fg`,title:d,children:d}),t[45]=d,t[46]=V);let H;t[47]!==n.key||t[48]!==ee?(H=ee?(0,Z.jsx)(`div`,{className:`mt-0.5 min-w-0 max-w-full truncate font-mono text-[11px] text-fg-subtle`,title:n.key,children:n.key}):null,t[47]=n.key,t[48]=ee,t[49]=H):H=t[49];let ie;t[50]!==V||t[51]!==H?(ie=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[V,H]}),t[50]=V,t[51]=H,t[52]=ie):ie=t[52];let W;t[53]!==re||t[54]!==B||t[55]!==ie?(W=(0,Z.jsxs)(`div`,{className:re,children:[B,ie]}),t[53]=re,t[54]=B,t[55]=ie,t[56]=W):W=t[56];let ae;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,Z.jsx)(he,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[57]=ae):ae=t[57];let G;t[58]===n.messageCount?G=t[59]:(G=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[ae,n.messageCount]}),t[58]=n.messageCount,t[59]=G);let ce;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,Z.jsx)(pe,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[60]=ce):ce=t[60];let le=x?.totalTokens??0,K;t[61]!==f||t[62]!==le?(K=ke(le,f),t[61]=f,t[62]=le,t[63]=K):K=t[63];let de;t[64]!==i.tokens||t[65]!==K?(de=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[ce,K,` `,i.tokens]}),t[64]=i.tokens,t[65]=K,t[66]=de):de=t[66];let me;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,Z.jsx)(fe,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[67]=me):me=t[67];let ve;t[68]!==te||t[69]!==C?(ve=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,title:C,children:[me,te]}),t[68]=te,t[69]=C,t[70]=ve):ve=t[70];let J;t[71]!==G||t[72]!==de||t[73]!==ve?(J=(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[G,de,ve]}),t[71]=G,t[72]=de,t[73]=ve,t[74]=J):J=t[74];let be;t[75]===n.tags?be=t[76]:(be=n.tags.length>0?(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n.tags.slice(0,3).map(Pe),n.tags.length>3?(0,Z.jsxs)(`span`,{className:`text-[11px] text-fg-disabled`,children:[`+`,n.tags.length-3]}):null]}):null,t[75]=n.tags,t[76]=be);let xe;t[77]!==R||t[78]!==W||t[79]!==J||t[80]!==be?(xe=(0,Z.jsxs)(`div`,{className:R,children:[W,J,be]}),t[77]=R,t[78]=W,t[79]=J,t[80]=be,t[81]=xe):xe=t[81];let Se;t[82]===l?Se=t[83]:(Se=()=>l(`continue`),t[82]=l,t[83]=Se);let Ce;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=(0,Z.jsx)(he,{className:`size-4`,strokeWidth:1.75}),t[84]=Ce):Ce=t[84];let Y;t[85]!==i.continueChat||t[86]!==Se?(Y=(0,Z.jsx)(`button`,{type:`button`,className:U,title:i.continueChat,"aria-label":i.continueChat,onClick:Se,children:Ce}),t[85]=i.continueChat,t[86]=Se,t[87]=Y):Y=t[87];let we;t[88]!==y||t[89]!==i.archive||t[90]!==i.unarchive||t[91]!==l?(we=y?(0,Z.jsx)(`button`,{type:`button`,className:U,title:i.unarchive,"aria-label":i.unarchive,onClick:()=>l(`unarchive`),children:(0,Z.jsx)(ye,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:U,title:i.archive,"aria-label":i.archive,onClick:()=>l(`archive`),children:(0,Z.jsx)(ge,{className:`size-4`,strokeWidth:1.75})}),t[88]=y,t[89]=i.archive,t[90]=i.unarchive,t[91]=l,t[92]=we):we=t[92];let Te;t[93]!==b||t[94]!==i.pin||t[95]!==i.unpin||t[96]!==l?(Te=b?(0,Z.jsx)(`button`,{type:`button`,className:U,title:i.unpin,"aria-label":i.unpin,onClick:()=>l(`unpin`),children:(0,Z.jsx)(q,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:U,title:i.pin,"aria-label":i.pin,onClick:()=>l(`pin`),children:(0,Z.jsx)(z,{className:`size-4`,strokeWidth:1.75})}),t[93]=b,t[94]=i.pin,t[95]=i.unpin,t[96]=l,t[97]=Te):Te=t[97];let Ee;t[98]===l?Ee=t[99]:(Ee=()=>l(`export`),t[98]=l,t[99]=Ee);let X;t[100]===Symbol.for(`react.memo_cache_sentinel`)?(X=(0,Z.jsx)(s,{className:`size-4`,strokeWidth:1.75}),t[100]=X):X=t[100];let je;t[101]!==i.export||t[102]!==Ee?(je=(0,Z.jsx)(`button`,{type:`button`,className:U,title:i.export,"aria-label":i.export,onClick:Ee,children:X}),t[101]=i.export,t[102]=Ee,t[103]=je):je=t[103];let Ie;t[104]===Symbol.for(`react.memo_cache_sentinel`)?(Ie=m(U,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),t[104]=Ie):Ie=t[104];let Le;t[105]===l?Le=t[106]:(Le=()=>l(`delete`),t[105]=l,t[106]=Le);let Re;t[107]===Symbol.for(`react.memo_cache_sentinel`)?(Re=(0,Z.jsx)(_e,{className:`size-4`,strokeWidth:1.75}),t[107]=Re):Re=t[107];let ze;t[108]!==i.delete||t[109]!==Le?(ze=(0,Z.jsx)(`button`,{type:`button`,className:Ie,title:i.delete,"aria-label":i.delete,onClick:Le,children:Re}),t[108]=i.delete,t[109]=Le,t[110]=ze):ze=t[110];let Be;t[111]!==Y||t[112]!==we||t[113]!==Te||t[114]!==je||t[115]!==ze?(Be=(0,Z.jsxs)(`div`,{role:`group`,className:`m-1 mt-0 flex flex-wrap items-center gap-0.5 rounded-lg bg-surface-hover/35 p-1.5`,onClick:Ne,onKeyDown:Me,children:[Y,we,Te,je,ze]}),t[111]=Y,t[112]=we,t[113]=Te,t[114]=je,t[115]=ze,t[116]=Be):Be=t[116];let Q;return t[117]!==c||t[118]!==I||t[119]!==xe||t[120]!==Be||t[121]!==T||t[122]!==E?(Q=(0,Z.jsxs)(`div`,{role:`button`,tabIndex:0,className:T,onClick:c,onKeyDown:E,children:[I,xe,Be]}),t[117]=c,t[118]=I,t[119]=xe,t[120]=Be,t[121]=T,t[122]=E,t[123]=Q):Q=t[123],Q}function Me(e){return e.stopPropagation()}function Ne(e){return e.stopPropagation()}function Pe(e){return(0,Z.jsx)(`span`,{className:`max-w-full break-words rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e},e)}function Fe(e){return e.language}function Ie(e,t){return e.routing?.agentId?.trim().toLowerCase()||t.trim().toLowerCase()||`main`}function Le(e,t){return t.find(t=>t.id===e)?.avatar}var Re={enabled:!0,triggerThreshold:.8,reserveTokens:8192,minMessagesBeforeCompact:10,keepRecentTokens:2e4,recentTurnsPreserve:3,summaryMaxTokens:16e3,summaryChunkTokens:24e3,summaryTimeoutMs:18e4,summaryRetries:2,qualityGuard:!0,gapAudit:!0,minToolResultKeepChars:1e3,maxActiveTranscriptBytes:2e6,postCompactionSections:[`Session Startup`,`Red Lines`]};function ze(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Be(e,t,n,r=1/0){return typeof e==`number`&&Number.isFinite(e)&&e>=n&&e<=r?e:t}function Q(e,t,n,r=1/0){return Number.isInteger(e)&&e>=n&&e<=r?e:t}function Ve(e){let t=ze(e)?e:{},n=ze(t.userContext)?t.userContext:{},r=ze(n.contextPlanning)?n.contextPlanning:{},i=ze(r.compaction)?r.compaction:{},a=Re,o=typeof i.model==`string`&&i.model.trim()?i.model.trim():void 0,s=Array.isArray(i.postCompactionSections)&&i.postCompactionSections.length<=12&&i.postCompactionSections.every(e=>typeof e==`string`&&e.trim())?[...new Set(i.postCompactionSections.map(e=>e.trim()))]:[...a.postCompactionSections];return{enabled:typeof i.enabled==`boolean`?i.enabled:a.enabled,triggerThreshold:Be(i.triggerThreshold,a.triggerThreshold,.1,.98),reserveTokens:Q(i.reserveTokens,a.reserveTokens,1024),minMessagesBeforeCompact:Q(i.minMessagesBeforeCompact,a.minMessagesBeforeCompact,2),keepRecentTokens:Q(i.keepRecentTokens,a.keepRecentTokens,1e3),recentTurnsPreserve:Q(i.recentTurnsPreserve,a.recentTurnsPreserve,1,12),summaryMaxTokens:Q(i.summaryMaxTokens,a.summaryMaxTokens,256),summaryChunkTokens:Q(i.summaryChunkTokens,a.summaryChunkTokens,1e3),summaryTimeoutMs:Q(i.summaryTimeoutMs,a.summaryTimeoutMs,1e3,6e5),summaryRetries:Q(i.summaryRetries,a.summaryRetries,0,5),qualityGuard:typeof i.qualityGuard==`boolean`?i.qualityGuard:a.qualityGuard,gapAudit:typeof i.gapAudit==`boolean`?i.gapAudit:a.gapAudit,...o?{model:o}:{},minToolResultKeepChars:Q(i.minToolResultKeepChars,a.minToolResultKeepChars,200),maxActiveTranscriptBytes:Q(i.maxActiveTranscriptBytes,a.maxActiveTranscriptBytes,64e3),postCompactionSections:s}}function He(e){return e.triggerThreshold<.1||e.triggerThreshold>.98?`triggerThreshold`:!Number.isInteger(e.reserveTokens)||e.reserveTokens<1024?`reserveTokens`:!Number.isInteger(e.minMessagesBeforeCompact)||e.minMessagesBeforeCompact<2?`minMessagesBeforeCompact`:!Number.isInteger(e.keepRecentTokens)||e.keepRecentTokens<1e3?`keepRecentTokens`:!Number.isInteger(e.recentTurnsPreserve)||e.recentTurnsPreserve<1||e.recentTurnsPreserve>12?`recentTurnsPreserve`:!Number.isInteger(e.summaryMaxTokens)||e.summaryMaxTokens<256?`summaryMaxTokens`:!Number.isInteger(e.summaryChunkTokens)||e.summaryChunkTokens<1e3?`summaryChunkTokens`:!Number.isInteger(e.summaryTimeoutMs)||e.summaryTimeoutMs<1e3||e.summaryTimeoutMs>6e5?`summaryTimeoutMs`:!Number.isInteger(e.summaryRetries)||e.summaryRetries<0||e.summaryRetries>5?`summaryRetries`:e.model!==void 0&&!e.model.trim()?`model`:!Number.isInteger(e.minToolResultKeepChars)||e.minToolResultKeepChars<200?`minToolResultKeepChars`:!Number.isInteger(e.maxActiveTranscriptBytes)||e.maxActiveTranscriptBytes<64e3?`maxActiveTranscriptBytes`:e.postCompactionSections.length>12||e.postCompactionSections.some(e=>!e.trim())?`postCompactionSections`:null}function Ue(e){let t={...e,...e.model?.trim()?{model:e.model.trim()}:{}};return e.model?.trim()||delete t.model,{userContext:{contextPlanning:{compaction:t}}}}async function We(e){await h(v(`/api/config`),{method:`PATCH`,body:JSON.stringify(Ue(e))}),await P()}var Ge=128e3,Ke={balanced:Re,preserve:{...Re,triggerThreshold:.88,keepRecentTokens:32e3,recentTurnsPreserve:5,maxActiveTranscriptBytes:4e6},early:{...Re,triggerThreshold:.65,reserveTokens:12e3,minMessagesBeforeCompact:6,keepRecentTokens:12e3,recentTurnsPreserve:2}},qe=H();function Je(){return m(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg disabled:cursor-not-allowed disabled:opacity-55`,G,`dark:border-edge`)}function Ye(e){let{enabled:t,model:n,postCompactionSections:r,...i}=e;return JSON.stringify(i)}function Xe(e){let t=Ye(e);for(let[e,n]of Object.entries(Ke))if(t===Ye(n))return e;return`custom`}function Ze(e){return e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}m`:e>=1e3?`${(e/1e3).toFixed(e%1e3==0?0:1)}k`:String(e)}function $(e){let t=(0,De.c)(20),{id:n,label:r,hint:i,value:a,min:o,max:s,step:c,disabled:l,onChange:u}=e,d=c===void 0?1:c,f;t[0]!==n||t[1]!==r?(f=(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=f):f=t[2];let p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=Je(),t[3]=p):p=t[3];let m;t[4]===u?m=t[5]:(m=e=>{if(!e.target.value.trim())return;let t=Number(e.target.value);Number.isFinite(t)&&u(t)},t[4]=u,t[5]=m);let h;t[6]!==l||t[7]!==n||t[8]!==s||t[9]!==o||t[10]!==d||t[11]!==m||t[12]!==a?(h=(0,Z.jsx)(`input`,{id:n,type:`number`,min:o,max:s,step:d,disabled:l,className:p,value:a,onChange:m}),t[6]=l,t[7]=n,t[8]=s,t[9]=o,t[10]=d,t[11]=m,t[12]=a,t[13]=h):h=t[13];let g;t[14]===i?g=t[15]:(g=i?(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}):null,t[14]=i,t[15]=g);let _;return t[16]!==f||t[17]!==h||t[18]!==g?(_=(0,Z.jsxs)(`div`,{children:[f,h,g]}),t[16]=f,t[17]=h,t[18]=g,t[19]=_):_=t[19],_}function Qe(e){let t=(0,De.c)(19),{label:n,hint:r,checked:i,disabled:a,onChange:o}=e,s=a?`cursor-not-allowed opacity-55`:`cursor-pointer`,c;t[0]===s?c=t[1]:(c=m(`flex items-start gap-2 text-sm text-fg`,s),t[0]=s,t[1]=c);let l;t[2]===o?l=t[3]:(l=e=>o(e.target.checked),t[2]=o,t[3]=l);let u;t[4]!==i||t[5]!==a||t[6]!==l?(u=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:i,disabled:a,onChange:l}),t[4]=i,t[5]=a,t[6]=l,t[7]=u):u=t[7];let d;t[8]===n?d=t[9]:(d=(0,Z.jsx)(`span`,{className:`font-medium`,children:n}),t[8]=n,t[9]=d);let f;t[10]===r?f=t[11]:(f=(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:r}),t[10]=r,t[11]=f);let p;t[12]!==d||t[13]!==f?(p=(0,Z.jsxs)(`span`,{children:[d,f]}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let h;return t[15]!==c||t[16]!==u||t[17]!==p?(h=(0,Z.jsxs)(`label`,{className:c,children:[u,p]}),t[15]=c,t[16]=u,t[17]=p,t[18]=h):h=t[18],h}function $e({hasToken:e}){let t=p(_(e=>e.language)).sessions.compaction,{data:n,isLoading:r}=F(e),{data:i=[],isLoading:a}=M(e?L:null,I,{revalidateOnFocus:!1}),o=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:Ve(n.payload.config),[n]),[s,c]=(0,X.useReducer)(qe,{form:null,baseline:null}),[d,h]=(0,X.useState)(``),g=(0,X.useRef)(!1),v=(0,X.useRef)(s.form);v.current=s.form;let ee=(0,X.useRef)(null);J({enabled:e,parsed:o,dirty:g.current,trackedParsedRef:ee,dispatch:c,onResetDirty:()=>{g.current=!1}});let y=s.form,b=s.baseline,x=!!(y&&b&&JSON.stringify(y)!==JSON.stringify(b)),S=(0,X.useCallback)(e=>{g.current=!0,c({type:`patch`,patch:e})},[]),te=(0,X.useCallback)(e=>({enabled:t.enabled,triggerThreshold:t.triggerThreshold,reserveTokens:t.reserveTokens,minMessagesBeforeCompact:t.minMessagesBeforeCompact,keepRecentTokens:t.keepRecentTokens,recentTurnsPreserve:t.recentTurnsPreserve,summaryMaxTokens:t.summaryMaxTokens,summaryChunkTokens:t.summaryChunkTokens,summaryTimeoutMs:t.summaryTimeoutSeconds,summaryRetries:t.summaryRetries,qualityGuard:t.qualityGuard,gapAudit:t.gapAudit,model:t.summaryModel,minToolResultKeepChars:t.minToolResultKeepChars,maxActiveTranscriptBytes:t.maxActiveTranscriptMb,postCompactionSections:t.postCompactionSections})[e],[t]),C=Te({value:y,dirty:x,onSave:(0,X.useCallback)(async e=>{try{await We(e),c({type:`saved`,value:e}),g.current=!!(v.current&&JSON.stringify(v.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError]),validate:e=>{let n=He(e);return n?t.invalidValue.replace(`{{field}}`,te(n)):null}});if(!e||!y)return r?(0,Z.jsx)(Y,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(R,{className:`h-5 w-48`}),(0,Z.jsx)(R,{className:`h-20 w-full rounded-xl`}),(0,Z.jsx)(R,{className:`h-36 w-full rounded-xl`})]})}):null;let w=Xe(y),T=Math.max(0,Ge-y.reserveTokens),E=Math.min(Math.floor(Ge*y.triggerThreshold),T),D=Math.min(100,E/Ge*100),O=Math.min(100,T/Ge*100),k=y.model?i.find(e=>e.id===y.model):void 0,A=k?.contextWindow&&y.summaryChunkTokens+y.summaryMaxTokens+4096>k.contextWindow,j=y.keepRecentTokens+y.reserveTokens>E,P=Math.round(y.summaryTimeoutMs*(y.summaryRetries+1)/1e3),ne=e=>{let t=Ke[e];S({...t,...y.model?{model:y.model}:{model:void 0},postCompactionSections:y.postCompactionSections})},re={balanced:{title:t.presetBalanced,hint:t.presetBalancedHint},preserve:{title:t.presetPreserve,hint:t.presetPreserveHint},early:{title:t.presetEarly,hint:t.presetEarlyHint}},z=()=>{let e=d.trim();!e||y.postCompactionSections.includes(e)||y.postCompactionSections.length>=12||(S({postCompactionSections:[...y.postCompactionSections,e]}),h(``))};return(0,Z.jsxs)(Y,{onBlurCapture:C.onBlurCapture,children:[(0,Z.jsx)(Ce,{icon:l,title:t.title,subtitle:t.hint,trailing:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(we,{status:C.status,error:C.error}),(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm font-medium text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:y.enabled,onChange:e=>S({enabled:e.target.checked})}),y.enabled?t.enabled:t.disabled]})]})}),C.error?(0,Z.jsx)(`p`,{className:`mb-4 rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700 dark:bg-red-950/40 dark:text-red-300`,role:`alert`,children:C.error}):null,y.enabled?null:(0,Z.jsx)(`p`,{className:`mb-4 rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.disabledWarning}),(0,Z.jsxs)(`fieldset`,{disabled:!y.enabled,className:`space-y-5 disabled:opacity-60`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.presetTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.presetHint})]}),w===`custom`?(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:t.presetCustom}):null]}),(0,Z.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[`balanced`,`preserve`,`early`].map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":w===e,className:m(`rounded-xl bg-surface-base/55 px-3 py-3 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,K.transition,K.focusRingPanel,w===e?`bg-accent-soft text-accent-fg shadow-surface`:`text-fg hover:bg-surface-hover`),onClick:()=>ne(e),children:[(0,Z.jsx)(`span`,{className:`block text-sm font-medium`,children:re[e].title}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:re[e].hint})]},e))})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.budgetPreview}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.budgetPreviewHint})]}),(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2.5 py-1 font-mono text-xs text-fg-muted`,children:t.previewModel128k})]}),(0,Z.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:t.compactionTrigger}),(0,Z.jsx)(`span`,{className:`font-mono text-fg`,children:Ze(E)})]}),(0,Z.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-accent`,style:{width:`${D}%`}})})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:t.hardInputLimit}),(0,Z.jsx)(`span`,{className:`font-mono text-fg`,children:Ze(T)})]}),(0,Z.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-fg-subtle`,style:{width:`${O}%`}})})]})]}),(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:t.budgetFormula})]}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)($,{id:`compaction-trigger-threshold`,label:t.triggerThreshold,hint:t.triggerThresholdHint,value:Number((y.triggerThreshold*100).toFixed(2)),min:10,max:98,step:.1,onChange:e=>S({triggerThreshold:e/100})}),(0,Z.jsx)($,{id:`compaction-reserve-tokens`,label:t.reserveTokens,hint:t.reserveTokensHint.replace(`{{tokens}}`,Ze(y.reserveTokens)),value:y.reserveTokens,min:1024,step:1024,onChange:e=>S({reserveTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-recent-turns`,label:t.recentTurnsPreserve,hint:t.recentTurnsPreserveHint,value:y.recentTurnsPreserve,min:1,max:12,onChange:e=>S({recentTurnsPreserve:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-keep-recent-tokens`,label:t.keepRecentTokens,hint:t.keepRecentTokensHint.replace(`{{tokens}}`,Ze(y.keepRecentTokens)),value:y.keepRecentTokens,min:1e3,step:1e3,onChange:e=>S({keepRecentTokens:Math.floor(e)})})]}),j?(0,Z.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.retentionWarning}):null,(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.summaryModel}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 gap-2`,children:[(0,Z.jsx)(le,{value:y.model??``,disabled:!y.enabled,placeholder:t.summaryModelInherited,searchPlaceholder:t.summaryModelSearch,noMatches:t.summaryModelNoMatches,models:i,modelsLoading:a,className:`min-w-0 flex-1 justify-between`,contentAlign:`start`,showProviderSettingsFooter:!0,onChange:e=>S({model:e})}),y.model?(0,Z.jsx)(N,{type:`button`,variant:`secondary`,onClick:()=>S({model:void 0}),children:t.summaryModelUseSession}):null]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.summaryModelHint})]}),(0,Z.jsx)(Qe,{label:t.qualityGuard,hint:t.qualityGuardHint,checked:y.qualityGuard,onChange:e=>S({qualityGuard:e})}),(0,Z.jsx)(Qe,{label:t.gapAudit,hint:t.gapAuditHint,checked:y.gapAudit,onChange:e=>S({gapAudit:e})})]}),y.qualityGuard?null:(0,Z.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.qualityGuardWarning}),(0,Z.jsx)(Ee,{children:(0,Z.jsxs)(`div`,{className:`space-y-5 rounded-xl bg-surface-base/45 p-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:t.advancedTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.advancedHint})]}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)($,{id:`compaction-min-messages`,label:t.minMessagesBeforeCompact,hint:t.minMessagesBeforeCompactHint,value:y.minMessagesBeforeCompact,min:2,onChange:e=>S({minMessagesBeforeCompact:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-max-transcript-mb`,label:t.maxActiveTranscriptMb,hint:t.maxActiveTranscriptMbHint,value:Number((y.maxActiveTranscriptBytes/1e6).toFixed(3)),min:.064,step:.1,onChange:e=>S({maxActiveTranscriptBytes:Math.max(64e3,Math.round(e*1e6))})}),(0,Z.jsx)($,{id:`compaction-summary-max-tokens`,label:t.summaryMaxTokens,hint:t.summaryMaxTokensHint,value:y.summaryMaxTokens,min:256,step:256,onChange:e=>S({summaryMaxTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-chunk-tokens`,label:t.summaryChunkTokens,hint:t.summaryChunkTokensHint,value:y.summaryChunkTokens,min:1e3,step:1e3,onChange:e=>S({summaryChunkTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-timeout`,label:t.summaryTimeoutSeconds,hint:t.summaryTimeoutSecondsHint.replace(`{{seconds}}`,String(P)),value:y.summaryTimeoutMs/1e3,min:1,max:600,onChange:e=>S({summaryTimeoutMs:Math.round(e*1e3)})}),(0,Z.jsx)($,{id:`compaction-summary-retries`,label:t.summaryRetries,hint:t.summaryRetriesHint,value:y.summaryRetries,min:0,max:5,onChange:e=>S({summaryRetries:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-min-tool-result-chars`,label:t.minToolResultKeepChars,hint:t.minToolResultKeepCharsHint,value:y.minToolResultKeepChars,min:200,step:100,onChange:e=>S({minToolResultKeepChars:Math.floor(e)})})]}),A?(0,Z.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.summaryBudgetWarning}):null,(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.postCompactionSections}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.postCompactionSectionsHint}),y.postCompactionSections.length>0?(0,Z.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:y.postCompactionSections.map(e=>(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs text-fg`,children:[e,(0,Z.jsx)(`button`,{type:`button`,className:m(`text-fg-muted hover:text-fg`,K.press),"aria-label":t.removeSection.replace(`{{section}}`,e),onClick:()=>S({postCompactionSections:y.postCompactionSections.filter(t=>t!==e)}),children:(0,Z.jsx)(f,{className:`size-3.5`,"aria-hidden":!0})})]},e))}):(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.postCompactionSectionsEmpty}),(0,Z.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,Z.jsx)(`input`,{className:Je(),value:d,maxLength:120,disabled:y.postCompactionSections.length>=12,placeholder:t.postCompactionSectionsPlaceholder,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),z())}}),(0,Z.jsxs)(N,{type:`button`,variant:`secondary`,disabled:!d.trim()||y.postCompactionSections.length>=12,onClick:z,children:[(0,Z.jsx)(u,{className:`size-4`,"aria-hidden":!0}),t.addSection]})]})]})]})})]})]})}function et(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function tt(e){return e===`main`||e===`per-peer`||e===`per-channel-peer`||e===`per-account-channel-peer`?e:`main`}function nt(e){let t=et(e)?e:{},n=et(t.session)?t.session:{},r=et(n.storage)?n.storage:{},i=typeof r.pruneAfterDays==`number`&&Number.isFinite(r.pruneAfterDays)?Math.max(0,Math.floor(r.pruneAfterDays)):typeof r.pruneAfterMs==`number`&&Number.isFinite(r.pruneAfterMs)?Math.max(0,Math.round(r.pruneAfterMs/864e5)):null,a=typeof r.maxEntries==`number`&&Number.isFinite(r.maxEntries)?Math.max(1,Math.floor(r.maxEntries)):null;return{dmScope:tt(n.dmScope),pruneAfterDays:i,maxEntries:a}}async function rt(e){await h(v(`/api/config`),{method:`PATCH`,body:JSON.stringify({session:{dmScope:e.dmScope,storage:{pruneAfterMs:e.pruneAfterDays===null?null:e.pruneAfterDays*864e5,maxEntries:e.maxEntries}}})}),P()}function it(){return m(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,G,`dark:border-edge`)}var at=H();function ot({hasToken:e}){let t=p(_(e=>e.language)).sessions.config,{data:n,isLoading:r}=F(e),i=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:nt(n.payload.config),[n]),[s,c]=(0,X.useReducer)(at,{form:null,baseline:null}),l=s.form,u=s.baseline,d=(0,X.useRef)(!1),f=(0,X.useRef)(l);f.current=l;let m=(0,X.useRef)(null);J({enabled:e,parsed:i,dirty:d.current,trackedParsedRef:m,dispatch:c,onResetDirty:()=>{d.current=!1}});let h=!!(l&&u&&JSON.stringify(l)!==JSON.stringify(u)),g=(0,X.useCallback)(e=>{d.current=!0,c({type:`patch`,patch:e})},[]),v=Te({value:l,dirty:h,onSave:(0,X.useCallback)(async e=>{try{await rt(e),c({type:`saved`,value:e}),d.current=!!(f.current&&JSON.stringify(f.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])});return!e||!l?r?(0,Z.jsx)(Y,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(R,{className:`h-5 w-40`}),(0,Z.jsx)(R,{className:`h-24 w-full rounded-xl`})]})}):null:(0,Z.jsxs)(Y,{onBlurCapture:v.onBlurCapture,children:[(0,Z.jsx)(Ce,{icon:pe,title:t.title,subtitle:t.hint,trailing:(0,Z.jsx)(we,{status:v.status,error:v.error})}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.dmScope}),(0,Z.jsxs)(a,{className:it(),value:l.dmScope,onChange:e=>g({dmScope:e.target.value}),children:[(0,Z.jsx)(o,{value:`main`,children:t.dmScopeMain}),(0,Z.jsx)(o,{value:`per-peer`,children:t.dmScopePerPeer}),(0,Z.jsx)(o,{value:`per-channel-peer`,children:t.dmScopePerChannelPeer}),(0,Z.jsx)(o,{value:`per-account-channel-peer`,children:t.dmScopePerAccountChannelPeer})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.dmScopeHint})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.pruneAfterDays}),(0,Z.jsx)(`input`,{type:`number`,min:0,className:it(),value:l.pruneAfterDays??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();g({pruneAfterDays:t===``?null:Math.max(0,Math.floor(Number(t)||0))})}})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.maxEntries}),(0,Z.jsx)(`input`,{type:`number`,min:1,className:it(),value:l.maxEntries??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();g({maxEntries:t===``?null:Math.max(1,Math.floor(Number(t)||1))})}})]})]})]})}function st(e){if(typeof e==`string`)return e.length>2e3?`${e.slice(0,2e3)}…`:e;try{let t=JSON.stringify(e,null,2);return t.length>2e3?`${t.slice(0,2e3)}…`:t}catch{return String(e)}}function ct(e){let t=(0,De.c)(60),{open:n,loading:r,session:i,sessionAgentId:a,sessionAgentAvatar:o,labels:s,onClose:c,onArchive:l,onUnarchive:u,onPin:d,onUnpin:p,onExport:h,onDelete:g}=e,_=i?.status===`archived`,v=i?.status===`pinned`,C;t[0]===c?C=t[1]:(C=e=>!e&&c(),t[0]=c,t[1]=C);let w;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Z.jsx)(ee,{className:m(`xopc-dialog-overlay fixed inset-0 bg-scrim`,re)}),t[2]=w):w=t[2];let T;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(T=m(`xopc-drawer-right fixed right-0 top-0 flex size-full max-w-lg flex-col border-l border-edge bg-surface-overlay shadow-popover outline-none`,ne,`dark:border-edge`),t[3]=T):T=t[3];let E;t[4]!==i||t[5]!==o||t[6]!==a?(E=i&&a?(0,Z.jsx)(oe,{agentId:a,avatar:o,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}):null,t[4]=i,t[5]=o,t[6]=a,t[7]=E):E=t[7];let D;t[8]!==s.unnamedSession||t[9]!==i?.name?(D=i?.name?.trim()||s.unnamedSession,t[8]=s.unnamedSession,t[9]=i?.name,t[10]=D):D=t[10];let O;t[11]===D?O=t[12]:(O=(0,Z.jsx)(S,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:D}),t[11]=D,t[12]=O);let k;t[13]!==E||t[14]!==O?(k=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[E,O]}),t[13]=E,t[14]=O,t[15]=k):k=t[15];let A;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Z.jsx)(f,{className:`size-5`,strokeWidth:1.75}),t[16]=A):A=t[16];let j;t[17]===s.close?j=t[18]:(j=(0,Z.jsx)(y,{asChild:!0,children:(0,Z.jsx)(N,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":s.close,children:A})}),t[17]=s.close,t[18]=j);let M;t[19]!==k||t[20]!==j?(M=(0,Z.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3 dark:border-edge`,children:[k,j]}),t[19]=k,t[20]=j,t[21]=M):M=t[21];let P;t[22]!==s.detailLoading||t[23]!==s.detailMessages||t[24]!==r||t[25]!==i?(P=r?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:s.detailLoading}):i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`dl`,{className:`mb-4 grid gap-2 text-xs text-fg-muted`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-fg-disabled`,children:`Key`}),(0,Z.jsx)(`dd`,{className:`mt-0.5 break-all font-mono text-fg`,children:i.key})]}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-4`,children:(0,Z.jsxs)(`span`,{children:[i.messageCount,` msgs · `,i.estimatedTokens,` tok`]})})]}),(0,Z.jsx)(`h3`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:s.detailMessages}),(0,Z.jsx)(`ul`,{className:`space-y-3`,children:i.messages.map(lt)})]}):null,t[22]=s.detailLoading,t[23]=s.detailMessages,t[24]=r,t[25]=i,t[26]=P):P=t[26];let F;t[27]===P?F=t[28]:(F=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:P}),t[27]=P,t[28]=F);let I;t[29]!==s.detailExport||t[30]!==h?(I=(0,Z.jsx)(N,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:h,children:s.detailExport}),t[29]=s.detailExport,t[30]=h,t[31]=I):I=t[31];let L;t[32]!==_||t[33]!==s.archive||t[34]!==s.unarchive||t[35]!==l||t[36]!==u?(L=_?(0,Z.jsx)(N,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:u,children:s.unarchive}):(0,Z.jsx)(N,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:l,children:s.archive}),t[32]=_,t[33]=s.archive,t[34]=s.unarchive,t[35]=l,t[36]=u,t[37]=L):L=t[37];let R;t[38]!==v||t[39]!==s.pin||t[40]!==s.unpin||t[41]!==d||t[42]!==p?(R=v?(0,Z.jsx)(N,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:p,children:s.unpin}):(0,Z.jsx)(N,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:d,children:s.pin}),t[38]=v,t[39]=s.pin,t[40]=s.unpin,t[41]=d,t[42]=p,t[43]=R):R=t[43];let z;t[44]!==s.delete||t[45]!==g?(z=(0,Z.jsx)(N,{type:`button`,variant:`secondary`,className:`text-sm text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`,onClick:g,children:s.delete}),t[44]=s.delete,t[45]=g,t[46]=z):z=t[46];let B;t[47]!==I||t[48]!==L||t[49]!==R||t[50]!==z?(B=(0,Z.jsx)(`div`,{className:`shrink-0 border-t border-edge px-4 py-3 dark:border-edge`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[I,L,R,z]})}),t[47]=I,t[48]=L,t[49]=R,t[50]=z,t[51]=B):B=t[51];let V;t[52]!==M||t[53]!==F||t[54]!==B?(V=(0,Z.jsxs)(b,{children:[w,(0,Z.jsxs)(x,{className:T,"aria-describedby":void 0,children:[M,F,B]})]}),t[52]=M,t[53]=F,t[54]=B,t[55]=V):V=t[55];let H;return t[56]!==n||t[57]!==C||t[58]!==V?(H=(0,Z.jsx)(te,{open:n,onOpenChange:C,children:V}),t[56]=n,t[57]=C,t[58]=V,t[59]=H):H=t[59],H}function lt(e){return(0,Z.jsxs)(`li`,{className:`rounded-lg border border-edge-subtle bg-surface-hover/50 p-2 dark:border-edge`,children:[(0,Z.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase text-fg-subtle`,children:e.role}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-fg-muted`,children:st(e.content)})]},`${e.timestamp??``}-${e.role}-${st(e.content).slice(0,24)}`)}var ut=20;function dt(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}var ft=new Set([`all`,`active`,`pinned`,`archived`]),pt=new Set([`grid`,`list`]),mt=[`sessions`,`settings`];function ht(e){return e&&mt.includes(e)?e:`sessions`}function gt(e,t){return t===`sessions`?e.tabsSessions:e.tabsSettings}function _t(e,t){return t===`sessions`?e.tabsSessionsHint:e.tabsSettingsHint}function vt(e){let t=(0,De.c)(7),{s:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=mt.map(e=>({id:e,label:gt(n,e),icon:e===`sessions`?ce:W})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==n.tabsAriaLabel?(s=(0,Z.jsx)(be,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`sessions-tab`,panelIdPrefix:`sessions-panel`}),t[2]=r,t[3]=o,t[4]=i,t[5]=n.tabsAriaLabel,t[6]=s):s=t[6],s}function yt(e){let t=(0,De.c)(10),{s:n,id:r,activeTab:i,plain:a,children:o}=e,s=a===void 0?!1:a;if(i!==r)return null;let c=`sessions-panel-${r}`,l=`sessions-tab-${r}`,u=s?`contents`:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,d;t[0]!==o||t[1]!==r||t[2]!==s||t[3]!==n?(d=s?o:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`mb-5`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:gt(n,r)}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:_t(n,r)})]}),(0,Z.jsx)(`div`,{className:`space-y-4`,children:o})]}),t[0]=o,t[1]=r,t[2]=s,t[3]=n,t[4]=d):d=t[4];let f;return t[5]!==c||t[6]!==l||t[7]!==u||t[8]!==d?(f=(0,Z.jsx)(`section`,{id:c,role:`tabpanel`,"aria-labelledby":l,className:u,children:d}),t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f):f=t[9],f}function bt(e){let t=e.get(`status`),n=e.get(`view`);return{searchInput:e.get(`q`)??``,debouncedSearch:(e.get(`q`)??``).trim(),statusFilter:ft.has(t)?t:`all`,viewMode:pt.has(n)?n:`grid`,channelFilter:(e.get(`channel`)??``).trim(),sessions:[],loading:!1,error:null,hasMore:!1,stats:null,detailOpen:!1,detailLoading:!1,detailSession:null,confirmOpen:!1,confirmKey:null}}function xt(){let e=p(_(e=>e.language)),t=e.sessions,n=g(e=>e.conversationId),r=!!n,{data:a,mutate:o}=M(r?[`gateway-chat-agents`,n]:null,B,{revalidateOnFocus:!1}),s=a?.defaultId??`main`,l=a?.items??[],[u,f]=i(),h=ht(u.get(`tab`)),v=(0,X.useCallback)(e=>{let t=new URLSearchParams(u);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),f(t,{replace:!0})},[u,f]),[y,P]=(0,X.useReducer)(de,u,bt),{searchInput:F,debouncedSearch:I,statusFilter:L,viewMode:R,channelFilter:H,sessions:U,loading:W,error:oe,hasMore:G,stats:se,detailOpen:le,detailLoading:ue,detailSession:q,confirmOpen:fe,confirmKey:pe}=y;(0,X.useEffect)(()=>{let e=setTimeout(()=>{let e=F.trim();I!==e&&P({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[F,I]);let he=u.toString(),_e=(0,X.useRef)(he);if(_e.current!==he){_e.current=he;let e=u.get(`q`)??``,t=u.get(`status`),n=u.get(`view`),r=(u.get(`channel`)??``).trim(),i=ft.has(t)?t:`all`,a=pt.has(n)?n:`grid`,o=e.trim();P({type:`patch`,patch:{...F===e?{}:{searchInput:e},...I===o?{}:{debouncedSearch:o},...L===i?{}:{statusFilter:i},...R===a?{}:{viewMode:a},...H===r?{}:{channelFilter:r}}})}(0,X.useEffect)(()=>{let e=new URLSearchParams(u),t=I.trim();t?e.set(`q`,t):e.delete(`q`),L===`all`?e.delete(`status`):e.set(`status`,L),R===`grid`?e.delete(`view`):e.set(`view`,R),H?e.set(`channel`,H):e.delete(`channel`),e.toString()!==u.toString()&&f(e,{replace:!0})},[I,u,f,L,R,H]),(0,X.useEffect)(()=>{if(!r||h!==`sessions`)return;let e=!1;return(async()=>{P({type:`patch`,patch:{loading:!0,error:null}});try{let t=await A({limit:ut,offset:0,...I?{search:I}:{},...L===`all`?{}:{status:L},...H?{channel:H}:{}});if(e)return;P({type:`patch`,patch:{sessions:t.items,hasMore:t.hasMore}})}catch(n){e||P({type:`patch`,patch:{error:n instanceof Error?n.message:t.loadError}})}finally{e||P({type:`patch`,patch:{loading:!1}})}})(),()=>{e=!0}},[r,h,I,L,H,t.loadError]),(0,X.useEffect)(()=>{!r||h!==`sessions`||D().then(e=>P({type:`patch`,patch:{stats:e}})).catch(()=>{})},[r,h]),(0,X.useEffect)(()=>{if(!r||h!==`sessions`)return;let e=()=>void o();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[r,h,o]),(0,X.useEffect)(()=>{if(!r||h!==`sessions`)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||P({type:`patch`,patch:{sessions:U.map(e=>e.key===t.key?{...e,name:t.name}:e),detailSession:q&&q.key===t.key?{...q,name:t.name}:q}})};return window.addEventListener(`session-updated`,e),()=>{window.removeEventListener(`session-updated`,e)}},[r,h,U,q]);let ye=(0,X.useCallback)(async()=>{if(!(!r||W||!G)){P({type:`patch`,patch:{loading:!0,error:null}});try{let e=await A({limit:ut,offset:U.length,...I?{search:I}:{},...L===`all`?{}:{status:L},...H?{channel:H}:{}});P({type:`patch`,patch:{sessions:[...U,...e.items],hasMore:e.hasMore}})}catch(e){P({type:`patch`,patch:{error:e instanceof Error?e.message:t.loadError}})}finally{P({type:`patch`,patch:{loading:!1}})}}},[r,W,G,U.length,I,L,H,t.loadError]),J=(0,X.useCallback)((e,t)=>{P({type:`patch`,patch:{sessions:U.map(n=>n.key===e?{...n,status:t}:n),detailSession:q&&q.key===e?{...q,status:t}:q}})},[U,q]),be=(0,X.useCallback)(async e=>{P({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{P({type:`patch`,patch:{detailSession:await C(e)}})}catch{P({type:`patch`,patch:{detailOpen:!1}})}finally{P({type:`patch`,patch:{detailLoading:!1}})}},[]),Ce=e=>{be(e)},Y=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:e},bubbles:!0}));return}if(t===`delete`){P({type:`patch`,patch:{confirmKey:e,confirmOpen:!0}});return}try{switch(t){case`archive`:await j(e),J(e,`archived`);break;case`unarchive`:await T(e),J(e,`active`);break;case`pin`:await w(e),J(e,`pinned`);break;case`unpin`:await O(e),J(e,`active`);break;case`export`:{let t=await k(e),n=new Blob([t],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`session-${e.replace(/[^a-z0-9]/gi,`_`)}.json`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r);break}default:break}D().then(e=>P({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},we=async e=>{try{await E(e),P({type:`patch`,patch:{sessions:U.filter(t=>t.key!==e),detailSession:q?.key===e?null:q,...q?.key===e?{detailOpen:!1}:{}}}),D().then(e=>P({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Te={continueChat:t.continueChat,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,export:t.export,delete:t.delete,tokens:t.tokens,cost:t.cost,costPartial:t.costPartial,costUnknown:t.costUnknown,noUsage:t.noUsage,unnamedSession:e.chat.newSession},Ee={close:t.close,detailLoading:t.detailLoading,detailMessages:t.detailMessages,detailExport:t.detailExport,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,delete:t.delete,unnamedSession:e.chat.newSession},De=[{key:`all`,label:t.filterAll,icon:ce},{key:`active`,label:t.filterActive,icon:ie},{key:`pinned`,label:t.filterPinned,icon:z},{key:`archived`,label:t.filterArchived,icon:ge}],Oe=(()=>{let e=Object.entries(se?.byChannel??{}).sort((e,t)=>t[1]-e[1]).slice(0,6).map(([e])=>e),t=new Set(e);for(let n of[`telegram`,`weixin`,`feishu`])t.has(n)||(e.push(n),t.add(n));return e.slice(0,8)})();return r?(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-surface-panel`,children:[(0,Z.jsxs)(Se,{gap:`gap-6`,children:[(0,Z.jsx)(xe,{title:t.title}),(0,Z.jsx)(vt,{s:t,activeTab:h,onChange:v}),(0,Z.jsx)(yt,{s:t,id:`settings`,activeTab:h,plain:!0,children:(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)($e,{hasToken:r}),(0,Z.jsx)(ot,{hasToken:r})]})}),(0,Z.jsxs)(yt,{s:t,id:`sessions`,activeTab:h,plain:!0,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:De.map(({key:e,label:t,icon:n})=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":L===e,onClick:()=>P({type:`patch`,patch:{statusFilter:e}}),className:m(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,K.transition,K.focusRingPanel,L===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[(0,Z.jsx)(n,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t]},e))}),(0,Z.jsxs)(`div`,{className:`flex min-h-11 w-full min-w-0 items-center gap-2 rounded-xl bg-surface-base focus-within:ring-2 focus-within:ring-accent px-3 py-2 transition-colors lg:max-w-md dark:bg-surface-hover/40`,children:[(0,Z.jsx)(d,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`input`,{type:`search`,value:F,onChange:e=>P({type:`patch`,patch:{searchInput:e.target.value}}),placeholder:t.searchPlaceholder,"aria-label":t.searchPlaceholder,"data-debounced-query":I||void 0,className:`min-w-0 flex-1 border-0 bg-transparent text-base sm:text-sm text-fg placeholder:text-fg-disabled focus:outline-none focus:ring-0`})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg-subtle`,children:t.filterChannelLabel}),(0,Z.jsx)(`button`,{type:`button`,"aria-pressed":!H,onClick:()=>P({type:`patch`,patch:{channelFilter:``}}),className:m(`touch-target inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,K.transition,K.focusRingPanel,H?`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`:`bg-accent-soft text-accent-fg`),children:t.filterChannelAll}),Oe.map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":H===e,onClick:()=>P({type:`patch`,patch:{channelFilter:e}}),className:m(`touch-target inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,K.transition,K.focusRingPanel,H===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[e,se?.byChannel?.[e]==null?null:(0,Z.jsx)(`span`,{className:`ml-2 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] text-fg-subtle`,children:se.byChannel[e]})]},e))]}),se?(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[[se.totalSessions,t.totalSessions],[se.activeSessions,t.activeSessions],[se.pinnedSessions,t.pinnedSessions],[se.archivedSessions,t.archivedSessions]].map(([e,t])=>(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-base p-3 dark:bg-surface-hover/30`,children:[(0,Z.jsx)(`div`,{className:`text-lg font-semibold tabular-nums text-fg`,children:e}),(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:t})]},t))}):null,oe?(0,Z.jsx)(`div`,{className:`rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700 dark:bg-red-950/40 dark:text-red-300`,children:oe}):null,(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:dt(t.sessionCount,{count:U.length})}),(0,Z.jsxs)(`div`,{className:ae,role:`group`,"aria-label":t.layoutToggleGroup,children:[(0,Z.jsx)(N,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":R===`grid`,onClick:()=>P({type:`patch`,patch:{viewMode:`grid`}}),className:m(ve,`size-7 p-0`,R===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,R===`grid`&&`text-accent-fg`),children:(0,Z.jsx)(me,{className:`size-3.5`,strokeWidth:1.5})}),(0,Z.jsx)(N,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":R===`list`,onClick:()=>P({type:`patch`,patch:{viewMode:`list`}}),className:m(ve,`size-9 p-0`,R===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,R===`list`&&`text-accent-fg`),children:(0,Z.jsx)(V,{className:`size-3.5`,strokeWidth:1.5})})]})]}),W&&U.length===0?(0,Z.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,Z.jsx)(`div`,{className:`h-40 animate-pulse rounded-xl bg-surface-hover/60 dark:bg-surface-hover/40`},t))}):U.length===0?(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-2xl bg-surface-base py-16 text-center dark:bg-surface-hover/25`,children:[(0,Z.jsx)(c,{className:`mb-3 size-12 text-fg-disabled`,strokeWidth:1.25,"aria-hidden":!0}),(0,Z.jsx)(`p`,{className:`text-base font-semibold text-fg`,children:t.noSessions}),(0,Z.jsx)(`p`,{className:`mt-1 max-w-sm text-sm text-fg-muted`,children:t.noSessionsDescription}),(0,Z.jsx)(N,{variant:`primary`,className:`mt-6`,onClick:()=>{window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:``},bubbles:!0}))},children:t.startNewChat})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:m(`grid min-w-0 gap-3`,R===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":I||void 0,children:U.map(e=>{let t=Ie(e,s);return(0,Z.jsx)(je,{session:e,variant:R,labels:Te,sessionAgentId:t,sessionAgentAvatar:Le(t,l),onOpen:()=>Ce(e.key),onAction:t=>void Y(e.key,t)},e.key)})}),G?(0,Z.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Z.jsx)(N,{type:`button`,variant:`secondary`,disabled:W,onClick:()=>void ye(),children:t.loadMore})}):null]})]})]}),(0,Z.jsx)(ct,{open:le,loading:ue,session:q,sessionAgentId:q?Ie(q,s):void 0,sessionAgentAvatar:q?Le(Ie(q,s),l):void 0,labels:Ee,onClose:()=>{P({type:`patch`,patch:{detailOpen:!1,detailSession:null}})},onArchive:()=>q&&void Y(q.key,`archive`),onUnarchive:()=>q&&void Y(q.key,`unarchive`),onPin:()=>q&&void Y(q.key,`pin`),onUnpin:()=>q&&void Y(q.key,`unpin`),onExport:()=>q&&void Y(q.key,`export`),onDelete:()=>q&&P({type:`patch`,patch:{confirmKey:q.key,confirmOpen:!0}})}),(0,Z.jsx)(te,{open:fe,onOpenChange:e=>P({type:`patch`,patch:{confirmOpen:e}}),children:(0,Z.jsxs)(b,{children:[(0,Z.jsx)(ee,{className:m(`xopc-dialog-overlay fixed inset-0 bg-scrim`,re)}),(0,Z.jsxs)(x,{className:m(`xopc-dialog-content fixed left-1/2 top-1/2 w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover dark:border-edge`,ne),children:[(0,Z.jsx)(S,{className:`text-base font-semibold text-fg`,children:t.deleteSessionTitle}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:pe?dt(t.deleteSessionMessage,{name:U.find(e=>e.key===pe)?.name?.trim()||e.chat.newSession}):``}),(0,Z.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Z.jsx)(N,{type:`button`,variant:`secondary`,onClick:()=>P({type:`patch`,patch:{confirmOpen:!1}}),children:t.cancel}),(0,Z.jsx)(N,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{pe&&we(pe),P({type:`patch`,patch:{confirmOpen:!1,confirmKey:null}})},children:t.delete})]})]})]})})]}):(0,Z.jsx)(`div`,{className:`w-full px-3 py-16 text-center text-sm text-fg-muted sm:px-5 xl:px-6`,children:t.needToken})}export{xt as SessionsPage};
@@ -1 +0,0 @@
1
- import{Cn as e}from"./index-CdvabjRm.js";function t(t){let{children:n,fallback:r}=t,i=r===void 0?null:r;return e()?n:i}export{t};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as a}from"./circle-check-C23XjkUj.js";import{t as o}from"./loader-circle-CifKLtgG.js";import{t as s}from"./messages-DsUnS7rn.js";import{t as c}from"./cn-JdwAhgNB.js";import{a as l,c as u,n as d,r as f}from"./locale-store-7F4l6DRV.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{r as m}from"./gateway-config-swr-Hn1vj6uI.js";import{n as h}from"./gateway-realtime-store-DytaaEu8.js";import{n as g,t as _}from"./registry-api-DU915Prn.js";import{n as v}from"./electron-env-Dit0bHgy.js";import{Du as y,Eu as b,Fu as x,Hc as S,Oo as C,Os as w,Pi as T,Rl as E,Sc as D,fc as O,id as k,zt as A}from"./index-CdvabjRm.js";import{n as j,r as M}from"./settings-page-layout-X1x-2Cp9.js";import{n as N,t as P}from"./settings-form-section-DziWi7ar.js";import{n as F}from"./settings-loading-skeleton-CAmWMaOT.js";import{t as I}from"./settings-advanced-gate-CPyqCG90.js";var L=e(t(),1),R=n();function z(e){if(!e||typeof e!=`object`)return 0;let t=e.providers;return!t||typeof t!=`object`||Array.isArray(t)?0:Object.values(t).filter(e=>typeof e==`string`&&C(e)).length}function B(e){if(!e||typeof e!=`object`)return``;let t=e.agents;if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=t.defaults,r=n&&typeof n==`object`&&!Array.isArray(n)?n.models:void 0;if(!r||typeof r!=`object`||Array.isArray(r))return``;let i=r.chat;if(!i||typeof i!=`object`||Array.isArray(i))return``;let a=i.primary;return typeof a==`string`?a.trim():``}function ee(e){if(!e||typeof e!=`object`)return!1;let t=e.channels;return!t||typeof t!=`object`||Array.isArray(t)?!1:Object.values(t).some(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;if(`configured`in t||`config`in t||`schema`in t||`uiHints`in t){if(t.configured===!0)return!0;let e=t.config;if(!e||typeof e!=`object`||Array.isArray(e))return!1;let n=e;return n.enabled===!0||Object.keys(n).length>0}return t.enabled===!0||Object.keys(t).length>0})}function te(e){if(!e||typeof e!=`object`)return{enabled:!1,driverKind:`extension`};let t=e.browser;if(!t||typeof t!=`object`||Array.isArray(t))return{enabled:!1,driverKind:`extension`};let n=t,r=n.driver&&typeof n.driver==`object`&&!Array.isArray(n.driver)?n.driver:void 0;return{enabled:n.enabled===!0,driverKind:typeof r?.kind==`string`&&r.kind.trim()?r.kind.trim():`extension`}}function V(e){return e?`pass`:`fail`}function H(e){if(e===`tool-runtimes`)return`/settings/runtimes`;if(e===`provider-auth`)return`/settings/capabilities/models`;if(e===`config-health`)return`/settings/gateway`;if(e===`state-integrity`||e===`workspace-status`)return`/capabilities/agents`;if(e===`database-schema`||e===`session-integrity`)return`/settings/sessions`;if(e===`channel-config`||e===`channel-pairing-pending`||e.startsWith(`channel:`))return`/capabilities/channels`;if(e===`security-audit`||e===`gateway-service`||e===`gateway-health`)return`/settings/gateway`;if(e===`version-check`)return`/settings/desktop-app`}function U(e){return{fail:4,warn:3,skip:2,pass:1}[e]}function W(e,t){let n=e.match(/^Run(?::|\s)(.*)$/i);if(n?.[1])return t.runCommand(n[1].trim());let r=e.match(/^Install(?::|\s)(.*)$/i);if(r?.[1])return t.installCommand(r[1].trim());let i=e.match(/^Start(?::|\s)(.*)$/i);return i?.[1]?t.startCommand(i[1].trim()):e}function G(e,t){if(!t)return e;let n=e.message;if(e.id===`tool-runtimes`){let r=e.message.match(/^(.*) runtime is not installed\.$/),i=e.message.match(/^(.*) runtime installation is invalid\.$/);r?.[1]?n=t.runtimeMissing(r[1]):i?.[1]&&(n=t.runtimeInvalid(i[1]))}else if(e.id===`gateway-service`)if(e.message===`Gateway is not installed as a system service.`)n=t.gatewayNotInstalled;else{let r=e.message.match(/^Service backend unavailable: (.*)$/),i=e.message.match(/^Gateway service is installed but not running \(status: (.*)\)\.$/);r?.[1]?n=t.gatewayUnavailable(r[1]):i?.[1]&&(n=t.gatewayNotRunning(i[1]))}else e.id===`provider-auth`&&e.message===`No API keys detected for configured providers.`&&(n=t.providerAuthMissing);return{...e,label:t.labels[e.id]??e.label,message:n,hints:e.hints.map(e=>W(e,t))}}function K(e,t){return e.filter(e=>e.status===`fail`||e.status===`warn`).map(e=>{let n=G(e,t);return{id:n.id,label:n.label,status:n.status,message:n.message,hints:n.hints,path:H(n.id),source:`doctor`}}).toSorted((e,t)=>U(t.status)-U(e.status)||e.label.localeCompare(t.label))}function q(e){let t=new Map(e.doctorChecks.map(e=>[e.id,e])),n=[];for(let r of[`security-audit`,`channel-config`,`channel-pairing-pending`,`gateway-health`]){let i=t.get(r);if(i){let t=G(i,e.copy);n.push({id:t.id,label:t.label,status:t.status,message:t.message,path:H(t.id)})}}if(e.logsHealth){let t=e.logsHealth.stats?.errorsLast24h??0;n.push({id:`logs-health`,label:e.copy?.labels[`logs-health`]??`Logs`,status:e.logsHealth.shuttingDown||t>0?`warn`:`pass`,message:e.copy?e.logsHealth.shuttingDown?e.copy.logsShuttingDown:t>0?e.copy.logsErrors(t):e.copy.logsHealthy:e.logsHealth.shuttingDown?`Logger is shutting down.`:t>0?`${t} error(s) in the last 24 hours.`:`Log system is healthy.`,path:`/settings/logs`})}for(let t of e.browserDiagnostics??[]){let r=t.message;if(e.copy){r={"Local Chromium is installed.":e.copy.chromiumInstalled,"Local Chromium is not installed.":e.copy.chromiumNotInstalled,"Chrome extension bridge is connected.":e.copy.extensionConnected,"Chrome extension needs refresh.":e.copy.extensionNeedsRefresh,"Chrome extension is installed but not connected.":e.copy.extensionNotConnected,"Chrome extension is not installed.":e.copy.extensionNotInstalled}[t.message]??t.message;let n=t.message.match(/^Browser driver "(.*)" is configured\.$/);n?.[1]&&(r=e.copy.browserDriverConfigured(n[1]))}n.push({...t,label:e.copy?.labels[t.id]??t.label,message:r})}return n}function ne(e){let t=z(e.config),n=e.providerMeta?.configured??t,r=e.providerMeta?.total??0,i=n>0||t>0,a=B(e.config),o=a.length>0,s=e.hasToken&&e.realtimeConnected,c=ee(e.config),l=e.skillCount>0,u=(e.doctorChecks??[]).filter(t=>!e.isElectron||t.id!==`gateway-service`),d=K(u,e.labels.diagnostics),f=[{id:`gateway`,done:s,detail:s?e.labels.gatewayOnline:e.labels.gatewayOffline},{id:`provider`,done:i,detail:i?e.providerMeta&&e.providerMeta.total>0?e.labels.providersMetaReady(n,r):e.labels.providersConfigured(t):e.labels.providersMissing},{id:`defaultModel`,done:o,detail:o?e.labels.modelConfigured(a):e.labels.modelMissing},{id:`channel`,done:c,optional:!0,detail:c?e.labels.channelConfigured:e.labels.channelMissing},{id:`skill`,done:l,optional:!0,detail:l?e.labels.skillsConfigured(e.skillCount):e.labels.skillsMissing}],p=f.filter(e=>!e.optional).every(e=>e.done),m=f.every(e=>e.done),h=[{id:`gateway`,status:V(s),title:`Gateway`,detail:s?e.labels.gatewayOnline:e.labels.gatewayOffline,path:`/settings/gateway`},{id:`provider`,status:V(i),title:`Model provider`,detail:i?e.providerMeta&&e.providerMeta.total>0?e.labels.providersMetaReady(n,r):e.labels.providersConfigured(t):e.labels.providersMissing,path:`/settings/capabilities/models`},{id:`defaultModel`,status:V(o),title:`Default model`,detail:o?e.labels.modelConfigured(a):e.labels.modelMissing,path:`/settings/capabilities/models`},{id:`ready`,status:p?`pass`:`fail`,title:`Chat readiness`,detail:p?e.labels.readyToChat:e.labels.modelMissing,path:`/chat`}],g=d.some(e=>e.status===`fail`),_=d.some(e=>e.status===`warn`),v=g?`blocked`:_?`attention`:p?`ready`:`setup`,y=q({doctorChecks:u,logsHealth:e.logsHealth,browserDiagnostics:e.browserDiagnostics,copy:e.labels.diagnostics});return{gatewayConnected:s,providerConfigured:i,providerCount:t,providerMetaConfigured:n,providerMetaTotal:r,defaultModel:a,defaultModelConfigured:o,channelConfigured:c,skillInstalled:l,skillCount:e.skillCount,checklist:f,readiness:h,issues:d,healthTier:v,diagnosticSignals:y,requiredComplete:p,allComplete:m}}function re(e){return te(e)}function ie(e){return!e.id||!e.label||!e.status||!e.message||![`pass`,`warn`,`fail`,`skip`].includes(e.status)?null:{id:e.id,label:e.label,status:e.status,message:e.message,hints:Array.isArray(e.hints)?e.hints.filter(e=>typeof e==`string`):[],fixed:e.fixed===!0,findings:Array.isArray(e.findings)?e.findings:void 0}}function ae(){return f(`/api/doctor`)}async function oe(){return((await l(ae())).checks??[]).map(ie).filter(e=>e!==null)}function se(){return f(`/api/logs/health`)}async function ce(){return l(se())}function le(e){return e?`pass`:`warn`}function ue(e){return e?.enabled?[`setup-browser-diagnostics`,e]:null}async function J(e){if(!e.enabled)return[];if(e.driverKind===`playwright`){let e=await l(f(`/api/browser/playwright/doctor`)),t=e.payload?.installed===!0;return[{id:`browser-playwright`,label:`Browser: Playwright`,status:le(t),message:t?`Local Chromium is installed.`:e.payload?.reason??`Local Chromium is not installed.`,path:`/settings/agent-browser`}]}if(e.driverKind===`extension`){let e=await l(f(`/api/browser/extension-status?probe=true`)),t=e.artifacts?.installed===!0,n=e.connected===!0,r=e.artifacts?.needsRefresh===!0||e.artifacts?.needsChromeReload===!0;return[{id:`browser-extension`,label:`Browser: Chrome extension`,status:n?`pass`:`warn`,message:n?`Chrome extension bridge is connected.`:t?r?`Chrome extension needs refresh.`:`Chrome extension is installed but not connected.`:`Chrome extension is not installed.`,path:`/settings/agent-browser`}]}return[{id:`browser-playwright`,label:`Browser`,status:`skip`,message:`Browser driver "${e.driverKind}" is configured.`,path:`/settings/agent-browser`}]}function Y(){let e=(0,R.c)(95),t=u(ge),n=d(he),r;e[0]===n?r=e[1]:(r=s(n),e[0]=n,e[1]=r);let i=r,a=i.setupStatus.labels,o=i.setupStatus.diagnostics,c=h(me),{data:l,error:f,isLoading:y,mutate:b}=m(!!t),x;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(x={revalidateOnFocus:!1},e[2]=x):x=e[2];let{data:S,error:C,isLoading:w,mutate:T}=p(t?`setup-checklist-skills`:null,pe,x),E;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(E={revalidateOnFocus:!1},e[3]=E):E=e[3];let{data:D,error:O,isLoading:k,mutate:j}=p(t?`setup-checklist-provider-meta`:null,A,E),M;e[4]===t?M=e[5]:(M=t?ae():null,e[4]=t,e[5]=M);let N;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(N={revalidateOnFocus:!1},e[6]=N):N=e[6];let{data:P,error:F,isLoading:I,mutate:L}=p(M,oe,N),z;e[7]===t?z=e[8]:(z=t?se():null,e[7]=t,e[8]=z);let B;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(B={revalidateOnFocus:!1},e[9]=B):B=e[9];let{data:ee,isLoading:te,mutate:V}=p(z,ce,B);l?.payload?.config;let H=l?.payload?.config,U;e[10]===H?U=e[11]:(U=re(H),e[10]=H,e[11]=U);let W=t?U:null,G;e[12]===W?G=e[13]:(G=ue(W),e[12]=W,e[13]=G);let K;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(K={revalidateOnFocus:!1},e[14]=K):K=e[14];let{data:q,isLoading:ie,mutate:le}=p(G,fe,K),J;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(J={revalidateOnFocus:!1},e[15]=J):J=e[15],p(t?_:null,g,J);let Y=!t||!y&&!w&&!k&&!I&&!te&&!ie,X=!!(f||C||O||F),_e;bb0:{if(!t||!Y){_e=null;break bb0}let n=S?.catalog?.length??0,r;if(e[16]!==q||e[17]!==l?.payload?.config||e[18]!==o.browserDriverConfigured||e[19]!==o.chromiumInstalled||e[20]!==o.chromiumNotInstalled||e[21]!==o.extensionConnected||e[22]!==o.extensionNeedsRefresh||e[23]!==o.extensionNotConnected||e[24]!==o.extensionNotInstalled||e[25]!==o.gatewayNotInstalled||e[26]!==o.gatewayNotRunning||e[27]!==o.gatewayUnavailable||e[28]!==o.installCommand||e[29]!==o.labels||e[30]!==o.logsErrors||e[31]!==o.logsHealthy||e[32]!==o.logsShuttingDown||e[33]!==o.providerAuthMissing||e[34]!==o.runCommand||e[35]!==o.runtimeInvalid||e[36]!==o.runtimeMissing||e[37]!==o.startCommand||e[38]!==P||e[39]!==a.channelConfigured||e[40]!==a.channelMissing||e[41]!==a.gatewayOffline||e[42]!==a.gatewayOnline||e[43]!==a.modelConfigured||e[44]!==a.modelMissing||e[45]!==a.providersConfigured||e[46]!==a.providersMetaReady||e[47]!==a.providersMissing||e[48]!==a.skillsConfigured||e[49]!==a.skillsMissing||e[50]!==ee||e[51]!==i.setupStatus.requiredCompleteMessage||e[52]!==D||e[53]!==c||e[54]!==n||e[55]!==t){let s=D?.filter(de).length??0,u=D?.length??0,d;e[57]===a.providersConfigured?d=e[58]:(d=e=>a.providersConfigured.replace(`{{count}}`,String(e)),e[57]=a.providersConfigured,e[58]=d);let f;e[59]===a.providersMetaReady?f=e[60]:(f=(e,t)=>a.providersMetaReady.replace(`{{configured}}`,String(e)).replace(`{{total}}`,String(t)),e[59]=a.providersMetaReady,e[60]=f);let p;e[61]===a.modelConfigured?p=e[62]:(p=e=>a.modelConfigured.replace(`{{model}}`,e),e[61]=a.modelConfigured,e[62]=p);let m;e[63]===a.skillsConfigured?m=e[64]:(m=e=>a.skillsConfigured.replace(`{{count}}`,String(e)),e[63]=a.skillsConfigured,e[64]=m);let h;e[65]===o.runtimeMissing?h=e[66]:(h=e=>o.runtimeMissing.replace(`{{runtimes}}`,e),e[65]=o.runtimeMissing,e[66]=h);let g;e[67]===o.runtimeInvalid?g=e[68]:(g=e=>o.runtimeInvalid.replace(`{{runtimes}}`,e),e[67]=o.runtimeInvalid,e[68]=g);let _;e[69]===o.gatewayUnavailable?_=e[70]:(_=e=>o.gatewayUnavailable.replace(`{{detail}}`,e),e[69]=o.gatewayUnavailable,e[70]=_);let y;e[71]===o.gatewayNotRunning?y=e[72]:(y=e=>o.gatewayNotRunning.replace(`{{status}}`,e),e[71]=o.gatewayNotRunning,e[72]=y);let b;e[73]===o.runCommand?b=e[74]:(b=e=>o.runCommand.replace(`{{command}}`,e),e[73]=o.runCommand,e[74]=b);let x;e[75]===o.installCommand?x=e[76]:(x=e=>o.installCommand.replace(`{{command}}`,e),e[75]=o.installCommand,e[76]=x);let S;e[77]===o.startCommand?S=e[78]:(S=e=>o.startCommand.replace(`{{command}}`,e),e[77]=o.startCommand,e[78]=S);let C;e[79]===o.logsErrors?C=e[80]:(C=e=>o.logsErrors.replace(`{{count}}`,String(e)),e[79]=o.logsErrors,e[80]=C);let w;e[81]===o.browserDriverConfigured?w=e[82]:(w=e=>o.browserDriverConfigured.replace(`{{driver}}`,e),e[81]=o.browserDriverConfigured,e[82]=w),r=ne({isElectron:v(),hasToken:!!t,realtimeConnected:c,config:l?.payload?.config,skillCount:n,providerMeta:u>0?{configured:s,total:u}:null,doctorChecks:P,logsHealth:ee,browserDiagnostics:q,labels:{gatewayOnline:a.gatewayOnline,gatewayOffline:a.gatewayOffline,providersConfigured:d,providersMetaReady:f,providersMissing:a.providersMissing,modelConfigured:p,modelMissing:a.modelMissing,channelConfigured:a.channelConfigured,channelMissing:a.channelMissing,skillsConfigured:m,skillsMissing:a.skillsMissing,readyToChat:i.setupStatus.requiredCompleteMessage,diagnostics:{labels:o.labels,runtimeMissing:h,runtimeInvalid:g,gatewayNotInstalled:o.gatewayNotInstalled,gatewayUnavailable:_,gatewayNotRunning:y,providerAuthMissing:o.providerAuthMissing,runCommand:b,installCommand:x,startCommand:S,logsHealthy:o.logsHealthy,logsShuttingDown:o.logsShuttingDown,logsErrors:C,chromiumInstalled:o.chromiumInstalled,chromiumNotInstalled:o.chromiumNotInstalled,extensionConnected:o.extensionConnected,extensionNeedsRefresh:o.extensionNeedsRefresh,extensionNotConnected:o.extensionNotConnected,extensionNotInstalled:o.extensionNotInstalled,browserDriverConfigured:w}}}),e[16]=q,e[17]=l?.payload?.config,e[18]=o.browserDriverConfigured,e[19]=o.chromiumInstalled,e[20]=o.chromiumNotInstalled,e[21]=o.extensionConnected,e[22]=o.extensionNeedsRefresh,e[23]=o.extensionNotConnected,e[24]=o.extensionNotInstalled,e[25]=o.gatewayNotInstalled,e[26]=o.gatewayNotRunning,e[27]=o.gatewayUnavailable,e[28]=o.installCommand,e[29]=o.labels,e[30]=o.logsErrors,e[31]=o.logsHealthy,e[32]=o.logsShuttingDown,e[33]=o.providerAuthMissing,e[34]=o.runCommand,e[35]=o.runtimeInvalid,e[36]=o.runtimeMissing,e[37]=o.startCommand,e[38]=P,e[39]=a.channelConfigured,e[40]=a.channelMissing,e[41]=a.gatewayOffline,e[42]=a.gatewayOnline,e[43]=a.modelConfigured,e[44]=a.modelMissing,e[45]=a.providersConfigured,e[46]=a.providersMetaReady,e[47]=a.providersMissing,e[48]=a.skillsConfigured,e[49]=a.skillsMissing,e[50]=ee,e[51]=i.setupStatus.requiredCompleteMessage,e[52]=D,e[53]=c,e[54]=n,e[55]=t,e[56]=r}else r=e[56];_e=r}let Z=_e,Q;e[83]!==le||e[84]!==b||e[85]!==L||e[86]!==V||e[87]!==j||e[88]!==T?(Q=async()=>{await Promise.all([b(),T(),j(),L(),V(),le()])},e[83]=le,e[84]=b,e[85]=L,e[86]=V,e[87]=j,e[88]=T,e[89]=Q):Q=e[89];let ve=Q,$;return e[90]!==X||e[91]!==Y||e[92]!==ve||e[93]!==Z?($={ready:Y,error:X,snapshot:Z,refresh:ve},e[90]=X,e[91]=Y,e[92]=ve,e[93]=Z,e[94]=$):$=e[94],$}function de(e){return e.configured}function fe(e){let[,t]=e;return J(t)}function pe(){return T()}function me(e){return e.connectionState===`connected`}function he(e){return e.language}function ge(e){return e.conversationId}var X=r();function _e(e){return e===`pass`?`bg-success-soft text-success`:e===`warn`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`fail`?`bg-red-500/10 text-red-700 dark:text-red-300`:`bg-surface-hover text-fg-muted`}function Z(e){return e===`pass`?a:e===`warn`?O:e===`fail`?y:E}function Q(e,t){return e===`blocked`?{icon:y,className:`bg-red-500/10 text-red-950 dark:text-red-100`,title:t.health.blockedTitle,body:t.health.blockedBody,action:t.health.viewIssues,targetId:`next-steps`}:e===`attention`?{icon:O,className:`bg-amber-500/10 text-amber-950 dark:text-amber-100`,title:t.health.attentionTitle,body:t.health.attentionBody,action:t.health.viewIssues,targetId:`next-steps`}:e===`setup`?{icon:b,className:`bg-surface-hover/50 text-fg`,title:t.health.setupTitle,body:t.health.setupBody,action:t.health.continueSetup,targetId:`next-steps`}:{icon:a,className:`bg-success-soft text-success`,title:t.health.readyTitle,body:t.health.readyBody,action:t.health.startChat,actionPath:`/chat`}}function ve(e){let t=(0,R.c)(46),{tier:n,issueCount:r,onRunDoctor:a,ready:l,doctorRunning:u,doctorRunState:f}=e,p=d($),m,h,g,_,v,y,b,C,T;if(t[0]!==r||t[1]!==p||t[2]!==n){h=s(p).setupStatus;let e=Q(n,h),a=e.icon,o=`targetId`in e&&typeof e.targetId==`string`?e.targetId:null,l=`actionPath`in e&&typeof e.actionPath==`string`?e.actionPath:`/chat`;m=o?(0,X.jsxs)(`button`,{type:`button`,onClick:()=>document.getElementById(o)?.scrollIntoView({block:`start`,behavior:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`}),className:`inline-flex items-center gap-1 rounded-lg bg-surface-base px-3 py-2 text-sm font-medium text-fg shadow-sm hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[e.action,(0,X.jsx)(x,{className:`size-4`,"aria-hidden":!0})]}):(0,X.jsxs)(i,{to:l,className:`inline-flex items-center gap-1 rounded-lg bg-surface-base px-3 py-2 text-sm font-medium text-fg shadow-sm hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[e.action,(0,X.jsx)(x,{className:`size-4`,"aria-hidden":!0})]}),T=c(`rounded-xl p-4`,e.className),C=`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,y=`flex min-w-0 gap-3`,b=(0,X.jsx)(a,{className:`mt-0.5 size-5 shrink-0`,"aria-hidden":!0}),g=`min-w-0`,_=(0,X.jsx)(`h2`,{className:`text-base font-semibold`,children:e.title}),v=r>0?(0,X.jsx)(`p`,{className:`mt-1 text-sm opacity-80`,children:h.health.issueCount.replace(`{{count}}`,String(r))}):null,t[0]=r,t[1]=p,t[2]=n,t[3]=m,t[4]=h,t[5]=g,t[6]=_,t[7]=v,t[8]=y,t[9]=b,t[10]=C,t[11]=T}else m=t[3],h=t[4],g=t[5],_=t[6],v=t[7],y=t[8],b=t[9],C=t[10],T=t[11];let E;t[12]!==g||t[13]!==_||t[14]!==v?(E=(0,X.jsxs)(`div`,{className:g,children:[_,v]}),t[12]=g,t[13]=_,t[14]=v,t[15]=E):E=t[15];let D;t[16]!==y||t[17]!==b||t[18]!==E?(D=(0,X.jsxs)(`div`,{className:y,children:[b,E]}),t[16]=y,t[17]=b,t[18]=E,t[19]=D):D=t[19];let O;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(O=c(`inline-flex items-center gap-2 rounded-lg bg-surface-base/70 px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,w.press),t[20]=O):O=t[20];let k=!l||u,A;t[21]===u?A=t[22]:(A=u?(0,X.jsx)(o,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,X.jsx)(S,{className:`size-4`,"aria-hidden":!0}),t[21]=u,t[22]=A);let j=u?h.health.runDoctorRunning:h.health.runDoctor,M;t[23]!==u||t[24]!==a||t[25]!==k||t[26]!==A||t[27]!==j?(M=(0,X.jsxs)(`button`,{type:`button`,className:O,onClick:a,disabled:k,"aria-busy":u,children:[A,j]}),t[23]=u,t[24]=a,t[25]=k,t[26]=A,t[27]=j,t[28]=M):M=t[28];let N;t[29]!==m||t[30]!==M?(N=(0,X.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[m,M]}),t[29]=m,t[30]=M,t[31]=N):N=t[31];let P;t[32]!==N||t[33]!==C||t[34]!==D?(P=(0,X.jsxs)(`div`,{className:C,children:[D,N]}),t[32]=N,t[33]=C,t[34]=D,t[35]=P):P=t[35];let F;t[36]!==f||t[37]!==u||t[38]!==h.health.doctorCompleteMessage||t[39]!==h.health.doctorFailedMessage||t[40]!==h.health.doctorRunningMessage?(F=u||f!==`idle`?(0,X.jsx)(`p`,{className:`mt-3 text-xs opacity-75`,role:`status`,"aria-live":`polite`,children:u?h.health.doctorRunningMessage:f===`success`?h.health.doctorCompleteMessage:h.health.doctorFailedMessage}):null,t[36]=f,t[37]=u,t[38]=h.health.doctorCompleteMessage,t[39]=h.health.doctorFailedMessage,t[40]=h.health.doctorRunningMessage,t[41]=F):F=t[41];let I;return t[42]!==P||t[43]!==F||t[44]!==T?(I=(0,X.jsxs)(`section`,{className:T,children:[P,F]}),t[42]=P,t[43]=F,t[44]=T,t[45]=I):I=t[45],I}function $(e){return e.language}function ye(e){let t=(0,R.c)(26),{issue:n,fixLabel:r}=e,a;t[0]===n.status?a=t[1]:(a=Z(n.status),t[0]=n.status,t[1]=a);let o=a,s;t[2]===o?s=t[3]:(s=(0,X.jsx)(o,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=o,t[3]=s);let c;t[4]===n.label?c=t[5]:(c=(0,X.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:n.label}),t[4]=n.label,t[5]=c);let l;t[6]===n.message?l=t[7]:(l=(0,X.jsx)(`span`,{className:`mt-1 block text-sm text-fg-muted`,children:n.message}),t[6]=n.message,t[7]=l);let u;t[8]===n.hints[0]?u=t[9]:(u=n.hints[0]?(0,X.jsx)(`span`,{className:`mt-1 block truncate text-xs text-fg-subtle`,children:n.hints[0]}):null,t[8]=n.hints[0],t[9]=u);let d;t[10]!==c||t[11]!==l||t[12]!==u?(d=(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[c,l,u]}),t[10]=c,t[11]=l,t[12]=u,t[13]=d):d=t[13];let f;t[14]!==r||t[15]!==n.path?(f=n.path?(0,X.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs font-medium text-accent-fg`,children:[r,(0,X.jsx)(x,{className:`size-4`,"aria-hidden":!0})]}):null,t[14]=r,t[15]=n.path,t[16]=f):f=t[16];let p;t[17]!==s||t[18]!==d||t[19]!==f?(p=(0,X.jsxs)(X.Fragment,{children:[s,d,f]}),t[17]=s,t[18]=d,t[19]=f,t[20]=p):p=t[20];let m=p;if(n.path){let e;return t[21]!==m||t[22]!==n.path?(e=(0,X.jsx)(i,{to:n.path,className:`flex items-start gap-3 px-1 py-3 hover:bg-surface-hover/30 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:m}),t[21]=m,t[22]=n.path,t[23]=e):e=t[23],e}let h;return t[24]===m?h=t[25]:(h=(0,X.jsx)(`div`,{className:`flex items-start gap-3 px-1 py-3`,children:m}),t[24]=m,t[25]=h),h}function be(e){let t=(0,R.c)(27),{item:n,labels:r}=e,a;t[0]===n.status?a=t[1]:(a=Z(n.status),t[0]=n.status,t[1]=a);let o=a,s=r[n.id]??n.title,l;t[2]===n.status?l=t[3]:(l=c(`flex size-7 shrink-0 items-center justify-center rounded-full`,_e(n.status)),t[2]=n.status,t[3]=l);let u;t[4]===o?u=t[5]:(u=(0,X.jsx)(o,{className:`size-4`,"aria-hidden":!0}),t[4]=o,t[5]=u);let d;t[6]!==l||t[7]!==u?(d=(0,X.jsx)(`span`,{className:l,children:u}),t[6]=l,t[7]=u,t[8]=d):d=t[8];let f;t[9]===s?f=t[10]:(f=(0,X.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:s}),t[9]=s,t[10]=f);let p;t[11]===n.detail?p=t[12]:(p=(0,X.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.detail}),t[11]=n.detail,t[12]=p);let m;t[13]!==f||t[14]!==p?(m=(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[f,p]}),t[13]=f,t[14]=p,t[15]=m):m=t[15];let h;t[16]===n.path?h=t[17]:(h=n.path?(0,X.jsx)(x,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}):null,t[16]=n.path,t[17]=h);let g;t[18]!==d||t[19]!==m||t[20]!==h?(g=(0,X.jsxs)(X.Fragment,{children:[d,m,h]}),t[18]=d,t[19]=m,t[20]=h,t[21]=g):g=t[21];let _=g;if(n.path){let e;return t[22]!==_||t[23]!==n.path?(e=(0,X.jsx)(i,{to:n.path,className:`flex items-center gap-3 rounded-lg p-3 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:_}),t[22]=_,t[23]=n.path,t[24]=e):e=t[24],e}let v;return t[25]===_?v=t[26]:(v=(0,X.jsx)(`div`,{className:`flex items-center gap-3 rounded-lg p-3`,children:_}),t[25]=_,t[26]=v),v}function xe(e){let t=(0,R.c)(23),{signal:n,fixLabel:r}=e,a;t[0]===n.status?a=t[1]:(a=Z(n.status),t[0]=n.status,t[1]=a);let o=a,s;t[2]===o?s=t[3]:(s=(0,X.jsx)(o,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=o,t[3]=s);let c;t[4]===n.label?c=t[5]:(c=(0,X.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:n.label}),t[4]=n.label,t[5]=c);let l;t[6]===n.message?l=t[7]:(l=(0,X.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.message}),t[6]=n.message,t[7]=l);let u;t[8]!==c||t[9]!==l?(u=(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10];let d;t[11]!==r||t[12]!==n.path?(d=n.path?(0,X.jsx)(`span`,{className:`sr-only`,children:r}):null,t[11]=r,t[12]=n.path,t[13]=d):d=t[13];let f;t[14]!==s||t[15]!==u||t[16]!==d?(f=(0,X.jsxs)(X.Fragment,{children:[s,u,d]}),t[14]=s,t[15]=u,t[16]=d,t[17]=f):f=t[17];let p=f;if(n.path){let e;return t[18]!==p||t[19]!==n.path?(e=(0,X.jsx)(i,{to:n.path,className:`flex min-w-0 items-start gap-2 px-1 py-3 hover:bg-surface-hover/30 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:p}),t[18]=p,t[19]=n.path,t[20]=e):e=t[20],e}let m;return t[21]===p?m=t[22]:(m=(0,X.jsx)(`div`,{className:`flex min-w-0 items-start gap-2 px-1 py-3`,children:p}),t[21]=p,t[22]=m),m}function Se(){let e=s(d(e=>e.language)).setupStatus,{ready:t,error:n,snapshot:r,refresh:i}=Y(),[a,o]=(0,L.useState)(!1),[c,l]=(0,L.useState)(`idle`),u=r?.diagnosticSignals.filter(e=>e.status===`fail`||e.status===`warn`)??[],f=async()=>{if(!(a||!t)){o(!0),l(`idle`);try{await i(),l(`success`)}catch{l(`error`)}finally{o(!1)}}};return(0,X.jsxs)(M,{gap:`gap-6`,children:[(0,X.jsx)(j,{title:e.title}),n?(0,X.jsx)(`p`,{className:`rounded-xl bg-red-50 px-4 py-3 text-sm text-red-700 dark:bg-red-950/30 dark:text-red-300`,children:e.loadError}):null,!t||!r?(0,X.jsx)(F,{sections:2}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ve,{tier:r.healthTier,issueCount:r.issues.length,ready:t,onRunDoctor:()=>void f(),doctorRunning:a,doctorRunState:c}),(0,X.jsxs)(P,{id:`next-steps`,children:[(0,X.jsx)(N,{icon:r.issues.length?O:k,title:e.nextStepsTitle}),r.issues.length?(0,X.jsx)(`div`,{className:`mt-3 flex flex-col gap-1 [&>*]:rounded-lg [&>*]:bg-surface-base/45 [&>*]:px-3`,children:r.issues.slice(0,8).map(t=>(0,X.jsx)(ye,{issue:t,fixLabel:e.fixIssue},`${t.source}:${t.id}`))}):(0,X.jsx)(`div`,{className:`mt-3 flex flex-col gap-1 [&>*]:bg-surface-base/45`,children:r.readiness.map(t=>(0,X.jsx)(be,{item:t,labels:e.readinessLabels},t.id))})]}),(0,X.jsx)(I,{children:(0,X.jsxs)(P,{children:[(0,X.jsx)(N,{icon:D,title:e.diagnosticsTitle}),u.length?(0,X.jsx)(`div`,{className:`mt-3 flex flex-col gap-1 [&>*]:rounded-lg [&>*]:bg-surface-base/45 [&>*]:px-3`,children:u.map(t=>(0,X.jsx)(xe,{signal:t,fixLabel:e.fixIssue},t.id))}):(0,X.jsx)(`p`,{className:`mt-3 py-2 text-sm text-fg-muted`,children:r.diagnosticSignals.length?e.diagnosticsAllClear:e.diagnosticsEmpty})]})})]})]})}export{Se as SetupStatusPanel};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{g as i}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as a}from"./check-DUBLcKHA.js";import{n as o,r as s}from"./popover-select-0p9PIHRy.js";import{t as c}from"./copy-Dv6d4Dvw.js";import{t as l}from"./folder-open-CyzJ19I9.js";import{t as u}from"./loader-circle-CifKLtgG.js";import{t as d}from"./plus-Q2yW6OE7.js";import{t as f}from"./x-B_N4OPjy.js";import{t as p}from"./messages-DsUnS7rn.js";import{t as m}from"./cn-JdwAhgNB.js";import{a as h,c as g,n as _,r as v}from"./locale-store-7F4l6DRV.js";import{a as y,n as b,o as x,r as S,s as C,t as w}from"./dist-BGTk37IG.js";import{t as T}from"./copy-to-clipboard-HOJ79TWv.js";import{i as ee}from"./vendor-swr-BIWyz7Rc.js";import{t as E}from"./button-CS04eWY9.js";import{n as D,r as O}from"./gateway-config-swr-Hn1vj6uI.js";import{o as te}from"./agents-admin-api-C82B1W9Z.js";import{t as k}from"./skeleton-BwbyijEw.js";import{$i as A,Bi as j,Gi as M,Hc as ne,Hi as N,Ki as P,Lu as F,Mo as I,Qi as re,Ta as L,Wi as R,Wl as z,Xi as ie,Yi as B,aa as V,bn as H,bu as U,ea as W,ia as G,iu as K,jt as ae,ml as oe,na as se,pc as ce,qi as le,ra as ue,ta as de,xa as fe,xc as pe,xu as me,ya as he}from"./index-CdvabjRm.js";import{t as ge}from"./page-tabs-Bp0yPTYw.js";import{n as _e,r as ve,t as ye}from"./settings-page-layout-X1x-2Cp9.js";import{t as q}from"./settings-form-section-DziWi7ar.js";import{t as be}from"./settings-loading-skeleton-CAmWMaOT.js";var J=e(t(),1),xe=n(),Y={enabled:!0,defaultTtlHours:24,maxTtlDays:30,maxActiveShares:500,maxFileSizeMb:500,directoryMaxFolderSizeMb:2048,directoryMaxFileCount:1e4,inlinePreviewMimes:[`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`image/svg+xml`,`application/pdf`,`text/html`,`text/markdown`,`text/plain`,`application/json`],noteEnabled:!0,noteMaxTotalSizeMb:250,noteMaxAttachmentCount:50,siteEnabled:!0,siteDefaultTtlHours:24,siteMaxTtlDays:30,maxActiveSites:50,siteMaxRootDirSizeMb:1024,siteMaxFileCount:2e4};function Se(){return structuredClone(Y)}var X=36e5,Z=864e5,Q=1048576;function Ce(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function we(e,t=32){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()).slice(0,t):[]}function Te(e){let t=Ce(e)?e:{},n=Ce(t.gateway)?t.gateway:{},r=Ce(n.share)?n.share:{},i=Ce(r.directory)?r.directory:{},a=Ce(r.note)?r.note:{},o=Ce(n.siteShare)?n.siteShare:{},s=Ce(o.static)?o.static:{},c=typeof r.defaultTtlMs==`number`&&Number.isFinite(r.defaultTtlMs)?Math.floor(r.defaultTtlMs):Y.defaultTtlHours*X,l=typeof r.maxTtlMs==`number`&&Number.isFinite(r.maxTtlMs)?Math.floor(r.maxTtlMs):Y.maxTtlDays*Z,u=typeof r.maxFileSize==`number`&&Number.isFinite(r.maxFileSize)?Math.floor(r.maxFileSize):Y.maxFileSizeMb*Q,d=typeof i.maxFolderSize==`number`&&Number.isFinite(i.maxFolderSize)?Math.floor(i.maxFolderSize):Y.directoryMaxFolderSizeMb*Q,f=typeof o.defaultTtlMs==`number`&&Number.isFinite(o.defaultTtlMs)?Math.floor(o.defaultTtlMs):Y.siteDefaultTtlHours*X,p=typeof o.maxTtlMs==`number`&&Number.isFinite(o.maxTtlMs)?Math.floor(o.maxTtlMs):Y.siteMaxTtlDays*Z,m=typeof s.maxRootDirSize==`number`&&Number.isFinite(s.maxRootDirSize)?Math.floor(s.maxRootDirSize):Y.siteMaxRootDirSizeMb*Q,h=typeof a.maxTotalSize==`number`&&Number.isFinite(a.maxTotalSize)?Math.floor(a.maxTotalSize):Y.noteMaxTotalSizeMb*Q;return{enabled:r.enabled!==!1,defaultTtlHours:Math.max(1,Math.round(c/X)),maxTtlDays:Math.max(1,Math.round(l/Z)),maxActiveShares:typeof r.maxActiveShares==`number`&&Number.isFinite(r.maxActiveShares)?Math.max(1,Math.min(1e4,Math.floor(r.maxActiveShares))):Y.maxActiveShares,maxFileSizeMb:Math.max(1,Math.round(u/Q)),directoryMaxFolderSizeMb:Math.max(1,Math.round(d/Q)),directoryMaxFileCount:typeof i.maxFileCount==`number`&&Number.isFinite(i.maxFileCount)?Math.max(1,Math.min(1e5,Math.floor(i.maxFileCount))):Y.directoryMaxFileCount,inlinePreviewMimes:we(r.inlinePreviewMimes,32).length?we(r.inlinePreviewMimes,32):[...Y.inlinePreviewMimes],noteEnabled:a.enabled!==!1,noteMaxTotalSizeMb:Math.max(1,Math.round(h/Q)),noteMaxAttachmentCount:typeof a.maxAttachmentCount==`number`&&Number.isFinite(a.maxAttachmentCount)?Math.max(0,Math.min(500,Math.floor(a.maxAttachmentCount))):Y.noteMaxAttachmentCount,siteEnabled:o.enabled!==!1,siteDefaultTtlHours:Math.max(1,Math.round(f/X)),siteMaxTtlDays:Math.max(1,Math.round(p/Z)),maxActiveSites:typeof o.maxActiveSites==`number`&&Number.isFinite(o.maxActiveSites)?Math.max(1,Math.min(1e3,Math.floor(o.maxActiveSites))):Y.maxActiveSites,siteMaxRootDirSizeMb:Math.max(1,Math.round(m/Q)),siteMaxFileCount:typeof s.maxFileCount==`number`&&Number.isFinite(s.maxFileCount)?Math.max(1,Math.min(1e5,Math.floor(s.maxFileCount))):Y.siteMaxFileCount}}function Ee(e){let t=e.defaultTtlHours*X,n=e.maxTtlDays*Z,r=e.siteDefaultTtlHours*X,i=e.siteMaxTtlDays*Z;return t<6e4||t>6048e5?`Default share TTL must be between 1 minute and 7 days.`:n<6e4||n>2592e6?`Maximum share TTL must be between 1 minute and 30 days.`:t>n?`Default TTL cannot exceed maximum TTL.`:e.maxActiveShares<1||e.maxActiveShares>1e4?`Maximum active shares must be between 1 and 10,000.`:e.maxActiveSites<1||e.maxActiveSites>1e3?`Maximum active site shares must be between 1 and 1,000.`:e.maxFileSizeMb<1||e.maxFileSizeMb>10240?`Maximum file size must be between 1 MB and 10 GB.`:e.directoryMaxFolderSizeMb<1||e.directoryMaxFolderSizeMb>10240?`Maximum folder size must be between 1 MB and 10 GB.`:e.directoryMaxFileCount<1||e.directoryMaxFileCount>1e5?`Maximum directory file count must be between 1 and 100,000.`:e.noteMaxTotalSizeMb<1||e.noteMaxTotalSizeMb>2048?`Maximum Note snapshot size must be between 1 MB and 2 GB.`:e.noteMaxAttachmentCount<0||e.noteMaxAttachmentCount>500?`Maximum Note attachment count must be between 0 and 500.`:r<6e4||r>6048e5?`Default site share TTL must be between 1 minute and 7 days.`:i<6e4||i>2592e6?`Maximum site share TTL must be between 1 minute and 30 days.`:r>i?`Default site TTL cannot exceed maximum site TTL.`:e.siteMaxRootDirSizeMb<1||e.siteMaxRootDirSizeMb>10240?`Maximum static site size must be between 1 MB and 10 GB.`:e.siteMaxFileCount<1||e.siteMaxFileCount>1e5?`Maximum static site file count must be between 1 and 100,000.`:null}async function De(e){let t=Ee(e);if(t)throw Error(t);await h(v(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{share:{enabled:e.enabled,defaultTtlMs:e.defaultTtlHours*X,maxTtlMs:e.maxTtlDays*Z,maxActiveShares:e.maxActiveShares,maxFileSize:e.maxFileSizeMb*Q,inlinePreviewMimes:e.inlinePreviewMimes,directory:{maxFolderSize:e.directoryMaxFolderSizeMb*Q,maxFileCount:e.directoryMaxFileCount},note:{enabled:e.noteEnabled,maxTotalSize:e.noteMaxTotalSizeMb*Q,maxAttachmentCount:e.noteMaxAttachmentCount}},siteShare:{enabled:e.siteEnabled,defaultTtlMs:e.siteDefaultTtlHours*X,maxTtlMs:e.siteMaxTtlDays*Z,maxActiveSites:e.maxActiveSites,static:{maxRootDirSize:e.siteMaxRootDirSizeMb*Q,maxFileCount:e.siteMaxFileCount}}}})}),D()}var $=r();function Oe(){return m(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,I,`dark:border-edge`)}function ke({hasToken:e}){let t=p(_(e=>e.language)).sharesSettings,{data:n,isLoading:r}=O(e),i=(0,J.useMemo)(()=>n?.payload?.config===void 0?null:structuredClone(Te(n.payload.config)),[n]),a=(0,J.useRef)(!1),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)(null),[f,m]=(0,J.useState)(!1),h=o??i,g=i,v=(0,J.useMemo)(()=>!h||!g?!1:JSON.stringify(h)!==JSON.stringify(g),[h,g]),y=(0,J.useCallback)(e=>{a.current=!0,s(t=>{let n=t??g;return n?{...n,...e}:null})},[g]),b=(0,J.useCallback)(async()=>{if(!(!h||c)){l(!0),d(null),m(!1);try{await De(h),a.current=!1,s(null),m(!0),window.setTimeout(()=>m(!1),2500)}catch(e){d(e instanceof Error?e.message:t.policySaveError)}finally{l(!1)}}},[h,c,t.policySaveError]),x=(0,J.useCallback)(()=>{a.current=!1,s(null),d(null),m(!1)},[]);return!e||!h?r?(0,$.jsx)(q,{children:(0,$.jsx)(be,{rows:2})}):null:(0,$.jsxs)(q,{children:[(0,$.jsxs)(`div`,{className:`mb-4 flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.policyTitle}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:t.policyHint})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[f?(0,$.jsx)(`span`,{className:`text-sm text-fg-muted`,children:t.policySaved}):null,(0,$.jsx)(E,{type:`button`,variant:`secondary`,disabled:c,onClick:()=>y(Se()),children:t.policyUseRecommended}),(0,$.jsx)(E,{type:`button`,variant:`secondary`,disabled:!v||c,onClick:x,children:t.policyDiscard}),(0,$.jsx)(E,{type:`button`,variant:`primary`,disabled:!v||c,onClick:()=>void b(),children:c?t.policySaving:t.policySave})]})]}),v?(0,$.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:t.policyUnsaved}):null,u?(0,$.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:u}):null,(0,$.jsx)(`p`,{className:`mb-4 text-xs text-fg-subtle`,children:t.policyRestartHint}),(0,$.jsx)(Ae,{t,form:h,onChange:y})]})}function Ae(e){let t=(0,xe.c)(189),{t:n,form:r,onChange:i}=e,a;t[0]===n.policyFileSection?a=t[1]:(a=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.policyFileSection}),t[0]=n.policyFileSection,t[1]=a);let o;t[2]===n.policyFileSectionHint?o=t[3]:(o=(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.policyFileSectionHint}),t[2]=n.policyFileSectionHint,t[3]=o);let s;t[4]!==a||t[5]!==o?(s=(0,$.jsxs)(`div`,{className:`mb-4`,children:[a,o]}),t[4]=a,t[5]=o,t[6]=s):s=t[6];let c;t[7]===i?c=t[8]:(c=e=>i({enabled:e.target.checked}),t[7]=i,t[8]=c);let l;t[9]!==r.enabled||t[10]!==c?(l=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.enabled,onChange:c}),t[9]=r.enabled,t[10]=c,t[11]=l):l=t[11];let u;t[12]!==n.policyEnabled||t[13]!==l?(u=(0,$.jsxs)(`label`,{className:`mb-4 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[l,n.policyEnabled]}),t[12]=n.policyEnabled,t[13]=l,t[14]=u):u=t[14];let d=!r.enabled,f;t[15]===i?f=t[16]:(f=e=>i({defaultTtlHours:e}),t[15]=i,t[16]=f);let p;t[17]!==r.defaultTtlHours||t[18]!==n.policyDefaultTtlHint||t[19]!==n.policyDefaultTtlHours||t[20]!==d||t[21]!==f?(p=(0,$.jsx)(je,{id:`share-default-ttl-hours`,label:n.policyDefaultTtlHours,hint:n.policyDefaultTtlHint,value:r.defaultTtlHours,min:1,max:168,disabled:d,onChange:f}),t[17]=r.defaultTtlHours,t[18]=n.policyDefaultTtlHint,t[19]=n.policyDefaultTtlHours,t[20]=d,t[21]=f,t[22]=p):p=t[22];let m=!r.enabled,h;t[23]===i?h=t[24]:(h=e=>i({maxTtlDays:e}),t[23]=i,t[24]=h);let g;t[25]!==r.maxTtlDays||t[26]!==n.policyMaxTtlDays||t[27]!==n.policyMaxTtlHint||t[28]!==m||t[29]!==h?(g=(0,$.jsx)(je,{id:`share-max-ttl-days`,label:n.policyMaxTtlDays,hint:n.policyMaxTtlHint,value:r.maxTtlDays,min:1,max:30,disabled:m,onChange:h}),t[25]=r.maxTtlDays,t[26]=n.policyMaxTtlDays,t[27]=n.policyMaxTtlHint,t[28]=m,t[29]=h,t[30]=g):g=t[30];let _=!r.enabled,v;t[31]===i?v=t[32]:(v=e=>i({maxActiveShares:e}),t[31]=i,t[32]=v);let y;t[33]!==r.maxActiveShares||t[34]!==n.policyMaxActiveShares||t[35]!==n.policyMaxActiveSharesHint||t[36]!==_||t[37]!==v?(y=(0,$.jsx)(je,{id:`share-max-active`,label:n.policyMaxActiveShares,hint:n.policyMaxActiveSharesHint,value:r.maxActiveShares,min:1,max:1e4,disabled:_,onChange:v}),t[33]=r.maxActiveShares,t[34]=n.policyMaxActiveShares,t[35]=n.policyMaxActiveSharesHint,t[36]=_,t[37]=v,t[38]=y):y=t[38];let b=!r.enabled,x;t[39]===i?x=t[40]:(x=e=>i({maxFileSizeMb:e}),t[39]=i,t[40]=x);let S;t[41]!==r.maxFileSizeMb||t[42]!==n.policyMaxFileSizeHint||t[43]!==n.policyMaxFileSizeMb||t[44]!==b||t[45]!==x?(S=(0,$.jsx)(je,{id:`share-max-file-mb`,label:n.policyMaxFileSizeMb,hint:n.policyMaxFileSizeHint,value:r.maxFileSizeMb,min:1,max:10240,disabled:b,onChange:x}),t[41]=r.maxFileSizeMb,t[42]=n.policyMaxFileSizeHint,t[43]=n.policyMaxFileSizeMb,t[44]=b,t[45]=x,t[46]=S):S=t[46];let C=!r.enabled,w;t[47]===i?w=t[48]:(w=e=>i({directoryMaxFolderSizeMb:e}),t[47]=i,t[48]=w);let T;t[49]!==r.directoryMaxFolderSizeMb||t[50]!==n.policyDirectoryMaxFolderSizeHint||t[51]!==n.policyDirectoryMaxFolderSizeMb||t[52]!==C||t[53]!==w?(T=(0,$.jsx)(je,{id:`share-directory-max-size-mb`,label:n.policyDirectoryMaxFolderSizeMb,hint:n.policyDirectoryMaxFolderSizeHint,value:r.directoryMaxFolderSizeMb,min:1,max:10240,disabled:C,onChange:w}),t[49]=r.directoryMaxFolderSizeMb,t[50]=n.policyDirectoryMaxFolderSizeHint,t[51]=n.policyDirectoryMaxFolderSizeMb,t[52]=C,t[53]=w,t[54]=T):T=t[54];let ee=!r.enabled,E;t[55]===i?E=t[56]:(E=e=>i({directoryMaxFileCount:e}),t[55]=i,t[56]=E);let D;t[57]!==r.directoryMaxFileCount||t[58]!==n.policyDirectoryMaxFileCount||t[59]!==n.policyDirectoryMaxFileCountHint||t[60]!==ee||t[61]!==E?(D=(0,$.jsx)(je,{id:`share-directory-max-files`,label:n.policyDirectoryMaxFileCount,hint:n.policyDirectoryMaxFileCountHint,value:r.directoryMaxFileCount,min:1,max:1e5,disabled:ee,onChange:E}),t[57]=r.directoryMaxFileCount,t[58]=n.policyDirectoryMaxFileCount,t[59]=n.policyDirectoryMaxFileCountHint,t[60]=ee,t[61]=E,t[62]=D):D=t[62];let O;t[63]!==g||t[64]!==y||t[65]!==S||t[66]!==T||t[67]!==D||t[68]!==p?(O=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[p,g,y,S,T,D]}),t[63]=g,t[64]=y,t[65]=S,t[66]=T,t[67]=D,t[68]=p,t[69]=O):O=t[69];let te=!r.enabled,k;t[70]===i?k=t[71]:(k=e=>i({inlinePreviewMimes:e}),t[70]=i,t[71]=k);let A;t[72]!==r.inlinePreviewMimes||t[73]!==n||t[74]!==te||t[75]!==k?(A=(0,$.jsx)(Me,{t:n,values:r.inlinePreviewMimes,disabled:te,onChange:k}),t[72]=r.inlinePreviewMimes,t[73]=n,t[74]=te,t[75]=k,t[76]=A):A=t[76];let j;t[77]!==O||t[78]!==A||t[79]!==s||t[80]!==u?(j=(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[s,u,O,A]}),t[77]=O,t[78]=A,t[79]=s,t[80]=u,t[81]=j):j=t[81];let M;t[82]===n.policyNoteSection?M=t[83]:(M=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.policyNoteSection}),t[82]=n.policyNoteSection,t[83]=M);let ne;t[84]===n.policyNoteSectionHint?ne=t[85]:(ne=(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.policyNoteSectionHint}),t[84]=n.policyNoteSectionHint,t[85]=ne);let N;t[86]!==M||t[87]!==ne?(N=(0,$.jsxs)(`div`,{className:`mb-4`,children:[M,ne]}),t[86]=M,t[87]=ne,t[88]=N):N=t[88];let P;t[89]===i?P=t[90]:(P=e=>i({noteEnabled:e.target.checked}),t[89]=i,t[90]=P);let F;t[91]!==r.noteEnabled||t[92]!==P?(F=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.noteEnabled,onChange:P}),t[91]=r.noteEnabled,t[92]=P,t[93]=F):F=t[93];let I;t[94]!==n.policyNoteEnabled||t[95]!==F?(I=(0,$.jsxs)(`label`,{className:`mb-4 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[F,n.policyNoteEnabled]}),t[94]=n.policyNoteEnabled,t[95]=F,t[96]=I):I=t[96];let re=!r.enabled||!r.noteEnabled,L;t[97]===i?L=t[98]:(L=e=>i({noteMaxTotalSizeMb:e}),t[97]=i,t[98]=L);let R;t[99]!==r.noteMaxTotalSizeMb||t[100]!==n.policyNoteMaxTotalSizeHint||t[101]!==n.policyNoteMaxTotalSizeMb||t[102]!==re||t[103]!==L?(R=(0,$.jsx)(je,{id:`share-note-max-size-mb`,label:n.policyNoteMaxTotalSizeMb,hint:n.policyNoteMaxTotalSizeHint,value:r.noteMaxTotalSizeMb,min:1,max:2048,disabled:re,onChange:L}),t[99]=r.noteMaxTotalSizeMb,t[100]=n.policyNoteMaxTotalSizeHint,t[101]=n.policyNoteMaxTotalSizeMb,t[102]=re,t[103]=L,t[104]=R):R=t[104];let z=!r.enabled||!r.noteEnabled,ie;t[105]===i?ie=t[106]:(ie=e=>i({noteMaxAttachmentCount:e}),t[105]=i,t[106]=ie);let B;t[107]!==r.noteMaxAttachmentCount||t[108]!==n.policyNoteMaxAttachmentCount||t[109]!==n.policyNoteMaxAttachmentCountHint||t[110]!==z||t[111]!==ie?(B=(0,$.jsx)(je,{id:`share-note-max-attachments`,label:n.policyNoteMaxAttachmentCount,hint:n.policyNoteMaxAttachmentCountHint,value:r.noteMaxAttachmentCount,min:0,max:500,disabled:z,onChange:ie}),t[107]=r.noteMaxAttachmentCount,t[108]=n.policyNoteMaxAttachmentCount,t[109]=n.policyNoteMaxAttachmentCountHint,t[110]=z,t[111]=ie,t[112]=B):B=t[112];let V;t[113]!==R||t[114]!==B?(V=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[R,B]}),t[113]=R,t[114]=B,t[115]=V):V=t[115];let H;t[116]!==N||t[117]!==I||t[118]!==V?(H=(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[N,I,V]}),t[116]=N,t[117]=I,t[118]=V,t[119]=H):H=t[119];let U;t[120]===n.policySiteSection?U=t[121]:(U=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.policySiteSection}),t[120]=n.policySiteSection,t[121]=U);let W;t[122]===n.policySiteSectionHint?W=t[123]:(W=(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.policySiteSectionHint}),t[122]=n.policySiteSectionHint,t[123]=W);let G;t[124]!==U||t[125]!==W?(G=(0,$.jsxs)(`div`,{className:`mb-4`,children:[U,W]}),t[124]=U,t[125]=W,t[126]=G):G=t[126];let K;t[127]===i?K=t[128]:(K=e=>i({siteEnabled:e.target.checked}),t[127]=i,t[128]=K);let ae;t[129]!==r.siteEnabled||t[130]!==K?(ae=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.siteEnabled,onChange:K}),t[129]=r.siteEnabled,t[130]=K,t[131]=ae):ae=t[131];let oe;t[132]!==n.policySiteEnabled||t[133]!==ae?(oe=(0,$.jsxs)(`label`,{className:`mb-4 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[ae,n.policySiteEnabled]}),t[132]=n.policySiteEnabled,t[133]=ae,t[134]=oe):oe=t[134];let se=!r.siteEnabled,ce;t[135]===i?ce=t[136]:(ce=e=>i({siteDefaultTtlHours:e}),t[135]=i,t[136]=ce);let le;t[137]!==r.siteDefaultTtlHours||t[138]!==n.policySiteDefaultTtlHint||t[139]!==n.policySiteDefaultTtlHours||t[140]!==se||t[141]!==ce?(le=(0,$.jsx)(je,{id:`site-share-default-ttl-hours`,label:n.policySiteDefaultTtlHours,hint:n.policySiteDefaultTtlHint,value:r.siteDefaultTtlHours,min:1,max:168,disabled:se,onChange:ce}),t[137]=r.siteDefaultTtlHours,t[138]=n.policySiteDefaultTtlHint,t[139]=n.policySiteDefaultTtlHours,t[140]=se,t[141]=ce,t[142]=le):le=t[142];let ue=!r.siteEnabled,de;t[143]===i?de=t[144]:(de=e=>i({siteMaxTtlDays:e}),t[143]=i,t[144]=de);let fe;t[145]!==r.siteMaxTtlDays||t[146]!==n.policySiteMaxTtlDays||t[147]!==n.policySiteMaxTtlHint||t[148]!==ue||t[149]!==de?(fe=(0,$.jsx)(je,{id:`site-share-max-ttl-days`,label:n.policySiteMaxTtlDays,hint:n.policySiteMaxTtlHint,value:r.siteMaxTtlDays,min:1,max:30,disabled:ue,onChange:de}),t[145]=r.siteMaxTtlDays,t[146]=n.policySiteMaxTtlDays,t[147]=n.policySiteMaxTtlHint,t[148]=ue,t[149]=de,t[150]=fe):fe=t[150];let pe=!r.siteEnabled,me;t[151]===i?me=t[152]:(me=e=>i({maxActiveSites:e}),t[151]=i,t[152]=me);let he;t[153]!==r.maxActiveSites||t[154]!==n.policyMaxActiveSites||t[155]!==n.policyMaxActiveSitesHint||t[156]!==pe||t[157]!==me?(he=(0,$.jsx)(je,{id:`site-share-max-active`,label:n.policyMaxActiveSites,hint:n.policyMaxActiveSitesHint,value:r.maxActiveSites,min:1,max:1e3,disabled:pe,onChange:me}),t[153]=r.maxActiveSites,t[154]=n.policyMaxActiveSites,t[155]=n.policyMaxActiveSitesHint,t[156]=pe,t[157]=me,t[158]=he):he=t[158];let ge=!r.siteEnabled,_e;t[159]===i?_e=t[160]:(_e=e=>i({siteMaxRootDirSizeMb:e}),t[159]=i,t[160]=_e);let ve;t[161]!==r.siteMaxRootDirSizeMb||t[162]!==n.policySiteMaxRootDirSizeHint||t[163]!==n.policySiteMaxRootDirSizeMb||t[164]!==ge||t[165]!==_e?(ve=(0,$.jsx)(je,{id:`site-share-max-root-size-mb`,label:n.policySiteMaxRootDirSizeMb,hint:n.policySiteMaxRootDirSizeHint,value:r.siteMaxRootDirSizeMb,min:1,max:10240,disabled:ge,onChange:_e}),t[161]=r.siteMaxRootDirSizeMb,t[162]=n.policySiteMaxRootDirSizeHint,t[163]=n.policySiteMaxRootDirSizeMb,t[164]=ge,t[165]=_e,t[166]=ve):ve=t[166];let ye=!r.siteEnabled,q;t[167]===i?q=t[168]:(q=e=>i({siteMaxFileCount:e}),t[167]=i,t[168]=q);let be;t[169]!==r.siteMaxFileCount||t[170]!==n.policySiteMaxFileCount||t[171]!==n.policySiteMaxFileCountHint||t[172]!==ye||t[173]!==q?(be=(0,$.jsx)(je,{id:`site-share-max-files`,label:n.policySiteMaxFileCount,hint:n.policySiteMaxFileCountHint,value:r.siteMaxFileCount,min:1,max:1e5,disabled:ye,onChange:q}),t[169]=r.siteMaxFileCount,t[170]=n.policySiteMaxFileCount,t[171]=n.policySiteMaxFileCountHint,t[172]=ye,t[173]=q,t[174]=be):be=t[174];let J;t[175]!==le||t[176]!==fe||t[177]!==he||t[178]!==ve||t[179]!==be?(J=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[le,fe,he,ve,be]}),t[175]=le,t[176]=fe,t[177]=he,t[178]=ve,t[179]=be,t[180]=J):J=t[180];let Y;t[181]!==G||t[182]!==oe||t[183]!==J?(Y=(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[G,oe,J]}),t[181]=G,t[182]=oe,t[183]=J,t[184]=Y):Y=t[184];let Se;return t[185]!==j||t[186]!==H||t[187]!==Y?(Se=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[j,H,Y]}),t[185]=j,t[186]=H,t[187]=Y,t[188]=Se):Se=t[188],Se}function je(e){let t=(0,xe.c)(21),{id:n,label:r,hint:i,value:a,min:o,max:s,disabled:c,onChange:l}=e,u;t[0]!==n||t[1]!==r?(u=(0,$.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=u):u=t[2];let d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=m(Oe(),`max-w-xs font-mono text-xs`),t[3]=d):d=t[3];let f;t[4]!==s||t[5]!==o||t[6]!==l?(f=e=>{let t=Number(e.target.value);Number.isFinite(t)&&l(Math.max(o,Math.min(s,Math.floor(t))))},t[4]=s,t[5]=o,t[6]=l,t[7]=f):f=t[7];let p;t[8]!==c||t[9]!==n||t[10]!==s||t[11]!==o||t[12]!==f||t[13]!==a?(p=(0,$.jsx)(`input`,{id:n,type:`number`,min:o,max:s,disabled:c,className:d,value:a,onChange:f}),t[8]=c,t[9]=n,t[10]=s,t[11]=o,t[12]=f,t[13]=a,t[14]=p):p=t[14];let h;t[15]===i?h=t[16]:(h=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}),t[15]=i,t[16]=h);let g;return t[17]!==u||t[18]!==p||t[19]!==h?(g=(0,$.jsxs)(`div`,{children:[u,p,h]}),t[17]=u,t[18]=p,t[19]=h,t[20]=g):g=t[20],g}function Me(e){let t=(0,xe.c)(25),{t:n,values:r,disabled:i,onChange:a}=e,o;t[0]!==a||t[1]!==r?(o=e=>{let t=e.trim();!t||r.includes(t)||r.length>=32||a([...r,t])},t[0]=a,t[1]=r,t[2]=o):o=t[2];let s=o,c;t[3]===n.policyInlinePreviewMimes?c=t[4]:(c=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.policyInlinePreviewMimes}),t[3]=n.policyInlinePreviewMimes,t[4]=c);let l;t[5]===n.policyInlinePreviewMimesHint?l=t[6]:(l=(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.policyInlinePreviewMimesHint}),t[5]=n.policyInlinePreviewMimesHint,t[6]=l);let u;t[7]!==i||t[8]!==a||t[9]!==r?(u=r.map(e=>(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-0.5 font-mono text-xs text-fg`,children:[e,i?null:(0,$.jsx)(`button`,{type:`button`,className:`text-fg-muted hover:text-fg`,"aria-label":`Remove ${e}`,onClick:()=>a(r.filter(t=>t!==e)),children:`×`})]},e)),t[7]=i,t[8]=a,t[9]=r,t[10]=u):u=t[10];let d;t[11]===u?d=t[12]:(d=(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:u}),t[11]=u,t[12]=d);let f;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(f=m(Oe(),`font-mono text-xs`),t[13]=f):f=t[13];let p=i||r.length>=32,h;t[14]===s?h=t[15]:(h=e=>{e.key===`Enter`&&(e.preventDefault(),s(e.target.value),e.target.value=``)},t[14]=s,t[15]=h);let g;t[16]!==n.policyMimePlaceholder||t[17]!==p||t[18]!==h?(g=(0,$.jsx)(`input`,{className:f,placeholder:n.policyMimePlaceholder,disabled:p,onKeyDown:h}),t[16]=n.policyMimePlaceholder,t[17]=p,t[18]=h,t[19]=g):g=t[19];let _;return t[20]!==c||t[21]!==l||t[22]!==d||t[23]!==g?(_=(0,$.jsxs)(`div`,{className:`space-y-2 rounded-xl bg-surface-base/45 p-4`,children:[c,l,d,g]}),t[20]=c,t[21]=l,t[22]=d,t[23]=g,t[24]=_):_=t[24],_}function Ne(e){let t=(0,xe.c)(70),{open:n,onOpenChange:r,onConfirm:i,initialPath:a,selectKind:c,conversationId:d,agentId:h}=e,v=c===void 0?`any`:c,T=p(_(Ie)),D=T.workspace,O=T.sharesSettings,k=j(Fe),{data:A}=ee(g(Pe)?`picker-agents-list`:null,te),M;bb0:{let e;t[0]===h?e=t[1]:(e=h?.trim(),t[0]=h,t[1]=e);let n=e;if(n){M=n;break bb0}let r;t[2]===k?r=t[3]:(r=k.trim(),t[2]=k,t[3]=r);let i=r;if(i){M=i;break bb0}if(A?.defaultId){M=A.defaultId;break bb0}if(A?.agents?.[0]?.id){M=A.agents[0].id;break bb0}M=``}let P=M,[F,I]=(0,J.useState)(P),re,L;t[4]===P?(re=t[5],L=t[6]):(re=()=>{I(P)},L=[P],t[4]=P,t[5]=re,t[6]=L),(0,J.useEffect)(re,L);let{tree:R,loading:z,error:ie,loadRoot:B,loadChildren:V,reset:U}=N(F,d??null),W;t[7]===a?W=t[8]:(W=a?{path:a,isDirectory:!1}:null,t[7]=a,t[8]=W);let[G,K]=(0,J.useState)(W),ae;t[9]!==a||t[10]!==B||t[11]!==n||t[12]!==U||t[13]!==K?(ae=()=>{if(!n){U(),K(a?{path:a,isDirectory:!1}:null);return}B()},t[9]=a,t[10]=B,t[11]=n,t[12]=U,t[13]=K,t[14]=ae):ae=t[14];let oe;t[15]!==d||t[16]!==a||t[17]!==B||t[18]!==n||t[19]!==F||t[20]!==U?(oe=[n,F,d,B,U,a],t[15]=d,t[16]=a,t[17]=B,t[18]=n,t[19]=F,t[20]=U,t[21]=oe):oe=t[21],(0,J.useEffect)(ae,oe);let se;t[22]===V?se=t[23]:(se=e=>{V(e)},t[22]=V,t[23]=se);let ce=se,le=G!==null&&(v===`any`||v===`file`&&!G.isDirectory||v===`directory`&&G.isDirectory),ue;bb1:{if(!G){ue=O.pickerHintNone;break bb1}if(v===`file`&&G.isDirectory){ue=O.pickerHintNeedsFile;break bb1}if(v===`directory`&&!G.isDirectory){ue=O.pickerHintNeedsDirectory;break bb1}ue=`${G.isDirectory?`📁`:`📄`} ${G.path}`}let de=ue,fe=A?.agents??[],pe;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,$.jsx)(y,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),t[24]=pe):pe=t[24];let me;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(me=m(`xopc-dialog-content fixed left-1/2 top-1/2 z-[71] w-[min(34rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2`,`flex h-[min(28rem,calc(100vh-3rem))] flex-col overflow-hidden rounded-lg border border-edge bg-surface-overlay shadow-popover outline-none`),t[25]=me):me=t[25];let ge;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,$.jsx)(l,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[26]=ge):ge=t[26];let _e=T.cron.refresh,ve=T.cron.refresh,ye;t[27]===B?ye=t[28]:(ye=()=>void B(),t[27]=B,t[28]=ye);let q=z&&`animate-spin`,be;t[29]===q?be=t[30]:(be=m(`size-4`,q),t[29]=q,t[30]=be);let Y;t[31]===be?Y=t[32]:(Y=(0,$.jsx)(ne,{className:be,"aria-hidden":!0}),t[31]=be,t[32]=Y);let Se;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,$.jsx)(f,{className:`size-4`}),t[33]=Se):Se=t[33];let X;t[34]!==ie||t[35]!==D.loadError?(X=ie?(0,$.jsxs)(`p`,{className:`shrink-0 px-4 py-2 text-xs text-red-600 dark:text-red-400`,children:[D.loadError,`: `,ie]}):null,t[34]=ie,t[35]=D.loadError,t[36]=X):X=t[36];let Z;t[37]!==ce||t[38]!==z||t[39]!==G?.path||t[40]!==K||t[41]!==D.emptyDir||t[42]!==D.title||t[43]!==R?(Z=z&&R.length===0?(0,$.jsxs)(`p`,{className:`flex shrink-0 items-center gap-2 px-4 py-3 text-sm text-fg-muted`,children:[(0,$.jsx)(u,{className:`size-4 animate-spin`}),D.title,`…`]}):(0,$.jsx)(he,{tree:R,selectedPath:G?.path??null,onSelectFile:e=>K({path:e,isDirectory:!1}),onSelectEntry:(e,t)=>K({path:e,isDirectory:t}),onExpandDir:ce,onAction:void 0,emptyHint:D.emptyDir}),t[37]=ce,t[38]=z,t[39]=G?.path,t[40]=K,t[41]=D.emptyDir,t[42]=D.title,t[43]=R,t[44]=Z):Z=t[44];let Q;t[45]!==X||t[46]!==Z?(Q=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[X,Z]}),t[45]=X,t[46]=Z,t[47]=Q):Q=t[47];let Ce;t[48]===de?Ce=t[49]:(Ce=(0,$.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,children:de}),t[48]=de,t[49]=Ce);let we;t[50]===r?we=t[51]:(we=()=>r(!1),t[50]=r,t[51]=we);let Te;t[52]!==O.cancel||t[53]!==we?(Te=(0,$.jsx)(E,{type:`button`,variant:`ghost`,onClick:we,children:O.cancel}),t[52]=O.cancel,t[53]=we,t[54]=Te):Te=t[54];let Ee=!le,De;t[55]!==i||t[56]!==r||t[57]!==F||t[58]!==G?(De=()=>{G&&(i({...G,agentId:F}),r(!1))},t[55]=i,t[56]=r,t[57]=F,t[58]=G,t[59]=De):De=t[59];let Oe;t[60]!==O.pickerConfirm||t[61]!==Ee||t[62]!==De?(Oe=(0,$.jsx)(E,{type:`button`,disabled:Ee,onClick:De,children:O.pickerConfirm}),t[60]=O.pickerConfirm,t[61]=Ee,t[62]=De,t[63]=Oe):Oe=t[63];let ke;t[64]!==Te||t[65]!==Oe?(ke=(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[Te,Oe]}),t[64]=Te,t[65]=Oe,t[66]=ke):ke=t[66];let Ae;return t[67]!==Ce||t[68]!==ke?(Ae=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-t border-edge px-4 py-3`,children:[Ce,ke]}),t[67]=Ce,t[68]=ke,t[69]=Ae):Ae=t[69],(0,$.jsx)(w,{open:n,onOpenChange:r,children:(0,$.jsxs)(x,{children:[pe,(0,$.jsxs)(S,{className:me,children:[(0,$.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-edge px-4`,children:[ge,(0,$.jsx)(C,{className:`min-w-0 flex-1 truncate text-base font-semibold text-fg`,children:O.pickerTitle}),(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-50`,title:_e,"aria-label":ve,disabled:z,onClick:ye,children:Y}),(0,$.jsx)(b,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":D.close,children:Se})})]}),fe.length>0?(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-edge px-4 py-2`,children:[(0,$.jsx)(`label`,{className:`text-xs text-fg-muted`,htmlFor:`picker-agent-select`,children:O.pickerAgentLabel}),(0,$.jsx)(o,{id:`picker-agent-select`,className:`min-w-0 flex-1 rounded-md border border-edge bg-surface-panel px-2 py-1 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:F,onChange:e=>{I(e.target.value),K(null)},children:fe.map(e=>(0,$.jsxs)(s,{value:e.id,children:[H(e,T.agentsSettings),e.id===A?.defaultId?` ★`:``]},e.id))})]}):null,Q,Ae]})]})})}function Pe(e){return e.conversationId}function Fe(e){return e.agentId}function Ie(e){return e.language}var Le=[`shares`,`policy`];function Re(e){let t=(e??``).trim();return Le.includes(t)?t:`shares`}function ze(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(1)} GB`}function Be(e,t){let n=new Date(e).getTime()-Date.now(),r=Math.abs(n),i=n<0;if(r<6e4)return t===`zh`?`刚刚`:`just now`;let a=Math.floor(r/6e4);if(a<60){let e=t===`zh`?`${a} 分钟`:`${a}m`;return i?t===`zh`?`${e}前`:`${e} ago`:e}let o=Math.floor(a/60);if(o<24){let e=t===`zh`?`${o} 小时`:`${o}h`;return i?t===`zh`?`${e}前`:`${e} ago`:e}let s=Math.floor(o/24),c=t===`zh`?`${s} 天`:`${s}d`;return i?t===`zh`?`${c}前`:`${c} ago`:c}var Ve=[{value:36e5,key:`1h`},{value:216e5,key:`6h`},{value:864e5,key:`24h`},{value:2592e5,key:`3d`},{value:6048e5,key:`7d`},{value:2592e6,key:`30d`}];function He(){let e=(0,xe.c)(23),t=_(We),n=p(t).sharesSettings,r=!!g(Ue),[a,o]=i(),s;e[0]===a?s=e[1]:(s=Re(a.get(`tab`)),e[0]=a,e[1]=s);let c=s,l;e[2]===o?l=e[3]:(l=e=>{o(t=>{let n=new URLSearchParams(t);return e===`shares`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[2]=o,e[3]=l);let u=l;if(!r)return(0,$.jsx)(ve,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})});let d={shares:n.tabShares,policy:n.tabPolicy},f=Le.map(e=>({id:e,label:d[e]})),m;e[4]===n.title?m=e[5]:(m=(0,$.jsx)(_e,{title:n.title}),e[4]=n.title,e[5]=m);let h;e[6]!==c||e[7]!==u||e[8]!==n.tabsAria||e[9]!==f?(h=(0,$.jsx)(ge,{items:f,activeTab:c,onChange:u,ariaLabel:n.tabsAria,tabIdPrefix:`shares-tab`,panelIdPrefix:`shares-panel`}),e[6]=c,e[7]=u,e[8]=n.tabsAria,e[9]=f,e[10]=h):h=e[10];let v;e[11]!==c||e[12]!==r||e[13]!==t||e[14]!==n?(v=c===`shares`?(0,$.jsx)(Ge,{t:n,language:t}):(0,$.jsx)(ke,{hasToken:r}),e[11]=c,e[12]=r,e[13]=t,e[14]=n,e[15]=v):v=e[15];let y;e[16]!==c||e[17]!==v?(y=(0,$.jsx)(ye,{id:c,activeTab:c,tabIdPrefix:`shares-tab`,panelIdPrefix:`shares-panel`,showHeading:!1,children:v}),e[16]=c,e[17]=v,e[18]=y):y=e[18];let b;return e[19]!==m||e[20]!==h||e[21]!==y?(b=(0,$.jsxs)(ve,{children:[m,h,y]}),e[19]=m,e[20]=h,e[21]=y,e[22]=b):b=e[22],b}function Ue(e){return e.conversationId}function We(e){return e.language}function Ge(e){let t=(0,xe.c)(79),{t:n,language:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={refreshInterval:3e4},t[0]=i):i=t[0];let{data:a,error:o,isLoading:s,mutate:c}=ee(`shares-list`,re,i),l;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(l={refreshInterval:3e4},t[1]=l):l=t[1];let u=ee(`hosted-publications-list`,ie,l),d;t[2]===a?.payload?.shares?d=t[3]:(d=a?.payload?.shares??[],t[2]=a?.payload?.shares,t[3]=d);let f=d,[p,h]=(0,J.useState)(!1),g;bb0:{if(p){g=f;break bb0}let e;t[4]===f?e=t[5]:(e=f.filter(Xe),t[4]=f,t[5]=e),g=e}let _=g,v;t[6]===f?v=t[7]:(v=f.filter(Ye),t[6]=f,t[7]=v);let y=v.length,b;t[8]===f?b=t[9]:(b=f.filter(Je),t[8]=f,t[9]=b);let x=b.length,S;t[10]===c?S=t[11]:(S=()=>void c(),t[10]=c,t[11]=S);let C;t[12]!==n||t[13]!==S?(C=(0,$.jsx)(nt,{t:n,onCreated:S}),t[12]=n,t[13]=S,t[14]=C):C=t[14];let w=u.data?.connected===!0,T=u.data?.publishingAllowed===!0,D;t[15]===u?D=t[16]:(D=()=>void u.mutate(),t[15]=u,t[16]=D);let O;t[17]!==r||t[18]!==T||t[19]!==D||t[20]!==w?(O=(0,$.jsx)(Ze,{language:r,connected:w,publishingAllowed:T,onCreated:D}),t[17]=r,t[18]=T,t[19]=D,t[20]=w,t[21]=O):O=t[21];let te=p?n.allSharesTitle:n.listTitle,k;t[22]===y?k=t[23]:(k=y>0&&(0,$.jsxs)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:[`(`,y,`)`]}),t[22]=y,t[23]=k);let A;t[24]!==te||t[25]!==k?(A=(0,$.jsxs)(`h2`,{className:`text-sm font-semibold text-fg`,children:[te,k]}),t[24]=te,t[25]=k,t[26]=A):A=t[26];let j;t[27]===c?j=t[28]:(j=()=>void c(),t[27]=c,t[28]=j);let M=s&&`animate-spin`,N;t[29]===M?N=t[30]:(N=m(`size-3.5`,M),t[29]=M,t[30]=N);let P;t[31]===N?P=t[32]:(P=(0,$.jsx)(ne,{className:N}),t[31]=N,t[32]=P);let F;t[33]!==s||t[34]!==j||t[35]!==P?(F=(0,$.jsx)(E,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:j,disabled:s,children:P}),t[33]=s,t[34]=j,t[35]=P,t[36]=F):F=t[36];let I;t[37]!==x||t[38]!==p||t[39]!==n.hideExpired||t[40]!==n.showExpired?(I=x>0&&(0,$.jsx)(`button`,{type:`button`,className:`text-xs text-accent hover:underline`,onClick:()=>h(qe),children:p?n.hideExpired:n.showExpired}),t[37]=x,t[38]=p,t[39]=n.hideExpired,t[40]=n.showExpired,t[41]=I):I=t[41];let L;t[42]!==F||t[43]!==I?(L=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[F,I]}),t[42]=F,t[43]=I,t[44]=L):L=t[44];let R;t[45]!==A||t[46]!==L?(R=(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[A,L]}),t[45]=A,t[46]=L,t[47]=R):R=t[47];let z;t[48]!==a||t[49]!==o||t[50]!==_||t[51]!==s||t[52]!==r||t[53]!==c||t[54]!==n?(z=s&&!a?(0,$.jsx)(`div`,{className:`grid gap-2`,"aria-busy":`true`,children:Array.from({length:4}).map(Ke)}):o?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-red-600 dark:text-red-400`,children:[(0,$.jsx)(`span`,{children:n.error}),(0,$.jsx)(E,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-xs`,onClick:()=>void c(),children:n.retry})]}):_.length===0?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.emptyState}):(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:_.map(e=>(0,$.jsx)(it,{share:e,t:n,language:r,onRevoked:()=>void c(),onExtended:()=>void c()},e.id))}),t[48]=a,t[49]=o,t[50]=_,t[51]=s,t[52]=r,t[53]=c,t[54]=n,t[55]=z):z=t[55];let B;t[56]!==x||t[57]!==c||t[58]!==p||t[59]!==n?(B=x>0&&p&&(0,$.jsx)(at,{t:n,onCleaned:()=>void c()}),t[56]=x,t[57]=c,t[58]=p,t[59]=n,t[60]=B):B=t[60];let V;t[61]!==R||t[62]!==z||t[63]!==B?(V=(0,$.jsxs)(q,{children:[R,z,B]}),t[61]=R,t[62]=z,t[63]=B,t[64]=V):V=t[64];let H;t[65]===u?H=t[66]:(H=()=>void u.mutate(),t[65]=u,t[66]=H);let U;t[67]!==u.data||t[68]!==u.error||t[69]!==u.isLoading||t[70]!==r||t[71]!==n||t[72]!==H?(U=(0,$.jsx)(Qe,{data:u.data,error:u.error,isLoading:u.isLoading,language:r,t:n,onChanged:H}),t[67]=u.data,t[68]=u.error,t[69]=u.isLoading,t[70]=r,t[71]=n,t[72]=H,t[73]=U):U=t[73];let W;return t[74]!==O||t[75]!==V||t[76]!==U||t[77]!==C?(W=(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[C,O,V,U]}),t[74]=O,t[75]=V,t[76]=U,t[77]=C,t[78]=W):W=t[78],W}function Ke(e,t){return(0,$.jsx)(`div`,{className:`rounded-lg bg-surface-base/55 p-3`,children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(k,{className:`h-4 w-2/3`}),(0,$.jsx)(k,{className:`mt-2 h-3 w-1/2`})]}),(0,$.jsx)(k,{className:`h-7 w-20 rounded-md`})]})},t)}function qe(e){return!e}function Je(e){return e.expired||e.revoked}function Ye(e){return!e.expired&&!e.revoked}function Xe(e){return!e.expired&&!e.revoked}function Ze({language:e,connected:t,publishingAllowed:n,onCreated:r}){let i=e===`zh`,[a,c]=(0,J.useState)(``),[d,f]=(0,J.useState)(``),[p,m]=(0,J.useState)(!1),[h,g]=(0,J.useState)(!1),[_,v]=(0,J.useState)(``),[y,b]=(0,J.useState)(6048e5),[x,S]=(0,J.useState)(!1),[C,w]=(0,J.useState)(null),[ee,D]=(0,J.useState)(null),O=async()=>{if(a.trim()){S(!0),D(null);try{w(await M({path:a.trim(),title:_.trim()||void 0,ttlMs:y,spaFallback:!0,...d?{agentId:d}:{}})),r()}catch(e){D(e instanceof Error?e.message:String(e))}finally{S(!1)}}};return(0,$.jsxs)(q,{children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(U,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:i?`发布静态网站`:`Publish static website`}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:i?`把工作区内的 HTML 文件,或包含 index.html 的网站目录,发布到隔离的托管域名。`:`Publish an HTML file or a website directory containing index.html to the isolated hosted origin.`}),t&&!n?(0,$.jsx)(`p`,{className:`mt-3 rounded-md bg-warning-soft px-3 py-2 text-xs text-warning`,children:i?`管理员已暂停你的公网分享能力。已有远端链接当前不可访问;你仍可在下方撤销它们。`:`An administrator has paused public sharing for your account. Existing hosted links are unavailable, but you can still revoke them below.`}):null,(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-[1fr_12rem]`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`input`,{value:a,onChange:e=>{c(e.target.value),m(!1),w(null)},placeholder:i?`选择 HTML 文件或网站目录`:`Select an HTML file or website directory`,className:`h-9 min-w-0 flex-1 rounded-md border border-edge bg-surface-panel px-3 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent`}),(0,$.jsxs)(E,{type:`button`,variant:`ghost`,className:`shrink-0`,onClick:()=>g(!0),children:[a&&!p?(0,$.jsx)(K,{className:`size-4`}):(0,$.jsx)(l,{className:`size-4`}),a?i?`更换`:`Change`:i?`选择`:`Browse`]})]}),(0,$.jsxs)(o,{value:String(y),onChange:e=>b(Number(e.target.value)),children:[(0,$.jsx)(s,{value:`86400000`,children:i?`24 小时`:`24 hours`}),(0,$.jsx)(s,{value:`604800000`,children:i?`7 天`:`7 days`}),(0,$.jsx)(s,{value:`2592000000`,children:i?`30 天`:`30 days`})]}),(0,$.jsx)(`input`,{value:_,onChange:e=>v(e.target.value),placeholder:i?`网站标题(可选)`:`Site title (optional)`,className:`h-9 rounded-md border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent sm:col-span-2`})]}),(0,$.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,$.jsxs)(E,{type:`button`,onClick:()=>void O(),disabled:!a.trim()||x||!t||!n,children:[x?(0,$.jsx)(u,{className:`size-4 animate-spin`}):(0,$.jsx)(U,{className:`size-4`}),x?i?`发布中…`:`Publishing…`:i?`发布网站`:`Publish site`]}),C?(0,$.jsxs)(`button`,{type:`button`,className:`min-w-0 truncate text-xs text-accent hover:underline`,onClick:()=>void T(C.shareUrl),children:[C.shareUrl,` · `,C.fileCount,` `,i?`个文件`:`files`,` · `,ze(C.totalBytes)]}):null]}),ee?(0,$.jsx)(`p`,{className:`mt-3 text-xs text-danger`,children:ee}):null]})]}),(0,$.jsx)(Ne,{open:h,onOpenChange:g,initialPath:a||void 0,agentId:d||void 0,selectKind:`any`,onConfirm:e=>{c(e.path),f(e.agentId),m(e.isDirectory),w(null),D(null)}})]})}function Qe(e){let t=(0,xe.c)(18),{data:n,error:r,isLoading:i,language:a,t:o,onChanged:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(U,{className:`size-4 text-accent`,"aria-hidden":!0}),t[0]=c):c=t[0];let l;t[1]===o.hostedTitle?l=t[2]:(l=(0,$.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[c,o.hostedTitle]}),t[1]=o.hostedTitle,t[2]=l);let u;t[3]===o.hostedHint?u=t[4]:(u=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:o.hostedHint}),t[3]=o.hostedHint,t[4]=u);let d;t[5]!==l||t[6]!==u?(d=(0,$.jsx)(`div`,{className:`mb-3 flex items-start justify-between gap-3`,children:(0,$.jsxs)(`div`,{children:[l,u]})}),t[5]=l,t[6]=u,t[7]=d):d=t[7];let f;t[8]!==n||t[9]!==r||t[10]!==i||t[11]!==a||t[12]!==s||t[13]!==o?(f=i&&!n?(0,$.jsx)(`div`,{className:`grid gap-2`,"aria-busy":`true`,children:Array.from({length:2}).map($e)}):r?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:o.error}):n?.connected?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[n.publishingAllowed?null:(0,$.jsx)(`p`,{className:`rounded-md bg-warning-soft px-3 py-2 text-xs text-warning`,children:a===`zh`?`管理员已暂停公网分享。已有托管链接当前不可访问,也不能更新;撤销操作仍然可用。`:`An administrator has paused public sharing. Existing hosted links are unavailable and cannot be updated; revocation remains available.`}),n.publications.length===0?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.hostedEmpty}):(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:n.publications.map(e=>(0,$.jsx)(et,{publication:e,language:a,t:o,publishingAllowed:n.publishingAllowed,onChanged:s},e.id))})]}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.hostedDisconnected}),(0,$.jsx)(ae,{providerId:`xopc-share`,displayName:`XOPC Hosted Share`,connected:!1,onConnected:s})]}),t[8]=n,t[9]=r,t[10]=i,t[11]=a,t[12]=s,t[13]=o,t[14]=f):f=t[14];let p;return t[15]!==d||t[16]!==f?(p=(0,$.jsxs)(q,{children:[d,f]}),t[15]=d,t[16]=f,t[17]=p):p=t[17],p}function $e(e,t){return(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-base/55 p-3`,children:[(0,$.jsx)(k,{className:`h-4 w-2/3`}),(0,$.jsx)(k,{className:`mt-2 h-3 w-1/2`})]},t)}function et({publication:e,language:t,t:n,publishingAllowed:r,onChanged:i}){let[o,s]=(0,J.useState)(!1),[l,d]=(0,J.useState)(!1),[f,p]=(0,J.useState)(!1),[h,g]=(0,J.useState)(!1),[_,v]=(0,J.useState)(!1),y=Date.now()>=new Date(e.expiresAt).getTime(),b=e.status===`active`&&!y,x=e.status===`revoked`?n.statusRevoked:y?n.statusExpired:e.status===`staging`?t===`zh`?`准备中`:`Staging`:n.statusActive,S=e.kind===`note_document`?pe:e.kind===`static_site`?U:oe,C=e.kind===`note_document`?t===`zh`?`笔记文档`:`Note document`:e.kind===`static_site`?t===`zh`?`静态网站`:`Static website`:t===`zh`?`会话快照`:`Conversation snapshot`,w=(0,J.useCallback)(async()=>{e.shareUrl&&await T(e.shareUrl)&&(p(!0),window.setTimeout(()=>p(!1),2e3))},[e.shareUrl]),ee=(0,J.useCallback)(async()=>{s(!1),d(!0);try{await W(e.id),i()}catch{}finally{d(!1)}},[e.id,i]),D=(0,J.useCallback)(async()=>{if(!(!e.revision||e.revision<=1)){g(!0);try{let t=(await B(e.id)).find(t=>t.revision<e.revision);if(!t)return;await se(e.id,e.revision,t.revision),i()}catch{}finally{g(!1)}}},[e.id,e.revision,i]),O=(0,J.useCallback)(async()=>{v(!0);try{await A(e.id),i()}catch{}finally{v(!1)}},[e.id,i]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`rounded-lg bg-surface-base/55 px-3 py-2.5`,children:(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(S,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.title}),(0,$.jsx)(`span`,{className:m(`text-xs font-medium`,b?`text-emerald-600 dark:text-emerald-400`:`text-fg-subtle`),children:x})]}),(0,$.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:[C,` · `,n.hostedRevision,` `,e.revision??`—`,` · `,e.managedFromThisDevice?n.hostedThisDevice:n.hostedOtherDevice]}),(0,$.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,$.jsxs)(`span`,{children:[t===`zh`?`浏览`:`Views`,`: `,e.viewCount,e.maxViews===null?``:` / ${e.maxViews}`]}),(0,$.jsx)(`span`,{children:y?n.statusExpired:Be(e.expiresAt,t)}),e.description?(0,$.jsx)(`span`,{className:`italic`,children:e.description}):null]})]}),b?(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[e.shareUrl?(0,$.jsx)(E,{type:`button`,variant:`ghost`,className:`px-2 py-1`,disabled:!r,title:n.copyUrl,onClick:()=>void w(),children:f?(0,$.jsx)(a,{className:`size-3.5 text-emerald-500`}):(0,$.jsx)(c,{className:`size-3.5`})}):null,(e.revision??0)>1?(0,$.jsx)(E,{type:`button`,variant:`ghost`,className:`px-2 py-1`,disabled:h||!r,onClick:()=>void D(),title:t===`zh`?`回滚上一版本`:`Roll back one revision`,children:h?(0,$.jsx)(u,{className:`size-3.5 animate-spin`}):(0,$.jsx)(z,{className:`size-3.5`})}):null,e.kind===`static_site`&&e.managedFromThisDevice?(0,$.jsx)(E,{type:`button`,variant:`ghost`,className:`px-2 py-1`,disabled:_||!r,onClick:()=>void O(),title:t===`zh`?`发布工作区中的最新版本`:`Publish latest workspace version`,children:(0,$.jsx)(ne,{className:m(`size-3.5`,_&&`animate-spin`)})}):null,(0,$.jsx)(E,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-red-600 hover:text-red-700 dark:text-red-400`,disabled:l,onClick:()=>s(!0),children:l?(0,$.jsx)(u,{className:`size-3.5 animate-spin`}):(0,$.jsx)(ce,{className:`size-3.5`})})]}):null]})}),(0,$.jsx)(fe,{open:o,title:n.revokeConfirmTitle,description:n.revokeConfirmBody,confirmLabel:n.revokeConfirmLabel,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void ee(),onCancel:()=>s(!1)})]})}var tt={expanded:!0,path:``,isDirectory:!1,agentId:``,ttlMs:864e5,maxViews:null,description:``,directoryMode:`browse`,creating:!1,result:null,errorMsg:null,resultDialogOpen:!1,pickerOpen:!1};function nt({t:e,onCreated:t}){let[n,r]=(0,J.useReducer)(L,tt),{expanded:i,path:a,isDirectory:c,agentId:l,ttlMs:f,maxViews:p,description:h,directoryMode:g,creating:_,result:v,errorMsg:y,resultDialogOpen:b,pickerOpen:x}=n,S=(0,J.useCallback)(async()=>{if(a.trim()){r({type:`patch`,patch:{creating:!0,errorMsg:null,result:null}});try{r({type:`patch`,patch:{result:(await P({path:a.trim(),ttlMs:f,maxViews:p,description:h.trim()||void 0,...l?{agentId:l}:{},...c?{kind:`directory`,directoryMode:g}:{}})).payload,resultDialogOpen:!0}}),t()}catch(e){r({type:`patch`,patch:{errorMsg:e instanceof Error?e.message:String(e)}})}finally{r({type:`patch`,patch:{creating:!1}})}}},[a,c,l,f,p,h,g,t]),C=(0,J.useCallback)(()=>{r({type:`patch`,patch:{path:``,isDirectory:!1,agentId:``,description:``,maxViews:null,ttlMs:864e5,directoryMode:`browse`,result:null,errorMsg:null}})},[]);return i?(0,$.jsxs)(q,{children:[(0,$.jsx)(`h2`,{className:`mb-1 text-sm font-semibold text-fg`,children:e.createTitle}),(0,$.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:e.createHint}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.pathLabel}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:m(`flex min-w-0 flex-1 items-center gap-2 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm`,a?`text-fg`:`text-fg-subtle`),children:a?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,children:c?`📁`:`📄`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:a,children:a})]}):(0,$.jsx)(`span`,{className:`truncate`,children:e.pathPlaceholder})}),(0,$.jsxs)(E,{type:`button`,variant:`ghost`,onClick:()=>r({type:`patch`,patch:{pickerOpen:!0}}),children:[(0,$.jsx)(K,{className:`size-4`}),a?e.pathBrowseChange:e.pathBrowse]})]})]}),c?(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.directoryModeLabel}),(0,$.jsxs)(o,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:g,onChange:e=>r({type:`patch`,patch:{directoryMode:e.target.value===`zip-only`?`zip-only`:`browse`}}),children:[(0,$.jsx)(s,{value:`browse`,children:e.directoryModeBrowse}),(0,$.jsx)(s,{value:`zip-only`,children:e.directoryModeZipOnly})]})]}):null,(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.ttlLabel}),(0,$.jsx)(o,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:f,onChange:e=>r({type:`patch`,patch:{ttlMs:Number(e.target.value)}}),children:Ve.map(t=>(0,$.jsx)(s,{value:t.value,children:e.ttlOptions[t.key]},t.key))})]}),(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.maxViewsLabel}),(0,$.jsxs)(o,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:p??`unlimited`,onChange:e=>r({type:`patch`,patch:{maxViews:e.target.value===`unlimited`?null:Number(e.target.value)}}),children:[(0,$.jsx)(s,{value:`unlimited`,children:e.maxViewsUnlimited}),(0,$.jsx)(s,{value:`1`,children:`1`}),(0,$.jsx)(s,{value:`5`,children:`5`}),(0,$.jsx)(s,{value:`10`,children:`10`}),(0,$.jsx)(s,{value:`50`,children:`50`}),(0,$.jsx)(s,{value:`100`,children:`100`})]})]})]}),(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.descriptionLabel}),(0,$.jsx)(`input`,{type:`text`,className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:outline-none focus:ring-2 focus:ring-accent`,placeholder:e.descriptionPlaceholder,value:h,onChange:e=>r({type:`patch`,patch:{description:e.target.value}})})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,$.jsxs)(E,{type:`button`,disabled:_||!a.trim(),onClick:()=>void S(),children:[_?(0,$.jsx)(u,{className:`size-4 animate-spin`}):(0,$.jsx)(d,{className:`size-4`}),_?e.creating:e.createButton]}),(0,$.jsx)(E,{type:`button`,variant:`ghost`,onClick:()=>{C(),r({type:`patch`,patch:{expanded:!1}})},children:e.cancel})]}),y&&(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:y})]}),(0,$.jsx)(G,{open:b,onOpenChange:e=>{r({type:`patch`,patch:{resultDialogOpen:e,...e?{}:{result:null}}})},result:v}),(0,$.jsx)(Ne,{open:x,onOpenChange:e=>r({type:`patch`,patch:{pickerOpen:e}}),initialPath:a||void 0,selectKind:`any`,onConfirm:e=>r({type:`patch`,patch:{path:e.path,isDirectory:e.isDirectory,agentId:e.agentId,directoryMode:`browse`}})})]}):(0,$.jsxs)(E,{type:`button`,onClick:()=>r({type:`patch`,patch:{expanded:!0}}),className:`self-start`,children:[(0,$.jsx)(d,{className:`size-4`}),e.createTitle]})}var rt={revokeOpen:!1,revoking:!1,linksOpen:!1,urlCopied:!1,copyFailed:!1,extending:!1};function it({share:e,t,language:n,onRevoked:r,onExtended:i}){let[o,s]=(0,J.useReducer)(L,rt),{revokeOpen:l,revoking:d,linksOpen:f,urlCopied:p,copyFailed:h,extending:g}=o,_=!e.expired&&!e.revoked,v=e.revoked?t.statusRevoked:e.expired?t.statusExpired:t.statusActive,y=e.revoked?`text-red-600 dark:text-red-400`:e.expired?`text-fg-subtle`:`text-emerald-600 dark:text-emerald-400`,b=(0,J.useCallback)(async()=>{s({type:`patch`,patch:{revokeOpen:!1,revoking:!0}});try{await de(e.id),r()}catch{}finally{s({type:`patch`,patch:{revoking:!1}})}},[e.id,r]),x=(0,J.useCallback)(async()=>{if(s({type:`patch`,patch:{linksOpen:!0,copyFailed:!1}}),!await T(e.shareUrl)){s({type:`patch`,patch:{copyFailed:!0}}),window.setTimeout(()=>s({type:`patch`,patch:{copyFailed:!1}}),2500);return}s({type:`patch`,patch:{urlCopied:!0}}),window.setTimeout(()=>s({type:`patch`,patch:{urlCopied:!1}}),2e3)},[e.shareUrl]),S=(0,J.useCallback)(async()=>{s({type:`patch`,patch:{extending:!0}});try{await le(e.id,864e5),i()}catch{}finally{s({type:`patch`,patch:{extending:!1}})}},[e.id,i]),C=`share-links-${e.id}`;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsxs)(`button`,{type:`button`,className:m(`flex min-w-0 flex-1 items-start gap-3 rounded-md text-left`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),"aria-expanded":f,"aria-controls":C,onClick:()=>s({type:`patch`,patch:{linksOpen:!f}}),children:[(0,$.jsx)(F,{className:m(`mt-0.5 size-4 shrink-0 text-fg-muted transition-transform`,f?`rotate-0`:`-rotate-90`),"aria-hidden":!0}),e.kind===`note`?(0,$.jsx)(pe,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}):e.kind===`session`?(0,$.jsx)(oe,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}):(0,$.jsx)(K,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.fileName}),(0,$.jsx)(`span`,{className:m(`text-xs font-medium`,y),children:v})]}),(0,$.jsx)(`p`,{className:`truncate text-xs text-fg-subtle`,children:e.kind===`note`?n===`zh`?`笔记快照 · 版本 ${e.snapshotRevision??1}`:`Note snapshot · revision ${e.snapshotRevision??1}`:e.kind===`session`?n===`zh`?`会话快照 · ${e.messageCount??0} 条消息 · 版本 ${e.snapshotRevision??1}`:`Conversation snapshot · ${e.messageCount??0} messages · revision ${e.snapshotRevision??1}`:e.workspaceRelativePath}),(0,$.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,$.jsx)(`span`,{children:ze(e.fileSize)}),(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(me,{className:`size-3`}),e.expired?n===`zh`?`已过期`:`expired`:Be(e.expiresAt,n)]}),(0,$.jsxs)(`span`,{children:[t.views,`: `,e.downloadCount,e.maxViews!==null&&` ${t.viewsOf} ${e.maxViews}`]}),e.description&&(0,$.jsx)(`span`,{className:`italic text-fg-subtle`,children:e.description})]})]})]}),(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:_&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(E,{type:`button`,variant:`ghost`,className:`px-2 py-1`,title:t.copyUrl,onClick:()=>void x(),children:p?(0,$.jsx)(a,{className:`size-3.5 text-emerald-500`}):(0,$.jsx)(c,{className:`size-3.5`})}),(0,$.jsx)(E,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:()=>void S(),disabled:g,title:t.extend,children:g?(0,$.jsx)(u,{className:`size-3.5 animate-spin`}):(0,$.jsx)(me,{className:`size-3.5`})}),(0,$.jsx)(E,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-red-600 hover:text-red-700 dark:text-red-400`,onClick:()=>s({type:`patch`,patch:{revokeOpen:!0}}),disabled:d,children:d?(0,$.jsx)(u,{className:`size-3.5 animate-spin`}):(0,$.jsx)(ce,{className:`size-3.5`})})]})})]}),_&&f?(0,$.jsxs)(`div`,{id:C,className:`mt-3 bg-surface-base/45 py-3 pl-7 pr-3`,children:[(0,$.jsx)(V,{shareUrl:e.shareUrl,lanUrl:e.lanUrl,reachability:e.reachability,compact:!0}),h?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-red-600 dark:text-red-400`,children:t.copyFailed}):null,(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsx)(ue,{reachability:e.reachability})})]}):null]}),(0,$.jsx)(fe,{open:l,title:t.revokeConfirmTitle,description:t.revokeConfirmBody,confirmLabel:t.revokeConfirmLabel,cancelLabel:t.cancel,destructive:!0,onConfirm:()=>void b(),onCancel:()=>s({type:`patch`,patch:{revokeOpen:!1}})})]})}function at({t:e,onCleaned:t}){let[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(!1),o=(0,J.useCallback)(async()=>{r(!1),a(!0);try{await R(),t()}catch{}finally{a(!1)}},[t]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,$.jsxs)(E,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>r(!0),className:`border-danger/40 px-2 py-1 text-xs text-danger hover:bg-danger/10`,children:[i?(0,$.jsx)(u,{className:`size-3.5 animate-spin`}):(0,$.jsx)(ce,{className:`size-3.5`}),e.cleanExpired]})}),(0,$.jsx)(fe,{open:n,title:e.cleanExpiredConfirmTitle,description:e.cleanExpiredConfirmBody,confirmLabel:e.cleanExpiredConfirmLabel,cancelLabel:e.cancel,destructive:!0,onConfirm:()=>void o(),onCancel:()=>r(!1)})]})}export{He as SharesSettingsPanel};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{i as t,r as n}from"./locale-store-7F4l6DRV.js";import{Fi as r}from"./index-CdvabjRm.js";var i=e({reloadSkills:()=>a});async function a(){let e=await t(n(`/api/skills/reload`),{method:`POST`});if(!e.ok)throw Error(await r(e))}export{i as n,a as t};