@xopcai/xopc 0.0.361 → 0.0.363

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 (220) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{activity-store-tpFInIoh.js → activity-store-GvR2gZ0T.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DUhFW_Go.js → agent-avatar-dicebear-DkcXyPH0.js} +1 -1
  5. package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-BNILmgey.js → agent-defaults-settings-panel-B-l5AaYN.js} +1 -1
  6. package/dist/gateway/static/root/assets/{agent-plugin-dialog-CnWci4JJ.js → agent-plugin-dialog-BY6tPYOK.js} +1 -1
  7. package/dist/gateway/static/root/assets/{agents-CKS5LUUs.js → agents-CdSEoeje.js} +3 -3
  8. package/dist/gateway/static/root/assets/{agents-admin-api-CiAjB2iQ.js → agents-admin-api-BkXb7VEZ.js} +1 -1
  9. package/dist/gateway/static/root/assets/{app-management-settings-panel-DEig00YU.js → app-management-settings-panel-BtD53cfe.js} +1 -1
  10. package/dist/gateway/static/root/assets/{appearance-settings-CccnRRrL.js → appearance-settings-BAweWgX_.js} +1 -1
  11. package/dist/gateway/static/root/assets/{apps-page-CkT6UNZW.js → apps-page-CS6-hrIB.js} +1 -1
  12. package/dist/gateway/static/root/assets/{archive-plugin-CIlmZBe5.js → archive-plugin-CKe3qAaL.js} +1 -1
  13. package/dist/gateway/static/root/assets/{automations-page-8kZugDcf.js → automations-page-CtE8r9Y2.js} +1 -1
  14. package/dist/gateway/static/root/assets/{automations-workspace-3V54ShL0.js → automations-workspace-pnMgR4Da.js} +1 -1
  15. package/dist/gateway/static/root/assets/{binary-plugins-BuQiee_b.js → binary-plugins-J51oS7-D.js} +1 -1
  16. package/dist/gateway/static/root/assets/{block-editor-BFFRbsKX.js → block-editor-D5hf6WcP.js} +1 -1
  17. package/dist/gateway/static/root/assets/{browser-automation-inputs-CWujpdCx.js → browser-automation-inputs-5B3qAdmb.js} +1 -1
  18. package/dist/gateway/static/root/assets/{browser-automations-page-HVXiBKXE.js → browser-automations-page-PZDQlXH4.js} +1 -1
  19. package/dist/gateway/static/root/assets/{browser-settings-page-DpxAXNvM.js → browser-settings-page-2YDV-ZWt.js} +1 -1
  20. package/dist/gateway/static/root/assets/{capabilities-CngwB2JU.js → capabilities-BKu9BqPe.js} +1 -1
  21. package/dist/gateway/static/root/assets/{capabilities-RMlKKfGF.js → capabilities-CT_ZW9fT.js} +1 -1
  22. package/dist/gateway/static/root/assets/{capabilities-page-BBi4ef3u.js → capabilities-page-CB-iX3Fy.js} +2 -2
  23. package/dist/gateway/static/root/assets/{capabilities-settings-panel-IxszGl-Q.js → capabilities-settings-panel-BCTuWNaW.js} +1 -1
  24. package/dist/gateway/static/root/assets/{capability-header-actions-BLOIJvIZ.js → capability-header-actions--aC5XB9E.js} +1 -1
  25. package/dist/gateway/static/root/assets/{channels-Ced5nFBc.js → channels-JnAQP1bt.js} +1 -1
  26. package/dist/gateway/static/root/assets/{chat-terminal-dock-BskUzDCS.js → chat-terminal-dock-BFZEpvzn.js} +1 -1
  27. package/dist/gateway/static/root/assets/{computer-settings-page-De-pjlvn.js → computer-settings-page-Dc9ooEM-.js} +1 -1
  28. package/dist/gateway/static/root/assets/{connector-service-page-Qc1mVfp9.js → connector-service-page-1_QB5D-t.js} +1 -1
  29. package/dist/gateway/static/root/assets/{connectors-page-CPqeY1x5.js → connectors-page-Um_Jy5zh.js} +1 -1
  30. package/dist/gateway/static/root/assets/{date-picker-7ppMIGfQ.js → date-picker-C9ZqTPui.js} +1 -1
  31. package/dist/gateway/static/root/assets/dependency-picker-DBz0Pmyr.js +1 -0
  32. package/dist/gateway/static/root/assets/{desktop-pet-GKEfqHDF.js → desktop-pet-BLtp2MmX.js} +1 -1
  33. package/dist/gateway/static/root/assets/{desktop-pet-settings-qoFZBKe9.js → desktop-pet-settings-BNGbqwec.js} +1 -1
  34. package/dist/gateway/static/root/assets/{device-pairing-wizard-D8sTDd5s.js → device-pairing-wizard-7rdo-A7d.js} +1 -1
  35. package/dist/gateway/static/root/assets/{directory-picker-path-field-BC87CZa2.js → directory-picker-path-field-BnilGgwM.js} +1 -1
  36. package/dist/gateway/static/root/assets/{extension-debug-page-VxCq29jC.js → extension-debug-page-BGyJpRv4.js} +1 -1
  37. package/dist/gateway/static/root/assets/{extension-page-DypBVBTt.js → extension-page-DsrVktRN.js} +1 -1
  38. package/dist/gateway/static/root/assets/{extension-provider-wlvxPese.js → extension-provider-F9JzOWZ3.js} +1 -1
  39. package/dist/gateway/static/root/assets/{extension-settings-page-DzzkBN9y.js → extension-settings-page-jeb0ytRK.js} +1 -1
  40. package/dist/gateway/static/root/assets/{fallback-models-s4qTRcPJ.js → fallback-models-bZcxkEDz.js} +1 -1
  41. package/dist/gateway/static/root/assets/{gateway-config-swr-ZM72jovc.js → gateway-config-swr-CoRoOG1l.js} +1 -1
  42. package/dist/gateway/static/root/assets/{gateway-realtime-B-hrykag.js → gateway-realtime-D0ygm6bc.js} +1 -1
  43. package/dist/gateway/static/root/assets/gateway-realtime-store-DBvCRclh.js +1 -0
  44. package/dist/gateway/static/root/assets/{gateway-settings--M7ZH_37.js → gateway-settings-A9SzLsGp.js} +1 -1
  45. package/dist/gateway/static/root/assets/{gateway-startup-retry-DjWuTj8B.js → gateway-startup-retry-FDS6S6qa.js} +1 -1
  46. package/dist/gateway/static/root/assets/{home-page-KFs5suD1.js → home-page-CnHzaH9K.js} +1 -1
  47. package/dist/gateway/static/root/assets/{image-generation-api-C9cwrqCr.js → image-generation-api-BPd76jW5.js} +1 -1
  48. package/dist/gateway/static/root/assets/{imports-page-BKy0ImXk.js → imports-page-CzpsV6Vz.js} +1 -1
  49. package/dist/gateway/static/root/assets/{index-C0JT9Ja4.js → index-BYNmHn-z.js} +7 -7
  50. package/dist/gateway/static/root/assets/index-CbJNcWAn.css +1 -0
  51. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CexiL-Ey.js → keyboard-shortcuts-settings-D90Dvlwo.js} +1 -1
  52. package/dist/gateway/static/root/assets/{local-app-workbench-page-CcU1OLWQ.js → local-app-workbench-page-_9IKMkV8.js} +1 -1
  53. package/dist/gateway/static/root/assets/{local-apps-page-BcLijQx4.js → local-apps-page-D6gejARs.js} +1 -1
  54. package/dist/gateway/static/root/assets/{local-session-drafts-C7QjBMNp.js → local-session-drafts-gbemPamv.js} +1 -1
  55. package/dist/gateway/static/root/assets/{locale-store-5sV3dDRG.js → locale-store-DId6-v2R.js} +1 -1
  56. package/dist/gateway/static/root/assets/{logs-page-48nrZNQe.js → logs-page--t8d-oLb.js} +1 -1
  57. package/dist/gateway/static/root/assets/{management-settings-B_gzl_Vh.js → management-settings-DVDmXzTg.js} +1 -1
  58. package/dist/gateway/static/root/assets/{markdown-view-V0f5NW7D.js → markdown-view-DQZ51j9e.js} +1 -1
  59. package/dist/gateway/static/root/assets/{media-plugins-_obxSZmT.js → media-plugins-XLewwq2q.js} +1 -1
  60. package/dist/gateway/static/root/assets/{messages-CaURu8bb.js → messages-BHvpZNe9.js} +2 -2
  61. package/dist/gateway/static/root/assets/models-hub-cache-B9SKjidc.js +1 -0
  62. package/dist/gateway/static/root/assets/{note-detail-panel-B9AeX98W.js → note-detail-panel-DuZAEfU1.js} +3 -3
  63. package/dist/gateway/static/root/assets/{notes-api-CBnMq6Nc.js → notes-api-Byt65v3r.js} +1 -1
  64. package/dist/gateway/static/root/assets/{notes-page-CKTTfxw-.js → notes-page-CgWNESGp.js} +1 -1
  65. package/dist/gateway/static/root/assets/{oauth-api-Bu2RoLF2.js → oauth-api-BYsCbyGZ.js} +1 -1
  66. package/dist/gateway/static/root/assets/{page-context-capture-button-BsxBAWD_.js → page-context-capture-button-Z72eiQZn.js} +1 -1
  67. package/dist/gateway/static/root/assets/{personal-page-Cfl1FR3i.js → personal-page-BtMatL9a.js} +1 -1
  68. package/dist/gateway/static/root/assets/{product-open-page-D1ARqS3r.js → product-open-page-w5Hdf0hQ.js} +1 -1
  69. package/dist/gateway/static/root/assets/{project-detail-page-Cro1OE8P.js → project-detail-page-CP6I3ZCV.js} +1 -1
  70. package/dist/gateway/static/root/assets/{projects-page-CdEmmBCz.js → projects-page-DYs6XrrK.js} +1 -1
  71. package/dist/gateway/static/root/assets/{registry-api-j1rNFkP2.js → registry-api-7F2WNEZC.js} +1 -1
  72. package/dist/gateway/static/root/assets/{remote-access-hub-C9_ea_4p.js → remote-access-hub-DjYoYAEw.js} +1 -1
  73. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-DtmQbC72.js → runtime-tools-settings-panel-Qar_DXLv.js} +1 -1
  74. package/dist/gateway/static/root/assets/{scenes-page-DeFdMf2q.js → scenes-page-BSIcDCa-.js} +1 -1
  75. package/dist/gateway/static/root/assets/{schema-form-ByEHHW6n.js → schema-form-C_cJLGgF.js} +1 -1
  76. package/dist/gateway/static/root/assets/{send-session-input-CO_vUCb8.js → send-session-input-D1oc6BC6.js} +1 -1
  77. package/dist/gateway/static/root/assets/{session-api-CYPGi01d.js → session-api-N3N37MrR.js} +1 -1
  78. package/dist/gateway/static/root/assets/{session-manager-BdJThQQ6.js → session-manager-CMGUwtbN.js} +2 -2
  79. package/dist/gateway/static/root/assets/{sessions-page-CV0JlaXS.js → sessions-page-BBV5Z24a.js} +1 -1
  80. package/dist/gateway/static/root/assets/settings-advanced-gate-DRc9IDJf.js +1 -0
  81. package/dist/gateway/static/root/assets/{settings-page-CHKsZFAN.js → settings-page-F2vGXBw7.js} +1 -1
  82. package/dist/gateway/static/root/assets/{setup-status-panel-CC58OVOe.js → setup-status-panel-DJxbjUOg.js} +1 -1
  83. package/dist/gateway/static/root/assets/{share-link-dialog-ZOdnHkmb.js → share-link-dialog-TBBGJPfT.js} +1 -1
  84. package/dist/gateway/static/root/assets/{share-preview-page-BPDWUuH_.js → share-preview-page-DyRLPsPv.js} +1 -1
  85. package/dist/gateway/static/root/assets/{shares-api-T5gR8yqz.js → shares-api-DU0fHP2G.js} +1 -1
  86. package/dist/gateway/static/root/assets/{shares-settings-DaXvdH8c.js → shares-settings-CJa6FBpP.js} +1 -1
  87. package/dist/gateway/static/root/assets/{skill-api-CHCLMcfO.js → skill-api-C340XD9d.js} +1 -1
  88. package/dist/gateway/static/root/assets/{skill-reload-api-C-RoiUJi.js → skill-reload-api-ClyFqHk7.js} +1 -1
  89. package/dist/gateway/static/root/assets/{skills-page-a9UQQnqn.js → skills-page-C4lF94m5.js} +1 -1
  90. package/dist/gateway/static/root/assets/{system-settings-panel-Dho_dlBS.js → system-settings-panel-CmJUu3lb.js} +1 -1
  91. package/dist/gateway/static/root/assets/task-detail-page-De-Rr8W6.js +2 -0
  92. package/dist/gateway/static/root/assets/{theme-store-CEl74p7l.js → theme-store-OhcbFEUR.js} +1 -1
  93. package/dist/gateway/static/root/assets/tracing-settings-page-DoBJ0TYY.js +1 -0
  94. package/dist/gateway/static/root/assets/{tunnel-api-BDqCyf8G.js → tunnel-api-Bl4nrCuE.js} +1 -1
  95. package/dist/gateway/static/root/assets/{usage-page-DKwKfszc.js → usage-page-QZEAaa8n.js} +1 -1
  96. package/dist/gateway/static/root/assets/{use-autosave-D09eZTLp.js → use-autosave-veoM0dHn.js} +1 -1
  97. package/dist/gateway/static/root/assets/{use-composer-attachments-CkvJM8Km.js → use-composer-attachments-DB0bBGzZ.js} +1 -1
  98. package/dist/gateway/static/root/assets/{use-file-preview-expanded-J3HnG8OH.js → use-file-preview-expanded-Bope6MW6.js} +2 -2
  99. package/dist/gateway/static/root/assets/{user-model-page-BsgADrGL.js → user-model-page-Crh2oNpZ.js} +1 -1
  100. package/dist/gateway/static/root/assets/{voice-api-key-field-DH-to9Rd.js → voice-api-key-field-CwD6a3KQ.js} +1 -1
  101. package/dist/gateway/static/root/assets/{voice-config-api-CmCfVy3H.js → voice-config-api-Daexehmc.js} +1 -1
  102. package/dist/gateway/static/root/assets/{work-discovery-overlay-x1vZDBhu.js → work-discovery-overlay-9jnjEAaz.js} +1 -1
  103. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DGatvmK1.js → workflow-run-setup-panel-BAcPxdcT.js} +1 -1
  104. package/dist/gateway/static/root/assets/{workflows-page-DgNy6mBQ.js → workflows-page-D8Zm-ooa.js} +1 -1
  105. package/dist/gateway/static/root/assets/{workspace-api-DzPw92Kx.js → workspace-api-Cs4sjV2A.js} +2 -2
  106. package/dist/gateway/static/root/connector-icons/README.md +5 -2
  107. package/dist/gateway/static/root/connector-icons/SOURCES.md +15 -1
  108. package/dist/gateway/static/root/connector-icons/amap.ico +0 -0
  109. package/dist/gateway/static/root/connector-icons/antv-chart.png +0 -0
  110. package/dist/gateway/static/root/connector-icons/bailian.png +0 -0
  111. package/dist/gateway/static/root/connector-icons/dida365.png +0 -0
  112. package/dist/gateway/static/root/connector-icons/flomo.png +0 -0
  113. package/dist/gateway/static/root/connector-icons/gmail.svg +1 -3
  114. package/dist/gateway/static/root/connector-icons/jira.svg +3 -14
  115. package/dist/gateway/static/root/connector-icons/railway-12306.jpg +0 -0
  116. package/dist/gateway/static/root/connector-icons/railway-query.svg +1 -0
  117. package/dist/gateway/static/root/connector-icons/tencent-docs.ico +0 -0
  118. package/dist/gateway/static/root/connector-icons/yuque.png +0 -0
  119. package/dist/gateway/static/root/index.html +28 -28
  120. package/dist/package.js +1 -1
  121. package/dist/packages/gateway-contract/src/task-result-delivery.js +2 -2
  122. package/dist/src/agent/agent-manager.js +10 -6
  123. package/dist/src/agent/embedded/model-runtime.js +1 -1
  124. package/dist/src/agent/embedded/run-for-session.js +28 -3
  125. package/dist/src/agent/embedded/run-turn.js +18 -3
  126. package/dist/src/agent/image/tool-model-config.js +1 -1
  127. package/dist/src/agent/mcp/oauth/mcp-oauth-store.js +1 -1
  128. package/dist/src/agent/service.js +5 -3
  129. package/dist/src/agent/skills/hub-lock.js +1 -1
  130. package/dist/src/agent/tasks/task-judge-service.js +1 -1
  131. package/dist/src/agent-catalog/migrations/legacy-config-cutover.js +1 -1
  132. package/dist/src/agent-catalog/repository.js +1 -1
  133. package/dist/src/auth/credentials.js +2 -2
  134. package/dist/src/auth/oauth-provider-lock.js +1 -1
  135. package/dist/src/auth/profiles/store.js +1 -1
  136. package/dist/src/auth/sync-provider-auth.js +1 -1
  137. package/dist/src/browser/providers/browser-ext-install.js +1 -1
  138. package/dist/src/chat-commands/agent-edit.js +1 -1
  139. package/dist/src/chat-commands/builtins/config.js +1 -1
  140. package/dist/src/cli/commands/agent.js +1 -1
  141. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  142. package/dist/src/cli/commands/doctor/checks/image-providers.js +1 -1
  143. package/dist/src/cli/commands/doctor/checks/provider-auth.js +3 -3
  144. package/dist/src/cli/commands/models.js +1 -1
  145. package/dist/src/cli/commands/onboard/model.js +3 -3
  146. package/dist/src/config/agent-profile.js +1 -1
  147. package/dist/src/config/index.js +4 -4
  148. package/dist/src/config/loader.js +2 -2
  149. package/dist/src/config/models-json.js +1 -1
  150. package/dist/src/config/reload.d.ts +1 -0
  151. package/dist/src/config/reload.js +4 -0
  152. package/dist/src/config/rules.js +5 -0
  153. package/dist/src/config/schema.d.ts +23 -0
  154. package/dist/src/config/schema.js +6 -3
  155. package/dist/src/connectors/china-catalog.js +572 -0
  156. package/dist/src/connectors/cli/authorization.js +3 -2
  157. package/dist/src/connectors/cli/installer.js +3 -1
  158. package/dist/src/extensions/activation-context.js +1 -1
  159. package/dist/src/extensions/lockfile.js +1 -1
  160. package/dist/src/gateway/file-path-classifier.js +1 -1
  161. package/dist/src/gateway/hono/lib/config-payload.js +2 -2
  162. package/dist/src/gateway/hono/routes/agents.js +1 -1
  163. package/dist/src/gateway/hono/routes/config-patch/misc.js +2 -2
  164. package/dist/src/gateway/hono/routes/lazy-bundles.js +8 -0
  165. package/dist/src/gateway/hono/routes/models.js +2 -2
  166. package/dist/src/gateway/hono/routes/observability.d.ts +3 -0
  167. package/dist/src/gateway/hono/routes/observability.js +106 -0
  168. package/dist/src/gateway/image-generation-setup.js +1 -1
  169. package/dist/src/gateway/lock.js +1 -1
  170. package/dist/src/gateway/security/gateway-scopes.js +1 -0
  171. package/dist/src/gateway/service/config-coordinator.d.ts +0 -25
  172. package/dist/src/gateway/service/config-coordinator.js +31 -0
  173. package/dist/src/gateway/service.js +5 -3
  174. package/dist/src/gateway/side-chat/manager.js +3 -2
  175. package/dist/src/observability/config.d.ts +40 -0
  176. package/dist/src/observability/config.js +31 -0
  177. package/dist/src/observability/langfuse.d.ts +31 -0
  178. package/dist/src/observability/langfuse.js +180 -0
  179. package/dist/src/observability/runtime.d.ts +57 -0
  180. package/dist/src/observability/runtime.js +404 -0
  181. package/dist/src/observability/sanitize.d.ts +3 -0
  182. package/dist/src/observability/sanitize.js +74 -0
  183. package/dist/src/observability/store.d.ts +20 -0
  184. package/dist/src/observability/store.js +128 -0
  185. package/dist/src/observability/storeWorker.d.ts +2 -0
  186. package/dist/src/observability/storeWorker.js +155 -0
  187. package/dist/src/observability/types.d.ts +21 -0
  188. package/dist/src/observability/types.js +1 -0
  189. package/dist/src/platform/index.js +1 -1
  190. package/dist/src/providers/auth-runtime/resolve-auth.js +1 -1
  191. package/dist/src/providers/index.js +3 -3
  192. package/dist/src/providers/model-call.js +19 -5
  193. package/dist/src/providers/model-catalog-persistence.js +1 -1
  194. package/dist/src/providers/model-registry.js +1 -1
  195. package/dist/src/providers/provider-disconnect-core.js +1 -1
  196. package/dist/src/providers/xopc-cloud-catalog-coordinator.js +1 -1
  197. package/dist/src/storage/sqlite/ai-usage-repository.d.ts +6 -0
  198. package/dist/src/storage/sqlite/ai-usage-repository.js +4 -2
  199. package/dist/src/storage/sqlite/migrations/233_observability_usage_links.sql +3 -0
  200. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  201. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  202. package/dist/src/storage/sqlite/schema.js +1 -1
  203. package/dist/src/tasks/task-result-delivery-repository.js +4 -5
  204. package/dist/src/tui/backends/embedded-backend.js +2 -2
  205. package/dist/src/tui/tui-commands.js +1 -1
  206. package/dist/src/tui/tui-startup-resources.js +1 -1
  207. package/dist/src/tui/tui.js +1 -1
  208. package/dist/src/usage/recorder.d.ts +4 -2
  209. package/dist/src/usage/recorder.js +54 -26
  210. package/dist/src/usage/types.d.ts +3 -0
  211. package/dist/src/utils/logger/context.d.ts +1 -1
  212. package/dist/src/utils/logger/context.js +4 -1
  213. package/dist/src/utils/logger/types.d.ts +3 -0
  214. package/package.json +5 -2
  215. package/dist/gateway/static/root/assets/dependency-picker-DfYC22si.js +0 -1
  216. package/dist/gateway/static/root/assets/gateway-realtime-store-B6B1fw_K.js +0 -1
  217. package/dist/gateway/static/root/assets/index-B7AHDHSO.css +0 -1
  218. package/dist/gateway/static/root/assets/models-hub-cache-Cs3E5pEA.js +0 -1
  219. package/dist/gateway/static/root/assets/settings-advanced-gate-D9sW0hKa.js +0 -1
  220. package/dist/gateway/static/root/assets/task-detail-page-B5JyH4z7.js +0 -1
