@xopcai/xopc 0.0.246 → 0.0.248

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 (199) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/src/update-offset-store.js +17 -54
  3. package/dist/extensions/telegram/xopc.extension.json +1 -1
  4. package/dist/extensions/weixin/src/auth/accounts.js +3 -5
  5. package/dist/extensions/weixin/src/monitor/monitor.js +3 -5
  6. package/dist/extensions/weixin/src/storage/sync-buf.d.ts +3 -6
  7. package/dist/extensions/weixin/src/storage/sync-buf.js +9 -22
  8. package/dist/gateway/static/root/assets/{activity-store-BlxqErph.js → activity-store-etpmyV7S.js} +1 -1
  9. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CJJzpYYS.js → agent-avatar-dicebear-BmKxSM1k.js} +1 -1
  10. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CUXApfcE.js +1 -0
  11. package/dist/gateway/static/root/assets/{agents-je3sRGmk.js → agents-DNq_GKuc.js} +1 -1
  12. package/dist/gateway/static/root/assets/{api-BbXzyQMj.js → api-B0-hLuZ1.js} +1 -1
  13. package/dist/gateway/static/root/assets/{app-management-settings-panel-Cnn3i00c.js → app-management-settings-panel-qfwAgyhQ.js} +1 -1
  14. package/dist/gateway/static/root/assets/{appearance-settings-BToQaw_v.js → appearance-settings-DqQVUpCC.js} +1 -1
  15. package/dist/gateway/static/root/assets/apps-page-dwIqYmXk.js +1 -0
  16. package/dist/gateway/static/root/assets/{archive-plugin-DD2SweEH.js → archive-plugin-BnMSgZvR.js} +1 -1
  17. package/dist/gateway/static/root/assets/{attachment-load-BFtcib5t.js → attachment-load-CejsQMev.js} +1 -1
  18. package/dist/gateway/static/root/assets/{automations-page-XS8wIl5o.js → automations-page-RC8EyoAf.js} +1 -1
  19. package/dist/gateway/static/root/assets/automations-workspace-SkdcSZ0i.js +6 -0
  20. package/dist/gateway/static/root/assets/{binary-plugins-Xs7pLHxR.js → binary-plugins-DGjppLSG.js} +1 -1
  21. package/dist/gateway/static/root/assets/{block-editor-BPdSzceB.js → block-editor-CWdP4bUc.js} +44 -44
  22. package/dist/gateway/static/root/assets/browser-settings-page-CKCa6TvG.js +8 -0
  23. package/dist/gateway/static/root/assets/{browser-workflow-inputs-BAAc151l.js → browser-workflow-inputs-BQ1Ilw_o.js} +1 -1
  24. package/dist/gateway/static/root/assets/{browser-workflows-page-DUPPvE30.js → browser-workflows-page-CJh4NyxT.js} +2 -2
  25. package/dist/gateway/static/root/assets/{capabilities-settings-panel-cl9kYilL.js → capabilities-settings-panel-DSp--zIZ.js} +5 -5
  26. package/dist/gateway/static/root/assets/channels-settings-CMd2dDrI.js +1 -0
  27. package/dist/gateway/static/root/assets/{channels-status-swr-CCBCtLDg.js → channels-status-swr-Ohhee4vm.js} +1 -1
  28. package/dist/gateway/static/root/assets/{chat-terminal-dock-DKW1M6aJ.js → chat-terminal-dock-BOtoKTK3.js} +2 -2
  29. package/dist/gateway/static/root/assets/connectors-page-udWs5Kdm.js +2 -0
  30. package/dist/gateway/static/root/assets/{cron-expression-Bijb0ZQu.js → cron-expression-DTj1V3Sw.js} +1 -1
  31. package/dist/gateway/static/root/assets/{date-picker-BZuHw-SY.js → date-picker-Yr6OCvGL.js} +1 -1
  32. package/dist/gateway/static/root/assets/{dependency-picker-BsBD2JFY.js → dependency-picker-DpN3XZg9.js} +1 -1
  33. package/dist/gateway/static/root/assets/{desktop-pet-Ceuw3QKb.js → desktop-pet-DbGzggPF.js} +1 -1
  34. package/dist/gateway/static/root/assets/{desktop-pet-settings-DctOXexM.js → desktop-pet-settings-DinCToZh.js} +1 -1
  35. package/dist/gateway/static/root/assets/{extension-debug-page-BNlMPATK.js → extension-debug-page-DgTtk4KC.js} +1 -1
  36. package/dist/gateway/static/root/assets/{extension-page-CK4Uvzge.js → extension-page-DtQeiP6f.js} +1 -1
  37. package/dist/gateway/static/root/assets/{extension-settings-page-CpnXXemw.js → extension-settings-page-DcguCgsH.js} +1 -1
  38. package/dist/gateway/static/root/assets/{gateway-config-api-C_mlpe-r.js → gateway-config-api-Br7lSf6H.js} +1 -1
  39. package/dist/gateway/static/root/assets/{gateway-config-swr-826dipyU.js → gateway-config-swr-DXuXtU1w.js} +1 -1
  40. package/dist/gateway/static/root/assets/{gateway-settings-DSSW17ed.js → gateway-settings-CdPoDMuj.js} +1 -1
  41. package/dist/gateway/static/root/assets/{gateway-startup-retry-DyvcAIMm.js → gateway-startup-retry-CzBzglzQ.js} +1 -1
  42. package/dist/gateway/static/root/assets/{heartbeat-settings-hbmIZTpg.js → heartbeat-settings-DHk1hawP.js} +1 -1
  43. package/dist/gateway/static/root/assets/home-page-YGipe_W6.js +1 -0
  44. package/dist/gateway/static/root/assets/{image-generation-api-D7cyfks6.js → image-generation-api-TIgsn04n.js} +1 -1
  45. package/dist/gateway/static/root/assets/{index-eZjksPvq.js → index-D5TQQpeb.js} +44 -44
  46. package/dist/gateway/static/root/assets/index-DReBaaTX.css +2 -0
  47. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BQrDwwgi.js → keyboard-shortcuts-settings-wsWuoa8p.js} +1 -1
  48. package/dist/gateway/static/root/assets/local-app-workbench-page-CpyvYyrb.js +2 -0
  49. package/dist/gateway/static/root/assets/{local-apps-page-D-YWD6LS.js → local-apps-page-CXrbrGo8.js} +1 -1
  50. package/dist/gateway/static/root/assets/local-context-graph-BjUf7fQ9.js +1 -0
  51. package/dist/gateway/static/root/assets/{locale-store-CBoCuIMx.js → locale-store-BJFLQY8O.js} +1 -1
  52. package/dist/gateway/static/root/assets/{logs-page-DvLc9l59.js → logs-page-CXKy6E_l.js} +2 -2
  53. package/dist/gateway/static/root/assets/{management-settings-DsULLUUv.js → management-settings-BdJZFR7U.js} +1 -1
  54. package/dist/gateway/static/root/assets/{markdown-split-CjqlP6IB.js → markdown-split-NK3ACVG2.js} +1 -1
  55. package/dist/gateway/static/root/assets/{markdown-view-BXsHghJd.js → markdown-view-DTF9v1gg.js} +1 -1
  56. package/dist/gateway/static/root/assets/{media-plugins-DQL029DU.js → media-plugins-F0jcUxyl.js} +1 -1
  57. package/dist/gateway/static/root/assets/messages-CHNYp8EQ.js +3 -0
  58. package/dist/gateway/static/root/assets/{mobile-pairing-wizard-gauprAae.js → mobile-pairing-wizard-3NKCniSp.js} +1 -1
  59. package/dist/gateway/static/root/assets/models-hub-cache-nCfkBN8M.js +1 -0
  60. package/dist/gateway/static/root/assets/{notes-page-AsEfLZt9.js → notes-page-DuqLahi6.js} +1 -1
  61. package/dist/gateway/static/root/assets/notes-workbench-C7j9EdQk.js +5 -0
  62. package/dist/gateway/static/root/assets/{oauth-api-BjSUDIgq.js → oauth-api-8lP_qJpq.js} +1 -1
  63. package/dist/gateway/static/root/assets/{product-open-page-CAJeUXeU.js → product-open-page-CxGGlWA8.js} +1 -1
  64. package/dist/gateway/static/root/assets/project-detail-page-CfebYVX0.js +1 -0
  65. package/dist/gateway/static/root/assets/projects-page-48GvzSVa.js +1 -0
  66. package/dist/gateway/static/root/assets/{registry-api-BhGKnvLP.js → registry-api-CIsNlSBi.js} +1 -1
  67. package/dist/gateway/static/root/assets/remote-access-hub-64xj_s2m.js +1 -0
  68. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-DH6EilMV.js → runtime-tools-settings-panel-YkjhiQfA.js} +2 -2
  69. package/dist/gateway/static/root/assets/{schema-form-DYHmEZeZ.js → schema-form-oFGf3G3s.js} +1 -1
  70. package/dist/gateway/static/root/assets/sessions-page-CcwcdRN8.js +1 -0
  71. package/dist/gateway/static/root/assets/settings-advanced-gate-BaN84CyW.js +1 -0
  72. package/dist/gateway/static/root/assets/{settings-page-BHwPd_M3.js → settings-page-C7VWs0IT.js} +1 -1
  73. package/dist/gateway/static/root/assets/setup-status-panel-DVVOCNbr.js +1 -0
  74. package/dist/gateway/static/root/assets/{share-preview-page-BjwrS03F.js → share-preview-page-t5oz18rh.js} +1 -1
  75. package/dist/gateway/static/root/assets/shares-settings-DUYbYLi7.js +1 -0
  76. package/dist/gateway/static/root/assets/skill-reload-api-BGyD0gB9.js +1 -0
  77. package/dist/gateway/static/root/assets/{skills-page-OHyK25op.js → skills-page-CjF8DTsN.js} +1 -1
  78. package/dist/gateway/static/root/assets/{skills-page.utils-DQx9ulmg.js → skills-page.utils-DEDTYs2W.js} +1 -1
  79. package/dist/gateway/static/root/assets/{system-settings-panel-wO7DWv4C.js → system-settings-panel-BSYuRgFI.js} +1 -1
  80. package/dist/gateway/static/root/assets/task-detail-page-YZYSTJH7.js +1 -0
  81. package/dist/gateway/static/root/assets/{theme-store-hybK3oC9.js → theme-store-O597U8q_.js} +1 -1
  82. package/dist/gateway/static/root/assets/{tunnel-api-CVC8BHZu.js → tunnel-api-FKUi9wDL.js} +1 -1
  83. package/dist/gateway/static/root/assets/{use-autosave-DMvRu2XZ.js → use-autosave-B5eUJ6Zq.js} +1 -1
  84. package/dist/gateway/static/root/assets/user-context-page-BCyiduKd.js +2 -0
  85. package/dist/gateway/static/root/assets/{voice-api-key-field-DuBK2NDG.js → voice-api-key-field-CMKSwz4C.js} +1 -1
  86. package/dist/gateway/static/root/assets/{voice-config-api-CBbiF1T3.js → voice-config-api-q7B6fOFB.js} +1 -1
  87. package/dist/gateway/static/root/assets/{work-discovery-overlay-B7VXWpDr.js → work-discovery-overlay-jhT2EzeH.js} +1 -1
  88. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-BokVAsWN.js → workflow-run-setup-panel-DZmvLZjb.js} +2 -2
  89. package/dist/gateway/static/root/assets/workflows-page-DQC0TpMa.js +5 -0
  90. package/dist/gateway/static/root/index.html +12 -12
  91. package/dist/package.js +1 -1
  92. package/dist/src/agent/commands/command-registry.d.ts +1 -0
  93. package/dist/src/agent/commands/command-registry.js +12 -22
  94. package/dist/src/agent/ipc/inbox.d.ts +8 -31
  95. package/dist/src/agent/ipc/inbox.js +64 -133
  96. package/dist/src/agent/service/process-direct-one-shot.js +15 -10
  97. package/dist/src/agent/workflow/catalog.d.ts +1 -8
  98. package/dist/src/agent/workflow/catalog.js +44 -102
  99. package/dist/src/agent/workflow/index.d.ts +1 -1
  100. package/dist/src/agent/workflow/index.js +2 -2
  101. package/dist/src/automations/domain/types.d.ts +1 -0
  102. package/dist/src/automations/service/action-executor.js +2 -2
  103. package/dist/src/automations/service/automation-service.js +2 -2
  104. package/dist/src/channels/manager.d.ts +1 -1
  105. package/dist/src/channels/manager.js +2 -2
  106. package/dist/src/channels/outbound/persist-store.d.ts +2 -8
  107. package/dist/src/channels/outbound/persist-store.js +11 -38
  108. package/dist/src/channels/outbound-sender.d.ts +1 -1
  109. package/dist/src/channels/outbound-sender.js +2 -2
  110. package/dist/src/cli/commands/connectors.js +1 -1
  111. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  112. package/dist/src/config/schema.js +2 -2
  113. package/dist/src/connectors/auth-provider-registry.js +1 -1
  114. package/dist/src/connectors/composio-triggers.d.ts +2 -2
  115. package/dist/src/connectors/composio-triggers.js +8 -15
  116. package/dist/src/connectors/connected-source-ingestion.js +1 -1
  117. package/dist/src/connectors/health.js +1 -1
  118. package/dist/src/gateway/automation-agent-session.js +3 -0
  119. package/dist/src/gateway/heartbeat/service.js +1 -1
  120. package/dist/src/gateway/hono/lib/extension-store.js +8 -25
  121. package/dist/src/gateway/hono/routes/capabilities.js +1 -1
  122. package/dist/src/gateway/hono/routes/connectors.js +3 -3
  123. package/dist/src/gateway/hono/routes/mcp.js +1 -1
  124. package/dist/src/gateway/hono/routes/projects.js +1 -1
  125. package/dist/src/gateway/hono/routes/you.js +20 -4
  126. package/dist/src/gateway/service.js +4 -5
  127. package/dist/src/heartbeat/index.js +1 -1
  128. package/dist/src/notes/index.d.ts +1 -1
  129. package/dist/src/notes/index.js +2 -2
  130. package/dist/src/notes/paths.d.ts +0 -3
  131. package/dist/src/notes/paths.js +1 -10
  132. package/dist/src/notes/service.d.ts +0 -1
  133. package/dist/src/notes/service.js +0 -3
  134. package/dist/src/notes/store.d.ts +0 -2
  135. package/dist/src/notes/store.js +33 -80
  136. package/dist/src/share/hosted-session-share.d.ts +1 -4
  137. package/dist/src/share/hosted-session-share.js +14 -47
  138. package/dist/src/share/share-auto.d.ts +1 -1
  139. package/dist/src/share/share-auto.js +2 -2
  140. package/dist/src/share/share-store.d.ts +2 -7
  141. package/dist/src/share/share-store.js +153 -195
  142. package/dist/src/share/share-types.d.ts +0 -4
  143. package/dist/src/share/site-share-store.d.ts +3 -8
  144. package/dist/src/share/site-share-store.js +94 -153
  145. package/dist/src/share/site-share-types.d.ts +0 -4
  146. package/dist/src/storage/sqlite/connection.d.ts +1 -2
  147. package/dist/src/storage/sqlite/connection.js +50 -47
  148. package/dist/src/storage/sqlite/durable-queue.d.ts +16 -0
  149. package/dist/src/storage/sqlite/durable-queue.js +52 -0
  150. package/dist/src/storage/sqlite/durable-state.d.ts +16 -0
  151. package/dist/src/storage/sqlite/durable-state.js +43 -0
  152. package/dist/src/storage/sqlite/migrations/146_understanding_focus_exclusions.sql +9 -0
  153. package/dist/src/storage/sqlite/migrations/147_durable_application_state.sql +39 -0
  154. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  155. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  156. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  157. package/dist/src/storage/sqlite/schema.js +1 -1
  158. package/dist/src/storage/sqlite/understanding-focus-exclusions.d.ts +2 -0
  159. package/dist/src/storage/sqlite/understanding-focus-exclusions.js +24 -0
  160. package/dist/src/tui/tui-scoped-models.js +9 -6
  161. package/dist/src/tui/tui-startup-resources.js +1 -1
  162. package/dist/src/voice/dashscope/streaming-tts-stream.js +49 -0
  163. package/dist/src/voice/realtime/agentEngine.js +63 -18
  164. package/dist/src/voice/realtime/conversationTurn.d.ts +20 -0
  165. package/dist/src/voice/realtime/conversationTurn.js +83 -0
  166. package/dist/src/voice/realtime/omniEngine.js +72 -18
  167. package/dist/src/workflows/authoring/workflow-draft-store.d.ts +1 -5
  168. package/dist/src/workflows/authoring/workflow-draft-store.js +23 -43
  169. package/dist/src/workflows/index.js +2 -2
  170. package/dist/src/workflows/store/event-store.d.ts +1 -2
  171. package/dist/src/workflows/store/event-store.js +19 -64
  172. package/dist/src/workflows/store/paths.d.ts +0 -2
  173. package/dist/src/workflows/store/paths.js +1 -7
  174. package/dist/src/workflows/store/run-store.d.ts +0 -1
  175. package/dist/src/workflows/store/run-store.js +1 -24
  176. package/package.json +3 -3
  177. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-0dRjnL2s.js +0 -1
  178. package/dist/gateway/static/root/assets/apps-page-EpUZsl4h.js +0 -1
  179. package/dist/gateway/static/root/assets/automations-workspace-BGQdHrip.js +0 -6
  180. package/dist/gateway/static/root/assets/browser-settings-page-DJGcm7rH.js +0 -8
  181. package/dist/gateway/static/root/assets/channels-settings-BcIr-_GM.js +0 -1
  182. package/dist/gateway/static/root/assets/connectors-page-DNHqaZfX.js +0 -2
  183. package/dist/gateway/static/root/assets/home-page-CaVvW77l.js +0 -1
  184. package/dist/gateway/static/root/assets/index-Dbh5SXyV.css +0 -2
  185. package/dist/gateway/static/root/assets/local-app-workbench-page-D3K1XmOM.js +0 -2
  186. package/dist/gateway/static/root/assets/messages-BbdwoxVo.js +0 -3
  187. package/dist/gateway/static/root/assets/models-hub-cache-88f4fzYS.js +0 -1
  188. package/dist/gateway/static/root/assets/notes-workbench-CI30cDh3.js +0 -4
  189. package/dist/gateway/static/root/assets/project-detail-page-jO_4I5zN.js +0 -1
  190. package/dist/gateway/static/root/assets/projects-page-BrTGFME0.js +0 -1
  191. package/dist/gateway/static/root/assets/remote-access-hub-CH70D5SH.js +0 -1
  192. package/dist/gateway/static/root/assets/sessions-page-hbfUNtNs.js +0 -1
  193. package/dist/gateway/static/root/assets/settings-advanced-gate-Vg3_jua6.js +0 -1
  194. package/dist/gateway/static/root/assets/setup-status-panel-DkcpWSss.js +0 -1
  195. package/dist/gateway/static/root/assets/shares-settings-BL4DEt6p.js +0 -1
  196. package/dist/gateway/static/root/assets/skill-reload-api-CafhNktn.js +0 -1
  197. package/dist/gateway/static/root/assets/task-detail-page-anyomXsu.js +0 -1
  198. package/dist/gateway/static/root/assets/user-context-page-BBk9YdBn.js +0 -1
  199. package/dist/gateway/static/root/assets/workflows-page-RUTv0yvR.js +0 -5
