@xopcai/xopc 0.0.146 → 0.0.147

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 (376) hide show
  1. package/README.md +2 -2
  2. package/dist/browser-ext/manifest.json +1 -1
  3. package/dist/extensions/demo-memory/src/index.js +6 -4
  4. package/dist/extensions/demo-memory/src/index.js.map +1 -1
  5. package/dist/extensions/telegram/xopc.extension.json +1 -1
  6. package/dist/gateway/static/root/assets/Combination-14nmIgxH.js +41 -0
  7. package/dist/gateway/static/root/assets/activity-store-DXeSSlw1.js +1 -0
  8. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-gBVDdd-Q.js → agent-avatar-dicebear-CFdJKSjY.js} +1 -1
  9. package/dist/gateway/static/root/assets/agents-DKjbRpbA.js +2 -0
  10. package/dist/gateway/static/root/assets/api-Bs69B5zA.js +1 -0
  11. package/dist/gateway/static/root/assets/{app-management-settings-panel-Dd5dmRWY.js → app-management-settings-panel-ag1ViXT_.js} +1 -1
  12. package/dist/gateway/static/root/assets/{appearance-settings-D89pY61C.js → appearance-settings-C6iMpwOM.js} +1 -1
  13. package/dist/gateway/static/root/assets/apps-page-CpX3lBFF.js +1 -0
  14. package/dist/gateway/static/root/assets/{archive-plugin-BZj1tk3p.js → archive-plugin-Dwi3mIBy.js} +1 -1
  15. package/dist/gateway/static/root/assets/{attachment-load-18eo6l3m.js → attachment-load-BaCDoq40.js} +1 -1
  16. package/dist/gateway/static/root/assets/{automation-suggestion-card-F1g3MckR.js → automation-suggestion-card-CwqtFgnw.js} +1 -1
  17. package/dist/gateway/static/root/assets/automations-page-DlupOxFQ.js +6 -0
  18. package/dist/gateway/static/root/assets/{binary-plugins-jOYMquLP.js → binary-plugins-DoAYhsxa.js} +1 -1
  19. package/dist/gateway/static/root/assets/{block-editor-CD77nXJU.js → block-editor-Bw72pO7S.js} +31 -31
  20. package/dist/gateway/static/root/assets/browser-settings-page-BwLoUBcZ.js +8 -0
  21. package/dist/gateway/static/root/assets/capability-presets-api-vdbAR65Q.js +1 -0
  22. package/dist/gateway/static/root/assets/capability-presets-settings-panel-BAsKbJgm.js +2 -0
  23. package/dist/gateway/static/root/assets/{channel-recipient-api-fTlTnWB4.js → channel-recipient-api-rTG26jpV.js} +1 -1
  24. package/dist/gateway/static/root/assets/channels-settings-CxFWy0cE.js +1 -0
  25. package/dist/gateway/static/root/assets/channels-status-swr-OKlqTtKJ.js +1 -0
  26. package/dist/gateway/static/root/assets/{connector-logo-g9f07qO6.js → connector-logo-DIMP4NWY.js} +1 -1
  27. package/dist/gateway/static/root/assets/connectors-page-BjQQwX62.js +2 -0
  28. package/dist/gateway/static/root/assets/{desktop-pet-DwPVWi3D.js → desktop-pet-kQq2e0BN.js} +1 -1
  29. package/dist/gateway/static/root/assets/{desktop-pet-settings-Dm1N7RRX.js → desktop-pet-settings-B6vtozMY.js} +1 -1
  30. package/dist/gateway/static/root/assets/{directory-picker-path-field-hZghTKie.js → directory-picker-path-field-Dn5-e3v4.js} +1 -1
  31. package/dist/gateway/static/root/assets/dist-C230izr8.js +1 -0
  32. package/dist/gateway/static/root/assets/dist-CxGUk8J-.js +1 -0
  33. package/dist/gateway/static/root/assets/dreaming-settings-BzwIujPG.js +3 -0
  34. package/dist/gateway/static/root/assets/extension-debug-page-D_e_hsEy.js +1 -0
  35. package/dist/gateway/static/root/assets/{extension-page-otKJCjKP.js → extension-page-D15CWHBd.js} +1 -1
  36. package/dist/gateway/static/root/assets/{extension-settings-page-ifHzMfT-.js → extension-settings-page-D4P0n1om.js} +1 -1
  37. package/dist/gateway/static/root/assets/{gateway-config-api-BQX5GGl2.js → gateway-config-api-B4qZctjG.js} +1 -1
  38. package/dist/gateway/static/root/assets/{gateway-settings-BfXo0j0O.js → gateway-settings-BvndV7TP.js} +1 -1
  39. package/dist/gateway/static/root/assets/{gateway-startup-retry-DtoLihQE.js → gateway-startup-retry-BpgMunEb.js} +1 -1
  40. package/dist/gateway/static/root/assets/{goal-create-dialog-C_Qw_QgW.js → goal-create-dialog-DrVHKXHq.js} +1 -1
  41. package/dist/gateway/static/root/assets/goal-detail-page-PHlCwv68.js +4 -0
  42. package/dist/gateway/static/root/assets/{goals-config-api-DQJ5mBXB.js → goals-config-api-B6YJB_ct.js} +1 -1
  43. package/dist/gateway/static/root/assets/goals-page-Hg9uyO6e.js +2 -0
  44. package/dist/gateway/static/root/assets/{goals-settings-CQX8zWKe.js → goals-settings-BROWCIcL.js} +1 -1
  45. package/dist/gateway/static/root/assets/{heartbeat-settings-yy_Pt_24.js → heartbeat-settings-CoCwIOIg.js} +1 -1
  46. package/dist/gateway/static/root/assets/index-CxkNzw3e.js +259 -0
  47. package/dist/gateway/static/root/assets/index-DjCSOyaN.css +1 -0
  48. package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-Bm_AIYQ7.js +1 -0
  49. package/dist/gateway/static/root/assets/local-app-workbench-page-BJWFcxwG.js +2 -0
  50. package/dist/gateway/static/root/assets/local-apps-page-BsiZMrEf.js +1 -0
  51. package/dist/gateway/static/root/assets/{locale-store-CiM-D9jA.js → locale-store-Bp8joZck.js} +1 -1
  52. package/dist/gateway/static/root/assets/logs-page-DOmK61ey.js +7 -0
  53. package/dist/gateway/static/root/assets/{markdown-split-BYasrWPk.js → markdown-split-Dy7QpaAz.js} +1 -1
  54. package/dist/gateway/static/root/assets/{media-plugins--cJpmHc2.js → media-plugins-3Lxliy9D.js} +1 -1
  55. package/dist/gateway/static/root/assets/messages-CQGpD-dC.js +5 -0
  56. package/dist/gateway/static/root/assets/models-hub-panel-DGCZom4o.js +2 -0
  57. package/dist/gateway/static/root/assets/{notes-page-Digm3EgB.js → notes-page-BJtT4vSf.js} +1 -1
  58. package/dist/gateway/static/root/assets/notes-workbench-B_bN7cOR.js +4 -0
  59. package/dist/gateway/static/root/assets/{page-tabs-CGVMJEW0.js → page-tabs-DKB6RDre.js} +1 -1
  60. package/dist/gateway/static/root/assets/{preview-open-alternatives-BBAkU4xW.js → preview-open-alternatives-Br_YhYHp.js} +1 -1
  61. package/dist/gateway/static/root/assets/project-detail-page-Dq8JouJj.js +1 -0
  62. package/dist/gateway/static/root/assets/projects-page-DvfL7fSe.js +1 -0
  63. package/dist/gateway/static/root/assets/remote-access-hub-DqwMXSXP.js +1 -0
  64. package/dist/gateway/static/root/assets/{save-bar-controls-D4B469dh.js → save-bar-controls-BgIE9BBh.js} +1 -1
  65. package/dist/gateway/static/root/assets/{schedule-field-Vy4OjH0i.js → schedule-field-BXDP-oMz.js} +1 -1
  66. package/dist/gateway/static/root/assets/{schema-form-CPYzgmby.js → schema-form-Dhv-SmjG.js} +1 -1
  67. package/dist/gateway/static/root/assets/sessions-page-B_mOZkQk.js +1 -0
  68. package/dist/gateway/static/root/assets/settings-advanced-gate-BHGmH6YS.js +1 -0
  69. package/dist/gateway/static/root/assets/{settings-collapsible-section-BB5y9vwh.js → settings-collapsible-section-CUTExnlK.js} +1 -1
  70. package/dist/gateway/static/root/assets/{settings-form-section-BfzJkVHd.js → settings-form-section-CmnDhsf0.js} +1 -1
  71. package/dist/gateway/static/root/assets/{settings-loading-skeleton-DM8iH25s.js → settings-loading-skeleton-B79dq-XY.js} +1 -1
  72. package/dist/gateway/static/root/assets/{settings-page-h5Alz_fA.js → settings-page-Db8uAv3X.js} +1 -1
  73. package/dist/gateway/static/root/assets/{settings-page-layout-DjbdpK2j.js → settings-page-layout-DaFwstQw.js} +1 -1
  74. package/dist/gateway/static/root/assets/setup-status-panel-BUSEj0KK.js +1 -0
  75. package/dist/gateway/static/root/assets/{share-preview-page-DxozU_zz.js → share-preview-page-Bi00uXzV.js} +1 -1
  76. package/dist/gateway/static/root/assets/shares-settings-DzsTYfuX.js +1 -0
  77. package/dist/gateway/static/root/assets/skill-reload-api-DSsdU081.js +1 -0
  78. package/dist/gateway/static/root/assets/skills-page-DeB1tQZL.js +2 -0
  79. package/dist/gateway/static/root/assets/{system-settings-panel-DNi9Ofuj.js → system-settings-panel-Cxaph7hW.js} +1 -1
  80. package/dist/gateway/static/root/assets/{theme-store-C9Dxcppm.js → theme-store-eCTN1RpG.js} +1 -1
  81. package/dist/gateway/static/root/assets/{typed-models-lib-B6Nw3iFM.js → typed-models-lib-CcZ_tyFY.js} +1 -1
  82. package/dist/gateway/static/root/assets/{use-channel-catalog-DE9cpn4G.js → use-channel-catalog-C4PWbNoi.js} +1 -1
  83. package/dist/gateway/static/root/assets/user-context-page-QTVMx_hG.js +1 -0
  84. package/dist/gateway/static/root/assets/{user-profile-fields-editor-DVBShNYF.js → user-profile-fields-editor-CPOO9Jz5.js} +1 -1
  85. package/dist/gateway/static/root/assets/{user-profile-settings-panel-CC0sf3vS.js → user-profile-settings-panel-C8cgtSF7.js} +1 -1
  86. package/dist/gateway/static/root/assets/{utils-DnsuE4YP.js → utils-CiZK2KwH.js} +1 -1
  87. package/dist/gateway/static/root/assets/voice-api-key-field-b-YZtvUu.js +1 -0
  88. package/dist/gateway/static/root/assets/work-discovery-page-4zVDOl2G.js +1 -0
  89. package/dist/gateway/static/root/assets/work-item-detail-page-CHe2tfkc.js +1 -0
  90. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DXc_pbVG.js → workflow-run-setup-panel-8SLCYeXE.js} +2 -2
  91. package/dist/gateway/static/root/assets/workflows-page-DEOFqiWn.js +11 -0
  92. package/dist/gateway/static/root/index.html +10 -9
  93. package/dist/package.js +1 -1
  94. package/dist/src/activity/types.d.ts +1 -1
  95. package/dist/src/agent/agent-instance-gateway.d.ts +1 -1
  96. package/dist/src/agent/agent-manager.d.ts +1 -1
  97. package/dist/src/agent/agent-manager.js +5 -4
  98. package/dist/src/agent/agent-manager.js.map +1 -1
  99. package/dist/src/agent/background-review/coordinator.js +0 -1
  100. package/dist/src/agent/background-review/coordinator.js.map +1 -1
  101. package/dist/src/agent/background-review/settings.d.ts +1 -1
  102. package/dist/src/agent/background-review/settings.js +10 -17
  103. package/dist/src/agent/background-review/settings.js.map +1 -1
  104. package/dist/src/agent/bootstrap/filter-bootstrap-files.d.ts +1 -1
  105. package/dist/src/agent/bootstrap/filter-bootstrap-files.js +1 -1
  106. package/dist/src/agent/bootstrap/filter-bootstrap-files.js.map +1 -1
  107. package/dist/src/agent/bootstrap/load-bootstrap-files.js +2 -3
  108. package/dist/src/agent/bootstrap/load-bootstrap-files.js.map +1 -1
  109. package/dist/src/agent/code-intelligence/binary.js +1 -1
  110. package/dist/src/agent/context/project-context.d.ts +14 -0
  111. package/dist/src/agent/context/project-context.js +23 -1
  112. package/dist/src/agent/context/project-context.js.map +1 -1
  113. package/dist/src/agent/context/workspace-templates/AGENTS.md +1 -1
  114. package/dist/src/agent/context/workspace.d.ts +1 -2
  115. package/dist/src/agent/context/workspace.js +2 -4
  116. package/dist/src/agent/context/workspace.js.map +1 -1
  117. package/dist/src/agent/embedded/run-for-session.js +1 -2
  118. package/dist/src/agent/embedded/run-for-session.js.map +1 -1
  119. package/dist/src/agent/embedded/run-turn.js +6 -1
  120. package/dist/src/agent/embedded/run-turn.js.map +1 -1
  121. package/dist/src/agent/embedded/types.d.ts +17 -0
  122. package/dist/src/agent/memory/builtin-memory-store.d.ts +2 -2
  123. package/dist/src/agent/memory/builtin-memory-store.js +2 -2
  124. package/dist/src/agent/memory/builtin-memory-store.js.map +1 -1
  125. package/dist/src/agent/memory/builtin-provider.d.ts +1 -3
  126. package/dist/src/agent/memory/builtin-provider.js +21 -48
  127. package/dist/src/agent/memory/builtin-provider.js.map +1 -1
  128. package/dist/src/agent/memory/context/planner.js +48 -9
  129. package/dist/src/agent/memory/context/planner.js.map +1 -1
  130. package/dist/src/agent/memory/context/types.d.ts +7 -1
  131. package/dist/src/agent/memory/context-fence.js +1 -1
  132. package/dist/src/agent/memory/context-fence.js.map +1 -1
  133. package/dist/src/agent/memory/create-memory-manager.js +2 -9
  134. package/dist/src/agent/memory/create-memory-manager.js.map +1 -1
  135. package/dist/src/agent/memory/dreaming/config.js +4 -9
  136. package/dist/src/agent/memory/dreaming/config.js.map +1 -1
  137. package/dist/src/agent/memory/dreaming/promotion-lifecycle.js +2 -2
  138. package/dist/src/agent/memory/dreaming/promotion-lifecycle.js.map +1 -1
  139. package/dist/src/agent/memory/dreaming/scope.d.ts +2 -3
  140. package/dist/src/agent/memory/dreaming/scope.js +8 -8
  141. package/dist/src/agent/memory/dreaming/scope.js.map +1 -1
  142. package/dist/src/agent/memory/manager.d.ts +1 -5
  143. package/dist/src/agent/memory/manager.js +2 -23
  144. package/dist/src/agent/memory/manager.js.map +1 -1
  145. package/dist/src/agent/memory/memory-config.d.ts +3 -3
  146. package/dist/src/agent/memory/memory-config.js +9 -14
  147. package/dist/src/agent/memory/memory-config.js.map +1 -1
  148. package/dist/src/agent/memory/types.d.ts +9 -5
  149. package/dist/src/agent/memory/understanding/service.js +21 -8
  150. package/dist/src/agent/memory/understanding/service.js.map +1 -1
  151. package/dist/src/agent/memory/understanding/types.d.ts +5 -0
  152. package/dist/src/agent/memory/user-context-coordinator.d.ts +1 -1
  153. package/dist/src/agent/memory/user-context-coordinator.js +6 -2
  154. package/dist/src/agent/memory/user-context-coordinator.js.map +1 -1
  155. package/dist/src/agent/orchestration/agent-orchestrator.js +2 -2
  156. package/dist/src/agent/orchestration/agent-orchestrator.js.map +1 -1
  157. package/dist/src/agent/prompt/memory/index.d.ts +1 -2
  158. package/dist/src/agent/prompt/memory/index.js +6 -7
  159. package/dist/src/agent/prompt/memory/index.js.map +1 -1
  160. package/dist/src/agent/prompt/sections/tooling.js +1 -1
  161. package/dist/src/agent/prompt/sections/tooling.js.map +1 -1
  162. package/dist/src/agent/service/direct-turn-helpers.js +13 -2
  163. package/dist/src/agent/service/direct-turn-helpers.js.map +1 -1
  164. package/dist/src/agent/tools/curated-memory-tool.js +4 -4
  165. package/dist/src/agent/tools/curated-memory-tool.js.map +1 -1
  166. package/dist/src/agent/tools/factory.d.ts +1 -1
  167. package/dist/src/agent/tools/factory.js +2 -2
  168. package/dist/src/agent/tools/factory.js.map +1 -1
  169. package/dist/src/agent/tools/memory-tool.js +1 -1
  170. package/dist/src/agent/tools/memory-tool.js.map +1 -1
  171. package/dist/src/agent/workflow/workflow-child-tools.js +2 -3
  172. package/dist/src/agent/workflow/workflow-child-tools.js.map +1 -1
  173. package/dist/src/agent/workspace-runtime/registry.d.ts +5 -5
  174. package/dist/src/agent/workspace-runtime/registry.js +6 -11
  175. package/dist/src/agent/workspace-runtime/registry.js.map +1 -1
  176. package/dist/src/agent-manifest/index.js +2 -2
  177. package/dist/src/agent-manifest/prompt.js +1 -7
  178. package/dist/src/agent-manifest/prompt.js.map +1 -1
  179. package/dist/src/agent-manifest/schema.d.ts +0 -598
  180. package/dist/src/agent-manifest/schema.js +2 -143
  181. package/dist/src/agent-manifest/schema.js.map +1 -1
  182. package/dist/src/agent-manifest/validator.js +0 -12
  183. package/dist/src/agent-manifest/validator.js.map +1 -1
  184. package/dist/src/agent-runtime/memory-runtime.d.ts +2 -2
  185. package/dist/src/agent-runtime/memory-runtime.js +8 -7
  186. package/dist/src/agent-runtime/memory-runtime.js.map +1 -1
  187. package/dist/src/agent-runtime/runtime-profile.d.ts +2 -0
  188. package/dist/src/agent-runtime/runtime-profile.js +1 -1
  189. package/dist/src/agent-runtime/runtime-profile.js.map +1 -1
  190. package/dist/src/chat-commands/agent-edit.js +1 -2
  191. package/dist/src/chat-commands/agent-edit.js.map +1 -1
  192. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  193. package/dist/src/cli/commands/init.js +0 -22
  194. package/dist/src/cli/commands/init.js.map +1 -1
  195. package/dist/src/cli/templates.d.ts +1 -1
  196. package/dist/src/cli/templates.js +1 -16
  197. package/dist/src/cli/templates.js.map +1 -1
  198. package/dist/src/commands/agents.config.js +0 -10
  199. package/dist/src/commands/agents.config.js.map +1 -1
  200. package/dist/src/config/index.js +2 -2
  201. package/dist/src/config/paths.d.ts +0 -1
  202. package/dist/src/config/paths.js +1 -2
  203. package/dist/src/config/paths.js.map +1 -1
  204. package/dist/src/config/schema.d.ts +118 -532
  205. package/dist/src/config/schema.js +32 -26
  206. package/dist/src/config/schema.js.map +1 -1
  207. package/dist/src/extensions/loader.js +2 -1
  208. package/dist/src/extensions/loader.js.map +1 -1
  209. package/dist/src/gateway/agents-admin.d.ts +0 -2
  210. package/dist/src/gateway/agents-admin.js +0 -6
  211. package/dist/src/gateway/agents-admin.js.map +1 -1
  212. package/dist/src/gateway/capability-presets-admin.d.ts +0 -2
  213. package/dist/src/gateway/capability-presets-admin.js.map +1 -1
  214. package/dist/src/gateway/chat-stream/mapper.js +26 -0
  215. package/dist/src/gateway/chat-stream/mapper.js.map +1 -1
  216. package/dist/src/gateway/chat-stream/protocol.d.ts +16 -1
  217. package/dist/src/gateway/dreaming-automation-reconciler.d.ts +0 -1
  218. package/dist/src/gateway/dreaming-automation-reconciler.js +41 -63
  219. package/dist/src/gateway/dreaming-automation-reconciler.js.map +1 -1
  220. package/dist/src/gateway/hono/app.js +3 -1
  221. package/dist/src/gateway/hono/app.js.map +1 -1
  222. package/dist/src/gateway/hono/lib/config-payload.d.ts +0 -130
  223. package/dist/src/gateway/hono/lib/config-payload.js +0 -1
  224. package/dist/src/gateway/hono/lib/config-payload.js.map +1 -1
  225. package/dist/src/gateway/hono/routes/agents.js +6 -12
  226. package/dist/src/gateway/hono/routes/agents.js.map +1 -1
  227. package/dist/src/gateway/hono/routes/auth-registry-extensions.js +6 -0
  228. package/dist/src/gateway/hono/routes/auth-registry-extensions.js.map +1 -1
  229. package/dist/src/gateway/hono/routes/capability-presets.js +2 -2
  230. package/dist/src/gateway/hono/routes/capability-presets.js.map +1 -1
  231. package/dist/src/gateway/hono/routes/dreaming.js +9 -20
  232. package/dist/src/gateway/hono/routes/dreaming.js.map +1 -1
  233. package/dist/src/gateway/hono/routes/index.js +4 -0
  234. package/dist/src/gateway/hono/routes/index.js.map +1 -1
  235. package/dist/src/gateway/hono/routes/local-apps.d.ts +5 -0
  236. package/dist/src/gateway/hono/routes/local-apps.js +99 -0
  237. package/dist/src/gateway/hono/routes/local-apps.js.map +1 -0
  238. package/dist/src/gateway/hono/routes/memory.js +48 -65
  239. package/dist/src/gateway/hono/routes/memory.js.map +1 -1
  240. package/dist/src/gateway/hono/routes/projects.js +2 -2
  241. package/dist/src/gateway/hono/routes/projects.js.map +1 -1
  242. package/dist/src/gateway/hono/routes/work-discovery.d.ts +3 -0
  243. package/dist/src/gateway/hono/routes/work-discovery.js +150 -0
  244. package/dist/src/gateway/hono/routes/work-discovery.js.map +1 -0
  245. package/dist/src/gateway/hono/routes/you.d.ts +3 -0
  246. package/dist/src/gateway/hono/routes/you.js +358 -91
  247. package/dist/src/gateway/hono/routes/you.js.map +1 -1
  248. package/dist/src/gateway/service.d.ts +3 -0
  249. package/dist/src/gateway/service.js +12 -0
  250. package/dist/src/gateway/service.js.map +1 -1
  251. package/dist/src/knowledge/connected-knowledge-pipeline.js +9 -5
  252. package/dist/src/knowledge/connected-knowledge-pipeline.js.map +1 -1
  253. package/dist/src/local-apps/acceptance.d.ts +30 -0
  254. package/dist/src/local-apps/acceptance.js +93 -0
  255. package/dist/src/local-apps/acceptance.js.map +1 -0
  256. package/dist/src/local-apps/index.d.ts +5 -0
  257. package/dist/src/local-apps/index.js +4 -0
  258. package/dist/src/local-apps/preview-runtime-bridge.d.ts +4 -0
  259. package/dist/src/local-apps/preview-runtime-bridge.js +171 -0
  260. package/dist/src/local-apps/preview-runtime-bridge.js.map +1 -0
  261. package/dist/src/local-apps/runtime-entry.d.ts +8 -0
  262. package/dist/src/local-apps/runtime-entry.js +25 -0
  263. package/dist/src/local-apps/runtime-entry.js.map +1 -0
  264. package/dist/src/local-apps/scaffold.d.ts +8 -0
  265. package/dist/src/local-apps/scaffold.js +122 -0
  266. package/dist/src/local-apps/scaffold.js.map +1 -0
  267. package/dist/src/local-apps/service.d.ts +37 -0
  268. package/dist/src/local-apps/service.js +553 -0
  269. package/dist/src/local-apps/service.js.map +1 -0
  270. package/dist/src/local-apps/store.d.ts +44 -0
  271. package/dist/src/local-apps/store.js +195 -0
  272. package/dist/src/local-apps/store.js.map +1 -0
  273. package/dist/src/local-apps/types.d.ts +105 -0
  274. package/dist/src/local-apps/types.js +1 -0
  275. package/dist/src/storage/sqlite/index.d.ts +3 -2
  276. package/dist/src/storage/sqlite/index.js +4 -3
  277. package/dist/src/storage/sqlite/memory-index-repository.d.ts +2 -3
  278. package/dist/src/storage/sqlite/memory-index-repository.js +16 -20
  279. package/dist/src/storage/sqlite/memory-index-repository.js.map +1 -1
  280. package/dist/src/storage/sqlite/memory-records-repository.d.ts +18 -10
  281. package/dist/src/storage/sqlite/memory-records-repository.js +79 -34
  282. package/dist/src/storage/sqlite/memory-records-repository.js.map +1 -1
  283. package/dist/src/storage/sqlite/memory-reference-consent-repository.d.ts +27 -0
  284. package/dist/src/storage/sqlite/memory-reference-consent-repository.js +109 -0
  285. package/dist/src/storage/sqlite/memory-reference-consent-repository.js.map +1 -0
  286. package/dist/src/storage/sqlite/migrations/038_user_owned_memory.sql +68 -0
  287. package/dist/src/storage/sqlite/migrations/039_memory_reference_consents.sql +19 -0
  288. package/dist/src/storage/sqlite/migrations/040_local_apps.sql +32 -0
  289. package/dist/src/storage/sqlite/migrations/041_local_app_release_lifecycle.sql +17 -0
  290. package/dist/src/storage/sqlite/migrations/042_work_discovery.sql +41 -0
  291. package/dist/src/storage/sqlite/migrations/043_local_app_acceptance_runs.sql +16 -0
  292. package/dist/src/storage/sqlite/migrations/044_repair_work_discovery_foreign_keys.sql +75 -0
  293. package/dist/src/storage/sqlite/migrations/045_extension_ui_grants.sql +13 -0
  294. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  295. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  296. package/dist/src/storage/sqlite/migrations/runner.js.map +1 -1
  297. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  298. package/dist/src/storage/sqlite/schema.js +1 -1
  299. package/dist/src/storage/sqlite/schema.sql +20 -0
  300. package/dist/src/user-context/config.d.ts +227 -0
  301. package/dist/src/user-context/config.js +158 -0
  302. package/dist/src/user-context/config.js.map +1 -0
  303. package/dist/src/user-context/import.d.ts +1 -1
  304. package/dist/src/user-context/import.js +6 -1
  305. package/dist/src/user-context/import.js.map +1 -1
  306. package/dist/src/user-context/owner.d.ts +5 -0
  307. package/dist/src/user-context/owner.js +9 -0
  308. package/dist/src/user-context/owner.js.map +1 -0
  309. package/dist/src/user-context/projection.d.ts +11 -9
  310. package/dist/src/user-context/projection.js +74 -47
  311. package/dist/src/user-context/projection.js.map +1 -1
  312. package/dist/src/user-context/runtime.d.ts +13 -0
  313. package/dist/src/user-context/runtime.js +36 -0
  314. package/dist/src/user-context/runtime.js.map +1 -0
  315. package/dist/src/work-discovery/analyzer.d.ts +11 -0
  316. package/dist/src/work-discovery/analyzer.js +171 -0
  317. package/dist/src/work-discovery/analyzer.js.map +1 -0
  318. package/dist/src/work-discovery/index.d.ts +5 -0
  319. package/dist/src/work-discovery/index.js +5 -0
  320. package/dist/src/work-discovery/probe.d.ts +12 -0
  321. package/dist/src/work-discovery/probe.js +335 -0
  322. package/dist/src/work-discovery/probe.js.map +1 -0
  323. package/dist/src/work-discovery/repository.d.ts +11 -0
  324. package/dist/src/work-discovery/repository.js +100 -0
  325. package/dist/src/work-discovery/repository.js.map +1 -0
  326. package/dist/src/work-discovery/service.d.ts +30 -0
  327. package/dist/src/work-discovery/service.js +387 -0
  328. package/dist/src/work-discovery/service.js.map +1 -0
  329. package/dist/src/work-discovery/types.d.ts +114 -0
  330. package/dist/src/work-discovery/types.js +1 -0
  331. package/dist/src/workflows/service/workflow-session-bridge.js +1 -1
  332. package/dist/src/workflows/service/workflow-session-bridge.js.map +1 -1
  333. package/package.json +4 -3
  334. package/skills/engineering/build-xopc-local-app/SKILL.md +45 -0
  335. package/skills/engineering/build-xopc-local-app/references/app-contract.md +33 -0
  336. package/skills/engineering/build-xopc-local-app/scripts/validate-local-app.mjs +72 -0
  337. package/dist/gateway/static/root/assets/Combination-DolwnuKi.js +0 -41
  338. package/dist/gateway/static/root/assets/activity-center-store-3l9ahUqb.js +0 -1
  339. package/dist/gateway/static/root/assets/agents-BLp5ItD3.js +0 -2
  340. package/dist/gateway/static/root/assets/apps-page-CgOy905b.js +0 -1
  341. package/dist/gateway/static/root/assets/automations-page-Bdj0A_IC.js +0 -6
  342. package/dist/gateway/static/root/assets/browser-settings-page-D73ClpC2.js +0 -8
  343. package/dist/gateway/static/root/assets/capability-presets-api-DZwIrY_P.js +0 -1
  344. package/dist/gateway/static/root/assets/capability-presets-settings-panel-Dw2uinRX.js +0 -2
  345. package/dist/gateway/static/root/assets/channels-settings-g9TZdnQh.js +0 -1
  346. package/dist/gateway/static/root/assets/channels-status-swr-CJauF1CW.js +0 -1
  347. package/dist/gateway/static/root/assets/connectors-page-CJLsXBB0.js +0 -2
  348. package/dist/gateway/static/root/assets/dist-C99RGfAH.js +0 -1
  349. package/dist/gateway/static/root/assets/dreaming-settings-B_LcHWcv.js +0 -3
  350. package/dist/gateway/static/root/assets/extension-debug-page-BqguEetG.js +0 -1
  351. package/dist/gateway/static/root/assets/goal-detail-page-BnUrr9_O.js +0 -4
  352. package/dist/gateway/static/root/assets/goals-page-BgDCoiG0.js +0 -2
  353. package/dist/gateway/static/root/assets/index-BJGusbyV.js +0 -259
  354. package/dist/gateway/static/root/assets/index-CSLF84-Q.css +0 -1
  355. package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-D1rVyDdf.js +0 -1
  356. package/dist/gateway/static/root/assets/logs-page-C35Xa_mx.js +0 -7
  357. package/dist/gateway/static/root/assets/messages-Cb1VMeqP.js +0 -5
  358. package/dist/gateway/static/root/assets/models-hub-panel-CqehWxbT.js +0 -2
  359. package/dist/gateway/static/root/assets/notes-workbench-CCuL7qlg.js +0 -4
  360. package/dist/gateway/static/root/assets/project-detail-page-DTWPEtSE.js +0 -1
  361. package/dist/gateway/static/root/assets/projects-page-NnJpsIAD.js +0 -1
  362. package/dist/gateway/static/root/assets/remote-access-hub-wbk1GCvg.js +0 -1
  363. package/dist/gateway/static/root/assets/sessions-page-Do0ZNuqM.js +0 -1
  364. package/dist/gateway/static/root/assets/settings-advanced-gate-HeYP_JCr.js +0 -1
  365. package/dist/gateway/static/root/assets/setup-status-panel-bjbH7U6x.js +0 -1
  366. package/dist/gateway/static/root/assets/shares-settings-Cl_bE9gQ.js +0 -1
  367. package/dist/gateway/static/root/assets/skill-reload-api-DcqbKYgB.js +0 -1
  368. package/dist/gateway/static/root/assets/skills-page-D_Xkjxtr.js +0 -2
  369. package/dist/gateway/static/root/assets/user-context-page-BtU2sQoK.js +0 -1
  370. package/dist/gateway/static/root/assets/voice-api-key-field-BIcSMf0O.js +0 -1
  371. package/dist/gateway/static/root/assets/work-item-detail-page-ChCKymS7.js +0 -1
  372. package/dist/gateway/static/root/assets/workflows-page-CheHRVox.js +0 -11
  373. package/dist/src/agent/context/workspace-templates/MEMORY.md +0 -33
  374. package/dist/src/agent/memory/access-policy.d.ts +0 -12
  375. package/dist/src/agent/memory/access-policy.js +0 -44
  376. package/dist/src/agent/memory/access-policy.js.map +0 -1
