@xopcai/xopc 0.0.224 → 0.0.225

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 (183) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/demo-memory/src/index.js +10 -1
  3. package/dist/extensions/feishu/src/outbound/media-load.js +1 -1
  4. package/dist/extensions/telegram/xopc.extension.json +1 -1
  5. package/dist/gateway/static/root/assets/{activity-store--GBciH10.js → activity-store-CtTYnku4.js} +1 -1
  6. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-K7V4XXt7.js → agent-avatar-dicebear-dizuqu_4.js} +1 -1
  7. package/dist/gateway/static/root/assets/{agents-BsxTpXyq.js → agents-DeEEFZJ4.js} +1 -1
  8. package/dist/gateway/static/root/assets/{api-HoIz_ija.js → api-CLRMz2BT.js} +1 -1
  9. package/dist/gateway/static/root/assets/{app-management-settings-panel-xQCmkAHh.js → app-management-settings-panel-Cnk-DtQh.js} +1 -1
  10. package/dist/gateway/static/root/assets/{appearance-settings-BRoeA4kU.js → appearance-settings-wP0rogVI.js} +1 -1
  11. package/dist/gateway/static/root/assets/{apps-page-BXgpBA8w.js → apps-page-Db5YNHVM.js} +1 -1
  12. package/dist/gateway/static/root/assets/{archive-plugin-CteCVsBP.js → archive-plugin-Cpzsm-DM.js} +1 -1
  13. package/dist/gateway/static/root/assets/{attachment-load-D7xNA2jB.js → attachment-load-Bd2OOoEK.js} +1 -1
  14. package/dist/gateway/static/root/assets/{automations-page-BD1vK7r5.js → automations-page-DNqhguyk.js} +1 -1
  15. package/dist/gateway/static/root/assets/{automations-workspace-wrgf-z7D.js → automations-workspace-CNT05YTb.js} +1 -1
  16. package/dist/gateway/static/root/assets/{binary-plugins-C3DaJa0W.js → binary-plugins-Dcma5HdI.js} +1 -1
  17. package/dist/gateway/static/root/assets/{block-editor-lTkcHTve.js → block-editor-D-B8ThwK.js} +1 -1
  18. package/dist/gateway/static/root/assets/{browser-settings-page-zhzNkeVG.js → browser-settings-page-UbDj3LIq.js} +1 -1
  19. package/dist/gateway/static/root/assets/{browser-workflow-inputs-1UZ0vnIy.js → browser-workflow-inputs-BAPZIXrs.js} +1 -1
  20. package/dist/gateway/static/root/assets/{browser-workflows-page-BHuJOF4M.js → browser-workflows-page-DHtaSKEh.js} +1 -1
  21. package/dist/gateway/static/root/assets/{capabilities-settings-panel-DuCmg2Ej.js → capabilities-settings-panel-CiO152QS.js} +1 -1
  22. package/dist/gateway/static/root/assets/{capability-presets-api-yNqTIuyd.js → capability-presets-api-zsZQ7im3.js} +1 -1
  23. package/dist/gateway/static/root/assets/{capability-presets-settings-panel-DjiP3mQQ.js → capability-presets-settings-panel-Bc_hRwfL.js} +1 -1
  24. package/dist/gateway/static/root/assets/{channel-recipient-api-krezGsKc.js → channel-recipient-api-Cp8iaaXp.js} +1 -1
  25. package/dist/gateway/static/root/assets/{channels-settings-B4AtvQHk.js → channels-settings-CFW7zBoT.js} +1 -1
  26. package/dist/gateway/static/root/assets/channels-status-swr-5rNVq7iI.js +1 -0
  27. package/dist/gateway/static/root/assets/{chat-terminal-dock-BRrL2iHA.js → chat-terminal-dock-Dr6Rq2ln.js} +1 -1
  28. package/dist/gateway/static/root/assets/connectors-page-DLBr5nre.js +2 -0
  29. package/dist/gateway/static/root/assets/{cron-expression-Bl-2DzBQ.js → cron-expression-BiXrpzmo.js} +1 -1
  30. package/dist/gateway/static/root/assets/{date-picker-CxTl6Wlz.js → date-picker-BPuRtwKt.js} +1 -1
  31. package/dist/gateway/static/root/assets/{dependency-picker-DSl0mOPa.js → dependency-picker-BNC_W7wI.js} +1 -1
  32. package/dist/gateway/static/root/assets/{desktop-pet-DTeCmCdb.js → desktop-pet-DzOpt5nI.js} +1 -1
  33. package/dist/gateway/static/root/assets/{desktop-pet-settings-BNebxg0V.js → desktop-pet-settings-BW0brCvH.js} +1 -1
  34. package/dist/gateway/static/root/assets/{directory-picker-path-field-Dn9XpmXY.js → directory-picker-path-field-Baml0uTS.js} +1 -1
  35. package/dist/gateway/static/root/assets/{extension-debug-page-D-J-eOTb.js → extension-debug-page-CBXyKmfS.js} +1 -1
  36. package/dist/gateway/static/root/assets/{extension-page-CpST24nU.js → extension-page-BBhcr_SZ.js} +1 -1
  37. package/dist/gateway/static/root/assets/{extension-settings-page-4nQXFnFq.js → extension-settings-page-4rwWpN9_.js} +1 -1
  38. package/dist/gateway/static/root/assets/{gateway-config-api-BHWHduDi.js → gateway-config-api-Dg-BlBe4.js} +1 -1
  39. package/dist/gateway/static/root/assets/{gateway-config-swr-yUxMMVjK.js → gateway-config-swr-Du0MvK9s.js} +1 -1
  40. package/dist/gateway/static/root/assets/{gateway-settings-BimMKmkM.js → gateway-settings-BOuYZOYe.js} +1 -1
  41. package/dist/gateway/static/root/assets/{gateway-startup-retry-9mrsL84j.js → gateway-startup-retry-JbjcHCaN.js} +1 -1
  42. package/dist/gateway/static/root/assets/{heartbeat-settings-MUJ3mEC9.js → heartbeat-settings-Dq4YAlSx.js} +1 -1
  43. package/dist/gateway/static/root/assets/{home-page-DSM6aPHF.js → home-page-BIXkO0Ck.js} +1 -1
  44. package/dist/gateway/static/root/assets/{image-generation-api-CgFAGDi8.js → image-generation-api-G2tfPvKP.js} +1 -1
  45. package/dist/gateway/static/root/assets/{index-B3zYJBhK.js → index-Csccu8sa.js} +11 -11
  46. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-6Ar5rfX4.js → keyboard-shortcuts-settings-L1Vtxgp9.js} +1 -1
  47. package/dist/gateway/static/root/assets/{local-app-workbench-page-tzM0wTL8.js → local-app-workbench-page-D-eacBcO.js} +1 -1
  48. package/dist/gateway/static/root/assets/{local-apps-page-B5n-x544.js → local-apps-page--thlkBLS.js} +1 -1
  49. package/dist/gateway/static/root/assets/{locale-store-CPylQjH9.js → locale-store-DqJz-cOR.js} +1 -1
  50. package/dist/gateway/static/root/assets/{logs-page-CgoQlera.js → logs-page-BRCglHvd.js} +1 -1
  51. package/dist/gateway/static/root/assets/{management-settings-CXBLyU-0.js → management-settings-p55fR4XO.js} +1 -1
  52. package/dist/gateway/static/root/assets/{markdown-split-CtmQemJi.js → markdown-split-DwMcRlBR.js} +1 -1
  53. package/dist/gateway/static/root/assets/{markdown-view-CUsob4Pz.js → markdown-view-CTB9u15e.js} +1 -1
  54. package/dist/gateway/static/root/assets/{media-plugins-Dsd-IEOW.js → media-plugins-O6H3GZn7.js} +1 -1
  55. package/dist/gateway/static/root/assets/{messages-B82nsi9k.js → messages-CeydamsI.js} +3 -3
  56. package/dist/gateway/static/root/assets/{notes-api-CfKZYrBC.js → notes-api-CrjQbmk1.js} +1 -1
  57. package/dist/gateway/static/root/assets/{notes-page-BKbOTE2n.js → notes-page-miO9ig9C.js} +1 -1
  58. package/dist/gateway/static/root/assets/{notes-workbench-BScELo01.js → notes-workbench-_13lmvmF.js} +2 -2
  59. package/dist/gateway/static/root/assets/{product-open-page-DqB9bsDB.js → product-open-page-BOu07nXf.js} +1 -1
  60. package/dist/gateway/static/root/assets/{project-detail-page-DUoyty8X.js → project-detail-page-BStRkOQr.js} +1 -1
  61. package/dist/gateway/static/root/assets/{projects-page-PeXUdGdO.js → projects-page-CY03RxVr.js} +1 -1
  62. package/dist/gateway/static/root/assets/{registry-api-B_5D8epF.js → registry-api-Bf_HDLUJ.js} +1 -1
  63. package/dist/gateway/static/root/assets/{remote-access-hub-sHho-uXP.js → remote-access-hub-B19llkld.js} +1 -1
  64. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-DBTH_t0O.js → runtime-tools-settings-panel-DthuRqUH.js} +1 -1
  65. package/dist/gateway/static/root/assets/{schema-form-CqMKAwV0.js → schema-form-8W8PhXxa.js} +1 -1
  66. package/dist/gateway/static/root/assets/{sessions-page-DyvNgaP9.js → sessions-page-BDA2qbTd.js} +1 -1
  67. package/dist/gateway/static/root/assets/settings-advanced-gate-BONIDX4v.js +1 -0
  68. package/dist/gateway/static/root/assets/{settings-form-section-dPriuuYq.js → settings-form-section-CrsKGYiG.js} +1 -1
  69. package/dist/gateway/static/root/assets/{settings-loading-skeleton-B-Mbm8Va.js → settings-loading-skeleton-WJtI0AAq.js} +1 -1
  70. package/dist/gateway/static/root/assets/{settings-page-Dyj3w-Ml.js → settings-page-PCjwRF47.js} +1 -1
  71. package/dist/gateway/static/root/assets/{setup-status-panel-C4FxY5J3.js → setup-status-panel-D65CwlNC.js} +1 -1
  72. package/dist/gateway/static/root/assets/{share-preview-page-emEdx7YL.js → share-preview-page-BGtvLLeZ.js} +1 -1
  73. package/dist/gateway/static/root/assets/{shares-settings-BQBVq-sN.js → shares-settings-CdzVKrBl.js} +1 -1
  74. package/dist/gateway/static/root/assets/skill-reload-api-CsRWid5h.js +1 -0
  75. package/dist/gateway/static/root/assets/{skills-page-BNtYnrRT.js → skills-page-C_npyryI.js} +1 -1
  76. package/dist/gateway/static/root/assets/{skills-page.utils-DjnbNFs5.js → skills-page.utils-C46Sd78k.js} +1 -1
  77. package/dist/gateway/static/root/assets/{system-settings-panel-DDStf-jZ.js → system-settings-panel-DomTLwki.js} +1 -1
  78. package/dist/gateway/static/root/assets/{task-detail-page-ZVwr8KbS.js → task-detail-page-B6YFX7kK.js} +1 -1
  79. package/dist/gateway/static/root/assets/{theme-store-BN-32Fz5.js → theme-store-Ce7wq__X.js} +1 -1
  80. package/dist/gateway/static/root/assets/{use-autosave-C2mKZ-ua.js → use-autosave-Do9mCRcY.js} +1 -1
  81. package/dist/gateway/static/root/assets/{user-context-page-CHjIinCW.js → user-context-page-CiCQA40E.js} +1 -1
  82. package/dist/gateway/static/root/assets/{voice-api-key-field-D7OHeQby.js → voice-api-key-field-Bc5p-0tX.js} +1 -1
  83. package/dist/gateway/static/root/assets/{work-discovery-overlay-CIiXie7F.js → work-discovery-overlay-BieqsmT1.js} +1 -1
  84. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-9_dAGW3_.js → workflow-run-setup-panel-DVj8iYvm.js} +1 -1
  85. package/dist/gateway/static/root/assets/{workflows-page-DXpYJxao.js → workflows-page-AG04TTuH.js} +1 -1
  86. package/dist/gateway/static/root/index.html +10 -10
  87. package/dist/package.js +1 -1
  88. package/dist/src/agent/embedded/run-turn.js +2 -0
  89. package/dist/src/agent/mcp/bundle-mcp-config.d.ts +9 -1
  90. package/dist/src/agent/mcp/bundle-mcp-config.js +11 -15
  91. package/dist/src/agent/mcp/embedded-mcp.d.ts +1 -1
  92. package/dist/src/agent/mcp/index.d.ts +1 -0
  93. package/dist/src/agent/mcp/index.js +7 -1
  94. package/dist/src/agent/mcp/mcp-http.d.ts +4 -0
  95. package/dist/src/agent/mcp/mcp-http.js +25 -1
  96. package/dist/src/agent/mcp/mcp-transport-config.d.ts +4 -0
  97. package/dist/src/agent/mcp/mcp-transport-config.js +1 -0
  98. package/dist/src/agent/mcp/mcp-transport.d.ts +7 -1
  99. package/dist/src/agent/mcp/mcp-transport.js +38 -11
  100. package/dist/src/agent/mcp/oauth/index.d.ts +6 -0
  101. package/dist/src/agent/mcp/oauth/index.js +6 -0
  102. package/dist/src/agent/mcp/oauth/mcp-oauth-errors.d.ts +5 -0
  103. package/dist/src/agent/mcp/oauth/mcp-oauth-errors.js +14 -0
  104. package/dist/src/agent/mcp/oauth/mcp-oauth-manager.d.ts +25 -0
  105. package/dist/src/agent/mcp/oauth/mcp-oauth-manager.js +219 -0
  106. package/dist/src/agent/mcp/oauth/mcp-oauth-provider.d.ts +33 -0
  107. package/dist/src/agent/mcp/oauth/mcp-oauth-provider.js +103 -0
  108. package/dist/src/agent/mcp/oauth/mcp-oauth-session.d.ts +29 -0
  109. package/dist/src/agent/mcp/oauth/mcp-oauth-session.js +169 -0
  110. package/dist/src/agent/mcp/oauth/mcp-oauth-store.d.ts +9 -0
  111. package/dist/src/agent/mcp/oauth/mcp-oauth-store.js +79 -0
  112. package/dist/src/agent/mcp/oauth/mcp-oauth-types.d.ts +22 -0
  113. package/dist/src/agent/mcp/oauth/mcp-oauth-types.js +1 -0
  114. package/dist/src/agent/memory/builtin-provider.js +23 -4
  115. package/dist/src/agent/memory/compaction-promotion.d.ts +18 -0
  116. package/dist/src/agent/memory/compaction-promotion.js +211 -0
  117. package/dist/src/agent/memory/context/types.d.ts +5 -0
  118. package/dist/src/agent/memory/manager.d.ts +3 -0
  119. package/dist/src/agent/memory/manager.js +12 -2
  120. package/dist/src/agent/memory/trusted-recall.d.ts +7 -0
  121. package/dist/src/agent/memory/trusted-recall.js +53 -0
  122. package/dist/src/agent/memory/turn-provenance.d.ts +14 -0
  123. package/dist/src/agent/memory/turn-provenance.js +60 -0
  124. package/dist/src/agent/memory/types.d.ts +18 -3
  125. package/dist/src/agent/memory/user-context-coordinator.js +57 -6
  126. package/dist/src/agent/skills/marketplace/adapters/store/store-api-client.d.ts +2 -0
  127. package/dist/src/agent/tools/memory-tool.js +5 -1
  128. package/dist/src/capabilities/store-connector.js +99 -10
  129. package/dist/src/cli/commands/channels.js +1 -1
  130. package/dist/src/cli/commands/connectors.js +1 -1
  131. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  132. package/dist/src/cli/commands/extension-marketplace.js +1 -1
  133. package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
  134. package/dist/src/cli/commands/models.js +1 -1
  135. package/dist/src/cli/commands/onboard.js +1 -1
  136. package/dist/src/config/config-mutation.d.ts +14 -0
  137. package/dist/src/config/config-mutation.js +33 -0
  138. package/dist/src/config/index.js +3 -3
  139. package/dist/src/config/paths.d.ts +2 -0
  140. package/dist/src/config/paths.js +5 -1
  141. package/dist/src/config/schema.d.ts +17 -0
  142. package/dist/src/config/schema.js +26 -2
  143. package/dist/src/connectors/auth-provider-registry.d.ts +1 -1
  144. package/dist/src/connectors/auth-provider-registry.js +23 -2
  145. package/dist/src/connectors/install.js +3 -3
  146. package/dist/src/connectors/instances.d.ts +2 -1
  147. package/dist/src/connectors/instances.js +15 -5
  148. package/dist/src/connectors/materialize.d.ts +1 -0
  149. package/dist/src/connectors/materialize.js +9 -1
  150. package/dist/src/connectors/runtime-adapter-registry.js +1 -0
  151. package/dist/src/connectors/types.d.ts +4 -1
  152. package/dist/src/extensions/connector-dependencies.d.ts +10 -0
  153. package/dist/src/extensions/connector-dependencies.js +65 -0
  154. package/dist/src/extensions/install.js +27 -0
  155. package/dist/src/extensions/normalize-manifest.js +1 -0
  156. package/dist/src/extensions/sdk/index.js +1 -1
  157. package/dist/src/extensions/types/manifest.d.ts +2 -0
  158. package/dist/src/gateway/heartbeat/service.js +1 -1
  159. package/dist/src/gateway/hono/routes/capabilities.js +8 -8
  160. package/dist/src/gateway/hono/routes/connectors.js +87 -55
  161. package/dist/src/gateway/hono/routes/mcp.js +77 -5
  162. package/dist/src/gateway/hono/routes/voice.js +1 -1
  163. package/dist/src/gateway/service.js +8 -8
  164. package/dist/src/heartbeat/index.js +1 -1
  165. package/dist/src/infra/update-restart.js +1 -1
  166. package/dist/src/knowledge/connected-knowledge-pipeline.js +26 -4
  167. package/dist/src/session/store.js +27 -0
  168. package/dist/src/storage/sqlite/memory-records-repository.d.ts +9 -1
  169. package/dist/src/storage/sqlite/memory-records-repository.js +40 -6
  170. package/dist/src/storage/sqlite/migrations/134_memory_provenance.sql +18 -0
  171. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  172. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  173. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  174. package/dist/src/storage/sqlite/schema.js +1 -1
  175. package/dist/src/tui/backends/embedded-backend.js +1 -1
  176. package/dist/src/user-context/planner.js +8 -3
  177. package/package.json +2 -2
  178. package/dist/gateway/static/root/assets/channels-status-swr-DMxB7slL.js +0 -1
  179. package/dist/gateway/static/root/assets/connectors-page-fmda2NEP.js +0 -2
  180. package/dist/gateway/static/root/assets/settings-advanced-gate-CnYf1R7z.js +0 -1
  181. package/dist/gateway/static/root/assets/skill-reload-api-BFoEpQ4I.js +0 -1
  182. package/dist/src/extensions/bundle-mcp.d.ts +0 -18
  183. package/dist/src/extensions/bundle-mcp.js +0 -69