@@ -0,0 +1,2 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i,g as a,m as o,t as s}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{n as c,r as l}from"./popover-select-BgSdSbCL.js";import{t as u}from"./circle-check-C23XjkUj.js";import{t as d}from"./ellipsis-0k4rZLoy.js";import{t as f}from"./external-link-DjqjBmc3.js";import{C as p,D as m,N as h,g,h as _,j as v,k as y,v as b}from"./use-composer-attachments-DB0bBGzZ.js";import{b as x,f as S,m as C,t as w,v as T}from"./markdown-view-DQZ51j9e.js";import{t as E}from"./folder-open-CyzJ19I9.js";import{t as D}from"./message-square-fVE7Ghj1.js";import{t as O}from"./pause-DuPxgSxk.js";import{t as k}from"./play-kxZvpBg8.js";import{t as A}from"./x-B_N4OPjy.js";import{t as j}from"./cn-JdwAhgNB.js";import{a as M,c as N,n as ee,r as P}from"./locale-store-DId6-v2R.js";import{i as te,n as ne,o as re,r as ie,s as F,t as ae}from"./dist-BGTk37IG.js";import{u as I}from"./tasks-CH6KoBeY.js";import{i as oe}from"./vendor-swr-BIWyz7Rc.js";import{t as L}from"./button-CS04eWY9.js";import{t as se}from"./activity-store-GvR2gZ0T.js";import{t as ce}from"./skeleton-BwbyijEw.js";import{m as le,o as ue}from"./shares-api-DU0fHP2G.js";import{An as de,Dn as fe,Gs as pe,Ic as me,Js as he,Mn as ge,Nn as _e,On as ve,Sc as ye,Tr as be,Vt as R,Wi as xe,Xa as Se,Xr as z,Yi as Ce,Za as we,Zr as Te,bi as Ee,ci as De,hc as Oe,ii as ke,jn as Ae,kn as je,l as Me,mc as Ne,n as Pe}from"./index-BYNmHn-z.js";import{t as Fe}from"./page-context-capture-button-Z72eiQZn.js";import{t as Ie}from"./date-picker-C9ZqTPui.js";import{t as Le}from"./dependency-picker-DBz0Pmyr.js";var B=n(),V=e(t(),1),H=r();function Re({wait:e,detail:t,zh:n,onUpdated:r}){let[i,a]=(0,V.useState)(``),[o,s]=(0,V.useState)(!1),[c,l]=(0,V.useState)(``),[u,d]=(0,V.useState)(!1),f=(0,V.useRef)(null),p=e.kind===`approval`,m=Array.isArray(e.condition.choices)?e.condition.choices.filter(e=>typeof e==`string`):[];async function h(a){if(!p&&!i.trim()||p&&!a||o)return;let c=JSON.stringify([t.task.version,i.trim(),a]);f.current?.signature!==c&&(f.current={signature:c,key:crypto.randomUUID()}),s(!0),l(``);try{let o=await g(t.task.id,{type:`resolve_wait`,waitId:e.id,resolution:p?{kind:`task_approval`,decision:a}:{kind:`user_answer`,answer:i.trim()}},t.task.version,f.current.key);d(!0),r(o),se({tone:`success`,title:p?n?`决定已保存`:`Decision saved`:n?`补充信息已保存`:`Answer saved`,message:o.waits.length?n?`仍有其他等待条件,任务尚未恢复执行。`:`Other waiting conditions remain.`:n?`等待已解除,请在任务状态中查看后续执行进展。`:`The wait is resolved. Follow progress in the task status.`,source:n?`任务`:`Task`})}catch{l(n?`提交未确认,内容已保留。可重试;若问题已变化,请刷新。`:`Submission not confirmed. Your answer is saved here; retry or refresh if the question changed.`)}finally{s(!1)}}return(0,H.jsxs)(`form`,{className:`mt-3 space-y-3 rounded-lg border border-edge p-3`,onSubmit:e=>{e.preventDefault(),h()},children:[p?(0,H.jsxs)(`div`,{className:`text-sm text-fg`,children:[(0,H.jsx)(`p`,{children:e.reason}),(0,H.jsxs)(`p`,{className:`mt-2`,children:[n?`授权范围:`:`Permission: `,String(e.condition.capability)]}),(0,H.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,H.jsx)(L,{type:`button`,variant:`primary`,disabled:o||u,onClick:()=>void h(`approve`),children:n?`批准`:`Approve`}),(0,H.jsx)(L,{type:`button`,disabled:o||u,onClick:()=>void h(`deny`),children:n?`拒绝并暂停`:`Deny and pause`})]})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`label`,{className:`block text-sm text-fg`,children:[typeof e.condition.question==`string`?e.condition.question:e.reason,(0,H.jsx)(`textarea`,{className:`mt-2 w-full rounded-lg border border-edge bg-surface-panel p-3`,rows:3,maxLength:12e3,value:i,disabled:o||u,onChange:e=>a(e.target.value)})]}),m.length>0&&(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:m.map(e=>(0,H.jsx)(L,{type:`button`,disabled:o||u,variant:`secondary`,"aria-pressed":i===e,onClick:()=>a(e),children:e},e))}),(0,H.jsx)(L,{type:`submit`,variant:`primary`,disabled:o||u||!i.trim(),children:o?n?`正在提交`:`Submitting`:n?`提交补充信息`:`Submit answer`})]}),(0,H.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`保存到任务上下文;其他等待条件满足后继续执行。`:`Saved to task context. Work continues once all waiting conditions are met.`}),c&&(0,H.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:c})]})}function U(e){let t=(0,B.c)(36),{content:n,contentKey:r,language:i,markdown:o,breaks:s,previewHeight:c,className:l,children:u}=e,d=o===void 0?!0:o,f=s===void 0?!1:s,p=c===void 0?240:c,m=(0,V.useId)(),h=(0,V.useRef)(null),[g,_]=(0,V.useState)(!1),[v,y]=a(),b;t[0]!==r||t[1]!==v?(b=v.getAll(`taskExpanded`).includes(r),t[0]=r,t[1]=v,t[2]=b):b=t[2];let x=b,S;t[3]===p?S=t[4]:(S=()=>{let e=h.current;if(!e)return;let t=()=>_(e.scrollHeight>p);if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},t[3]=p,t[4]=S);let C;t[5]!==n||t[6]!==p?(C=[n,p],t[5]=n,t[6]=p,t[7]=C):C=t[7],(0,V.useLayoutEffect)(S,C);let T=g&&!x,E;t[8]===l?E=t[9]:(E=j(`min-w-0`,l),t[8]=l,t[9]=E);let D;t[10]!==T||t[11]!==p?(D=T?{maxHeight:p,overflow:`hidden`,maskImage:`linear-gradient(to bottom, black calc(100% - ${Math.min(24,p/3)}px), transparent)`}:void 0,t[10]=T,t[11]=p,t[12]=D):D=t[12];let O;t[13]!==f||t[14]!==u||t[15]!==n||t[16]!==d?(O=u??(d?(0,H.jsx)(w,{content:n,compact:!0,breaks:f,className:`text-sm leading-6 text-fg`}):(0,H.jsx)(`p`,{className:`whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:n})),t[13]=f,t[14]=u,t[15]=n,t[16]=d,t[17]=O):O=t[17];let k;t[18]!==T||t[19]!==O?(k=(0,H.jsx)(`div`,{ref:h,inert:T,children:O}),t[18]=T,t[19]=O,t[20]=k):k=t[20];let A;t[21]!==m||t[22]!==k||t[23]!==D?(A=(0,H.jsx)(`div`,{id:m,style:D,children:k}),t[21]=m,t[22]=k,t[23]=D,t[24]=A):A=t[24];let M;t[25]!==r||t[26]!==x||t[27]!==m||t[28]!==i||t[29]!==g||t[30]!==y?(M=g?(0,H.jsx)(`button`,{type:`button`,"aria-expanded":x,"aria-controls":m,className:`mt-2 min-h-9 rounded-sm text-xs font-medium text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,onClick:()=>y(e=>{let t=new URLSearchParams(e),n=t.getAll(`taskExpanded`).filter(e=>e!==r);t.delete(`taskExpanded`);for(let e of n)t.append(`taskExpanded`,e);return x||t.append(`taskExpanded`,r),t},{preventScrollReset:!0}),children:i===`zh`?x?`收起`:`查看更多`:x?`Show less`:`Show more`}):null,t[25]=r,t[26]=x,t[27]=m,t[28]=i,t[29]=g,t[30]=y,t[31]=M):M=t[31];let N;return t[32]!==A||t[33]!==M||t[34]!==E?(N=(0,H.jsxs)(`div`,{className:E,children:[A,M]}),t[32]=A,t[33]=M,t[34]=E,t[35]=N):N=t[35],N}function ze(e){let t=(0,B.c)(17),{children:n,contentKey:r,language:i,className:o}=e,s=(0,V.useId)(),c=V.Children.toArray(n),[l,u]=a(),d;t[0]!==r||t[1]!==l?(d=l.getAll(`taskExpanded`).includes(r),t[0]=r,t[1]=l,t[2]=d):d=t[2];let f=d,p=f?c:c.slice(0,3),m;t[3]!==s||t[4]!==p?(m=(0,H.jsx)(`ul`,{id:s,className:`space-y-1.5`,children:p}),t[3]=s,t[4]=p,t[5]=m):m=t[5];let h;t[6]!==r||t[7]!==f||t[8]!==s||t[9]!==c.length||t[10]!==i||t[11]!==u?(h=c.length>3?(0,H.jsx)(`button`,{type:`button`,"aria-expanded":f,"aria-controls":s,className:`mt-2 min-h-9 rounded-sm text-xs font-medium text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,onClick:()=>u(e=>{let t=new URLSearchParams(e),n=t.getAll(`taskExpanded`).filter(e=>e!==r);return t.delete(`taskExpanded`),n.forEach(e=>t.append(`taskExpanded`,e)),f||t.append(`taskExpanded`,r),t},{preventScrollReset:!0}),children:i===`zh`?f?`收起`:`查看全部(${c.length})`:f?`Show less`:`Show all (${c.length})`}):null,t[6]=r,t[7]=f,t[8]=s,t[9]=c.length,t[10]=i,t[11]=u,t[12]=h):h=t[12];let g;return t[13]!==o||t[14]!==m||t[15]!==h?(g=(0,H.jsxs)(`div`,{className:o,children:[m,h]}),t[13]=o,t[14]=m,t[15]=h,t[16]=g):g=t[16],g}function W(e,t){let n;try{n=new URL(e)}catch{return}return t.find(e=>[e.shareUrl,e.lanUrl].some(e=>{if(!e)return!1;try{let t=new URL(e);return t.origin===n.origin&&t.pathname.replace(/\/$/,``)===n.pathname.replace(/\/$/,``)}catch{return!1}}))}function Be({uri:e,zh:t}){let[n,r]=(0,V.useState)(),[i,a]=(0,V.useState)(!1),[o,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(``),[d,f]=(0,V.useState)(``);async function p(){a(!0),u(``);try{let n=W(e,(await le()).payload.shares);r(n),c(!0),n?n.kind!==`file`&&n.kind!==`directory`?u(t?`这是文档快照,请从原笔记或对话的分享面板重新发布。`:`This is a document snapshot. Republish it from the original note or conversation.`):n.revoked?u(t?`分享已被撤销,不能自动恢复。请从原任务重新生成并分享。`:`This share was revoked. Generate and share a new artifact from the task.`):n.maxViews!==null&&n.downloadCount>=n.maxViews?u(t?`已达到访问次数上限,请在分享设置中调整后重试。`:`The access limit was reached. Adjust it in share settings.`):n.expired||(f(n.shareUrl),u(t?`链接仍在有效期内;若打不开,请检查网关连接。`:`The link has not expired. If it cannot open, check gateway connectivity.`)):u(t?`未找到本机管理的分享记录。外部链接或已清理的记录无法在这里续期,请从原任务重新生成产物。`:`No locally managed share matches this link. Regenerate the artifact from its task.`)}catch{u(t?`检查失败,请重试。`:`Check failed. Please retry.`)}finally{a(!1)}}async function m(){if(!(!n||i)){a(!0),u(``);try{let e=await ue(n.id,864e5);f(e.payload.shareUrl),r({...n,expired:!1,expiresAt:e.payload.expiresAt}),u(t?`已续期 24 小时,访问范围与次数限制保持不变。`:`Renewed for 24 hours. Access scope and view limits are unchanged.`)}catch(e){u(`${t?`恢复失败:`:`Recovery failed: `}${e instanceof Error?e.message:String(e)}`)}finally{a(!1)}}}return(0,H.jsxs)(`details`,{className:`mt-2 text-xs text-fg-muted`,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer py-2`,children:t?`链接打不开?`:`Trouble opening the link?`}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(L,{type:`button`,variant:`ghost`,disabled:i,onClick:()=>void p(),children:t?`检查链接状态`:`Check link`}),o&&n?.expired&&(n.kind===`file`||n.kind===`directory`)&&!n.revoked&&(n.maxViews===null||n.downloadCount<n.maxViews)&&(0,H.jsx)(L,{type:`button`,disabled:i,onClick:()=>void m(),children:t?`恢复链接 · 续期 24 小时`:`Restore link for 24 hours`}),l&&(0,H.jsx)(`p`,{role:`status`,className:`break-words leading-5`,children:l}),d&&(0,H.jsx)(`a`,{className:`block py-2 text-accent`,href:d,target:`_blank`,rel:`noopener noreferrer`,children:t?`打开产物`:`Open artifact`}),o&&(0,H.jsx)(s,{className:`block py-2 text-accent`,to:`/settings/shares`,children:t?`管理分享记录`:`Manage shares`})]})]})}function Ve(e){let t=(0,B.c)(14),{evidence:n,projectId:r,conversationId:i,language:a}=e,o=z(He);if(!n.length)return null;let s=a===`zh`?`交付物与验证依据`:`Deliverables and evidence`,c;if(t[0]!==i||t[1]!==n||t[2]!==a||t[3]!==r||t[4]!==o){let e;t[6]!==i||t[7]!==a||t[8]!==r||t[9]!==o?(e=(e,t)=>{let n=e.uri?.trim(),s=n&&/^https?:\/\//i.test(n),c=n&&!s&&e.kind===`artifact`&&!/^[a-z][a-z0-9+.-]*:/i.test(n)&&!n.startsWith(`//`),l=e.title||(a===`zh`?`查看产物`:`Open artifact`);return(0,H.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge-subtle p-3`,children:[(0,H.jsx)(U,{content:l,contentKey:`${i??r}:evidence-title:${t}:${e.title}`,language:a,previewHeight:60,children:s?(0,H.jsxs)(`a`,{className:`inline-flex min-h-11 items-center gap-2 text-sm font-medium text-accent hover:underline [overflow-wrap:anywhere]`,href:n,target:`_blank`,rel:`noopener noreferrer`,children:[(0,H.jsx)(f,{className:`size-4 shrink-0`}),(0,H.jsx)(`span`,{className:`min-w-0 break-words`,children:l})]}):c&&(r||i)?(0,H.jsxs)(`button`,{type:`button`,className:`inline-flex min-h-11 items-center gap-2 text-sm font-medium text-accent hover:underline [overflow-wrap:anywhere]`,onClick:()=>o(n,null,r,i),children:[(0,H.jsx)(he,{className:`size-4 shrink-0`}),l]}):(0,H.jsx)(`p`,{className:`break-words [overflow-wrap:anywhere] text-sm font-medium text-fg`,children:l})}),s&&e.kind===`artifact`&&(0,H.jsx)(Be,{uri:n,zh:a===`zh`},n),e.summary?(0,H.jsx)(U,{content:e.summary,contentKey:`${i??r}:evidence:${t}:${e.title}`,language:a,markdown:!1,previewHeight:80,className:`mt-1 text-xs leading-5 text-fg-muted`}):null,(0,H.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:e.strength===`verified`?a===`zh`?`已验证`:`Verified`:a===`zh`?`已记录,待验证`:`Observed, not verified`})]},`${e.title}-${t}`)},t[6]=i,t[7]=a,t[8]=r,t[9]=o,t[10]=e):e=t[10],c=n.map(e),t[0]=i,t[1]=n,t[2]=a,t[3]=r,t[4]=o,t[5]=c}else c=t[5];let l;return t[11]!==s||t[12]!==c?(l=(0,H.jsx)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,"aria-label":s,children:c}),t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function He(e){return e.setPath}function Ue({taskId:e}){let t=N(e=>e.conversationId),n=ee(e=>e.language),[r,i]=(0,V.useState)(``),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(!1),[d,f]=(0,V.useState)([]),[p,m]=(0,V.useState)(null),h=P(`/api/tasks/${encodeURIComponent(e)}/collaboration`),{data:g,error:_,mutate:v}=oe([`task-collaboration`,e,t],()=>M(`${h}?recent=1`),{revalidateOnFocus:!0}),y=[...new Map([...d,...g?.items??[]].map(e=>[e.id,e])).values()].sort((e,t)=>e.sequence-t.sequence),b=async()=>{let e=y[0];if(!(!e||l)){u(!0);try{let t=await M(`${h}?recent=1&beforeSequence=${e.sequence}`);f(e=>[...t.items,...e])}catch(e){m(e instanceof Error?e.message:String(e))}finally{u(!1)}}};(0,V.useEffect)(()=>{let t=t=>{let n=t.detail;(!n?.taskId||n.taskId===e)&&v()};return window.addEventListener(`task-collaboration-entry-added`,t),window.addEventListener(`gateway-realtime-connected`,t),()=>{window.removeEventListener(`task-collaboration-entry-added`,t),window.removeEventListener(`gateway-realtime-connected`,t)}},[v,e]);let x=async()=>{if(!(!r.trim()||s)){c(!0),m(null);try{await M(h,{method:`POST`,headers:{"idempotency-key":crypto.randomUUID()},body:JSON.stringify({kind:a?`answer`:`instruction`,body:r.trim(),...a?{causationId:a}:{}})}),i(``),o(null),await v()}catch(e){m(e instanceof Error?e.message:String(e))}finally{c(!1)}}};return(0,H.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n===`zh`?`任务留言`:`Task updates`}),(0,H.jsxs)(`div`,{className:`mt-3 max-h-64 space-y-2 overflow-y-auto`,children:[!g&&!_?(0,H.jsxs)(`div`,{"aria-busy":`true`,className:`space-y-2`,children:[(0,H.jsx)(ce,{className:`h-14 w-full`}),(0,H.jsx)(ce,{className:`h-14 w-4/5`})]}):null,_?(0,H.jsx)(`p`,{role:`status`,className:`text-xs text-fg-muted`,children:n===`zh`?`暂时无法读取留言`:`Updates unavailable`}):null,y[0]&&y[0].sequence>1?(0,H.jsx)(`button`,{type:`button`,disabled:l,onClick:()=>void b(),className:`text-xs text-accent hover:underline disabled:opacity-50`,children:n===`zh`?`查看更早留言`:`Earlier updates`}):null,y.map(t=>(0,H.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 text-sm`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-subtle`,children:[(0,H.jsx)(`span`,{children:t.authorKind===`worker_agent`?n===`zh`?`执行 Agent`:`Worker`:t.authorKind===`main_agent`?n===`zh`?`主 Agent`:`Main Agent`:t.authorKind===`system`?n===`zh`?`系统`:`System`:n===`zh`?`用户`:`You`}),(0,H.jsxs)(`span`,{children:[`· `,t.kind]}),t.deliveryStatus?(0,H.jsxs)(`span`,{children:[`· `,t.deliveryStatus]}):null]}),(0,H.jsx)(`div`,{className:`mt-1 min-w-0 text-fg`,"data-task-collaboration-body":!0,children:(0,H.jsx)(U,{content:t.body,contentKey:`${e}:update:${t.id}`,language:n,breaks:!0,previewHeight:120})}),t.kind===`question`&&t.authorKind===`worker_agent`?(0,H.jsx)(`button`,{type:`button`,className:`mt-2 text-xs text-accent hover:underline`,onClick:()=>o(t.id),children:n===`zh`?`回复问题`:`Reply`}):null]},t.id)),g&&!y.length?(0,H.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n===`zh`?`暂无进展留言`:`No updates yet`}):null]}),a?(0,H.jsxs)(`p`,{className:`mt-3 text-xs text-accent`,children:[n===`zh`?`正在回复执行 Agent 的问题`:`Replying to the worker`,(0,H.jsx)(`button`,{type:`button`,className:`ml-2 underline`,onClick:()=>o(null),children:n===`zh`?`取消`:`Cancel`})]}):null,(0,H.jsx)(`textarea`,{value:r,onChange:e=>i(e.target.value),rows:2,"aria-label":n===`zh`?`任务留言`:`Task message`,placeholder:n===`zh`?`给执行 Agent 留言`:`Message the worker`,className:`mt-3 w-full resize-y rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`}),p?(0,H.jsx)(`p`,{role:`alert`,className:`mt-1 text-xs text-danger`,children:p}):null,(0,H.jsx)(`button`,{type:`button`,disabled:!r.trim()||s,onClick:()=>void x(),className:`mt-2 rounded-lg bg-accent px-3 py-2 text-xs font-medium text-white disabled:opacity-50`,children:s?n===`zh`?`发送中`:`Sending`:n===`zh`?`发送`:`Send`})]})}function We(e){let t=e.task.contract?.acceptanceCriteria??[],n=new Map(e.runs.map(e=>[e.id,e])),r=e.receipts.filter(t=>n.get(t.runId)?.contractVersion===e.task.latestContractVersion).sort((e,t)=>t.finalizedAt-e.finalizedAt);return t.map((t,n)=>{let i=e.criterionReviews.find(r=>r.criterionIndex===n&&r.contractVersion===e.task.latestContractVersion&&r.criterionText===t),a={text:t,status:`unverified`,evidence:[]};for(let e of r){let n=e.verification.checks.find(e=>e.criterion===t);if(!n||n.status===`unverified`)continue;let r=e.evidence.filter(e=>n.evidenceTitles.includes(e.title)),i=n.status===`passed`&&I(e).has(t)?`passed`:n.status===`failed`?`failed`:`unverified`;if(i!==`unverified`){a={text:t,status:i,evidence:r,runId:e.runId};break}}return i&&e.task.contract?.acceptancePolicy!==`verified_auto`?{...a,status:i.status,review:i}:e.task.contract?.acceptancePolicy===`manual`?{...a,status:`unverified`}:a})}function Ge(e,t,n,r){return!!(e&&t!==e.version&&n!==e.value&&r!==n)}function Ke(e,t){let n={...e.task};t.title!==void 0&&(n.title=t.title),t.priority!==void 0&&(n.priority=t.priority);for(let e of[`body`,`projectId`,`milestoneId`,`parentTaskId`,`dueAt`,`ownerId`]){let r=t[e];r!==void 0&&(r===null?delete n[e]:Object.assign(n,{[e]:r}))}return n.version+=1,n.updatedAt=Date.now(),{...e,task:n}}function qe(e,t){return(t===`zh`?{backlog:`待规划`,ready:`就绪`,active:`进行中`,review:`待验收`,closed:`已完成`}:{backlog:`Backlog`,ready:`Ready`,active:`Active`,review:`Review`,closed:`Completed`})[e]}function Je(){let e=(0,B.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,H.jsxs)(`div`,{className:`space-y-4`,"aria-busy":!0,children:[(0,H.jsx)(ce,{className:`h-32 rounded-2xl`}),(0,H.jsx)(ce,{className:`h-52 rounded-2xl`}),(0,H.jsx)(ce,{className:`h-40 rounded-2xl`})]}),e[0]=t):t=e[0],t}function Ye(e){if(e===void 0)return``;let t=new Date(e);return new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString().slice(0,10)}function Xe(e){return e?new Date(`${e}T23:59:59.999`).getTime():null}var Ze=[`backlog`,`ready`,`active`,`review`,`closed`],Qe=[`low`,`normal`,`high`,`critical`],$e=(0,V.memo)(function(e){let t=(0,B.c)(20),{value:n,disabled:r,canMove:i,canApprove:a,canReopen:o,language:s,label:u,onChange:d}=e,f;t[0]!==a||t[1]!==i||t[2]!==o||t[3]!==n?(f=e=>e!==n&&(e===`closed`?!a:n===`closed`?!o:!i),t[0]=a,t[1]=i,t[2]=o,t[3]=n,t[4]=f):f=t[4];let p=f,m;t[5]===u?m=t[6]:(m=(0,H.jsx)(`span`,{children:u}),t[5]=u,t[6]=m);let h;t[7]===d?h=t[8]:(h=e=>d(e.target.value),t[7]=d,t[8]=h);let g;t[9]!==s||t[10]!==p?(g=Ze.map(e=>(0,H.jsx)(l,{value:e,disabled:p(e),children:qe(e,s)},e)),t[9]=s,t[10]=p,t[11]=g):g=t[11];let _;t[12]!==r||t[13]!==h||t[14]!==g||t[15]!==n?(_=(0,H.jsx)(c,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:h,children:g}),t[12]=r,t[13]=h,t[14]=g,t[15]=n,t[16]=_):_=t[16];let v;return t[17]!==m||t[18]!==_?(v=(0,H.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[m,_]}),t[17]=m,t[18]=_,t[19]=v):v=t[19],v}),et=(0,V.memo)(function(e){let t=(0,B.c)(14),{value:n,disabled:r,label:i,labels:a,onChange:o}=e,s;t[0]===i?s=t[1]:(s=(0,H.jsx)(`span`,{children:i}),t[0]=i,t[1]=s);let u;t[2]===o?u=t[3]:(u=e=>o(e.target.value),t[2]=o,t[3]=u);let d;t[4]===a?d=t[5]:(d=Qe.map(e=>(0,H.jsx)(l,{value:e,children:a[e]},e)),t[4]=a,t[5]=d);let f;t[6]!==r||t[7]!==u||t[8]!==d||t[9]!==n?(f=(0,H.jsx)(c,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:u,children:d}),t[6]=r,t[7]=u,t[8]=d,t[9]=n,t[10]=f):f=t[10];let p;return t[11]!==s||t[12]!==f?(p=(0,H.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[s,f]}),t[11]=s,t[12]=f,t[13]=p):p=t[13],p}),tt=(0,V.memo)(function(e){let t=(0,B.c)(10),{value:n,disabled:r,label:i,onChange:a}=e,o;t[0]===i?o=t[1]:(o=(0,H.jsx)(`span`,{children:i}),t[0]=i,t[1]=o);let s;t[2]!==r||t[3]!==i||t[4]!==a||t[5]!==n?(s=(0,H.jsx)(Ie,{disabled:r,value:n,onChange:a,ariaLabel:i}),t[2]=r,t[3]=i,t[4]=a,t[5]=n,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,H.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c}),nt=(0,V.memo)(function(e){let t=(0,B.c)(17),{value:n,disabled:r,label:i,unassignedLabel:a,agents:o,onChange:s}=e,u;t[0]===i?u=t[1]:(u=(0,H.jsx)(`span`,{children:i}),t[0]=i,t[1]=u);let d;t[2]===s?d=t[3]:(d=e=>s(e.target.value),t[2]=s,t[3]=d);let f;t[4]===a?f=t[5]:(f=(0,H.jsx)(l,{value:``,disabled:!0,children:a}),t[4]=a,t[5]=f);let p;t[6]===o?p=t[7]:(p=o.map(Ct),t[6]=o,t[7]=p);let m;t[8]!==r||t[9]!==d||t[10]!==f||t[11]!==p||t[12]!==n?(m=(0,H.jsxs)(c,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:d,children:[f,p]}),t[8]=r,t[9]=d,t[10]=f,t[11]=p,t[12]=n,t[13]=m):m=t[13];let h;return t[14]!==u||t[15]!==m?(h=(0,H.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[u,m]}),t[14]=u,t[15]=m,t[16]=h):h=t[16],h}),rt=(0,V.memo)(function(e){let t=(0,B.c)(9),{candidates:n,selected:r,disabled:i,labels:a,getTaskHref:o,onChange:s}=e,c;t[0]===r?c=t[1]:(c=r.map(wt),t[0]=r,t[1]=c);let l;return t[2]!==n||t[3]!==i||t[4]!==o||t[5]!==a||t[6]!==s||t[7]!==c?(l=(0,H.jsx)(Le,{borderless:!0,candidates:n,selectedIds:c,disabled:i,getTaskHref:o,onChange:s,labels:a}),t[2]=n,t[3]=i,t[4]=o,t[5]=a,t[6]=s,t[7]=c,t[8]=l):l=t[8],l},(e,t)=>e.disabled===t.disabled&&e.labels===t.labels&&e.getTaskHref===t.getTaskHref&&e.onChange===t.onChange&&e.candidates.length===t.candidates.length&&e.candidates.every((e,n)=>e.id===t.candidates[n]?.id&&e.title===t.candidates[n]?.title)&&e.selected.length===t.selected.length&&e.selected.every((e,n)=>e.id===t.selected[n]?.id&&e.title===t.selected[n]?.title)),it=`xopc.taskDetail.chatPanelPercent`,at=42;function ot(e,t){let n=Math.max(30,352/Math.max(t,1)*100),r=Math.min(60,(t-480)/Math.max(t,1)*100);return r<n?at:Math.min(r,Math.max(n,e))}function st(){try{let e=Number(window.localStorage.getItem(it));return Number.isFinite(e)&&e>=30&&e<=60?e:at}catch{return at}}function ct(e){return e.task.phase===`closed`?e.task.resolution===`done`?`completed`:`ended`:e.waits.some(e=>e.kind===`paused`)?`paused`:e.attention.some(e=>e.kind===`input_required`||e.kind===`approval_required`)?`needsUser`:e.operationalState===`idle`?e.task.phase===`backlog`?`captured`:e.task.phase===`ready`?`ready`:e.task.phase===`review`?`review`:`ready`:e.operationalState}function lt(e){return e===`failed`?`bg-danger/10 text-danger`:e===`needsUser`||e===`blocked`?`bg-warning/10 text-warning`:e===`completed`?`bg-success-soft text-success`:e===`running`||e===`verifying`||e===`review`?`bg-accent-soft text-accent-fg`:`bg-surface-hover text-fg-muted`}function ut(e){let t=(0,B.c)(13),{items:n,empty:r,contentKey:i}=e,a=ee(ft);if(n.length===0){let e;return t[0]===r?e=t[1]:(e=(0,H.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:r}),t[0]=r,t[1]=e),e}let o;t[2]===n?o=t[3]:(o=n.join(`
2
+ `),t[2]=n,t[3]=o);let s;t[4]===n?s=t[5]:(s=n.map(dt),t[4]=n,t[5]=s);let c;t[6]===s?c=t[7]:(c=(0,H.jsx)(`ul`,{className:`space-y-2`,children:s}),t[6]=s,t[7]=c);let l;return t[8]!==i||t[9]!==a||t[10]!==o||t[11]!==c?(l=(0,H.jsx)(U,{content:o,contentKey:i,language:a,previewHeight:144,children:c}),t[8]=i,t[9]=a,t[10]=o,t[11]=c,t[12]=l):l=t[12],l}function dt(e){return(0,H.jsxs)(`li`,{className:`flex gap-2 text-sm leading-6 text-fg`,children:[(0,H.jsx)(Ne,{className:`mt-1 size-4 shrink-0 text-fg-subtle`}),(0,H.jsx)(`span`,{className:`min-w-0 whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:e})]},e)}function ft(e){return e.language}function pt({taskId:e,presentation:t,backgroundPath:n,onDeleted:r}){let[o]=a(),c=i(),l=ee(e=>e.language),w=N(e=>e.conversationId),A=(0,V.useMemo)(()=>we(l),[l]),M=Ce(e=>e.setPageHeader),P=Ce(e=>e.clearPageHeader),te=Te(e=>e.open),ne=Te(e=>e.conversationIdOverride),re=Te(e=>e.openForSession),ie=_e(e=>e.setOpen),{data:F,error:ae,mutate:I,lastChange:se,conversationLoading:ce,conversationError:le}=Se(e),{data:ue}=oe(e?`task-detail-automations`:null,()=>Me.list()),[he,R]=(0,V.useState)(null),[z,Ie]=(0,V.useState)(()=>new Set),[Le,B]=(0,V.useState)([]),[W,Be]=(0,V.useState)(null),[He,qe]=(0,V.useState)([]),[Ze,Qe]=(0,V.useState)(!1),[dt,ft]=(0,V.useState)(``),[pt,G]=(0,V.useState)(!1),[mt,ht]=(0,V.useState)(``),[gt,_t]=(0,V.useState)(st),[vt,yt]=(0,V.useState)(!1),bt=(0,V.useRef)(null),xt=(0,V.useRef)(!1),St=(0,V.useRef)(!1),Ct=(0,V.useRef)(``),wt=(0,V.useRef)(null),Tt=(0,V.useRef)(null),Et=(0,V.useRef)(null),K=(0,V.useRef)(F),[Dt,q]=(0,V.useState)(null),[Ot,kt]=(0,V.useState)(null),[At,jt]=(0,V.useState)(!1),Mt=(0,V.useMemo)(()=>({link:A.linkDependencies,linked:A.linkedDependencies,searchPlaceholder:A.dependencySearchPlaceholder,noMatches:A.noDependencyMatches,noCandidates:A.noDependencyCandidates,remove:A.removeDependency}),[A.dependencySearchPlaceholder,A.linkDependencies,A.linkedDependencies,A.noDependencyCandidates,A.noDependencyMatches,A.removeDependency]),Nt=F?.dependencies.map(e=>`${e.id}:${e.title}`).join(`\0`)??``,Pt=(0,V.useMemo)(()=>S(o.get(`returnTo`),`/`,[`/projects`,`/chat`,`/notes`,`/tasks`]),[o]),Ft=(0,V.useCallback)(e=>t===`modal`&&n?x(n,e):C(`/tasks/${encodeURIComponent(e)}`,Pt),[n,t,Pt]);K.current=F;let J=(0,V.useCallback)((e,t)=>{Ie(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]);(0,V.useEffect)(()=>{R(null),q(null),Qe(!1),wt.current=null,G(!1),kt(null),jt(!1)},[e]),(0,V.useEffect)(()=>{let e=!0;return De().then(t=>{e&&qe(t.items)}).catch(()=>void 0),()=>{e=!1}},[w]),(0,V.useEffect)(()=>{if(!se||se.source===`user`)return;kt(se);let e=window.setTimeout(()=>kt(null),3500);return()=>window.clearTimeout(e)},[se]),(0,V.useEffect)(()=>{let t=F?.task.projectId,n=F?.dependencies??[];if(!t){Et.current=null,Be(null),B(n);return}Et.current!==t&&(Et.current=t,Be(null));let r=!0;return Ee(t).then(t=>{if(!r)return;Be(t.project.name);let i=new Map;for(let r of[...t.tasks,...n])r.id!==e&&i.set(r.id,{id:r.id,title:r.title});B([...i.values()])}).catch(()=>{r&&B(n)}),()=>{r=!1}},[Nt,F?.task.projectId,e]);let Y=(0,V.useCallback)(async(t,n=`command`)=>{let r=K.current;if(r){J(n,!0),R(null);try{await I(await g(e,t,r.task.version),{revalidate:!1})}catch{R(A.actionFailed)}finally{J(n,!1)}}},[A.actionFailed,I,J,e]),It=(0,V.useCallback)(async(t,n)=>{let r=K.current;if(!r)return!1;n&&J(n,!0),R(null);try{return await I(v(e,t,r.task.version),{optimisticData:Ke(r,t),populateCache:!0,revalidate:!1,rollbackOnError:!0}),!0}catch{return R(A.actionFailed),!1}finally{n&&J(n,!1)}},[A.actionFailed,I,J,e]),Lt=()=>{F&&(wt.current={value:F.task.title,version:F.task.version},q(null),ft(F.task.title),Qe(!0))},Rt=()=>{xt.current=!0,ft(K.current?.task.title??``),wt.current=null,q(null),Qe(!1),queueMicrotask(()=>{xt.current=!1})},zt=async(e=!1)=>{if(xt.current){xt.current=!1;return}let t=K.current;if(!t||z.has(`title`))return;let n=dt.trim();if(!n){Rt();return}let r=wt.current;if(!e&&Ge(r,t.task.version,t.task.title,n)){q(`title`);return}if(n===t.task.title){Rt();return}await It({title:n},`title`)&&(wt.current=null,q(null),Qe(!1))},Bt=async()=>{if(!F)return;if(St.current){St.current=!1;return}let e=mt.trim(),t=Tt.current;if(Ge(t,F.task.version,F.task.body??``,e)){q(`description`);return}if(mt===Ct.current||e===(F.task.body??``).trim()){G(!1);return}await It({body:e||null})&&(q(null),G(!1))},Vt=(0,V.useCallback)(async e=>{let t=K.current;if(!(!t||e===t.task.phase)){if(t.task.phase===`closed`){await Y({type:`reopen`,phase:e===`closed`?`ready`:e},`phase`);return}if(e===`closed`){await Y({type:`close`,resolution:`done`},`phase`);return}await Y({type:`move`,phase:e},`phase`)}},[Y]),Ht=(0,V.useCallback)(e=>{It({priority:e},`priority`)},[It]),Ut=(0,V.useCallback)(e=>{It({dueAt:Xe(e)},`dueAt`)},[It]),Wt=(0,V.useCallback)(e=>{_t(e);try{window.localStorage.setItem(it,String(e))}catch{}},[]),Gt=(0,V.useCallback)(e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`&&e.key!==`Home`)return;e.preventDefault();let t=bt.current?.clientWidth??0;Wt(ot(e.key===`Home`?at:gt+(e.key===`ArrowLeft`?2:-2),t))},[gt,Wt]),Kt=(0,V.useCallback)(e=>{if(!window.matchMedia(`(min-width: 1024px)`).matches)return;let t=bt.current;if(!t)return;e.preventDefault();let n=e.currentTarget,r=e.pointerId;n.setPointerCapture(r),yt(!0);let i=gt,a=0,o=()=>{a=0,t.style.setProperty(`--task-chat-panel-width`,`${i}%`)},s=e=>{let n=t.getBoundingClientRect();i=ot((n.right-e.clientX)/n.width*100,n.width),a===0&&(a=window.requestAnimationFrame(o))},c=()=>{a!==0&&(window.cancelAnimationFrame(a),o());try{n.releasePointerCapture(r)}catch{}yt(!1),Wt(i),window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c)};window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c),window.addEventListener(`pointercancel`,c)},[gt,Wt]),qt=(0,V.useCallback)(async t=>{let n=K.current;if(n){J(`dependencies`,!0),R(null);try{await I(await h(e,t,n.task.version),{revalidate:!1})}catch{R(A.dependencyUpdateFailed)}finally{J(`dependencies`,!1)}}},[A.dependencyUpdateFailed,I,J,e]),Jt=(0,V.useCallback)(async t=>{let n=K.current;if(!(!n||!t||t===n.conversation.currentExecutorAgentId)){J(`delegateAgentId`,!0),R(null);try{await I(await p(e,t,n.task.version),{revalidate:!1})}catch{R(A.actionFailed)}finally{J(`delegateAgentId`,!1)}}},[A.actionFailed,I,J,e]),Yt=(0,V.useCallback)(async()=>{J(`delete`,!0),R(null);try{await b(e),r?r():c(Pt,{replace:!0})}catch(e){R(e instanceof Error?e.message:A.actionFailed)}finally{J(`delete`,!1)}},[A.actionFailed,c,r,Pt,J,e]),Xt=(0,V.useCallback)(async(t,n)=>{let r=K.current;if(r){J(`acceptance`,!0),R(null);try{await I(await m(e,t,n,r.task.version,r.task.latestContractVersion),{revalidate:!1})}catch{R(A.actionFailed),await I()}finally{J(`acceptance`,!1)}}},[A.actionFailed,I,J,e]);if((0,V.useLayoutEffect)(()=>{if(t!==`modal`)return M({startExtra:(0,H.jsx)(s,{to:Pt,className:`flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":A.backToWork,children:(0,H.jsx)(me,{className:`size-4`})}),main:F?(0,H.jsx)(`p`,{className:`truncate text-sm font-semibold text-fg`,children:W?`${W} / ${A.taskLabel}`:A.taskLabel}):null,end:null}),P},[P,A.backToWork,A.taskLabel,F,t,W,Pt,M]),ae&&!F)return(0,H.jsx)(`div`,{className:t===`modal`?`p-5 text-sm text-danger`:`mx-auto max-w-3xl p-6 text-sm text-danger`,children:A.taskNotFound});if(!F)return(0,H.jsx)(`div`,{className:t===`modal`?`p-5`:`mx-auto max-w-4xl p-4 sm:p-6`,children:(0,H.jsx)(Je,{})});let Zt=F.waits[0],Qt=We(F),$t=Qt.length>0&&Qt.every(e=>e.status===`passed`),en=F.waits.find(e=>e.kind===`paused`),X=F.receipts[0],tn=ct(F),nn=A.detailStatuses[tn],rn=F.task.body?.trim()||F.task.contract?.objective.trim(),an=F.allowedCommands.includes(`mark_ready`),on=F.allowedCommands.includes(`start`),sn=F.allowedCommands.includes(`add_wait`),cn=!Zt&&$t&&F.task.phase===`review`&&F.allowedCommands.includes(`close`),ln=F.allowedCommands.includes(`reopen`),Z=F.conversation.activeConversationId,un=F.conversation.currentExecutorAgentId??F.task.delegateAgentId??F.task.ownerId,dn=He.find(e=>e.id===un),fn=!!(Z&&te&&ne===Z),pn=F.attention.some(e=>e.kind===`input_required`||e.kind===`approval_required`),mn=Qt.filter(e=>e.status===`passed`).length,hn=F.context.filter(e=>e.role===`deliverable`),gn=new Set(F.runs.filter(e=>e.contractVersion===F.task.latestContractVersion).map(e=>e.id)),_n=[...new Map(F.receipts.filter(e=>gn.has(e.runId)).flatMap(e=>e.evidence.filter(e=>e.kind===`artifact`)).map(e=>[e.uri??e.title,e])).values()],vn=F.context.filter(e=>e.role!==`deliverable`),yn=F.runs.filter(e=>e.executorKind===`workflow`&&!e.parentRunId),bn=[...new Set(yn.map(e=>e.executorRef.workflowId).filter(e=>typeof e==`string`))],xn=ue?.automations.filter(t=>t.action.kind===`task_command`&&t.action.taskId===e)??[],Q=F.sessions.filter((e,t,n)=>n.findIndex(t=>t.conversationId===e.conversationId)===t),Sn=F.task.contract?.expectedOutputs??[],Cn=F.task.contract?.constraints??[],wn=F.task.contract?.approvalRequired??[],Tn=F.task.contract?.assumptions??[],En=F.task.contract?.risks??[],Dn=Cn.length>0||wn.length>0||Tn.length>0||En.length>0,$=(...e)=>!!Ot?.changedFields.some(t=>e.includes(t)),On=F.allowedCommands.includes(`move`),kn=z.has(`command`),An=z.has(`delete`),jn=F.runs.find(e=>!e.parentRunId&&[`queued`,`running`,`waiting`,`verifying`].includes(e.status)),Mn=jn!==void 0,Nn=`/automations?action=create&taskId=${encodeURIComponent(F.task.id)}${F.task.projectId?`&projectId=${encodeURIComponent(F.task.projectId)}`:``}`,Pn=(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[an?(0,H.jsxs)(L,{className:`min-h-9 px-3 py-1.5 text-xs`,variant:`primary`,disabled:kn,onClick:()=>void Y({type:`mark_ready`}),children:[(0,H.jsx)(k,{className:`size-4`}),A.scheduleTask]}):null,en&&F.allowedCommands.includes(`resolve_wait`)?(0,H.jsxs)(L,{className:`min-h-9 px-3 py-1.5 text-xs`,variant:`primary`,disabled:kn,onClick:()=>void Y({type:`resolve_wait`,waitId:en.id}),children:[(0,H.jsx)(k,{className:`size-4`}),A.resumeTask]}):null,!Zt&&on&&un?(0,H.jsxs)(L,{className:`min-h-9 px-3 py-1.5 text-xs`,variant:`primary`,disabled:kn,onClick:()=>void Y({type:`start`,executor:{kind:`agent`,agentId:un}}),children:[(0,H.jsx)(k,{className:`size-4`}),A.runTask]}):null,cn?(0,H.jsxs)(L,{className:`min-h-9 px-3 py-1.5 text-xs`,variant:`primary`,disabled:kn,onClick:()=>void Y({type:`close`,resolution:`done`}),children:[(0,H.jsx)(u,{className:`size-4`}),A.approveTask]}):null,ln?(0,H.jsxs)(L,{className:`min-h-9 px-3 py-1.5 text-xs`,variant:`primary`,disabled:kn,onClick:()=>void Y({type:`reopen`,phase:`ready`}),children:[(0,H.jsx)(k,{className:`size-4`}),A.reopenTask]}):null,!en&&sn?(0,H.jsxs)(L,{variant:`ghost`,className:`min-h-9 px-3 py-1.5 text-xs`,disabled:kn,onClick:()=>void Y({type:`add_wait`,wait:{kind:`paused`,reason:`Paused by user`,condition:{}}}),children:[(0,H.jsx)(O,{className:`size-4`}),A.pauseTask]}):null,F.task.phase===`closed`?null:(0,H.jsx)(L,{asChild:!0,variant:`ghost`,className:`min-h-9 px-3 py-1.5 text-xs`,children:(0,H.jsxs)(s,{to:Nn,children:[(0,H.jsx)(ye,{className:`size-4`}),A.scheduleRecurringTask]})}),(0,H.jsxs)(de,{children:[(0,H.jsx)(ge,{asChild:!0,children:(0,H.jsx)(L,{type:`button`,variant:`ghost`,className:`size-9 p-0`,disabled:kn||An,"aria-label":A.moreActions,children:(0,H.jsx)(d,{className:`size-4`,"aria-hidden":!0})})}),(0,H.jsx)(je,{children:(0,H.jsxs)(fe,{align:`end`,sideOffset:6,className:`z-[100] min-w-44 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:[jn?(0,H.jsx)(ve,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>{J(`command`,!0),R(null),I(_(e,jn.id,jn.version),{revalidate:!1}).catch(()=>R(A.actionFailed)).finally(()=>J(`command`,!1))},children:A.cancelActiveRun}):null,jn?(0,H.jsx)(Ae,{className:`my-1 h-px bg-edge`}):null,F.task.phase===`closed`?null:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(ve,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>void Y({type:`close`,resolution:`cancelled`}),children:A.cancelTask}),(0,H.jsx)(Ae,{className:`my-1 h-px bg-edge`})]}),(0,H.jsx)(ve,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>{if(Mn){R(A.deleteActiveTaskBlocked);return}jt(!0)},children:A.deleteTask})]})})]})]});return(0,H.jsxs)(`div`,{ref:bt,className:`flex h-full min-h-0 flex-col overflow-hidden ${vt?`lg:cursor-col-resize lg:select-none`:``}`,style:{"--task-chat-panel-width":`${gt}%`},children:[(0,H.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto lg:flex-row lg:overflow-hidden`,children:[(0,H.jsxs)(`div`,{className:`task-detail-scroll flex min-w-0 shrink-0 flex-col lg:min-h-0 lg:flex-1 lg:shrink lg:overflow-y-auto lg:overscroll-contain`,children:[(0,H.jsxs)(`header`,{className:j(`shrink-0 border-b border-edge-subtle bg-surface-panel px-5 py-4 sm:px-6`,$(`title`)&&`task-detail-live-update`),children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-x-6 gap-y-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[W?(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,H.jsx)(pe,{className:`size-3.5`,"aria-hidden":!0}),W]}):null,W?(0,H.jsx)(`span`,{"aria-hidden":`true`,children:`/`}):null,(0,H.jsx)(`span`,{children:A.taskLabel}),Ot?(0,H.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,role:`status`,children:Ot.source===`agent`?l===`zh`?`Agent 刚刚更新`:`Updated by Agent`:l===`zh`?`执行结果已同步`:`Execution result synced`}):null]}),Ze?(0,H.jsx)(`textarea`,{autoFocus:!0,"data-task-inline-editor":!0,"aria-label":l===`zh`?`任务标题`:`Task title`,rows:2,value:dt,onFocus:e=>{wt.current?.value===dt&&(e.currentTarget.setSelectionRange(0,0),e.currentTarget.scrollTop=0)},onChange:e=>ft(e.target.value),onBlur:()=>void zt(),onKeyDown:e=>{e.nativeEvent.isComposing||(e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),Rt()):e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.currentTarget.blur()))},className:`mt-2 block max-h-56 min-h-14 w-full max-w-3xl resize-none overflow-y-auto bg-transparent p-0 text-xl font-semibold leading-7 text-fg outline-none [field-sizing:content]`}):(0,H.jsx)(U,{content:F.task.title,contentKey:`${e}:title`,language:l,previewHeight:56,className:`mt-2 max-w-3xl`,children:(0,H.jsx)(`h1`,{className:`break-words text-xl font-semibold leading-7 text-fg`,children:(0,H.jsx)(`button`,{type:`button`,className:`max-w-full whitespace-pre-wrap break-words [overflow-wrap:anywhere] rounded-sm text-left outline-none hover:bg-surface-hover/60 focus-visible:ring-2 focus-visible:ring-accent/40`,title:F.task.title,onClick:Lt,children:F.task.title})})}),Dt===`title`?(0,H.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,H.jsx)(`span`,{children:l===`zh`?`Agent 在你编辑期间更新了标题。`:`The Agent updated the title while you were editing.`}),(0,H.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:Rt,children:l===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,H.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,disabled:z.has(`title`),onClick:()=>void zt(!0),children:l===`zh`?`保留我的修改`:`Keep my changes`})]}):null]}),(0,H.jsx)(`span`,{className:j(`shrink-0 rounded-full px-2.5 py-1 text-xs font-medium`,lt(tn)),children:nn})]}),(0,H.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-4 gap-y-2 text-xs text-fg-muted`,children:[(0,H.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2`,children:[un?(0,H.jsx)(xe,{agentId:un,avatar:dn?.avatar,size:20,className:`shrink-0`}):null,(0,H.jsxs)(`span`,{className:`min-w-0 break-words [overflow-wrap:anywhere]`,children:[A.executorLabel,` · `,dn?.name??un??A.unassigned]})]}),(0,H.jsx)(`span`,{className:`text-fg-subtle`,children:A.updatedAt.replace(`{{date}}`,be(F.task.updatedAt,l))})]}),(0,H.jsx)(`div`,{className:`mt-4 border-t border-edge-subtle pt-3`,children:Pn}),he?(0,H.jsx)(`p`,{className:`mt-3 text-sm text-danger`,children:he}):null]}),(0,H.jsxs)(`section`,{className:`min-w-0 p-5 sm:p-6`,children:[(0,H.jsxs)(`section`,{className:`mb-4 overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel shadow-surface`,children:[(0,H.jsxs)(`div`,{className:`border-b border-edge-subtle p-5`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:l===`zh`?`目标与验收`:`Goal and acceptance`}),Qt.length>0?(0,H.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2.5 py-1 text-xs text-fg-muted`,children:A.criteriaProgress.replace(`{{verified}}`,String(mn)).replace(`{{total}}`,String(Qt.length))}):null]}),(0,H.jsx)(U,{content:F.task.contract?.objective||F.task.title,contentKey:`${e}:goal`,language:l,markdown:!1,previewHeight:72,className:`mt-3 text-sm leading-6 text-fg`})]}),(0,H.jsxs)(`div`,{className:`p-5`,children:[(0,H.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:A.successDefinition}),Qt.length>0?(0,H.jsx)(`ul`,{className:`mt-3 space-y-3`,children:Qt.map((t,n)=>(0,H.jsxs)(`li`,{className:`flex items-start gap-2.5 text-sm leading-5 text-fg`,children:[(0,H.jsx)(t.status===`passed`?u:t.status===`failed`?Oe:Ne,{className:j(`mt-0.5 size-4 shrink-0`,t.status===`passed`?`text-success`:t.status===`failed`?`text-danger`:`text-fg-subtle`),"aria-hidden":!0}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(U,{content:t.text,contentKey:`${e}:criterion:${n}`,language:l,markdown:!1,previewHeight:60}),t.evidence.length>0?(0,H.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-x-2 text-xs leading-5 text-fg-muted`,children:[(0,H.jsx)(`span`,{children:l===`zh`?`依据:`:`Evidence:`}),t.evidence.map(e=>e.uri&&/^https?:\/\//.test(e.uri)?(0,H.jsx)(`a`,{className:`text-accent hover:underline`,href:e.uri,target:`_blank`,rel:`noreferrer`,children:e.title},e.title):(0,H.jsx)(`span`,{children:e.title},e.title))]}):null,t.review?(0,H.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[l===`zh`?`人工判定`:`Reviewed by user`,` · `,be(t.review.reviewedAt,l)]}):null]}),F.task.phase!==`closed`&&F.task.contract?.acceptancePolicy!==`verified_auto`?(0,H.jsxs)(de,{children:[(0,H.jsx)(ge,{asChild:!0,children:(0,H.jsx)(L,{type:`button`,variant:`ghost`,className:`h-7 shrink-0 px-2 text-xs`,disabled:z.has(`acceptance`),children:l===`zh`?`判定`:`Review`})}),(0,H.jsx)(je,{children:(0,H.jsxs)(fe,{align:`end`,sideOffset:4,className:`z-[100] min-w-32 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:[(0,H.jsx)(ve,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>void Xt(n,`passed`),children:l===`zh`?`确认通过`:`Mark passed`}),(0,H.jsx)(ve,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>void Xt(n,`failed`),children:l===`zh`?`标记未通过`:`Mark failed`})]})})]}):null]},`${n}-${t.text}`))}):(0,H.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:A.noDefinition})]})]}),F.attention.length>0?(0,H.jsxs)(`section`,{className:j(`mb-4 rounded-xl border border-warning/20 bg-warning/10 p-4`,$(`attention`)&&`task-detail-live-update`),children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:pn?A.needsAttention:A.waitingStatus}),(0,H.jsx)(`ul`,{className:`mt-2 space-y-1.5 text-sm leading-6 text-fg-muted`,children:F.attention.map((t,n)=>(0,H.jsxs)(`li`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,H.jsx)(U,{content:t.summary,contentKey:`${e}:attention:${t.kind}:${n}`,language:l,markdown:!1,previewHeight:72,className:`min-w-0 flex-1`}),t.kind===`input_required`||t.kind===`approval_required`?(0,H.jsx)(s,{className:`inline-flex min-h-11 items-center rounded-lg bg-surface-panel px-3 text-sm font-medium text-accent`,to:T(e),children:l===`zh`?t.kind===`approval_required`?`查看并决定`:`补充信息`:t.kind===`approval_required`?`Review decision`:`Provide information`}):null]},`${t.kind}-${n}`))})]}):null,F.task.phase!==`closed`&&!en&&F.waits.filter(e=>(e.kind===`user_input`||e.kind===`approval`&&typeof e.condition.capability==`string`)&&e.condition.type!==`connection`).map(e=>(0,H.jsx)(Re,{wait:e,detail:F,zh:l===`zh`,onUpdated:e=>{I(e,{revalidate:!1})}},e.id)),(0,H.jsx)(`div`,{className:`mb-4`,children:(0,H.jsx)(Ue,{taskId:e},e)}),hn.length>0||_n.length>0||Sn.length>0?(0,H.jsxs)(`section`,{className:`mb-4 rounded-xl border border-edge-subtle bg-surface-panel p-5 shadow-surface`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:l===`zh`?`交付物`:`Deliverables`}),hn.length>0||_n.length>0?(0,H.jsxs)(`ul`,{className:`mt-3 space-y-2`,children:[hn.map(t=>(0,H.jsxs)(`li`,{className:`rounded-lg bg-surface-hover p-3 text-sm`,children:[(0,H.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:A.contextKindLabels[t.targetKind]}),t.targetKind===`url`&&/^https?:\/\//.test(t.targetId)?(0,H.jsx)(U,{content:t.title??t.targetId,contentKey:`${e}:deliverable:${t.id}`,language:l,previewHeight:60,className:`mt-1`,children:(0,H.jsx)(`a`,{className:`block break-all text-accent hover:underline`,href:t.targetId,target:`_blank`,rel:`noreferrer`,children:t.title??t.targetId})}):(0,H.jsx)(U,{content:t.title??t.targetId,contentKey:`${e}:deliverable:${t.id}`,language:l,markdown:!1,previewHeight:60,className:`mt-1 text-fg`})]},t.id)),_n.map(t=>(0,H.jsxs)(`li`,{className:`rounded-lg bg-surface-hover p-3 text-sm`,children:[(0,H.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:l===`zh`?`执行产物`:`Run artifact`}),t.uri&&/^https?:\/\//.test(t.uri)?(0,H.jsx)(U,{content:t.title,contentKey:`${e}:artifact:${t.uri??t.title}`,language:l,previewHeight:60,className:`mt-1`,children:(0,H.jsx)(`a`,{className:`block break-all text-accent hover:underline`,href:t.uri,target:`_blank`,rel:`noreferrer`,children:t.title})}):(0,H.jsx)(U,{content:t.title,contentKey:`${e}:artifact:${t.uri??t.title}`,language:l,markdown:!1,previewHeight:60,className:`mt-1 text-fg`})]},t.uri??t.title))]}):(0,H.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:l===`zh`?`尚未关联交付物`:`No deliverables linked yet`}),Sn.length>0?(0,H.jsxs)(`div`,{className:`mt-4 border-t border-edge-subtle pt-3`,children:[(0,H.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:A.expectedOutputs}),(0,H.jsx)(`div`,{className:`mt-2`,children:(0,H.jsx)(ut,{contentKey:`${e}:expectedOutputs`,items:Sn,empty:A.noDefinition})})]}):null]}):null,(0,H.jsxs)(`section`,{className:`mb-4 rounded-xl border border-edge-subtle bg-surface-panel p-5 shadow-surface`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:l===`zh`?`关联内容`:`Related work`}),Q.length>0||F.runs.length>0||xn.length>0||F.dependencies.length>0||F.dependents.length>0?(0,H.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[Q.length>0?(0,H.jsxs)(`div`,{className:`rounded-lg bg-surface-hover p-3`,children:[(0,H.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:l===`zh`?`对话 · ${Q.length}`:`Conversations · ${Q.length}`}),(0,H.jsx)(ze,{contentKey:`${e}:sessions`,language:l,className:`mt-2`,children:Q.map(t=>(0,H.jsx)(`li`,{children:(0,H.jsx)(s,{className:`block break-words [overflow-wrap:anywhere] text-sm text-accent hover:underline`,to:t.conversationId===Z?T(e):`/chat/${encodeURIComponent(t.conversationId)}`,children:t.conversationId===Z?l===`zh`?`当前执行对话`:`Current execution chat`:t.role===`discussion`?l===`zh`?`关联讨论`:`Linked discussion`:l===`zh`?`历史执行对话`:`Earlier execution chat`})},t.id))})]}):null,F.runs.length>0?(0,H.jsxs)(`div`,{className:`rounded-lg bg-surface-hover p-3`,children:[(0,H.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:l===`zh`?`执行 · ${F.runs.length}`:`Runs · ${F.runs.length}`}),(0,H.jsxs)(`p`,{className:`mt-2 text-sm text-fg`,children:[l===`zh`?`最近执行:`:`Latest run: `,X?A.receiptStatuses[X.status]:nn]}),yn.length>0?(0,H.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:l===`zh`?`含 ${yn.length} 次工作流执行`:`${yn.length} workflow runs`}):null,bn.map(e=>(0,H.jsxs)(s,{className:`mt-1 block break-words [overflow-wrap:anywhere] text-xs text-accent hover:underline`,to:`/workflows/${encodeURIComponent(e)}`,children:[l===`zh`?`工作流:`:`Workflow: `,e]},e))]}):null,xn.length>0?(0,H.jsxs)(`div`,{className:`rounded-lg bg-surface-hover p-3`,children:[(0,H.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:l===`zh`?`自动化 · ${xn.length}`:`Automations · ${xn.length}`}),(0,H.jsx)(ze,{contentKey:`${e}:automations`,language:l,className:`mt-2`,children:xn.map(e=>(0,H.jsx)(`li`,{children:(0,H.jsx)(s,{className:`block break-words [overflow-wrap:anywhere] text-sm text-accent hover:underline`,to:`/automations?automation=${encodeURIComponent(e.id)}`,children:e.name})},e.id))})]}):null,F.dependencies.length>0||F.dependents.length>0?(0,H.jsxs)(`div`,{className:`rounded-lg bg-surface-hover p-3`,children:[(0,H.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:A.taskRelations}),(0,H.jsx)(`p`,{className:`mt-2 text-sm text-fg`,children:l===`zh`?`${F.dependencies.length} 个前置任务 · ${F.dependents.length} 个后续任务`:`${F.dependencies.length} prerequisites · ${F.dependents.length} dependents`})]}):null]}):(0,H.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:l===`zh`?`还没有关联内容`:`No related work yet`}),(0,H.jsx)(`div`,{className:`mt-4 border-t border-edge-subtle pt-3`,children:(0,H.jsx)(Fe,{resource:{kind:`task`,id:F.task.id,revision:String(F.task.version)},disabled:Ze||pt||z.size>0})})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,H.jsxs)(`main`,{className:`min-w-0 overflow-hidden rounded-xl bg-surface-panel shadow-surface divide-y divide-edge-subtle`,children:[(0,H.jsxs)(`section`,{className:j(`p-5`,$(`body`)&&`task-detail-live-update`),children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:A.taskDescription}),pt?(0,H.jsx)(`textarea`,{autoFocus:!0,"data-task-inline-editor":!0,rows:6,value:mt,onChange:e=>ht(e.target.value),onBlur:()=>void Bt(),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),St.current=!0,ht(F.task.body??F.task.contract?.objective??``),G(!1),queueMicrotask(()=>{St.current=!1}))},className:`mt-3 w-full resize-y rounded-lg bg-surface-hover px-3 py-2 text-sm leading-6 text-fg outline-none ring-2 ring-accent/20 focus:ring-accent/50`}):(0,H.jsxs)(`div`,{className:`mt-2`,children:[rn&&rn!==F.task.title?(0,H.jsx)(U,{content:rn,contentKey:`${e}:description`,language:l}):(0,H.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:A.noTaskDescription}),(0,H.jsx)(`button`,{type:`button`,className:`mt-2 rounded-md px-2 py-1 text-xs text-accent hover:bg-surface-hover focus-visible:bg-surface-hover`,onClick:()=>{let e=F.task.body??F.task.contract?.objective??``;Ct.current=e,Tt.current={value:F.task.body??``,version:F.task.version},q(null),ht(e),G(!0)},children:l===`zh`?`编辑说明`:`Edit description`})]}),Dt===`description`?(0,H.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,H.jsx)(`span`,{children:l===`zh`?`Agent 在你编辑期间更新了描述。`:`The Agent updated the description while you were editing.`}),(0,H.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:()=>{ht(F.task.body??``),q(null),G(!1)},children:l===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,H.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,onClick:()=>void It({body:mt.trim()||null}).then(e=>{e&&(q(null),G(!1))}),children:l===`zh`?`保留我的修改`:`Keep my changes`})]}):null]}),Dn?(0,H.jsxs)(`section`,{className:j(`p-5`,$(`contract`)&&`task-detail-live-update`),children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:A.taskDefinition}),(0,H.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:l===`zh`?`执行边界及补充背景`:`Execution boundaries and supporting context`}),Cn.length>0?(0,H.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted hover:text-fg`,children:A.constraints}),(0,H.jsx)(`div`,{className:`mt-3`,children:(0,H.jsx)(ut,{contentKey:`${e}:constraints`,items:Cn,empty:A.noDefinition})})]}):null,wn.length>0?(0,H.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted hover:text-fg`,children:A.approvalRequired}),(0,H.jsx)(`div`,{className:`mt-3`,children:(0,H.jsx)(ut,{contentKey:`${e}:approvalRequired`,items:wn,empty:A.noDefinition})})]}):null,Tn.length>0?(0,H.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted hover:text-fg`,children:A.contextAssumptions}),(0,H.jsx)(`div`,{className:`mt-3`,children:(0,H.jsx)(ut,{contentKey:`${e}:assumptions`,items:Tn,empty:A.noDefinition})})]}):null,En.length>0?(0,H.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted hover:text-fg`,children:A.contextRisks}),(0,H.jsx)(`div`,{className:`mt-3`,children:(0,H.jsx)(ut,{contentKey:`${e}:risks`,items:En,empty:A.noDefinition})})]}):null]}):null,X?(0,H.jsxs)(`section`,{className:j(`p-5`,$(`runs`,`receipts`)&&`task-detail-live-update`),children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:A.latestResult}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:l===`zh`?X.completionVerdict===`achieved`?`本次执行报告目标已达成,请结合下方验证依据验收。`:`这是阶段性结果,尚不能代表任务全部完成。`:X.completionVerdict===`achieved`?`The run reports the goal achieved. Review the evidence below.`:`This is a partial result; the task is not yet fully complete.`})]}),(0,H.jsxs)(`span`,{className:`rounded-full bg-surface-hover px-2.5 py-1 text-xs text-fg-muted`,children:[A.receiptStatuses[X.status],` · `,A.verificationStatuses[X.verification.status]]})]}),(0,H.jsx)(U,{content:X.summary,contentKey:`${e}:result:${X.runId}`,language:l,className:`mt-3`}),X.remainingWork.length>0?(0,H.jsxs)(`div`,{className:`mt-4`,children:[(0,H.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:A.remainingWork}),(0,H.jsx)(`div`,{className:`mt-2`,children:(0,H.jsx)(ut,{contentKey:`${e}:remaining:${X.runId}`,items:X.remainingWork,empty:A.noRemainingWork})})]}):null,X.nextAction?(0,H.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-hover p-3`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:A.nextAction}),(0,H.jsx)(U,{content:X.nextAction,contentKey:`${e}:next:${X.runId}`,language:l,markdown:!1,previewHeight:72,className:`mt-1 text-sm text-fg`})]}):null,(0,H.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(L,{className:`border-0 bg-surface-hover px-2 py-1 text-xs shadow-none`,variant:`secondary`,onClick:()=>void y(X.runId,`helpful`),children:A.doneWell}),(0,H.jsx)(L,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>void y(X.runId,`not_helpful`),children:A.needsFix})]}),(0,H.jsx)(Ve,{evidence:X.evidence,projectId:F.task.projectId,conversationId:Z??void 0,language:l}),F.receipts.length>1?(0,H.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted hover:text-fg`,children:A.executionHistory.replace(`{{count}}`,String(F.receipts.length-1))}),(0,H.jsx)(`div`,{className:`mt-3 space-y-3`,children:F.receipts.slice(1).map(t=>(0,H.jsx)(`article`,{className:`rounded-lg bg-surface-hover p-3`,children:(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,H.jsx)(U,{content:t.summary,contentKey:`${e}:result:${t.runId}`,language:l,className:`min-w-0 flex-1`}),(0,H.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:A.receiptStatuses[t.status]})]})},t.runId))})]}):null]}):null,vn.length>0?(0,H.jsxs)(`section`,{className:j(`p-5`,$(`context`)&&`task-detail-live-update`),children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:A.contextUsed}),(0,H.jsx)(`ul`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:vn.map(e=>(0,H.jsxs)(`li`,{className:`min-w-0 rounded-lg bg-surface-hover p-2.5`,children:[(0,H.jsxs)(`span`,{className:`text-[11px] text-fg-subtle`,children:[A.contextRoleLabels[e.role],` · `,A.contextKindLabels[e.targetKind]]}),e.targetKind===`url`&&/^https?:\/\//.test(e.targetId)?(0,H.jsx)(`a`,{className:`mt-1 block break-all text-sm text-accent hover:underline`,href:e.targetId,target:`_blank`,rel:`noreferrer`,children:e.title??e.targetId}):(0,H.jsx)(`p`,{className:`mt-1 break-words text-sm text-fg`,children:e.title??e.targetId})]},e.id))})]}):null]}),(0,H.jsxs)(`aside`,{className:`min-w-0 overflow-hidden rounded-xl bg-surface-panel shadow-surface divide-y divide-edge-subtle`,children:[(0,H.jsxs)(`section`,{className:j(`p-5`,$(`phase`,`resolution`,`priority`,`dueAt`,`delegateAgentId`)&&`task-detail-live-update`),children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:A.taskProperties}),(0,H.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[(0,H.jsx)($e,{value:F.task.phase,disabled:z.has(`phase`),canMove:On,canApprove:cn,canReopen:ln,language:l,label:A.taskPhase,onChange:Vt}),(0,H.jsx)(et,{value:F.task.priority,disabled:z.has(`priority`),label:A.priority,labels:A.priorityLabels,onChange:Ht}),(0,H.jsx)(tt,{value:Ye(F.task.dueAt),disabled:z.has(`dueAt`),label:A.dueDate,onChange:Ut}),(0,H.jsx)(nt,{value:F.conversation.currentExecutorAgentId??``,disabled:z.has(`delegateAgentId`),label:A.executorLabel,unassignedLabel:A.unassigned,agents:He,onChange:Jt})]})]}),(0,H.jsxs)(`section`,{className:j(`p-5`,$(`dependencies`)&&`task-detail-live-update`),children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:A.taskRelations}),(0,H.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:A.dependencies}),(0,H.jsx)(rt,{candidates:Le,selected:F.dependencies,disabled:z.has(`dependencies`),labels:Mt,getTaskHref:Ft,onChange:qt})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:A.dependents}),F.dependents.length>0?(0,H.jsx)(`div`,{className:`space-y-1.5`,children:F.dependents.map(t=>(0,H.jsx)(U,{content:t.title,contentKey:`${e}:dependent:${t.id}`,language:l,previewHeight:72,className:`rounded-lg bg-surface-hover p-2.5`,children:(0,H.jsx)(s,{to:Ft(t.id),className:`block break-words [overflow-wrap:anywhere] text-sm text-fg-muted transition-colors hover:text-fg`,children:t.title})},t.id))}):(0,H.jsx)(`p`,{className:`text-sm text-fg-subtle`,children:A.noDependents})]})]})]})]})]})]})]}),(0,H.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":l===`zh`?`调整任务信息和 Agent 对话的宽度`:`Resize task details and Agent chat`,"aria-valuemin":30,"aria-valuemax":60,"aria-valuenow":Math.round(gt),tabIndex:0,onPointerDown:Kt,onKeyDown:Gt,onDoubleClick:()=>Wt(at),className:`group hidden w-2 shrink-0 cursor-col-resize touch-none items-stretch justify-center bg-surface-panel outline-none transition-colors hover:bg-surface-hover focus-visible:bg-surface-hover lg:flex ${vt?`bg-surface-hover`:``}`,children:(0,H.jsx)(`div`,{className:`w-px bg-edge-strong/70 transition-colors group-hover:bg-accent group-focus-visible:bg-accent`})}),(0,H.jsxs)(`aside`,{className:`flex min-h-[34rem] min-w-0 shrink-0 flex-col border-t border-edge-subtle bg-surface-panel lg:min-h-0 lg:w-[var(--task-chat-panel-width)] lg:border-t-0`,children:[(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge-subtle px-4 py-3`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-medium text-fg-muted`,children:l===`zh`?`执行对话`:`Execution chat`}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[Q.length>1?(0,H.jsxs)(de,{children:[(0,H.jsx)(ge,{asChild:!0,children:(0,H.jsx)(L,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,children:l===`zh`?`${Q.length} 段对话`:`${Q.length} conversations`})}),(0,H.jsx)(je,{children:(0,H.jsx)(fe,{align:`end`,sideOffset:6,className:`z-[100] min-w-52 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:Q.map(t=>(0,H.jsx)(ve,{asChild:!0,children:(0,H.jsx)(s,{className:`block rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,to:t.conversationId===Z?T(e):`/chat/${encodeURIComponent(t.conversationId)}`,children:t.conversationId===Z?l===`zh`?`当前执行对话`:`Current execution chat`:t.role===`discussion`?l===`zh`?`关联讨论`:`Linked discussion`:l===`zh`?`历史执行对话`:`Earlier execution chat`})},t.id))})})]}):null,Z?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(L,{type:`button`,variant:`ghost`,className:j(`size-8 p-0`,fn&&`bg-surface-hover text-fg`),"aria-label":l===`zh`?`项目文件`:`Project files`,"aria-pressed":fn,onClick:()=>{ie(Z,!1),re(Z)},children:(0,H.jsx)(E,{className:`size-4`,"aria-hidden":!0})}),(0,H.jsx)(L,{asChild:!0,variant:`ghost`,className:`size-8 p-0`,children:(0,H.jsx)(s,{to:T(e),"aria-label":l===`zh`?`全屏打开对话`:`Open chat full screen`,children:(0,H.jsx)(f,{className:`size-4`,"aria-hidden":!0})})})]}):null]})]}),Z?(0,H.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,H.jsx)(Pe,{embedded:!0,conversationId:Z,taskId:e})}):ce?(0,H.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,H.jsxs)(`div`,{className:`max-w-xs`,children:[(0,H.jsx)(D,{className:`mx-auto size-8 animate-pulse text-fg-subtle`}),(0,H.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:l===`zh`?`正在创建任务会话`:`Creating task conversation`})]})}):le?(0,H.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,H.jsxs)(`div`,{className:`max-w-xs`,children:[(0,H.jsx)(D,{className:`mx-auto size-8 text-danger`}),(0,H.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:l===`zh`?`任务会话创建失败`:`Could not create task conversation`}),(0,H.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:le instanceof Error?le.message:String(le)})]})}):(0,H.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,H.jsxs)(`div`,{className:`max-w-xs`,children:[(0,H.jsx)(D,{className:`mx-auto size-8 text-fg-subtle`}),(0,H.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:l===`zh`?`等待任务会话`:`Waiting for a task conversation`}),(0,H.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:l===`zh`?`安排或开始任务后,Agent 的执行过程和持续对话会显示在这里。`:`Schedule or start the task to see the agent run and continue the conversation here.`})]})})]})]}),(0,H.jsx)(ke,{open:At,title:A.deleteTaskTitle,description:A.deleteTaskDescription.replace(`{{title}}`,F.task.title),confirmLabel:A.confirmDeleteTask,cancelLabel:A.keepTask,destructive:!0,onConfirm:()=>{jt(!1),Yt()},onCancel:()=>jt(!1)})]})}function G(){let e=(0,B.c)(2),{taskId:t}=o(),n=t===void 0?``:t,r;return e[0]===n?r=e[1]:(r=(0,H.jsx)(pt,{taskId:n,presentation:`page`}),e[0]=n,e[1]=r),r}function mt(e){let t=(0,B.c)(47),{taskId:n,backgroundPath:r,onClose:i}=e,a=ee(St),o=Te(xt),s=Te(bt),c=Te(yt),l=z(vt),u=z(_t),d=o?s:0,f;t[0]!==i||t[1]!==u?(f=e=>{e||(u(null),i())},t[0]=i,t[1]=u,t[2]=f):f=t[2];let p=a===`zh`?`关闭任务详情`:`Close task details`,m;t[3]!==i||t[4]!==u?(m=()=>{u(null),i()},t[3]=i,t[4]=u,t[5]=m):m=t[5];let h;t[6]!==p||t[7]!==m?(h=(0,H.jsx)(`button`,{type:`button`,tabIndex:-1,"data-task-modal-backdrop":!0,className:`fixed inset-0 z-[80] bg-black/45 backdrop-blur-[1px]`,"aria-label":p,onClick:m}),t[6]=p,t[7]=m,t[8]=h):h=t[8];let g=o?`true`:`false`,_=`${d/2}px`,v=`${d}px`,y;t[9]!==_||t[10]!==v?(y={"--task-detail-workspace-offset":_,"--task-detail-workspace-width":v},t[9]=_,t[10]=v,t[11]=y):y=t[11];let b=y,x=a===`zh`?`任务详情`:`Task details`,S;t[12]===x?S=t[13]:(S=(0,H.jsx)(F,{className:`font-medium text-fg`,children:x}),t[12]=x,t[13]=S);let C=a===`zh`?`查看并操作任务详情`:`View and manage task details`,w;t[14]===C?w=t[15]:(w=(0,H.jsx)(te,{className:`sr-only`,children:C}),t[14]=C,t[15]=w);let T=a===`zh`?`关闭任务详情`:`Close task details`,E;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,H.jsx)(A,{className:`size-4`,"aria-hidden":!0}),t[16]=E):E=t[16];let D;t[17]===T?D=t[18]:(D=(0,H.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:(0,H.jsx)(ne,{className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":T,children:E})}),t[17]=T,t[18]=D);let O;t[19]!==S||t[20]!==w||t[21]!==D?(O=(0,H.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-3 bg-surface-panel px-5 py-3.5`,children:[S,w,D]}),t[19]=S,t[20]=w,t[21]=D,t[22]=O):O=t[22];let k;t[23]!==i||t[24]!==u?(k=()=>{u(null),i()},t[23]=i,t[24]=u,t[25]=k):k=t[25];let j;t[26]!==r||t[27]!==k||t[28]!==n?(j=(0,H.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,H.jsx)(pt,{taskId:n,presentation:`modal`,backgroundPath:r,onDeleted:k})}),t[26]=r,t[27]=k,t[28]=n,t[29]=j):j=t[29];let M;t[30]!==O||t[31]!==j||t[32]!==g||t[33]!==b?(M=(0,H.jsxs)(ie,{className:`xopc-dialog-content task-detail-modal-content fixed top-1/2 z-[90] flex h-[min(54rem,calc(100dvh-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay focus:outline-none`,"data-workspace-panel-open":g,style:b,onEscapeKeyDown:gt,onInteractOutside:ht,children:[O,j]}),t[30]=O,t[31]=j,t[32]=g,t[33]=b,t[34]=M):M=t[34];let N;t[35]!==l||t[36]!==c||t[37]!==o||t[38]!==s?(N=l?(0,H.jsx)(`div`,{className:`fixed inset-y-0 left-0 z-[100] flex min-h-0 min-w-0 overflow-hidden bg-surface-panel transition-[right] duration-200 ease-out motion-reduce:transition-none`,style:{right:o?s:0},children:(0,H.jsx)(R,{allowOutsideChat:!0,conversationId:c??void 0})}):null,t[35]=l,t[36]=c,t[37]=o,t[38]=s,t[39]=N):N=t[39];let P;t[40]!==M||t[41]!==N||t[42]!==h?(P=(0,H.jsxs)(re,{children:[h,M,N]}),t[40]=M,t[41]=N,t[42]=h,t[43]=P):P=t[43];let I;return t[44]!==f||t[45]!==P?(I=(0,H.jsx)(ae,{modal:!1,open:!0,onOpenChange:f,children:P}),t[44]=f,t[45]=P,t[46]=I):I=t[46],I}function ht(e){let t=e.detail.originalEvent.target;t instanceof Element&&t.closest(`#app-workspace-panel, [data-task-modal-backdrop]`)&&e.preventDefault()}function gt(e){let t=e.target;t instanceof HTMLElement&&t.closest(`[data-task-inline-editor]`)&&e.preventDefault()}function _t(e){return e.setPath}function vt(e){return e.path}function yt(e){return e.conversationIdOverride}function bt(e){return e.widthPx}function xt(e){return e.open}function St(e){return e.language}function Ct(e){return(0,H.jsx)(l,{value:e.id,children:e.name||e.id},e.id)}function wt(e){return e.id}export{mt as TaskDetailModal,G as TaskDetailPage};
@@ -1 +1 @@
1
- import{p as e}from"./locale-store-5sV3dDRG.js";import{t}from"./middleware-Pd0e8Igk.js";var n=`default`,r={light:{default:`#f7f8fa`,emerald:`#f0fdf4`,clay:`#fffaf0`,dawn:`#accdec`,porcelain:`#f6f0e7`},dark:{default:`#14171c`,emerald:`#000000`,clay:`#0a1a1a`,dawn:`#172433`,porcelain:`#211c19`}};function i(e,t){let n=document.head;if(!n)return;let i=n.querySelector(`meta[name="theme-color"][data-xopc-theme-color="true"]`);i||(i=document.createElement(`meta`),i.setAttribute(`name`,`theme-color`),i.setAttribute(`data-xopc-theme-color`,`true`),n.appendChild(i)),i.setAttribute(`content`,r[e][t])}function a(){return globalThis.matchMedia?.(`(prefers-color-scheme: dark)`).matches??!1}function o(e){return e===`system`?a()?`dark`:`light`:e}function s(){return globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1}function c(e){return e==="default"||e===`emerald`||e===`clay`||e===`dawn`||e===`porcelain`?e:n}function l(e){window.electronAPI?.theme?.setPreference(e).catch(()=>{})}function u(e,t,n){let r=document.documentElement,a=()=>{r.classList.toggle(`dark`,e===`dark`),r.dataset.theme=e,r.dataset.colorScheme=t,i(e,t)},o=document;n&&!s()&&typeof o.startViewTransition==`function`?o.startViewTransition(a):a()}function d(){try{let e=localStorage.getItem(`xopc-web-theme`),t=`system`,r=n;if(e){let n=JSON.parse(e);n.state?.preference&&(t=n.state.preference),n.state&&`colorScheme`in n.state&&(r=c(n.state.colorScheme))}u(o(t),r,!1),l(t)}catch{u(o(`system`),`default`,!1)}}var f=e(t((e,t)=>({preference:`system`,colorScheme:n,resolved:o(`system`),setPreference:n=>{let r=o(n),{resolved:i,colorScheme:a}=t();u(r,a,r!==i),e({preference:n,resolved:r}),l(n)},setColorScheme:n=>{let{resolved:r}=t();u(r,n,!0),e({colorScheme:n})}}),{name:`xopc-web-theme`,merge:(e,t)=>{let n=e??{};return{...t,...n,colorScheme:c(n.colorScheme)}}}));function p(){let{preference:e,colorScheme:t}=f.getState(),n=o(e);u(n,t,!1),f.setState({resolved:n}),l(e)}function m(){let e=globalThis.matchMedia?.(`(prefers-color-scheme: dark)`);if(!e)return()=>{};let t=()=>{let{preference:e,colorScheme:t}=f.getState();if(e!==`system`)return;let n=o(`system`),r=f.getState().resolved;u(n,t,n!==r),f.setState({resolved:n})};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)}export{f as i,m as n,p as r,d as t};
1
+ import{p as e}from"./locale-store-DId6-v2R.js";import{t}from"./middleware-Pd0e8Igk.js";var n=`default`,r={light:{default:`#f7f8fa`,emerald:`#f0fdf4`,clay:`#fffaf0`,dawn:`#accdec`,porcelain:`#f6f0e7`},dark:{default:`#14171c`,emerald:`#000000`,clay:`#0a1a1a`,dawn:`#172433`,porcelain:`#211c19`}};function i(e,t){let n=document.head;if(!n)return;let i=n.querySelector(`meta[name="theme-color"][data-xopc-theme-color="true"]`);i||(i=document.createElement(`meta`),i.setAttribute(`name`,`theme-color`),i.setAttribute(`data-xopc-theme-color`,`true`),n.appendChild(i)),i.setAttribute(`content`,r[e][t])}function a(){return globalThis.matchMedia?.(`(prefers-color-scheme: dark)`).matches??!1}function o(e){return e===`system`?a()?`dark`:`light`:e}function s(){return globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1}function c(e){return e==="default"||e===`emerald`||e===`clay`||e===`dawn`||e===`porcelain`?e:n}function l(e){window.electronAPI?.theme?.setPreference(e).catch(()=>{})}function u(e,t,n){let r=document.documentElement,a=()=>{r.classList.toggle(`dark`,e===`dark`),r.dataset.theme=e,r.dataset.colorScheme=t,i(e,t)},o=document;n&&!s()&&typeof o.startViewTransition==`function`?o.startViewTransition(a):a()}function d(){try{let e=localStorage.getItem(`xopc-web-theme`),t=`system`,r=n;if(e){let n=JSON.parse(e);n.state?.preference&&(t=n.state.preference),n.state&&`colorScheme`in n.state&&(r=c(n.state.colorScheme))}u(o(t),r,!1),l(t)}catch{u(o(`system`),`default`,!1)}}var f=e(t((e,t)=>({preference:`system`,colorScheme:n,resolved:o(`system`),setPreference:n=>{let r=o(n),{resolved:i,colorScheme:a}=t();u(r,a,r!==i),e({preference:n,resolved:r}),l(n)},setColorScheme:n=>{let{resolved:r}=t();u(r,n,!0),e({colorScheme:n})}}),{name:`xopc-web-theme`,merge:(e,t)=>{let n=e??{};return{...t,...n,colorScheme:c(n.colorScheme)}}}));function p(){let{preference:e,colorScheme:t}=f.getState(),n=o(e);u(n,t,!1),f.setState({resolved:n}),l(e)}function m(){let e=globalThis.matchMedia?.(`(prefers-color-scheme: dark)`);if(!e)return()=>{};let t=()=>{let{preference:e,colorScheme:t}=f.getState();if(e!==`system`)return;let n=o(`system`),r=f.getState().resolved;u(n,t,n!==r),f.setState({resolved:n})};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)}export{f as i,m as n,p as r,d as t};
@@ -0,0 +1 @@
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"./popover-select-BgSdSbCL.js";import{a,n as ee,r as o}from"./locale-store-DId6-v2R.js";import{a as s,i as c,n as te,o as l,r as u,s as d,t as f}from"./dist-BGTk37IG.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{t as m}from"./button-CS04eWY9.js";import{t as h}from"./skeleton-BwbyijEw.js";import{n as ne,r as re}from"./settings-page-layout-X1x-2Cp9.js";import{n as ie,t as ae}from"./use-autosave-veoM0dHn.js";var g=e(t(),1),_=n(),v=e=>o(`/api/observability/${e}`);async function y(e,t=`GET`,n){return a(v(e),{method:t,...n===void 0?{}:{body:JSON.stringify(n)}})}var b=r(),x=`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,S=`space-y-4 rounded-xl border border-edge bg-surface-panel p-4`,oe=(e=0)=>`${(e/1048576).toFixed(1)} MiB`;function se(){let e=(0,_.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,b.jsxs)(`div`,{"aria-busy":`true`,className:`space-y-4`,children:[(0,b.jsx)(h,{className:`h-48 rounded-xl`}),(0,b.jsx)(h,{className:`h-64 rounded-xl`})]}),e[0]=t):t=e[0],t}function ce(e,t){let n=0,r=e,i=new Set;for(;r.parentSpanId&&n<12&&!i.has(r.spanId);){i.add(r.spanId);let e=t.find(e=>e.spanId===r.parentSpanId);if(!e)break;r=e,n++}return n}function le(e){let t=[],n=new Set;function r(i){n.has(i.spanId)||(n.add(i.spanId),t.push(i),e.filter(e=>e.parentSpanId===i.spanId).forEach(r))}return e.filter(t=>!t.parentSpanId||!e.some(e=>e.spanId===t.parentSpanId)).forEach(r),e.forEach(r),t}function ue(){let e=ee(e=>e.language)===`zh`,t=(t,n)=>e?n:t,n=p(v(`tracing/settings`),()=>y(`tracing/settings`)),r=p(v(`tracing/status`),()=>y(`tracing/status`),{refreshInterval:1e4}),[a,o]=(0,g.useState)(),[_,ue]=(0,g.useState)(),C=a??_??n.data?.config,[w,T]=(0,g.useState)(``),[E,D]=(0,g.useState)(``),[O,de]=(0,g.useState)(!1),[fe,k]=(0,g.useState)(``),[pe,me]=(0,g.useState)(!1),[A,he]=(0,g.useState)(``),[j,ge]=(0,g.useState)(`7`),[M,_e]=(0,g.useState)({conversationId:``,runId:``,agentId:``}),[N,P]=(0,g.useState)(`records`),[F,ve]=(0,g.useState)(`10`),[ye,I]=(0,g.useState)([``]),[L,R]=(0,g.useState)(0),[z,be]=(0,g.useState)(()=>Date.now()+1),B=ye[L],[V,H]=(0,g.useState)();function U(){I([``]),R(0),be(Date.now()+1)}let[xe,W]=(0,g.useState)(!1),G=new URLSearchParams({limit:F,from:String(z-Number(j)*864e5),to:String(z)});A&&G.set(`status`,A),B&&G.set(`cursor`,B);for(let[e,t]of Object.entries(M))t&&G.set(e,t);let Se=`traces?${G}`,K=p(v(Se),()=>y(Se),{refreshInterval:B?0:1e4}),q=p(V?v(`traces/${V}`):null,()=>y(`traces/${V}`));function J(e){if(!C)return;let t=structuredClone(C);e(t),o(t)}async function Y(e,i=t(`Saved`,`已保存`)){de(!0),k(``),me(!1);try{await e(),k(i),await Promise.all([n.mutate(),r.mutate(),K.mutate()])}catch(e){me(!0),k(e instanceof Error?e.message:t(`Request failed`,`操作失败`))}finally{de(!1)}}let X=ae({value:C??null,dirty:!!(a&&JSON.stringify(a)!==JSON.stringify(_??n.data?.config)),validate:e=>{if([[`retentionDays`,1,90],[`maxStoreMiB`,16,4096],[`maxTraces`,10,1e5],[`maxSpans`,100,1e6],[`maxTraceKiB`,16,4096],[`maxWriteMiBPerMinute`,1,100]].some(([t,n,r])=>!Number.isInteger(e.local[t])||e.local[t]<n||e.local[t]>r))return t(`Enter valid storage limits before continuing.`,`请填写有效的存储限额。`);try{let t=new URL(e.langfuse.baseUrl);if(![`http:`,`https:`].includes(t.protocol)||e.langfuse.baseUrl.length>2048)throw Error()}catch{return t(`Enter a valid HTTP(S) Base URL.`,`请填写有效的 HTTP(S) Base URL。`)}return null},onSave:async e=>{ue((await y(`tracing/settings`,`PATCH`,e)).config),o(t=>t&&JSON.stringify(t)===JSON.stringify(e)?void 0:t),await r.mutate().catch(()=>{})}}),Z=(0,g.useMemo)(()=>({publicKey:w.trim(),secretKey:E.trim()}),[w,E]),Q=ae({value:Z,dirty:!!(Z.publicKey||Z.secretKey),delayMs:1e3,validate:e=>e.publicKey.length>512||e.secretKey.length>512?t(`Credentials must be at most 512 characters.`,`凭证长度不能超过 512 个字符。`):null,onSave:async e=>{await y(`tracing/langfuse/credentials`,`PUT`,{...e.publicKey?{publicKey:e.publicKey}:{},...e.secretKey?{secretKey:e.secretKey}:{}}),T(t=>t.trim()===e.publicKey?``:t),D(t=>t.trim()===e.secretKey?``:t),await Promise.allSettled([n.mutate(),r.mutate()])}}),$=[X.status,Q.status].some(e=>e===`dirty`||e===`saving`);async function Ce(){V&&await Y(async()=>{let e=await y(`traces/${V}/export`),t=URL.createObjectURL(new Blob([JSON.stringify(e,null,2)],{type:`application/json`})),n=document.createElement(`a`);n.href=t,n.download=`trace-${V}.json`,n.click(),URL.revokeObjectURL(t)},t(`Exported`,`已导出`))}return(0,b.jsxs)(re,{className:`space-y-6`,children:[(0,b.jsx)(ne,{title:t(`Runtime tracing`,`运行追踪`),subtitle:t(`Local diagnostics with bounded retention. Enable Langfuse to also export new traces.`,`默认保留有界本地记录;启用 Langfuse 后同时导出新采集的追踪。`),actions:N===`settings`?(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,b.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t(`Changes save automatically`,`修改后自动保存`)}),(0,b.jsx)(ie,{status:X.status,error:X.error})]}):(0,b.jsx)(m,{disabled:K.isValidating,onClick:U,children:t(`Refresh records`,`刷新记录`)})}),fe&&(0,b.jsx)(`p`,{role:pe?`alert`:`status`,className:`text-sm text-fg-muted`,children:fe}),n.error&&(0,b.jsx)(`p`,{role:`alert`,children:String(n.error.message)}),(0,b.jsxs)(`nav`,{"aria-label":t(`Tracing sections`,`追踪页面分区`),className:`flex gap-2 border-b border-edge pb-3`,children:[(0,b.jsx)(m,{"aria-pressed":N===`records`,variant:N===`records`?`primary`:`ghost`,onClick:()=>P(`records`),children:t(`Execution records`,`执行记录`)}),(0,b.jsx)(m,{"aria-pressed":N===`settings`,variant:N===`settings`?`primary`:`ghost`,onClick:()=>P(`settings`),children:t(`Capture settings`,`采集设置`)})]}),N===`settings`&&(C?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`section`,{className:S,onBlurCapture:X.onBlurCapture,children:[(0,b.jsx)(`h2`,{className:`font-medium`,children:t(`Local recording`,`本地记录`)}),X.error&&(0,b.jsx)(m,{variant:`ghost`,onClick:X.retry,children:t(`Retry autosave`,`重试自动保存`)}),(0,b.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:C.enabled,onChange:e=>J(t=>{t.enabled=e.target.checked})}),t(`Record traces`,`记录运行追踪`)]}),(0,b.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[(0,b.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t(`Retention (days)`,`保留天数`),(0,b.jsx)(`input`,{className:x,type:`number`,min:1,max:90,value:C.local.retentionDays,onChange:e=>J(t=>{t.local.retentionDays=Number(e.target.value)})})]}),(0,b.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t(`Storage budget (MiB)`,`存储上限(MiB)`),(0,b.jsx)(`input`,{className:x,type:`number`,min:16,max:4096,value:C.local.maxStoreMiB,onChange:e=>J(t=>{t.local.maxStoreMiB=Number(e.target.value)})})]}),(0,b.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t(`Capture`,`采集内容`),(0,b.jsx)(i,{placeholder:t(`Choose`,`请选择`),allowEmpty:!1,value:C.capture,onChange:e=>J(t=>{t.capture=e}),options:[{value:`metadata`,label:t(`Metadata only`,`仅元数据`)},{value:`redacted`,label:t(`Redacted previews`,`脱敏摘要`)},{value:`detailed`,label:t(`Detailed · 30 minutes`,`详细记录 · 30 分钟`)}]})]})]}),(0,b.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t(`Previews may contain personal content. Secrets and media are filtered; large values are truncated.`,`摘要可能包含个人内容。过滤凭证和媒体,超长内容会截断。`)}),C.detailedUntil&&(0,b.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[t(`Detailed capture expires: `,`详细采集截止:`),new Date(C.detailedUntil).toLocaleString()]}),(0,b.jsxs)(`details`,{children:[(0,b.jsx)(`summary`,{className:`cursor-pointer text-sm`,children:t(`Advanced limits`,`高级限制`)}),(0,b.jsx)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[[`maxTraces`,t(`Trace count`,`Trace 条数`)],[`maxSpans`,t(`Span count`,`Span 条数`)],[`maxTraceKiB`,t(`Per trace (KiB)`,`单 Trace 上限(KiB)`)],[`maxWriteMiBPerMinute`,t(`Write budget (MiB/minute)`,`写入额度(MiB/分钟)`)]].map(([e,t])=>(0,b.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t,(0,b.jsx)(`input`,{type:`number`,min:1,className:x,value:C.local[e],onChange:t=>J(n=>{n.local[e]=Number(t.target.value)})})]},e))})]}),r.data?(0,b.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[t(`Disk / payload`,`磁盘 / 数据`),`:`,oe(r.data.local.physicalBytes),` / `,oe(r.data.local.bytes),` · `,r.data.local.traces??0,` traces · `,r.data.local.spans??0,` spans · `,t(`Dropped`,`丢弃`),` `,Number(r.data.local.dropped??0)+Number(r.data.local.queueDropped??0),(r.data.local.paused||r.data.local.unavailable)&&` · ${t(`Recording paused`,`存储暂停`)}`]}):(0,b.jsx)(h,{className:`h-10`}),(r.error||r.data?.local.lastError)&&(0,b.jsx)(`p`,{role:`alert`,className:`text-sm`,children:r.data?.local.lastError||String(r.error.message)}),(0,b.jsxs)(`div`,{className:`flex gap-2`,children:[(0,b.jsx)(m,{disabled:O||$,onClick:()=>void Y(async()=>{await y(`traces/prune`,`POST`)}),children:t(`Clean expired`,`清理过期记录`)}),(0,b.jsx)(m,{disabled:O,onClick:()=>W(!0),children:t(`Clear local traces`,`清空本地追踪`)})]})]}),(0,b.jsxs)(`section`,{className:S,children:[(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,b.jsx)(`h2`,{className:`font-medium`,children:`Langfuse`}),(0,b.jsx)(ie,{status:Q.status,error:Q.error})]}),Q.error&&(0,b.jsx)(m,{variant:`ghost`,onClick:Q.retry,children:t(`Retry autosave`,`重试自动保存`)}),(0,b.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:C.langfuse.enabled,onBlur:X.onBlurCapture,onChange:e=>J(t=>{t.langfuse.enabled=e.target.checked})}),t(`Also export new traces to Langfuse`,`同时导出新采集的追踪到 Langfuse`)]}),(0,b.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,b.jsxs)(`label`,{className:`space-y-1 text-sm sm:col-span-2`,children:[`Base URL`,(0,b.jsx)(`input`,{className:x,type:`url`,value:C.langfuse.baseUrl,onBlur:X.onBlurCapture,onChange:e=>J(t=>{t.langfuse.baseUrl=e.target.value})})]}),(0,b.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[`Public Key`,(0,b.jsx)(`input`,{autoComplete:`off`,className:x,value:w,onBlur:Q.onBlurCapture,placeholder:n.data?.credentials.publicKeyConfigured?t(`Configured · leave blank to keep`,`已配置 · 留空保留`):`pk-lf-…`,onChange:e=>T(e.target.value)})]}),(0,b.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[`Secret Key`,(0,b.jsx)(`input`,{autoComplete:`new-password`,type:`password`,className:x,value:E,onBlur:Q.onBlurCapture,placeholder:n.data?.credentials.secretKeyConfigured?t(`Configured · leave blank to keep`,`已配置 · 留空保留`):`sk-lf-…`,onChange:e=>D(e.target.value)})]})]}),(0,b.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[t(`Credential sources`,`凭证来源`),`:`,n.data?.credentials.publicKeySource,` / `,n.data?.credentials.secretKeySource,` · URL: `,n.data?.credentials.baseUrlSource]}),r.data&&(0,b.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[r.data.langfuse.state,` · `,t(`Pending`,`待发送`),` `,r.data.langfuse.pending,` · `,t(`Dropped`,`丢弃`),` `,r.data.langfuse.dropped,r.data.langfuse.lastSuccess?` · ${new Date(r.data.langfuse.lastSuccess).toLocaleString()}`:``]}),r.data?.langfuse.lastError&&(0,b.jsx)(`p`,{role:`alert`,className:`text-sm`,children:r.data.langfuse.lastError}),(0,b.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t(`Changes save automatically. Historical traces are not uploaded. Offline exports may be dropped.`,`修改后自动保存。不会上传历史记录;断网或队列满时可能丢弃远端导出。`)}),(0,b.jsxs)(`div`,{className:`flex gap-2`,children:[(0,b.jsx)(m,{disabled:O||$,onClick:()=>void Y(async()=>{if(!(await y(`tracing/langfuse/test`,`POST`)).ok)throw Error(t(`Connection test failed. Check saved configuration and credentials.`,`连接测试失败,请检查已保存的配置和凭证。`))},t(`Diagnostic trace accepted by the ingestion endpoint`,`采集端已接受诊断追踪`)),children:t(`Test connection`,`测试连接`)}),(0,b.jsx)(m,{disabled:O||$,onClick:()=>void Y(async()=>{await y(`tracing/langfuse/credentials`,`DELETE`),T(``),D(``)}),children:t(`Remove saved credentials`,`移除已保存凭证`)})]})]})]}):(0,b.jsx)(se,{})),N===`records`&&(0,b.jsxs)(`section`,{className:S,children:[(0,b.jsx)(`h2`,{className:`font-medium`,children:t(`Recent runs`,`最近执行`)}),(0,b.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,b.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t(`Status`,`执行状态`),(0,b.jsx)(i,{placeholder:t(`All statuses`,`全部状态`),allowEmpty:!1,value:A,onChange:e=>{he(e),U()},options:[{value:``,label:t(`All statuses`,`全部状态`)},...[`running`,`success`,`error`,`cancelled`,`suspended`,`interrupted`].map(e=>({value:e,label:t(e,{running:`运行中`,success:`成功`,error:`失败`,cancelled:`已取消`,suspended:`已暂停`,interrupted:`已中断`}[e])}))]})]}),(0,b.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t(`Time range`,`时间范围`),(0,b.jsx)(i,{placeholder:t(`Choose`,`请选择`),value:j,allowEmpty:!1,onChange:e=>{ge(e),U()},options:[`1`,`7`,`30`,`90`].map(e=>({value:e,label:`${e} ${t(`days`,`天`)}`}))})]}),(0,b.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t(`Page size`,`每页条数`),(0,b.jsx)(i,{placeholder:t(`Choose`,`请选择`),value:F,allowEmpty:!1,onChange:e=>{ve(e),U()},options:[`10`,`20`].map(e=>({value:e,label:`${e} ${t(`records`,`条`)}`}))})]})]}),(0,b.jsxs)(`details`,{children:[(0,b.jsxs)(`summary`,{className:`cursor-pointer text-sm text-fg-muted`,children:[t(`Advanced filters`,`高级筛选`),Object.values(M).some(Boolean)?` · ${t(`Active`,`已启用`)}`:``]}),(0,b.jsx)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-3`,children:[`conversationId`,`runId`,`agentId`].map(e=>(0,b.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[{conversationId:t(`Conversation ID`,`会话 ID`),runId:t(`Run ID`,`执行 ID`),agentId:t(`Agent ID`,`Agent ID`)}[e],(0,b.jsx)(`input`,{"aria-label":e,placeholder:t(`Exact ID`,`输入完整 ID`),className:x,value:M[e],onChange:t=>{_e({...M,[e]:t.target.value}),U()}})]},e))})]}),(0,b.jsxs)(`div`,{role:`region`,"aria-label":t(`Execution results`,`执行结果`),"aria-busy":K.isValidating,className:`h-[24rem] min-h-0 overflow-y-auto overscroll-contain rounded-lg border border-edge sm:h-[28rem]`,children:[K.error&&(0,b.jsx)(`p`,{role:`alert`,className:`p-4 text-sm`,children:K.error.message}),!K.data&&!K.error?(0,b.jsx)(`div`,{className:`space-y-3 p-3`,children:[0,1,2,3,4].map(e=>(0,b.jsx)(h,{className:`h-16`},e))}):(0,b.jsxs)(`div`,{className:`divide-y divide-edge`,children:[K.data?.traces.length===0&&(0,b.jsx)(`p`,{className:`flex h-48 items-center justify-center px-4 text-sm text-fg-muted`,children:t(`No traces in this range`,`此时间范围内暂无记录`)}),K.data?.traces.map(n=>(0,b.jsxs)(`button`,{onClick:()=>H(n.traceId),className:`flex w-full flex-col gap-2 px-3 py-3 text-left text-sm hover:bg-surface-hover sm:flex-row sm:items-center sm:justify-between`,children:[(0,b.jsxs)(`div`,{className:`min-w-0`,children:[(0,b.jsxs)(`p`,{className:`truncate font-medium`,children:[n.name,n.attributes[`xopc.agentId`]?` · ${n.attributes[`xopc.agentId`]}`:``]}),(0,b.jsxs)(`p`,{className:`truncate text-xs text-fg-muted`,children:[new Date(n.startedAt).toLocaleString(e?`zh-CN`:`en-US`),` · `,n.traceId]}),n.stats&&(0,b.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[n.stats.generations,` `,t(`model calls`,`次模型调用`),` · `,n.stats.tokens,` tokens · $`,n.stats.knownCostUsd.toFixed(4),n.stats.unknownCostCalls>0?` · ${t(`partial cost`,`部分成本未知`)}`:``]})]}),(0,b.jsxs)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:[t(n.status,{running:`运行中`,success:`成功`,error:`失败`,cancelled:`已取消`,suspended:`已暂停`,interrupted:`已中断`}[n.status]??n.status),` · `,n.endedAt?`${Math.round(n.endedAt-n.startedAt)} ms`:`—`,n.partialReason?` · ${t(`Partial`,`部分记录`)}`:``]})]},n.traceId))]})]}),(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,b.jsx)(`p`,{"aria-live":`polite`,className:`text-xs text-fg-muted`,children:t(`Page ${L+1} · ${K.data?.traces.length??0} records`,`第 ${L+1} 页 · ${K.data?.traces.length??0} 条`)}),(0,b.jsxs)(`div`,{className:`flex gap-2`,children:[(0,b.jsx)(m,{disabled:L===0||K.isValidating,onClick:()=>R(e=>Math.max(0,e-1)),children:t(`Previous page`,`上一页`)}),(0,b.jsx)(m,{disabled:!K.data?.nextCursor||K.isValidating,onClick:()=>{let e=K.data?.nextCursor;e&&(I(t=>[...t.slice(0,L+1),e]),R(e=>e+1))},children:t(`Next page`,`下一页`)})]})]})]}),(0,b.jsx)(f,{open:!!V,onOpenChange:e=>{e||H(void 0)},children:(0,b.jsxs)(l,{children:[(0,b.jsx)(s,{className:`fixed inset-0 z-[90] bg-black/40`}),(0,b.jsxs)(u,{className:`fixed left-1/2 top-1/2 z-[91] flex h-[min(44rem,calc(100vh-2rem))] w-[min(64rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay p-4`,children:[(0,b.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3`,children:[(0,b.jsx)(d,{className:`font-medium`,children:t(`Trace details`,`追踪详情`)}),(0,b.jsx)(te,{asChild:!0,children:(0,b.jsx)(m,{children:t(`Close`,`关闭`)})})]}),(0,b.jsx)(c,{className:`shrink-0 truncate text-xs text-fg-muted`,children:V}),(0,b.jsx)(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto py-4`,children:q.error?(0,b.jsx)(`p`,{role:`alert`,children:q.error.message}):q.data?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`p`,{className:`text-sm`,children:[q.data.trace.status,` `,q.data.trace.partialReason&&` · ${q.data.trace.partialReason}`]}),le(q.data.spans).map(e=>(0,b.jsxs)(`details`,{style:{marginLeft:ce(e,q.data.spans)*12},className:`rounded-lg border border-edge p-3 text-sm`,children:[(0,b.jsxs)(`summary`,{className:`cursor-pointer`,children:[e.name,` · `,e.status,` · `,e.endedAt?`${Math.round(e.endedAt-e.startedAt)} ms`:`—`]}),(0,b.jsx)(`pre`,{className:`mt-3 whitespace-pre-wrap break-all text-xs text-fg-muted`,children:JSON.stringify(e.attributes,null,2)})]},e.spanId))]}):(0,b.jsx)(se,{})}),(0,b.jsx)(`div`,{className:`shrink-0 border-t border-edge pt-3`,children:(0,b.jsx)(m,{disabled:!q.data||O,onClick:()=>void Ce(),children:t(`Export JSON`,`导出 JSON`)})})]})]})}),(0,b.jsx)(f,{open:xe,onOpenChange:W,children:(0,b.jsxs)(l,{children:[(0,b.jsx)(s,{className:`fixed inset-0 z-[90] bg-black/40`}),(0,b.jsxs)(u,{className:`fixed left-1/2 top-1/2 z-[91] w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 space-y-4 rounded-xl border border-edge bg-surface-overlay p-5`,children:[(0,b.jsx)(d,{children:t(`Clear local traces?`,`清空本地追踪?`)}),(0,b.jsx)(c,{className:`text-sm text-fg-muted`,children:t(`Removes retained local traces. Conversations, usage records and Langfuse data remain available.`,`删除已保留的本地追踪。会话、用量记录及 Langfuse 数据仍保留。`)}),(0,b.jsxs)(`div`,{className:`flex gap-2`,children:[(0,b.jsx)(m,{disabled:O||$,onClick:()=>void Y(async()=>{await y(`traces`,`DELETE`),W(!1),H(void 0)}),children:t(`Clear`,`清空`)}),(0,b.jsx)(te,{asChild:!0,children:(0,b.jsx)(m,{children:t(`Cancel`,`取消`)})})]})]})]})})]})}export{ue as TracingSettingsPage};
@@ -1 +1 @@
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"./external-link-DjqjBmc3.js";import{t as a}from"./globe-DSSGFWFn.js";import{t as o}from"./loader-circle-CifKLtgG.js";import{t as s}from"./messages-CaURu8bb.js";import{t as c}from"./cn-JdwAhgNB.js";import{a as l,c as u,i as d,n as ee,r as f}from"./locale-store-5sV3dDRG.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{t as m}from"./button-CS04eWY9.js";import{n as h,r as g}from"./gateway-config-swr-ZM72jovc.js";import{s as _}from"./form-field-width-DJw_jULe.js";import{t as v}from"./skeleton-BwbyijEw.js";import{t as y}from"./copy-text-row-BHDs3cBa.js";import{$i as b,Uo as x}from"./index-C0JT9Ja4.js";import{n as te,t as ne}from"./settings-form-section-exRhP9xn.js";var S=e(t(),1),C=n(),w=r();function T(e){let t=(0,C.c)(10),{language:n,label:r,section:a,className:o}=e,s;t[0]!==n||t[1]!==a?(s=b(n,a),t[0]=n,t[1]=a,t[2]=s):s=t[2];let l;t[3]===o?l=t[4]:(l=c(`inline-flex items-center gap-1 text-sm font-medium text-accent hover:underline`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,o),t[3]=o,t[4]=l);let u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,w.jsx)(i,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[5]=u):u=t[5];let d;return t[6]!==r||t[7]!==s||t[8]!==l?(d=(0,w.jsxs)(`a`,{href:s,target:`_blank`,rel:`noreferrer`,className:l,children:[r,u]}),t[6]=r,t[7]=s,t[8]=l,t[9]=d):d=t[9],d}async function E(){let e=await d(`/api/exposure/status`);if(!e.ok)throw Error(`Failed to load exposure status (${e.status})`);return await e.json()}async function D(e=`serve`){let t=await d(`/api/exposure/tailscale/start`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({mode:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`Start failed (${t.status})`)}return await t.json()}async function O(){let e=await d(`/api/exposure/tailscale/stop`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??`Stop failed (${e.status})`)}return await e.json()}var k=`https://tailscale.com/download`;function A(e){let t=(0,C.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,w.jsx)(`a`,{href:k,target:`_blank`,rel:`noreferrer`,className:`font-medium text-accent hover:underline`,children:n}),t[0]=n,t[1]=r),r}function j({embedded:e=!1}){let t=ee(e=>e.language),n=s(t).remoteAccess.tailscale,r=(0,S.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:s(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]),i=!!u(e=>e.conversationId),[c,l]=(0,S.useState)(!1),[d,f]=(0,S.useState)(null),{data:h,mutate:g,isLoading:_}=p(i?`exposure-status`:null,E,{refreshInterval:3e4}),b=h?.tailscale.hostname,C=h?.tailscale.active===!0,k=h?.tailscale.cliAvailable!==!1,j=b?`https://${b}/`:null,re=(0,S.useCallback)(async()=>{l(!0),f(null);try{await D(`serve`),await g()}catch(e){f(e instanceof Error?e.message:String(e))}finally{l(!1)}},[g]),ie=(0,S.useCallback)(async()=>{l(!0),f(null);try{await O(),await g()}catch(e){f(e instanceof Error?e.message:String(e))}finally{l(!1)}},[g]);if(!i)return null;let M=(0,w.jsxs)(`div`,{className:e?`space-y-4`:`mt-4 space-y-3`,children:[e?(0,w.jsxs)(`ol`,{className:`space-y-3 text-sm text-fg-muted`,children:[(0,w.jsxs)(`li`,{className:`flex gap-2`,children:[(0,w.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`1`}),(0,w.jsxs)(`span`,{children:[n.stepInstallBefore,(0,w.jsx)(A,{label:n.stepInstallLink}),n.stepInstallAfter]})]}),(0,w.jsxs)(`li`,{className:`flex gap-2`,children:[(0,w.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`2`}),(0,w.jsx)(`span`,{children:n.stepEnable})]}),(0,w.jsxs)(`li`,{className:`flex gap-2`,children:[(0,w.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`3`}),(0,w.jsx)(`span`,{children:n.stepCopy})]})]}):null,e&&h?.tailscale.cliAvailable===!1?(0,w.jsxs)(`p`,{className:`rounded-lg bg-amber-500/10 px-3 py-2 text-sm text-fg-muted`,children:[n.cliMissingIntro,` `,(0,w.jsx)(A,{label:n.cliMissingDownloadLink}),n.cliMissingSuffix]}):null,_&&!h?(0,w.jsxs)(`div`,{className:`grid gap-3`,"aria-busy":`true`,children:[(0,w.jsx)(v,{className:`h-20 rounded-lg`}),(0,w.jsx)(v,{className:`h-20 rounded-lg`})]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(ne,{children:[(0,w.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.statusLabel}),(0,w.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:C?n.statusActive:n.statusOff}),j?(0,w.jsx)(`div`,{className:`mt-3`,children:(0,w.jsx)(y,{text:j,labels:r})}):null,d?(0,w.jsx)(`p`,{className:`mt-2 text-sm text-red-600 dark:text-red-400`,children:d}):null,(0,w.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:C?(0,w.jsxs)(m,{type:`button`,variant:`secondary`,disabled:c,onClick:()=>void ie(),children:[c?(0,w.jsx)(o,{className:`mr-1 size-4 animate-spin`}):null,n.disableServe]}):(0,w.jsxs)(m,{type:`button`,disabled:c||!k,onClick:()=>void re(),children:[c?(0,w.jsx)(o,{className:`mr-1 size-4 animate-spin`}):(0,w.jsx)(x,{className:`mr-1 size-4`}),n.enableServe]})})]}),(0,w.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.hint}),(0,w.jsx)(T,{language:t,label:n.docsLink,section:`tailscale-serve`,className:`mt-2`})]})]});return e?M:(0,w.jsxs)(ne,{children:[(0,w.jsx)(te,{icon:a,title:n.title,subtitle:n.subtitle}),M]})}async function re(e){let t=await d(f(`/api/tunnel/probe-public`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:e})});if(!t.ok&&t.status!==400)throw Error(`Probe failed (${t.status})`);return await t.json()}async function ie(e){await l(f(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{publicUrl:e??null}})})}function M(e){let t=e.split(`.`).map(e=>Number.parseInt(e,10));if(t.length!==4||t.some(e=>!Number.isFinite(e)))return!1;let[n,r]=t;return n===10||n===127||n===169&&r===254||n===172&&r>=16&&r<=31||n===192&&r===168||n===100&&r>=64&&r<=127}function ae(){return(0,S.useMemo)(()=>{if(typeof window>`u`)return null;let{protocol:e,hostname:t,origin:n}=window.location;if(e!==`https:`&&e!==`http:`)return null;let r=t.toLowerCase();return!r||r===`localhost`||r===`127.0.0.1`||r===`::1`||r===`[::1]`||r.endsWith(`.local`)||r.endsWith(`.localhost`)||M(r)?null:n.toLowerCase().replace(/\/+$/,``)},[])}function oe(){return c(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,_,`dark:border-edge`)}function se(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e.gateway;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t.publicUrl;return typeof n==`string`&&n.trim()?n.trim():null}function N(){let e=(0,C.c)(85),t=ee(le),n;e[0]===t?n=e[1]:(n=s(t),e[0]=t,e[1]=n);let r=n.remoteAccess.reverseProxy,i=!!u(ce),l=ae(),d=g(i).data?.payload?.config,f;e[2]===d?f=e[3]:(f=se(d),e[2]=d,e[3]=f);let p=f,[_,v]=(0,S.useState)(``),y;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(y={busy:!1,result:null},e[4]=y):y=e[4];let[b,x]=(0,S.useState)(y),T;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(T={busy:!1,error:null},e[5]=T):T=e[5];let[E,D]=(0,S.useState)(T),O,k;e[6]!==p||e[7]!==l||e[8]!==_?(O=()=>{_||(p?v(p):l&&v(l))},k=[p,l,_],e[6]=p,e[7]=l,e[8]=_,e[9]=O,e[10]=k):(O=e[9],k=e[10]),(0,S.useEffect)(O,k);let A;bb0:{let t;e[11]===_?t=e[12]:(t=_.trim(),e[11]=_,e[12]=t);let n=t;if(n){A=n;break bb0}A=p??l??``}let j=A,M=!p&&!!l&&j===l,N;e[13]!==_||e[14]!==j?(N=async()=>{let e=_.trim()||j;if(e){x({busy:!0,result:null});try{x({busy:!1,result:await re(e)})}catch(e){let t=e;x({busy:!1,result:{ok:!1,code:`NETWORK_ERROR`,message:t instanceof Error?t.message:String(t)}})}}},e[13]=_,e[14]=j,e[15]=N):N=e[15];let de=N,fe;e[16]===j?fe=e[17]:(fe=async()=>{let e=j.trim();if(e){D({busy:!0,error:null});try{await ie(e),await h(),D({busy:!1,error:null})}catch(e){let t=e;D({busy:!1,error:t instanceof Error?t.message:String(t)})}}},e[16]=j,e[17]=fe);let pe=fe,P;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(P=async()=>{D({busy:!0,error:null});try{await ie(null),await h(),v(``),x({busy:!1,result:null}),D({busy:!1,error:null})}catch(e){let t=e;D({busy:!1,error:t instanceof Error?t.message:String(t)})}},e[18]=P):P=e[18];let me=P;if(!i)return null;let F;e[19]!==r.subtitle||e[20]!==r.title?(F=(0,w.jsx)(te,{icon:a,title:r.title,subtitle:r.subtitle}),e[19]=r.subtitle,e[20]=r.title,e[21]=F):F=e[21];let I;e[22]===r.urlLabel?I=e[23]:(I=(0,w.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`reverse-proxy-url`,children:r.urlLabel}),e[22]=r.urlLabel,e[23]=I);let L;e[24]===Symbol.for(`react.memo_cache_sentinel`)?(L=c(oe(),`font-mono text-xs sm:flex-1 sm:min-w-0 sm:w-auto`),e[24]=L):L=e[24];let R;e[25]===Symbol.for(`react.memo_cache_sentinel`)?(R=e=>{v(e.target.value),x({busy:!1,result:null})},e[25]=R):R=e[25];let z;e[26]!==_||e[27]!==r.urlPlaceholder||e[28]!==L?(z=(0,w.jsx)(`input`,{id:`reverse-proxy-url`,className:L,type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:r.urlPlaceholder,value:_,onChange:R}),e[26]=_,e[27]=r.urlPlaceholder,e[28]=L,e[29]=z):z=e[29];let B;e[30]===de?B=e[31]:(B=()=>void de(),e[30]=de,e[31]=B);let V;e[32]!==_||e[33]!==b.busy?(V=b.busy||!_.trim(),e[32]=_,e[33]=b.busy,e[34]=V):V=e[34];let H;e[35]===b.busy?H=e[36]:(H=b.busy?(0,w.jsx)(o,{className:`size-3.5 animate-spin`}):null,e[35]=b.busy,e[36]=H);let he=b.busy?r.probing:r.probeButton,U;e[37]!==B||e[38]!==V||e[39]!==H||e[40]!==he?(U=(0,w.jsxs)(m,{type:`button`,variant:`secondary`,className:`shrink-0 whitespace-nowrap`,onClick:B,disabled:V,children:[H,he]}),e[37]=B,e[38]=V,e[39]=H,e[40]=he,e[41]=U):U=e[41];let W;e[42]!==z||e[43]!==U?(W=(0,w.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch`,children:[z,U]}),e[42]=z,e[43]=U,e[44]=W):W=e[44];let G;e[45]===r.urlHint?G=e[46]:(G=(0,w.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.urlHint}),e[45]=r.urlHint,e[46]=G);let K;e[47]!==l||e[48]!==M||e[49]!==r.autoDetectedHint||e[50]!==r.autoDetectedTitle?(K=M&&l?(0,w.jsxs)(`div`,{className:`rounded-lg bg-accent-soft/60 px-3 py-2 text-xs leading-relaxed text-accent-fg`,children:[(0,w.jsx)(`div`,{className:`font-medium`,children:r.autoDetectedTitle}),(0,w.jsx)(`div`,{className:`mt-1 break-all font-mono text-[11px]`,children:l}),(0,w.jsx)(`p`,{className:`mt-1`,children:r.autoDetectedHint})]}):null,e[47]=l,e[48]=M,e[49]=r.autoDetectedHint,e[50]=r.autoDetectedTitle,e[51]=K):K=e[51];let q;e[52]!==b.result||e[53]!==r.probeStatus?(q=b.result?(0,w.jsx)(ue,{result:b.result,labels:r.probeStatus}):null,e[52]=b.result,e[53]=r.probeStatus,e[54]=q):q=e[54];let J;e[55]!==p||e[56]!==j||e[57]!==pe||e[58]!==r.saveAsDefault||e[59]!==r.saving||e[60]!==E.busy?(J=j&&p!==j?(0,w.jsxs)(m,{type:`button`,onClick:()=>void pe(),disabled:E.busy,children:[E.busy?(0,w.jsx)(o,{className:`size-3.5 animate-spin`}):null,E.busy?r.saving:r.saveAsDefault]}):null,e[55]=p,e[56]=j,e[57]=pe,e[58]=r.saveAsDefault,e[59]=r.saving,e[60]=E.busy,e[61]=J):J=e[61];let Y;e[62]!==p||e[63]!==r.clear||e[64]!==E.busy?(Y=p?(0,w.jsx)(m,{type:`button`,variant:`ghost`,onClick:()=>void me(),disabled:E.busy,children:r.clear}):null,e[62]=p,e[63]=r.clear,e[64]=E.busy,e[65]=Y):Y=e[65];let X;e[66]!==J||e[67]!==Y?(X=(0,w.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap`,children:[J,Y]}),e[66]=J,e[67]=Y,e[68]=X):X=e[68];let Z;e[69]===E.error?Z=e[70]:(Z=E.error?(0,w.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:E.error}):null,e[69]=E.error,e[70]=Z);let Q;e[71]===r.certWarning?Q=e[72]:(Q=(0,w.jsx)(`div`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs leading-relaxed text-amber-950 dark:bg-amber-950/30 dark:text-amber-100`,children:r.certWarning}),e[71]=r.certWarning,e[72]=Q);let $;e[73]!==I||e[74]!==W||e[75]!==G||e[76]!==K||e[77]!==q||e[78]!==X||e[79]!==Z||e[80]!==Q?($=(0,w.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[I,W,G,K,q,X,Z,Q]}),e[73]=I,e[74]=W,e[75]=G,e[76]=K,e[77]=q,e[78]=X,e[79]=Z,e[80]=Q,e[81]=$):$=e[81];let ge;return e[82]!==F||e[83]!==$?(ge=(0,w.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,w.jsxs)(ne,{children:[F,$]})}),e[82]=F,e[83]=$,e[84]=ge):ge=e[84],ge}function ce(e){return e.conversationId}function le(e){return e.language}function ue(e){let t=(0,C.c)(18),{result:n,labels:r}=e;if(n.ok){let e;t[0]===r.ok?e=t[1]:(e=(0,w.jsx)(`span`,{className:`font-medium`,children:r.ok}),t[0]=r.ok,t[1]=e);let i;t[2]===n.latencyMs?i=t[3]:(i=(0,w.jsxs)(`span`,{className:`font-mono`,children:[n.latencyMs,`ms`]}),t[2]=n.latencyMs,t[3]=i);let a;t[4]!==r.gatewayReady||t[5]!==n.gatewayReady?(a=n.gatewayReady?(0,w.jsxs)(w.Fragment,{children:[` · `,(0,w.jsx)(`span`,{children:r.gatewayReady})]}):null,t[4]=r.gatewayReady,t[5]=n.gatewayReady,t[6]=a):a=t[6];let o;return t[7]!==e||t[8]!==i||t[9]!==a?(o=(0,w.jsxs)(`div`,{className:`rounded-lg bg-emerald-50 px-3 py-2 text-xs text-emerald-900 dark:bg-emerald-950/30 dark:text-emerald-100`,children:[e,` · `,i,a]}),t[7]=e,t[8]=i,t[9]=a,t[10]=o):o=t[10],o}let i=r[`code_${n.code}`]??r.codeUnknown,a;t[11]===i?a=t[12]:(a=(0,w.jsx)(`span`,{className:`font-medium`,children:i}),t[11]=i,t[12]=a);let o;t[13]===n.message?o=t[14]:(o=n.message?(0,w.jsxs)(w.Fragment,{children:[` — `,(0,w.jsx)(`span`,{className:`font-mono break-all`,children:n.message})]}):null,t[13]=n.message,t[14]=o);let s;return t[15]!==a||t[16]!==o?(s=(0,w.jsxs)(`div`,{className:`rounded-lg bg-red-50 px-3 py-2 text-xs text-red-900 dark:bg-red-950/30 dark:text-red-100`,children:[a,o]}),t[15]=a,t[16]=o,t[17]=s):s=t[17],s}async function de(){let e=await l(f(`/api/device-pairing/readiness`));return{ready:e.ready,routes:e.routes,protocolVersion:e.protocolVersion}}async function fe(e){try{return{kind:`ready`,setup:(await l(f(`/api/device-pairing/setups`),{method:`POST`,body:JSON.stringify({targetKind:e})})).setup}}catch(e){if(e.body?.error?.code===`NO_SECURE_ROUTE`)return{kind:`needs-secure-route`};throw e}}async function pe(e){return l(f(`/api/device-pairing/setups/${encodeURIComponent(e)}`))}async function P(e){await l(f(`/api/device-pairing/setups/${encodeURIComponent(e)}`),{method:`DELETE`})}async function me(e,t){await l(f(`/api/device-pairing/requests/${encodeURIComponent(e.requestId)}/decision`),{method:`POST`,body:JSON.stringify({decision:t,expectedRevision:e.revision})})}async function F(){let e=await d(f(`/api/browser/extension/archive`));if(!e.ok)throw Error(`Browser extension download failed (${e.status})`);let t=e.headers.get(`Content-Disposition`)??``,n=/filename="([^"]+)"/.exec(t)?.[1]??`xopc-browser-extension.zip`,r=URL.createObjectURL(await e.blob());try{let e=document.createElement(`a`);e.href=r,e.download=n,e.click()}finally{URL.revokeObjectURL(r)}}var I=`https://console.xopc.ai/access/client`;function L(e){if(!e||typeof e!=`object`)return;let t=e.body;if(!t||typeof t!=`object`)return;let n=t.error;if(!n||typeof n!=`object`)return;let r=n.code;return typeof r==`string`?r:void 0}function R(e){return[`tunnel_oauth_required`,`invalid_token`,`insufficient_scope`].includes(L(e)??``)}async function z(){return l(f(`/api/tunnel/status`))}async function B(){await l(f(`/api/tunnel/consent`),{method:`POST`,body:JSON.stringify({})})}async function V(){await l(f(`/api/tunnel/registration-key`),{method:`POST`,body:JSON.stringify({})})}async function H(){return l(f(`/api/tunnel/start`),{method:`POST`,body:JSON.stringify({})})}async function he(e){return l(f(`/api/tunnel/stop`),{method:`POST`,body:JSON.stringify({release:e?.release===!0})})}async function U(){let e=(await l(f(`/api/tunnel/reveal-registration-secret`),{method:`POST`,body:JSON.stringify({})})).payload;if(!e)throw Error(`Missing reveal payload`);return{registrationSecret:e.registrationSecret??null,source:e.source===`config`?`config`:`none`}}async function W(e){await l(f(`/api/config`),{method:`PATCH`,body:JSON.stringify({tunnel:e})})}export{N as _,B as a,T as b,he as c,P as d,fe as f,pe as g,de as h,V as i,L as l,F as m,z as n,U as o,me as p,W as r,H as s,I as t,R as u,j as v,E as y};
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"./external-link-DjqjBmc3.js";import{t as a}from"./globe-DSSGFWFn.js";import{t as o}from"./loader-circle-CifKLtgG.js";import{t as s}from"./messages-BHvpZNe9.js";import{t as c}from"./cn-JdwAhgNB.js";import{a as l,c as u,i as d,n as ee,r as f}from"./locale-store-DId6-v2R.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{t as m}from"./button-CS04eWY9.js";import{n as h,r as g}from"./gateway-config-swr-CoRoOG1l.js";import{s as _}from"./form-field-width-DJw_jULe.js";import{t as v}from"./skeleton-BwbyijEw.js";import{t as y}from"./copy-text-row-BHDs3cBa.js";import{$i as b,Uo as x}from"./index-BYNmHn-z.js";import{n as te,t as ne}from"./settings-form-section-exRhP9xn.js";var S=e(t(),1),C=n(),w=r();function T(e){let t=(0,C.c)(10),{language:n,label:r,section:a,className:o}=e,s;t[0]!==n||t[1]!==a?(s=b(n,a),t[0]=n,t[1]=a,t[2]=s):s=t[2];let l;t[3]===o?l=t[4]:(l=c(`inline-flex items-center gap-1 text-sm font-medium text-accent hover:underline`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,o),t[3]=o,t[4]=l);let u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,w.jsx)(i,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[5]=u):u=t[5];let d;return t[6]!==r||t[7]!==s||t[8]!==l?(d=(0,w.jsxs)(`a`,{href:s,target:`_blank`,rel:`noreferrer`,className:l,children:[r,u]}),t[6]=r,t[7]=s,t[8]=l,t[9]=d):d=t[9],d}async function E(){let e=await d(`/api/exposure/status`);if(!e.ok)throw Error(`Failed to load exposure status (${e.status})`);return await e.json()}async function D(e=`serve`){let t=await d(`/api/exposure/tailscale/start`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({mode:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`Start failed (${t.status})`)}return await t.json()}async function O(){let e=await d(`/api/exposure/tailscale/stop`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??`Stop failed (${e.status})`)}return await e.json()}var k=`https://tailscale.com/download`;function A(e){let t=(0,C.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,w.jsx)(`a`,{href:k,target:`_blank`,rel:`noreferrer`,className:`font-medium text-accent hover:underline`,children:n}),t[0]=n,t[1]=r),r}function j({embedded:e=!1}){let t=ee(e=>e.language),n=s(t).remoteAccess.tailscale,r=(0,S.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:s(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]),i=!!u(e=>e.conversationId),[c,l]=(0,S.useState)(!1),[d,f]=(0,S.useState)(null),{data:h,mutate:g,isLoading:_}=p(i?`exposure-status`:null,E,{refreshInterval:3e4}),b=h?.tailscale.hostname,C=h?.tailscale.active===!0,k=h?.tailscale.cliAvailable!==!1,j=b?`https://${b}/`:null,re=(0,S.useCallback)(async()=>{l(!0),f(null);try{await D(`serve`),await g()}catch(e){f(e instanceof Error?e.message:String(e))}finally{l(!1)}},[g]),ie=(0,S.useCallback)(async()=>{l(!0),f(null);try{await O(),await g()}catch(e){f(e instanceof Error?e.message:String(e))}finally{l(!1)}},[g]);if(!i)return null;let M=(0,w.jsxs)(`div`,{className:e?`space-y-4`:`mt-4 space-y-3`,children:[e?(0,w.jsxs)(`ol`,{className:`space-y-3 text-sm text-fg-muted`,children:[(0,w.jsxs)(`li`,{className:`flex gap-2`,children:[(0,w.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`1`}),(0,w.jsxs)(`span`,{children:[n.stepInstallBefore,(0,w.jsx)(A,{label:n.stepInstallLink}),n.stepInstallAfter]})]}),(0,w.jsxs)(`li`,{className:`flex gap-2`,children:[(0,w.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`2`}),(0,w.jsx)(`span`,{children:n.stepEnable})]}),(0,w.jsxs)(`li`,{className:`flex gap-2`,children:[(0,w.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`3`}),(0,w.jsx)(`span`,{children:n.stepCopy})]})]}):null,e&&h?.tailscale.cliAvailable===!1?(0,w.jsxs)(`p`,{className:`rounded-lg bg-amber-500/10 px-3 py-2 text-sm text-fg-muted`,children:[n.cliMissingIntro,` `,(0,w.jsx)(A,{label:n.cliMissingDownloadLink}),n.cliMissingSuffix]}):null,_&&!h?(0,w.jsxs)(`div`,{className:`grid gap-3`,"aria-busy":`true`,children:[(0,w.jsx)(v,{className:`h-20 rounded-lg`}),(0,w.jsx)(v,{className:`h-20 rounded-lg`})]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(ne,{children:[(0,w.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.statusLabel}),(0,w.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:C?n.statusActive:n.statusOff}),j?(0,w.jsx)(`div`,{className:`mt-3`,children:(0,w.jsx)(y,{text:j,labels:r})}):null,d?(0,w.jsx)(`p`,{className:`mt-2 text-sm text-red-600 dark:text-red-400`,children:d}):null,(0,w.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:C?(0,w.jsxs)(m,{type:`button`,variant:`secondary`,disabled:c,onClick:()=>void ie(),children:[c?(0,w.jsx)(o,{className:`mr-1 size-4 animate-spin`}):null,n.disableServe]}):(0,w.jsxs)(m,{type:`button`,disabled:c||!k,onClick:()=>void re(),children:[c?(0,w.jsx)(o,{className:`mr-1 size-4 animate-spin`}):(0,w.jsx)(x,{className:`mr-1 size-4`}),n.enableServe]})})]}),(0,w.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.hint}),(0,w.jsx)(T,{language:t,label:n.docsLink,section:`tailscale-serve`,className:`mt-2`})]})]});return e?M:(0,w.jsxs)(ne,{children:[(0,w.jsx)(te,{icon:a,title:n.title,subtitle:n.subtitle}),M]})}async function re(e){let t=await d(f(`/api/tunnel/probe-public`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:e})});if(!t.ok&&t.status!==400)throw Error(`Probe failed (${t.status})`);return await t.json()}async function ie(e){await l(f(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{publicUrl:e??null}})})}function M(e){let t=e.split(`.`).map(e=>Number.parseInt(e,10));if(t.length!==4||t.some(e=>!Number.isFinite(e)))return!1;let[n,r]=t;return n===10||n===127||n===169&&r===254||n===172&&r>=16&&r<=31||n===192&&r===168||n===100&&r>=64&&r<=127}function ae(){return(0,S.useMemo)(()=>{if(typeof window>`u`)return null;let{protocol:e,hostname:t,origin:n}=window.location;if(e!==`https:`&&e!==`http:`)return null;let r=t.toLowerCase();return!r||r===`localhost`||r===`127.0.0.1`||r===`::1`||r===`[::1]`||r.endsWith(`.local`)||r.endsWith(`.localhost`)||M(r)?null:n.toLowerCase().replace(/\/+$/,``)},[])}function oe(){return c(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,_,`dark:border-edge`)}function se(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e.gateway;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t.publicUrl;return typeof n==`string`&&n.trim()?n.trim():null}function N(){let e=(0,C.c)(85),t=ee(le),n;e[0]===t?n=e[1]:(n=s(t),e[0]=t,e[1]=n);let r=n.remoteAccess.reverseProxy,i=!!u(ce),l=ae(),d=g(i).data?.payload?.config,f;e[2]===d?f=e[3]:(f=se(d),e[2]=d,e[3]=f);let p=f,[_,v]=(0,S.useState)(``),y;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(y={busy:!1,result:null},e[4]=y):y=e[4];let[b,x]=(0,S.useState)(y),T;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(T={busy:!1,error:null},e[5]=T):T=e[5];let[E,D]=(0,S.useState)(T),O,k;e[6]!==p||e[7]!==l||e[8]!==_?(O=()=>{_||(p?v(p):l&&v(l))},k=[p,l,_],e[6]=p,e[7]=l,e[8]=_,e[9]=O,e[10]=k):(O=e[9],k=e[10]),(0,S.useEffect)(O,k);let A;bb0:{let t;e[11]===_?t=e[12]:(t=_.trim(),e[11]=_,e[12]=t);let n=t;if(n){A=n;break bb0}A=p??l??``}let j=A,M=!p&&!!l&&j===l,N;e[13]!==_||e[14]!==j?(N=async()=>{let e=_.trim()||j;if(e){x({busy:!0,result:null});try{x({busy:!1,result:await re(e)})}catch(e){let t=e;x({busy:!1,result:{ok:!1,code:`NETWORK_ERROR`,message:t instanceof Error?t.message:String(t)}})}}},e[13]=_,e[14]=j,e[15]=N):N=e[15];let de=N,fe;e[16]===j?fe=e[17]:(fe=async()=>{let e=j.trim();if(e){D({busy:!0,error:null});try{await ie(e),await h(),D({busy:!1,error:null})}catch(e){let t=e;D({busy:!1,error:t instanceof Error?t.message:String(t)})}}},e[16]=j,e[17]=fe);let pe=fe,P;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(P=async()=>{D({busy:!0,error:null});try{await ie(null),await h(),v(``),x({busy:!1,result:null}),D({busy:!1,error:null})}catch(e){let t=e;D({busy:!1,error:t instanceof Error?t.message:String(t)})}},e[18]=P):P=e[18];let me=P;if(!i)return null;let F;e[19]!==r.subtitle||e[20]!==r.title?(F=(0,w.jsx)(te,{icon:a,title:r.title,subtitle:r.subtitle}),e[19]=r.subtitle,e[20]=r.title,e[21]=F):F=e[21];let I;e[22]===r.urlLabel?I=e[23]:(I=(0,w.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`reverse-proxy-url`,children:r.urlLabel}),e[22]=r.urlLabel,e[23]=I);let L;e[24]===Symbol.for(`react.memo_cache_sentinel`)?(L=c(oe(),`font-mono text-xs sm:flex-1 sm:min-w-0 sm:w-auto`),e[24]=L):L=e[24];let R;e[25]===Symbol.for(`react.memo_cache_sentinel`)?(R=e=>{v(e.target.value),x({busy:!1,result:null})},e[25]=R):R=e[25];let z;e[26]!==_||e[27]!==r.urlPlaceholder||e[28]!==L?(z=(0,w.jsx)(`input`,{id:`reverse-proxy-url`,className:L,type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:r.urlPlaceholder,value:_,onChange:R}),e[26]=_,e[27]=r.urlPlaceholder,e[28]=L,e[29]=z):z=e[29];let B;e[30]===de?B=e[31]:(B=()=>void de(),e[30]=de,e[31]=B);let V;e[32]!==_||e[33]!==b.busy?(V=b.busy||!_.trim(),e[32]=_,e[33]=b.busy,e[34]=V):V=e[34];let H;e[35]===b.busy?H=e[36]:(H=b.busy?(0,w.jsx)(o,{className:`size-3.5 animate-spin`}):null,e[35]=b.busy,e[36]=H);let he=b.busy?r.probing:r.probeButton,U;e[37]!==B||e[38]!==V||e[39]!==H||e[40]!==he?(U=(0,w.jsxs)(m,{type:`button`,variant:`secondary`,className:`shrink-0 whitespace-nowrap`,onClick:B,disabled:V,children:[H,he]}),e[37]=B,e[38]=V,e[39]=H,e[40]=he,e[41]=U):U=e[41];let W;e[42]!==z||e[43]!==U?(W=(0,w.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch`,children:[z,U]}),e[42]=z,e[43]=U,e[44]=W):W=e[44];let G;e[45]===r.urlHint?G=e[46]:(G=(0,w.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.urlHint}),e[45]=r.urlHint,e[46]=G);let K;e[47]!==l||e[48]!==M||e[49]!==r.autoDetectedHint||e[50]!==r.autoDetectedTitle?(K=M&&l?(0,w.jsxs)(`div`,{className:`rounded-lg bg-accent-soft/60 px-3 py-2 text-xs leading-relaxed text-accent-fg`,children:[(0,w.jsx)(`div`,{className:`font-medium`,children:r.autoDetectedTitle}),(0,w.jsx)(`div`,{className:`mt-1 break-all font-mono text-[11px]`,children:l}),(0,w.jsx)(`p`,{className:`mt-1`,children:r.autoDetectedHint})]}):null,e[47]=l,e[48]=M,e[49]=r.autoDetectedHint,e[50]=r.autoDetectedTitle,e[51]=K):K=e[51];let q;e[52]!==b.result||e[53]!==r.probeStatus?(q=b.result?(0,w.jsx)(ue,{result:b.result,labels:r.probeStatus}):null,e[52]=b.result,e[53]=r.probeStatus,e[54]=q):q=e[54];let J;e[55]!==p||e[56]!==j||e[57]!==pe||e[58]!==r.saveAsDefault||e[59]!==r.saving||e[60]!==E.busy?(J=j&&p!==j?(0,w.jsxs)(m,{type:`button`,onClick:()=>void pe(),disabled:E.busy,children:[E.busy?(0,w.jsx)(o,{className:`size-3.5 animate-spin`}):null,E.busy?r.saving:r.saveAsDefault]}):null,e[55]=p,e[56]=j,e[57]=pe,e[58]=r.saveAsDefault,e[59]=r.saving,e[60]=E.busy,e[61]=J):J=e[61];let Y;e[62]!==p||e[63]!==r.clear||e[64]!==E.busy?(Y=p?(0,w.jsx)(m,{type:`button`,variant:`ghost`,onClick:()=>void me(),disabled:E.busy,children:r.clear}):null,e[62]=p,e[63]=r.clear,e[64]=E.busy,e[65]=Y):Y=e[65];let X;e[66]!==J||e[67]!==Y?(X=(0,w.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap`,children:[J,Y]}),e[66]=J,e[67]=Y,e[68]=X):X=e[68];let Z;e[69]===E.error?Z=e[70]:(Z=E.error?(0,w.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:E.error}):null,e[69]=E.error,e[70]=Z);let Q;e[71]===r.certWarning?Q=e[72]:(Q=(0,w.jsx)(`div`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs leading-relaxed text-amber-950 dark:bg-amber-950/30 dark:text-amber-100`,children:r.certWarning}),e[71]=r.certWarning,e[72]=Q);let $;e[73]!==I||e[74]!==W||e[75]!==G||e[76]!==K||e[77]!==q||e[78]!==X||e[79]!==Z||e[80]!==Q?($=(0,w.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[I,W,G,K,q,X,Z,Q]}),e[73]=I,e[74]=W,e[75]=G,e[76]=K,e[77]=q,e[78]=X,e[79]=Z,e[80]=Q,e[81]=$):$=e[81];let ge;return e[82]!==F||e[83]!==$?(ge=(0,w.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,w.jsxs)(ne,{children:[F,$]})}),e[82]=F,e[83]=$,e[84]=ge):ge=e[84],ge}function ce(e){return e.conversationId}function le(e){return e.language}function ue(e){let t=(0,C.c)(18),{result:n,labels:r}=e;if(n.ok){let e;t[0]===r.ok?e=t[1]:(e=(0,w.jsx)(`span`,{className:`font-medium`,children:r.ok}),t[0]=r.ok,t[1]=e);let i;t[2]===n.latencyMs?i=t[3]:(i=(0,w.jsxs)(`span`,{className:`font-mono`,children:[n.latencyMs,`ms`]}),t[2]=n.latencyMs,t[3]=i);let a;t[4]!==r.gatewayReady||t[5]!==n.gatewayReady?(a=n.gatewayReady?(0,w.jsxs)(w.Fragment,{children:[` · `,(0,w.jsx)(`span`,{children:r.gatewayReady})]}):null,t[4]=r.gatewayReady,t[5]=n.gatewayReady,t[6]=a):a=t[6];let o;return t[7]!==e||t[8]!==i||t[9]!==a?(o=(0,w.jsxs)(`div`,{className:`rounded-lg bg-emerald-50 px-3 py-2 text-xs text-emerald-900 dark:bg-emerald-950/30 dark:text-emerald-100`,children:[e,` · `,i,a]}),t[7]=e,t[8]=i,t[9]=a,t[10]=o):o=t[10],o}let i=r[`code_${n.code}`]??r.codeUnknown,a;t[11]===i?a=t[12]:(a=(0,w.jsx)(`span`,{className:`font-medium`,children:i}),t[11]=i,t[12]=a);let o;t[13]===n.message?o=t[14]:(o=n.message?(0,w.jsxs)(w.Fragment,{children:[` — `,(0,w.jsx)(`span`,{className:`font-mono break-all`,children:n.message})]}):null,t[13]=n.message,t[14]=o);let s;return t[15]!==a||t[16]!==o?(s=(0,w.jsxs)(`div`,{className:`rounded-lg bg-red-50 px-3 py-2 text-xs text-red-900 dark:bg-red-950/30 dark:text-red-100`,children:[a,o]}),t[15]=a,t[16]=o,t[17]=s):s=t[17],s}async function de(){let e=await l(f(`/api/device-pairing/readiness`));return{ready:e.ready,routes:e.routes,protocolVersion:e.protocolVersion}}async function fe(e){try{return{kind:`ready`,setup:(await l(f(`/api/device-pairing/setups`),{method:`POST`,body:JSON.stringify({targetKind:e})})).setup}}catch(e){if(e.body?.error?.code===`NO_SECURE_ROUTE`)return{kind:`needs-secure-route`};throw e}}async function pe(e){return l(f(`/api/device-pairing/setups/${encodeURIComponent(e)}`))}async function P(e){await l(f(`/api/device-pairing/setups/${encodeURIComponent(e)}`),{method:`DELETE`})}async function me(e,t){await l(f(`/api/device-pairing/requests/${encodeURIComponent(e.requestId)}/decision`),{method:`POST`,body:JSON.stringify({decision:t,expectedRevision:e.revision})})}async function F(){let e=await d(f(`/api/browser/extension/archive`));if(!e.ok)throw Error(`Browser extension download failed (${e.status})`);let t=e.headers.get(`Content-Disposition`)??``,n=/filename="([^"]+)"/.exec(t)?.[1]??`xopc-browser-extension.zip`,r=URL.createObjectURL(await e.blob());try{let e=document.createElement(`a`);e.href=r,e.download=n,e.click()}finally{URL.revokeObjectURL(r)}}var I=`https://console.xopc.ai/access/client`;function L(e){if(!e||typeof e!=`object`)return;let t=e.body;if(!t||typeof t!=`object`)return;let n=t.error;if(!n||typeof n!=`object`)return;let r=n.code;return typeof r==`string`?r:void 0}function R(e){return[`tunnel_oauth_required`,`invalid_token`,`insufficient_scope`].includes(L(e)??``)}async function z(){return l(f(`/api/tunnel/status`))}async function B(){await l(f(`/api/tunnel/consent`),{method:`POST`,body:JSON.stringify({})})}async function V(){await l(f(`/api/tunnel/registration-key`),{method:`POST`,body:JSON.stringify({})})}async function H(){return l(f(`/api/tunnel/start`),{method:`POST`,body:JSON.stringify({})})}async function he(e){return l(f(`/api/tunnel/stop`),{method:`POST`,body:JSON.stringify({release:e?.release===!0})})}async function U(){let e=(await l(f(`/api/tunnel/reveal-registration-secret`),{method:`POST`,body:JSON.stringify({})})).payload;if(!e)throw Error(`Missing reveal payload`);return{registrationSecret:e.registrationSecret??null,source:e.source===`config`?`config`:`none`}}async function W(e){await l(f(`/api/config`),{method:`PATCH`,body:JSON.stringify({tunnel:e})})}export{N as _,B as a,T as b,he as c,P as d,fe as f,pe as g,de as h,V as i,L as l,F as m,z as n,U as o,me as p,W as r,H as s,I as t,R as u,j as v,E as y};
@@ -1 +1 @@
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"./bot-DjLkhyZL.js";import{t as a}from"./popover-select-BgSdSbCL.js";import{t as o}from"./circle-alert-BEjgurr2.js";import{t as s}from"./messages-CaURu8bb.js";import{a as c,n as l,r as u}from"./locale-store-5sV3dDRG.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{t as f}from"./button-CS04eWY9.js";import{t as p}from"./skeleton-BwbyijEw.js";import{Hs as m,fo as h,nc as g,sc as _}from"./index-C0JT9Ja4.js";import{n as v,r as y}from"./settings-page-layout-X1x-2Cp9.js";var b=e(t(),1),x=n();function S(e){let t=Date.now()+1,n=t-e*24*60*60*1e3;return new URLSearchParams({from:String(n),to:String(t)}).toString()}function C(e){return c(u(`/api/usage/summary?${e}`))}function w(e){return c(u(`/api/usage/events?${e}&limit=50`))}var T=r();function E(e,t){return new Intl.NumberFormat(t===`zh`?`zh-CN`:`en-US`,{notation:`compact`,maximumFractionDigits:1}).format(e)}function D(e){return`$${Number(e).toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:6})}`}function O(e,t){return new Intl.DateTimeFormat(t===`zh`?`zh-CN`:`en-US`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}).format(e)}function k(){let e=(0,x.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,T.jsxs)(`div`,{className:`space-y-4`,"aria-busy":`true`,children:[(0,T.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[0,1,2,3].map(A)}),(0,T.jsx)(p,{className:`h-52 rounded-xl`}),(0,T.jsx)(p,{className:`h-72 rounded-xl`})]}),e[0]=t):t=e[0],t}function A(e){return(0,T.jsx)(p,{className:`h-24 rounded-xl`},e)}function j(){let e=(0,x.c)(82),t=l(N),n;e[0]===t?n=e[1]:(n=s(t),e[0]=t,e[1]=n);let r=n.usage,[c,u]=(0,b.useState)(`7`),p=Number(c),A;e[2]===p?A=e[3]:(A=S(p),e[2]=p,e[3]=A);let j=A,P,F;e[4]===j?(P=e[5],F=e[6]):(P=[`usage-summary`,j],F=()=>C(j),e[4]=j,e[5]=P,e[6]=F);let I=d(P,F),L,R;e[7]===j?(L=e[8],R=e[9]):(L=[`usage-events`,j],R=()=>w(j),e[7]=j,e[8]=L,e[9]=R);let z=d(L,R),B=!I.data&&!I.error||!z.data&&!z.error,V=I.error??z.error,H=I.data?.totals,U;e[10]!==r.reasons.agentAnswer||e[11]!==r.reasons.automationDraft||e[12]!==r.reasons.backgroundReview||e[13]!==r.reasons.continueAfterTool||e[14]!==r.reasons.discussionAnalysis||e[15]!==r.reasons.homeAdvice||e[16]!==r.reasons.imageUnderstanding||e[17]!==r.reasons.noteGeneration||e[18]!==r.reasons.other||e[19]!==r.reasons.sceneExecution||e[20]!==r.reasons.sessionCompaction||e[21]!==r.reasons.sessionSearch||e[22]!==r.reasons.sessionTitle||e[23]!==r.reasons.taskJudging||e[24]!==r.reasons.taskPlanning||e[25]!==r.reasons.textAssist||e[26]!==r.reasons.userModelInterpretation||e[27]!==r.reasons.voiceSelection||e[28]!==r.reasons.voiceSummary||e[29]!==r.reasons.webExtract||e[30]!==r.reasons.workDiscovery||e[31]!==r.reasons.workInvestigation?(U={"usage.reason.agentAnswer":r.reasons.agentAnswer,"usage.reason.continueAfterTool":r.reasons.continueAfterTool,"usage.reason.backgroundReview":r.reasons.backgroundReview,"usage.reason.sessionCompaction":r.reasons.sessionCompaction,"usage.reason.sessionTitle":r.reasons.sessionTitle,"usage.reason.imageUnderstanding":r.reasons.imageUnderstanding,"usage.reason.webExtract":r.reasons.webExtract,"usage.reason.sessionSearch":r.reasons.sessionSearch,"usage.reason.noteGeneration":r.reasons.noteGeneration,"usage.reason.automationDraft":r.reasons.automationDraft,"usage.reason.sceneExecution":r.reasons.sceneExecution,"usage.reason.taskPlanning":r.reasons.taskPlanning,"usage.reason.taskJudging":r.reasons.taskJudging,"usage.reason.voiceSummary":r.reasons.voiceSummary,"usage.reason.voiceSelection":r.reasons.voiceSelection,"usage.reason.homeAdvice":r.reasons.homeAdvice,"usage.reason.workDiscovery":r.reasons.workDiscovery,"usage.reason.workInvestigation":r.reasons.workInvestigation,"usage.reason.discussionAnalysis":r.reasons.discussionAnalysis,"usage.reason.textAssist":r.reasons.textAssist,"usage.reason.userModelInterpretation":r.reasons.userModelInterpretation,"usage.reason.other":r.reasons.other},e[10]=r.reasons.agentAnswer,e[11]=r.reasons.automationDraft,e[12]=r.reasons.backgroundReview,e[13]=r.reasons.continueAfterTool,e[14]=r.reasons.discussionAnalysis,e[15]=r.reasons.homeAdvice,e[16]=r.reasons.imageUnderstanding,e[17]=r.reasons.noteGeneration,e[18]=r.reasons.other,e[19]=r.reasons.sceneExecution,e[20]=r.reasons.sessionCompaction,e[21]=r.reasons.sessionSearch,e[22]=r.reasons.sessionTitle,e[23]=r.reasons.taskJudging,e[24]=r.reasons.taskPlanning,e[25]=r.reasons.textAssist,e[26]=r.reasons.userModelInterpretation,e[27]=r.reasons.voiceSelection,e[28]=r.reasons.voiceSummary,e[29]=r.reasons.webExtract,e[30]=r.reasons.workDiscovery,e[31]=r.reasons.workInvestigation,e[32]=U):U=e[32];let W=U,G;e[33]===r.last7Days?G=e[34]:(G={value:`7`,label:r.last7Days},e[33]=r.last7Days,e[34]=G);let K;e[35]===r.last30Days?K=e[36]:(K={value:`30`,label:r.last30Days},e[35]=r.last30Days,e[36]=K);let q;e[37]===r.last90Days?q=e[38]:(q={value:`90`,label:r.last90Days},e[37]=r.last90Days,e[38]=q);let J;e[39]!==q||e[40]!==G||e[41]!==K?(J=[G,K,q],e[39]=q,e[40]=G,e[41]=K,e[42]=J):J=e[42];let Y;e[43]!==c||e[44]!==r.periodLabel||e[45]!==J?(Y=(0,T.jsx)(`div`,{className:`w-36`,children:(0,T.jsx)(a,{value:c,allowEmpty:!1,ariaLabel:r.periodLabel,placeholder:r.periodLabel,options:J,onChange:u})}),e[43]=c,e[44]=r.periodLabel,e[45]=J,e[46]=Y):Y=e[46];let X;e[47]!==r.subtitle||e[48]!==r.title||e[49]!==Y?(X=(0,T.jsx)(v,{title:r.title,subtitle:r.subtitle,actions:Y}),e[47]=r.subtitle,e[48]=r.title,e[49]=Y,e[50]=X):X=e[50];let Z;e[51]!==V||e[52]!==z||e[53]!==t||e[54]!==B||e[55]!==W||e[56]!==I||e[57]!==r.allCostsUnknown||e[58]!==r.byModel||e[59]!==r.byScenario||e[60]!==r.callUnit||e[61]!==r.calls||e[62]!==r.categories||e[63]!==r.costUnknown||e[64]!==r.empty||e[65]!==r.knownCost||e[66]!==r.loadError||e[67]!==r.reasons.other||e[68]!==r.recentCalls||e[69]!==r.recentCallsHint||e[70]!==r.retry||e[71]!==r.someCostsUnknown||e[72]!==r.status||e[73]!==r.summaryLabel||e[74]!==r.tokens||e[75]!==r.tokensUnknown||e[76]!==r.unknownCosts||e[77]!==H?(Z=B?(0,T.jsx)(k,{}):V?(0,T.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-3 rounded-xl border border-edge bg-surface-inset p-4 text-sm text-fg-muted`,children:[(0,T.jsx)(o,{className:`mt-0.5 size-4 shrink-0 text-danger`,"aria-hidden":!0}),(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`p`,{className:`font-medium text-fg`,children:r.loadError}),(0,T.jsx)(`p`,{className:`mt-1`,children:String(V.message??V)})]}),(0,T.jsx)(f,{variant:`secondary`,onClick:()=>void Promise.all([I.mutate(),z.mutate()]),children:r.retry})]})]}):H?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`section`,{"aria-label":r.summaryLabel,className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[{label:r.knownCost,value:D(H.knownCostUsd),icon:_},{label:r.calls,value:H.calls.toLocaleString(),icon:m},{label:r.tokens,value:E(H.totalTokens,t),icon:g},{label:r.unknownCosts,value:H.unknownCostCalls.toLocaleString(),icon:o}].map(M)}),H.calls>0&&H.costCompleteness!==`complete`?(0,T.jsx)(`p`,{className:`rounded-lg border border-edge bg-surface-inset px-3 py-2 text-xs leading-5 text-fg-muted`,children:H.costCompleteness===`unknown`?r.allCostsUnknown:r.someCostsUnknown}):null,(0,T.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,T.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,T.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r.byScenario}),(0,T.jsx)(`div`,{className:`mt-3 divide-y divide-edge-subtle`,children:I.data?.byCategory.length?I.data.byCategory.map(e=>(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-2.5 text-sm`,children:[(0,T.jsx)(`span`,{className:`min-w-0 truncate text-fg-muted`,title:r.categories[e.key]??e.key,children:r.categories[e.key]??e.key}),(0,T.jsxs)(`span`,{className:`shrink-0 tabular-nums text-fg`,children:[D(e.totals.knownCostUsd),` · `,e.totals.calls,` `,r.callUnit]})]},e.key)):(0,T.jsx)(`p`,{className:`py-5 text-sm text-fg-subtle`,children:r.empty})})]}),(0,T.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,T.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r.byModel}),(0,T.jsx)(`div`,{className:`mt-3 divide-y divide-edge-subtle`,children:I.data?.byModel.length?I.data.byModel.map(e=>(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-2.5 text-sm`,children:[(0,T.jsx)(`span`,{className:`min-w-0 truncate text-fg-muted`,title:e.key,children:e.key}),(0,T.jsxs)(`span`,{className:`shrink-0 tabular-nums text-fg`,children:[D(e.totals.knownCostUsd),` · `,e.totals.calls,` `,r.callUnit]})]},e.key)):(0,T.jsx)(`p`,{className:`py-5 text-sm text-fg-subtle`,children:r.empty})})]})]}),(0,T.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,T.jsxs)(`div`,{className:`border-b border-edge px-4 py-3`,children:[(0,T.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r.recentCalls}),(0,T.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:r.recentCallsHint})]}),(0,T.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:z.data?.items.length?z.data.items.map(e=>(0,T.jsxs)(`article`,{className:`grid gap-2 px-4 py-3 text-sm sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center`,children:[(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,T.jsx)(i,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`truncate font-medium text-fg`,children:W[e.reasonKey]??r.reasons.other})]}),(0,T.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-subtle`,children:[(0,T.jsxs)(`span`,{className:`min-w-0 [overflow-wrap:anywhere]`,children:[e.provider,`/`,e.model]}),(0,T.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,T.jsx)(h,{className:`size-3`,"aria-hidden":!0}),O(e.startedAt,t)]}),(0,T.jsx)(`span`,{children:e.totalTokens===void 0?r.tokensUnknown:`${E(e.totalTokens,t)} tokens`})]})]}),(0,T.jsxs)(`div`,{className:`text-left tabular-nums text-fg sm:text-right`,children:[e.costSource===`unknown`||e.estimatedCostUsd===void 0?r.costUnknown:`≈ ${D(e.estimatedCostUsd)}`,(0,T.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-subtle`,children:r.status[e.status]??e.status})]})]},e.id)):(0,T.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-fg-subtle`,children:r.empty})})]})]}):null,e[51]=V,e[52]=z,e[53]=t,e[54]=B,e[55]=W,e[56]=I,e[57]=r.allCostsUnknown,e[58]=r.byModel,e[59]=r.byScenario,e[60]=r.callUnit,e[61]=r.calls,e[62]=r.categories,e[63]=r.costUnknown,e[64]=r.empty,e[65]=r.knownCost,e[66]=r.loadError,e[67]=r.reasons.other,e[68]=r.recentCalls,e[69]=r.recentCallsHint,e[70]=r.retry,e[71]=r.someCostsUnknown,e[72]=r.status,e[73]=r.summaryLabel,e[74]=r.tokens,e[75]=r.tokensUnknown,e[76]=r.unknownCosts,e[77]=H,e[78]=Z):Z=e[78];let Q;return e[79]!==X||e[80]!==Z?(Q=(0,T.jsxs)(y,{children:[X,Z]}),e[79]=X,e[80]=Z,e[81]=Q):Q=e[81],Q}function M(e){return(0,T.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,T.jsx)(e.icon,{className:`size-4`,"aria-hidden":!0}),e.label]}),(0,T.jsx)(`div`,{className:`mt-2 text-xl font-semibold tabular-nums text-fg`,children:e.value})]},e.label)}function N(e){return e.language}export{j as UsageSettingsPage};
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"./bot-DjLkhyZL.js";import{t as a}from"./popover-select-BgSdSbCL.js";import{t as o}from"./circle-alert-BEjgurr2.js";import{t as s}from"./messages-BHvpZNe9.js";import{a as c,n as l,r as u}from"./locale-store-DId6-v2R.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{t as f}from"./button-CS04eWY9.js";import{t as p}from"./skeleton-BwbyijEw.js";import{Hs as m,fo as h,nc as g,sc as _}from"./index-BYNmHn-z.js";import{n as v,r as y}from"./settings-page-layout-X1x-2Cp9.js";var b=e(t(),1),x=n();function S(e){let t=Date.now()+1,n=t-e*24*60*60*1e3;return new URLSearchParams({from:String(n),to:String(t)}).toString()}function C(e){return c(u(`/api/usage/summary?${e}`))}function w(e){return c(u(`/api/usage/events?${e}&limit=50`))}var T=r();function E(e,t){return new Intl.NumberFormat(t===`zh`?`zh-CN`:`en-US`,{notation:`compact`,maximumFractionDigits:1}).format(e)}function D(e){return`$${Number(e).toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:6})}`}function O(e,t){return new Intl.DateTimeFormat(t===`zh`?`zh-CN`:`en-US`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}).format(e)}function k(){let e=(0,x.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,T.jsxs)(`div`,{className:`space-y-4`,"aria-busy":`true`,children:[(0,T.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[0,1,2,3].map(A)}),(0,T.jsx)(p,{className:`h-52 rounded-xl`}),(0,T.jsx)(p,{className:`h-72 rounded-xl`})]}),e[0]=t):t=e[0],t}function A(e){return(0,T.jsx)(p,{className:`h-24 rounded-xl`},e)}function j(){let e=(0,x.c)(82),t=l(N),n;e[0]===t?n=e[1]:(n=s(t),e[0]=t,e[1]=n);let r=n.usage,[c,u]=(0,b.useState)(`7`),p=Number(c),A;e[2]===p?A=e[3]:(A=S(p),e[2]=p,e[3]=A);let j=A,P,F;e[4]===j?(P=e[5],F=e[6]):(P=[`usage-summary`,j],F=()=>C(j),e[4]=j,e[5]=P,e[6]=F);let I=d(P,F),L,R;e[7]===j?(L=e[8],R=e[9]):(L=[`usage-events`,j],R=()=>w(j),e[7]=j,e[8]=L,e[9]=R);let z=d(L,R),B=!I.data&&!I.error||!z.data&&!z.error,V=I.error??z.error,H=I.data?.totals,U;e[10]!==r.reasons.agentAnswer||e[11]!==r.reasons.automationDraft||e[12]!==r.reasons.backgroundReview||e[13]!==r.reasons.continueAfterTool||e[14]!==r.reasons.discussionAnalysis||e[15]!==r.reasons.homeAdvice||e[16]!==r.reasons.imageUnderstanding||e[17]!==r.reasons.noteGeneration||e[18]!==r.reasons.other||e[19]!==r.reasons.sceneExecution||e[20]!==r.reasons.sessionCompaction||e[21]!==r.reasons.sessionSearch||e[22]!==r.reasons.sessionTitle||e[23]!==r.reasons.taskJudging||e[24]!==r.reasons.taskPlanning||e[25]!==r.reasons.textAssist||e[26]!==r.reasons.userModelInterpretation||e[27]!==r.reasons.voiceSelection||e[28]!==r.reasons.voiceSummary||e[29]!==r.reasons.webExtract||e[30]!==r.reasons.workDiscovery||e[31]!==r.reasons.workInvestigation?(U={"usage.reason.agentAnswer":r.reasons.agentAnswer,"usage.reason.continueAfterTool":r.reasons.continueAfterTool,"usage.reason.backgroundReview":r.reasons.backgroundReview,"usage.reason.sessionCompaction":r.reasons.sessionCompaction,"usage.reason.sessionTitle":r.reasons.sessionTitle,"usage.reason.imageUnderstanding":r.reasons.imageUnderstanding,"usage.reason.webExtract":r.reasons.webExtract,"usage.reason.sessionSearch":r.reasons.sessionSearch,"usage.reason.noteGeneration":r.reasons.noteGeneration,"usage.reason.automationDraft":r.reasons.automationDraft,"usage.reason.sceneExecution":r.reasons.sceneExecution,"usage.reason.taskPlanning":r.reasons.taskPlanning,"usage.reason.taskJudging":r.reasons.taskJudging,"usage.reason.voiceSummary":r.reasons.voiceSummary,"usage.reason.voiceSelection":r.reasons.voiceSelection,"usage.reason.homeAdvice":r.reasons.homeAdvice,"usage.reason.workDiscovery":r.reasons.workDiscovery,"usage.reason.workInvestigation":r.reasons.workInvestigation,"usage.reason.discussionAnalysis":r.reasons.discussionAnalysis,"usage.reason.textAssist":r.reasons.textAssist,"usage.reason.userModelInterpretation":r.reasons.userModelInterpretation,"usage.reason.other":r.reasons.other},e[10]=r.reasons.agentAnswer,e[11]=r.reasons.automationDraft,e[12]=r.reasons.backgroundReview,e[13]=r.reasons.continueAfterTool,e[14]=r.reasons.discussionAnalysis,e[15]=r.reasons.homeAdvice,e[16]=r.reasons.imageUnderstanding,e[17]=r.reasons.noteGeneration,e[18]=r.reasons.other,e[19]=r.reasons.sceneExecution,e[20]=r.reasons.sessionCompaction,e[21]=r.reasons.sessionSearch,e[22]=r.reasons.sessionTitle,e[23]=r.reasons.taskJudging,e[24]=r.reasons.taskPlanning,e[25]=r.reasons.textAssist,e[26]=r.reasons.userModelInterpretation,e[27]=r.reasons.voiceSelection,e[28]=r.reasons.voiceSummary,e[29]=r.reasons.webExtract,e[30]=r.reasons.workDiscovery,e[31]=r.reasons.workInvestigation,e[32]=U):U=e[32];let W=U,G;e[33]===r.last7Days?G=e[34]:(G={value:`7`,label:r.last7Days},e[33]=r.last7Days,e[34]=G);let K;e[35]===r.last30Days?K=e[36]:(K={value:`30`,label:r.last30Days},e[35]=r.last30Days,e[36]=K);let q;e[37]===r.last90Days?q=e[38]:(q={value:`90`,label:r.last90Days},e[37]=r.last90Days,e[38]=q);let J;e[39]!==q||e[40]!==G||e[41]!==K?(J=[G,K,q],e[39]=q,e[40]=G,e[41]=K,e[42]=J):J=e[42];let Y;e[43]!==c||e[44]!==r.periodLabel||e[45]!==J?(Y=(0,T.jsx)(`div`,{className:`w-36`,children:(0,T.jsx)(a,{value:c,allowEmpty:!1,ariaLabel:r.periodLabel,placeholder:r.periodLabel,options:J,onChange:u})}),e[43]=c,e[44]=r.periodLabel,e[45]=J,e[46]=Y):Y=e[46];let X;e[47]!==r.subtitle||e[48]!==r.title||e[49]!==Y?(X=(0,T.jsx)(v,{title:r.title,subtitle:r.subtitle,actions:Y}),e[47]=r.subtitle,e[48]=r.title,e[49]=Y,e[50]=X):X=e[50];let Z;e[51]!==V||e[52]!==z||e[53]!==t||e[54]!==B||e[55]!==W||e[56]!==I||e[57]!==r.allCostsUnknown||e[58]!==r.byModel||e[59]!==r.byScenario||e[60]!==r.callUnit||e[61]!==r.calls||e[62]!==r.categories||e[63]!==r.costUnknown||e[64]!==r.empty||e[65]!==r.knownCost||e[66]!==r.loadError||e[67]!==r.reasons.other||e[68]!==r.recentCalls||e[69]!==r.recentCallsHint||e[70]!==r.retry||e[71]!==r.someCostsUnknown||e[72]!==r.status||e[73]!==r.summaryLabel||e[74]!==r.tokens||e[75]!==r.tokensUnknown||e[76]!==r.unknownCosts||e[77]!==H?(Z=B?(0,T.jsx)(k,{}):V?(0,T.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-3 rounded-xl border border-edge bg-surface-inset p-4 text-sm text-fg-muted`,children:[(0,T.jsx)(o,{className:`mt-0.5 size-4 shrink-0 text-danger`,"aria-hidden":!0}),(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`p`,{className:`font-medium text-fg`,children:r.loadError}),(0,T.jsx)(`p`,{className:`mt-1`,children:String(V.message??V)})]}),(0,T.jsx)(f,{variant:`secondary`,onClick:()=>void Promise.all([I.mutate(),z.mutate()]),children:r.retry})]})]}):H?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`section`,{"aria-label":r.summaryLabel,className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[{label:r.knownCost,value:D(H.knownCostUsd),icon:_},{label:r.calls,value:H.calls.toLocaleString(),icon:m},{label:r.tokens,value:E(H.totalTokens,t),icon:g},{label:r.unknownCosts,value:H.unknownCostCalls.toLocaleString(),icon:o}].map(M)}),H.calls>0&&H.costCompleteness!==`complete`?(0,T.jsx)(`p`,{className:`rounded-lg border border-edge bg-surface-inset px-3 py-2 text-xs leading-5 text-fg-muted`,children:H.costCompleteness===`unknown`?r.allCostsUnknown:r.someCostsUnknown}):null,(0,T.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,T.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,T.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r.byScenario}),(0,T.jsx)(`div`,{className:`mt-3 divide-y divide-edge-subtle`,children:I.data?.byCategory.length?I.data.byCategory.map(e=>(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-2.5 text-sm`,children:[(0,T.jsx)(`span`,{className:`min-w-0 truncate text-fg-muted`,title:r.categories[e.key]??e.key,children:r.categories[e.key]??e.key}),(0,T.jsxs)(`span`,{className:`shrink-0 tabular-nums text-fg`,children:[D(e.totals.knownCostUsd),` · `,e.totals.calls,` `,r.callUnit]})]},e.key)):(0,T.jsx)(`p`,{className:`py-5 text-sm text-fg-subtle`,children:r.empty})})]}),(0,T.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,T.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r.byModel}),(0,T.jsx)(`div`,{className:`mt-3 divide-y divide-edge-subtle`,children:I.data?.byModel.length?I.data.byModel.map(e=>(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-2.5 text-sm`,children:[(0,T.jsx)(`span`,{className:`min-w-0 truncate text-fg-muted`,title:e.key,children:e.key}),(0,T.jsxs)(`span`,{className:`shrink-0 tabular-nums text-fg`,children:[D(e.totals.knownCostUsd),` · `,e.totals.calls,` `,r.callUnit]})]},e.key)):(0,T.jsx)(`p`,{className:`py-5 text-sm text-fg-subtle`,children:r.empty})})]})]}),(0,T.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,T.jsxs)(`div`,{className:`border-b border-edge px-4 py-3`,children:[(0,T.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r.recentCalls}),(0,T.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:r.recentCallsHint})]}),(0,T.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:z.data?.items.length?z.data.items.map(e=>(0,T.jsxs)(`article`,{className:`grid gap-2 px-4 py-3 text-sm sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center`,children:[(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,T.jsx)(i,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`truncate font-medium text-fg`,children:W[e.reasonKey]??r.reasons.other})]}),(0,T.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-subtle`,children:[(0,T.jsxs)(`span`,{className:`min-w-0 [overflow-wrap:anywhere]`,children:[e.provider,`/`,e.model]}),(0,T.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,T.jsx)(h,{className:`size-3`,"aria-hidden":!0}),O(e.startedAt,t)]}),(0,T.jsx)(`span`,{children:e.totalTokens===void 0?r.tokensUnknown:`${E(e.totalTokens,t)} tokens`})]})]}),(0,T.jsxs)(`div`,{className:`text-left tabular-nums text-fg sm:text-right`,children:[e.costSource===`unknown`||e.estimatedCostUsd===void 0?r.costUnknown:`≈ ${D(e.estimatedCostUsd)}`,(0,T.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-subtle`,children:r.status[e.status]??e.status})]})]},e.id)):(0,T.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-fg-subtle`,children:r.empty})})]})]}):null,e[51]=V,e[52]=z,e[53]=t,e[54]=B,e[55]=W,e[56]=I,e[57]=r.allCostsUnknown,e[58]=r.byModel,e[59]=r.byScenario,e[60]=r.callUnit,e[61]=r.calls,e[62]=r.categories,e[63]=r.costUnknown,e[64]=r.empty,e[65]=r.knownCost,e[66]=r.loadError,e[67]=r.reasons.other,e[68]=r.recentCalls,e[69]=r.recentCallsHint,e[70]=r.retry,e[71]=r.someCostsUnknown,e[72]=r.status,e[73]=r.summaryLabel,e[74]=r.tokens,e[75]=r.tokensUnknown,e[76]=r.unknownCosts,e[77]=H,e[78]=Z):Z=e[78];let Q;return e[79]!==X||e[80]!==Z?(Q=(0,T.jsxs)(y,{children:[X,Z]}),e[79]=X,e[80]=Z,e[81]=Q):Q=e[81],Q}function M(e){return(0,T.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,T.jsx)(e.icon,{className:`size-4`,"aria-hidden":!0}),e.label]}),(0,T.jsx)(`div`,{className:`mt-2 text-xl font-semibold tabular-nums text-fg`,children:e.value})]},e.label)}function N(e){return e.language}export{j as UsageSettingsPage};
@@ -1 +1 @@
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"./check-DUBLcKHA.js";import{t as a}from"./circle-alert-BEjgurr2.js";import{t as o}from"./loader-circle-CifKLtgG.js";import{t as s}from"./cn-JdwAhgNB.js";import{n as c}from"./locale-store-5sV3dDRG.js";var l=n(),u=r();function d(e){let t=(0,l.c)(21),{status:n,error:r,className:d}=e,p=c(f)===`zh`;if(n===`idle`)return null;let m=n===`saving`?p?`正在保存…`:`Saving…`:n===`saved`?p?`已自动保存`:`Saved automatically`:n===`error`?r||(p?`自动保存失败`:`Autosave failed`):n===`dirty`?p?`编辑中,将自动保存`:`Editing — autosave pending`:``,h=n===`error`?`text-danger`:n===`saved`?`text-success`:`text-fg-subtle`,g;t[0]!==d||t[1]!==h?(g=s(`inline-flex min-w-0 items-center gap-1.5 text-xs`,h,d),t[0]=d,t[1]=h,t[2]=g):g=t[2];let _;t[3]===n?_=t[4]:(_=n===`saving`?(0,u.jsx)(o,{className:`size-3.5 shrink-0 animate-spin`,"aria-hidden":!0}):null,t[3]=n,t[4]=_);let v;t[5]===n?v=t[6]:(v=n===`saved`?(0,u.jsx)(i,{className:`size-3.5 shrink-0`,"aria-hidden":!0}):null,t[5]=n,t[6]=v);let y;t[7]===n?y=t[8]:(y=n===`error`?(0,u.jsx)(a,{className:`size-3.5 shrink-0`,"aria-hidden":!0}):null,t[7]=n,t[8]=y);let b;t[9]===n?b=t[10]:(b=n===`dirty`?(0,u.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-current`,"aria-hidden":!0}):null,t[9]=n,t[10]=b);let x;t[11]===m?x=t[12]:(x=(0,u.jsx)(`span`,{className:`truncate`,children:m}),t[11]=m,t[12]=x);let S;return t[13]!==m||t[14]!==g||t[15]!==_||t[16]!==v||t[17]!==y||t[18]!==b||t[19]!==x?(S=(0,u.jsxs)(`span`,{className:g,role:`status`,"aria-live":`polite`,title:m,children:[_,v,y,b,x]}),t[13]=m,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b,t[19]=x,t[20]=S):S=t[20],S}function f(e){return e.language}var p=e(t(),1);function m({value:e,dirty:t,onSave:n,enabled:r=!0,delayMs:i=700,validate:a,serialize:o=JSON.stringify}){let[s,c]=(0,p.useState)(`idle`),[l,u]=(0,p.useState)(null),d=(0,p.useRef)(e),f=(0,p.useRef)(n),m=(0,p.useRef)(a),h=(0,p.useRef)(o),g=(0,p.useRef)(null),_=(0,p.useRef)(!1),v=(0,p.useRef)(null),y=(0,p.useRef)(null),b=(0,p.useRef)(null),x=(0,p.useRef)(!0);d.current=e,f.current=n,m.current=a,h.current=o;let S=(0,p.useCallback)(()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null)},[]),C=(0,p.useCallback)(async e=>{S();let t=h.current(e);b.current=t;let n=m.current?.(e)??null;if(n){u(n),c(`error`);return}if(_.current){v.current=e;return}_.current=!0,u(null),c(`saving`);try{await f.current(e),y.current=t,x.current&&c(`saved`)}catch(e){x.current&&(u(e instanceof Error?e.message:String(e)),c(`error`))}finally{_.current=!1;let e=v.current;v.current=null,e&&h.current(e)!==y.current&&C(e)}},[S]),w=(0,p.useCallback)(()=>{let e=d.current;!r||!t||e===null||C(e)},[t,r,C]),T=(0,p.useCallback)(e=>{let t=e??d.current;!r||t===null||C(t)},[r,C]);return(0,p.useEffect)(()=>{if(!r||!t||e===null){S(),!t&&s===`dirty`&&c(`idle`);return}let n=o(e);if(n!==y.current&&!(s===`error`&&n===b.current))return c(e=>e===`saving`?e:`dirty`),S(),g.current=window.setTimeout(()=>void C(e),i),S},[S,i,t,r,C,o,s,e]),(0,p.useEffect)(()=>(x.current=!0,()=>{x.current=!1,S()}),[S]),(0,p.useEffect)(()=>{if(s!==`saved`)return;let e=window.setTimeout(()=>c(`idle`),1600);return()=>window.clearTimeout(e)},[s]),{status:s,error:l,flush:w,saveNow:T,retry:w,onBlurCapture:w}}export{d as n,m as t};
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"./check-DUBLcKHA.js";import{t as a}from"./circle-alert-BEjgurr2.js";import{t as o}from"./loader-circle-CifKLtgG.js";import{t as s}from"./cn-JdwAhgNB.js";import{n as c}from"./locale-store-DId6-v2R.js";var l=n(),u=r();function d(e){let t=(0,l.c)(21),{status:n,error:r,className:d}=e,p=c(f)===`zh`;if(n===`idle`)return null;let m=n===`saving`?p?`正在保存…`:`Saving…`:n===`saved`?p?`已自动保存`:`Saved automatically`:n===`error`?r||(p?`自动保存失败`:`Autosave failed`):n===`dirty`?p?`编辑中,将自动保存`:`Editing — autosave pending`:``,h=n===`error`?`text-danger`:n===`saved`?`text-success`:`text-fg-subtle`,g;t[0]!==d||t[1]!==h?(g=s(`inline-flex min-w-0 items-center gap-1.5 text-xs`,h,d),t[0]=d,t[1]=h,t[2]=g):g=t[2];let _;t[3]===n?_=t[4]:(_=n===`saving`?(0,u.jsx)(o,{className:`size-3.5 shrink-0 animate-spin`,"aria-hidden":!0}):null,t[3]=n,t[4]=_);let v;t[5]===n?v=t[6]:(v=n===`saved`?(0,u.jsx)(i,{className:`size-3.5 shrink-0`,"aria-hidden":!0}):null,t[5]=n,t[6]=v);let y;t[7]===n?y=t[8]:(y=n===`error`?(0,u.jsx)(a,{className:`size-3.5 shrink-0`,"aria-hidden":!0}):null,t[7]=n,t[8]=y);let b;t[9]===n?b=t[10]:(b=n===`dirty`?(0,u.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-current`,"aria-hidden":!0}):null,t[9]=n,t[10]=b);let x;t[11]===m?x=t[12]:(x=(0,u.jsx)(`span`,{className:`truncate`,children:m}),t[11]=m,t[12]=x);let S;return t[13]!==m||t[14]!==g||t[15]!==_||t[16]!==v||t[17]!==y||t[18]!==b||t[19]!==x?(S=(0,u.jsxs)(`span`,{className:g,role:`status`,"aria-live":`polite`,title:m,children:[_,v,y,b,x]}),t[13]=m,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b,t[19]=x,t[20]=S):S=t[20],S}function f(e){return e.language}var p=e(t(),1);function m({value:e,dirty:t,onSave:n,enabled:r=!0,delayMs:i=700,validate:a,serialize:o=JSON.stringify}){let[s,c]=(0,p.useState)(`idle`),[l,u]=(0,p.useState)(null),d=(0,p.useRef)(e),f=(0,p.useRef)(n),m=(0,p.useRef)(a),h=(0,p.useRef)(o),g=(0,p.useRef)(null),_=(0,p.useRef)(!1),v=(0,p.useRef)(null),y=(0,p.useRef)(null),b=(0,p.useRef)(null),x=(0,p.useRef)(!0);d.current=e,f.current=n,m.current=a,h.current=o;let S=(0,p.useCallback)(()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null)},[]),C=(0,p.useCallback)(async e=>{S();let t=h.current(e);b.current=t;let n=m.current?.(e)??null;if(n){u(n),c(`error`);return}if(_.current){v.current=e;return}_.current=!0,u(null),c(`saving`);try{await f.current(e),y.current=t,x.current&&c(`saved`)}catch(e){x.current&&(u(e instanceof Error?e.message:String(e)),c(`error`))}finally{_.current=!1;let e=v.current;v.current=null,e&&h.current(e)!==y.current&&C(e)}},[S]),w=(0,p.useCallback)(()=>{let e=d.current;!r||!t||e===null||C(e)},[t,r,C]),T=(0,p.useCallback)(e=>{let t=e??d.current;!r||t===null||C(t)},[r,C]);return(0,p.useEffect)(()=>{if(!r||!t||e===null){S(),!t&&s===`dirty`&&c(`idle`);return}let n=o(e);if(n!==y.current&&!(s===`error`&&n===b.current))return c(e=>e===`saving`?e:`dirty`),S(),g.current=window.setTimeout(()=>void C(e),i),S},[S,i,t,r,C,o,s,e]),(0,p.useEffect)(()=>(x.current=!0,()=>{x.current=!1,S()}),[S]),(0,p.useEffect)(()=>{if(s!==`saved`)return;let e=window.setTimeout(()=>c(`idle`),1600);return()=>window.clearTimeout(e)},[s]),{status:s,error:l,flush:w,saveNow:T,retry:w,onBlurCapture:w}}export{d as n,m as t};
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/attachment-load-qjPpQzYY.js","assets/attachment-utils-core-BIOUBrpT.js"])))=>i.map(i=>d[i]);
2
- 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"./preload-helper-zJ_50EbN.js";import{t as a}from"./createLucideIcon-DPHK1VkS.js";import{t as o}from"./mic-CuUb7zc-.js";import{m as s,n as c,o as l,t as u}from"./use-file-preview-expanded-J3HnG8OH.js";import{n as d}from"./share-link-dialog-ZOdnHkmb.js";import{t as f}from"./messages-CaURu8bb.js";import{t as p}from"./cn-JdwAhgNB.js";import{a as m,n as h,r as g}from"./locale-store-5sV3dDRG.js";import{o as _,r as v,s as y,t as b}from"./dist-BGTk37IG.js";import{r as x,t as S}from"./constants-Dy8Gw0sF.js";import{r as C}from"./tasks-CH6KoBeY.js";import{a as w,i as T,o as E}from"./capabilities-RMlKKfGF.js";import{t as D}from"./capabilities-CngwB2JU.js";import{n as O}from"./interaction-BdhHBbYa.js";import{r as k}from"./attachment-utils-core-BIOUBrpT.js";import{n as A}from"./electron-env-Dit0bHgy.js";import{i as j}from"./skill-wire-pattern-BPpeIcCi.js";import{a as M}from"./shares-api-T5gR8yqz.js";var N=a(`file-code-corner`,[[`path`,{d:`M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35`,key:`1wthlu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m5 16-3 3 3 3`,key:`331omg`}],[`path`,{d:`m9 22 3-3-3-3`,key:`lsp7cz`}]]),P=a(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]);async function F(e){return C.parse(await m(g(`/api/tasks`),{method:`POST`,body:JSON.stringify(e)}))}async function I(e){return D(`xopc.tasks.get`,{id:e})}async function L(e){return m(g(`/api/tasks/${encodeURIComponent(e)}/conversation`),{method:`POST`})}async function R(e,t,n){return await m(g(`/api/tasks/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({...t,expectedVersion:n})}),I(e)}async function z(e){await m(g(`/api/tasks/${encodeURIComponent(e)}`),{method:`DELETE`})}async function B(e,t,n,r=crypto.randomUUID()){return await m(g(`/api/tasks/${encodeURIComponent(e)}/commands`),{method:`POST`,body:JSON.stringify({idempotencyKey:r,expectedVersion:n,command:t})}),I(e)}async function V(e,t,n,r,i){return await m(g(`/api/tasks/${encodeURIComponent(e)}/criteria/${t}/review`),{method:`PUT`,body:JSON.stringify({status:n,expectedVersion:r,contractVersion:i})}),I(e)}async function H(e,t,n){return await m(g(`/api/task-runs/${encodeURIComponent(t)}/cancel`),{method:`POST`,body:JSON.stringify({expectedVersion:n,reason:`Cancelled by user`})}),I(e)}async function U(e,t,n){return await m(g(`/api/tasks/${encodeURIComponent(e)}/handoff`),{method:`POST`,body:JSON.stringify({toAgentId:t,expectedVersion:n,idempotencyKey:crypto.randomUUID()})}),I(e)}async function ee(e,t,n){return await m(g(`/api/tasks/${encodeURIComponent(e)}/dependencies`),{method:`PUT`,body:JSON.stringify({dependsOnTaskIds:t,expectedVersion:n})}),I(e)}async function te(e,t,n){return await m(g(`/api/tasks/${encodeURIComponent(e)}/board-position`),{method:`PUT`,body:JSON.stringify({beforeTaskId:t,expectedVersion:n})}),I(e)}async function ne(e,t,n){await m(g(`/api/task-runs/${encodeURIComponent(e)}/feedback`),{method:`POST`,headers:{"idempotency-key":crypto.randomUUID()},body:JSON.stringify({rating:t,reason:n?.trim()||void 0})})}function re(e){return m(g(`/api/home${e?`?locale=${encodeURIComponent(e)}`:``}`)).then(E)}function ie(e){return m(g(`/api/home/advisor/refresh`),{method:`POST`,body:JSON.stringify({idempotencyKey:crypto.randomUUID(),locale:e})})}function ae(){return m(g(`/api/home/advisor/history`)).then(e=>w.parse(e))}async function oe(e,t){return T.parse(await m(g(`/api/home/opportunities/${encodeURIComponent(e.id)}/action`),{method:`POST`,body:JSON.stringify({idempotencyKey:crypto.randomUUID(),expectedRevision:e.revision,mode:t})}))}function W(e,t){let n=crypto.randomUUID();return m(g(`/api/home/opportunities/${encodeURIComponent(e.id)}/feedback`),{method:`POST`,body:JSON.stringify({...t,idempotencyKey:n,expectedRevision:e.revision})}).then(()=>({ok:!0,idempotencyKey:n}))}function G(e,t){return m(g(`/api/home/opportunities/${encodeURIComponent(e)}/feedback/undo`),{method:`POST`,body:JSON.stringify({idempotencyKey:t})})}function K(e,t){return m(g(`/api/home/decisions/respond`),{method:`POST`,body:JSON.stringify({...e,decision:t})})}function se(e){return m(g(`/api/home/attention/acknowledge`),{method:`POST`,body:JSON.stringify(e)})}function ce(e){return m(g(`/api/home/attention/retry`),{method:`POST`,body:JSON.stringify(e)})}function le(e,t){let n=e.trim(),r=t.trim();return n&&j(n)?`/skill:${n}${r?` ${r}`:` `}`:r||null}function ue(e,t,n){let r=e.trim(),i=t?.trim()??``;if(!r&&!i)return null;let a=new URLSearchParams;return r&&a.set(`draft`,r),a.set(`autoSend`,`1`),i&&a.set(`attachmentsHandoff`,i),n?.projectScope===`none`&&a.set(`projectScope`,`none`),`/chat/new?${a.toString()}`}function de(e){let t=e.startsWith(`?`)?e.slice(1):e;if(!t)return``;let n=new URLSearchParams(t),r=new URLSearchParams,i=n.get(`skill`),a=n.get(`slash`),o=n.get(`draft`),s=n.get(`autoSend`),c=n.get(`attachmentHandoff`),l=n.get(`attachmentsHandoff`),u=n.get(`agentSetup`);i&&r.set(`skill`,i),a&&r.set(`slash`,a),o&&r.set(`draft`,o),s===`1`&&r.set(`autoSend`,`1`),c&&r.set(`attachmentHandoff`,c),l&&r.set(`attachmentsHandoff`,l),u===`1`&&r.set(`agentSetup`,`1`),n.get(`scene`)===`find-skills`&&r.set(`scene`,`find-skills`);let d=r.toString();return d?`?${d}`:``}function fe(e){let t=e.startsWith(`?`)?e.slice(1):e,n=new URLSearchParams(t),r=n.get(`projectId`)?.trim();return r?{kind:`project`,projectId:r}:n.get(`projectScope`)===`none`?{kind:`none`}:{kind:`remember-last`}}function pe(e){let t=e?.trim();return t?`/chat/new?projectId=${encodeURIComponent(t)}`:`/chat/new?projectScope=none`}var q=n(),J=e(t(),1);function Y(){let[e,t]=(0,J.useState)(!1),[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(null),u=(0,J.useCallback)(e=>{t(!0),l(e),a(null),s(null)},[]),d=(0,J.useCallback)(async e=>{if(!c||n)return null;r(!0),s(null);try{let t=await M({...c,...e});return a(t.payload),t.payload}catch(e){return s(e instanceof Error?e.message:String(e)),null}finally{r(!1)}},[n,c]),f=(0,J.useCallback)(()=>{a(null),s(null),r(!1),l(null)},[]);return{dialogOpen:e,loading:n,result:i,error:o,pendingParams:c,createShareLink:u,confirmShareLink:d,handleOpenChange:(0,J.useCallback)(e=>{t(e),e||f()},[f])}}function me(){return A()&&window.electronAPI?.platform===`darwin`}function X(){return A()&&window.electronAPI?.platform===`win32`}function Z(){return X()?`windows-preview-viewport`:``}var Q=r();function $({open:e,attachment:t,authToken:n,conversationId:r,layerClassName:i=`z-[81]`,onClose:a}){let o=h(e=>e.language),m=f(o).chat,g=l({open:e,attachment:t,authToken:n,conversationId:r,language:o}),S=Y(),{expanded:C,setExpanded:w}=u(e,S.dialogOpen),[T,E]=(0,J.useState)(!1),{preview:D,fileType:k,hasExtractedText:j}=g,M=k!==`image`&&k!==`text`&&k!==`pptx`&&j,N=D?.uri?x(D.uri):null,P=!!(N||D?.uri?.startsWith(`media://`)&&(r||D.taskId)),F=()=>{!D?.uri||!P||S.createShareLink(N?{fileId:N,fileName:D.name}:{uri:D.uri,conversationId:r??void 0,taskId:D.taskId,fileName:D.name})},I=!!(D&&!g.loading&&!g.loadError),L=()=>{w(!1),a()},R=()=>{if(!D||!g.downloadBuffer)return;let e=new Blob([g.downloadBuffer],{type:g.descriptor.mimeType}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=D.name??`download`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)},z=!!g.downloadBuffer,B=A()&&k===`spreadsheet`&&/\.xlsx?$/i.test(g.fileName)&&!!g.downloadBuffer&&!!window.electronAPI?.shell?.openTemporaryFile,V=async()=>{let e=g.downloadBuffer,t=window.electronAPI?.shell?.openTemporaryFile;if(!(!e||!t||T)){E(!0);try{(await t({fileName:g.fileName,data:new Uint8Array(e)})).ok||s(`warning`,m.attachmentPreviewOpenLocalFailed)}catch{s(`warning`,m.attachmentPreviewOpenLocalFailed)}finally{E(!1)}}},H={onDownload:R,canDownload:z},U=p(`min-h-0 min-w-0 flex-1 cursor-pointer border-0 p-0`,`bg-surface-base transition-colors`,`hover:bg-surface-hover/90 dark:bg-black/60 dark:hover:bg-black/70`,O.focusRingBase);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(b,{open:e,onOpenChange:e=>!e&&L(),children:(0,Q.jsx)(_,{children:(0,Q.jsxs)(v,{"aria-describedby":void 0,className:p(`xopc-dialog-content-fullscreen fixed inset-0 flex h-[100dvh] w-full flex-row overflow-hidden`,Z(),i,`border-0 bg-transparent p-0 shadow-none outline-none`),children:[(0,Q.jsx)(y,{className:`sr-only`,children:D?.name??``}),(0,Q.jsx)(`button`,{type:`button`,className:U,onClick:L,"aria-label":m.attachmentPreviewClose}),(0,Q.jsx)(`div`,{className:p(`flex h-full min-h-0 shrink-0 flex-col overflow-hidden`,C?`w-full`:`w-[min(100%,var(--max-width-app-main))]`,`bg-surface-panel sm:border-x sm:border-edge dark:sm:border-edge`,`shadow-float dark:shadow-elevated`),children:(0,Q.jsx)(c,{header:{expanded:C,onToggleExpanded:I?()=>w(e=>!e):void 0,onClose:L,share:P?{onClick:F,loading:S.loading}:void 0,openWithSystemApp:B?{onClick:()=>void V(),loading:T}:void 0,textView:M?{active:g.showExtractedText,onChange:e=>{g.setShowExtractedText(e),g.clearLoadError()}}:void 0},chat:g.downloadBuffer?{conversationId:r,createFile:async()=>new File([g.downloadBuffer],g.fileName,{type:g.descriptor.mimeType})}:void 0,language:o,descriptor:g.descriptor,loading:g.loading,loadError:g.loadError,textContent:g.textContent,binaryBuffer:g.binaryBuffer,showExtractedText:g.showExtractedText,extractedText:g.extractedText,extractedTextTruncated:g.extractedTextTruncated,actions:H})}),(0,Q.jsx)(`button`,{type:`button`,className:U,onClick:L,"aria-label":m.attachmentPreviewClose})]})})}),(0,Q.jsx)(d,{open:S.dialogOpen,onOpenChange:S.handleOpenChange,loading:S.loading,error:S.error,result:S.result,pendingParams:S.pendingParams,onConfirm:e=>void S.confirmShareLink(e)})]})}function he(e){let t=(0,q.c)(23),{attachments:n,conversationId:r,topPadded:i,onRemove:a,className:s}=e,c=h(ge),l;t[0]===c?l=t[1]:(l=f(c),t[0]=c,t[1]=l);let u=l.chat,[d,m]=(0,J.useState)(null);if(n.length===0)return null;let g=i?`pt-2`:`pt-3`,_;t[2]!==s||t[3]!==g?(_=p(`flex flex-wrap gap-2 border-b border-edge-subtle/90 bg-surface-hover/20 px-4 pb-2 dark:border-edge-subtle`,g,s),t[2]=s,t[3]=g,t[4]=_):_=t[4];let v;if(t[5]!==n||t[6]!==u||t[7]!==a){let e;t[9]!==u||t[10]!==a?(e=(e,t)=>{let n=e.type===`pasted_text`?u.pastedText:e.name;return(0,Q.jsxs)(`div`,{className:`flex max-w-[200px] items-center rounded-lg bg-surface-hover text-xs dark:bg-surface-hover/80`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:p(`flex min-w-0 flex-1 items-center gap-1.5 rounded-l-lg py-1 pl-2 pr-1 text-left hover:bg-surface-active`,O.transition,O.press,O.focusRingPanel),onClick:()=>m(e),"aria-label":`${u.attachmentPreviewOpen}: ${n}`,title:`${u.attachmentPreviewOpen}: ${n}`,children:[e.mimeType?.startsWith(`image/`)&&e.content?(0,Q.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.content}`,alt:``,className:`size-6 shrink-0 rounded object-cover`}):e.type===`voice`||e.mimeType?.startsWith(`audio/`)?(0,Q.jsx)(o,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):e.type===`pasted_text`?(0,Q.jsx)(N,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):(0,Q.jsx)(P,{className:`size-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n}),(0,Q.jsx)(`span`,{className:`shrink-0 text-fg-disabled`,children:k(e.size)})]}),(0,Q.jsx)(`button`,{type:`button`,className:p(`flex min-h-8 min-w-8 items-center justify-center rounded-r-lg text-fg-muted hover:bg-surface-active hover:text-fg`,O.transition,O.press,O.focusRingPanel),onClick:()=>a(t),"aria-label":`${u.attachmentPreviewRemove}: ${n}`,title:`${u.attachmentPreviewRemove}: ${n}`,children:(0,Q.jsx)(`span`,{"aria-hidden":!0,children:`×`})})]},e.id??`${e.name}-${e.size}-${e.mimeType}-${e.content?.slice(0,16)??``}`)},t[9]=u,t[10]=a,t[11]=e):e=t[11],v=n.map(e),t[5]=n,t[6]=u,t[7]=a,t[8]=v}else v=t[8];let y;t[12]!==_||t[13]!==v?(y=(0,Q.jsx)(`div`,{className:_,children:v}),t[12]=_,t[13]=v,t[14]=y):y=t[14];let b=d!==null,x;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>m(null),t[15]=x):x=t[15];let S;t[16]!==r||t[17]!==d||t[18]!==b?(S=(0,Q.jsx)($,{open:b,attachment:d,conversationId:r,onClose:x}),t[16]=r,t[17]=d,t[18]=b,t[19]=S):S=t[19];let C;return t[20]!==y||t[21]!==S?(C=(0,Q.jsxs)(Q.Fragment,{children:[y,S]}),t[20]=y,t[21]=S,t[22]=C):C=t[22],C}function ge(e){return e.language}function _e(e){let{chat:t,initialAttachments:n=[],onAttachmentsChange:r}=e,[a,o]=(0,J.useState)(n),[c,l]=(0,J.useState)(!1),u=(0,J.useRef)(null),d=(0,J.useRef)(a),f=(0,J.useRef)(r);d.current=a,f.current=r;let p=(0,J.useCallback)(e=>{let t=typeof e==`function`?e(d.current):e;d.current=t,o(t),f.current?.(t)},[]),m=(0,J.useCallback)(()=>{p([])},[]),h=(0,J.useCallback)(e=>{p(t=>t.filter((t,n)=>n!==e))},[]),g=(0,J.useCallback)(()=>d.current.map(e=>({type:e.type===`voice`?`voice`:e.type||`file`,mimeType:e.mimeType,data:e.content,name:e.name,size:e.size,...e.uri?{uri:e.uri}:{},...typeof e.durationSeconds==`number`&&Number.isFinite(e.durationSeconds)&&e.durationSeconds>0?{durationSeconds:e.durationSeconds}:{}})),[]),_=(0,J.useCallback)(async(e,n)=>{if(e.length===0)return;let r=10-d.current.length;if(r<=0){s(`warning`,t.maxAttachmentsReached,{max:10});return}let a=e.slice(0,r);e.length>a.length&&s(`warning`,t.maxAttachmentsTruncated,{max:10,dropped:e.length-a.length});let{loadAttachment:o}=await i(async()=>{let{loadAttachment:e}=await import(`./attachment-load-qjPpQzYY.js`);return{loadAttachment:e}},__vite__mapDeps([0,1])),c=(await Promise.all(a.map(async e=>{if(e.size>33554432)return s(`warning`,t.attachmentFileTooLarge,{name:e.name,maxSize:k(S)}),null;try{return await o(e,e.name)}catch{return s(`error`,t.attachmentLoadFailed,{name:e.name}),null}}))).filter(e=>e!==null).map(e=>n?{...e,type:n}:e);p(e=>[...e,...c])},[t.attachmentFileTooLarge,t.attachmentLoadFailed,t.maxAttachmentsReached,t.maxAttachmentsTruncated]);return{attachments:a,setAttachments:p,attachmentsRef:d,isDragging:c,setIsDragging:l,fileInputRef:u,processFiles:(0,J.useCallback)(e=>_(e),[_]),processPastedText:(0,J.useCallback)(e=>_([new File([e.text],e.name,{type:e.mimeType})],`pasted_text`),[_]),removeAttachment:h,clearAttachments:m,wireAttachmentsPayload:g}}export{G as A,U as C,V as D,ce as E,N as F,te as M,ee as N,W as O,P,I as S,K as T,F as _,me as a,re as b,le as c,fe as d,de as f,B as g,H as h,Z as i,R as j,ne as k,ue as l,oe as m,he as n,X as o,se as p,$ as r,Y as s,_e as t,pe as u,z as v,ie as w,ae as x,L as y};
2
+ 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"./preload-helper-zJ_50EbN.js";import{t as a}from"./createLucideIcon-DPHK1VkS.js";import{t as o}from"./mic-CuUb7zc-.js";import{m as s,n as c,o as l,t as u}from"./use-file-preview-expanded-Bope6MW6.js";import{n as d}from"./share-link-dialog-TBBGJPfT.js";import{t as f}from"./messages-BHvpZNe9.js";import{t as p}from"./cn-JdwAhgNB.js";import{a as m,n as h,r as g}from"./locale-store-DId6-v2R.js";import{o as _,r as v,s as y,t as b}from"./dist-BGTk37IG.js";import{r as x,t as S}from"./constants-Dy8Gw0sF.js";import{r as C}from"./tasks-CH6KoBeY.js";import{a as w,i as T,o as E}from"./capabilities-CT_ZW9fT.js";import{t as D}from"./capabilities-BKu9BqPe.js";import{n as O}from"./interaction-BdhHBbYa.js";import{r as k}from"./attachment-utils-core-BIOUBrpT.js";import{n as A}from"./electron-env-Dit0bHgy.js";import{i as j}from"./skill-wire-pattern-BPpeIcCi.js";import{a as M}from"./shares-api-DU0fHP2G.js";var N=a(`file-code-corner`,[[`path`,{d:`M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35`,key:`1wthlu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m5 16-3 3 3 3`,key:`331omg`}],[`path`,{d:`m9 22 3-3-3-3`,key:`lsp7cz`}]]),P=a(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]);async function F(e){return C.parse(await m(g(`/api/tasks`),{method:`POST`,body:JSON.stringify(e)}))}async function I(e){return D(`xopc.tasks.get`,{id:e})}async function L(e){return m(g(`/api/tasks/${encodeURIComponent(e)}/conversation`),{method:`POST`})}async function R(e,t,n){return await m(g(`/api/tasks/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({...t,expectedVersion:n})}),I(e)}async function z(e){await m(g(`/api/tasks/${encodeURIComponent(e)}`),{method:`DELETE`})}async function B(e,t,n,r=crypto.randomUUID()){return await m(g(`/api/tasks/${encodeURIComponent(e)}/commands`),{method:`POST`,body:JSON.stringify({idempotencyKey:r,expectedVersion:n,command:t})}),I(e)}async function V(e,t,n,r,i){return await m(g(`/api/tasks/${encodeURIComponent(e)}/criteria/${t}/review`),{method:`PUT`,body:JSON.stringify({status:n,expectedVersion:r,contractVersion:i})}),I(e)}async function H(e,t,n){return await m(g(`/api/task-runs/${encodeURIComponent(t)}/cancel`),{method:`POST`,body:JSON.stringify({expectedVersion:n,reason:`Cancelled by user`})}),I(e)}async function U(e,t,n){return await m(g(`/api/tasks/${encodeURIComponent(e)}/handoff`),{method:`POST`,body:JSON.stringify({toAgentId:t,expectedVersion:n,idempotencyKey:crypto.randomUUID()})}),I(e)}async function ee(e,t,n){return await m(g(`/api/tasks/${encodeURIComponent(e)}/dependencies`),{method:`PUT`,body:JSON.stringify({dependsOnTaskIds:t,expectedVersion:n})}),I(e)}async function te(e,t,n){return await m(g(`/api/tasks/${encodeURIComponent(e)}/board-position`),{method:`PUT`,body:JSON.stringify({beforeTaskId:t,expectedVersion:n})}),I(e)}async function ne(e,t,n){await m(g(`/api/task-runs/${encodeURIComponent(e)}/feedback`),{method:`POST`,headers:{"idempotency-key":crypto.randomUUID()},body:JSON.stringify({rating:t,reason:n?.trim()||void 0})})}function re(e){return m(g(`/api/home${e?`?locale=${encodeURIComponent(e)}`:``}`)).then(E)}function ie(e){return m(g(`/api/home/advisor/refresh`),{method:`POST`,body:JSON.stringify({idempotencyKey:crypto.randomUUID(),locale:e})})}function ae(){return m(g(`/api/home/advisor/history`)).then(e=>w.parse(e))}async function oe(e,t){return T.parse(await m(g(`/api/home/opportunities/${encodeURIComponent(e.id)}/action`),{method:`POST`,body:JSON.stringify({idempotencyKey:crypto.randomUUID(),expectedRevision:e.revision,mode:t})}))}function W(e,t){let n=crypto.randomUUID();return m(g(`/api/home/opportunities/${encodeURIComponent(e.id)}/feedback`),{method:`POST`,body:JSON.stringify({...t,idempotencyKey:n,expectedRevision:e.revision})}).then(()=>({ok:!0,idempotencyKey:n}))}function G(e,t){return m(g(`/api/home/opportunities/${encodeURIComponent(e)}/feedback/undo`),{method:`POST`,body:JSON.stringify({idempotencyKey:t})})}function K(e,t){return m(g(`/api/home/decisions/respond`),{method:`POST`,body:JSON.stringify({...e,decision:t})})}function se(e){return m(g(`/api/home/attention/acknowledge`),{method:`POST`,body:JSON.stringify(e)})}function ce(e){return m(g(`/api/home/attention/retry`),{method:`POST`,body:JSON.stringify(e)})}function le(e,t){let n=e.trim(),r=t.trim();return n&&j(n)?`/skill:${n}${r?` ${r}`:` `}`:r||null}function ue(e,t,n){let r=e.trim(),i=t?.trim()??``;if(!r&&!i)return null;let a=new URLSearchParams;return r&&a.set(`draft`,r),a.set(`autoSend`,`1`),i&&a.set(`attachmentsHandoff`,i),n?.projectScope===`none`&&a.set(`projectScope`,`none`),`/chat/new?${a.toString()}`}function de(e){let t=e.startsWith(`?`)?e.slice(1):e;if(!t)return``;let n=new URLSearchParams(t),r=new URLSearchParams,i=n.get(`skill`),a=n.get(`slash`),o=n.get(`draft`),s=n.get(`autoSend`),c=n.get(`attachmentHandoff`),l=n.get(`attachmentsHandoff`),u=n.get(`agentSetup`);i&&r.set(`skill`,i),a&&r.set(`slash`,a),o&&r.set(`draft`,o),s===`1`&&r.set(`autoSend`,`1`),c&&r.set(`attachmentHandoff`,c),l&&r.set(`attachmentsHandoff`,l),u===`1`&&r.set(`agentSetup`,`1`),n.get(`scene`)===`find-skills`&&r.set(`scene`,`find-skills`);let d=r.toString();return d?`?${d}`:``}function fe(e){let t=e.startsWith(`?`)?e.slice(1):e,n=new URLSearchParams(t),r=n.get(`projectId`)?.trim();return r?{kind:`project`,projectId:r}:n.get(`projectScope`)===`none`?{kind:`none`}:{kind:`remember-last`}}function pe(e){let t=e?.trim();return t?`/chat/new?projectId=${encodeURIComponent(t)}`:`/chat/new?projectScope=none`}var q=n(),J=e(t(),1);function Y(){let[e,t]=(0,J.useState)(!1),[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(null),u=(0,J.useCallback)(e=>{t(!0),l(e),a(null),s(null)},[]),d=(0,J.useCallback)(async e=>{if(!c||n)return null;r(!0),s(null);try{let t=await M({...c,...e});return a(t.payload),t.payload}catch(e){return s(e instanceof Error?e.message:String(e)),null}finally{r(!1)}},[n,c]),f=(0,J.useCallback)(()=>{a(null),s(null),r(!1),l(null)},[]);return{dialogOpen:e,loading:n,result:i,error:o,pendingParams:c,createShareLink:u,confirmShareLink:d,handleOpenChange:(0,J.useCallback)(e=>{t(e),e||f()},[f])}}function me(){return A()&&window.electronAPI?.platform===`darwin`}function X(){return A()&&window.electronAPI?.platform===`win32`}function Z(){return X()?`windows-preview-viewport`:``}var Q=r();function $({open:e,attachment:t,authToken:n,conversationId:r,layerClassName:i=`z-[81]`,onClose:a}){let o=h(e=>e.language),m=f(o).chat,g=l({open:e,attachment:t,authToken:n,conversationId:r,language:o}),S=Y(),{expanded:C,setExpanded:w}=u(e,S.dialogOpen),[T,E]=(0,J.useState)(!1),{preview:D,fileType:k,hasExtractedText:j}=g,M=k!==`image`&&k!==`text`&&k!==`pptx`&&j,N=D?.uri?x(D.uri):null,P=!!(N||D?.uri?.startsWith(`media://`)&&(r||D.taskId)),F=()=>{!D?.uri||!P||S.createShareLink(N?{fileId:N,fileName:D.name}:{uri:D.uri,conversationId:r??void 0,taskId:D.taskId,fileName:D.name})},I=!!(D&&!g.loading&&!g.loadError),L=()=>{w(!1),a()},R=()=>{if(!D||!g.downloadBuffer)return;let e=new Blob([g.downloadBuffer],{type:g.descriptor.mimeType}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=D.name??`download`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)},z=!!g.downloadBuffer,B=A()&&k===`spreadsheet`&&/\.xlsx?$/i.test(g.fileName)&&!!g.downloadBuffer&&!!window.electronAPI?.shell?.openTemporaryFile,V=async()=>{let e=g.downloadBuffer,t=window.electronAPI?.shell?.openTemporaryFile;if(!(!e||!t||T)){E(!0);try{(await t({fileName:g.fileName,data:new Uint8Array(e)})).ok||s(`warning`,m.attachmentPreviewOpenLocalFailed)}catch{s(`warning`,m.attachmentPreviewOpenLocalFailed)}finally{E(!1)}}},H={onDownload:R,canDownload:z},U=p(`min-h-0 min-w-0 flex-1 cursor-pointer border-0 p-0`,`bg-surface-base transition-colors`,`hover:bg-surface-hover/90 dark:bg-black/60 dark:hover:bg-black/70`,O.focusRingBase);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(b,{open:e,onOpenChange:e=>!e&&L(),children:(0,Q.jsx)(_,{children:(0,Q.jsxs)(v,{"aria-describedby":void 0,className:p(`xopc-dialog-content-fullscreen fixed inset-0 flex h-[100dvh] w-full flex-row overflow-hidden`,Z(),i,`border-0 bg-transparent p-0 shadow-none outline-none`),children:[(0,Q.jsx)(y,{className:`sr-only`,children:D?.name??``}),(0,Q.jsx)(`button`,{type:`button`,className:U,onClick:L,"aria-label":m.attachmentPreviewClose}),(0,Q.jsx)(`div`,{className:p(`flex h-full min-h-0 shrink-0 flex-col overflow-hidden`,C?`w-full`:`w-[min(100%,var(--max-width-app-main))]`,`bg-surface-panel sm:border-x sm:border-edge dark:sm:border-edge`,`shadow-float dark:shadow-elevated`),children:(0,Q.jsx)(c,{header:{expanded:C,onToggleExpanded:I?()=>w(e=>!e):void 0,onClose:L,share:P?{onClick:F,loading:S.loading}:void 0,openWithSystemApp:B?{onClick:()=>void V(),loading:T}:void 0,textView:M?{active:g.showExtractedText,onChange:e=>{g.setShowExtractedText(e),g.clearLoadError()}}:void 0},chat:g.downloadBuffer?{conversationId:r,createFile:async()=>new File([g.downloadBuffer],g.fileName,{type:g.descriptor.mimeType})}:void 0,language:o,descriptor:g.descriptor,loading:g.loading,loadError:g.loadError,textContent:g.textContent,binaryBuffer:g.binaryBuffer,showExtractedText:g.showExtractedText,extractedText:g.extractedText,extractedTextTruncated:g.extractedTextTruncated,actions:H})}),(0,Q.jsx)(`button`,{type:`button`,className:U,onClick:L,"aria-label":m.attachmentPreviewClose})]})})}),(0,Q.jsx)(d,{open:S.dialogOpen,onOpenChange:S.handleOpenChange,loading:S.loading,error:S.error,result:S.result,pendingParams:S.pendingParams,onConfirm:e=>void S.confirmShareLink(e)})]})}function he(e){let t=(0,q.c)(23),{attachments:n,conversationId:r,topPadded:i,onRemove:a,className:s}=e,c=h(ge),l;t[0]===c?l=t[1]:(l=f(c),t[0]=c,t[1]=l);let u=l.chat,[d,m]=(0,J.useState)(null);if(n.length===0)return null;let g=i?`pt-2`:`pt-3`,_;t[2]!==s||t[3]!==g?(_=p(`flex flex-wrap gap-2 border-b border-edge-subtle/90 bg-surface-hover/20 px-4 pb-2 dark:border-edge-subtle`,g,s),t[2]=s,t[3]=g,t[4]=_):_=t[4];let v;if(t[5]!==n||t[6]!==u||t[7]!==a){let e;t[9]!==u||t[10]!==a?(e=(e,t)=>{let n=e.type===`pasted_text`?u.pastedText:e.name;return(0,Q.jsxs)(`div`,{className:`flex max-w-[200px] items-center rounded-lg bg-surface-hover text-xs dark:bg-surface-hover/80`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:p(`flex min-w-0 flex-1 items-center gap-1.5 rounded-l-lg py-1 pl-2 pr-1 text-left hover:bg-surface-active`,O.transition,O.press,O.focusRingPanel),onClick:()=>m(e),"aria-label":`${u.attachmentPreviewOpen}: ${n}`,title:`${u.attachmentPreviewOpen}: ${n}`,children:[e.mimeType?.startsWith(`image/`)&&e.content?(0,Q.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.content}`,alt:``,className:`size-6 shrink-0 rounded object-cover`}):e.type===`voice`||e.mimeType?.startsWith(`audio/`)?(0,Q.jsx)(o,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):e.type===`pasted_text`?(0,Q.jsx)(N,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):(0,Q.jsx)(P,{className:`size-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n}),(0,Q.jsx)(`span`,{className:`shrink-0 text-fg-disabled`,children:k(e.size)})]}),(0,Q.jsx)(`button`,{type:`button`,className:p(`flex min-h-8 min-w-8 items-center justify-center rounded-r-lg text-fg-muted hover:bg-surface-active hover:text-fg`,O.transition,O.press,O.focusRingPanel),onClick:()=>a(t),"aria-label":`${u.attachmentPreviewRemove}: ${n}`,title:`${u.attachmentPreviewRemove}: ${n}`,children:(0,Q.jsx)(`span`,{"aria-hidden":!0,children:`×`})})]},e.id??`${e.name}-${e.size}-${e.mimeType}-${e.content?.slice(0,16)??``}`)},t[9]=u,t[10]=a,t[11]=e):e=t[11],v=n.map(e),t[5]=n,t[6]=u,t[7]=a,t[8]=v}else v=t[8];let y;t[12]!==_||t[13]!==v?(y=(0,Q.jsx)(`div`,{className:_,children:v}),t[12]=_,t[13]=v,t[14]=y):y=t[14];let b=d!==null,x;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>m(null),t[15]=x):x=t[15];let S;t[16]!==r||t[17]!==d||t[18]!==b?(S=(0,Q.jsx)($,{open:b,attachment:d,conversationId:r,onClose:x}),t[16]=r,t[17]=d,t[18]=b,t[19]=S):S=t[19];let C;return t[20]!==y||t[21]!==S?(C=(0,Q.jsxs)(Q.Fragment,{children:[y,S]}),t[20]=y,t[21]=S,t[22]=C):C=t[22],C}function ge(e){return e.language}function _e(e){let{chat:t,initialAttachments:n=[],onAttachmentsChange:r}=e,[a,o]=(0,J.useState)(n),[c,l]=(0,J.useState)(!1),u=(0,J.useRef)(null),d=(0,J.useRef)(a),f=(0,J.useRef)(r);d.current=a,f.current=r;let p=(0,J.useCallback)(e=>{let t=typeof e==`function`?e(d.current):e;d.current=t,o(t),f.current?.(t)},[]),m=(0,J.useCallback)(()=>{p([])},[]),h=(0,J.useCallback)(e=>{p(t=>t.filter((t,n)=>n!==e))},[]),g=(0,J.useCallback)(()=>d.current.map(e=>({type:e.type===`voice`?`voice`:e.type||`file`,mimeType:e.mimeType,data:e.content,name:e.name,size:e.size,...e.uri?{uri:e.uri}:{},...typeof e.durationSeconds==`number`&&Number.isFinite(e.durationSeconds)&&e.durationSeconds>0?{durationSeconds:e.durationSeconds}:{}})),[]),_=(0,J.useCallback)(async(e,n)=>{if(e.length===0)return;let r=10-d.current.length;if(r<=0){s(`warning`,t.maxAttachmentsReached,{max:10});return}let a=e.slice(0,r);e.length>a.length&&s(`warning`,t.maxAttachmentsTruncated,{max:10,dropped:e.length-a.length});let{loadAttachment:o}=await i(async()=>{let{loadAttachment:e}=await import(`./attachment-load-qjPpQzYY.js`);return{loadAttachment:e}},__vite__mapDeps([0,1])),c=(await Promise.all(a.map(async e=>{if(e.size>33554432)return s(`warning`,t.attachmentFileTooLarge,{name:e.name,maxSize:k(S)}),null;try{return await o(e,e.name)}catch{return s(`error`,t.attachmentLoadFailed,{name:e.name}),null}}))).filter(e=>e!==null).map(e=>n?{...e,type:n}:e);p(e=>[...e,...c])},[t.attachmentFileTooLarge,t.attachmentLoadFailed,t.maxAttachmentsReached,t.maxAttachmentsTruncated]);return{attachments:a,setAttachments:p,attachmentsRef:d,isDragging:c,setIsDragging:l,fileInputRef:u,processFiles:(0,J.useCallback)(e=>_(e),[_]),processPastedText:(0,J.useCallback)(e=>_([new File([e.text],e.name,{type:e.mimeType})],`pasted_text`),[_]),removeAttachment:h,clearAttachments:m,wireAttachmentsPayload:g}}export{G as A,U as C,V as D,ce as E,N as F,te as M,ee as N,W as O,P,I as S,K as T,F as _,me as a,re as b,le as c,fe as d,de as f,B as g,H as h,Z as i,R as j,ne as k,ue as l,oe as m,he as n,X as o,se as p,$ as r,Y as s,_e as t,pe as u,z as v,ie as w,ae as x,L as y};