@@ -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,t as a,u as o}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as s}from"./cn-BQ_8x0bT.js";import{t as c}from"./check-BODqo66o.js";import{t as l}from"./circle-alert-RzVebuX2.js";import{t as u}from"./copy-to-clipboard-HOJ79TWv.js";import{t as d}from"./messages-Cb1VMeqP.js";import{n as f,o as p,r as m}from"./locale-store-CiM-D9jA.js";import{Aa as h,As as g,Ba as _,Bi as v,Ca as y,Cc as b,Da as x,Do as S,Ea as C,Fi as w,Fo as T,Hi as E,Ii as D,Io as O,Kc as k,Kl as A,La as j,Lc as M,Li as N,Ln as P,Ls as F,Mn as I,Mo as L,Na as R,Ni as z,No as B,Oa as ee,Oc as V,Pa as te,Pi as ne,Po as re,Ps as H,Qo as ie,Qs as ae,Ri as oe,Sa as se,Ta as ce,Tl as le,To as ue,Tr as de,Ui as fe,Ul as pe,Vi as me,Xc as he,Yo as U,Ys as ge,Zc as W,Zo as _e,Zs as ve,_a as ye,_o as be,a as xe,at as Se,ba as Ce,c as we,d as Te,da as Ee,do as De,f as Oe,fa as ke,fc as Ae,fo as je,go as Me,gt as Ne,h as Pe,ha as Fe,ho as Ie,i as Le,il as Re,ka as ze,kl as Be,lo as Ve,m as He,ma as Ue,mo as We,ms as Ge,mt as Ke,nc as qe,nl as Je,o as Ye,pa as Xe,pl as Ze,po as Qe,qc as $e,qs as et,rt as G,s as tt,sl as nt,tc as rt,tl as it,u as at,ui as ot,us as st,vr as ct,wa as lt,x as ut,xa as dt,xs as ft,ya as pt,yt as mt,z as ht,zi as gt,zs as _t}from"./index-BJGusbyV.js";import{t as vt}from"./notes-workbench-CCuL7qlg.js";import{t as yt}from"./page-tabs-CGVMJEW0.js";import{t as bt}from"./directory-picker-path-field-hZghTKie.js";import{t as xt}from"./goals-config-api-DQJ5mBXB.js";import{n as St,t as Ct}from"./goal-create-dialog-C_Qw_QgW.js";var K=n(),q=e(t(),1),J=r(),wt=`application/x-xopc-work-item`,Tt=[`backlog`,`todo`,`in_progress`,`blocked`,`needs_input`,`in_review`,`done`],Et=[`low`,`normal`,`high`,`urgent`];function Dt(e){return e===`done`||e===`in_review`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`blocked`||e===`needs_input`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`in_progress`?`bg-accent-soft text-accent-fg`:e===`backlog`||e===`todo`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:`bg-surface-muted text-fg-subtle`}function Ot(e){return e?new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(e)):``}function kt(e){return!Number.isFinite(e)||e<=0?`0 B`:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(+(e<10*1024))} KB`:`${(e/(1024*1024)).toFixed(+(e<10*1024*1024))} MB`}function At(e){return`${e.name}:${e.size}:${e.lastModified}`}function jt(e,t){return z(e,t)!==`unsupported`}function Mt(e,t){return e.startsWith(`image/`)?`image`:e.startsWith(`audio/`)?`audio`:t===`image`||t===`audio`||t===`video`?t:`document`}function Nt(e,t){return{id:e.id,name:e.fileName,type:Mt(e.mimeType,e.type),mimeType:e.mimeType,size:e.size,...t?{content:t,preview:e.mimeType.startsWith(`image/`)?t:void 0}:{}}}async function Pt(e,t){let n=w(e.name||`upload`,e.type||`application/octet-stream`),r=R(await e.arrayBuffer());return{id:t,name:e.name||`upload`,type:Mt(n),mimeType:n,size:e.size,content:r,preview:n.startsWith(`image/`)?r:void 0}}function Ft(e){let t=(0,K.c)(3),[n,r]=(0,q.useState)(``),i,a;return t[0]===e?(i=t[1],a=t[2]):(i=()=>{if(!e){r(``);return}let t=URL.createObjectURL(e);return r(t),()=>URL.revokeObjectURL(t)},a=[e],t[0]=e,t[1]=i,t[2]=a),(0,q.useEffect)(i,a),n}function It(e,t){let n=(0,K.c)(5),[r,i]=(0,q.useState)(``),a,o;return n[0]!==t.id||n[1]!==t.mimeType||n[2]!==e?(a=()=>{if(!e||!t.mimeType.startsWith(`image/`)){i(``);return}let n=!1,r=``;return(async()=>{let a=await m(Pe(e,t.id));if(!a.ok||n)return;let o=await a.blob();n||(r=URL.createObjectURL(o),i(r))})().catch(()=>{n||i(``)}),()=>{n=!0,r&&URL.revokeObjectURL(r)}},o=[t.id,t.mimeType,e],n[0]=t.id,n[1]=t.mimeType,n[2]=e,n[3]=a,n[4]=o):(a=n[3],o=n[4]),(0,q.useEffect)(a,o),r}function Lt(e){let t=(0,K.c)(11),{name:n,mimeType:r,thumbnailUrl:i,previewable:a,disabled:o,onOpen:s}=e,c;t[0]===r?c=t[1]:(c=r.startsWith(`image/`),t[0]=r,t[1]=c);let l=c,u;t[2]!==l||t[3]!==n||t[4]!==i?(u=l&&i?(0,J.jsx)(`img`,{src:i,alt:n,className:`size-10 rounded-md object-cover`}):(0,J.jsx)(`span`,{className:`inline-flex size-10 items-center justify-center rounded-md border border-edge bg-surface-muted`,children:(0,J.jsx)(W,{className:`size-4 text-fg-muted`,"aria-hidden":!0})}),t[2]=l,t[3]=n,t[4]=i,t[5]=u):u=t[5];let d=u;if(!a)return d;let f;return t[6]!==d||t[7]!==o||t[8]!==n||t[9]!==s?(f=(0,J.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel disabled:cursor-wait disabled:opacity-70`,title:n,"aria-label":n,disabled:o,onClick:s,children:d}),t[6]=d,t[7]=o,t[8]=n,t[9]=s,t[10]=f):f=t[10],f}function Rt(e){return e.kind===`chat`?`/chat/${encodeURIComponent(e.targetId)}`:e.kind===`goal`?`/goals/${encodeURIComponent(e.targetId)}`:e.kind===`workflow_run`?`/workflows?run=${encodeURIComponent(e.targetId)}`:e.kind===`automation`?`/automations?automationId=${encodeURIComponent(e.targetId)}`:`#`}function zt(e){return e instanceof Element?!!e.closest(`a,button,input,select,textarea,[contenteditable="true"],[draggable="true"],[data-board-pan-skip="true"]`):!0}function Bt(e,t){return e.nextAction||e.blockedReason||e.description||t.noNextAction}function Vt(e){let t=(0,K.c)(63),{item:n,dragging:r,onOpen:i,onToggleDone:o,onDragStart:c,onDragEnd:l,t:u}=e,d=n.status===`done`,f;t[0]!==n||t[1]!==c?(f=e=>c(n,e),t[0]=n,t[1]=c,t[2]=f):f=t[2];let p=u.dragToUpdate,m=r&&`opacity-50`,h;t[3]===m?h=t[4]:(h=s(`flex min-h-24 w-full min-w-0 max-w-full cursor-grab flex-col overflow-hidden rounded-lg bg-surface-panel px-3 py-3 shadow-surface transition-colors hover:bg-surface-hover active:cursor-grabbing`,m),t[3]=m,t[4]=h);let g=d?`border-success bg-success text-white`:`border-edge bg-surface-base hover:border-accent/50`,_;t[5]===g?_=t[6]:(_=s(`mt-0.5 inline-flex size-3.5 shrink-0 items-center justify-center rounded border transition-colors 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=d?u.markTodo:u.markDone,y=d?u.markTodo:u.markDone,b;t[7]!==n||t[8]!==o?(b=()=>o(n),t[7]=n,t[8]=o,t[9]=b):b=t[9];let x;t[10]===d?x=t[11]:(x=d?(0,J.jsx)(le,{className:`size-3`,"aria-hidden":!0}):null,t[10]=d,t[11]=x);let S;t[12]!==x||t[13]!==_||t[14]!==v||t[15]!==y||t[16]!==b?(S=(0,J.jsx)(`button`,{type:`button`,className:_,"aria-label":v,title:y,onClick:b,children:x}),t[12]=x,t[13]=_,t[14]=v,t[15]=y,t[16]=b,t[17]=S):S=t[17];let C;t[18]!==n||t[19]!==i?(C=()=>i(n),t[18]=n,t[19]=i,t[20]=C):C=t[20];let w;t[21]===n.title?w=t[22]:(w=(0,J.jsx)(`h4`,{className:`min-w-0 flex-1 basis-0 text-sm font-medium leading-5 text-fg line-clamp-2`,children:n.title}),t[21]=n.title,t[22]=w);let T;t[23]!==n||t[24]!==u?(T=Bt(n,u),t[23]=n,t[24]=u,t[25]=T):T=t[25];let E;t[26]===T?E=t[27]:(E=(0,J.jsx)(`p`,{className:`mt-2 max-w-full break-words text-xs leading-5 text-fg-muted line-clamp-1`,children:T}),t[26]=T,t[27]=E);let D;t[28]!==C||t[29]!==w||t[30]!==E?(D=(0,J.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 text-left`,onClick:C,children:[w,E]}),t[28]=C,t[29]=w,t[30]=E,t[31]=D):D=t[31];let O;t[32]!==S||t[33]!==D?(O=(0,J.jsxs)(`div`,{className:`flex min-w-0 max-w-full items-start gap-2`,children:[S,D]}),t[32]=S,t[33]=D,t[34]=O):O=t[34];let k;t[35]===n.status?k=t[36]:(k=s(`rounded-full px-2 py-0.5 text-[11px] font-medium`,Dt(n.status)),t[35]=n.status,t[36]=k);let A=u.statuses[n.status],j;t[37]!==k||t[38]!==A?(j=(0,J.jsx)(`span`,{className:k,children:A}),t[37]=k,t[38]=A,t[39]=j):j=t[39];let M=u.priorities[n.priority],N;t[40]===M?N=t[41]:(N=(0,J.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-[11px] text-fg-muted`,children:M}),t[40]=M,t[41]=N);let P;t[42]===n.attachments?P=t[43]:(P=n.attachments?.length?(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-surface-muted px-2 py-0.5 text-[11px] text-fg-muted`,children:[(0,J.jsx)(qe,{className:`size-3`,"aria-hidden":!0}),n.attachments.length]}):null,t[42]=n.attachments,t[43]=P);let F;t[44]===n.links?F=t[45]:(F=n.links?.length?(0,J.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-[11px] text-fg-muted`,children:n.links.length}):null,t[44]=n.links,t[45]=F);let I=`/work-items/${encodeURIComponent(n.id)}`,L;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,J.jsx)(it,{className:`size-3`,"aria-hidden":!0}),t[46]=L):L=t[46];let R;t[47]!==u.detail.openItem||t[48]!==I?(R=(0,J.jsxs)(a,{to:I,className:`ml-auto inline-flex shrink-0 items-center gap-1 rounded-full px-2 py-0.5 text-[11px] font-medium text-accent hover:bg-accent-soft hover:text-accent-fg`,children:[u.detail.openItem,L]}),t[47]=u.detail.openItem,t[48]=I,t[49]=R):R=t[49];let z;t[50]!==j||t[51]!==N||t[52]!==P||t[53]!==F||t[54]!==R?(z=(0,J.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:[j,N,P,F,R]}),t[50]=j,t[51]=N,t[52]=P,t[53]=F,t[54]=R,t[55]=z):z=t[55];let B;return t[56]!==l||t[57]!==u.dragToUpdate||t[58]!==f||t[59]!==O||t[60]!==z||t[61]!==h?(B=(0,J.jsxs)(`article`,{draggable:!0,onDragStart:f,onDragEnd:l,title:p,className:h,children:[O,z]}),t[56]=l,t[57]=u.dragToUpdate,t[58]=f,t[59]=O,t[60]=z,t[61]=h,t[62]=B):B=t[62],B}function Ht(){let e=(0,K.c)(3),t,n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`div`,{className:`size-3.5 shrink-0 rounded-full bg-surface-muted`}),(0,J.jsx)(`div`,{className:`h-3 w-36 rounded bg-surface-muted`})]}),n=(0,J.jsx)(`div`,{className:`mt-3 h-3 w-48 rounded bg-surface-muted`}),e[0]=t,e[1]=n):(t=e[0],n=e[1]);let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,J.jsxs)(`article`,{className:`flex h-24 w-full min-w-0 max-w-full flex-col overflow-hidden rounded-lg bg-surface-panel px-3 pt-3 pb-0 shadow-surface`,children:[t,n,(0,J.jsxs)(`div`,{className:`mt-3 flex gap-1.5`,children:[(0,J.jsx)(`div`,{className:`h-5 w-16 rounded-full bg-surface-muted`}),(0,J.jsx)(`div`,{className:`h-5 w-10 rounded-full bg-surface-muted`})]})]}),e[2]=r):r=e[2],r}function Ut(e){let t=(0,K.c)(44),{file:n,index:r,busy:i,previewBusy:a,t:o,onOpen:c,onRemove:l}=e,u,d,f,p;t[0]===n?(u=t[1],d=t[2],f=t[3],p=t[4]):(u=w(n.name||`upload`,n.type||`application/octet-stream`),d=jt(n.name||`upload`,u),f=Ft,p=u.startsWith(`image/`)?n:null,t[0]=n,t[1]=u,t[2]=d,t[3]=f,t[4]=p);let m=f(p),h=n.name||`upload`,g=i||a,_;t[5]!==n||t[6]!==c?(_=()=>c(n),t[5]=n,t[6]=c,t[7]=_):_=t[7];let v;t[8]!==u||t[9]!==d||t[10]!==h||t[11]!==g||t[12]!==_||t[13]!==m?(v=(0,J.jsx)(Lt,{name:h,mimeType:u,thumbnailUrl:m,previewable:d,disabled:g,onOpen:_}),t[8]=u,t[9]=d,t[10]=h,t[11]=g,t[12]=_,t[13]=m,t[14]=v):v=t[14];let y=d?`rounded-md hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`:`cursor-default`,b;t[15]===y?b=t[16]:(b=s(`min-w-0 flex-1 text-left`,y),t[15]=y,t[16]=b);let x=!d||i||a,S;t[17]!==n||t[18]!==c?(S=()=>c(n),t[17]=n,t[18]=c,t[19]=S):S=t[19];let C=n.name||`upload`,T;t[20]===C?T=t[21]:(T=(0,J.jsx)(`div`,{className:`truncate font-medium text-fg`,children:C}),t[20]=C,t[21]=T);let E;t[22]===n.size?E=t[23]:(E=kt(n.size),t[22]=n.size,t[23]=E);let D;t[24]===E?D=t[25]:(D=(0,J.jsx)(`div`,{className:`text-xs text-fg-subtle`,children:E}),t[24]=E,t[25]=D);let O;t[26]!==S||t[27]!==T||t[28]!==D||t[29]!==b||t[30]!==x?(O=(0,J.jsxs)(`button`,{type:`button`,className:b,disabled:x,onClick:S,children:[T,D]}),t[26]=S,t[27]=T,t[28]=D,t[29]=b,t[30]=x,t[31]=O):O=t[31];let k;t[32]!==r||t[33]!==l?(k=()=>l(r),t[32]=r,t[33]=l,t[34]=k):k=t[34];let A;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,J.jsx)(ie,{className:`size-3.5`,"aria-hidden":!0}),t[35]=A):A=t[35];let j;t[36]!==i||t[37]!==o.attachments.remove||t[38]!==k?(j=(0,J.jsx)(`button`,{type:`button`,className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,title:o.attachments.remove,"aria-label":o.attachments.remove,disabled:i,onClick:k,children:A}),t[36]=i,t[37]=o.attachments.remove,t[38]=k,t[39]=j):j=t[39];let M;return t[40]!==O||t[41]!==j||t[42]!==v?(M=(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 rounded-md border border-edge bg-surface-panel px-2 py-2 text-sm`,children:[v,O,j]}),t[40]=O,t[41]=j,t[42]=v,t[43]=M):M=t[43],M}function Wt(e){let t=(0,K.c)(56),{item:n,attachment:r,busy:i,previewBusy:a,t:o,onOpen:c,onDownload:l,onRemove:u}=e,d;t[0]!==r.fileName||t[1]!==r.mimeType?(d=jt(r.fileName,r.mimeType),t[0]=r.fileName,t[1]=r.mimeType,t[2]=d):d=t[2];let f=d,p=It(n.id,r),m=i||a,h;t[3]!==r||t[4]!==n||t[5]!==c?(h=()=>c(n,r),t[3]=r,t[4]=n,t[5]=c,t[6]=h):h=t[6];let g;t[7]!==r.fileName||t[8]!==r.mimeType||t[9]!==f||t[10]!==m||t[11]!==h||t[12]!==p?(g=(0,J.jsx)(Lt,{name:r.fileName,mimeType:r.mimeType,thumbnailUrl:p,previewable:f,disabled:m,onOpen:h}),t[7]=r.fileName,t[8]=r.mimeType,t[9]=f,t[10]=m,t[11]=h,t[12]=p,t[13]=g):g=t[13];let _=f?`rounded-md hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`:`cursor-default`,v;t[14]===_?v=t[15]:(v=s(`min-w-0 flex-1 text-left`,_),t[14]=_,t[15]=v);let y=!f||i||a,b;t[16]!==r||t[17]!==n||t[18]!==c?(b=()=>c(n,r),t[16]=r,t[17]=n,t[18]=c,t[19]=b):b=t[19];let x;t[20]===r.fileName?x=t[21]:(x=(0,J.jsx)(`div`,{className:`truncate font-medium text-fg`,children:r.fileName}),t[20]=r.fileName,t[21]=x);let S=r.mimeType,C;t[22]===r.size?C=t[23]:(C=kt(r.size),t[22]=r.size,t[23]=C);let w;t[24]!==r.mimeType||t[25]!==C?(w=(0,J.jsxs)(`div`,{className:`truncate text-xs text-fg-subtle`,children:[S,` · `,C]}),t[24]=r.mimeType,t[25]=C,t[26]=w):w=t[26];let T;t[27]!==w||t[28]!==v||t[29]!==y||t[30]!==b||t[31]!==x?(T=(0,J.jsxs)(`button`,{type:`button`,className:v,disabled:y,onClick:b,children:[x,w]}),t[27]=w,t[28]=v,t[29]=y,t[30]=b,t[31]=x,t[32]=T):T=t[32];let E;t[33]!==r||t[34]!==n||t[35]!==l?(E=()=>l(n,r),t[33]=r,t[34]=n,t[35]=l,t[36]=E):E=t[36];let D;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,J.jsx)(Re,{className:`size-3.5`,"aria-hidden":!0}),t[37]=D):D=t[37];let O;t[38]!==i||t[39]!==o.attachments.download||t[40]!==E?(O=(0,J.jsx)(`button`,{type:`button`,className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,title:o.attachments.download,"aria-label":o.attachments.download,disabled:i,onClick:E,children:D}),t[38]=i,t[39]=o.attachments.download,t[40]=E,t[41]=O):O=t[41];let k;t[42]!==r||t[43]!==n||t[44]!==u?(k=()=>u(n,r),t[42]=r,t[43]=n,t[44]=u,t[45]=k):k=t[45];let A;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,J.jsx)(st,{className:`size-3.5`,"aria-hidden":!0}),t[46]=A):A=t[46];let j;t[47]!==i||t[48]!==o.attachments.remove||t[49]!==k?(j=(0,J.jsx)(`button`,{type:`button`,className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-danger`,title:o.attachments.remove,"aria-label":o.attachments.remove,disabled:i,onClick:k,children:A}),t[47]=i,t[48]=o.attachments.remove,t[49]=k,t[50]=j):j=t[50];let M;return t[51]!==T||t[52]!==O||t[53]!==j||t[54]!==g?(M=(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 rounded-md border border-edge bg-surface-panel px-2 py-2 text-sm`,children:[g,T,O,j]}),t[51]=T,t[52]=O,t[53]=j,t[54]=g,t[55]=M):M=t[55],M}function Gt({mode:e,item:t,pendingFiles:n,busy:r,t:i,onPendingFilesChange:a,onUpload:o,onRemove:c,onDownload:l,onPreviewError:u}){let d=(0,q.useRef)(null),[f,h]=(0,q.useState)(!1),[g,_]=(0,q.useState)(!1),[v,y]=(0,q.useState)(null),[b,x]=(0,q.useState)(null),S=p(e=>e.token),C=t?.attachments??[];function w(r){if(!r.length)return;if(e===`detail`&&t){o(t,r);return}let i=new Set(n.map(At)),s=[...n];for(let e of r){let t=At(e);i.has(t)||(i.add(t),s.push(e))}a(s)}function T(e){a(n.filter((t,n)=>n!==e))}async function E(e){let t=At(e);x(`pending:${t}`);try{y(await Pt(e,`pending:${t}`)),_(!0)}catch(e){u(e instanceof Error?e.message:String(e))}finally{x(null)}}async function D(e,t){x(`saved:${t.id}`);try{let n=await m(Pe(e.id,t.id));if(!n.ok)throw Error(`HTTP ${n.status}`);y(Nt(t,R(await n.arrayBuffer()))),_(!0)}catch(e){u(e instanceof Error?e.message:String(e))}finally{x(null)}}return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`section`,{className:s(`grid gap-3 rounded-lg border border-edge bg-surface-base p-3`,f&&`border-accent bg-accent-soft/40`),onDragOver:e=>{e.preventDefault(),h(!0)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||h(!1)},onDrop:e=>{e.preventDefault(),h(!1),w(Array.from(e.dataTransfer.files))},children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,J.jsxs)(`h3`,{className:`inline-flex min-w-0 items-center gap-2 text-sm font-semibold text-fg`,children:[(0,J.jsx)(qe,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`truncate`,children:i.attachments.title})]}),(0,J.jsxs)(U,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:r,onClick:()=>d.current?.click(),children:[(0,J.jsx)(et,{className:`size-3.5`,"aria-hidden":!0}),i.attachments.add]}),(0,J.jsx)(`input`,{ref:d,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{w(Array.from(e.target.files??[])),e.currentTarget.value=``}})]}),n.length?(0,J.jsx)(`div`,{className:`grid gap-2`,children:n.map((e,t)=>(0,J.jsx)(Ut,{file:e,index:t,busy:r,previewBusy:b===`pending:${At(e)}`,t:i,onOpen:e=>void E(e),onRemove:T},At(e)))}):null,t&&C.length?(0,J.jsx)(`div`,{className:`grid gap-2`,children:C.map(e=>(0,J.jsx)(Wt,{item:t,attachment:e,busy:r,previewBusy:b===`saved:${e.id}`,t:i,onOpen:(e,t)=>void D(e,t),onDownload:l,onRemove:c},e.id))}):null,!n.length&&!C.length?(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:i.attachments.empty}):null]}),(0,J.jsx)(G,{open:g,attachment:v,authToken:S,layerClassName:`z-[100]`,onClose:()=>{_(!1),y(null)}})]})}function Kt(e){let t=(0,K.c)(170),{mode:n,item:r,initialStatus:i,events:o,busy:c,error:l,notice:u,t:d,onClose:f,onCreate:p,onSave:m,onStartChat:h,onCreateGoal:g,onAddAttachments:_,onRemoveAttachment:v,onDownloadAttachment:y,onPreviewError:b}=e,x=n!==null,[C,w]=(0,q.useState)(``),[T,E]=(0,q.useState)(``),[D,O]=(0,q.useState)(`todo`),[k,A]=(0,q.useState)(`normal`),[j,M]=(0,q.useState)(``),[N,P]=(0,q.useState)(``),F;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(F=[],t[0]=F):F=t[0];let[I,L]=(0,q.useState)(F),R,z;t[1]!==i||t[2]!==r||t[3]!==n?(R=()=>{if(n===`create`){w(``),E(``),O(i),A(`normal`),M(``),P(``),L([]);return}n===`detail`&&r&&(w(r.title),E(r.description??``),O(r.status),A(r.priority),M(r.nextAction??``),P(r.blockedReason??``),L([]))},z=[i,r,n],t[1]=i,t[2]=r,t[3]=n,t[4]=R,t[5]=z):(R=t[4],z=t[5]),(0,q.useEffect)(R,z);let B;t[6]!==N||t[7]!==T||t[8]!==r||t[9]!==n||t[10]!==j||t[11]!==p||t[12]!==m||t[13]!==I||t[14]!==k||t[15]!==D||t[16]!==C?(B=function(e){e.preventDefault();let t=C.trim();if(t){if(n===`create`){p({title:t,description:T.trim()||void 0,priority:k,status:D,nextAction:j.trim()||void 0,blockedReason:N.trim()||void 0,attachments:I});return}r&&m(r,{title:t,description:T.trim()||null,status:D,priority:k,nextAction:j.trim()||null,blockedReason:N.trim()||null})}},t[6]=N,t[7]=T,t[8]=r,t[9]=n,t[10]=j,t[11]=p,t[12]=m,t[13]=I,t[14]=k,t[15]=D,t[16]=C,t[17]=B):B=t[17];let ee=B,V;t[18]===f?V=t[19]:(V=e=>!e&&f(),t[18]=f,t[19]=V);let te;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,J.jsx)(Ie,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),t[20]=te):te=t[20];let ne=n===`create`?d.create.title:r?.title||d.title,re;t[21]===ne?re=t[22]:(re=(0,J.jsx)(be,{className:`truncate text-base font-semibold text-fg`,children:ne}),t[21]=ne,t[22]=re);let H;t[23]===d.detail.description?H=t[24]:(H=(0,J.jsx)(We,{className:`mt-1 text-sm text-fg-muted`,children:d.detail.description}),t[23]=d.detail.description,t[24]=H);let ae;t[25]!==re||t[26]!==H?(ae=(0,J.jsxs)(`div`,{className:`min-w-0`,children:[re,H]}),t[25]=re,t[26]=H,t[27]=ae):ae=t[27];let oe;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,J.jsx)(ie,{className:`size-4`,"aria-hidden":!0}),t[28]=oe):oe=t[28];let se;t[29]===c?se=t[30]:(se=(0,J.jsx)(je,{asChild:!0,children:(0,J.jsx)(`button`,{type:`button`,className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,disabled:c,children:oe})}),t[29]=c,t[30]=se);let ce;t[31]!==ae||t[32]!==se?(ce=(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[ae,se]}),t[31]=ae,t[32]=se,t[33]=ce):ce=t[33];let de;t[34]===l?de=t[35]:(de=l?(0,J.jsx)(`div`,{className:`rounded-lg border border-danger/30 bg-danger-soft px-3 py-2 text-sm text-danger`,children:l}):null,t[34]=l,t[35]=de);let fe;t[36]!==l||t[37]!==u?(fe=!l&&u?(0,J.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-success/30 bg-success-soft px-3 py-2 text-sm text-fg`,role:`status`,"aria-live":`polite`,children:[(0,J.jsx)(le,{className:`mt-0.5 size-4 shrink-0 text-success`,"aria-hidden":!0}),(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`div`,{className:`font-medium text-success`,children:u.title}),(0,J.jsx)(`div`,{className:`mt-1 text-fg-muted`,children:u.message})]})]}):null,t[36]=l,t[37]=u,t[38]=fe):fe=t[38];let pe;t[39]===d.create.titleLabel?pe=t[40]:(pe=(0,J.jsx)(`span`,{className:`font-medium text-fg-muted`,children:d.create.titleLabel}),t[39]=d.create.titleLabel,t[40]=pe);let me;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(me=e=>w(e.target.value),t[41]=me):me=t[41];let he=n===`create`,ge;t[42]!==he||t[43]!==C?(ge=(0,J.jsx)(`input`,{className:`h-10 rounded-lg border border-edge bg-surface-base px-3 text-sm text-fg outline-none focus:border-accent`,value:C,onChange:me,autoFocus:he}),t[42]=he,t[43]=C,t[44]=ge):ge=t[44];let W;t[45]!==pe||t[46]!==ge?(W=(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[pe,ge]}),t[45]=pe,t[46]=ge,t[47]=W):W=t[47];let _e;t[48]===d.detail.status?_e=t[49]:(_e=(0,J.jsx)(`span`,{className:`font-medium text-fg-muted`,children:d.detail.status}),t[48]=d.detail.status,t[49]=_e);let ve;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(ve=e=>O(e.target.value),t[50]=ve):ve=t[50];let ye;t[51]===d.statuses?ye=t[52]:(ye=Tt.map(e=>(0,J.jsx)(S,{value:e,children:d.statuses[e]},e)),t[51]=d.statuses,t[52]=ye);let xe;t[53]!==D||t[54]!==ye?(xe=(0,J.jsx)(ue,{className:`h-10 rounded-lg border border-edge bg-surface-base px-3 text-sm text-fg outline-none focus:border-accent`,value:D,onChange:ve,children:ye}),t[53]=D,t[54]=ye,t[55]=xe):xe=t[55];let Se;t[56]!==_e||t[57]!==xe?(Se=(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[_e,xe]}),t[56]=_e,t[57]=xe,t[58]=Se):Se=t[58];let Ce;t[59]===d.create.priorityLabel?Ce=t[60]:(Ce=(0,J.jsx)(`span`,{className:`font-medium text-fg-muted`,children:d.create.priorityLabel}),t[59]=d.create.priorityLabel,t[60]=Ce);let we;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(we=e=>A(e.target.value),t[61]=we):we=t[61];let Te;t[62]===d.priorities?Te=t[63]:(Te=Et.map(e=>(0,J.jsx)(S,{value:e,children:d.priorities[e]},e)),t[62]=d.priorities,t[63]=Te);let Ee;t[64]!==k||t[65]!==Te?(Ee=(0,J.jsx)(ue,{className:`h-10 rounded-lg border border-edge bg-surface-base px-3 text-sm text-fg outline-none focus:border-accent`,value:k,onChange:we,children:Te}),t[64]=k,t[65]=Te,t[66]=Ee):Ee=t[66];let Oe;t[67]!==Ce||t[68]!==Ee?(Oe=(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[Ce,Ee]}),t[67]=Ce,t[68]=Ee,t[69]=Oe):Oe=t[69];let ke;t[70]!==Se||t[71]!==Oe?(ke=(0,J.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[Se,Oe]}),t[70]=Se,t[71]=Oe,t[72]=ke):ke=t[72];let Ne;t[73]===d.create.descriptionLabel?Ne=t[74]:(Ne=(0,J.jsx)(`span`,{className:`font-medium text-fg-muted`,children:d.create.descriptionLabel}),t[73]=d.create.descriptionLabel,t[74]=Ne);let Pe;t[75]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=e=>E(e.target.value),t[75]=Pe):Pe=t[75];let Fe;t[76]===T?Fe=t[77]:(Fe=(0,J.jsx)(`textarea`,{className:`min-h-28 rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none focus:border-accent`,value:T,onChange:Pe}),t[76]=T,t[77]=Fe);let Le;t[78]!==Ne||t[79]!==Fe?(Le=(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[Ne,Fe]}),t[78]=Ne,t[79]=Fe,t[80]=Le):Le=t[80];let Re;t[81]!==c||t[82]!==r||t[83]!==n||t[84]!==_||t[85]!==y||t[86]!==b||t[87]!==v||t[88]!==I||t[89]!==d?(Re=(0,J.jsx)(Gt,{mode:n,item:r,pendingFiles:I,busy:c,t:d,onPendingFilesChange:L,onUpload:_,onRemove:v,onDownload:y,onPreviewError:b}),t[81]=c,t[82]=r,t[83]=n,t[84]=_,t[85]=y,t[86]=b,t[87]=v,t[88]=I,t[89]=d,t[90]=Re):Re=t[90];let ze;t[91]!==N||t[92]!==n||t[93]!==j||t[94]!==D||t[95]!==d.blockedReason||t[96]!==d.nextAction?(ze=n===`detail`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,J.jsx)(`span`,{className:`font-medium text-fg-muted`,children:d.nextAction}),(0,J.jsx)(`textarea`,{className:`min-h-20 rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none focus:border-accent`,value:j,onChange:e=>M(e.target.value)})]}),(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,J.jsx)(`span`,{className:s(`font-medium`,D===`blocked`||D===`needs_input`?`text-red-700 dark:text-red-300`:`text-fg-muted`),children:d.blockedReason}),(0,J.jsx)(`textarea`,{className:s(`min-h-20 rounded-lg border bg-surface-base px-3 py-2 text-sm text-fg outline-none focus:border-accent`,D===`blocked`||D===`needs_input`?`border-red-500/40`:`border-edge`),value:N,onChange:e=>P(e.target.value)})]})]}):null,t[91]=N,t[92]=n,t[93]=j,t[94]=D,t[95]=d.blockedReason,t[96]=d.nextAction,t[97]=ze):ze=t[97];let Be;t[98]!==de||t[99]!==fe||t[100]!==W||t[101]!==ke||t[102]!==Le||t[103]!==Re||t[104]!==ze?(Be=(0,J.jsxs)(`div`,{className:`grid content-start gap-4`,children:[de,fe,W,ke,Le,Re,ze]}),t[98]=de,t[99]=fe,t[100]=W,t[101]=ke,t[102]=Le,t[103]=Re,t[104]=ze,t[105]=Be):Be=t[105];let Ve;t[106]!==c||t[107]!==r||t[108]!==n||t[109]!==g||t[110]!==h||t[111]!==d.detail.actions||t[112]!==d.detail.createGoal||t[113]!==d.detail.openItem||t[114]!==d.detail.startChat?(Ve=n===`detail`&&r?(0,J.jsxs)(`section`,{children:[(0,J.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:d.detail.actions}),(0,J.jsxs)(`div`,{className:`mt-2 grid gap-2`,children:[(0,J.jsxs)(U,{type:`button`,variant:`secondary`,className:`justify-start rounded-lg`,disabled:c,onClick:()=>h(r),children:[(0,J.jsx)(Ae,{className:`size-4`,"aria-hidden":!0}),d.detail.startChat]}),(0,J.jsxs)(U,{type:`button`,variant:`secondary`,className:`justify-start rounded-lg`,disabled:c,onClick:()=>g(r),children:[(0,J.jsx)(Ge,{className:`size-4`,"aria-hidden":!0}),d.detail.createGoal]}),(0,J.jsx)(U,{asChild:!0,variant:`secondary`,className:`justify-start rounded-lg`,children:(0,J.jsxs)(a,{to:`/work-items/${encodeURIComponent(r.id)}`,children:[(0,J.jsx)(it,{className:`size-4`,"aria-hidden":!0}),d.detail.openItem]})})]})]}):null,t[106]=c,t[107]=r,t[108]=n,t[109]=g,t[110]=h,t[111]=d.detail.actions,t[112]=d.detail.createGoal,t[113]=d.detail.openItem,t[114]=d.detail.startChat,t[115]=Ve):Ve=t[115];let He;t[116]===d.detail.links?He=t[117]:(He=(0,J.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:d.detail.links}),t[116]=d.detail.links,t[117]=He);let Ue;t[118]!==r||t[119]!==d.detail.noLinks||t[120]!==d.linkKinds?(Ue=r?.links?.length?r.links.slice(0,6).map(e=>(0,J.jsxs)(a,{to:Rt(e),className:`flex min-w-0 items-center justify-between gap-3 rounded-md px-2 py-1.5 hover:bg-surface-hover`,children:[(0,J.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.title||e.targetId}),(0,J.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs text-fg-muted`,children:[d.linkKinds[e.kind],(0,J.jsx)(it,{className:`size-3.5`,"aria-hidden":!0})]})]},e.id)):(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:d.detail.noLinks}),t[118]=r,t[119]=d.detail.noLinks,t[120]=d.linkKinds,t[121]=Ue):Ue=t[121];let Ke;t[122]===Ue?Ke=t[123]:(Ke=(0,J.jsx)(`div`,{className:`mt-2 grid gap-2 text-sm`,children:Ue}),t[122]=Ue,t[123]=Ke);let qe;t[124]!==He||t[125]!==Ke?(qe=(0,J.jsxs)(`section`,{children:[He,Ke]}),t[124]=He,t[125]=Ke,t[126]=qe):qe=t[126];let Je;t[127]===d.detail.activity?Je=t[128]:(Je=(0,J.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:d.detail.activity}),t[127]=d.detail.activity,t[128]=Je);let Ye;t[129]!==o||t[130]!==d.detail.noActivity||t[131]!==d.eventTypes?(Ye=o.length?o.slice(0,5).map(e=>(0,J.jsxs)(`div`,{className:`text-sm`,children:[(0,J.jsx)(`div`,{className:`font-medium text-fg`,children:d.eventTypes[e.type]??e.type}),(0,J.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-subtle`,children:Ot(e.createdAt)})]},e.id)):(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:d.detail.noActivity}),t[129]=o,t[130]=d.detail.noActivity,t[131]=d.eventTypes,t[132]=Ye):Ye=t[132];let Xe;t[133]===Ye?Xe=t[134]:(Xe=(0,J.jsx)(`div`,{className:`mt-2 grid gap-2`,children:Ye}),t[133]=Ye,t[134]=Xe);let Ze;t[135]!==Je||t[136]!==Xe?(Ze=(0,J.jsxs)(`section`,{children:[Je,Xe]}),t[135]=Je,t[136]=Xe,t[137]=Ze):Ze=t[137];let $e;t[138]!==Ve||t[139]!==qe||t[140]!==Ze?($e=(0,J.jsxs)(`aside`,{className:`grid content-start gap-5`,children:[Ve,qe,Ze]}),t[138]=Ve,t[139]=qe,t[140]=Ze,t[141]=$e):$e=t[141];let G;t[142]!==Be||t[143]!==$e?(G=(0,J.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-6 overflow-y-auto px-5 py-4 lg:grid-cols-[minmax(0,1fr)_16rem]`,children:[Be,$e]}),t[142]=Be,t[143]=$e,t[144]=G):G=t[144];let tt;t[145]!==c||t[146]!==f||t[147]!==d.create.cancel?(tt=(0,J.jsx)(U,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:f,disabled:c,children:d.create.cancel}),t[145]=c,t[146]=f,t[147]=d.create.cancel,t[148]=tt):tt=t[148];let nt;t[149]!==c||t[150]!==C?(nt=c||!C.trim(),t[149]=c,t[150]=C,t[151]=nt):nt=t[151];let rt;t[152]===n?rt=t[153]:(rt=n===`create`?(0,J.jsx)(et,{className:`size-4`,"aria-hidden":!0}):null,t[152]=n,t[153]=rt);let at=n===`create`?d.create.submit:d.detail.save,ot;t[154]!==nt||t[155]!==rt||t[156]!==at?(ot=(0,J.jsxs)(U,{type:`submit`,variant:`primary`,className:`rounded-lg`,disabled:nt,children:[rt,at]}),t[154]=nt,t[155]=rt,t[156]=at,t[157]=ot):ot=t[157];let st;t[158]!==tt||t[159]!==ot?(st=(0,J.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[tt,ot]}),t[158]=tt,t[159]=ot,t[160]=st):st=t[160];let ct;t[161]!==ee||t[162]!==ce||t[163]!==G||t[164]!==st?(ct=(0,J.jsxs)(Me,{children:[te,(0,J.jsx)(Qe,{className:`fixed left-1/2 top-1/2 z-[90] flex h-[min(86dvh,48rem)] w-[min(60rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:(0,J.jsxs)(`form`,{onSubmit:ee,className:`flex min-h-0 flex-1 flex-col`,children:[ce,G,st]})})]}),t[161]=ee,t[162]=ce,t[163]=G,t[164]=st,t[165]=ct):ct=t[165];let lt;return t[166]!==x||t[167]!==V||t[168]!==ct?(lt=(0,J.jsx)(De,{open:x,onOpenChange:V,children:ct}),t[166]=x,t[167]=V,t[168]=ct,t[169]=lt):lt=t[169],lt}function qt({projectId:e,createRequestKey:t=0}){let n=i(),r=d(f(e=>e.language)).projectDetailPage.workItems,a=(0,q.useRef)(null),o=(0,q.useRef)(null),[c,l]=(0,q.useState)([]),[u,p]=(0,q.useState)(!0),[m,h]=(0,q.useState)(null),[g,_]=(0,q.useState)(null),[v,y]=(0,q.useState)(!1),[b,x]=(0,q.useState)(null),[S,C]=(0,q.useState)(null),[w,T]=(0,q.useState)(!1),[E,D]=(0,q.useState)(!1),[O,k]=(0,q.useState)(!1),[A,j]=(0,q.useState)(`todo`),[M,N]=(0,q.useState)(null),[P,F]=(0,q.useState)([]),I=(0,q.useCallback)(async(t=`replace`,n=0)=>{p(!0),h(null);try{let r=await we(e,{limit:100,offset:n});l(e=>t===`append`?[...e,...r.items]:r.items),D(r.hasMore)}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(!1)}},[e]);(0,q.useEffect)(()=>{I(`replace`,0)},[I]),(0,q.useEffect)(()=>{t&&(N(null),F([]),h(null),_(null),j(`todo`),k(!0))},[t]);let L=(0,q.useMemo)(()=>Tt.map(e=>({status:e,title:r.statuses[e],items:c.filter(t=>t.status===e)})),[c,r.statuses]),R=(0,q.useCallback)(e=>{l(t=>t.map(t=>t.id===e.id?e:t)),N(t=>t?.id===e.id?e:t)},[]),z=(0,q.useCallback)(async(e,t)=>{y(!0),h(null),_(null);try{let n=await Te(e.id,t);n.item.archivedAt?(l(e=>e.filter(e=>e.id!==n.item.id)),N(null)):(R(n.item),_({title:r.feedback.savedTitle,message:r.feedback.savedNext}))}catch(e){h(e instanceof Error?e.message:String(e))}finally{y(!1)}},[r.feedback.savedNext,r.feedback.savedTitle,R]),B=(0,q.useCallback)(async e=>{N(e),F([]),h(null),_(null);let t=await at(e.id).catch(()=>null);t&&F(t.events)},[]),ee=(0,q.useCallback)(async t=>{y(!0),h(null),_(null);try{let n=await Le(e,t);l(e=>[n.item,...e]),k(!1),N(n.item),F((await at(n.item.id).catch(()=>({events:[]}))).events),_({title:r.feedback.createdTitle,message:r.feedback.createdNext})}catch(e){h(e instanceof Error?e.message:String(e))}finally{y(!1)}},[e,r.feedback.createdNext,r.feedback.createdTitle]),V=(0,q.useCallback)(async(e,t)=>{if(t.length){y(!0),h(null),_(null);try{let n=await He(e.id,t);R(n.item),F((await at(n.item.id).catch(()=>({events:[]}))).events)}catch(e){h(e instanceof Error?e.message:String(e))}finally{y(!1)}}},[R]),te=(0,q.useCallback)(async(e,t)=>{y(!0),h(null),_(null);try{let n=await Ye(e.id,t.id);R(n.item),F((await at(n.item.id).catch(()=>({events:[]}))).events)}catch(e){h(e instanceof Error?e.message:String(e))}finally{y(!1)}},[R]),ne=(0,q.useCallback)(async(e,t)=>{h(null),_(null);try{await tt(e.id,t)}catch(e){h(e instanceof Error?e.message:String(e))}},[]),re=(0,q.useCallback)(async e=>{y(!0),h(null),_(null);try{let t=await Oe(e.id);R(t.item),await B(t.item),n(`/chat/${encodeURIComponent(t.session.key)}`)}catch(e){h(e instanceof Error?e.message:String(e))}finally{y(!1)}},[n,B,R]),H=(0,q.useCallback)(async e=>{y(!0),h(null),_(null);try{let t=await xe(e.id);R(t.item),await B(t.item),n(`/goals/${encodeURIComponent(t.goal.id)}`)}catch(e){h(e instanceof Error?e.message:String(e))}finally{y(!1)}},[n,B,R]),ie=(0,q.useCallback)((e,t)=>{t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(wt,e.id),x(e.id)},[]),ae=(0,q.useCallback)((e,t)=>{t.preventDefault();let n=t.dataTransfer.getData(wt)||b;C(null),x(null);let r=c.find(e=>e.id===n);!r||r.status===e||z(r,{status:e})},[b,c,z]),oe=(0,q.useCallback)(e=>{z(e,{status:e.status===`done`?`todo`:`done`})},[z]),se=(0,q.useCallback)(e=>{N(null),F([]),h(null),_(null),j(e),k(!0)},[]),ce=(0,q.useCallback)(e=>{let t=o.current;!t||t.pointerId!==e.pointerId||(o.current=null,T(!1),e.currentTarget.hasPointerCapture?.(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))},[]),le=(0,q.useCallback)(e=>{if(e.button!==0||b||zt(e.target))return;let t=a.current;t&&(o.current={pointerId:e.pointerId,startX:e.clientX,scrollLeft:t.scrollLeft,active:!1},e.currentTarget.setPointerCapture(e.pointerId))},[b]),ue=(0,q.useCallback)(e=>{let t=o.current,n=a.current;if(!t||!n||t.pointerId!==e.pointerId)return;let r=e.clientX-t.startX;!t.active&&Math.abs(r)<5||(t.active||(t.active=!0,T(!0)),e.preventDefault(),n.scrollLeft=t.scrollLeft-r)},[]);return(0,J.jsxs)(`section`,{id:`project-panel-work-items`,role:`tabpanel`,"aria-labelledby":`project-tab-work-items`,className:`flex h-full min-h-0 flex-col`,children:[m?(0,J.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-4 py-3 text-sm text-red-700 dark:text-red-300`,children:m}):null,(0,J.jsx)(`section`,{ref:a,className:s(`min-h-0 flex-1 overflow-x-auto rounded-lg px-2 py-2 transition-opacity`,u&&`opacity-60`,w?`cursor-grabbing select-none`:`cursor-grab`),"aria-label":r.boardAria,"aria-busy":u,onPointerDown:le,onPointerMove:ue,onPointerUp:ce,onPointerCancel:ce,onLostPointerCapture:e=>{o.current?.pointerId===e.pointerId&&(o.current=null,T(!1))},children:(0,J.jsx)(`div`,{className:`flex min-h-full min-w-max items-start gap-3 pr-4`,children:L.map(e=>(0,J.jsxs)(`section`,{className:s(`flex max-h-full w-72 min-w-72 max-w-72 shrink-0 flex-col overflow-y-auto rounded-lg bg-surface-base shadow-surface`,S===e.status&&`bg-surface-active`),"aria-label":e.title,onDragOver:t=>{b&&(t.preventDefault(),t.dataTransfer.dropEffect=`move`,C(e.status))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||C(null)},onDrop:t=>ae(e.status,t),children:[(0,J.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-2 px-3 py-3`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,J.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.title}),(0,J.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:e.items.length})]}),(0,J.jsx)(Je,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0})]}),(0,J.jsxs)(`div`,{className:`mx-2 mt-3 grid min-h-0 min-w-0 content-start gap-2 pb-2 pr-1 [scrollbar-gutter:stable]`,children:[e.items.length?e.items.map(e=>(0,J.jsx)(Vt,{item:e,dragging:b===e.id,onOpen:B,onToggleDone:oe,onDragStart:ie,onDragEnd:()=>{x(null),C(null)},t:r},e.id)):u?(0,J.jsxs)(`div`,{className:`grid gap-2 animate-pulse motion-reduce:animate-none`,children:[(0,J.jsx)(Ht,{}),(0,J.jsx)(Ht,{})]}):(0,J.jsx)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-6 text-center text-xs text-fg-subtle`,children:r.emptyColumn}),u?null:(0,J.jsx)(`button`,{type:`button`,className:`inline-flex h-8 w-full items-center justify-center rounded-lg bg-surface-panel/85 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-muted`,"aria-label":r.create.addToColumn.replace(`{{status}}`,e.title),title:r.create.addToColumn.replace(`{{status}}`,e.title),onClick:()=>se(e.status),children:(0,J.jsx)(et,{className:`size-4`,"aria-hidden":!0})})]})]},e.status))})}),!u&&E?(0,J.jsx)(U,{type:`button`,variant:`secondary`,className:`justify-self-center`,onClick:()=>void I(`append`,c.length),children:r.loadMore}):null,(0,J.jsx)(Kt,{mode:O?`create`:M?`detail`:null,item:M,initialStatus:A,events:P,busy:v,error:m,notice:g,t:r,onClose:()=>{k(!1),N(null),F([]),h(null),_(null)},onCreate:ee,onSave:(e,t)=>void z(e,t),onStartChat:re,onCreateGoal:H,onAddAttachments:(e,t)=>void V(e,t),onRemoveAttachment:(e,t)=>void te(e,t),onDownloadAttachment:(e,t)=>void ne(e,t),onPreviewError:e=>{_(null),h(e)}})]})}var Jt=[{id:`overview`,icon:V},{id:`work-items`,icon:b},{id:`sessions`,icon:Ae},{id:`goals`,icon:Ge},{id:`workflows`,icon:ge},{id:`files`,icon:k},{id:`activity`,icon:M},{id:`automations`,icon:_e},{id:`notes`,icon:he},{id:`settings`,icon:g}],Yt=new Set(Jt.map(e=>e.id)),Xt=`xopc.projectFiles.panelWidthPx`,Zt=320,Qt=220,$t=560;function en(e){return Math.min($t,Math.max(Qt,Math.round(e)))}function tn(){try{let e=window.localStorage.getItem(Xt);if(e==null)return Zt;let t=Number.parseInt(e,10);return Number.isFinite(t)?en(t):Zt}catch{return Zt}}function nn(e){try{window.localStorage.setItem(Xt,String(en(e)))}catch{}}function rn(e){return!!(e&&Yt.has(e))}function an(e){return e===`overview`?`overview`:e===`work-items`||e===`goals`||e===`workflows`||e===`automations`?`work`:`context`}function on(e){return e===`work`?`work-items`:e===`context`?`files`:`overview`}function sn(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function cn(e,t=``){if(!e)return t;let n=new Date(e);return Number.isNaN(n.getTime())?String(e):new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(n)}function ln(e){return e===`active`?`bg-accent-soft text-accent-fg`:e===`done`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`paused`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`archived`?`bg-surface-muted text-fg-subtle`:`bg-surface-hover text-fg-muted`}function un(e){return e===`succeeded`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`failed`||e===`timeout`||e===`cancelled`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`running`||e===`queued`?`bg-accent-soft text-accent-fg`:`bg-surface-hover text-fg-muted`}function dn(e){let t=(0,K.c)(8),{label:n,hint:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,J.jsx)(`span`,{className:`font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=r?(0,J.jsx)(`span`,{className:`text-xs leading-5 text-fg-subtle`,children:r}):null,t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function fn(e=!1){return s(`w-full rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none focus:border-accent`,e?`min-h-24 py-2 leading-5`:`min-h-10`)}function pn(e){let t=(0,K.c)(10),{label:n,value:r,mono:i}=e,a=i===void 0?!1:i,o;t[0]===n?o=t[1]:(o=(0,J.jsx)(`div`,{className:`text-xs font-medium text-fg-subtle`,children:n}),t[0]=n,t[1]=o);let c=a&&`font-mono text-xs`,l;t[2]===c?l=t[3]:(l=s(`mt-1 min-w-0 truncate text-sm text-fg`,c),t[2]=c,t[3]=l);let u;t[4]!==l||t[5]!==r?(u=(0,J.jsx)(`div`,{className:l,title:r,children:r}),t[4]=l,t[5]=r,t[6]=u):u=t[6];let d;return t[7]!==o||t[8]!==u?(d=(0,J.jsxs)(`div`,{className:`min-w-0 rounded-md bg-surface-base px-3 py-2`,children:[o,u]}),t[7]=o,t[8]=u,t[9]=d):d=t[9],d}function mn(e){return[e.name,e.slug,e.workspaceRoot,e.description,e.brief].filter(Boolean).join(` `).toLowerCase()}function hn(e){let t=e.lastActiveAt??e.updatedAt??e.createdAt,n=t?new Date(t).getTime():0;return Number.isFinite(n)?n:0}function gn(e){return e.trim().replace(/[\\/]+$/,``).split(/[\\/]/).filter(Boolean).pop()??``}function _n(e){let t=e?.body;return t?.code===`workspace_root_missing`&&t.workspaceRoot?t.workspaceRoot:null}function vn(e){let t=e.actor;return t.name?t.name:t.agentId?t.agentId:t.id?t.id:t.sessionKey?t.sessionKey:t.kind}function yn(e){return e.primaryObject.title?.trim()||e.primaryObject.id}function bn(e){let t=e.source;return t.toolCallId?`${t.kind} · ${t.toolCallId}`:t.runId?`${t.kind} · ${t.runId}`:t.requestId?`${t.kind} · ${t.requestId}`:t.kind}function xn(e){let t=e.sourceChannel?.trim();if(t)return Sn(t);let n=e.key.split(`:`).filter(Boolean),r=(n[0]?.toLowerCase()===`agent`?n.slice(2).join(`:`):e.key).split(`:`)[0]?.split(/[-_]/)[0]?.trim();return Sn(r||``)}function Sn(e){let t=e.trim().toLowerCase();return t?t===`tui`?`TUI`:t===`acp`?`ACP`:t===`webchat`?`Webchat`:t:``}function Cn(e){let t=e.payload.changes;if(Array.isArray(t)&&t.length)return t.filter(e=>typeof e==`string`).join(`, `);let n=e.payload.contentPreview;if(typeof n==`string`&&n.trim())return n.trim();let r=e.payload.title??e.payload.name;return typeof r==`string`&&r.trim()?r.trim():``}function wn(e){return e.map(e=>({name:e.name,path:e.path,absolutePath:e.absolutePath,isDirectory:e.type===`directory`,children:e.type===`directory`?[]:void 0}))}function Tn(e,t,n){return e.map(e=>e.path===t?{...e,children:n}:e.isDirectory&&e.children?.length?{...e,children:Tn(e.children,t,n)}:e)}function En({currentProject:e,pm:t,projectsText:n,wd:r}){let a=i(),[o,l]=(0,q.useState)(!1),[u,d]=(0,q.useState)([e]),[f,p]=(0,q.useState)(``),[m,h]=(0,q.useState)(!1),[_,v]=(0,q.useState)(null),[y,b]=(0,q.useState)(!1),[x,S]=(0,q.useState)(`new`),[C,w]=(0,q.useState)(``),[E,D]=(0,q.useState)(``),[A,j]=(0,q.useState)(!1),[M,N]=(0,q.useState)(null),[P,F]=(0,q.useState)(null),I=(0,q.useCallback)(async()=>{h(!0),v(null);try{let t=await lt({limit:100});d(n=>{let r=new Map;r.set(e.id,e);for(let e of n)r.set(e.id,e);for(let e of t.items)r.set(e.id,e);return Array.from(r.values())})}catch(e){v(e instanceof Error?e.message:String(e))}finally{h(!1)}},[e]);(0,q.useEffect)(()=>{d(t=>[e,...t.filter(t=>t.id!==e.id)])},[e]),(0,q.useEffect)(()=>{o&&I()},[I,o]);let L=(0,q.useMemo)(()=>{let t=f.trim().toLowerCase().split(/\s+/).filter(Boolean);return u.filter(t=>t.id!==e.id).filter(e=>{if(t.length===0)return!0;let n=mn(e);return t.every(e=>n.includes(e))}).sort((e,t)=>hn(t)-hn(e))},[e.id,u,f]),R=e=>t.statuses[e.status]??e.status,z=e=>e.workspaceRoot||e.effectiveWorkspaceRoot||e.description||e.brief||t.common.defaultWorkspace,ee=e=>{S(e),w(``),D(``),N(null),b(!0),l(!1)},V=(0,q.useCallback)(async(e={})=>{let t=E.trim(),n=C.trim()||(x===`directory`?gn(t):``);if(n){j(!0),N(null),F(null);try{let r=await ke({name:n,...t?{workspaceRoot:t}:{},...e.createWorkspaceRoot?{createWorkspaceRoot:!0}:{}});b(!1),w(``),D(``),d(e=>[r,...e.filter(e=>e.id!==r.id)]),a(`/projects/${encodeURIComponent(r.id)}`)}catch(e){let t=_n(e);t?(F(t),b(!1)):N(e instanceof Error?e.message:String(e))}finally{j(!1)}}},[x,C,a,E]),te=(0,q.useCallback)(e=>{e.preventDefault(),V()},[V]),ne=(0,q.useCallback)(()=>{V({createWorkspaceRoot:!0})},[V]),ie=(0,q.useCallback)(()=>{F(null),b(!0)},[]),ae=e=>{D(e),x===`directory`&&!C.trim()&&w(gn(e))},oe=(e,t)=>(0,J.jsxs)(`button`,{type:`button`,className:s(`grid w-full grid-cols-[1rem_minmax(0,1fr)_auto] items-center gap-2 rounded-md px-2 py-2 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,t&&`bg-accent-soft/55 hover:bg-accent-soft/70`),onClick:()=>{l(!1),t||a(`/projects/${encodeURIComponent(e.id)}`)},children:[(0,J.jsx)(c,{className:s(`size-4 text-accent-fg`,!t&&`invisible`),"aria-hidden":!0}),(0,J.jsxs)(`span`,{className:`min-w-0`,children:[(0,J.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:e.name}),(0,J.jsx)(`span`,{className:`block truncate text-xs text-fg-muted`,children:z(e)})]}),(0,J.jsx)(`span`,{className:s(`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium`,ln(e.status)),children:R(e)})]},e.id);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(T,{open:o,onOpenChange:l,children:[(0,J.jsx)(O,{asChild:!0,children:(0,J.jsxs)(`button`,{type:`button`,className:`group -ml-2 flex max-w-full min-w-0 items-center gap-2 rounded-lg px-2 py-1 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":t.projectSwitcher.switchProject,title:t.projectSwitcher.switchProject,children:[(0,J.jsxs)(`span`,{className:`min-w-0`,children:[(0,J.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:e.name}),(0,J.jsx)(`span`,{className:s(`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium`,ln(e.status)),children:R(e)})]}),(0,J.jsx)(`span`,{className:`block truncate text-xs text-fg-muted`,children:z(e)})]}),(0,J.jsx)(Be,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-data-[state=open]:rotate-180`,"aria-hidden":!0})]})}),(0,J.jsx)(re,{children:(0,J.jsxs)(B,{side:`bottom`,align:`start`,sideOffset:6,className:`z-[70] w-[min(26rem,calc(100vw-2rem))] overflow-hidden rounded-xl border border-edge bg-surface-panel p-1.5 shadow-popover outline-none`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,J.jsxs)(`label`,{className:`relative block`,children:[(0,J.jsx)(H,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,J.jsx)(`input`,{type:`search`,className:`h-9 w-full rounded-lg border border-edge bg-surface-base pl-9 pr-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`,value:f,onChange:e=>p(e.target.value),placeholder:t.projectSwitcher.searchPlaceholder,"aria-label":t.projectSwitcher.searchPlaceholder})]}),(0,J.jsxs)(`div`,{className:`mt-1 max-h-[min(54vh,24rem)] overflow-y-auto pr-0.5 [scrollbar-gutter:stable]`,children:[(0,J.jsx)(`div`,{className:`px-2 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:t.projectSwitcher.current}),oe(e,!0),(0,J.jsx)(`div`,{className:`px-2 pb-1 pt-3 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:t.projectSwitcher.recent}),_?(0,J.jsx)(`div`,{className:`px-2 py-2 text-xs text-red-600 dark:text-red-400`,children:_}):null,m&&L.length===0?(0,J.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:t.projectSwitcher.loading}):null,!m&&L.length===0?(0,J.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:t.projectSwitcher.noMatches}):null,L.map(e=>oe(e,!1))]}),(0,J.jsxs)(`div`,{className:`mt-1 border-t border-edge-subtle pt-1`,children:[(0,J.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm text-fg hover:bg-surface-hover`,onClick:()=>ee(`new`),children:[(0,J.jsx)(et,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`min-w-0 truncate`,children:t.projectSwitcher.newProject})]}),(0,J.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm text-fg hover:bg-surface-hover`,onClick:()=>ee(`directory`),children:[(0,J.jsx)(k,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`min-w-0 truncate`,children:t.projectSwitcher.openDirectory})]}),(0,J.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm text-fg hover:bg-surface-hover`,onClick:()=>{l(!1),a(`/projects`)},children:[(0,J.jsx)(g,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`min-w-0 truncate`,children:t.projectSwitcher.manageProjects})]})]})]})})]}),(0,J.jsx)(De,{open:y,onOpenChange:e=>!A&&b(e),children:(0,J.jsxs)(Me,{children:[(0,J.jsx)(Ie,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,J.jsxs)(Qe,{className:`fixed left-1/2 top-1/2 z-[90] flex h-[min(32rem,calc(100vh-2rem))] w-[min(40rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,J.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,J.jsx)(be,{className:`text-base font-semibold text-fg`,children:x===`directory`?t.projectSwitcher.createFromDirectoryTitle:n.createTitle}),(0,J.jsx)(We,{className:`mt-1 text-sm text-fg-muted`,children:x===`directory`?t.projectSwitcher.createFromDirectoryDescription:n.createDescription})]}),(0,J.jsxs)(`form`,{onSubmit:te,className:`flex min-h-0 flex-1 flex-col`,children:[(0,J.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[M?(0,J.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:M}):null,(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,J.jsx)(`span`,{className:`font-medium text-fg-muted`,children:n.projectName}),(0,J.jsx)(`input`,{className:`min-h-10 rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`,value:C,onChange:e=>w(e.target.value),placeholder:`xopc`,autoFocus:!0})]}),(0,J.jsxs)(`div`,{className:`grid gap-1.5 text-sm`,children:[(0,J.jsx)(`span`,{className:`font-medium text-fg-muted`,children:n.workspaceRoot}),(0,J.jsx)(bt,{value:E,onChange:ae,disabled:A,wd:r,placeholder:n.workspacePlaceholder,inputClassName:`min-h-10 rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`}),(0,J.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.workspaceHint})]})]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,J.jsx)(je,{asChild:!0,children:(0,J.jsx)(U,{type:`button`,variant:`ghost`,className:`rounded-lg`,disabled:A,children:n.cancel})}),(0,J.jsxs)(U,{type:`submit`,variant:`primary`,className:`rounded-lg`,disabled:A||!(C.trim()||x===`directory`&&gn(E)),children:[(0,J.jsx)(et,{className:`size-4`,"aria-hidden":!0}),n.create]})]})]})]})]})}),(0,J.jsx)(De,{open:!!P,onOpenChange:e=>{e||F(null)},children:(0,J.jsxs)(Me,{children:[(0,J.jsx)(Ie,{className:`fixed inset-0 z-[100] bg-scrim backdrop-blur-[2px]`}),(0,J.jsxs)(Qe,{className:`fixed left-1/2 top-1/2 z-[110] flex w-[min(30rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,J.jsxs)(`div`,{className:`border-b border-edge px-5 py-4`,children:[(0,J.jsx)(be,{className:`text-base font-semibold text-fg`,children:n.workspaceMissingTitle}),(0,J.jsx)(We,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:P?sn(n.workspaceMissingDescription,{workspace:P}):null})]}),P?(0,J.jsx)(`div`,{className:`px-5 py-4`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-surface-muted px-3 py-2 text-sm text-fg-muted`,children:[(0,J.jsx)(k,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`min-w-0 truncate`,children:P})]})}):null,(0,J.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,J.jsx)(U,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:ie,disabled:A,children:n.workspaceMissingBack}),(0,J.jsxs)(U,{type:`button`,variant:`primary`,className:`rounded-lg`,onClick:ne,disabled:A,children:[(0,J.jsx)($e,{className:`size-4`,"aria-hidden":!0}),n.workspaceMissingCreate]})]})]})]})})]})}function Dn(){let{projectId:e=``,tabId:t,noteId:n}=o(),r=i(),c=d(f(e=>e.language)),p=c.chat.workingDirectory,m=c.projectDetailPage,g=c.projectsPage,w=Ve(e=>e.setPageHeader),M=Ve(e=>e.clearPageHeader),[R,le]=(0,q.useState)(null),[W,xe]=(0,q.useState)(null),[we,Te]=(0,q.useState)([]),[Oe,ke]=(0,q.useState)(``),[Pe,Le]=(0,q.useState)([]),[Re,He]=(0,q.useState)([]),[Ge,qe]=(0,q.useState)([]),[Je,Ye]=(0,q.useState)([]),[G,tt]=(0,q.useState)([]),[it,at]=(0,q.useState)(!1),[lt,K]=(0,q.useState)(null),[wt,Tt]=(0,q.useState)([]),[Et,Dt]=(0,q.useState)(0),[Ot,kt]=(0,q.useState)(!1),[At,jt]=(0,q.useState)(!1),[Mt,Nt]=(0,q.useState)(!1),[Pt,Ft]=(0,q.useState)([]),It=(0,q.useRef)(new Set),[Lt,Rt]=(0,q.useState)(null),[zt,Bt]=(0,q.useState)(tn),[Vt,Ht]=(0,q.useState)(!1),[Ut,Wt]=(0,q.useState)(!1),[Gt,Kt]=(0,q.useState)(``),[Yt,Xt]=(0,q.useState)([]),[Zt,Qt]=(0,q.useState)(!1),[$t,mn]=(0,q.useState)(null),[hn,gn]=(0,q.useState)(!1),[Sn,Dn]=(0,q.useState)(null),[On,kn]=(0,q.useState)([]),[Y,An]=(0,q.useState)(``),[jn,Mn]=(0,q.useState)(!0),[Nn,Pn]=(0,q.useState)(!1),[Fn,In]=(0,q.useState)(!1),[Ln,Rn]=(0,q.useState)(null),[zn,Bn]=(0,q.useState)(!1),[X,Vn]=(0,q.useState)(`fixed`),[Hn,Un]=(0,q.useState)(``),[Wn,Gn]=(0,q.useState)(null),[Kn,qn]=(0,q.useState)(!1),[Jn,Yn]=(0,q.useState)(!1),[Xn,Zn]=(0,q.useState)(0),[Qn,$n]=(0,q.useState)(!1),[er,tr]=(0,q.useState)(null),[nr,rr]=(0,q.useState)(!1),[ir,ar]=(0,q.useState)(!1),[or,sr]=(0,q.useState)(!1),[cr,Z]=(0,q.useState)(null),[lr,ur]=(0,q.useState)({defaultAgentId:``,agents:[],models:[],checklistDecomposePolicy:`empty_only`}),[dr,fr]=(0,q.useState)({title:``,reason:``}),[Q,pr]=(0,q.useState)({name:``,description:``,status:`active`,defaultAgentId:``,workspaceRoot:``,brief:``,instructions:``}),mr=`overview`,$=n?`notes`:rn(t)?t:mr,hr=(0,q.useCallback)(t=>{e&&r(`/projects/${encodeURIComponent(e)}/${t}`)},[r,e]),gr=(0,q.useCallback)(t=>e?`/projects/${encodeURIComponent(e)}/${t}`:`/projects`,[e]),_r=(0,q.useCallback)(e=>{let t=gr(`goals`);return`/goals/${encodeURIComponent(e)}?returnTo=${encodeURIComponent(t)}`},[gr]),vr=(0,q.useCallback)(t=>{e&&r(gr(t),{replace:!0})},[r,e,gr]),yr=(0,q.useCallback)((e,t)=>{vr(e),r(t)},[r,vr]),br=(0,q.useCallback)(e=>t=>{t.defaultPrevented||t.button!==0||t.metaKey||t.altKey||t.ctrlKey||t.shiftKey||vr(e)},[vr]),xr=(0,q.useCallback)(e=>e.startsWith(`/goals/`)?`goals`:e.startsWith(`/chat/`)?`sessions`:e.startsWith(`/workflows`)?`workflows`:e.startsWith(`/automations`)?`automations`:e.startsWith(`/notes`)?`notes`:$,[$]);(0,q.useEffect)(()=>{!e||!t||rn(t)||r(`/projects/${encodeURIComponent(e)}/${mr}`,{replace:!0})},[mr,r,e,t]),(0,q.useEffect)(()=>{if(!e)return;let t=!1;return Mn(!0),Z(null),Promise.all([se(e),y(e),dt(e),de().catch(()=>null)]).then(([e,n,r,i])=>{if(t)return;let a=e.project;le(a),xe(e),Te(n),Le(r),kn(i?.agents??[]),An(a.defaultAgentId??``),pr({name:a.name,description:a.description??``,status:a.status,defaultAgentId:a.defaultAgentId??``,workspaceRoot:a.workspaceRoot??``,brief:a.brief??``,instructions:a.instructions??``})}).catch(e=>{t||Z(e instanceof Error?e.message:String(e))}).finally(()=>{t||Mn(!1)}),()=>{t=!0}},[e]),(0,q.useEffect)(()=>{let e=!1;async function t(){let[t,n,r]=await Promise.allSettled([de(),I(),j()]);e||ur(e=>{let i=t.status===`fulfilled`?t.value.defaultId:e.defaultAgentId,a=R?.defaultAgentId||Y||i,o=t.status===`fulfilled`?t.value.agents:e.agents,s=n.status===`fulfilled`?n.value:e.models,c=r.status===`fulfilled`?xt(r.value.payload?.config).checklistDecomposePolicy:e.checklistDecomposePolicy;return{defaultAgentId:a,agents:o.length?o:[{id:a||`main`,workspace:``,profileDir:``,typedModels:{defaultRole:`deep`,preset:[],effective:[]},extends:[],isDefault:!0,skills:{preset:[]},tools:{presetDenied:[],entryDisable:[],effectiveDisable:[]}}],models:s,checklistDecomposePolicy:c}})}return t(),()=>{e=!0}},[R?.defaultAgentId,Y]);let Sr=(0,q.useCallback)(async()=>{if(R){$n(!0),Z(null);try{let[e,t]=await Promise.all([Ke(),Ne(100,{ownerAgentId:Y||void 0,projectId:R.id})]);He(e),qe(t)}catch(e){Z(e instanceof Error?e.message:String(e))}finally{$n(!1)}}},[R,Y]);(0,q.useEffect)(()=>{R&&Sr()},[R,Sr]);let Cr=(0,q.useCallback)(async()=>{if(R){at(!0),Z(null);try{let[e,t]=await Promise.all([ut.list({projectId:R.id}),ut.runs(50,void 0,{projectId:R.id})]);Ye(e.automations),tt(t.runs)}catch(e){Z(e instanceof Error?e.message:String(e))}finally{at(!1)}}},[R]);(0,q.useEffect)(()=>{$===`automations`&&Cr()},[Cr,$]);let wr=(0,q.useCallback)(async()=>{if(R){kt(!0),Z(null);try{let e=await pt(R.id,{includeRelated:At,limit:100});Tt(e.items),Dt(e.total)}catch(e){Z(e instanceof Error?e.message:String(e))}finally{kt(!1)}}},[R,At]);(0,q.useEffect)(()=>{$===`activity`&&wr()},[wr,$]);let Tr=(0,q.useCallback)(async e=>{K(`run:${e.id}`),Z(null);try{await ut.runNow(e.id),await Cr()}catch(e){Z(e instanceof Error?e.message:String(e))}finally{K(null)}},[Cr]),Er=(0,q.useCallback)(async e=>{K(`toggle:${e.id}`),Z(null);try{e.enabled?await ut.pause(e.id):await ut.resume(e.id),await Cr()}catch(e){Z(e instanceof Error?e.message:String(e))}finally{K(null)}},[Cr]),Dr=(0,q.useCallback)(async()=>{if(!R?.effectiveWorkspaceRoot?.trim()){Ft([]),It.current.clear(),Dn(null);return}gn(!0),Dn(null),It.current.clear();try{Ft(wn((await Ce(R.id,``)).entries)),It.current.add(``)}catch(e){Ft([]),It.current.clear(),Dn(e instanceof Error?e.message:String(e))}finally{gn(!1)}},[R]),Or=(0,q.useCallback)(async e=>{if(!(!R?.effectiveWorkspaceRoot?.trim()||It.current.has(e))){It.current.add(e),Dn(null);try{let t=await Ce(R.id,e);Ft(n=>Tn(n,e,wn(t.entries)))}catch(t){It.current.delete(e),Dn(t instanceof Error?t.message:String(t))}}},[R]);(0,q.useEffect)(()=>{$===`files`&&Dr()},[Dr,$]);let kr=Gt.trim();(0,q.useEffect)(()=>{if($!==`files`||!R||!Ut||!kr){Xt([]),Qt(!1),mn(null);return}let e=!1;Qt(!0),mn(null),Xt([]);let t=window.setTimeout(()=>{ee(R.id,kr,50).then(t=>{e||Xt(t)}).catch(t=>{e||mn(t instanceof Error?t.message:String(t))}).finally(()=>{e||Qt(!1)})},180);return()=>{e=!0,window.clearTimeout(t)}},[kr,R,Ut,$]);let Ar=(0,q.useCallback)(async()=>{if(R){Yn(!0),Z(null);try{let e=await Fe(R.id);yr(`sessions`,`/chat/${encodeURIComponent(e.key)}`)}catch(e){Z(e instanceof Error?e.message:String(e))}finally{Yn(!1)}}},[yr,R]),jr=(0,q.useCallback)(()=>{hr(`work-items`),Zn(e=>e+1)},[hr]),Mr=(0,q.useCallback)(async()=>{if(!R)return;let[e,t]=await Promise.all([se(R.id),dt(R.id)]);xe(e),le(e.project),Le(t)},[R]),Nr=(0,q.useCallback)(async e=>{if(!R||!e.title.trim())return;let t=Number.parseInt(e.maxTurns,10),n=e.deadline?new Date(e.deadline).getTime():void 0;rr(!0),Z(null);try{await Ue(R.id,{title:e.title.trim(),description:e.description.trim()||void 0,attachments:e.attachments.length?e.attachments:void 0,priority:e.priority,deadlineAt:Number.isFinite(n)?n:void 0,maxTurns:Number.isFinite(t)?t:void 0,agentId:e.agentId.trim()||void 0,judgeModelRef:e.judgeModelRef.trim()||void 0,contract:{objective:e.objective.trim()||e.title.trim(),scopeBoundary:e.scopeBoundary.trim()||void 0,evidencePlan:St(e.evidencePlan),criteria:St(e.checklist)}}),sr(!1),hr(`goals`),await Mr()}catch(e){throw Z(e instanceof Error?e.message:String(e)),e}finally{rr(!1)}},[hr,R,Mr]),Pr=(0,q.useCallback)(async e=>{if(e.preventDefault(),!(!R||!dr.title.trim())){ar(!0),Z(null);try{await Xe(R.id,{title:dr.title.trim(),reason:dr.reason.trim()||void 0}),fr({title:``,reason:``}),await Mr()}catch(e){Z(e instanceof Error?e.message:String(e))}finally{ar(!1)}}},[dr.reason,dr.title,R,Mr]),Fr=(0,q.useCallback)(async e=>{if(R){tr(`retry:${e.id}`),Z(null);try{let t=await mt(e.id,{ownerAgentId:Y||e.metadata?.agentId,projectId:e.metadata?.projectId||R.id});await Sr(),yr(`workflows`,ht(t.runId,{ownerAgentId:Y||e.metadata?.agentId||R.defaultAgentId}))}catch(e){Z(e instanceof Error?e.message:String(e))}finally{tr(null)}}},[yr,R,Sr,Y]),Ir=(0,q.useCallback)(async e=>{tr(`cancel:${e.id}`),Z(null);try{await Se(e.id,{ownerAgentId:Y||e.metadata?.agentId}),await Sr()}catch(e){Z(e instanceof Error?e.message:String(e))}finally{tr(null)}},[Sr,Y]),Lr=(0,q.useMemo)(()=>(0,J.jsx)(a,{to:`/projects`,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":m.backToProjects,children:(0,J.jsx)(pe,{className:`size-4`,"aria-hidden":!0})}),[m.backToProjects]),Rr=(0,q.useMemo)(()=>R?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(U,{variant:`secondary`,className:`h-9 rounded-lg`,onClick:jr,children:[(0,J.jsx)(et,{className:`size-4`,"aria-hidden":!0}),m.workItems.create.header]}),(0,J.jsxs)(U,{variant:`primary`,className:`h-9 rounded-lg`,onClick:()=>void Ar(),disabled:Jn,children:[(0,J.jsx)(Ae,{className:`size-4`,"aria-hidden":!0}),m.common.newChat]})]}):null,[jr,m.common.newChat,m.workItems.create.header,R,Ar,Jn]);(0,q.useLayoutEffect)(()=>(w({startExtra:Lr,main:R?(0,J.jsx)(En,{currentProject:R,pm:m,projectsText:g,wd:p}):(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:m.fallbackTitle}),(0,J.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:m.fallbackContext})]}),end:Rr}),()=>M()),[M,Rr,Lr,m,R,g,w,p]);function zr(e){le(t=>t?{...t,...e}:null),xe(t=>t?{...t,project:{...t.project,...e}}:null),An(e.defaultAgentId??``),pr(t=>({...t,name:e.name,description:e.description??``,status:e.status,defaultAgentId:e.defaultAgentId??``,workspaceRoot:e.workspaceRoot??``,brief:e.brief??``,instructions:e.instructions??``})),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}async function Br(){if(!(!R||!Q.name.trim())){Pn(!0),Z(null),Rn(null);try{zr(await h(R.id,{name:Q.name.trim(),status:Q.status,description:Q.description,defaultAgentId:Q.defaultAgentId,brief:Q.brief,instructions:Q.instructions}))}catch(e){let t=_n(e);t?Rn(t):Z(e instanceof Error?e.message:String(e))}finally{Pn(!1)}}}function Vr(e){e.preventDefault(),Br()}let Hr=(0,q.useCallback)(()=>{if(!R)return;let e=R.workspaceRoot?.trim()??``;Vn(e?`fixed`:`follow`),Un(e||R.effectiveWorkspaceRoot||``),Bn(!0)},[R]);async function Ur(e={}){if(!R)return;let t=X===`fixed`?Hn.trim():``;if(!(X===`fixed`&&!t)){Pn(!0),Z(null),Rn(null);try{zr(await h(R.id,{workspaceRoot:t,...e.createWorkspaceRoot?{createWorkspaceRoot:!0}:{}})),Bn(!1),Rn(null)}catch(e){let t=_n(e);t?(Rn(t),Bn(!1)):Z(e instanceof Error?e.message:String(e))}finally{Pn(!1)}}}async function Wr(){if(!(!R||Wn)){Gn(`pin`),Z(null);try{zr(R.pinnedAt?await ze(R.id):await ce(R.id))}catch(e){Z(e instanceof Error?e.message:String(e))}finally{Gn(null)}}}async function Gr(){if(!(!R||Wn)){Gn(`archive`),Z(null);try{zr(R.status===`archived`?await C(R.id):await Ee(R.id))}catch(e){Z(e instanceof Error?e.message:String(e))}finally{Gn(null)}}}async function Kr(){if(R){qn(!0),Z(null);try{await ye(R.id),In(!1),r(`/projects`)}catch(e){Z(e instanceof Error?e.message:String(e))}finally{qn(!1)}}}async function qr(){if(!(!R||Mt)){Nt(!0),Z(null);try{await x(R.id)}catch(e){Z(e instanceof Error?e.message:String(e))}finally{Nt(!1)}}}let Jr=(0,q.useCallback)(e=>{Rt(e)},[]),Yr=(0,q.useCallback)((e,t)=>{t||Rt(e)},[]),Xr=(0,q.useCallback)(async(e,t,n)=>{let r=R?.id;if(r)switch(e){case`preview`:t.isDirectory||Rt(t.path);break;case`download`:if(t.isDirectory)return;try{let e=ne(t.path);if(D(z(e))!==`text`){let n=await gt(t.path,{projectId:r}),i=te(e)??`application/octet-stream`;N(e,await n.arrayBuffer(),i)}else{let{content:n}=await v(t.path,{projectId:r});oe(e,n)}}catch(e){fe(`warning`,e instanceof Error?e.message:String(e),void 0,{duration:4e3})}break;case`copyPath`:try{await u(t.absolutePath??t.path)&&fe(`success`,c.workspace.pathCopied,void 0,{duration:2500})}catch{fe(`warning`,c.clipboard.copyFailed,void 0,{duration:4e3})}break;case`openDefault`:if(!t.absolutePath||!window.electronAPI?.shell?.openPath)return;await window.electronAPI.shell.openPath(t.absolutePath);break;case`openWith`:if(!t.absolutePath||!window.electronAPI?.shell?.chooseAppAndOpenPath)return;await window.electronAPI.shell.chooseAppAndOpenPath(t.absolutePath);break;case`openWithApp`:if(!t.absolutePath||!n||!window.electronAPI?.shell?.openPathWithApp)return;await window.electronAPI.shell.openPathWithApp(t.absolutePath,n);break;case`revealInFolder`:if(!t.absolutePath||!window.electronAPI?.shell?.showItemInFolder)return;await window.electronAPI.shell.showItemInFolder(t.absolutePath);break;default:break}},[c.clipboard.copyFailed,c.workspace.pathCopied,R?.id]),Zr=(0,q.useCallback)(e=>{if(!window.matchMedia(`(min-width: 1024px)`).matches)return;e.preventDefault();let t=e.currentTarget,n=t.closest(`[data-project-files-grid]`);if(!n)return;t.setPointerCapture(e.pointerId),Ht(!0);let r=e.clientX,i=zt,a=e.pointerId,o=0,s=i,c=i,l=()=>{o=0,c=s,n.style.setProperty(`--project-files-panel-width`,`${c}px`)},u=e=>{s=en(i+(e.clientX-r)),o===0&&(o=window.requestAnimationFrame(l))},d=()=>{o!==0&&(window.cancelAnimationFrame(o),l());try{t.releasePointerCapture(a)}catch{}Ht(!1),Bt(c),nn(c),window.removeEventListener(`pointermove`,u),window.removeEventListener(`pointerup`,d),window.removeEventListener(`pointercancel`,d)};window.addEventListener(`pointermove`,u),window.addEventListener(`pointerup`,d),window.addEventListener(`pointercancel`,d)},[zt]);if((0,q.useEffect)(()=>{$!==`files`&&Rt(null)},[e,$]),jn)return(0,J.jsx)(`main`,{className:`w-full flex-1 px-3 py-3 text-sm text-fg-muted sm:px-5 sm:py-4 xl:px-6`,children:m.loading});if(!R)return(0,J.jsxs)(`main`,{className:`w-full flex-1 px-3 py-3 sm:px-5 sm:py-4 xl:px-6`,children:[(0,J.jsxs)(a,{to:`/projects`,className:`inline-flex items-center gap-2 text-sm text-accent-fg hover:underline`,children:[(0,J.jsx)(pe,{className:`size-4`,"aria-hidden":!0}),m.backToProjects]}),(0,J.jsx)(`p`,{className:`mt-6 rounded-lg bg-surface-panel p-4 shadow-surface text-sm text-fg-muted`,children:cr||m.notFound})]});let Qr=W?.recentSessions.length?W.recentSessions:R.recentSessions,$r=W?.attentionItems??[],ei=e=>m.statuses[e]??e,ti=e=>sn(m.common.messages,{count:e}),ni=Oe.trim().toLowerCase(),ri=ni?we.filter(e=>{let t=cn(e.updatedAt),n=e.routing?.agentId||e.agentId||m.common.agent,r=e.name?.trim()||m.sessions.fallbackTitle,i=ti(e.messageCount??0),a=xn(e);return[r,e.key,n,a,t,i].filter(Boolean).join(` `).toLowerCase().includes(ni)}):we,ii=we.length>0&&ri.length===0,ai=On.find(e=>e.id===Q.defaultAgentId)?.name||Q.defaultAgentId||m.settings.globalDefaultAgent,oi=On.find(e=>e.id===Q.defaultAgentId),si=R.workspaceRoot?.trim()||``,ci=R.status===`archived`,li=!!R.pinnedAt,ui=!si,di=si||oi?.workspace||R.effectiveWorkspaceRoot||m.common.defaultWorkspace,fi=X===`fixed`?Hn.trim()||m.settings.workspacePlaceholder:oi?.workspace||R.effectiveWorkspaceRoot||m.common.defaultWorkspace,pi=(X===`fixed`?Hn.trim():``)!==si&&(X===`follow`||!!Hn.trim()),mi=[{id:`overview`,icon:V,label:m.surfaceTabs.overview},{id:`work`,icon:b,label:m.surfaceTabs.work},{id:`context`,icon:k,label:m.surfaceTabs.context}],hi=Jt.filter(e=>e.id!==`overview`&&e.id!==`work-items`&&e.id!==`files`);async function gi(){if(!di)return;let e=await u(di);fe(e?`success`:`warning`,e?c.workspace.pathCopied:c.clipboard.copyFailed,void 0,{duration:e?2500:4e3})}function _i(){Rn(null),Bn(!0)}return(0,J.jsxs)(`main`,{className:`flex h-full min-h-0 w-full flex-1 flex-col overflow-hidden px-3 py-3 sm:px-5 sm:py-4 xl:px-6`,children:[(0,J.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3`,children:[(0,J.jsx)(yt,{items:mi,activeTab:an($),onChange:e=>hr(on(e)),ariaLabel:m.navAria,tabIdPrefix:`project-surface-tab`,className:`min-w-0 flex-1`}),(0,J.jsxs)(T,{children:[(0,J.jsx)(O,{asChild:!0,children:(0,J.jsxs)(U,{type:`button`,variant:hi.some(e=>e.id===$)?`secondary`:`ghost`,className:`h-9 shrink-0 rounded-lg px-3`,children:[m.surfaceTabs.details,(0,J.jsx)(Be,{className:`size-3.5`,"aria-hidden":!0})]})}),(0,J.jsx)(re,{children:(0,J.jsx)(B,{align:`end`,sideOffset:6,className:`z-[70] w-48 rounded-xl border border-edge bg-surface-panel p-1.5 shadow-float`,children:hi.map(e=>{let t=e.icon,n=e.id===`work-items`?m.workItems.tab:m.tabs[e.id];return(0,J.jsx)(L,{asChild:!0,children:(0,J.jsxs)(`button`,{type:`button`,className:s(`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-sm hover:bg-surface-hover`,$===e.id?`bg-accent-soft text-accent-fg`:`text-fg-muted`),onClick:()=>hr(e.id),children:[(0,J.jsx)(t,{className:`size-4`,"aria-hidden":!0}),(0,J.jsx)(`span`,{children:n})]})},e.id)})})})]})]}),cr?(0,J.jsx)(`p`,{className:`mt-3 shrink-0 rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:cr}):null,(0,J.jsxs)(`div`,{className:s(`mt-3 min-h-0 flex-1`,$===`work-items`?`-mx-3 -mb-3 overflow-hidden sm:-mx-5 sm:-mb-4 xl:-mx-6`:$===`overview`?`overflow-y-auto pr-1 [scrollbar-gutter:stable] xl:overflow-hidden xl:pr-0`:`overflow-y-auto pr-1 [scrollbar-gutter:stable]`),children:[$===`overview`?(0,J.jsxs)(`section`,{id:`project-panel-overview`,role:`tabpanel`,"aria-labelledby":`project-surface-tab-overview`,className:`grid min-h-full gap-4 xl:h-full xl:min-h-0 xl:grid-cols-[minmax(0,1fr)_20rem] xl:overflow-hidden`,children:[(0,J.jsxs)(`div`,{className:`grid min-w-0 content-start gap-4 xl:min-h-0 xl:overflow-y-auto xl:pr-1 xl:[scrollbar-gutter:stable]`,children:[(0,J.jsx)(`div`,{className:`min-w-0 rounded-lg bg-surface-panel p-4 shadow-surface`,children:(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:m.overview.directionTitle}),(0,J.jsx)(`p`,{className:`mt-1 max-w-3xl text-sm leading-6 text-fg-muted`,children:W?.digest?.summary||W?.recommendedAction||R.description||R.brief||m.overview.directionFallback}),W?.digest?.nextAction?(0,J.jsx)(`p`,{className:`mt-2 max-w-3xl text-sm font-medium leading-6 text-fg`,children:sn(m.overview.recommendedNext,{action:W.digest.nextAction})}):null]}),(0,J.jsx)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:(0,J.jsxs)(U,{type:`button`,variant:`secondary`,onClick:()=>void qr(),disabled:Mt,children:[(0,J.jsx)(F,{className:`size-4`,"aria-hidden":!0}),Mt?m.overview.savingDigest:m.overview.saveDigest]})})]})}),(0,J.jsxs)(`div`,{className:`min-w-0 rounded-lg bg-surface-panel shadow-surface`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:m.overview.nextActions}),(0,J.jsxs)(U,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2 py-1 text-xs`,onClick:()=>sr(!0),children:[(0,J.jsx)(et,{className:`size-4`,"aria-hidden":!0}),m.overview.goal]})]}),(0,J.jsx)(`div`,{className:`divide-y divide-edge`,children:W?.nextActions.length?W.nextActions.map(e=>(0,J.jsxs)(a,{to:_r(e.goalId),onClick:br(`goals`),className:`block px-4 py-3 hover:bg-surface-hover`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,J.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.title}),(0,J.jsx)(`span`,{className:s(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,ln(e.status)),children:ei(e.status)})]}),(0,J.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e.nextAction})]},e.goalId)):(0,J.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:m.overview.noNextActions})})]})]}),(0,J.jsxs)(`aside`,{className:`grid min-w-0 content-start gap-4 xl:min-h-0 xl:overflow-y-auto xl:pr-1 xl:[scrollbar-gutter:stable]`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:m.overview.attention}),$r.length?(0,J.jsx)(`div`,{className:`mt-3 grid gap-3`,children:$r.map(e=>{let t=(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(l,{className:`size-4 text-amber-600 dark:text-amber-300`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.title})]}),(0,J.jsxs)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:[m.overview.attentionKinds[e.kind]??e.kind,e.detail?` · ${e.detail}`:e.status?` · ${ei(e.status)}`:``]})]});return e.href?(0,J.jsx)(a,{to:e.href,onClick:br(xr(e.href)),className:`min-w-0 rounded-md bg-surface-base p-3 hover:bg-surface-hover`,children:t},e.id):(0,J.jsx)(`div`,{className:`min-w-0 rounded-md bg-surface-base p-3`,children:t},e.id)})}):(0,J.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:m.overview.noBlockedGoals}),(0,J.jsxs)(`form`,{onSubmit:Pr,className:`mt-4 flex gap-2 border-t border-edge pt-4`,children:[(0,J.jsx)(`input`,{className:`min-h-9 min-w-0 flex-1 rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none focus:border-accent`,value:dr.title,onChange:e=>fr(t=>({...t,title:e.target.value})),placeholder:m.overview.blockerTitlePlaceholder}),(0,J.jsx)(U,{type:`submit`,variant:`secondary`,className:`shrink-0 rounded-lg px-3`,disabled:ir||!dr.title.trim(),"aria-label":ir?m.overview.addingBlocker:m.overview.addBlocker,title:ir?m.overview.addingBlocker:m.overview.addBlocker,children:(0,J.jsx)(et,{className:`size-4`,"aria-hidden":!0})})]})]}),(0,J.jsxs)(`div`,{className:`min-w-0 rounded-lg bg-surface-panel shadow-surface`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(Ze,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,J.jsx)(`h2`,{className:`min-w-0 truncate text-sm font-semibold text-fg`,children:m.overview.recentSessions})]}),(0,J.jsx)(`button`,{type:`button`,className:`shrink-0 text-xs font-medium text-accent-fg hover:underline`,onClick:()=>hr(`sessions`),children:m.common.viewAll})]}),(0,J.jsx)(`div`,{className:`divide-y divide-edge`,children:Qr.length?Qr.map(e=>(0,J.jsxs)(a,{to:`/chat/${encodeURIComponent(e.key)}`,onClick:br(`sessions`),className:`block px-4 py-3 hover:bg-surface-hover`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,J.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.name||e.key}),(0,J.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:cn(e.updatedAt)})]}),(0,J.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:e.agentId||m.common.agent})]},e.key)):(0,J.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:m.overview.noSessions})})]})]})]}):null,$===`work-items`?(0,J.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col`,role:`tabpanel`,"aria-labelledby":`project-surface-tab-work`,children:[(0,J.jsxs)(`div`,{className:`mb-3 flex shrink-0 flex-wrap items-center justify-between gap-2 rounded-xl border border-edge-subtle bg-surface-panel px-3 py-2`,children:[(0,J.jsx)(`p`,{className:`text-xs text-fg-muted`,children:m.surfaceTabs.workHint}),(0,J.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:[`goals`,`workflows`,`automations`].map(e=>(0,J.jsx)(U,{type:`button`,variant:`ghost`,className:`h-7 rounded-md px-2 text-xs`,onClick:()=>hr(e),children:m.tabs[e]},e))})]}),(0,J.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,J.jsx)(qt,{projectId:R.id,createRequestKey:Xn})})]}):null,$===`workflows`?(0,J.jsxs)(`section`,{id:`project-panel-workflows`,role:`tabpanel`,"aria-labelledby":`project-surface-tab-work`,className:`grid h-full min-h-[28rem] gap-4 xl:grid-cols-[minmax(0,1fr)_22rem]`,children:[(0,J.jsx)(`div`,{className:`min-h-0`,children:(0,J.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:m.workflows.runsTitle}),(0,J.jsx)(`p`,{className:`text-xs text-fg-muted`,children:m.workflows.runsHint})]}),(0,J.jsxs)(U,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg`,onClick:()=>void Sr(),disabled:Qn,children:[(0,J.jsx)(_t,{className:`size-4`,"aria-hidden":!0}),m.common.refresh]})]}),(0,J.jsx)(`div`,{className:`min-h-0 flex-1 divide-y divide-edge overflow-y-auto`,children:Qn&&Ge.length===0?(0,J.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:m.workflows.loadingRuns}):Ge.length?Ge.map(e=>{let t=e.status===`queued`||e.status===`running`,n=e.status===`failed`||e.status===`timeout`||e.status===`cancelled`;return(0,J.jsxs)(`div`,{className:`grid gap-2 px-4 py-3 hover:bg-surface-hover`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,J.jsx)(`button`,{type:`button`,className:`min-w-0 truncate text-left text-sm font-medium text-fg hover:text-accent-fg`,onClick:()=>yr(`workflows`,ht(e.id,{ownerAgentId:Y||e.metadata?.agentId||R.defaultAgentId})),children:e.title||e.definitionId}),(0,J.jsx)(`span`,{className:s(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,un(e.status)),children:ei(e.status)})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,J.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:sn(m.workflows.runMeta,{definitionId:e.definitionId,done:e.metrics.doneAgentCount,total:e.metrics.agentCount,time:cn(e.createdAtMs)})}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(U,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2 py-1 text-xs`,onClick:()=>yr(`workflows`,ht(e.id,{ownerAgentId:Y||e.metadata?.agentId||R.defaultAgentId})),children:m.common.open}),n?(0,J.jsxs)(U,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2 py-1 text-xs`,disabled:er===`retry:${e.id}`,onClick:()=>void Fr(e),children:[(0,J.jsx)(_t,{className:`size-3.5`,"aria-hidden":!0}),m.common.retry]}):null,t?(0,J.jsxs)(U,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2 py-1 text-xs`,disabled:er===`cancel:${e.id}`,onClick:()=>void Ir(e),children:[(0,J.jsx)(ft,{className:`size-3.5`,"aria-hidden":!0}),m.common.cancel]}):null]})]})]},e.id)}):(0,J.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:m.workflows.emptyRuns})})]})}),(0,J.jsx)(`aside`,{className:`min-h-0`,children:(0,J.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:[(0,J.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-4 py-3`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:m.workflows.startTitle}),(0,J.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:m.workflows.startHint})]}),(0,J.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3`,children:(0,J.jsx)(`div`,{className:`grid gap-2`,children:Re.length?Re.map(e=>(0,J.jsxs)(`button`,{type:`button`,className:`grid gap-1 rounded-md bg-surface-base p-3 text-left hover:bg-surface-hover focus:outline-none focus:ring-2 focus:ring-accent/30`,onClick:()=>r(`/workflows/${e.id}?projectId=${encodeURIComponent(R.id)}${Y?`&agentId=${encodeURIComponent(Y)}`:``}`),children:[(0,J.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,J.jsx)(ge,{className:`size-4 text-accent-fg`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title})]}),(0,J.jsx)(`span`,{className:`line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description||e.metadata.whenToUse||e.name})]},e.id)):(0,J.jsx)(`div`,{className:`px-1 py-3 text-sm text-fg-muted`,children:m.workflows.emptyDefinitions})})})]})})]}):null,$===`automations`?(0,J.jsxs)(`section`,{id:`project-panel-automations`,role:`tabpanel`,"aria-labelledby":`project-surface-tab-work`,className:`grid h-full min-h-[28rem] overflow-hidden gap-4 xl:grid-cols-[minmax(0,1fr)_22rem]`,children:[(0,J.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-col overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:m.automations.title}),(0,J.jsx)(`p`,{className:`text-xs text-fg-muted`,children:m.automations.hint})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsxs)(U,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg`,onClick:()=>void Cr(),disabled:it,children:[(0,J.jsx)(_t,{className:`size-4`,"aria-hidden":!0}),m.common.refresh]}),(0,J.jsxs)(U,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,onClick:()=>yr(`automations`,`/automations?projectId=${encodeURIComponent(R.id)}&action=create`),children:[(0,J.jsx)(et,{className:`size-4`,"aria-hidden":!0}),m.common.new]})]})]}),(0,J.jsx)(`div`,{className:`min-h-0 flex-1 divide-y divide-edge overflow-y-auto`,children:it&&Je.length===0?(0,J.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:m.automations.loading}):Je.length?Je.map(e=>{let t=G.find(t=>t.automationId===e.id),n=e.state.runningRunId?G.find(t=>t.id===e.state.runningRunId):null;return(0,J.jsxs)(`div`,{className:`grid gap-2 px-4 py-3 hover:bg-surface-hover`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,J.jsx)(`button`,{type:`button`,className:`min-w-0 truncate text-left text-sm font-medium text-fg hover:text-accent-fg`,onClick:()=>yr(`automations`,`/automations?automation=${encodeURIComponent(e.id)}`),children:e.name}),(0,J.jsx)(`span`,{className:s(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,e.enabled?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-surface-hover text-fg-muted`),children:e.enabled?m.automations.enabled:m.automations.paused})]}),(0,J.jsx)(`p`,{className:`line-clamp-2 text-sm leading-5 text-fg-muted`,children:e.description||e.action.kind}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,J.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:sn(m.common.lastRun,{trigger:e.trigger.kind,action:e.action.kind,time:t?cn(t.createdAtMs):m.common.never})}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsxs)(U,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2 py-1 text-xs`,disabled:lt===`run:${e.id}`||!!n,onClick:()=>void Tr(e),children:[(0,J.jsx)(ge,{className:`size-3.5`,"aria-hidden":!0}),m.automations.run]}),(0,J.jsxs)(U,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2 py-1 text-xs`,disabled:lt===`toggle:${e.id}`,onClick:()=>void Er(e),children:[e.enabled?(0,J.jsx)(rt,{className:`size-3.5`,"aria-hidden":!0}):(0,J.jsx)(ge,{className:`size-3.5`,"aria-hidden":!0}),e.enabled?m.automations.pause:m.automations.resume]})]})]})]},e.id)}):(0,J.jsxs)(`div`,{className:`grid gap-3 px-4 py-6 text-sm text-fg-muted`,children:[(0,J.jsx)(`p`,{children:m.automations.empty}),(0,J.jsx)(`div`,{children:(0,J.jsxs)(U,{type:`button`,variant:`secondary`,className:`rounded-lg`,onClick:()=>yr(`automations`,`/automations?projectId=${encodeURIComponent(R.id)}&action=create`),children:[(0,J.jsx)(_e,{className:`size-4`,"aria-hidden":!0}),m.automations.create]})})]})})]}),(0,J.jsxs)(`aside`,{className:`grid min-h-0 min-w-0 content-start gap-4 overflow-y-auto pr-1 [scrollbar-gutter:stable]`,children:[(0,J.jsxs)(`div`,{className:`rounded-lg bg-surface-panel shadow-surface`,children:[(0,J.jsx)(`div`,{className:`border-b border-edge px-4 py-3`,children:(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:m.automations.recentRuns})}),(0,J.jsx)(`div`,{className:`divide-y divide-edge`,children:G.length?G.slice(0,8).map(e=>(0,J.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,J.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.automationName}),(0,J.jsx)(`span`,{className:s(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,un(e.status)),children:ei(e.status)})]}),(0,J.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:cn(e.createdAtMs)})]},e.id)):(0,J.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:m.automations.emptyRuns})})]}),(0,J.jsxs)(`div`,{className:`rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:m.automations.contextTitle}),(0,J.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:m.automations.contextHint}),(0,J.jsx)(`p`,{className:`mt-3 break-all text-xs text-fg-subtle`,children:R.workspaceRoot||R.effectiveWorkspaceRoot||m.common.defaultWorkspace})]})]})]}):null,$===`notes`?(0,J.jsx)(`section`,{id:`project-panel-notes`,role:`tabpanel`,"aria-labelledby":`project-surface-tab-context`,className:`flex h-full min-h-[28rem] overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:(0,J.jsx)(vt,{selectedNoteId:n,basePath:`/projects/${encodeURIComponent(R.id)}/notes`,showLibrary:!1,allowMediaCapture:!1,listTag:`project:${R.id}`,captureTags:[`project:${R.id}`,R.slug],listTitle:m.notes.title,listDescription:m.notes.hint,emptyText:m.notes.emptyTitle,emptyDescription:m.notes.emptyDescription,listWidthStorageKey:`xopc.projectNotes.listWidth.${R.id}`})}):null,$===`files`?(0,J.jsxs)(`section`,{id:`project-panel-files`,role:`tabpanel`,"aria-labelledby":`project-surface-tab-context`,className:`flex h-full min-h-[28rem] flex-col gap-3`,children:[(0,J.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-start justify-between gap-3 rounded-xl border border-edge-subtle bg-surface-panel px-4 py-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 max-w-3xl`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:m.surfaceTabs.contextTitle}),(0,J.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:R.brief||R.instructions||R.description||m.surfaceTabs.contextFallback})]}),(0,J.jsx)(`div`,{className:`flex shrink-0 flex-wrap gap-1`,children:[`sessions`,`notes`,`settings`].map(e=>(0,J.jsx)(U,{type:`button`,variant:`ghost`,className:`h-7 rounded-md px-2 text-xs`,onClick:()=>hr(e),children:m.tabs[e]},e))})]}),(0,J.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:R.effectiveWorkspaceRoot?(0,J.jsxs)(`div`,{"data-project-files-grid":!0,className:s(`grid min-h-0 flex-1 grid-cols-1 overflow-hidden lg:grid-cols-[var(--project-files-panel-width)_6px_minmax(0,1fr)]`,Vt&&`cursor-col-resize select-none`),style:{"--project-files-panel-width":`${zt}px`},children:[(0,J.jsxs)(`aside`,{className:`flex min-h-0 flex-col border-b border-edge lg:border-b-0 lg:border-r`,children:[(0,J.jsxs)(`div`,{className:`flex h-11 items-center gap-1 border-b border-edge bg-surface-muted/50 px-3 text-sm`,children:[(0,J.jsx)(ot,{workspacePath:di}),(0,J.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[(0,J.jsx)(`button`,{type:`button`,className:s(`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,Ut&&`bg-surface-hover text-fg`),onClick:()=>Wt(!0),"aria-label":m.files.search,title:m.files.search,"aria-pressed":Ut,children:(0,J.jsx)(H,{className:`size-3.5`,"aria-hidden":!0})}),(0,J.jsx)(E,{className:`size-7 shrink-0 rounded-md p-0`,loading:hn,label:c.cron.refresh,onClick:()=>void Dr()})]})]}),Ut?(0,J.jsx)(`div`,{className:`shrink-0 border-b border-edge bg-surface-muted/40 px-3 py-2`,children:(0,J.jsxs)(`div`,{className:`flex h-8 items-center gap-2 rounded-md border border-edge bg-surface-panel px-2 focus-within:border-accent focus-within:ring-2 focus-within:ring-accent/20`,children:[(0,J.jsx)(H,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,J.jsx)(`input`,{type:`text`,role:`searchbox`,value:Gt,onChange:e=>Kt(e.target.value),placeholder:m.files.searchPlaceholder,"aria-label":m.files.searchPlaceholder,autoFocus:!0,className:`min-w-0 flex-1 bg-transparent text-xs text-fg outline-none placeholder:text-fg-subtle`}),(0,J.jsx)(`button`,{type:`button`,className:`flex size-6 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":m.files.clearSearch,title:m.files.clearSearch,onClick:()=>{Kt(``),Wt(!1)},children:(0,J.jsx)(ie,{className:`size-3.5`,"aria-hidden":!0})})]})}):null,Sn?(0,J.jsx)(`div`,{className:`border-b border-edge bg-red-500/10 px-4 py-3 text-sm text-red-700 dark:text-red-300`,children:Sn}):null,kr?(0,J.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-2`,children:Zt?(0,J.jsxs)(`div`,{className:`space-y-2 px-3 py-1`,children:[(0,J.jsx)(_,{className:`h-11 w-full`}),(0,J.jsx)(_,{className:`h-11 w-full`}),(0,J.jsx)(_,{className:`h-11 w-full`})]}):$t?(0,J.jsxs)(`p`,{className:`px-3 py-2 text-xs text-red-600 dark:text-red-400`,children:[c.workspace.loadError,`: `,$t]}):Yt.length===0?(0,J.jsx)(`p`,{className:`px-3 py-2 text-xs text-fg-muted`,children:m.files.noSearchResults}):Yt.map(e=>(0,J.jsxs)(`button`,{type:`button`,className:s(`flex w-full min-w-0 items-center gap-2 px-3 py-2 text-left hover:bg-surface-hover`,Lt===e.path&&`bg-accent-soft text-accent-fg`),onClick:()=>Rt(e.path),title:e.path,children:[(0,J.jsx)(he,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`span`,{className:`block truncate text-sm text-fg`,children:e.name}),(0,J.jsx)(`span`,{className:`block truncate text-xs text-fg-subtle`,children:e.path})]})]},e.path))}):hn&&Pt.length===0?(0,J.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:m.files.loading}):(0,J.jsx)(me,{tree:Pt,selectedPath:Lt,onSelectFile:Jr,onSelectEntry:Yr,onExpandDir:e=>void Or(e),onAction:Xr,actionLabels:{preview:c.workspace.preview,download:c.workspace.download,copyPath:c.workspace.copyPath,openDefault:c.workspace.openSystemApp,openWith:c.workspace.openWith,revealInFolder:c.workspace.revealInFolder,recommendedApps:c.workspace.recommendedApps},emptyHint:m.files.emptyDirectory})]}),(0,J.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":m.files.resizeHandle,className:s(`hidden cursor-col-resize touch-none items-stretch justify-center bg-surface-panel transition-colors hover:bg-surface-hover lg:flex`,Vt&&`bg-surface-hover`),onPointerDown:Zr,children:(0,J.jsx)(`div`,{className:`my-3 w-px rounded-full bg-edge-strong/70`})}),(0,J.jsx)(`div`,{className:`min-h-0 min-w-0 overflow-hidden bg-surface-base`,children:Lt?(0,J.jsx)(P,{filePath:Lt,projectId:R.id,onClose:()=>Rt(null)}):(0,J.jsx)(`div`,{className:`flex h-full min-h-[18rem] items-center justify-center px-6 text-center`,children:(0,J.jsxs)(`div`,{className:`max-w-sm`,children:[(0,J.jsx)(k,{className:`mx-auto size-8 text-fg-subtle`,"aria-hidden":!0}),(0,J.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:m.files.previewEmptyTitle}),(0,J.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:m.files.previewEmptyDescription})]})})})]}):(0,J.jsxs)(`div`,{className:`grid gap-3 px-4 py-8 text-sm text-fg-muted`,children:[(0,J.jsx)(`p`,{children:m.files.needWorkspace}),(0,J.jsx)(`div`,{children:(0,J.jsx)(U,{type:`button`,variant:`secondary`,className:`rounded-lg`,onClick:()=>hr(`settings`),children:m.files.openSettings})})]})})]}):null,$===`sessions`?(0,J.jsxs)(`section`,{id:`project-panel-sessions`,role:`tabpanel`,"aria-labelledby":`project-surface-tab-context`,className:`grid min-h-full content-start gap-3`,children:[we.length?(0,J.jsxs)(`label`,{className:`relative flex min-h-9 w-full max-w-lg cursor-text items-center rounded-lg bg-surface-panel py-1.5 pl-9 pr-9 shadow-surface`,children:[(0,J.jsx)(H,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-disabled`,"aria-hidden":!0}),(0,J.jsx)(`input`,{type:`search`,enterKeyHint:`search`,value:Oe,onChange:e=>ke(e.currentTarget.value),placeholder:m.sessions.searchPlaceholder,"aria-label":m.sessions.searchPlaceholder,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent py-0.5 text-sm leading-normal text-fg caret-current placeholder:text-fg-disabled focus:border-0 focus:shadow-none focus:outline-none focus:ring-0 focus-visible:outline-none`}),Oe?(0,J.jsx)(`button`,{type:`button`,className:`absolute right-2 top-1/2 inline-flex size-6 -translate-y-1/2 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":m.sessions.clearSearch,onClick:()=>ke(``),children:(0,J.jsx)(ie,{className:`size-3.5`,"aria-hidden":!0})}):null]}):null,ri.length?(0,J.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:ri.map(e=>{let t=cn(e.updatedAt),n=e.routing?.agentId||e.agentId||m.common.agent,r=xn(e),i=e.name?.trim()||m.sessions.fallbackTitle,o=ti(e.messageCount??0);return(0,J.jsxs)(a,{to:`/chat/${encodeURIComponent(e.key)}`,onClick:br(`sessions`),className:`group flex min-h-[8.75rem] min-w-0 flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,J.jsx)(`span`,{className:`mt-0.5 flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-base text-fg-muted`,children:(0,J.jsx)(Ae,{className:`size-4`,"aria-hidden":!0})}),(0,J.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(`h3`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-fg`,children:i}),r?(0,J.jsx)(`span`,{className:`shrink-0 rounded-md bg-surface-base px-2 py-0.5 text-[11px] font-medium leading-5 text-fg-muted`,children:r}):null]})})]}),(0,J.jsxs)(`div`,{className:`mt-auto grid gap-2 pt-4 text-xs text-fg-muted`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,J.jsxs)(`span`,{className:`min-w-0 max-w-full truncate rounded-md bg-surface-base px-2 py-1`,children:[m.sessions.agent,`: `,n]}),(0,J.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:o})]}),t?(0,J.jsxs)(`span`,{className:`truncate rounded-md bg-surface-base px-2 py-1`,children:[m.sessions.updated,`: `,t]}):null]})]},e.key)})}):ii?(0,J.jsx)(`div`,{className:`grid gap-1 rounded-lg bg-surface-panel px-4 py-8 text-center shadow-surface`,children:(0,J.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:m.sessions.noMatches})}):(0,J.jsx)(`div`,{className:`grid gap-1 rounded-lg bg-surface-panel px-4 py-8 text-center shadow-surface`,children:(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:m.sessions.emptyTitle}),(0,J.jsx)(`p`,{className:`mx-auto mt-1 max-w-md text-sm leading-6 text-fg-muted`,children:m.sessions.emptyDescription})]})})]}):null,$===`goals`?(0,J.jsxs)(`section`,{id:`project-panel-goals`,role:`tabpanel`,"aria-labelledby":`project-surface-tab-work`,className:`grid min-h-full content-start gap-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,J.jsx)(`div`,{children:(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:m.goals.title})}),(0,J.jsxs)(U,{type:`button`,variant:`primary`,className:`h-9 rounded-lg px-3`,disabled:nr,onClick:()=>sr(!0),children:[(0,J.jsx)(et,{className:`size-4`,"aria-hidden":!0}),m.goals.new]})]}),(0,J.jsx)(`div`,{className:`overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:Pe.length?Pe.map(e=>(0,J.jsxs)(a,{to:_r(e.id),onClick:br(`goals`),className:`grid gap-1 border-b border-edge px-4 py-3 last:border-b-0 hover:bg-surface-hover`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,J.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.title}),(0,J.jsx)(`span`,{className:s(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,ln(e.status)),children:ei(e.status)})]}),(0,J.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:e.nextAction||e.description||m.goals.noNextAction})]},e.id)):(0,J.jsx)(`p`,{className:`p-4 text-sm text-fg-muted`,children:m.goals.empty})})]}):null,$===`activity`?(0,J.jsxs)(`section`,{id:`project-panel-activity`,role:`tabpanel`,"aria-labelledby":`project-surface-tab-context`,className:`grid min-h-full content-start gap-3`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:m.activity.title}),(0,J.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:sn(m.activity.count,{count:Et})})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsxs)(`label`,{className:`inline-flex min-h-9 items-center gap-2 rounded-lg bg-surface-panel px-3 text-sm text-fg-muted shadow-surface`,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:At,onChange:e=>jt(e.currentTarget.checked),className:`size-4 rounded border-edge text-accent focus:ring-accent/30`}),m.activity.includeRelated]}),(0,J.jsxs)(U,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg px-3`,onClick:()=>void wr(),disabled:Ot,children:[(0,J.jsx)(_t,{className:s(`size-4`,Ot&&`animate-spin`),"aria-hidden":!0}),m.common.refresh]})]})]}),(0,J.jsx)(`div`,{className:`overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:Ot&&wt.length===0?(0,J.jsx)(`div`,{className:`px-4 py-8 text-sm text-fg-muted`,children:m.activity.loading}):wt.length?(0,J.jsx)(`div`,{className:`divide-y divide-edge`,children:wt.map(e=>{let t=m.activity.types[e.type]??e.type,n=m.activity.objectKinds[e.primaryObject.kind]??e.primaryObject.kind,r=Cn(e),i=e.relatedProjects.length>0&&!e.scopes.some(e=>e.scopeKind===`project`&&e.scopeId===R.id);return(0,J.jsxs)(`article`,{className:`grid gap-2 px-4 py-3`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:t}),i?(0,J.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-xs font-medium text-fg-muted`,children:m.activity.related}):null]}),(0,J.jsxs)(`p`,{className:`mt-1 min-w-0 truncate text-sm text-fg-muted`,children:[n,`: `,yn(e)]})]}),(0,J.jsx)(`time`,{className:`shrink-0 text-xs text-fg-subtle`,dateTime:new Date(e.createdAt).toISOString(),children:cn(e.createdAt)})]}),r?(0,J.jsx)(`p`,{className:`line-clamp-2 text-sm leading-5 text-fg-muted`,children:r}):null,(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 text-xs text-fg-subtle`,children:[(0,J.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:[m.activity.actor,`: `,vn(e)]}),(0,J.jsxs)(`span`,{className:`max-w-full truncate rounded-md bg-surface-base px-2 py-1`,children:[m.activity.source,`: `,bn(e)]})]})]},e.id)})}):(0,J.jsx)(`div`,{className:`px-4 py-8 text-sm text-fg-muted`,children:m.activity.empty})})]}):null,$===`settings`?(0,J.jsxs)(`form`,{id:`project-panel-settings`,role:`tabpanel`,"aria-labelledby":`project-surface-tab-context`,onSubmit:Vr,className:`grid min-h-full content-start gap-4`,children:[(0,J.jsxs)(`section`,{className:`grid gap-3 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:m.settings.contextTitle}),(0,J.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:m.settings.contextHint})]}),(0,J.jsx)(`span`,{className:s(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,ln(Q.status)),children:m.settings.statuses[Q.status]})]}),(0,J.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-5`,children:[(0,J.jsx)(pn,{label:m.settings.workspaceRoot,value:di,mono:!0}),(0,J.jsx)(pn,{label:m.settings.defaultAgent,value:ai}),(0,J.jsx)(pn,{label:m.settings.pinState,value:li?m.settings.pinned:m.settings.notPinned}),(0,J.jsx)(pn,{label:m.settings.createdAt,value:cn(R.createdAt)||m.common.never}),(0,J.jsx)(pn,{label:m.settings.updatedAt,value:cn(R.updatedAt)||m.common.never})]})]}),(0,J.jsxs)(`section`,{className:`grid gap-4 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,J.jsx)(`div`,{children:(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:m.settings.detailsTitle})}),(0,J.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,J.jsx)(dn,{label:m.settings.name,children:(0,J.jsx)(`input`,{className:fn(),value:Q.name,onChange:e=>pr(t=>({...t,name:e.target.value}))})}),(0,J.jsx)(dn,{label:m.settings.defaultAgent,children:(0,J.jsxs)(ue,{className:fn(),value:Q.defaultAgentId,onChange:e=>pr(t=>({...t,defaultAgentId:e.target.value})),children:[(0,J.jsx)(S,{value:``,children:m.settings.globalDefaultAgent}),On.map(e=>(0,J.jsx)(S,{value:e.id,children:ct(e,c.agentsSettings)},e.id))]})}),(0,J.jsx)(dn,{label:m.settings.status,children:ci?(0,J.jsx)(`div`,{className:`grid min-h-10 content-center rounded-md border border-edge bg-surface-muted px-3 text-sm text-fg-muted`,children:m.settings.statuses.archived}):(0,J.jsxs)(ue,{className:fn(),value:Q.status===`archived`?`active`:Q.status,onChange:e=>pr(t=>({...t,status:e.target.value})),children:[(0,J.jsx)(S,{value:`active`,children:m.settings.statuses.active}),(0,J.jsx)(S,{value:`paused`,children:m.settings.statuses.paused})]})}),(0,J.jsx)(dn,{label:m.settings.description,hint:m.settings.descriptionHint,children:(0,J.jsx)(`textarea`,{className:fn(!0),value:Q.description,onChange:e=>pr(t=>({...t,description:e.target.value}))})})]})]}),(0,J.jsx)(`section`,{className:`grid gap-4 rounded-lg bg-surface-panel p-4 shadow-surface`,children:(0,J.jsxs)(`div`,{className:`grid gap-2 text-sm`,children:[(0,J.jsx)(`span`,{className:`font-medium text-fg-muted`,children:m.settings.workspaceRoot}),(0,J.jsxs)(`div`,{className:`grid gap-3 rounded-md border border-edge bg-surface-base px-3 py-3`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 md:flex-row md:items-start md:justify-between`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,J.jsx)(`span`,{className:`rounded-md bg-surface-muted px-2 py-0.5 text-xs font-medium text-fg-muted`,children:ui?m.settings.workspaceModeFollow:m.settings.workspaceModeFixed})}),(0,J.jsx)(`div`,{className:`mt-2 break-all font-mono text-xs leading-5 text-fg`,title:di,children:di})]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[(0,J.jsxs)(U,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:()=>void gi(),children:[(0,J.jsx)(nt,{className:`size-4`,"aria-hidden":!0}),m.settings.copyWorkspacePath]}),(0,J.jsx)(ot,{workspacePath:di}),(0,J.jsxs)(U,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:Hr,children:[(0,J.jsx)($e,{className:`size-4`,"aria-hidden":!0}),m.settings.migrateWorkspace]})]})]}),(0,J.jsx)(`p`,{className:`text-xs leading-5 text-fg-subtle`,children:m.settings.workspaceMigrationHint})]})]})}),(0,J.jsxs)(`section`,{className:`grid gap-4 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:m.settings.agentContextTitle}),(0,J.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:m.settings.agentContextHint})]}),(0,J.jsx)(dn,{label:m.settings.brief,hint:m.settings.briefHint,children:(0,J.jsx)(`textarea`,{className:fn(!0),value:Q.brief,onChange:e=>pr(t=>({...t,brief:e.target.value}))})}),(0,J.jsx)(dn,{label:m.settings.instructions,hint:m.settings.instructionsHint,children:(0,J.jsx)(`textarea`,{className:fn(!0),value:Q.instructions,onChange:e=>pr(t=>({...t,instructions:e.target.value}))})})]}),(0,J.jsxs)(`section`,{className:`grid gap-4 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:m.settings.managementTitle}),(0,J.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:m.settings.managementHint})]}),(0,J.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,J.jsxs)(`div`,{className:`grid gap-3 rounded-md border border-edge bg-surface-base px-3 py-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:li?m.settings.pinnedTitle:m.settings.pinTitle}),(0,J.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:m.settings.pinHint})]}),(0,J.jsxs)(U,{type:`button`,variant:`ghost`,className:`w-fit rounded-lg`,disabled:Wn===`pin`,onClick:()=>void Wr(),children:[li?(0,J.jsx)(ve,{className:`size-4`,"aria-hidden":!0}):(0,J.jsx)(ae,{className:`size-4`,"aria-hidden":!0}),li?m.settings.unpinProject:m.settings.pinProject]})]}),(0,J.jsxs)(`div`,{className:`grid gap-3 rounded-md border border-edge bg-surface-base px-3 py-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:ci?m.settings.restoreTitle:m.settings.archiveTitle}),(0,J.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:ci?m.settings.restoreHint:m.settings.archiveHint})]}),(0,J.jsxs)(U,{type:`button`,variant:ci?`primary`:`ghost`,className:`w-fit rounded-lg`,disabled:Wn===`archive`,onClick:()=>void Gr(),children:[ci?(0,J.jsx)(_t,{className:`size-4`,"aria-hidden":!0}):(0,J.jsx)(A,{className:`size-4`,"aria-hidden":!0}),ci?m.settings.restoreProject:m.settings.archiveProject]})]})]})]}),(0,J.jsxs)(`section`,{className:`grid gap-3 rounded-lg border border-red-500/20 bg-red-500/5 p-4`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-red-700 dark:text-red-300`,children:m.settings.dangerTitle}),(0,J.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-red-700/80 dark:text-red-200/80`,children:m.settings.dangerHint})]}),(0,J.jsxs)(U,{type:`button`,variant:`ghost`,className:`w-fit text-red-600 hover:bg-red-500/10 hover:text-red-700 focus-visible:ring-red-500 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>In(!0),children:[(0,J.jsx)(st,{className:`size-4`,"aria-hidden":!0}),m.settings.deleteConfirmAction]})]}),(0,J.jsx)(`div`,{className:`flex flex-wrap justify-end gap-2 border-t border-edge pt-4`,children:(0,J.jsxs)(U,{type:`submit`,variant:`primary`,disabled:Nn||!Q.name.trim(),children:[(0,J.jsx)(F,{className:`size-4`,"aria-hidden":!0}),m.common.save]})})]}):null]}),(0,J.jsx)(De,{open:Fn,onOpenChange:e=>{Kn||In(e)},children:(0,J.jsxs)(Me,{children:[(0,J.jsx)(Ie,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,J.jsxs)(Qe,{className:`fixed left-1/2 top-1/2 z-[90] w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-panel p-5 shadow-float focus:outline-none`,children:[(0,J.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,J.jsx)(`span`,{className:`mt-0.5 flex size-9 shrink-0 items-center justify-center rounded-lg bg-red-500/10 text-red-600 dark:text-red-400`,children:(0,J.jsx)(l,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0})}),(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(be,{className:`text-base font-semibold text-fg`,children:m.settings.deleteConfirmTitle}),(0,J.jsx)(We,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:R?sn(m.settings.deleteConfirm,{name:R.name}):m.settings.deleteConfirmFallback})]})]}),(0,J.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,J.jsx)(je,{asChild:!0,children:(0,J.jsx)(U,{type:`button`,variant:`ghost`,className:`rounded-lg`,disabled:Kn,children:m.common.cancel})}),(0,J.jsxs)(U,{type:`button`,variant:`ghost`,className:`rounded-lg text-red-600 hover:bg-red-500/10 hover:text-red-700 focus-visible:ring-red-500 dark:text-red-400 dark:hover:text-red-300`,disabled:Kn||!R,onClick:()=>void Kr(),children:[(0,J.jsx)(st,{className:`size-4`,"aria-hidden":!0}),m.settings.deleteConfirmAction]})]})]})]})}),(0,J.jsx)(De,{open:zn,onOpenChange:e=>{Nn||Bn(e)},children:(0,J.jsxs)(Me,{children:[(0,J.jsx)(Ie,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,J.jsxs)(Qe,{className:`fixed left-1/2 top-1/2 z-[90] flex h-[min(34rem,calc(100vh-2rem))] w-[min(36rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,J.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,J.jsx)(be,{className:`text-base font-semibold text-fg`,children:m.settings.workspaceMigrationTitle}),(0,J.jsx)(We,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:m.settings.workspaceMigrationDescription})]}),(0,J.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[(0,J.jsxs)(`div`,{className:`grid gap-2 text-sm`,children:[(0,J.jsx)(`span`,{className:`font-medium text-fg-muted`,children:m.settings.workspaceMode}),(0,J.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-2`,children:[(0,J.jsxs)(`label`,{className:s(`flex min-h-10 items-start gap-2 rounded-md border px-3 py-2`,X===`fixed`?`border-accent bg-accent-soft/40 text-fg`:`border-edge bg-surface-base text-fg-muted`),children:[(0,J.jsx)(`input`,{type:`radio`,className:`mt-0.5 size-4`,checked:X===`fixed`,onChange:()=>Vn(`fixed`),disabled:Nn}),(0,J.jsxs)(`span`,{className:`min-w-0`,children:[(0,J.jsx)(`span`,{className:`block font-medium`,children:m.settings.workspaceModeFixed}),(0,J.jsx)(`span`,{className:`block text-xs leading-5 text-fg-subtle`,children:m.settings.workspaceMigrationFixedHint})]})]}),(0,J.jsxs)(`label`,{className:s(`flex min-h-10 items-start gap-2 rounded-md border px-3 py-2`,X===`follow`?`border-accent bg-accent-soft/40 text-fg`:`border-edge bg-surface-base text-fg-muted`),children:[(0,J.jsx)(`input`,{type:`radio`,className:`mt-0.5 size-4`,checked:X===`follow`,onChange:()=>Vn(`follow`),disabled:Nn}),(0,J.jsxs)(`span`,{className:`min-w-0`,children:[(0,J.jsx)(`span`,{className:`block font-medium`,children:m.settings.workspaceModeFollow}),(0,J.jsx)(`span`,{className:`block text-xs leading-5 text-fg-subtle`,children:m.settings.workspaceHint})]})]})]})]}),X===`fixed`?(0,J.jsx)(bt,{value:Hn,onChange:Un,disabled:Nn,wd:p,placeholder:m.settings.workspacePlaceholder,inputClassName:fn(),autoFocus:!0}):null,(0,J.jsx)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-sm leading-6 text-amber-800 dark:text-amber-200`,children:m.settings.workspaceMigrationImpact}),(0,J.jsx)(`div`,{className:`rounded-lg bg-surface-muted px-3 py-2 text-xs leading-5 text-fg-subtle`,children:sn(m.settings.workspaceCurrent,{workspace:fi})})]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,J.jsx)(je,{asChild:!0,children:(0,J.jsx)(U,{type:`button`,variant:`ghost`,className:`rounded-lg`,disabled:Nn,children:m.common.cancel})}),(0,J.jsxs)(U,{type:`button`,variant:`primary`,className:`rounded-lg`,disabled:Nn||!pi,onClick:()=>void Ur(),children:[(0,J.jsx)($e,{className:`size-4`,"aria-hidden":!0}),m.settings.workspaceMigrationConfirm]})]})]})]})}),(0,J.jsx)(De,{open:!!Ln,onOpenChange:e=>{e||Rn(null)},children:(0,J.jsxs)(Me,{children:[(0,J.jsx)(Ie,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,J.jsxs)(Qe,{className:`fixed left-1/2 top-1/2 z-[90] flex w-[min(30rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,J.jsxs)(`div`,{className:`border-b border-edge px-5 py-4`,children:[(0,J.jsx)(be,{className:`text-base font-semibold text-fg`,children:m.settings.workspaceMissingTitle}),(0,J.jsx)(We,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:Ln?sn(m.settings.workspaceMissingDescription,{workspace:Ln}):null})]}),Ln?(0,J.jsx)(`div`,{className:`px-5 py-4`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-surface-muted px-3 py-2 text-sm text-fg-muted`,children:[(0,J.jsx)(k,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`min-w-0 truncate`,children:Ln})]})}):null,(0,J.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,J.jsx)(U,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:_i,disabled:Nn,children:m.settings.workspaceMissingBack}),(0,J.jsxs)(U,{type:`button`,variant:`primary`,className:`rounded-lg`,onClick:()=>void Ur({createWorkspaceRoot:!0}),disabled:Nn,children:[(0,J.jsx)($e,{className:`size-4`,"aria-hidden":!0}),m.settings.workspaceMissingCreate]})]})]})]})}),(0,J.jsx)(Ct,{open:or,t:c.goalsPage,chat:c.chat,busy:nr,options:lr,onClose:()=>!nr&&sr(!1),onCreate:Nr})]})}export{Dn as ProjectDetailPage};
@@ -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,t as a}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as o}from"./cn-BQ_8x0bT.js";import{t as s}from"./circle-alert-RzVebuX2.js";import{t as c}from"./messages-Cb1VMeqP.js";import{d as l,i as u,n as d}from"./locale-store-CiM-D9jA.js";import{Al as f,Ba as p,Cc as m,Hl as h,Ps as g,Tl as _,Yc as v,Yo as y,_o as b,do as x,el as ee,fo as te,ga as ne,go as re,ho as ie,lo as S,ml as C,mo as w,pc as ae,po as oe,qs as se,wa as T,ws as E,z as D}from"./index-BJGusbyV.js";var O=e(t(),1),k=n();function ce(e){return u(l(`/api/home${e?`?locale=${encodeURIComponent(e)}`:``}`))}function le(e,t){return u(l(`/api/home/decisions/respond`),{method:`POST`,body:JSON.stringify({...e,decision:t})})}var A=r();function j(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function M(e,t){if(e==null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?t:new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(n)}function ue(){let e=(0,k.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,A.jsx)(p,{className:`h-32 rounded-2xl`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,A.jsxs)(`div`,{className:`space-y-5`,"aria-busy":!0,children:[t,(0,A.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,A.jsx)(p,{className:`h-64 rounded-2xl`}),(0,A.jsx)(p,{className:`h-64 rounded-2xl`})]}),(0,A.jsx)(p,{className:`h-44 rounded-2xl`})]}),e[1]=n):n=e[1],n}function de(e){let t=(0,k.c)(22),{item:n,statusLabel:r,needsAttention:i}=e,s=i===void 0?!1:i,c=`/work-items/${encodeURIComponent(n.id)}`,l=s?`border-warning/35 bg-warning-soft/25 hover:bg-warning-soft/40`:`border-edge-subtle bg-surface-panel hover:bg-surface-hover/55`,u;t[0]===l?u=t[1]:(u=o(`group block rounded-xl border p-3.5 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,l),t[0]=l,t[1]=u);let d;t[2]===n.title?d=t[3]:(d=(0,A.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.title}),t[2]=n.title,t[3]=d);let f;t[4]===n.projectName?f=t[5]:(f=(0,A.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:n.projectName}),t[4]=n.projectName,t[5]=f);let p;t[6]!==d||t[7]!==f?(p=(0,A.jsxs)(`div`,{className:`min-w-0`,children:[d,f]}),t[6]=d,t[7]=f,t[8]=p):p=t[8];let m;t[9]===r?m=t[10]:(m=(0,A.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:r}),t[9]=r,t[10]=m);let h;t[11]!==p||t[12]!==m?(h=(0,A.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[p,m]}),t[11]=p,t[12]=m,t[13]=h):h=t[13];let g;t[14]!==n.blockedReason||t[15]!==n.nextAction?(g=n.blockedReason||n.nextAction?(0,A.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-5 text-fg-muted`,children:n.blockedReason||n.nextAction}):null,t[14]=n.blockedReason,t[15]=n.nextAction,t[16]=g):g=t[16];let _;return t[17]!==g||t[18]!==c||t[19]!==u||t[20]!==h?(_=(0,A.jsxs)(a,{to:c,className:u,children:[h,g]}),t[17]=g,t[18]=c,t[19]=u,t[20]=h,t[21]=_):_=t[21],_}function fe(e){let t=(0,k.c)(27),{item:n,kindLabel:r,reasonLabel:i,approveLabel:o,denyLabel:s,busy:c,onRespond:l}=e,u;t[0]===n.title?u=t[1]:(u=(0,A.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.title}),t[0]=n.title,t[1]=u);let d=n.projectName||r,f;t[2]===d?f=t[3]:(f=(0,A.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:d}),t[2]=d,t[3]=f);let p;t[4]!==u||t[5]!==f?(p=(0,A.jsxs)(`div`,{className:`min-w-0`,children:[u,f]}),t[4]=u,t[5]=f,t[6]=p):p=t[6];let m;t[7]===i?m=t[8]:(m=(0,A.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-panel/80 px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:i}),t[7]=i,t[8]=m);let h;t[9]!==p||t[10]!==m?(h=(0,A.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[p,m]}),t[9]=p,t[10]=m,t[11]=h):h=t[11];let g;t[12]===n.detail?g=t[13]:(g=n.detail?(0,A.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-5 text-fg-muted`,children:n.detail}):null,t[12]=n.detail,t[13]=g);let _;t[14]!==n.href||t[15]!==h||t[16]!==g?(_=(0,A.jsxs)(a,{to:n.href,className:`group block focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[h,g]}),t[14]=n.href,t[15]=h,t[16]=g,t[17]=_):_=t[17];let v;t[18]!==o||t[19]!==c||t[20]!==s||t[21]!==n.response||t[22]!==l?(v=n.response?(0,A.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2 border-t border-warning/20 pt-3`,children:[(0,A.jsx)(y,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:c,onClick:()=>l(`deny`),children:s}),(0,A.jsx)(y,{type:`button`,variant:`primary`,className:`h-8 px-2`,disabled:c,onClick:()=>l(`approve`),children:o})]}):null,t[18]=o,t[19]=c,t[20]=s,t[21]=n.response,t[22]=l,t[23]=v):v=t[23];let b;return t[24]!==_||t[25]!==v?(b=(0,A.jsxs)(`article`,{className:`rounded-xl border border-warning/35 bg-warning-soft/25 p-3.5 transition-colors hover:bg-warning-soft/40`,children:[_,v]}),t[24]=_,t[25]=v,t[26]=b):b=t[26],b}function N(e){let t=(0,k.c)(19),{project:n,openLabel:r,noDescription:i}=e,o=`/projects/${encodeURIComponent(n.id)}`,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,A.jsx)(v,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[0]=s):s=t[0];let c;t[1]===n.name?c=t[2]:(c=(0,A.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[s,(0,A.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.name})]}),t[1]=n.name,t[2]=c);let l;t[3]===r?l=t[4]:(l=(0,A.jsx)(h,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5`,"aria-label":r}),t[3]=r,t[4]=l);let u;t[5]!==c||t[6]!==l?(u=(0,A.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[c,l]}),t[5]=c,t[6]=l,t[7]=u):u=t[7];let d=n.description||n.brief||i,f;t[8]===d?f=t[9]:(f=(0,A.jsx)(`p`,{className:`mt-3 line-clamp-2 text-xs leading-5 text-fg-muted`,children:d}),t[8]=d,t[9]=f);let p=n.lastActiveAt??n.updatedAt,m;t[10]===p?m=t[11]:(m=M(p,``),t[10]=p,t[11]=m);let g;t[12]===m?g=t[13]:(g=(0,A.jsx)(`p`,{className:`mt-auto pt-3 text-[11px] text-fg-subtle`,children:m}),t[12]=m,t[13]=g);let _;return t[14]!==o||t[15]!==g||t[16]!==u||t[17]!==f?(_=(0,A.jsxs)(a,{to:o,className:`group flex min-h-32 flex-col rounded-xl border border-edge-subtle bg-surface-panel p-4 transition-colors hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[u,f,g]}),t[14]=o,t[15]=g,t[16]=u,t[17]=f,t[18]=_):_=t[18],_}function P(){let e=d(e=>e.language),t=c(e),n=t.projectsPage,r=i(),o=S(e=>e.setPageHeader),l=S(e=>e.clearPageHeader),[u,p]=(0,O.useState)(null),[h,v]=(0,O.useState)([]),[k,P]=(0,O.useState)(!0),[F,I]=(0,O.useState)(null),[L,R]=(0,O.useState)(null),[z,B]=(0,O.useState)(``),[pe,V]=(0,O.useState)(!1),[H,U]=(0,O.useState)(`delegate`),[W,G]=(0,O.useState)(``),[K,q]=(0,O.useState)(!1),[me,J]=(0,O.useState)(null),Y=(0,O.useCallback)(async()=>{P(!0),I(null);try{let[t,n]=await Promise.all([ce(e),T({limit:100,sortBy:`updatedAt`,sortOrder:`desc`})]);p(t),v(n.items)}catch(e){I(e instanceof Error?e.message:String(e))}finally{P(!1)}},[e]);(0,O.useEffect)(()=>{Y()},[Y]);let X=(0,O.useMemo)(()=>{let e=z.trim().toLocaleLowerCase(),t=h.filter(e=>e.status!==`archived`);return e?t.filter(t=>[t.name,t.description,t.brief].filter(Boolean).some(t=>t.toLocaleLowerCase().includes(e))):t.slice(0,12)},[h,z]),Z=(0,O.useMemo)(()=>u?.decisions??[],[u]),Q=(0,O.useMemo)(()=>u?.work.current.filter(e=>e.status!==`needs_input`&&e.status!==`in_review`&&e.status!==`blocked`).slice(0,10)??[],[u]),he=(0,O.useCallback)(async t=>{t.preventDefault();let n=W.trim();if(!(!n||K)){if(H===`watch`){let t=e===`zh`?`持续关注以下事项,在发生有意义的变化时通知我:\n${n}`:`Keep watching the following and notify me when something meaningfully changes:\n${n}`;G(``),V(!1),r(`/automations?draft=${encodeURIComponent(t)}&autogenerate=1`);return}q(!0),R(null);try{let t=await ne({outcome:n,uiLocale:e});G(``),V(!1),r(`/projects/${encodeURIComponent(t.project.id)}`)}catch(e){R(e instanceof Error?e.message:String(e))}finally{q(!1)}}},[H,K,e,r,W]),$=(0,O.useMemo)(()=>(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsxs)(y,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg`,onClick:()=>{U(`watch`),V(!0)},children:[(0,A.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),n.workHome.watch]}),(0,A.jsxs)(y,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,onClick:()=>{U(`delegate`),V(!0)},children:[(0,A.jsx)(se,{className:`size-4`,"aria-hidden":!0}),n.workHome.delegate]})]}),[n.workHome.delegate,n.workHome.watch]),ge=(0,O.useCallback)(async(e,t)=>{if(e.response){J(e.id),I(null);try{await le(e.response,t),await Y()}catch(e){I(e instanceof Error?e.message:String(e))}finally{J(null)}}},[Y]);return(0,O.useLayoutEffect)(()=>(o({startExtra:null,main:(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title}),(0,A.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:n.workHome.subtitle})]}),end:$}),()=>l()),[l,$,o,n.title,n.workHome.subtitle]),(0,A.jsxs)(`main`,{className:`flex w-full flex-1 flex-col gap-5 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,A.jsx)(x,{open:pe,onOpenChange:e=>{V(e),e||R(null)},children:(0,A.jsxs)(re,{children:[(0,A.jsx)(ie,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,A.jsxs)(oe,{className:`fixed left-1/2 top-1/2 z-[90] flex h-[min(26rem,calc(100vh-2rem))] w-[min(36rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,A.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,A.jsx)(b,{className:`text-base font-semibold text-fg`,children:H===`watch`?n.workHome.watchTitle:n.workHome.delegateTitle}),(0,A.jsx)(w,{className:`mt-1 text-sm text-fg-muted`,children:H===`watch`?n.workHome.watchDescription:n.workHome.delegateDescription})]}),(0,A.jsxs)(`form`,{onSubmit:he,className:`flex min-h-0 flex-1 flex-col`,children:[(0,A.jsxs)(`div`,{className:`min-h-0 flex-1 px-5 py-4`,children:[(0,A.jsxs)(`label`,{className:`grid gap-2 text-sm font-medium text-fg`,children:[H===`watch`?n.workHome.watchLabel:n.workHome.outcomeLabel,(0,A.jsx)(`textarea`,{className:`min-h-40 w-full resize-none rounded-xl border border-edge bg-surface-base px-3 py-3 text-sm font-normal leading-6 text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`,value:W,onChange:e=>G(e.target.value),placeholder:H===`watch`?n.workHome.watchPlaceholder:n.workHome.outcomePlaceholder,maxLength:12e3,autoFocus:!0,disabled:K})]}),L?(0,A.jsx)(`p`,{className:`mt-3 rounded-lg bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,children:L}):null]}),(0,A.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-t border-edge px-5 py-4`,children:[(0,A.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:H===`watch`?n.workHome.watchSetupHint:n.workHome.autoSetupHint}),(0,A.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,A.jsx)(te,{asChild:!0,children:(0,A.jsx)(y,{type:`button`,variant:`ghost`,children:n.cancel})}),(0,A.jsxs)(y,{type:`submit`,variant:`primary`,disabled:K||!W.trim(),children:[(0,A.jsx)(E,{className:`size-4`,"aria-hidden":!0}),K?n.workHome.delegating:H===`watch`?n.workHome.designWatch:n.workHome.delegate]})]})]})]})]})]})}),F?(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl border border-danger/25 bg-danger-soft px-4 py-3 text-sm text-danger`,children:[(0,A.jsx)(`span`,{children:F}),(0,A.jsx)(y,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>void Y(),children:n.workHome.retry})]}):null,k?(0,A.jsx)(ue,{}):u?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`section`,{className:`relative overflow-hidden rounded-2xl border border-accent/15 bg-gradient-to-br from-accent-soft/70 via-surface-panel to-surface-panel p-5 sm:p-6`,children:[(0,A.jsx)(`div`,{className:`absolute -right-8 -top-12 size-40 rounded-full bg-accent/10 blur-3xl`,"aria-hidden":!0}),(0,A.jsxs)(`div`,{className:`relative flex flex-wrap items-end justify-between gap-4`,children:[(0,A.jsxs)(`div`,{className:`max-w-2xl`,children:[(0,A.jsx)(`div`,{className:`mb-3 flex size-10 items-center justify-center rounded-xl bg-accent text-white`,children:(0,A.jsx)(m,{className:`size-5`,"aria-hidden":!0})}),(0,A.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-wider text-accent`,children:n.workHome.briefingTitle}),(0,A.jsx)(`h2`,{className:`mt-1 text-xl font-semibold tracking-tight text-fg`,children:n.workHome.heroTitle}),(0,A.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:u.briefing.summary})]}),(0,A.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-xs`,children:[(0,A.jsx)(`span`,{className:`rounded-full bg-surface-panel/80 px-3 py-1.5 text-fg-muted`,children:j(n.workHome.activeCount,{count:u.briefing.progress.movingCount})}),u.decisions.length>0?(0,A.jsx)(`span`,{className:`rounded-full bg-warning-soft px-3 py-1.5 text-fg`,children:j(n.workHome.attentionCount,{count:u.decisions.length})}):null]})]})]}),u.work.current.length===0&&u.workflowRuns.active.length===0?(0,A.jsxs)(`section`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center`,children:[(0,A.jsx)(ae,{className:`mx-auto size-6 text-accent`,"aria-hidden":!0}),(0,A.jsx)(`h2`,{className:`mt-3 text-sm font-semibold text-fg`,children:n.workHome.emptyTitle}),(0,A.jsx)(`p`,{className:`mx-auto mt-1 max-w-lg text-sm leading-6 text-fg-muted`,children:n.workHome.emptyBody}),(0,A.jsxs)(`div`,{className:`mt-4 flex justify-center gap-2`,children:[(0,A.jsx)(y,{type:`button`,variant:`primary`,onClick:()=>r(`/chat/new`),children:n.workHome.startChat}),(0,A.jsx)(y,{type:`button`,variant:`secondary`,onClick:()=>{U(`delegate`),V(!0)},children:n.workHome.startLongWork})]})]}):null,(0,A.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,A.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(s,{className:`size-4 text-warning`,"aria-hidden":!0}),(0,A.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.workHome.needsYou})]}),(0,A.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.workHome.needsYouHint}),(0,A.jsx)(`div`,{className:`mt-4 space-y-2`,children:Z.length?Z.map(e=>(0,A.jsx)(fe,{item:e,kindLabel:n.workHome.decisionKinds[e.kind],reasonLabel:n.workHome.decisionReasons[e.reason],approveLabel:n.workHome.approve,denyLabel:n.workHome.deny,busy:me===e.id,onRespond:t=>void ge(e,t)},e.id)):(0,A.jsx)(`p`,{className:`rounded-xl bg-surface-panel px-4 py-6 text-center text-sm text-fg-muted`,children:n.workHome.nothingNeedsYou})})]}),(0,A.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(C,{className:`size-4 text-accent`,"aria-hidden":!0}),(0,A.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.workHome.continueTitle})]}),(0,A.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.workHome.continueHint}),(0,A.jsx)(`div`,{className:`mt-4 space-y-2`,children:Q.length?Q.map(e=>(0,A.jsx)(de,{item:e,statusLabel:t.projectDetailPage.workItems.statuses[e.status]},e.id)):(0,A.jsx)(`p`,{className:`rounded-xl bg-surface-panel px-4 py-6 text-center text-sm text-fg-muted`,children:n.workHome.noCurrentWork})})]})]}),u.workflowRuns.active.length>0||u.upcomingAutomations.length>0?(0,A.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,A.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(E,{className:`size-4 text-accent`,"aria-hidden":!0}),(0,A.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.workHome.processing})]}),(0,A.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[u.workflowRuns.active.map(e=>(0,A.jsxs)(a,{to:D(e.id),className:`flex items-center justify-between gap-3 rounded-xl bg-surface-panel px-3 py-3 text-sm hover:bg-surface-hover`,children:[(0,A.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.title}),(0,A.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:n.workHome.running})]},e.id)),u.workflowRuns.active.length===0?(0,A.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.workHome.nothingRunning}):null]})]}),(0,A.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(f,{className:`size-4 text-accent`,"aria-hidden":!0}),(0,A.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.workHome.scheduled})]}),(0,A.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[u.upcomingAutomations.map(e=>(0,A.jsxs)(a,{to:`/automations`,className:`flex items-center justify-between gap-3 rounded-xl bg-surface-panel px-3 py-3 text-sm hover:bg-surface-hover`,children:[(0,A.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.name||e.action}),(0,A.jsx)(`time`,{className:`shrink-0 text-xs text-fg-subtle`,children:M(e.nextRunAt,n.never)})]},e.id)),u.upcomingAutomations.length===0?(0,A.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.workHome.noScheduled}):null]})]})]}):null,u.briefing.wins.length>0?(0,A.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(_,{className:`size-4 text-success`,"aria-hidden":!0}),(0,A.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.workHome.completed})]}),(0,A.jsx)(`div`,{className:`mt-3 grid gap-2 md:grid-cols-2 xl:grid-cols-3`,children:u.briefing.wins.map(e=>(0,A.jsxs)(a,{to:e.href,className:`rounded-xl border border-edge-subtle bg-surface-panel p-3.5 transition-colors hover:bg-surface-hover/55`,children:[(0,A.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:e.title}),(0,A.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.workHome.winKinds[e.kind]})]},e.id))})]}):null]}):null,(0,A.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,A.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.workHome.spacesTitle}),(0,A.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.workHome.spacesHint})]}),(0,A.jsxs)(`label`,{className:`relative block min-w-0`,children:[(0,A.jsx)(g,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,A.jsx)(`input`,{className:`h-9 w-52 rounded-lg border border-edge bg-surface-panel pl-9 pr-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`,value:z,onChange:e=>B(e.target.value),placeholder:n.searchPlaceholder,"aria-label":n.searchPlaceholder})]})]}),(0,A.jsx)(`div`,{className:`mt-4 grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:X.map(e=>(0,A.jsx)(N,{project:e,openLabel:n.workHome.openSpace,noDescription:n.noDescription},e.id))}),!k&&X.length===0?(0,A.jsx)(`p`,{className:`py-8 text-center text-sm text-fg-muted`,children:n.workHome.noSpaces}):null]})]})}export{P as ProjectsPage};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,t as a}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as o}from"./cn-BQ_8x0bT.js";import{t as s}from"./check-BODqo66o.js";import{t as c}from"./copy-to-clipboard-HOJ79TWv.js";import{t as l}from"./messages-Cb1VMeqP.js";import{d as u,f as d,i as f,n as p,o as m,p as h,r as g}from"./locale-store-CiM-D9jA.js";import{a as _,i as v}from"./vendor-swr-BIWyz7Rc.js";import{$r as y,Ac as b,Ao as x,Ba as S,Bo as C,Dl as w,Ds as T,Gr as E,Hr as D,In as O,Jo as k,Jr as A,Kr as j,Ks as M,Ms as N,Ot as P,Qr as F,Ra as I,So as L,Ts as R,Uc as z,Ur as B,Vs as ee,Wr as V,Xr as H,Yo as U,Yr as W,Zr as te,_l as ne,_o as G,bi as re,co as K,do as q,ei as J,gc as ie,go as Y,ho as X,ko as ae,ls as oe,mo as se,oc as ce,po as le,ps as ue,qr as de,sl as fe,tl as pe,wn as me,za as he}from"./index-BJGusbyV.js";import{n as ge,r as _e,t as ve}from"./settings-page-layout-DjbdpK2j.js";import{t as ye}from"./settings-collapsible-section-BB5y9vwh.js";import{n as be,r as xe,t as Se}from"./settings-form-section-BfzJkVHd.js";import{t as Ce}from"./browser-BLJWD7WI.js";import{t as we}from"./page-tabs-CGVMJEW0.js";var Z=n(),Q=e(t(),1);function Te(e,t){let{mutate:n}=_(),[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(!1),l=(0,Q.useCallback)(async()=>{await Promise.all([n(`tunnel-pair-context`),n(`tunnel-pair`),n(`tunnel-status`),I()])},[n]);return{busy:r,error:a,confirmOpen:s,setConfirmOpen:c,runEnableLanPairing:(0,Q.useCallback)(async()=>{if(!(!e||r)){i(!0),o(null);try{let n=await j();if(!n.ok)throw Error(`Failed to enable LAN pairing`);if(n.requiresRestart){let t=await D();if(!t.ok)throw Error(t.message??`Gateway restart failed`);if(!await B(e))throw Error(`Gateway did not come back online in time`)}let r=n.requiresRestart?await V():n.context;if(!r?.pairingReady)throw Error(`LAN pairing is still not ready after restart`);return await l(),t?.(r),c(!1),r}catch(e){return o(e instanceof Error?e.message:`Enable LAN pairing failed`),null}finally{i(!1)}}},[r,e,t,l]),clearError:()=>o(null)}}var $=r();function Ee(){return o(`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 De(e){let t=(0,Z.c)(122),{pairQr:n,gatewayToken:r,streamlined:i,lanOnly:s,onRefreshQr:c}=e,u=i===void 0?!1:i,d=s===void 0?!1:s,f=p(Ae),m;t[0]===f?m=t[1]:(m=l(f),t[0]=f,t[1]=m);let h=m,g=h.tunnelSettings,_=d?h.remoteAccess.lan:null,v;t[2]!==h.clipboard.copyFailed||t[3]!==g.pairCopied||t[4]!==g.pairCopyLink?(v={copy:g.pairCopyLink,copied:g.pairCopied,copyFailed:h.clipboard.copyFailed},t[2]=h.clipboard.copyFailed,t[3]=g.pairCopied,t[4]=g.pairCopyLink,t[5]=v):v=t[5];let y=v,{tunnelActive:b,tunnelStatus:x,tunnelQr:S,pairContext:C,pairBaseUrl:w,setPairBaseUrl:T,applySuggestedPairUrl:E,applyCandidateUrl:D,resetPairBaseFromContext:k,baseOk:A,localhostWarn:j,pairingBlocked:M,deepLink:N,qrPayload:P,qrDataUrl:F,qrGenFailed:I,encoding:L}=n,z;t[6]===k?z=t[7]:(z=e=>{k(e.recommended.url)},t[6]=k,t[7]=z);let B=Te(r,z),V,H,W,te,ne;if(t[8]!==D||t[9]!==E||t[10]!==A||t[11]!==B||t[12]!==r||t[13]!==_||t[14]!==d||t[15]!==j||t[16]!==c||t[17]!==w||t[18]!==C?.candidates||t[19]!==C?.recommended||t[20]!==M||t[21]!==T||t[22]!==u||t[23]!==g.pairBaseUrlHint||t[24]!==g.pairBaseUrlLabel||t[25]!==g.pairBaseUrlPlaceholder||t[26]!==g.pairBlockedLoopbackBody||t[27]!==g.pairBlockedNextSteps||t[28]!==g.pairBlockedTitle||t[29]!==g.pairCandidatesTitle||t[30]!==g.pairEnableLanButton||t[31]!==g.pairEnableLanEnabling||t[32]!==g.pairEnableLanSecurityAuditLink||t[33]!==g.pairInvalidBaseUrl||t[34]!==g.pairLocalhostWarning||t[35]!==g.pairSelectCandidateHint||t[36]!==g.pairSelectCandidateTitle||t[37]!==g.pairSubtitle||t[38]!==g.pairSuggestedLanLabel||t[39]!==g.pairTitle||t[40]!==g.pairTunnelActive||t[41]!==g.pairTunnelLanUrl||t[42]!==g.pairTunnelPublicUrl||t[43]!==g.pairUseSuggestedUrl||t[44]!==g.pairWaitingForTunnel||t[45]!==g.refreshQr||t[46]!==b||t[47]!==S||t[48]!==x?.publicUrl){ne=Symbol.for(`react.early_return_sentinel`);bb0:{let e=C?.candidates.filter(ke)??[],n=d?(e.find(Oe)?.url??e[0]?.url??``).trim():C?.recommended.url?.trim()??``,i=(d||!b)&&e.length>1,s=function(t){if(e.length===0)return null;let n=t===`amber`?`text-amber-950 dark:text-amber-100`:`text-fg`,r=t===`amber`?`text-amber-950/80 dark:text-amber-200/90`:`text-fg-muted`;return(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:o(`text-xs font-medium`,r),children:i?g.pairSelectCandidateTitle:g.pairCandidatesTitle}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1`,children:e.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,className:o(`w-full rounded-md border px-2 py-1.5 text-left font-mono text-[11px] transition-colors`,t===`amber`?`border-amber-300/70 hover:bg-amber-100/80 dark:border-amber-800 dark:hover:bg-amber-950/50`:`border-edge hover:bg-surface-panel`,w.trim()===e.url&&`border-accent bg-accent/5`,n),onClick:()=>D(e.url),children:[e.label?`${e.label}: `:``,e.url]})},e.url))}),i?(0,$.jsx)(`p`,{className:o(`mt-1 text-[11px] leading-relaxed`,r),children:g.pairSelectCandidateHint}):null]})};if(V=u&&!d,V&&!b){let e;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(R,{className:`size-4 text-accent`,strokeWidth:1.75}),t[54]=e):e=t[54];let n;t[55]===g.pairTitle?n=t[56]:(n=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[e,g.pairTitle]}),t[55]=g.pairTitle,t[56]=n);let r;t[57]===g.pairWaitingForTunnel?r=t[58]:(r=(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:g.pairWaitingForTunnel}),t[57]=g.pairWaitingForTunnel,t[58]=r);let i;t[59]!==n||t[60]!==r?(i=(0,$.jsxs)(Se,{children:[n,r]}),t[59]=n,t[60]=r,t[61]=i):i=t[61],ne=i;break bb0}let l=_?.pairTitle??g.pairTitle,f=d?_?.pairSubtitle??g.pairSubtitle:b?g.pairTunnelActive:g.pairSubtitle,p=!!(c&&(d||u&&b)),m=V?`mb-2`:`mb-3`,h;t[62]===m?h=t[63]:(h=o(`flex flex-wrap items-start justify-between gap-2`,m),t[62]=m,t[63]=h);let v;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(R,{className:`size-4 text-accent`,strokeWidth:1.75}),t[64]=v):v=t[64];let y;t[65]===l?y=t[66]:(y=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[v,l]}),t[65]=l,t[66]=y);let O;t[67]!==V||t[68]!==f||t[69]!==g.pairSubtitle?(O=V?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:g.pairSubtitle}):(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:f}),t[67]=V,t[68]=f,t[69]=g.pairSubtitle,t[70]=O):O=t[70];let k;t[71]!==y||t[72]!==O?(k=(0,$.jsxs)(`div`,{children:[y,O]}),t[71]=y,t[72]=O,t[73]=k):k=t[73];let N;t[74]!==c||t[75]!==p||t[76]!==g.refreshQr?(N=p?(0,$.jsxs)(U,{type:`button`,variant:`ghost`,className:`shrink-0`,onClick:()=>void c(),children:[(0,$.jsx)(ee,{className:`size-4`}),g.refreshQr]}):null,t[74]=c,t[75]=p,t[76]=g.refreshQr,t[77]=N):N=t[77],t[78]!==h||t[79]!==k||t[80]!==N?(H=(0,$.jsxs)(`div`,{className:h,children:[k,N]}),t[78]=h,t[79]=k,t[80]=N,t[81]=H):H=t[81],W=M?(0,$.jsxs)(`div`,{className:`mb-3 space-y-3 rounded-lg border border-amber-200 bg-amber-50 px-3 py-3 dark:border-amber-900/50 dark:bg-amber-950/30`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-amber-950 dark:text-amber-100`,children:g.pairBlockedTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-amber-900 dark:text-amber-200`,children:g.pairBlockedLoopbackBody})]}),n?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-amber-950/80 dark:text-amber-200/90`,children:g.pairSuggestedLanLabel}),(0,$.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-amber-950 dark:text-amber-100`,children:n})]}),(0,$.jsx)(U,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,onClick:E,children:g.pairUseSuggestedUrl})]}):null,e.length>0?s(`amber`):null,(0,$.jsx)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap`,children:(0,$.jsxs)(U,{type:`button`,className:`w-full sm:w-auto`,disabled:B.busy||!r,onClick:()=>B.setConfirmOpen(!0),children:[B.busy?(0,$.jsx)(ie,{className:`size-3.5 animate-spin`}):null,B.busy?g.pairEnableLanEnabling:g.pairEnableLanButton]})}),B.error?(0,$.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:B.error}):null,(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-amber-900 dark:text-amber-200`,children:d?_?.pairBlockedNextSteps??g.pairBlockedNextSteps:g.pairBlockedNextSteps}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(a,{to:`/settings/gateway`,className:`inline-block text-xs font-medium text-accent hover:underline`,children:g.pairEnableLanSecurityAuditLink}),d&&_?.pairPublicTabLink?(0,$.jsx)(a,{to:`/settings/remote-access?tab=public`,className:`inline-block text-xs font-medium text-accent hover:underline`,children:_.pairPublicTabLink}):null]})]}):null,te=b&&!d?V?null:(0,$.jsxs)(`div`,{className:`mb-3 space-y-2 rounded-lg bg-surface-panel/80 px-3 py-3 shadow-surface`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.pairTunnelPublicUrl}),(0,$.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-fg`,children:x?.publicUrl})]}),S?.lanUrl?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.pairTunnelLanUrl}),(0,$.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-fg`,children:S.lanUrl})]}):null]}):(0,$.jsxs)(`div`,{className:`mb-3 space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`tunnel-mobile-pair-base`,children:g.pairBaseUrlLabel}),(0,$.jsx)(`input`,{id:`tunnel-mobile-pair-base`,className:o(Ee(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:n||g.pairBaseUrlPlaceholder,value:w,onChange:e=>T(e.target.value)}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:g.pairBaseUrlHint}),!A&&w.trim()?(0,$.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:g.pairInvalidBaseUrl}):null,j?(0,$.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:g.pairLocalhostWarning}):null,i?s(`neutral`):null]})}t[8]=D,t[9]=E,t[10]=A,t[11]=B,t[12]=r,t[13]=_,t[14]=d,t[15]=j,t[16]=c,t[17]=w,t[18]=C?.candidates,t[19]=C?.recommended,t[20]=M,t[21]=T,t[22]=u,t[23]=g.pairBaseUrlHint,t[24]=g.pairBaseUrlLabel,t[25]=g.pairBaseUrlPlaceholder,t[26]=g.pairBlockedLoopbackBody,t[27]=g.pairBlockedNextSteps,t[28]=g.pairBlockedTitle,t[29]=g.pairCandidatesTitle,t[30]=g.pairEnableLanButton,t[31]=g.pairEnableLanEnabling,t[32]=g.pairEnableLanSecurityAuditLink,t[33]=g.pairInvalidBaseUrl,t[34]=g.pairLocalhostWarning,t[35]=g.pairSelectCandidateHint,t[36]=g.pairSelectCandidateTitle,t[37]=g.pairSubtitle,t[38]=g.pairSuggestedLanLabel,t[39]=g.pairTitle,t[40]=g.pairTunnelActive,t[41]=g.pairTunnelLanUrl,t[42]=g.pairTunnelPublicUrl,t[43]=g.pairUseSuggestedUrl,t[44]=g.pairWaitingForTunnel,t[45]=g.refreshQr,t[46]=b,t[47]=S,t[48]=x?.publicUrl,t[49]=V,t[50]=H,t[51]=W,t[52]=te,t[53]=ne}else V=t[49],H=t[50],W=t[51],te=t[52],ne=t[53];if(ne!==Symbol.for(`react.early_return_sentinel`))return ne;let G;t[82]===g.pairSecurityNote?G=t[83]:(G=(0,$.jsx)(`p`,{className:`mb-3 text-xs text-fg-subtle`,children:g.pairSecurityNote}),t[82]=g.pairSecurityNote,t[83]=G);let K;t[84]!==y||t[85]!==N||t[86]!==L||t[87]!==M||t[88]!==F||t[89]!==I||t[90]!==g.pairEncoding||t[91]!==g.pairImageError||t[92]!==g.pairQrDisabled?(K=N?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 sm:items-start`,children:[F&&!I?(0,$.jsx)(`img`,{src:F,alt:``,className:`size-56 rounded-lg border border-edge-subtle bg-white object-contain p-3 dark:border-edge`}):null,L?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:g.pairEncoding}):null,I?(0,$.jsx)(`p`,{className:`text-center text-sm text-fg-muted sm:text-left`,children:g.pairImageError}):null,(0,$.jsx)(re,{text:N,labels:y})]}):M?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:g.pairQrDisabled}):null,t[84]=y,t[85]=N,t[86]=L,t[87]=M,t[88]=F,t[89]=I,t[90]=g.pairEncoding,t[91]=g.pairImageError,t[92]=g.pairQrDisabled,t[93]=K):K=t[93];let q;t[94]!==V||t[95]!==P||t[96]!==g.deeplinkTitle?(q=P&&!V?(0,$.jsxs)(`details`,{className:`mt-3 rounded-lg bg-surface-panel/80 px-3 py-2 shadow-surface`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-fg-muted`,children:g.deeplinkTitle}),(0,$.jsx)(`p`,{className:`mt-2 break-all font-mono text-[10px] leading-relaxed text-fg-subtle`,children:P})]}):null,t[94]=V,t[95]=P,t[96]=g.deeplinkTitle,t[97]=q):q=t[97];let J;t[98]!==V||t[99]!==g.pairMobileProbeHint||t[100]!==g.pairSchemeHint?(J=V?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`mt-3 break-all font-mono text-[10px] leading-relaxed text-fg-subtle`,children:g.pairSchemeHint}),(0,$.jsx)(`p`,{className:`mt-1 text-[10px] leading-relaxed text-fg-subtle`,children:g.pairMobileProbeHint})]}),t[98]=V,t[99]=g.pairMobileProbeHint,t[100]=g.pairSchemeHint,t[101]=J):J=t[101];let Y,X;t[102]===B?(Y=t[103],X=t[104]):(Y=()=>void B.runEnableLanPairing(),X=()=>{B.busy||B.setConfirmOpen(!1)},t[102]=B,t[103]=Y,t[104]=X);let ae;t[105]!==B.confirmOpen||t[106]!==g.consentCancel||t[107]!==g.pairEnableLanButton||t[108]!==g.pairEnableLanConfirmBody||t[109]!==g.pairEnableLanConfirmTitle||t[110]!==Y||t[111]!==X?(ae=(0,$.jsx)(O,{open:B.confirmOpen,title:g.pairEnableLanConfirmTitle,description:g.pairEnableLanConfirmBody,confirmLabel:g.pairEnableLanButton,cancelLabel:g.consentCancel,onConfirm:Y,onCancel:X}),t[105]=B.confirmOpen,t[106]=g.consentCancel,t[107]=g.pairEnableLanButton,t[108]=g.pairEnableLanConfirmBody,t[109]=g.pairEnableLanConfirmTitle,t[110]=Y,t[111]=X,t[112]=ae):ae=t[112];let oe;return t[113]!==G||t[114]!==K||t[115]!==q||t[116]!==J||t[117]!==ae||t[118]!==H||t[119]!==W||t[120]!==te?(oe=(0,$.jsx)(Se,{children:(0,$.jsxs)($.Fragment,{children:[H,W,te,G,K,q,J,ae]})}),t[113]=G,t[114]=K,t[115]=q,t[116]=J,t[117]=ae,t[118]=H,t[119]=W,t[120]=te,t[121]=oe):oe=t[121],oe}function Oe(e){return e.reachable}function ke(e){return e.kind===`lan`}function Ae(e){return e.language}function je(e){let t=(0,Z.c)(40),{open:n,title:r,intro:i,bullets:a,checkboxLabel:s,confirmLabel:c,cancelLabel:l,onConfirm:u,onCancel:d}=e,[f,p]=(0,Q.useState)(!1),m;t[0]===d?m=t[1]:(m=e=>{e||(p(!1),d())},t[0]=d,t[1]=m);let h;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(X,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,x)}),t[2]=h):h=t[2];let g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=o(`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`,ae),t[3]=g):g=t[3];let _;t[4]===r?_=t[5]:(_=(0,$.jsx)(G,{className:`text-base font-semibold text-fg`,children:r}),t[4]=r,t[5]=_);let v;t[6]===i?v=t[7]:(v=(0,$.jsx)(se,{className:`mt-2 text-sm text-fg-muted`,children:i}),t[6]=i,t[7]=v);let y;t[8]===a?y=t[9]:(y=a.map(Me),t[8]=a,t[9]=y);let b;t[10]===y?b=t[11]:(b=(0,$.jsx)(`ul`,{className:`mt-4 list-disc space-y-2 pl-5 text-sm text-fg-muted`,children:y}),t[10]=y,t[11]=b);let S;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(S=e=>p(e.target.checked),t[12]=S):S=t[12];let C;t[13]===f?C=t[14]:(C=(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 shrink-0 rounded border-edge accent-accent`,checked:f,onChange:S}),t[13]=f,t[14]=C);let w;t[15]===s?w=t[16]:(w=(0,$.jsx)(`span`,{children:s}),t[15]=s,t[16]=w);let T;t[17]!==w||t[18]!==C?(T=(0,$.jsxs)(`label`,{className:`mt-5 flex cursor-pointer items-start gap-3 text-sm text-fg`,children:[C,w]}),t[17]=w,t[18]=C,t[19]=T):T=t[19];let E;t[20]!==l||t[21]!==d?(E=(0,$.jsx)(U,{type:`button`,variant:`secondary`,onClick:d,children:l}),t[20]=l,t[21]=d,t[22]=E):E=t[22];let D=!f,O;t[23]!==c||t[24]!==u||t[25]!==D?(O=(0,$.jsx)(U,{type:`button`,disabled:D,onClick:u,children:c}),t[23]=c,t[24]=u,t[25]=D,t[26]=O):O=t[26];let k;t[27]!==E||t[28]!==O?(k=(0,$.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[E,O]}),t[27]=E,t[28]=O,t[29]=k):k=t[29];let A;t[30]!==T||t[31]!==k||t[32]!==_||t[33]!==v||t[34]!==b?(A=(0,$.jsxs)(Y,{children:[h,(0,$.jsxs)(le,{className:g,onOpenAutoFocus:Ne,children:[_,v,b,T,k]})]}),t[30]=T,t[31]=k,t[32]=_,t[33]=v,t[34]=b,t[35]=A):A=t[35];let j;return t[36]!==n||t[37]!==m||t[38]!==A?(j=(0,$.jsx)(q,{open:n,onOpenChange:m,children:A}),t[36]=n,t[37]=m,t[38]=A,t[39]=j):j=t[39],j}function Me(e){return(0,$.jsx)(`li`,{children:e},e)}function Ne(e){return e.preventDefault()}function Pe(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var Fe=[`preparing_frpc`,`registering`,`starting_frpc`];function Ie(e){return e?e===`reconnecting_frpc`?Fe.indexOf(`starting_frpc`):Fe.indexOf(e):-1}function Le(e,t){if(t.state===`connected`)return`done`;let n=t.startProgress?.phase,r=Fe.indexOf(e),i=Ie(n);return i<0?t.state===`connecting`||t.state===`reconnecting`?`active`:`pending`:r<i?`done`:r===i?`active`:`pending`}function Re(e,t,n){let r=n.startProgress;return Le(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 ze(e,t){switch(t){case`preparing_frpc`:return e.stepPrepareFrpc;case`registering`:return e.stepRegister;case`starting_frpc`:return e.stepFrpcLogin}}function Be(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 Ve(e){let t=(0,Z.c)(31),{status:n,t:r}=e,[,i]=(0,Q.useState)(0),a;t[0]!==i||t[1]!==n.state?(a=()=>{if(n.state!==`connecting`&&n.state!==`reconnecting`)return;let e=window.setInterval(()=>i(He),1e3);return()=>window.clearInterval(e)},t[0]=i,t[1]=n.state,t[2]=a):a=t[2];let c=n.startProgress?.startedAt,l;if(t[3]!==n.state||t[4]!==c?(l=[n.state,c],t[3]=n.state,t[4]=c,t[5]=l):l=t[5],(0,Q.useEffect)(a,l),!(n.state===`connecting`||n.state===`reconnecting`||n.state===`connected`&&n.startProgress))return null;let u,d,f,p,m;if(t[6]!==n||t[7]!==r){let e=Be(n.startProgress?.startedAt);u=!!n.publicUrl&&n.state!==`connected`&&n.startProgress?.phase!==`registering`,d=`mt-3 space-y-3 rounded-lg bg-surface-panel/80 px-3 py-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?(f=(0,$.jsxs)(`div`,{children:[i,a]}),t[17]=i,t[18]=a,t[19]=f):f=t[19];let c=Fe.map(e=>{let t=Le(e,n),i=Re(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)(s,{className:`size-3.5 text-emerald-600 dark:text-emerald-400`}):t===`active`?(0,$.jsx)(ie,{className:`size-3.5 animate-spin text-accent`}):(0,$.jsx)(ne,{className:`size-3.5`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:o(`font-medium`,t===`active`?`text-fg`:t===`done`?`text-fg-muted`:`text-fg-subtle`),children:ze(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:o(`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:[Pe(n.frpcDownload.bytesReceived),` /`,` `,Pe(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]===c?p=t[21]:(p=(0,$.jsx)(`ol`,{className:`space-y-2`,children:c}),t[20]=c,t[21]=p),m=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]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m}else u=t[8],d=t[9],f=t[10],p=t[11],m=t[12];let h;t[22]!==u||t[23]!==r.publicUrlPendingNotice?(h=u?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.publicUrlPendingNotice}):null,t[22]=u,t[23]=r.publicUrlPendingNotice,t[24]=h):h=t[24];let g;return t[25]!==d||t[26]!==f||t[27]!==p||t[28]!==m||t[29]!==h?(g=(0,$.jsxs)(`div`,{className:d,children:[f,p,m,h]}),t[25]=d,t[26]=f,t[27]=p,t[28]=m,t[29]=h,t[30]=g):g=t[30],g}function He(e){return e+1}function Ue(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 We(e){return e.state===`connected`?`connected`:e.state===`error`?`error`:e.state===`connecting`||e.state===`reconnecting`||e.startProgress||e.frpcDownload?`progress`:`off`}function Ge(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 Ke(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 qe(e){let t=(0,Z.c)(61),{t:n,status:r,isLoading:i,statusErr:a,starting:s,stopping:c,showConsentExpired:l,copyLabels:u,startDisabled:d,startDisabledReason:f,stepLabel:p,onStart:m,onStop:h}=e,g=d===void 0?!1:d,_,v,y,b,x,S,C;t[0]!==r||t[1]!==s?(C=We(r),_=r.enabled||s,v=s||r.state===`connecting`||r.state===`reconnecting`||!!r.startProgress||!!r.frpcDownload,t[9]===Symbol.for(`react.memo_cache_sentinel`)?(S=o(xe(),`space-y-4`),t[9]=S):S=t[9],x=`flex flex-wrap items-start justify-between gap-3`,b=`flex items-center gap-2`,y=o(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,Ge(C)),t[0]=r,t[1]=s,t[2]=_,t[3]=v,t[4]=y,t[5]=b,t[6]=x,t[7]=S,t[8]=C):(_=t[2],v=t[3],y=t[4],b=t[5],x=t[6],S=t[7],C=t[8]);let w=C===`connected`&&`bg-emerald-500`,T=C===`progress`&&`bg-amber-500 animate-pulse`,E=C===`error`&&`bg-red-500`,D=C===`off`&&`bg-fg-subtle`,O;t[10]!==w||t[11]!==T||t[12]!==E||t[13]!==D?(O=o(`size-1.5 rounded-full`,w,T,E,D),t[10]=w,t[11]=T,t[12]=E,t[13]=D,t[14]=O):O=t[14];let k;t[15]===O?k=t[16]:(k=(0,$.jsx)(`span`,{className:O,"aria-hidden":!0}),t[15]=O,t[16]=k);let A;t[17]!==i||t[18]!==r||t[19]!==n?(A=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`}):Ue(n,r),t[17]=i,t[18]=r,t[19]=n,t[20]=A):A=t[20];let j;t[21]!==k||t[22]!==A||t[23]!==y?(j=(0,$.jsxs)(`span`,{className:y,children:[k,A]}),t[21]=k,t[22]=A,t[23]=y,t[24]=j):j=t[24];let N;t[25]!==r.connectedSince||t[26]!==r.state||t[27]!==n.uptime?(N=r.connectedSince&&r.state===`connected`?(0,$.jsxs)(`span`,{className:`text-xs text-fg-subtle`,children:[n.uptime,` `,Ke(r.connectedSince)]}):null,t[25]=r.connectedSince,t[26]=r.state,t[27]=n.uptime,t[28]=N):N=t[28];let P;t[29]!==j||t[30]!==N||t[31]!==b?(P=(0,$.jsxs)(`div`,{className:b,children:[j,N]}),t[29]=j,t[30]=N,t[31]=b,t[32]=P):P=t[32];let F;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(z,{className:`size-4 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[33]=F):F=t[33];let I;t[34]!==P||t[35]!==x?(I=(0,$.jsxs)(`div`,{className:x,children:[P,F]}),t[34]=P,t[35]=x,t[36]=I):I=t[36];let L;t[37]===a?L=t[38]:(L=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]=L);let R;t[39]!==l||t[40]!==n.consentExpiredBanner?(R=l?(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]=l,t[40]=n.consentExpiredBanner,t[41]=R):R=t[41];let B;t[42]!==_||t[43]!==u||t[44]!==m||t[45]!==h||t[46]!==v||t[47]!==r||t[48]!==g||t[49]!==f||t[50]!==s||t[51]!==p||t[52]!==c||t[53]!==n?(B=_?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[r.publicUrl?(0,$.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 px-3 py-3 shadow-surface`,children:(0,$.jsx)(re,{label:n.publicUrlLabel,text:r.publicUrl,labels:u})}):null,v?(0,$.jsx)(Ve,{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)(U,{type:`button`,variant:`secondary`,disabled:c,onClick:h,children:[c?(0,$.jsx)(ie,{className:`size-4 animate-spin`}):null,n.stop]}):(0,$.jsxs)(U,{type:`button`,disabled:s,onClick:m,children:[s?(0,$.jsx)(ie,{className:`size-4 animate-spin`}):(0,$.jsx)(M,{className:`size-4`}),n.start]})})]}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[p?(0,$.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:p}):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)(oe,{className:`mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-400`}),(0,$.jsx)(`p`,{children:n.riskBannerBody})]}),g&&f?(0,$.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200`,children:f}):null,(0,$.jsxs)(U,{type:`button`,disabled:s||g,onClick:m,className:`w-full sm:w-auto`,children:[s?(0,$.jsx)(ie,{className:`size-4 animate-spin`}):(0,$.jsx)(M,{className:`size-4`}),n.start]})]}),t[42]=_,t[43]=u,t[44]=m,t[45]=h,t[46]=v,t[47]=r,t[48]=g,t[49]=f,t[50]=s,t[51]=p,t[52]=c,t[53]=n,t[54]=B):B=t[54];let ee;return t[55]!==I||t[56]!==L||t[57]!==R||t[58]!==B||t[59]!==S?(ee=(0,$.jsxs)(`section`,{className:S,children:[I,L,R,B]}),t[55]=I,t[56]=L,t[57]=R,t[58]=B,t[59]=S,t[60]=ee):ee=t[60],ee}var Je=`https://console.xopc.ai/keys/tunnel`,Ye={reconfiguring:!1};function Xe(e){let t=(0,Z.c)(84),{t:n,brokerSecretFromEnv:r,brokerSecretMissing:i,brokerSecretConfiguredInConfig:a,brokerSecretMaskedValue:c,brokerSecretDraft:l,savingBrokerSecret:u,brokerSecretNotice:d,copyFailedLabel:f,onDraftChange:p,onSave:m,onClear:h,sectionRef:g}=e,_=(0,Q.useId)(),v=i&&!r,y=!v,[x,S]=(0,Q.useReducer)(P,Ye),{reconfiguring:w}=x,T;t[0]!==a||t[1]!==l||t[2]!==r||t[3]!==w?(T=a&&!r&&!w&&!l.trim(),t[0]=a,t[1]=l,t[2]=r,t[3]=w,t[4]=T):T=t[4];let E=T,D;t[5]!==n.copied||t[6]!==n.copyKey||t[7]!==n.hideKey||t[8]!==n.showKey?(D={show:n.showKey,hide:n.hideKey,copy:n.copyKey,copied:n.copied},t[5]=n.copied,t[6]=n.copyKey,t[7]=n.hideKey,t[8]=n.showKey,t[9]=D):D=t[9];let O=D,k;t[10]===l?k=t[11]:(k=l.trim().length>0&&!me(l.trim()),t[10]=l,t[11]=k);let A=k,j;t[12]===p?j=t[13]:(j=()=>{S({type:`patch`,patch:{reconfiguring:!1}}),p(``)},t[12]=p,t[13]=j);let M=j,N=v&&`ring-1 ring-amber-500/30`,F;t[14]===N?F=t[15]:(F=o(N),t[14]=N,t[15]=F);let I=y?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`:v?`bg-amber-500/10 text-amber-700 dark:text-amber-400`:`bg-surface-hover text-fg-muted`,L;t[16]===I?L=t[17]:(L=o(`flex size-9 shrink-0 items-center justify-center rounded-lg`,I),t[16]=I,t[17]=L);let R;t[18]===y?R=t[19]:(R=y?(0,$.jsx)(s,{className:`size-4`,strokeWidth:2,"aria-hidden":!0}):(0,$.jsx)(b,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[18]=y,t[19]=R);let z;t[20]!==L||t[21]!==R?(z=(0,$.jsx)(`span`,{className:L,children:R}),t[20]=L,t[21]=R,t[22]=z):z=t[22];let B=y?n.brokerSecretReadyTitle:n.brokerSecretStepTitle,ee;t[23]===B?ee=t[24]:(ee=(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:B}),t[23]=B,t[24]=ee);let V=y?n.brokerSecretReadyHint:n.brokerSecretHint,H;t[25]===V?H=t[26]:(H=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:V}),t[25]=V,t[26]=H);let W;t[27]!==v||t[28]!==n.brokerSecretMissingHint?(W=v?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-amber-800 dark:text-amber-200`,children:n.brokerSecretMissingHint}):null,t[27]=v,t[28]=n.brokerSecretMissingHint,t[29]=W):W=t[29];let te;t[30]!==ee||t[31]!==H||t[32]!==W?(te=(0,$.jsxs)(`div`,{children:[ee,H,W]}),t[30]=ee,t[31]=H,t[32]=W,t[33]=te):te=t[33];let ne;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,$.jsx)(pe,{className:`size-3`,"aria-hidden":!0}),t[34]=ne):ne=t[34];let G;t[35]===n.brokerSecretConsoleLink?G=t[36]:(G=(0,$.jsxs)(`a`,{href:Je,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,ne]}),t[35]=n.brokerSecretConsoleLink,t[36]=G);let re;t[37]!==r||t[38]!==n.brokerSecretEnvHint?(re=r?(0,$.jsx)(`p`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2 text-xs text-fg-muted shadow-surface`,children:n.brokerSecretEnvHint}):null,t[37]=r,t[38]=n.brokerSecretEnvHint,t[39]=re):re=t[39];let K;t[40]!==a||t[41]!==l||t[42]!==r||t[43]!==c||t[44]!==A||t[45]!==M||t[46]!==f||t[47]!==_||t[48]!==v||t[49]!==h||t[50]!==p||t[51]!==m||t[52]!==w||t[53]!==u||t[54]!==O||t[55]!==E||t[56]!==n.brokerSecretCancelReconfigure||t[57]!==n.brokerSecretClear||t[58]!==n.brokerSecretMaskedHelp||t[59]!==n.brokerSecretNotInConfigFile||t[60]!==n.brokerSecretPlaceholder||t[61]!==n.brokerSecretReconfigure||t[62]!==n.brokerSecretRevealFailed||t[63]!==n.brokerSecretSave||t[64]!==n.brokerSecretSaveAndContinue||t[65]!==n.brokerSecretTitle?(K=E?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:_,children:n.brokerSecretTitle}),(0,$.jsx)(C,{id:_,value:c,labels:O,reveal:Ze,loadFailedLabel:f||n.brokerSecretRevealFailed,maskedHelp:n.brokerSecretMaskedHelp,notInConfigFile:n.brokerSecretNotInConfigFile,readOnly:!0}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(U,{type:`button`,variant:`secondary`,disabled:u,onClick:()=>{S({type:`patch`,patch:{reconfiguring:!0}})},children:n.brokerSecretReconfigure}),(0,$.jsx)(U,{type:`button`,variant:`ghost`,disabled:u,onClick:h,children:n.brokerSecretClear})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:_,children:n.brokerSecretTitle}),(0,$.jsx)(C,{id:_,value:l,onChange:p,placeholder:n.brokerSecretPlaceholder,labels:O,disabled:u}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(U,{type:`button`,disabled:u||!A,onClick:m,children:[u?(0,$.jsx)(ie,{className:`size-4 animate-spin`}):null,v?n.brokerSecretSaveAndContinue:n.brokerSecretSave]}),a||r?(0,$.jsx)(U,{type:`button`,variant:`ghost`,disabled:u,onClick:h,children:n.brokerSecretClear}):null,w?(0,$.jsx)(U,{type:`button`,variant:`ghost`,disabled:u,onClick:M,children:n.brokerSecretCancelReconfigure}):null]})]}),t[40]=a,t[41]=l,t[42]=r,t[43]=c,t[44]=A,t[45]=M,t[46]=f,t[47]=_,t[48]=v,t[49]=h,t[50]=p,t[51]=m,t[52]=w,t[53]=u,t[54]=O,t[55]=E,t[56]=n.brokerSecretCancelReconfigure,t[57]=n.brokerSecretClear,t[58]=n.brokerSecretMaskedHelp,t[59]=n.brokerSecretNotInConfigFile,t[60]=n.brokerSecretPlaceholder,t[61]=n.brokerSecretReconfigure,t[62]=n.brokerSecretRevealFailed,t[63]=n.brokerSecretSave,t[64]=n.brokerSecretSaveAndContinue,t[65]=n.brokerSecretTitle,t[66]=K):K=t[66];let q;t[67]===d?q=t[68]:(q=d?(0,$.jsx)(`p`,{className:`text-xs text-emerald-700 dark:text-emerald-400`,children:d}):null,t[67]=d,t[68]=q);let J;t[69]!==te||t[70]!==G||t[71]!==re||t[72]!==K||t[73]!==q?(J=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[te,G,re,K,q]}),t[69]=te,t[70]=G,t[71]=re,t[72]=K,t[73]=q,t[74]=J):J=t[74];let Y;t[75]!==z||t[76]!==J?(Y=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[z,J]}),t[75]=z,t[76]=J,t[77]=Y):Y=t[77];let X;t[78]!==Y||t[79]!==F?(X=(0,$.jsx)(Se,{className:F,children:Y}),t[78]=Y,t[79]=F,t[80]=X):X=t[80];let ae;return t[81]!==g||t[82]!==X?(ae=(0,$.jsx)(`div`,{ref:g,id:`tunnel-broker-secret-setup`,children:X}),t[81]=g,t[82]=X,t[83]=ae):ae=t[83],ae}function Ze(){return F().then(Qe)}function Qe(e){return e.registrationSecret??null}function $e(e){let t=(0,Z.c)(10),{language:n,label:r,section:i,className:a}=e,s;t[0]!==n||t[1]!==i?(s=L(n,i),t[0]=n,t[1]=i,t[2]=s):s=t[2];let c;t[3]===a?c=t[4]:(c=o(`inline-flex items-center gap-1 text-sm font-medium text-accent hover:underline`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,a),t[3]=a,t[4]=c);let l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(pe,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[5]=l):l=t[5];let u;return t[6]!==r||t[7]!==s||t[8]!==c?(u=(0,$.jsxs)(`a`,{href:s,target:`_blank`,rel:`noreferrer`,className:c,children:[r,l]}),t[6]=r,t[7]=s,t[8]=c,t[9]=u):u=t[9],u}var et=e(Ce(),1),tt={width:216,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}};async function nt(e){return et.toDataURL(e,tt)}function rt(e){let t=e?.candidates??[],n=t.find(e=>e.kind===`lan`&&e.reachable),r=t.find(e=>e.kind===`lan`);return(n??r)?.url?.trim()??``}function it(e,t){let n=t.trim();return!n||!e?!1:e.candidates.some(e=>e.kind===`tunnel`&&e.url.trim()===n)}function at(e,t){return e?t?rt(e)||e.recommended.url?.trim()||``:e.recommended.url?.trim()||``:``}function ot(e,t){let n=t?.preferLan===!0,r=!!e,{mutate:i}=_(),a=(0,Q.useRef)(!1),{data:o}=v(r?`tunnel-status`:null,W,{refreshInterval:6e4}),{data:s,mutate:c}=v(r?`tunnel-pair-context`:null,de,{refreshInterval:6e4});(0,Q.useEffect)(()=>{let e=()=>{i(`tunnel-status`),i(`tunnel-qr`),i(`tunnel-pair`),i(`tunnel-pair-context`)};return window.addEventListener(`tunnel-status`,e),()=>window.removeEventListener(`tunnel-status`,e)},[i]);let l=o?.state===`connected`&&!!o.publicUrl?.trim(),u=l&&!n,{data:f,mutate:p}=v(u&&r?`tunnel-qr`:null,A,{refreshInterval:4*6e4}),{data:m,mutate:g}=v(!u&&r&&s?.pairingReady?`tunnel-pair`:null,E,{refreshInterval:4*6e4}),[y,b]=(0,Q.useState)(``),[x,S]=(0,Q.useState)(``),[C,w]=(0,Q.useState)({pairContext:void 0,preferLan:n});if(!a.current&&(s!==C.pairContext||n!==C.preferLan)){w({pairContext:s,preferLan:n});let e=at(s,n);y!==e&&b(e)}let T=(0,Q.useCallback)(e=>{a.current=!0,b(e)},[]),D=(0,Q.useCallback)(()=>{let e=at(s,n);e&&(a.current=!0,b(e))},[s,n]),O=(0,Q.useCallback)(e=>{let t=e.trim();t&&(a.current=!0,b(t))},[]),k=(0,Q.useCallback)(e=>{a.current=!1,b(e?.trim()||at(s,n))},[s,n]),j=y.trim(),M=(0,Q.useMemo)(()=>{try{let e=new URL(j);return e.protocol===`http:`||e.protocol===`https:`}catch{return!1}},[j]),N=M&&h(j),P=!u&&!!(s&&!s.pairingReady&&s.blockReason===`GATEWAY_LOOPBACK_ONLY`),F=!u&&M&&!N&&!!m?.pairingSecret&&(s?.pairingReady===!0||!P),I=(0,Q.useMemo)(()=>{let e=rt(s);return n?e||(j&&!it(s,j)?j:``):j},[s,n,j]),L=(0,Q.useMemo)(()=>{if(!e)return``;if(x.trim())return x.trim();if(u&&f?.qrPayload?.trim())return f.qrPayload.trim();if(!F||!m?.pairingSecret)return``;let t=s?.candidates.find(e=>e.kind===`tunnel`&&e.reachable),r=s?.candidates.find(e=>e.kind===`lan`&&e.reachable),i=n?I:t?.url??j;return i?d({baseUrl:i,pairingSecret:m.pairingSecret,lanUrl:n?null:t&&r?r.url:null}):``},[e,I,m?.pairingSecret,F,x,n,j,u,f?.qrPayload,s?.candidates]),R=K(()=>nt(L),[L],{enabled:!!L,initial:null,errorData:null}),z=L?R.data:null,B=!!(L&&R.error!==null&&!R.loading);return{tunnelActive:l,tunnelStatus:o,tunnelQr:f,pairContext:s,pairBaseUrl:y,setPairBaseUrl:T,applySuggestedPairUrl:D,applyCandidateUrl:O,baseOk:M,localhostWarn:N,pairingBlocked:P,deepLink:L,qrPayload:L,qrDataUrl:z,qrGenFailed:B,encoding:!!(L&&!z&&!B),refreshQr:(0,Q.useCallback)(async e=>{if(e?.trim()){S(e.trim()),p({qrPayload:e.trim(),publicUrl:o?.publicUrl??``,lanUrl:f?.lanUrl??null},!1);return}S(``),await c(),u?await p():s?.pairingReady&&await g()},[g,c,p,s?.pairingReady,f?.lanUrl,o?.publicUrl,u]),resetPairBaseFromContext:k}}var st={actionError:null,starting:!1,stopping:!1,savingAutoStart:!1,consentOpen:!1,autoStartConfirmOpen:!1,releaseConfirmOpen:!1,releasing:!1,brokerSecretDraft:``,savingBrokerSecret:!1,brokerSecretNotice:null};function ct({embedded:e=!1}){let t=p(e=>e.language),n=l(t).tunnelSettings,r=m(e=>e.token),i=!!r,[a,s]=(0,Q.useReducer)(P,st),{actionError:c,starting:u,stopping:d,savingAutoStart:f,consentOpen:h,autoStartConfirmOpen:g,releaseConfirmOpen:_,releasing:b,brokerSecretDraft:x,savingBrokerSecret:S,brokerSecretNotice:C}=a,w=(0,Q.useRef)(null),T=ot(r??``),{data:E}=he(i),{data:D,error:k,isLoading:A,mutate:j}=v(i?`tunnel-status`:null,W,{refreshInterval:e=>u?1e3:e?.frpcDownload||e?.state===`connecting`||e?.state===`reconnecting`?2e3:6e4}),M=(0,Q.useMemo)(()=>{let e=E?.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 D?.config?.autoStart===!0},[E,D?.config?.autoStart]),N=(0,Q.useMemo)(()=>{let e=E?.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``},[E]),F=me(N),L=D?.registrationSecret?.source===`env`,R=D?.registrationSecret?.source===`missing`,B=D?.registrationSecret?.configured===!0;(0,Q.useEffect)(()=>{let e=()=>{j()};return window.addEventListener(`tunnel-status`,e),()=>window.removeEventListener(`tunnel-status`,e)},[j]);let ee=(0,Q.useMemo)(()=>[n.consentBullet1,n.consentBullet2,n.consentBullet3],[n.consentBullet1,n.consentBullet2,n.consentBullet3]),V=(0,Q.useCallback)(async()=>{s({type:`patch`,patch:{actionError:null}}),s({type:`patch`,patch:{starting:!0}});try{let e=await y();await j(),I(),await T.refreshQr(e.qrPayload)}catch(e){s({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{s({type:`patch`,patch:{starting:!1}})}},[j,T.refreshQr]),ne=(0,Q.useCallback)(()=>{if(!B){s({type:`patch`,patch:{actionError:n.brokerSecretRequiredBeforeStart}}),w.current?.scrollIntoView({behavior:`smooth`,block:`start`});return}if(D?.consentRequired){s({type:`patch`,patch:{consentOpen:!0}});return}V()},[B,D?.consentRequired,V,n.brokerSecretRequiredBeforeStart]),G=(0,Q.useCallback)(async()=>{s({type:`patch`,patch:{consentOpen:!1}}),s({type:`patch`,patch:{actionError:null}});try{await te(),await Promise.all([j(),V()])}catch(e){s({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}},[j,V]),re=(0,Q.useCallback)(async()=>{s({type:`patch`,patch:{actionError:null}}),s({type:`patch`,patch:{stopping:!0}});try{await J(),await Promise.all([T.refreshQr(),j()]),I()}catch(e){s({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{s({type:`patch`,patch:{stopping:!1}})}},[j,T.refreshQr]),K=(0,Q.useCallback)(async e=>{s({type:`patch`,patch:{savingAutoStart:!0}}),s({type:`patch`,patch:{actionError:null}});try{await H({autoStart:e}),I()}catch(e){s({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{s({type:`patch`,patch:{savingAutoStart:!1}})}},[]),q=(0,Q.useCallback)(()=>{if(M){K(!1);return}if(D?.consentRequired){s({type:`patch`,patch:{actionError:n.consentExpiredBanner}});return}if(!D?.canAutoStart){s({type:`patch`,patch:{actionError:n.autoStartHint}});return}s({type:`patch`,patch:{autoStartConfirmOpen:!0}})},[K,D?.canAutoStart,D?.consentRequired,n,M]),Y=(0,Q.useCallback)(async()=>{let e=x.trim();if(e){s({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await H({registrationSecret:e}),s({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretSaved}}),I(),await j(),s({type:`patch`,patch:{actionError:null}})}catch(e){s({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{s({type:`patch`,patch:{savingBrokerSecret:!1}})}}},[x,j,n.brokerSecretSaved]),X=(0,Q.useCallback)(async()=>{s({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await H({registrationSecret:null}),s({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretCleared}}),I(),await j()}catch(e){s({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{s({type:`patch`,patch:{savingBrokerSecret:!1}})}},[j,n.brokerSecretCleared]),ae=(0,Q.useCallback)(async()=>{s({type:`patch`,patch:{releaseConfirmOpen:!1,actionError:null,releasing:!0}});try{await J({release:!0}),await Promise.all([T.refreshQr(),j()]),I()}catch(e){s({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{s({type:`patch`,patch:{releasing:!1}})}},[j,T.refreshQr]),oe=(0,Q.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:l(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]);if(!i)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 se=D??{enabled:!1,state:`disconnected`,subdomain:null,publicUrl:null,connectedSince:null,frpcPid:null,lastHeartbeatAt:null,lastError:null,consentRequired:!0,config:{autoStart:M,brokerUrl:`https://frp.xopc.ai/api`}},ce=D?.consentRequired&&(se.enabled||M||D?.consent?.acceptedAt),le=(0,$.jsx)(Xe,{t:n,brokerSecretFromEnv:L,brokerSecretMissing:R,brokerSecretConfiguredInConfig:F,brokerSecretMaskedValue:F?N:``,brokerSecretDraft:x,savingBrokerSecret:S,brokerSecretNotice:C,copyFailedLabel:l(t).clipboard.copyFailed,onDraftChange:e=>s({type:`patch`,patch:{brokerSecretDraft:e}}),onSave:()=>void Y(),onClear:()=>void X(),sectionRef:w}),ue=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(je,{open:h,title:n.consentTitle,intro:n.consentIntro,bullets:ee,checkboxLabel:n.consentCheckbox,confirmLabel:ce?n.consentReconfirm:n.consentConfirm,cancelLabel:n.consentCancel,onConfirm:()=>void G(),onCancel:()=>s({type:`patch`,patch:{consentOpen:!1}})},h?`consent-open`:`consent-closed`),(0,$.jsx)(O,{open:g,title:n.autoStartConfirmTitle,description:n.autoStartConfirmBody,confirmLabel:n.autoStartConfirmLabel,cancelLabel:n.consentCancel,onConfirm:()=>{s({type:`patch`,patch:{autoStartConfirmOpen:!1}}),K(!0)},onCancel:()=>s({type:`patch`,patch:{autoStartConfirmOpen:!1}})}),(0,$.jsx)(O,{open:_,title:n.releaseConfirmTitle,description:n.releaseConfirmBody,confirmLabel:n.releaseConfirmLabel,cancelLabel:n.consentCancel,destructive:!0,onConfirm:()=>void ae(),onCancel:()=>s({type:`patch`,patch:{releaseConfirmOpen:!1}})})]});return e?(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[c?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:c}):null,le,(0,$.jsx)(qe,{t:n,status:se,isLoading:A,statusErr:k,starting:u,stopping:d,showConsentExpired:!!ce,copyLabels:oe,startDisabled:!B,startDisabledReason:B?void 0:n.brokerSecretRequiredBeforeStart,stepLabel:n.flowStepStart,onStart:ne,onStop:()=>void re()}),(0,$.jsx)(De,{pairQr:T,gatewayToken:r??``,streamlined:!0,onRefreshQr:()=>void T.refreshQr()}),(0,$.jsxs)(ye,{showLabel:n.showOptions,hideLabel:n.hideOptions,children:[(0,$.jsxs)(`label`,{className:o(`flex items-center gap-3 text-sm text-fg`,!M&&!D?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:M,disabled:f||!M&&!D?.canAutoStart,onChange:q}),n.autoStart]}),!D?.canAutoStart&&!M?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.autoStartHint}):null,se.subdomain||se.publicUrl?(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-edge-subtle pt-4`,children:[(0,$.jsxs)(U,{type:`button`,variant:`secondary`,disabled:b||d,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>s({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[b?(0,$.jsx)(ie,{className:`size-4 animate-spin`}):null,n.release]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint})]}):null]}),(0,$.jsx)(ye,{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)(z,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)($e,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]})}),ue]}):(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})]}),c?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:c}):null,le,(0,$.jsx)(qe,{t:n,status:se,isLoading:A,statusErr:k,starting:u,stopping:d,showConsentExpired:!!ce,copyLabels:oe,startDisabled:!B,startDisabledReason:B?void 0:n.brokerSecretRequiredBeforeStart,onStart:ne,onStop:()=>void re()}),(0,$.jsx)(De,{pairQr:T,gatewayToken:r??``}),se.subdomain||se.publicUrl?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,$.jsxs)(U,{type:`button`,variant:`secondary`,disabled:b||d,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>s({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[b?(0,$.jsx)(ie,{className:`size-4 animate-spin`}):null,n.release]})}):null,se.subdomain||se.publicUrl?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint}):null,(0,$.jsxs)(Se,{children:[(0,$.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-fg`,children:n.optionsTitle}),(0,$.jsxs)(`label`,{className:o(`flex items-center gap-3 text-sm text-fg`,!M&&!D?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:M,disabled:f||!M&&!D?.canAutoStart,onChange:q}),n.autoStart]}),!D?.canAutoStart&&!M?(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)(z,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)($e,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]}),ue]})}async function lt(){let e=await g(`/api/exposure/status`);if(!e.ok)throw Error(`Failed to load exposure status (${e.status})`);return await e.json()}async function ut(e=`serve`){let t=await g(`/api/exposure/tailscale/start`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({mode:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`Start failed (${t.status})`)}return await t.json()}async function dt(){let e=await g(`/api/exposure/tailscale/stop`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??`Stop failed (${e.status})`)}return await e.json()}var ft=`https://tailscale.com/download`;function pt(e){let t=(0,Z.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`a`,{href:ft,target:`_blank`,rel:`noreferrer`,className:`font-medium text-accent hover:underline`,children:n}),t[0]=n,t[1]=r),r}function mt({embedded:e=!1}){let t=p(e=>e.language),n=l(t).remoteAccess.tailscale,r=(0,Q.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:l(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]),i=!!m(e=>e.token),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),{data:u,mutate:d,isLoading:f}=v(i?`exposure-status`:null,lt,{refreshInterval:3e4}),h=u?.tailscale.hostname,g=u?.tailscale.active===!0,_=u?.tailscale.cliAvailable!==!1,y=h?`https://${h}/`:null,b=(0,Q.useCallback)(async()=>{o(!0),c(null);try{await ut(`serve`),await d()}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1)}},[d]),x=(0,Q.useCallback)(async()=>{o(!0),c(null);try{await dt(),await d()}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1)}},[d]);if(!i)return null;let C=(0,$.jsxs)(`div`,{className:e?`space-y-4`:`mt-4 space-y-3`,children:[e?(0,$.jsxs)(`ol`,{className:`space-y-3 text-sm text-fg-muted`,children:[(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`1`}),(0,$.jsxs)(`span`,{children:[n.stepInstallBefore,(0,$.jsx)(pt,{label:n.stepInstallLink}),n.stepInstallAfter]})]}),(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`2`}),(0,$.jsx)(`span`,{children:n.stepEnable})]}),(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`3`}),(0,$.jsx)(`span`,{children:n.stepCopy})]})]}):null,e&&u?.tailscale.cliAvailable===!1?(0,$.jsxs)(`p`,{className:`rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2 text-sm text-fg-muted`,children:[n.cliMissingIntro,` `,(0,$.jsx)(pt,{label:n.cliMissingDownloadLink}),n.cliMissingSuffix]}):null,f&&!u?(0,$.jsxs)(`div`,{className:`grid gap-3`,"aria-busy":`true`,children:[(0,$.jsx)(S,{className:`h-20 rounded-lg`}),(0,$.jsx)(S,{className:`h-20 rounded-lg`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Se,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.statusLabel}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:g?n.statusActive:n.statusOff}),y?(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(re,{text:y,labels:r})}):null,s?(0,$.jsx)(`p`,{className:`mt-2 text-sm text-red-600 dark:text-red-400`,children:s}):null,(0,$.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:g?(0,$.jsxs)(U,{type:`button`,variant:`secondary`,disabled:a,onClick:()=>void x(),children:[a?(0,$.jsx)(ie,{className:`mr-1 h-4 w-4 animate-spin`}):null,n.disableServe]}):(0,$.jsxs)(U,{type:`button`,disabled:a||!_,onClick:()=>void b(),children:[a?(0,$.jsx)(ie,{className:`mr-1 h-4 w-4 animate-spin`}):(0,$.jsx)(M,{className:`mr-1 h-4 w-4`}),n.enableServe]})})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.hint}),(0,$.jsx)($e,{language:t,label:n.docsLink,section:`tailscale-serve`,className:`mt-2`})]})]});return e?C:(0,$.jsxs)(Se,{children:[(0,$.jsx)(be,{icon:z,title:n.title,subtitle:n.subtitle}),C]})}function ht(){let e=(0,Z.c)(26),t=p(_t),n=m(gt),r;e[0]===t?r=e[1]:(r=l(t),e[0]=t,e[1]=r);let i=r.remoteAccess.lan,o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o={preferLan:!0},e[2]=o):o=e[2];let s=ot(n??``,o),c;e[3]!==i.subtitle||e[4]!==i.title?(c=(0,$.jsx)(be,{icon:N,title:i.title,subtitle:i.subtitle}),e[3]=i.subtitle,e[4]=i.title,e[5]=c):c=e[5];let u;e[6]===i.body?u=e[7]:(u=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:i.body}),e[6]=i.body,e[7]=u);let d;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(pe,{className:`size-3.5`,"aria-hidden":!0}),e[8]=d):d=e[8];let f;e[9]===i.link?f=e[10]:(f=(0,$.jsxs)(a,{to:`/settings/gateway`,className:`inline-flex items-center gap-1.5 text-sm font-medium text-accent hover:underline`,children:[i.link,d]}),e[9]=i.link,e[10]=f);let h;e[11]!==u||e[12]!==f?(h=(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[u,f]}),e[11]=u,e[12]=f,e[13]=h):h=e[13];let g;e[14]!==c||e[15]!==h?(g=(0,$.jsxs)(Se,{children:[c,h]}),e[14]=c,e[15]=h,e[16]=g):g=e[16];let _=n??``,v;e[17]===s?v=e[18]:(v=()=>void s.refreshQr(),e[17]=s,e[18]=v);let y;e[19]!==s||e[20]!==_||e[21]!==v?(y=(0,$.jsx)(De,{pairQr:s,gatewayToken:_,lanOnly:!0,onRefreshQr:v}),e[19]=s,e[20]=_,e[21]=v,e[22]=y):y=e[22];let b;return e[23]!==y||e[24]!==g?(b=(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[g,y]}),e[23]=y,e[24]=g,e[25]=b):b=e[25],b}function gt(e){return e.token}function _t(e){return e.language}function vt(e){let t=(0,Z.c)(30),{embedded:n}=e,r=n===void 0?!1:n,i=p(yt),a;t[0]===i?a=t[1]:(a=l(i),t[0]=i,t[1]=a);let o=a.remoteAccess.ssh,[s,u]=(0,Q.useState)(!1),d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=async()=>{await c(`xopc gateway ssh-tunnel --target user@your-host --local-port 18790 --remote-port 18790`)&&(u(!0),setTimeout(()=>u(!1),2e3))},t[2]=d):d=t[2];let f=d,m;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(m=(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]=m):m=t[3];let h,g;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>void f(),g=(0,$.jsx)(fe,{className:`mr-1 h-4 w-4`}),t[4]=h,t[5]=g):(h=t[4],g=t[5]);let _=s?o.copied:o.copy,v;t[6]===_?v=t[7]:(v=(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsxs)(U,{type:`button`,variant:`ghost`,onClick:h,children:[g,_]})}),t[6]=_,t[7]=v);let y;t[8]!==r||t[9]!==o.hint?(y=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]=y):y=t[10];let b;t[11]!==v||t[12]!==y?(b=(0,$.jsxs)($.Fragment,{children:[m,v,y]}),t[11]=v,t[12]=y,t[13]=b):b=t[13];let x=b;if(r){let e;t[14]!==o.subtitle||t[15]!==o.title?(e=(0,$.jsx)(be,{icon:ue,title:o.title,subtitle:o.subtitle}),t[14]=o.subtitle,t[15]=o.title,t[16]=e):e=t[16];let n;t[17]===x?n=t[18]:(n=(0,$.jsx)(`div`,{className:`mt-4 space-y-2`,children:x}),t[17]=x,t[18]=n);let r;return t[19]!==e||t[20]!==n?(r=(0,$.jsxs)(Se,{children:[e,n]}),t[19]=e,t[20]=n,t[21]=r):r=t[21],r}let S;t[22]!==o.subtitle||t[23]!==o.title?(S=(0,$.jsx)(be,{icon:ue,title:o.title,subtitle:o.subtitle}),t[22]=o.subtitle,t[23]=o.title,t[24]=S):S=t[24];let C;t[25]===x?C=t[26]:(C=(0,$.jsx)(`div`,{className:`mt-4`,children:x}),t[25]=x,t[26]=C);let w;return t[27]!==S||t[28]!==C?(w=(0,$.jsxs)(Se,{children:[S,C]}),t[27]=S,t[28]=C,t[29]=w):w=t[29],w}function yt(e){return e.language}function bt(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(vt,{embedded:!0}),e[0]=t):t=e[0],t}function xt(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 St(e){let t=(0,Z.c)(5),{label:n,kind:r}=e,i;t[0]===r?i=t[1]:(i=o(`rounded-full px-2 py-0.5 text-[11px] font-medium`,xt(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 Ct(e){let t=(0,Z.c)(32),{onOpenTab:n}=e,r=p(Et),i;t[0]===r?i=t[1]:(i=l(r),t[0]=r,t[1]=i);let a=i.remoteAccess.guide,s=!!m(Tt),c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c={refreshInterval:3e4},t[2]=c):c=t[2];let{data:u}=v(s?`exposure-status`:null,lt,c),d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d={refreshInterval:15e3},t[3]=d):d=t[3];let{data:f}=v(s?`tunnel-status`:null,W,d),h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h={refreshInterval:6e4},t[4]=h):h=t[4];let{data:g}=v(s?`tunnel-pair-context`:null,de,h);if(!s)return null;let _=u?.tailscale.active===!0,y=f?.state,b=f?.enabled&&y===`connected`,x=f?.enabled&&(y===`connecting`||y===`reconnecting`||!!f?.startProgress||!!f?.frpcDownload),S=(g?.candidates??[]).some(wt),C=_?`active`:`off`,w=_?a.statusActive:a.statusOff,E;t[5]!==a.tailscaleCardTitle||t[6]!==C||t[7]!==w?(E={tab:`tailscale`,icon:z,title:a.tailscaleCardTitle,kind:C,statusLabel:w},t[5]=a.tailscaleCardTitle,t[6]=C,t[7]=w,t[8]=E):E=t[8];let D=b?`active`:x?`connecting`:`off`,O=b?a.statusActive:x?a.statusConnecting:a.statusOff,k;t[9]!==a.publicCardTitle||t[10]!==D||t[11]!==O?(k={tab:`public`,icon:ce,title:a.publicCardTitle,kind:D,statusLabel:O},t[9]=a.publicCardTitle,t[10]=D,t[11]=O,t[12]=k):k=t[12];let A=S?`active`:`off`,j=S?a.statusActive:a.statusOff,M;t[13]!==a.reverseProxyCardTitle||t[14]!==A||t[15]!==j?(M={tab:`reverse-proxy`,icon:T,title:a.reverseProxyCardTitle,kind:A,statusLabel:j},t[13]=a.reverseProxyCardTitle,t[14]=A,t[15]=j,t[16]=M):M=t[16];let P;t[17]!==a.sshCardStatus||t[18]!==a.sshCardTitle?(P={tab:`ssh`,icon:ue,title:a.sshCardTitle,kind:`off`,statusLabel:a.sshCardStatus},t[17]=a.sshCardStatus,t[18]=a.sshCardTitle,t[19]=P):P=t[19];let F;t[20]!==a.lanCardStatus||t[21]!==a.lanCardTitle?(F={tab:`lan`,icon:N,title:a.lanCardTitle,kind:`off`,statusLabel:a.lanCardStatus},t[20]=a.lanCardStatus,t[21]=a.lanCardTitle,t[22]=F):F=t[22];let I;t[23]!==k||t[24]!==M||t[25]!==P||t[26]!==F||t[27]!==E?(I=[E,k,M,P,F],t[23]=k,t[24]=M,t[25]=P,t[26]=F,t[27]=E,t[28]=I):I=t[28];let L=I,R;return t[29]!==L||t[30]!==n?(R=(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:o(`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)(St,{label:e.statusLabel,kind:e.kind})]})]},`${e.tab}-${e.title}`)})}),t[29]=L,t[30]=n,t[31]=R):R=t[31],R}function wt(e){return e.kind===`reverse-proxy`}function Tt(e){return e.token}function Et(e){return e.language}function Dt(e){let t=(0,Z.c)(26),{title:n,description:r,recommended:i,icon:a,onOpen:s,openLabel:c,recommendedLabel:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=o(`group flex w-full flex-col rounded-2xl bg-surface-base px-4 py-4 text-left transition-colors`,`hover:bg-surface-hover/40`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),t[0]=u):u=t[0];let d;t[1]===a?d=t[2]:(d=(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]=d);let f;t[3]===n?f=t[4]:(f=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[3]=n,t[4]=f);let p;t[5]!==i||t[6]!==l?(p=i&&l?(0,$.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:l}):null,t[5]=i,t[6]=l,t[7]=p):p=t[7];let m;t[8]!==f||t[9]!==p?(m=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f,p]}),t[8]=f,t[9]=p,t[10]=m):m=t[10];let h;t[11]===r?h=t[12]:(h=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:r}),t[11]=r,t[12]=h);let g;t[13]!==m||t[14]!==h?(g=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[m,h]}),t[13]=m,t[14]=h,t[15]=g):g=t[15];let _;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(w,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0}),t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==g?(v=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[d,g,_]}),t[17]=d,t[18]=g,t[19]=v):v=t[19];let y;t[20]===c?y=t[21]:(y=(0,$.jsx)(`span`,{className:`mt-3 text-xs font-medium text-accent`,children:c}),t[20]=c,t[21]=y);let b;return t[22]!==s||t[23]!==y||t[24]!==v?(b=(0,$.jsxs)(`button`,{type:`button`,onClick:s,className:u,children:[v,y]}),t[22]=s,t[23]=y,t[24]=v,t[25]=b):b=t[25],b}function Ot(e){let t=(0,Z.c)(83),{onOpenTab:n}=e,r=p(jt),i;t[0]===r?i=t[1]:(i=l(r),t[0]=r,t[1]=i);let a=i.remoteAccess,o=a.guide,s=!!m(At),c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c={refreshInterval:3e4},t[2]=c):c=t[2];let{data:u}=v(s?`exposure-status`:null,lt,c),d;t[3]===u?.conflicts?d=t[4]:(d=u?.conflicts??[],t[3]=u?.conflicts,t[4]=d);let f=d;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 h;t[7]===n?h=t[8]:(h=(0,$.jsx)(Ct,{onOpenTab:n}),t[7]=n,t[8]=h);let g;t[9]!==f||t[10]!==o.conflictsHint||t[11]!==o.conflictsTitle?(g=f.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:f.map(kt)})]}):null,t[9]=f,t[10]=o.conflictsHint,t[11]=o.conflictsTitle,t[12]=g):g=t[12];let _;t[13]===o.pickMethod?_=t[14]:(_=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:o.pickMethod}),t[13]=o.pickMethod,t[14]=_);let y;t[15]===n?y=t[16]:(y=()=>n(`tailscale`),t[15]=n,t[16]=y);let b;t[17]!==o.configure||t[18]!==o.recommended||t[19]!==o.tailscaleCardDesc||t[20]!==o.tailscaleCardTitle||t[21]!==y?(b=(0,$.jsx)(Dt,{icon:z,title:o.tailscaleCardTitle,description:o.tailscaleCardDesc,recommended:!0,recommendedLabel:o.recommended,openLabel:o.configure,onOpen:y}),t[17]=o.configure,t[18]=o.recommended,t[19]=o.tailscaleCardDesc,t[20]=o.tailscaleCardTitle,t[21]=y,t[22]=b):b=t[22];let x;t[23]===n?x=t[24]:(x=()=>n(`public`),t[23]=n,t[24]=x);let S;t[25]!==o.configure||t[26]!==o.publicCardDesc||t[27]!==o.publicCardTitle||t[28]!==x?(S=(0,$.jsx)(Dt,{icon:ce,title:o.publicCardTitle,description:o.publicCardDesc,openLabel:o.configure,onOpen:x}),t[25]=o.configure,t[26]=o.publicCardDesc,t[27]=o.publicCardTitle,t[28]=x,t[29]=S):S=t[29];let C;t[30]===n?C=t[31]:(C=()=>n(`reverse-proxy`),t[30]=n,t[31]=C);let w;t[32]!==o.configure||t[33]!==o.reverseProxyCardDesc||t[34]!==o.reverseProxyCardTitle||t[35]!==C?(w=(0,$.jsx)(Dt,{icon:T,title:o.reverseProxyCardTitle,description:o.reverseProxyCardDesc,openLabel:o.configure,onOpen:C}),t[32]=o.configure,t[33]=o.reverseProxyCardDesc,t[34]=o.reverseProxyCardTitle,t[35]=C,t[36]=w):w=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)(Dt,{icon:ue,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)(Dt,{icon:N,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]!==w||t[53]!==D||t[54]!==k||t[55]!==b?(A=(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:[b,S,w,D,k]}),t[51]=S,t[52]=w,t[53]=D,t[54]=k,t[55]=b,t[56]=A):A=t[56];let j;t[57]!==A||t[58]!==_?(j=(0,$.jsxs)(`div`,{children:[_,A]}),t[57]=A,t[58]=_,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 P;t[62]===a.advanced.proxyTitle?P=t[63]:(P=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.advanced.proxyTitle}),t[62]=a.advanced.proxyTitle,t[63]=P);let F;t[64]===a.advanced.proxyBody?F=t[65]:(F=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:a.advanced.proxyBody}),t[64]=a.advanced.proxyBody,t[65]=F);let I;t[66]!==r||t[67]!==a.advanced.proxyDocs?(I=(0,$.jsx)($e,{language:r,label:a.advanced.proxyDocs,section:`advanced`,className:`mt-2`}),t[66]=r,t[67]=a.advanced.proxyDocs,t[68]=I):I=t[68];let L;t[69]!==P||t[70]!==F||t[71]!==I?(L=(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-base px-4 py-3`,children:[P,F,I]}),t[69]=P,t[70]=F,t[71]=I,t[72]=L):L=t[72];let R;t[73]!==o.docsLink||t[74]!==r?(R=(0,$.jsx)($e,{language:r,label:o.docsLink}),t[73]=o.docsLink,t[74]=r,t[75]=R):R=t[75];let B;return t[76]!==j||t[77]!==M||t[78]!==L||t[79]!==R||t[80]!==h||t[81]!==g?(B=(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[h,g,j,M,L,R]}),t[76]=j,t[77]=M,t[78]=L,t[79]=R,t[80]=h,t[81]=g,t[82]=B):B=t[82],B}function kt(e){return(0,$.jsx)(`li`,{children:e.message},e.code)}function At(e){return e.token}function jt(e){return e.language}async function Mt(e){let t=await g(u(`/api/tunnel/pair/probe-public`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:e})});if(!t.ok&&t.status!==400)throw Error(`Probe failed (${t.status})`);return await t.json()}async function Nt(e){await f(u(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{publicUrl:e??null}})})}function Pt(e){let t=e.split(`.`).map(e=>Number.parseInt(e,10));if(t.length!==4||t.some(e=>!Number.isFinite(e)))return!1;let[n,r]=t;return n===10||n===127||n===169&&r===254||n===172&&r>=16&&r<=31||n===192&&r===168||n===100&&r>=64&&r<=127}function Ft(){return(0,Q.useMemo)(()=>{if(typeof window>`u`)return null;let{protocol:e,hostname:t,origin:n}=window.location;if(e!==`https:`&&e!==`http:`)return null;let r=t.toLowerCase();return!r||r===`localhost`||r===`127.0.0.1`||r===`::1`||r===`[::1]`||r.endsWith(`.local`)||r.endsWith(`.localhost`)||Pt(r)?null:n.toLowerCase().replace(/\/+$/,``)},[])}function It(){return o(`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 Lt(e){return(e?.candidates.find(e=>e.kind===`reverse-proxy`))?.url?.trim()||null}function Rt(e){return(e?.candidates.find(e=>e.kind===`lan`&&e.reachable))?.url?.trim()||null}function zt(){let e=p(e=>e.language),t=l(e).remoteAccess.reverseProxy,n=!!m(e=>e.token),r=Ft(),{mutate:i}=_(),{data:a,mutate:s}=v(n?`tunnel-pair-context`:null,de,{refreshInterval:6e4}),c=Lt(a),[u,f]=(0,Q.useState)(``),[h,g]=(0,Q.useState)({busy:!1,result:null}),[y,b]=(0,Q.useState)({busy:!1,error:null});(0,Q.useEffect)(()=>{u||(c?f(c):r&&f(r))},[c,r,u]);let x=(0,Q.useMemo)(()=>u.trim()||(c??r??``),[c,r,u]),S=!c&&!!r&&x===r,C=Rt(a),{data:w,mutate:T}=v(n&&x?[`reverse-proxy-pair`,x]:null,()=>E(),{refreshInterval:4*6e4,revalidateOnFocus:!1}),D=(0,Q.useMemo)(()=>!x||!w?.pairingSecret?``:d({baseUrl:x,pairingSecret:w.pairingSecret,lanUrl:C}),[x,C,w?.pairingSecret]),O=K(()=>nt(D),[D],{enabled:!!D,initial:null,errorData:null}),k=(0,Q.useCallback)(async()=>{let e=u.trim()||x;if(e){g({busy:!0,result:null});try{g({busy:!1,result:await Mt(e)})}catch(e){g({busy:!1,result:{ok:!1,code:`NETWORK_ERROR`,message:e instanceof Error?e.message:String(e)}})}}},[u,x]),A=(0,Q.useCallback)(async()=>{let e=x.trim();if(e){b({busy:!0,error:null});try{await Nt(e),await s(),await i(`tunnel-pair-context`),b({busy:!1,error:null})}catch(e){b({busy:!1,error:e instanceof Error?e.message:String(e)})}}},[x,i,s]),j=(0,Q.useCallback)(async()=>{b({busy:!0,error:null});try{await Nt(null),await s(),await i(`tunnel-pair-context`),f(``),g({busy:!1,result:null}),b({busy:!1,error:null})}catch(e){b({busy:!1,error:e instanceof Error?e.message:String(e)})}},[i,s]),M=(0,Q.useCallback)(async()=>{await T()},[T]);return n?(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsxs)(Se,{children:[(0,$.jsx)(be,{icon:z,title:t.title,subtitle:t.subtitle}),(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,$.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`reverse-proxy-url`,children:t.urlLabel}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch`,children:[(0,$.jsx)(`input`,{id:`reverse-proxy-url`,className:o(It(),`font-mono text-xs sm:flex-1 sm:min-w-0 sm:w-auto`),type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:t.urlPlaceholder,value:u,onChange:e=>{f(e.target.value),g({busy:!1,result:null})}}),(0,$.jsxs)(U,{type:`button`,variant:`secondary`,className:`shrink-0 whitespace-nowrap`,onClick:()=>void k(),disabled:h.busy||!u.trim(),children:[h.busy?(0,$.jsx)(ie,{className:`size-3.5 animate-spin`}):null,h.busy?t.probing:t.probeButton]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.urlHint}),S&&r?(0,$.jsxs)(`div`,{className:`rounded-lg border border-accent/40 bg-accent-soft/50 px-3 py-2 text-xs leading-relaxed text-accent-fg`,children:[(0,$.jsx)(`div`,{className:`font-medium`,children:t.autoDetectedTitle}),(0,$.jsx)(`div`,{className:`mt-1 break-all font-mono text-[11px]`,children:r}),(0,$.jsx)(`p`,{className:`mt-1`,children:t.autoDetectedHint})]}):null,h.result?(0,$.jsx)(Bt,{result:h.result,labels:t.probeStatus}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap`,children:[x&&c!==x?(0,$.jsxs)(U,{type:`button`,onClick:()=>void A(),disabled:y.busy,children:[y.busy?(0,$.jsx)(ie,{className:`size-3.5 animate-spin`}):null,y.busy?t.saving:t.saveAsDefault]}):null,c?(0,$.jsx)(U,{type:`button`,variant:`ghost`,onClick:()=>void j(),disabled:y.busy,children:t.clear}):null]}),y.error?(0,$.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:y.error}):null,(0,$.jsx)(`div`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs leading-relaxed text-amber-950 dark:border-amber-800/60 dark:bg-amber-950/30 dark:text-amber-100`,children:t.certWarning})]})]}),(0,$.jsxs)(Se,{children:[(0,$.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:t.qrTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.qrSubtitle})]}),D?(0,$.jsxs)(U,{type:`button`,variant:`ghost`,className:`shrink-0`,onClick:()=>void M(),children:[(0,$.jsx)(ee,{className:`size-4`}),t.refreshQr]}):null]}),x?w?.pairingSecret?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 sm:items-start`,children:[(0,$.jsxs)(`div`,{className:`break-all font-mono text-[11px] text-fg-muted`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:`baseUrl:`}),` `,x,C?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`br`,{}),(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:`lanUrl:`}),` `,C]}):null]}),O.data?(0,$.jsx)(`img`,{src:O.data,alt:``,className:`size-56 rounded-lg border border-edge-subtle bg-white object-contain p-3 dark:border-edge`}):O.loading?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.encoding}):null,(0,$.jsx)(re,{text:D,labels:{copy:t.copyLink,copied:t.copied,copyFailed:l(e).clipboard.copyFailed}})]}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.mintingSecret}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noUrlYet})]})]}):null}function Bt(e){let t=(0,Z.c)(18),{result:n,labels:r}=e;if(n.ok){let e;t[0]===r.ok?e=t[1]:(e=(0,$.jsx)(`span`,{className:`font-medium`,children:r.ok}),t[0]=r.ok,t[1]=e);let i;t[2]===n.latencyMs?i=t[3]:(i=(0,$.jsxs)(`span`,{className:`font-mono`,children:[n.latencyMs,`ms`]}),t[2]=n.latencyMs,t[3]=i);let a;t[4]!==r.mobileReady||t[5]!==n.mobilePairing?(a=n.mobilePairing?(0,$.jsxs)($.Fragment,{children:[` · `,(0,$.jsx)(`span`,{children:r.mobileReady})]}):null,t[4]=r.mobileReady,t[5]=n.mobilePairing,t[6]=a):a=t[6];let o;return t[7]!==e||t[8]!==i||t[9]!==a?(o=(0,$.jsxs)(`div`,{className:`rounded-lg border border-emerald-200 bg-emerald-50 px-3 py-2 text-xs text-emerald-900 dark:border-emerald-800/60 dark:bg-emerald-950/30 dark:text-emerald-100`,children:[e,` · `,i,a]}),t[7]=e,t[8]=i,t[9]=a,t[10]=o):o=t[10],o}let i=r[`code_${n.code}`]??r.codeUnknown,a;t[11]===i?a=t[12]:(a=(0,$.jsx)(`span`,{className:`font-medium`,children:i}),t[11]=i,t[12]=a);let o;t[13]===n.message?o=t[14]:(o=n.message?(0,$.jsxs)($.Fragment,{children:[` — `,(0,$.jsx)(`span`,{className:`font-mono break-all`,children:n.message})]}):null,t[13]=n.message,t[14]=o);let s;return t[15]!==a||t[16]!==o?(s=(0,$.jsxs)(`div`,{className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-900 dark:border-red-800/60 dark:bg-red-950/30 dark:text-red-100`,children:[a,o]}),t[15]=a,t[16]=o,t[17]=s):s=t[17],s}var Vt=[`guide`,`tailscale`,`public`,`reverse-proxy`,`ssh`,`lan`];function Ht(e){return e&&Vt.includes(e)?e:`guide`}function Ut(e,t){return e.tabs[t]}function Wt(e,t){return e.tabIntro[t]}function Gt(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 Kt(e){let t=(0,Z.c)(7),{tab:n,onOpenTab:r}=e;switch(n){case`guide`:{let e;return t[0]===r?e=t[1]:(e=(0,$.jsx)(Ot,{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)(mt,{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)(zt,{}),t[4]=e):e=t[4],e}case`ssh`:{let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(bt,{}),t[5]=e):e=t[5],e}case`lan`:{let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ht,{}),t[6]=e):e=t[6],e}}}function qt(){let e=(0,Z.c)(2),t=p(Yt),n=l(t).remoteAccess,r=!!m(Jt),[a,o]=i(),s=Ht(a.get(`tab`)),c;e[0]===o?c=e[1]:(c=e=>{o(t=>{let n=new URLSearchParams(t);return e===`guide`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[0]=o,e[1]=c);let u=c,d=Wt(n,s),f=Vt.map(e=>({id:e,label:Ut(n,e)}));return(0,$.jsxs)(ve,{children:[(0,$.jsx)(ge,{title:n.pageTitle,subtitle:n.pageSubtitle,meta:(0,$.jsx)($e,{language:t,label:n.docsLink,section:Gt(s),className:`mt-1`})}),r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(we,{items:f,activeTab:s,onChange:u,ariaLabel:n.tabsAria,tabIdPrefix:`remote-access-tab`,panelIdPrefix:`remote-access-panel`}),(0,$.jsx)(_e,{id:s,activeTab:s,tabIdPrefix:`remote-access-tab`,panelIdPrefix:`remote-access-panel`,title:Ut(n,s),hint:s===`public`?void 0:d,children:(0,$.jsx)(Kt,{tab:s,onOpenTab:u})})]}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.guide.needToken})]})}function Jt(e){return e.token}function Yt(e){return e.language}export{qt 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{d as i}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as a}from"./cn-BQ_8x0bT.js";import{t as o}from"./messages-Cb1VMeqP.js";import{d as s,i as c,n as l,o as u}from"./locale-store-CiM-D9jA.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{$i as f,Ao as ee,As as p,Dc as m,Do as h,Dt as g,Ec as _,Et as v,Gi as y,Ho as b,Ia as x,Jc as S,Ji as C,Jo as w,Ki as T,Kl as E,Ot as D,Ps as O,Qi as k,Qo as te,Qs as A,Ra as j,To as M,Uo as N,Wi as P,Xi as F,Yi as I,Yo as L,Zo as R,Zs as z,_l as ne,_o as re,al as B,dc as V,do as H,ea as U,fo as W,gc as G,go as K,ho as ie,il as ae,kc as oe,ko as se,na as ce,po as le,qi as ue,ql as q,ta as de,us as fe,za as pe}from"./index-BJGusbyV.js";import{n as J,t as Y}from"./settings-form-section-BfzJkVHd.js";import{t as X}from"./page-tabs-CGVMJEW0.js";import{n as me,r as he}from"./segmented-styles-BL8oLBEp.js";var Z=e(t(),1),ge=n(),Q=r();function _e(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 ve(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function ye(e){let t=(0,ge.c)(105),{session:n,variant:r,labels:i,sessionAgentId:o,sessionAgentAvatar:s,onOpen:c,onAction:l}=e,u;t[0]!==i.unnamedSession||t[1]!==n.name?(u=n.name?.trim()||i.unnamedSession,t[0]=i.unnamedSession,t[1]=n.name,t[2]=u):u=t[2];let d=u,f;t[3]===n.name?f=t[4]:(f=n.name?.trim(),t[3]=n.name,t[4]=f);let ee=!!f,p=n.status===`archived`,m=n.status===`pinned`,h=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,g;t[5]===h?g=t[6]:(g=a(`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`,h),t[5]=h,t[6]=g);let _;t[7]===c?_=t[8]:(_=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},t[7]=c,t[8]=_);let v=r===`list`&&`sm:py-3`,y;t[9]===v?y=t[10]:(y=a(`flex min-w-0 items-start justify-between gap-2 bg-surface-hover/35 px-3 py-2 dark:bg-surface-hover/25`,v),t[9]=v,t[10]=y);let x;t[11]===n.sourceChannel?x=t[12]:(x=(0,Q.jsx)(`div`,{className:`flex min-w-0 items-center gap-2`,children:(0,Q.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]===m?S=t[14]:(S=m?(0,Q.jsx)(A,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[13]=m,t[14]=S);let C;t[15]===n.updatedAt?C=t[16]:(C=_e(n.updatedAt),t[15]=n.updatedAt,t[16]=C);let w;t[17]===C?w=t[18]:(w=(0,Q.jsx)(`span`,{children:C}),t[17]=C,t[18]=w);let T;t[19]!==w||t[20]!==S?(T=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,children:[S,w]}),t[19]=w,t[20]=S,t[21]=T):T=t[21];let D;t[22]!==T||t[23]!==y||t[24]!==x?(D=(0,Q.jsxs)(`div`,{className:y,children:[x,T]}),t[22]=T,t[23]=y,t[24]=x,t[25]=D):D=t[25];let O=r===`list`&&`sm:py-3`,k;t[26]===O?k=t[27]:(k=a(`min-w-0 flex-1 px-3 py-2`,O),t[26]=O,t[27]=k);let te=r===`list`&&`sm:items-start`,j;t[28]===te?j=t[29]:(j=a(`flex gap-3`,te),t[28]=te,t[29]=j);let M;t[30]!==s||t[31]!==o?(M=(0,Q.jsx)(ce,{agentId:o,avatar:s,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}),t[30]=s,t[31]=o,t[32]=M):M=t[32];let N;t[33]===d?N=t[34]:(N=(0,Q.jsx)(`div`,{className:`min-w-0 max-w-full truncate text-sm font-semibold text-fg`,title:d,children:d}),t[33]=d,t[34]=N);let P;t[35]!==n.key||t[36]!==ee?(P=ee?(0,Q.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]=ee,t[37]=P):P=t[37];let F;t[38]!==N||t[39]!==P?(F=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[N,P]}),t[38]=N,t[39]=P,t[40]=F):F=t[40];let I;t[41]!==j||t[42]!==M||t[43]!==F?(I=(0,Q.jsxs)(`div`,{className:j,children:[M,F]}),t[41]=j,t[42]=M,t[43]=F,t[44]=I):I=t[44];let L;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Q.jsx)(V,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[45]=L):L=t[45];let ne;t[46]===n.messageCount?ne=t[47]:(ne=(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[L,n.messageCount]}),t[46]=n.messageCount,t[47]=ne);let re;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,Q.jsx)(R,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[48]=re):re=t[48];let B;t[49]===n.estimatedTokens?B=t[50]:(B=ve(n.estimatedTokens),t[49]=n.estimatedTokens,t[50]=B);let H;t[51]===B?H=t[52]:(H=(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[re,B]}),t[51]=B,t[52]=H);let U;t[53]!==ne||t[54]!==H?(U=(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[ne,H]}),t[53]=ne,t[54]=H,t[55]=U):U=t[55];let W;t[56]===n.tags?W=t[57]:(W=n.tags.length>0?(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n.tags.slice(0,3).map(Se),n.tags.length>3?(0,Q.jsxs)(`span`,{className:`text-[11px] text-fg-disabled`,children:[`+`,n.tags.length-3]}):null]}):null,t[56]=n.tags,t[57]=W);let G;t[58]!==k||t[59]!==I||t[60]!==U||t[61]!==W?(G=(0,Q.jsxs)(`div`,{className:k,children:[I,U,W]}),t[58]=k,t[59]=I,t[60]=U,t[61]=W,t[62]=G):G=t[62];let K;t[63]===l?K=t[64]:(K=()=>l(`continue`),t[63]=l,t[64]=K);let ie;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,Q.jsx)(V,{className:`size-4`,strokeWidth:1.75}),t[65]=ie):ie=t[65];let oe;t[66]!==i.continueChat||t[67]!==K?(oe=(0,Q.jsx)(`button`,{type:`button`,className:b,title:i.continueChat,"aria-label":i.continueChat,onClick:K,children:ie}),t[66]=i.continueChat,t[67]=K,t[68]=oe):oe=t[68];let se;t[69]!==p||t[70]!==i.archive||t[71]!==i.unarchive||t[72]!==l?(se=p?(0,Q.jsx)(`button`,{type:`button`,className:b,title:i.unarchive,"aria-label":i.unarchive,onClick:()=>l(`unarchive`),children:(0,Q.jsx)(q,{className:`size-4`,strokeWidth:1.75})}):(0,Q.jsx)(`button`,{type:`button`,className:b,title:i.archive,"aria-label":i.archive,onClick:()=>l(`archive`),children:(0,Q.jsx)(E,{className:`size-4`,strokeWidth:1.75})}),t[69]=p,t[70]=i.archive,t[71]=i.unarchive,t[72]=l,t[73]=se):se=t[73];let le;t[74]!==m||t[75]!==i.pin||t[76]!==i.unpin||t[77]!==l?(le=m?(0,Q.jsx)(`button`,{type:`button`,className:b,title:i.unpin,"aria-label":i.unpin,onClick:()=>l(`unpin`),children:(0,Q.jsx)(z,{className:`size-4`,strokeWidth:1.75})}):(0,Q.jsx)(`button`,{type:`button`,className:b,title:i.pin,"aria-label":i.pin,onClick:()=>l(`pin`),children:(0,Q.jsx)(A,{className:`size-4`,strokeWidth:1.75})}),t[74]=m,t[75]=i.pin,t[76]=i.unpin,t[77]=l,t[78]=le):le=t[78];let ue;t[79]===l?ue=t[80]:(ue=()=>l(`export`),t[79]=l,t[80]=ue);let de;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,Q.jsx)(ae,{className:`size-4`,strokeWidth:1.75}),t[81]=de):de=t[81];let pe;t[82]!==i.export||t[83]!==ue?(pe=(0,Q.jsx)(`button`,{type:`button`,className:b,title:i.export,"aria-label":i.export,onClick:ue,children:de}),t[82]=i.export,t[83]=ue,t[84]=pe):pe=t[84];let J;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(J=a(b,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),t[85]=J):J=t[85];let Y;t[86]===l?Y=t[87]:(Y=()=>l(`delete`),t[86]=l,t[87]=Y);let X;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(X=(0,Q.jsx)(fe,{className:`size-4`,strokeWidth:1.75}),t[88]=X):X=t[88];let me;t[89]!==i.delete||t[90]!==Y?(me=(0,Q.jsx)(`button`,{type:`button`,className:J,title:i.delete,"aria-label":i.delete,onClick:Y,children:X}),t[89]=i.delete,t[90]=Y,t[91]=me):me=t[91];let he;t[92]!==oe||t[93]!==se||t[94]!==le||t[95]!==pe||t[96]!==me?(he=(0,Q.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:xe,onKeyDown:be,children:[oe,se,le,pe,me]}),t[92]=oe,t[93]=se,t[94]=le,t[95]=pe,t[96]=me,t[97]=he):he=t[97];let Z;return t[98]!==c||t[99]!==D||t[100]!==G||t[101]!==g||t[102]!==he||t[103]!==_?(Z=(0,Q.jsxs)(`div`,{role:`button`,tabIndex:0,className:g,onClick:c,onKeyDown:_,children:[D,G,he]}),t[98]=c,t[99]=D,t[100]=G,t[101]=g,t[102]=he,t[103]=_,t[104]=Z):Z=t[104],Z}function be(e){return e.stopPropagation()}function xe(e){return e.stopPropagation()}function Se(e){return(0,Q.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 $(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ce(e){return e===`main`||e===`per-peer`||e===`per-channel-peer`||e===`per-account-channel-peer`?e:`main`}function we(e){let t=$(e)?e:{},n=$(t.session)?t.session:{},r=$(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:Ce(n.dmScope),pruneAfterDays:i,maxEntries:a}}async function Te(e){await c(s(`/api/config`),{method:`PATCH`,body:JSON.stringify({session:{dmScope:e.dmScope,storage:{pruneAfterMs:e.pruneAfterDays===null?null:e.pruneAfterDays*864e5,maxEntries:e.maxEntries}}})}),j()}function Ee(){return a(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,w,`dark:border-edge`)}var De=v();function Oe({hasToken:e}){let t=o(l(e=>e.language)).sessions.config,{data:n,isLoading:r}=pe(e),i=(0,Z.useMemo)(()=>n?.payload?.config===void 0?null:we(n.payload.config),[n]),[a,s]=(0,Z.useReducer)(De,{form:null,baseline:null}),c=a.form,u=a.baseline,[d,f]=(0,Z.useState)(!1),[ee,p]=(0,Z.useState)(null),m=(0,Z.useRef)(!1),_=(0,Z.useRef)(null);g({enabled:e,parsed:i,dirty:m.current,trackedParsedRef:_,dispatch:s,onResetDirty:()=>{m.current=!1}});let v=c&&u&&JSON.stringify(c)!==JSON.stringify(u),y=(0,Z.useCallback)(e=>{m.current=!0,s({type:`patch`,patch:e})},[]);return!e||!c?r?(0,Q.jsx)(Y,{children:(0,Q.jsx)(G,{className:`size-4 animate-spin text-fg-muted`})}):null:(0,Q.jsxs)(Y,{children:[(0,Q.jsx)(J,{icon:B,title:t.title,subtitle:t.hint}),(0,Q.jsxs)(`div`,{className:`mb-4 flex justify-end gap-2`,children:[(0,Q.jsx)(L,{type:`button`,variant:`secondary`,disabled:!v||d,onClick:()=>s({type:`discard`}),children:t.discard}),(0,Q.jsx)(L,{type:`button`,variant:`primary`,disabled:!v||d,onClick:()=>{(async()=>{f(!0),p(null);try{await Te(c),m.current=!1,s({type:`saved`,value:c})}catch(e){p(e instanceof Error?e.message:t.saveError)}finally{f(!1)}})()},children:d?t.saving:t.save})]}),ee?(0,Q.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:ee}):null,(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.dmScope}),(0,Q.jsxs)(M,{className:Ee(),value:c.dmScope,onChange:e=>y({dmScope:e.target.value}),children:[(0,Q.jsx)(h,{value:`main`,children:t.dmScopeMain}),(0,Q.jsx)(h,{value:`per-peer`,children:t.dmScopePerPeer}),(0,Q.jsx)(h,{value:`per-channel-peer`,children:t.dmScopePerChannelPeer}),(0,Q.jsx)(h,{value:`per-account-channel-peer`,children:t.dmScopePerAccountChannelPeer})]}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.dmScopeHint})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.pruneAfterDays}),(0,Q.jsx)(`input`,{type:`number`,min:0,className:Ee(),value:c.pruneAfterDays??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();y({pruneAfterDays:t===``?null:Math.max(0,Math.floor(Number(t)||0))})}})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.maxEntries}),(0,Q.jsx)(`input`,{type:`number`,min:1,className:Ee(),value:c.maxEntries??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();y({maxEntries:t===``?null:Math.max(1,Math.floor(Number(t)||1))})}})]})]})]})}function ke(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 Ae(e){let t=(0,ge.c)(60),{open:n,loading:r,session:i,sessionAgentId:o,sessionAgentAvatar:s,labels:c,onClose:l,onArchive:u,onUnarchive:d,onPin:f,onUnpin:p,onExport:m,onDelete:h}=e,g=i?.status===`archived`,_=i?.status===`pinned`,v;t[0]===l?v=t[1]:(v=e=>!e&&l(),t[0]=l,t[1]=v);let y;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Q.jsx)(ie,{className:a(`xopc-dialog-overlay fixed inset-0 bg-scrim`,ee)}),t[2]=y):y=t[2];let b;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(b=a(`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`,se,`dark:border-edge`),t[3]=b):b=t[3];let x;t[4]!==i||t[5]!==s||t[6]!==o?(x=i&&o?(0,Q.jsx)(ce,{agentId:o,avatar:s,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}):null,t[4]=i,t[5]=s,t[6]=o,t[7]=x):x=t[7];let S;t[8]!==c.unnamedSession||t[9]!==i?.name?(S=i?.name?.trim()||c.unnamedSession,t[8]=c.unnamedSession,t[9]=i?.name,t[10]=S):S=t[10];let C;t[11]===S?C=t[12]:(C=(0,Q.jsx)(re,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:S}),t[11]=S,t[12]=C);let w;t[13]!==x||t[14]!==C?(w=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[x,C]}),t[13]=x,t[14]=C,t[15]=w):w=t[15];let T;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Q.jsx)(te,{className:`size-5`,strokeWidth:1.75}),t[16]=T):T=t[16];let E;t[17]===c.close?E=t[18]:(E=(0,Q.jsx)(W,{asChild:!0,children:(0,Q.jsx)(L,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":c.close,children:T})}),t[17]=c.close,t[18]=E);let D;t[19]!==w||t[20]!==E?(D=(0,Q.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:[w,E]}),t[19]=w,t[20]=E,t[21]=D):D=t[21];let O;t[22]!==c.detailLoading||t[23]!==c.detailMessages||t[24]!==r||t[25]!==i?(O=r?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:c.detailLoading}):i?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`dl`,{className:`mb-4 grid gap-2 text-xs text-fg-muted`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-fg-disabled`,children:`Key`}),(0,Q.jsx)(`dd`,{className:`mt-0.5 break-all font-mono text-fg`,children:i.key})]}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-4`,children:(0,Q.jsxs)(`span`,{children:[i.messageCount,` msgs · `,i.estimatedTokens,` tok`]})})]}),(0,Q.jsx)(`h3`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:c.detailMessages}),(0,Q.jsx)(`ul`,{className:`space-y-3`,children:i.messages.map(je)})]}):null,t[22]=c.detailLoading,t[23]=c.detailMessages,t[24]=r,t[25]=i,t[26]=O):O=t[26];let k;t[27]===O?k=t[28]:(k=(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:O}),t[27]=O,t[28]=k);let A;t[29]!==c.detailExport||t[30]!==m?(A=(0,Q.jsx)(L,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:m,children:c.detailExport}),t[29]=c.detailExport,t[30]=m,t[31]=A):A=t[31];let j;t[32]!==g||t[33]!==c.archive||t[34]!==c.unarchive||t[35]!==u||t[36]!==d?(j=g?(0,Q.jsx)(L,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:d,children:c.unarchive}):(0,Q.jsx)(L,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:u,children:c.archive}),t[32]=g,t[33]=c.archive,t[34]=c.unarchive,t[35]=u,t[36]=d,t[37]=j):j=t[37];let M;t[38]!==_||t[39]!==c.pin||t[40]!==c.unpin||t[41]!==f||t[42]!==p?(M=_?(0,Q.jsx)(L,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:p,children:c.unpin}):(0,Q.jsx)(L,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:f,children:c.pin}),t[38]=_,t[39]=c.pin,t[40]=c.unpin,t[41]=f,t[42]=p,t[43]=M):M=t[43];let N;t[44]!==c.delete||t[45]!==h?(N=(0,Q.jsx)(L,{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:h,children:c.delete}),t[44]=c.delete,t[45]=h,t[46]=N):N=t[46];let P;t[47]!==A||t[48]!==j||t[49]!==M||t[50]!==N?(P=(0,Q.jsx)(`div`,{className:`shrink-0 border-t border-edge px-4 py-3 dark:border-edge`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[A,j,M,N]})}),t[47]=A,t[48]=j,t[49]=M,t[50]=N,t[51]=P):P=t[51];let F;t[52]!==D||t[53]!==k||t[54]!==P?(F=(0,Q.jsxs)(K,{children:[y,(0,Q.jsxs)(le,{className:b,"aria-describedby":void 0,children:[D,k,P]})]}),t[52]=D,t[53]=k,t[54]=P,t[55]=F):F=t[55];let I;return t[56]!==n||t[57]!==v||t[58]!==F?(I=(0,Q.jsx)(H,{open:n,onOpenChange:v,children:F}),t[56]=n,t[57]=v,t[58]=F,t[59]=I):I=t[59],I}function je(e){return(0,Q.jsxs)(`li`,{className:`rounded-lg border border-edge-subtle bg-surface-hover/50 p-2 dark:border-edge`,children:[(0,Q.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase text-fg-subtle`,children:e.role}),(0,Q.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-fg-muted`,children:ke(e.content)})]},`${e.timestamp??``}-${e.role}-${ke(e.content).slice(0,24)}`)}var Me=20;function Ne(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}var Pe=new Set([`all`,`active`,`pinned`,`archived`]),Fe=new Set([`grid`,`list`]),Ie=[`sessions`,`settings`];function Le(e){return e&&Ie.includes(e)?e:`sessions`}function Re(e,t){return t===`sessions`?e.tabsSessions:e.tabsSettings}function ze(e,t){return t===`sessions`?e.tabsSessionsHint:e.tabsSettingsHint}function Be(e){let t=(0,ge.c)(7),{s:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=Ie.map(e=>({id:e,label:Re(n,e),icon:e===`sessions`?oe:p})),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,Q.jsx)(X,{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 Ve(e){let t=(0,ge.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,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`mb-5`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:Re(n,r)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:ze(n,r)})]}),(0,Q.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,Q.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 He(e){let t=e.get(`status`),n=e.get(`view`);return{searchInput:e.get(`q`)??``,debouncedSearch:(e.get(`q`)??``).trim(),statusFilter:Pe.has(t)?t:`all`,viewMode:Fe.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 Ue(){let e=o(l(e=>e.language)),t=e.sessions,n=u(e=>e.token),r=!!n,{data:s,mutate:c}=d(r?[`gateway-chat-agents`,n]:null,x,{revalidateOnFocus:!1}),p=s?.defaultId??`main`,h=s?.items??[],[g,v]=i(),b=Le(g.get(`tab`)),w=(0,Z.useCallback)(e=>{let t=new URLSearchParams(g);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),v(t,{replace:!0})},[g,v]),[te,j]=(0,Z.useReducer)(D,g,He),{searchInput:M,debouncedSearch:R,statusFilter:z,viewMode:B,channelFilter:V,sessions:W,loading:G,error:ae,hasMore:ce,stats:q,detailOpen:fe,detailLoading:pe,detailSession:J,confirmOpen:Y,confirmKey:X}=te;(0,Z.useEffect)(()=>{let e=setTimeout(()=>{let e=M.trim();R!==e&&j({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[M,R]);let ge=g.toString(),_e=(0,Z.useRef)(ge);if(_e.current!==ge){_e.current=ge;let e=g.get(`q`)??``,t=g.get(`status`),n=g.get(`view`),r=(g.get(`channel`)??``).trim(),i=Pe.has(t)?t:`all`,a=Fe.has(n)?n:`grid`,o=e.trim();j({type:`patch`,patch:{...M===e?{}:{searchInput:e},...R===o?{}:{debouncedSearch:o},...z===i?{}:{statusFilter:i},...B===a?{}:{viewMode:a},...V===r?{}:{channelFilter:r}}})}(0,Z.useEffect)(()=>{let e=new URLSearchParams(g),t=R.trim();t?e.set(`q`,t):e.delete(`q`),z===`all`?e.delete(`status`):e.set(`status`,z),B===`grid`?e.delete(`view`):e.set(`view`,B),V?e.set(`channel`,V):e.delete(`channel`),e.toString()!==g.toString()&&v(e,{replace:!0})},[R,g,v,z,B,V]),(0,Z.useEffect)(()=>{if(!r||b!==`sessions`)return;let e=!1;return(async()=>{j({type:`patch`,patch:{loading:!0,error:null}});try{let t=await I({limit:Me,offset:0,...R?{search:R}:{},...z===`all`?{}:{status:z},...V?{channel:V}:{}});if(e)return;j({type:`patch`,patch:{sessions:t.items,hasMore:t.hasMore}})}catch(n){e||j({type:`patch`,patch:{error:n instanceof Error?n.message:t.loadError}})}finally{e||j({type:`patch`,patch:{loading:!1}})}})(),()=>{e=!0}},[r,b,R,z,V,t.loadError]),(0,Z.useEffect)(()=>{!r||b!==`sessions`||C().then(e=>j({type:`patch`,patch:{stats:e}})).catch(()=>{})},[r,b]),(0,Z.useEffect)(()=>{if(!r||b!==`sessions`)return;let e=()=>void c();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[r,b,c]),(0,Z.useEffect)(()=>{if(!r||b!==`sessions`)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||j({type:`patch`,patch:{sessions:W.map(e=>e.key===t.key?{...e,name:t.name}:e),detailSession:J&&J.key===t.key?{...J,name:t.name}:J}})};return window.addEventListener(`session-updated`,e),()=>{window.removeEventListener(`session-updated`,e)}},[r,b,W,J]);let ve=(0,Z.useCallback)(async()=>{if(!(!r||G||!ce)){j({type:`patch`,patch:{loading:!0,error:null}});try{let e=await I({limit:Me,offset:W.length,...R?{search:R}:{},...z===`all`?{}:{status:z},...V?{channel:V}:{}});j({type:`patch`,patch:{sessions:[...W,...e.items],hasMore:e.hasMore}})}catch(e){j({type:`patch`,patch:{error:e instanceof Error?e.message:t.loadError}})}finally{j({type:`patch`,patch:{loading:!1}})}}},[r,G,ce,W.length,R,z,V,t.loadError]),be=(0,Z.useCallback)((e,t)=>{j({type:`patch`,patch:{sessions:W.map(n=>n.key===e?{...n,status:t}:n),detailSession:J&&J.key===e?{...J,status:t}:J}})},[W,J]),xe=(0,Z.useCallback)(async e=>{j({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{j({type:`patch`,patch:{detailSession:await ue(e)}})}catch{j({type:`patch`,patch:{detailOpen:!1}})}finally{j({type:`patch`,patch:{detailLoading:!1}})}},[]),Se=e=>{xe(e)},$=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:e},bubbles:!0}));return}if(t===`delete`){j({type:`patch`,patch:{confirmKey:e,confirmOpen:!0}});return}try{switch(t){case`archive`:await P(e),be(e,`archived`);break;case`unarchive`:await k(e),be(e,`active`);break;case`pin`:await F(e),be(e,`pinned`);break;case`unpin`:await f(e),be(e,`active`);break;case`export`:{let t=await T(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}C().then(e=>j({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Ce=async e=>{try{await y(e),j({type:`patch`,patch:{sessions:W.filter(t=>t.key!==e),detailSession:J?.key===e?null:J,...J?.key===e?{detailOpen:!1}:{}}}),C().then(e=>j({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},we={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},Te={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},Ee=[{key:`all`,label:t.filterAll,icon:oe},{key:`active`,label:t.filterActive,icon:ne},{key:`pinned`,label:t.filterPinned,icon:A},{key:`archived`,label:t.filterArchived,icon:E}],De=(()=>{let e=Object.entries(q?.byChannel??{}).sort((e,t)=>t[1]-e[1]).slice(0,6).map(([e])=>e),t=new Set(e);for(let n of[`telegram`,`weixin`,`feishu`])t.has(n)||(e.push(n),t.add(n));return e.slice(0,8)})();return r?(0,Q.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-surface-panel`,children:[(0,Q.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,Q.jsx)(`header`,{className:`flex flex-col gap-2`,children:(0,Q.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:t.title})}),(0,Q.jsx)(Be,{s:t,activeTab:b,onChange:w}),(0,Q.jsx)(Ve,{s:t,id:`settings`,activeTab:b,plain:!0,children:(0,Q.jsx)(Oe,{hasToken:r})}),(0,Q.jsxs)(Ve,{s:t,id:`sessions`,activeTab:b,plain:!0,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Ee.map(({key:e,label:t,icon:n})=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":z===e,onClick:()=>j({type:`patch`,patch:{statusFilter:e}}),className:a(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,N.transition,N.focusRingPanel,z===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,Q.jsx)(n,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t]},e))}),(0,Q.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,Q.jsx)(O,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`input`,{type:`search`,value:M,onChange:e=>j({type:`patch`,patch:{searchInput:e.target.value}}),placeholder:t.searchPlaceholder,"data-debounced-query":R||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,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg-subtle`,children:t.filterChannelLabel}),(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":!V,onClick:()=>j({type:`patch`,patch:{channelFilter:``}}),className:a(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,N.transition,N.focusRingPanel,V?`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,Q.jsxs)(`button`,{type:`button`,"aria-pressed":V===e,onClick:()=>j({type:`patch`,patch:{channelFilter:e}}),className:a(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,N.transition,N.focusRingPanel,V===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[e,q?.byChannel?.[e]==null?null:(0,Q.jsx)(`span`,{className:`ml-2 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] text-fg-subtle`,children:q.byChannel[e]})]},e))]}),q?(0,Q.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[[q.totalSessions,t.totalSessions],[q.activeSessions,t.activeSessions],[q.pinnedSessions,t.pinnedSessions],[q.archivedSessions,t.archivedSessions]].map(([e,t])=>(0,Q.jsxs)(`div`,{className:`rounded-xl bg-surface-base p-3 dark:bg-surface-hover/30`,children:[(0,Q.jsx)(`div`,{className:`text-lg font-semibold tabular-nums text-fg`,children:e}),(0,Q.jsx)(`div`,{className:`text-xs text-fg-muted`,children:t})]},t))}):null,ae?(0,Q.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:ae}):null,(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:Ne(t.sessionCount,{count:W.length})}),(0,Q.jsxs)(`div`,{className:he,role:`group`,"aria-label":t.layoutToggleGroup,children:[(0,Q.jsx)(L,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":B===`grid`,onClick:()=>j({type:`patch`,patch:{viewMode:`grid`}}),className:a(me,`size-7 p-0`,B===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,B===`grid`&&`text-accent-fg`),children:(0,Q.jsx)(m,{className:`size-3.5`,strokeWidth:1.5})}),(0,Q.jsx)(L,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":B===`list`,onClick:()=>j({type:`patch`,patch:{viewMode:`list`}}),className:a(me,`size-9 p-0`,B===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,B===`list`&&`text-accent-fg`),children:(0,Q.jsx)(_,{className:`size-3.5`,strokeWidth:1.5})})]})]}),G&&W.length===0?(0,Q.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,Q.jsx)(`div`,{className:`h-40 animate-pulse rounded-xl bg-surface-hover/60 dark:bg-surface-hover/40`},t))}):W.length===0?(0,Q.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,Q.jsx)(S,{className:`mb-3 size-12 text-fg-disabled`,strokeWidth:1.25,"aria-hidden":!0}),(0,Q.jsx)(`p`,{className:`text-base font-semibold text-fg`,children:t.noSessions}),(0,Q.jsx)(`p`,{className:`mt-1 max-w-sm text-sm text-fg-muted`,children:t.noSessionsDescription}),(0,Q.jsx)(L,{variant:`primary`,className:`mt-6`,onClick:()=>{window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:``},bubbles:!0}))},children:t.startNewChat})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:a(`grid min-w-0 gap-3`,B===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":R||void 0,children:W.map(e=>{let t=de(e,p);return(0,Q.jsx)(ye,{session:e,variant:B,labels:we,sessionAgentId:t,sessionAgentAvatar:U(t,h),onOpen:()=>Se(e.key),onAction:t=>void $(e.key,t)},e.key)})}),ce?(0,Q.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Q.jsx)(L,{type:`button`,variant:`secondary`,disabled:G,onClick:()=>void ve(),children:t.loadMore})}):null]})]})]}),(0,Q.jsx)(Ae,{open:fe,loading:pe,session:J,sessionAgentId:J?de(J,p):void 0,sessionAgentAvatar:J?U(de(J,p),h):void 0,labels:Te,onClose:()=>{j({type:`patch`,patch:{detailOpen:!1,detailSession:null}})},onArchive:()=>J&&void $(J.key,`archive`),onUnarchive:()=>J&&void $(J.key,`unarchive`),onPin:()=>J&&void $(J.key,`pin`),onUnpin:()=>J&&void $(J.key,`unpin`),onExport:()=>J&&void $(J.key,`export`),onDelete:()=>J&&j({type:`patch`,patch:{confirmKey:J.key,confirmOpen:!0}})}),(0,Q.jsx)(H,{open:Y,onOpenChange:e=>j({type:`patch`,patch:{confirmOpen:e}}),children:(0,Q.jsxs)(K,{children:[(0,Q.jsx)(ie,{className:a(`xopc-dialog-overlay fixed inset-0 bg-scrim`,ee)}),(0,Q.jsxs)(le,{className:a(`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`,se),children:[(0,Q.jsx)(re,{className:`text-base font-semibold text-fg`,children:t.deleteSessionTitle}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:X?Ne(t.deleteSessionMessage,{name:W.find(e=>e.key===X)?.name?.trim()||e.chat.newSession}):``}),(0,Q.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Q.jsx)(L,{type:`button`,variant:`secondary`,onClick:()=>j({type:`patch`,patch:{confirmOpen:!1}}),children:t.cancel}),(0,Q.jsx)(L,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{X&&Ce(X),j({type:`patch`,patch:{confirmOpen:!1,confirmKey:null}})},children:t.delete})]})]})]})})]}):(0,Q.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{Ue as SessionsPage};
@@ -1 +0,0 @@
1
- import{Rr as e}from"./index-BJGusbyV.js";function t(t){let{children:n,fallback:r}=t,i=r===void 0?null:r;return e()?n:i}export{t};