@@ -1 +1 @@
1
- import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-JdwAhgNB.js";import{l as r,o as i,r as a}from"./locale-store-CPylQjH9.js";import{br as o}from"./index-B3zYJBhK.js";import"./skill-reload-api-BFoEpQ4I.js";async function s(e,t){let n=new FormData;n.append(`file`,e),t.skillId&&n.append(`skillId`,t.skillId),t.overwrite&&n.append(`overwrite`,`true`),n.append(`target`,t.target??`global`);let i=r.getState().token,o=new Headers;i&&o.set(`Authorization`,`Bearer ${i}`);let s=await fetch(a(`/api/skills/upload`),{method:`POST`,headers:o,body:n});s.status===401&&r.getState().onUnauthorized();let c=await s.json().catch(()=>({}));if(!s.ok)throw Error(c.error||`HTTP ${s.status}`);if(!c.payload?.skillId)throw Error(`Invalid response`);return c.payload}async function c(e,t){let n=t?`?target=${encodeURIComponent(t)}`:``,r=await i(a(`/api/skills/${encodeURIComponent(e)}${n}`),{method:`DELETE`});if(!r.ok)throw Error(await o(r))}async function l(e,t){let n=await i(a(`/api/skills/enabled`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({skillName:e,enabled:t})});if(!n.ok)throw Error(await o(n))}function u(e,t){t?.trim()&&e.set(`provider`,t.trim())}async function d(e){let t=new URLSearchParams;u(t,e?.provider),e?.locale?.trim()&&t.set(`locale`,e.locale.trim());let n=t.toString(),r=await i(a(`/api/skills/marketplace/categories${n?`?${n}`:``}`),{cache:`no-store`});if(!r.ok)throw Error(await o(r));let s=await r.json();if(!s.payload||!Array.isArray(s.payload.items))throw Error(`Invalid response`);return{items:s.payload.items}}async function f(e){let t=new URLSearchParams;e.q?.trim()&&t.set(`q`,e.q.trim()),e.page!=null&&t.set(`page`,String(e.page)),e.pageSize!=null&&t.set(`pageSize`,String(e.pageSize)),e.sort&&t.set(`sort`,e.sort),e.category?.trim()&&t.set(`category`,e.category.trim()),u(t,e.provider);let n=t.toString(),r=await i(a(`/api/skills/marketplace${n?`?${n}`:``}`),{cache:`no-store`,signal:e.signal});if(!r.ok)throw Error(await o(r));let s=await r.json();if(!s.payload?.items||!s.payload.meta)throw Error(`Invalid response`);return s.payload}async function p(e,t){let n=encodeURIComponent(e),r=new URLSearchParams;u(r,t?.provider);let s=r.toString(),c=await i(a(`/api/skills/marketplace/packages/${n}${s?`?${s}`:``}`),{cache:`no-store`});if(!c.ok)throw Error(await o(c));let l=(await c.json()).payload;if(!l?.name||!l.skillDocPreview||typeof l.skillDocPreview.name!=`string`||typeof l.skillDocPreview.description!=`string`||typeof l.skillDocPreview.bodyMarkdown!=`string`||typeof l.skillDocPreview.disableModelInvocation!=`boolean`||!l.skillDocPreview.metadata||typeof l.skillDocPreview.metadata!=`object`||typeof l.skillDocPreview.metadata.name!=`string`||typeof l.skillDocPreview.metadata.description!=`string`)throw Error(`Invalid response`);return l}async function m(e){let t=await i(a(`/api/skills/marketplace/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({target:`global`,...e})});if(!t.ok)throw Error(await o(t));let n=await t.json();if(!n.payload?.skillId)throw Error(n.error||`Invalid response`);return n.payload}async function h(e){let t=await i(a(`/api/skills/${encodeURIComponent(e)}/content`),{cache:`no-store`});if(!t.ok)throw Error(await o(t));let n=(await t.json()).payload;if(!n||typeof n.name!=`string`||typeof n.description!=`string`||typeof n.bodyMarkdown!=`string`||typeof n.disableModelInvocation!=`boolean`||!n.metadata||typeof n.metadata!=`object`||typeof n.metadata.name!=`string`||typeof n.metadata.description!=`string`)throw Error(`Invalid response`);return n}async function g(){let e=await i(a(`/api/skills/marketplace/provider`),{cache:`no-store`});if(!e.ok)throw Error(await o(e));let t=await e.json();if(!t.payload?.provider)throw Error(`Invalid response`);return t.payload}async function _(){let e=await i(a(`/api/skills/marketplace/providers`),{cache:`no-store`});if(!e.ok)throw Error(await o(e));let t=await e.json();if(!t.payload?.providers)throw Error(`Invalid response`);return t.payload}var v=e(),y=t(),b=[{light:`bg-sky-100 text-sky-800`,dark:`dark:bg-sky-950/55 dark:text-sky-200`},{light:`bg-violet-100 text-violet-800`,dark:`dark:bg-violet-950/55 dark:text-violet-200`},{light:`bg-emerald-100 text-emerald-800`,dark:`dark:bg-emerald-950/55 dark:text-emerald-200`},{light:`bg-orange-100 text-orange-800`,dark:`dark:bg-orange-950/55 dark:text-orange-200`},{light:`bg-rose-100 text-rose-800`,dark:`dark:bg-rose-950/55 dark:text-rose-200`},{light:`bg-amber-100 text-amber-900`,dark:`dark:bg-amber-950/55 dark:text-amber-200`},{light:`bg-cyan-100 text-cyan-800`,dark:`dark:bg-cyan-950/55 dark:text-cyan-200`},{light:`bg-indigo-100 text-indigo-800`,dark:`dark:bg-indigo-950/55 dark:text-indigo-200`},{light:`bg-fuchsia-100 text-fuchsia-800`,dark:`dark:bg-fuchsia-950/55 dark:text-fuchsia-200`},{light:`bg-teal-100 text-teal-800`,dark:`dark:bg-teal-950/55 dark:text-teal-200`}];function x(e){let t=0;for(let n=0;n<e.length;n+=1)t=Math.imul(31,t)+e.charCodeAt(n)|0;return Math.abs(t)}function S(e){let t=e.trim();if(!t)return`?`;let n=t.match(/[\p{L}\p{N}]/u);return n?n[0].toLocaleUpperCase(`en-US`):t[0]}function C(e){let t=(0,v.c)(9),{name:r,className:i}=e,a;t[0]===r?a=t[1]:(a=S(r),t[0]=r,t[1]=a);let o=a,s=b[x(r)%b.length],c;t[2]!==i||t[3]!==s.dark||t[4]!==s.light?(c=n(`flex size-11 shrink-0 items-center justify-center rounded-xl font-semibold tracking-tight shadow-surface`,`text-[1.05rem] ring-1 ring-inset ring-black/[0.06] dark:ring-white/[0.1]`,`transition-[transform,box-shadow] duration-200 ease-out group-hover:ring-black/[0.1] dark:group-hover:ring-white/[0.14]`,`group-hover:-translate-y-px`,s.light,s.dark,i),t[2]=i,t[3]=s.dark,t[4]=s.light,t[5]=c):c=t[5];let l;return t[6]!==o||t[7]!==c?(l=(0,y.jsx)(`div`,{className:c,"aria-hidden":!0,children:o}),t[6]=o,t[7]=c,t[8]=l):l=t[8],l}var w=`https://skillhub.cn`,T=`https://clawhub.ai`;function E(e){let t=e.trim();return t?`${w}/skills/${encodeURIComponent(t)}`:null}function D(e){let t=e.trim();return t?`${T}/${encodeURIComponent(t)}`:null}function O(e,t){return e===`skillhub`?E(t):e===`clawhub`?D(t):null}function k(e,t){return t===`store`?e.name.trim()||e.id:e.id.trim()||e.name}function A(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function j(e){return e.filter(e=>e.type!==`collision`)}function M(e){let t=[e.kind];return e.label?.trim()&&t.push(e.label.trim()),e.package?.trim()&&t.push(e.package.trim()),e.formula?.trim()&&t.push(e.formula.trim()),e.module?.trim()&&t.push(e.module.trim()),e.url?.trim()&&t.push(e.url.trim()),t.join(` · `)}function N(e){return{...e,enabled:e.enabled??!0,disableModelInvocation:e.disableModelInvocation??!1}}export{s as _,O as a,c,g as d,_ as f,l as g,m as h,k as i,d as l,h as m,M as n,N as o,f as p,A as r,C as s,j as t,p as u};
1
+ import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-JdwAhgNB.js";import{l as r,o as i,r as a}from"./locale-store-DqJz-cOR.js";import{br as o}from"./index-Csccu8sa.js";import"./skill-reload-api-CsRWid5h.js";async function s(e,t){let n=new FormData;n.append(`file`,e),t.skillId&&n.append(`skillId`,t.skillId),t.overwrite&&n.append(`overwrite`,`true`),n.append(`target`,t.target??`global`);let i=r.getState().token,o=new Headers;i&&o.set(`Authorization`,`Bearer ${i}`);let s=await fetch(a(`/api/skills/upload`),{method:`POST`,headers:o,body:n});s.status===401&&r.getState().onUnauthorized();let c=await s.json().catch(()=>({}));if(!s.ok)throw Error(c.error||`HTTP ${s.status}`);if(!c.payload?.skillId)throw Error(`Invalid response`);return c.payload}async function c(e,t){let n=t?`?target=${encodeURIComponent(t)}`:``,r=await i(a(`/api/skills/${encodeURIComponent(e)}${n}`),{method:`DELETE`});if(!r.ok)throw Error(await o(r))}async function l(e,t){let n=await i(a(`/api/skills/enabled`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({skillName:e,enabled:t})});if(!n.ok)throw Error(await o(n))}function u(e,t){t?.trim()&&e.set(`provider`,t.trim())}async function d(e){let t=new URLSearchParams;u(t,e?.provider),e?.locale?.trim()&&t.set(`locale`,e.locale.trim());let n=t.toString(),r=await i(a(`/api/skills/marketplace/categories${n?`?${n}`:``}`),{cache:`no-store`});if(!r.ok)throw Error(await o(r));let s=await r.json();if(!s.payload||!Array.isArray(s.payload.items))throw Error(`Invalid response`);return{items:s.payload.items}}async function f(e){let t=new URLSearchParams;e.q?.trim()&&t.set(`q`,e.q.trim()),e.page!=null&&t.set(`page`,String(e.page)),e.pageSize!=null&&t.set(`pageSize`,String(e.pageSize)),e.sort&&t.set(`sort`,e.sort),e.category?.trim()&&t.set(`category`,e.category.trim()),u(t,e.provider);let n=t.toString(),r=await i(a(`/api/skills/marketplace${n?`?${n}`:``}`),{cache:`no-store`,signal:e.signal});if(!r.ok)throw Error(await o(r));let s=await r.json();if(!s.payload?.items||!s.payload.meta)throw Error(`Invalid response`);return s.payload}async function p(e,t){let n=encodeURIComponent(e),r=new URLSearchParams;u(r,t?.provider);let s=r.toString(),c=await i(a(`/api/skills/marketplace/packages/${n}${s?`?${s}`:``}`),{cache:`no-store`});if(!c.ok)throw Error(await o(c));let l=(await c.json()).payload;if(!l?.name||!l.skillDocPreview||typeof l.skillDocPreview.name!=`string`||typeof l.skillDocPreview.description!=`string`||typeof l.skillDocPreview.bodyMarkdown!=`string`||typeof l.skillDocPreview.disableModelInvocation!=`boolean`||!l.skillDocPreview.metadata||typeof l.skillDocPreview.metadata!=`object`||typeof l.skillDocPreview.metadata.name!=`string`||typeof l.skillDocPreview.metadata.description!=`string`)throw Error(`Invalid response`);return l}async function m(e){let t=await i(a(`/api/skills/marketplace/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({target:`global`,...e})});if(!t.ok)throw Error(await o(t));let n=await t.json();if(!n.payload?.skillId)throw Error(n.error||`Invalid response`);return n.payload}async function h(e){let t=await i(a(`/api/skills/${encodeURIComponent(e)}/content`),{cache:`no-store`});if(!t.ok)throw Error(await o(t));let n=(await t.json()).payload;if(!n||typeof n.name!=`string`||typeof n.description!=`string`||typeof n.bodyMarkdown!=`string`||typeof n.disableModelInvocation!=`boolean`||!n.metadata||typeof n.metadata!=`object`||typeof n.metadata.name!=`string`||typeof n.metadata.description!=`string`)throw Error(`Invalid response`);return n}async function g(){let e=await i(a(`/api/skills/marketplace/provider`),{cache:`no-store`});if(!e.ok)throw Error(await o(e));let t=await e.json();if(!t.payload?.provider)throw Error(`Invalid response`);return t.payload}async function _(){let e=await i(a(`/api/skills/marketplace/providers`),{cache:`no-store`});if(!e.ok)throw Error(await o(e));let t=await e.json();if(!t.payload?.providers)throw Error(`Invalid response`);return t.payload}var v=e(),y=t(),b=[{light:`bg-sky-100 text-sky-800`,dark:`dark:bg-sky-950/55 dark:text-sky-200`},{light:`bg-violet-100 text-violet-800`,dark:`dark:bg-violet-950/55 dark:text-violet-200`},{light:`bg-emerald-100 text-emerald-800`,dark:`dark:bg-emerald-950/55 dark:text-emerald-200`},{light:`bg-orange-100 text-orange-800`,dark:`dark:bg-orange-950/55 dark:text-orange-200`},{light:`bg-rose-100 text-rose-800`,dark:`dark:bg-rose-950/55 dark:text-rose-200`},{light:`bg-amber-100 text-amber-900`,dark:`dark:bg-amber-950/55 dark:text-amber-200`},{light:`bg-cyan-100 text-cyan-800`,dark:`dark:bg-cyan-950/55 dark:text-cyan-200`},{light:`bg-indigo-100 text-indigo-800`,dark:`dark:bg-indigo-950/55 dark:text-indigo-200`},{light:`bg-fuchsia-100 text-fuchsia-800`,dark:`dark:bg-fuchsia-950/55 dark:text-fuchsia-200`},{light:`bg-teal-100 text-teal-800`,dark:`dark:bg-teal-950/55 dark:text-teal-200`}];function x(e){let t=0;for(let n=0;n<e.length;n+=1)t=Math.imul(31,t)+e.charCodeAt(n)|0;return Math.abs(t)}function S(e){let t=e.trim();if(!t)return`?`;let n=t.match(/[\p{L}\p{N}]/u);return n?n[0].toLocaleUpperCase(`en-US`):t[0]}function C(e){let t=(0,v.c)(9),{name:r,className:i}=e,a;t[0]===r?a=t[1]:(a=S(r),t[0]=r,t[1]=a);let o=a,s=b[x(r)%b.length],c;t[2]!==i||t[3]!==s.dark||t[4]!==s.light?(c=n(`flex size-11 shrink-0 items-center justify-center rounded-xl font-semibold tracking-tight shadow-surface`,`text-[1.05rem] ring-1 ring-inset ring-black/[0.06] dark:ring-white/[0.1]`,`transition-[transform,box-shadow] duration-200 ease-out group-hover:ring-black/[0.1] dark:group-hover:ring-white/[0.14]`,`group-hover:-translate-y-px`,s.light,s.dark,i),t[2]=i,t[3]=s.dark,t[4]=s.light,t[5]=c):c=t[5];let l;return t[6]!==o||t[7]!==c?(l=(0,y.jsx)(`div`,{className:c,"aria-hidden":!0,children:o}),t[6]=o,t[7]=c,t[8]=l):l=t[8],l}var w=`https://skillhub.cn`,T=`https://clawhub.ai`;function E(e){let t=e.trim();return t?`${w}/skills/${encodeURIComponent(t)}`:null}function D(e){let t=e.trim();return t?`${T}/${encodeURIComponent(t)}`:null}function O(e,t){return e===`skillhub`?E(t):e===`clawhub`?D(t):null}function k(e,t){return t===`store`?e.name.trim()||e.id:e.id.trim()||e.name}function A(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function j(e){return e.filter(e=>e.type!==`collision`)}function M(e){let t=[e.kind];return e.label?.trim()&&t.push(e.label.trim()),e.package?.trim()&&t.push(e.package.trim()),e.formula?.trim()&&t.push(e.formula.trim()),e.module?.trim()&&t.push(e.module.trim()),e.url?.trim()&&t.push(e.url.trim()),t.join(` · `)}function N(e){return{...e,enabled:e.enabled??!0,disableModelInvocation:e.disableModelInvocation??!1}}export{s as _,O as a,c,g as d,_ as f,l as g,m as h,k as i,d as l,h as m,M as n,N as o,f as p,A as r,C as s,j as t,p as u};
@@ -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"./cn-JdwAhgNB.js";import{n as a}from"./interaction-BmQogeqz.js";import{t as o}from"./messages-B82nsi9k.js";import{n as s}from"./locale-store-CPylQjH9.js";import{t as c}from"./electron-env-DH5wF8X8.js";import{Gn as l,Is as u,Kl as d,Kn as f,Ua as p,Wn as m,qn as h,qs as g}from"./index-B3zYJBhK.js";import{n as _,r as v}from"./settings-page-layout-BRQNel6r.js";import{r as y,t as b}from"./settings-form-section-dPriuuYq.js";var x=e(t(),1);async function S(e,t){let n=window.electronAPI?.system;if(!c()||!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=o(s(e=>e.language)).systemSettings.browserNotify,[t,n]=(0,x.useState)(f),[r,i]=(0,x.useState)(null),[a,c]=(0,x.useState)(!1),u=async t=>{if(!t){n(h({enabled:!1})),i(null);return}c(!0);try{let t=await m();if(t!==`granted`){i(t===`unsupported`?e.unsupported:e.denied);return}n(h({enabled:!0})),i(await l(e.testTitle,e.testBody)?e.testShown:e.failed)}finally{c(!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)(d,{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]].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:a||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=o(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=o(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=s(e=>e.language),t=o(e).systemSettings,[n,l]=(0,x.useReducer)(p,L),{behavior:d,perms:f,loadError:m,permFeedback:h,permBusy:A,refreshing:N}=n,R=typeof window<`u`?window.electronAPI?.system:void 0,z=(0,x.useCallback)(async e=>{if(R){l({type:`patch`,patch:{loadError:null}});try{l({type:`patch`,patch:{behavior:await R.getBehavior(),perms:await R.getPermissions({probe:e?.showRefreshFeedback}),...e?.showRefreshFeedback?{permFeedback:t.refreshDone}:{}}})}catch(t){l({type:`patch`,patch:{loadError:t instanceof Error?t.message:String(t),...e?.showRefreshFeedback?{permFeedback:null}:{}}})}}},[R,t.refreshDone]),B=(0,x.useCallback)(async()=>{if(!(N||A)){l({type:`patch`,patch:{refreshing:!0}});try{await z({showRefreshFeedback:!0})}finally{l({type:`patch`,patch:{refreshing:!1}})}}},[z,A,N]);if((0,x.useEffect)(()=>{let e=new Set([t.refreshDone,t.openSettingsDone,t.openSettingsFailed,t.desktopNotify.testShown]);if(!h||!e.has(h))return;let n=window.setTimeout(()=>{l({type:`patch`,patch:{permFeedback:null}})},3e3);return()=>window.clearTimeout(n)},[h,t.openSettingsDone,t.openSettingsFailed,t.refreshDone,t.desktopNotify.testShown]),(0,x.useEffect)(()=>{c()&&R&&z()},[R,z]),!c()||!R)return(0,C.jsx)(w,{});let V=async e=>{try{let{behavior:t}=await R.setBehavior(e);l({type:`patch`,patch:{behavior:t}})}catch(e){l({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}},H=async e=>{if(!e){await V({notifyEnabled:!1});return}l({type:`patch`,patch:{permBusy:!0,permFeedback:null}});try{let e=await S(t.desktopNotify.testTitle,t.desktopNotify.testBody);if(e===`unsupported`){l({type:`patch`,patch:{permFeedback:t.notificationsFeedback.unsupported}});return}if(e===`denied`){l({type:`patch`,patch:{permFeedback:t.desktopNotify.denied}});return}if(e==="default"){l({type:`patch`,patch:{permFeedback:t.notificationsFeedback.default}});return}await V({notifyEnabled:!0}),l({type:`patch`,patch:{perms:await R.getPermissions()}}),l({type:`patch`,patch:{permFeedback:t.desktopNotify.testShown}})}catch(e){l({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{l({type:`patch`,patch:{permBusy:!1}})}},U=async e=>{l({type:`patch`,patch:{permFeedback:null}}),l({type:`patch`,patch:{loadError:null}});try{(await R.openPrivacy(e)).ok?l({type:`patch`,patch:{permFeedback:t.openSettingsDone}}):l({type:`patch`,patch:{permFeedback:t.openSettingsFailed}})}catch(e){l({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}},W=async()=>{l({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),l({type:`patch`,patch:{loadError:null}});try{let e=await R.requestMicrophone(),n=e.outcome===`opened-settings`||e.status===`denied`?!1:await T();l({type:`patch`,patch:{perms:await R.getPermissions()}}),l({type:`patch`,patch:{permFeedback:E(e,n,t.permFeedback)}})}catch(e){l({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{l({type:`patch`,patch:{permBusy:!1}})}},G=async()=>{if(R.requestAccessibility){l({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),l({type:`patch`,patch:{loadError:null}});try{let e=await R.requestAccessibility();l({type:`patch`,patch:{perms:await R.getPermissions()}}),l({type:`patch`,patch:{permFeedback:D(e,t.accessibilityFeedback)}})}catch(e){l({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{l({type:`patch`,patch:{permBusy:!1}})}}},K=async()=>{if(R.requestNotifications){l({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),l({type:`patch`,patch:{loadError:null}});try{let e=await R.requestNotifications();l({type:`patch`,patch:{perms:await R.getPermissions()}}),l({type:`patch`,patch:{permFeedback:O(e,t.notificationsFeedback)}})}catch(e){l({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{l({type:`patch`,patch:{permBusy:!1}})}}},q=async()=>{if(R.requestScreen){l({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),l({type:`patch`,patch:{loadError:null}});try{let e=await R.requestScreen();l({type:`patch`,patch:{perms:await R.getPermissions()}}),l({type:`patch`,patch:{permFeedback:k(e,t.screenFeedback)}})}catch(e){l({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{l({type:`patch`,patch:{permBusy:!1}})}}},J=d?d.platform===`win32`?t.permissionsHintWin:d.platform===`linux`?t.permissionsHintLinux:d.platform===`darwin`?t.permissionsHintDarwin:t.permissionsHint:t.permissionsHint;return(0,C.jsxs)(v,{gap:`gap-6`,children:[(0,C.jsx)(_,{title:t.title}),m?(0,C.jsx)(`p`,{className:`text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:m}):null,h?(0,C.jsx)(`p`,{className:i(`text-sm`,h===t.refreshDone||h===t.openSettingsDone||h===t.permFeedback.granted||h===t.permFeedback.alreadyGranted||h===t.accessibilityFeedback.granted||h===t.accessibilityFeedback.alreadyGranted||h===t.notificationsFeedback.granted||h===t.notificationsFeedback.alreadyGranted||h===t.screenFeedback.granted||h===t.screenFeedback.alreadyGranted||h===t.desktopNotify.testShown?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`),role:`status`,"aria-live":`polite`,children:h}):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)(u,{className:`size-4 text-accent`,strokeWidth:1.75}),t.behaviorGroup]}),(0,C.jsxs)(`div`,{className:`space-y-2`,children:[(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:t.toggles.openAtLogin}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.toggles.openAtLoginDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!d,checked:!!d?.openAtLogin,onChange:e=>{V({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:t.toggles.keepAwake}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.toggles.keepAwakeDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!d,checked:!!d?.keepAwakePreferred,onChange:e=>{V({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:t.toggles.notifyDesktop}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.toggles.notifyDesktopDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!d||A,checked:!!d?.notifyEnabled,onChange:e=>{H(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:t.toggles.notifySound}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.toggles.notifySoundDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!d,checked:!!d?.notifySoundEnabled,onChange:e=>{V({notifySoundEnabled:e.target.checked})}})]})]})]}),d&&f?(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:t.permissionsTitle}),(0,C.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:J}),d.platform===`darwin`&&!d.packaged?(0,C.jsx)(`p`,{className:`mt-1 text-xs text-amber-600 dark:text-amber-400`,children:t.permissionsHintDevDarwin}):null]}),(0,C.jsxs)(`button`,{type:`button`,disabled:N||A,"aria-busy":N,className:i(`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`,a.press),onClick:()=>void B(),children:[(0,C.jsx)(g,{className:i(`size-3.5`,N&&`animate-spin`),strokeWidth:1.75,"aria-hidden":!0}),N?t.refreshing:t.refresh]})]}),(0,C.jsx)(`ul`,{className:`space-y-3`,children:P(d.platform).map(({key:n,pane:o})=>{let s=F(e,f[n]),c=t.perm[n],l=f[n]===`unknown`?I(e,n,d.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 ${s.className}`,children:s.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:[n===`notifications`&&j(n,f[n],d.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:A,className:i(`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`,a.press),onClick:()=>void K(),children:t.requestAccess}):null,n===`microphone`&&j(n,f[n],d.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:A,className:i(`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`,a.press),onClick:()=>void W(),children:t.requestAccess}):null,n===`accessibility`&&j(n,f[n],d.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:A,className:i(`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`,a.press),onClick:()=>void G(),children:t.requestAccess}):null,n===`screen`&&j(n,f[n],d.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:A,className:i(`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`,a.press),onClick:()=>void q(),children:t.requestAccess}):null,M(n,f[n],d.platform)?(0,C.jsxs)(`button`,{type:`button`,className:i(`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`,a.press),onClick:()=>void U(o),children:[t.openSettings,(0,C.jsx)(r,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})]}):null]})]},n):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"./cn-JdwAhgNB.js";import{n as a}from"./interaction-BmQogeqz.js";import{t as o}from"./messages-CeydamsI.js";import{n as s}from"./locale-store-DqJz-cOR.js";import{t as c}from"./electron-env-DH5wF8X8.js";import{Gn as l,Is as u,Kl as d,Kn as f,Ua as p,Wn as m,qn as h,qs as g}from"./index-Csccu8sa.js";import{n as _,r as v}from"./settings-page-layout-BRQNel6r.js";import{r as y,t as b}from"./settings-form-section-CrsKGYiG.js";var x=e(t(),1);async function S(e,t){let n=window.electronAPI?.system;if(!c()||!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=o(s(e=>e.language)).systemSettings.browserNotify,[t,n]=(0,x.useState)(f),[r,i]=(0,x.useState)(null),[a,c]=(0,x.useState)(!1),u=async t=>{if(!t){n(h({enabled:!1})),i(null);return}c(!0);try{let t=await m();if(t!==`granted`){i(t===`unsupported`?e.unsupported:e.denied);return}n(h({enabled:!0})),i(await l(e.testTitle,e.testBody)?e.testShown:e.failed)}finally{c(!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)(d,{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]].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:a||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=o(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=o(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=s(e=>e.language),t=o(e).systemSettings,[n,l]=(0,x.useReducer)(p,L),{behavior:d,perms:f,loadError:m,permFeedback:h,permBusy:A,refreshing:N}=n,R=typeof window<`u`?window.electronAPI?.system:void 0,z=(0,x.useCallback)(async e=>{if(R){l({type:`patch`,patch:{loadError:null}});try{l({type:`patch`,patch:{behavior:await R.getBehavior(),perms:await R.getPermissions({probe:e?.showRefreshFeedback}),...e?.showRefreshFeedback?{permFeedback:t.refreshDone}:{}}})}catch(t){l({type:`patch`,patch:{loadError:t instanceof Error?t.message:String(t),...e?.showRefreshFeedback?{permFeedback:null}:{}}})}}},[R,t.refreshDone]),B=(0,x.useCallback)(async()=>{if(!(N||A)){l({type:`patch`,patch:{refreshing:!0}});try{await z({showRefreshFeedback:!0})}finally{l({type:`patch`,patch:{refreshing:!1}})}}},[z,A,N]);if((0,x.useEffect)(()=>{let e=new Set([t.refreshDone,t.openSettingsDone,t.openSettingsFailed,t.desktopNotify.testShown]);if(!h||!e.has(h))return;let n=window.setTimeout(()=>{l({type:`patch`,patch:{permFeedback:null}})},3e3);return()=>window.clearTimeout(n)},[h,t.openSettingsDone,t.openSettingsFailed,t.refreshDone,t.desktopNotify.testShown]),(0,x.useEffect)(()=>{c()&&R&&z()},[R,z]),!c()||!R)return(0,C.jsx)(w,{});let V=async e=>{try{let{behavior:t}=await R.setBehavior(e);l({type:`patch`,patch:{behavior:t}})}catch(e){l({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}},H=async e=>{if(!e){await V({notifyEnabled:!1});return}l({type:`patch`,patch:{permBusy:!0,permFeedback:null}});try{let e=await S(t.desktopNotify.testTitle,t.desktopNotify.testBody);if(e===`unsupported`){l({type:`patch`,patch:{permFeedback:t.notificationsFeedback.unsupported}});return}if(e===`denied`){l({type:`patch`,patch:{permFeedback:t.desktopNotify.denied}});return}if(e==="default"){l({type:`patch`,patch:{permFeedback:t.notificationsFeedback.default}});return}await V({notifyEnabled:!0}),l({type:`patch`,patch:{perms:await R.getPermissions()}}),l({type:`patch`,patch:{permFeedback:t.desktopNotify.testShown}})}catch(e){l({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{l({type:`patch`,patch:{permBusy:!1}})}},U=async e=>{l({type:`patch`,patch:{permFeedback:null}}),l({type:`patch`,patch:{loadError:null}});try{(await R.openPrivacy(e)).ok?l({type:`patch`,patch:{permFeedback:t.openSettingsDone}}):l({type:`patch`,patch:{permFeedback:t.openSettingsFailed}})}catch(e){l({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}},W=async()=>{l({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),l({type:`patch`,patch:{loadError:null}});try{let e=await R.requestMicrophone(),n=e.outcome===`opened-settings`||e.status===`denied`?!1:await T();l({type:`patch`,patch:{perms:await R.getPermissions()}}),l({type:`patch`,patch:{permFeedback:E(e,n,t.permFeedback)}})}catch(e){l({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{l({type:`patch`,patch:{permBusy:!1}})}},G=async()=>{if(R.requestAccessibility){l({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),l({type:`patch`,patch:{loadError:null}});try{let e=await R.requestAccessibility();l({type:`patch`,patch:{perms:await R.getPermissions()}}),l({type:`patch`,patch:{permFeedback:D(e,t.accessibilityFeedback)}})}catch(e){l({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{l({type:`patch`,patch:{permBusy:!1}})}}},K=async()=>{if(R.requestNotifications){l({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),l({type:`patch`,patch:{loadError:null}});try{let e=await R.requestNotifications();l({type:`patch`,patch:{perms:await R.getPermissions()}}),l({type:`patch`,patch:{permFeedback:O(e,t.notificationsFeedback)}})}catch(e){l({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{l({type:`patch`,patch:{permBusy:!1}})}}},q=async()=>{if(R.requestScreen){l({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),l({type:`patch`,patch:{loadError:null}});try{let e=await R.requestScreen();l({type:`patch`,patch:{perms:await R.getPermissions()}}),l({type:`patch`,patch:{permFeedback:k(e,t.screenFeedback)}})}catch(e){l({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{l({type:`patch`,patch:{permBusy:!1}})}}},J=d?d.platform===`win32`?t.permissionsHintWin:d.platform===`linux`?t.permissionsHintLinux:d.platform===`darwin`?t.permissionsHintDarwin:t.permissionsHint:t.permissionsHint;return(0,C.jsxs)(v,{gap:`gap-6`,children:[(0,C.jsx)(_,{title:t.title}),m?(0,C.jsx)(`p`,{className:`text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:m}):null,h?(0,C.jsx)(`p`,{className:i(`text-sm`,h===t.refreshDone||h===t.openSettingsDone||h===t.permFeedback.granted||h===t.permFeedback.alreadyGranted||h===t.accessibilityFeedback.granted||h===t.accessibilityFeedback.alreadyGranted||h===t.notificationsFeedback.granted||h===t.notificationsFeedback.alreadyGranted||h===t.screenFeedback.granted||h===t.screenFeedback.alreadyGranted||h===t.desktopNotify.testShown?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`),role:`status`,"aria-live":`polite`,children:h}):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)(u,{className:`size-4 text-accent`,strokeWidth:1.75}),t.behaviorGroup]}),(0,C.jsxs)(`div`,{className:`space-y-2`,children:[(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:t.toggles.openAtLogin}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.toggles.openAtLoginDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!d,checked:!!d?.openAtLogin,onChange:e=>{V({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:t.toggles.keepAwake}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.toggles.keepAwakeDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!d,checked:!!d?.keepAwakePreferred,onChange:e=>{V({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:t.toggles.notifyDesktop}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.toggles.notifyDesktopDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!d||A,checked:!!d?.notifyEnabled,onChange:e=>{H(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:t.toggles.notifySound}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.toggles.notifySoundDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!d,checked:!!d?.notifySoundEnabled,onChange:e=>{V({notifySoundEnabled:e.target.checked})}})]})]})]}),d&&f?(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:t.permissionsTitle}),(0,C.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:J}),d.platform===`darwin`&&!d.packaged?(0,C.jsx)(`p`,{className:`mt-1 text-xs text-amber-600 dark:text-amber-400`,children:t.permissionsHintDevDarwin}):null]}),(0,C.jsxs)(`button`,{type:`button`,disabled:N||A,"aria-busy":N,className:i(`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`,a.press),onClick:()=>void B(),children:[(0,C.jsx)(g,{className:i(`size-3.5`,N&&`animate-spin`),strokeWidth:1.75,"aria-hidden":!0}),N?t.refreshing:t.refresh]})]}),(0,C.jsx)(`ul`,{className:`space-y-3`,children:P(d.platform).map(({key:n,pane:o})=>{let s=F(e,f[n]),c=t.perm[n],l=f[n]===`unknown`?I(e,n,d.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 ${s.className}`,children:s.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:[n===`notifications`&&j(n,f[n],d.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:A,className:i(`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`,a.press),onClick:()=>void K(),children:t.requestAccess}):null,n===`microphone`&&j(n,f[n],d.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:A,className:i(`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`,a.press),onClick:()=>void W(),children:t.requestAccess}):null,n===`accessibility`&&j(n,f[n],d.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:A,className:i(`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`,a.press),onClick:()=>void G(),children:t.requestAccess}):null,n===`screen`&&j(n,f[n],d.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:A,className:i(`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`,a.press),onClick:()=>void q(),children:t.requestAccess}):null,M(n,f[n],d.platform)?(0,C.jsxs)(`button`,{type:`button`,className:i(`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`,a.press),onClick:()=>void U(o),children:[t.openSettings,(0,C.jsx)(r,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})]}):null]})]},n):null})})]}):null]})}export{R as SystemSettingsPanel};
@@ -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{d as i,l as a,p as o,t as s}from"./chunk-KS7C4IRE-BaASWQor.js";import{n as c,r as l}from"./popover-select-CccGri5Y.js";import{t as u}from"./circle-check-C23XjkUj.js";import{t as d}from"./ellipsis-0k4rZLoy.js";import{t as f}from"./external-link-DjqjBmc3.js";import{d as p,p as m,t as h}from"./markdown-view-CUsob4Pz.js";import{t as g}from"./x-B_N4OPjy.js";import{t as _}from"./cn-JdwAhgNB.js";import{t as v}from"./button-CSEbl4zT.js";import{l as ee,n as te}from"./locale-store-CPylQjH9.js";import{i as y,n as ne,o as re,r as ie,s as ae,t as oe}from"./dist-BPoKqzeH.js";import{$ as b,$c as se,B as ce,Bn as le,Br as x,Fi as ue,Gr as S,Hn as C,Hr as de,I as fe,Ii as w,J as pe,Kr as me,L as he,P as ge,Pi as _e,Q as ve,Ql as T,Sl as ye,Ur as E,Vn as D,Vr as be,W as xe,Wr as O,X as k,Xa as A,Ya as j,_c as M,at as N,do as P,el as F,ka as Se,n as Ce,sc as we,tc as Te,wi as Ee,xl as De}from"./index-B3zYJBhK.js";import{t as Oe}from"./date-picker-CxTl6Wlz.js";import{t as ke}from"./dependency-picker-DSl0mOPa.js";var I=e(t(),1),L=n();function Ae(e,t,n,r){return!!(e&&t!==e.version&&n!==e.value&&r!==n)}function je(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}}var R=r();function z(e,t){return(t===`zh`?{backlog:`待规划`,ready:`就绪`,active:`进行中`,review:`待验收`,closed:`已完成`}:{backlog:`Backlog`,ready:`Ready`,active:`Active`,review:`Review`,closed:`Completed`})[e]}function Me(){let e=(0,L.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,R.jsxs)(`div`,{className:`space-y-4`,"aria-busy":!0,children:[(0,R.jsx)(A,{className:`h-32 rounded-2xl`}),(0,R.jsx)(A,{className:`h-52 rounded-2xl`}),(0,R.jsx)(A,{className:`h-40 rounded-2xl`})]}),e[0]=t):t=e[0],t}function Ne(e){if(e===void 0)return``;let t=new Date(e);return new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString().slice(0,10)}function Pe(e){return e?new Date(`${e}T23:59:59.999`).getTime():null}var B=[`backlog`,`ready`,`active`,`review`,`closed`],Fe=[`low`,`normal`,`high`,`critical`],Ie=(0,I.memo)(function(e){let t=(0,L.c)(20),{value:n,disabled:r,canMove:i,canApprove:a,canReopen:o,language:s,label:u,onChange:d}=e,f;t[0]!==a||t[1]!==i||t[2]!==o||t[3]!==n?(f=e=>e!==n&&(e===`closed`?!a:n===`closed`?!o:!i),t[0]=a,t[1]=i,t[2]=o,t[3]=n,t[4]=f):f=t[4];let p=f,m;t[5]===u?m=t[6]:(m=(0,R.jsx)(`span`,{children:u}),t[5]=u,t[6]=m);let h;t[7]===d?h=t[8]:(h=e=>d(e.target.value),t[7]=d,t[8]=h);let g;t[9]!==s||t[10]!==p?(g=B.map(e=>(0,R.jsx)(l,{value:e,disabled:p(e),children:z(e,s)},e)),t[9]=s,t[10]=p,t[11]=g):g=t[11];let _;t[12]!==r||t[13]!==h||t[14]!==g||t[15]!==n?(_=(0,R.jsx)(c,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:h,children:g}),t[12]=r,t[13]=h,t[14]=g,t[15]=n,t[16]=_):_=t[16];let v;return t[17]!==m||t[18]!==_?(v=(0,R.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[m,_]}),t[17]=m,t[18]=_,t[19]=v):v=t[19],v}),Le=(0,I.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,R.jsx)(`span`,{children:i}),t[0]=i,t[1]=s);let u;t[2]===o?u=t[3]:(u=e=>o(e.target.value),t[2]=o,t[3]=u);let d;t[4]===a?d=t[5]:(d=Fe.map(e=>(0,R.jsx)(l,{value:e,children:a[e]},e)),t[4]=a,t[5]=d);let f;t[6]!==r||t[7]!==u||t[8]!==d||t[9]!==n?(f=(0,R.jsx)(c,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:u,children:d}),t[6]=r,t[7]=u,t[8]=d,t[9]=n,t[10]=f):f=t[10];let p;return t[11]!==s||t[12]!==f?(p=(0,R.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[s,f]}),t[11]=s,t[12]=f,t[13]=p):p=t[13],p}),Re=(0,I.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,R.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,R.jsx)(Oe,{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,R.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}),ze=(0,I.memo)(function(e){let t=(0,L.c)(17),{value:n,disabled:r,label:i,unassignedLabel:a,agents:o,onChange:s}=e,u;t[0]===i?u=t[1]:(u=(0,R.jsx)(`span`,{children:i}),t[0]=i,t[1]=u);let d;t[2]===s?d=t[3]:(d=e=>s(e.target.value),t[2]=s,t[3]=d);let f;t[4]===a?f=t[5]:(f=(0,R.jsx)(l,{value:``,disabled:!0,children:a}),t[4]=a,t[5]=f);let p;t[6]===o?p=t[7]:(p=o.map(nt),t[6]=o,t[7]=p);let m;t[8]!==r||t[9]!==d||t[10]!==f||t[11]!==p||t[12]!==n?(m=(0,R.jsxs)(c,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:d,children:[f,p]}),t[8]=r,t[9]=d,t[10]=f,t[11]=p,t[12]=n,t[13]=m):m=t[13];let h;return t[14]!==u||t[15]!==m?(h=(0,R.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[u,m]}),t[14]=u,t[15]=m,t[16]=h):h=t[16],h}),Be=(0,I.memo)(function(e){let t=(0,L.c)(8),{candidates:n,selected:r,disabled:i,labels:a,onChange:o}=e,s;t[0]===r?s=t[1]:(s=r.map(G),t[0]=r,t[1]=s);let c;return t[2]!==n||t[3]!==i||t[4]!==a||t[5]!==o||t[6]!==s?(c=(0,R.jsx)(ke,{borderless:!0,candidates:n,selectedIds:s,disabled:i,onChange:o,labels:a}),t[2]=n,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c):c=t[7],c},(e,t)=>e.disabled===t.disabled&&e.labels===t.labels&&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)),Ve=`xopc.taskDetail.chatPanelPercent`,He=42;function Ue(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?He:Math.min(r,Math.max(n,e))}function We(){try{let e=Number(window.localStorage.getItem(Ve));return Number.isFinite(e)&&e>=30&&e<=60?e:He}catch{return He}}function Ge(e){return e.task.phase===`closed`?e.task.resolution===`done`?`completed`:`ended`: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`:`paused`:e.operationalState}function V(e){let t=(0,L.c)(9),{items:n,empty:r,verificationByCriterion:i}=e;if(n.length===0){let e;return t[0]===r?e=t[1]:(e=(0,R.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:r}),t[0]=r,t[1]=e),e}let a;if(t[2]!==n||t[3]!==i){let e;t[5]===i?e=t[6]:(e=e=>{let t=i?.get(e)??`unverified`;return(0,R.jsxs)(`li`,{className:`flex gap-2 text-sm leading-6 text-fg`,children:[(0,R.jsx)(t===`passed`?u:t===`failed`?ye:De,{className:t===`passed`?`mt-1 size-4 shrink-0 text-success`:t===`failed`?`mt-1 size-4 shrink-0 text-danger`:`mt-1 size-4 shrink-0 text-fg-subtle`}),(0,R.jsx)(`span`,{children:e})]},e)},t[5]=i,t[6]=e),a=n.map(e),t[2]=n,t[3]=i,t[4]=a}else a=t[4];let o;return t[7]===a?o=t[8]:(o=(0,R.jsx)(`ul`,{className:`space-y-2`,children:a}),t[7]=a,t[8]=o),o}function Ke({taskId:e,presentation:t,backgroundPath:n,onDeleted:r}){let[i]=o(),c=a(),l=te(e=>e.language),g=ee(e=>e.token),y=(0,I.useMemo)(()=>b(l),[l]),ne=P(e=>e.setPageHeader),re=P(e=>e.clearPageHeader),ie=w(e=>e.open),ae=w(e=>e.sessionKeyOverride),oe=w(e=>e.openForSession),ue=me(e=>e.setOpen),{data:C,error:ye,mutate:A,lastChange:De,conversationLoading:Oe,conversationError:ke}=ge(e),[L,z]=(0,I.useState)(null),[B,Fe]=(0,I.useState)(()=>new Set),[Ke,qe]=(0,I.useState)([]),[H,Je]=(0,I.useState)(null),[Ye,Xe]=(0,I.useState)([]),[Ze,U]=(0,I.useState)(!1),[Qe,$e]=(0,I.useState)(``),[et,W]=(0,I.useState)(!1),[tt,nt]=(0,I.useState)(``),[G,rt]=(0,I.useState)(We),[it,at]=(0,I.useState)(!1),ot=(0,I.useRef)(null),st=(0,I.useRef)(!1),ct=(0,I.useRef)(!1),lt=(0,I.useRef)(``),ut=(0,I.useRef)(null),dt=(0,I.useRef)(null),ft=(0,I.useRef)(null),pt=(0,I.useRef)(C),[mt,K]=(0,I.useState)(null),[ht,gt]=(0,I.useState)(null),[_t,vt]=(0,I.useState)(!1),yt=(0,I.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]),bt=C?.dependencies.map(e=>`${e.id}:${e.title}`).join(`\0`)??``,xt=(0,I.useMemo)(()=>p(i.get(`returnTo`),`/`,[`/projects`,`/chat`,`/notes`,`/tasks`]),[i]);pt.current=C;let q=(0,I.useCallback)((e,t)=>{Fe(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]);(0,I.useEffect)(()=>{z(null),K(null),U(!1),W(!1),gt(null),vt(!1)},[e]),(0,I.useEffect)(()=>{let e=!0;return j().then(t=>{e&&Xe(t.items)}).catch(()=>void 0),()=>{e=!1}},[g]),(0,I.useEffect)(()=>{if(!De||De.source===`user`)return;gt(De);let e=window.setTimeout(()=>gt(null),3500);return()=>window.clearTimeout(e)},[De]),(0,I.useEffect)(()=>{let t=C?.task.projectId,n=C?.dependencies??[];if(!t){ft.current=null,Je(null),qe(n);return}ft.current!==t&&(ft.current=t,Je(null));let r=!0;return Se(t).then(t=>{if(!r)return;Je(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});qe([...i.values()])}).catch(()=>{r&&qe(n)}),()=>{r=!1}},[bt,C?.task.projectId,e]);let J=(0,I.useCallback)(async(t,n=`command`)=>{let r=pt.current;if(r){q(n,!0),z(null);try{await A(await he(e,t,r.task.version),{revalidate:!1})}catch{z(y.actionFailed)}finally{q(n,!1)}}},[y.actionFailed,A,q,e]),Y=(0,I.useCallback)(async(t,n)=>{let r=pt.current;if(!r)return!1;n&&q(n,!0),z(null);try{return await A(k(e,t,r.task.version),{optimisticData:je(r,t),populateCache:!0,revalidate:!1,rollbackOnError:!0}),!0}catch{return z(y.actionFailed),!1}finally{n&&q(n,!1)}},[y.actionFailed,A,q,e]),St=async()=>{if(!C)return;if(st.current){st.current=!1;return}let e=Qe.trim(),t=ut.current;if(Ae(t,C.task.version,C.task.title,e)){K(`title`);return}if(!e||e===C.task.title){$e(C.task.title),U(!1);return}await Y({title:e})&&(K(null),U(!1))},Ct=async()=>{if(!C)return;if(ct.current){ct.current=!1;return}let e=tt.trim(),t=dt.current;if(Ae(t,C.task.version,C.task.body??``,e)){K(`description`);return}if(tt===lt.current||e===(C.task.body??``).trim()){W(!1);return}await Y({body:e||null})&&(K(null),W(!1))},wt=(0,I.useCallback)(async e=>{let t=pt.current;if(!(!t||e===t.task.phase)){if(t.task.phase===`closed`){await J({type:`reopen`,phase:e===`closed`?`ready`:e},`phase`);return}if(e===`closed`){await J({type:`close`,resolution:`done`},`phase`);return}await J({type:`move`,phase:e},`phase`)}},[J]),Tt=(0,I.useCallback)(e=>{Y({priority:e},`priority`)},[Y]),Et=(0,I.useCallback)(e=>{Y({dueAt:Pe(e)},`dueAt`)},[Y]),Dt=(0,I.useCallback)(e=>{rt(e);try{window.localStorage.setItem(Ve,String(e))}catch{}},[]),Ot=(0,I.useCallback)(e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`&&e.key!==`Home`)return;e.preventDefault();let t=ot.current?.clientWidth??0;Dt(Ue(e.key===`Home`?He:G+(e.key===`ArrowLeft`?2:-2),t))},[G,Dt]),kt=(0,I.useCallback)(e=>{if(!window.matchMedia(`(min-width: 1024px)`).matches)return;let t=ot.current;if(!t)return;e.preventDefault();let n=e.currentTarget,r=e.pointerId;n.setPointerCapture(r),at(!0);let i=G,a=0,o=()=>{a=0,t.style.setProperty(`--task-chat-panel-width`,`${i}%`)},s=e=>{let n=t.getBoundingClientRect();i=Ue((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{}at(!1),Dt(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)},[G,Dt]),At=(0,I.useCallback)(async t=>{let n=pt.current;if(n){q(`dependencies`,!0),z(null);try{await A(await ve(e,t,n.task.version),{revalidate:!1})}catch{z(y.dependencyUpdateFailed)}finally{q(`dependencies`,!1)}}},[y.dependencyUpdateFailed,A,q,e]),jt=(0,I.useCallback)(async t=>{let n=pt.current;if(!(!n||!t||t===n.conversation.currentExecutorAgentId)){q(`delegateAgentId`,!0),z(null);try{await A(await xe(e,t,n.task.version),{revalidate:!1})}catch{z(y.actionFailed)}finally{q(`delegateAgentId`,!1)}}},[y.actionFailed,A,q,e]),Mt=(0,I.useCallback)(async()=>{q(`delete`,!0),z(null);try{await ce(e),r?r():c(xt,{replace:!0})}catch(e){z(e instanceof Error?e.message:y.actionFailed)}finally{q(`delete`,!1)}},[y.actionFailed,c,r,xt,q,e]);if((0,I.useLayoutEffect)(()=>{if(t!==`modal`)return ne({startExtra:(0,R.jsx)(s,{to:xt,className:`flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":y.backToWork,children:(0,R.jsx)(T,{className:`size-4`})}),main:C?(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`p`,{className:`truncate text-sm font-semibold text-fg`,children:H?`${H} / ${y.taskLabel}`:y.taskLabel}),(0,R.jsx)(`p`,{className:`text-xs text-fg-muted`,children:y.detailStatuses[Ge(C)]})]}):null,end:null}),re},[re,y.backToWork,y.detailStatuses,y.taskLabel,C,t,H,xt,ne]),ye&&!C)return(0,R.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(!C)return(0,R.jsx)(`div`,{className:t===`modal`?`p-5`:`mx-auto max-w-4xl p-4 sm:p-6`,children:(0,R.jsx)(Me,{})});let Nt=C.waits[0],Pt=Nt?.kind===`paused`?Nt:void 0,X=C.receipts[0],Ft=y.detailStatuses[Ge(C)],It=y.detailStatusDescriptions[Ge(C)],Lt=C.task.body?.trim()||C.task.contract?.objective.trim(),Rt=new Map(X?.verification.checks.map(e=>[e.criterion,e.status])),zt=C.allowedCommands.includes(`mark_ready`),Bt=C.allowedCommands.includes(`start`),Vt=C.allowedCommands.includes(`add_wait`),Ht=C.task.phase===`review`&&C.allowedCommands.includes(`close`),Ut=C.allowedCommands.includes(`reopen`),Z=C.conversation.activeSessionKey,Wt=C.conversation.currentExecutorAgentId??C.task.delegateAgentId??C.task.ownerId,Gt=Ye.find(e=>e.id===Wt),Kt=!!(Z&&ie&&ae===Z),qt=C.attention.some(e=>e.kind===`input_required`||e.kind===`approval_required`),Jt=C.task.contract?.acceptanceCriteria??[],Yt=Jt.filter(e=>Rt.get(e)===`passed`).length,Xt=C.task.contract?.expectedOutputs??[],Zt=C.task.contract?.constraints??[],Qt=C.task.contract?.approvalRequired??[],$t=C.task.contract?.assumptions??[],en=C.task.contract?.risks??[],Q=(...e)=>!!ht?.changedFields.some(t=>e.includes(t)),tn=e=>t===`modal`&&n?D(n,e):m(`/tasks/${e}`,xt),nn=C.allowedCommands.includes(`move`),$=B.has(`command`),rn=B.has(`delete`),an=C.runs.find(e=>[`queued`,`running`,`waiting`,`verifying`].includes(e.status)),on=an!==void 0,sn=(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[zt?(0,R.jsxs)(v,{variant:`primary`,disabled:$,onClick:()=>void J({type:`mark_ready`}),children:[(0,R.jsx)(Te,{className:`size-4`}),y.scheduleTask]}):null,Pt?(0,R.jsxs)(v,{variant:`primary`,disabled:$,onClick:()=>void J({type:`resolve_wait`,waitId:Pt.id}),children:[(0,R.jsx)(Te,{className:`size-4`}),y.resumeTask]}):null,!Nt&&Bt&&Wt?(0,R.jsxs)(v,{variant:`primary`,disabled:$,onClick:()=>void J({type:`start`,executor:{kind:`agent`,agentId:Wt}}),children:[(0,R.jsx)(Te,{className:`size-4`}),y.runTask]}):null,Ht?(0,R.jsxs)(v,{variant:`primary`,disabled:$,onClick:()=>void J({type:`close`,resolution:`done`}),children:[(0,R.jsx)(u,{className:`size-4`}),y.approveTask]}):null,Ut?(0,R.jsxs)(v,{variant:`primary`,disabled:$,onClick:()=>void J({type:`reopen`,phase:`ready`}),children:[(0,R.jsx)(Te,{className:`size-4`}),y.reopenTask]}):null,!Nt&&Vt?(0,R.jsxs)(v,{variant:`secondary`,className:`border-0 bg-surface-hover shadow-none`,disabled:$,onClick:()=>void J({type:`add_wait`,wait:{kind:`paused`,reason:`Paused by user`,condition:{}}}),children:[(0,R.jsx)(we,{className:`size-4`}),y.pauseTask]}):null,(0,R.jsxs)(E,{children:[(0,R.jsx)(S,{asChild:!0,children:(0,R.jsx)(v,{type:`button`,variant:`ghost`,className:`size-9 p-0`,disabled:$||rn,"aria-label":y.moreActions,children:(0,R.jsx)(d,{className:`size-4`,"aria-hidden":!0})})}),(0,R.jsx)(de,{children:(0,R.jsxs)(x,{align:`end`,sideOffset:6,className:`z-[100] min-w-44 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:[an?(0,R.jsx)(be,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>{q(`command`,!0),z(null),A(fe(e,an.id,an.version),{revalidate:!1}).catch(()=>z(y.actionFailed)).finally(()=>q(`command`,!1))},children:y.cancelActiveRun}):null,an?(0,R.jsx)(O,{className:`my-1 h-px bg-edge`}):null,C.task.phase===`closed`?null:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(be,{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 J({type:`close`,resolution:`cancelled`}),children:y.cancelTask}),(0,R.jsx)(O,{className:`my-1 h-px bg-edge`})]}),(0,R.jsx)(be,{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(on){z(y.deleteActiveTaskBlocked);return}vt(!0)},children:y.deleteTask})]})})]})]});return(0,R.jsxs)(`div`,{ref:ot,className:`${t===`modal`?`flex h-full min-h-0 flex-col lg:flex-row`:`flex min-h-[calc(100dvh-8rem)] flex-col overflow-hidden lg:flex-row`} ${it?`lg:cursor-col-resize lg:select-none`:``}`,style:{"--task-chat-panel-width":`${G}%`},children:[(0,R.jsxs)(`section`,{className:`task-detail-scroll min-w-0 flex-1 overflow-y-auto overscroll-contain p-5 sm:p-6`,children:[(0,R.jsxs)(`header`,{className:_(`px-4 pb-5`,Q(`title`)&&`task-detail-live-update`),children:[(0,R.jsx)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[H?(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,R.jsx)(F,{className:`size-3.5`,"aria-hidden":!0}),H]}):null,(0,R.jsx)(`span`,{children:`/`}),(0,R.jsx)(`span`,{children:y.taskLabel}),ht?(0,R.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,role:`status`,children:ht.source===`agent`?l===`zh`?`Agent 刚刚更新`:`Updated by Agent`:l===`zh`?`执行结果已同步`:`Execution result synced`}):null]}),Ze?(0,R.jsx)(`input`,{autoFocus:!0,"data-task-inline-editor":!0,value:Qe,onChange:e=>$e(e.target.value),onBlur:()=>void St(),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),st.current=!0,$e(C.task.title),U(!1),queueMicrotask(()=>{st.current=!1}))},className:`mt-3 w-full max-w-3xl rounded-lg bg-surface-hover px-3 py-2 text-2xl font-semibold leading-8 text-fg outline-none ring-2 ring-accent/30 focus:ring-accent/60`}):(0,R.jsx)(`button`,{type:`button`,className:`mt-3 block max-w-3xl rounded-lg text-left outline-none hover:bg-surface-hover focus-visible:bg-surface-hover`,onClick:()=>{ut.current={value:C.task.title,version:C.task.version},K(null),$e(C.task.title),U(!0)},children:(0,R.jsx)(`h1`,{className:`text-2xl font-semibold leading-8 text-fg`,children:C.task.title})}),mt===`title`?(0,R.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,R.jsx)(`span`,{children:l===`zh`?`Agent 在你编辑期间更新了标题。`:`The Agent updated the title while you were editing.`}),(0,R.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:()=>{$e(C.task.title),K(null),U(!1)},children:l===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,R.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,onClick:()=>void Y({title:Qe.trim()}).then(e=>{e&&(K(null),U(!1))}),children:l===`zh`?`保留我的修改`:`Keep my changes`})]}):null]})}),L?(0,R.jsx)(`p`,{className:`mt-3 text-sm text-danger`,children:L}):null]}),(0,R.jsxs)(`div`,{className:`mt-5 flex flex-col gap-5`,children:[(0,R.jsxs)(`main`,{className:`order-2 min-w-0 space-y-5`,children:[(0,R.jsxs)(`section`,{className:_(`rounded-xl bg-surface-panel p-4`,Q(`body`)&&`task-detail-live-update`),children:[(0,R.jsx)(`h2`,{className:`font-medium text-fg`,children:y.taskDescription}),et?(0,R.jsx)(`textarea`,{autoFocus:!0,"data-task-inline-editor":!0,rows:6,value:tt,onChange:e=>nt(e.target.value),onBlur:()=>void Ct(),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),ct.current=!0,nt(C.task.body??C.task.contract?.objective??``),W(!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,R.jsx)(`button`,{type:`button`,className:`-mx-1 mt-2 block w-[calc(100%+0.5rem)] rounded-lg px-1 py-1 text-left outline-none hover:bg-surface-hover focus-visible:bg-surface-hover`,onClick:()=>{let e=C.task.body??C.task.contract?.objective??``;lt.current=e,dt.current={value:C.task.body??``,version:C.task.version},K(null),nt(e),W(!0)},children:(0,R.jsx)(`span`,{className:`whitespace-pre-wrap text-sm leading-6 text-fg-muted`,children:Lt&&Lt!==C.task.title?Lt:y.noTaskDescription})}),mt===`description`?(0,R.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,R.jsx)(`span`,{children:l===`zh`?`Agent 在你编辑期间更新了描述。`:`The Agent updated the description while you were editing.`}),(0,R.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:()=>{nt(C.task.body??``),K(null),W(!1)},children:l===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,R.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,onClick:()=>void Y({body:tt.trim()||null}).then(e=>{e&&(K(null),W(!1))}),children:l===`zh`?`保留我的修改`:`Keep my changes`})]}):null]}),C.attention.length>0?(0,R.jsxs)(`section`,{className:_(`rounded-xl bg-warning/10 p-4`,Q(`attention`)&&`task-detail-live-update`),children:[(0,R.jsx)(`h3`,{className:`font-medium text-fg`,children:qt?y.needsAttention:y.waitingStatus}),(0,R.jsx)(`ul`,{className:`mt-3 space-y-2 text-sm text-fg-muted`,children:C.attention.map((e,t)=>(0,R.jsx)(`li`,{children:e.summary},`${e.kind}-${t}`))})]}):null,(0,R.jsxs)(`section`,{className:_(`rounded-xl bg-surface-panel p-4`,Q(`contract`)&&`task-detail-live-update`),children:[(0,R.jsx)(`h2`,{className:`font-medium text-fg`,children:y.taskDefinition}),(0,R.jsxs)(`div`,{className:`mt-5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,R.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:y.successDefinition}),Jt.length>0?(0,R.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:y.criteriaProgress.replace(`{{verified}}`,String(Yt)).replace(`{{total}}`,String(Jt.length))}):null]}),(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(V,{items:Jt,empty:y.noDefinition,verificationByCriterion:Rt})})]}),Xt.length>0?(0,R.jsxs)(`div`,{className:`mt-5 rounded-lg bg-surface-hover p-4`,children:[(0,R.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:y.expectedOutputs}),(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(V,{items:Xt,empty:y.noDefinition})})]}):null,Zt.length>0?(0,R.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:y.constraints}),(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(V,{items:Zt,empty:y.noDefinition})})]}):null,Qt.length>0?(0,R.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:y.approvalRequired}),(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(V,{items:Qt,empty:y.noDefinition})})]}):null,$t.length>0?(0,R.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:y.contextAssumptions}),(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(V,{items:$t,empty:y.noDefinition})})]}):null,en.length>0?(0,R.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:y.contextRisks}),(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(V,{items:en,empty:y.noDefinition})})]}):null]}),X?(0,R.jsxs)(`section`,{className:_(`rounded-xl bg-surface-panel p-4`,Q(`runs`,`receipts`)&&`task-detail-live-update`),children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`h2`,{className:`font-medium text-fg`,children:y.latestResult}),(0,R.jsx)(h,{content:X.summary,compact:!0,className:`mt-2 text-sm leading-6 text-fg`})]}),(0,R.jsxs)(`span`,{className:`rounded-full bg-surface-hover px-2.5 py-1 text-xs text-fg-muted`,children:[y.receiptStatuses[X.status],` · `,y.verificationStatuses[X.verification.status]]})]}),X.remainingWork.length>0?(0,R.jsxs)(`div`,{className:`mt-4`,children:[(0,R.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:y.remainingWork}),(0,R.jsx)(`div`,{className:`mt-2`,children:(0,R.jsx)(V,{items:X.remainingWork,empty:y.noRemainingWork})})]}):null,X.nextAction?(0,R.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-hover p-3`,children:[(0,R.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:y.nextAction}),(0,R.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:X.nextAction})]}):null,(0,R.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(v,{className:`border-0 bg-surface-hover px-2 py-1 text-xs shadow-none`,variant:`secondary`,onClick:()=>void pe(X.runId,`helpful`),children:y.doneWell}),(0,R.jsx)(v,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>void pe(X.runId,`not_helpful`),children:y.needsFix}),X.evidence.filter(e=>e.uri).map(e=>(0,R.jsxs)(`a`,{className:`ml-auto inline-flex items-center gap-1 text-xs text-accent hover:underline`,href:e.uri,children:[(0,R.jsx)(f,{className:`size-3`}),e.title]},`${e.title}-${e.uri}`))]}),C.receipts.length>1?(0,R.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:y.executionHistory.replace(`{{count}}`,String(C.receipts.length-1))}),(0,R.jsx)(`div`,{className:`mt-3 space-y-3`,children:C.receipts.slice(1).map(e=>(0,R.jsx)(`article`,{className:`rounded-lg bg-surface-active p-3`,children:(0,R.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,R.jsx)(`p`,{className:`text-sm text-fg`,children:e.summary}),(0,R.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:y.receiptStatuses[e.status]})]})},e.runId))})]}):null]}):null,C.context.length>0?(0,R.jsxs)(`section`,{className:_(`rounded-xl bg-surface-panel p-4`,Q(`context`)&&`task-detail-live-update`),children:[(0,R.jsx)(`h2`,{className:`font-medium text-fg`,children:y.contextUsed}),(0,R.jsx)(`ul`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:C.context.map(e=>(0,R.jsxs)(`li`,{className:`min-w-0 rounded-lg bg-surface-hover p-2.5`,children:[(0,R.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,R.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,R.jsx)(`p`,{className:`mt-1 break-words text-sm text-fg`,children:e.title??e.targetId})]},e.id))})]}):null]}),(0,R.jsxs)(`aside`,{className:`order-1 min-w-0 space-y-4`,children:[(0,R.jsxs)(`section`,{className:_(`rounded-xl bg-surface-subtle p-4`,Q(`phase`,`resolution`,`priority`,`dueAt`,`delegateAgentId`)&&`task-detail-live-update`),children:[(0,R.jsx)(`h2`,{className:`font-medium text-fg`,children:y.taskProperties}),(0,R.jsxs)(`div`,{className:`mt-4 grid gap-4 sm:grid-cols-2`,children:[(0,R.jsx)(Ie,{value:C.task.phase,disabled:B.has(`phase`),canMove:nn,canApprove:Ht,canReopen:Ut,language:l,label:y.taskPhase,onChange:wt}),(0,R.jsx)(Le,{value:C.task.priority,disabled:B.has(`priority`),label:y.priority,labels:y.priorityLabels,onChange:Tt}),(0,R.jsx)(Re,{value:Ne(C.task.dueAt),disabled:B.has(`dueAt`),label:y.dueDate,onChange:Et}),(0,R.jsx)(ze,{value:C.conversation.currentExecutorAgentId??``,disabled:B.has(`delegateAgentId`),label:y.executorLabel,unassignedLabel:y.unassigned,agents:Ye,onChange:jt}),H?(0,R.jsxs)(`div`,{className:`grid gap-1 text-xs text-fg-muted`,children:[(0,R.jsx)(`span`,{children:y.projectLabel}),(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5 rounded-lg bg-surface-hover px-3 py-2 text-sm text-fg`,children:[(0,R.jsx)(F,{className:`size-3.5`}),H]})]}):null]}),(0,R.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-hover p-3 text-xs leading-5 text-fg-subtle`,children:[(0,R.jsx)(`p`,{children:Ft}),(0,R.jsx)(`p`,{children:It}),(0,R.jsx)(`p`,{className:`mt-2`,children:y.updatedAt.replace(`{{date}}`,Ee(C.task.updatedAt,l))})]})]}),(0,R.jsxs)(`section`,{className:_(`rounded-xl bg-surface-panel p-4`,Q(`dependencies`)&&`task-detail-live-update`),children:[(0,R.jsx)(`h2`,{className:`font-medium text-fg`,children:y.taskRelations}),(0,R.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:y.dependencies}),(0,R.jsx)(Be,{candidates:Ke,selected:C.dependencies,disabled:B.has(`dependencies`),labels:yt,onChange:At})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:y.dependents}),C.dependents.length>0?(0,R.jsx)(`div`,{className:`space-y-1.5`,children:C.dependents.map(e=>(0,R.jsx)(s,{to:tn(e.id),className:`block rounded-lg bg-surface-hover p-2.5 text-sm text-accent hover:underline`,children:e.title},e.id))}):(0,R.jsx)(`p`,{className:`text-sm text-fg-subtle`,children:y.noDependents})]})]})]})]})]})]}),(0,R.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":l===`zh`?`调整任务信息和 Agent 对话的宽度`:`Resize task details and Agent chat`,"aria-valuemin":30,"aria-valuemax":60,"aria-valuenow":Math.round(G),tabIndex:0,onPointerDown:kt,onKeyDown:Ot,onDoubleClick:()=>Dt(He),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 ${it?`bg-surface-hover`:``}`,children:(0,R.jsx)(`div`,{className:`my-3 w-px rounded-full bg-edge-strong/70 transition-colors group-hover:bg-accent group-focus-visible:bg-accent`})}),(0,R.jsxs)(`aside`,{className:`flex min-h-[34rem] min-w-0 flex-col bg-surface-panel lg:min-h-0 lg:w-[var(--task-chat-panel-width)] lg:shrink-0`,children:[(0,R.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3 bg-surface-subtle px-4 py-3.5`,children:[(0,R.jsx)(`div`,{className:`min-w-0`,children:(0,R.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[Wt?(0,R.jsx)(N,{agentId:Wt,avatar:Gt?.avatar,size:28,className:`shrink-0`}):null,(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:l===`zh`?`Agent 执行与对话`:`Agent execution and chat`}),(0,R.jsxs)(`p`,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:[Gt?.name??Wt??y.unassigned,` · `,Ft]})]})]})}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[sn,Z&&t!==`modal`?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(v,{type:`button`,variant:`ghost`,className:_(`h-8 shrink-0 px-2 text-xs`,Kt&&`bg-surface-hover text-fg`),"aria-label":l===`zh`?`项目文件`:`Project files`,"aria-pressed":Kt,onClick:()=>{ue(Z,!1),oe(Z)},children:[(0,R.jsx)(se,{className:`size-3.5`,"aria-hidden":!0}),l===`zh`?`文件`:`Files`]}),(0,R.jsx)(v,{asChild:!0,variant:`ghost`,className:`h-8 shrink-0 px-2 text-xs`,children:(0,R.jsxs)(s,{to:le(e),children:[(0,R.jsx)(f,{className:`size-3.5`}),l===`zh`?`全屏`:`Full screen`]})})]}):null]})]}),Z?(0,R.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,R.jsx)(Ce,{embedded:!0,sessionKey:Z,taskId:e})}):Oe?(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,R.jsxs)(`div`,{className:`max-w-xs`,children:[(0,R.jsx)(M,{className:`mx-auto size-8 animate-pulse text-fg-subtle`}),(0,R.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:l===`zh`?`正在创建任务会话`:`Creating task conversation`})]})}):ke?(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,R.jsxs)(`div`,{className:`max-w-xs`,children:[(0,R.jsx)(M,{className:`mx-auto size-8 text-danger`}),(0,R.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:l===`zh`?`任务会话创建失败`:`Could not create task conversation`}),(0,R.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:ke instanceof Error?ke.message:String(ke)})]})}):(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,R.jsxs)(`div`,{className:`max-w-xs`,children:[(0,R.jsx)(M,{className:`mx-auto size-8 text-fg-subtle`}),(0,R.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:l===`zh`?`等待任务会话`:`Waiting for a task conversation`}),(0,R.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:l===`zh`?`安排或开始任务后,Agent 的执行过程和持续对话会显示在这里。`:`Schedule or start the task to see the agent run and continue the conversation here.`})]})})]}),(0,R.jsx)(_e,{open:_t,title:y.deleteTaskTitle,description:y.deleteTaskDescription.replace(`{{title}}`,C.task.title),confirmLabel:y.confirmDeleteTask,cancelLabel:y.keepTask,destructive:!0,onConfirm:()=>{vt(!1),Mt()},onCancel:()=>vt(!1)})]})}function qe(){let e=(0,L.c)(2),{taskId:t}=i(),n=t===void 0?``:t,r;return e[0]===n?r=e[1]:(r=(0,R.jsx)(Ke,{taskId:n,presentation:`page`}),e[0]=n,e[1]=r),r}function H(e){let t=(0,L.c)(58),{taskId:n,backgroundPath:r,onClose:i}=e,a=te(tt),{data:o}=ge(n),c=o?.conversation.activeSessionKey??null,l=w(W),u=w(et),d=w($e),p=w(Qe),m=me(U),h=ue(Ze),v=ue(Xe),ee=l?u:0,b;t[0]!==i||t[1]!==v?(b=e=>{e||(v(null),i())},t[0]=i,t[1]=v,t[2]=b):b=t[2];let ce=a===`zh`?`关闭任务详情`:`Close task details`,x;t[3]!==i||t[4]!==v?(x=()=>{v(null),i()},t[3]=i,t[4]=v,t[5]=x):x=t[5];let S;t[6]!==ce||t[7]!==x?(S=(0,R.jsx)(`button`,{type:`button`,tabIndex:-1,"data-task-modal-backdrop":!0,className:`fixed inset-0 z-[80] bg-black/45 backdrop-blur-[1px]`,"aria-label":ce,onClick:x}),t[6]=ce,t[7]=x,t[8]=S):S=t[8];let de=l?`true`:`false`,fe=`${ee/2}px`,pe=`${ee}px`,he;t[9]!==fe||t[10]!==pe?(he={"--task-detail-workspace-offset":fe,"--task-detail-workspace-width":pe},t[9]=fe,t[10]=pe,t[11]=he):he=t[11];let _e=he,ve=a===`zh`?`任务详情`:`Task details`,T;t[12]===ve?T=t[13]:(T=(0,R.jsx)(ae,{className:`font-medium text-fg`,children:ve}),t[12]=ve,t[13]=T);let ye=a===`zh`?`查看并操作任务详情`:`View and manage task details`,E;t[14]===ye?E=t[15]:(E=(0,R.jsx)(y,{className:`sr-only`,children:ye}),t[14]=ye,t[15]=E);let D;t[16]!==c||t[17]!==a||t[18]!==p||t[19]!==m||t[20]!==n||t[21]!==l||t[22]!==d?(D=c?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,className:_(`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,l&&d===c&&`bg-surface-hover text-fg`),"aria-label":a===`zh`?`项目文件`:`Project files`,title:a===`zh`?`项目文件`:`Project files`,"aria-pressed":l&&d===c,onClick:()=>{m(c,!1),p(c)},children:(0,R.jsx)(se,{className:`size-4`,"aria-hidden":!0})}),(0,R.jsx)(s,{to:le(n),className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":a===`zh`?`全屏打开对话`:`Open chat full screen`,title:a===`zh`?`全屏打开对话`:`Open chat full screen`,children:(0,R.jsx)(f,{className:`size-4`,"aria-hidden":!0})})]}):null,t[16]=c,t[17]=a,t[18]=p,t[19]=m,t[20]=n,t[21]=l,t[22]=d,t[23]=D):D=t[23];let be=a===`zh`?`关闭任务详情`:`Close task details`,xe;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,R.jsx)(g,{className:`size-4`,"aria-hidden":!0}),t[24]=xe):xe=t[24];let O;t[25]===be?O=t[26]:(O=(0,R.jsx)(ne,{className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":be,children:xe}),t[25]=be,t[26]=O);let k;t[27]!==D||t[28]!==O?(k=(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[D,O]}),t[27]=D,t[28]=O,t[29]=k):k=t[29];let A;t[30]!==T||t[31]!==E||t[32]!==k?(A=(0,R.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-3 bg-surface-panel px-5 py-3.5`,children:[T,E,k]}),t[30]=T,t[31]=E,t[32]=k,t[33]=A):A=t[33];let j;t[34]!==i||t[35]!==v?(j=()=>{v(null),i()},t[34]=i,t[35]=v,t[36]=j):j=t[36];let M;t[37]!==r||t[38]!==j||t[39]!==n?(M=(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,R.jsx)(Ke,{taskId:n,presentation:`modal`,backgroundPath:r,onDeleted:j})}),t[37]=r,t[38]=j,t[39]=n,t[40]=M):M=t[40];let N;t[41]!==A||t[42]!==M||t[43]!==de||t[44]!==_e?(N=(0,R.jsxs)(ie,{className:`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 bg-surface-base shadow-float focus:outline-none`,"data-workspace-panel-open":de,style:_e,onEscapeKeyDown:Ye,onInteractOutside:Je,children:[A,M]}),t[41]=A,t[42]=M,t[43]=de,t[44]=_e,t[45]=N):N=t[45];let P;t[46]!==h||t[47]!==l||t[48]!==u||t[49]!==d?(P=h?(0,R.jsx)(`div`,{className:`fixed inset-y-0 left-0 z-[100] flex min-h-0 min-w-0 overflow-hidden bg-surface-panel transition-[right] duration-200 ease-out motion-reduce:transition-none`,style:{right:l?u:0},children:(0,R.jsx)(C,{allowOutsideChat:!0,sessionKey:d??void 0})}):null,t[46]=h,t[47]=l,t[48]=u,t[49]=d,t[50]=P):P=t[50];let F;t[51]!==N||t[52]!==P||t[53]!==S?(F=(0,R.jsxs)(re,{children:[S,N,P]}),t[51]=N,t[52]=P,t[53]=S,t[54]=F):F=t[54];let Se;return t[55]!==b||t[56]!==F?(Se=(0,R.jsx)(oe,{modal:!1,open:!0,onOpenChange:b,children:F}),t[55]=b,t[56]=F,t[57]=Se):Se=t[57],Se}function Je(e){let t=e.detail.originalEvent.target;t instanceof Element&&t.closest(`#app-workspace-panel, [data-task-modal-backdrop]`)&&e.preventDefault()}function Ye(e){let t=e.target;t instanceof HTMLElement&&t.closest(`[data-task-inline-editor]`)&&e.preventDefault()}function Xe(e){return e.setPath}function Ze(e){return e.path}function U(e){return e.setOpen}function Qe(e){return e.openForSession}function $e(e){return e.sessionKeyOverride}function et(e){return e.widthPx}function W(e){return e.open}function tt(e){return e.language}function nt(e){return(0,R.jsx)(l,{value:e.id,children:e.name||e.id},e.id)}function G(e){return e.id}export{H as TaskDetailModal,qe as TaskDetailPage};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,l as a,p as o,t as s}from"./chunk-KS7C4IRE-BaASWQor.js";import{n as c,r as l}from"./popover-select-CccGri5Y.js";import{t as u}from"./circle-check-C23XjkUj.js";import{t as d}from"./ellipsis-0k4rZLoy.js";import{t as f}from"./external-link-DjqjBmc3.js";import{d as p,p as m,t as h}from"./markdown-view-CTB9u15e.js";import{t as g}from"./x-B_N4OPjy.js";import{t as _}from"./cn-JdwAhgNB.js";import{t as v}from"./button-CSEbl4zT.js";import{l as ee,n as te}from"./locale-store-DqJz-cOR.js";import{i as y,n as ne,o as re,r as ie,s as ae,t as oe}from"./dist-BPoKqzeH.js";import{$ as b,$c as se,B as ce,Bn as le,Br as x,Fi as ue,Gr as S,Hn as C,Hr as de,I as fe,Ii as w,J as pe,Kr as me,L as he,P as ge,Pi as _e,Q as ve,Ql as T,Sl as ye,Ur as E,Vn as D,Vr as be,W as xe,Wr as O,X as k,Xa as A,Ya as j,_c as M,at as N,do as P,el as F,ka as Se,n as Ce,sc as we,tc as Te,wi as Ee,xl as De}from"./index-Csccu8sa.js";import{t as Oe}from"./date-picker-BPuRtwKt.js";import{t as ke}from"./dependency-picker-BNC_W7wI.js";var I=e(t(),1),L=n();function Ae(e,t,n,r){return!!(e&&t!==e.version&&n!==e.value&&r!==n)}function je(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}}var R=r();function z(e,t){return(t===`zh`?{backlog:`待规划`,ready:`就绪`,active:`进行中`,review:`待验收`,closed:`已完成`}:{backlog:`Backlog`,ready:`Ready`,active:`Active`,review:`Review`,closed:`Completed`})[e]}function Me(){let e=(0,L.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,R.jsxs)(`div`,{className:`space-y-4`,"aria-busy":!0,children:[(0,R.jsx)(A,{className:`h-32 rounded-2xl`}),(0,R.jsx)(A,{className:`h-52 rounded-2xl`}),(0,R.jsx)(A,{className:`h-40 rounded-2xl`})]}),e[0]=t):t=e[0],t}function Ne(e){if(e===void 0)return``;let t=new Date(e);return new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString().slice(0,10)}function Pe(e){return e?new Date(`${e}T23:59:59.999`).getTime():null}var B=[`backlog`,`ready`,`active`,`review`,`closed`],Fe=[`low`,`normal`,`high`,`critical`],Ie=(0,I.memo)(function(e){let t=(0,L.c)(20),{value:n,disabled:r,canMove:i,canApprove:a,canReopen:o,language:s,label:u,onChange:d}=e,f;t[0]!==a||t[1]!==i||t[2]!==o||t[3]!==n?(f=e=>e!==n&&(e===`closed`?!a:n===`closed`?!o:!i),t[0]=a,t[1]=i,t[2]=o,t[3]=n,t[4]=f):f=t[4];let p=f,m;t[5]===u?m=t[6]:(m=(0,R.jsx)(`span`,{children:u}),t[5]=u,t[6]=m);let h;t[7]===d?h=t[8]:(h=e=>d(e.target.value),t[7]=d,t[8]=h);let g;t[9]!==s||t[10]!==p?(g=B.map(e=>(0,R.jsx)(l,{value:e,disabled:p(e),children:z(e,s)},e)),t[9]=s,t[10]=p,t[11]=g):g=t[11];let _;t[12]!==r||t[13]!==h||t[14]!==g||t[15]!==n?(_=(0,R.jsx)(c,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:h,children:g}),t[12]=r,t[13]=h,t[14]=g,t[15]=n,t[16]=_):_=t[16];let v;return t[17]!==m||t[18]!==_?(v=(0,R.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[m,_]}),t[17]=m,t[18]=_,t[19]=v):v=t[19],v}),Le=(0,I.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,R.jsx)(`span`,{children:i}),t[0]=i,t[1]=s);let u;t[2]===o?u=t[3]:(u=e=>o(e.target.value),t[2]=o,t[3]=u);let d;t[4]===a?d=t[5]:(d=Fe.map(e=>(0,R.jsx)(l,{value:e,children:a[e]},e)),t[4]=a,t[5]=d);let f;t[6]!==r||t[7]!==u||t[8]!==d||t[9]!==n?(f=(0,R.jsx)(c,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:u,children:d}),t[6]=r,t[7]=u,t[8]=d,t[9]=n,t[10]=f):f=t[10];let p;return t[11]!==s||t[12]!==f?(p=(0,R.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[s,f]}),t[11]=s,t[12]=f,t[13]=p):p=t[13],p}),Re=(0,I.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,R.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,R.jsx)(Oe,{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,R.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}),ze=(0,I.memo)(function(e){let t=(0,L.c)(17),{value:n,disabled:r,label:i,unassignedLabel:a,agents:o,onChange:s}=e,u;t[0]===i?u=t[1]:(u=(0,R.jsx)(`span`,{children:i}),t[0]=i,t[1]=u);let d;t[2]===s?d=t[3]:(d=e=>s(e.target.value),t[2]=s,t[3]=d);let f;t[4]===a?f=t[5]:(f=(0,R.jsx)(l,{value:``,disabled:!0,children:a}),t[4]=a,t[5]=f);let p;t[6]===o?p=t[7]:(p=o.map(nt),t[6]=o,t[7]=p);let m;t[8]!==r||t[9]!==d||t[10]!==f||t[11]!==p||t[12]!==n?(m=(0,R.jsxs)(c,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:d,children:[f,p]}),t[8]=r,t[9]=d,t[10]=f,t[11]=p,t[12]=n,t[13]=m):m=t[13];let h;return t[14]!==u||t[15]!==m?(h=(0,R.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[u,m]}),t[14]=u,t[15]=m,t[16]=h):h=t[16],h}),Be=(0,I.memo)(function(e){let t=(0,L.c)(8),{candidates:n,selected:r,disabled:i,labels:a,onChange:o}=e,s;t[0]===r?s=t[1]:(s=r.map(G),t[0]=r,t[1]=s);let c;return t[2]!==n||t[3]!==i||t[4]!==a||t[5]!==o||t[6]!==s?(c=(0,R.jsx)(ke,{borderless:!0,candidates:n,selectedIds:s,disabled:i,onChange:o,labels:a}),t[2]=n,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c):c=t[7],c},(e,t)=>e.disabled===t.disabled&&e.labels===t.labels&&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)),Ve=`xopc.taskDetail.chatPanelPercent`,He=42;function Ue(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?He:Math.min(r,Math.max(n,e))}function We(){try{let e=Number(window.localStorage.getItem(Ve));return Number.isFinite(e)&&e>=30&&e<=60?e:He}catch{return He}}function Ge(e){return e.task.phase===`closed`?e.task.resolution===`done`?`completed`:`ended`: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`:`paused`:e.operationalState}function V(e){let t=(0,L.c)(9),{items:n,empty:r,verificationByCriterion:i}=e;if(n.length===0){let e;return t[0]===r?e=t[1]:(e=(0,R.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:r}),t[0]=r,t[1]=e),e}let a;if(t[2]!==n||t[3]!==i){let e;t[5]===i?e=t[6]:(e=e=>{let t=i?.get(e)??`unverified`;return(0,R.jsxs)(`li`,{className:`flex gap-2 text-sm leading-6 text-fg`,children:[(0,R.jsx)(t===`passed`?u:t===`failed`?ye:De,{className:t===`passed`?`mt-1 size-4 shrink-0 text-success`:t===`failed`?`mt-1 size-4 shrink-0 text-danger`:`mt-1 size-4 shrink-0 text-fg-subtle`}),(0,R.jsx)(`span`,{children:e})]},e)},t[5]=i,t[6]=e),a=n.map(e),t[2]=n,t[3]=i,t[4]=a}else a=t[4];let o;return t[7]===a?o=t[8]:(o=(0,R.jsx)(`ul`,{className:`space-y-2`,children:a}),t[7]=a,t[8]=o),o}function Ke({taskId:e,presentation:t,backgroundPath:n,onDeleted:r}){let[i]=o(),c=a(),l=te(e=>e.language),g=ee(e=>e.token),y=(0,I.useMemo)(()=>b(l),[l]),ne=P(e=>e.setPageHeader),re=P(e=>e.clearPageHeader),ie=w(e=>e.open),ae=w(e=>e.sessionKeyOverride),oe=w(e=>e.openForSession),ue=me(e=>e.setOpen),{data:C,error:ye,mutate:A,lastChange:De,conversationLoading:Oe,conversationError:ke}=ge(e),[L,z]=(0,I.useState)(null),[B,Fe]=(0,I.useState)(()=>new Set),[Ke,qe]=(0,I.useState)([]),[H,Je]=(0,I.useState)(null),[Ye,Xe]=(0,I.useState)([]),[Ze,U]=(0,I.useState)(!1),[Qe,$e]=(0,I.useState)(``),[et,W]=(0,I.useState)(!1),[tt,nt]=(0,I.useState)(``),[G,rt]=(0,I.useState)(We),[it,at]=(0,I.useState)(!1),ot=(0,I.useRef)(null),st=(0,I.useRef)(!1),ct=(0,I.useRef)(!1),lt=(0,I.useRef)(``),ut=(0,I.useRef)(null),dt=(0,I.useRef)(null),ft=(0,I.useRef)(null),pt=(0,I.useRef)(C),[mt,K]=(0,I.useState)(null),[ht,gt]=(0,I.useState)(null),[_t,vt]=(0,I.useState)(!1),yt=(0,I.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]),bt=C?.dependencies.map(e=>`${e.id}:${e.title}`).join(`\0`)??``,xt=(0,I.useMemo)(()=>p(i.get(`returnTo`),`/`,[`/projects`,`/chat`,`/notes`,`/tasks`]),[i]);pt.current=C;let q=(0,I.useCallback)((e,t)=>{Fe(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]);(0,I.useEffect)(()=>{z(null),K(null),U(!1),W(!1),gt(null),vt(!1)},[e]),(0,I.useEffect)(()=>{let e=!0;return j().then(t=>{e&&Xe(t.items)}).catch(()=>void 0),()=>{e=!1}},[g]),(0,I.useEffect)(()=>{if(!De||De.source===`user`)return;gt(De);let e=window.setTimeout(()=>gt(null),3500);return()=>window.clearTimeout(e)},[De]),(0,I.useEffect)(()=>{let t=C?.task.projectId,n=C?.dependencies??[];if(!t){ft.current=null,Je(null),qe(n);return}ft.current!==t&&(ft.current=t,Je(null));let r=!0;return Se(t).then(t=>{if(!r)return;Je(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});qe([...i.values()])}).catch(()=>{r&&qe(n)}),()=>{r=!1}},[bt,C?.task.projectId,e]);let J=(0,I.useCallback)(async(t,n=`command`)=>{let r=pt.current;if(r){q(n,!0),z(null);try{await A(await he(e,t,r.task.version),{revalidate:!1})}catch{z(y.actionFailed)}finally{q(n,!1)}}},[y.actionFailed,A,q,e]),Y=(0,I.useCallback)(async(t,n)=>{let r=pt.current;if(!r)return!1;n&&q(n,!0),z(null);try{return await A(k(e,t,r.task.version),{optimisticData:je(r,t),populateCache:!0,revalidate:!1,rollbackOnError:!0}),!0}catch{return z(y.actionFailed),!1}finally{n&&q(n,!1)}},[y.actionFailed,A,q,e]),St=async()=>{if(!C)return;if(st.current){st.current=!1;return}let e=Qe.trim(),t=ut.current;if(Ae(t,C.task.version,C.task.title,e)){K(`title`);return}if(!e||e===C.task.title){$e(C.task.title),U(!1);return}await Y({title:e})&&(K(null),U(!1))},Ct=async()=>{if(!C)return;if(ct.current){ct.current=!1;return}let e=tt.trim(),t=dt.current;if(Ae(t,C.task.version,C.task.body??``,e)){K(`description`);return}if(tt===lt.current||e===(C.task.body??``).trim()){W(!1);return}await Y({body:e||null})&&(K(null),W(!1))},wt=(0,I.useCallback)(async e=>{let t=pt.current;if(!(!t||e===t.task.phase)){if(t.task.phase===`closed`){await J({type:`reopen`,phase:e===`closed`?`ready`:e},`phase`);return}if(e===`closed`){await J({type:`close`,resolution:`done`},`phase`);return}await J({type:`move`,phase:e},`phase`)}},[J]),Tt=(0,I.useCallback)(e=>{Y({priority:e},`priority`)},[Y]),Et=(0,I.useCallback)(e=>{Y({dueAt:Pe(e)},`dueAt`)},[Y]),Dt=(0,I.useCallback)(e=>{rt(e);try{window.localStorage.setItem(Ve,String(e))}catch{}},[]),Ot=(0,I.useCallback)(e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`&&e.key!==`Home`)return;e.preventDefault();let t=ot.current?.clientWidth??0;Dt(Ue(e.key===`Home`?He:G+(e.key===`ArrowLeft`?2:-2),t))},[G,Dt]),kt=(0,I.useCallback)(e=>{if(!window.matchMedia(`(min-width: 1024px)`).matches)return;let t=ot.current;if(!t)return;e.preventDefault();let n=e.currentTarget,r=e.pointerId;n.setPointerCapture(r),at(!0);let i=G,a=0,o=()=>{a=0,t.style.setProperty(`--task-chat-panel-width`,`${i}%`)},s=e=>{let n=t.getBoundingClientRect();i=Ue((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{}at(!1),Dt(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)},[G,Dt]),At=(0,I.useCallback)(async t=>{let n=pt.current;if(n){q(`dependencies`,!0),z(null);try{await A(await ve(e,t,n.task.version),{revalidate:!1})}catch{z(y.dependencyUpdateFailed)}finally{q(`dependencies`,!1)}}},[y.dependencyUpdateFailed,A,q,e]),jt=(0,I.useCallback)(async t=>{let n=pt.current;if(!(!n||!t||t===n.conversation.currentExecutorAgentId)){q(`delegateAgentId`,!0),z(null);try{await A(await xe(e,t,n.task.version),{revalidate:!1})}catch{z(y.actionFailed)}finally{q(`delegateAgentId`,!1)}}},[y.actionFailed,A,q,e]),Mt=(0,I.useCallback)(async()=>{q(`delete`,!0),z(null);try{await ce(e),r?r():c(xt,{replace:!0})}catch(e){z(e instanceof Error?e.message:y.actionFailed)}finally{q(`delete`,!1)}},[y.actionFailed,c,r,xt,q,e]);if((0,I.useLayoutEffect)(()=>{if(t!==`modal`)return ne({startExtra:(0,R.jsx)(s,{to:xt,className:`flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":y.backToWork,children:(0,R.jsx)(T,{className:`size-4`})}),main:C?(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`p`,{className:`truncate text-sm font-semibold text-fg`,children:H?`${H} / ${y.taskLabel}`:y.taskLabel}),(0,R.jsx)(`p`,{className:`text-xs text-fg-muted`,children:y.detailStatuses[Ge(C)]})]}):null,end:null}),re},[re,y.backToWork,y.detailStatuses,y.taskLabel,C,t,H,xt,ne]),ye&&!C)return(0,R.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(!C)return(0,R.jsx)(`div`,{className:t===`modal`?`p-5`:`mx-auto max-w-4xl p-4 sm:p-6`,children:(0,R.jsx)(Me,{})});let Nt=C.waits[0],Pt=Nt?.kind===`paused`?Nt:void 0,X=C.receipts[0],Ft=y.detailStatuses[Ge(C)],It=y.detailStatusDescriptions[Ge(C)],Lt=C.task.body?.trim()||C.task.contract?.objective.trim(),Rt=new Map(X?.verification.checks.map(e=>[e.criterion,e.status])),zt=C.allowedCommands.includes(`mark_ready`),Bt=C.allowedCommands.includes(`start`),Vt=C.allowedCommands.includes(`add_wait`),Ht=C.task.phase===`review`&&C.allowedCommands.includes(`close`),Ut=C.allowedCommands.includes(`reopen`),Z=C.conversation.activeSessionKey,Wt=C.conversation.currentExecutorAgentId??C.task.delegateAgentId??C.task.ownerId,Gt=Ye.find(e=>e.id===Wt),Kt=!!(Z&&ie&&ae===Z),qt=C.attention.some(e=>e.kind===`input_required`||e.kind===`approval_required`),Jt=C.task.contract?.acceptanceCriteria??[],Yt=Jt.filter(e=>Rt.get(e)===`passed`).length,Xt=C.task.contract?.expectedOutputs??[],Zt=C.task.contract?.constraints??[],Qt=C.task.contract?.approvalRequired??[],$t=C.task.contract?.assumptions??[],en=C.task.contract?.risks??[],Q=(...e)=>!!ht?.changedFields.some(t=>e.includes(t)),tn=e=>t===`modal`&&n?D(n,e):m(`/tasks/${e}`,xt),nn=C.allowedCommands.includes(`move`),$=B.has(`command`),rn=B.has(`delete`),an=C.runs.find(e=>[`queued`,`running`,`waiting`,`verifying`].includes(e.status)),on=an!==void 0,sn=(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[zt?(0,R.jsxs)(v,{variant:`primary`,disabled:$,onClick:()=>void J({type:`mark_ready`}),children:[(0,R.jsx)(Te,{className:`size-4`}),y.scheduleTask]}):null,Pt?(0,R.jsxs)(v,{variant:`primary`,disabled:$,onClick:()=>void J({type:`resolve_wait`,waitId:Pt.id}),children:[(0,R.jsx)(Te,{className:`size-4`}),y.resumeTask]}):null,!Nt&&Bt&&Wt?(0,R.jsxs)(v,{variant:`primary`,disabled:$,onClick:()=>void J({type:`start`,executor:{kind:`agent`,agentId:Wt}}),children:[(0,R.jsx)(Te,{className:`size-4`}),y.runTask]}):null,Ht?(0,R.jsxs)(v,{variant:`primary`,disabled:$,onClick:()=>void J({type:`close`,resolution:`done`}),children:[(0,R.jsx)(u,{className:`size-4`}),y.approveTask]}):null,Ut?(0,R.jsxs)(v,{variant:`primary`,disabled:$,onClick:()=>void J({type:`reopen`,phase:`ready`}),children:[(0,R.jsx)(Te,{className:`size-4`}),y.reopenTask]}):null,!Nt&&Vt?(0,R.jsxs)(v,{variant:`secondary`,className:`border-0 bg-surface-hover shadow-none`,disabled:$,onClick:()=>void J({type:`add_wait`,wait:{kind:`paused`,reason:`Paused by user`,condition:{}}}),children:[(0,R.jsx)(we,{className:`size-4`}),y.pauseTask]}):null,(0,R.jsxs)(E,{children:[(0,R.jsx)(S,{asChild:!0,children:(0,R.jsx)(v,{type:`button`,variant:`ghost`,className:`size-9 p-0`,disabled:$||rn,"aria-label":y.moreActions,children:(0,R.jsx)(d,{className:`size-4`,"aria-hidden":!0})})}),(0,R.jsx)(de,{children:(0,R.jsxs)(x,{align:`end`,sideOffset:6,className:`z-[100] min-w-44 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:[an?(0,R.jsx)(be,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>{q(`command`,!0),z(null),A(fe(e,an.id,an.version),{revalidate:!1}).catch(()=>z(y.actionFailed)).finally(()=>q(`command`,!1))},children:y.cancelActiveRun}):null,an?(0,R.jsx)(O,{className:`my-1 h-px bg-edge`}):null,C.task.phase===`closed`?null:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(be,{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 J({type:`close`,resolution:`cancelled`}),children:y.cancelTask}),(0,R.jsx)(O,{className:`my-1 h-px bg-edge`})]}),(0,R.jsx)(be,{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(on){z(y.deleteActiveTaskBlocked);return}vt(!0)},children:y.deleteTask})]})})]})]});return(0,R.jsxs)(`div`,{ref:ot,className:`${t===`modal`?`flex h-full min-h-0 flex-col lg:flex-row`:`flex min-h-[calc(100dvh-8rem)] flex-col overflow-hidden lg:flex-row`} ${it?`lg:cursor-col-resize lg:select-none`:``}`,style:{"--task-chat-panel-width":`${G}%`},children:[(0,R.jsxs)(`section`,{className:`task-detail-scroll min-w-0 flex-1 overflow-y-auto overscroll-contain p-5 sm:p-6`,children:[(0,R.jsxs)(`header`,{className:_(`px-4 pb-5`,Q(`title`)&&`task-detail-live-update`),children:[(0,R.jsx)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[H?(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,R.jsx)(F,{className:`size-3.5`,"aria-hidden":!0}),H]}):null,(0,R.jsx)(`span`,{children:`/`}),(0,R.jsx)(`span`,{children:y.taskLabel}),ht?(0,R.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,role:`status`,children:ht.source===`agent`?l===`zh`?`Agent 刚刚更新`:`Updated by Agent`:l===`zh`?`执行结果已同步`:`Execution result synced`}):null]}),Ze?(0,R.jsx)(`input`,{autoFocus:!0,"data-task-inline-editor":!0,value:Qe,onChange:e=>$e(e.target.value),onBlur:()=>void St(),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),st.current=!0,$e(C.task.title),U(!1),queueMicrotask(()=>{st.current=!1}))},className:`mt-3 w-full max-w-3xl rounded-lg bg-surface-hover px-3 py-2 text-2xl font-semibold leading-8 text-fg outline-none ring-2 ring-accent/30 focus:ring-accent/60`}):(0,R.jsx)(`button`,{type:`button`,className:`mt-3 block max-w-3xl rounded-lg text-left outline-none hover:bg-surface-hover focus-visible:bg-surface-hover`,onClick:()=>{ut.current={value:C.task.title,version:C.task.version},K(null),$e(C.task.title),U(!0)},children:(0,R.jsx)(`h1`,{className:`text-2xl font-semibold leading-8 text-fg`,children:C.task.title})}),mt===`title`?(0,R.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,R.jsx)(`span`,{children:l===`zh`?`Agent 在你编辑期间更新了标题。`:`The Agent updated the title while you were editing.`}),(0,R.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:()=>{$e(C.task.title),K(null),U(!1)},children:l===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,R.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,onClick:()=>void Y({title:Qe.trim()}).then(e=>{e&&(K(null),U(!1))}),children:l===`zh`?`保留我的修改`:`Keep my changes`})]}):null]})}),L?(0,R.jsx)(`p`,{className:`mt-3 text-sm text-danger`,children:L}):null]}),(0,R.jsxs)(`div`,{className:`mt-5 flex flex-col gap-5`,children:[(0,R.jsxs)(`main`,{className:`order-2 min-w-0 space-y-5`,children:[(0,R.jsxs)(`section`,{className:_(`rounded-xl bg-surface-panel p-4`,Q(`body`)&&`task-detail-live-update`),children:[(0,R.jsx)(`h2`,{className:`font-medium text-fg`,children:y.taskDescription}),et?(0,R.jsx)(`textarea`,{autoFocus:!0,"data-task-inline-editor":!0,rows:6,value:tt,onChange:e=>nt(e.target.value),onBlur:()=>void Ct(),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),ct.current=!0,nt(C.task.body??C.task.contract?.objective??``),W(!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,R.jsx)(`button`,{type:`button`,className:`-mx-1 mt-2 block w-[calc(100%+0.5rem)] rounded-lg px-1 py-1 text-left outline-none hover:bg-surface-hover focus-visible:bg-surface-hover`,onClick:()=>{let e=C.task.body??C.task.contract?.objective??``;lt.current=e,dt.current={value:C.task.body??``,version:C.task.version},K(null),nt(e),W(!0)},children:(0,R.jsx)(`span`,{className:`whitespace-pre-wrap text-sm leading-6 text-fg-muted`,children:Lt&&Lt!==C.task.title?Lt:y.noTaskDescription})}),mt===`description`?(0,R.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,R.jsx)(`span`,{children:l===`zh`?`Agent 在你编辑期间更新了描述。`:`The Agent updated the description while you were editing.`}),(0,R.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:()=>{nt(C.task.body??``),K(null),W(!1)},children:l===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,R.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,onClick:()=>void Y({body:tt.trim()||null}).then(e=>{e&&(K(null),W(!1))}),children:l===`zh`?`保留我的修改`:`Keep my changes`})]}):null]}),C.attention.length>0?(0,R.jsxs)(`section`,{className:_(`rounded-xl bg-warning/10 p-4`,Q(`attention`)&&`task-detail-live-update`),children:[(0,R.jsx)(`h3`,{className:`font-medium text-fg`,children:qt?y.needsAttention:y.waitingStatus}),(0,R.jsx)(`ul`,{className:`mt-3 space-y-2 text-sm text-fg-muted`,children:C.attention.map((e,t)=>(0,R.jsx)(`li`,{children:e.summary},`${e.kind}-${t}`))})]}):null,(0,R.jsxs)(`section`,{className:_(`rounded-xl bg-surface-panel p-4`,Q(`contract`)&&`task-detail-live-update`),children:[(0,R.jsx)(`h2`,{className:`font-medium text-fg`,children:y.taskDefinition}),(0,R.jsxs)(`div`,{className:`mt-5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,R.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:y.successDefinition}),Jt.length>0?(0,R.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:y.criteriaProgress.replace(`{{verified}}`,String(Yt)).replace(`{{total}}`,String(Jt.length))}):null]}),(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(V,{items:Jt,empty:y.noDefinition,verificationByCriterion:Rt})})]}),Xt.length>0?(0,R.jsxs)(`div`,{className:`mt-5 rounded-lg bg-surface-hover p-4`,children:[(0,R.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:y.expectedOutputs}),(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(V,{items:Xt,empty:y.noDefinition})})]}):null,Zt.length>0?(0,R.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:y.constraints}),(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(V,{items:Zt,empty:y.noDefinition})})]}):null,Qt.length>0?(0,R.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:y.approvalRequired}),(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(V,{items:Qt,empty:y.noDefinition})})]}):null,$t.length>0?(0,R.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:y.contextAssumptions}),(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(V,{items:$t,empty:y.noDefinition})})]}):null,en.length>0?(0,R.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:y.contextRisks}),(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(V,{items:en,empty:y.noDefinition})})]}):null]}),X?(0,R.jsxs)(`section`,{className:_(`rounded-xl bg-surface-panel p-4`,Q(`runs`,`receipts`)&&`task-detail-live-update`),children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`h2`,{className:`font-medium text-fg`,children:y.latestResult}),(0,R.jsx)(h,{content:X.summary,compact:!0,className:`mt-2 text-sm leading-6 text-fg`})]}),(0,R.jsxs)(`span`,{className:`rounded-full bg-surface-hover px-2.5 py-1 text-xs text-fg-muted`,children:[y.receiptStatuses[X.status],` · `,y.verificationStatuses[X.verification.status]]})]}),X.remainingWork.length>0?(0,R.jsxs)(`div`,{className:`mt-4`,children:[(0,R.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:y.remainingWork}),(0,R.jsx)(`div`,{className:`mt-2`,children:(0,R.jsx)(V,{items:X.remainingWork,empty:y.noRemainingWork})})]}):null,X.nextAction?(0,R.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-hover p-3`,children:[(0,R.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:y.nextAction}),(0,R.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:X.nextAction})]}):null,(0,R.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(v,{className:`border-0 bg-surface-hover px-2 py-1 text-xs shadow-none`,variant:`secondary`,onClick:()=>void pe(X.runId,`helpful`),children:y.doneWell}),(0,R.jsx)(v,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>void pe(X.runId,`not_helpful`),children:y.needsFix}),X.evidence.filter(e=>e.uri).map(e=>(0,R.jsxs)(`a`,{className:`ml-auto inline-flex items-center gap-1 text-xs text-accent hover:underline`,href:e.uri,children:[(0,R.jsx)(f,{className:`size-3`}),e.title]},`${e.title}-${e.uri}`))]}),C.receipts.length>1?(0,R.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:y.executionHistory.replace(`{{count}}`,String(C.receipts.length-1))}),(0,R.jsx)(`div`,{className:`mt-3 space-y-3`,children:C.receipts.slice(1).map(e=>(0,R.jsx)(`article`,{className:`rounded-lg bg-surface-active p-3`,children:(0,R.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,R.jsx)(`p`,{className:`text-sm text-fg`,children:e.summary}),(0,R.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:y.receiptStatuses[e.status]})]})},e.runId))})]}):null]}):null,C.context.length>0?(0,R.jsxs)(`section`,{className:_(`rounded-xl bg-surface-panel p-4`,Q(`context`)&&`task-detail-live-update`),children:[(0,R.jsx)(`h2`,{className:`font-medium text-fg`,children:y.contextUsed}),(0,R.jsx)(`ul`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:C.context.map(e=>(0,R.jsxs)(`li`,{className:`min-w-0 rounded-lg bg-surface-hover p-2.5`,children:[(0,R.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,R.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,R.jsx)(`p`,{className:`mt-1 break-words text-sm text-fg`,children:e.title??e.targetId})]},e.id))})]}):null]}),(0,R.jsxs)(`aside`,{className:`order-1 min-w-0 space-y-4`,children:[(0,R.jsxs)(`section`,{className:_(`rounded-xl bg-surface-subtle p-4`,Q(`phase`,`resolution`,`priority`,`dueAt`,`delegateAgentId`)&&`task-detail-live-update`),children:[(0,R.jsx)(`h2`,{className:`font-medium text-fg`,children:y.taskProperties}),(0,R.jsxs)(`div`,{className:`mt-4 grid gap-4 sm:grid-cols-2`,children:[(0,R.jsx)(Ie,{value:C.task.phase,disabled:B.has(`phase`),canMove:nn,canApprove:Ht,canReopen:Ut,language:l,label:y.taskPhase,onChange:wt}),(0,R.jsx)(Le,{value:C.task.priority,disabled:B.has(`priority`),label:y.priority,labels:y.priorityLabels,onChange:Tt}),(0,R.jsx)(Re,{value:Ne(C.task.dueAt),disabled:B.has(`dueAt`),label:y.dueDate,onChange:Et}),(0,R.jsx)(ze,{value:C.conversation.currentExecutorAgentId??``,disabled:B.has(`delegateAgentId`),label:y.executorLabel,unassignedLabel:y.unassigned,agents:Ye,onChange:jt}),H?(0,R.jsxs)(`div`,{className:`grid gap-1 text-xs text-fg-muted`,children:[(0,R.jsx)(`span`,{children:y.projectLabel}),(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5 rounded-lg bg-surface-hover px-3 py-2 text-sm text-fg`,children:[(0,R.jsx)(F,{className:`size-3.5`}),H]})]}):null]}),(0,R.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-hover p-3 text-xs leading-5 text-fg-subtle`,children:[(0,R.jsx)(`p`,{children:Ft}),(0,R.jsx)(`p`,{children:It}),(0,R.jsx)(`p`,{className:`mt-2`,children:y.updatedAt.replace(`{{date}}`,Ee(C.task.updatedAt,l))})]})]}),(0,R.jsxs)(`section`,{className:_(`rounded-xl bg-surface-panel p-4`,Q(`dependencies`)&&`task-detail-live-update`),children:[(0,R.jsx)(`h2`,{className:`font-medium text-fg`,children:y.taskRelations}),(0,R.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:y.dependencies}),(0,R.jsx)(Be,{candidates:Ke,selected:C.dependencies,disabled:B.has(`dependencies`),labels:yt,onChange:At})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:y.dependents}),C.dependents.length>0?(0,R.jsx)(`div`,{className:`space-y-1.5`,children:C.dependents.map(e=>(0,R.jsx)(s,{to:tn(e.id),className:`block rounded-lg bg-surface-hover p-2.5 text-sm text-accent hover:underline`,children:e.title},e.id))}):(0,R.jsx)(`p`,{className:`text-sm text-fg-subtle`,children:y.noDependents})]})]})]})]})]})]}),(0,R.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":l===`zh`?`调整任务信息和 Agent 对话的宽度`:`Resize task details and Agent chat`,"aria-valuemin":30,"aria-valuemax":60,"aria-valuenow":Math.round(G),tabIndex:0,onPointerDown:kt,onKeyDown:Ot,onDoubleClick:()=>Dt(He),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 ${it?`bg-surface-hover`:``}`,children:(0,R.jsx)(`div`,{className:`my-3 w-px rounded-full bg-edge-strong/70 transition-colors group-hover:bg-accent group-focus-visible:bg-accent`})}),(0,R.jsxs)(`aside`,{className:`flex min-h-[34rem] min-w-0 flex-col bg-surface-panel lg:min-h-0 lg:w-[var(--task-chat-panel-width)] lg:shrink-0`,children:[(0,R.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3 bg-surface-subtle px-4 py-3.5`,children:[(0,R.jsx)(`div`,{className:`min-w-0`,children:(0,R.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[Wt?(0,R.jsx)(N,{agentId:Wt,avatar:Gt?.avatar,size:28,className:`shrink-0`}):null,(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:l===`zh`?`Agent 执行与对话`:`Agent execution and chat`}),(0,R.jsxs)(`p`,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:[Gt?.name??Wt??y.unassigned,` · `,Ft]})]})]})}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[sn,Z&&t!==`modal`?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(v,{type:`button`,variant:`ghost`,className:_(`h-8 shrink-0 px-2 text-xs`,Kt&&`bg-surface-hover text-fg`),"aria-label":l===`zh`?`项目文件`:`Project files`,"aria-pressed":Kt,onClick:()=>{ue(Z,!1),oe(Z)},children:[(0,R.jsx)(se,{className:`size-3.5`,"aria-hidden":!0}),l===`zh`?`文件`:`Files`]}),(0,R.jsx)(v,{asChild:!0,variant:`ghost`,className:`h-8 shrink-0 px-2 text-xs`,children:(0,R.jsxs)(s,{to:le(e),children:[(0,R.jsx)(f,{className:`size-3.5`}),l===`zh`?`全屏`:`Full screen`]})})]}):null]})]}),Z?(0,R.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,R.jsx)(Ce,{embedded:!0,sessionKey:Z,taskId:e})}):Oe?(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,R.jsxs)(`div`,{className:`max-w-xs`,children:[(0,R.jsx)(M,{className:`mx-auto size-8 animate-pulse text-fg-subtle`}),(0,R.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:l===`zh`?`正在创建任务会话`:`Creating task conversation`})]})}):ke?(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,R.jsxs)(`div`,{className:`max-w-xs`,children:[(0,R.jsx)(M,{className:`mx-auto size-8 text-danger`}),(0,R.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:l===`zh`?`任务会话创建失败`:`Could not create task conversation`}),(0,R.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:ke instanceof Error?ke.message:String(ke)})]})}):(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,R.jsxs)(`div`,{className:`max-w-xs`,children:[(0,R.jsx)(M,{className:`mx-auto size-8 text-fg-subtle`}),(0,R.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:l===`zh`?`等待任务会话`:`Waiting for a task conversation`}),(0,R.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:l===`zh`?`安排或开始任务后,Agent 的执行过程和持续对话会显示在这里。`:`Schedule or start the task to see the agent run and continue the conversation here.`})]})})]}),(0,R.jsx)(_e,{open:_t,title:y.deleteTaskTitle,description:y.deleteTaskDescription.replace(`{{title}}`,C.task.title),confirmLabel:y.confirmDeleteTask,cancelLabel:y.keepTask,destructive:!0,onConfirm:()=>{vt(!1),Mt()},onCancel:()=>vt(!1)})]})}function qe(){let e=(0,L.c)(2),{taskId:t}=i(),n=t===void 0?``:t,r;return e[0]===n?r=e[1]:(r=(0,R.jsx)(Ke,{taskId:n,presentation:`page`}),e[0]=n,e[1]=r),r}function H(e){let t=(0,L.c)(58),{taskId:n,backgroundPath:r,onClose:i}=e,a=te(tt),{data:o}=ge(n),c=o?.conversation.activeSessionKey??null,l=w(W),u=w(et),d=w($e),p=w(Qe),m=me(U),h=ue(Ze),v=ue(Xe),ee=l?u:0,b;t[0]!==i||t[1]!==v?(b=e=>{e||(v(null),i())},t[0]=i,t[1]=v,t[2]=b):b=t[2];let ce=a===`zh`?`关闭任务详情`:`Close task details`,x;t[3]!==i||t[4]!==v?(x=()=>{v(null),i()},t[3]=i,t[4]=v,t[5]=x):x=t[5];let S;t[6]!==ce||t[7]!==x?(S=(0,R.jsx)(`button`,{type:`button`,tabIndex:-1,"data-task-modal-backdrop":!0,className:`fixed inset-0 z-[80] bg-black/45 backdrop-blur-[1px]`,"aria-label":ce,onClick:x}),t[6]=ce,t[7]=x,t[8]=S):S=t[8];let de=l?`true`:`false`,fe=`${ee/2}px`,pe=`${ee}px`,he;t[9]!==fe||t[10]!==pe?(he={"--task-detail-workspace-offset":fe,"--task-detail-workspace-width":pe},t[9]=fe,t[10]=pe,t[11]=he):he=t[11];let _e=he,ve=a===`zh`?`任务详情`:`Task details`,T;t[12]===ve?T=t[13]:(T=(0,R.jsx)(ae,{className:`font-medium text-fg`,children:ve}),t[12]=ve,t[13]=T);let ye=a===`zh`?`查看并操作任务详情`:`View and manage task details`,E;t[14]===ye?E=t[15]:(E=(0,R.jsx)(y,{className:`sr-only`,children:ye}),t[14]=ye,t[15]=E);let D;t[16]!==c||t[17]!==a||t[18]!==p||t[19]!==m||t[20]!==n||t[21]!==l||t[22]!==d?(D=c?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,className:_(`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,l&&d===c&&`bg-surface-hover text-fg`),"aria-label":a===`zh`?`项目文件`:`Project files`,title:a===`zh`?`项目文件`:`Project files`,"aria-pressed":l&&d===c,onClick:()=>{m(c,!1),p(c)},children:(0,R.jsx)(se,{className:`size-4`,"aria-hidden":!0})}),(0,R.jsx)(s,{to:le(n),className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":a===`zh`?`全屏打开对话`:`Open chat full screen`,title:a===`zh`?`全屏打开对话`:`Open chat full screen`,children:(0,R.jsx)(f,{className:`size-4`,"aria-hidden":!0})})]}):null,t[16]=c,t[17]=a,t[18]=p,t[19]=m,t[20]=n,t[21]=l,t[22]=d,t[23]=D):D=t[23];let be=a===`zh`?`关闭任务详情`:`Close task details`,xe;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,R.jsx)(g,{className:`size-4`,"aria-hidden":!0}),t[24]=xe):xe=t[24];let O;t[25]===be?O=t[26]:(O=(0,R.jsx)(ne,{className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":be,children:xe}),t[25]=be,t[26]=O);let k;t[27]!==D||t[28]!==O?(k=(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[D,O]}),t[27]=D,t[28]=O,t[29]=k):k=t[29];let A;t[30]!==T||t[31]!==E||t[32]!==k?(A=(0,R.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-3 bg-surface-panel px-5 py-3.5`,children:[T,E,k]}),t[30]=T,t[31]=E,t[32]=k,t[33]=A):A=t[33];let j;t[34]!==i||t[35]!==v?(j=()=>{v(null),i()},t[34]=i,t[35]=v,t[36]=j):j=t[36];let M;t[37]!==r||t[38]!==j||t[39]!==n?(M=(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,R.jsx)(Ke,{taskId:n,presentation:`modal`,backgroundPath:r,onDeleted:j})}),t[37]=r,t[38]=j,t[39]=n,t[40]=M):M=t[40];let N;t[41]!==A||t[42]!==M||t[43]!==de||t[44]!==_e?(N=(0,R.jsxs)(ie,{className:`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 bg-surface-base shadow-float focus:outline-none`,"data-workspace-panel-open":de,style:_e,onEscapeKeyDown:Ye,onInteractOutside:Je,children:[A,M]}),t[41]=A,t[42]=M,t[43]=de,t[44]=_e,t[45]=N):N=t[45];let P;t[46]!==h||t[47]!==l||t[48]!==u||t[49]!==d?(P=h?(0,R.jsx)(`div`,{className:`fixed inset-y-0 left-0 z-[100] flex min-h-0 min-w-0 overflow-hidden bg-surface-panel transition-[right] duration-200 ease-out motion-reduce:transition-none`,style:{right:l?u:0},children:(0,R.jsx)(C,{allowOutsideChat:!0,sessionKey:d??void 0})}):null,t[46]=h,t[47]=l,t[48]=u,t[49]=d,t[50]=P):P=t[50];let F;t[51]!==N||t[52]!==P||t[53]!==S?(F=(0,R.jsxs)(re,{children:[S,N,P]}),t[51]=N,t[52]=P,t[53]=S,t[54]=F):F=t[54];let Se;return t[55]!==b||t[56]!==F?(Se=(0,R.jsx)(oe,{modal:!1,open:!0,onOpenChange:b,children:F}),t[55]=b,t[56]=F,t[57]=Se):Se=t[57],Se}function Je(e){let t=e.detail.originalEvent.target;t instanceof Element&&t.closest(`#app-workspace-panel, [data-task-modal-backdrop]`)&&e.preventDefault()}function Ye(e){let t=e.target;t instanceof HTMLElement&&t.closest(`[data-task-inline-editor]`)&&e.preventDefault()}function Xe(e){return e.setPath}function Ze(e){return e.path}function U(e){return e.setOpen}function Qe(e){return e.openForSession}function $e(e){return e.sessionKeyOverride}function et(e){return e.widthPx}function W(e){return e.open}function tt(e){return e.language}function nt(e){return(0,R.jsx)(l,{value:e.id,children:e.name||e.id},e.id)}function G(e){return e.id}export{H as TaskDetailModal,qe as TaskDetailPage};
@@ -1 +1 @@
1
- import{p as e}from"./locale-store-CPylQjH9.js";import{t}from"./middleware-Pd0e8Igk.js";var n=`default`,r={light:{default:`#ffffff`,emerald:`#f0fdf4`,mono:`#ffffff`,clay:`#fffaf0`},dark:{default:`#0a0a0a`,emerald:`#000000`,mono:`#101010`,clay:`#0a1a1a`}};function i(e,t){let n=document.head;if(!n)return;let i=n.querySelector(`meta[name="theme-color"][data-xopc-theme-color="true"]`);i||(i=document.createElement(`meta`),i.setAttribute(`name`,`theme-color`),i.setAttribute(`data-xopc-theme-color`,`true`),n.appendChild(i)),i.setAttribute(`content`,r[e][t])}function a(){return globalThis.matchMedia?.(`(prefers-color-scheme: dark)`).matches??!1}function o(e){return e===`system`?a()?`dark`:`light`:e}function s(){return globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1}function c(e){return e===`cal`?`mono`:e==="default"||e===`emerald`||e===`mono`||e===`clay`?e:n}function l(e,t,n){let r=document.documentElement,a=()=>{r.classList.toggle(`dark`,e===`dark`),r.dataset.theme=e,r.dataset.colorScheme=t,i(e,t)},o=document;n&&!s()&&typeof o.startViewTransition==`function`?o.startViewTransition(a):a()}function u(){try{let e=localStorage.getItem(`xopc-web-theme`),t=`system`,r=n;if(e){let n=JSON.parse(e);n.state?.preference&&(t=n.state.preference),n.state&&`colorScheme`in n.state&&(r=c(n.state.colorScheme))}l(o(t),r,!1)}catch{l(o(`system`),`default`,!1)}}var d=e(t((e,t)=>({preference:`system`,colorScheme:n,resolved:o(`system`),setPreference:n=>{let r=o(n),{resolved:i,colorScheme:a}=t();l(r,a,r!==i),e({preference:n,resolved:r})},setColorScheme:n=>{let{resolved:r}=t();l(r,n,!0),e({colorScheme:n})}}),{name:`xopc-web-theme`,merge:(e,t)=>{let n=e??{};return{...t,...n,colorScheme:c(n.colorScheme)}}}));function f(){let{preference:e,colorScheme:t}=d.getState(),n=o(e);l(n,t,!1),d.setState({resolved:n})}function p(){let e=globalThis.matchMedia?.(`(prefers-color-scheme: dark)`);if(!e)return()=>{};let t=()=>{let{preference:e,colorScheme:t}=d.getState();if(e!==`system`)return;let n=o(`system`),r=d.getState().resolved;l(n,t,n!==r),d.setState({resolved:n})};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)}export{d as i,p as n,f as r,u as t};
1
+ import{p as e}from"./locale-store-DqJz-cOR.js";import{t}from"./middleware-Pd0e8Igk.js";var n=`default`,r={light:{default:`#ffffff`,emerald:`#f0fdf4`,mono:`#ffffff`,clay:`#fffaf0`},dark:{default:`#0a0a0a`,emerald:`#000000`,mono:`#101010`,clay:`#0a1a1a`}};function i(e,t){let n=document.head;if(!n)return;let i=n.querySelector(`meta[name="theme-color"][data-xopc-theme-color="true"]`);i||(i=document.createElement(`meta`),i.setAttribute(`name`,`theme-color`),i.setAttribute(`data-xopc-theme-color`,`true`),n.appendChild(i)),i.setAttribute(`content`,r[e][t])}function a(){return globalThis.matchMedia?.(`(prefers-color-scheme: dark)`).matches??!1}function o(e){return e===`system`?a()?`dark`:`light`:e}function s(){return globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1}function c(e){return e===`cal`?`mono`:e==="default"||e===`emerald`||e===`mono`||e===`clay`?e:n}function l(e,t,n){let r=document.documentElement,a=()=>{r.classList.toggle(`dark`,e===`dark`),r.dataset.theme=e,r.dataset.colorScheme=t,i(e,t)},o=document;n&&!s()&&typeof o.startViewTransition==`function`?o.startViewTransition(a):a()}function u(){try{let e=localStorage.getItem(`xopc-web-theme`),t=`system`,r=n;if(e){let n=JSON.parse(e);n.state?.preference&&(t=n.state.preference),n.state&&`colorScheme`in n.state&&(r=c(n.state.colorScheme))}l(o(t),r,!1)}catch{l(o(`system`),`default`,!1)}}var d=e(t((e,t)=>({preference:`system`,colorScheme:n,resolved:o(`system`),setPreference:n=>{let r=o(n),{resolved:i,colorScheme:a}=t();l(r,a,r!==i),e({preference:n,resolved:r})},setColorScheme:n=>{let{resolved:r}=t();l(r,n,!0),e({colorScheme:n})}}),{name:`xopc-web-theme`,merge:(e,t)=>{let n=e??{};return{...t,...n,colorScheme:c(n.colorScheme)}}}));function f(){let{preference:e,colorScheme:t}=d.getState(),n=o(e);l(n,t,!1),d.setState({resolved:n})}function p(){let e=globalThis.matchMedia?.(`(prefers-color-scheme: dark)`);if(!e)return()=>{};let t=()=>{let{preference:e,colorScheme:t}=d.getState();if(e!==`system`)return;let n=o(`system`),r=d.getState().resolved;l(n,t,n!==r),d.setState({resolved:n})};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)}export{d as i,p as n,f as r,u as t};
@@ -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"./loader-circle-CifKLtgG.js";import{t as o}from"./cn-JdwAhgNB.js";import{n as s}from"./locale-store-CPylQjH9.js";import{Al as c}from"./index-B3zYJBhK.js";var l=n(),u=r();function d(e){let t=(0,l.c)(21),{status:n,error:r,className:d}=e,p=s(f)===`zh`,m=n===`saving`?p?`正在保存…`:`Saving…`:n===`saved`?p?`已自动保存`:`Saved automatically`:n===`error`?r||(p?`自动保存失败`:`Autosave failed`):n===`dirty`?p?`编辑中,将自动保存`:`Editing — autosave pending`:p?`自动保存`:`Autosave`,h=n===`error`?`text-danger`:n===`saved`?`text-success`:`text-fg-subtle`,g;t[0]!==d||t[1]!==h?(g=o(`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)(a,{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]),{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"./loader-circle-CifKLtgG.js";import{t as o}from"./cn-JdwAhgNB.js";import{n as s}from"./locale-store-DqJz-cOR.js";import{Al as c}from"./index-Csccu8sa.js";var l=n(),u=r();function d(e){let t=(0,l.c)(21),{status:n,error:r,className:d}=e,p=s(f)===`zh`,m=n===`saving`?p?`正在保存…`:`Saving…`:n===`saved`?p?`已自动保存`:`Saved automatically`:n===`error`?r||(p?`自动保存失败`:`Autosave failed`):n===`dirty`?p?`编辑中,将自动保存`:`Editing — autosave pending`:p?`自动保存`:`Autosave`,h=n===`error`?`text-danger`:n===`saved`?`text-success`:`text-fg-subtle`,g;t[0]!==d||t[1]!==h?(g=o(`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)(a,{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]),{status:s,error:l,flush:w,saveNow:T,retry:w,onBlurCapture:w}}export{d as n,m as t};