@xopcai/xopc 0.0.223 → 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 (197) 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/telegram/xopc.extension.json +1 -1
  4. package/dist/gateway/static/root/assets/{activity-store--GBciH10.js → activity-store-CtTYnku4.js} +1 -1
  5. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-C93T3FLD.js → agent-avatar-dicebear-dizuqu_4.js} +1 -1
  6. package/dist/gateway/static/root/assets/agents-DeEEFZJ4.js +68 -0
  7. package/dist/gateway/static/root/assets/{api-HoIz_ija.js → api-CLRMz2BT.js} +1 -1
  8. package/dist/gateway/static/root/assets/{app-management-settings-panel-Bhl8Xluk.js → app-management-settings-panel-Cnk-DtQh.js} +1 -1
  9. package/dist/gateway/static/root/assets/{appearance-settings-CywEN-kG.js → appearance-settings-wP0rogVI.js} +1 -1
  10. package/dist/gateway/static/root/assets/{apps-page-BZY09nuJ.js → apps-page-Db5YNHVM.js} +1 -1
  11. package/dist/gateway/static/root/assets/{archive-plugin-CteCVsBP.js → archive-plugin-Cpzsm-DM.js} +1 -1
  12. package/dist/gateway/static/root/assets/{attachment-load-CbNE_EPd.js → attachment-load-Bd2OOoEK.js} +1 -1
  13. package/dist/gateway/static/root/assets/{automations-page-Bcqk6tOx.js → automations-page-DNqhguyk.js} +1 -1
  14. package/dist/gateway/static/root/assets/automations-workspace-CNT05YTb.js +6 -0
  15. package/dist/gateway/static/root/assets/{binary-plugins-M_i3WS5M.js → binary-plugins-Dcma5HdI.js} +1 -1
  16. package/dist/gateway/static/root/assets/{block-editor-eg9LEH2o.js → block-editor-D-B8ThwK.js} +3 -3
  17. package/dist/gateway/static/root/assets/{browser-settings-page-kKwbvzjj.js → browser-settings-page-UbDj3LIq.js} +3 -3
  18. package/dist/gateway/static/root/assets/{browser-workflow-inputs-1UZ0vnIy.js → browser-workflow-inputs-BAPZIXrs.js} +1 -1
  19. package/dist/gateway/static/root/assets/{browser-workflows-page-D8ATQqZ5.js → browser-workflows-page-DHtaSKEh.js} +1 -1
  20. package/dist/gateway/static/root/assets/capabilities-settings-panel-CiO152QS.js +7 -0
  21. package/dist/gateway/static/root/assets/{capability-presets-api-yNqTIuyd.js → capability-presets-api-zsZQ7im3.js} +1 -1
  22. package/dist/gateway/static/root/assets/{capability-presets-settings-panel-CgdRkwnk.js → capability-presets-settings-panel-Bc_hRwfL.js} +2 -2
  23. package/dist/gateway/static/root/assets/{channel-recipient-api-krezGsKc.js → channel-recipient-api-Cp8iaaXp.js} +1 -1
  24. package/dist/gateway/static/root/assets/channels-settings-CFW7zBoT.js +1 -0
  25. package/dist/gateway/static/root/assets/channels-status-swr-5rNVq7iI.js +1 -0
  26. package/dist/gateway/static/root/assets/{chat-terminal-dock-DQ5bB4Su.js → chat-terminal-dock-Dr6Rq2ln.js} +1 -1
  27. package/dist/gateway/static/root/assets/connectors-page-DLBr5nre.js +2 -0
  28. package/dist/gateway/static/root/assets/{cron-expression-CEwPkdhh.js → cron-expression-BiXrpzmo.js} +1 -1
  29. package/dist/gateway/static/root/assets/{date-picker-DDAxTir8.js → date-picker-BPuRtwKt.js} +1 -1
  30. package/dist/gateway/static/root/assets/{dependency-picker-CYVoSZwI.js → dependency-picker-BNC_W7wI.js} +1 -1
  31. package/dist/gateway/static/root/assets/{desktop-pet-CrNKfW_c.js → desktop-pet-DzOpt5nI.js} +1 -1
  32. package/dist/gateway/static/root/assets/{desktop-pet-settings-C06PaB46.js → desktop-pet-settings-BW0brCvH.js} +1 -1
  33. package/dist/gateway/static/root/assets/{directory-picker-path-field--D7laeLF.js → directory-picker-path-field-Baml0uTS.js} +1 -1
  34. package/dist/gateway/static/root/assets/{extension-debug-page-Dn4Px9KQ.js → extension-debug-page-CBXyKmfS.js} +1 -1
  35. package/dist/gateway/static/root/assets/{extension-page-DzLf3fMQ.js → extension-page-BBhcr_SZ.js} +1 -1
  36. package/dist/gateway/static/root/assets/{extension-settings-page-DIchwtvB.js → extension-settings-page-4rwWpN9_.js} +1 -1
  37. package/dist/gateway/static/root/assets/{gateway-config-api-SmTGLhqK.js → gateway-config-api-Dg-BlBe4.js} +1 -1
  38. package/dist/gateway/static/root/assets/{gateway-config-swr-yUxMMVjK.js → gateway-config-swr-Du0MvK9s.js} +1 -1
  39. package/dist/gateway/static/root/assets/{gateway-settings-yCDkOYzA.js → gateway-settings-BOuYZOYe.js} +1 -1
  40. package/dist/gateway/static/root/assets/{gateway-startup-retry-9mrsL84j.js → gateway-startup-retry-JbjcHCaN.js} +1 -1
  41. package/dist/gateway/static/root/assets/{heartbeat-settings-CquIULHX.js → heartbeat-settings-Dq4YAlSx.js} +1 -1
  42. package/dist/gateway/static/root/assets/home-page-BIXkO0Ck.js +1 -0
  43. package/dist/gateway/static/root/assets/{image-generation-api-CgFAGDi8.js → image-generation-api-G2tfPvKP.js} +1 -1
  44. package/dist/gateway/static/root/assets/index-Csccu8sa.js +74 -0
  45. package/dist/gateway/static/root/assets/index-D3_xSYKd.css +2 -0
  46. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-DI2To7yl.js → keyboard-shortcuts-settings-L1Vtxgp9.js} +1 -1
  47. package/dist/gateway/static/root/assets/local-app-workbench-page-D-eacBcO.js +2 -0
  48. package/dist/gateway/static/root/assets/{local-apps-page-CSEJsQ1F.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-BRCglHvd.js +2 -0
  51. package/dist/gateway/static/root/assets/{management-settings-CgyaIyuk.js → management-settings-p55fR4XO.js} +1 -1
  52. package/dist/gateway/static/root/assets/{markdown-split-paG9qap9.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-0Q-c_QIy.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-Bvb-ycX_.js → notes-page-miO9ig9C.js} +1 -1
  58. package/dist/gateway/static/root/assets/notes-workbench-_13lmvmF.js +4 -0
  59. package/dist/gateway/static/root/assets/{product-open-page-DrvBwAns.js → product-open-page-BOu07nXf.js} +1 -1
  60. package/dist/gateway/static/root/assets/project-detail-page-BStRkOQr.js +1 -0
  61. package/dist/gateway/static/root/assets/projects-page-CY03RxVr.js +1 -0
  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-B19llkld.js +1 -0
  64. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-DKjdN4Lr.js → runtime-tools-settings-panel-DthuRqUH.js} +1 -1
  65. package/dist/gateway/static/root/assets/{schema-form-DskqaNqC.js → schema-form-8W8PhXxa.js} +1 -1
  66. package/dist/gateway/static/root/assets/sessions-page-BDA2qbTd.js +1 -0
  67. package/dist/gateway/static/root/assets/settings-advanced-gate-BONIDX4v.js +1 -0
  68. package/dist/gateway/static/root/assets/{settings-form-section-CZlMvHA9.js → settings-form-section-CrsKGYiG.js} +1 -1
  69. package/dist/gateway/static/root/assets/{settings-loading-skeleton-DS6lcAg9.js → settings-loading-skeleton-WJtI0AAq.js} +1 -1
  70. package/dist/gateway/static/root/assets/{settings-page-oE5J9tsV.js → settings-page-PCjwRF47.js} +1 -1
  71. package/dist/gateway/static/root/assets/{setup-status-panel-C7oFCIqD.js → setup-status-panel-D65CwlNC.js} +1 -1
  72. package/dist/gateway/static/root/assets/{share-preview-page-CPFAj8NE.js → share-preview-page-BGtvLLeZ.js} +1 -1
  73. package/dist/gateway/static/root/assets/shares-settings-CdzVKrBl.js +1 -0
  74. package/dist/gateway/static/root/assets/skill-reload-api-CsRWid5h.js +1 -0
  75. package/dist/gateway/static/root/assets/{skills-page-Bh4gFi8e.js → skills-page-C_npyryI.js} +1 -1
  76. package/dist/gateway/static/root/assets/{skills-page.utils-BQaUWP9z.js → skills-page.utils-C46Sd78k.js} +1 -1
  77. package/dist/gateway/static/root/assets/{system-settings-panel-COAZoh_O.js → system-settings-panel-DomTLwki.js} +1 -1
  78. package/dist/gateway/static/root/assets/task-detail-page-B6YFX7kK.js +1 -0
  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-BAkToU15.js → use-autosave-Do9mCRcY.js} +1 -1
  81. package/dist/gateway/static/root/assets/{user-context-page-Br5wgARM.js → user-context-page-CiCQA40E.js} +1 -1
  82. package/dist/gateway/static/root/assets/{voice-api-key-field-CC4z9-ux.js → voice-api-key-field-Bc5p-0tX.js} +1 -1
  83. package/dist/gateway/static/root/assets/{work-discovery-overlay-dLVUYSSE.js → work-discovery-overlay-BieqsmT1.js} +1 -1
  84. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-BYU5-0KF.js → workflow-run-setup-panel-DVj8iYvm.js} +2 -2
  85. package/dist/gateway/static/root/assets/workflows-page-AG04TTuH.js +5 -0
  86. package/dist/gateway/static/root/index.html +11 -11
  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/doctor/checks/database-schema.js +1 -1
  130. package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
  131. package/dist/src/config/config-mutation.d.ts +14 -0
  132. package/dist/src/config/config-mutation.js +33 -0
  133. package/dist/src/config/index.js +3 -3
  134. package/dist/src/config/paths.d.ts +2 -0
  135. package/dist/src/config/paths.js +5 -1
  136. package/dist/src/config/schema.d.ts +17 -0
  137. package/dist/src/config/schema.js +26 -2
  138. package/dist/src/connectors/auth-provider-registry.d.ts +1 -1
  139. package/dist/src/connectors/auth-provider-registry.js +23 -2
  140. package/dist/src/connectors/install.js +3 -3
  141. package/dist/src/connectors/instances.d.ts +2 -1
  142. package/dist/src/connectors/instances.js +15 -5
  143. package/dist/src/connectors/materialize.d.ts +1 -0
  144. package/dist/src/connectors/materialize.js +9 -1
  145. package/dist/src/connectors/runtime-adapter-registry.js +1 -0
  146. package/dist/src/connectors/types.d.ts +4 -1
  147. package/dist/src/extensions/connector-dependencies.d.ts +10 -0
  148. package/dist/src/extensions/connector-dependencies.js +65 -0
  149. package/dist/src/extensions/install.js +27 -0
  150. package/dist/src/extensions/normalize-manifest.js +1 -0
  151. package/dist/src/extensions/types/manifest.d.ts +2 -0
  152. package/dist/src/gateway/heartbeat/service.js +1 -1
  153. package/dist/src/gateway/hono/routes/capabilities.js +8 -8
  154. package/dist/src/gateway/hono/routes/connectors.js +87 -55
  155. package/dist/src/gateway/hono/routes/mcp.js +77 -5
  156. package/dist/src/gateway/hono/routes/voice.js +1 -1
  157. package/dist/src/gateway/run-loop.js +3 -0
  158. package/dist/src/gateway/server.d.ts +3 -0
  159. package/dist/src/gateway/server.js +30 -5
  160. package/dist/src/heartbeat/index.js +1 -1
  161. package/dist/src/infra/update-restart.js +1 -1
  162. package/dist/src/knowledge/connected-knowledge-pipeline.js +26 -4
  163. package/dist/src/session/store.js +27 -0
  164. package/dist/src/storage/sqlite/memory-records-repository.d.ts +9 -1
  165. package/dist/src/storage/sqlite/memory-records-repository.js +40 -6
  166. package/dist/src/storage/sqlite/migrations/134_memory_provenance.sql +18 -0
  167. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  168. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  169. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  170. package/dist/src/storage/sqlite/schema.js +1 -1
  171. package/dist/src/user-context/planner.js +8 -3
  172. package/dist/src/voice/stt/transcribe-core.js +17 -1
  173. package/dist/src/voice/stt/types.d.ts +1 -1
  174. package/package.json +3 -3
  175. package/dist/gateway/static/root/assets/agents-Ba4XF0Im.js +0 -68
  176. package/dist/gateway/static/root/assets/automations-workspace-DtI6vsMf.js +0 -6
  177. package/dist/gateway/static/root/assets/capabilities-settings-panel-CZRcis8B.js +0 -7
  178. package/dist/gateway/static/root/assets/channels-settings-DETCY0Ku.js +0 -1
  179. package/dist/gateway/static/root/assets/channels-status-swr-DMxB7slL.js +0 -1
  180. package/dist/gateway/static/root/assets/connectors-page-D9D92u28.js +0 -2
  181. package/dist/gateway/static/root/assets/home-page-COSGBh4c.js +0 -1
  182. package/dist/gateway/static/root/assets/index-5XkDWH_Q.css +0 -2
  183. package/dist/gateway/static/root/assets/index-wnDPGRTi.js +0 -74
  184. package/dist/gateway/static/root/assets/local-app-workbench-page-CAF5SZXv.js +0 -2
  185. package/dist/gateway/static/root/assets/logs-page-D1KFPHL1.js +0 -2
  186. package/dist/gateway/static/root/assets/notes-workbench-DelxGBof.js +0 -4
  187. package/dist/gateway/static/root/assets/project-detail-page-C2EnYXEQ.js +0 -1
  188. package/dist/gateway/static/root/assets/projects-page-BiMPU6Oa.js +0 -1
  189. package/dist/gateway/static/root/assets/remote-access-hub-CpbNivVs.js +0 -1
  190. package/dist/gateway/static/root/assets/sessions-page-BxKtzsKI.js +0 -1
  191. package/dist/gateway/static/root/assets/settings-advanced-gate-BfBKMMUx.js +0 -1
  192. package/dist/gateway/static/root/assets/shares-settings-B46DWZK4.js +0 -1
  193. package/dist/gateway/static/root/assets/skill-reload-api-CyKolUZ-.js +0 -1
  194. package/dist/gateway/static/root/assets/task-detail-page-CXkhprf-.js +0 -1
  195. package/dist/gateway/static/root/assets/workflows-page-CJ24a1HM.js +0 -5
  196. package/dist/src/extensions/bundle-mcp.d.ts +0 -18
  197. package/dist/src/extensions/bundle-mcp.js +0 -69
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{p as i}from"./chunk-KS7C4IRE-BaASWQor.js";import{n as a,r as o}from"./popover-select-CccGri5Y.js";import{t as s}from"./download-Dk-ZjtO6.js";import{t as c}from"./plus-Q2yW6OE7.js";import{t as l}from"./search-DA7gz22f.js";import{t as u}from"./x-B_N4OPjy.js";import{t as d}from"./cn-JdwAhgNB.js";import{t as f}from"./button-CSEbl4zT.js";import{s as p}from"./form-field-width-DJw_jULe.js";import{n as m,t as h}from"./interaction-BmQogeqz.js";import{t as g}from"./messages-B82nsi9k.js";import{l as _,n as ee,r as v,s as y}from"./locale-store-CPylQjH9.js";import{i as b,o as x}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{a as S,n as C,o as te,r as w,s as T,t as E}from"./dist-BPoKqzeH.js";import{i as D}from"./vendor-swr-BIWyz7Rc.js";import{n as O,r as k}from"./gateway-config-swr-yUxMMVjK.js";import{n as A,t as j}from"./registry-api-B_5D8epF.js";import{$c as M,Bn as N,Ca as P,Ea as F,Fc as I,Fi as L,Ii as R,Li as z,Mc as B,Nc as V,Sa as H,Ta as U,Vn as W,Vs as G,Xa as K,Ya as ne,_a as re,_c as ie,at as q,ba as ae,hc as oe,ic as se,mt as ce,nu as J,rc as le,rs as ue,tu as de,ul as fe,va as pe,xa as me,xl as he,ya as ge,ys as _e}from"./index-wnDPGRTi.js";import{n as ve,t as ye}from"./use-autosave-BAkToU15.js";import{t as be}from"./settings-advanced-gate-BfBKMMUx.js";import{n as xe,t as Y}from"./settings-form-section-CZlMvHA9.js";import{t as Se}from"./page-tabs-BaEQMYm_.js";var X=e(t(),1),Ce=n(),Z=r();function we(e){let t=new Date(e),n=Math.floor((new Date().getTime()-t.getTime())/(1e3*60*60*24));return n===0?t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):n===1?`Yesterday`:n<7?t.toLocaleDateString([],{weekday:`short`}):t.toLocaleDateString([],{month:`short`,day:`numeric`})}function Te(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Ee(e){let t=(0,Ce.c)(105),{session:n,variant:r,labels:i,sessionAgentId:a,sessionAgentAvatar:o,onOpen:c,onAction:l}=e,u;t[0]!==i.unnamedSession||t[1]!==n.name?(u=n.name?.trim()||i.unnamedSession,t[0]=i.unnamedSession,t[1]=n.name,t[2]=u):u=t[2];let f=u,p;t[3]===n.name?p=t[4]:(p=n.name?.trim(),t[3]=n.name,t[4]=p);let m=!!p,g=n.status===`archived`,_=n.status===`pinned`,ee=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,v;t[5]===ee?v=t[6]:(v=d(`group flex min-w-0 w-full max-w-full cursor-pointer flex-col rounded-xl bg-surface-base text-left transition-colors duration-150 ease-out`,`hover:bg-surface-hover active:scale-[0.99]`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,ee),t[5]=ee,t[6]=v);let y;t[7]===c?y=t[8]:(y=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},t[7]=c,t[8]=y);let b=r===`list`&&`sm:py-3`,x;t[9]===b?x=t[10]:(x=d(`flex min-w-0 items-start justify-between gap-2 bg-surface-hover/35 px-3 py-2 dark:bg-surface-hover/25`,b),t[9]=b,t[10]=x);let S;t[11]===n.sourceChannel?S=t[12]:(S=(0,Z.jsx)(`div`,{className:`flex min-w-0 items-center gap-2`,children:(0,Z.jsx)(`span`,{className:`truncate text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:n.sourceChannel})}),t[11]=n.sourceChannel,t[12]=S);let C;t[13]===_?C=t[14]:(C=_?(0,Z.jsx)(se,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[13]=_,t[14]=C);let te;t[15]===n.updatedAt?te=t[16]:(te=we(n.updatedAt),t[15]=n.updatedAt,t[16]=te);let w;t[17]===te?w=t[18]:(w=(0,Z.jsx)(`span`,{children:te}),t[17]=te,t[18]=w);let T;t[19]!==w||t[20]!==C?(T=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,children:[C,w]}),t[19]=w,t[20]=C,t[21]=T):T=t[21];let E;t[22]!==T||t[23]!==x||t[24]!==S?(E=(0,Z.jsxs)(`div`,{className:x,children:[S,T]}),t[22]=T,t[23]=x,t[24]=S,t[25]=E):E=t[25];let D=r===`list`&&`sm:py-3`,O;t[26]===D?O=t[27]:(O=d(`min-w-0 flex-1 px-3 py-2`,D),t[26]=D,t[27]=O);let k=r===`list`&&`sm:items-start`,A;t[28]===k?A=t[29]:(A=d(`flex gap-3`,k),t[28]=k,t[29]=A);let j;t[30]!==o||t[31]!==a?(j=(0,Z.jsx)(q,{agentId:a,avatar:o,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}),t[30]=o,t[31]=a,t[32]=j):j=t[32];let M;t[33]===f?M=t[34]:(M=(0,Z.jsx)(`div`,{className:`min-w-0 max-w-full truncate text-sm font-semibold text-fg`,title:f,children:f}),t[33]=f,t[34]=M);let N;t[35]!==n.key||t[36]!==m?(N=m?(0,Z.jsx)(`div`,{className:`mt-0.5 min-w-0 max-w-full truncate font-mono text-[11px] text-fg-subtle`,title:n.key,children:n.key}):null,t[35]=n.key,t[36]=m,t[37]=N):N=t[37];let P;t[38]!==M||t[39]!==N?(P=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[M,N]}),t[38]=M,t[39]=N,t[40]=P):P=t[40];let F;t[41]!==A||t[42]!==j||t[43]!==P?(F=(0,Z.jsxs)(`div`,{className:A,children:[j,P]}),t[41]=A,t[42]=j,t[43]=P,t[44]=F):F=t[44];let I;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Z.jsx)(ie,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[45]=I):I=t[45];let L;t[46]===n.messageCount?L=t[47]:(L=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[I,n.messageCount]}),t[46]=n.messageCount,t[47]=L);let R;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,Z.jsx)(ue,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[48]=R):R=t[48];let z;t[49]===n.estimatedTokens?z=t[50]:(z=Te(n.estimatedTokens),t[49]=n.estimatedTokens,t[50]=z);let B;t[51]===z?B=t[52]:(B=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[R,z]}),t[51]=z,t[52]=B);let V;t[53]!==L||t[54]!==B?(V=(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[L,B]}),t[53]=L,t[54]=B,t[55]=V):V=t[55];let H;t[56]===n.tags?H=t[57]:(H=n.tags.length>0?(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n.tags.slice(0,3).map(ke),n.tags.length>3?(0,Z.jsxs)(`span`,{className:`text-[11px] text-fg-disabled`,children:[`+`,n.tags.length-3]}):null]}):null,t[56]=n.tags,t[57]=H);let U;t[58]!==O||t[59]!==F||t[60]!==V||t[61]!==H?(U=(0,Z.jsxs)(`div`,{className:O,children:[F,V,H]}),t[58]=O,t[59]=F,t[60]=V,t[61]=H,t[62]=U):U=t[62];let W;t[63]===l?W=t[64]:(W=()=>l(`continue`),t[63]=l,t[64]=W);let G;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,Z.jsx)(ie,{className:`size-4`,strokeWidth:1.75}),t[65]=G):G=t[65];let K;t[66]!==i.continueChat||t[67]!==W?(K=(0,Z.jsx)(`button`,{type:`button`,className:h,title:i.continueChat,"aria-label":i.continueChat,onClick:W,children:G}),t[66]=i.continueChat,t[67]=W,t[68]=K):K=t[68];let ne;t[69]!==g||t[70]!==i.archive||t[71]!==i.unarchive||t[72]!==l?(ne=g?(0,Z.jsx)(`button`,{type:`button`,className:h,title:i.unarchive,"aria-label":i.unarchive,onClick:()=>l(`unarchive`),children:(0,Z.jsx)(J,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:h,title:i.archive,"aria-label":i.archive,onClick:()=>l(`archive`),children:(0,Z.jsx)(de,{className:`size-4`,strokeWidth:1.75})}),t[69]=g,t[70]=i.archive,t[71]=i.unarchive,t[72]=l,t[73]=ne):ne=t[73];let re;t[74]!==_||t[75]!==i.pin||t[76]!==i.unpin||t[77]!==l?(re=_?(0,Z.jsx)(`button`,{type:`button`,className:h,title:i.unpin,"aria-label":i.unpin,onClick:()=>l(`unpin`),children:(0,Z.jsx)(le,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:h,title:i.pin,"aria-label":i.pin,onClick:()=>l(`pin`),children:(0,Z.jsx)(se,{className:`size-4`,strokeWidth:1.75})}),t[74]=_,t[75]=i.pin,t[76]=i.unpin,t[77]=l,t[78]=re):re=t[78];let ae;t[79]===l?ae=t[80]:(ae=()=>l(`export`),t[79]=l,t[80]=ae);let oe;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,Z.jsx)(s,{className:`size-4`,strokeWidth:1.75}),t[81]=oe):oe=t[81];let ce;t[82]!==i.export||t[83]!==ae?(ce=(0,Z.jsx)(`button`,{type:`button`,className:h,title:i.export,"aria-label":i.export,onClick:ae,children:oe}),t[82]=i.export,t[83]=ae,t[84]=ce):ce=t[84];let fe;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(fe=d(h,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),t[85]=fe):fe=t[85];let pe;t[86]===l?pe=t[87]:(pe=()=>l(`delete`),t[86]=l,t[87]=pe);let me;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,Z.jsx)(_e,{className:`size-4`,strokeWidth:1.75}),t[88]=me):me=t[88];let he;t[89]!==i.delete||t[90]!==pe?(he=(0,Z.jsx)(`button`,{type:`button`,className:fe,title:i.delete,"aria-label":i.delete,onClick:pe,children:me}),t[89]=i.delete,t[90]=pe,t[91]=he):he=t[91];let ge;t[92]!==K||t[93]!==ne||t[94]!==re||t[95]!==ce||t[96]!==he?(ge=(0,Z.jsxs)(`div`,{role:`group`,className:`flex flex-wrap items-center gap-0.5 border-t border-edge-subtle/80 bg-surface-hover/25 p-2 dark:border-edge-subtle`,onClick:Oe,onKeyDown:De,children:[K,ne,re,ce,he]}),t[92]=K,t[93]=ne,t[94]=re,t[95]=ce,t[96]=he,t[97]=ge):ge=t[97];let ve;return t[98]!==c||t[99]!==E||t[100]!==U||t[101]!==v||t[102]!==ge||t[103]!==y?(ve=(0,Z.jsxs)(`div`,{role:`button`,tabIndex:0,className:v,onClick:c,onKeyDown:y,children:[E,U,ge]}),t[98]=c,t[99]=E,t[100]=U,t[101]=v,t[102]=ge,t[103]=y,t[104]=ve):ve=t[104],ve}function De(e){return e.stopPropagation()}function Oe(e){return e.stopPropagation()}function ke(e){return(0,Z.jsx)(`span`,{className:`max-w-full break-words rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e},e)}function Ae(e,t){return e.routing?.agentId?.trim().toLowerCase()||t.trim().toLowerCase()||`main`}function je(e,t){return t.find(t=>t.id===e)?.avatar}var Me={enabled:!0,triggerThreshold:.8,reserveTokens:8192,minMessagesBeforeCompact:10,keepRecentTokens:2e4,recentTurnsPreserve:3,summaryMaxTokens:2e3,summaryChunkTokens:24e3,summaryTimeoutMs:18e4,summaryRetries:2,qualityGuard:!0,gapAudit:!0,minToolResultKeepChars:1e3,maxActiveTranscriptBytes:2e6,postCompactionSections:[`Session Startup`,`Red Lines`]};function Ne(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Pe(e,t,n,r=1/0){return typeof e==`number`&&Number.isFinite(e)&&e>=n&&e<=r?e:t}function Q(e,t,n,r=1/0){return Number.isInteger(e)&&e>=n&&e<=r?e:t}function Fe(e){let t=Ne(e)?e:{},n=Ne(t.userContext)?t.userContext:{},r=Ne(n.memory)?n.memory:{},i=Ne(r.retention)?r.retention:{},a=Ne(i.compaction)?i.compaction:{},o=Me,s=typeof a.model==`string`&&a.model.trim()?a.model.trim():void 0,c=Array.isArray(a.postCompactionSections)&&a.postCompactionSections.length<=12&&a.postCompactionSections.every(e=>typeof e==`string`&&e.trim())?[...new Set(a.postCompactionSections.map(e=>e.trim()))]:[...o.postCompactionSections];return{enabled:typeof a.enabled==`boolean`?a.enabled:o.enabled,triggerThreshold:Pe(a.triggerThreshold,o.triggerThreshold,.1,.98),reserveTokens:Q(a.reserveTokens,o.reserveTokens,1024),minMessagesBeforeCompact:Q(a.minMessagesBeforeCompact,o.minMessagesBeforeCompact,2),keepRecentTokens:Q(a.keepRecentTokens,o.keepRecentTokens,1e3),recentTurnsPreserve:Q(a.recentTurnsPreserve,o.recentTurnsPreserve,1,12),summaryMaxTokens:Q(a.summaryMaxTokens,o.summaryMaxTokens,256),summaryChunkTokens:Q(a.summaryChunkTokens,o.summaryChunkTokens,1e3),summaryTimeoutMs:Q(a.summaryTimeoutMs,o.summaryTimeoutMs,1e3,6e5),summaryRetries:Q(a.summaryRetries,o.summaryRetries,0,5),qualityGuard:typeof a.qualityGuard==`boolean`?a.qualityGuard:o.qualityGuard,gapAudit:typeof a.gapAudit==`boolean`?a.gapAudit:o.gapAudit,...s?{model:s}:{},minToolResultKeepChars:Q(a.minToolResultKeepChars,o.minToolResultKeepChars,200),maxActiveTranscriptBytes:Q(a.maxActiveTranscriptBytes,o.maxActiveTranscriptBytes,64e3),postCompactionSections:c}}function Ie(e){return e.triggerThreshold<.1||e.triggerThreshold>.98?`triggerThreshold`:!Number.isInteger(e.reserveTokens)||e.reserveTokens<1024?`reserveTokens`:!Number.isInteger(e.minMessagesBeforeCompact)||e.minMessagesBeforeCompact<2?`minMessagesBeforeCompact`:!Number.isInteger(e.keepRecentTokens)||e.keepRecentTokens<1e3?`keepRecentTokens`:!Number.isInteger(e.recentTurnsPreserve)||e.recentTurnsPreserve<1||e.recentTurnsPreserve>12?`recentTurnsPreserve`:!Number.isInteger(e.summaryMaxTokens)||e.summaryMaxTokens<256?`summaryMaxTokens`:!Number.isInteger(e.summaryChunkTokens)||e.summaryChunkTokens<1e3?`summaryChunkTokens`:!Number.isInteger(e.summaryTimeoutMs)||e.summaryTimeoutMs<1e3||e.summaryTimeoutMs>6e5?`summaryTimeoutMs`:!Number.isInteger(e.summaryRetries)||e.summaryRetries<0||e.summaryRetries>5?`summaryRetries`:e.model!==void 0&&!e.model.trim()?`model`:!Number.isInteger(e.minToolResultKeepChars)||e.minToolResultKeepChars<200?`minToolResultKeepChars`:!Number.isInteger(e.maxActiveTranscriptBytes)||e.maxActiveTranscriptBytes<64e3?`maxActiveTranscriptBytes`:e.postCompactionSections.length>12||e.postCompactionSections.some(e=>!e.trim())?`postCompactionSections`:null}function Le(e){let t={...e,...e.model?.trim()?{model:e.model.trim()}:{}};return e.model?.trim()||delete t.model,{userContext:{memory:{retention:{compaction:t}}}}}async function Re(e){await y(v(`/api/config`),{method:`PATCH`,body:JSON.stringify(Le(e))}),await O()}var ze=128e3,Be={balanced:Me,preserve:{...Me,triggerThreshold:.88,keepRecentTokens:32e3,recentTurnsPreserve:5,maxActiveTranscriptBytes:4e6},early:{...Me,triggerThreshold:.65,reserveTokens:12e3,minMessagesBeforeCompact:6,keepRecentTokens:12e3,recentTurnsPreserve:2}},Ve=L();function He(){return d(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg disabled:cursor-not-allowed disabled:opacity-55`,p,`dark:border-edge`)}function Ue(e){let{enabled:t,model:n,postCompactionSections:r,...i}=e;return JSON.stringify(i)}function We(e){let t=Ue(e);for(let[e,n]of Object.entries(Be))if(t===Ue(n))return e;return`custom`}function Ge(e){return e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}m`:e>=1e3?`${(e/1e3).toFixed(e%1e3==0?0:1)}k`:String(e)}function $(e){let t=(0,Ce.c)(20),{id:n,label:r,hint:i,value:a,min:o,max:s,step:c,disabled:l,onChange:u}=e,d=c===void 0?1:c,f;t[0]!==n||t[1]!==r?(f=(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=f):f=t[2];let p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=He(),t[3]=p):p=t[3];let m;t[4]===u?m=t[5]:(m=e=>{if(!e.target.value.trim())return;let t=Number(e.target.value);Number.isFinite(t)&&u(t)},t[4]=u,t[5]=m);let h;t[6]!==l||t[7]!==n||t[8]!==s||t[9]!==o||t[10]!==d||t[11]!==m||t[12]!==a?(h=(0,Z.jsx)(`input`,{id:n,type:`number`,min:o,max:s,step:d,disabled:l,className:p,value:a,onChange:m}),t[6]=l,t[7]=n,t[8]=s,t[9]=o,t[10]=d,t[11]=m,t[12]=a,t[13]=h):h=t[13];let g;t[14]===i?g=t[15]:(g=i?(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}):null,t[14]=i,t[15]=g);let _;return t[16]!==f||t[17]!==h||t[18]!==g?(_=(0,Z.jsxs)(`div`,{children:[f,h,g]}),t[16]=f,t[17]=h,t[18]=g,t[19]=_):_=t[19],_}function Ke(e){let t=(0,Ce.c)(19),{label:n,hint:r,checked:i,disabled:a,onChange:o}=e,s=a?`cursor-not-allowed opacity-55`:`cursor-pointer`,c;t[0]===s?c=t[1]:(c=d(`flex items-start gap-2 text-sm text-fg`,s),t[0]=s,t[1]=c);let l;t[2]===o?l=t[3]:(l=e=>o(e.target.checked),t[2]=o,t[3]=l);let u;t[4]!==i||t[5]!==a||t[6]!==l?(u=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:i,disabled:a,onChange:l}),t[4]=i,t[5]=a,t[6]=l,t[7]=u):u=t[7];let f;t[8]===n?f=t[9]:(f=(0,Z.jsx)(`span`,{className:`font-medium`,children:n}),t[8]=n,t[9]=f);let p;t[10]===r?p=t[11]:(p=(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:r}),t[10]=r,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,Z.jsxs)(`span`,{children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;return t[15]!==c||t[16]!==u||t[17]!==m?(h=(0,Z.jsxs)(`label`,{className:c,children:[u,m]}),t[15]=c,t[16]=u,t[17]=m,t[18]=h):h=t[18],h}function qe({hasToken:e}){let t=g(ee(e=>e.language)).sessions.compaction,{data:n,isLoading:r}=k(e),{data:i=[],isLoading:a}=D(e?j:null,A,{revalidateOnFocus:!1}),o=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:Fe(n.payload.config),[n]),[s,l]=(0,X.useReducer)(Ve,{form:null,baseline:null}),[p,h]=(0,X.useState)(``),_=(0,X.useRef)(!1),v=(0,X.useRef)(s.form);v.current=s.form;let y=(0,X.useRef)(null);R({enabled:e,parsed:o,dirty:_.current,trackedParsedRef:y,dispatch:l,onResetDirty:()=>{_.current=!1}});let b=s.form,x=s.baseline,S=!!(b&&x&&JSON.stringify(b)!==JSON.stringify(x)),C=(0,X.useCallback)(e=>{_.current=!0,l({type:`patch`,patch:e})},[]),te=(0,X.useCallback)(e=>({enabled:t.enabled,triggerThreshold:t.triggerThreshold,reserveTokens:t.reserveTokens,minMessagesBeforeCompact:t.minMessagesBeforeCompact,keepRecentTokens:t.keepRecentTokens,recentTurnsPreserve:t.recentTurnsPreserve,summaryMaxTokens:t.summaryMaxTokens,summaryChunkTokens:t.summaryChunkTokens,summaryTimeoutMs:t.summaryTimeoutSeconds,summaryRetries:t.summaryRetries,qualityGuard:t.qualityGuard,gapAudit:t.gapAudit,model:t.summaryModel,minToolResultKeepChars:t.minToolResultKeepChars,maxActiveTranscriptBytes:t.maxActiveTranscriptMb,postCompactionSections:t.postCompactionSections})[e],[t]),w=ye({value:b,dirty:S,onSave:(0,X.useCallback)(async e=>{try{await Re(e),l({type:`saved`,value:e}),_.current=!!(v.current&&JSON.stringify(v.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError]),validate:e=>{let n=Ie(e);return n?t.invalidValue.replace(`{{field}}`,te(n)):null}});if(!e||!b)return r?(0,Z.jsx)(Y,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(K,{className:`h-5 w-48`}),(0,Z.jsx)(K,{className:`h-20 w-full rounded-xl`}),(0,Z.jsx)(K,{className:`h-36 w-full rounded-xl`})]})}):null;let T=We(b),E=Math.max(0,ze-b.reserveTokens),O=Math.min(Math.floor(ze*b.triggerThreshold),E),M=Math.min(100,O/ze*100),N=Math.min(100,E/ze*100),P=b.model?i.find(e=>e.id===b.model):void 0,F=P?.contextWindow&&b.summaryChunkTokens+b.summaryMaxTokens+4096>P.contextWindow,I=b.keepRecentTokens+b.reserveTokens>O,L=Math.round(b.summaryTimeoutMs*(b.summaryRetries+1)/1e3),z=e=>{let t=Be[e];C({...t,...b.model?{model:b.model}:{model:void 0},postCompactionSections:b.postCompactionSections})},B={balanced:{title:t.presetBalanced,hint:t.presetBalancedHint},preserve:{title:t.presetPreserve,hint:t.presetPreserveHint},early:{title:t.presetEarly,hint:t.presetEarlyHint}},V=()=>{let e=p.trim();!e||b.postCompactionSections.includes(e)||b.postCompactionSections.length>=12||(C({postCompactionSections:[...b.postCompactionSections,e]}),h(``))};return(0,Z.jsxs)(Y,{onBlurCapture:w.onBlurCapture,children:[(0,Z.jsx)(xe,{icon:oe,title:t.title,subtitle:t.hint,trailing:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(ve,{status:w.status,error:w.error}),(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm font-medium text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:b.enabled,onChange:e=>C({enabled:e.target.checked})}),b.enabled?t.enabled:t.disabled]})]})}),w.error?(0,Z.jsx)(`p`,{className:`mb-4 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900 dark:bg-red-950/40 dark:text-red-300`,role:`alert`,children:w.error}):null,b.enabled?null:(0,Z.jsx)(`p`,{className:`mb-4 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:t.disabledWarning}),(0,Z.jsxs)(`fieldset`,{disabled:!b.enabled,className:`space-y-5 disabled:opacity-60`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.presetTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.presetHint})]}),T===`custom`?(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:t.presetCustom}):null]}),(0,Z.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[`balanced`,`preserve`,`early`].map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":T===e,className:d(`rounded-xl border px-3 py-3 text-left`,m.transition,m.focusRingPanel,T===e?`border-accent/50 bg-accent-soft text-accent-fg`:`border-edge bg-surface-panel text-fg hover:bg-surface-hover`),onClick:()=>z(e),children:[(0,Z.jsx)(`span`,{className:`block text-sm font-medium`,children:B[e].title}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:B[e].hint})]},e))})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-hover/35 p-4 dark:border-edge`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.budgetPreview}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.budgetPreviewHint})]}),(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2.5 py-1 font-mono text-xs text-fg-muted`,children:t.previewModel128k})]}),(0,Z.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:t.compactionTrigger}),(0,Z.jsx)(`span`,{className:`font-mono text-fg`,children:Ge(O)})]}),(0,Z.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-accent`,style:{width:`${M}%`}})})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:t.hardInputLimit}),(0,Z.jsx)(`span`,{className:`font-mono text-fg`,children:Ge(E)})]}),(0,Z.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-fg-subtle`,style:{width:`${N}%`}})})]})]}),(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:t.budgetFormula})]}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)($,{id:`compaction-trigger-threshold`,label:t.triggerThreshold,hint:t.triggerThresholdHint,value:Number((b.triggerThreshold*100).toFixed(2)),min:10,max:98,step:.1,onChange:e=>C({triggerThreshold:e/100})}),(0,Z.jsx)($,{id:`compaction-reserve-tokens`,label:t.reserveTokens,hint:t.reserveTokensHint.replace(`{{tokens}}`,Ge(b.reserveTokens)),value:b.reserveTokens,min:1024,step:1024,onChange:e=>C({reserveTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-recent-turns`,label:t.recentTurnsPreserve,hint:t.recentTurnsPreserveHint,value:b.recentTurnsPreserve,min:1,max:12,onChange:e=>C({recentTurnsPreserve:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-keep-recent-tokens`,label:t.keepRecentTokens,hint:t.keepRecentTokensHint.replace(`{{tokens}}`,Ge(b.keepRecentTokens)),value:b.keepRecentTokens,min:1e3,step:1e3,onChange:e=>C({keepRecentTokens:Math.floor(e)})})]}),I?(0,Z.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:t.retentionWarning}):null,(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.summaryModel}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 gap-2`,children:[(0,Z.jsx)(ce,{value:b.model??``,disabled:!b.enabled,placeholder:t.summaryModelInherited,searchPlaceholder:t.summaryModelSearch,noMatches:t.summaryModelNoMatches,models:i,modelsLoading:a,className:`min-w-0 flex-1 justify-between`,contentAlign:`start`,showProviderSettingsFooter:!0,onChange:e=>C({model:e})}),b.model?(0,Z.jsx)(f,{type:`button`,variant:`secondary`,onClick:()=>C({model:void 0}),children:t.summaryModelUseSession}):null]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.summaryModelHint})]}),(0,Z.jsx)(Ke,{label:t.qualityGuard,hint:t.qualityGuardHint,checked:b.qualityGuard,onChange:e=>C({qualityGuard:e})}),(0,Z.jsx)(Ke,{label:t.gapAudit,hint:t.gapAuditHint,checked:b.gapAudit,onChange:e=>C({gapAudit:e})})]}),b.qualityGuard?null:(0,Z.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:t.qualityGuardWarning}),(0,Z.jsx)(be,{children:(0,Z.jsxs)(`div`,{className:`space-y-5 border-t border-edge pt-5`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:t.advancedTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.advancedHint})]}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)($,{id:`compaction-min-messages`,label:t.minMessagesBeforeCompact,hint:t.minMessagesBeforeCompactHint,value:b.minMessagesBeforeCompact,min:2,onChange:e=>C({minMessagesBeforeCompact:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-max-transcript-mb`,label:t.maxActiveTranscriptMb,hint:t.maxActiveTranscriptMbHint,value:Number((b.maxActiveTranscriptBytes/1e6).toFixed(3)),min:.064,step:.1,onChange:e=>C({maxActiveTranscriptBytes:Math.max(64e3,Math.round(e*1e6))})}),(0,Z.jsx)($,{id:`compaction-summary-max-tokens`,label:t.summaryMaxTokens,hint:t.summaryMaxTokensHint,value:b.summaryMaxTokens,min:256,step:256,onChange:e=>C({summaryMaxTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-chunk-tokens`,label:t.summaryChunkTokens,hint:t.summaryChunkTokensHint,value:b.summaryChunkTokens,min:1e3,step:1e3,onChange:e=>C({summaryChunkTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-timeout`,label:t.summaryTimeoutSeconds,hint:t.summaryTimeoutSecondsHint.replace(`{{seconds}}`,String(L)),value:b.summaryTimeoutMs/1e3,min:1,max:600,onChange:e=>C({summaryTimeoutMs:Math.round(e*1e3)})}),(0,Z.jsx)($,{id:`compaction-summary-retries`,label:t.summaryRetries,hint:t.summaryRetriesHint,value:b.summaryRetries,min:0,max:5,onChange:e=>C({summaryRetries:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-min-tool-result-chars`,label:t.minToolResultKeepChars,hint:t.minToolResultKeepCharsHint,value:b.minToolResultKeepChars,min:200,step:100,onChange:e=>C({minToolResultKeepChars:Math.floor(e)})})]}),F?(0,Z.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:t.summaryBudgetWarning}):null,(0,Z.jsxs)(`div`,{className:`border-t border-edge pt-5`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.postCompactionSections}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.postCompactionSectionsHint}),b.postCompactionSections.length>0?(0,Z.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:b.postCompactionSections.map(e=>(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs text-fg`,children:[e,(0,Z.jsx)(`button`,{type:`button`,className:d(`text-fg-muted hover:text-fg`,m.press),"aria-label":t.removeSection.replace(`{{section}}`,e),onClick:()=>C({postCompactionSections:b.postCompactionSections.filter(t=>t!==e)}),children:(0,Z.jsx)(u,{className:`size-3.5`,"aria-hidden":!0})})]},e))}):(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.postCompactionSectionsEmpty}),(0,Z.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,Z.jsx)(`input`,{className:He(),value:p,maxLength:120,disabled:b.postCompactionSections.length>=12,placeholder:t.postCompactionSectionsPlaceholder,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),V())}}),(0,Z.jsxs)(f,{type:`button`,variant:`secondary`,disabled:!p.trim()||b.postCompactionSections.length>=12,onClick:V,children:[(0,Z.jsx)(c,{className:`size-4`,"aria-hidden":!0}),t.addSection]})]})]})]})})]})]})}function Je(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ye(e){return e===`main`||e===`per-peer`||e===`per-channel-peer`||e===`per-account-channel-peer`?e:`main`}function Xe(e){let t=Je(e)?e:{},n=Je(t.session)?t.session:{},r=Je(n.storage)?n.storage:{},i=typeof r.pruneAfterDays==`number`&&Number.isFinite(r.pruneAfterDays)?Math.max(0,Math.floor(r.pruneAfterDays)):typeof r.pruneAfterMs==`number`&&Number.isFinite(r.pruneAfterMs)?Math.max(0,Math.round(r.pruneAfterMs/864e5)):null,a=typeof r.maxEntries==`number`&&Number.isFinite(r.maxEntries)?Math.max(1,Math.floor(r.maxEntries)):null;return{dmScope:Ye(n.dmScope),pruneAfterDays:i,maxEntries:a}}async function Ze(e){await y(v(`/api/config`),{method:`PATCH`,body:JSON.stringify({session:{dmScope:e.dmScope,storage:{pruneAfterMs:e.pruneAfterDays===null?null:e.pruneAfterDays*864e5,maxEntries:e.maxEntries}}})}),O()}function Qe(){return d(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,p,`dark:border-edge`)}var $e=L();function et({hasToken:e}){let t=g(ee(e=>e.language)).sessions.config,{data:n,isLoading:r}=k(e),i=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:Xe(n.payload.config),[n]),[s,c]=(0,X.useReducer)($e,{form:null,baseline:null}),l=s.form,u=s.baseline,d=(0,X.useRef)(!1),f=(0,X.useRef)(l);f.current=l;let p=(0,X.useRef)(null);R({enabled:e,parsed:i,dirty:d.current,trackedParsedRef:p,dispatch:c,onResetDirty:()=>{d.current=!1}});let m=!!(l&&u&&JSON.stringify(l)!==JSON.stringify(u)),h=(0,X.useCallback)(e=>{d.current=!0,c({type:`patch`,patch:e})},[]),_=ye({value:l,dirty:m,onSave:(0,X.useCallback)(async e=>{try{await Ze(e),c({type:`saved`,value:e}),d.current=!!(f.current&&JSON.stringify(f.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])});return!e||!l?r?(0,Z.jsx)(Y,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(K,{className:`h-5 w-40`}),(0,Z.jsx)(K,{className:`h-24 w-full rounded-xl`})]})}):null:(0,Z.jsxs)(Y,{onBlurCapture:_.onBlurCapture,children:[(0,Z.jsx)(xe,{icon:fe,title:t.title,subtitle:t.hint,trailing:(0,Z.jsx)(ve,{status:_.status,error:_.error})}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.dmScope}),(0,Z.jsxs)(a,{className:Qe(),value:l.dmScope,onChange:e=>h({dmScope:e.target.value}),children:[(0,Z.jsx)(o,{value:`main`,children:t.dmScopeMain}),(0,Z.jsx)(o,{value:`per-peer`,children:t.dmScopePerPeer}),(0,Z.jsx)(o,{value:`per-channel-peer`,children:t.dmScopePerChannelPeer}),(0,Z.jsx)(o,{value:`per-account-channel-peer`,children:t.dmScopePerAccountChannelPeer})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.dmScopeHint})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.pruneAfterDays}),(0,Z.jsx)(`input`,{type:`number`,min:0,className:Qe(),value:l.pruneAfterDays??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();h({pruneAfterDays:t===``?null:Math.max(0,Math.floor(Number(t)||0))})}})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.maxEntries}),(0,Z.jsx)(`input`,{type:`number`,min:1,className:Qe(),value:l.maxEntries??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();h({maxEntries:t===``?null:Math.max(1,Math.floor(Number(t)||1))})}})]})]})]})}function tt(e){if(typeof e==`string`)return e.length>2e3?`${e.slice(0,2e3)}…`:e;try{let t=JSON.stringify(e,null,2);return t.length>2e3?`${t.slice(0,2e3)}…`:t}catch{return String(e)}}function nt(e){let t=(0,Ce.c)(60),{open:n,loading:r,session:i,sessionAgentId:a,sessionAgentAvatar:o,labels:s,onClose:c,onArchive:l,onUnarchive:p,onPin:m,onUnpin:h,onExport:g,onDelete:_}=e,ee=i?.status===`archived`,v=i?.status===`pinned`,y;t[0]===c?y=t[1]:(y=e=>!e&&c(),t[0]=c,t[1]=y);let D;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Z.jsx)(S,{className:d(`xopc-dialog-overlay fixed inset-0 bg-scrim`,x)}),t[2]=D):D=t[2];let O;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(O=d(`xopc-drawer-right fixed right-0 top-0 flex size-full max-w-lg flex-col border-l border-edge bg-surface-panel shadow-popover outline-none`,b,`dark:border-edge`),t[3]=O):O=t[3];let k;t[4]!==i||t[5]!==o||t[6]!==a?(k=i&&a?(0,Z.jsx)(q,{agentId:a,avatar:o,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}):null,t[4]=i,t[5]=o,t[6]=a,t[7]=k):k=t[7];let A;t[8]!==s.unnamedSession||t[9]!==i?.name?(A=i?.name?.trim()||s.unnamedSession,t[8]=s.unnamedSession,t[9]=i?.name,t[10]=A):A=t[10];let j;t[11]===A?j=t[12]:(j=(0,Z.jsx)(T,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:A}),t[11]=A,t[12]=j);let M;t[13]!==k||t[14]!==j?(M=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[k,j]}),t[13]=k,t[14]=j,t[15]=M):M=t[15];let N;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Z.jsx)(u,{className:`size-5`,strokeWidth:1.75}),t[16]=N):N=t[16];let P;t[17]===s.close?P=t[18]:(P=(0,Z.jsx)(C,{asChild:!0,children:(0,Z.jsx)(f,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":s.close,children:N})}),t[17]=s.close,t[18]=P);let F;t[19]!==M||t[20]!==P?(F=(0,Z.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3 dark:border-edge`,children:[M,P]}),t[19]=M,t[20]=P,t[21]=F):F=t[21];let I;t[22]!==s.detailLoading||t[23]!==s.detailMessages||t[24]!==r||t[25]!==i?(I=r?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:s.detailLoading}):i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`dl`,{className:`mb-4 grid gap-2 text-xs text-fg-muted`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-fg-disabled`,children:`Key`}),(0,Z.jsx)(`dd`,{className:`mt-0.5 break-all font-mono text-fg`,children:i.key})]}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-4`,children:(0,Z.jsxs)(`span`,{children:[i.messageCount,` msgs · `,i.estimatedTokens,` tok`]})})]}),(0,Z.jsx)(`h3`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:s.detailMessages}),(0,Z.jsx)(`ul`,{className:`space-y-3`,children:i.messages.map(rt)})]}):null,t[22]=s.detailLoading,t[23]=s.detailMessages,t[24]=r,t[25]=i,t[26]=I):I=t[26];let L;t[27]===I?L=t[28]:(L=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:I}),t[27]=I,t[28]=L);let R;t[29]!==s.detailExport||t[30]!==g?(R=(0,Z.jsx)(f,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:g,children:s.detailExport}),t[29]=s.detailExport,t[30]=g,t[31]=R):R=t[31];let z;t[32]!==ee||t[33]!==s.archive||t[34]!==s.unarchive||t[35]!==l||t[36]!==p?(z=ee?(0,Z.jsx)(f,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:p,children:s.unarchive}):(0,Z.jsx)(f,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:l,children:s.archive}),t[32]=ee,t[33]=s.archive,t[34]=s.unarchive,t[35]=l,t[36]=p,t[37]=z):z=t[37];let B;t[38]!==v||t[39]!==s.pin||t[40]!==s.unpin||t[41]!==m||t[42]!==h?(B=v?(0,Z.jsx)(f,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:h,children:s.unpin}):(0,Z.jsx)(f,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:m,children:s.pin}),t[38]=v,t[39]=s.pin,t[40]=s.unpin,t[41]=m,t[42]=h,t[43]=B):B=t[43];let V;t[44]!==s.delete||t[45]!==_?(V=(0,Z.jsx)(f,{type:`button`,variant:`secondary`,className:`text-sm text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`,onClick:_,children:s.delete}),t[44]=s.delete,t[45]=_,t[46]=V):V=t[46];let H;t[47]!==R||t[48]!==z||t[49]!==B||t[50]!==V?(H=(0,Z.jsx)(`div`,{className:`shrink-0 border-t border-edge px-4 py-3 dark:border-edge`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[R,z,B,V]})}),t[47]=R,t[48]=z,t[49]=B,t[50]=V,t[51]=H):H=t[51];let U;t[52]!==F||t[53]!==L||t[54]!==H?(U=(0,Z.jsxs)(te,{children:[D,(0,Z.jsxs)(w,{className:O,"aria-describedby":void 0,children:[F,L,H]})]}),t[52]=F,t[53]=L,t[54]=H,t[55]=U):U=t[55];let W;return t[56]!==n||t[57]!==y||t[58]!==U?(W=(0,Z.jsx)(E,{open:n,onOpenChange:y,children:U}),t[56]=n,t[57]=y,t[58]=U,t[59]=W):W=t[59],W}function rt(e){return(0,Z.jsxs)(`li`,{className:`rounded-lg border border-edge-subtle bg-surface-hover/50 p-2 dark:border-edge`,children:[(0,Z.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase text-fg-subtle`,children:e.role}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-fg-muted`,children:tt(e.content)})]},`${e.timestamp??``}-${e.role}-${tt(e.content).slice(0,24)}`)}var it=20;function at(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}var ot=new Set([`all`,`active`,`pinned`,`archived`]),st=new Set([`grid`,`list`]),ct=[`sessions`,`settings`];function lt(e){return e&&ct.includes(e)?e:`sessions`}function ut(e,t){return t===`sessions`?e.tabsSessions:e.tabsSettings}function dt(e,t){return t===`sessions`?e.tabsSessionsHint:e.tabsSettingsHint}function ft(e){let t=(0,Ce.c)(7),{s:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=ct.map(e=>({id:e,label:ut(n,e),icon:e===`sessions`?I:G})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==n.tabsAriaLabel?(s=(0,Z.jsx)(Se,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`sessions-tab`,panelIdPrefix:`sessions-panel`}),t[2]=r,t[3]=o,t[4]=i,t[5]=n.tabsAriaLabel,t[6]=s):s=t[6],s}function pt(e){let t=(0,Ce.c)(10),{s:n,id:r,activeTab:i,plain:a,children:o}=e,s=a===void 0?!1:a;if(i!==r)return null;let c=`sessions-panel-${r}`,l=`sessions-tab-${r}`,u=s?`contents`:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,d;t[0]!==o||t[1]!==r||t[2]!==s||t[3]!==n?(d=s?o:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`mb-5`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:ut(n,r)}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:dt(n,r)})]}),(0,Z.jsx)(`div`,{className:`space-y-4`,children:o})]}),t[0]=o,t[1]=r,t[2]=s,t[3]=n,t[4]=d):d=t[4];let f;return t[5]!==c||t[6]!==l||t[7]!==u||t[8]!==d?(f=(0,Z.jsx)(`section`,{id:c,role:`tabpanel`,"aria-labelledby":l,className:u,children:d}),t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f):f=t[9],f}function mt(e){let t=e.get(`status`),n=e.get(`view`);return{searchInput:e.get(`q`)??``,debouncedSearch:(e.get(`q`)??``).trim(),statusFilter:ot.has(t)?t:`all`,viewMode:st.has(n)?n:`grid`,channelFilter:(e.get(`channel`)??``).trim(),sessions:[],loading:!1,error:null,hasMore:!1,stats:null,detailOpen:!1,detailLoading:!1,detailSession:null,confirmOpen:!1,confirmKey:null}}function ht(){let e=g(ee(e=>e.language)),t=e.sessions,n=_(e=>e.token),r=!!n,{data:a,mutate:o}=D(r?[`gateway-chat-agents`,n]:null,ne,{revalidateOnFocus:!1}),s=a?.defaultId??`main`,c=a?.items??[],[u,p]=i(),h=lt(u.get(`tab`)),v=(0,X.useCallback)(e=>{let t=new URLSearchParams(u);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),p(t,{replace:!0})},[u,p]),[y,C]=(0,X.useReducer)(z,u,mt),{searchInput:O,debouncedSearch:k,statusFilter:A,viewMode:j,channelFilter:L,sessions:R,loading:G,error:K,hasMore:ie,stats:q,detailOpen:oe,detailLoading:ce,detailSession:J,confirmOpen:le,confirmKey:ue}=y;(0,X.useEffect)(()=>{let e=setTimeout(()=>{let e=O.trim();k!==e&&C({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[O,k]);let fe=u.toString(),_e=(0,X.useRef)(fe);if(_e.current!==fe){_e.current=fe;let e=u.get(`q`)??``,t=u.get(`status`),n=u.get(`view`),r=(u.get(`channel`)??``).trim(),i=ot.has(t)?t:`all`,a=st.has(n)?n:`grid`,o=e.trim();C({type:`patch`,patch:{...O===e?{}:{searchInput:e},...k===o?{}:{debouncedSearch:o},...A===i?{}:{statusFilter:i},...j===a?{}:{viewMode:a},...L===r?{}:{channelFilter:r}}})}(0,X.useEffect)(()=>{let e=new URLSearchParams(u),t=k.trim();t?e.set(`q`,t):e.delete(`q`),A===`all`?e.delete(`status`):e.set(`status`,A),j===`grid`?e.delete(`view`):e.set(`view`,j),L?e.set(`channel`,L):e.delete(`channel`),e.toString()!==u.toString()&&p(e,{replace:!0})},[k,u,p,A,j,L]),(0,X.useEffect)(()=>{if(!r||h!==`sessions`)return;let e=!1;return(async()=>{C({type:`patch`,patch:{loading:!0,error:null}});try{let t=await H({limit:it,offset:0,...k?{search:k}:{},...A===`all`?{}:{status:A},...L?{channel:L}:{}});if(e)return;C({type:`patch`,patch:{sessions:t.items,hasMore:t.hasMore}})}catch(n){e||C({type:`patch`,patch:{error:n instanceof Error?n.message:t.loadError}})}finally{e||C({type:`patch`,patch:{loading:!1}})}})(),()=>{e=!0}},[r,h,k,A,L,t.loadError]),(0,X.useEffect)(()=>{!r||h!==`sessions`||me().then(e=>C({type:`patch`,patch:{stats:e}})).catch(()=>{})},[r,h]),(0,X.useEffect)(()=>{if(!r||h!==`sessions`)return;let e=()=>void o();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[r,h,o]),(0,X.useEffect)(()=>{if(!r||h!==`sessions`)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||C({type:`patch`,patch:{sessions:R.map(e=>e.key===t.key?{...e,name:t.name}:e),detailSession:J&&J.key===t.key?{...J,name:t.name}:J}})};return window.addEventListener(`session-updated`,e),()=>{window.removeEventListener(`session-updated`,e)}},[r,h,R,J]);let ve=(0,X.useCallback)(async()=>{if(!(!r||G||!ie)){C({type:`patch`,patch:{loading:!0,error:null}});try{let e=await H({limit:it,offset:R.length,...k?{search:k}:{},...A===`all`?{}:{status:A},...L?{channel:L}:{}});C({type:`patch`,patch:{sessions:[...R,...e.items],hasMore:e.hasMore}})}catch(e){C({type:`patch`,patch:{error:e instanceof Error?e.message:t.loadError}})}finally{C({type:`patch`,patch:{loading:!1}})}}},[r,G,ie,R.length,k,A,L,t.loadError]),ye=(0,X.useCallback)((e,t)=>{C({type:`patch`,patch:{sessions:R.map(n=>n.key===e?{...n,status:t}:n),detailSession:J&&J.key===e?{...J,status:t}:J}})},[R,J]),be=(0,X.useCallback)(async e=>{C({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{C({type:`patch`,patch:{detailSession:await ae(e)}})}catch{C({type:`patch`,patch:{detailOpen:!1}})}finally{C({type:`patch`,patch:{detailLoading:!1}})}},[]),xe=e=>{be(e)},Y=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:e},bubbles:!0}));return}if(t===`delete`){C({type:`patch`,patch:{confirmKey:e,confirmOpen:!0}});return}try{switch(t){case`archive`:await re(e),ye(e,`archived`);break;case`unarchive`:await U(e),ye(e,`active`);break;case`pin`:await P(e),ye(e,`pinned`);break;case`unpin`:await F(e),ye(e,`active`);break;case`export`:{let t=await ge(e),n=new Blob([t],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`session-${e.replace(/[^a-z0-9]/gi,`_`)}.json`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r);break}default:break}me().then(e=>C({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Se=async e=>{try{await pe(e),C({type:`patch`,patch:{sessions:R.filter(t=>t.key!==e),detailSession:J?.key===e?null:J,...J?.key===e?{detailOpen:!1}:{}}}),me().then(e=>C({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Ce={continueChat:t.continueChat,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,export:t.export,delete:t.delete,unnamedSession:e.chat.newSession},we={close:t.close,detailLoading:t.detailLoading,detailMessages:t.detailMessages,detailExport:t.detailExport,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,delete:t.delete,unnamedSession:e.chat.newSession},Te=[{key:`all`,label:t.filterAll,icon:I},{key:`active`,label:t.filterActive,icon:he},{key:`pinned`,label:t.filterPinned,icon:se},{key:`archived`,label:t.filterArchived,icon:de}],De=(()=>{let e=Object.entries(q?.byChannel??{}).sort((e,t)=>t[1]-e[1]).slice(0,6).map(([e])=>e),t=new Set(e);for(let n of[`telegram`,`weixin`,`feishu`])t.has(n)||(e.push(n),t.add(n));return e.slice(0,8)})();return r?(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-surface-panel`,children:[(0,Z.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,Z.jsx)(`header`,{className:`flex flex-col gap-2`,children:(0,Z.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:t.title})}),(0,Z.jsx)(ft,{s:t,activeTab:h,onChange:v}),(0,Z.jsx)(pt,{s:t,id:`settings`,activeTab:h,plain:!0,children:(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(qe,{hasToken:r}),(0,Z.jsx)(et,{hasToken:r})]})}),(0,Z.jsxs)(pt,{s:t,id:`sessions`,activeTab:h,plain:!0,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Te.map(({key:e,label:t,icon:n})=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":A===e,onClick:()=>C({type:`patch`,patch:{statusFilter:e}}),className:d(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,m.transition,m.focusRingPanel,A===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[(0,Z.jsx)(n,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t]},e))}),(0,Z.jsxs)(`div`,{className:`flex w-full min-w-0 items-center gap-2 rounded-xl bg-surface-base px-3 py-2 transition-colors lg:max-w-md dark:bg-surface-hover/40`,children:[(0,Z.jsx)(l,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`input`,{type:`search`,value:O,onChange:e=>C({type:`patch`,patch:{searchInput:e.target.value}}),placeholder:t.searchPlaceholder,"data-debounced-query":k||void 0,className:`min-w-0 flex-1 border-0 bg-transparent text-sm text-fg placeholder:text-fg-disabled focus:outline-none focus:ring-0`})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg-subtle`,children:t.filterChannelLabel}),(0,Z.jsx)(`button`,{type:`button`,"aria-pressed":!L,onClick:()=>C({type:`patch`,patch:{channelFilter:``}}),className:d(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,m.transition,m.focusRingPanel,L?`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`:`bg-accent-soft text-accent-fg`),children:t.filterChannelAll}),De.map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":L===e,onClick:()=>C({type:`patch`,patch:{channelFilter:e}}),className:d(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,m.transition,m.focusRingPanel,L===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[e,q?.byChannel?.[e]==null?null:(0,Z.jsx)(`span`,{className:`ml-2 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] text-fg-subtle`,children:q.byChannel[e]})]},e))]}),q?(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[[q.totalSessions,t.totalSessions],[q.activeSessions,t.activeSessions],[q.pinnedSessions,t.pinnedSessions],[q.archivedSessions,t.archivedSessions]].map(([e,t])=>(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-base p-3 dark:bg-surface-hover/30`,children:[(0,Z.jsx)(`div`,{className:`text-lg font-semibold tabular-nums text-fg`,children:e}),(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:t})]},t))}):null,K?(0,Z.jsx)(`div`,{className:`rounded-lg border border-edge bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-edge dark:bg-red-950/40 dark:text-red-300`,children:K}):null,(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:at(t.sessionCount,{count:R.length})}),(0,Z.jsxs)(`div`,{className:W,role:`group`,"aria-label":t.layoutToggleGroup,children:[(0,Z.jsx)(f,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":j===`grid`,onClick:()=>C({type:`patch`,patch:{viewMode:`grid`}}),className:d(N,`size-7 p-0`,j===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,j===`grid`&&`text-accent-fg`),children:(0,Z.jsx)(V,{className:`size-3.5`,strokeWidth:1.5})}),(0,Z.jsx)(f,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":j===`list`,onClick:()=>C({type:`patch`,patch:{viewMode:`list`}}),className:d(N,`size-9 p-0`,j===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,j===`list`&&`text-accent-fg`),children:(0,Z.jsx)(B,{className:`size-3.5`,strokeWidth:1.5})})]})]}),G&&R.length===0?(0,Z.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,Z.jsx)(`div`,{className:`h-40 animate-pulse rounded-xl bg-surface-hover/60 dark:bg-surface-hover/40`},t))}):R.length===0?(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-2xl bg-surface-base py-16 text-center dark:bg-surface-hover/25`,children:[(0,Z.jsx)(M,{className:`mb-3 size-12 text-fg-disabled`,strokeWidth:1.25,"aria-hidden":!0}),(0,Z.jsx)(`p`,{className:`text-base font-semibold text-fg`,children:t.noSessions}),(0,Z.jsx)(`p`,{className:`mt-1 max-w-sm text-sm text-fg-muted`,children:t.noSessionsDescription}),(0,Z.jsx)(f,{variant:`primary`,className:`mt-6`,onClick:()=>{window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:``},bubbles:!0}))},children:t.startNewChat})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:d(`grid min-w-0 gap-3`,j===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":k||void 0,children:R.map(e=>{let t=Ae(e,s);return(0,Z.jsx)(Ee,{session:e,variant:j,labels:Ce,sessionAgentId:t,sessionAgentAvatar:je(t,c),onOpen:()=>xe(e.key),onAction:t=>void Y(e.key,t)},e.key)})}),ie?(0,Z.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Z.jsx)(f,{type:`button`,variant:`secondary`,disabled:G,onClick:()=>void ve(),children:t.loadMore})}):null]})]})]}),(0,Z.jsx)(nt,{open:oe,loading:ce,session:J,sessionAgentId:J?Ae(J,s):void 0,sessionAgentAvatar:J?je(Ae(J,s),c):void 0,labels:we,onClose:()=>{C({type:`patch`,patch:{detailOpen:!1,detailSession:null}})},onArchive:()=>J&&void Y(J.key,`archive`),onUnarchive:()=>J&&void Y(J.key,`unarchive`),onPin:()=>J&&void Y(J.key,`pin`),onUnpin:()=>J&&void Y(J.key,`unpin`),onExport:()=>J&&void Y(J.key,`export`),onDelete:()=>J&&C({type:`patch`,patch:{confirmKey:J.key,confirmOpen:!0}})}),(0,Z.jsx)(E,{open:le,onOpenChange:e=>C({type:`patch`,patch:{confirmOpen:e}}),children:(0,Z.jsxs)(te,{children:[(0,Z.jsx)(S,{className:d(`xopc-dialog-overlay fixed inset-0 bg-scrim`,x)}),(0,Z.jsxs)(w,{className:d(`xopc-dialog-content fixed left-1/2 top-1/2 w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`,b),children:[(0,Z.jsx)(T,{className:`text-base font-semibold text-fg`,children:t.deleteSessionTitle}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:ue?at(t.deleteSessionMessage,{name:R.find(e=>e.key===ue)?.name?.trim()||e.chat.newSession}):``}),(0,Z.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Z.jsx)(f,{type:`button`,variant:`secondary`,onClick:()=>C({type:`patch`,patch:{confirmOpen:!1}}),children:t.cancel}),(0,Z.jsx)(f,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{ue&&Se(ue),C({type:`patch`,patch:{confirmOpen:!1,confirmKey:null}})},children:t.delete})]})]})]})})]}):(0,Z.jsx)(`div`,{className:`w-full px-3 py-16 text-center text-sm text-fg-muted sm:px-5 xl:px-6`,children:t.needToken})}export{ht as SessionsPage};
@@ -1 +0,0 @@
1
- import{wr as e}from"./index-wnDPGRTi.js";function t(t){let{children:n,fallback:r}=t,i=r===void 0?null:r;return e()?n:i}export{t};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{p as i}from"./chunk-KS7C4IRE-BaASWQor.js";import{t as a}from"./check-DUBLcKHA.js";import{n as o,r as s}from"./popover-select-CccGri5Y.js";import{t as c}from"./copy-Dv6d4Dvw.js";import{t as l}from"./loader-circle-CifKLtgG.js";import{t as u}from"./plus-Q2yW6OE7.js";import{t as d}from"./x-B_N4OPjy.js";import{t as f}from"./cn-JdwAhgNB.js";import{t as p}from"./button-CSEbl4zT.js";import{s as m}from"./form-field-width-DJw_jULe.js";import{t as h}from"./copy-to-clipboard-HOJ79TWv.js";import{t as g}from"./messages-B82nsi9k.js";import{l as _,n as v,r as y,s as b}from"./locale-store-CPylQjH9.js";import{a as x,n as S,o as ee,r as C,s as w,t as te}from"./dist-BPoKqzeH.js";import{i as ne}from"./vendor-swr-BIWyz7Rc.js";import{n as T,r as E}from"./gateway-config-swr-yUxMMVjK.js";import{$c as re,Es as D,Gi as O,Hi as k,Ji as A,Ki as j,Li as M,Pl as N,Qi as P,Wi as ie,Xa as ae,Xi as F,Yi as I,Zi as L,_l as oe,al as R,ma as se,or as ce,pr as le,qi as ue,qs as de,ys as z,zi as B}from"./index-wnDPGRTi.js";import{n as V,r as fe,t as H}from"./settings-page-layout-BRQNel6r.js";import{t as pe}from"./settings-loading-skeleton-DS6lcAg9.js";import{t as me}from"./settings-form-section-CZlMvHA9.js";import{t as U}from"./page-tabs-BaEQMYm_.js";var W=e(t(),1),he=n(),G={enabled:!0,defaultTtlHours:24,maxTtlDays:30,maxActiveShares:500,maxFileSizeMb:500,directoryMaxFolderSizeMb:2048,directoryMaxFileCount:1e4,inlinePreviewMimes:[`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`image/svg+xml`,`application/pdf`,`text/html`,`text/markdown`,`text/plain`,`application/json`],noteEnabled:!0,noteMaxTotalSizeMb:250,noteMaxAttachmentCount:50,siteEnabled:!0,siteDefaultTtlHours:24,siteMaxTtlDays:30,maxActiveSites:50,siteMaxRootDirSizeMb:1024,siteMaxFileCount:2e4};function ge(){return structuredClone(G)}var K=36e5,q=864e5,J=1048576;function Y(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function _e(e,t=32){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()).slice(0,t):[]}function ve(e){let t=Y(e)?e:{},n=Y(t.gateway)?t.gateway:{},r=Y(n.share)?n.share:{},i=Y(r.directory)?r.directory:{},a=Y(r.note)?r.note:{},o=Y(n.siteShare)?n.siteShare:{},s=Y(o.static)?o.static:{},c=typeof r.defaultTtlMs==`number`&&Number.isFinite(r.defaultTtlMs)?Math.floor(r.defaultTtlMs):G.defaultTtlHours*K,l=typeof r.maxTtlMs==`number`&&Number.isFinite(r.maxTtlMs)?Math.floor(r.maxTtlMs):G.maxTtlDays*q,u=typeof r.maxFileSize==`number`&&Number.isFinite(r.maxFileSize)?Math.floor(r.maxFileSize):G.maxFileSizeMb*J,d=typeof i.maxFolderSize==`number`&&Number.isFinite(i.maxFolderSize)?Math.floor(i.maxFolderSize):G.directoryMaxFolderSizeMb*J,f=typeof o.defaultTtlMs==`number`&&Number.isFinite(o.defaultTtlMs)?Math.floor(o.defaultTtlMs):G.siteDefaultTtlHours*K,p=typeof o.maxTtlMs==`number`&&Number.isFinite(o.maxTtlMs)?Math.floor(o.maxTtlMs):G.siteMaxTtlDays*q,m=typeof s.maxRootDirSize==`number`&&Number.isFinite(s.maxRootDirSize)?Math.floor(s.maxRootDirSize):G.siteMaxRootDirSizeMb*J,h=typeof a.maxTotalSize==`number`&&Number.isFinite(a.maxTotalSize)?Math.floor(a.maxTotalSize):G.noteMaxTotalSizeMb*J;return{enabled:r.enabled!==!1,defaultTtlHours:Math.max(1,Math.round(c/K)),maxTtlDays:Math.max(1,Math.round(l/q)),maxActiveShares:typeof r.maxActiveShares==`number`&&Number.isFinite(r.maxActiveShares)?Math.max(1,Math.min(1e4,Math.floor(r.maxActiveShares))):G.maxActiveShares,maxFileSizeMb:Math.max(1,Math.round(u/J)),directoryMaxFolderSizeMb:Math.max(1,Math.round(d/J)),directoryMaxFileCount:typeof i.maxFileCount==`number`&&Number.isFinite(i.maxFileCount)?Math.max(1,Math.min(1e5,Math.floor(i.maxFileCount))):G.directoryMaxFileCount,inlinePreviewMimes:_e(r.inlinePreviewMimes,32).length?_e(r.inlinePreviewMimes,32):[...G.inlinePreviewMimes],noteEnabled:a.enabled!==!1,noteMaxTotalSizeMb:Math.max(1,Math.round(h/J)),noteMaxAttachmentCount:typeof a.maxAttachmentCount==`number`&&Number.isFinite(a.maxAttachmentCount)?Math.max(0,Math.min(500,Math.floor(a.maxAttachmentCount))):G.noteMaxAttachmentCount,siteEnabled:o.enabled!==!1,siteDefaultTtlHours:Math.max(1,Math.round(f/K)),siteMaxTtlDays:Math.max(1,Math.round(p/q)),maxActiveSites:typeof o.maxActiveSites==`number`&&Number.isFinite(o.maxActiveSites)?Math.max(1,Math.min(1e3,Math.floor(o.maxActiveSites))):G.maxActiveSites,siteMaxRootDirSizeMb:Math.max(1,Math.round(m/J)),siteMaxFileCount:typeof s.maxFileCount==`number`&&Number.isFinite(s.maxFileCount)?Math.max(1,Math.min(1e5,Math.floor(s.maxFileCount))):G.siteMaxFileCount}}function ye(e){let t=e.defaultTtlHours*K,n=e.maxTtlDays*q,r=e.siteDefaultTtlHours*K,i=e.siteMaxTtlDays*q;return t<6e4||t>6048e5?`Default share TTL must be between 1 minute and 7 days.`:n<6e4||n>2592e6?`Maximum share TTL must be between 1 minute and 30 days.`:t>n?`Default TTL cannot exceed maximum TTL.`:e.maxActiveShares<1||e.maxActiveShares>1e4?`Maximum active shares must be between 1 and 10,000.`:e.maxActiveSites<1||e.maxActiveSites>1e3?`Maximum active site shares must be between 1 and 1,000.`:e.maxFileSizeMb<1||e.maxFileSizeMb>10240?`Maximum file size must be between 1 MB and 10 GB.`:e.directoryMaxFolderSizeMb<1||e.directoryMaxFolderSizeMb>10240?`Maximum folder size must be between 1 MB and 10 GB.`:e.directoryMaxFileCount<1||e.directoryMaxFileCount>1e5?`Maximum directory file count must be between 1 and 100,000.`:e.noteMaxTotalSizeMb<1||e.noteMaxTotalSizeMb>2048?`Maximum Note snapshot size must be between 1 MB and 2 GB.`:e.noteMaxAttachmentCount<0||e.noteMaxAttachmentCount>500?`Maximum Note attachment count must be between 0 and 500.`:r<6e4||r>6048e5?`Default site share TTL must be between 1 minute and 7 days.`:i<6e4||i>2592e6?`Maximum site share TTL must be between 1 minute and 30 days.`:r>i?`Default site TTL cannot exceed maximum site TTL.`:e.siteMaxRootDirSizeMb<1||e.siteMaxRootDirSizeMb>10240?`Maximum static site size must be between 1 MB and 10 GB.`:e.siteMaxFileCount<1||e.siteMaxFileCount>1e5?`Maximum static site file count must be between 1 and 100,000.`:null}async function X(e){let t=ye(e);if(t)throw Error(t);await b(y(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{share:{enabled:e.enabled,defaultTtlMs:e.defaultTtlHours*K,maxTtlMs:e.maxTtlDays*q,maxActiveShares:e.maxActiveShares,maxFileSize:e.maxFileSizeMb*J,inlinePreviewMimes:e.inlinePreviewMimes,directory:{maxFolderSize:e.directoryMaxFolderSizeMb*J,maxFileCount:e.directoryMaxFileCount},note:{enabled:e.noteEnabled,maxTotalSize:e.noteMaxTotalSizeMb*J,maxAttachmentCount:e.noteMaxAttachmentCount}},siteShare:{enabled:e.siteEnabled,defaultTtlMs:e.siteDefaultTtlHours*K,maxTtlMs:e.siteMaxTtlDays*q,maxActiveSites:e.maxActiveSites,static:{maxRootDirSize:e.siteMaxRootDirSizeMb*J,maxFileCount:e.siteMaxFileCount}}}})}),T()}var Z=r();function Q(){return f(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,m,`dark:border-edge`)}function be({hasToken:e}){let t=g(v(e=>e.language)).sharesSettings,{data:n,isLoading:r}=E(e),i=(0,W.useMemo)(()=>n?.payload?.config===void 0?null:structuredClone(ve(n.payload.config)),[n]),a=(0,W.useRef)(!1),[o,s]=(0,W.useState)(null),[c,l]=(0,W.useState)(!1),[u,d]=(0,W.useState)(null),[f,m]=(0,W.useState)(!1),h=o??i,_=i,y=(0,W.useMemo)(()=>!h||!_?!1:JSON.stringify(h)!==JSON.stringify(_),[h,_]),b=(0,W.useCallback)(e=>{a.current=!0,s(t=>{let n=t??_;return n?{...n,...e}:null})},[_]),x=(0,W.useCallback)(async()=>{if(!(!h||c)){l(!0),d(null),m(!1);try{await X(h),a.current=!1,s(null),m(!0),window.setTimeout(()=>m(!1),2500)}catch(e){d(e instanceof Error?e.message:t.policySaveError)}finally{l(!1)}}},[h,c,t.policySaveError]),S=(0,W.useCallback)(()=>{a.current=!1,s(null),d(null),m(!1)},[]);return!e||!h?r?(0,Z.jsx)(me,{children:(0,Z.jsx)(pe,{rows:2})}):null:(0,Z.jsxs)(me,{children:[(0,Z.jsxs)(`div`,{className:`mb-4 flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.policyTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:t.policyHint})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[f?(0,Z.jsx)(`span`,{className:`text-sm text-fg-muted`,children:t.policySaved}):null,(0,Z.jsx)(p,{type:`button`,variant:`secondary`,disabled:c,onClick:()=>b(ge()),children:t.policyUseRecommended}),(0,Z.jsx)(p,{type:`button`,variant:`secondary`,disabled:!y||c,onClick:S,children:t.policyDiscard}),(0,Z.jsx)(p,{type:`button`,variant:`primary`,disabled:!y||c,onClick:()=>void x(),children:c?t.policySaving:t.policySave})]})]}),y?(0,Z.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:t.policyUnsaved}):null,u?(0,Z.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:u}):null,(0,Z.jsx)(`p`,{className:`mb-4 text-xs text-fg-subtle`,children:t.policyRestartHint}),(0,Z.jsx)(xe,{t,form:h,onChange:b})]})}function xe(e){let t=(0,he.c)(189),{t:n,form:r,onChange:i}=e,a;t[0]===n.policyFileSection?a=t[1]:(a=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.policyFileSection}),t[0]=n.policyFileSection,t[1]=a);let o;t[2]===n.policyFileSectionHint?o=t[3]:(o=(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.policyFileSectionHint}),t[2]=n.policyFileSectionHint,t[3]=o);let s;t[4]!==a||t[5]!==o?(s=(0,Z.jsxs)(`div`,{className:`mb-4`,children:[a,o]}),t[4]=a,t[5]=o,t[6]=s):s=t[6];let c;t[7]===i?c=t[8]:(c=e=>i({enabled:e.target.checked}),t[7]=i,t[8]=c);let l;t[9]!==r.enabled||t[10]!==c?(l=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.enabled,onChange:c}),t[9]=r.enabled,t[10]=c,t[11]=l):l=t[11];let u;t[12]!==n.policyEnabled||t[13]!==l?(u=(0,Z.jsxs)(`label`,{className:`mb-4 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[l,n.policyEnabled]}),t[12]=n.policyEnabled,t[13]=l,t[14]=u):u=t[14];let d=!r.enabled,f;t[15]===i?f=t[16]:(f=e=>i({defaultTtlHours:e}),t[15]=i,t[16]=f);let p;t[17]!==r.defaultTtlHours||t[18]!==n.policyDefaultTtlHint||t[19]!==n.policyDefaultTtlHours||t[20]!==d||t[21]!==f?(p=(0,Z.jsx)($,{id:`share-default-ttl-hours`,label:n.policyDefaultTtlHours,hint:n.policyDefaultTtlHint,value:r.defaultTtlHours,min:1,max:168,disabled:d,onChange:f}),t[17]=r.defaultTtlHours,t[18]=n.policyDefaultTtlHint,t[19]=n.policyDefaultTtlHours,t[20]=d,t[21]=f,t[22]=p):p=t[22];let m=!r.enabled,h;t[23]===i?h=t[24]:(h=e=>i({maxTtlDays:e}),t[23]=i,t[24]=h);let g;t[25]!==r.maxTtlDays||t[26]!==n.policyMaxTtlDays||t[27]!==n.policyMaxTtlHint||t[28]!==m||t[29]!==h?(g=(0,Z.jsx)($,{id:`share-max-ttl-days`,label:n.policyMaxTtlDays,hint:n.policyMaxTtlHint,value:r.maxTtlDays,min:1,max:30,disabled:m,onChange:h}),t[25]=r.maxTtlDays,t[26]=n.policyMaxTtlDays,t[27]=n.policyMaxTtlHint,t[28]=m,t[29]=h,t[30]=g):g=t[30];let _=!r.enabled,v;t[31]===i?v=t[32]:(v=e=>i({maxActiveShares:e}),t[31]=i,t[32]=v);let y;t[33]!==r.maxActiveShares||t[34]!==n.policyMaxActiveShares||t[35]!==n.policyMaxActiveSharesHint||t[36]!==_||t[37]!==v?(y=(0,Z.jsx)($,{id:`share-max-active`,label:n.policyMaxActiveShares,hint:n.policyMaxActiveSharesHint,value:r.maxActiveShares,min:1,max:1e4,disabled:_,onChange:v}),t[33]=r.maxActiveShares,t[34]=n.policyMaxActiveShares,t[35]=n.policyMaxActiveSharesHint,t[36]=_,t[37]=v,t[38]=y):y=t[38];let b=!r.enabled,x;t[39]===i?x=t[40]:(x=e=>i({maxFileSizeMb:e}),t[39]=i,t[40]=x);let S;t[41]!==r.maxFileSizeMb||t[42]!==n.policyMaxFileSizeHint||t[43]!==n.policyMaxFileSizeMb||t[44]!==b||t[45]!==x?(S=(0,Z.jsx)($,{id:`share-max-file-mb`,label:n.policyMaxFileSizeMb,hint:n.policyMaxFileSizeHint,value:r.maxFileSizeMb,min:1,max:10240,disabled:b,onChange:x}),t[41]=r.maxFileSizeMb,t[42]=n.policyMaxFileSizeHint,t[43]=n.policyMaxFileSizeMb,t[44]=b,t[45]=x,t[46]=S):S=t[46];let ee=!r.enabled,C;t[47]===i?C=t[48]:(C=e=>i({directoryMaxFolderSizeMb:e}),t[47]=i,t[48]=C);let w;t[49]!==r.directoryMaxFolderSizeMb||t[50]!==n.policyDirectoryMaxFolderSizeHint||t[51]!==n.policyDirectoryMaxFolderSizeMb||t[52]!==ee||t[53]!==C?(w=(0,Z.jsx)($,{id:`share-directory-max-size-mb`,label:n.policyDirectoryMaxFolderSizeMb,hint:n.policyDirectoryMaxFolderSizeHint,value:r.directoryMaxFolderSizeMb,min:1,max:10240,disabled:ee,onChange:C}),t[49]=r.directoryMaxFolderSizeMb,t[50]=n.policyDirectoryMaxFolderSizeHint,t[51]=n.policyDirectoryMaxFolderSizeMb,t[52]=ee,t[53]=C,t[54]=w):w=t[54];let te=!r.enabled,ne;t[55]===i?ne=t[56]:(ne=e=>i({directoryMaxFileCount:e}),t[55]=i,t[56]=ne);let T;t[57]!==r.directoryMaxFileCount||t[58]!==n.policyDirectoryMaxFileCount||t[59]!==n.policyDirectoryMaxFileCountHint||t[60]!==te||t[61]!==ne?(T=(0,Z.jsx)($,{id:`share-directory-max-files`,label:n.policyDirectoryMaxFileCount,hint:n.policyDirectoryMaxFileCountHint,value:r.directoryMaxFileCount,min:1,max:1e5,disabled:te,onChange:ne}),t[57]=r.directoryMaxFileCount,t[58]=n.policyDirectoryMaxFileCount,t[59]=n.policyDirectoryMaxFileCountHint,t[60]=te,t[61]=ne,t[62]=T):T=t[62];let E;t[63]!==g||t[64]!==y||t[65]!==S||t[66]!==w||t[67]!==T||t[68]!==p?(E=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[p,g,y,S,w,T]}),t[63]=g,t[64]=y,t[65]=S,t[66]=w,t[67]=T,t[68]=p,t[69]=E):E=t[69];let re=!r.enabled,D;t[70]===i?D=t[71]:(D=e=>i({inlinePreviewMimes:e}),t[70]=i,t[71]=D);let O;t[72]!==r.inlinePreviewMimes||t[73]!==n||t[74]!==re||t[75]!==D?(O=(0,Z.jsx)(Se,{t:n,values:r.inlinePreviewMimes,disabled:re,onChange:D}),t[72]=r.inlinePreviewMimes,t[73]=n,t[74]=re,t[75]=D,t[76]=O):O=t[76];let k;t[77]!==E||t[78]!==O||t[79]!==s||t[80]!==u?(k=(0,Z.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-muted/25 p-4`,children:[s,u,E,O]}),t[77]=E,t[78]=O,t[79]=s,t[80]=u,t[81]=k):k=t[81];let A;t[82]===n.policyNoteSection?A=t[83]:(A=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.policyNoteSection}),t[82]=n.policyNoteSection,t[83]=A);let j;t[84]===n.policyNoteSectionHint?j=t[85]:(j=(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.policyNoteSectionHint}),t[84]=n.policyNoteSectionHint,t[85]=j);let M;t[86]!==A||t[87]!==j?(M=(0,Z.jsxs)(`div`,{className:`mb-4`,children:[A,j]}),t[86]=A,t[87]=j,t[88]=M):M=t[88];let N;t[89]===i?N=t[90]:(N=e=>i({noteEnabled:e.target.checked}),t[89]=i,t[90]=N);let P;t[91]!==r.noteEnabled||t[92]!==N?(P=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.noteEnabled,onChange:N}),t[91]=r.noteEnabled,t[92]=N,t[93]=P):P=t[93];let ie;t[94]!==n.policyNoteEnabled||t[95]!==P?(ie=(0,Z.jsxs)(`label`,{className:`mb-4 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[P,n.policyNoteEnabled]}),t[94]=n.policyNoteEnabled,t[95]=P,t[96]=ie):ie=t[96];let ae=!r.enabled||!r.noteEnabled,F;t[97]===i?F=t[98]:(F=e=>i({noteMaxTotalSizeMb:e}),t[97]=i,t[98]=F);let I;t[99]!==r.noteMaxTotalSizeMb||t[100]!==n.policyNoteMaxTotalSizeHint||t[101]!==n.policyNoteMaxTotalSizeMb||t[102]!==ae||t[103]!==F?(I=(0,Z.jsx)($,{id:`share-note-max-size-mb`,label:n.policyNoteMaxTotalSizeMb,hint:n.policyNoteMaxTotalSizeHint,value:r.noteMaxTotalSizeMb,min:1,max:2048,disabled:ae,onChange:F}),t[99]=r.noteMaxTotalSizeMb,t[100]=n.policyNoteMaxTotalSizeHint,t[101]=n.policyNoteMaxTotalSizeMb,t[102]=ae,t[103]=F,t[104]=I):I=t[104];let L=!r.enabled||!r.noteEnabled,oe;t[105]===i?oe=t[106]:(oe=e=>i({noteMaxAttachmentCount:e}),t[105]=i,t[106]=oe);let R;t[107]!==r.noteMaxAttachmentCount||t[108]!==n.policyNoteMaxAttachmentCount||t[109]!==n.policyNoteMaxAttachmentCountHint||t[110]!==L||t[111]!==oe?(R=(0,Z.jsx)($,{id:`share-note-max-attachments`,label:n.policyNoteMaxAttachmentCount,hint:n.policyNoteMaxAttachmentCountHint,value:r.noteMaxAttachmentCount,min:0,max:500,disabled:L,onChange:oe}),t[107]=r.noteMaxAttachmentCount,t[108]=n.policyNoteMaxAttachmentCount,t[109]=n.policyNoteMaxAttachmentCountHint,t[110]=L,t[111]=oe,t[112]=R):R=t[112];let se;t[113]!==I||t[114]!==R?(se=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[I,R]}),t[113]=I,t[114]=R,t[115]=se):se=t[115];let ce;t[116]!==M||t[117]!==ie||t[118]!==se?(ce=(0,Z.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-muted/25 p-4`,children:[M,ie,se]}),t[116]=M,t[117]=ie,t[118]=se,t[119]=ce):ce=t[119];let le;t[120]===n.policySiteSection?le=t[121]:(le=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.policySiteSection}),t[120]=n.policySiteSection,t[121]=le);let ue;t[122]===n.policySiteSectionHint?ue=t[123]:(ue=(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.policySiteSectionHint}),t[122]=n.policySiteSectionHint,t[123]=ue);let de;t[124]!==le||t[125]!==ue?(de=(0,Z.jsxs)(`div`,{className:`mb-4`,children:[le,ue]}),t[124]=le,t[125]=ue,t[126]=de):de=t[126];let z;t[127]===i?z=t[128]:(z=e=>i({siteEnabled:e.target.checked}),t[127]=i,t[128]=z);let B;t[129]!==r.siteEnabled||t[130]!==z?(B=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.siteEnabled,onChange:z}),t[129]=r.siteEnabled,t[130]=z,t[131]=B):B=t[131];let V;t[132]!==n.policySiteEnabled||t[133]!==B?(V=(0,Z.jsxs)(`label`,{className:`mb-4 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[B,n.policySiteEnabled]}),t[132]=n.policySiteEnabled,t[133]=B,t[134]=V):V=t[134];let fe=!r.siteEnabled,H;t[135]===i?H=t[136]:(H=e=>i({siteDefaultTtlHours:e}),t[135]=i,t[136]=H);let pe;t[137]!==r.siteDefaultTtlHours||t[138]!==n.policySiteDefaultTtlHint||t[139]!==n.policySiteDefaultTtlHours||t[140]!==fe||t[141]!==H?(pe=(0,Z.jsx)($,{id:`site-share-default-ttl-hours`,label:n.policySiteDefaultTtlHours,hint:n.policySiteDefaultTtlHint,value:r.siteDefaultTtlHours,min:1,max:168,disabled:fe,onChange:H}),t[137]=r.siteDefaultTtlHours,t[138]=n.policySiteDefaultTtlHint,t[139]=n.policySiteDefaultTtlHours,t[140]=fe,t[141]=H,t[142]=pe):pe=t[142];let me=!r.siteEnabled,U;t[143]===i?U=t[144]:(U=e=>i({siteMaxTtlDays:e}),t[143]=i,t[144]=U);let W;t[145]!==r.siteMaxTtlDays||t[146]!==n.policySiteMaxTtlDays||t[147]!==n.policySiteMaxTtlHint||t[148]!==me||t[149]!==U?(W=(0,Z.jsx)($,{id:`site-share-max-ttl-days`,label:n.policySiteMaxTtlDays,hint:n.policySiteMaxTtlHint,value:r.siteMaxTtlDays,min:1,max:30,disabled:me,onChange:U}),t[145]=r.siteMaxTtlDays,t[146]=n.policySiteMaxTtlDays,t[147]=n.policySiteMaxTtlHint,t[148]=me,t[149]=U,t[150]=W):W=t[150];let G=!r.siteEnabled,ge;t[151]===i?ge=t[152]:(ge=e=>i({maxActiveSites:e}),t[151]=i,t[152]=ge);let K;t[153]!==r.maxActiveSites||t[154]!==n.policyMaxActiveSites||t[155]!==n.policyMaxActiveSitesHint||t[156]!==G||t[157]!==ge?(K=(0,Z.jsx)($,{id:`site-share-max-active`,label:n.policyMaxActiveSites,hint:n.policyMaxActiveSitesHint,value:r.maxActiveSites,min:1,max:1e3,disabled:G,onChange:ge}),t[153]=r.maxActiveSites,t[154]=n.policyMaxActiveSites,t[155]=n.policyMaxActiveSitesHint,t[156]=G,t[157]=ge,t[158]=K):K=t[158];let q=!r.siteEnabled,J;t[159]===i?J=t[160]:(J=e=>i({siteMaxRootDirSizeMb:e}),t[159]=i,t[160]=J);let Y;t[161]!==r.siteMaxRootDirSizeMb||t[162]!==n.policySiteMaxRootDirSizeHint||t[163]!==n.policySiteMaxRootDirSizeMb||t[164]!==q||t[165]!==J?(Y=(0,Z.jsx)($,{id:`site-share-max-root-size-mb`,label:n.policySiteMaxRootDirSizeMb,hint:n.policySiteMaxRootDirSizeHint,value:r.siteMaxRootDirSizeMb,min:1,max:10240,disabled:q,onChange:J}),t[161]=r.siteMaxRootDirSizeMb,t[162]=n.policySiteMaxRootDirSizeHint,t[163]=n.policySiteMaxRootDirSizeMb,t[164]=q,t[165]=J,t[166]=Y):Y=t[166];let _e=!r.siteEnabled,ve;t[167]===i?ve=t[168]:(ve=e=>i({siteMaxFileCount:e}),t[167]=i,t[168]=ve);let ye;t[169]!==r.siteMaxFileCount||t[170]!==n.policySiteMaxFileCount||t[171]!==n.policySiteMaxFileCountHint||t[172]!==_e||t[173]!==ve?(ye=(0,Z.jsx)($,{id:`site-share-max-files`,label:n.policySiteMaxFileCount,hint:n.policySiteMaxFileCountHint,value:r.siteMaxFileCount,min:1,max:1e5,disabled:_e,onChange:ve}),t[169]=r.siteMaxFileCount,t[170]=n.policySiteMaxFileCount,t[171]=n.policySiteMaxFileCountHint,t[172]=_e,t[173]=ve,t[174]=ye):ye=t[174];let X;t[175]!==pe||t[176]!==W||t[177]!==K||t[178]!==Y||t[179]!==ye?(X=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[pe,W,K,Y,ye]}),t[175]=pe,t[176]=W,t[177]=K,t[178]=Y,t[179]=ye,t[180]=X):X=t[180];let Q;t[181]!==de||t[182]!==V||t[183]!==X?(Q=(0,Z.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-muted/25 p-4`,children:[de,V,X]}),t[181]=de,t[182]=V,t[183]=X,t[184]=Q):Q=t[184];let be;return t[185]!==k||t[186]!==ce||t[187]!==Q?(be=(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[k,ce,Q]}),t[185]=k,t[186]=ce,t[187]=Q,t[188]=be):be=t[188],be}function $(e){let t=(0,he.c)(21),{id:n,label:r,hint:i,value:a,min:o,max:s,disabled:c,onChange:l}=e,u;t[0]!==n||t[1]!==r?(u=(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=u):u=t[2];let d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=f(Q(),`max-w-xs font-mono text-xs`),t[3]=d):d=t[3];let p;t[4]!==s||t[5]!==o||t[6]!==l?(p=e=>{let t=Number(e.target.value);Number.isFinite(t)&&l(Math.max(o,Math.min(s,Math.floor(t))))},t[4]=s,t[5]=o,t[6]=l,t[7]=p):p=t[7];let m;t[8]!==c||t[9]!==n||t[10]!==s||t[11]!==o||t[12]!==p||t[13]!==a?(m=(0,Z.jsx)(`input`,{id:n,type:`number`,min:o,max:s,disabled:c,className:d,value:a,onChange:p}),t[8]=c,t[9]=n,t[10]=s,t[11]=o,t[12]=p,t[13]=a,t[14]=m):m=t[14];let h;t[15]===i?h=t[16]:(h=(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}),t[15]=i,t[16]=h);let g;return t[17]!==u||t[18]!==m||t[19]!==h?(g=(0,Z.jsxs)(`div`,{children:[u,m,h]}),t[17]=u,t[18]=m,t[19]=h,t[20]=g):g=t[20],g}function Se(e){let t=(0,he.c)(25),{t:n,values:r,disabled:i,onChange:a}=e,o;t[0]!==a||t[1]!==r?(o=e=>{let t=e.trim();!t||r.includes(t)||r.length>=32||a([...r,t])},t[0]=a,t[1]=r,t[2]=o):o=t[2];let s=o,c;t[3]===n.policyInlinePreviewMimes?c=t[4]:(c=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.policyInlinePreviewMimes}),t[3]=n.policyInlinePreviewMimes,t[4]=c);let l;t[5]===n.policyInlinePreviewMimesHint?l=t[6]:(l=(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.policyInlinePreviewMimesHint}),t[5]=n.policyInlinePreviewMimesHint,t[6]=l);let u;t[7]!==i||t[8]!==a||t[9]!==r?(u=r.map(e=>(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-0.5 font-mono text-xs text-fg`,children:[e,i?null:(0,Z.jsx)(`button`,{type:`button`,className:`text-fg-muted hover:text-fg`,"aria-label":`Remove ${e}`,onClick:()=>a(r.filter(t=>t!==e)),children:`×`})]},e)),t[7]=i,t[8]=a,t[9]=r,t[10]=u):u=t[10];let d;t[11]===u?d=t[12]:(d=(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:u}),t[11]=u,t[12]=d);let p;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(p=f(Q(),`font-mono text-xs`),t[13]=p):p=t[13];let m=i||r.length>=32,h;t[14]===s?h=t[15]:(h=e=>{e.key===`Enter`&&(e.preventDefault(),s(e.target.value),e.target.value=``)},t[14]=s,t[15]=h);let g;t[16]!==n.policyMimePlaceholder||t[17]!==m||t[18]!==h?(g=(0,Z.jsx)(`input`,{className:p,placeholder:n.policyMimePlaceholder,disabled:m,onKeyDown:h}),t[16]=n.policyMimePlaceholder,t[17]=m,t[18]=h,t[19]=g):g=t[19];let _;return t[20]!==c||t[21]!==l||t[22]!==d||t[23]!==g?(_=(0,Z.jsxs)(`div`,{className:`space-y-2 border-t border-edge pt-4`,children:[c,l,d,g]}),t[20]=c,t[21]=l,t[22]=d,t[23]=g,t[24]=_):_=t[24],_}function Ce(e){let t=(0,he.c)(70),{open:n,onOpenChange:r,onConfirm:i,initialPath:a,selectKind:c,sessionKey:u,agentId:m}=e,h=c===void 0?`any`:c,y=g(v(Ee)),b=y.workspace,T=y.sharesSettings,E=k(Te),{data:D}=ne(_(we)?`picker-agents-list`:null,le),O;bb0:{let e;t[0]===m?e=t[1]:(e=m?.trim(),t[0]=m,t[1]=e);let n=e;if(n){O=n;break bb0}let r;t[2]===E?r=t[3]:(r=E.trim(),t[2]=E,t[3]=r);let i=r;if(i){O=i;break bb0}if(D?.defaultId){O=D.defaultId;break bb0}if(D?.agents?.[0]?.id){O=D.agents[0].id;break bb0}O=``}let A=O,[j,M]=(0,W.useState)(A),N,P;t[4]===A?(N=t[5],P=t[6]):(N=()=>{M(A)},P=[A],t[4]=A,t[5]=N,t[6]=P),(0,W.useEffect)(N,P);let{tree:ae,loading:F,error:I,loadRoot:L,loadChildren:oe,reset:R}=ie(j,u??null),ue;t[7]===a?ue=t[8]:(ue=a?{path:a,isDirectory:!1}:null,t[7]=a,t[8]=ue);let[z,B]=(0,W.useState)(ue),V;t[9]!==a||t[10]!==L||t[11]!==n||t[12]!==R||t[13]!==B?(V=()=>{if(!n){R(),B(a?{path:a,isDirectory:!1}:null);return}L()},t[9]=a,t[10]=L,t[11]=n,t[12]=R,t[13]=B,t[14]=V):V=t[14];let fe;t[15]!==a||t[16]!==L||t[17]!==n||t[18]!==j||t[19]!==R||t[20]!==u?(fe=[n,j,u,L,R,a],t[15]=a,t[16]=L,t[17]=n,t[18]=j,t[19]=R,t[20]=u,t[21]=fe):fe=t[21],(0,W.useEffect)(V,fe);let H;t[22]===oe?H=t[23]:(H=e=>{oe(e)},t[22]=oe,t[23]=H);let pe=H,me=z!==null&&(h===`any`||h===`file`&&!z.isDirectory||h===`directory`&&z.isDirectory),U;bb1:{if(!z){U=T.pickerHintNone;break bb1}if(h===`file`&&z.isDirectory){U=T.pickerHintNeedsFile;break bb1}if(h===`directory`&&!z.isDirectory){U=T.pickerHintNeedsDirectory;break bb1}U=`${z.isDirectory?`📁`:`📄`} ${z.path}`}let G=U,ge=D?.agents??[],K;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,Z.jsx)(x,{className:`fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),t[24]=K):K=t[24];let q;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(q=f(`fixed left-1/2 top-1/2 z-[71] w-[min(34rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2`,`flex h-[min(28rem,calc(100vh-3rem))] flex-col overflow-hidden rounded-lg border border-edge bg-surface-panel shadow-popover outline-none`),t[25]=q):q=t[25];let J;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,Z.jsx)(re,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[26]=J):J=t[26];let Y=y.cron.refresh,_e=y.cron.refresh,ve;t[27]===L?ve=t[28]:(ve=()=>void L(),t[27]=L,t[28]=ve);let ye=F&&`animate-spin`,X;t[29]===ye?X=t[30]:(X=f(`size-4`,ye),t[29]=ye,t[30]=X);let Q;t[31]===X?Q=t[32]:(Q=(0,Z.jsx)(de,{className:X,"aria-hidden":!0}),t[31]=X,t[32]=Q);let be;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(be=(0,Z.jsx)(d,{className:`size-4`}),t[33]=be):be=t[33];let xe;t[34]!==I||t[35]!==b.loadError?(xe=I?(0,Z.jsxs)(`p`,{className:`shrink-0 px-4 py-2 text-xs text-red-600 dark:text-red-400`,children:[b.loadError,`: `,I]}):null,t[34]=I,t[35]=b.loadError,t[36]=xe):xe=t[36];let $;t[37]!==pe||t[38]!==F||t[39]!==z?.path||t[40]!==B||t[41]!==b.emptyDir||t[42]!==b.title||t[43]!==ae?($=F&&ae.length===0?(0,Z.jsxs)(`p`,{className:`flex shrink-0 items-center gap-2 px-4 py-3 text-sm text-fg-muted`,children:[(0,Z.jsx)(l,{className:`size-4 animate-spin`}),b.title,`…`]}):(0,Z.jsx)(se,{tree:ae,selectedPath:z?.path??null,onSelectFile:e=>B({path:e,isDirectory:!1}),onSelectEntry:(e,t)=>B({path:e,isDirectory:t}),onExpandDir:pe,onAction:void 0,emptyHint:b.emptyDir}),t[37]=pe,t[38]=F,t[39]=z?.path,t[40]=B,t[41]=b.emptyDir,t[42]=b.title,t[43]=ae,t[44]=$):$=t[44];let Se;t[45]!==xe||t[46]!==$?(Se=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[xe,$]}),t[45]=xe,t[46]=$,t[47]=Se):Se=t[47];let Ce;t[48]===G?Ce=t[49]:(Ce=(0,Z.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,children:G}),t[48]=G,t[49]=Ce);let De;t[50]===r?De=t[51]:(De=()=>r(!1),t[50]=r,t[51]=De);let Oe;t[52]!==T.cancel||t[53]!==De?(Oe=(0,Z.jsx)(p,{type:`button`,variant:`ghost`,onClick:De,children:T.cancel}),t[52]=T.cancel,t[53]=De,t[54]=Oe):Oe=t[54];let ke=!me,Ae;t[55]!==i||t[56]!==r||t[57]!==j||t[58]!==z?(Ae=()=>{z&&(i({...z,agentId:j}),r(!1))},t[55]=i,t[56]=r,t[57]=j,t[58]=z,t[59]=Ae):Ae=t[59];let je;t[60]!==T.pickerConfirm||t[61]!==ke||t[62]!==Ae?(je=(0,Z.jsx)(p,{type:`button`,disabled:ke,onClick:Ae,children:T.pickerConfirm}),t[60]=T.pickerConfirm,t[61]=ke,t[62]=Ae,t[63]=je):je=t[63];let Me;t[64]!==Oe||t[65]!==je?(Me=(0,Z.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[Oe,je]}),t[64]=Oe,t[65]=je,t[66]=Me):Me=t[66];let Ne;return t[67]!==Ce||t[68]!==Me?(Ne=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-t border-edge px-4 py-3`,children:[Ce,Me]}),t[67]=Ce,t[68]=Me,t[69]=Ne):Ne=t[69],(0,Z.jsx)(te,{open:n,onOpenChange:r,children:(0,Z.jsxs)(ee,{children:[K,(0,Z.jsxs)(C,{className:q,children:[(0,Z.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-edge px-4`,children:[J,(0,Z.jsx)(w,{className:`min-w-0 flex-1 truncate text-base font-semibold text-fg`,children:T.pickerTitle}),(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-50`,title:Y,"aria-label":_e,disabled:F,onClick:ve,children:Q}),(0,Z.jsx)(S,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":b.close,children:be})})]}),ge.length>0?(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-edge px-4 py-2`,children:[(0,Z.jsx)(`label`,{className:`text-xs text-fg-muted`,htmlFor:`picker-agent-select`,children:T.pickerAgentLabel}),(0,Z.jsx)(o,{id:`picker-agent-select`,className:`min-w-0 flex-1 rounded-md border border-edge bg-surface-panel px-2 py-1 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:j,onChange:e=>{M(e.target.value),B(null)},children:ge.map(e=>(0,Z.jsxs)(s,{value:e.id,children:[ce(e,y.agentsSettings),e.id===D?.defaultId?` ★`:``]},e.id))})]}):null,Se,Ne]})]})})}function we(e){return e.token}function Te(e){return e.agentId}function Ee(e){return e.language}var De=[`shares`,`policy`];function Oe(e){let t=(e??``).trim();return De.includes(t)?t:`shares`}function ke(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(1)} GB`}function Ae(e,t){let n=new Date(e).getTime()-Date.now(),r=Math.abs(n),i=n<0;if(r<6e4)return t===`zh`?`刚刚`:`just now`;let a=Math.floor(r/6e4);if(a<60){let e=t===`zh`?`${a} 分钟`:`${a}m`;return i?t===`zh`?`${e}前`:`${e} ago`:e}let o=Math.floor(a/60);if(o<24){let e=t===`zh`?`${o} 小时`:`${o}h`;return i?t===`zh`?`${e}前`:`${e} ago`:e}let s=Math.floor(o/24),c=t===`zh`?`${s} 天`:`${s}d`;return i?t===`zh`?`${c}前`:`${c} ago`:c}var je=[{value:36e5,key:`1h`},{value:216e5,key:`6h`},{value:864e5,key:`24h`},{value:2592e5,key:`3d`},{value:6048e5,key:`7d`},{value:2592e6,key:`30d`}];function Me(){let e=(0,he.c)(24),t=v(Pe),n=g(t).sharesSettings,r=!!_(Ne),[a,o]=i(),s;e[0]===a?s=e[1]:(s=Oe(a.get(`tab`)),e[0]=a,e[1]=s);let c=s,l;e[2]===o?l=e[3]:(l=e=>{o(t=>{let n=new URLSearchParams(t);return e===`shares`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[2]=o,e[3]=l);let u=l;if(!r)return(0,Z.jsx)(fe,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})});let d={shares:n.tabShares,policy:n.tabPolicy},f=De.map(e=>({id:e,label:d[e]})),p;e[4]!==n.subtitle||e[5]!==n.title?(p=(0,Z.jsx)(V,{title:n.title,subtitle:n.subtitle}),e[4]=n.subtitle,e[5]=n.title,e[6]=p):p=e[6];let m;e[7]!==c||e[8]!==u||e[9]!==n.tabsAria||e[10]!==f?(m=(0,Z.jsx)(U,{items:f,activeTab:c,onChange:u,ariaLabel:n.tabsAria,tabIdPrefix:`shares-tab`,panelIdPrefix:`shares-panel`}),e[7]=c,e[8]=u,e[9]=n.tabsAria,e[10]=f,e[11]=m):m=e[11];let h;e[12]!==c||e[13]!==r||e[14]!==t||e[15]!==n?(h=c===`shares`?(0,Z.jsx)(Fe,{t:n,language:t}):(0,Z.jsx)(be,{hasToken:r}),e[12]=c,e[13]=r,e[14]=t,e[15]=n,e[16]=h):h=e[16];let y;e[17]!==c||e[18]!==h?(y=(0,Z.jsx)(H,{id:c,activeTab:c,tabIdPrefix:`shares-tab`,panelIdPrefix:`shares-panel`,showHeading:!1,children:h}),e[17]=c,e[18]=h,e[19]=y):y=e[19];let b;return e[20]!==p||e[21]!==m||e[22]!==y?(b=(0,Z.jsxs)(fe,{children:[p,m,y]}),e[20]=p,e[21]=m,e[22]=y,e[23]=b):b=e[23],b}function Ne(e){return e.token}function Pe(e){return e.language}function Fe(e){let t=(0,he.c)(60),{t:n,language:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={refreshInterval:3e4},t[0]=i):i=t[0];let{data:a,error:o,isLoading:s,mutate:c}=ne(`shares-list`,A,i),l;t[1]===a?.payload?.shares?l=t[2]:(l=a?.payload?.shares??[],t[1]=a?.payload?.shares,t[2]=l);let u=l,[d,m]=(0,W.useState)(!1),h;bb0:{if(d){h=u;break bb0}let e;t[3]===u?e=t[4]:(e=u.filter(Be),t[3]=u,t[4]=e),h=e}let g=h,_;t[5]===u?_=t[6]:(_=u.filter(ze),t[5]=u,t[6]=_);let v=_.length,y;t[7]===u?y=t[8]:(y=u.filter(Re),t[7]=u,t[8]=y);let b=y.length,x;t[9]===c?x=t[10]:(x=()=>void c(),t[9]=c,t[10]=x);let S;t[11]!==n||t[12]!==x?(S=(0,Z.jsx)(He,{t:n,onCreated:x}),t[11]=n,t[12]=x,t[13]=S):S=t[13];let ee=d?n.allSharesTitle:n.listTitle,C;t[14]===v?C=t[15]:(C=v>0&&(0,Z.jsxs)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:[`(`,v,`)`]}),t[14]=v,t[15]=C);let w;t[16]!==ee||t[17]!==C?(w=(0,Z.jsxs)(`h2`,{className:`text-sm font-semibold text-fg`,children:[ee,C]}),t[16]=ee,t[17]=C,t[18]=w):w=t[18];let te;t[19]===c?te=t[20]:(te=()=>void c(),t[19]=c,t[20]=te);let T=s&&`animate-spin`,E;t[21]===T?E=t[22]:(E=f(`size-3.5`,T),t[21]=T,t[22]=E);let re;t[23]===E?re=t[24]:(re=(0,Z.jsx)(de,{className:E}),t[23]=E,t[24]=re);let D;t[25]!==s||t[26]!==te||t[27]!==re?(D=(0,Z.jsx)(p,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:te,disabled:s,children:re}),t[25]=s,t[26]=te,t[27]=re,t[28]=D):D=t[28];let O;t[29]!==b||t[30]!==d||t[31]!==n.hideExpired||t[32]!==n.showExpired?(O=b>0&&(0,Z.jsx)(`button`,{type:`button`,className:`text-xs text-accent hover:underline`,onClick:()=>m(Le),children:d?n.hideExpired:n.showExpired}),t[29]=b,t[30]=d,t[31]=n.hideExpired,t[32]=n.showExpired,t[33]=O):O=t[33];let k;t[34]!==D||t[35]!==O?(k=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[D,O]}),t[34]=D,t[35]=O,t[36]=k):k=t[36];let j;t[37]!==w||t[38]!==k?(j=(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[w,k]}),t[37]=w,t[38]=k,t[39]=j):j=t[39];let M;t[40]!==a||t[41]!==o||t[42]!==g||t[43]!==s||t[44]!==r||t[45]!==c||t[46]!==n?(M=s&&!a?(0,Z.jsx)(`div`,{className:`grid gap-2`,"aria-busy":`true`,children:Array.from({length:4}).map(Ie)}):o?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-red-600 dark:text-red-400`,children:[(0,Z.jsx)(`span`,{children:n.error}),(0,Z.jsx)(p,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-xs`,onClick:()=>void c(),children:n.retry})]}):g.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.emptyState}):(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:g.map(e=>(0,Z.jsx)(We,{share:e,t:n,language:r,onRevoked:()=>void c(),onExtended:()=>void c()},e.id))}),t[40]=a,t[41]=o,t[42]=g,t[43]=s,t[44]=r,t[45]=c,t[46]=n,t[47]=M):M=t[47];let N;t[48]!==b||t[49]!==c||t[50]!==d||t[51]!==n?(N=b>0&&d&&(0,Z.jsx)(Ge,{t:n,onCleaned:()=>void c()}),t[48]=b,t[49]=c,t[50]=d,t[51]=n,t[52]=N):N=t[52];let P;t[53]!==j||t[54]!==M||t[55]!==N?(P=(0,Z.jsxs)(me,{children:[j,M,N]}),t[53]=j,t[54]=M,t[55]=N,t[56]=P):P=t[56];let ie;return t[57]!==P||t[58]!==S?(ie=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[S,P]}),t[57]=P,t[58]=S,t[59]=ie):ie=t[59],ie}function Ie(e,t){return(0,Z.jsx)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(ae,{className:`h-4 w-2/3`}),(0,Z.jsx)(ae,{className:`mt-2 h-3 w-1/2`})]}),(0,Z.jsx)(ae,{className:`h-7 w-20 rounded-md`})]})},t)}function Le(e){return!e}function Re(e){return e.expired||e.revoked}function ze(e){return!e.expired&&!e.revoked}function Be(e){return!e.expired&&!e.revoked}var Ve={expanded:!0,path:``,isDirectory:!1,agentId:``,ttlMs:864e5,maxViews:null,description:``,directoryMode:`browse`,creating:!1,result:null,errorMsg:null,resultDialogOpen:!1,pickerOpen:!1};function He({t:e,onCreated:t}){let[n,r]=(0,W.useReducer)(M,Ve),{expanded:i,path:a,isDirectory:c,agentId:d,ttlMs:m,maxViews:h,description:g,directoryMode:_,creating:v,result:y,errorMsg:b,resultDialogOpen:x,pickerOpen:S}=n,ee=(0,W.useCallback)(async()=>{if(a.trim()){r({type:`patch`,patch:{creating:!0,errorMsg:null,result:null}});try{r({type:`patch`,patch:{result:(await j({path:a.trim(),ttlMs:m,maxViews:h,description:g.trim()||void 0,...d?{agentId:d}:{},...c?{kind:`directory`,directoryMode:_}:{}})).payload,resultDialogOpen:!0}}),t()}catch(e){r({type:`patch`,patch:{errorMsg:e instanceof Error?e.message:String(e)}})}finally{r({type:`patch`,patch:{creating:!1}})}}},[a,c,d,m,h,g,_,t]),C=(0,W.useCallback)(()=>{r({type:`patch`,patch:{path:``,isDirectory:!1,agentId:``,description:``,maxViews:null,ttlMs:864e5,directoryMode:`browse`,result:null,errorMsg:null}})},[]);return i?(0,Z.jsxs)(me,{children:[(0,Z.jsx)(`h2`,{className:`mb-1 text-sm font-semibold text-fg`,children:e.createTitle}),(0,Z.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:e.createHint}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.pathLabel}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:f(`flex min-w-0 flex-1 items-center gap-2 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm`,a?`text-fg`:`text-fg-subtle`),children:a?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,children:c?`📁`:`📄`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:a,children:a})]}):(0,Z.jsx)(`span`,{className:`truncate`,children:e.pathPlaceholder})}),(0,Z.jsxs)(p,{type:`button`,variant:`ghost`,onClick:()=>r({type:`patch`,patch:{pickerOpen:!0}}),children:[(0,Z.jsx)(R,{className:`size-4`}),a?e.pathBrowseChange:e.pathBrowse]})]})]}),c?(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.directoryModeLabel}),(0,Z.jsxs)(o,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:_,onChange:e=>r({type:`patch`,patch:{directoryMode:e.target.value===`zip-only`?`zip-only`:`browse`}}),children:[(0,Z.jsx)(s,{value:`browse`,children:e.directoryModeBrowse}),(0,Z.jsx)(s,{value:`zip-only`,children:e.directoryModeZipOnly})]})]}):null,(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.ttlLabel}),(0,Z.jsx)(o,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:m,onChange:e=>r({type:`patch`,patch:{ttlMs:Number(e.target.value)}}),children:je.map(t=>(0,Z.jsx)(s,{value:t.value,children:e.ttlOptions[t.key]},t.key))})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.maxViewsLabel}),(0,Z.jsxs)(o,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:h??`unlimited`,onChange:e=>r({type:`patch`,patch:{maxViews:e.target.value===`unlimited`?null:Number(e.target.value)}}),children:[(0,Z.jsx)(s,{value:`unlimited`,children:e.maxViewsUnlimited}),(0,Z.jsx)(s,{value:`1`,children:`1`}),(0,Z.jsx)(s,{value:`5`,children:`5`}),(0,Z.jsx)(s,{value:`10`,children:`10`}),(0,Z.jsx)(s,{value:`50`,children:`50`}),(0,Z.jsx)(s,{value:`100`,children:`100`})]})]})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.descriptionLabel}),(0,Z.jsx)(`input`,{type:`text`,className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:outline-none focus:ring-2 focus:ring-accent`,placeholder:e.descriptionPlaceholder,value:g,onChange:e=>r({type:`patch`,patch:{description:e.target.value}})})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,Z.jsxs)(p,{type:`button`,disabled:v||!a.trim(),onClick:()=>void ee(),children:[v?(0,Z.jsx)(l,{className:`size-4 animate-spin`}):(0,Z.jsx)(u,{className:`size-4`}),v?e.creating:e.createButton]}),(0,Z.jsx)(p,{type:`button`,variant:`ghost`,onClick:()=>{C(),r({type:`patch`,patch:{expanded:!1}})},children:e.cancel})]}),b&&(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:b})]}),(0,Z.jsx)(L,{open:x,onOpenChange:e=>{r({type:`patch`,patch:{resultDialogOpen:e,...e?{}:{result:null}}})},result:y}),(0,Z.jsx)(Ce,{open:S,onOpenChange:e=>r({type:`patch`,patch:{pickerOpen:e}}),initialPath:a||void 0,selectKind:`any`,onConfirm:e=>r({type:`patch`,patch:{path:e.path,isDirectory:e.isDirectory,agentId:e.agentId,directoryMode:`browse`}})})]}):(0,Z.jsxs)(p,{type:`button`,onClick:()=>r({type:`patch`,patch:{expanded:!0}}),className:`self-start`,children:[(0,Z.jsx)(u,{className:`size-4`}),e.createTitle]})}var Ue={revokeOpen:!1,revoking:!1,linksOpen:!1,urlCopied:!1,copyFailed:!1,extending:!1};function We({share:e,t,language:n,onRevoked:r,onExtended:i}){let[o,s]=(0,W.useReducer)(M,Ue),{revokeOpen:u,revoking:d,linksOpen:m,urlCopied:g,copyFailed:_,extending:v}=o,y=!e.expired&&!e.revoked,b=e.revoked?t.statusRevoked:e.expired?t.statusExpired:t.statusActive,x=e.revoked?`text-red-600 dark:text-red-400`:e.expired?`text-fg-subtle`:`text-emerald-600 dark:text-emerald-400`,S=(0,W.useCallback)(async()=>{s({type:`patch`,patch:{revokeOpen:!1,revoking:!0}});try{await I(e.id),r()}catch{}finally{s({type:`patch`,patch:{revoking:!1}})}},[e.id,r]),ee=(0,W.useCallback)(async()=>{if(s({type:`patch`,patch:{linksOpen:!0,copyFailed:!1}}),!await h(e.shareUrl)){s({type:`patch`,patch:{copyFailed:!0}}),window.setTimeout(()=>s({type:`patch`,patch:{copyFailed:!1}}),2500);return}s({type:`patch`,patch:{urlCopied:!0}}),window.setTimeout(()=>s({type:`patch`,patch:{urlCopied:!1}}),2e3)},[e.shareUrl]),C=(0,W.useCallback)(async()=>{s({type:`patch`,patch:{extending:!0}});try{await ue(e.id,864e5),i()}catch{}finally{s({type:`patch`,patch:{extending:!1}})}},[e.id,i]),w=`share-links-${e.id}`;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:f(`flex min-w-0 flex-1 items-start gap-3 rounded-md text-left`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),"aria-expanded":m,"aria-controls":w,onClick:()=>s({type:`patch`,patch:{linksOpen:!m}}),children:[(0,Z.jsx)(N,{className:f(`mt-0.5 size-4 shrink-0 text-fg-muted transition-transform`,m?`rotate-0`:`-rotate-90`),"aria-hidden":!0}),e.kind===`note`?(0,Z.jsx)(D,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}):(0,Z.jsx)(R,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.fileName}),(0,Z.jsx)(`span`,{className:f(`text-xs font-medium`,x),children:b})]}),(0,Z.jsx)(`p`,{className:`truncate text-xs text-fg-subtle`,children:e.kind===`note`?n===`zh`?`笔记快照 · 版本 ${e.snapshotRevision??1}`:`Note snapshot · revision ${e.snapshotRevision??1}`:e.workspaceRelativePath}),(0,Z.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:ke(e.fileSize)}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(oe,{className:`size-3`}),e.expired?n===`zh`?`已过期`:`expired`:Ae(e.expiresAt,n)]}),(0,Z.jsxs)(`span`,{children:[t.views,`: `,e.downloadCount,e.maxViews!==null&&` ${t.viewsOf} ${e.maxViews}`]}),e.description&&(0,Z.jsx)(`span`,{className:`italic text-fg-subtle`,children:e.description})]})]})]}),(0,Z.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:y&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(p,{type:`button`,variant:`ghost`,className:`px-2 py-1`,title:t.copyUrl,onClick:()=>void ee(),children:g?(0,Z.jsx)(a,{className:`size-3.5 text-emerald-500`}):(0,Z.jsx)(c,{className:`size-3.5`})}),(0,Z.jsx)(p,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:()=>void C(),disabled:v,title:t.extend,children:v?(0,Z.jsx)(l,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(oe,{className:`size-3.5`})}),(0,Z.jsx)(p,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-red-600 hover:text-red-700 dark:text-red-400`,onClick:()=>s({type:`patch`,patch:{revokeOpen:!0}}),disabled:d,children:d?(0,Z.jsx)(l,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(z,{className:`size-3.5`})})]})})]}),y&&m?(0,Z.jsxs)(`div`,{id:w,className:`mt-3 bg-surface-base/45 py-3 pl-7 pr-3`,children:[(0,Z.jsx)(P,{shareUrl:e.shareUrl,lanUrl:e.lanUrl,reachability:e.reachability,compact:!0}),_?(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-red-600 dark:text-red-400`,children:t.copyFailed}):null,(0,Z.jsx)(`div`,{className:`mt-2`,children:(0,Z.jsx)(F,{reachability:e.reachability})})]}):null]}),(0,Z.jsx)(B,{open:u,title:t.revokeConfirmTitle,description:t.revokeConfirmBody,confirmLabel:t.revokeConfirmLabel,cancelLabel:t.cancel,destructive:!0,onConfirm:()=>void S(),onCancel:()=>s({type:`patch`,patch:{revokeOpen:!1}})})]})}function Ge({t:e,onCleaned:t}){let[n,r]=(0,W.useState)(!1),[i,a]=(0,W.useState)(!1),o=(0,W.useCallback)(async()=>{r(!1),a(!0);try{await O(),t()}catch{}finally{a(!1)}},[t]);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Z.jsxs)(p,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>r(!0),className:`border-danger/40 px-2 py-1 text-xs text-danger hover:bg-danger/10`,children:[i?(0,Z.jsx)(l,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(z,{className:`size-3.5`}),e.cleanExpired]})}),(0,Z.jsx)(B,{open:n,title:e.cleanExpiredConfirmTitle,description:e.cleanExpiredConfirmBody,confirmLabel:e.cleanExpiredConfirmLabel,cancelLabel:e.cancel,destructive:!0,onConfirm:()=>void o(),onCancel:()=>r(!1)})]})}export{Me as SharesSettingsPanel};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{o as t,r as n}from"./locale-store-CPylQjH9.js";import{Sr as r}from"./index-wnDPGRTi.js";var i=e({reloadSkills:()=>a});async function a(){let e=await t(n(`/api/skills/reload`),{method:`POST`});if(!e.ok)throw Error(await r(e))}export{i as n,a as t};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{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,Bi as le,Ei as x,Fa as S,Gr as ue,Hn as de,Hr as fe,I as pe,J as me,Jr as he,Kr as ge,L as _e,P as ve,Q as C,Ql as ye,Sl as w,Un as T,Ur as E,Vi as D,W as be,Wn 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,n as Se,qr as Ce,sc as we,tc as Te,xl as Ee,zi as De}from"./index-wnDPGRTi.js";import{t as Oe}from"./date-picker-DDAxTir8.js";import{t as ke}from"./dependency-picker-CYVoSZwI.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`?w:Ee,{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=D(e=>e.open),ae=D(e=>e.sessionKeyOverride),oe=D(e=>e.openForSession),le=he(e=>e.setOpen),{data:w,error:xe,mutate:A,lastChange:Ee,conversationLoading:Oe,conversationError:ke}=ve(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)(w),[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=w?.dependencies.map(e=>`${e.id}:${e.title}`).join(`\0`)??``,xt=(0,I.useMemo)(()=>p(i.get(`returnTo`),`/`,[`/projects`,`/chat`,`/notes`,`/tasks`]),[i]);pt.current=w;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(!Ee||Ee.source===`user`)return;gt(Ee);let e=window.setTimeout(()=>gt(null),3500);return()=>window.clearTimeout(e)},[Ee]),(0,I.useEffect)(()=>{let t=w?.task.projectId,n=w?.dependencies??[];if(!t){ft.current=null,Je(null),qe(n);return}ft.current!==t&&(ft.current=t,Je(null));let r=!0;return S(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,w?.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 _e(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(!w)return;if(st.current){st.current=!1;return}let e=Qe.trim(),t=ut.current;if(Ae(t,w.task.version,w.task.title,e)){K(`title`);return}if(!e||e===w.task.title){$e(w.task.title),U(!1);return}await Y({title:e})&&(K(null),U(!1))},Ct=async()=>{if(!w)return;if(ct.current){ct.current=!1;return}let e=tt.trim(),t=dt.current;if(Ae(t,w.task.version,w.task.body??``,e)){K(`description`);return}if(tt===lt.current||e===(w.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 C(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 be(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)(ye,{className:`size-4`})}),main:w?(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(w)]})]}):null,end:null}),re},[re,y.backToWork,y.detailStatuses,y.taskLabel,w,t,H,xt,ne]),xe&&!w)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(!w)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=w.waits[0],Pt=Nt?.kind===`paused`?Nt:void 0,X=w.receipts[0],Ft=y.detailStatuses[Ge(w)],It=y.detailStatusDescriptions[Ge(w)],Lt=w.task.body?.trim()||w.task.contract?.objective.trim(),Rt=new Map(X?.verification.checks.map(e=>[e.criterion,e.status])),zt=w.allowedCommands.includes(`mark_ready`),Bt=w.allowedCommands.includes(`start`),Vt=w.allowedCommands.includes(`add_wait`),Ht=w.task.phase===`review`&&w.allowedCommands.includes(`close`),Ut=w.allowedCommands.includes(`reopen`),Z=w.conversation.activeSessionKey,Wt=w.conversation.currentExecutorAgentId??w.task.delegateAgentId??w.task.ownerId,Gt=Ye.find(e=>e.id===Wt),Kt=!!(Z&&ie&&ae===Z),qt=w.attention.some(e=>e.kind===`input_required`||e.kind===`approval_required`),Jt=w.task.contract?.acceptanceCriteria??[],Yt=Jt.filter(e=>Rt.get(e)===`passed`).length,Xt=w.task.contract?.expectedOutputs??[],Zt=w.task.contract?.constraints??[],Qt=w.task.contract?.approvalRequired??[],$t=w.task.contract?.assumptions??[],en=w.task.contract?.risks??[],Q=(...e)=>!!ht?.changedFields.some(t=>e.includes(t)),tn=e=>t===`modal`&&n?T(n,e):m(`/tasks/${e}`,xt),nn=w.allowedCommands.includes(`move`),$=B.has(`command`),rn=B.has(`delete`),an=w.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)(ue,{children:[(0,R.jsx)(Ce,{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)(O,{children:(0,R.jsxs)(fe,{align:`end`,sideOffset:6,className:`z-[100] min-w-44 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:[an?(0,R.jsx)(E,{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(pe(e,an.id,an.version),{revalidate:!1}).catch(()=>z(y.actionFailed)).finally(()=>q(`command`,!1))},children:y.cancelActiveRun}):null,an?(0,R.jsx)(ge,{className:`my-1 h-px bg-edge`}):null,w.task.phase===`closed`?null:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(E,{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)(ge,{className:`my-1 h-px bg-edge`})]}),(0,R.jsx)(E,{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(w.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:w.task.title,version:w.task.version},K(null),$e(w.task.title),U(!0)},children:(0,R.jsx)(`h1`,{className:`text-2xl font-semibold leading-8 text-fg`,children:w.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(w.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(w.task.body??w.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=w.task.body??w.task.contract?.objective??``;lt.current=e,dt.current={value:w.task.body??``,version:w.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!==w.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(w.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]}),w.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:w.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 me(X.runId,`helpful`),children:y.doneWell}),(0,R.jsx)(v,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>void me(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}`))]}),w.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(w.receipts.length-1))}),(0,R.jsx)(`div`,{className:`mt-3 space-y-3`,children:w.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,w.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:w.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:w.task.phase,disabled:B.has(`phase`),canMove:nn,canApprove:Ht,canReopen:Ut,language:l,label:y.taskPhase,onChange:wt}),(0,R.jsx)(Le,{value:w.task.priority,disabled:B.has(`priority`),label:y.priority,labels:y.priorityLabels,onChange:Tt}),(0,R.jsx)(Re,{value:Ne(w.task.dueAt),disabled:B.has(`dueAt`),label:y.dueDate,onChange:Et}),(0,R.jsx)(ze,{value:w.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}}`,x(w.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:w.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}),w.dependents.length>0?(0,R.jsx)(`div`,{className:`space-y-1.5`,children:w.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:()=>{le(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:de(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)(Se,{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)(De,{open:_t,title:y.deleteTaskTitle,description:y.deleteTaskDescription.replace(`{{title}}`,w.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}=ve(n),c=o?.conversation.activeSessionKey??null,l=D(W),u=D(et),d=D($e),p=D(Qe),m=he(U),h=le(Ze),v=le(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 ue=l?`true`:`false`,fe=`${ee/2}px`,pe=`${ee}px`,me;t[9]!==fe||t[10]!==pe?(me={"--task-detail-workspace-offset":fe,"--task-detail-workspace-width":pe},t[9]=fe,t[10]=pe,t[11]=me):me=t[11];let ge=me,_e=a===`zh`?`任务详情`:`Task details`,C;t[12]===_e?C=t[13]:(C=(0,R.jsx)(ae,{className:`font-medium text-fg`,children:_e}),t[12]=_e,t[13]=C);let ye=a===`zh`?`查看并操作任务详情`:`View and manage task details`,w;t[14]===ye?w=t[15]:(w=(0,R.jsx)(y,{className:`sr-only`,children:ye}),t[14]=ye,t[15]=w);let T;t[16]!==c||t[17]!==a||t[18]!==p||t[19]!==m||t[20]!==n||t[21]!==l||t[22]!==d?(T=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:de(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]=T):T=t[23];let E=a===`zh`?`关闭任务详情`:`Close task details`,be;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(be=(0,R.jsx)(g,{className:`size-4`,"aria-hidden":!0}),t[24]=be):be=t[24];let O;t[25]===E?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":E,children:be}),t[25]=E,t[26]=O);let k;t[27]!==T||t[28]!==O?(k=(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[T,O]}),t[27]=T,t[28]=O,t[29]=k):k=t[29];let A;t[30]!==C||t[31]!==w||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:[C,w,k]}),t[30]=C,t[31]=w,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]!==ue||t[44]!==ge?(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":ue,style:ge,onEscapeKeyDown:Ye,onInteractOutside:Je,children:[A,M]}),t[41]=A,t[42]=M,t[43]=ue,t[44]=ge,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)(xe,{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};