@xopcai/xopc 0.0.403 → 0.0.404

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 (195) 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/{agent-avatar-dicebear-BibqpRFi.js → agent-avatar-dicebear-CdwFK70g.js} +1 -1
  4. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-BMj9HwIQ.js +1 -0
  5. package/dist/gateway/static/root/assets/{agents-admin-api-DvSe10zu.js → agents-admin-api-D6XzhsQy.js} +1 -1
  6. package/dist/gateway/static/root/assets/agents-hrm6V8Dp.js +77 -0
  7. package/dist/gateway/static/root/assets/{app-management-settings-panel-cRzpsDIP.js → app-management-settings-panel-Rg9jOmoj.js} +1 -1
  8. package/dist/gateway/static/root/assets/{appearance-settings-BKnQuWtS.js → appearance-settings-S3yp0GUO.js} +1 -1
  9. package/dist/gateway/static/root/assets/apps-page-ChrJSB_2.js +1 -0
  10. package/dist/gateway/static/root/assets/{archive-plugin-Duhsr1eD.js → archive-plugin-J7hwA5cs.js} +1 -1
  11. package/dist/gateway/static/root/assets/{automations-page-OfEhd4vL.js → automations-page-Cesz1cjw.js} +1 -1
  12. package/dist/gateway/static/root/assets/automations-workspace-DdopDyED.js +6 -0
  13. package/dist/gateway/static/root/assets/{binary-plugins-BDsjWsNb.js → binary-plugins-Bg4Se8Kg.js} +1 -1
  14. package/dist/gateway/static/root/assets/{block-editor-D_wE8D8_.js → block-editor-Bw1sO9YH.js} +40 -40
  15. package/dist/gateway/static/root/assets/{browser-automation-inputs-DlqyI0ez.js → browser-automation-inputs-Y46Mf8aY.js} +1 -1
  16. package/dist/gateway/static/root/assets/browser-automations-page-BcNjBdFQ.js +3 -0
  17. package/dist/gateway/static/root/assets/browser-settings-page-ByeqxrSF.js +3 -0
  18. package/dist/gateway/static/root/assets/{capabilities-glv1DeRI.js → capabilities-CIv3LUQk.js} +1 -1
  19. package/dist/gateway/static/root/assets/{capabilities-page-CYWBkGj0.js → capabilities-page-BUTQSo3A.js} +2 -2
  20. package/dist/gateway/static/root/assets/capabilities-settings-panel-B-Uwmjbo.js +8 -0
  21. package/dist/gateway/static/root/assets/{capability-header-actions-DCxxOLIt.js → capability-header-actions-BGGJKzPL.js} +1 -1
  22. package/dist/gateway/static/root/assets/channels-z6iuM4HE.js +1 -0
  23. package/dist/gateway/static/root/assets/{chat-terminal-dock-B0g-YEQo.js → chat-terminal-dock-oMmP0flJ.js} +2 -2
  24. package/dist/gateway/static/root/assets/{computer-settings-page-DNI0SuC-.js → computer-settings-page-CERhSG5W.js} +1 -1
  25. package/dist/gateway/static/root/assets/{connector-service-page-CDR35YqB.js → connector-service-page-DyW3mLTh.js} +1 -1
  26. package/dist/gateway/static/root/assets/connectors-page-CdMwhiio.js +1 -0
  27. package/dist/gateway/static/root/assets/{date-picker-B88pKWvd.js → date-picker-CO3Jhdzg.js} +1 -1
  28. package/dist/gateway/static/root/assets/{dependency-picker-ChpYlt2j.js → dependency-picker-DbyMpo5J.js} +1 -1
  29. package/dist/gateway/static/root/assets/{desktop-pet-17hqnL87.js → desktop-pet-DJ9OAPJs.js} +1 -1
  30. package/dist/gateway/static/root/assets/{desktop-pet-settings-3jN8S9Zu.js → desktop-pet-settings-CNrNXWlk.js} +1 -1
  31. package/dist/gateway/static/root/assets/{device-pairing-wizard-DIcqqq97.js → device-pairing-wizard-TzK-VCuf.js} +1 -1
  32. package/dist/gateway/static/root/assets/{directory-picker-path-field-CFBLUC-2.js → directory-picker-path-field-BmFgRA8G.js} +1 -1
  33. package/dist/gateway/static/root/assets/{extension-debug-page-CRjY1QeU.js → extension-debug-page-C3ZpHHYc.js} +1 -1
  34. package/dist/gateway/static/root/assets/{extension-page-or5zrKc7.js → extension-page-gfOwpT2R.js} +1 -1
  35. package/dist/gateway/static/root/assets/{extension-settings-page-X8kI665r.js → extension-settings-page-BS7cDqZJ.js} +1 -1
  36. package/dist/gateway/static/root/assets/{gateway-config-swr-DAir1JsW.js → gateway-config-swr-BvuySoCX.js} +1 -1
  37. package/dist/gateway/static/root/assets/{gateway-realtime-dE0XrVAT.js → gateway-realtime-SBtdXzco.js} +1 -1
  38. package/dist/gateway/static/root/assets/gateway-realtime-store-dKq2fm2X.js +1 -0
  39. package/dist/gateway/static/root/assets/gateway-settings-UB6hyqcj.js +1 -0
  40. package/dist/gateway/static/root/assets/{gateway-startup-retry-CqyGHM2M.js → gateway-startup-retry-CEpuztYK.js} +1 -1
  41. package/dist/gateway/static/root/assets/{highlighted-body-KQOG7T2V-CL6ZYfP_.js → highlighted-body-KQOG7T2V-BRfDRn2k.js} +1 -1
  42. package/dist/gateway/static/root/assets/home-page-DBUnR1DO.js +2 -0
  43. package/dist/gateway/static/root/assets/{image-generation-api-DPcsBPX7.js → image-generation-api-BoMWmqwF.js} +1 -1
  44. package/dist/gateway/static/root/assets/{imports-page-Cpuq7Ri0.js → imports-page-CPiPsiEP.js} +1 -1
  45. package/dist/gateway/static/root/assets/{index-CzkAd5Su.js → index-DmURUvvA.js} +114 -114
  46. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BIoPfzm1.js → keyboard-shortcuts-settings-D9y8h4dR.js} +1 -1
  47. package/dist/gateway/static/root/assets/local-app-workbench-page-DoAmV6on.js +1 -0
  48. package/dist/gateway/static/root/assets/{local-apps-page-Dutmy_H3.js → local-apps-page-CE6Ag8oQ.js} +1 -1
  49. package/dist/gateway/static/root/assets/{local-session-drafts-fhip41-L.js → local-session-drafts-DhJjHCfQ.js} +1 -1
  50. package/dist/gateway/static/root/assets/{locale-store-Jnhw2WMv.js → locale-store-D5h-Ha6-.js} +1 -1
  51. package/dist/gateway/static/root/assets/logs-page-DFysUb2k.js +2 -0
  52. package/dist/gateway/static/root/assets/management-settings-CmXPsu0I.js +1 -0
  53. package/dist/gateway/static/root/assets/{markdown-view-B58RypQ4.js → markdown-view-CthsQiiO.js} +1 -1
  54. package/dist/gateway/static/root/assets/{media-plugins-Brwr53z1.js → media-plugins-DvfdiczR.js} +1 -1
  55. package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-SuiLTd5Y.js +1 -0
  56. package/dist/gateway/static/root/assets/{messages-DBvKzlCl.js → messages-Bwv-AOYl.js} +2 -2
  57. package/dist/gateway/static/root/assets/note-detail-panel-BpddDFQt.js +5 -0
  58. package/dist/gateway/static/root/assets/note-image-lightbox-CMLVzPsQ.js +1 -0
  59. package/dist/gateway/static/root/assets/notes-page-DQ4KZsWt.js +8 -0
  60. package/dist/gateway/static/root/assets/{page-context-capture-button-CTMrt6Ws.js → page-context-capture-button-BcxVEGa2.js} +1 -1
  61. package/dist/gateway/static/root/assets/personal-page-CCQDxb7E.js +1 -0
  62. package/dist/gateway/static/root/assets/plugin-details-dialog-CGFQ_-bG.js +1 -0
  63. package/dist/gateway/static/root/assets/plugin-presentation-DF1gfuGf.js +1 -0
  64. package/dist/gateway/static/root/assets/{preview-open-alternatives-DCffBrFR.js → preview-open-alternatives-CXjjpXVx.js} +1 -1
  65. package/dist/gateway/static/root/assets/{product-open-page--caaVC81.js → product-open-page-DqiyvM4c.js} +1 -1
  66. package/dist/gateway/static/root/assets/{product-preview-content-B2pgfzxA.js → product-preview-content-f7Q4giA3.js} +1 -1
  67. package/dist/gateway/static/root/assets/project-detail-page-PBK7vXK5.js +1 -0
  68. package/dist/gateway/static/root/assets/projects-page-DO_pIhy-.js +1 -0
  69. package/dist/gateway/static/root/assets/{registry-api-BbUEMGcj.js → registry-api-Bf0hVPNV.js} +1 -1
  70. package/dist/gateway/static/root/assets/{remote-access-hub-Crf01UPK.js → remote-access-hub-BFtELmg0.js} +1 -1
  71. package/dist/gateway/static/root/assets/{runtime-tools-api-D0xtCTXr.js → runtime-tools-api-ByH1meP7.js} +1 -1
  72. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-Bo_vaiIq.js → runtime-tools-settings-panel-B9Beu-oK.js} +1 -1
  73. package/dist/gateway/static/root/assets/{schema-form-BXk8w1q-.js → schema-form-ZAX7C5uI.js} +1 -1
  74. package/dist/gateway/static/root/assets/{session-api-CAKgrbgz.js → session-api-fVuszA_P.js} +1 -1
  75. package/dist/gateway/static/root/assets/{session-manager-D_N7qha7.js → session-manager-BUMUjup5.js} +1 -1
  76. package/dist/gateway/static/root/assets/sessions-page-D27knqOl.js +1 -0
  77. package/dist/gateway/static/root/assets/settings-advanced-gate-CDzdr1zW.js +1 -0
  78. package/dist/gateway/static/root/assets/{settings-form-section-COwDGhbe.js → settings-form-section-BTUFu5KS.js} +1 -1
  79. package/dist/gateway/static/root/assets/{settings-page-CV_QX35m.js → settings-page-YFr6zzh7.js} +1 -1
  80. package/dist/gateway/static/root/assets/setup-status-panel-C5Jszsd1.js +1 -0
  81. package/dist/gateway/static/root/assets/{share-preview-page-BsRSJVHV.js → share-preview-page-CsfrvY_G.js} +1 -1
  82. package/dist/gateway/static/root/assets/shares-settings-BW6BNot0.js +1 -0
  83. package/dist/gateway/static/root/assets/{skill-api-W7NoRL_J.js → skill-api-o3HSgF_K.js} +1 -1
  84. package/dist/gateway/static/root/assets/skill-reload-api-BJsPnE87.js +1 -0
  85. package/dist/gateway/static/root/assets/skills-page-Kuf2t7MG.js +2 -0
  86. package/dist/gateway/static/root/assets/{style-CXJD5Nzd.js → style-DOz6lLJB.js} +1 -1
  87. package/dist/gateway/static/root/assets/{system-settings-panel-DrdONDJA.js → system-settings-panel-B69rR6vw.js} +1 -1
  88. package/dist/gateway/static/root/assets/task-detail-page-DOb97OLI.js +2 -0
  89. package/dist/gateway/static/root/assets/{task-expandable-content-HdEeV_0-.js → task-expandable-content-BZCJqajv.js} +1 -1
  90. package/dist/gateway/static/root/assets/tracing-settings-page-BIq3Ayeg.js +1 -0
  91. package/dist/gateway/static/root/assets/{tunnel-api-Ce4mYarE.js → tunnel-api-V9pJ8fUo.js} +1 -1
  92. package/dist/gateway/static/root/assets/usage-page-DZdpti28.js +1 -0
  93. package/dist/gateway/static/root/assets/{use-autosave-BmbPOiQU.js → use-autosave-BnMIUc_5.js} +1 -1
  94. package/dist/gateway/static/root/assets/user-model-page-BEgJ97hp.js +2 -0
  95. package/dist/gateway/static/root/assets/{voice-api-key-field-DqLKXIfy.js → voice-api-key-field-1h6fMaZL.js} +1 -1
  96. package/dist/gateway/static/root/assets/{voice-config-api-T3nM4buh.js → voice-config-api-CRjdZdJF.js} +1 -1
  97. package/dist/gateway/static/root/assets/{work-discovery-overlay-oUsUigJS.js → work-discovery-overlay-CVNqSNz8.js} +1 -1
  98. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-C3oU639v.js → workflow-run-setup-panel-Dq63AthQ.js} +2 -2
  99. package/dist/gateway/static/root/assets/workflows-page-CfA1iwZu.js +6 -0
  100. package/dist/gateway/static/root/assets/{xopc-cloud-account-card-DQNlWhsN.js → xopc-cloud-account-card-BsW2acj1.js} +1 -1
  101. package/dist/gateway/static/root/index.html +14 -14
  102. package/dist/package.js +1 -1
  103. package/dist/src/agent/agent-manager.js +1 -1
  104. package/dist/src/agent/background-review/run-background-review.js +1 -1
  105. package/dist/src/agent/external-tools/cliProvider.js +2 -2
  106. package/dist/src/agent/external-tools/composio-provider.js +2 -2
  107. package/dist/src/agent/external-tools/endpoint-provider.js +2 -2
  108. package/dist/src/agent/service.js +1 -1
  109. package/dist/src/agent/skills/index.js +1 -1
  110. package/dist/src/agent/skills/managed-store.js +1 -1
  111. package/dist/src/agent/skills/skill-manage-ops.js +1 -1
  112. package/dist/src/agent/tools/personal-read-tool.js +1 -1
  113. package/dist/src/agent/tools/xopc-use-tool.js +2 -2
  114. package/dist/src/agent-catalog/capabilities.js +2 -2
  115. package/dist/src/agent-catalog/migrations/legacy-config-cutover.js +1 -1
  116. package/dist/src/agent-catalog/repository.js +1 -1
  117. package/dist/src/automations/capabilities/drafts.js +1 -1
  118. package/dist/src/bootstrap/application-state.js +1 -1
  119. package/dist/src/browser/providers/browser-ext-install.js +1 -1
  120. package/dist/src/capabilities/runtime/dispatcher.js +1 -1
  121. package/dist/src/capabilities/runtime/product.js +1 -1
  122. package/dist/src/cli/commands/agents.js +1 -1
  123. package/dist/src/cli/commands/extension-marketplace.js +2 -2
  124. package/dist/src/cli/commands/extension.js +1 -1
  125. package/dist/src/cli/commands/models.js +1 -1
  126. package/dist/src/cli/commands/onboard/model.js +1 -1
  127. package/dist/src/cli/commands/onboard.js +1 -1
  128. package/dist/src/cli/utils/init-workspace-core.js +1 -1
  129. package/dist/src/config/agent-profile.js +1 -1
  130. package/dist/src/execution-environments/local-worktree-manager.js +1 -1
  131. package/dist/src/extensions/agent-plugins/skill-catalog.js +1 -1
  132. package/dist/src/extensions/agent-plugins/validation.js +1 -1
  133. package/dist/src/extensions/update.js +1 -1
  134. package/dist/src/gateway/agents-admin.js +2 -2
  135. package/dist/src/gateway/auth.d.ts +2 -0
  136. package/dist/src/gateway/auth.js +13 -4
  137. package/dist/src/gateway/hono/routes/agents.js +1 -1
  138. package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
  139. package/dist/src/gateway/hono/routes/config-patch/misc.js +1 -1
  140. package/dist/src/gateway/hono/routes/config.js +1 -1
  141. package/dist/src/gateway/hono/routes/notes.js +2 -2
  142. package/dist/src/gateway/hono/routes/projects.js +2 -2
  143. package/dist/src/gateway/hono/routes/session-input-handler.js +1 -1
  144. package/dist/src/gateway/hono/routes/tasks.js +1 -1
  145. package/dist/src/gateway/image-generation-setup.js +1 -1
  146. package/dist/src/gateway/security/audit.js +3 -3
  147. package/dist/src/gateway/service/config-coordinator.js +1 -1
  148. package/dist/src/gateway/service.js +6 -6
  149. package/dist/src/gateway/xopc-cloud-capability-setup.js +1 -1
  150. package/dist/src/home-intelligence/host.js +2 -2
  151. package/dist/src/imports/importService.js +1 -1
  152. package/dist/src/infra/update-runner.js +1 -1
  153. package/dist/src/local-apps/service.js +1 -1
  154. package/dist/src/personal-agent/service.js +1 -1
  155. package/dist/src/runtime-tools/archive.js +1 -1
  156. package/dist/src/tasks/capabilities/read.js +2 -2
  157. package/dist/src/tasks/capabilities/write.js +1 -1
  158. package/dist/src/tui/backends/embedded-backend.js +1 -1
  159. package/dist/src/voice/realtime/persona-context.js +1 -1
  160. package/package.json +2 -2
  161. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-Dj5XE9fO.js +0 -1
  162. package/dist/gateway/static/root/assets/agents-HpKwxi9M.js +0 -77
  163. package/dist/gateway/static/root/assets/apps-page-B_4AiHMy.js +0 -1
  164. package/dist/gateway/static/root/assets/automations-workspace-DyNAy5A1.js +0 -6
  165. package/dist/gateway/static/root/assets/browser-automations-page-BlSVIXB6.js +0 -3
  166. package/dist/gateway/static/root/assets/browser-settings-page-BuGBM-PJ.js +0 -3
  167. package/dist/gateway/static/root/assets/capabilities-settings-panel-CWoM2AZn.js +0 -8
  168. package/dist/gateway/static/root/assets/channels-DEB1AYkM.js +0 -1
  169. package/dist/gateway/static/root/assets/connectors-page-CW2vHnSK.js +0 -1
  170. package/dist/gateway/static/root/assets/gateway-realtime-store-CPlVuu0d.js +0 -1
  171. package/dist/gateway/static/root/assets/gateway-settings-BT6ZMqA4.js +0 -1
  172. package/dist/gateway/static/root/assets/home-page-MxealTDk.js +0 -2
  173. package/dist/gateway/static/root/assets/local-app-workbench-page-CvY6c0zW.js +0 -1
  174. package/dist/gateway/static/root/assets/logs-page-DFNUn-Lf.js +0 -2
  175. package/dist/gateway/static/root/assets/management-settings--LHmsgjW.js +0 -1
  176. package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-CosDs4aI.js +0 -1
  177. package/dist/gateway/static/root/assets/note-detail-panel-1k-swf3p.js +0 -5
  178. package/dist/gateway/static/root/assets/note-image-lightbox-BYNLO2pt.js +0 -1
  179. package/dist/gateway/static/root/assets/notes-page-B1ADIBKj.js +0 -8
  180. package/dist/gateway/static/root/assets/personal-page-MhVNCcRA.js +0 -1
  181. package/dist/gateway/static/root/assets/plugin-details-dialog-BAPTOn3F.js +0 -1
  182. package/dist/gateway/static/root/assets/plugin-presentation-D-o-0IeU.js +0 -1
  183. package/dist/gateway/static/root/assets/project-detail-page-Cm4cR-TZ.js +0 -1
  184. package/dist/gateway/static/root/assets/projects-page-DPR6478A.js +0 -1
  185. package/dist/gateway/static/root/assets/sessions-page-DcAxjdZi.js +0 -1
  186. package/dist/gateway/static/root/assets/settings-advanced-gate-DLLcp7l0.js +0 -1
  187. package/dist/gateway/static/root/assets/setup-status-panel-BvAAETqm.js +0 -1
  188. package/dist/gateway/static/root/assets/shares-settings-Cm0iaWqX.js +0 -1
  189. package/dist/gateway/static/root/assets/skill-reload-api-DNp30a6A.js +0 -1
  190. package/dist/gateway/static/root/assets/skills-page-dHlURgRl.js +0 -2
  191. package/dist/gateway/static/root/assets/task-detail-page-C7zXj_B9.js +0 -2
  192. package/dist/gateway/static/root/assets/tracing-settings-page-CXI5s3V-.js +0 -1
  193. package/dist/gateway/static/root/assets/usage-page-yt14VUPq.js +0 -1
  194. package/dist/gateway/static/root/assets/user-model-page-ne3A7X7a.js +0 -2
  195. package/dist/gateway/static/root/assets/workflows-page-szPvZMys.js +0 -6
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./external-link-DjqjBmc3.js";import{t as i}from"./messages-DBvKzlCl.js";import{t as a}from"./cn-0WouolD0.js";import{n as o}from"./locale-store-Jnhw2WMv.js";import{Ic as s,Sf as c,Yl as l,cu as u,en as d,nn as f,no as p,os as m,rn as h,tn as g}from"./index-CzkAd5Su.js";import{n as _,r as v}from"./settings-page-layout-Dx5S-Msc.js";import{r as y,t as b}from"./settings-form-section-COwDGhbe.js";var x=e(t(),1);async function S(e,t){let n=window.electronAPI?.system;if(!m()||!n?.requestNotifications)return`unsupported`;let r=await n.requestNotifications();if(r.status!==`granted`)return r.outcome===`opened-settings`||r.status===`denied`?`denied`:`default`;await n.setBehavior({notifyEnabled:!0});let i=await n.showEndpointNotification({title:e,body:t});return i.ok||await n.setBehavior({notifyEnabled:!1}),i.ok?`enabled`:`default`}var C=n();function w(){let e=i(o(e=>e.language)).systemSettings.browserNotify,[t,n]=(0,x.useState)(f),[r,a]=(0,x.useState)(null),[s,l]=(0,x.useState)(!1),u=async t=>{if(!t){n(h({enabled:!1})),a(null);return}l(!0);try{let t=await d();if(t!==`granted`){a(t===`unsupported`?e.unsupported:e.denied);return}n(h({enabled:!0})),a(await g(e.testTitle,e.testBody)?e.testShown:e.failed)}finally{l(!1)}},p=e=>{n(h(e))};return(0,C.jsxs)(v,{gap:`gap-6`,children:[(0,C.jsx)(_,{title:e.pageTitle}),(0,C.jsxs)(b,{children:[(0,C.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,C.jsx)(c,{className:`size-4 text-accent`,strokeWidth:1.75}),e.title]}),(0,C.jsx)(`p`,{className:`mb-4 text-sm text-fg-muted`,children:e.description}),(0,C.jsx)(`div`,{className:`space-y-2`,children:[[`enabled`,e.enabled,e.enabledDesc],[`completed`,e.completed,e.completedDesc],[`failed`,e.failedRuns,e.failedRunsDesc],[`needsInput`,e.needsInput,e.needsInputDesc]].map(([e,n,r])=>(0,C.jsxs)(`label`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`span`,{children:[(0,C.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n}),(0,C.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:r})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:s||e!==`enabled`&&!t.enabled,checked:t[e],onChange:t=>{e===`enabled`?u(t.target.checked):p({[e]:t.target.checked})}})]},e))}),r?(0,C.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,role:`status`,children:r}):null,(0,C.jsx)(`p`,{className:`mt-4 text-xs text-fg-muted`,children:e.limitation})]})]})}async function T(){if(typeof navigator>`u`||!navigator.mediaDevices?.getUserMedia)return!1;try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});for(let t of e.getTracks())t.stop();return!0}catch{return!1}}function E(e,t,n){return e.outcome===`opened-settings`?n.openedSettings:e.status===`granted`&&t?e.outcome===`already-granted`?n.alreadyGranted:n.granted:t?e.status===`denied`?n.denied:n.prompted:n.rendererDenied}function D(e,t){return e.outcome===`opened-settings`?t.openedSettings:e.status===`granted`?e.outcome===`already-granted`?t.alreadyGranted:t.granted:t.denied}function O(e,t){return e.outcome===`opened-settings`?t.openedSettings:e.status===`granted`?e.outcome===`already-granted`?t.alreadyGranted:t.granted:e.status===`denied`?t.denied:t.prompted}function k(e,t){return e.outcome===`opened-settings`?t.openedSettings:e.status===`granted`?e.outcome===`already-granted`?t.alreadyGranted:t.granted:e.status===`denied`?t.denied:t.prompted}var A=new Set([`microphone`,`accessibility`,`notifications`,`screen`]);function j(e,t,n){return t===`granted`?!1:e===`accessibility`&&(n===`darwin`||n===`win32`||n===`linux`)||e===`screen`&&(n===`darwin`||n===`win32`)||A.has(e)?t===`unknown`:!1}function M(e,t,n){return e===`accessibility`?!1:e===`screen`&&n===`linux`?!0:A.has(e)?t===`denied`:!0}var N=[{key:`fullDisk`,pane:`fullDisk`,platforms:[`darwin`]},{key:`screen`,pane:`screen`},{key:`microphone`,pane:`microphone`},{key:`accessibility`,pane:`accessibility`},{key:`automation`,pane:`automation`},{key:`notifications`,pane:`notifications`},{key:`location`,pane:`location`}];function P(e){return e===`linux`?N:N.filter(t=>!t.platforms||t.platforms.includes(e))}function F(e,t){let n=i(e).systemSettings.status;return t===`granted`?{label:n.granted,className:`text-emerald-600 dark:text-emerald-400`}:t===`denied`?{label:n.denied,className:`text-amber-600 dark:text-amber-400`}:{label:n.unknown,className:`text-fg-muted`}}function I(e,t,n){let r=i(e).systemSettings.permUnknown?.[t];return r?n===`darwin`&&r.darwin?r.darwin:n===`win32`&&r.win32?r.win32:n===`linux`&&r.linux?r.linux:null:null}var L={behavior:null,perms:null,loadError:null,permFeedback:null,permBusy:!1,refreshing:!1};function R(){let e=o(e=>e.language),t=i(e),n=t.systemSettings,[c,d]=(0,x.useReducer)(p,L),{behavior:f,perms:h,loadError:g,permFeedback:A,permBusy:N,refreshing:R}=c,z=typeof window<`u`?window.electronAPI?.system:void 0,B=(0,x.useCallback)(async e=>{if(z){d({type:`patch`,patch:{loadError:null}});try{d({type:`patch`,patch:{behavior:await z.getBehavior(),perms:await z.getPermissions({probe:e?.showRefreshFeedback}),...e?.showRefreshFeedback?{permFeedback:n.refreshDone}:{}}})}catch(t){d({type:`patch`,patch:{loadError:t instanceof Error?t.message:String(t),...e?.showRefreshFeedback?{permFeedback:null}:{}}})}}},[z,n.refreshDone]),V=(0,x.useCallback)(async()=>{if(!(R||N)){d({type:`patch`,patch:{refreshing:!0}});try{await B({showRefreshFeedback:!0})}finally{d({type:`patch`,patch:{refreshing:!1}})}}},[B,N,R]);if((0,x.useEffect)(()=>{let e=new Set([n.refreshDone,n.openSettingsDone,n.openSettingsFailed,n.desktopNotify.testShown]);if(!A||!e.has(A))return;let t=window.setTimeout(()=>{d({type:`patch`,patch:{permFeedback:null}})},3e3);return()=>window.clearTimeout(t)},[A,n.openSettingsDone,n.openSettingsFailed,n.refreshDone,n.desktopNotify.testShown]),(0,x.useEffect)(()=>{m()&&z&&B()},[z,B]),!m()||!z)return(0,C.jsx)(w,{});let H=async e=>{try{let{behavior:t}=await z.setBehavior(e);d({type:`patch`,patch:{behavior:t}})}catch(e){d({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}},U=async e=>{if(!e){await H({notifyEnabled:!1});return}d({type:`patch`,patch:{permBusy:!0,permFeedback:null}});try{let e=await S(n.desktopNotify.testTitle,n.desktopNotify.testBody);if(e===`unsupported`){d({type:`patch`,patch:{permFeedback:n.notificationsFeedback.unsupported}});return}if(e===`denied`){d({type:`patch`,patch:{permFeedback:n.desktopNotify.denied}});return}if(e==="default"){d({type:`patch`,patch:{permFeedback:n.notificationsFeedback.default}});return}await H({notifyEnabled:!0}),d({type:`patch`,patch:{perms:await z.getPermissions()}}),d({type:`patch`,patch:{permFeedback:n.desktopNotify.testShown}})}catch(e){d({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{d({type:`patch`,patch:{permBusy:!1}})}},W=async e=>{d({type:`patch`,patch:{permFeedback:null}}),d({type:`patch`,patch:{loadError:null}});try{(await z.openPrivacy(e)).ok?d({type:`patch`,patch:{permFeedback:n.openSettingsDone}}):d({type:`patch`,patch:{permFeedback:n.openSettingsFailed}})}catch(e){d({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}},G=async()=>{d({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),d({type:`patch`,patch:{loadError:null}});try{let e=await z.requestMicrophone(),t=e.outcome===`opened-settings`||e.status===`denied`?!1:await T();d({type:`patch`,patch:{perms:await z.getPermissions()}}),d({type:`patch`,patch:{permFeedback:E(e,t,n.permFeedback)}})}catch(e){d({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{d({type:`patch`,patch:{permBusy:!1}})}},K=async()=>{if(z.requestAccessibility){d({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),d({type:`patch`,patch:{loadError:null}});try{let e=await z.requestAccessibility();d({type:`patch`,patch:{perms:await z.getPermissions()}}),d({type:`patch`,patch:{permFeedback:D(e,n.accessibilityFeedback)}})}catch(e){d({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{d({type:`patch`,patch:{permBusy:!1}})}}},q=async()=>{if(z.requestNotifications){d({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),d({type:`patch`,patch:{loadError:null}});try{let e=await z.requestNotifications();d({type:`patch`,patch:{perms:await z.getPermissions()}}),d({type:`patch`,patch:{permFeedback:O(e,n.notificationsFeedback)}})}catch(e){d({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{d({type:`patch`,patch:{permBusy:!1}})}}},J=async()=>{if(z.requestScreen){d({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),d({type:`patch`,patch:{loadError:null}});try{let e=await z.requestScreen();d({type:`patch`,patch:{perms:await z.getPermissions()}}),d({type:`patch`,patch:{permFeedback:k(e,n.screenFeedback)}})}catch(e){d({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{d({type:`patch`,patch:{permBusy:!1}})}}},Y=f?f.platform===`win32`?n.permissionsHintWin:f.platform===`linux`?n.permissionsHintLinux:f.platform===`darwin`?n.permissionsHintDarwin:n.permissionsHint:n.permissionsHint;return(0,C.jsxs)(v,{gap:`gap-6`,children:[(0,C.jsx)(_,{title:n.title}),g?(0,C.jsx)(`p`,{className:`text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:g}):null,A?(0,C.jsx)(`p`,{className:a(`text-sm`,A===n.refreshDone||A===n.openSettingsDone||A===n.permFeedback.granted||A===n.permFeedback.alreadyGranted||A===n.accessibilityFeedback.granted||A===n.accessibilityFeedback.alreadyGranted||A===n.notificationsFeedback.granted||A===n.notificationsFeedback.alreadyGranted||A===n.screenFeedback.granted||A===n.screenFeedback.alreadyGranted||A===n.desktopNotify.testShown?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`),role:`status`,"aria-live":`polite`,children:A}):null,(0,C.jsxs)(b,{children:[(0,C.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,C.jsx)(l,{className:`size-4 text-accent`,strokeWidth:1.75}),n.behaviorGroup]}),(0,C.jsxs)(`div`,{className:`space-y-2`,children:[(0,C.jsxs)(`label`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.endpointToolsSettings.deviceAccess.background}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.endpointToolsSettings.deviceAccess.sleep})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!f?.backgroundSupported,checked:!!f?.runInBackground,onChange:e=>void H({runInBackground:e.target.checked})})]}),(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.toggles.openAtLogin}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.toggles.openAtLoginDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!f,checked:!!f?.openAtLogin,onChange:e=>{H({openAtLogin:e.target.checked})}})]}),(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.toggles.keepAwake}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.toggles.keepAwakeDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!f,checked:!!f?.keepAwakePreferred,onChange:e=>{H({keepAwakePreferred:e.target.checked})}})]}),(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.toggles.notifyDesktop}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.toggles.notifyDesktopDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!f||N,checked:!!f?.notifyEnabled,onChange:e=>{U(e.target.checked)}})]}),(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.toggles.notifySound}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.toggles.notifySoundDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!f,checked:!!f?.notifySoundEnabled,onChange:e=>{H({notifySoundEnabled:e.target.checked})}})]})]})]}),f&&h?(0,C.jsxs)(`section`,{className:y(),children:[(0,C.jsxs)(`div`,{className:`mb-4 flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.permissionsTitle}),(0,C.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:Y}),f.platform===`darwin`&&!f.packaged?(0,C.jsx)(`p`,{className:`mt-1 text-xs text-amber-600 dark:text-amber-400`,children:n.permissionsHintDevDarwin}):null]}),(0,C.jsxs)(`button`,{type:`button`,disabled:R||N,"aria-busy":R,className:a(`mt-2 inline-flex max-w-full items-center justify-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-3 py-1.5 text-sm font-medium text-fg transition-colors hover:bg-surface-hover disabled:opacity-50 sm:mt-0`,s.press),onClick:()=>void V(),children:[(0,C.jsx)(u,{className:a(`size-3.5`,R&&`animate-spin`),strokeWidth:1.75,"aria-hidden":!0}),R?n.refreshing:n.refresh]})]}),(0,C.jsx)(`ul`,{className:`space-y-3`,children:P(f.platform).map(({key:t,pane:i})=>{let o=F(e,h[t]),c=n.perm[t],l=h[t]===`unknown`?I(e,t,f.platform):null;return c?(0,C.jsxs)(`li`,{className:`flex flex-col gap-2 rounded-xl bg-surface-panel/70 p-3 shadow-surface sm:flex-row sm:items-center sm:justify-between`,children:[(0,C.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:c.title}),(0,C.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:c.desc}),(0,C.jsx)(`p`,{className:`mt-1 text-xs font-medium ${o.className}`,children:o.label}),l?(0,C.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:l}):null]}),(0,C.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[t===`notifications`&&j(t,h[t],f.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:a(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,s.press),onClick:()=>void q(),children:n.requestAccess}):null,t===`microphone`&&j(t,h[t],f.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:a(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,s.press),onClick:()=>void G(),children:n.requestAccess}):null,t===`accessibility`&&j(t,h[t],f.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:a(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,s.press),onClick:()=>void K(),children:n.requestAccess}):null,t===`screen`&&j(t,h[t],f.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:a(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,s.press),onClick:()=>void J(),children:n.requestAccess}):null,M(t,h[t],f.platform)?(0,C.jsxs)(`button`,{type:`button`,className:a(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,s.press),onClick:()=>void W(i),children:[n.openSettings,(0,C.jsx)(r,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})]}):null]})]},t):null})})]}):null]})}export{R as SystemSettingsPanel};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./external-link-DjqjBmc3.js";import{t as i}from"./messages-Bwv-AOYl.js";import{t as a}from"./cn-0WouolD0.js";import{n as o}from"./locale-store-D5h-Ha6-.js";import{Ic as s,Tf as c,Zl as l,du as u,en as d,nn as f,no as p,os as m,rn as h,tn as g}from"./index-DmURUvvA.js";import{n as _,r as v}from"./settings-page-layout-Dx5S-Msc.js";import{r as y,t as b}from"./settings-form-section-BTUFu5KS.js";var x=e(t(),1);async function S(e,t){let n=window.electronAPI?.system;if(!m()||!n?.requestNotifications)return`unsupported`;let r=await n.requestNotifications();if(r.status!==`granted`)return r.outcome===`opened-settings`||r.status===`denied`?`denied`:`default`;await n.setBehavior({notifyEnabled:!0});let i=await n.showEndpointNotification({title:e,body:t});return i.ok||await n.setBehavior({notifyEnabled:!1}),i.ok?`enabled`:`default`}var C=n();function w(){let e=i(o(e=>e.language)).systemSettings.browserNotify,[t,n]=(0,x.useState)(f),[r,a]=(0,x.useState)(null),[s,l]=(0,x.useState)(!1),u=async t=>{if(!t){n(h({enabled:!1})),a(null);return}l(!0);try{let t=await d();if(t!==`granted`){a(t===`unsupported`?e.unsupported:e.denied);return}n(h({enabled:!0})),a(await g(e.testTitle,e.testBody)?e.testShown:e.failed)}finally{l(!1)}},p=e=>{n(h(e))};return(0,C.jsxs)(v,{gap:`gap-6`,children:[(0,C.jsx)(_,{title:e.pageTitle}),(0,C.jsxs)(b,{children:[(0,C.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,C.jsx)(c,{className:`size-4 text-accent`,strokeWidth:1.75}),e.title]}),(0,C.jsx)(`p`,{className:`mb-4 text-sm text-fg-muted`,children:e.description}),(0,C.jsx)(`div`,{className:`space-y-2`,children:[[`enabled`,e.enabled,e.enabledDesc],[`completed`,e.completed,e.completedDesc],[`failed`,e.failedRuns,e.failedRunsDesc],[`needsInput`,e.needsInput,e.needsInputDesc]].map(([e,n,r])=>(0,C.jsxs)(`label`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`span`,{children:[(0,C.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n}),(0,C.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:r})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:s||e!==`enabled`&&!t.enabled,checked:t[e],onChange:t=>{e===`enabled`?u(t.target.checked):p({[e]:t.target.checked})}})]},e))}),r?(0,C.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,role:`status`,children:r}):null,(0,C.jsx)(`p`,{className:`mt-4 text-xs text-fg-muted`,children:e.limitation})]})]})}async function T(){if(typeof navigator>`u`||!navigator.mediaDevices?.getUserMedia)return!1;try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});for(let t of e.getTracks())t.stop();return!0}catch{return!1}}function E(e,t,n){return e.outcome===`opened-settings`?n.openedSettings:e.status===`granted`&&t?e.outcome===`already-granted`?n.alreadyGranted:n.granted:t?e.status===`denied`?n.denied:n.prompted:n.rendererDenied}function D(e,t){return e.outcome===`opened-settings`?t.openedSettings:e.status===`granted`?e.outcome===`already-granted`?t.alreadyGranted:t.granted:t.denied}function O(e,t){return e.outcome===`opened-settings`?t.openedSettings:e.status===`granted`?e.outcome===`already-granted`?t.alreadyGranted:t.granted:e.status===`denied`?t.denied:t.prompted}function k(e,t){return e.outcome===`opened-settings`?t.openedSettings:e.status===`granted`?e.outcome===`already-granted`?t.alreadyGranted:t.granted:e.status===`denied`?t.denied:t.prompted}var A=new Set([`microphone`,`accessibility`,`notifications`,`screen`]);function j(e,t,n){return t===`granted`?!1:e===`accessibility`&&(n===`darwin`||n===`win32`||n===`linux`)||e===`screen`&&(n===`darwin`||n===`win32`)||A.has(e)?t===`unknown`:!1}function M(e,t,n){return e===`accessibility`?!1:e===`screen`&&n===`linux`?!0:A.has(e)?t===`denied`:!0}var N=[{key:`fullDisk`,pane:`fullDisk`,platforms:[`darwin`]},{key:`screen`,pane:`screen`},{key:`microphone`,pane:`microphone`},{key:`accessibility`,pane:`accessibility`},{key:`automation`,pane:`automation`},{key:`notifications`,pane:`notifications`},{key:`location`,pane:`location`}];function P(e){return e===`linux`?N:N.filter(t=>!t.platforms||t.platforms.includes(e))}function F(e,t){let n=i(e).systemSettings.status;return t===`granted`?{label:n.granted,className:`text-emerald-600 dark:text-emerald-400`}:t===`denied`?{label:n.denied,className:`text-amber-600 dark:text-amber-400`}:{label:n.unknown,className:`text-fg-muted`}}function I(e,t,n){let r=i(e).systemSettings.permUnknown?.[t];return r?n===`darwin`&&r.darwin?r.darwin:n===`win32`&&r.win32?r.win32:n===`linux`&&r.linux?r.linux:null:null}var L={behavior:null,perms:null,loadError:null,permFeedback:null,permBusy:!1,refreshing:!1};function R(){let e=o(e=>e.language),t=i(e),n=t.systemSettings,[c,d]=(0,x.useReducer)(p,L),{behavior:f,perms:h,loadError:g,permFeedback:A,permBusy:N,refreshing:R}=c,z=typeof window<`u`?window.electronAPI?.system:void 0,B=(0,x.useCallback)(async e=>{if(z){d({type:`patch`,patch:{loadError:null}});try{d({type:`patch`,patch:{behavior:await z.getBehavior(),perms:await z.getPermissions({probe:e?.showRefreshFeedback}),...e?.showRefreshFeedback?{permFeedback:n.refreshDone}:{}}})}catch(t){d({type:`patch`,patch:{loadError:t instanceof Error?t.message:String(t),...e?.showRefreshFeedback?{permFeedback:null}:{}}})}}},[z,n.refreshDone]),V=(0,x.useCallback)(async()=>{if(!(R||N)){d({type:`patch`,patch:{refreshing:!0}});try{await B({showRefreshFeedback:!0})}finally{d({type:`patch`,patch:{refreshing:!1}})}}},[B,N,R]);if((0,x.useEffect)(()=>{let e=new Set([n.refreshDone,n.openSettingsDone,n.openSettingsFailed,n.desktopNotify.testShown]);if(!A||!e.has(A))return;let t=window.setTimeout(()=>{d({type:`patch`,patch:{permFeedback:null}})},3e3);return()=>window.clearTimeout(t)},[A,n.openSettingsDone,n.openSettingsFailed,n.refreshDone,n.desktopNotify.testShown]),(0,x.useEffect)(()=>{m()&&z&&B()},[z,B]),!m()||!z)return(0,C.jsx)(w,{});let H=async e=>{try{let{behavior:t}=await z.setBehavior(e);d({type:`patch`,patch:{behavior:t}})}catch(e){d({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}},U=async e=>{if(!e){await H({notifyEnabled:!1});return}d({type:`patch`,patch:{permBusy:!0,permFeedback:null}});try{let e=await S(n.desktopNotify.testTitle,n.desktopNotify.testBody);if(e===`unsupported`){d({type:`patch`,patch:{permFeedback:n.notificationsFeedback.unsupported}});return}if(e===`denied`){d({type:`patch`,patch:{permFeedback:n.desktopNotify.denied}});return}if(e==="default"){d({type:`patch`,patch:{permFeedback:n.notificationsFeedback.default}});return}await H({notifyEnabled:!0}),d({type:`patch`,patch:{perms:await z.getPermissions()}}),d({type:`patch`,patch:{permFeedback:n.desktopNotify.testShown}})}catch(e){d({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{d({type:`patch`,patch:{permBusy:!1}})}},W=async e=>{d({type:`patch`,patch:{permFeedback:null}}),d({type:`patch`,patch:{loadError:null}});try{(await z.openPrivacy(e)).ok?d({type:`patch`,patch:{permFeedback:n.openSettingsDone}}):d({type:`patch`,patch:{permFeedback:n.openSettingsFailed}})}catch(e){d({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}},G=async()=>{d({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),d({type:`patch`,patch:{loadError:null}});try{let e=await z.requestMicrophone(),t=e.outcome===`opened-settings`||e.status===`denied`?!1:await T();d({type:`patch`,patch:{perms:await z.getPermissions()}}),d({type:`patch`,patch:{permFeedback:E(e,t,n.permFeedback)}})}catch(e){d({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{d({type:`patch`,patch:{permBusy:!1}})}},K=async()=>{if(z.requestAccessibility){d({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),d({type:`patch`,patch:{loadError:null}});try{let e=await z.requestAccessibility();d({type:`patch`,patch:{perms:await z.getPermissions()}}),d({type:`patch`,patch:{permFeedback:D(e,n.accessibilityFeedback)}})}catch(e){d({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{d({type:`patch`,patch:{permBusy:!1}})}}},q=async()=>{if(z.requestNotifications){d({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),d({type:`patch`,patch:{loadError:null}});try{let e=await z.requestNotifications();d({type:`patch`,patch:{perms:await z.getPermissions()}}),d({type:`patch`,patch:{permFeedback:O(e,n.notificationsFeedback)}})}catch(e){d({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{d({type:`patch`,patch:{permBusy:!1}})}}},J=async()=>{if(z.requestScreen){d({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),d({type:`patch`,patch:{loadError:null}});try{let e=await z.requestScreen();d({type:`patch`,patch:{perms:await z.getPermissions()}}),d({type:`patch`,patch:{permFeedback:k(e,n.screenFeedback)}})}catch(e){d({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{d({type:`patch`,patch:{permBusy:!1}})}}},Y=f?f.platform===`win32`?n.permissionsHintWin:f.platform===`linux`?n.permissionsHintLinux:f.platform===`darwin`?n.permissionsHintDarwin:n.permissionsHint:n.permissionsHint;return(0,C.jsxs)(v,{gap:`gap-6`,children:[(0,C.jsx)(_,{title:n.title}),g?(0,C.jsx)(`p`,{className:`text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:g}):null,A?(0,C.jsx)(`p`,{className:a(`text-sm`,A===n.refreshDone||A===n.openSettingsDone||A===n.permFeedback.granted||A===n.permFeedback.alreadyGranted||A===n.accessibilityFeedback.granted||A===n.accessibilityFeedback.alreadyGranted||A===n.notificationsFeedback.granted||A===n.notificationsFeedback.alreadyGranted||A===n.screenFeedback.granted||A===n.screenFeedback.alreadyGranted||A===n.desktopNotify.testShown?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`),role:`status`,"aria-live":`polite`,children:A}):null,(0,C.jsxs)(b,{children:[(0,C.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,C.jsx)(l,{className:`size-4 text-accent`,strokeWidth:1.75}),n.behaviorGroup]}),(0,C.jsxs)(`div`,{className:`space-y-2`,children:[(0,C.jsxs)(`label`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.endpointToolsSettings.deviceAccess.background}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.endpointToolsSettings.deviceAccess.sleep})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!f?.backgroundSupported,checked:!!f?.runInBackground,onChange:e=>void H({runInBackground:e.target.checked})})]}),(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.toggles.openAtLogin}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.toggles.openAtLoginDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!f,checked:!!f?.openAtLogin,onChange:e=>{H({openAtLogin:e.target.checked})}})]}),(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.toggles.keepAwake}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.toggles.keepAwakeDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!f,checked:!!f?.keepAwakePreferred,onChange:e=>{H({keepAwakePreferred:e.target.checked})}})]}),(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.toggles.notifyDesktop}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.toggles.notifyDesktopDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!f||N,checked:!!f?.notifyEnabled,onChange:e=>{U(e.target.checked)}})]}),(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.toggles.notifySound}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.toggles.notifySoundDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!f,checked:!!f?.notifySoundEnabled,onChange:e=>{H({notifySoundEnabled:e.target.checked})}})]})]})]}),f&&h?(0,C.jsxs)(`section`,{className:y(),children:[(0,C.jsxs)(`div`,{className:`mb-4 flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.permissionsTitle}),(0,C.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:Y}),f.platform===`darwin`&&!f.packaged?(0,C.jsx)(`p`,{className:`mt-1 text-xs text-amber-600 dark:text-amber-400`,children:n.permissionsHintDevDarwin}):null]}),(0,C.jsxs)(`button`,{type:`button`,disabled:R||N,"aria-busy":R,className:a(`mt-2 inline-flex max-w-full items-center justify-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-3 py-1.5 text-sm font-medium text-fg transition-colors hover:bg-surface-hover disabled:opacity-50 sm:mt-0`,s.press),onClick:()=>void V(),children:[(0,C.jsx)(u,{className:a(`size-3.5`,R&&`animate-spin`),strokeWidth:1.75,"aria-hidden":!0}),R?n.refreshing:n.refresh]})]}),(0,C.jsx)(`ul`,{className:`space-y-3`,children:P(f.platform).map(({key:t,pane:i})=>{let o=F(e,h[t]),c=n.perm[t],l=h[t]===`unknown`?I(e,t,f.platform):null;return c?(0,C.jsxs)(`li`,{className:`flex flex-col gap-2 rounded-xl bg-surface-panel/70 p-3 shadow-surface sm:flex-row sm:items-center sm:justify-between`,children:[(0,C.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:c.title}),(0,C.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:c.desc}),(0,C.jsx)(`p`,{className:`mt-1 text-xs font-medium ${o.className}`,children:o.label}),l?(0,C.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:l}):null]}),(0,C.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[t===`notifications`&&j(t,h[t],f.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:a(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,s.press),onClick:()=>void q(),children:n.requestAccess}):null,t===`microphone`&&j(t,h[t],f.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:a(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,s.press),onClick:()=>void G(),children:n.requestAccess}):null,t===`accessibility`&&j(t,h[t],f.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:a(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,s.press),onClick:()=>void K(),children:n.requestAccess}):null,t===`screen`&&j(t,h[t],f.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:a(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,s.press),onClick:()=>void J(),children:n.requestAccess}):null,M(t,h[t],f.platform)?(0,C.jsxs)(`button`,{type:`button`,className:a(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,s.press),onClick:()=>void W(i),children:[n.openSettings,(0,C.jsx)(r,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})]}):null]})]},t):null})})]}):null]})}export{R as SystemSettingsPanel};
@@ -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-B2HK1psj.js";import{t as c}from"./circle-check-C23XjkUj.js";import{t as l}from"./ellipsis-0k4rZLoy.js";import{t as u}from"./external-link-DjqjBmc3.js";import{F as d,N as f,V as p,z as m}from"./markdown-view-CthsQiiO.js";import{t as h}from"./folder-open-CyzJ19I9.js";import{t as g}from"./x-B_N4OPjy.js";import{t as _}from"./cn-0WouolD0.js";import{a as v,c as ee,n as te,r as ne}from"./locale-store-D5h-Ha6-.js";import{i as y,n as b,o as re,r as ie,s as ae,t as x}from"./dist-BGTk37IG.js";import{i as S}from"./vendor-swr-BIWyz7Rc.js";import{$c as oe,Ad as C,Af as se,Bu as w,Ca as T,Eu as E,Go as D,Kc as O,Ni as k,No as A,Pd as j,Qa as ce,Qs as le,Rc as ue,Xc as de,Za as fe,Zc as pe,ar as me,bo as he,cl as ge,ds as M,er as _e,fl as ve,fs as ye,gl as be,hf as xe,il as Se,ir as Ce,l as we,la as Te,ml as Ee,n as De,nf as Oe,nr as ke,qc as Ae,rf as je,rr as Me,so as Ne,tr as N,ua as Pe,ul as Fe,va as P,yu as Ie}from"./index-DmURUvvA.js";import{t as F}from"./date-picker-CO3Jhdzg.js";import{n as Le,t as I}from"./task-expandable-content-BZCJqajv.js";import{t as Re}from"./page-context-capture-button-BcxVEGa2.js";import{t as ze}from"./dependency-picker-DbyMpo5J.js";var L=n(),R=e(t(),1),z=r();function Be({wait:e,detail:t,zh:n,onUpdated:r}){let[i,a]=(0,R.useState)(``),[o,s]=(0,R.useState)(!1),[c,l]=(0,R.useState)(``),[u,d]=(0,R.useState)(!1),f=(0,R.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 pe(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),le({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,z.jsxs)(`form`,{className:`mt-3 space-y-3 rounded-lg border border-edge p-3`,onSubmit:e=>{e.preventDefault(),h()},children:[p?(0,z.jsxs)(`div`,{className:`text-sm text-fg`,children:[(0,z.jsx)(`p`,{children:e.reason}),(0,z.jsxs)(`p`,{className:`mt-2`,children:[n?`授权范围:`:`Permission: `,String(e.condition.capability)]}),(0,z.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,z.jsx)(O,{type:`button`,variant:`primary`,disabled:o||u,onClick:()=>void h(`approve`),children:n?`批准`:`Approve`}),(0,z.jsx)(O,{type:`button`,disabled:o||u,onClick:()=>void h(`deny`),children:n?`拒绝并暂停`:`Deny and pause`})]})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`label`,{className:`block text-sm text-fg`,children:[typeof e.condition.question==`string`?e.condition.question:e.reason,(0,z.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,z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:m.map(e=>(0,z.jsx)(O,{type:`button`,disabled:o||u,variant:`secondary`,"aria-pressed":i===e,onClick:()=>a(e),children:e},e))}),(0,z.jsx)(O,{type:`submit`,variant:`primary`,disabled:o||u||!i.trim(),children:o?n?`正在提交`:`Submitting`:n?`提交补充信息`:`Submit answer`})]}),(0,z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`保存到任务上下文;其他等待条件满足后继续执行。`:`Saved to task context. Work continues once all waiting conditions are met.`}),c&&(0,z.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:c})]})}function Ve(e){let t=(0,L.c)(17),{children:n,contentKey:r,language:i,className:o}=e,s=(0,R.useId)(),c=R.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,z.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,z.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,z.jsxs)(`div`,{className:o,children:[m,h]}),t[13]=o,t[14]=m,t[15]=h,t[16]=g):g=t[16],g}function He(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 B({uri:e,zh:t}){let[n,r]=(0,R.useState)(),[i,a]=(0,R.useState)(!1),[o,c]=(0,R.useState)(!1),[l,u]=(0,R.useState)(``),[d,f]=(0,R.useState)(``);async function p(){a(!0),u(``);try{let n=He(e,(await T()).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 P(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,z.jsxs)(`details`,{className:`mt-2 text-xs text-fg-muted`,children:[(0,z.jsx)(`summary`,{className:`cursor-pointer py-2`,children:t?`链接打不开?`:`Trouble opening the link?`}),(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(O,{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,z.jsx)(O,{type:`button`,disabled:i,onClick:()=>void m(),children:t?`恢复链接 · 续期 24 小时`:`Restore link for 24 hours`}),l&&(0,z.jsx)(`p`,{role:`status`,className:`break-words leading-5`,children:l}),d&&(0,z.jsx)(`a`,{className:`block py-2 text-accent`,href:d,target:`_blank`,rel:`noopener noreferrer`,children:t?`打开产物`:`Open artifact`}),o&&(0,z.jsx)(s,{className:`block py-2 text-accent`,to:`/settings/shares`,children:t?`管理分享记录`:`Manage shares`})]})]})}function Ue(e){let t=(0,L.c)(14),{evidence:n,projectId:r,conversationId:i,language:a}=e,o=Te(We);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,z.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge-subtle p-3`,children:[(0,z.jsx)(I,{content:l,contentKey:`${i??r}:evidence-title:${t}:${e.title}`,language:a,previewHeight:60,children:s?(0,z.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,z.jsx)(u,{className:`size-4 shrink-0`}),(0,z.jsx)(`span`,{className:`min-w-0 break-words`,children:l})]}):c&&(r||i)?(0,z.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,z.jsx)(j,{className:`size-4 shrink-0`}),l]}):(0,z.jsx)(`p`,{className:`break-words [overflow-wrap:anywhere] text-sm font-medium text-fg`,children:l})}),s&&e.kind===`artifact`&&(0,z.jsx)(B,{uri:n,zh:a===`zh`},n),e.summary?(0,z.jsx)(I,{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,z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:e.provenance===`judge`?e.strength===`verified`?a===`zh`?`模型审阅通过`:`Model reviewed`:a===`zh`?`模型未确认,待核验`:`Not confirmed by review`: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,z.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 We(e){return e.setPath}function Ge({taskId:e}){let t=ee(e=>e.conversationId),n=te(e=>e.language),[r,i]=(0,R.useState)(``),[a,o]=(0,R.useState)(null),[s,c]=(0,R.useState)(!1),[l,u]=(0,R.useState)(!1),[d,f]=(0,R.useState)([]),[p,m]=(0,R.useState)(null),h=ne(`/api/tasks/${encodeURIComponent(e)}/collaboration`),{data:g,error:_,mutate:y}=S([`task-collaboration`,e,t],()=>v(`${h}?recent=1`),{revalidateOnFocus:!0}),b=[...new Map([...d,...g?.items??[]].map(e=>[e.id,e])).values()].sort((e,t)=>e.sequence-t.sequence),re=async()=>{let e=b[0];if(!(!e||l)){u(!0);try{let t=await v(`${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,R.useEffect)(()=>{let t=t=>{let n=t.detail;(!n?.taskId||n.taskId===e)&&y()};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)}},[y,e]);let ie=async()=>{if(!(!r.trim()||s)){c(!0),m(null);try{await v(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 y()}catch(e){m(e instanceof Error?e.message:String(e))}finally{c(!1)}}};return(0,z.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n===`zh`?`任务留言`:`Task updates`}),(0,z.jsxs)(`div`,{className:`mt-3 max-h-64 space-y-2 overflow-y-auto`,children:[!g&&!_?(0,z.jsxs)(`div`,{"aria-busy":`true`,className:`space-y-2`,children:[(0,z.jsx)(ue,{className:`h-14 w-full`}),(0,z.jsx)(ue,{className:`h-14 w-4/5`})]}):null,_?(0,z.jsx)(`p`,{role:`status`,className:`text-xs text-fg-muted`,children:n===`zh`?`暂时无法读取留言`:`Updates unavailable`}):null,b[0]&&b[0].sequence>1?(0,z.jsx)(`button`,{type:`button`,disabled:l,onClick:()=>void re(),className:`text-xs text-accent hover:underline disabled:opacity-50`,children:n===`zh`?`查看更早留言`:`Earlier updates`}):null,b.map(t=>(0,z.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 text-sm`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-subtle`,children:[(0,z.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,z.jsxs)(`span`,{children:[`· `,t.kind]}),t.deliveryStatus?(0,z.jsxs)(`span`,{children:[`· `,t.deliveryStatus]}):null]}),(0,z.jsx)(`div`,{className:`mt-1 min-w-0 text-fg`,"data-task-collaboration-body":!0,children:(0,z.jsx)(I,{content:t.body,contentKey:`${e}:update:${t.id}`,language:n,breaks:!0,previewHeight:120})}),t.kind===`question`&&t.authorKind===`worker_agent`?(0,z.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&&!b.length?(0,z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n===`zh`?`暂无进展留言`:`No updates yet`}):null]}),a?(0,z.jsxs)(`p`,{className:`mt-3 text-xs text-accent`,children:[n===`zh`?`正在回复执行 Agent 的问题`:`Replying to the worker`,(0,z.jsx)(`button`,{type:`button`,className:`ml-2 underline`,onClick:()=>o(null),children:n===`zh`?`取消`:`Cancel`})]}):null,(0,z.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,z.jsx)(`p`,{role:`alert`,className:`mt-1 text-xs text-danger`,children:p}):null,(0,z.jsx)(`button`,{type:`button`,disabled:!r.trim()||s,onClick:()=>void ie(),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 Ke(e,t,n,r){return!!(e&&t!==e.version&&n!==e.value&&r!==n)}function qe(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 Je(e,t){return(t===`zh`?{backlog:`待规划`,ready:`就绪`,active:`进行中`,review:`待验收`,closed:`已完成`}:{backlog:`Backlog`,ready:`Ready`,active:`Active`,review:`Review`,closed:`Completed`})[e]}function Ye(){let e=(0,L.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,z.jsxs)(`div`,{className:`space-y-4`,"aria-busy":!0,children:[(0,z.jsx)(ue,{className:`h-32 rounded-2xl`}),(0,z.jsx)(ue,{className:`h-52 rounded-2xl`}),(0,z.jsx)(ue,{className:`h-40 rounded-2xl`})]}),e[0]=t):t=e[0],t}function Xe(e){if(e===void 0)return``;let t=new Date(e);return new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString().slice(0,10)}function Ze(e){return e?new Date(`${e}T23:59:59.999`).getTime():null}var Qe=[`backlog`,`ready`,`active`,`review`,`closed`],$e=[`low`,`normal`,`high`,`critical`],et=(0,R.memo)(function(e){let t=(0,L.c)(20),{value:n,disabled:r,canMove:i,canApprove:a,canReopen:o,language:s,label:c,onChange:l}=e,u;t[0]!==a||t[1]!==i||t[2]!==o||t[3]!==n?(u=e=>e!==n&&(e===`closed`?!a:n===`closed`?!o:!i),t[0]=a,t[1]=i,t[2]=o,t[3]=n,t[4]=u):u=t[4];let d=u,f;t[5]===c?f=t[6]:(f=(0,z.jsx)(`span`,{children:c}),t[5]=c,t[6]=f);let p;t[7]===l?p=t[8]:(p=e=>l(e.target.value),t[7]=l,t[8]=p);let m;t[9]!==s||t[10]!==d?(m=Qe.map(e=>(0,z.jsx)(ye,{value:e,disabled:d(e),children:Je(e,s)},e)),t[9]=s,t[10]=d,t[11]=m):m=t[11];let h;t[12]!==r||t[13]!==p||t[14]!==m||t[15]!==n?(h=(0,z.jsx)(M,{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:p,children:m}),t[12]=r,t[13]=p,t[14]=m,t[15]=n,t[16]=h):h=t[16];let g;return t[17]!==f||t[18]!==h?(g=(0,z.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[f,h]}),t[17]=f,t[18]=h,t[19]=g):g=t[19],g}),tt=(0,R.memo)(function(e){let t=(0,L.c)(14),{value:n,disabled:r,label:i,labels:a,onChange:o}=e,s;t[0]===i?s=t[1]:(s=(0,z.jsx)(`span`,{children:i}),t[0]=i,t[1]=s);let c;t[2]===o?c=t[3]:(c=e=>o(e.target.value),t[2]=o,t[3]=c);let l;t[4]===a?l=t[5]:(l=$e.map(e=>(0,z.jsx)(ye,{value:e,children:a[e]},e)),t[4]=a,t[5]=l);let u;t[6]!==r||t[7]!==c||t[8]!==l||t[9]!==n?(u=(0,z.jsx)(M,{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:c,children:l}),t[6]=r,t[7]=c,t[8]=l,t[9]=n,t[10]=u):u=t[10];let d;return t[11]!==s||t[12]!==u?(d=(0,z.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[s,u]}),t[11]=s,t[12]=u,t[13]=d):d=t[13],d}),nt=(0,R.memo)(function(e){let t=(0,L.c)(10),{value:n,disabled:r,label:i,onChange:a}=e,o;t[0]===i?o=t[1]:(o=(0,z.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,z.jsx)(F,{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,z.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}),rt=(0,R.memo)(function(e){let t=(0,L.c)(17),{value:n,disabled:r,label:i,unassignedLabel:a,agents:o,onChange:s}=e,c;t[0]===i?c=t[1]:(c=(0,z.jsx)(`span`,{children:i}),t[0]=i,t[1]=c);let l;t[2]===s?l=t[3]:(l=e=>s(e.target.value),t[2]=s,t[3]=l);let u;t[4]===a?u=t[5]:(u=(0,z.jsx)(ye,{value:``,disabled:!0,children:a}),t[4]=a,t[5]=u);let d;t[6]===o?d=t[7]:(d=o.map(yt),t[6]=o,t[7]=d);let f;t[8]!==r||t[9]!==l||t[10]!==u||t[11]!==d||t[12]!==n?(f=(0,z.jsxs)(M,{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:l,children:[u,d]}),t[8]=r,t[9]=l,t[10]=u,t[11]=d,t[12]=n,t[13]=f):f=t[13];let p;return t[14]!==c||t[15]!==f?(p=(0,z.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[c,f]}),t[14]=c,t[15]=f,t[16]=p):p=t[16],p}),it=(0,R.memo)(function(e){let t=(0,L.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(bt),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,z.jsx)(ze,{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)),at=`xopc.taskDetail.chatPanelPercent`,ot=42;function st(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?ot:Math.min(r,Math.max(n,e))}function ct(){try{let e=Number(window.localStorage.getItem(at));return Number.isFinite(e)&&e>=30&&e<=60?e:ot}catch{return ot}}function lt(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 ut(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 dt(e){let t=(0,L.c)(13),{items:n,empty:r,contentKey:i}=e,a=te(pt);if(n.length===0){let e;return t[0]===r?e=t[1]:(e=(0,z.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(ft),t[4]=n,t[5]=s);let c;t[6]===s?c=t[7]:(c=(0,z.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,z.jsx)(I,{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 ft(e){return(0,z.jsxs)(`li`,{className:`flex gap-2 text-sm leading-6 text-fg`,children:[(0,z.jsx)(Oe,{className:`mt-1 size-4 shrink-0 text-fg-subtle`}),(0,z.jsx)(`span`,{className:`min-w-0 whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:e})]},e)}function pt(e){return e.language}function mt({taskId:e,presentation:t,backgroundPath:n,onDeleted:r}){let[o]=a(),g=i(),v=te(e=>e.language),ne=ee(e=>e.conversationId),y=(0,R.useMemo)(()=>be(v),[v]),b=D(e=>e.setPageHeader),re=D(e=>e.clearPageHeader),ie=ce(e=>e.panes),ae=Pe(e=>e.openForSession),{data:x,error:T,mutate:j,lastChange:le,conversationLoading:ue,conversationError:M}=Ae(e),{data:ye}=S(e?`task-detail-automations`:null,()=>we.list()),[Te,P]=(0,R.useState)(null),[F,ze]=(0,R.useState)(()=>new Set),[L,He]=(0,R.useState)([]),[B,We]=(0,R.useState)(null),[Je,Qe]=(0,R.useState)([]),[$e,ft]=(0,R.useState)(!1),[pt,mt]=(0,R.useState)(``),[ht,V]=(0,R.useState)(!1),[gt,_t]=(0,R.useState)(``),[H,vt]=(0,R.useState)(ct),[yt,bt]=(0,R.useState)(!1),xt=(0,R.useRef)(null),St=(0,R.useRef)(!1),Ct=(0,R.useRef)(!1),wt=(0,R.useRef)(``),Tt=(0,R.useRef)(null),Et=(0,R.useRef)(null),Dt=(0,R.useRef)(null),U=(0,R.useRef)(x),[Ot,W]=(0,R.useState)(null),[kt,At]=(0,R.useState)(null),[jt,Mt]=(0,R.useState)(!1),Nt=(0,R.useMemo)(()=>({link:y.linkDependencies,linked:y.linkedDependencies,searchPlaceholder:y.dependencySearchPlaceholder,noMatches:y.noDependencyMatches,noCandidates:y.noDependencyCandidates,remove:y.removeDependency}),[y.dependencySearchPlaceholder,y.linkDependencies,y.linkedDependencies,y.noDependencyCandidates,y.noDependencyMatches,y.removeDependency]),Pt=x?.dependencies.map(e=>`${e.id}:${e.title}`).join(`\0`)??``,Ft=(0,R.useMemo)(()=>m(o.get(`returnTo`),`/`,[`/projects`,`/chat`,`/notes`,`/tasks`]),[o]),It=(0,R.useCallback)(e=>t===`modal`&&n?d(n,e):p(`/tasks/${encodeURIComponent(e)}`,Ft),[n,t,Ft]);U.current=x;let G=(0,R.useCallback)((e,t)=>{ze(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]);(0,R.useEffect)(()=>{P(null),W(null),ft(!1),Tt.current=null,V(!1),At(null),Mt(!1)},[e]),(0,R.useEffect)(()=>{let e=!0;return Ne().then(t=>{e&&Qe(t.items)}).catch(()=>void 0),()=>{e=!1}},[ne]),(0,R.useEffect)(()=>{if(!le||le.source===`user`)return;At(le);let e=window.setTimeout(()=>At(null),3500);return()=>window.clearTimeout(e)},[le]),(0,R.useEffect)(()=>{let t=x?.task.projectId,n=x?.dependencies??[];if(!t){Dt.current=null,We(null),He(n);return}Dt.current!==t&&(Dt.current=t,We(null));let r=!0;return he(t).then(t=>{if(!r)return;We(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});He([...i.values()])}).catch(()=>{r&&He(n)}),()=>{r=!1}},[Pt,x?.task.projectId,e]);let K=(0,R.useCallback)(async(t,n=`command`)=>{let r=U.current;if(r){G(n,!0),P(null);try{await j(await pe(e,t,r.task.version),{revalidate:!1})}catch{P(y.actionFailed)}finally{G(n,!1)}}},[y.actionFailed,j,G,e]),q=(0,R.useCallback)(async(t,n)=>{let r=U.current;if(!r)return!1;n&&G(n,!0),P(null);try{return await j(ve(e,t,r.task.version),{optimisticData:qe(r,t),populateCache:!0,revalidate:!1,rollbackOnError:!0}),!0}catch{return P(y.actionFailed),!1}finally{n&&G(n,!1)}},[y.actionFailed,j,G,e]),Lt=()=>{x&&(Tt.current={value:x.task.title,version:x.task.version},W(null),mt(x.task.title),ft(!0))},Rt=()=>{St.current=!0,mt(U.current?.task.title??``),Tt.current=null,W(null),ft(!1),queueMicrotask(()=>{St.current=!1})},zt=async(e=!1)=>{if(St.current){St.current=!1;return}let t=U.current;if(!t||F.has(`title`))return;let n=pt.trim();if(!n){Rt();return}let r=Tt.current;if(!e&&Ke(r,t.task.version,t.task.title,n)){W(`title`);return}if(n===t.task.title){Rt();return}await q({title:n},`title`)&&(Tt.current=null,W(null),ft(!1))},Bt=async()=>{if(!x)return;if(Ct.current){Ct.current=!1;return}let e=gt.trim(),t=Et.current;if(Ke(t,x.task.version,x.task.body??``,e)){W(`description`);return}if(gt===wt.current||e===(x.task.body??``).trim()){V(!1);return}await q({body:e||null})&&(W(null),V(!1))},Vt=(0,R.useCallback)(async e=>{let t=U.current;if(!(!t||e===t.task.phase)){if(t.task.phase===`closed`){await K({type:`reopen`,phase:e===`closed`?`ready`:e},`phase`);return}if(e===`closed`){await K({type:`close`,resolution:`done`},`phase`);return}await K({type:`move`,phase:e},`phase`)}},[K]),Ht=(0,R.useCallback)(e=>{q({priority:e},`priority`)},[q]),Ut=(0,R.useCallback)(e=>{q({dueAt:Ze(e)},`dueAt`)},[q]),Wt=(0,R.useCallback)(e=>{vt(e);try{window.localStorage.setItem(at,String(e))}catch{}},[]),Gt=(0,R.useCallback)(e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`&&e.key!==`Home`)return;e.preventDefault();let t=xt.current?.clientWidth??0;Wt(st(e.key===`Home`?ot:H+(e.key===`ArrowLeft`?2:-2),t))},[H,Wt]),Kt=(0,R.useCallback)(e=>{if(!window.matchMedia(`(min-width: 1024px)`).matches)return;let t=xt.current;if(!t)return;e.preventDefault();let n=e.currentTarget,r=e.pointerId;n.setPointerCapture(r),bt(!0);let i=H,a=0,o=()=>{a=0,t.style.setProperty(`--task-chat-panel-width`,`${i}%`)},s=e=>{let n=t.getBoundingClientRect();i=st((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{}bt(!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)},[H,Wt]),qt=(0,R.useCallback)(async t=>{let n=U.current;if(n){G(`dependencies`,!0),P(null);try{await j(await Ee(e,t,n.task.version),{revalidate:!1})}catch{P(y.dependencyUpdateFailed)}finally{G(`dependencies`,!1)}}},[y.dependencyUpdateFailed,j,G,e]),Jt=(0,R.useCallback)(async t=>{let n=U.current;if(!(!n||!t||t===n.conversation.currentExecutorAgentId)){G(`delegateAgentId`,!0),P(null);try{await j(await Se(e,t,n.task.version),{revalidate:!1})}catch{P(y.actionFailed)}finally{G(`delegateAgentId`,!1)}}},[y.actionFailed,j,G,e]),Yt=(0,R.useCallback)(async()=>{G(`delete`,!0),P(null);try{await oe(e),r?r():g(Ft,{replace:!0})}catch(e){P(e instanceof Error?e.message:y.actionFailed)}finally{G(`delete`,!1)}},[y.actionFailed,g,r,Ft,G,e]),Xt=(0,R.useCallback)(async(t,n)=>{let r=U.current;if(r){G(`acceptance`,!0),P(null);try{await j(await ge(e,t,n,r.task.version,r.task.latestContractVersion),{revalidate:!1})}catch{P(y.actionFailed),await j()}finally{G(`acceptance`,!1)}}},[y.actionFailed,j,G,e]);if((0,R.useLayoutEffect)(()=>{if(t!==`modal`)return b({startExtra:(0,z.jsx)(s,{to:Ft,className:`flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":y.backToWork,children:(0,z.jsx)(se,{className:`size-4`})}),main:x?(0,z.jsx)(`p`,{className:`truncate text-sm font-semibold text-fg`,children:B?`${B} / ${y.taskLabel}`:y.taskLabel}):null,end:null}),re},[re,y.backToWork,y.taskLabel,x,t,B,Ft,b]),T&&!x)return(0,z.jsx)(`div`,{className:t===`modal`?`p-5 text-sm text-danger`:`mx-auto max-w-3xl p-6 text-sm text-danger`,children:y.taskNotFound});if(!x)return(0,z.jsx)(`div`,{className:t===`modal`?`p-5`:`mx-auto max-w-4xl p-4 sm:p-6`,children:(0,z.jsx)(Ye,{})});let Zt=x.waits[0],J=Le(x),Qt=J.length>0&&J.every(e=>e.status===`passed`),$t=x.waits.find(e=>e.kind===`paused`),Y=x.receipts[0],en=lt(x),tn=y.detailStatuses[en],nn=x.task.body?.trim()||x.task.contract?.objective.trim(),rn=x.allowedCommands.includes(`mark_ready`),an=x.allowedCommands.includes(`start`),on=x.allowedCommands.includes(`add_wait`),sn=!Zt&&Qt&&x.task.phase===`review`&&x.allowedCommands.includes(`close`),cn=x.allowedCommands.includes(`reopen`),X=x.conversation.activeConversationId,ln=x.conversation.currentExecutorAgentId??x.task.delegateAgentId??x.task.ownerId,un=Je.find(e=>e.id===ln),dn=!!(X&&ie[X]?.open),fn=x.attention.some(e=>e.kind===`input_required`||e.kind===`approval_required`),pn=J.filter(e=>e.status===`passed`).length,mn=x.context.filter(e=>e.role===`deliverable`),hn=new Set(x.runs.filter(e=>e.contractVersion===x.task.latestContractVersion).map(e=>e.id)),gn=[...new Map(x.receipts.filter(e=>hn.has(e.runId)).flatMap(e=>e.evidence.filter(e=>e.kind===`artifact`)).map(e=>[e.uri??e.title,e])).values()],_n=x.context.filter(e=>e.role!==`deliverable`),vn=x.runs.filter(e=>e.executorKind===`workflow`&&!e.parentRunId),yn=[...new Set(vn.map(e=>e.executorRef.workflowId).filter(e=>typeof e==`string`))],bn=ye?.automations.filter(t=>t.action.kind===`task_command`&&t.action.taskId===e)??[],Z=x.sessions.filter((e,t,n)=>n.findIndex(t=>t.conversationId===e.conversationId)===t),xn=x.task.contract?.expectedOutputs??[],Sn=x.task.contract?.constraints??[],Cn=x.task.contract?.approvalRequired??[],wn=x.task.contract?.assumptions??[],Tn=x.task.contract?.risks??[],En=Sn.length>0||Cn.length>0||wn.length>0||Tn.length>0,Q=(...e)=>!!kt?.changedFields.some(t=>e.includes(t)),Dn=x.allowedCommands.includes(`move`),$=F.has(`command`),On=F.has(`delete`),kn=x.runs.find(e=>!e.parentRunId&&[`queued`,`running`,`waiting`,`verifying`].includes(e.status)),An=kn!==void 0,jn=`/automations?action=create&taskId=${encodeURIComponent(x.task.id)}${x.task.projectId?`&projectId=${encodeURIComponent(x.task.projectId)}`:``}`,Mn=(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[rn?(0,z.jsxs)(O,{className:`min-h-9 px-3 py-1.5 text-xs`,variant:`primary`,disabled:$,onClick:()=>void K({type:`mark_ready`}),children:[(0,z.jsx)(Ie,{className:`size-4`}),y.scheduleTask]}):null,$t&&x.allowedCommands.includes(`resolve_wait`)?(0,z.jsxs)(O,{className:`min-h-9 px-3 py-1.5 text-xs`,variant:`primary`,disabled:$,onClick:()=>void K({type:`resolve_wait`,waitId:$t.id}),children:[(0,z.jsx)(Ie,{className:`size-4`}),y.resumeTask]}):null,!Zt&&an&&ln?(0,z.jsxs)(O,{className:`min-h-9 px-3 py-1.5 text-xs`,variant:`primary`,disabled:$,onClick:()=>void K({type:`start`,executor:{kind:`agent`,agentId:ln}}),children:[(0,z.jsx)(Ie,{className:`size-4`}),y.runTask]}):null,sn?(0,z.jsxs)(O,{className:`min-h-9 px-3 py-1.5 text-xs`,variant:`primary`,disabled:$,onClick:()=>void K({type:`close`,resolution:`done`}),children:[(0,z.jsx)(c,{className:`size-4`}),y.approveTask]}):null,cn?(0,z.jsxs)(O,{className:`min-h-9 px-3 py-1.5 text-xs`,variant:`primary`,disabled:$,onClick:()=>void K({type:`reopen`,phase:`ready`}),children:[(0,z.jsx)(Ie,{className:`size-4`}),y.reopenTask]}):null,!$t&&on?(0,z.jsxs)(O,{variant:`ghost`,className:`min-h-9 px-3 py-1.5 text-xs`,disabled:$,onClick:()=>void K({type:`add_wait`,wait:{kind:`paused`,reason:`Paused by user`,condition:{}}}),children:[(0,z.jsx)(E,{className:`size-4`}),y.pauseTask]}):null,x.task.phase===`closed`?null:(0,z.jsx)(O,{asChild:!0,variant:`ghost`,className:`min-h-9 px-3 py-1.5 text-xs`,children:(0,z.jsxs)(s,{to:jn,children:[(0,z.jsx)(xe,{className:`size-4`}),y.scheduleRecurringTask]})}),(0,z.jsxs)(Me,{children:[(0,z.jsx)(me,{asChild:!0,children:(0,z.jsx)(O,{type:`button`,variant:`ghost`,className:`size-9 p-0`,disabled:$||On,"aria-label":y.moreActions,children:(0,z.jsx)(l,{className:`size-4`,"aria-hidden":!0})})}),(0,z.jsx)(ke,{children:(0,z.jsxs)(_e,{align:`end`,sideOffset:6,className:`z-[100] min-w-44 rounded-lg border border-edge bg-surface-overlay p-1 shadow-popover`,children:[kn?(0,z.jsx)(N,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>{G(`command`,!0),P(null),j(de(e,kn.id,kn.version),{revalidate:!1}).catch(()=>P(y.actionFailed)).finally(()=>G(`command`,!1))},children:y.cancelActiveRun}):null,kn?(0,z.jsx)(Ce,{className:`my-1 h-px bg-edge`}):null,x.task.phase===`closed`?null:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(N,{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 K({type:`close`,resolution:`cancelled`}),children:y.cancelTask}),(0,z.jsx)(Ce,{className:`my-1 h-px bg-edge`})]}),(0,z.jsx)(N,{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(An){P(y.deleteActiveTaskBlocked);return}Mt(!0)},children:y.deleteTask})]})})]})]});return(0,z.jsxs)(`div`,{ref:xt,className:`flex h-full min-h-0 flex-col overflow-hidden ${yt?`lg:cursor-col-resize lg:select-none`:``}`,style:{"--task-chat-panel-width":`${H}%`},children:[(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto lg:flex-row lg:overflow-hidden`,children:[(0,z.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,z.jsxs)(`header`,{className:_(`shrink-0 border-b border-edge-subtle bg-surface-panel px-5 py-4 sm:px-6`,Q(`title`)&&`task-detail-live-update`),children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-x-6 gap-y-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[B?(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,z.jsx)(C,{className:`size-3.5`,"aria-hidden":!0}),B]}):null,B?(0,z.jsx)(`span`,{"aria-hidden":`true`,children:`/`}):null,(0,z.jsx)(`span`,{children:y.taskLabel}),kt?(0,z.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,role:`status`,children:kt.source===`agent`?v===`zh`?`Agent 刚刚更新`:`Updated by Agent`:v===`zh`?`执行结果已同步`:`Execution result synced`}):null]}),$e?(0,z.jsx)(`textarea`,{autoFocus:!0,"data-task-inline-editor":!0,"aria-label":v===`zh`?`任务标题`:`Task title`,rows:2,value:pt,onFocus:e=>{Tt.current?.value===pt&&(e.currentTarget.setSelectionRange(0,0),e.currentTarget.scrollTop=0)},onChange:e=>mt(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,z.jsx)(I,{content:x.task.title,contentKey:`${e}:title`,language:v,previewHeight:56,className:`mt-2 max-w-3xl`,children:(0,z.jsx)(`h1`,{className:`break-words text-xl font-semibold leading-7 text-fg`,children:(0,z.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:x.task.title,onClick:Lt,children:x.task.title})})}),Ot===`title`?(0,z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,z.jsx)(`span`,{children:v===`zh`?`Agent 在你编辑期间更新了标题。`:`The Agent updated the title while you were editing.`}),(0,z.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:Rt,children:v===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,z.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,disabled:F.has(`title`),onClick:()=>void zt(!0),children:v===`zh`?`保留我的修改`:`Keep my changes`})]}):null]}),(0,z.jsx)(`span`,{className:_(`shrink-0 rounded-full px-2.5 py-1 text-xs font-medium`,ut(en)),children:tn})]}),(0,z.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-4 gap-y-2 text-xs text-fg-muted`,children:[(0,z.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2`,children:[ln?(0,z.jsx)(A,{agentId:ln,avatar:un?.avatar,size:20,className:`shrink-0`}):null,(0,z.jsxs)(`span`,{className:`min-w-0 break-words [overflow-wrap:anywhere]`,children:[y.executorLabel,` · `,un?.name??ln??y.unassigned]})]}),(0,z.jsx)(`span`,{className:`text-fg-subtle`,children:y.updatedAt.replace(`{{date}}`,k(x.task.updatedAt,v))})]}),(0,z.jsx)(`div`,{className:`mt-4 border-t border-edge-subtle pt-3`,children:Mn}),Te?(0,z.jsx)(`p`,{className:`mt-3 text-sm text-danger`,children:Te}):null]}),(0,z.jsxs)(`section`,{className:`min-w-0 p-5 sm:p-6`,children:[(0,z.jsxs)(`section`,{className:`mb-4 overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel shadow-surface`,children:[(0,z.jsxs)(`div`,{className:`border-b border-edge-subtle p-5`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:v===`zh`?`目标与验收`:`Goal and acceptance`}),J.length>0?(0,z.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2.5 py-1 text-xs text-fg-muted`,children:y.criteriaProgress.replace(`{{verified}}`,String(pn)).replace(`{{total}}`,String(J.length))}):null]}),(0,z.jsx)(I,{content:x.task.contract?.objective||x.task.title,contentKey:`${e}:goal`,language:v,markdown:!1,previewHeight:72,className:`mt-3 text-sm leading-6 text-fg`})]}),(0,z.jsxs)(`div`,{className:`p-5`,children:[(0,z.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:y.successDefinition}),J.length>0?(0,z.jsx)(`ul`,{className:`mt-3 space-y-3`,children:J.map((t,n)=>(0,z.jsxs)(`li`,{className:`flex items-start gap-2.5 text-sm leading-5 text-fg`,children:[(0,z.jsx)(t.status===`passed`?c:t.status===`failed`?je:Oe,{className:_(`mt-0.5 size-4 shrink-0`,t.status===`passed`?`text-success`:t.status===`failed`?`text-danger`:`text-fg-subtle`),"aria-hidden":!0}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(I,{content:t.text,contentKey:`${e}:criterion:${n}`,language:v,markdown:!1,previewHeight:60}),t.evidence.length>0?(0,z.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-x-2 text-xs leading-5 text-fg-muted`,children:[(0,z.jsx)(`span`,{children:v===`zh`?`依据:`:`Evidence:`}),t.evidence.map(e=>e.uri&&/^https?:\/\//.test(e.uri)?(0,z.jsx)(`a`,{className:`text-accent hover:underline`,href:e.uri,target:`_blank`,rel:`noreferrer`,children:e.title},e.title):(0,z.jsx)(`span`,{children:e.title},e.title))]}):null,t.review?(0,z.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[v===`zh`?`人工判定`:`Reviewed by user`,` · `,k(t.review.reviewedAt,v)]}):null,t.method===`model_reviewed`?(0,z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:v===`zh`?`模型审阅:${t.verificationStatus===`passed`?`通过`:t.verificationStatus===`failed`?`未通过`:`未核验`}`:`Model review: ${t.verificationStatus===`passed`?`passed`:t.verificationStatus===`failed`?`failed`:`unverified`}`}):null,t.note?(0,z.jsx)(I,{content:t.note,contentKey:`${e}:criterion-note:${n}`,language:v,markdown:!1,previewHeight:60,className:`mt-1 text-xs text-fg-muted`}):null]}),x.task.phase!==`closed`&&x.task.contract?.acceptancePolicy!==`verified_auto`?(0,z.jsxs)(Me,{children:[(0,z.jsx)(me,{asChild:!0,children:(0,z.jsx)(O,{type:`button`,variant:`ghost`,className:`h-7 shrink-0 px-2 text-xs`,disabled:F.has(`acceptance`),children:v===`zh`?`判定`:`Review`})}),(0,z.jsx)(ke,{children:(0,z.jsxs)(_e,{align:`end`,sideOffset:4,className:`z-[100] min-w-32 rounded-lg border border-edge bg-surface-overlay p-1 shadow-popover`,children:[(0,z.jsx)(N,{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:v===`zh`?`确认通过`:`Mark passed`}),(0,z.jsx)(N,{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:v===`zh`?`标记未通过`:`Mark failed`})]})})]}):null]},`${n}-${t.text}`))}):(0,z.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:y.noDefinition})]})]}),x.attention.length>0?(0,z.jsxs)(`section`,{className:_(`mb-4 rounded-xl border border-warning/20 bg-warning/10 p-4`,Q(`attention`)&&`task-detail-live-update`),children:[(0,z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:fn?y.needsAttention:y.waitingStatus}),(0,z.jsx)(`ul`,{className:`mt-2 space-y-1.5 text-sm leading-6 text-fg-muted`,children:x.attention.map((t,n)=>(0,z.jsxs)(`li`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,z.jsx)(I,{content:t.summary,contentKey:`${e}:attention:${t.kind}:${n}`,language:v,markdown:!1,previewHeight:72,className:`min-w-0 flex-1`}),t.kind===`input_required`||t.kind===`approval_required`?(0,z.jsx)(s,{className:`inline-flex min-h-11 items-center rounded-lg bg-surface-panel px-3 text-sm font-medium text-accent`,to:f(e),children:v===`zh`?t.kind===`approval_required`?`查看并决定`:`补充信息`:t.kind===`approval_required`?`Review decision`:`Provide information`}):null]},`${t.kind}-${n}`))})]}):null,x.task.phase!==`closed`&&!$t&&x.waits.filter(e=>(e.kind===`user_input`||e.kind===`approval`&&typeof e.condition.capability==`string`)&&e.condition.type!==`connection`).map(e=>(0,z.jsx)(Be,{wait:e,detail:x,zh:v===`zh`,onUpdated:e=>{j(e,{revalidate:!1})}},e.id)),(0,z.jsx)(`div`,{className:`mb-4`,children:(0,z.jsx)(Ge,{taskId:e},e)}),mn.length>0||gn.length>0||xn.length>0?(0,z.jsxs)(`section`,{className:`mb-4 rounded-xl border border-edge-subtle bg-surface-panel p-5 shadow-surface`,children:[(0,z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:v===`zh`?`交付物`:`Deliverables`}),mn.length>0||gn.length>0?(0,z.jsxs)(`ul`,{className:`mt-3 space-y-2`,children:[mn.map(t=>(0,z.jsxs)(`li`,{className:`rounded-lg bg-surface-hover p-3 text-sm`,children:[(0,z.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:y.contextKindLabels[t.targetKind]}),t.targetKind===`url`&&/^https?:\/\//.test(t.targetId)?(0,z.jsx)(I,{content:t.title??t.targetId,contentKey:`${e}:deliverable:${t.id}`,language:v,previewHeight:60,className:`mt-1`,children:(0,z.jsx)(`a`,{className:`block break-all text-accent hover:underline`,href:t.targetId,target:`_blank`,rel:`noreferrer`,children:t.title??t.targetId})}):(0,z.jsx)(I,{content:t.title??t.targetId,contentKey:`${e}:deliverable:${t.id}`,language:v,markdown:!1,previewHeight:60,className:`mt-1 text-fg`})]},t.id)),gn.map(t=>(0,z.jsxs)(`li`,{className:`rounded-lg bg-surface-hover p-3 text-sm`,children:[(0,z.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:v===`zh`?`执行产物`:`Run artifact`}),t.uri&&/^https?:\/\//.test(t.uri)?(0,z.jsx)(I,{content:t.title,contentKey:`${e}:artifact:${t.uri??t.title}`,language:v,previewHeight:60,className:`mt-1`,children:(0,z.jsx)(`a`,{className:`block break-all text-accent hover:underline`,href:t.uri,target:`_blank`,rel:`noreferrer`,children:t.title})}):(0,z.jsx)(I,{content:t.title,contentKey:`${e}:artifact:${t.uri??t.title}`,language:v,markdown:!1,previewHeight:60,className:`mt-1 text-fg`})]},t.uri??t.title))]}):(0,z.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:v===`zh`?`尚未关联交付物`:`No deliverables linked yet`}),xn.length>0?(0,z.jsxs)(`div`,{className:`mt-4 border-t border-edge-subtle pt-3`,children:[(0,z.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:y.expectedOutputs}),(0,z.jsx)(`div`,{className:`mt-2`,children:(0,z.jsx)(dt,{contentKey:`${e}:expectedOutputs`,items:xn,empty:y.noDefinition})})]}):null]}):null,(0,z.jsxs)(`section`,{className:`mb-4 rounded-xl border border-edge-subtle bg-surface-panel p-5 shadow-surface`,children:[(0,z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:v===`zh`?`关联内容`:`Related work`}),Z.length>0||x.runs.length>0||bn.length>0||x.dependencies.length>0||x.dependents.length>0?(0,z.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[Z.length>0?(0,z.jsxs)(`div`,{className:`rounded-lg bg-surface-hover p-3`,children:[(0,z.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:v===`zh`?`对话 · ${Z.length}`:`Conversations · ${Z.length}`}),(0,z.jsx)(Ve,{contentKey:`${e}:sessions`,language:v,className:`mt-2`,children:Z.map(t=>(0,z.jsx)(`li`,{children:(0,z.jsx)(s,{className:`block break-words [overflow-wrap:anywhere] text-sm text-accent hover:underline`,to:t.conversationId===X?f(e):`/chat/${encodeURIComponent(t.conversationId)}`,children:t.conversationId===X?v===`zh`?`当前执行对话`:`Current execution chat`:t.role===`discussion`?v===`zh`?`关联讨论`:`Linked discussion`:v===`zh`?`历史执行对话`:`Earlier execution chat`})},t.id))})]}):null,x.runs.length>0?(0,z.jsxs)(`div`,{className:`rounded-lg bg-surface-hover p-3`,children:[(0,z.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:v===`zh`?`执行 · ${x.runs.length}`:`Runs · ${x.runs.length}`}),(0,z.jsxs)(`p`,{className:`mt-2 text-sm text-fg`,children:[v===`zh`?`最近执行:`:`Latest run: `,Y?y.receiptStatuses[Y.status]:tn]}),vn.length>0?(0,z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:v===`zh`?`含 ${vn.length} 次工作流执行`:`${vn.length} workflow runs`}):null,yn.map(e=>(0,z.jsxs)(s,{className:`mt-1 block break-words [overflow-wrap:anywhere] text-xs text-accent hover:underline`,to:`/workflows/${encodeURIComponent(e)}`,children:[v===`zh`?`工作流:`:`Workflow: `,e]},e))]}):null,bn.length>0?(0,z.jsxs)(`div`,{className:`rounded-lg bg-surface-hover p-3`,children:[(0,z.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:v===`zh`?`自动化 · ${bn.length}`:`Automations · ${bn.length}`}),(0,z.jsx)(Ve,{contentKey:`${e}:automations`,language:v,className:`mt-2`,children:bn.map(e=>(0,z.jsx)(`li`,{children:(0,z.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,x.dependencies.length>0||x.dependents.length>0?(0,z.jsxs)(`div`,{className:`rounded-lg bg-surface-hover p-3`,children:[(0,z.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:y.taskRelations}),(0,z.jsx)(`p`,{className:`mt-2 text-sm text-fg`,children:v===`zh`?`${x.dependencies.length} 个前置任务 · ${x.dependents.length} 个后续任务`:`${x.dependencies.length} prerequisites · ${x.dependents.length} dependents`})]}):null]}):(0,z.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:v===`zh`?`还没有关联内容`:`No related work yet`}),(0,z.jsx)(`div`,{className:`mt-4 border-t border-edge-subtle pt-3`,children:(0,z.jsx)(Re,{resource:{kind:`task`,id:x.task.id,revision:String(x.task.version)},disabled:$e||ht||F.size>0})})]}),(0,z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,z.jsxs)(`main`,{className:`min-w-0 overflow-hidden rounded-xl bg-surface-panel shadow-surface divide-y divide-edge-subtle`,children:[(0,z.jsxs)(`section`,{className:_(`p-5`,Q(`body`)&&`task-detail-live-update`),children:[(0,z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:y.taskDescription}),ht?(0,z.jsx)(`textarea`,{autoFocus:!0,"data-task-inline-editor":!0,rows:6,value:gt,onChange:e=>_t(e.target.value),onBlur:()=>void Bt(),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),Ct.current=!0,_t(x.task.body??x.task.contract?.objective??``),V(!1),queueMicrotask(()=>{Ct.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,z.jsxs)(`div`,{className:`mt-2`,children:[nn&&nn!==x.task.title?(0,z.jsx)(I,{content:nn,contentKey:`${e}:description`,language:v}):(0,z.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:y.noTaskDescription}),(0,z.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=x.task.body??x.task.contract?.objective??``;wt.current=e,Et.current={value:x.task.body??``,version:x.task.version},W(null),_t(e),V(!0)},children:v===`zh`?`编辑说明`:`Edit description`})]}),Ot===`description`?(0,z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,z.jsx)(`span`,{children:v===`zh`?`Agent 在你编辑期间更新了描述。`:`The Agent updated the description while you were editing.`}),(0,z.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:()=>{_t(x.task.body??``),W(null),V(!1)},children:v===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,z.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,onClick:()=>void q({body:gt.trim()||null}).then(e=>{e&&(W(null),V(!1))}),children:v===`zh`?`保留我的修改`:`Keep my changes`})]}):null]}),En?(0,z.jsxs)(`section`,{className:_(`p-5`,Q(`contract`)&&`task-detail-live-update`),children:[(0,z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:y.taskDefinition}),(0,z.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:v===`zh`?`执行边界及补充背景`:`Execution boundaries and supporting context`}),Sn.length>0?(0,z.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[(0,z.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted hover:text-fg`,children:y.constraints}),(0,z.jsx)(`div`,{className:`mt-3`,children:(0,z.jsx)(dt,{contentKey:`${e}:constraints`,items:Sn,empty:y.noDefinition})})]}):null,Cn.length>0?(0,z.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[(0,z.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted hover:text-fg`,children:y.approvalRequired}),(0,z.jsx)(`div`,{className:`mt-3`,children:(0,z.jsx)(dt,{contentKey:`${e}:approvalRequired`,items:Cn,empty:y.noDefinition})})]}):null,wn.length>0?(0,z.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[(0,z.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted hover:text-fg`,children:y.contextAssumptions}),(0,z.jsx)(`div`,{className:`mt-3`,children:(0,z.jsx)(dt,{contentKey:`${e}:assumptions`,items:wn,empty:y.noDefinition})})]}):null,Tn.length>0?(0,z.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[(0,z.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted hover:text-fg`,children:y.contextRisks}),(0,z.jsx)(`div`,{className:`mt-3`,children:(0,z.jsx)(dt,{contentKey:`${e}:risks`,items:Tn,empty:y.noDefinition})})]}):null]}):null,Y?(0,z.jsxs)(`section`,{className:_(`p-5`,Q(`runs`,`receipts`)&&`task-detail-live-update`),children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:y.latestResult}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:v===`zh`?Y.completionVerdict===`achieved`?`本次执行报告目标已达成,请结合下方验证依据验收。`:`这是阶段性结果,尚不能代表任务全部完成。`:Y.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,z.jsxs)(`span`,{className:`rounded-full bg-surface-hover px-2.5 py-1 text-xs text-fg-muted`,children:[y.receiptStatuses[Y.status],` · `,y.verificationStatuses[Y.verification.status]]})]}),(0,z.jsx)(I,{content:Y.summary,contentKey:`${e}:result:${Y.runId}`,language:v,className:`mt-3`}),Y.remainingWork.length>0?(0,z.jsxs)(`div`,{className:`mt-4`,children:[(0,z.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:y.remainingWork}),(0,z.jsx)(`div`,{className:`mt-2`,children:(0,z.jsx)(dt,{contentKey:`${e}:remaining:${Y.runId}`,items:Y.remainingWork,empty:y.noRemainingWork})})]}):null,Y.nextAction?(0,z.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-hover p-3`,children:[(0,z.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:y.nextAction}),(0,z.jsx)(I,{content:Y.nextAction,contentKey:`${e}:next:${Y.runId}`,language:v,markdown:!1,previewHeight:72,className:`mt-1 text-sm text-fg`})]}):null,(0,z.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[(0,z.jsx)(O,{className:`border-0 bg-surface-hover px-2 py-1 text-xs shadow-none`,variant:`secondary`,onClick:()=>void Fe(Y.runId,`helpful`),children:y.doneWell}),(0,z.jsx)(O,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>void Fe(Y.runId,`not_helpful`),children:y.needsFix})]}),(0,z.jsx)(Ue,{evidence:Y.evidence,projectId:x.task.projectId,conversationId:X??void 0,language:v}),x.receipts.length>1?(0,z.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[(0,z.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted hover:text-fg`,children:y.executionHistory.replace(`{{count}}`,String(x.receipts.length-1))}),(0,z.jsx)(`div`,{className:`mt-3 space-y-3`,children:x.receipts.slice(1).map(t=>(0,z.jsx)(`article`,{className:`rounded-lg bg-surface-hover p-3`,children:(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,z.jsx)(I,{content:t.summary,contentKey:`${e}:result:${t.runId}`,language:v,className:`min-w-0 flex-1`}),(0,z.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:y.receiptStatuses[t.status]})]})},t.runId))})]}):null]}):null,_n.length>0?(0,z.jsxs)(`section`,{className:_(`p-5`,Q(`context`)&&`task-detail-live-update`),children:[(0,z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:y.contextUsed}),(0,z.jsx)(`ul`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:_n.map(e=>(0,z.jsxs)(`li`,{className:`min-w-0 rounded-lg bg-surface-hover p-2.5`,children:[(0,z.jsxs)(`span`,{className:`text-[11px] text-fg-subtle`,children:[y.contextRoleLabels[e.role],` · `,y.contextKindLabels[e.targetKind]]}),e.targetKind===`url`&&/^https?:\/\//.test(e.targetId)?(0,z.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,z.jsx)(`p`,{className:`mt-1 break-words text-sm text-fg`,children:e.title??e.targetId})]},e.id))})]}):null]}),(0,z.jsxs)(`aside`,{className:`min-w-0 overflow-hidden rounded-xl bg-surface-panel shadow-surface divide-y divide-edge-subtle`,children:[(0,z.jsxs)(`section`,{className:_(`p-5`,Q(`phase`,`resolution`,`priority`,`dueAt`,`delegateAgentId`)&&`task-detail-live-update`),children:[(0,z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:y.taskProperties}),(0,z.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[(0,z.jsx)(et,{value:x.task.phase,disabled:F.has(`phase`),canMove:Dn,canApprove:sn,canReopen:cn,language:v,label:y.taskPhase,onChange:Vt}),(0,z.jsx)(tt,{value:x.task.priority,disabled:F.has(`priority`),label:y.priority,labels:y.priorityLabels,onChange:Ht}),(0,z.jsx)(nt,{value:Xe(x.task.dueAt),disabled:F.has(`dueAt`),label:y.dueDate,onChange:Ut}),(0,z.jsx)(rt,{value:x.conversation.currentExecutorAgentId??``,disabled:F.has(`delegateAgentId`),label:y.executorLabel,unassignedLabel:y.unassigned,agents:Je,onChange:Jt})]})]}),(0,z.jsxs)(`section`,{className:_(`p-5`,Q(`dependencies`)&&`task-detail-live-update`),children:[(0,z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:y.taskRelations}),(0,z.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:y.dependencies}),(0,z.jsx)(it,{candidates:L,selected:x.dependencies,disabled:F.has(`dependencies`),labels:Nt,getTaskHref:It,onChange:qt})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:y.dependents}),x.dependents.length>0?(0,z.jsx)(`div`,{className:`space-y-1.5`,children:x.dependents.map(t=>(0,z.jsx)(I,{content:t.title,contentKey:`${e}:dependent:${t.id}`,language:v,previewHeight:72,className:`rounded-lg bg-surface-hover p-2.5`,children:(0,z.jsx)(s,{to:It(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,z.jsx)(`p`,{className:`text-sm text-fg-subtle`,children:y.noDependents})]})]})]})]})]})]})]}),(0,z.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":v===`zh`?`调整任务信息和 Agent 对话的宽度`:`Resize task details and Agent chat`,"aria-valuemin":30,"aria-valuemax":60,"aria-valuenow":Math.round(H),tabIndex:0,onPointerDown:Kt,onKeyDown:Gt,onDoubleClick:()=>Wt(ot),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 ${yt?`bg-surface-hover`:``}`,children:(0,z.jsx)(`div`,{className:`w-px bg-edge-strong/70 transition-colors group-hover:bg-accent group-focus-visible:bg-accent`})}),(0,z.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,z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge-subtle px-4 py-3`,children:[(0,z.jsx)(`h2`,{className:`text-sm font-medium text-fg-muted`,children:v===`zh`?`执行对话`:`Execution chat`}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[Z.length>1?(0,z.jsxs)(Me,{children:[(0,z.jsx)(me,{asChild:!0,children:(0,z.jsx)(O,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,children:v===`zh`?`${Z.length} 段对话`:`${Z.length} conversations`})}),(0,z.jsx)(ke,{children:(0,z.jsx)(_e,{align:`end`,sideOffset:6,className:`z-[100] min-w-52 rounded-lg border border-edge bg-surface-overlay p-1 shadow-popover`,children:Z.map(t=>(0,z.jsx)(N,{asChild:!0,children:(0,z.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===X?f(e):`/chat/${encodeURIComponent(t.conversationId)}`,children:t.conversationId===X?v===`zh`?`当前执行对话`:`Current execution chat`:t.role===`discussion`?v===`zh`?`关联讨论`:`Linked discussion`:v===`zh`?`历史执行对话`:`Earlier execution chat`})},t.id))})})]}):null,X?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(O,{type:`button`,variant:`ghost`,className:_(`size-8 p-0`,dn&&`bg-surface-hover text-fg`),"aria-label":v===`zh`?`项目文件`:`Project files`,"aria-pressed":dn,onClick:()=>{ce.getState().openFiles(X),ae(X)},children:(0,z.jsx)(h,{className:`size-4`,"aria-hidden":!0})}),(0,z.jsx)(O,{asChild:!0,variant:`ghost`,className:`size-8 p-0`,children:(0,z.jsx)(s,{to:f(e),"aria-label":v===`zh`?`全屏打开对话`:`Open chat full screen`,children:(0,z.jsx)(u,{className:`size-4`,"aria-hidden":!0})})})]}):null]})]}),X?(0,z.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,z.jsx)(De,{embedded:!0,conversationId:X,taskId:e})}):ue?(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,z.jsxs)(`div`,{className:`max-w-xs`,children:[(0,z.jsx)(w,{className:`mx-auto size-8 animate-pulse text-fg-subtle`}),(0,z.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:v===`zh`?`正在创建任务会话`:`Creating task conversation`})]})}):M?(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,z.jsxs)(`div`,{className:`max-w-xs`,children:[(0,z.jsx)(w,{className:`mx-auto size-8 text-danger`}),(0,z.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:v===`zh`?`任务会话创建失败`:`Could not create task conversation`}),(0,z.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:M instanceof Error?M.message:String(M)})]})}):(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,z.jsxs)(`div`,{className:`max-w-xs`,children:[(0,z.jsx)(w,{className:`mx-auto size-8 text-fg-subtle`}),(0,z.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:v===`zh`?`等待任务会话`:`Waiting for a task conversation`}),(0,z.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:v===`zh`?`安排或开始任务后,Agent 的执行过程和持续对话会显示在这里。`:`Schedule or start the task to see the agent run and continue the conversation here.`})]})})]})]}),(0,z.jsx)(fe,{open:jt,title:y.deleteTaskTitle,description:y.deleteTaskDescription.replace(`{{title}}`,x.task.title),confirmLabel:y.confirmDeleteTask,cancelLabel:y.keepTask,destructive:!0,onConfirm:()=>{Mt(!1),Yt()},onCancel:()=>Mt(!1)})]})}function ht(){let e=(0,L.c)(2),{taskId:t}=o(),n=t===void 0?``:t,r;return e[0]===n?r=e[1]:(r=(0,z.jsx)(mt,{taskId:n,presentation:`page`}),e[0]=n,e[1]=r),r}function V(e){let t=(0,L.c)(41),{taskId:n,backgroundPath:r,workspacePanelWidth:i,onClose:a}=e,o=i===void 0?0:i,s=te(vt),c=Te(H),l=o>0,u;t[0]!==a||t[1]!==c?(u=e=>{e||(c(null),a())},t[0]=a,t[1]=c,t[2]=u):u=t[2];let d=s===`zh`?`关闭任务详情`:`Close task details`,f;t[3]!==a||t[4]!==c?(f=()=>{c(null),a()},t[3]=a,t[4]=c,t[5]=f):f=t[5];let p;t[6]!==d||t[7]!==f?(p=(0,z.jsx)(`button`,{type:`button`,tabIndex:-1,"data-task-modal-backdrop":!0,className:`fixed inset-0 z-[80] bg-black/45`,"aria-label":d,onClick:f}),t[6]=d,t[7]=f,t[8]=p):p=t[8];let m=l?`true`:`false`,h=`${o/2}px`,_=`${o}px`,v;t[9]!==h||t[10]!==_?(v={"--task-detail-workspace-offset":h,"--task-detail-workspace-width":_},t[9]=h,t[10]=_,t[11]=v):v=t[11];let ee=v,ne=s===`zh`?`任务详情`:`Task details`,S;t[12]===ne?S=t[13]:(S=(0,z.jsx)(ae,{className:`font-medium text-fg`,children:ne}),t[12]=ne,t[13]=S);let oe=s===`zh`?`查看并操作任务详情`:`View and manage task details`,C;t[14]===oe?C=t[15]:(C=(0,z.jsx)(y,{className:`sr-only`,children:oe}),t[14]=oe,t[15]=C);let se=s===`zh`?`关闭任务详情`:`Close task details`,w;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,z.jsx)(g,{className:`size-4`,"aria-hidden":!0}),t[16]=w):w=t[16];let T;t[17]===se?T=t[18]:(T=(0,z.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:(0,z.jsx)(b,{className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":se,children:w})}),t[17]=se,t[18]=T);let E;t[19]!==S||t[20]!==C||t[21]!==T?(E=(0,z.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-3 bg-surface-panel px-5 py-3.5`,children:[S,C,T]}),t[19]=S,t[20]=C,t[21]=T,t[22]=E):E=t[22];let D;t[23]!==a||t[24]!==c?(D=()=>{c(null),a()},t[23]=a,t[24]=c,t[25]=D):D=t[25];let O;t[26]!==r||t[27]!==D||t[28]!==n?(O=(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,z.jsx)(mt,{taskId:n,presentation:`modal`,backgroundPath:r,onDeleted:D})}),t[26]=r,t[27]=D,t[28]=n,t[29]=O):O=t[29];let k;t[30]!==ee||t[31]!==E||t[32]!==O||t[33]!==m?(k=(0,z.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":m,style:ee,onEscapeKeyDown:_t,onInteractOutside:gt,children:[E,O]}),t[30]=ee,t[31]=E,t[32]=O,t[33]=m,t[34]=k):k=t[34];let A;t[35]!==k||t[36]!==p?(A=(0,z.jsxs)(re,{children:[p,k]}),t[35]=k,t[36]=p,t[37]=A):A=t[37];let j;return t[38]!==u||t[39]!==A?(j=(0,z.jsx)(x,{modal:!1,open:!0,onOpenChange:u,children:A}),t[38]=u,t[39]=A,t[40]=j):j=t[40],j}function gt(e){let t=e.detail.originalEvent.target;t instanceof Element&&t.closest(`#app-workspace-panel, [data-task-modal-backdrop]`)&&e.preventDefault()}function _t(e){let t=e.target;t instanceof HTMLElement&&t.closest(`[data-task-inline-editor]`)&&e.preventDefault()}function H(e){return e.setPath}function vt(e){return e.language}function yt(e){return(0,z.jsx)(ye,{value:e.id,children:e.name||e.id},e.id)}function bt(e){return e.id}export{V as TaskDetailModal,ht as TaskDetailPage};
@@ -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{g as i}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as a}from"./markdown-view-B58RypQ4.js";import{t as o}from"./cn-0WouolD0.js";import{d as s}from"./tasks-PuIUgF9L.js";function c(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)continue;let r=e.evidence.filter(e=>n.evidenceTitles.includes(e.title)),i=n.status===`passed`&&s(e).has(t)?`passed`:n.status===`failed`?`failed`:`unverified`;a={text:t,status:i,evidence:r,runId:e.runId,verificationStatus:i,method:n.method,note:n.note};break}return i&&e.task.contract?.acceptancePolicy!==`verified_auto`?{...a,status:i.status,review:i}:e.task.contract?.acceptancePolicy===`manual`?{...a,status:`unverified`}:a})}var l=n(),u=e(t(),1),d=r();function f(e){let t=(0,l.c)(36),{content:n,contentKey:r,language:s,markdown:c,breaks:f,previewHeight:p,className:m,children:h}=e,g=c===void 0?!0:c,_=f===void 0?!1:f,v=p===void 0?240:p,y=(0,u.useId)(),b=(0,u.useRef)(null),[x,S]=(0,u.useState)(!1),[C,w]=i(),T;t[0]!==r||t[1]!==C?(T=C.getAll(`taskExpanded`).includes(r),t[0]=r,t[1]=C,t[2]=T):T=t[2];let E=T,D;t[3]===v?D=t[4]:(D=()=>{let e=b.current;if(!e)return;let t=()=>S(e.scrollHeight>v);if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},t[3]=v,t[4]=D);let O;t[5]!==n||t[6]!==v?(O=[n,v],t[5]=n,t[6]=v,t[7]=O):O=t[7],(0,u.useLayoutEffect)(D,O);let k=x&&!E,A;t[8]===m?A=t[9]:(A=o(`min-w-0`,m),t[8]=m,t[9]=A);let j;t[10]!==k||t[11]!==v?(j=k?{maxHeight:v,overflow:`hidden`,maskImage:`linear-gradient(to bottom, black calc(100% - ${Math.min(24,v/3)}px), transparent)`}:void 0,t[10]=k,t[11]=v,t[12]=j):j=t[12];let M;t[13]!==_||t[14]!==h||t[15]!==n||t[16]!==g?(M=h??(g?(0,d.jsx)(a,{content:n,compact:!0,breaks:_,className:`text-sm leading-6 text-fg`}):(0,d.jsx)(`p`,{className:`whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:n})),t[13]=_,t[14]=h,t[15]=n,t[16]=g,t[17]=M):M=t[17];let N;t[18]!==k||t[19]!==M?(N=(0,d.jsx)(`div`,{ref:b,inert:k,children:M}),t[18]=k,t[19]=M,t[20]=N):N=t[20];let P;t[21]!==y||t[22]!==N||t[23]!==j?(P=(0,d.jsx)(`div`,{id:y,style:j,children:N}),t[21]=y,t[22]=N,t[23]=j,t[24]=P):P=t[24];let F;t[25]!==r||t[26]!==E||t[27]!==y||t[28]!==s||t[29]!==x||t[30]!==w?(F=x?(0,d.jsx)(`button`,{type:`button`,"aria-expanded":E,"aria-controls":y,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:()=>w(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 E||t.append(`taskExpanded`,r),t},{preventScrollReset:!0}),children:s===`zh`?E?`收起`:`查看更多`:E?`Show less`:`Show more`}):null,t[25]=r,t[26]=E,t[27]=y,t[28]=s,t[29]=x,t[30]=w,t[31]=F):F=t[31];let I;return t[32]!==P||t[33]!==F||t[34]!==A?(I=(0,d.jsxs)(`div`,{className:A,children:[P,F]}),t[32]=P,t[33]=F,t[34]=A,t[35]=I):I=t[35],I}export{c as n,f 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{g as i}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as a}from"./markdown-view-CthsQiiO.js";import{t as o}from"./cn-0WouolD0.js";import{d as s}from"./tasks-PuIUgF9L.js";function c(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)continue;let r=e.evidence.filter(e=>n.evidenceTitles.includes(e.title)),i=n.status===`passed`&&s(e).has(t)?`passed`:n.status===`failed`?`failed`:`unverified`;a={text:t,status:i,evidence:r,runId:e.runId,verificationStatus:i,method:n.method,note:n.note};break}return i&&e.task.contract?.acceptancePolicy!==`verified_auto`?{...a,status:i.status,review:i}:e.task.contract?.acceptancePolicy===`manual`?{...a,status:`unverified`}:a})}var l=n(),u=e(t(),1),d=r();function f(e){let t=(0,l.c)(36),{content:n,contentKey:r,language:s,markdown:c,breaks:f,previewHeight:p,className:m,children:h}=e,g=c===void 0?!0:c,_=f===void 0?!1:f,v=p===void 0?240:p,y=(0,u.useId)(),b=(0,u.useRef)(null),[x,S]=(0,u.useState)(!1),[C,w]=i(),T;t[0]!==r||t[1]!==C?(T=C.getAll(`taskExpanded`).includes(r),t[0]=r,t[1]=C,t[2]=T):T=t[2];let E=T,D;t[3]===v?D=t[4]:(D=()=>{let e=b.current;if(!e)return;let t=()=>S(e.scrollHeight>v);if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},t[3]=v,t[4]=D);let O;t[5]!==n||t[6]!==v?(O=[n,v],t[5]=n,t[6]=v,t[7]=O):O=t[7],(0,u.useLayoutEffect)(D,O);let k=x&&!E,A;t[8]===m?A=t[9]:(A=o(`min-w-0`,m),t[8]=m,t[9]=A);let j;t[10]!==k||t[11]!==v?(j=k?{maxHeight:v,overflow:`hidden`,maskImage:`linear-gradient(to bottom, black calc(100% - ${Math.min(24,v/3)}px), transparent)`}:void 0,t[10]=k,t[11]=v,t[12]=j):j=t[12];let M;t[13]!==_||t[14]!==h||t[15]!==n||t[16]!==g?(M=h??(g?(0,d.jsx)(a,{content:n,compact:!0,breaks:_,className:`text-sm leading-6 text-fg`}):(0,d.jsx)(`p`,{className:`whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:n})),t[13]=_,t[14]=h,t[15]=n,t[16]=g,t[17]=M):M=t[17];let N;t[18]!==k||t[19]!==M?(N=(0,d.jsx)(`div`,{ref:b,inert:k,children:M}),t[18]=k,t[19]=M,t[20]=N):N=t[20];let P;t[21]!==y||t[22]!==N||t[23]!==j?(P=(0,d.jsx)(`div`,{id:y,style:j,children:N}),t[21]=y,t[22]=N,t[23]=j,t[24]=P):P=t[24];let F;t[25]!==r||t[26]!==E||t[27]!==y||t[28]!==s||t[29]!==x||t[30]!==w?(F=x?(0,d.jsx)(`button`,{type:`button`,"aria-expanded":E,"aria-controls":y,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:()=>w(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 E||t.append(`taskExpanded`,r),t},{preventScrollReset:!0}),children:s===`zh`?E?`收起`:`查看更多`:E?`Show less`:`Show more`}):null,t[25]=r,t[26]=E,t[27]=y,t[28]=s,t[29]=x,t[30]=w,t[31]=F):F=t[31];let I;return t[32]!==P||t[33]!==F||t[34]!==A?(I=(0,d.jsxs)(`div`,{className:A,children:[P,F]}),t[32]=P,t[33]=F,t[34]=A,t[35]=I):I=t[35],I}export{c as n,f 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{a as i,n as ee,r as a}from"./locale-store-D5h-Ha6-.js";import{a as te,i as ne,n as o,o as re,r as ie,s as ae,t as oe}from"./dist-BGTk37IG.js";import{i as s}from"./vendor-swr-BIWyz7Rc.js";import{Ao as se,Kc as c,Ns as ce,Rc as l,us as u}from"./index-DmURUvvA.js";import{t as d}from"./number-input-DDeqHK-G.js";import{n as le,r as ue}from"./settings-page-layout-Dx5S-Msc.js";import{n as f,t as p}from"./use-autosave-BnMIUc_5.js";var m=e(t(),1),h=n(),g=e=>a(`/api/observability/${e}`);async function _(e,t=`GET`,n){return i(g(e),{method:t,...n===void 0?{}:{body:JSON.stringify(n)}})}var v=r(),y=`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,b=`space-y-4 rounded-xl border border-edge bg-surface-panel p-4`,x=(e=0)=>`${(e/1048576).toFixed(1)} MiB`;function S(){let e=(0,h.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,v.jsxs)(`div`,{"aria-busy":`true`,className:`space-y-4`,children:[(0,v.jsx)(l,{className:`h-48 rounded-xl`}),(0,v.jsx)(l,{className:`h-64 rounded-xl`})]}),e[0]=t):t=e[0],t}function de(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 fe(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 pe(){let e=ee(e=>e.language)===`zh`,t=(t,n)=>e?n:t,n=s(g(`tracing/settings`),()=>_(`tracing/settings`)),r=s(g(`tracing/status`),()=>_(`tracing/status`),{refreshInterval:1e4}),[i,a]=(0,m.useState)(),[h,pe]=(0,m.useState)(),C=i??h??n.data?.config,[w,T]=(0,m.useState)(``),[E,D]=(0,m.useState)(``),[me,O]=(0,m.useState)(0),[k,he]=(0,m.useState)(!1),[ge,A]=(0,m.useState)(``),[_e,ve]=(0,m.useState)(!1),[j,ye]=(0,m.useState)(``),[M,be]=(0,m.useState)(`7`),[N,xe]=(0,m.useState)({conversationId:``,runId:``,agentId:``}),[P,F]=(0,m.useState)(`records`),[I,Se]=(0,m.useState)(`10`),[Ce,L]=(0,m.useState)([``]),[R,z]=(0,m.useState)(0),[we,Te]=(0,m.useState)(()=>Date.now()+1),B=Ce[R],[V,H]=(0,m.useState)();function U(){L([``]),z(0),Te(Date.now()+1)}let[Ee,W]=(0,m.useState)(!1),G=new URLSearchParams({limit:I,from:String(we-Number(M)*864e5),to:String(we)});j&&G.set(`status`,j),B&&G.set(`cursor`,B);for(let[e,t]of Object.entries(N))t&&G.set(e,t);let De=`traces?${G}`,K=s(g(De),()=>_(De),{refreshInterval:B?0:1e4}),q=s(V?g(`traces/${V}`):null,()=>_(`traces/${V}`));function J(e){if(!C)return;let t=structuredClone(C);e(t),a(t)}async function Y(e,i=t(`Saved`,`已保存`)){he(!0),A(``),ve(!1);try{await e(),A(i),await Promise.all([n.mutate(),r.mutate(),K.mutate()])}catch(e){ve(!0),A(e instanceof Error?e.message:t(`Request failed`,`操作失败`))}finally{he(!1)}}let X=p({value:C??null,dirty:!!(i&&JSON.stringify(i)!==JSON.stringify(h??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=>{pe((await _(`tracing/settings`,`PATCH`,e)).config),a(t=>t&&JSON.stringify(t)===JSON.stringify(e)?void 0:t),await r.mutate().catch(()=>{})}}),Z=(0,m.useMemo)(()=>({publicKey:w.trim(),secretKey:E.trim()}),[w,E]),Q=p({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 _(`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),O(e=>e+1),await Promise.allSettled([n.mutate(),r.mutate()])}}),$=[X.status,Q.status].some(e=>e===`dirty`||e===`saving`);async function Oe(){V&&await Y(async()=>{let e=await _(`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,v.jsxs)(ue,{className:`space-y-6`,children:[(0,v.jsx)(le,{title:t(`Runtime tracing`,`运行追踪`),subtitle:t(`Local diagnostics with bounded retention. Enable Langfuse to also export new traces.`,`默认保留有界本地记录;启用 Langfuse 后同时导出新采集的追踪。`),actions:P===`settings`?(0,v.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,v.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t(`Changes save automatically`,`修改后自动保存`)}),(0,v.jsx)(f,{status:X.status,error:X.error})]}):(0,v.jsx)(c,{disabled:K.isValidating,onClick:U,children:t(`Refresh records`,`刷新记录`)})}),ge&&(0,v.jsx)(`p`,{role:_e?`alert`:`status`,className:`text-sm text-fg-muted`,children:ge}),n.error&&(0,v.jsx)(`p`,{role:`alert`,children:String(n.error.message)}),(0,v.jsxs)(se,{as:`nav`,"aria-label":t(`Tracing sections`,`追踪页面分区`),className:`flex gap-2 border-b border-edge pb-3`,children:[(0,v.jsx)(c,{"aria-pressed":P===`records`,variant:`ghost`,onClick:()=>F(`records`),children:t(`Execution records`,`执行记录`)}),(0,v.jsx)(c,{"aria-pressed":P===`settings`,variant:`ghost`,onClick:()=>F(`settings`),children:t(`Capture settings`,`采集设置`)})]}),P===`settings`&&(C?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`section`,{className:b,onBlurCapture:X.onBlurCapture,children:[(0,v.jsx)(`h2`,{className:`font-medium`,children:t(`Local recording`,`本地记录`)}),X.error&&(0,v.jsx)(c,{variant:`ghost`,onClick:X.retry,children:t(`Retry autosave`,`重试自动保存`)}),(0,v.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,v.jsx)(`input`,{type:`checkbox`,checked:C.enabled,onChange:e=>J(t=>{t.enabled=e.target.checked})}),t(`Record traces`,`记录运行追踪`)]}),(0,v.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[(0,v.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t(`Retention (days)`,`保留天数`),(0,v.jsx)(d,{className:y,type:`number`,min:1,max:90,value:C.local.retentionDays,onChange:e=>J(t=>{t.local.retentionDays=Number(e.target.value)})})]}),(0,v.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t(`Storage budget (MiB)`,`存储上限(MiB)`),(0,v.jsx)(d,{className:y,type:`number`,min:16,max:4096,value:C.local.maxStoreMiB,onChange:e=>J(t=>{t.local.maxStoreMiB=Number(e.target.value)})})]}),(0,v.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t(`Capture`,`采集内容`),(0,v.jsx)(u,{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,v.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,v.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[t(`Detailed capture expires: `,`详细采集截止:`),new Date(C.detailedUntil).toLocaleString()]}),(0,v.jsxs)(`details`,{children:[(0,v.jsx)(`summary`,{className:`cursor-pointer text-sm`,children:t(`Advanced limits`,`高级限制`)}),(0,v.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,v.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t,(0,v.jsx)(d,{type:`number`,min:1,className:y,value:C.local[e],onChange:t=>J(n=>{n.local[e]=Number(t.target.value)})})]},e))})]}),r.data?(0,v.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[t(`Disk / payload`,`磁盘 / 数据`),`:`,x(r.data.local.physicalBytes),` / `,x(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,v.jsx)(l,{className:`h-10`}),(r.error||r.data?.local.lastError)&&(0,v.jsx)(`p`,{role:`alert`,className:`text-sm`,children:r.data?.local.lastError||String(r.error.message)}),(0,v.jsxs)(`div`,{className:`flex gap-2`,children:[(0,v.jsx)(c,{disabled:k||$,onClick:()=>void Y(async()=>{await _(`traces/prune`,`POST`)}),children:t(`Clean expired`,`清理过期记录`)}),(0,v.jsx)(c,{disabled:k,onClick:()=>W(!0),children:t(`Clear local traces`,`清空本地追踪`)})]})]}),(0,v.jsxs)(`section`,{className:b,children:[(0,v.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,v.jsx)(`h2`,{className:`font-medium`,children:`Langfuse`}),(0,v.jsx)(f,{status:Q.status,error:Q.error})]}),Q.error&&(0,v.jsx)(c,{variant:`ghost`,onClick:Q.retry,children:t(`Retry autosave`,`重试自动保存`)}),(0,v.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,v.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,v.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,v.jsxs)(`label`,{className:`space-y-1 text-sm sm:col-span-2`,children:[`Base URL`,(0,v.jsx)(`input`,{className:y,type:`url`,value:C.langfuse.baseUrl,onBlur:X.onBlurCapture,onChange:e=>J(t=>{t.langfuse.baseUrl=e.target.value})})]}),[`publicKey`,`secretKey`].map(e=>{let r=e===`publicKey`?`Public Key`:`Secret Key`,i=e===`publicKey`?w:E,ee=n.data?.credentials[e===`publicKey`?`publicKeyConfigured`:`secretKeyConfigured`];return(0,v.jsxs)(`div`,{className:`space-y-1 text-sm`,onBlurCapture:Q.onBlurCapture,children:[(0,v.jsx)(`label`,{htmlFor:`langfuse-${e}`,children:r}),(0,v.jsx)(ce,{id:`langfuse-${e}`,value:i||(ee?`••••••••••••`:``),allowUnrevealedCopy:!0,onChange:t=>(e===`publicKey`?T:D)(t.replace(/^•+/,``)),placeholder:e===`publicKey`?`pk-lf-…`:`sk-lf-…`,labels:{show:t(`Show ${r}`,`查看 ${r}`),hide:t(`Hide ${r}`,`隐藏 ${r}`),copy:t(`Copy ${r}`,`复制 ${r}`),copied:t(`Copied`,`已复制`)},reveal:()=>_(`tracing/langfuse/credentials/${e}/reveal`,`POST`).then(e=>e.key),loadFailedLabel:t(`Unable to load the configured key.`,`无法读取已配置的 Key。`),notInConfigFile:t(`No configured key is available.`,`暂无已配置的 Key。`)},me)]},e)})]}),(0,v.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,v.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,v.jsx)(`p`,{role:`alert`,className:`text-sm`,children:r.data.langfuse.lastError}),(0,v.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t(`Changes save automatically. Historical traces are not uploaded. Offline exports may be dropped.`,`修改后自动保存。不会上传历史记录;断网或队列满时可能丢弃远端导出。`)}),(0,v.jsxs)(`div`,{className:`flex gap-2`,children:[(0,v.jsx)(c,{disabled:k||$,onClick:()=>void Y(async()=>{if(!(await _(`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,v.jsx)(c,{disabled:k||$,onClick:()=>void Y(async()=>{await _(`tracing/langfuse/credentials`,`DELETE`),T(``),D(``),O(e=>e+1)}),children:t(`Remove saved credentials`,`移除已保存凭证`)})]})]})]}):(0,v.jsx)(S,{})),P===`records`&&(0,v.jsxs)(`section`,{className:b,children:[(0,v.jsx)(`h2`,{className:`font-medium`,children:t(`Recent runs`,`最近执行`)}),(0,v.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,v.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t(`Status`,`执行状态`),(0,v.jsx)(u,{placeholder:t(`All statuses`,`全部状态`),allowEmpty:!1,value:j,onChange:e=>{ye(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,v.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t(`Time range`,`时间范围`),(0,v.jsx)(u,{placeholder:t(`Choose`,`请选择`),value:M,allowEmpty:!1,onChange:e=>{be(e),U()},options:[`1`,`7`,`30`,`90`].map(e=>({value:e,label:`${e} ${t(`days`,`天`)}`}))})]}),(0,v.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t(`Page size`,`每页条数`),(0,v.jsx)(u,{placeholder:t(`Choose`,`请选择`),value:I,allowEmpty:!1,onChange:e=>{Se(e),U()},options:[`10`,`20`].map(e=>({value:e,label:`${e} ${t(`records`,`条`)}`}))})]})]}),(0,v.jsxs)(`details`,{children:[(0,v.jsxs)(`summary`,{className:`cursor-pointer text-sm text-fg-muted`,children:[t(`Advanced filters`,`高级筛选`),Object.values(N).some(Boolean)?` · ${t(`Active`,`已启用`)}`:``]}),(0,v.jsx)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-3`,children:[`conversationId`,`runId`,`agentId`].map(e=>(0,v.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,v.jsx)(`input`,{"aria-label":e,placeholder:t(`Exact ID`,`输入完整 ID`),className:y,value:N[e],onChange:t=>{xe({...N,[e]:t.target.value}),U()}})]},e))})]}),(0,v.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,v.jsx)(`p`,{role:`alert`,className:`p-4 text-sm`,children:K.error.message}),!K.data&&!K.error?(0,v.jsx)(`div`,{className:`space-y-3 p-3`,children:[0,1,2,3,4].map(e=>(0,v.jsx)(l,{className:`h-16`},e))}):(0,v.jsxs)(`div`,{className:`divide-y divide-edge`,children:[K.data?.traces.length===0&&(0,v.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,v.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,v.jsxs)(`div`,{className:`min-w-0`,children:[(0,v.jsxs)(`p`,{className:`truncate font-medium`,children:[n.name,n.attributes[`xopc.agentId`]?` · ${n.attributes[`xopc.agentId`]}`:``]}),(0,v.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,v.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,v.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,v.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,v.jsx)(`p`,{"aria-live":`polite`,className:`text-xs text-fg-muted`,children:t(`Page ${R+1} · ${K.data?.traces.length??0} records`,`第 ${R+1} 页 · ${K.data?.traces.length??0} 条`)}),(0,v.jsxs)(`div`,{className:`flex gap-2`,children:[(0,v.jsx)(c,{disabled:R===0||K.isValidating,onClick:()=>z(e=>Math.max(0,e-1)),children:t(`Previous page`,`上一页`)}),(0,v.jsx)(c,{disabled:!K.data?.nextCursor||K.isValidating,onClick:()=>{let e=K.data?.nextCursor;e&&(L(t=>[...t.slice(0,R+1),e]),z(e=>e+1))},children:t(`Next page`,`下一页`)})]})]})]}),(0,v.jsx)(oe,{open:!!V,onOpenChange:e=>{e||H(void 0)},children:(0,v.jsxs)(re,{children:[(0,v.jsx)(te,{className:`fixed inset-0 z-[90] bg-black/40`}),(0,v.jsxs)(ie,{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,v.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3`,children:[(0,v.jsx)(ae,{className:`font-medium`,children:t(`Trace details`,`追踪详情`)}),(0,v.jsx)(o,{asChild:!0,children:(0,v.jsx)(c,{children:t(`Close`,`关闭`)})})]}),(0,v.jsx)(ne,{className:`shrink-0 truncate text-xs text-fg-muted`,children:V}),(0,v.jsx)(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto py-4`,children:q.error?(0,v.jsx)(`p`,{role:`alert`,children:q.error.message}):q.data?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`p`,{className:`text-sm`,children:[q.data.trace.status,` `,q.data.trace.partialReason&&` · ${q.data.trace.partialReason}`]}),fe(q.data.spans).map(e=>(0,v.jsxs)(`details`,{style:{marginLeft:de(e,q.data.spans)*12},className:`rounded-lg border border-edge p-3 text-sm`,children:[(0,v.jsxs)(`summary`,{className:`cursor-pointer`,children:[e.name,` · `,e.status,` · `,e.endedAt?`${Math.round(e.endedAt-e.startedAt)} ms`:`—`]}),(0,v.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,v.jsx)(S,{})}),(0,v.jsx)(`div`,{className:`shrink-0 border-t border-edge pt-3`,children:(0,v.jsx)(c,{disabled:!q.data||k,onClick:()=>void Oe(),children:t(`Export JSON`,`导出 JSON`)})})]})]})}),(0,v.jsx)(oe,{open:Ee,onOpenChange:W,children:(0,v.jsxs)(re,{children:[(0,v.jsx)(te,{className:`fixed inset-0 z-[90] bg-black/40`}),(0,v.jsxs)(ie,{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,v.jsx)(ae,{children:t(`Clear local traces?`,`清空本地追踪?`)}),(0,v.jsx)(ne,{className:`text-sm text-fg-muted`,children:t(`Removes retained local traces. Conversations, usage records and Langfuse data remain available.`,`删除已保留的本地追踪。会话、用量记录及 Langfuse 数据仍保留。`)}),(0,v.jsxs)(`div`,{className:`flex gap-2`,children:[(0,v.jsx)(c,{disabled:k||$,onClick:()=>void Y(async()=>{await _(`traces`,`DELETE`),W(!1),H(void 0)}),children:t(`Clear`,`清空`)}),(0,v.jsx)(o,{asChild:!0,children:(0,v.jsx)(c,{children:t(`Cancel`,`取消`)})})]})]})]})})]})}export{pe 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"./messages-DBvKzlCl.js";import{t as o}from"./cn-0WouolD0.js";import{a as s,c,i as l,n as u,r as d}from"./locale-store-Jnhw2WMv.js";import{i as f}from"./vendor-swr-BIWyz7Rc.js";import{n as p,r as m}from"./gateway-config-swr-DAir1JsW.js";import{Gu as ee,Rc as h,Rs as g,Sd as te,Wc as _,cs as v,ja as y,pu as b}from"./index-CzkAd5Su.js";import{n as ne,t as re}from"./settings-form-section-COwDGhbe.js";var x=e(t(),1),S=n(),C=r();function w(e){let t=(0,S.c)(10),{language:n,label:r,section:a,className:s}=e,c;t[0]!==n||t[1]!==a?(c=v(n,a),t[0]=n,t[1]=a,t[2]=c):c=t[2];let l;t[3]===s?l=t[4]:(l=o(`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`,s),t[3]=s,t[4]=l);let u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,C.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]!==c||t[8]!==l?(d=(0,C.jsxs)(`a`,{href:c,target:`_blank`,rel:`noreferrer`,className:l,children:[r,u]}),t[6]=r,t[7]=c,t[8]=l,t[9]=d):d=t[9],d}async function T(){let e=await l(`/api/exposure/status`);if(!e.ok)throw Error(`Failed to load exposure status (${e.status})`);return await e.json()}async function E(e=`serve`){let t=await l(`/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 D(){let e=await l(`/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 O=`https://tailscale.com/download`;function k(e){let t=(0,S.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,C.jsx)(`a`,{href:O,target:`_blank`,rel:`noreferrer`,className:`font-medium text-accent hover:underline`,children:n}),t[0]=n,t[1]=r),r}function A({embedded:e=!1}){let t=u(e=>e.language),n=a(t).remoteAccess.tailscale,r=(0,x.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:a(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]),i=!!c(e=>e.conversationId),[o,s]=(0,x.useState)(!1),[l,d]=(0,x.useState)(null),{data:p,mutate:m,isLoading:g}=f(i?`exposure-status`:null,T,{refreshInterval:3e4}),v=p?.tailscale.hostname,S=p?.tailscale.active===!0,O=p?.tailscale.cliAvailable!==!1,A=v?`https://${v}/`:null,ie=(0,x.useCallback)(async()=>{s(!0),d(null);try{await E(`serve`),await m()}catch(e){d(e instanceof Error?e.message:String(e))}finally{s(!1)}},[m]),ae=(0,x.useCallback)(async()=>{s(!0),d(null);try{await D(),await m()}catch(e){d(e instanceof Error?e.message:String(e))}finally{s(!1)}},[m]);if(!i)return null;let j=(0,C.jsxs)(`div`,{className:e?`space-y-4`:`mt-4 space-y-3`,children:[e?(0,C.jsxs)(`ol`,{className:`space-y-3 text-sm text-fg-muted`,children:[(0,C.jsxs)(`li`,{className:`flex gap-2`,children:[(0,C.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,C.jsxs)(`span`,{children:[n.stepInstallBefore,(0,C.jsx)(k,{label:n.stepInstallLink}),n.stepInstallAfter]})]}),(0,C.jsxs)(`li`,{className:`flex gap-2`,children:[(0,C.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,C.jsx)(`span`,{children:n.stepEnable})]}),(0,C.jsxs)(`li`,{className:`flex gap-2`,children:[(0,C.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,C.jsx)(`span`,{children:n.stepCopy})]})]}):null,e&&p?.tailscale.cliAvailable===!1?(0,C.jsxs)(`p`,{className:`rounded-lg bg-amber-500/10 px-3 py-2 text-sm text-fg-muted`,children:[n.cliMissingIntro,` `,(0,C.jsx)(k,{label:n.cliMissingDownloadLink}),n.cliMissingSuffix]}):null,g&&!p?(0,C.jsxs)(`div`,{className:`grid gap-3`,"aria-busy":`true`,children:[(0,C.jsx)(h,{className:`h-20 rounded-lg`}),(0,C.jsx)(h,{className:`h-20 rounded-lg`})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(re,{children:[(0,C.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.statusLabel}),(0,C.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:S?n.statusActive:n.statusOff}),A?(0,C.jsx)(`div`,{className:`mt-3`,children:(0,C.jsx)(y,{text:A,labels:r})}):null,l?(0,C.jsx)(`p`,{className:`mt-2 text-sm text-red-600 dark:text-red-400`,children:l}):null,(0,C.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:S?(0,C.jsxs)(_,{type:`button`,variant:`secondary`,disabled:o,onClick:()=>void ae(),children:[o?(0,C.jsx)(ee,{className:`mr-1 size-4 animate-spin`}):null,n.disableServe]}):(0,C.jsxs)(_,{type:`button`,disabled:o||!O,onClick:()=>void ie(),children:[o?(0,C.jsx)(ee,{className:`mr-1 size-4 animate-spin`}):(0,C.jsx)(b,{className:`mr-1 size-4`}),n.enableServe]})})]}),(0,C.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.hint}),(0,C.jsx)(w,{language:t,label:n.docsLink,section:`tailscale-serve`,className:`mt-2`})]})]});return e?j:(0,C.jsxs)(re,{children:[(0,C.jsx)(ne,{icon:te,title:n.title,subtitle:n.subtitle}),j]})}async function ie(e){let t=await l(d(`/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 ae(e){await s(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{publicUrl:e??null}})})}function j(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 oe(){return(0,x.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`)||j(r)?null:n.toLowerCase().replace(/\/+$/,``)},[])}function se(){return o(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,g,`dark:border-edge`)}function ce(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 M(){let e=(0,S.c)(85),t=u(ue),n;e[0]===t?n=e[1]:(n=a(t),e[0]=t,e[1]=n);let r=n.remoteAccess.reverseProxy,i=!!c(le),s=oe(),l=m(i).data?.payload?.config,d;e[2]===l?d=e[3]:(d=ce(l),e[2]=l,e[3]=d);let f=d,[h,g]=(0,x.useState)(``),v;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(v={busy:!1,result:null},e[4]=v):v=e[4];let[y,b]=(0,x.useState)(v),w;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(w={busy:!1,error:null},e[5]=w):w=e[5];let[T,E]=(0,x.useState)(w),D,O;e[6]!==f||e[7]!==s||e[8]!==h?(D=()=>{h||(f?g(f):s&&g(s))},O=[f,s,h],e[6]=f,e[7]=s,e[8]=h,e[9]=D,e[10]=O):(D=e[9],O=e[10]),(0,x.useEffect)(D,O);let k;bb0:{let t;e[11]===h?t=e[12]:(t=h.trim(),e[11]=h,e[12]=t);let n=t;if(n){k=n;break bb0}k=f??s??``}let A=k,j=!f&&!!s&&A===s,M;e[13]!==h||e[14]!==A?(M=async()=>{let e=h.trim()||A;if(e){b({busy:!0,result:null});try{b({busy:!1,result:await ie(e)})}catch(e){let t=e;b({busy:!1,result:{ok:!1,code:`NETWORK_ERROR`,message:t instanceof Error?t.message:String(t)}})}}},e[13]=h,e[14]=A,e[15]=M):M=e[15];let fe=M,N;e[16]===A?N=e[17]:(N=async()=>{let e=A.trim();if(e){E({busy:!0,error:null});try{await ae(e),await p(),E({busy:!1,error:null})}catch(e){let t=e;E({busy:!1,error:t instanceof Error?t.message:String(t)})}}},e[16]=A,e[17]=N);let pe=N,P;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(P=async()=>{E({busy:!0,error:null});try{await ae(null),await p(),g(``),b({busy:!1,result:null}),E({busy:!1,error:null})}catch(e){let t=e;E({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,C.jsx)(ne,{icon:te,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,C.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=o(se(),`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=>{g(e.target.value),b({busy:!1,result:null})},e[25]=R):R=e[25];let z;e[26]!==h||e[27]!==r.urlPlaceholder||e[28]!==L?(z=(0,C.jsx)(`input`,{id:`reverse-proxy-url`,className:L,type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:r.urlPlaceholder,value:h,onChange:R}),e[26]=h,e[27]=r.urlPlaceholder,e[28]=L,e[29]=z):z=e[29];let B;e[30]===fe?B=e[31]:(B=()=>void fe(),e[30]=fe,e[31]=B);let V;e[32]!==h||e[33]!==y.busy?(V=y.busy||!h.trim(),e[32]=h,e[33]=y.busy,e[34]=V):V=e[34];let H;e[35]===y.busy?H=e[36]:(H=y.busy?(0,C.jsx)(ee,{className:`size-3.5 animate-spin`}):null,e[35]=y.busy,e[36]=H);let he=y.busy?r.probing:r.probeButton,U;e[37]!==B||e[38]!==V||e[39]!==H||e[40]!==he?(U=(0,C.jsxs)(_,{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,C.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,C.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.urlHint}),e[45]=r.urlHint,e[46]=G);let K;e[47]!==s||e[48]!==j||e[49]!==r.autoDetectedHint||e[50]!==r.autoDetectedTitle?(K=j&&s?(0,C.jsxs)(`div`,{className:`rounded-lg bg-accent-soft/60 px-3 py-2 text-xs leading-relaxed text-accent-fg`,children:[(0,C.jsx)(`div`,{className:`font-medium`,children:r.autoDetectedTitle}),(0,C.jsx)(`div`,{className:`mt-1 break-all font-mono text-[11px]`,children:s}),(0,C.jsx)(`p`,{className:`mt-1`,children:r.autoDetectedHint})]}):null,e[47]=s,e[48]=j,e[49]=r.autoDetectedHint,e[50]=r.autoDetectedTitle,e[51]=K):K=e[51];let q;e[52]!==y.result||e[53]!==r.probeStatus?(q=y.result?(0,C.jsx)(de,{result:y.result,labels:r.probeStatus}):null,e[52]=y.result,e[53]=r.probeStatus,e[54]=q):q=e[54];let J;e[55]!==f||e[56]!==A||e[57]!==pe||e[58]!==r.saveAsDefault||e[59]!==r.saving||e[60]!==T.busy?(J=A&&f!==A?(0,C.jsxs)(_,{type:`button`,onClick:()=>void pe(),disabled:T.busy,children:[T.busy?(0,C.jsx)(ee,{className:`size-3.5 animate-spin`}):null,T.busy?r.saving:r.saveAsDefault]}):null,e[55]=f,e[56]=A,e[57]=pe,e[58]=r.saveAsDefault,e[59]=r.saving,e[60]=T.busy,e[61]=J):J=e[61];let Y;e[62]!==f||e[63]!==r.clear||e[64]!==T.busy?(Y=f?(0,C.jsx)(_,{type:`button`,variant:`ghost`,onClick:()=>void me(),disabled:T.busy,children:r.clear}):null,e[62]=f,e[63]=r.clear,e[64]=T.busy,e[65]=Y):Y=e[65];let X;e[66]!==J||e[67]!==Y?(X=(0,C.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]===T.error?Z=e[70]:(Z=T.error?(0,C.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:T.error}):null,e[69]=T.error,e[70]=Z);let Q;e[71]===r.certWarning?Q=e[72]:(Q=(0,C.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,C.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,C.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,C.jsxs)(re,{children:[F,$]})}),e[82]=F,e[83]=$,e[84]=ge):ge=e[84],ge}function le(e){return e.conversationId}function ue(e){return e.language}function de(e){let t=(0,S.c)(18),{result:n,labels:r}=e;if(n.ok){let e;t[0]===r.ok?e=t[1]:(e=(0,C.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,C.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,C.jsxs)(C.Fragment,{children:[` · `,(0,C.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,C.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,C.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,C.jsxs)(C.Fragment,{children:[` — `,(0,C.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,C.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 fe(){let e=await s(d(`/api/device-pairing/readiness`));return{ready:e.ready,routes:e.routes,protocolVersion:e.protocolVersion}}async function N(e){try{return{kind:`ready`,setup:(await s(d(`/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 s(d(`/api/device-pairing/setups/${encodeURIComponent(e)}`))}async function P(e){await s(d(`/api/device-pairing/setups/${encodeURIComponent(e)}`),{method:`DELETE`})}async function me(e,t){await s(d(`/api/device-pairing/requests/${encodeURIComponent(e.requestId)}/decision`),{method:`POST`,body:JSON.stringify({decision:t,expectedRevision:e.revision})})}async function F(){let e=await l(d(`/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 s(d(`/api/tunnel/status`))}async function B(){await s(d(`/api/tunnel/consent`),{method:`POST`,body:JSON.stringify({})})}async function V(){await s(d(`/api/tunnel/registration-key`),{method:`POST`,body:JSON.stringify({})})}async function H(){return s(d(`/api/tunnel/start`),{method:`POST`,body:JSON.stringify({})})}async function he(e){return s(d(`/api/tunnel/stop`),{method:`POST`,body:JSON.stringify({release:e?.release===!0})})}async function U(){let e=(await s(d(`/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 s(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({tunnel:e})})}export{M as _,B as a,w as b,he as c,P as d,N as f,pe as g,fe 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,A as v,T 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"./messages-Bwv-AOYl.js";import{t as o}from"./cn-0WouolD0.js";import{a as s,c,i as l,n as u,r as d}from"./locale-store-D5h-Ha6-.js";import{i as f}from"./vendor-swr-BIWyz7Rc.js";import{n as p,r as m}from"./gateway-config-swr-BvuySoCX.js";import{Ju as ee,Kc as h,Rc as g,Rs as _,Td as te,cs as v,gu as y,ja as b}from"./index-DmURUvvA.js";import{n as ne,t as re}from"./settings-form-section-BTUFu5KS.js";var x=e(t(),1),S=n(),C=r();function w(e){let t=(0,S.c)(10),{language:n,label:r,section:a,className:s}=e,c;t[0]!==n||t[1]!==a?(c=v(n,a),t[0]=n,t[1]=a,t[2]=c):c=t[2];let l;t[3]===s?l=t[4]:(l=o(`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`,s),t[3]=s,t[4]=l);let u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,C.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]!==c||t[8]!==l?(d=(0,C.jsxs)(`a`,{href:c,target:`_blank`,rel:`noreferrer`,className:l,children:[r,u]}),t[6]=r,t[7]=c,t[8]=l,t[9]=d):d=t[9],d}async function T(){let e=await l(`/api/exposure/status`);if(!e.ok)throw Error(`Failed to load exposure status (${e.status})`);return await e.json()}async function E(e=`serve`){let t=await l(`/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 D(){let e=await l(`/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 O=`https://tailscale.com/download`;function k(e){let t=(0,S.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,C.jsx)(`a`,{href:O,target:`_blank`,rel:`noreferrer`,className:`font-medium text-accent hover:underline`,children:n}),t[0]=n,t[1]=r),r}function A({embedded:e=!1}){let t=u(e=>e.language),n=a(t).remoteAccess.tailscale,r=(0,x.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:a(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]),i=!!c(e=>e.conversationId),[o,s]=(0,x.useState)(!1),[l,d]=(0,x.useState)(null),{data:p,mutate:m,isLoading:_}=f(i?`exposure-status`:null,T,{refreshInterval:3e4}),v=p?.tailscale.hostname,S=p?.tailscale.active===!0,O=p?.tailscale.cliAvailable!==!1,A=v?`https://${v}/`:null,ie=(0,x.useCallback)(async()=>{s(!0),d(null);try{await E(`serve`),await m()}catch(e){d(e instanceof Error?e.message:String(e))}finally{s(!1)}},[m]),ae=(0,x.useCallback)(async()=>{s(!0),d(null);try{await D(),await m()}catch(e){d(e instanceof Error?e.message:String(e))}finally{s(!1)}},[m]);if(!i)return null;let j=(0,C.jsxs)(`div`,{className:e?`space-y-4`:`mt-4 space-y-3`,children:[e?(0,C.jsxs)(`ol`,{className:`space-y-3 text-sm text-fg-muted`,children:[(0,C.jsxs)(`li`,{className:`flex gap-2`,children:[(0,C.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,C.jsxs)(`span`,{children:[n.stepInstallBefore,(0,C.jsx)(k,{label:n.stepInstallLink}),n.stepInstallAfter]})]}),(0,C.jsxs)(`li`,{className:`flex gap-2`,children:[(0,C.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,C.jsx)(`span`,{children:n.stepEnable})]}),(0,C.jsxs)(`li`,{className:`flex gap-2`,children:[(0,C.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,C.jsx)(`span`,{children:n.stepCopy})]})]}):null,e&&p?.tailscale.cliAvailable===!1?(0,C.jsxs)(`p`,{className:`rounded-lg bg-amber-500/10 px-3 py-2 text-sm text-fg-muted`,children:[n.cliMissingIntro,` `,(0,C.jsx)(k,{label:n.cliMissingDownloadLink}),n.cliMissingSuffix]}):null,_&&!p?(0,C.jsxs)(`div`,{className:`grid gap-3`,"aria-busy":`true`,children:[(0,C.jsx)(g,{className:`h-20 rounded-lg`}),(0,C.jsx)(g,{className:`h-20 rounded-lg`})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(re,{children:[(0,C.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.statusLabel}),(0,C.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:S?n.statusActive:n.statusOff}),A?(0,C.jsx)(`div`,{className:`mt-3`,children:(0,C.jsx)(b,{text:A,labels:r})}):null,l?(0,C.jsx)(`p`,{className:`mt-2 text-sm text-red-600 dark:text-red-400`,children:l}):null,(0,C.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:S?(0,C.jsxs)(h,{type:`button`,variant:`secondary`,disabled:o,onClick:()=>void ae(),children:[o?(0,C.jsx)(ee,{className:`mr-1 size-4 animate-spin`}):null,n.disableServe]}):(0,C.jsxs)(h,{type:`button`,disabled:o||!O,onClick:()=>void ie(),children:[o?(0,C.jsx)(ee,{className:`mr-1 size-4 animate-spin`}):(0,C.jsx)(y,{className:`mr-1 size-4`}),n.enableServe]})})]}),(0,C.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.hint}),(0,C.jsx)(w,{language:t,label:n.docsLink,section:`tailscale-serve`,className:`mt-2`})]})]});return e?j:(0,C.jsxs)(re,{children:[(0,C.jsx)(ne,{icon:te,title:n.title,subtitle:n.subtitle}),j]})}async function ie(e){let t=await l(d(`/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 ae(e){await s(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{publicUrl:e??null}})})}function j(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 oe(){return(0,x.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`)||j(r)?null:n.toLowerCase().replace(/\/+$/,``)},[])}function se(){return o(`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 ce(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 M(){let e=(0,S.c)(85),t=u(ue),n;e[0]===t?n=e[1]:(n=a(t),e[0]=t,e[1]=n);let r=n.remoteAccess.reverseProxy,i=!!c(le),s=oe(),l=m(i).data?.payload?.config,d;e[2]===l?d=e[3]:(d=ce(l),e[2]=l,e[3]=d);let f=d,[g,_]=(0,x.useState)(``),v;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(v={busy:!1,result:null},e[4]=v):v=e[4];let[y,b]=(0,x.useState)(v),w;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(w={busy:!1,error:null},e[5]=w):w=e[5];let[T,E]=(0,x.useState)(w),D,O;e[6]!==f||e[7]!==s||e[8]!==g?(D=()=>{g||(f?_(f):s&&_(s))},O=[f,s,g],e[6]=f,e[7]=s,e[8]=g,e[9]=D,e[10]=O):(D=e[9],O=e[10]),(0,x.useEffect)(D,O);let k;bb0:{let t;e[11]===g?t=e[12]:(t=g.trim(),e[11]=g,e[12]=t);let n=t;if(n){k=n;break bb0}k=f??s??``}let A=k,j=!f&&!!s&&A===s,M;e[13]!==g||e[14]!==A?(M=async()=>{let e=g.trim()||A;if(e){b({busy:!0,result:null});try{b({busy:!1,result:await ie(e)})}catch(e){let t=e;b({busy:!1,result:{ok:!1,code:`NETWORK_ERROR`,message:t instanceof Error?t.message:String(t)}})}}},e[13]=g,e[14]=A,e[15]=M):M=e[15];let fe=M,N;e[16]===A?N=e[17]:(N=async()=>{let e=A.trim();if(e){E({busy:!0,error:null});try{await ae(e),await p(),E({busy:!1,error:null})}catch(e){let t=e;E({busy:!1,error:t instanceof Error?t.message:String(t)})}}},e[16]=A,e[17]=N);let pe=N,P;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(P=async()=>{E({busy:!0,error:null});try{await ae(null),await p(),_(``),b({busy:!1,result:null}),E({busy:!1,error:null})}catch(e){let t=e;E({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,C.jsx)(ne,{icon:te,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,C.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=o(se(),`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=>{_(e.target.value),b({busy:!1,result:null})},e[25]=R):R=e[25];let z;e[26]!==g||e[27]!==r.urlPlaceholder||e[28]!==L?(z=(0,C.jsx)(`input`,{id:`reverse-proxy-url`,className:L,type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:r.urlPlaceholder,value:g,onChange:R}),e[26]=g,e[27]=r.urlPlaceholder,e[28]=L,e[29]=z):z=e[29];let B;e[30]===fe?B=e[31]:(B=()=>void fe(),e[30]=fe,e[31]=B);let V;e[32]!==g||e[33]!==y.busy?(V=y.busy||!g.trim(),e[32]=g,e[33]=y.busy,e[34]=V):V=e[34];let H;e[35]===y.busy?H=e[36]:(H=y.busy?(0,C.jsx)(ee,{className:`size-3.5 animate-spin`}):null,e[35]=y.busy,e[36]=H);let he=y.busy?r.probing:r.probeButton,U;e[37]!==B||e[38]!==V||e[39]!==H||e[40]!==he?(U=(0,C.jsxs)(h,{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,C.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,C.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.urlHint}),e[45]=r.urlHint,e[46]=G);let K;e[47]!==s||e[48]!==j||e[49]!==r.autoDetectedHint||e[50]!==r.autoDetectedTitle?(K=j&&s?(0,C.jsxs)(`div`,{className:`rounded-lg bg-accent-soft/60 px-3 py-2 text-xs leading-relaxed text-accent-fg`,children:[(0,C.jsx)(`div`,{className:`font-medium`,children:r.autoDetectedTitle}),(0,C.jsx)(`div`,{className:`mt-1 break-all font-mono text-[11px]`,children:s}),(0,C.jsx)(`p`,{className:`mt-1`,children:r.autoDetectedHint})]}):null,e[47]=s,e[48]=j,e[49]=r.autoDetectedHint,e[50]=r.autoDetectedTitle,e[51]=K):K=e[51];let q;e[52]!==y.result||e[53]!==r.probeStatus?(q=y.result?(0,C.jsx)(de,{result:y.result,labels:r.probeStatus}):null,e[52]=y.result,e[53]=r.probeStatus,e[54]=q):q=e[54];let J;e[55]!==f||e[56]!==A||e[57]!==pe||e[58]!==r.saveAsDefault||e[59]!==r.saving||e[60]!==T.busy?(J=A&&f!==A?(0,C.jsxs)(h,{type:`button`,onClick:()=>void pe(),disabled:T.busy,children:[T.busy?(0,C.jsx)(ee,{className:`size-3.5 animate-spin`}):null,T.busy?r.saving:r.saveAsDefault]}):null,e[55]=f,e[56]=A,e[57]=pe,e[58]=r.saveAsDefault,e[59]=r.saving,e[60]=T.busy,e[61]=J):J=e[61];let Y;e[62]!==f||e[63]!==r.clear||e[64]!==T.busy?(Y=f?(0,C.jsx)(h,{type:`button`,variant:`ghost`,onClick:()=>void me(),disabled:T.busy,children:r.clear}):null,e[62]=f,e[63]=r.clear,e[64]=T.busy,e[65]=Y):Y=e[65];let X;e[66]!==J||e[67]!==Y?(X=(0,C.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]===T.error?Z=e[70]:(Z=T.error?(0,C.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:T.error}):null,e[69]=T.error,e[70]=Z);let Q;e[71]===r.certWarning?Q=e[72]:(Q=(0,C.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,C.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,C.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,C.jsxs)(re,{children:[F,$]})}),e[82]=F,e[83]=$,e[84]=ge):ge=e[84],ge}function le(e){return e.conversationId}function ue(e){return e.language}function de(e){let t=(0,S.c)(18),{result:n,labels:r}=e;if(n.ok){let e;t[0]===r.ok?e=t[1]:(e=(0,C.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,C.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,C.jsxs)(C.Fragment,{children:[` · `,(0,C.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,C.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,C.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,C.jsxs)(C.Fragment,{children:[` — `,(0,C.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,C.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 fe(){let e=await s(d(`/api/device-pairing/readiness`));return{ready:e.ready,routes:e.routes,protocolVersion:e.protocolVersion}}async function N(e){try{return{kind:`ready`,setup:(await s(d(`/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 s(d(`/api/device-pairing/setups/${encodeURIComponent(e)}`))}async function P(e){await s(d(`/api/device-pairing/setups/${encodeURIComponent(e)}`),{method:`DELETE`})}async function me(e,t){await s(d(`/api/device-pairing/requests/${encodeURIComponent(e.requestId)}/decision`),{method:`POST`,body:JSON.stringify({decision:t,expectedRevision:e.revision})})}async function F(){let e=await l(d(`/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 s(d(`/api/tunnel/status`))}async function B(){await s(d(`/api/tunnel/consent`),{method:`POST`,body:JSON.stringify({})})}async function V(){await s(d(`/api/tunnel/registration-key`),{method:`POST`,body:JSON.stringify({})})}async function H(){return s(d(`/api/tunnel/start`),{method:`POST`,body:JSON.stringify({})})}async function he(e){return s(d(`/api/tunnel/stop`),{method:`POST`,body:JSON.stringify({release:e?.release===!0})})}async function U(){let e=(await s(d(`/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 s(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({tunnel:e})})}export{M as _,B as a,w as b,he as c,P as d,N as f,pe as g,fe 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,A as v,T as y};
@@ -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{g as i}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as a}from"./messages-Bwv-AOYl.js";import{a as o,n as s,r as c}from"./locale-store-D5h-Ha6-.js";import{i as l}from"./vendor-swr-BIWyz7Rc.js";import{Ao as u,Dd as d,Hd as f,Kc as p,Pl as m,Rc as h,bf as g,du as _,qd as v,uf as y,us as b}from"./index-DmURUvvA.js";import{n as x,r as S}from"./settings-page-layout-Dx5S-Msc.js";import{t as ee}from"./xopc-cloud-account-card-BsW2acj1.js";var C=e(t(),1),w=n();function T(e,t=Date.now()+1){let n=t-e*24*60*60*1e3;return new URLSearchParams({from:String(n),to:String(t)}).toString()}function E(e){return o(c(`/api/usage/summary?${e}`))}function D(e,t,n=20){let r=new URLSearchParams(e);return r.set(`limit`,String(n)),t&&r.set(`cursor`,t),o(c(`/api/usage/events?${r}`))}var O=r();function k(e,t){return new Intl.NumberFormat(t===`zh`?`zh-CN`:`en-US`,{notation:`compact`,maximumFractionDigits:1}).format(e)}function A(e){return`$${Number(e).toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:6})}`}function j(e){let t=BigInt(e),n=String(t%10000n).padStart(4,`0`).replace(/0+$/,``);return`${t/10000n}${n?`.${n}`:``}`}function te(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 M(){let e=(0,w.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,O.jsxs)(`div`,{className:`space-y-4`,"aria-busy":`true`,children:[(0,O.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[0,1,2,3].map(N)}),(0,O.jsx)(h,{className:`h-52 rounded-xl`}),(0,O.jsx)(h,{className:`h-72 rounded-xl`})]}),e[0]=t):t=e[0],t}function N(e){return(0,O.jsx)(h,{className:`h-24 rounded-xl`},e)}function P(){let e=s(e=>e.language),t=a(e).usage,[n,r]=i(),o=[`7`,`30`,`90`].includes(n.get(`days`)??``)?n.get(`days`):`7`,c=n.get(`size`)===`50`?50:20,w=n.getAll(`cursor`),N=w.at(-1),[P]=(0,C.useState)(()=>Date.now()+1),F=Number(n.get(`to`)),I=Number.isSafeInteger(F)&&F>Number(o)*864e5?F:P,L=(0,C.useMemo)(()=>T(Number(o),I),[o,I]),R=l([`usage-summary`,L],()=>E(L),{refreshInterval:15e3}),z=l([`usage-events`,L,N,c],()=>D(L,N,c),{refreshInterval:15e3}),B=!R.data&&!R.error,V=R.error,H=e=>{let t=new URLSearchParams(n);t.set(`to`,String(I)),e(t),r(t)},U=e=>H(t=>{t.set(`days`,e),t.set(`to`,String(Date.now()+1)),t.delete(`cursor`),t.delete(`groupPage`)}),W=n.get(`group`)===`model`?`model`:`scenario`,G=[...W===`model`?R.data?.byModel??[]:R.data?.byCategory??[]].sort((e,t)=>t.totals.calls-e.totals.calls||e.key.localeCompare(t.key)),K=Math.max(1,Math.ceil((G?.length??0)/6)),q=Number(n.get(`groupPage`)),J=Math.min(K,Number.isSafeInteger(q)&&q>0?q:1),Y=G?.slice((J-1)*6,J*6),X=w.length+1,Z=R.data?.totals,ne=(Z?.billing?.cloud.calls??0)>0,Q=e=>{let n=e.billing?.cloud;return n?.calls?n.chargedCreditMicro===null?t.cloudUnconfirmed:`${n.pendingCalls+n.unavailableCalls>0?`≥ `:``}${j(n.chargedCreditMicro)} Credits`:t.noCloudCalls},$=e=>{let n=e.billing?.external;return n?.calls?n.unknownCostCalls===n.calls?t.costUnknown:`${n.unknownCostCalls>0?`≥ `:`≈ `}${A(n.estimatedCostUsd)}`:t.noExternalCalls},re=e=>e.billing?.source===`local`||e.provider!==`xopc-cloud`&&e.costSource===`local`?t.localSource:e.billing?.source===`xopc_cloud`||e.provider===`xopc-cloud`?t.cloudSource:t.externalSource,ie=e=>{let n=e.billing;return n?.source===`local`?t.localNoCharge:n?.source===`xopc_cloud`?n.state===`settled`&&n.chargedCreditMicro!==null?`${j(n.chargedCreditMicro)} Credits`:n.state===`released`?t.cloudReleased:n.state===`pending`?n.reservedCreditMicro===null?t.cloudPending:t.cloudPendingReserved.replace(`{{credits}}`,j(n.reservedCreditMicro)):t.cloudUnconfirmed:e.provider===`xopc-cloud`?t.cloudUnconfirmed:e.costSource===`local`?t.localNoCharge:e.estimatedCostUsd===void 0?t.costUnknown:`≈ ${A(e.estimatedCostUsd)}`},ae=e=>(0,O.jsxs)(`span`,{className:`flex flex-col items-end gap-1 text-xs`,children:[e.billing?.cloud.calls?(0,O.jsxs)(`span`,{children:[t.cloudSource,`: `,Q(e)]}):null,e.billing?.external.calls?(0,O.jsxs)(`span`,{children:[t.externalSource,`: `,$(e)]}):null,e.billing?.localCalls?(0,O.jsx)(`span`,{children:t.localNoCharge}):null,(0,O.jsxs)(`span`,{children:[e.calls,` `,t.callUnit]})]}),oe={"usage.reason.imageGeneration":t.reasons.imageGeneration,"usage.reason.audioTranscription":t.reasons.audioTranscription,"usage.reason.audioSpeech":t.reasons.audioSpeech,"usage.reason.agentAnswer":t.reasons.agentAnswer,"usage.reason.continueAfterTool":t.reasons.continueAfterTool,"usage.reason.backgroundReview":t.reasons.backgroundReview,"usage.reason.sessionCompaction":t.reasons.sessionCompaction,"usage.reason.sessionTitle":t.reasons.sessionTitle,"usage.reason.imageUnderstanding":t.reasons.imageUnderstanding,"usage.reason.webExtract":t.reasons.webExtract,"usage.reason.sessionSearch":t.reasons.sessionSearch,"usage.reason.noteGeneration":t.reasons.noteGeneration,"usage.reason.automationDraft":t.reasons.automationDraft,"usage.reason.taskPlanning":t.reasons.taskPlanning,"usage.reason.taskJudging":t.reasons.taskJudging,"usage.reason.voiceSummary":t.reasons.voiceSummary,"usage.reason.voiceSelection":t.reasons.voiceSelection,"usage.reason.homeAdvice":t.reasons.homeAdvice,"usage.reason.workDiscovery":t.reasons.workDiscovery,"usage.reason.workInvestigation":t.reasons.workInvestigation,"usage.reason.discussionAnalysis":t.reasons.discussionAnalysis,"usage.reason.textAssist":t.reasons.textAssist,"usage.reason.userModelInterpretation":t.reasons.userModelInterpretation,"usage.reason.other":t.reasons.other};return(0,O.jsxs)(S,{children:[(0,O.jsx)(x,{title:t.title,subtitle:t.subtitle,actions:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`div`,{className:`w-36`,children:(0,O.jsx)(b,{value:o,allowEmpty:!1,ariaLabel:t.periodLabel,placeholder:t.periodLabel,options:[{value:`7`,label:t.last7Days},{value:`30`,label:t.last30Days},{value:`90`,label:t.last90Days}],onChange:U})}),(0,O.jsx)(p,{variant:`ghost`,"aria-label":t.refresh,title:t.refresh,onClick:()=>U(o),children:(0,O.jsx)(_,{className:`size-4`,"aria-hidden":!0})})]})}),B?(0,O.jsx)(M,{}):V?(0,O.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,O.jsx)(y,{className:`mt-0.5 size-4 shrink-0 text-danger`,"aria-hidden":!0}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`p`,{className:`font-medium text-fg`,children:t.loadError}),(0,O.jsx)(`p`,{className:`mt-1`,children:String(V.message??V)})]}),(0,O.jsx)(p,{variant:`secondary`,onClick:()=>void Promise.all([R.mutate(),z.mutate()]),children:t.retry})]})]}):Z?(0,O.jsxs)(`div`,{className:`space-y-5`,children:[(0,O.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.summaryLabel}),(0,O.jsx)(`section`,{"aria-label":t.summaryLabel,className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[{label:t.cloudCharged,value:Q(Z),icon:v},{label:t.knownCost,value:$(Z),icon:v},{label:t.calls,value:Z.calls.toLocaleString(),icon:d},{label:t.tokens,value:k(Z.totalTokens,e),icon:f}].map(e=>(0,O.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,O.jsx)(e.icon,{className:`size-4`,"aria-hidden":!0}),e.label]}),(0,O.jsx)(`div`,{className:`mt-2 text-xl font-semibold tabular-nums text-fg`,children:e.value})]},e.label))}),(Z.billing?.external.unknownCostCalls??0)>0?(0,O.jsx)(`p`,{className:`rounded-lg border border-edge bg-surface-inset px-3 py-2 text-xs leading-5 text-fg-muted`,children:Z.billing?.external.unknownCostCalls===Z.billing?.external.calls?t.allCostsUnknown:t.someCostsUnknown}):null,Z.billing?.cloud.calls?(0,O.jsxs)(`p`,{className:`rounded-lg border border-edge bg-surface-inset px-3 py-2 text-xs leading-5 text-fg-muted`,children:[t.cloudCoverage.replace(`{{pending}}`,String(Z.billing.cloud.pendingCalls)).replace(`{{unknown}}`,String(Z.billing.cloud.unavailableCalls)),Z.billing.cloud.reservedCreditMicro===null?``:` ${t.cloudReserved.replace(`{{credits}}`,j(Z.billing.cloud.reservedCreditMicro))}`]}):null,(0,O.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.distribution}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.distributionHint})]}),(0,O.jsx)(u,{className:`flex gap-1`,role:`group`,"aria-label":t.distribution,children:[`scenario`,`model`].map(e=>(0,O.jsx)(p,{variant:W===e?`secondary`:`ghost`,"aria-pressed":W===e,onClick:()=>H(t=>{t.set(`group`,e),t.delete(`groupPage`)}),children:e===`scenario`?t.byScenario:t.byModel},e))})]}),(0,O.jsx)(`div`,{className:`divide-y divide-edge-subtle px-4`,children:Y?.length?Y.map(e=>{let n=W===`scenario`?t.categories[e.key]??e.key:e.key;return(0,O.jsxs)(`div`,{className:`flex flex-col gap-3 py-3 text-sm sm:flex-row sm:items-center sm:justify-between`,children:[(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`p`,{className:`truncate font-medium text-fg`,title:n,children:n}),(0,O.jsx)(`div`,{className:`mt-2 h-1 max-w-64 overflow-hidden rounded-full bg-surface-inset`,"aria-hidden":!0,children:(0,O.jsx)(`div`,{className:`h-full rounded-full bg-accent`,style:{width:`${Z.calls?e.totals.calls/Z.calls*100:0}%`}})})]}),(0,O.jsx)(`div`,{className:`shrink-0 self-end tabular-nums text-fg-muted sm:self-auto`,children:ae(e.totals)})]},e.key)}):(0,O.jsx)(`p`,{className:`py-5 text-sm text-fg-subtle`,children:t.empty})}),K>1?(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-t border-edge px-4 py-3`,children:[(0,O.jsx)(`p`,{className:`text-xs text-fg-muted`,"aria-live":`polite`,children:t.groupPage.replace(`{{page}}`,String(J)).replace(`{{pages}}`,String(K)).replace(`{{count}}`,String(G?.length??0))}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(p,{disabled:J===1,"aria-label":t.previousDistribution,onClick:()=>H(e=>e.set(`groupPage`,String(J-1))),children:t.previousPage}),(0,O.jsx)(p,{disabled:J===K,"aria-label":t.nextDistribution,onClick:()=>H(e=>e.set(`groupPage`,String(J+1))),children:t.nextPage})]})]}):null]}),(0,O.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.recentCalls}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.recentCallsHint})]}),(0,O.jsx)(`div`,{className:`w-36`,children:(0,O.jsx)(b,{value:String(c),allowEmpty:!1,ariaLabel:t.pageSize,placeholder:t.pageSize,options:[20,50].map(e=>({value:String(e),label:t.rowsPerPage.replace(`{{count}}`,String(e))})),onChange:e=>H(t=>{t.set(`size`,e),t.delete(`cursor`)})})})]}),(0,O.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:z.error?(0,O.jsxs)(`div`,{role:`alert`,className:`space-y-3 p-4 text-sm text-fg-muted`,children:[(0,O.jsx)(`p`,{children:t.loadError}),(0,O.jsx)(p,{onClick:()=>void z.mutate(),children:t.retry})]}):z.data?z.data.items.length?z.data.items.map(n=>(0,O.jsxs)(`article`,{className:`grid gap-2 px-4 py-3 text-sm sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,O.jsx)(g,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,O.jsx)(`span`,{className:`truncate font-medium text-fg`,children:oe[n.reasonKey]??t.reasons.other})]}),(0,O.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-subtle`,children:[(0,O.jsxs)(`span`,{className:`min-w-0 [overflow-wrap:anywhere]`,children:[n.provider,`/`,n.model]}),(0,O.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,O.jsx)(m,{className:`size-3`,"aria-hidden":!0}),te(n.startedAt,e)]}),(0,O.jsx)(`span`,{className:`rounded border border-edge px-1.5 py-0.5`,children:re(n)}),(0,O.jsx)(`span`,{children:n.totalTokens===void 0?t.tokensUnknown:`${k(n.totalTokens,e)} tokens`})]})]}),(0,O.jsxs)(`div`,{className:`text-left tabular-nums text-fg sm:text-right`,children:[ie(n),(0,O.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.status[n.status]??n.status})]})]},n.id)):(0,O.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-fg-subtle`,children:t.empty}):(0,O.jsx)(`div`,{"aria-busy":`true`,className:`space-y-3 p-4`,children:[0,1,2,3].map(e=>(0,O.jsx)(h,{className:`h-16`},e))})}),(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-t border-edge px-4 py-3`,children:[(0,O.jsx)(`p`,{className:`text-xs text-fg-muted`,"aria-live":`polite`,children:t.eventPage.replace(`{{page}}`,String(X)).replace(`{{count}}`,String(z.data?.items.length??0))}),(0,O.jsxs)(`nav`,{className:`flex gap-2`,"aria-label":t.pagination,children:[X>1?(0,O.jsx)(p,{variant:`ghost`,onClick:()=>H(e=>e.delete(`cursor`)),children:t.firstPage}):null,(0,O.jsx)(p,{disabled:X===1,onClick:()=>H(e=>{e.delete(`cursor`),w.slice(0,-1).forEach(t=>e.append(`cursor`,t))}),children:t.previousPage}),(0,O.jsx)(p,{disabled:!z.data?.nextCursor||!!z.error,onClick:()=>H(e=>{z.data?.nextCursor&&e.append(`cursor`,z.data.nextCursor)}),children:t.nextPage})]})]})]}),(0,O.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,O.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg focus-visible:outline-accent`,children:t.billingDetails}),(0,O.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-muted`,children:t.cloudBillingHint}),(0,O.jsx)(`a`,{className:`mt-2 inline-block text-xs text-accent-fg hover:underline`,href:`https://console.xopc.ai/models/billing`,target:`_blank`,rel:`noreferrer`,children:t.cloudCreditsLabel}),ne?(0,O.jsx)(`div`,{className:`mt-4`,children:(0,O.jsx)(ee,{labels:a(e).capabilitiesSettings.xopcCloudAccount})}):null]})]}):null]})}export{P 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"./cn-0WouolD0.js";import{n as o}from"./locale-store-Jnhw2WMv.js";import{Gu as s,sf as c}from"./index-CzkAd5Su.js";var l=n(),u=r();function d(e){let t=(0,l.c)(21),{status:n,error:r,className:d}=e,p=o(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=a(`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)(s,{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)(c,{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"./cn-0WouolD0.js";import{n as o}from"./locale-store-D5h-Ha6-.js";import{Ju as s,uf as c}from"./index-DmURUvvA.js";var l=n(),u=r();function d(e){let t=(0,l.c)(21),{status:n,error:r,className:d}=e,p=o(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=a(`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)(s,{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)(c,{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};