@@ -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{l as i,p as a,t as o}from"./chunk-KS7C4IRE-BaASWQor.js";import{a as s,i as c,o as l,r as u,s as d,t as f}from"./dist-CpzYSoz7.js";import{t as p}from"./check-DUBLcKHA.js";import{t as m}from"./copy-Dv6d4Dvw.js";import{t as h}from"./external-link-DjqjBmc3.js";import{t as g}from"./globe-DSSGFWFn.js";import{t as _}from"./loader-circle-CifKLtgG.js";import{t as v}from"./copy-to-clipboard-HOJ79TWv.js";import{t as y}from"./messages-BbdwoxVo.js";import{n as b,s as x}from"./locale-store-CBoCuIMx.js";import{t as S}from"./cn-JdwAhgNB.js";import{i as C}from"./vendor-swr-BIWyz7Rc.js";import{t as w}from"./button-CtTvuElV.js";import{n as T,r as E}from"./gateway-config-swr-826dipyU.js";import{i as D,o as O}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{a as k,n as A,r as j}from"./oauth-api-BjSUDIgq.js";import{$l as M,Fl as N,Hr as P,Li as F,Ll as I,Ts as L,Us as R,Vc as z,Vs as B,Xs as V,ac as H,eo as ee,ht as te,ks as U,ri as ne,vc as W,wl as re}from"./index-eZjksPvq.js";import{n as G,r as K,t as q}from"./settings-page-layout-BRQNel6r.js";import{a as ie,c as ae,d as J,g as oe,i as se,l as ce,n as Y,o as le,r as ue,s as de,t as fe,u as pe}from"./tunnel-api-CVC8BHZu.js";import{n as X,r as me,t as he}from"./settings-form-section-DjWzRk4z.js";import{n as ge,r as _e,t as ve}from"./oauth-authorization-window-Cdolr2wE.js";import{t as ye}from"./page-tabs-BaEQMYm_.js";import{t as be}from"./settings-advanced-gate-Vg3_jua6.js";var Z=e(t(),1),Q=n(),$=r();function xe(e){switch(e){case`active`:return`bg-emerald-500/15 text-emerald-700 dark:text-emerald-400`;case`connecting`:return`bg-amber-500/15 text-amber-700 dark:text-amber-400`;default:return`bg-surface-hover text-fg-muted`}}function Se(e){let t=(0,Q.c)(5),{label:n,kind:r}=e,i;t[0]===r?i=t[1]:(i=S(`rounded-full px-2 py-0.5 text-[11px] font-medium`,xe(r)),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,$.jsx)(`span`,{className:i,children:n}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}function Ce(e){let t=(0,Q.c)(31),{onOpenTab:n}=e,r=b(Te),i;t[0]===r?i=t[1]:(i=y(r),t[0]=r,t[1]=i);let a=i.remoteAccess.guide,o=!!x(we),s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s={refreshInterval:3e4},t[2]=s):s=t[2];let{data:c}=C(o?`exposure-status`:null,pe,s),l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l={refreshInterval:15e3},t[3]=l):l=t[3];let{data:u}=C(o?`tunnel-status`:null,fe,l),d=E(o);if(!o)return null;let f=c?.tailscale.active===!0,p=u?.state,m=u?.enabled&&p===`connected`,h=u?.enabled&&(p===`connecting`||p===`reconnecting`||!!u?.startProgress||!!u?.frpcDownload),_=d.data?.payload?.config,v=!!(_&&typeof _==`object`&&!Array.isArray(_)&&_.gateway?.publicUrl),w=f?`active`:`off`,T=f?a.statusActive:a.statusOff,D;t[4]!==a.tailscaleCardTitle||t[5]!==w||t[6]!==T?(D={tab:`tailscale`,icon:g,title:a.tailscaleCardTitle,kind:w,statusLabel:T},t[4]=a.tailscaleCardTitle,t[5]=w,t[6]=T,t[7]=D):D=t[7];let O=m?`active`:h?`connecting`:`off`,k=m?a.statusActive:h?a.statusConnecting:a.statusOff,A;t[8]!==a.publicCardTitle||t[9]!==O||t[10]!==k?(A={tab:`public`,icon:W,title:a.publicCardTitle,kind:O,statusLabel:k},t[8]=a.publicCardTitle,t[9]=O,t[10]=k,t[11]=A):A=t[11];let j=v?`active`:`off`,M=v?a.statusActive:a.statusOff,N;t[12]!==a.reverseProxyCardTitle||t[13]!==j||t[14]!==M?(N={tab:`reverse-proxy`,icon:R,title:a.reverseProxyCardTitle,kind:j,statusLabel:M},t[12]=a.reverseProxyCardTitle,t[13]=j,t[14]=M,t[15]=N):N=t[15];let P;t[16]!==a.sshCardStatus||t[17]!==a.sshCardTitle?(P={tab:`ssh`,icon:U,title:a.sshCardTitle,kind:`off`,statusLabel:a.sshCardStatus},t[16]=a.sshCardStatus,t[17]=a.sshCardTitle,t[18]=P):P=t[18];let F;t[19]!==a.lanCardStatus||t[20]!==a.lanCardTitle?(F={tab:`lan`,icon:V,title:a.lanCardTitle,kind:`off`,statusLabel:a.lanCardStatus},t[19]=a.lanCardStatus,t[20]=a.lanCardTitle,t[21]=F):F=t[21];let I;t[22]!==N||t[23]!==P||t[24]!==F||t[25]!==D||t[26]!==A?(I=[D,A,N,P,F],t[22]=N,t[23]=P,t[24]=F,t[25]=D,t[26]=A,t[27]=I):I=t[27];let L=I,z;return t[28]!==L||t[29]!==n?(z=(0,$.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-5`,children:L.map(e=>{let t=e.icon;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e.tab),className:S(`flex items-start gap-3 rounded-xl bg-surface-base px-3 py-2.5 text-left shadow-surface transition-colors`,`hover:bg-surface-hover/50`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,$.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted`,children:(0,$.jsx)(t,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:e.title}),(0,$.jsx)(Se,{label:e.statusLabel,kind:e.kind})]})]},`${e.tab}-${e.title}`)})}),t[28]=L,t[29]=n,t[30]=z):z=t[30],z}function we(e){return e.token}function Te(e){return e.language}function Ee(e){let t=(0,Q.c)(26),{title:n,description:r,recommended:i,icon:a,onOpen:o,openLabel:s,recommendedLabel:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=S(`group flex w-full flex-col rounded-2xl bg-surface-base p-4 text-left transition-colors`,`hover:bg-surface-hover/40`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),t[0]=l):l=t[0];let u;t[1]===a?u=t[2]:(u=(0,$.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted`,children:(0,$.jsx)(a,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[1]=a,t[2]=u);let d;t[3]===n?d=t[4]:(d=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[3]=n,t[4]=d);let f;t[5]!==i||t[6]!==c?(f=i&&c?(0,$.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:c}):null,t[5]=i,t[6]=c,t[7]=f):f=t[7];let p;t[8]!==d||t[9]!==f?(p=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[d,f]}),t[8]=d,t[9]=f,t[10]=p):p=t[10];let m;t[11]===r?m=t[12]:(m=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:r}),t[11]=r,t[12]=m);let h;t[13]!==p||t[14]!==m?(h=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[p,m]}),t[13]=p,t[14]=m,t[15]=h):h=t[15];let g;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(N,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0}),t[16]=g):g=t[16];let _;t[17]!==u||t[18]!==h?(_=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[u,h,g]}),t[17]=u,t[18]=h,t[19]=_):_=t[19];let v;t[20]===s?v=t[21]:(v=(0,$.jsx)(`span`,{className:`mt-3 text-xs font-medium text-accent`,children:s}),t[20]=s,t[21]=v);let y;return t[22]!==o||t[23]!==v||t[24]!==_?(y=(0,$.jsxs)(`button`,{type:`button`,onClick:o,className:l,children:[_,v]}),t[22]=o,t[23]=v,t[24]=_,t[25]=y):y=t[25],y}function De(e){let t=(0,Q.c)(83),{onOpenTab:n}=e,r=b(Ae),i;t[0]===r?i=t[1]:(i=y(r),t[0]=r,t[1]=i);let a=i.remoteAccess,o=a.guide,s=!!x(ke),c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c={refreshInterval:3e4},t[2]=c):c=t[2];let{data:l}=C(s?`exposure-status`:null,pe,c),u;t[3]===l?.conflicts?u=t[4]:(u=l?.conflicts??[],t[3]=l?.conflicts,t[4]=u);let d=u;if(!s){let e;return t[5]===o.needToken?e=t[6]:(e=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.needToken}),t[5]=o.needToken,t[6]=e),e}let f;t[7]===n?f=t[8]:(f=(0,$.jsx)(Ce,{onOpenTab:n}),t[7]=n,t[8]=f);let p;t[9]!==d||t[10]!==o.conflictsHint||t[11]!==o.conflictsTitle?(p=d.length>0?(0,$.jsxs)(`div`,{className:`rounded-xl border border-amber-500/30 bg-amber-500/5 px-4 py-3 text-sm text-fg-muted`,children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:o.conflictsTitle}),(0,$.jsx)(`p`,{className:`mt-1`,children:o.conflictsHint}),(0,$.jsx)(`ul`,{className:`mt-2 list-inside list-disc text-xs`,children:d.map(Oe)})]}):null,t[9]=d,t[10]=o.conflictsHint,t[11]=o.conflictsTitle,t[12]=p):p=t[12];let m;t[13]===o.pickMethod?m=t[14]:(m=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:o.pickMethod}),t[13]=o.pickMethod,t[14]=m);let h;t[15]===n?h=t[16]:(h=()=>n(`tailscale`),t[15]=n,t[16]=h);let _;t[17]!==o.configure||t[18]!==o.recommended||t[19]!==o.tailscaleCardDesc||t[20]!==o.tailscaleCardTitle||t[21]!==h?(_=(0,$.jsx)(Ee,{icon:g,title:o.tailscaleCardTitle,description:o.tailscaleCardDesc,recommended:!0,recommendedLabel:o.recommended,openLabel:o.configure,onOpen:h}),t[17]=o.configure,t[18]=o.recommended,t[19]=o.tailscaleCardDesc,t[20]=o.tailscaleCardTitle,t[21]=h,t[22]=_):_=t[22];let v;t[23]===n?v=t[24]:(v=()=>n(`public`),t[23]=n,t[24]=v);let S;t[25]!==o.configure||t[26]!==o.publicCardDesc||t[27]!==o.publicCardTitle||t[28]!==v?(S=(0,$.jsx)(Ee,{icon:W,title:o.publicCardTitle,description:o.publicCardDesc,openLabel:o.configure,onOpen:v}),t[25]=o.configure,t[26]=o.publicCardDesc,t[27]=o.publicCardTitle,t[28]=v,t[29]=S):S=t[29];let w;t[30]===n?w=t[31]:(w=()=>n(`reverse-proxy`),t[30]=n,t[31]=w);let T;t[32]!==o.configure||t[33]!==o.reverseProxyCardDesc||t[34]!==o.reverseProxyCardTitle||t[35]!==w?(T=(0,$.jsx)(Ee,{icon:R,title:o.reverseProxyCardTitle,description:o.reverseProxyCardDesc,openLabel:o.configure,onOpen:w}),t[32]=o.configure,t[33]=o.reverseProxyCardDesc,t[34]=o.reverseProxyCardTitle,t[35]=w,t[36]=T):T=t[36];let E;t[37]===n?E=t[38]:(E=()=>n(`ssh`),t[37]=n,t[38]=E);let D;t[39]!==o.configure||t[40]!==o.sshCardDesc||t[41]!==o.sshCardTitle||t[42]!==E?(D=(0,$.jsx)(Ee,{icon:U,title:o.sshCardTitle,description:o.sshCardDesc,openLabel:o.configure,onOpen:E}),t[39]=o.configure,t[40]=o.sshCardDesc,t[41]=o.sshCardTitle,t[42]=E,t[43]=D):D=t[43];let O;t[44]===n?O=t[45]:(O=()=>n(`lan`),t[44]=n,t[45]=O);let k;t[46]!==o.configure||t[47]!==o.lanCardDesc||t[48]!==o.lanCardTitle||t[49]!==O?(k=(0,$.jsx)(Ee,{icon:V,title:o.lanCardTitle,description:o.lanCardDesc,openLabel:o.configure,onOpen:O}),t[46]=o.configure,t[47]=o.lanCardDesc,t[48]=o.lanCardTitle,t[49]=O,t[50]=k):k=t[50];let A;t[51]!==S||t[52]!==T||t[53]!==D||t[54]!==k||t[55]!==_?(A=(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:[_,S,T,D,k]}),t[51]=S,t[52]=T,t[53]=D,t[54]=k,t[55]=_,t[56]=A):A=t[56];let j;t[57]!==A||t[58]!==m?(j=(0,$.jsxs)(`div`,{children:[m,A]}),t[57]=A,t[58]=m,t[59]=j):j=t[59];let M;t[60]===o.oneAtATimeHint?M=t[61]:(M=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:o.oneAtATimeHint}),t[60]=o.oneAtATimeHint,t[61]=M);let N;t[62]===a.advanced.proxyTitle?N=t[63]:(N=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.advanced.proxyTitle}),t[62]=a.advanced.proxyTitle,t[63]=N);let P;t[64]===a.advanced.proxyBody?P=t[65]:(P=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:a.advanced.proxyBody}),t[64]=a.advanced.proxyBody,t[65]=P);let F;t[66]!==r||t[67]!==a.advanced.proxyDocs?(F=(0,$.jsx)(J,{language:r,label:a.advanced.proxyDocs,section:`advanced`,className:`mt-2`}),t[66]=r,t[67]=a.advanced.proxyDocs,t[68]=F):F=t[68];let I;t[69]!==N||t[70]!==P||t[71]!==F?(I=(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-base px-4 py-3`,children:[N,P,F]}),t[69]=N,t[70]=P,t[71]=F,t[72]=I):I=t[72];let L;t[73]!==o.docsLink||t[74]!==r?(L=(0,$.jsx)(J,{language:r,label:o.docsLink}),t[73]=o.docsLink,t[74]=r,t[75]=L):L=t[75];let z;return t[76]!==j||t[77]!==M||t[78]!==I||t[79]!==L||t[80]!==f||t[81]!==p?(z=(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[f,p,j,M,I,L]}),t[76]=j,t[77]=M,t[78]=I,t[79]=L,t[80]=f,t[81]=p,t[82]=z):z=t[82],z}function Oe(e){return(0,$.jsx)(`li`,{children:e.message},e.code)}function ke(e){return e.token}function Ae(e){return e.language}function je(){let e=(0,Q.c)(16),t=b(Me),n;e[0]===t?n=e[1]:(n=y(t),e[0]=t,e[1]=n);let r=n.remoteAccess.lan,i;e[2]!==r.subtitle||e[3]!==r.title?(i=(0,$.jsx)(X,{icon:V,title:r.title,subtitle:r.subtitle}),e[2]=r.subtitle,e[3]=r.title,e[4]=i):i=e[4];let a;e[5]===r.body?a=e[6]:(a=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.body}),e[5]=r.body,e[6]=a);let s;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(h,{className:`size-3.5`,"aria-hidden":!0}),e[7]=s):s=e[7];let c;e[8]===r.link?c=e[9]:(c=(0,$.jsxs)(o,{to:`/settings/gateway`,className:`inline-flex items-center gap-1.5 text-sm font-medium text-accent hover:underline`,children:[r.link,s]}),e[8]=r.link,e[9]=c);let l;e[10]!==a||e[11]!==c?(l=(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[a,c]}),e[10]=a,e[11]=c,e[12]=l):l=e[12];let u;return e[13]!==i||e[14]!==l?(u=(0,$.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,$.jsxs)(he,{children:[i,l]})}),e[13]=i,e[14]=l,e[15]=u):u=e[15],u}function Me(e){return e.language}function Ne(e){let t=(0,Q.c)(30),{embedded:n}=e,r=n===void 0?!1:n,i=b(Pe),a;t[0]===i?a=t[1]:(a=y(i),t[0]=i,t[1]=a);let o=a.remoteAccess.ssh,[s,c]=(0,Z.useState)(!1),l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=async()=>{await v(`xopc gateway ssh-tunnel --target user@your-host --local-port 18790 --remote-port 18790`)&&(c(!0),setTimeout(()=>c(!1),2e3))},t[2]=l):l=t[2];let u=l,d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(`pre`,{className:`overflow-x-auto rounded-lg border border-edge bg-surface px-3 py-2 text-xs text-fg-muted`,children:`xopc gateway ssh-tunnel --target user@your-host --local-port 18790 --remote-port 18790`}),t[3]=d):d=t[3];let f,p;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>void u(),p=(0,$.jsx)(m,{className:`mr-1 size-4`}),t[4]=f,t[5]=p):(f=t[4],p=t[5]);let h=s?o.copied:o.copy,g;t[6]===h?g=t[7]:(g=(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsxs)(w,{type:`button`,variant:`ghost`,onClick:f,children:[p,h]})}),t[6]=h,t[7]=g);let _;t[8]!==r||t[9]!==o.hint?(_=r?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:o.hint}):null,t[8]=r,t[9]=o.hint,t[10]=_):_=t[10];let x;t[11]!==g||t[12]!==_?(x=(0,$.jsxs)($.Fragment,{children:[d,g,_]}),t[11]=g,t[12]=_,t[13]=x):x=t[13];let S=x;if(r){let e;t[14]!==o.subtitle||t[15]!==o.title?(e=(0,$.jsx)(X,{icon:U,title:o.title,subtitle:o.subtitle}),t[14]=o.subtitle,t[15]=o.title,t[16]=e):e=t[16];let n;t[17]===S?n=t[18]:(n=(0,$.jsx)(`div`,{className:`mt-4 space-y-2`,children:S}),t[17]=S,t[18]=n);let r;return t[19]!==e||t[20]!==n?(r=(0,$.jsxs)(he,{children:[e,n]}),t[19]=e,t[20]=n,t[21]=r):r=t[21],r}let C;t[22]!==o.subtitle||t[23]!==o.title?(C=(0,$.jsx)(X,{icon:U,title:o.title,subtitle:o.subtitle}),t[22]=o.subtitle,t[23]=o.title,t[24]=C):C=t[24];let T;t[25]===S?T=t[26]:(T=(0,$.jsx)(`div`,{className:`mt-4`,children:S}),t[25]=S,t[26]=T);let E;return t[27]!==C||t[28]!==T?(E=(0,$.jsxs)(he,{children:[C,T]}),t[27]=C,t[28]=T,t[29]=E):E=t[29],E}function Pe(e){return e.language}function Fe(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Ne,{embedded:!0}),e[0]=t):t=e[0],t}var Ie=[`guide`,`tailscale`,`public`,`reverse-proxy`,`ssh`,`lan`];function Le(e){return e&&Ie.includes(e)?e:`guide`}function Re(e){let t=(0,Q.c)(26),{showLabel:n,hideLabel:r,icon:i,hint:a,children:o,className:s,defaultOpen:c,advancedOnly:l}=e,u=l===void 0?!1:l,[d,f]=(0,Z.useState)(c??!1),p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=e=>f(e.currentTarget.open),t[0]=p):p=t[0];let m;t[1]===s?m=t[2]:(m=S(`group rounded-2xl bg-surface-base open:pb-1`,s),t[1]=s,t[2]=m);let h;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(I,{className:`size-4 shrink-0 text-fg-muted transition-transform group-open:rotate-180`,"aria-hidden":!0}),t[3]=h):h=t[3];let g;t[4]===i?g=t[5]:(g=i?(0,$.jsx)(i,{className:`size-4 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}):null,t[4]=i,t[5]=g);let _;t[6]===n?_=t[7]:(_=(0,$.jsx)(`span`,{className:`group-open:hidden`,children:n}),t[6]=n,t[7]=_);let v;t[8]===r?v=t[9]:(v=(0,$.jsx)(`span`,{className:`hidden group-open:inline`,children:r}),t[8]=r,t[9]=v);let y;t[10]!==g||t[11]!==_||t[12]!==v?(y=(0,$.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 rounded-2xl px-4 py-3.5 text-sm font-medium text-fg transition-colors hover:text-fg group-open:rounded-b-none [&::-webkit-details-marker]:hidden`,children:[h,g,_,v]}),t[10]=g,t[11]=_,t[12]=v,t[13]=y):y=t[13];let b;t[14]===a?b=t[15]:(b=a?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:a}):null,t[14]=a,t[15]=b);let x;t[16]!==o||t[17]!==b?(x=(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 px-4 pb-4 pt-1`,children:[b,o]}),t[16]=o,t[17]=b,t[18]=x):x=t[18];let C;t[19]!==d||t[20]!==x||t[21]!==m||t[22]!==y?(C=(0,$.jsxs)(`details`,{open:d,onToggle:p,className:m,children:[y,x]}),t[19]=d,t[20]=x,t[21]=m,t[22]=y,t[23]=C):C=t[23];let w=C;if(u){let e;return t[24]===w?e=t[25]:(e=(0,$.jsx)(be,{children:w}),t[24]=w,t[25]=e),e}return w}function ze(e){let t=(0,Q.c)(40),{open:n,title:r,intro:i,bullets:a,checkboxLabel:o,confirmLabel:p,cancelLabel:m,onConfirm:h,onCancel:g}=e,[_,v]=(0,Z.useState)(!1),y;t[0]===g?y=t[1]:(y=e=>{e||(v(!1),g())},t[0]=g,t[1]=y);let b;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(s,{className:S(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,O)}),t[2]=b):b=t[2];let x;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(x=S(`fixed left-1/2 top-1/2 max-h-[min(90vh,40rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2`,`overflow-y-auto rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`,D),t[3]=x):x=t[3];let C;t[4]===r?C=t[5]:(C=(0,$.jsx)(d,{className:`text-base font-semibold text-fg`,children:r}),t[4]=r,t[5]=C);let T;t[6]===i?T=t[7]:(T=(0,$.jsx)(c,{className:`mt-2 text-sm text-fg-muted`,children:i}),t[6]=i,t[7]=T);let E;t[8]===a?E=t[9]:(E=a.map(Be),t[8]=a,t[9]=E);let k;t[10]===E?k=t[11]:(k=(0,$.jsx)(`ul`,{className:`mt-4 list-disc space-y-2 pl-5 text-sm text-fg-muted`,children:E}),t[10]=E,t[11]=k);let A;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(A=e=>v(e.target.checked),t[12]=A):A=t[12];let j;t[13]===_?j=t[14]:(j=(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 shrink-0 rounded border-edge accent-accent`,checked:_,onChange:A}),t[13]=_,t[14]=j);let M;t[15]===o?M=t[16]:(M=(0,$.jsx)(`span`,{children:o}),t[15]=o,t[16]=M);let N;t[17]!==M||t[18]!==j?(N=(0,$.jsxs)(`label`,{className:`mt-5 flex cursor-pointer items-start gap-3 text-sm text-fg`,children:[j,M]}),t[17]=M,t[18]=j,t[19]=N):N=t[19];let P;t[20]!==m||t[21]!==g?(P=(0,$.jsx)(w,{type:`button`,variant:`secondary`,onClick:g,children:m}),t[20]=m,t[21]=g,t[22]=P):P=t[22];let F=!_,I;t[23]!==p||t[24]!==h||t[25]!==F?(I=(0,$.jsx)(w,{type:`button`,disabled:F,onClick:h,children:p}),t[23]=p,t[24]=h,t[25]=F,t[26]=I):I=t[26];let L;t[27]!==P||t[28]!==I?(L=(0,$.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[P,I]}),t[27]=P,t[28]=I,t[29]=L):L=t[29];let R;t[30]!==N||t[31]!==L||t[32]!==C||t[33]!==T||t[34]!==k?(R=(0,$.jsxs)(l,{children:[b,(0,$.jsxs)(u,{className:x,onOpenAutoFocus:Ve,children:[C,T,k,N,L]})]}),t[30]=N,t[31]=L,t[32]=C,t[33]=T,t[34]=k,t[35]=R):R=t[35];let z;return t[36]!==n||t[37]!==y||t[38]!==R?(z=(0,$.jsx)(f,{open:n,onOpenChange:y,children:R}),t[36]=n,t[37]=y,t[38]=R,t[39]=z):z=t[39],z}function Be(e){return(0,$.jsx)(`li`,{children:e},e)}function Ve(e){return e.preventDefault()}function He(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var Ue=[`preparing_frpc`,`registering`,`starting_frpc`];function We(e){return e?e===`reconnecting_frpc`?Ue.indexOf(`starting_frpc`):Ue.indexOf(e):-1}function Ge(e,t){if(t.state===`connected`)return`done`;let n=t.startProgress?.phase,r=Ue.indexOf(e),i=We(n);return i<0?t.state===`connecting`||t.state===`reconnecting`?`active`:`pending`:r<i?`done`:r===i?`active`:`pending`}function Ke(e,t,n){let r=n.startProgress;return Ge(t,n)===`active`?t===`preparing_frpc`&&n.frpcDownload?n.frpcDownload.phase===`extracting`?e.frpcExtracting:n.frpcDownload.percent==null?e.frpcDownloading:e.frpcDownloadingPercent.replace(`{{percent}}`,String(n.frpcDownload.percent)):t===`registering`&&r?.publicUrl?e.stepRegisterDetail:t===`starting_frpc`?r?.phase===`reconnecting_frpc`?e.stepReconnectDetail:e.stepFrpcDetail:null:null}function qe(e,t){switch(t){case`preparing_frpc`:return e.stepPrepareFrpc;case`registering`:return e.stepRegister;case`starting_frpc`:return e.stepFrpcLogin}}function Je(e){if(!e)return null;let t=Math.max(0,Math.floor((Date.now()-new Date(e).getTime())/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function Ye(e){let t=(0,Q.c)(31),{status:n,t:r}=e,[,i]=(0,Z.useState)(0),a;t[0]!==i||t[1]!==n.state?(a=()=>{if(n.state!==`connecting`&&n.state!==`reconnecting`)return;let e=window.setInterval(()=>i(Xe),1e3);return()=>window.clearInterval(e)},t[0]=i,t[1]=n.state,t[2]=a):a=t[2];let o=n.startProgress?.startedAt,s;if(t[3]!==n.state||t[4]!==o?(s=[n.state,o],t[3]=n.state,t[4]=o,t[5]=s):s=t[5],(0,Z.useEffect)(a,s),!(n.state===`connecting`||n.state===`reconnecting`||n.state===`connected`&&n.startProgress))return null;let c,l,u,d,f;if(t[6]!==n||t[7]!==r){let e=Je(n.startProgress?.startedAt);c=!!n.publicUrl&&n.state!==`connected`&&n.startProgress?.phase!==`registering`,l=`mt-3 space-y-3 rounded-lg bg-surface-panel/80 p-3 shadow-surface`;let i;t[13]===r.startProgressTitle?i=t[14]:(i=(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:r.startProgressTitle}),t[13]=r.startProgressTitle,t[14]=i);let a;t[15]===r.startProgressHint?a=t[16]:(a=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:r.startProgressHint}),t[15]=r.startProgressHint,t[16]=a),t[17]!==i||t[18]!==a?(u=(0,$.jsxs)(`div`,{children:[i,a]}),t[17]=i,t[18]=a,t[19]=u):u=t[19];let o=Ue.map(e=>{let t=Ge(e,n),i=Ke(r,e,n);return(0,$.jsxs)(`li`,{className:`flex gap-2 text-xs`,children:[(0,$.jsx)(`span`,{className:`mt-0.5 shrink-0 text-fg-subtle`,"aria-hidden":!0,children:t===`done`?(0,$.jsx)(p,{className:`size-3.5 text-emerald-600 dark:text-emerald-400`}):t===`active`?(0,$.jsx)(_,{className:`size-3.5 animate-spin text-accent`}):(0,$.jsx)(re,{className:`size-3.5`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:S(`font-medium`,t===`active`?`text-fg`:t===`done`?`text-fg-muted`:`text-fg-subtle`),children:qe(r,e)}),i?(0,$.jsx)(`div`,{className:`mt-0.5 text-fg-muted`,children:i}):null,e===`preparing_frpc`&&t===`active`&&n.frpcDownload&&n.frpcDownload.phase===`downloading`?(0,$.jsxs)(`div`,{className:`mt-2 space-y-1`,children:[(0,$.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-surface-panel`,children:(0,$.jsx)(`div`,{className:S(`h-full rounded-full bg-accent transition-[width] duration-300`,n.frpcDownload.percent==null&&`w-1/3 animate-pulse`),style:n.frpcDownload.percent==null?void 0:{width:`${n.frpcDownload.percent}%`}})}),n.frpcDownload.bytesReceived!=null&&n.frpcDownload.totalBytes?(0,$.jsxs)(`p`,{className:`text-fg-subtle`,children:[He(n.frpcDownload.bytesReceived),` /`,` `,He(n.frpcDownload.totalBytes)]}):null]}):null,e===`preparing_frpc`&&t===`active`&&n.frpcDownload?.url?(0,$.jsxs)(`p`,{className:`mt-2 text-fg-subtle`,children:[(0,$.jsxs)(`span`,{className:`font-sans`,children:[r.frpcDownloadingUrlLabel,`: `]}),(0,$.jsx)(`a`,{href:n.frpcDownload.url,target:`_blank`,rel:`noopener noreferrer`,className:`break-all font-mono text-[11px] text-accent hover:underline`,children:n.frpcDownload.url})]}):null]})]},e)});t[20]===o?d=t[21]:(d=(0,$.jsx)(`ol`,{className:`space-y-2`,children:o}),t[20]=o,t[21]=d),f=e&&n.startProgress?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.startProgressElapsed.replace(`{{elapsed}}`,e)}):null,t[6]=n,t[7]=r,t[8]=c,t[9]=l,t[10]=u,t[11]=d,t[12]=f}else c=t[8],l=t[9],u=t[10],d=t[11],f=t[12];let m;t[22]!==c||t[23]!==r.publicUrlPendingNotice?(m=c?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.publicUrlPendingNotice}):null,t[22]=c,t[23]=r.publicUrlPendingNotice,t[24]=m):m=t[24];let h;return t[25]!==l||t[26]!==u||t[27]!==d||t[28]!==f||t[29]!==m?(h=(0,$.jsxs)(`div`,{className:l,children:[u,d,f,m]}),t[25]=l,t[26]=u,t[27]=d,t[28]=f,t[29]=m,t[30]=h):h=t[30],h}function Xe(e){return e+1}function Ze(e,t){return t.state===`connected`?e.statusConnected:t.state===`error`?e.statusError:t.startProgress?.phase===`reconnecting_frpc`?e.statusReconnecting:t.startProgress?.phase===`starting_frpc`?e.statusStartingFrpc:t.startProgress?.phase===`registering`?e.statusRegistering:t.startProgress?.phase===`preparing_frpc`||t.frpcDownload?e.statusPreparingFrpc:t.state===`connecting`||t.state===`reconnecting`?e.statusConnecting:e.statusOff}function Qe(e){return e.state===`connected`?`connected`:e.state===`error`?`error`:e.state===`connecting`||e.state===`reconnecting`||e.startProgress||e.frpcDownload?`progress`:`off`}function $e(e){switch(e){case`connected`:return`bg-emerald-500/15 text-emerald-700 dark:text-emerald-400`;case`progress`:return`bg-amber-500/15 text-amber-700 dark:text-amber-400`;case`error`:return`bg-red-500/15 text-red-700 dark:text-red-400`;default:return`bg-surface-hover text-fg-muted`}}function et(e){if(!e)return`—`;let t=Date.now()-new Date(e).getTime();if(t<0)return`—`;let n=Math.floor(t/6e4);return n<60?`${n}m`:`${Math.floor(n/60)}h ${n%60}m`}function tt(e){let t=(0,Q.c)(61),{t:n,status:r,isLoading:i,statusErr:a,starting:o,stopping:s,showConsentExpired:c,copyLabels:l,startDisabled:u,startDisabledReason:d,stepLabel:f,onStart:p,onStop:m}=e,h=u===void 0?!1:u,v,y,b,x,C,T,E;t[0]!==r||t[1]!==o?(E=Qe(r),v=r.enabled||o,y=o||r.state===`connecting`||r.state===`reconnecting`||!!r.startProgress||!!r.frpcDownload,t[9]===Symbol.for(`react.memo_cache_sentinel`)?(T=S(me(),`space-y-4`),t[9]=T):T=t[9],C=`flex flex-wrap items-start justify-between gap-3`,x=`flex items-center gap-2`,b=S(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,$e(E)),t[0]=r,t[1]=o,t[2]=v,t[3]=y,t[4]=b,t[5]=x,t[6]=C,t[7]=T,t[8]=E):(v=t[2],y=t[3],b=t[4],x=t[5],C=t[6],T=t[7],E=t[8]);let D=E===`connected`&&`bg-emerald-500`,O=E===`progress`&&`bg-amber-500 animate-pulse`,k=E===`error`&&`bg-red-500`,A=E===`off`&&`bg-fg-subtle`,j;t[10]!==D||t[11]!==O||t[12]!==k||t[13]!==A?(j=S(`size-1.5 rounded-full`,D,O,k,A),t[10]=D,t[11]=O,t[12]=k,t[13]=A,t[14]=j):j=t[14];let M;t[15]===j?M=t[16]:(M=(0,$.jsx)(`span`,{className:j,"aria-hidden":!0}),t[15]=j,t[16]=M);let N;t[17]!==i||t[18]!==r||t[19]!==n?(N=i&&!r.enabled?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`inline-block h-3 w-16 animate-pulse rounded-full bg-surface-hover/70 motion-reduce:animate-none`}):Ze(n,r),t[17]=i,t[18]=r,t[19]=n,t[20]=N):N=t[20];let F;t[21]!==M||t[22]!==N||t[23]!==b?(F=(0,$.jsxs)(`span`,{className:b,children:[M,N]}),t[21]=M,t[22]=N,t[23]=b,t[24]=F):F=t[24];let I;t[25]!==r.connectedSince||t[26]!==r.state||t[27]!==n.uptime?(I=r.connectedSince&&r.state===`connected`?(0,$.jsxs)(`span`,{className:`text-xs text-fg-subtle`,children:[n.uptime,` `,et(r.connectedSince)]}):null,t[25]=r.connectedSince,t[26]=r.state,t[27]=n.uptime,t[28]=I):I=t[28];let R;t[29]!==F||t[30]!==I||t[31]!==x?(R=(0,$.jsxs)(`div`,{className:x,children:[F,I]}),t[29]=F,t[30]=I,t[31]=x,t[32]=R):R=t[32];let z;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(g,{className:`size-4 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[33]=z):z=t[33];let B;t[34]!==R||t[35]!==C?(B=(0,$.jsxs)(`div`,{className:C,children:[R,z]}),t[34]=R,t[35]=C,t[36]=B):B=t[36];let V;t[37]===a?V=t[38]:(V=a?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:a instanceof Error?a.message:String(a)}):null,t[37]=a,t[38]=V);let ee;t[39]!==c||t[40]!==n.consentExpiredBanner?(ee=c?(0,$.jsx)(`p`,{className:`rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2 text-xs text-fg-muted`,children:n.consentExpiredBanner}):null,t[39]=c,t[40]=n.consentExpiredBanner,t[41]=ee):ee=t[41];let te;t[42]!==v||t[43]!==l||t[44]!==p||t[45]!==m||t[46]!==y||t[47]!==r||t[48]!==h||t[49]!==d||t[50]!==o||t[51]!==f||t[52]!==s||t[53]!==n?(te=v?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[r.publicUrl?(0,$.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,$.jsx)(P,{label:n.publicUrlLabel,text:r.publicUrl,labels:l})}):null,y?(0,$.jsx)(Ye,{status:r,t:n}):null,r.lastError&&r.state===`error`?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:r.lastError}):null,(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.enabled?(0,$.jsxs)(w,{type:`button`,variant:`secondary`,disabled:s,onClick:m,children:[s?(0,$.jsx)(_,{className:`size-4 animate-spin`}):null,n.stop]}):(0,$.jsxs)(w,{type:`button`,disabled:o,onClick:p,children:[o?(0,$.jsx)(_,{className:`size-4 animate-spin`}):(0,$.jsx)(H,{className:`size-4`}),n.start]})})]}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[f?(0,$.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:f}):null,(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.emptyStateTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:n.emptyStateBody})]}),(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2.5 text-xs text-fg-muted`,children:[(0,$.jsx)(L,{className:`mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-400`}),(0,$.jsx)(`p`,{children:n.riskBannerBody})]}),h&&d?(0,$.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200`,children:d}):null,(0,$.jsxs)(w,{type:`button`,disabled:o||h,onClick:p,className:`w-full sm:w-auto`,children:[o?(0,$.jsx)(_,{className:`size-4 animate-spin`}):(0,$.jsx)(H,{className:`size-4`}),n.start]})]}),t[42]=v,t[43]=l,t[44]=p,t[45]=m,t[46]=y,t[47]=r,t[48]=h,t[49]=d,t[50]=o,t[51]=f,t[52]=s,t[53]=n,t[54]=te):te=t[54];let U;return t[55]!==B||t[56]!==V||t[57]!==ee||t[58]!==te||t[59]!==T?(U=(0,$.jsxs)(`section`,{className:T,children:[B,V,ee,te]}),t[55]=B,t[56]=V,t[57]=ee,t[58]=te,t[59]=T,t[60]=U):U=t[60],U}var nt=`https://console.xopc.ai/access/client`,rt={reconfiguring:!1};function it(e){let t=(0,Q.c)(89),{t:n,brokerSecretReady:r,brokerSecretConfiguredInConfig:i,brokerSecretMaskedValue:a,brokerSecretDraft:o,savingBrokerSecret:s,authorizingBrokerSecret:c,brokerSecretAuthorizationUrl:l,brokerSecretNotice:u,copyFailedLabel:d,onDraftChange:f,onSave:m,onAuthorize:g,onClear:v,sectionRef:y}=e,b=(0,Z.useId)(),x=r,C=!x,[T,E]=(0,Z.useReducer)(F,rt),{reconfiguring:D}=T,O;t[0]!==i||t[1]!==o||t[2]!==D?(O=i&&!D&&!o.trim(),t[0]=i,t[1]=o,t[2]=D,t[3]=O):O=t[3];let k=O,A;t[4]!==n.copied||t[5]!==n.copyKey||t[6]!==n.hideKey||t[7]!==n.showKey?(A={show:n.showKey,hide:n.hideKey,copy:n.copyKey,copied:n.copied},t[4]=n.copied,t[5]=n.copyKey,t[6]=n.hideKey,t[7]=n.showKey,t[8]=A):A=t[8];let j=A,M;t[9]===o?M=t[10]:(M=o.trim().length>0&&!te(o.trim()),t[9]=o,t[10]=M);let N=M,P;t[11]===f?P=t[12]:(P=()=>{E({type:`patch`,patch:{reconfiguring:!1}}),f(``)},t[11]=f,t[12]=P);let I=P,L=C&&`ring-1 ring-amber-500/30`,R;t[13]===L?R=t[14]:(R=S(L),t[13]=L,t[14]=R);let B=x?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`:C?`bg-amber-500/10 text-amber-700 dark:text-amber-400`:`bg-surface-hover text-fg-muted`,V;t[15]===B?V=t[16]:(V=S(`flex size-9 shrink-0 items-center justify-center rounded-lg`,B),t[15]=B,t[16]=V);let H;t[17]===x?H=t[18]:(H=x?(0,$.jsx)(p,{className:`size-4`,strokeWidth:2,"aria-hidden":!0}):(0,$.jsx)(z,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[17]=x,t[18]=H);let U;t[19]!==V||t[20]!==H?(U=(0,$.jsx)(`span`,{className:V,children:H}),t[19]=V,t[20]=H,t[21]=U):U=t[21];let ne=x?n.brokerSecretReadyTitle:n.brokerSecretStepTitle,W;t[22]===ne?W=t[23]:(W=(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:ne}),t[22]=ne,t[23]=W);let re=x?n.brokerSecretReadyHint:n.brokerSecretHint,G;t[24]===re?G=t[25]:(G=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:re}),t[24]=re,t[25]=G);let K;t[26]!==C||t[27]!==n.brokerSecretMissingHint?(K=C?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-amber-800 dark:text-amber-200`,children:n.brokerSecretMissingHint}):null,t[26]=C,t[27]=n.brokerSecretMissingHint,t[28]=K):K=t[28];let q;t[29]!==W||t[30]!==G||t[31]!==K?(q=(0,$.jsxs)(`div`,{children:[W,G,K]}),t[29]=W,t[30]=G,t[31]=K,t[32]=q):q=t[32];let ie;t[33]!==c||t[34]!==C||t[35]!==g||t[36]!==D||t[37]!==s||t[38]!==n.brokerSecretAuthorize||t[39]!==n.brokerSecretAuthorizing||t[40]!==n.brokerSecretConsoleLink?(ie=C||D?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(w,{type:`button`,disabled:s||c,onClick:g,children:[c?(0,$.jsx)(_,{className:`size-4 animate-spin`}):null,c?n.brokerSecretAuthorizing:n.brokerSecretAuthorize]}),(0,$.jsxs)(`a`,{href:nt,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex w-fit items-center gap-1 text-xs font-medium text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[n.brokerSecretConsoleLink,(0,$.jsx)(h,{className:`size-3`,"aria-hidden":!0})]})]}):null,t[33]=c,t[34]=C,t[35]=g,t[36]=D,t[37]=s,t[38]=n.brokerSecretAuthorize,t[39]=n.brokerSecretAuthorizing,t[40]=n.brokerSecretConsoleLink,t[41]=ie):ie=t[41];let ae;t[42]!==c||t[43]!==l||t[44]!==n.brokerSecretOpenAuthorization?(ae=c&&l?(0,$.jsxs)(`a`,{href:l,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex w-fit items-center gap-1 text-xs font-medium text-accent-fg hover:underline`,children:[n.brokerSecretOpenAuthorization,(0,$.jsx)(h,{className:`size-3`,"aria-hidden":!0})]}):null,t[42]=c,t[43]=l,t[44]=n.brokerSecretOpenAuthorization,t[45]=ae):ae=t[45];let J;t[46]!==i||t[47]!==o||t[48]!==a||t[49]!==N||t[50]!==I||t[51]!==d||t[52]!==b||t[53]!==C||t[54]!==v||t[55]!==f||t[56]!==m||t[57]!==D||t[58]!==s||t[59]!==j||t[60]!==k||t[61]!==n.brokerSecretCancelReconfigure||t[62]!==n.brokerSecretClear||t[63]!==n.brokerSecretMaskedHelp||t[64]!==n.brokerSecretNotInConfigFile||t[65]!==n.brokerSecretPlaceholder||t[66]!==n.brokerSecretReconfigure||t[67]!==n.brokerSecretRevealFailed||t[68]!==n.brokerSecretSave||t[69]!==n.brokerSecretSaveAndContinue||t[70]!==n.brokerSecretTitle?(J=k?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:b,children:n.brokerSecretTitle}),(0,$.jsx)(ee,{id:b,value:a,labels:j,reveal:at,loadFailedLabel:d||n.brokerSecretRevealFailed,maskedHelp:n.brokerSecretMaskedHelp,notInConfigFile:n.brokerSecretNotInConfigFile,readOnly:!0}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(w,{type:`button`,variant:`secondary`,disabled:s,onClick:()=>{E({type:`patch`,patch:{reconfiguring:!0}})},children:n.brokerSecretReconfigure}),(0,$.jsx)(w,{type:`button`,variant:`ghost`,disabled:s,onClick:v,children:n.brokerSecretClear})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:b,children:n.brokerSecretTitle}),(0,$.jsx)(ee,{id:b,value:o,onChange:f,placeholder:n.brokerSecretPlaceholder,labels:j,disabled:s}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(w,{type:`button`,disabled:s||!N,onClick:m,children:[s?(0,$.jsx)(_,{className:`size-4 animate-spin`}):null,C?n.brokerSecretSaveAndContinue:n.brokerSecretSave]}),i?(0,$.jsx)(w,{type:`button`,variant:`ghost`,disabled:s,onClick:v,children:n.brokerSecretClear}):null,D?(0,$.jsx)(w,{type:`button`,variant:`ghost`,disabled:s,onClick:I,children:n.brokerSecretCancelReconfigure}):null]})]}),t[46]=i,t[47]=o,t[48]=a,t[49]=N,t[50]=I,t[51]=d,t[52]=b,t[53]=C,t[54]=v,t[55]=f,t[56]=m,t[57]=D,t[58]=s,t[59]=j,t[60]=k,t[61]=n.brokerSecretCancelReconfigure,t[62]=n.brokerSecretClear,t[63]=n.brokerSecretMaskedHelp,t[64]=n.brokerSecretNotInConfigFile,t[65]=n.brokerSecretPlaceholder,t[66]=n.brokerSecretReconfigure,t[67]=n.brokerSecretRevealFailed,t[68]=n.brokerSecretSave,t[69]=n.brokerSecretSaveAndContinue,t[70]=n.brokerSecretTitle,t[71]=J):J=t[71];let oe;t[72]===u?oe=t[73]:(oe=u?(0,$.jsx)(`p`,{className:`text-xs text-emerald-700 dark:text-emerald-400`,children:u}):null,t[72]=u,t[73]=oe);let se;t[74]!==q||t[75]!==ie||t[76]!==ae||t[77]!==J||t[78]!==oe?(se=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[q,ie,ae,J,oe]}),t[74]=q,t[75]=ie,t[76]=ae,t[77]=J,t[78]=oe,t[79]=se):se=t[79];let ce;t[80]!==U||t[81]!==se?(ce=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[U,se]}),t[80]=U,t[81]=se,t[82]=ce):ce=t[82];let Y;t[83]!==ce||t[84]!==R?(Y=(0,$.jsx)(he,{className:R,children:ce}),t[83]=ce,t[84]=R,t[85]=Y):Y=t[85];let le;return t[86]!==y||t[87]!==Y?(le=(0,$.jsx)(`div`,{ref:y,id:`tunnel-broker-secret-setup`,children:Y}),t[86]=y,t[87]=Y,t[88]=le):le=t[88],le}function at(){return ie().then(ot)}function ot(e){return e.registrationSecret??null}var st={actionError:null,starting:!1,stopping:!1,savingAutoStart:!1,consentOpen:!1,autoStartConfirmOpen:!1,releaseConfirmOpen:!1,releasing:!1,brokerSecretDraft:``,savingBrokerSecret:!1,authorizingBrokerSecret:!1,brokerSecretAuthorizationUrl:null,brokerSecretNotice:null};function ct({embedded:e=!1}){let t=b(e=>e.language),n=y(t).tunnelSettings,r=!!x(e=>e.token),[i,a]=(0,Z.useReducer)(F,st),{actionError:o,starting:s,stopping:c,savingAutoStart:l,consentOpen:u,autoStartConfirmOpen:d,releaseConfirmOpen:f,releasing:p,brokerSecretDraft:m,savingBrokerSecret:h,authorizingBrokerSecret:v,brokerSecretAuthorizationUrl:D,brokerSecretNotice:O}=i,M=(0,Z.useRef)(null),{data:N}=E(r),{data:P,error:I,isLoading:L,mutate:R}=C(r?`tunnel-status`:null,fe,{refreshInterval:e=>s?1e3:e?.frpcDownload||e?.state===`connecting`||e?.state===`reconnecting`?2e3:6e4}),z=(0,Z.useMemo)(()=>{let e=N?.payload?.config;if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e.tunnel;if(t&&typeof t==`object`&&!Array.isArray(t)&&t.autoStart===!0)return!0}return P?.config?.autoStart===!0},[N,P?.config?.autoStart]),B=(0,Z.useMemo)(()=>{let e=N?.payload?.config;if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e.tunnel;if(t&&typeof t==`object`&&!Array.isArray(t)){let e=t.registrationSecret;if(typeof e==`string`)return e}}return``},[N]),V=te(B),H=P?.registrationSecret?.configured??V;(0,Z.useEffect)(()=>{let e=()=>{R()};return window.addEventListener(`tunnel-status`,e),()=>window.removeEventListener(`tunnel-status`,e)},[R]);let ee=(0,Z.useMemo)(()=>[n.consentBullet1,n.consentBullet2,n.consentBullet3],[n.consentBullet1,n.consentBullet2,n.consentBullet3]),U=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{actionError:null}}),a({type:`patch`,patch:{starting:!0}});try{await le(),await R(),T()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{starting:!1}})}},[R]),W=(0,Z.useCallback)(()=>{if(!H){a({type:`patch`,patch:{actionError:n.brokerSecretRequiredBeforeStart}}),M.current?.scrollIntoView({behavior:`smooth`,block:`start`});return}if(P?.consentRequired){a({type:`patch`,patch:{consentOpen:!0}});return}U()},[H,P?.consentRequired,U,n.brokerSecretRequiredBeforeStart]),re=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{consentOpen:!1}}),a({type:`patch`,patch:{actionError:null}});try{await se(),await Promise.all([R(),U()])}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}},[R,U]),G=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{actionError:null}}),a({type:`patch`,patch:{stopping:!0}});try{await de(),await R(),T()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{stopping:!1}})}},[R]),K=(0,Z.useCallback)(async e=>{a({type:`patch`,patch:{savingAutoStart:!0}}),a({type:`patch`,patch:{actionError:null}});try{await Y({autoStart:e}),T()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{savingAutoStart:!1}})}},[]),q=(0,Z.useCallback)(()=>{if(z){K(!1);return}if(P?.consentRequired){a({type:`patch`,patch:{actionError:n.consentExpiredBanner}});return}if(!P?.canAutoStart){a({type:`patch`,patch:{actionError:n.autoStartHint}});return}a({type:`patch`,patch:{autoStartConfirmOpen:!0}})},[K,P?.canAutoStart,P?.consentRequired,n,z]),ie=(0,Z.useCallback)(async()=>{let e=m.trim();if(e){a({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await Y({registrationSecret:e}),a({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretSaved}}),T(),await R(),a({type:`patch`,patch:{actionError:null}})}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{savingBrokerSecret:!1}})}}},[m,R,n.brokerSecretSaved]),ae=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await Y({registrationSecret:null}),a({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretCleared}}),T(),await R()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{savingBrokerSecret:!1}})}},[R,n.brokerSecretCleared]),oe=(0,Z.useCallback)(async()=>{let e=_e(),t=null,r=null;a({type:`patch`,patch:{authorizingBrokerSecret:!0,brokerSecretAuthorizationUrl:null,brokerSecretNotice:null,actionError:null}});try{for(t=(await k(`xopc-tunnel`)).sessionId;;){await new Promise(e=>window.setTimeout(e,1e3));let i=await j(t);if(i.authUrl&&i.authUrl!==r&&(r=i.authUrl,a({type:`patch`,patch:{brokerSecretAuthorizationUrl:i.authUrl}}),await ge(i.authUrl,e)),i.status===`failed`||i.status===`cancelled`)throw Error(i.error??i.message??`OAuth authorization failed`);if(i.status===`completed`){await ue(),await Promise.all([R(),T()]),a({type:`patch`,patch:{brokerSecretNotice:n.brokerSecretSaved,brokerSecretDraft:``}});return}}}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{ve(e),t&&A(t).catch(()=>void 0),a({type:`patch`,patch:{authorizingBrokerSecret:!1,brokerSecretAuthorizationUrl:null}})}},[R,n.brokerSecretSaved]),ce=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{releaseConfirmOpen:!1,actionError:null,releasing:!0}});try{await de({release:!0}),await R(),T()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{releasing:!1}})}},[R]),pe=(0,Z.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:y(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]);if(!r)return(0,$.jsx)(`div`,{className:e?void 0:`w-full px-3 py-8 sm:px-5 xl:px-6`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})});let X=P??{enabled:!1,state:`disconnected`,subdomain:null,publicUrl:null,connectedSince:null,frpcPid:null,lastHeartbeatAt:null,lastError:null,consentRequired:!0,config:{autoStart:z,brokerUrl:`https://frp.xopc.ai/api`}},me=P?.consentRequired&&(X.enabled||z||P?.consent?.acceptedAt),ye=(0,$.jsx)(it,{t:n,brokerSecretReady:H,brokerSecretConfiguredInConfig:V,brokerSecretMaskedValue:V?B:``,brokerSecretDraft:m,savingBrokerSecret:h,authorizingBrokerSecret:v,brokerSecretAuthorizationUrl:D,brokerSecretNotice:O,copyFailedLabel:y(t).clipboard.copyFailed,onDraftChange:e=>a({type:`patch`,patch:{brokerSecretDraft:e}}),onSave:()=>void ie(),onAuthorize:()=>void oe(),onClear:()=>void ae(),sectionRef:M}),be=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ze,{open:u,title:n.consentTitle,intro:n.consentIntro,bullets:ee,checkboxLabel:n.consentCheckbox,confirmLabel:me?n.consentReconfirm:n.consentConfirm,cancelLabel:n.consentCancel,onConfirm:()=>void re(),onCancel:()=>a({type:`patch`,patch:{consentOpen:!1}})},u?`consent-open`:`consent-closed`),(0,$.jsx)(ne,{open:d,title:n.autoStartConfirmTitle,description:n.autoStartConfirmBody,confirmLabel:n.autoStartConfirmLabel,cancelLabel:n.consentCancel,onConfirm:()=>{a({type:`patch`,patch:{autoStartConfirmOpen:!1}}),K(!0)},onCancel:()=>a({type:`patch`,patch:{autoStartConfirmOpen:!1}})}),(0,$.jsx)(ne,{open:f,title:n.releaseConfirmTitle,description:n.releaseConfirmBody,confirmLabel:n.releaseConfirmLabel,cancelLabel:n.consentCancel,destructive:!0,onConfirm:()=>void ce(),onCancel:()=>a({type:`patch`,patch:{releaseConfirmOpen:!1}})})]});return e?(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[o?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:o}):null,ye,(0,$.jsx)(tt,{t:n,status:X,isLoading:L,statusErr:I,starting:s,stopping:c,showConsentExpired:!!me,copyLabels:pe,startDisabled:!H,startDisabledReason:H?void 0:n.brokerSecretRequiredBeforeStart,stepLabel:n.flowStepStart,onStart:W,onStop:()=>void G()}),(0,$.jsxs)(Re,{showLabel:n.showOptions,hideLabel:n.hideOptions,children:[(0,$.jsxs)(`label`,{className:S(`flex items-center gap-3 text-sm text-fg`,!z&&!P?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:z,disabled:l||!z&&!P?.canAutoStart,onChange:q}),n.autoStart]}),!P?.canAutoStart&&!z?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.autoStartHint}):null,X.subdomain||X.publicUrl?(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-edge-subtle pt-4`,children:[(0,$.jsxs)(w,{type:`button`,variant:`secondary`,disabled:p||c,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>a({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[p?(0,$.jsx)(_,{className:`size-4 animate-spin`}):null,n.release]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint})]}):null]}),(0,$.jsx)(Re,{showLabel:n.showAdvanced,hideLabel:n.hideAdvanced,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-edge-subtle pt-4 text-xs text-fg-subtle`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(g,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)(J,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]})}),be]}):(0,$.jsxs)(`div`,{className:e?`flex w-full flex-col gap-6`:`flex w-full flex-col gap-6 px-3 py-8 sm:px-5 xl:px-6`,children:[e?null:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:n.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.subtitle})]}),o?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:o}):null,ye,(0,$.jsx)(tt,{t:n,status:X,isLoading:L,statusErr:I,starting:s,stopping:c,showConsentExpired:!!me,copyLabels:pe,startDisabled:!H,startDisabledReason:H?void 0:n.brokerSecretRequiredBeforeStart,onStart:W,onStop:()=>void G()}),X.subdomain||X.publicUrl?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,$.jsxs)(w,{type:`button`,variant:`secondary`,disabled:p||c,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>a({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[p?(0,$.jsx)(_,{className:`size-4 animate-spin`}):null,n.release]})}):null,X.subdomain||X.publicUrl?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint}):null,(0,$.jsxs)(he,{children:[(0,$.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-fg`,children:n.optionsTitle}),(0,$.jsxs)(`label`,{className:S(`flex items-center gap-3 text-sm text-fg`,!z&&!P?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:z,disabled:l||!z&&!P?.canAutoStart,onChange:q}),n.autoStart]}),!P?.canAutoStart&&!z?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:n.autoStartHint}):null]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-panel/80 px-3 py-2 text-xs text-fg-subtle shadow-surface`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(g,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)(J,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]}),be]})}function lt(e,t){return e.tabs[t]}function ut(e,t){return e.tabIntro[t]}function dt(e){switch(e){case`tailscale`:return`tailscale-serve`;case`public`:return`public-tunnel`;case`reverse-proxy`:return`reverse-proxy`;case`ssh`:return`ssh-tunnel`;case`lan`:return`lan`;default:return}}function ft(e){let t=(0,Q.c)(7),{tab:n,onOpenTab:r}=e;switch(n){case`guide`:{let e;return t[0]===r?e=t[1]:(e=(0,$.jsx)(De,{onOpenTab:r}),t[0]=r,t[1]=e),e}case`tailscale`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ce,{embedded:!0}),t[2]=e):e=t[2],e}case`public`:{let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ct,{embedded:!0}),t[3]=e):e=t[3],e}case`reverse-proxy`:{let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ae,{}),t[4]=e):e=t[4],e}case`ssh`:{let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Fe,{}),t[5]=e):e=t[5],e}case`lan`:{let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(je,{}),t[6]=e):e=t[6],e}}}function pt(){let e=(0,Q.c)(3),t=i(),n=b(ht),r=y(n).remoteAccess,o=!!x(mt),[s,c]=a(),l=Le(s.get(`tab`)),u=s.get(`intent`)===`mobile-pairing`,d;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(d={refreshInterval:2e3},e[0]=d):d=e[0];let f=C(u?`mobile-pairing-readiness`:null,oe,d),p;e[1]===c?p=e[2]:(p=e=>{c(t=>{let n=new URLSearchParams(t);return e===`guide`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[1]=c,e[2]=p);let m=p,h=ut(r,l),g=Ie.map(e=>({id:e,label:lt(r,e)}));return(0,$.jsxs)(K,{children:[(0,$.jsx)(G,{title:r.pageTitle,subtitle:r.pageSubtitle,meta:(0,$.jsx)(J,{language:n,label:r.docsLink,section:dt(l),className:`mt-1`})}),o?(0,$.jsxs)($.Fragment,{children:[u?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-xl border border-accent/25 bg-accent-soft px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(B,{className:`mt-0.5 size-5 shrink-0 text-accent`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:r.mobilePairingFlow.title}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:f.data?.ready?r.mobilePairingFlow.ready:r.mobilePairingFlow.hint})]})]}),(0,$.jsxs)(w,{variant:`primary`,disabled:!f.data?.ready,onClick:()=>t(`/settings/devices?startMobilePairing=1`),children:[f.data?.ready?r.mobilePairingFlow.continue:r.mobilePairingFlow.waiting,(0,$.jsx)(M,{className:`size-4`,"aria-hidden":!0})]})]}):null,(0,$.jsx)(ye,{items:g,activeTab:l,onChange:m,ariaLabel:r.tabsAria,tabIdPrefix:`remote-access-tab`,panelIdPrefix:`remote-access-panel`}),(0,$.jsx)(q,{id:l,activeTab:l,tabIdPrefix:`remote-access-tab`,panelIdPrefix:`remote-access-panel`,title:lt(r,l),hint:l===`public`?void 0:h,children:(0,$.jsx)(ft,{tab:l,onOpenTab:m})})]}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.guide.needToken})]})}function mt(e){return e.token}function ht(e){return e.language}export{pt as RemoteAccessHub};
@@ -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{a,n as o,o as s,r as c,s as l,t as u}from"./dist-CpzYSoz7.js";import{n as d,r as f}from"./popover-select-C-Hj-nXR.js";import{t as p}from"./download-Dk-ZjtO6.js";import{t as m}from"./folder-open-CyzJ19I9.js";import{t as h}from"./minimize-2-DtOGrlpo.js";import{t as g}from"./plus-Q2yW6OE7.js";import{t as _}from"./search-DA7gz22f.js";import{t as v}from"./x-B_N4OPjy.js";import{t as y}from"./messages-BbdwoxVo.js";import{a as b,n as x,r as S,s as C}from"./locale-store-CBoCuIMx.js";import{t as w}from"./cn-JdwAhgNB.js";import{i as T}from"./vendor-swr-BIWyz7Rc.js";import{t as E}from"./button-CtTvuElV.js";import{n as D,t as O}from"./interaction-BmQogeqz.js";import{n as k,r as A}from"./gateway-config-swr-826dipyU.js";import{s as j}from"./form-field-width-DJw_jULe.js";import{t as M}from"./skeleton-BwbyijEw.js";import{i as N,o as P}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{n as F,t as I}from"./registry-api-BhGKnvLP.js";import{Bc as L,Es as R,Fi as z,Gi as B,Ii as V,Js as H,Lc as U,Li as W,P as ee,Rc as G,Sc as te,St as ne,ai as re,ci as ie,dc as ae,fi as oe,fs as K,ii as se,li as q,ml as J,nu as ce,oi as le,pi as ue,ru as de,si as fe,uc as pe,ui as me,wl as he,xt as ge,z as Y}from"./index-eZjksPvq.js";import{n as _e,t as ve}from"./settings-form-section-DjWzRk4z.js";import{n as ye,t as be}from"./use-autosave-DMvRu2XZ.js";import{t as xe}from"./page-tabs-BaEQMYm_.js";import{t as Se}from"./settings-advanced-gate-Vg3_jua6.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:s,onAction:c}=e,l;t[0]!==i.unnamedSession||t[1]!==n.name?(l=n.name?.trim()||i.unnamedSession,t[0]=i.unnamedSession,t[1]=n.name,t[2]=l):l=t[2];let u=l,d;t[3]===n.name?d=t[4]:(d=n.name?.trim(),t[3]=n.name,t[4]=d);let f=!!d,m=n.status===`archived`,h=n.status===`pinned`,g=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,_;t[5]===g?_=t[6]:(_=w(`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`,g),t[5]=g,t[6]=_);let v;t[7]===s?v=t[8]:(v=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s())},t[7]=s,t[8]=v);let y=r===`list`&&`sm:py-3`,b;t[9]===y?b=t[10]:(b=w(`flex min-w-0 items-start justify-between gap-2 bg-surface-hover/35 px-3 py-2 dark:bg-surface-hover/25`,y),t[9]=y,t[10]=b);let x;t[11]===n.sourceChannel?x=t[12]:(x=(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]=x);let S;t[13]===h?S=t[14]:(S=h?(0,Z.jsx)(ae,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[13]=h,t[14]=S);let C;t[15]===n.updatedAt?C=t[16]:(C=we(n.updatedAt),t[15]=n.updatedAt,t[16]=C);let T;t[17]===C?T=t[18]:(T=(0,Z.jsx)(`span`,{children:C}),t[17]=C,t[18]=T);let E;t[19]!==T||t[20]!==S?(E=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,children:[S,T]}),t[19]=T,t[20]=S,t[21]=E):E=t[21];let D;t[22]!==E||t[23]!==b||t[24]!==x?(D=(0,Z.jsxs)(`div`,{className:b,children:[x,E]}),t[22]=E,t[23]=b,t[24]=x,t[25]=D):D=t[25];let k=r===`list`&&`sm:py-3`,A;t[26]===k?A=t[27]:(A=w(`min-w-0 flex-1 px-3 py-2`,k),t[26]=k,t[27]=A);let j=r===`list`&&`sm:items-start`,M;t[28]===j?M=t[29]:(M=w(`flex gap-3`,j),t[28]=j,t[29]=M);let N;t[30]!==o||t[31]!==a?(N=(0,Z.jsx)(ee,{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]=N):N=t[32];let P;t[33]===u?P=t[34]:(P=(0,Z.jsx)(`div`,{className:`min-w-0 max-w-full truncate text-sm font-semibold text-fg`,title:u,children:u}),t[33]=u,t[34]=P);let F;t[35]!==n.key||t[36]!==f?(F=f?(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]=f,t[37]=F):F=t[37];let I;t[38]!==P||t[39]!==F?(I=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[P,F]}),t[38]=P,t[39]=F,t[40]=I):I=t[40];let L;t[41]!==M||t[42]!==N||t[43]!==I?(L=(0,Z.jsxs)(`div`,{className:M,children:[N,I]}),t[41]=M,t[42]=N,t[43]=I,t[44]=L):L=t[44];let z;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Z.jsx)(te,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[45]=z):z=t[45];let B;t[46]===n.messageCount?B=t[47]:(B=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[z,n.messageCount]}),t[46]=n.messageCount,t[47]=B);let V;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,Z.jsx)(K,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[48]=V):V=t[48];let H;t[49]===n.estimatedTokens?H=t[50]:(H=Te(n.estimatedTokens),t[49]=n.estimatedTokens,t[50]=H);let U;t[51]===H?U=t[52]:(U=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[V,H]}),t[51]=H,t[52]=U);let W;t[53]!==B||t[54]!==U?(W=(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[B,U]}),t[53]=B,t[54]=U,t[55]=W):W=t[55];let G;t[56]===n.tags?G=t[57]:(G=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]=G);let ne;t[58]!==A||t[59]!==L||t[60]!==W||t[61]!==G?(ne=(0,Z.jsxs)(`div`,{className:A,children:[L,W,G]}),t[58]=A,t[59]=L,t[60]=W,t[61]=G,t[62]=ne):ne=t[62];let re;t[63]===c?re=t[64]:(re=()=>c(`continue`),t[63]=c,t[64]=re);let ie;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,Z.jsx)(te,{className:`size-4`,strokeWidth:1.75}),t[65]=ie):ie=t[65];let oe;t[66]!==i.continueChat||t[67]!==re?(oe=(0,Z.jsx)(`button`,{type:`button`,className:O,title:i.continueChat,"aria-label":i.continueChat,onClick:re,children:ie}),t[66]=i.continueChat,t[67]=re,t[68]=oe):oe=t[68];let se;t[69]!==m||t[70]!==i.archive||t[71]!==i.unarchive||t[72]!==c?(se=m?(0,Z.jsx)(`button`,{type:`button`,className:O,title:i.unarchive,"aria-label":i.unarchive,onClick:()=>c(`unarchive`),children:(0,Z.jsx)(de,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:O,title:i.archive,"aria-label":i.archive,onClick:()=>c(`archive`),children:(0,Z.jsx)(ce,{className:`size-4`,strokeWidth:1.75})}),t[69]=m,t[70]=i.archive,t[71]=i.unarchive,t[72]=c,t[73]=se):se=t[73];let q;t[74]!==h||t[75]!==i.pin||t[76]!==i.unpin||t[77]!==c?(q=h?(0,Z.jsx)(`button`,{type:`button`,className:O,title:i.unpin,"aria-label":i.unpin,onClick:()=>c(`unpin`),children:(0,Z.jsx)(pe,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:O,title:i.pin,"aria-label":i.pin,onClick:()=>c(`pin`),children:(0,Z.jsx)(ae,{className:`size-4`,strokeWidth:1.75})}),t[74]=h,t[75]=i.pin,t[76]=i.unpin,t[77]=c,t[78]=q):q=t[78];let J;t[79]===c?J=t[80]:(J=()=>c(`export`),t[79]=c,t[80]=J);let le;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,Z.jsx)(p,{className:`size-4`,strokeWidth:1.75}),t[81]=le):le=t[81];let ue;t[82]!==i.export||t[83]!==J?(ue=(0,Z.jsx)(`button`,{type:`button`,className:O,title:i.export,"aria-label":i.export,onClick:J,children:le}),t[82]=i.export,t[83]=J,t[84]=ue):ue=t[84];let fe;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(fe=w(O,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),t[85]=fe):fe=t[85];let me;t[86]===c?me=t[87]:(me=()=>c(`delete`),t[86]=c,t[87]=me);let he;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,Z.jsx)(R,{className:`size-4`,strokeWidth:1.75}),t[88]=he):he=t[88];let ge;t[89]!==i.delete||t[90]!==me?(ge=(0,Z.jsx)(`button`,{type:`button`,className:fe,title:i.delete,"aria-label":i.delete,onClick:me,children:he}),t[89]=i.delete,t[90]=me,t[91]=ge):ge=t[91];let Y;t[92]!==oe||t[93]!==se||t[94]!==q||t[95]!==ue||t[96]!==ge?(Y=(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:[oe,se,q,ue,ge]}),t[92]=oe,t[93]=se,t[94]=q,t[95]=ue,t[96]=ge,t[97]=Y):Y=t[97];let _e;return t[98]!==s||t[99]!==D||t[100]!==ne||t[101]!==_||t[102]!==Y||t[103]!==v?(_e=(0,Z.jsxs)(`div`,{role:`button`,tabIndex:0,className:_,onClick:s,onKeyDown:v,children:[D,ne,Y]}),t[98]=s,t[99]=D,t[100]=ne,t[101]=_,t[102]=Y,t[103]=v,t[104]=_e):_e=t[104],_e}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 b(S(`/api/config`),{method:`PATCH`,body:JSON.stringify(Le(e))}),await k()}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=z();function He(){return w(`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`,j,`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=w(`flex items-start gap-2 text-sm text-fg`,s),t[0]=s,t[1]=c);let l;t[2]===o?l=t[3]:(l=e=>o(e.target.checked),t[2]=o,t[3]=l);let u;t[4]!==i||t[5]!==a||t[6]!==l?(u=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:i,disabled:a,onChange:l}),t[4]=i,t[5]=a,t[6]=l,t[7]=u):u=t[7];let d;t[8]===n?d=t[9]:(d=(0,Z.jsx)(`span`,{className:`font-medium`,children:n}),t[8]=n,t[9]=d);let f;t[10]===r?f=t[11]:(f=(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:r}),t[10]=r,t[11]=f);let p;t[12]!==d||t[13]!==f?(p=(0,Z.jsxs)(`span`,{children:[d,f]}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let m;return t[15]!==c||t[16]!==u||t[17]!==p?(m=(0,Z.jsxs)(`label`,{className:c,children:[u,p]}),t[15]=c,t[16]=u,t[17]=p,t[18]=m):m=t[18],m}function qe({hasToken:e}){let t=y(x(e=>e.language)).sessions.compaction,{data:n,isLoading:r}=A(e),{data:i=[],isLoading:a}=T(e?I:null,F,{revalidateOnFocus:!1}),o=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:Fe(n.payload.config),[n]),[s,c]=(0,X.useReducer)(Ve,{form:null,baseline:null}),[l,u]=(0,X.useState)(``),d=(0,X.useRef)(!1),f=(0,X.useRef)(s.form);f.current=s.form;let p=(0,X.useRef)(null);V({enabled:e,parsed:o,dirty:d.current,trackedParsedRef:p,dispatch:c,onResetDirty:()=>{d.current=!1}});let m=s.form,_=s.baseline,b=!!(m&&_&&JSON.stringify(m)!==JSON.stringify(_)),S=(0,X.useCallback)(e=>{d.current=!0,c({type:`patch`,patch:e})},[]),C=(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]),O=be({value:m,dirty:b,onSave:(0,X.useCallback)(async e=>{try{await Re(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]),validate:e=>{let n=Ie(e);return n?t.invalidValue.replace(`{{field}}`,C(n)):null}});if(!e||!m)return r?(0,Z.jsx)(ve,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(M,{className:`h-5 w-48`}),(0,Z.jsx)(M,{className:`h-20 w-full rounded-xl`}),(0,Z.jsx)(M,{className:`h-36 w-full rounded-xl`})]})}):null;let k=We(m),j=Math.max(0,ze-m.reserveTokens),N=Math.min(Math.floor(ze*m.triggerThreshold),j),P=Math.min(100,N/ze*100),L=Math.min(100,j/ze*100),R=m.model?i.find(e=>e.id===m.model):void 0,z=R?.contextWindow&&m.summaryChunkTokens+m.summaryMaxTokens+4096>R.contextWindow,B=m.keepRecentTokens+m.reserveTokens>N,H=Math.round(m.summaryTimeoutMs*(m.summaryRetries+1)/1e3),U=e=>{let t=Be[e];S({...t,...m.model?{model:m.model}:{model:void 0},postCompactionSections:m.postCompactionSections})},W={balanced:{title:t.presetBalanced,hint:t.presetBalancedHint},preserve:{title:t.presetPreserve,hint:t.presetPreserveHint},early:{title:t.presetEarly,hint:t.presetEarlyHint}},ee=()=>{let e=l.trim();!e||m.postCompactionSections.includes(e)||m.postCompactionSections.length>=12||(S({postCompactionSections:[...m.postCompactionSections,e]}),u(``))};return(0,Z.jsxs)(ve,{onBlurCapture:O.onBlurCapture,children:[(0,Z.jsx)(_e,{icon:h,title:t.title,subtitle:t.hint,trailing:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(ye,{status:O.status,error:O.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:m.enabled,onChange:e=>S({enabled:e.target.checked})}),m.enabled?t.enabled:t.disabled]})]})}),O.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:O.error}):null,m.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:!m.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})]}),k===`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":k===e,className:w(`rounded-xl border px-3 py-3 text-left`,D.transition,D.focusRingPanel,k===e?`border-accent/50 bg-accent-soft text-accent-fg`:`border-edge bg-surface-panel text-fg hover:bg-surface-hover`),onClick:()=>U(e),children:[(0,Z.jsx)(`span`,{className:`block text-sm font-medium`,children:W[e].title}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:W[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(N)})]}),(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:`${P}%`}})})]}),(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(j)})]}),(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:`${L}%`}})})]})]}),(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((m.triggerThreshold*100).toFixed(2)),min:10,max:98,step:.1,onChange:e=>S({triggerThreshold:e/100})}),(0,Z.jsx)($,{id:`compaction-reserve-tokens`,label:t.reserveTokens,hint:t.reserveTokensHint.replace(`{{tokens}}`,Ge(m.reserveTokens)),value:m.reserveTokens,min:1024,step:1024,onChange:e=>S({reserveTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-recent-turns`,label:t.recentTurnsPreserve,hint:t.recentTurnsPreserveHint,value:m.recentTurnsPreserve,min:1,max:12,onChange:e=>S({recentTurnsPreserve:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-keep-recent-tokens`,label:t.keepRecentTokens,hint:t.keepRecentTokensHint.replace(`{{tokens}}`,Ge(m.keepRecentTokens)),value:m.keepRecentTokens,min:1e3,step:1e3,onChange:e=>S({keepRecentTokens:Math.floor(e)})})]}),B?(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)(Y,{value:m.model??``,disabled:!m.enabled,placeholder:t.summaryModelInherited,searchPlaceholder:t.summaryModelSearch,noMatches:t.summaryModelNoMatches,models:i,modelsLoading:a,className:`min-w-0 flex-1 justify-between`,contentAlign:`start`,showProviderSettingsFooter:!0,onChange:e=>S({model:e})}),m.model?(0,Z.jsx)(E,{type:`button`,variant:`secondary`,onClick:()=>S({model:void 0}),children:t.summaryModelUseSession}):null]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.summaryModelHint})]}),(0,Z.jsx)(Ke,{label:t.qualityGuard,hint:t.qualityGuardHint,checked:m.qualityGuard,onChange:e=>S({qualityGuard:e})}),(0,Z.jsx)(Ke,{label:t.gapAudit,hint:t.gapAuditHint,checked:m.gapAudit,onChange:e=>S({gapAudit:e})})]}),m.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)(Se,{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:m.minMessagesBeforeCompact,min:2,onChange:e=>S({minMessagesBeforeCompact:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-max-transcript-mb`,label:t.maxActiveTranscriptMb,hint:t.maxActiveTranscriptMbHint,value:Number((m.maxActiveTranscriptBytes/1e6).toFixed(3)),min:.064,step:.1,onChange:e=>S({maxActiveTranscriptBytes:Math.max(64e3,Math.round(e*1e6))})}),(0,Z.jsx)($,{id:`compaction-summary-max-tokens`,label:t.summaryMaxTokens,hint:t.summaryMaxTokensHint,value:m.summaryMaxTokens,min:256,step:256,onChange:e=>S({summaryMaxTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-chunk-tokens`,label:t.summaryChunkTokens,hint:t.summaryChunkTokensHint,value:m.summaryChunkTokens,min:1e3,step:1e3,onChange:e=>S({summaryChunkTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-timeout`,label:t.summaryTimeoutSeconds,hint:t.summaryTimeoutSecondsHint.replace(`{{seconds}}`,String(H)),value:m.summaryTimeoutMs/1e3,min:1,max:600,onChange:e=>S({summaryTimeoutMs:Math.round(e*1e3)})}),(0,Z.jsx)($,{id:`compaction-summary-retries`,label:t.summaryRetries,hint:t.summaryRetriesHint,value:m.summaryRetries,min:0,max:5,onChange:e=>S({summaryRetries:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-min-tool-result-chars`,label:t.minToolResultKeepChars,hint:t.minToolResultKeepCharsHint,value:m.minToolResultKeepChars,min:200,step:100,onChange:e=>S({minToolResultKeepChars:Math.floor(e)})})]}),z?(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}),m.postCompactionSections.length>0?(0,Z.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:m.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:w(`text-fg-muted hover:text-fg`,D.press),"aria-label":t.removeSection.replace(`{{section}}`,e),onClick:()=>S({postCompactionSections:m.postCompactionSections.filter(t=>t!==e)}),children:(0,Z.jsx)(v,{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:l,maxLength:120,disabled:m.postCompactionSections.length>=12,placeholder:t.postCompactionSectionsPlaceholder,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),ee())}}),(0,Z.jsxs)(E,{type:`button`,variant:`secondary`,disabled:!l.trim()||m.postCompactionSections.length>=12,onClick:ee,children:[(0,Z.jsx)(g,{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 b(S(`/api/config`),{method:`PATCH`,body:JSON.stringify({session:{dmScope:e.dmScope,storage:{pruneAfterMs:e.pruneAfterDays===null?null:e.pruneAfterDays*864e5,maxEntries:e.maxEntries}}})}),k()}function Qe(){return w(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,j,`dark:border-edge`)}var $e=z();function et({hasToken:e}){let t=y(x(e=>e.language)).sessions.config,{data:n,isLoading:r}=A(e),i=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:Xe(n.payload.config),[n]),[a,o]=(0,X.useReducer)($e,{form:null,baseline:null}),s=a.form,c=a.baseline,l=(0,X.useRef)(!1),u=(0,X.useRef)(s);u.current=s;let p=(0,X.useRef)(null);V({enabled:e,parsed:i,dirty:l.current,trackedParsedRef:p,dispatch:o,onResetDirty:()=>{l.current=!1}});let m=!!(s&&c&&JSON.stringify(s)!==JSON.stringify(c)),h=(0,X.useCallback)(e=>{l.current=!0,o({type:`patch`,patch:e})},[]),g=be({value:s,dirty:m,onSave:(0,X.useCallback)(async e=>{try{await Ze(e),o({type:`saved`,value:e}),l.current=!!(u.current&&JSON.stringify(u.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])});return!e||!s?r?(0,Z.jsx)(ve,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(M,{className:`h-5 w-40`}),(0,Z.jsx)(M,{className:`h-24 w-full rounded-xl`})]})}):null:(0,Z.jsxs)(ve,{onBlurCapture:g.onBlurCapture,children:[(0,Z.jsx)(_e,{icon:J,title:t.title,subtitle:t.hint,trailing:(0,Z.jsx)(ye,{status:g.status,error:g.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)(d,{className:Qe(),value:s.dmScope,onChange:e=>h({dmScope:e.target.value}),children:[(0,Z.jsx)(f,{value:`main`,children:t.dmScopeMain}),(0,Z.jsx)(f,{value:`per-peer`,children:t.dmScopePerPeer}),(0,Z.jsx)(f,{value:`per-channel-peer`,children:t.dmScopePerChannelPeer}),(0,Z.jsx)(f,{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:s.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:s.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:d,sessionAgentAvatar:f,labels:p,onClose:m,onArchive:h,onUnarchive:g,onPin:_,onUnpin:y,onExport:b,onDelete:x}=e,S=i?.status===`archived`,C=i?.status===`pinned`,T;t[0]===m?T=t[1]:(T=e=>!e&&m(),t[0]=m,t[1]=T);let D;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Z.jsx)(a,{className:w(`xopc-dialog-overlay fixed inset-0 bg-scrim`,P)}),t[2]=D):D=t[2];let O;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(O=w(`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`,N,`dark:border-edge`),t[3]=O):O=t[3];let k;t[4]!==i||t[5]!==f||t[6]!==d?(k=i&&d?(0,Z.jsx)(ee,{agentId:d,avatar:f,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}):null,t[4]=i,t[5]=f,t[6]=d,t[7]=k):k=t[7];let A;t[8]!==p.unnamedSession||t[9]!==i?.name?(A=i?.name?.trim()||p.unnamedSession,t[8]=p.unnamedSession,t[9]=i?.name,t[10]=A):A=t[10];let j;t[11]===A?j=t[12]:(j=(0,Z.jsx)(l,{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 F;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Z.jsx)(v,{className:`size-5`,strokeWidth:1.75}),t[16]=F):F=t[16];let I;t[17]===p.close?I=t[18]:(I=(0,Z.jsx)(o,{asChild:!0,children:(0,Z.jsx)(E,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":p.close,children:F})}),t[17]=p.close,t[18]=I);let L;t[19]!==M||t[20]!==I?(L=(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,I]}),t[19]=M,t[20]=I,t[21]=L):L=t[21];let R;t[22]!==p.detailLoading||t[23]!==p.detailMessages||t[24]!==r||t[25]!==i?(R=r?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:p.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:p.detailMessages}),(0,Z.jsx)(`ul`,{className:`space-y-3`,children:i.messages.map(rt)})]}):null,t[22]=p.detailLoading,t[23]=p.detailMessages,t[24]=r,t[25]=i,t[26]=R):R=t[26];let z;t[27]===R?z=t[28]:(z=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:R}),t[27]=R,t[28]=z);let B;t[29]!==p.detailExport||t[30]!==b?(B=(0,Z.jsx)(E,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:b,children:p.detailExport}),t[29]=p.detailExport,t[30]=b,t[31]=B):B=t[31];let V;t[32]!==S||t[33]!==p.archive||t[34]!==p.unarchive||t[35]!==h||t[36]!==g?(V=S?(0,Z.jsx)(E,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:g,children:p.unarchive}):(0,Z.jsx)(E,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:h,children:p.archive}),t[32]=S,t[33]=p.archive,t[34]=p.unarchive,t[35]=h,t[36]=g,t[37]=V):V=t[37];let H;t[38]!==C||t[39]!==p.pin||t[40]!==p.unpin||t[41]!==_||t[42]!==y?(H=C?(0,Z.jsx)(E,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:y,children:p.unpin}):(0,Z.jsx)(E,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:_,children:p.pin}),t[38]=C,t[39]=p.pin,t[40]=p.unpin,t[41]=_,t[42]=y,t[43]=H):H=t[43];let U;t[44]!==p.delete||t[45]!==x?(U=(0,Z.jsx)(E,{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:x,children:p.delete}),t[44]=p.delete,t[45]=x,t[46]=U):U=t[46];let W;t[47]!==B||t[48]!==V||t[49]!==H||t[50]!==U?(W=(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:[B,V,H,U]})}),t[47]=B,t[48]=V,t[49]=H,t[50]=U,t[51]=W):W=t[51];let G;t[52]!==L||t[53]!==z||t[54]!==W?(G=(0,Z.jsxs)(s,{children:[D,(0,Z.jsxs)(c,{className:O,"aria-describedby":void 0,children:[L,z,W]})]}),t[52]=L,t[53]=z,t[54]=W,t[55]=G):G=t[55];let te;return t[56]!==n||t[57]!==T||t[58]!==G?(te=(0,Z.jsx)(u,{open:n,onOpenChange:T,children:G}),t[56]=n,t[57]=T,t[58]=G,t[59]=te):te=t[59],te}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`?L:H})),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)(xe,{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=y(x(e=>e.language)),t=e.sessions,n=C(e=>e.token),r=!!n,{data:o,mutate:d}=T(r?[`gateway-chat-agents`,n]:null,B,{revalidateOnFocus:!1}),f=o?.defaultId??`main`,p=o?.items??[],[h,g]=i(),v=lt(h.get(`tab`)),b=(0,X.useCallback)(e=>{let t=new URLSearchParams(h);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),g(t,{replace:!0})},[h,g]),[S,O]=(0,X.useReducer)(W,h,mt),{searchInput:k,debouncedSearch:A,statusFilter:j,viewMode:M,channelFilter:F,sessions:I,loading:R,error:z,hasMore:V,stats:H,detailOpen:ee,detailLoading:te,detailSession:K,confirmOpen:J,confirmKey:de}=S;(0,X.useEffect)(()=>{let e=setTimeout(()=>{let e=k.trim();A!==e&&O({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[k,A]);let pe=h.toString(),Y=(0,X.useRef)(pe);if(Y.current!==pe){Y.current=pe;let e=h.get(`q`)??``,t=h.get(`status`),n=h.get(`view`),r=(h.get(`channel`)??``).trim(),i=ot.has(t)?t:`all`,a=st.has(n)?n:`grid`,o=e.trim();O({type:`patch`,patch:{...k===e?{}:{searchInput:e},...A===o?{}:{debouncedSearch:o},...j===i?{}:{statusFilter:i},...M===a?{}:{viewMode:a},...F===r?{}:{channelFilter:r}}})}(0,X.useEffect)(()=>{let e=new URLSearchParams(h),t=A.trim();t?e.set(`q`,t):e.delete(`q`),j===`all`?e.delete(`status`):e.set(`status`,j),M===`grid`?e.delete(`view`):e.set(`view`,M),F?e.set(`channel`,F):e.delete(`channel`),e.toString()!==h.toString()&&g(e,{replace:!0})},[A,h,g,j,M,F]),(0,X.useEffect)(()=>{if(!r||v!==`sessions`)return;let e=!1;return(async()=>{O({type:`patch`,patch:{loading:!0,error:null}});try{let t=await q({limit:it,offset:0,...A?{search:A}:{},...j===`all`?{}:{status:j},...F?{channel:F}:{}});if(e)return;O({type:`patch`,patch:{sessions:t.items,hasMore:t.hasMore}})}catch(n){e||O({type:`patch`,patch:{error:n instanceof Error?n.message:t.loadError}})}finally{e||O({type:`patch`,patch:{loading:!1}})}})(),()=>{e=!0}},[r,v,A,j,F,t.loadError]),(0,X.useEffect)(()=>{!r||v!==`sessions`||ie().then(e=>O({type:`patch`,patch:{stats:e}})).catch(()=>{})},[r,v]),(0,X.useEffect)(()=>{if(!r||v!==`sessions`)return;let e=()=>void d();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[r,v,d]),(0,X.useEffect)(()=>{if(!r||v!==`sessions`)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||O({type:`patch`,patch:{sessions:I.map(e=>e.key===t.key?{...e,name:t.name}:e),detailSession:K&&K.key===t.key?{...K,name:t.name}:K}})};return window.addEventListener(`session-updated`,e),()=>{window.removeEventListener(`session-updated`,e)}},[r,v,I,K]);let _e=(0,X.useCallback)(async()=>{if(!(!r||R||!V)){O({type:`patch`,patch:{loading:!0,error:null}});try{let e=await q({limit:it,offset:I.length,...A?{search:A}:{},...j===`all`?{}:{status:j},...F?{channel:F}:{}});O({type:`patch`,patch:{sessions:[...I,...e.items],hasMore:e.hasMore}})}catch(e){O({type:`patch`,patch:{error:e instanceof Error?e.message:t.loadError}})}finally{O({type:`patch`,patch:{loading:!1}})}}},[r,R,V,I.length,A,j,F,t.loadError]),ve=(0,X.useCallback)((e,t)=>{O({type:`patch`,patch:{sessions:I.map(n=>n.key===e?{...n,status:t}:n),detailSession:K&&K.key===e?{...K,status:t}:K}})},[I,K]),ye=(0,X.useCallback)(async e=>{O({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{O({type:`patch`,patch:{detailSession:await fe(e)}})}catch{O({type:`patch`,patch:{detailOpen:!1}})}finally{O({type:`patch`,patch:{detailLoading:!1}})}},[]),be=e=>{ye(e)},xe=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:e},bubbles:!0}));return}if(t===`delete`){O({type:`patch`,patch:{confirmKey:e,confirmOpen:!0}});return}try{switch(t){case`archive`:await se(e),ve(e,`archived`);break;case`unarchive`:await oe(e),ve(e,`active`);break;case`pin`:await me(e),ve(e,`pinned`);break;case`unpin`:await ue(e),ve(e,`active`);break;case`export`:{let t=await le(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}ie().then(e=>O({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Se=async e=>{try{await re(e),O({type:`patch`,patch:{sessions:I.filter(t=>t.key!==e),detailSession:K?.key===e?null:K,...K?.key===e?{detailOpen:!1}:{}}}),ie().then(e=>O({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:L},{key:`active`,label:t.filterActive,icon:he},{key:`pinned`,label:t.filterPinned,icon:ae},{key:`archived`,label:t.filterArchived,icon:ce}],De=(()=>{let e=Object.entries(H?.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:v,onChange:b}),(0,Z.jsx)(pt,{s:t,id:`settings`,activeTab:v,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:v,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":j===e,onClick:()=>O({type:`patch`,patch:{statusFilter:e}}),className:w(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,D.transition,D.focusRingPanel,j===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)(_,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`input`,{type:`search`,value:k,onChange:e=>O({type:`patch`,patch:{searchInput:e.target.value}}),placeholder:t.searchPlaceholder,"data-debounced-query":A||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":!F,onClick:()=>O({type:`patch`,patch:{channelFilter:``}}),className:w(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,D.transition,D.focusRingPanel,F?`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":F===e,onClick:()=>O({type:`patch`,patch:{channelFilter:e}}),className:w(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,D.transition,D.focusRingPanel,F===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,H?.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:H.byChannel[e]})]},e))]}),H?(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[[H.totalSessions,t.totalSessions],[H.activeSessions,t.activeSessions],[H.pinnedSessions,t.pinnedSessions],[H.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,z?(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:z}):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:I.length})}),(0,Z.jsxs)(`div`,{className:ne,role:`group`,"aria-label":t.layoutToggleGroup,children:[(0,Z.jsx)(E,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":M===`grid`,onClick:()=>O({type:`patch`,patch:{viewMode:`grid`}}),className:w(ge,`size-7 p-0`,M===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,M===`grid`&&`text-accent-fg`),children:(0,Z.jsx)(G,{className:`size-3.5`,strokeWidth:1.5})}),(0,Z.jsx)(E,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":M===`list`,onClick:()=>O({type:`patch`,patch:{viewMode:`list`}}),className:w(ge,`size-9 p-0`,M===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,M===`list`&&`text-accent-fg`),children:(0,Z.jsx)(U,{className:`size-3.5`,strokeWidth:1.5})})]})]}),R&&I.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))}):I.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)(E,{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:w(`grid min-w-0 gap-3`,M===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":A||void 0,children:I.map(e=>{let t=Ae(e,f);return(0,Z.jsx)(Ee,{session:e,variant:M,labels:Ce,sessionAgentId:t,sessionAgentAvatar:je(t,p),onOpen:()=>be(e.key),onAction:t=>void xe(e.key,t)},e.key)})}),V?(0,Z.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Z.jsx)(E,{type:`button`,variant:`secondary`,disabled:R,onClick:()=>void _e(),children:t.loadMore})}):null]})]})]}),(0,Z.jsx)(nt,{open:ee,loading:te,session:K,sessionAgentId:K?Ae(K,f):void 0,sessionAgentAvatar:K?je(Ae(K,f),p):void 0,labels:we,onClose:()=>{O({type:`patch`,patch:{detailOpen:!1,detailSession:null}})},onArchive:()=>K&&void xe(K.key,`archive`),onUnarchive:()=>K&&void xe(K.key,`unarchive`),onPin:()=>K&&void xe(K.key,`pin`),onUnpin:()=>K&&void xe(K.key,`unpin`),onExport:()=>K&&void xe(K.key,`export`),onDelete:()=>K&&O({type:`patch`,patch:{confirmKey:K.key,confirmOpen:!0}})}),(0,Z.jsx)(u,{open:J,onOpenChange:e=>O({type:`patch`,patch:{confirmOpen:e}}),children:(0,Z.jsxs)(s,{children:[(0,Z.jsx)(a,{className:w(`xopc-dialog-overlay fixed inset-0 bg-scrim`,P)}),(0,Z.jsxs)(c,{className:w(`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`,N),children:[(0,Z.jsx)(l,{className:`text-base font-semibold text-fg`,children:t.deleteSessionTitle}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:de?at(t.deleteSessionMessage,{name:I.find(e=>e.key===de)?.name?.trim()||e.chat.newSession}):``}),(0,Z.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Z.jsx)(E,{type:`button`,variant:`secondary`,onClick:()=>O({type:`patch`,patch:{confirmOpen:!1}}),children:t.cancel}),(0,Z.jsx)(E,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{de&&Se(de),O({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{$t as e}from"./index-eZjksPvq.js";function t(t){let{children:n,fallback:r}=t,i=r===void 0?null:r;return e()?n:i}export{t};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-BaASWQor.js";import{t as a}from"./circle-check-C23XjkUj.js";import{t as o}from"./loader-circle-CifKLtgG.js";import{t as s}from"./messages-BbdwoxVo.js";import{a as c,n as l,r as u,s as d}from"./locale-store-CBoCuIMx.js";import{t as f}from"./cn-JdwAhgNB.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{n as m}from"./interaction-BmQogeqz.js";import{r as h}from"./gateway-config-swr-826dipyU.js";import{n as g}from"./is-masked-secret-DOkL5b_X.js";import{n as _,t as v}from"./registry-api-BhGKnvLP.js";import{Fl as y,Ps as b,Tl as x,Ts as S,Uc as C,Xt as w,ea as T,ec as ee,iu as E,mt as D,wl as O}from"./index-eZjksPvq.js";import{n as k,r as A}from"./settings-page-layout-BRQNel6r.js";import{n as j}from"./settings-loading-skeleton-CAmWMaOT.js";import{n as M,t as N}from"./settings-form-section-DjWzRk4z.js";var P=e(t(),1),F=n();function I(e){if(!e||typeof e!=`object`)return 0;let t=e.providers;return!t||typeof t!=`object`||Array.isArray(t)?0:Object.values(t).filter(e=>typeof e==`string`&&g(e)).length}function L(e){if(!e||typeof e!=`object`)return``;let t=e.agents;if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=t.defaults,r=n&&typeof n==`object`&&!Array.isArray(n)?n.models:void 0;if(!r||typeof r!=`object`||Array.isArray(r))return``;let i=r.chat;if(!i||typeof i!=`object`||Array.isArray(i))return``;let a=i.primary;return typeof a==`string`?a.trim():``}function R(e){if(!e||typeof e!=`object`)return!1;let t=e.channels;return!t||typeof t!=`object`||Array.isArray(t)?!1:Object.values(t).some(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;if(`configured`in t||`config`in t||`schema`in t||`uiHints`in t){if(t.configured===!0)return!0;let e=t.config;if(!e||typeof e!=`object`||Array.isArray(e))return!1;let n=e;return n.enabled===!0||Object.keys(n).length>0}return t.enabled===!0||Object.keys(t).length>0})}function z(e){if(!e||typeof e!=`object`)return{enabled:!1,backend:`extension`};let t=e.browser;if(!t||typeof t!=`object`||Array.isArray(t))return{enabled:!1,backend:`extension`};let n=t;return{enabled:n.enabled===!0,backend:typeof n.backend==`string`&&n.backend.trim()?n.backend.trim():`extension`}}function B(e){return e?`pass`:`fail`}function V(e){if(e===`provider-auth`)return`/settings/capabilities/models`;if(e===`config-health`)return`/settings/gateway`;if(e===`state-integrity`||e===`workspace-status`)return`/agents`;if(e===`database-schema`||e===`session-integrity`)return`/settings/sessions`;if(e===`channel-config`||e===`channel-pairing-pending`||e.startsWith(`channel:`))return`/channels`;if(e===`security-audit`||e===`gateway-service`||e===`gateway-health`)return`/settings/gateway`;if(e===`version-check`)return`/settings/desktop-app`}function H(e){return{fail:4,warn:3,skip:2,pass:1}[e]}function te(e){return e.filter(e=>e.status===`fail`||e.status===`warn`).map(e=>({id:e.id,label:e.label,status:e.status,message:e.message,hints:e.hints,path:V(e.id),source:`doctor`})).toSorted((e,t)=>H(t.status)-H(e.status)||e.label.localeCompare(t.label))}function U(e){let t=new Map(e.doctorChecks.map(e=>[e.id,e])),n=[];for(let e of[`security-audit`,`channel-config`,`channel-pairing-pending`,`gateway-health`]){let r=t.get(e);r&&n.push({id:r.id,label:r.label,status:r.status,message:r.message,path:V(r.id)})}if(e.logsHealth){let t=e.logsHealth.stats?.errorsLast24h??0;n.push({id:`logs-health`,label:`Logs`,status:e.logsHealth.shuttingDown||t>0?`warn`:`pass`,message:e.logsHealth.shuttingDown?`Logger is shutting down.`:t>0?`${t} error(s) in the last 24 hours.`:`Log system is healthy.`,path:`/settings/logs`})}for(let t of e.browserDiagnostics??[])n.push(t);return n}function ne(e){let t=I(e.config),n=e.providerMeta?.configured??t,r=e.providerMeta?.total??0,i=n>0||t>0,a=L(e.config),o=a.length>0,s=e.hasToken&&e.realtimeConnected,c=R(e.config),l=e.skillCount>0,u=e.doctorChecks??[],d=te(u),f=[{id:`gateway`,done:s,detail:s?e.labels.gatewayOnline:e.labels.gatewayOffline},{id:`provider`,done:i,detail:i?e.providerMeta&&e.providerMeta.total>0?e.labels.providersMetaReady(n,r):e.labels.providersConfigured(t):e.labels.providersMissing},{id:`defaultModel`,done:o,detail:o?e.labels.modelConfigured(a):e.labels.modelMissing},{id:`channel`,done:c,optional:!0,detail:c?e.labels.channelConfigured:e.labels.channelMissing},{id:`skill`,done:l,optional:!0,detail:l?e.labels.skillsConfigured(e.skillCount):e.labels.skillsMissing}],p=f.filter(e=>!e.optional).every(e=>e.done),m=f.every(e=>e.done),h=[{id:`gateway`,status:B(s),title:`Gateway`,detail:s?e.labels.gatewayOnline:e.labels.gatewayOffline,path:`/settings/gateway`},{id:`provider`,status:B(i),title:`Model provider`,detail:i?e.providerMeta&&e.providerMeta.total>0?e.labels.providersMetaReady(n,r):e.labels.providersConfigured(t):e.labels.providersMissing,path:`/settings/capabilities/models`},{id:`defaultModel`,status:B(o),title:`Default model`,detail:o?e.labels.modelConfigured(a):e.labels.modelMissing,path:`/settings/capabilities/models`},{id:`ready`,status:p?`pass`:`fail`,title:`Chat readiness`,detail:p?e.labels.readyToChat:e.labels.modelMissing,path:`/chat`}],g=d.some(e=>e.status===`fail`),_=d.some(e=>e.status===`warn`),v=g?`blocked`:_?`attention`:p?`ready`:`setup`,y=U({doctorChecks:u,logsHealth:e.logsHealth,browserDiagnostics:e.browserDiagnostics});return{gatewayConnected:s,providerConfigured:i,providerCount:t,providerMetaConfigured:n,providerMetaTotal:r,defaultModel:a,defaultModelConfigured:o,channelConfigured:c,skillInstalled:l,skillCount:e.skillCount,checklist:f,readiness:h,issues:d,healthTier:v,diagnosticSignals:y,requiredComplete:p,allComplete:m}}function re(e){return z(e)}function W(e){return!e.id||!e.label||!e.status||!e.message||![`pass`,`warn`,`fail`,`skip`].includes(e.status)?null:{id:e.id,label:e.label,status:e.status,message:e.message,hints:Array.isArray(e.hints)?e.hints.filter(e=>typeof e==`string`):[],fixed:e.fixed===!0,findings:Array.isArray(e.findings)?e.findings:void 0}}function ie(){return u(`/api/doctor`)}async function ae(){return((await c(ie())).checks??[]).map(W).filter(e=>e!==null)}function oe(){return u(`/api/logs/health`)}async function se(){return c(oe())}function G(e){return e?`pass`:`warn`}function K(e){return`/settings/agent-browser?tab=${encodeURIComponent(e)}`}function ce(e){return e?.enabled?[`setup-browser-diagnostics`,e]:null}async function q(e){if(!e.enabled)return[];if(e.backend===`local`){let e=await c(u(`/api/browser/playwright/doctor`)),t=e.payload?.installed===!0;return[{id:`browser-playwright`,label:`Browser: Playwright`,status:G(t),message:t?`Local Chromium is installed.`:e.payload?.reason??`Local Chromium is not installed.`,path:K(`local`)}]}if(e.backend===`cloakbrowser`){let e=await c(u(`/api/browser/cloakbrowser/doctor`)),t=e.payload?.installed===!0;return[{id:`browser-cloakbrowser`,label:`Browser: CloakBrowser`,status:G(t),message:t?`CloakBrowser ${e.payload?.version??``}`.trim():`CloakBrowser is not installed.`,path:K(`cloakbrowser`)}]}if(e.backend===`extension`){let e=await c(u(`/api/browser/extension-status?probe=true`)),t=e.artifacts?.installed===!0,n=e.connected===!0,r=e.artifacts?.needsRefresh===!0||e.artifacts?.needsChromeReload===!0;return[{id:`browser-extension`,label:`Browser: Chrome extension`,status:n?`pass`:`warn`,message:n?`Chrome extension bridge is connected.`:t?r?`Chrome extension needs refresh.`:`Chrome extension is installed but not connected.`:`Chrome extension is not installed.`,path:K(`extension`)}]}return[{id:`browser-playwright`,label:`Browser`,status:`skip`,message:`Browser backend "${e.backend}" is not checked on this overview.`,path:K(e.backend||`overview`)}]}function J(){let e=(0,F.c)(57),t=d(me),n=l(pe),r;e[0]===n?r=e[1]:(r=s(n),e[0]=n,e[1]=r);let i=r,a=i.setupStatus.labels,o=T(fe),{data:c,error:u,isLoading:f,mutate:m}=h(!!t),g;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(g={revalidateOnFocus:!1},e[2]=g):g=e[2];let{data:y,error:b,isLoading:x,mutate:S}=p(t?`setup-checklist-skills`:null,de,g),C;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(C={revalidateOnFocus:!1},e[3]=C):C=e[3];let{data:w,error:ee,isLoading:E,mutate:O}=p(t?`setup-checklist-provider-meta`:null,D,C),k;e[4]===t?k=e[5]:(k=t?ie():null,e[4]=t,e[5]=k);let A;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(A={revalidateOnFocus:!1},e[6]=A):A=e[6];let{data:j,error:M,isLoading:N,mutate:P}=p(k,ae,A),I;e[7]===t?I=e[8]:(I=t?oe():null,e[7]=t,e[8]=I);let L;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(L={revalidateOnFocus:!1},e[9]=L):L=e[9];let{data:R,isLoading:z,mutate:B}=p(I,se,L);c?.payload?.config;let V=c?.payload?.config,H;e[10]===V?H=e[11]:(H=re(V),e[10]=V,e[11]=H);let te=t?H:null,U;e[12]===te?U=e[13]:(U=ce(te),e[12]=te,e[13]=U);let W;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(W={revalidateOnFocus:!1},e[14]=W):W=e[14];let{data:G,isLoading:K,mutate:q}=p(U,ue,W),J;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(J={revalidateOnFocus:!1},e[15]=J):J=e[15],p(t?v:null,_,J);let Y=!t||!f&&!x&&!E&&!N&&!z&&!K,X=!!(u||b||ee||M),Z;bb0:{if(!t||!Y){Z=null;break bb0}let n=y?.catalog?.length??0,r;if(e[16]!==G||e[17]!==c?.payload?.config||e[18]!==j||e[19]!==a.channelConfigured||e[20]!==a.channelMissing||e[21]!==a.gatewayOffline||e[22]!==a.gatewayOnline||e[23]!==a.modelConfigured||e[24]!==a.modelMissing||e[25]!==a.providersConfigured||e[26]!==a.providersMetaReady||e[27]!==a.providersMissing||e[28]!==a.skillsConfigured||e[29]!==a.skillsMissing||e[30]!==R||e[31]!==i.setupStatus.requiredCompleteMessage||e[32]!==w||e[33]!==o||e[34]!==n||e[35]!==t){let s=w?.filter(le).length??0,l=w?.length??0,u;e[37]===a.providersConfigured?u=e[38]:(u=e=>a.providersConfigured.replace(`{{count}}`,String(e)),e[37]=a.providersConfigured,e[38]=u);let d;e[39]===a.providersMetaReady?d=e[40]:(d=(e,t)=>a.providersMetaReady.replace(`{{configured}}`,String(e)).replace(`{{total}}`,String(t)),e[39]=a.providersMetaReady,e[40]=d);let f;e[41]===a.modelConfigured?f=e[42]:(f=e=>a.modelConfigured.replace(`{{model}}`,e),e[41]=a.modelConfigured,e[42]=f);let p;e[43]===a.skillsConfigured?p=e[44]:(p=e=>a.skillsConfigured.replace(`{{count}}`,String(e)),e[43]=a.skillsConfigured,e[44]=p),r=ne({hasToken:!!t,realtimeConnected:o,config:c?.payload?.config,skillCount:n,providerMeta:l>0?{configured:s,total:l}:null,doctorChecks:j,logsHealth:R,browserDiagnostics:G,labels:{gatewayOnline:a.gatewayOnline,gatewayOffline:a.gatewayOffline,providersConfigured:u,providersMetaReady:d,providersMissing:a.providersMissing,modelConfigured:f,modelMissing:a.modelMissing,channelConfigured:a.channelConfigured,channelMissing:a.channelMissing,skillsConfigured:p,skillsMissing:a.skillsMissing,readyToChat:i.setupStatus.requiredCompleteMessage}}),e[16]=G,e[17]=c?.payload?.config,e[18]=j,e[19]=a.channelConfigured,e[20]=a.channelMissing,e[21]=a.gatewayOffline,e[22]=a.gatewayOnline,e[23]=a.modelConfigured,e[24]=a.modelMissing,e[25]=a.providersConfigured,e[26]=a.providersMetaReady,e[27]=a.providersMissing,e[28]=a.skillsConfigured,e[29]=a.skillsMissing,e[30]=R,e[31]=i.setupStatus.requiredCompleteMessage,e[32]=w,e[33]=o,e[34]=n,e[35]=t,e[36]=r}else r=e[36];Z=r}let he=Z,Q;e[45]!==q||e[46]!==m||e[47]!==P||e[48]!==B||e[49]!==O||e[50]!==S?(Q=async()=>{await Promise.all([m(),S(),O(),P(),B(),q()])},e[45]=q,e[46]=m,e[47]=P,e[48]=B,e[49]=O,e[50]=S,e[51]=Q):Q=e[51];let ge=Q,$;return e[52]!==X||e[53]!==Y||e[54]!==ge||e[55]!==he?($={ready:Y,error:X,snapshot:he,refresh:ge},e[52]=X,e[53]=Y,e[54]=ge,e[55]=he,e[56]=$):$=e[56],$}function le(e){return e.configured}function ue(e){let[,t]=e;return q(t)}function de(){return w()}function fe(e){return e.connectionState===`connected`}function pe(e){return e.language}function me(e){return e.token}var Y=r();function X(e){return e===`pass`?`border-success/30 bg-success-soft text-success`:e===`warn`?`border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`fail`?`border-red-500/30 bg-red-500/10 text-red-700 dark:text-red-300`:`border-edge bg-surface-hover text-fg-muted`}function Z(e){return e===`pass`?a:e===`warn`?S:e===`fail`?x:C}function he(e,t){return e===`blocked`?{icon:x,className:`bg-red-500/10 text-red-950 dark:text-red-100`,title:t.health.blockedTitle,body:t.health.blockedBody,action:t.health.viewIssues,targetId:`next-steps`}:e===`attention`?{icon:S,className:`bg-amber-500/10 text-amber-950 dark:text-amber-100`,title:t.health.attentionTitle,body:t.health.attentionBody,action:t.health.viewIssues,targetId:`next-steps`}:e===`setup`?{icon:O,className:`bg-surface-base text-fg shadow-surface`,title:t.health.setupTitle,body:t.health.setupBody,action:t.health.continueSetup,targetId:`next-steps`}:{icon:a,className:`bg-success-soft text-success`,title:t.health.readyTitle,body:t.health.readyBody,action:t.health.startChat,actionPath:`/chat`}}function Q(e){let t=(0,F.c)(48),{tier:n,issueCount:r,onRunDoctor:a,ready:c,doctorRunning:u,doctorRunState:d}=e,p=l(ge),h,g,_,v,b,x,S,C,w,T,E;if(t[0]!==r||t[1]!==p||t[2]!==n){g=s(p).setupStatus;let e=he(n,g),a=e.icon,o=`targetId`in e&&typeof e.targetId==`string`?e.targetId:null,c=`actionPath`in e&&typeof e.actionPath==`string`?e.actionPath:`/chat`;h=o?(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>document.getElementById(o)?.scrollIntoView({block:`start`,behavior:`smooth`}),className:`inline-flex items-center gap-1 rounded-lg bg-surface-base px-3 py-2 text-sm font-medium text-fg shadow-sm hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[e.action,(0,Y.jsx)(y,{className:`size-4`,"aria-hidden":!0})]}):(0,Y.jsxs)(i,{to:c,className:`inline-flex items-center gap-1 rounded-lg bg-surface-base px-3 py-2 text-sm font-medium text-fg shadow-sm hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[e.action,(0,Y.jsx)(y,{className:`size-4`,"aria-hidden":!0})]}),E=f(`rounded-xl p-4`,e.className),T=`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,C=`flex min-w-0 gap-3`,w=(0,Y.jsx)(a,{className:`mt-0.5 size-5 shrink-0`,"aria-hidden":!0}),b=`min-w-0`,x=(0,Y.jsx)(`h2`,{className:`text-base font-semibold`,children:e.title}),S=(0,Y.jsx)(`p`,{className:`mt-1 text-sm opacity-85`,children:e.body}),_=`mt-2 text-xs opacity-75`,v=g.health.issueCount.replace(`{{count}}`,String(r)),t[0]=r,t[1]=p,t[2]=n,t[3]=h,t[4]=g,t[5]=_,t[6]=v,t[7]=b,t[8]=x,t[9]=S,t[10]=C,t[11]=w,t[12]=T,t[13]=E}else h=t[3],g=t[4],_=t[5],v=t[6],b=t[7],x=t[8],S=t[9],C=t[10],w=t[11],T=t[12],E=t[13];let D;t[14]!==_||t[15]!==v?(D=(0,Y.jsx)(`p`,{className:_,children:v}),t[14]=_,t[15]=v,t[16]=D):D=t[16];let O;t[17]!==D||t[18]!==b||t[19]!==x||t[20]!==S?(O=(0,Y.jsxs)(`div`,{className:b,children:[x,S,D]}),t[17]=D,t[18]=b,t[19]=x,t[20]=S,t[21]=O):O=t[21];let k;t[22]!==O||t[23]!==C||t[24]!==w?(k=(0,Y.jsxs)(`div`,{className:C,children:[w,O]}),t[22]=O,t[23]=C,t[24]=w,t[25]=k):k=t[25];let A;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(A=f(`inline-flex items-center gap-2 rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,m.press),t[26]=A):A=t[26];let j=!c||u,M;t[27]===u?M=t[28]:(M=u?(0,Y.jsx)(o,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,Y.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),t[27]=u,t[28]=M);let N=u?g.health.runDoctorRunning:g.health.runDoctor,P;t[29]!==u||t[30]!==a||t[31]!==j||t[32]!==M||t[33]!==N?(P=(0,Y.jsxs)(`button`,{type:`button`,className:A,onClick:a,disabled:j,"aria-busy":u,children:[M,N]}),t[29]=u,t[30]=a,t[31]=j,t[32]=M,t[33]=N,t[34]=P):P=t[34];let I;t[35]!==h||t[36]!==P?(I=(0,Y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[h,P]}),t[35]=h,t[36]=P,t[37]=I):I=t[37];let L;t[38]!==k||t[39]!==I||t[40]!==T?(L=(0,Y.jsxs)(`div`,{className:T,children:[k,I]}),t[38]=k,t[39]=I,t[40]=T,t[41]=L):L=t[41];let R=u?g.health.doctorRunningMessage:d===`success`?g.health.doctorCompleteMessage:d===`error`?g.health.doctorFailedMessage:g.health.doctorIdleMessage,z;t[42]===R?z=t[43]:(z=(0,Y.jsx)(`p`,{className:`mt-3 text-xs opacity-75`,role:`status`,"aria-live":`polite`,children:R}),t[42]=R,t[43]=z);let B;return t[44]!==L||t[45]!==z||t[46]!==E?(B=(0,Y.jsxs)(`section`,{className:E,children:[L,z]}),t[44]=L,t[45]=z,t[46]=E,t[47]=B):B=t[47],B}function ge(e){return e.language}function $(e){let t=(0,F.c)(34),{issue:n,fixLabel:r}=e,a;t[0]===n.status?a=t[1]:(a=Z(n.status),t[0]=n.status,t[1]=a);let o=a,s;t[2]===o?s=t[3]:(s=(0,Y.jsx)(o,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=o,t[3]=s);let c;t[4]===n.label?c=t[5]:(c=(0,Y.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:n.label}),t[4]=n.label,t[5]=c);let l;t[6]===n.status?l=t[7]:(l=f(`rounded-full border px-2 py-0.5 text-[11px] font-medium uppercase`,X(n.status)),t[6]=n.status,t[7]=l);let u;t[8]!==n.status||t[9]!==l?(u=(0,Y.jsx)(`span`,{className:l,children:n.status}),t[8]=n.status,t[9]=l,t[10]=u):u=t[10];let d;t[11]!==c||t[12]!==u?(d=(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[c,u]}),t[11]=c,t[12]=u,t[13]=d):d=t[13];let p;t[14]===n.message?p=t[15]:(p=(0,Y.jsx)(`span`,{className:`mt-1 block text-sm text-fg-muted`,children:n.message}),t[14]=n.message,t[15]=p);let m;t[16]===n.hints[0]?m=t[17]:(m=n.hints[0]?(0,Y.jsx)(`span`,{className:`mt-1 block truncate text-xs text-fg-subtle`,children:n.hints[0]}):null,t[16]=n.hints[0],t[17]=m);let h;t[18]!==d||t[19]!==p||t[20]!==m?(h=(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[d,p,m]}),t[18]=d,t[19]=p,t[20]=m,t[21]=h):h=t[21];let g;t[22]!==r||t[23]!==n.path?(g=n.path?(0,Y.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs font-medium text-accent-fg`,children:[r,(0,Y.jsx)(y,{className:`size-4`,"aria-hidden":!0})]}):null,t[22]=r,t[23]=n.path,t[24]=g):g=t[24];let _;t[25]!==g||t[26]!==s||t[27]!==h?(_=(0,Y.jsxs)(Y.Fragment,{children:[s,h,g]}),t[25]=g,t[26]=s,t[27]=h,t[28]=_):_=t[28];let v=_;if(n.path){let e;return t[29]!==v||t[30]!==n.path?(e=(0,Y.jsx)(i,{to:n.path,className:`flex items-start gap-3 rounded-lg bg-surface-panel/80 p-3 shadow-surface hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:v}),t[29]=v,t[30]=n.path,t[31]=e):e=t[31],e}let b;return t[32]===v?b=t[33]:(b=(0,Y.jsx)(`div`,{className:`flex items-start gap-3 rounded-lg bg-surface-panel/80 p-3 shadow-surface`,children:v}),t[32]=v,t[33]=b),b}function _e(e){let t=(0,F.c)(27),{item:n,labels:r}=e,a;t[0]===n.status?a=t[1]:(a=Z(n.status),t[0]=n.status,t[1]=a);let o=a,s=r[n.id]??n.title,c;t[2]===n.status?c=t[3]:(c=f(`flex size-7 shrink-0 items-center justify-center rounded-full border`,X(n.status)),t[2]=n.status,t[3]=c);let l;t[4]===o?l=t[5]:(l=(0,Y.jsx)(o,{className:`size-4`,"aria-hidden":!0}),t[4]=o,t[5]=l);let u;t[6]!==c||t[7]!==l?(u=(0,Y.jsx)(`span`,{className:c,children:l}),t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]===s?d=t[10]:(d=(0,Y.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:s}),t[9]=s,t[10]=d);let p;t[11]===n.detail?p=t[12]:(p=(0,Y.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.detail}),t[11]=n.detail,t[12]=p);let m;t[13]!==d||t[14]!==p?(m=(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[d,p]}),t[13]=d,t[14]=p,t[15]=m):m=t[15];let h;t[16]===n.path?h=t[17]:(h=n.path?(0,Y.jsx)(y,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}):null,t[16]=n.path,t[17]=h);let g;t[18]!==u||t[19]!==m||t[20]!==h?(g=(0,Y.jsxs)(Y.Fragment,{children:[u,m,h]}),t[18]=u,t[19]=m,t[20]=h,t[21]=g):g=t[21];let _=g;if(n.path){let e;return t[22]!==_||t[23]!==n.path?(e=(0,Y.jsx)(i,{to:n.path,className:`flex items-center gap-3 rounded-lg p-3 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:_}),t[22]=_,t[23]=n.path,t[24]=e):e=t[24],e}let v;return t[25]===_?v=t[26]:(v=(0,Y.jsx)(`div`,{className:`flex items-center gap-3 rounded-lg p-3`,children:_}),t[25]=_,t[26]=v),v}function ve(e){let t=(0,F.c)(29),{signal:n,fixLabel:r}=e,a;t[0]===n.status?a=t[1]:(a=Z(n.status),t[0]=n.status,t[1]=a);let o=a,s;t[2]===o?s=t[3]:(s=(0,Y.jsx)(o,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=o,t[3]=s);let c;t[4]===n.label?c=t[5]:(c=(0,Y.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:n.label}),t[4]=n.label,t[5]=c);let l;t[6]===n.message?l=t[7]:(l=(0,Y.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.message}),t[6]=n.message,t[7]=l);let u;t[8]!==c||t[9]!==l?(u=(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10];let d;t[11]===n.status?d=t[12]:(d=f(`shrink-0 rounded-full border px-2 py-0.5 text-[11px] font-medium uppercase`,X(n.status)),t[11]=n.status,t[12]=d);let p;t[13]!==n.status||t[14]!==d?(p=(0,Y.jsx)(`span`,{className:d,children:n.status}),t[13]=n.status,t[14]=d,t[15]=p):p=t[15];let m;t[16]!==r||t[17]!==n.path?(m=n.path?(0,Y.jsx)(`span`,{className:`sr-only`,children:r}):null,t[16]=r,t[17]=n.path,t[18]=m):m=t[18];let h;t[19]!==s||t[20]!==u||t[21]!==p||t[22]!==m?(h=(0,Y.jsxs)(Y.Fragment,{children:[s,u,p,m]}),t[19]=s,t[20]=u,t[21]=p,t[22]=m,t[23]=h):h=t[23];let g=h;if(n.path){let e;return t[24]!==g||t[25]!==n.path?(e=(0,Y.jsx)(i,{to:n.path,className:`flex min-w-0 items-start gap-2 rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:g}),t[24]=g,t[25]=n.path,t[26]=e):e=t[26],e}let _;return t[27]===g?_=t[28]:(_=(0,Y.jsx)(`div`,{className:`flex min-w-0 items-start gap-2 rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:g}),t[27]=g,t[28]=_),_}function ye(){let e=s(l(e=>e.language)).setupStatus,{ready:t,error:n,snapshot:r,refresh:i}=J(),[a,o]=(0,P.useState)(!1),[c,u]=(0,P.useState)(`idle`),d=r?.diagnosticSignals.filter(e=>e.status===`fail`||e.status===`warn`)??[],p=async()=>{if(!(a||!t)){o(!0),u(`idle`);try{await i(),u(`success`)}catch{u(`error`)}finally{o(!1)}}};return(0,Y.jsxs)(A,{gap:`gap-6`,children:[(0,Y.jsx)(k,{title:e.title,subtitle:e.subtitle,actions:(0,Y.jsxs)(`button`,{type:`button`,className:f(`inline-flex shrink-0 items-center gap-2 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,m.press),onClick:()=>void p(),disabled:!t||a,"aria-busy":a,children:[(0,Y.jsx)(ee,{className:f(`size-4`,(!t||a)&&`animate-spin`),"aria-hidden":!0}),a?e.health.runDoctorRunning:e.refresh]})}),n?(0,Y.jsx)(`p`,{className:`rounded-xl border border-red-300/40 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-900/40 dark:bg-red-950/30 dark:text-red-300`,children:e.loadError}):null,!t||!r?(0,Y.jsx)(j,{sections:2}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{tier:r.healthTier,issueCount:r.issues.length,ready:t,onRunDoctor:()=>void p(),doctorRunning:a,doctorRunState:c}),(0,Y.jsxs)(N,{id:`next-steps`,children:[(0,Y.jsx)(M,{icon:r.issues.length?S:E,title:e.nextStepsTitle,subtitle:r.issues.length?e.nextStepsIssuesSubtitle:e.nextStepsReadySubtitle}),r.issues.length?(0,Y.jsx)(`div`,{className:`mt-4 flex flex-col gap-2`,children:r.issues.slice(0,8).map(t=>(0,Y.jsx)($,{issue:t,fixLabel:e.fixIssue},`${t.source}:${t.id}`))}):(0,Y.jsx)(`div`,{className:`mt-4 rounded-lg bg-surface-panel/80 shadow-surface`,children:r.readiness.map(t=>(0,Y.jsx)(_e,{item:t,labels:e.readinessLabels},t.id))})]}),(0,Y.jsxs)(N,{children:[(0,Y.jsx)(M,{icon:b,title:e.diagnosticsTitle,subtitle:e.diagnosticsSubtitle}),d.length?(0,Y.jsx)(`div`,{className:`mt-4 grid gap-2 md:grid-cols-2`,children:d.map(t=>(0,Y.jsx)(ve,{signal:t,fixLabel:e.fixIssue},t.id))}):(0,Y.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-panel/80 p-3 text-sm text-fg-muted shadow-surface`,children:r.diagnosticSignals.length?e.diagnosticsAllClear:e.diagnosticsEmpty})]})]})]})}export{ye as SetupStatusPanel};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{p as i}from"./chunk-KS7C4IRE-BaASWQor.js";import{a,n as o,o as s,r as c,s as l,t as u}from"./dist-CpzYSoz7.js";import{t as d}from"./check-DUBLcKHA.js";import{n as f,r as p}from"./popover-select-C-Hj-nXR.js";import{t as m}from"./copy-Dv6d4Dvw.js";import{t as h}from"./folder-open-CyzJ19I9.js";import{t as g}from"./loader-circle-CifKLtgG.js";import{t as _}from"./plus-Q2yW6OE7.js";import{t as v}from"./x-B_N4OPjy.js";import{t as y}from"./copy-to-clipboard-HOJ79TWv.js";import{t as b}from"./messages-BbdwoxVo.js";import{a as x,n as S,r as C,s as w}from"./locale-store-CBoCuIMx.js";import{t as T}from"./cn-JdwAhgNB.js";import{i as ee}from"./vendor-swr-BIWyz7Rc.js";import{t as E}from"./button-CtTvuElV.js";import{n as D,r as O}from"./gateway-config-swr-826dipyU.js";import{s as k}from"./form-field-width-DJw_jULe.js";import{t as A}from"./skeleton-BwbyijEw.js";import{Ar as j,Br as M,Es as N,Fr as P,Ir as F,Li as I,Ll as L,Lr as te,Mr as ne,Ns as re,Pr as ie,Rr as R,Sc as ae,Vr as z,Wt as oe,bl as B,ec as se,ll as V,qt as ce,ri as H,ti as le,zr as ue}from"./index-eZjksPvq.js";import{n as de,r as U,t as fe}from"./settings-page-layout-BRQNel6r.js";import{t as pe}from"./settings-loading-skeleton-CAmWMaOT.js";import{t as W}from"./settings-form-section-DjWzRk4z.js";import{t as me}from"./page-tabs-BaEQMYm_.js";var G=e(t(),1),he=n(),K={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(K)}var q=36e5,J=864e5,Y=1048576;function _e(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function X(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=_e(e)?e:{},n=_e(t.gateway)?t.gateway:{},r=_e(n.share)?n.share:{},i=_e(r.directory)?r.directory:{},a=_e(r.note)?r.note:{},o=_e(n.siteShare)?n.siteShare:{},s=_e(o.static)?o.static:{},c=typeof r.defaultTtlMs==`number`&&Number.isFinite(r.defaultTtlMs)?Math.floor(r.defaultTtlMs):K.defaultTtlHours*q,l=typeof r.maxTtlMs==`number`&&Number.isFinite(r.maxTtlMs)?Math.floor(r.maxTtlMs):K.maxTtlDays*J,u=typeof r.maxFileSize==`number`&&Number.isFinite(r.maxFileSize)?Math.floor(r.maxFileSize):K.maxFileSizeMb*Y,d=typeof i.maxFolderSize==`number`&&Number.isFinite(i.maxFolderSize)?Math.floor(i.maxFolderSize):K.directoryMaxFolderSizeMb*Y,f=typeof o.defaultTtlMs==`number`&&Number.isFinite(o.defaultTtlMs)?Math.floor(o.defaultTtlMs):K.siteDefaultTtlHours*q,p=typeof o.maxTtlMs==`number`&&Number.isFinite(o.maxTtlMs)?Math.floor(o.maxTtlMs):K.siteMaxTtlDays*J,m=typeof s.maxRootDirSize==`number`&&Number.isFinite(s.maxRootDirSize)?Math.floor(s.maxRootDirSize):K.siteMaxRootDirSizeMb*Y,h=typeof a.maxTotalSize==`number`&&Number.isFinite(a.maxTotalSize)?Math.floor(a.maxTotalSize):K.noteMaxTotalSizeMb*Y;return{enabled:r.enabled!==!1,defaultTtlHours:Math.max(1,Math.round(c/q)),maxTtlDays:Math.max(1,Math.round(l/J)),maxActiveShares:typeof r.maxActiveShares==`number`&&Number.isFinite(r.maxActiveShares)?Math.max(1,Math.min(1e4,Math.floor(r.maxActiveShares))):K.maxActiveShares,maxFileSizeMb:Math.max(1,Math.round(u/Y)),directoryMaxFolderSizeMb:Math.max(1,Math.round(d/Y)),directoryMaxFileCount:typeof i.maxFileCount==`number`&&Number.isFinite(i.maxFileCount)?Math.max(1,Math.min(1e5,Math.floor(i.maxFileCount))):K.directoryMaxFileCount,inlinePreviewMimes:X(r.inlinePreviewMimes,32).length?X(r.inlinePreviewMimes,32):[...K.inlinePreviewMimes],noteEnabled:a.enabled!==!1,noteMaxTotalSizeMb:Math.max(1,Math.round(h/Y)),noteMaxAttachmentCount:typeof a.maxAttachmentCount==`number`&&Number.isFinite(a.maxAttachmentCount)?Math.max(0,Math.min(500,Math.floor(a.maxAttachmentCount))):K.noteMaxAttachmentCount,siteEnabled:o.enabled!==!1,siteDefaultTtlHours:Math.max(1,Math.round(f/q)),siteMaxTtlDays:Math.max(1,Math.round(p/J)),maxActiveSites:typeof o.maxActiveSites==`number`&&Number.isFinite(o.maxActiveSites)?Math.max(1,Math.min(1e3,Math.floor(o.maxActiveSites))):K.maxActiveSites,siteMaxRootDirSizeMb:Math.max(1,Math.round(m/Y)),siteMaxFileCount:typeof s.maxFileCount==`number`&&Number.isFinite(s.maxFileCount)?Math.max(1,Math.min(1e5,Math.floor(s.maxFileCount))):K.siteMaxFileCount}}function Z(e){let t=e.defaultTtlHours*q,n=e.maxTtlDays*J,r=e.siteDefaultTtlHours*q,i=e.siteMaxTtlDays*J;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 ye(e){let t=Z(e);if(t)throw Error(t);await x(C(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{share:{enabled:e.enabled,defaultTtlMs:e.defaultTtlHours*q,maxTtlMs:e.maxTtlDays*J,maxActiveShares:e.maxActiveShares,maxFileSize:e.maxFileSizeMb*Y,inlinePreviewMimes:e.inlinePreviewMimes,directory:{maxFolderSize:e.directoryMaxFolderSizeMb*Y,maxFileCount:e.directoryMaxFileCount},note:{enabled:e.noteEnabled,maxTotalSize:e.noteMaxTotalSizeMb*Y,maxAttachmentCount:e.noteMaxAttachmentCount}},siteShare:{enabled:e.siteEnabled,defaultTtlMs:e.siteDefaultTtlHours*q,maxTtlMs:e.siteMaxTtlDays*J,maxActiveSites:e.maxActiveSites,static:{maxRootDirSize:e.siteMaxRootDirSizeMb*Y,maxFileCount:e.siteMaxFileCount}}}})}),D()}var Q=r();function be(){return T(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,k,`dark:border-edge`)}function xe({hasToken:e}){let t=b(S(e=>e.language)).sharesSettings,{data:n,isLoading:r}=O(e),i=(0,G.useMemo)(()=>n?.payload?.config===void 0?null:structuredClone(ve(n.payload.config)),[n]),a=(0,G.useRef)(!1),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(null),[f,p]=(0,G.useState)(!1),m=o??i,h=i,g=(0,G.useMemo)(()=>!m||!h?!1:JSON.stringify(m)!==JSON.stringify(h),[m,h]),_=(0,G.useCallback)(e=>{a.current=!0,s(t=>{let n=t??h;return n?{...n,...e}:null})},[h]),v=(0,G.useCallback)(async()=>{if(!(!m||c)){l(!0),d(null),p(!1);try{await ye(m),a.current=!1,s(null),p(!0),window.setTimeout(()=>p(!1),2500)}catch(e){d(e instanceof Error?e.message:t.policySaveError)}finally{l(!1)}}},[m,c,t.policySaveError]),y=(0,G.useCallback)(()=>{a.current=!1,s(null),d(null),p(!1)},[]);return!e||!m?r?(0,Q.jsx)(W,{children:(0,Q.jsx)(pe,{rows:2})}):null:(0,Q.jsxs)(W,{children:[(0,Q.jsxs)(`div`,{className:`mb-4 flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.policyTitle}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:t.policyHint})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[f?(0,Q.jsx)(`span`,{className:`text-sm text-fg-muted`,children:t.policySaved}):null,(0,Q.jsx)(E,{type:`button`,variant:`secondary`,disabled:c,onClick:()=>_(ge()),children:t.policyUseRecommended}),(0,Q.jsx)(E,{type:`button`,variant:`secondary`,disabled:!g||c,onClick:y,children:t.policyDiscard}),(0,Q.jsx)(E,{type:`button`,variant:`primary`,disabled:!g||c,onClick:()=>void v(),children:c?t.policySaving:t.policySave})]})]}),g?(0,Q.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:t.policyUnsaved}):null,u?(0,Q.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:u}):null,(0,Q.jsx)(`p`,{className:`mb-4 text-xs text-fg-subtle`,children:t.policyRestartHint}),(0,Q.jsx)(Se,{t,form:m,onChange:_})]})}function Se(e){let t=(0,he.c)(189),{t:n,form:r,onChange:i}=e,a;t[0]===n.policyFileSection?a=t[1]:(a=(0,Q.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,Q.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,Q.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,Q.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,Q.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,Q.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,Q.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,Q.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,Q.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 C=!r.enabled,w;t[47]===i?w=t[48]:(w=e=>i({directoryMaxFolderSizeMb:e}),t[47]=i,t[48]=w);let T;t[49]!==r.directoryMaxFolderSizeMb||t[50]!==n.policyDirectoryMaxFolderSizeHint||t[51]!==n.policyDirectoryMaxFolderSizeMb||t[52]!==C||t[53]!==w?(T=(0,Q.jsx)($,{id:`share-directory-max-size-mb`,label:n.policyDirectoryMaxFolderSizeMb,hint:n.policyDirectoryMaxFolderSizeHint,value:r.directoryMaxFolderSizeMb,min:1,max:10240,disabled:C,onChange:w}),t[49]=r.directoryMaxFolderSizeMb,t[50]=n.policyDirectoryMaxFolderSizeHint,t[51]=n.policyDirectoryMaxFolderSizeMb,t[52]=C,t[53]=w,t[54]=T):T=t[54];let ee=!r.enabled,E;t[55]===i?E=t[56]:(E=e=>i({directoryMaxFileCount:e}),t[55]=i,t[56]=E);let D;t[57]!==r.directoryMaxFileCount||t[58]!==n.policyDirectoryMaxFileCount||t[59]!==n.policyDirectoryMaxFileCountHint||t[60]!==ee||t[61]!==E?(D=(0,Q.jsx)($,{id:`share-directory-max-files`,label:n.policyDirectoryMaxFileCount,hint:n.policyDirectoryMaxFileCountHint,value:r.directoryMaxFileCount,min:1,max:1e5,disabled:ee,onChange:E}),t[57]=r.directoryMaxFileCount,t[58]=n.policyDirectoryMaxFileCount,t[59]=n.policyDirectoryMaxFileCountHint,t[60]=ee,t[61]=E,t[62]=D):D=t[62];let O;t[63]!==g||t[64]!==y||t[65]!==S||t[66]!==T||t[67]!==D||t[68]!==p?(O=(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[p,g,y,S,T,D]}),t[63]=g,t[64]=y,t[65]=S,t[66]=T,t[67]=D,t[68]=p,t[69]=O):O=t[69];let k=!r.enabled,A;t[70]===i?A=t[71]:(A=e=>i({inlinePreviewMimes:e}),t[70]=i,t[71]=A);let j;t[72]!==r.inlinePreviewMimes||t[73]!==n||t[74]!==k||t[75]!==A?(j=(0,Q.jsx)(Ce,{t:n,values:r.inlinePreviewMimes,disabled:k,onChange:A}),t[72]=r.inlinePreviewMimes,t[73]=n,t[74]=k,t[75]=A,t[76]=j):j=t[76];let M;t[77]!==O||t[78]!==j||t[79]!==s||t[80]!==u?(M=(0,Q.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-muted/25 p-4`,children:[s,u,O,j]}),t[77]=O,t[78]=j,t[79]=s,t[80]=u,t[81]=M):M=t[81];let N;t[82]===n.policyNoteSection?N=t[83]:(N=(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.policyNoteSection}),t[82]=n.policyNoteSection,t[83]=N);let P;t[84]===n.policyNoteSectionHint?P=t[85]:(P=(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.policyNoteSectionHint}),t[84]=n.policyNoteSectionHint,t[85]=P);let F;t[86]!==N||t[87]!==P?(F=(0,Q.jsxs)(`div`,{className:`mb-4`,children:[N,P]}),t[86]=N,t[87]=P,t[88]=F):F=t[88];let I;t[89]===i?I=t[90]:(I=e=>i({noteEnabled:e.target.checked}),t[89]=i,t[90]=I);let L;t[91]!==r.noteEnabled||t[92]!==I?(L=(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.noteEnabled,onChange:I}),t[91]=r.noteEnabled,t[92]=I,t[93]=L):L=t[93];let te;t[94]!==n.policyNoteEnabled||t[95]!==L?(te=(0,Q.jsxs)(`label`,{className:`mb-4 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[L,n.policyNoteEnabled]}),t[94]=n.policyNoteEnabled,t[95]=L,t[96]=te):te=t[96];let ne=!r.enabled||!r.noteEnabled,re;t[97]===i?re=t[98]:(re=e=>i({noteMaxTotalSizeMb:e}),t[97]=i,t[98]=re);let ie;t[99]!==r.noteMaxTotalSizeMb||t[100]!==n.policyNoteMaxTotalSizeHint||t[101]!==n.policyNoteMaxTotalSizeMb||t[102]!==ne||t[103]!==re?(ie=(0,Q.jsx)($,{id:`share-note-max-size-mb`,label:n.policyNoteMaxTotalSizeMb,hint:n.policyNoteMaxTotalSizeHint,value:r.noteMaxTotalSizeMb,min:1,max:2048,disabled:ne,onChange:re}),t[99]=r.noteMaxTotalSizeMb,t[100]=n.policyNoteMaxTotalSizeHint,t[101]=n.policyNoteMaxTotalSizeMb,t[102]=ne,t[103]=re,t[104]=ie):ie=t[104];let R=!r.enabled||!r.noteEnabled,ae;t[105]===i?ae=t[106]:(ae=e=>i({noteMaxAttachmentCount:e}),t[105]=i,t[106]=ae);let z;t[107]!==r.noteMaxAttachmentCount||t[108]!==n.policyNoteMaxAttachmentCount||t[109]!==n.policyNoteMaxAttachmentCountHint||t[110]!==R||t[111]!==ae?(z=(0,Q.jsx)($,{id:`share-note-max-attachments`,label:n.policyNoteMaxAttachmentCount,hint:n.policyNoteMaxAttachmentCountHint,value:r.noteMaxAttachmentCount,min:0,max:500,disabled:R,onChange:ae}),t[107]=r.noteMaxAttachmentCount,t[108]=n.policyNoteMaxAttachmentCount,t[109]=n.policyNoteMaxAttachmentCountHint,t[110]=R,t[111]=ae,t[112]=z):z=t[112];let oe;t[113]!==ie||t[114]!==z?(oe=(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[ie,z]}),t[113]=ie,t[114]=z,t[115]=oe):oe=t[115];let B;t[116]!==F||t[117]!==te||t[118]!==oe?(B=(0,Q.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-muted/25 p-4`,children:[F,te,oe]}),t[116]=F,t[117]=te,t[118]=oe,t[119]=B):B=t[119];let se;t[120]===n.policySiteSection?se=t[121]:(se=(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.policySiteSection}),t[120]=n.policySiteSection,t[121]=se);let V;t[122]===n.policySiteSectionHint?V=t[123]:(V=(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.policySiteSectionHint}),t[122]=n.policySiteSectionHint,t[123]=V);let ce;t[124]!==se||t[125]!==V?(ce=(0,Q.jsxs)(`div`,{className:`mb-4`,children:[se,V]}),t[124]=se,t[125]=V,t[126]=ce):ce=t[126];let H;t[127]===i?H=t[128]:(H=e=>i({siteEnabled:e.target.checked}),t[127]=i,t[128]=H);let le;t[129]!==r.siteEnabled||t[130]!==H?(le=(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.siteEnabled,onChange:H}),t[129]=r.siteEnabled,t[130]=H,t[131]=le):le=t[131];let ue;t[132]!==n.policySiteEnabled||t[133]!==le?(ue=(0,Q.jsxs)(`label`,{className:`mb-4 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[le,n.policySiteEnabled]}),t[132]=n.policySiteEnabled,t[133]=le,t[134]=ue):ue=t[134];let de=!r.siteEnabled,U;t[135]===i?U=t[136]:(U=e=>i({siteDefaultTtlHours:e}),t[135]=i,t[136]=U);let fe;t[137]!==r.siteDefaultTtlHours||t[138]!==n.policySiteDefaultTtlHint||t[139]!==n.policySiteDefaultTtlHours||t[140]!==de||t[141]!==U?(fe=(0,Q.jsx)($,{id:`site-share-default-ttl-hours`,label:n.policySiteDefaultTtlHours,hint:n.policySiteDefaultTtlHint,value:r.siteDefaultTtlHours,min:1,max:168,disabled:de,onChange:U}),t[137]=r.siteDefaultTtlHours,t[138]=n.policySiteDefaultTtlHint,t[139]=n.policySiteDefaultTtlHours,t[140]=de,t[141]=U,t[142]=fe):fe=t[142];let pe=!r.siteEnabled,W;t[143]===i?W=t[144]:(W=e=>i({siteMaxTtlDays:e}),t[143]=i,t[144]=W);let me;t[145]!==r.siteMaxTtlDays||t[146]!==n.policySiteMaxTtlDays||t[147]!==n.policySiteMaxTtlHint||t[148]!==pe||t[149]!==W?(me=(0,Q.jsx)($,{id:`site-share-max-ttl-days`,label:n.policySiteMaxTtlDays,hint:n.policySiteMaxTtlHint,value:r.siteMaxTtlDays,min:1,max:30,disabled:pe,onChange:W}),t[145]=r.siteMaxTtlDays,t[146]=n.policySiteMaxTtlDays,t[147]=n.policySiteMaxTtlHint,t[148]=pe,t[149]=W,t[150]=me):me=t[150];let G=!r.siteEnabled,K;t[151]===i?K=t[152]:(K=e=>i({maxActiveSites:e}),t[151]=i,t[152]=K);let ge;t[153]!==r.maxActiveSites||t[154]!==n.policyMaxActiveSites||t[155]!==n.policyMaxActiveSitesHint||t[156]!==G||t[157]!==K?(ge=(0,Q.jsx)($,{id:`site-share-max-active`,label:n.policyMaxActiveSites,hint:n.policyMaxActiveSitesHint,value:r.maxActiveSites,min:1,max:1e3,disabled:G,onChange:K}),t[153]=r.maxActiveSites,t[154]=n.policyMaxActiveSites,t[155]=n.policyMaxActiveSitesHint,t[156]=G,t[157]=K,t[158]=ge):ge=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,Q.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,X;t[167]===i?X=t[168]:(X=e=>i({siteMaxFileCount:e}),t[167]=i,t[168]=X);let ve;t[169]!==r.siteMaxFileCount||t[170]!==n.policySiteMaxFileCount||t[171]!==n.policySiteMaxFileCountHint||t[172]!==_e||t[173]!==X?(ve=(0,Q.jsx)($,{id:`site-share-max-files`,label:n.policySiteMaxFileCount,hint:n.policySiteMaxFileCountHint,value:r.siteMaxFileCount,min:1,max:1e5,disabled:_e,onChange:X}),t[169]=r.siteMaxFileCount,t[170]=n.policySiteMaxFileCount,t[171]=n.policySiteMaxFileCountHint,t[172]=_e,t[173]=X,t[174]=ve):ve=t[174];let Z;t[175]!==fe||t[176]!==me||t[177]!==ge||t[178]!==Y||t[179]!==ve?(Z=(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[fe,me,ge,Y,ve]}),t[175]=fe,t[176]=me,t[177]=ge,t[178]=Y,t[179]=ve,t[180]=Z):Z=t[180];let ye;t[181]!==ce||t[182]!==ue||t[183]!==Z?(ye=(0,Q.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-muted/25 p-4`,children:[ce,ue,Z]}),t[181]=ce,t[182]=ue,t[183]=Z,t[184]=ye):ye=t[184];let be;return t[185]!==M||t[186]!==B||t[187]!==ye?(be=(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[M,B,ye]}),t[185]=M,t[186]=B,t[187]=ye,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,Q.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=T(be(),`max-w-xs font-mono text-xs`),t[3]=d):d=t[3];let f;t[4]!==s||t[5]!==o||t[6]!==l?(f=e=>{let t=Number(e.target.value);Number.isFinite(t)&&l(Math.max(o,Math.min(s,Math.floor(t))))},t[4]=s,t[5]=o,t[6]=l,t[7]=f):f=t[7];let p;t[8]!==c||t[9]!==n||t[10]!==s||t[11]!==o||t[12]!==f||t[13]!==a?(p=(0,Q.jsx)(`input`,{id:n,type:`number`,min:o,max:s,disabled:c,className:d,value:a,onChange:f}),t[8]=c,t[9]=n,t[10]=s,t[11]=o,t[12]=f,t[13]=a,t[14]=p):p=t[14];let m;t[15]===i?m=t[16]:(m=(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}),t[15]=i,t[16]=m);let h;return t[17]!==u||t[18]!==p||t[19]!==m?(h=(0,Q.jsxs)(`div`,{children:[u,p,m]}),t[17]=u,t[18]=p,t[19]=m,t[20]=h):h=t[20],h}function Ce(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,Q.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,Q.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,Q.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,Q.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,Q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:u}),t[11]=u,t[12]=d);let f;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(f=T(be(),`font-mono text-xs`),t[13]=f):f=t[13];let p=i||r.length>=32,m;t[14]===s?m=t[15]:(m=e=>{e.key===`Enter`&&(e.preventDefault(),s(e.target.value),e.target.value=``)},t[14]=s,t[15]=m);let h;t[16]!==n.policyMimePlaceholder||t[17]!==p||t[18]!==m?(h=(0,Q.jsx)(`input`,{className:f,placeholder:n.policyMimePlaceholder,disabled:p,onKeyDown:m}),t[16]=n.policyMimePlaceholder,t[17]=p,t[18]=m,t[19]=h):h=t[19];let g;return t[20]!==c||t[21]!==l||t[22]!==d||t[23]!==h?(g=(0,Q.jsxs)(`div`,{className:`space-y-2 border-t border-edge pt-4`,children:[c,l,d,h]}),t[20]=c,t[21]=l,t[22]=d,t[23]=h,t[24]=g):g=t[24],g}function we(e){let t=(0,he.c)(70),{open:n,onOpenChange:r,onConfirm:i,initialPath:d,selectKind:m,sessionKey:_,agentId:y}=e,x=m===void 0?`any`:m,C=b(S(De)),D=C.workspace,O=C.sharesSettings,k=j(Ee),{data:A}=ee(w(Te)?`picker-agents-list`:null,ce),M;bb0:{let e;t[0]===y?e=t[1]:(e=y?.trim(),t[0]=y,t[1]=e);let n=e;if(n){M=n;break bb0}let r;t[2]===k?r=t[3]:(r=k.trim(),t[2]=k,t[3]=r);let i=r;if(i){M=i;break bb0}if(A?.defaultId){M=A.defaultId;break bb0}if(A?.agents?.[0]?.id){M=A.agents[0].id;break bb0}M=``}let N=M,[P,F]=(0,G.useState)(N),I,L;t[4]===N?(I=t[5],L=t[6]):(I=()=>{F(N)},L=[N],t[4]=N,t[5]=I,t[6]=L),(0,G.useEffect)(I,L);let{tree:te,loading:re,error:ie,loadRoot:R,loadChildren:ae,reset:z}=ne(P,_??null),B;t[7]===d?B=t[8]:(B=d?{path:d,isDirectory:!1}:null,t[7]=d,t[8]=B);let[V,H]=(0,G.useState)(B),ue;t[9]!==d||t[10]!==R||t[11]!==n||t[12]!==z||t[13]!==H?(ue=()=>{if(!n){z(),H(d?{path:d,isDirectory:!1}:null);return}R()},t[9]=d,t[10]=R,t[11]=n,t[12]=z,t[13]=H,t[14]=ue):ue=t[14];let de;t[15]!==d||t[16]!==R||t[17]!==n||t[18]!==P||t[19]!==z||t[20]!==_?(de=[n,P,_,R,z,d],t[15]=d,t[16]=R,t[17]=n,t[18]=P,t[19]=z,t[20]=_,t[21]=de):de=t[21],(0,G.useEffect)(ue,de);let U;t[22]===ae?U=t[23]:(U=e=>{ae(e)},t[22]=ae,t[23]=U);let fe=U,pe=V!==null&&(x===`any`||x===`file`&&!V.isDirectory||x===`directory`&&V.isDirectory),W;bb1:{if(!V){W=O.pickerHintNone;break bb1}if(x===`file`&&V.isDirectory){W=O.pickerHintNeedsFile;break bb1}if(x===`directory`&&!V.isDirectory){W=O.pickerHintNeedsDirectory;break bb1}W=`${V.isDirectory?`📁`:`📄`} ${V.path}`}let me=W,K=A?.agents??[],ge;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,Q.jsx)(a,{className:`fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),t[24]=ge):ge=t[24];let q;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(q=T(`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,Q.jsx)(h,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[26]=J):J=t[26];let Y=C.cron.refresh,_e=C.cron.refresh,X;t[27]===R?X=t[28]:(X=()=>void R(),t[27]=R,t[28]=X);let ve=re&&`animate-spin`,Z;t[29]===ve?Z=t[30]:(Z=T(`size-4`,ve),t[29]=ve,t[30]=Z);let ye;t[31]===Z?ye=t[32]:(ye=(0,Q.jsx)(se,{className:Z,"aria-hidden":!0}),t[31]=Z,t[32]=ye);let be;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(be=(0,Q.jsx)(v,{className:`size-4`}),t[33]=be):be=t[33];let xe;t[34]!==ie||t[35]!==D.loadError?(xe=ie?(0,Q.jsxs)(`p`,{className:`shrink-0 px-4 py-2 text-xs text-red-600 dark:text-red-400`,children:[D.loadError,`: `,ie]}):null,t[34]=ie,t[35]=D.loadError,t[36]=xe):xe=t[36];let Se;t[37]!==fe||t[38]!==re||t[39]!==V?.path||t[40]!==H||t[41]!==D.emptyDir||t[42]!==D.title||t[43]!==te?(Se=re&&te.length===0?(0,Q.jsxs)(`p`,{className:`flex shrink-0 items-center gap-2 px-4 py-3 text-sm text-fg-muted`,children:[(0,Q.jsx)(g,{className:`size-4 animate-spin`}),D.title,`…`]}):(0,Q.jsx)(le,{tree:te,selectedPath:V?.path??null,onSelectFile:e=>H({path:e,isDirectory:!1}),onSelectEntry:(e,t)=>H({path:e,isDirectory:t}),onExpandDir:fe,onAction:void 0,emptyHint:D.emptyDir}),t[37]=fe,t[38]=re,t[39]=V?.path,t[40]=H,t[41]=D.emptyDir,t[42]=D.title,t[43]=te,t[44]=Se):Se=t[44];let $;t[45]!==xe||t[46]!==Se?($=(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[xe,Se]}),t[45]=xe,t[46]=Se,t[47]=$):$=t[47];let Ce;t[48]===me?Ce=t[49]:(Ce=(0,Q.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,children:me}),t[48]=me,t[49]=Ce);let we;t[50]===r?we=t[51]:(we=()=>r(!1),t[50]=r,t[51]=we);let Oe;t[52]!==O.cancel||t[53]!==we?(Oe=(0,Q.jsx)(E,{type:`button`,variant:`ghost`,onClick:we,children:O.cancel}),t[52]=O.cancel,t[53]=we,t[54]=Oe):Oe=t[54];let ke=!pe,Ae;t[55]!==i||t[56]!==r||t[57]!==P||t[58]!==V?(Ae=()=>{V&&(i({...V,agentId:P}),r(!1))},t[55]=i,t[56]=r,t[57]=P,t[58]=V,t[59]=Ae):Ae=t[59];let je;t[60]!==O.pickerConfirm||t[61]!==ke||t[62]!==Ae?(je=(0,Q.jsx)(E,{type:`button`,disabled:ke,onClick:Ae,children:O.pickerConfirm}),t[60]=O.pickerConfirm,t[61]=ke,t[62]=Ae,t[63]=je):je=t[63];let Me;t[64]!==Oe||t[65]!==je?(Me=(0,Q.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,Q.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,Q.jsx)(u,{open:n,onOpenChange:r,children:(0,Q.jsxs)(s,{children:[ge,(0,Q.jsxs)(c,{className:q,children:[(0,Q.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-edge px-4`,children:[J,(0,Q.jsx)(l,{className:`min-w-0 flex-1 truncate text-base font-semibold text-fg`,children:O.pickerTitle}),(0,Q.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:re,onClick:X,children:ye}),(0,Q.jsx)(o,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":D.close,children:be})})]}),K.length>0?(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-edge px-4 py-2`,children:[(0,Q.jsx)(`label`,{className:`text-xs text-fg-muted`,htmlFor:`picker-agent-select`,children:O.pickerAgentLabel}),(0,Q.jsx)(f,{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:P,onChange:e=>{F(e.target.value),H(null)},children:K.map(e=>(0,Q.jsxs)(p,{value:e.id,children:[oe(e,C.agentsSettings),e.id===A?.defaultId?` ★`:``]},e.id))})]}):null,$,Ne]})]})})}function Te(e){return e.token}function Ee(e){return e.agentId}function De(e){return e.language}var Oe=[`shares`,`policy`];function ke(e){let t=(e??``).trim();return Oe.includes(t)?t:`shares`}function Ae(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 je(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 Me=[{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 Ne(){let e=(0,he.c)(24),t=S(Fe),n=b(t).sharesSettings,r=!!w(Pe),[a,o]=i(),s;e[0]===a?s=e[1]:(s=ke(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,Q.jsx)(U,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})});let d={shares:n.tabShares,policy:n.tabPolicy},f=Oe.map(e=>({id:e,label:d[e]})),p;e[4]!==n.subtitle||e[5]!==n.title?(p=(0,Q.jsx)(de,{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,Q.jsx)(me,{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,Q.jsx)(Ie,{t:n,language:t}):(0,Q.jsx)(xe,{hasToken:r}),e[12]=c,e[13]=r,e[14]=t,e[15]=n,e[16]=h):h=e[16];let g;e[17]!==c||e[18]!==h?(g=(0,Q.jsx)(fe,{id:c,activeTab:c,tabIdPrefix:`shares-tab`,panelIdPrefix:`shares-panel`,showHeading:!1,children:h}),e[17]=c,e[18]=h,e[19]=g):g=e[19];let _;return e[20]!==p||e[21]!==m||e[22]!==g?(_=(0,Q.jsxs)(U,{children:[p,m,g]}),e[20]=p,e[21]=m,e[22]=g,e[23]=_):_=e[23],_}function Pe(e){return e.token}function Fe(e){return e.language}function Ie(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}=ee(`shares-list`,te,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,f]=(0,G.useState)(!1),p;bb0:{if(d){p=u;break bb0}let e;t[3]===u?e=t[4]:(e=u.filter(Ve),t[3]=u,t[4]=e),p=e}let m=p,h;t[5]===u?h=t[6]:(h=u.filter(Be),t[5]=u,t[6]=h);let g=h.length,_;t[7]===u?_=t[8]:(_=u.filter(ze),t[7]=u,t[8]=_);let v=_.length,y;t[9]===c?y=t[10]:(y=()=>void c(),t[9]=c,t[10]=y);let b;t[11]!==n||t[12]!==y?(b=(0,Q.jsx)(Ue,{t:n,onCreated:y}),t[11]=n,t[12]=y,t[13]=b):b=t[13];let x=d?n.allSharesTitle:n.listTitle,S;t[14]===g?S=t[15]:(S=g>0&&(0,Q.jsxs)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:[`(`,g,`)`]}),t[14]=g,t[15]=S);let C;t[16]!==x||t[17]!==S?(C=(0,Q.jsxs)(`h2`,{className:`text-sm font-semibold text-fg`,children:[x,S]}),t[16]=x,t[17]=S,t[18]=C):C=t[18];let w;t[19]===c?w=t[20]:(w=()=>void c(),t[19]=c,t[20]=w);let D=s&&`animate-spin`,O;t[21]===D?O=t[22]:(O=T(`size-3.5`,D),t[21]=D,t[22]=O);let k;t[23]===O?k=t[24]:(k=(0,Q.jsx)(se,{className:O}),t[23]=O,t[24]=k);let A;t[25]!==s||t[26]!==w||t[27]!==k?(A=(0,Q.jsx)(E,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:w,disabled:s,children:k}),t[25]=s,t[26]=w,t[27]=k,t[28]=A):A=t[28];let j;t[29]!==v||t[30]!==d||t[31]!==n.hideExpired||t[32]!==n.showExpired?(j=v>0&&(0,Q.jsx)(`button`,{type:`button`,className:`text-xs text-accent hover:underline`,onClick:()=>f(Re),children:d?n.hideExpired:n.showExpired}),t[29]=v,t[30]=d,t[31]=n.hideExpired,t[32]=n.showExpired,t[33]=j):j=t[33];let M;t[34]!==A||t[35]!==j?(M=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[A,j]}),t[34]=A,t[35]=j,t[36]=M):M=t[36];let N;t[37]!==C||t[38]!==M?(N=(0,Q.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[C,M]}),t[37]=C,t[38]=M,t[39]=N):N=t[39];let P;t[40]!==a||t[41]!==o||t[42]!==m||t[43]!==s||t[44]!==r||t[45]!==c||t[46]!==n?(P=s&&!a?(0,Q.jsx)(`div`,{className:`grid gap-2`,"aria-busy":`true`,children:Array.from({length:4}).map(Le)}):o?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-red-600 dark:text-red-400`,children:[(0,Q.jsx)(`span`,{children:n.error}),(0,Q.jsx)(E,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-xs`,onClick:()=>void c(),children:n.retry})]}):m.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.emptyState}):(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:m.map(e=>(0,Q.jsx)(Ge,{share:e,t:n,language:r,onRevoked:()=>void c(),onExtended:()=>void c()},e.id))}),t[40]=a,t[41]=o,t[42]=m,t[43]=s,t[44]=r,t[45]=c,t[46]=n,t[47]=P):P=t[47];let F;t[48]!==v||t[49]!==c||t[50]!==d||t[51]!==n?(F=v>0&&d&&(0,Q.jsx)(Ke,{t:n,onCleaned:()=>void c()}),t[48]=v,t[49]=c,t[50]=d,t[51]=n,t[52]=F):F=t[52];let I;t[53]!==N||t[54]!==P||t[55]!==F?(I=(0,Q.jsxs)(W,{children:[N,P,F]}),t[53]=N,t[54]=P,t[55]=F,t[56]=I):I=t[56];let L;return t[57]!==I||t[58]!==b?(L=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[b,I]}),t[57]=I,t[58]=b,t[59]=L):L=t[59],L}function Le(e,t){return(0,Q.jsx)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(A,{className:`h-4 w-2/3`}),(0,Q.jsx)(A,{className:`mt-2 h-3 w-1/2`})]}),(0,Q.jsx)(A,{className:`h-7 w-20 rounded-md`})]})},t)}function Re(e){return!e}function ze(e){return e.expired||e.revoked}function Be(e){return!e.expired&&!e.revoked}function Ve(e){return!e.expired&&!e.revoked}var He={expanded:!0,path:``,isDirectory:!1,agentId:``,ttlMs:864e5,maxViews:null,description:``,directoryMode:`browse`,creating:!1,result:null,errorMsg:null,resultDialogOpen:!1,pickerOpen:!1};function Ue({t:e,onCreated:t}){let[n,r]=(0,G.useReducer)(I,He),{expanded:i,path:a,isDirectory:o,agentId:s,ttlMs:c,maxViews:l,description:u,directoryMode:d,creating:m,result:h,errorMsg:v,resultDialogOpen:y,pickerOpen:b}=n,x=(0,G.useCallback)(async()=>{if(a.trim()){r({type:`patch`,patch:{creating:!0,errorMsg:null,result:null}});try{r({type:`patch`,patch:{result:(await P({path:a.trim(),ttlMs:c,maxViews:l,description:u.trim()||void 0,...s?{agentId:s}:{},...o?{kind:`directory`,directoryMode:d}:{}})).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,o,s,c,l,u,d,t]),S=(0,G.useCallback)(()=>{r({type:`patch`,patch:{path:``,isDirectory:!1,agentId:``,description:``,maxViews:null,ttlMs:864e5,directoryMode:`browse`,result:null,errorMsg:null}})},[]);return i?(0,Q.jsxs)(W,{children:[(0,Q.jsx)(`h2`,{className:`mb-1 text-sm font-semibold text-fg`,children:e.createTitle}),(0,Q.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:e.createHint}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.pathLabel}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`div`,{className:T(`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,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,children:o?`📁`:`📄`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:a,children:a})]}):(0,Q.jsx)(`span`,{className:`truncate`,children:e.pathPlaceholder})}),(0,Q.jsxs)(E,{type:`button`,variant:`ghost`,onClick:()=>r({type:`patch`,patch:{pickerOpen:!0}}),children:[(0,Q.jsx)(V,{className:`size-4`}),a?e.pathBrowseChange:e.pathBrowse]})]})]}),o?(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.directoryModeLabel}),(0,Q.jsxs)(f,{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:d,onChange:e=>r({type:`patch`,patch:{directoryMode:e.target.value===`zip-only`?`zip-only`:`browse`}}),children:[(0,Q.jsx)(p,{value:`browse`,children:e.directoryModeBrowse}),(0,Q.jsx)(p,{value:`zip-only`,children:e.directoryModeZipOnly})]})]}):null,(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.ttlLabel}),(0,Q.jsx)(f,{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:c,onChange:e=>r({type:`patch`,patch:{ttlMs:Number(e.target.value)}}),children:Me.map(t=>(0,Q.jsx)(p,{value:t.value,children:e.ttlOptions[t.key]},t.key))})]}),(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.maxViewsLabel}),(0,Q.jsxs)(f,{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:l??`unlimited`,onChange:e=>r({type:`patch`,patch:{maxViews:e.target.value===`unlimited`?null:Number(e.target.value)}}),children:[(0,Q.jsx)(p,{value:`unlimited`,children:e.maxViewsUnlimited}),(0,Q.jsx)(p,{value:`1`,children:`1`}),(0,Q.jsx)(p,{value:`5`,children:`5`}),(0,Q.jsx)(p,{value:`10`,children:`10`}),(0,Q.jsx)(p,{value:`50`,children:`50`}),(0,Q.jsx)(p,{value:`100`,children:`100`})]})]})]}),(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.descriptionLabel}),(0,Q.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:u,onChange:e=>r({type:`patch`,patch:{description:e.target.value}})})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,Q.jsxs)(E,{type:`button`,disabled:m||!a.trim(),onClick:()=>void x(),children:[m?(0,Q.jsx)(g,{className:`size-4 animate-spin`}):(0,Q.jsx)(_,{className:`size-4`}),m?e.creating:e.createButton]}),(0,Q.jsx)(E,{type:`button`,variant:`ghost`,onClick:()=>{S(),r({type:`patch`,patch:{expanded:!1}})},children:e.cancel})]}),v&&(0,Q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:v})]}),(0,Q.jsx)(M,{open:y,onOpenChange:e=>{r({type:`patch`,patch:{resultDialogOpen:e,...e?{}:{result:null}}})},result:h}),(0,Q.jsx)(we,{open:b,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,Q.jsxs)(E,{type:`button`,onClick:()=>r({type:`patch`,patch:{expanded:!0}}),className:`self-start`,children:[(0,Q.jsx)(_,{className:`size-4`}),e.createTitle]})}var We={revokeOpen:!1,revoking:!1,linksOpen:!1,urlCopied:!1,copyFailed:!1,extending:!1};function Ge({share:e,t,language:n,onRevoked:r,onExtended:i}){let[a,o]=(0,G.useReducer)(I,We),{revokeOpen:s,revoking:c,linksOpen:l,urlCopied:u,copyFailed:f,extending:p}=a,h=!e.expired&&!e.revoked,_=e.revoked?t.statusRevoked:e.expired?t.statusExpired:t.statusActive,v=e.revoked?`text-red-600 dark:text-red-400`:e.expired?`text-fg-subtle`:`text-emerald-600 dark:text-emerald-400`,b=(0,G.useCallback)(async()=>{o({type:`patch`,patch:{revokeOpen:!1,revoking:!0}});try{await R(e.id),r()}catch{}finally{o({type:`patch`,patch:{revoking:!1}})}},[e.id,r]),x=(0,G.useCallback)(async()=>{if(o({type:`patch`,patch:{linksOpen:!0,copyFailed:!1}}),!await y(e.shareUrl)){o({type:`patch`,patch:{copyFailed:!0}}),window.setTimeout(()=>o({type:`patch`,patch:{copyFailed:!1}}),2500);return}o({type:`patch`,patch:{urlCopied:!0}}),window.setTimeout(()=>o({type:`patch`,patch:{urlCopied:!1}}),2e3)},[e.shareUrl]),S=(0,G.useCallback)(async()=>{o({type:`patch`,patch:{extending:!0}});try{await F(e.id,864e5),i()}catch{}finally{o({type:`patch`,patch:{extending:!1}})}},[e.id,i]),C=`share-links-${e.id}`;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:T(`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":l,"aria-controls":C,onClick:()=>o({type:`patch`,patch:{linksOpen:!l}}),children:[(0,Q.jsx)(L,{className:T(`mt-0.5 size-4 shrink-0 text-fg-muted transition-transform`,l?`rotate-0`:`-rotate-90`),"aria-hidden":!0}),e.kind===`note`?(0,Q.jsx)(re,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}):e.kind===`session`?(0,Q.jsx)(ae,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}):(0,Q.jsx)(V,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.fileName}),(0,Q.jsx)(`span`,{className:T(`text-xs font-medium`,v),children:_})]}),(0,Q.jsx)(`p`,{className:`truncate text-xs text-fg-subtle`,children:e.kind===`note`?n===`zh`?`笔记快照 · 版本 ${e.snapshotRevision??1}`:`Note snapshot · revision ${e.snapshotRevision??1}`:e.kind===`session`?n===`zh`?`会话快照 · ${e.messageCount??0} 条消息 · 版本 ${e.snapshotRevision??1}`:`Conversation snapshot · ${e.messageCount??0} messages · revision ${e.snapshotRevision??1}`:e.workspaceRelativePath}),(0,Q.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,Q.jsx)(`span`,{children:Ae(e.fileSize)}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(B,{className:`size-3`}),e.expired?n===`zh`?`已过期`:`expired`:je(e.expiresAt,n)]}),(0,Q.jsxs)(`span`,{children:[t.views,`: `,e.downloadCount,e.maxViews!==null&&` ${t.viewsOf} ${e.maxViews}`]}),e.description&&(0,Q.jsx)(`span`,{className:`italic text-fg-subtle`,children:e.description})]})]})]}),(0,Q.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:h&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(E,{type:`button`,variant:`ghost`,className:`px-2 py-1`,title:t.copyUrl,onClick:()=>void x(),children:u?(0,Q.jsx)(d,{className:`size-3.5 text-emerald-500`}):(0,Q.jsx)(m,{className:`size-3.5`})}),(0,Q.jsx)(E,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:()=>void S(),disabled:p,title:t.extend,children:p?(0,Q.jsx)(g,{className:`size-3.5 animate-spin`}):(0,Q.jsx)(B,{className:`size-3.5`})}),(0,Q.jsx)(E,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-red-600 hover:text-red-700 dark:text-red-400`,onClick:()=>o({type:`patch`,patch:{revokeOpen:!0}}),disabled:c,children:c?(0,Q.jsx)(g,{className:`size-3.5 animate-spin`}):(0,Q.jsx)(N,{className:`size-3.5`})})]})})]}),h&&l?(0,Q.jsxs)(`div`,{id:C,className:`mt-3 bg-surface-base/45 py-3 pl-7 pr-3`,children:[(0,Q.jsx)(z,{shareUrl:e.shareUrl,lanUrl:e.lanUrl,reachability:e.reachability,compact:!0}),f?(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-red-600 dark:text-red-400`,children:t.copyFailed}):null,(0,Q.jsx)(`div`,{className:`mt-2`,children:(0,Q.jsx)(ue,{reachability:e.reachability})})]}):null]}),(0,Q.jsx)(H,{open:s,title:t.revokeConfirmTitle,description:t.revokeConfirmBody,confirmLabel:t.revokeConfirmLabel,cancelLabel:t.cancel,destructive:!0,onConfirm:()=>void b(),onCancel:()=>o({type:`patch`,patch:{revokeOpen:!1}})})]})}function Ke({t:e,onCleaned:t}){let[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)(!1),o=(0,G.useCallback)(async()=>{r(!1),a(!0);try{await ie(),t()}catch{}finally{a(!1)}},[t]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Q.jsxs)(E,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>r(!0),className:`border-danger/40 px-2 py-1 text-xs text-danger hover:bg-danger/10`,children:[i?(0,Q.jsx)(g,{className:`size-3.5 animate-spin`}):(0,Q.jsx)(N,{className:`size-3.5`}),e.cleanExpired]})}),(0,Q.jsx)(H,{open:n,title:e.cleanExpiredConfirmTitle,description:e.cleanExpiredConfirmBody,confirmLabel:e.cleanExpiredConfirmLabel,cancelLabel:e.cancel,destructive:!0,onConfirm:()=>void o(),onCancel:()=>r(!1)})]})}export{Ne as SharesSettingsPanel};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{i as t,r as n}from"./locale-store-CBoCuIMx.js";import{Zt as r}from"./index-eZjksPvq.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,i as n,n as r,t as i}from"./vendor-react-BOUWij0V.js";import{d as a,l as o,p as s,t as c}from"./chunk-KS7C4IRE-BaASWQor.js";import{i as l,n as u,o as d,r as f,s as p,t as m}from"./dist-CpzYSoz7.js";import{n as h,r as g}from"./popover-select-C-Hj-nXR.js";import{t as _}from"./circle-check-C23XjkUj.js";import{t as v}from"./ellipsis-0k4rZLoy.js";import{t as ee}from"./external-link-DjqjBmc3.js";import{d as te,p as ne,t as y}from"./markdown-view-BXsHghJd.js";import{t as re}from"./folder-open-CyzJ19I9.js";import{t as ie}from"./x-B_N4OPjy.js";import{n as ae,s as oe}from"./locale-store-CBoCuIMx.js";import{t as b}from"./cn-JdwAhgNB.js";import{t as x}from"./button-CtTvuElV.js";import{t as S}from"./skeleton-BwbyijEw.js";import{Ct as se,Gi as C,Go as ce,Ho as le,Jo as ue,Or as w,P as de,Pn as fe,Qo as pe,Sc as T,Si as me,Tl as E,Wo as D,al as he,an as O,cc as k,cn as ge,cs as _e,eu as A,gr as j,in as M,is as N,kr as P,ln as F,ls as I,n as ve,ns as L,oa as ye,on as be,os as xe,pc as Se,ri as Ce,sn as we,ss as Te,wl as Ee}from"./index-eZjksPvq.js";import{t as De}from"./date-picker-BZuHw-SY.js";import{t as Oe}from"./dependency-picker-BsBD2JFY.js";var R=e(t(),1),ke=e(n(),1),z=r();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 B=i();function Me(e,t){return(t===`zh`?{backlog:`待规划`,ready:`就绪`,active:`进行中`,review:`待验收`,closed:`已完成`}:{backlog:`Backlog`,ready:`Ready`,active:`Active`,review:`Review`,closed:`Completed`})[e]}function Ne(){let e=(0,z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,B.jsxs)(`div`,{className:`space-y-4`,"aria-busy":!0,children:[(0,B.jsx)(S,{className:`h-32 rounded-2xl`}),(0,B.jsx)(S,{className:`h-52 rounded-2xl`}),(0,B.jsx)(S,{className:`h-40 rounded-2xl`})]}),e[0]=t):t=e[0],t}function Pe(e){if(e===void 0)return``;let t=new Date(e);return new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString().slice(0,10)}function Fe(e){return e?new Date(`${e}T23:59:59.999`).getTime():null}var V=[`backlog`,`ready`,`active`,`review`,`closed`],H=[`low`,`normal`,`high`,`critical`],Ie=(0,R.memo)(function(e){let t=(0,z.c)(20),{value:n,disabled:r,canMove:i,canApprove:a,canReopen:o,language:s,label:c,onChange:l}=e,u;t[0]!==a||t[1]!==i||t[2]!==o||t[3]!==n?(u=e=>e!==n&&(e===`closed`?!a:n===`closed`?!o:!i),t[0]=a,t[1]=i,t[2]=o,t[3]=n,t[4]=u):u=t[4];let d=u,f;t[5]===c?f=t[6]:(f=(0,B.jsx)(`span`,{children:c}),t[5]=c,t[6]=f);let p;t[7]===l?p=t[8]:(p=e=>l(e.target.value),t[7]=l,t[8]=p);let m;t[9]!==s||t[10]!==d?(m=V.map(e=>(0,B.jsx)(g,{value:e,disabled:d(e),children:Me(e,s)},e)),t[9]=s,t[10]=d,t[11]=m):m=t[11];let _;t[12]!==r||t[13]!==p||t[14]!==m||t[15]!==n?(_=(0,B.jsx)(h,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:p,children:m}),t[12]=r,t[13]=p,t[14]=m,t[15]=n,t[16]=_):_=t[16];let v;return t[17]!==f||t[18]!==_?(v=(0,B.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[f,_]}),t[17]=f,t[18]=_,t[19]=v):v=t[19],v}),Le=(0,R.memo)(function(e){let t=(0,z.c)(14),{value:n,disabled:r,label:i,labels:a,onChange:o}=e,s;t[0]===i?s=t[1]:(s=(0,B.jsx)(`span`,{children:i}),t[0]=i,t[1]=s);let c;t[2]===o?c=t[3]:(c=e=>o(e.target.value),t[2]=o,t[3]=c);let l;t[4]===a?l=t[5]:(l=H.map(e=>(0,B.jsx)(g,{value:e,children:a[e]},e)),t[4]=a,t[5]=l);let u;t[6]!==r||t[7]!==c||t[8]!==l||t[9]!==n?(u=(0,B.jsx)(h,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:c,children:l}),t[6]=r,t[7]=c,t[8]=l,t[9]=n,t[10]=u):u=t[10];let d;return t[11]!==s||t[12]!==u?(d=(0,B.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[s,u]}),t[11]=s,t[12]=u,t[13]=d):d=t[13],d}),Re=(0,R.memo)(function(e){let t=(0,z.c)(10),{value:n,disabled:r,label:i,onChange:a}=e,o;t[0]===i?o=t[1]:(o=(0,B.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,B.jsx)(De,{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,B.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,R.memo)(function(e){let t=(0,z.c)(17),{value:n,disabled:r,label:i,unassignedLabel:a,agents:o,onChange:s}=e,c;t[0]===i?c=t[1]:(c=(0,B.jsx)(`span`,{children:i}),t[0]=i,t[1]=c);let l;t[2]===s?l=t[3]:(l=e=>s(e.target.value),t[2]=s,t[3]=l);let u;t[4]===a?u=t[5]:(u=(0,B.jsx)(g,{value:``,disabled:!0,children:a}),t[4]=a,t[5]=u);let d;t[6]===o?d=t[7]:(d=o.map(nt),t[6]=o,t[7]=d);let f;t[8]!==r||t[9]!==l||t[10]!==u||t[11]!==d||t[12]!==n?(f=(0,B.jsxs)(h,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:l,children:[u,d]}),t[8]=r,t[9]=l,t[10]=u,t[11]=d,t[12]=n,t[13]=f):f=t[13];let p;return t[14]!==c||t[15]!==f?(p=(0,B.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[c,f]}),t[14]=c,t[15]=f,t[16]=p):p=t[16],p}),Be=(0,R.memo)(function(e){let t=(0,z.c)(8),{candidates:n,selected:r,disabled:i,labels:a,onChange:o}=e,s;t[0]===r?s=t[1]:(s=r.map(rt),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,B.jsx)(Oe,{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 U(e){let t=(0,z.c)(9),{items:n,empty:r,verificationByCriterion:i}=e;if(n.length===0){let e;return t[0]===r?e=t[1]:(e=(0,B.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,B.jsxs)(`li`,{className:`flex gap-2 text-sm leading-6 text-fg`,children:[(0,B.jsx)(t===`passed`?_:t===`failed`?E: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,B.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,B.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]=s(),a=o(),l=ae(e=>e.language),u=oe(e=>e.token),d=(0,R.useMemo)(()=>I(l),[l]),f=ye(e=>e.setPageHeader),p=ye(e=>e.clearPageHeader),m=P(e=>e.open),h=P(e=>e.sessionKeyOverride),g=P(e=>e.openForSession),ie=fe(e=>e.setOpen),{data:S,error:se,mutate:w,lastChange:E,conversationLoading:Ee,conversationError:De}=le(e),[Oe,z]=(0,R.useState)(null),[Me,V]=(0,R.useState)(null),[H,Ke]=(0,R.useState)(()=>new Set),[qe,Je]=(0,R.useState)([]),[W,Ye]=(0,R.useState)(null),[Xe,Ze]=(0,R.useState)([]),[Qe,G]=(0,R.useState)(!1),[$e,et]=(0,R.useState)(``),[tt,K]=(0,R.useState)(!1),[nt,rt]=(0,R.useState)(``),[it,at]=(0,R.useState)(We),[ot,st]=(0,R.useState)(!1),ct=(0,R.useRef)(null),lt=(0,R.useRef)(!1),ut=(0,R.useRef)(!1),dt=(0,R.useRef)(``),ft=(0,R.useRef)(null),pt=(0,R.useRef)(null),mt=(0,R.useRef)(null),ht=(0,R.useRef)(S),[gt,q]=(0,R.useState)(null),[_t,vt]=(0,R.useState)(null),[yt,bt]=(0,R.useState)(!1),xt=(0,R.useMemo)(()=>({link:d.linkDependencies,linked:d.linkedDependencies,searchPlaceholder:d.dependencySearchPlaceholder,noMatches:d.noDependencyMatches,noCandidates:d.noDependencyCandidates,remove:d.removeDependency}),[d.dependencySearchPlaceholder,d.linkDependencies,d.linkedDependencies,d.noDependencyCandidates,d.noDependencyMatches,d.removeDependency]),St=S?.dependencies.map(e=>`${e.id}:${e.title}`).join(`\0`)??``,Ct=(0,R.useMemo)(()=>te(i.get(`returnTo`),`/`,[`/projects`,`/chat`,`/notes`,`/tasks`]),[i]);ht.current=S;let J=(0,R.useCallback)((e,t)=>{Ke(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]);(0,R.useEffect)(()=>{V(null),q(null),G(!1),K(!1),vt(null),bt(!1)},[e]),(0,R.useEffect)(()=>{let e=!0;return C().then(t=>{e&&Ze(t.items)}).catch(()=>void 0),()=>{e=!1}},[u]),(0,R.useEffect)(()=>{if(!E||E.source===`user`)return;vt(E);let e=window.setTimeout(()=>vt(null),3500);return()=>window.clearTimeout(e)},[E]),(0,R.useEffect)(()=>{let t=S?.task.projectId,n=S?.dependencies??[];if(!t){mt.current=null,Ye(null),Je(n);return}mt.current!==t&&(mt.current=t,Ye(null));let r=!0;return me(t).then(t=>{if(!r)return;Ye(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});Je([...i.values()])}).catch(()=>{r&&Je(n)}),()=>{r=!1}},[St,S?.task.projectId,e]);let Y=(0,R.useCallback)(async(t,n=`command`)=>{let r=ht.current;if(r){J(n,!0),V(null);try{await w(await ce(e,t,r.task.version),{revalidate:!1})}catch{V(d.actionFailed)}finally{J(n,!1)}}},[d.actionFailed,w,J,e]),X=(0,R.useCallback)(async(t,n)=>{let r=ht.current;if(!r)return!1;n&&J(n,!0),V(null);try{return await w(N(e,t,r.task.version),{optimisticData:je(r,t),populateCache:!0,revalidate:!1,rollbackOnError:!0}),!0}catch{return V(d.actionFailed),!1}finally{n&&J(n,!1)}},[d.actionFailed,w,J,e]),wt=async()=>{if(!S)return;if(lt.current){lt.current=!1;return}let e=$e.trim(),t=ft.current;if(Ae(t,S.task.version,S.task.title,e)){q(`title`);return}if(!e||e===S.task.title){et(S.task.title),G(!1);return}await X({title:e})&&(q(null),G(!1))},Tt=async()=>{if(!S)return;if(ut.current){ut.current=!1;return}let e=nt.trim(),t=pt.current;if(Ae(t,S.task.version,S.task.body??``,e)){q(`description`);return}if(nt===dt.current||e===(S.task.body??``).trim()){K(!1);return}await X({body:e||null})&&(q(null),K(!1))},Et=(0,R.useCallback)(async e=>{let t=ht.current;if(!(!t||e===t.task.phase)){if(t.task.phase===`closed`){await Y({type:`reopen`,phase:e===`closed`?`ready`:e},`phase`);return}if(e===`closed`){await Y({type:`close`,resolution:`done`},`phase`);return}await Y({type:`move`,phase:e},`phase`)}},[Y]),Dt=(0,R.useCallback)(e=>{X({priority:e},`priority`)},[X]),Ot=(0,R.useCallback)(e=>{X({dueAt:Fe(e)},`dueAt`)},[X]),kt=(0,R.useCallback)(e=>{at(e);try{window.localStorage.setItem(Ve,String(e))}catch{}},[]),At=(0,R.useCallback)(e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`&&e.key!==`Home`)return;e.preventDefault();let t=ct.current?.clientWidth??0;kt(Ue(e.key===`Home`?He:it+(e.key===`ArrowLeft`?2:-2),t))},[it,kt]),jt=(0,R.useCallback)(e=>{if(!window.matchMedia(`(min-width: 1024px)`).matches)return;let t=ct.current;if(!t)return;e.preventDefault();let n=e.currentTarget,r=e.pointerId;n.setPointerCapture(r),st(!0);let i=it,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{}st(!1),kt(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)},[it,kt]),Mt=(0,R.useCallback)(async t=>{let n=ht.current;if(n){J(`dependencies`,!0),V(null);try{await w(await xe(e,t,n.task.version),{revalidate:!1})}catch{V(d.dependencyUpdateFailed)}finally{J(`dependencies`,!1)}}},[d.dependencyUpdateFailed,w,J,e]),Nt=(0,R.useCallback)(async t=>{let n=ht.current;if(!(!n||!t||t===n.conversation.currentExecutorAgentId)){J(`delegateAgentId`,!0),V(null);try{await w(await pe(e,t,n.task.version),{revalidate:!1})}catch{V(d.actionFailed)}finally{J(`delegateAgentId`,!1)}}},[d.actionFailed,w,J,e]),Pt=(0,R.useCallback)(async()=>{J(`delete`,!0),V(null);try{await ue(e),r?r():a(Ct,{replace:!0})}catch(e){V(e instanceof Error?e.message:d.actionFailed)}finally{J(`delete`,!1)}},[d.actionFailed,a,r,Ct,J,e]);if((0,R.useLayoutEffect)(()=>{if(t!==`modal`)return f({startExtra:(0,B.jsx)(c,{to:Ct,className:`flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":d.backToWork,children:(0,B.jsx)(A,{className:`size-4`})}),main:S?(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`p`,{className:`truncate text-sm font-semibold text-fg`,children:W?`${W} / ${d.taskLabel}`:d.taskLabel}),(0,B.jsx)(`p`,{className:`text-xs text-fg-muted`,children:d.detailStatuses[Ge(S)]})]}):null,end:(0,B.jsx)(`div`,{ref:z,className:`flex min-w-0 items-center justify-end`})}),p},[p,d.backToWork,d.detailStatuses,d.taskLabel,S,t,W,Ct,f]),se&&!S)return(0,B.jsx)(`div`,{className:t===`modal`?`p-5 text-sm text-danger`:`mx-auto max-w-3xl p-6 text-sm text-danger`,children:d.taskNotFound});if(!S)return(0,B.jsx)(`div`,{className:t===`modal`?`p-5`:`mx-auto max-w-4xl p-4 sm:p-6`,children:(0,B.jsx)(Ne,{})});let Ft=S.waits[0],It=Ft?.kind===`paused`?Ft:void 0,Z=S.receipts[0],Lt=d.detailStatuses[Ge(S)],Rt=d.detailStatusDescriptions[Ge(S)],zt=S.task.body?.trim()||S.task.contract?.objective.trim(),Bt=new Map(Z?.verification.checks.map(e=>[e.criterion,e.status])),Vt=S.allowedCommands.includes(`mark_ready`),Ht=S.allowedCommands.includes(`start`),Ut=S.allowedCommands.includes(`add_wait`),Wt=S.task.phase===`review`&&S.allowedCommands.includes(`close`),Gt=S.allowedCommands.includes(`reopen`),Kt=S.conversation.activeSessionKey,qt=S.conversation.currentExecutorAgentId??S.task.delegateAgentId??S.task.ownerId,Jt=Xe.find(e=>e.id===qt),Yt=!!(Kt&&m&&h===Kt),Xt=S.attention.some(e=>e.kind===`input_required`||e.kind===`approval_required`),Zt=S.task.contract?.acceptanceCriteria??[],Qt=Zt.filter(e=>Bt.get(e)===`passed`).length,$t=S.task.contract?.expectedOutputs??[],en=S.task.contract?.constraints??[],tn=S.task.contract?.approvalRequired??[],nn=S.task.contract?.assumptions??[],rn=S.task.contract?.risks??[],Q=(...e)=>!!_t?.changedFields.some(t=>e.includes(t)),an=e=>t===`modal`&&n?_e(n,e):ne(`/tasks/${e}`,Ct),on=S.allowedCommands.includes(`move`),$=H.has(`command`),sn=H.has(`delete`),cn=S.runs.find(e=>[`queued`,`running`,`waiting`,`verifying`].includes(e.status)),ln=cn!==void 0,un=(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[Vt?(0,B.jsxs)(x,{variant:`primary`,disabled:$,onClick:()=>void Y({type:`mark_ready`}),children:[(0,B.jsx)(k,{className:`size-4`}),d.scheduleTask]}):null,It?(0,B.jsxs)(x,{variant:`primary`,disabled:$,onClick:()=>void Y({type:`resolve_wait`,waitId:It.id}),children:[(0,B.jsx)(k,{className:`size-4`}),d.resumeTask]}):null,!Ft&&Ht&&qt?(0,B.jsxs)(x,{variant:`primary`,disabled:$,onClick:()=>void Y({type:`start`,executor:{kind:`agent`,agentId:qt}}),children:[(0,B.jsx)(k,{className:`size-4`}),d.runTask]}):null,Wt?(0,B.jsxs)(x,{variant:`primary`,disabled:$,onClick:()=>void Y({type:`close`,resolution:`done`}),children:[(0,B.jsx)(_,{className:`size-4`}),d.approveTask]}):null,Gt?(0,B.jsxs)(x,{variant:`primary`,disabled:$,onClick:()=>void Y({type:`reopen`,phase:`ready`}),children:[(0,B.jsx)(k,{className:`size-4`}),d.reopenTask]}):null,!Ft&&Ut?(0,B.jsxs)(x,{variant:`secondary`,className:`border-0 bg-surface-hover shadow-none`,disabled:$,onClick:()=>void Y({type:`add_wait`,wait:{kind:`paused`,reason:`Paused by user`,condition:{}}}),children:[(0,B.jsx)(Se,{className:`size-4`}),d.pauseTask]}):null,(0,B.jsxs)(we,{children:[(0,B.jsx)(F,{asChild:!0,children:(0,B.jsx)(x,{type:`button`,variant:`ghost`,className:`size-9 p-0`,disabled:$||sn,"aria-label":d.moreActions,children:(0,B.jsx)(v,{className:`size-4`,"aria-hidden":!0})})}),(0,B.jsx)(be,{children:(0,B.jsxs)(M,{align:`end`,sideOffset:6,className:`z-[100] min-w-44 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:[cn?(0,B.jsx)(O,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>{J(`command`,!0),V(null),w(D(e,cn.id,cn.version),{revalidate:!1}).catch(()=>V(d.actionFailed)).finally(()=>J(`command`,!1))},children:d.cancelActiveRun}):null,cn?(0,B.jsx)(ge,{className:`my-1 h-px bg-edge`}):null,S.task.phase===`closed`?null:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(O,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>void Y({type:`close`,resolution:`cancelled`}),children:d.cancelTask}),(0,B.jsx)(ge,{className:`my-1 h-px bg-edge`})]}),(0,B.jsx)(O,{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(ln){V(d.deleteActiveTaskBlocked);return}bt(!0)},children:d.deleteTask})]})})]})]}),Kt&&t!==`modal`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(x,{type:`button`,variant:`ghost`,className:b(`h-8 shrink-0 px-2 text-xs`,Yt&&`bg-surface-hover text-fg`),"aria-label":l===`zh`?`项目文件`:`Project files`,"aria-pressed":Yt,onClick:()=>{ie(Kt,!1),g(Kt)},children:[(0,B.jsx)(re,{className:`size-3.5`,"aria-hidden":!0}),l===`zh`?`文件`:`Files`]}),(0,B.jsx)(x,{asChild:!0,variant:`ghost`,className:`h-8 shrink-0 px-2 text-xs`,children:(0,B.jsxs)(c,{to:Te(e),children:[(0,B.jsx)(ee,{className:`size-3.5`}),l===`zh`?`全屏`:`Full screen`]})})]}):null]});return(0,B.jsxs)(`div`,{ref:ct,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`} ${ot?`lg:cursor-col-resize lg:select-none`:``}`,style:{"--task-chat-panel-width":`${it}%`},children:[t===`page`&&Oe?(0,ke.createPortal)(un,Oe):null,(0,B.jsxs)(`section`,{className:`task-detail-scroll min-w-0 flex-1 overflow-y-auto overscroll-contain p-5 sm:p-6`,children:[(0,B.jsxs)(`header`,{className:b(`px-4 pb-5`,Q(`title`)&&`task-detail-live-update`),children:[(0,B.jsx)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[W?(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,B.jsx)(he,{className:`size-3.5`,"aria-hidden":!0}),W]}):null,(0,B.jsx)(`span`,{children:`/`}),(0,B.jsx)(`span`,{children:d.taskLabel}),_t?(0,B.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,role:`status`,children:_t.source===`agent`?l===`zh`?`Agent 刚刚更新`:`Updated by Agent`:l===`zh`?`执行结果已同步`:`Execution result synced`}):null]}),Qe?(0,B.jsx)(`input`,{autoFocus:!0,"data-task-inline-editor":!0,value:$e,onChange:e=>et(e.target.value),onBlur:()=>void wt(),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),lt.current=!0,et(S.task.title),G(!1),queueMicrotask(()=>{lt.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,B.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:()=>{ft.current={value:S.task.title,version:S.task.version},q(null),et(S.task.title),G(!0)},children:(0,B.jsx)(`h1`,{className:`text-2xl font-semibold leading-8 text-fg`,children:S.task.title})}),gt===`title`?(0,B.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,B.jsx)(`span`,{children:l===`zh`?`Agent 在你编辑期间更新了标题。`:`The Agent updated the title while you were editing.`}),(0,B.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:()=>{et(S.task.title),q(null),G(!1)},children:l===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,B.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,onClick:()=>void X({title:$e.trim()}).then(e=>{e&&(q(null),G(!1))}),children:l===`zh`?`保留我的修改`:`Keep my changes`})]}):null]})}),Me?(0,B.jsx)(`p`,{className:`mt-3 text-sm text-danger`,children:Me}):null]}),(0,B.jsxs)(`div`,{className:`mt-5 flex flex-col gap-5`,children:[(0,B.jsxs)(`main`,{className:`order-2 min-w-0 space-y-5`,children:[(0,B.jsxs)(`section`,{className:b(`rounded-xl bg-surface-panel p-4`,Q(`body`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:d.taskDescription}),tt?(0,B.jsx)(`textarea`,{autoFocus:!0,"data-task-inline-editor":!0,rows:6,value:nt,onChange:e=>rt(e.target.value),onBlur:()=>void Tt(),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),ut.current=!0,rt(S.task.body??S.task.contract?.objective??``),K(!1),queueMicrotask(()=>{ut.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,B.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=S.task.body??S.task.contract?.objective??``;dt.current=e,pt.current={value:S.task.body??``,version:S.task.version},q(null),rt(e),K(!0)},children:(0,B.jsx)(`span`,{className:`whitespace-pre-wrap text-sm leading-6 text-fg-muted`,children:zt&&zt!==S.task.title?zt:d.noTaskDescription})}),gt===`description`?(0,B.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,B.jsx)(`span`,{children:l===`zh`?`Agent 在你编辑期间更新了描述。`:`The Agent updated the description while you were editing.`}),(0,B.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:()=>{rt(S.task.body??``),q(null),K(!1)},children:l===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,B.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,onClick:()=>void X({body:nt.trim()||null}).then(e=>{e&&(q(null),K(!1))}),children:l===`zh`?`保留我的修改`:`Keep my changes`})]}):null]}),S.attention.length>0?(0,B.jsxs)(`section`,{className:b(`rounded-xl bg-warning/10 p-4`,Q(`attention`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h3`,{className:`font-medium text-fg`,children:Xt?d.needsAttention:d.waitingStatus}),(0,B.jsx)(`ul`,{className:`mt-3 space-y-2 text-sm text-fg-muted`,children:S.attention.map((e,t)=>(0,B.jsx)(`li`,{children:e.summary},`${e.kind}-${t}`))})]}):null,(0,B.jsxs)(`section`,{className:b(`rounded-xl bg-surface-panel p-4`,Q(`contract`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:d.taskDefinition}),(0,B.jsxs)(`div`,{className:`mt-5`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:d.successDefinition}),Zt.length>0?(0,B.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:d.criteriaProgress.replace(`{{verified}}`,String(Qt)).replace(`{{total}}`,String(Zt.length))}):null]}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(U,{items:Zt,empty:d.noDefinition,verificationByCriterion:Bt})})]}),$t.length>0?(0,B.jsxs)(`div`,{className:`mt-5 rounded-lg bg-surface-hover p-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:d.expectedOutputs}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(U,{items:$t,empty:d.noDefinition})})]}):null,en.length>0?(0,B.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,B.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:d.constraints}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(U,{items:en,empty:d.noDefinition})})]}):null,tn.length>0?(0,B.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,B.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:d.approvalRequired}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(U,{items:tn,empty:d.noDefinition})})]}):null,nn.length>0?(0,B.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,B.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:d.contextAssumptions}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(U,{items:nn,empty:d.noDefinition})})]}):null,rn.length>0?(0,B.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,B.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:d.contextRisks}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(U,{items:rn,empty:d.noDefinition})})]}):null]}),Z?(0,B.jsxs)(`section`,{className:b(`rounded-xl bg-surface-panel p-4`,Q(`runs`,`receipts`)&&`task-detail-live-update`),children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:d.latestResult}),(0,B.jsx)(y,{content:Z.summary,compact:!0,className:`mt-2 text-sm leading-6 text-fg`})]}),(0,B.jsxs)(`span`,{className:`rounded-full bg-surface-hover px-2.5 py-1 text-xs text-fg-muted`,children:[d.receiptStatuses[Z.status],` · `,d.verificationStatuses[Z.verification.status]]})]}),Z.remainingWork.length>0?(0,B.jsxs)(`div`,{className:`mt-4`,children:[(0,B.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:d.remainingWork}),(0,B.jsx)(`div`,{className:`mt-2`,children:(0,B.jsx)(U,{items:Z.remainingWork,empty:d.noRemainingWork})})]}):null,Z.nextAction?(0,B.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-hover p-3`,children:[(0,B.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:d.nextAction}),(0,B.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:Z.nextAction})]}):null,(0,B.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(x,{className:`border-0 bg-surface-hover px-2 py-1 text-xs shadow-none`,variant:`secondary`,onClick:()=>void L(Z.runId,`helpful`),children:d.doneWell}),(0,B.jsx)(x,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>void L(Z.runId,`not_helpful`),children:d.needsFix}),Z.evidence.filter(e=>e.uri).map(e=>(0,B.jsxs)(`a`,{className:`ml-auto inline-flex items-center gap-1 text-xs text-accent hover:underline`,href:e.uri,children:[(0,B.jsx)(ee,{className:`size-3`}),e.title]},`${e.title}-${e.uri}`))]}),S.receipts.length>1?(0,B.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,B.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:d.executionHistory.replace(`{{count}}`,String(S.receipts.length-1))}),(0,B.jsx)(`div`,{className:`mt-3 space-y-3`,children:S.receipts.slice(1).map(e=>(0,B.jsx)(`article`,{className:`rounded-lg bg-surface-active p-3`,children:(0,B.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,B.jsx)(`p`,{className:`text-sm text-fg`,children:e.summary}),(0,B.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:d.receiptStatuses[e.status]})]})},e.runId))})]}):null]}):null,S.context.length>0?(0,B.jsxs)(`section`,{className:b(`rounded-xl bg-surface-panel p-4`,Q(`context`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:d.contextUsed}),(0,B.jsx)(`ul`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:S.context.map(e=>(0,B.jsxs)(`li`,{className:`min-w-0 rounded-lg bg-surface-hover p-2.5`,children:[(0,B.jsxs)(`span`,{className:`text-[11px] text-fg-subtle`,children:[d.contextRoleLabels[e.role],` · `,d.contextKindLabels[e.targetKind]]}),e.targetKind===`url`&&/^https?:\/\//.test(e.targetId)?(0,B.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,B.jsx)(`p`,{className:`mt-1 break-words text-sm text-fg`,children:e.title??e.targetId})]},e.id))})]}):null]}),(0,B.jsxs)(`aside`,{className:`order-1 min-w-0 space-y-4`,children:[(0,B.jsxs)(`section`,{className:b(`rounded-xl bg-surface-subtle p-4`,Q(`phase`,`resolution`,`priority`,`dueAt`,`delegateAgentId`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:d.taskProperties}),(0,B.jsxs)(`div`,{className:`mt-4 grid gap-4 sm:grid-cols-2`,children:[(0,B.jsx)(Ie,{value:S.task.phase,disabled:H.has(`phase`),canMove:on,canApprove:Wt,canReopen:Gt,language:l,label:d.taskPhase,onChange:Et}),(0,B.jsx)(Le,{value:S.task.priority,disabled:H.has(`priority`),label:d.priority,labels:d.priorityLabels,onChange:Dt}),(0,B.jsx)(Re,{value:Pe(S.task.dueAt),disabled:H.has(`dueAt`),label:d.dueDate,onChange:Ot}),(0,B.jsx)(ze,{value:S.conversation.currentExecutorAgentId??``,disabled:H.has(`delegateAgentId`),label:d.executorLabel,unassignedLabel:d.unassigned,agents:Xe,onChange:Nt}),W?(0,B.jsxs)(`div`,{className:`grid gap-1 text-xs text-fg-muted`,children:[(0,B.jsx)(`span`,{children:d.projectLabel}),(0,B.jsxs)(`span`,{className:`flex items-center gap-1.5 rounded-lg bg-surface-hover px-3 py-2 text-sm text-fg`,children:[(0,B.jsx)(he,{className:`size-3.5`}),W]})]}):null]}),(0,B.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-hover p-3 text-xs leading-5 text-fg-subtle`,children:[(0,B.jsx)(`p`,{children:Lt}),(0,B.jsx)(`p`,{children:Rt}),(0,B.jsx)(`p`,{className:`mt-2`,children:d.updatedAt.replace(`{{date}}`,j(S.task.updatedAt,l))})]})]}),(0,B.jsxs)(`section`,{className:b(`rounded-xl bg-surface-panel p-4`,Q(`dependencies`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:d.taskRelations}),(0,B.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:d.dependencies}),(0,B.jsx)(Be,{candidates:qe,selected:S.dependencies,disabled:H.has(`dependencies`),labels:xt,onChange:Mt})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:d.dependents}),S.dependents.length>0?(0,B.jsx)(`div`,{className:`space-y-1.5`,children:S.dependents.map(e=>(0,B.jsx)(c,{to:an(e.id),className:`block rounded-lg bg-surface-hover p-2.5 text-sm text-accent hover:underline`,children:e.title},e.id))}):(0,B.jsx)(`p`,{className:`text-sm text-fg-subtle`,children:d.noDependents})]})]})]})]})]})]}),(0,B.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(it),tabIndex:0,onPointerDown:jt,onKeyDown:At,onDoubleClick:()=>kt(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 ${ot?`bg-surface-hover`:``}`,children:(0,B.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,B.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,B.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3 bg-surface-subtle px-4 py-3.5`,children:[(0,B.jsx)(`div`,{className:`min-w-0`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[qt?(0,B.jsx)(de,{agentId:qt,avatar:Jt?.avatar,size:28,className:`shrink-0`}):null,(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:l===`zh`?`Agent 执行与对话`:`Agent execution and chat`}),(0,B.jsxs)(`p`,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:[Jt?.name??qt??d.unassigned,` · `,Lt]})]})]})}),t===`modal`?un:null]}),Kt?(0,B.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,B.jsx)(ve,{embedded:!0,sessionKey:Kt,taskId:e})}):Ee?(0,B.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,B.jsxs)(`div`,{className:`max-w-xs`,children:[(0,B.jsx)(T,{className:`mx-auto size-8 animate-pulse text-fg-subtle`}),(0,B.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:l===`zh`?`正在创建任务会话`:`Creating task conversation`})]})}):De?(0,B.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,B.jsxs)(`div`,{className:`max-w-xs`,children:[(0,B.jsx)(T,{className:`mx-auto size-8 text-danger`}),(0,B.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:l===`zh`?`任务会话创建失败`:`Could not create task conversation`}),(0,B.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:De instanceof Error?De.message:String(De)})]})}):(0,B.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,B.jsxs)(`div`,{className:`max-w-xs`,children:[(0,B.jsx)(T,{className:`mx-auto size-8 text-fg-subtle`}),(0,B.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:l===`zh`?`等待任务会话`:`Waiting for a task conversation`}),(0,B.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,B.jsx)(Ce,{open:yt,title:d.deleteTaskTitle,description:d.deleteTaskDescription.replace(`{{title}}`,S.task.title),confirmLabel:d.confirmDeleteTask,cancelLabel:d.keepTask,destructive:!0,onConfirm:()=>{bt(!1),Pt()},onCancel:()=>bt(!1)})]})}function qe(){let e=(0,z.c)(2),{taskId:t}=a(),n=t===void 0?``:t,r;return e[0]===n?r=e[1]:(r=(0,B.jsx)(Ke,{taskId:n,presentation:`page`}),e[0]=n,e[1]=r),r}function Je(e){let t=(0,z.c)(58),{taskId:n,backgroundPath:r,onClose:i}=e,a=ae(K),{data:o}=le(n),s=o?.conversation.activeSessionKey??null,h=P(tt),g=P(et),_=P($e),v=P(G),te=fe(Qe),ne=w(Ze),y=w(Xe),oe=h?g:0,x;t[0]!==i||t[1]!==y?(x=e=>{e||(y(null),i())},t[0]=i,t[1]=y,t[2]=x):x=t[2];let S=a===`zh`?`关闭任务详情`:`Close task details`,C;t[3]!==i||t[4]!==y?(C=()=>{y(null),i()},t[3]=i,t[4]=y,t[5]=C):C=t[5];let ce;t[6]!==S||t[7]!==C?(ce=(0,B.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":S,onClick:C}),t[6]=S,t[7]=C,t[8]=ce):ce=t[8];let ue=h?`true`:`false`,de=`${oe/2}px`,pe=`${oe}px`,T;t[9]!==de||t[10]!==pe?(T={"--task-detail-workspace-offset":de,"--task-detail-workspace-width":pe},t[9]=de,t[10]=pe,t[11]=T):T=t[11];let me=T,E=a===`zh`?`任务详情`:`Task details`,D;t[12]===E?D=t[13]:(D=(0,B.jsx)(p,{className:`font-medium text-fg`,children:E}),t[12]=E,t[13]=D);let he=a===`zh`?`查看并操作任务详情`:`View and manage task details`,O;t[14]===he?O=t[15]:(O=(0,B.jsx)(l,{className:`sr-only`,children:he}),t[14]=he,t[15]=O);let k;t[16]!==s||t[17]!==a||t[18]!==v||t[19]!==te||t[20]!==n||t[21]!==h||t[22]!==_?(k=s?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`button`,{type:`button`,className:b(`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,h&&_===s&&`bg-surface-hover text-fg`),"aria-label":a===`zh`?`项目文件`:`Project files`,title:a===`zh`?`项目文件`:`Project files`,"aria-pressed":h&&_===s,onClick:()=>{te(s,!1),v(s)},children:(0,B.jsx)(re,{className:`size-4`,"aria-hidden":!0})}),(0,B.jsx)(c,{to:Te(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,B.jsx)(ee,{className:`size-4`,"aria-hidden":!0})})]}):null,t[16]=s,t[17]=a,t[18]=v,t[19]=te,t[20]=n,t[21]=h,t[22]=_,t[23]=k):k=t[23];let ge=a===`zh`?`关闭任务详情`:`Close task details`,_e;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,B.jsx)(ie,{className:`size-4`,"aria-hidden":!0}),t[24]=_e):_e=t[24];let A;t[25]===ge?A=t[26]:(A=(0,B.jsx)(u,{className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":ge,children:_e}),t[25]=ge,t[26]=A);let j;t[27]!==k||t[28]!==A?(j=(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[k,A]}),t[27]=k,t[28]=A,t[29]=j):j=t[29];let M;t[30]!==D||t[31]!==O||t[32]!==j?(M=(0,B.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-3 bg-surface-panel px-5 py-3.5`,children:[D,O,j]}),t[30]=D,t[31]=O,t[32]=j,t[33]=M):M=t[33];let N;t[34]!==i||t[35]!==y?(N=()=>{y(null),i()},t[34]=i,t[35]=y,t[36]=N):N=t[36];let F;t[37]!==r||t[38]!==N||t[39]!==n?(F=(0,B.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,B.jsx)(Ke,{taskId:n,presentation:`modal`,backgroundPath:r,onDeleted:N})}),t[37]=r,t[38]=N,t[39]=n,t[40]=F):F=t[40];let I;t[41]!==M||t[42]!==F||t[43]!==ue||t[44]!==me?(I=(0,B.jsxs)(f,{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:me,onEscapeKeyDown:Ye,onInteractOutside:W,children:[M,F]}),t[41]=M,t[42]=F,t[43]=ue,t[44]=me,t[45]=I):I=t[45];let ve;t[46]!==ne||t[47]!==h||t[48]!==g||t[49]!==_?(ve=ne?(0,B.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:h?g:0},children:(0,B.jsx)(se,{allowOutsideChat:!0,sessionKey:_??void 0})}):null,t[46]=ne,t[47]=h,t[48]=g,t[49]=_,t[50]=ve):ve=t[50];let L;t[51]!==I||t[52]!==ve||t[53]!==ce?(L=(0,B.jsxs)(d,{children:[ce,I,ve]}),t[51]=I,t[52]=ve,t[53]=ce,t[54]=L):L=t[54];let ye;return t[55]!==x||t[56]!==L?(ye=(0,B.jsx)(m,{modal:!1,open:!0,onOpenChange:x,children:L}),t[55]=x,t[56]=L,t[57]=ye):ye=t[57],ye}function W(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 Qe(e){return e.setOpen}function G(e){return e.openForSession}function $e(e){return e.sessionKeyOverride}function et(e){return e.widthPx}function tt(e){return e.open}function K(e){return e.language}function nt(e){return(0,B.jsx)(g,{value:e.id,children:e.name||e.id},e.id)}function rt(e){return e.id}export{Je as TaskDetailModal,qe as TaskDetailPage};