@xopcai/xopc 0.0.360 → 0.0.361

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 (225) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{activity-store-CnmHVy1D.js → activity-store-tpFInIoh.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CQTERenW.js → agent-avatar-dicebear-DUhFW_Go.js} +1 -1
  5. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-BNILmgey.js +1 -0
  6. package/dist/gateway/static/root/assets/agent-plugin-dialog-CnWci4JJ.js +1 -0
  7. package/dist/gateway/static/root/assets/agents-CKS5LUUs.js +66 -0
  8. package/dist/gateway/static/root/assets/{agents-admin-api-BtnYiq7O.js → agents-admin-api-CiAjB2iQ.js} +1 -1
  9. package/dist/gateway/static/root/assets/{app-management-settings-panel-V5QVeMvW.js → app-management-settings-panel-DEig00YU.js} +1 -1
  10. package/dist/gateway/static/root/assets/{appearance-settings-BDkRcoI6.js → appearance-settings-CccnRRrL.js} +1 -1
  11. package/dist/gateway/static/root/assets/{apps-page-DzCyL89L.js → apps-page-CkT6UNZW.js} +1 -1
  12. package/dist/gateway/static/root/assets/{archive-plugin-DZCN9m71.js → archive-plugin-CIlmZBe5.js} +1 -1
  13. package/dist/gateway/static/root/assets/{automations-page-DOu1wMOV.js → automations-page-8kZugDcf.js} +1 -1
  14. package/dist/gateway/static/root/assets/automations-workspace-3V54ShL0.js +7 -0
  15. package/dist/gateway/static/root/assets/{binary-plugins-U63xxRgh.js → binary-plugins-BuQiee_b.js} +1 -1
  16. package/dist/gateway/static/root/assets/{block-editor-K6is5GrS.js → block-editor-BFFRbsKX.js} +3 -3
  17. package/dist/gateway/static/root/assets/{browser-automation-inputs-MmkUGn9W.js → browser-automation-inputs-CWujpdCx.js} +1 -1
  18. package/dist/gateway/static/root/assets/{browser-automations-page-B8IiXEBs.js → browser-automations-page-HVXiBKXE.js} +2 -2
  19. package/dist/gateway/static/root/assets/browser-settings-page-DpxAXNvM.js +3 -0
  20. package/dist/gateway/static/root/assets/{capabilities-BXG_5wIg.js → capabilities-CngwB2JU.js} +1 -1
  21. package/dist/gateway/static/root/assets/{capabilities-Bigu28Z6.js → capabilities-RMlKKfGF.js} +1 -1
  22. package/dist/gateway/static/root/assets/capabilities-page-BBi4ef3u.js +2 -0
  23. package/dist/gateway/static/root/assets/capabilities-settings-panel-IxszGl-Q.js +8 -0
  24. package/dist/gateway/static/root/assets/{capability-header-actions-wh3Nr0qS.js → capability-header-actions-BLOIJvIZ.js} +1 -1
  25. package/dist/gateway/static/root/assets/channels-Ced5nFBc.js +1 -0
  26. package/dist/gateway/static/root/assets/{chat-terminal-dock-BU-X9nu1.js → chat-terminal-dock-BskUzDCS.js} +2 -2
  27. package/dist/gateway/static/root/assets/{computer-settings-page-MyXsSqFJ.js → computer-settings-page-De-pjlvn.js} +1 -1
  28. package/dist/gateway/static/root/assets/{connector-service-page-DyxPM_MZ.js → connector-service-page-Qc1mVfp9.js} +1 -1
  29. package/dist/gateway/static/root/assets/connectors-page-CPqeY1x5.js +2 -0
  30. package/dist/gateway/static/root/assets/{date-picker-WRFvi7Pu.js → date-picker-7ppMIGfQ.js} +1 -1
  31. package/dist/gateway/static/root/assets/{dependency-picker-CLun5Tst.js → dependency-picker-DfYC22si.js} +1 -1
  32. package/dist/gateway/static/root/assets/{desktop-pet-iaVa9vVM.js → desktop-pet-GKEfqHDF.js} +1 -1
  33. package/dist/gateway/static/root/assets/{desktop-pet-settings-0RS3sP3Z.js → desktop-pet-settings-qoFZBKe9.js} +1 -1
  34. package/dist/gateway/static/root/assets/device-pairing-wizard-D8sTDd5s.js +1 -0
  35. package/dist/gateway/static/root/assets/{directory-picker-path-field-Btlldlt3.js → directory-picker-path-field-BC87CZa2.js} +1 -1
  36. package/dist/gateway/static/root/assets/{extension-debug-page-BImQT4PU.js → extension-debug-page-VxCq29jC.js} +1 -1
  37. package/dist/gateway/static/root/assets/{extension-page-BmuLv-ET.js → extension-page-DypBVBTt.js} +1 -1
  38. package/dist/gateway/static/root/assets/{extension-provider-Dg7cRxDX.js → extension-provider-wlvxPese.js} +1 -1
  39. package/dist/gateway/static/root/assets/{extension-settings-page-7Kr8UJK4.js → extension-settings-page-DzzkBN9y.js} +1 -1
  40. package/dist/gateway/static/root/assets/{fallback-models-B0w1lumZ.js → fallback-models-s4qTRcPJ.js} +1 -1
  41. package/dist/gateway/static/root/assets/{gateway-config-swr-EZxaKXdC.js → gateway-config-swr-ZM72jovc.js} +1 -1
  42. package/dist/gateway/static/root/assets/{gateway-realtime-DBRa17u3.js → gateway-realtime-B-hrykag.js} +1 -1
  43. package/dist/gateway/static/root/assets/gateway-realtime-store-B6B1fw_K.js +1 -0
  44. package/dist/gateway/static/root/assets/gateway-settings--M7ZH_37.js +1 -0
  45. package/dist/gateway/static/root/assets/{gateway-startup-retry-Wtxq_y2f.js → gateway-startup-retry-DjWuTj8B.js} +1 -1
  46. package/dist/gateway/static/root/assets/home-page-KFs5suD1.js +1 -0
  47. package/dist/gateway/static/root/assets/{image-generation-api-Bnl0CH4n.js → image-generation-api-C9cwrqCr.js} +1 -1
  48. package/dist/gateway/static/root/assets/{imports-page-BLOJY67-.js → imports-page-BKy0ImXk.js} +1 -1
  49. package/dist/gateway/static/root/assets/index-C0JT9Ja4.js +106 -0
  50. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-Dlbsip2R.js → keyboard-shortcuts-settings-CexiL-Ey.js} +1 -1
  51. package/dist/gateway/static/root/assets/{local-app-workbench-page-nyWeTK0r.js → local-app-workbench-page-CcU1OLWQ.js} +1 -1
  52. package/dist/gateway/static/root/assets/{local-apps-page-CfEpFLs0.js → local-apps-page-BcLijQx4.js} +1 -1
  53. package/dist/gateway/static/root/assets/{local-session-drafts-CeHhcudO.js → local-session-drafts-C7QjBMNp.js} +1 -1
  54. package/dist/gateway/static/root/assets/{locale-store-ChN_vjs2.js → locale-store-5sV3dDRG.js} +1 -1
  55. package/dist/gateway/static/root/assets/{logs-page-A38cawkA.js → logs-page-48nrZNQe.js} +2 -2
  56. package/dist/gateway/static/root/assets/management-settings-B_gzl_Vh.js +1 -0
  57. package/dist/gateway/static/root/assets/{markdown-view-DKlJx4eo.js → markdown-view-V0f5NW7D.js} +1 -1
  58. package/dist/gateway/static/root/assets/{media-plugins-JWzrPQwt.js → media-plugins-_obxSZmT.js} +1 -1
  59. package/dist/gateway/static/root/assets/{messages-CnM6Qfr7.js → messages-CaURu8bb.js} +2 -2
  60. package/dist/gateway/static/root/assets/models-hub-cache-Cs3E5pEA.js +1 -0
  61. package/dist/gateway/static/root/assets/{note-detail-panel-CUGVyo2V.js → note-detail-panel-B9AeX98W.js} +3 -3
  62. package/dist/gateway/static/root/assets/{notes-api-D8nvWMMC.js → notes-api-CBnMq6Nc.js} +1 -1
  63. package/dist/gateway/static/root/assets/notes-page-CKTTfxw-.js +8 -0
  64. package/dist/gateway/static/root/assets/{oauth-api-BXn1a9qx.js → oauth-api-Bu2RoLF2.js} +1 -1
  65. package/dist/gateway/static/root/assets/{page-context-capture-button-C72qIgBg.js → page-context-capture-button-BsxBAWD_.js} +1 -1
  66. package/dist/gateway/static/root/assets/personal-page-Cfl1FR3i.js +1 -0
  67. package/dist/gateway/static/root/assets/{product-open-page-CT98FsVl.js → product-open-page-D1ARqS3r.js} +1 -1
  68. package/dist/gateway/static/root/assets/{project-detail-page-BlqOVwKP.js → project-detail-page-Cro1OE8P.js} +1 -1
  69. package/dist/gateway/static/root/assets/projects-page-CdEmmBCz.js +1 -0
  70. package/dist/gateway/static/root/assets/{registry-api-BM_81rLe.js → registry-api-j1rNFkP2.js} +1 -1
  71. package/dist/gateway/static/root/assets/remote-access-hub-C9_ea_4p.js +1 -0
  72. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-ry0jprz7.js → runtime-tools-settings-panel-DtmQbC72.js} +1 -1
  73. package/dist/gateway/static/root/assets/{scenes-page-CV1GkOj6.js → scenes-page-DeFdMf2q.js} +2 -2
  74. package/dist/gateway/static/root/assets/{schema-form-C5zMrxgR.js → schema-form-ByEHHW6n.js} +1 -1
  75. package/dist/gateway/static/root/assets/{send-session-input-Dt0t5SoR.js → send-session-input-CO_vUCb8.js} +1 -1
  76. package/dist/gateway/static/root/assets/{session-api-UkGomZfv.js → session-api-CYPGi01d.js} +1 -1
  77. package/dist/gateway/static/root/assets/{session-manager-DDR-gv_e.js → session-manager-BdJThQQ6.js} +1 -1
  78. package/dist/gateway/static/root/assets/sessions-page-CV0JlaXS.js +1 -0
  79. package/dist/gateway/static/root/assets/settings-advanced-gate-D9sW0hKa.js +1 -0
  80. package/dist/gateway/static/root/assets/{settings-page-C88fsfZF.js → settings-page-CHKsZFAN.js} +1 -1
  81. package/dist/gateway/static/root/assets/{setup-status-panel-DESlRgZS.js → setup-status-panel-CC58OVOe.js} +1 -1
  82. package/dist/gateway/static/root/assets/{share-link-dialog-BvSRHs1P.js → share-link-dialog-ZOdnHkmb.js} +1 -1
  83. package/dist/gateway/static/root/assets/{share-preview-page-D5Gey-6E.js → share-preview-page-BPDWUuH_.js} +1 -1
  84. package/dist/gateway/static/root/assets/{shares-api-DwqLga5H.js → shares-api-T5gR8yqz.js} +1 -1
  85. package/dist/gateway/static/root/assets/shares-settings-DaXvdH8c.js +1 -0
  86. package/dist/gateway/static/root/assets/{skill-api-1hbX3qDC.js → skill-api-CHCLMcfO.js} +1 -1
  87. package/dist/gateway/static/root/assets/{skill-reload-api-C1hzIawD.js → skill-reload-api-C-RoiUJi.js} +1 -1
  88. package/dist/gateway/static/root/assets/skills-page-a9UQQnqn.js +2 -0
  89. package/dist/gateway/static/root/assets/{system-settings-panel-DbNk-Jwq.js → system-settings-panel-Dho_dlBS.js} +1 -1
  90. package/dist/gateway/static/root/assets/{task-detail-page-DoLKOJrE.js → task-detail-page-B5JyH4z7.js} +1 -1
  91. package/dist/gateway/static/root/assets/{theme-store-DTYk7Gll.js → theme-store-CEl74p7l.js} +1 -1
  92. package/dist/gateway/static/root/assets/{tunnel-api-H3FheXYH.js → tunnel-api-BDqCyf8G.js} +1 -1
  93. package/dist/gateway/static/root/assets/{usage-page-DGbqcsV6.js → usage-page-DKwKfszc.js} +1 -1
  94. package/dist/gateway/static/root/assets/{use-autosave-R3hEHQQq.js → use-autosave-D09eZTLp.js} +1 -1
  95. package/dist/gateway/static/root/assets/{use-composer-attachments-pzPAUV_o.js → use-composer-attachments-CkvJM8Km.js} +1 -1
  96. package/dist/gateway/static/root/assets/{use-file-preview-expanded-DNhXjL0W.js → use-file-preview-expanded-J3HnG8OH.js} +2 -2
  97. package/dist/gateway/static/root/assets/user-model-page-BsgADrGL.js +2 -0
  98. package/dist/gateway/static/root/assets/{voice-api-key-field-C-AF-IcO.js → voice-api-key-field-DH-to9Rd.js} +1 -1
  99. package/dist/gateway/static/root/assets/{voice-config-api-CxGsCDoW.js → voice-config-api-CmCfVy3H.js} +1 -1
  100. package/dist/gateway/static/root/assets/{work-discovery-overlay-DfyI9kVf.js → work-discovery-overlay-x1vZDBhu.js} +1 -1
  101. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-De80GODZ.js → workflow-run-setup-panel-DGatvmK1.js} +2 -2
  102. package/dist/gateway/static/root/assets/workflows-page-DgNy6mBQ.js +6 -0
  103. package/dist/gateway/static/root/assets/{workspace-api-Dwa8kHdY.js → workspace-api-DzPw92Kx.js} +2 -2
  104. package/dist/gateway/static/root/index.html +27 -28
  105. package/dist/package.js +1 -1
  106. package/dist/src/agent/agent-manager.js +3 -3
  107. package/dist/src/agent/background-review/run-background-review.js +1 -1
  108. package/dist/src/agent/embedded/run-for-session.js +70 -4
  109. package/dist/src/agent/external-tools/endpoint-provider.js +2 -2
  110. package/dist/src/agent/image/tool-model-config.js +1 -1
  111. package/dist/src/agent/inbound/attachment-pipeline.js +13 -0
  112. package/dist/src/agent/mcp/oauth/mcp-oauth-store.js +1 -1
  113. package/dist/src/agent/memory/compaction-policy.d.ts +4 -0
  114. package/dist/src/agent/memory/compaction-policy.js +3 -0
  115. package/dist/src/agent/memory/idle-compaction-scheduler.d.ts +28 -0
  116. package/dist/src/agent/memory/idle-compaction-scheduler.js +127 -0
  117. package/dist/src/agent/service/process-direct-one-shot.js +1 -0
  118. package/dist/src/agent/service/process-direct-streaming.js +1 -0
  119. package/dist/src/agent/service.js +3 -2
  120. package/dist/src/agent/session/session-config-service.js +1 -1
  121. package/dist/src/agent/skills/hub-lock.js +1 -1
  122. package/dist/src/agent/skills/index.js +1 -1
  123. package/dist/src/agent/skills/managed-store.js +1 -1
  124. package/dist/src/agent/skills/skill-manage-ops.js +1 -1
  125. package/dist/src/agent/tools/delegation-policy.js +1 -0
  126. package/dist/src/agent/tools/factory.js +16 -2
  127. package/dist/src/agent/tools/index.d.ts +1 -0
  128. package/dist/src/agent/tools/index.js +2 -1
  129. package/dist/src/agent/tools/media-read-tool.d.ts +5 -1
  130. package/dist/src/agent/tools/media-read-tool.js +44 -5
  131. package/dist/src/agent/tools/personal-read-tool.d.ts +3 -0
  132. package/dist/src/agent/tools/personal-read-tool.js +155 -0
  133. package/dist/src/agent/tools/personal-task-tool.js +1 -1
  134. package/dist/src/agent/tools/read.d.ts +3 -0
  135. package/dist/src/agent/tools/read.js +26 -8
  136. package/dist/src/agent/tools/session-search-tool.d.ts +1 -0
  137. package/dist/src/agent/tools/session-search-tool.js +39 -5
  138. package/dist/src/agent/tools/xopc-use-tool.js +2 -2
  139. package/dist/src/agent-catalog/capabilities.js +2 -2
  140. package/dist/src/auth/credentials.js +1 -1
  141. package/dist/src/auth/oauth-provider-lock.js +1 -1
  142. package/dist/src/auth/profiles/store.js +1 -1
  143. package/dist/src/automations/capabilities/drafts.js +1 -1
  144. package/dist/src/bootstrap/application-state.js +1 -1
  145. package/dist/src/browser/providers/browser-ext-install.js +1 -1
  146. package/dist/src/capabilities/runtime/dispatcher.js +1 -1
  147. package/dist/src/capabilities/runtime/product.js +1 -1
  148. package/dist/src/cli/commands/agent.js +1 -1
  149. package/dist/src/cli/commands/agents.js +1 -1
  150. package/dist/src/cli/commands/models.js +1 -1
  151. package/dist/src/cli/commands/onboard/model.js +1 -1
  152. package/dist/src/cli/utils/init-workspace-core.js +1 -1
  153. package/dist/src/config/index.js +3 -3
  154. package/dist/src/config/loader.js +1 -1
  155. package/dist/src/config/models-json.js +1 -1
  156. package/dist/src/config/schema.d.ts +10 -0
  157. package/dist/src/config/schema.js +1 -1
  158. package/dist/src/extensions/agent-plugins/validation.js +1 -1
  159. package/dist/src/extensions/lockfile.js +1 -1
  160. package/dist/src/gateway/agents-admin.js +2 -2
  161. package/dist/src/gateway/hono/lib/config-payload.d.ts +10 -0
  162. package/dist/src/gateway/hono/lib/config-payload.js +1 -1
  163. package/dist/src/gateway/hono/routes/config-patch/misc.js +2 -2
  164. package/dist/src/gateway/hono/routes/notes.js +2 -2
  165. package/dist/src/gateway/hono/routes/personal-agent.js +1 -1
  166. package/dist/src/gateway/hono/routes/projects.js +2 -2
  167. package/dist/src/gateway/hono/routes/session-input-handler.js +1 -1
  168. package/dist/src/gateway/hono/routes/sessions.js +1 -1
  169. package/dist/src/gateway/hono/routes/tasks.js +1 -1
  170. package/dist/src/gateway/hono/routes/voice.js +1 -1
  171. package/dist/src/gateway/image-generation-setup.js +2 -2
  172. package/dist/src/gateway/lock.js +1 -1
  173. package/dist/src/gateway/service/agent-runner.js +1 -0
  174. package/dist/src/gateway/service/session-command-service.js +1 -1
  175. package/dist/src/gateway/service/session-input-coordinator.d.ts +1 -0
  176. package/dist/src/gateway/service/session-input-coordinator.js +2 -0
  177. package/dist/src/gateway/service.js +1 -1
  178. package/dist/src/gateway/xopc-cloud-capability-setup.js +1 -1
  179. package/dist/src/local-apps/service.js +1 -1
  180. package/dist/src/media/store.js +5 -1
  181. package/dist/src/personal-agent/policy.d.ts +1 -1
  182. package/dist/src/personal-agent/policy.js +4 -0
  183. package/dist/src/personal-agent/request-service.js +1 -1
  184. package/dist/src/personal-agent/service.js +9 -7
  185. package/dist/src/providers/model-catalog-persistence.js +1 -1
  186. package/dist/src/session/store.d.ts +12 -1
  187. package/dist/src/session/store.js +33 -0
  188. package/dist/src/storage/sqlite/transcript-repository.d.ts +4 -1
  189. package/dist/src/storage/sqlite/transcript-repository.js +15 -1
  190. package/dist/src/tasks/capabilities/read.js +2 -2
  191. package/dist/src/tasks/task-main-update-decision-service.js +1 -1
  192. package/dist/src/tasks/task-result-delivery-repository.js +1 -1
  193. package/dist/src/tui/backends/embedded-backend.js +2 -2
  194. package/dist/src/user-context/config.d.ts +48 -0
  195. package/dist/src/user-context/config.js +23 -3
  196. package/dist/src/voice/realtime/persona-context.js +1 -1
  197. package/dist/src/voice/realtime/runtime.js +1 -1
  198. package/package.json +1 -1
  199. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CPF0lunJ.js +0 -1
  200. package/dist/gateway/static/root/assets/agent-plugin-dialog-BjDaZlKy.js +0 -1
  201. package/dist/gateway/static/root/assets/agents-XopBILLB.js +0 -66
  202. package/dist/gateway/static/root/assets/automations-workspace-CiY_2otj.js +0 -7
  203. package/dist/gateway/static/root/assets/browser-settings-page-Cms2Bu3Q.js +0 -3
  204. package/dist/gateway/static/root/assets/capabilities-page-BAFRNHQv.js +0 -2
  205. package/dist/gateway/static/root/assets/capabilities-settings-panel-Cws6od1d.js +0 -8
  206. package/dist/gateway/static/root/assets/channels-DxwismTc.js +0 -1
  207. package/dist/gateway/static/root/assets/connectors-page-C7-OC3MW.js +0 -2
  208. package/dist/gateway/static/root/assets/device-pairing-wizard-DVAGb04L.js +0 -1
  209. package/dist/gateway/static/root/assets/gateway-realtime-store-7glMlD2l.js +0 -1
  210. package/dist/gateway/static/root/assets/gateway-settings-DmPvmwYp.js +0 -1
  211. package/dist/gateway/static/root/assets/home-page-N0Mp-eTJ.js +0 -1
  212. package/dist/gateway/static/root/assets/index-BXrBL_Hb.js +0 -106
  213. package/dist/gateway/static/root/assets/management-settings-Cse9K61x.js +0 -1
  214. package/dist/gateway/static/root/assets/model-display-name-DXhO9rcM.js +0 -1
  215. package/dist/gateway/static/root/assets/models-hub-cache-DnIOzcvn.js +0 -1
  216. package/dist/gateway/static/root/assets/notes-page-Dk89l5dC.js +0 -8
  217. package/dist/gateway/static/root/assets/personal-page-DCtduzh8.js +0 -1
  218. package/dist/gateway/static/root/assets/projects-page-DVN2q_yR.js +0 -1
  219. package/dist/gateway/static/root/assets/remote-access-hub-BP5kUgIN.js +0 -1
  220. package/dist/gateway/static/root/assets/sessions-page-BXtGeOsR.js +0 -1
  221. package/dist/gateway/static/root/assets/settings-advanced-gate-CvFVkELy.js +0 -1
  222. package/dist/gateway/static/root/assets/shares-settings-btoP07Fx.js +0 -1
  223. package/dist/gateway/static/root/assets/skills-page-DYJbwwBT.js +0 -2
  224. package/dist/gateway/static/root/assets/user-model-page-7pW4Pazn.js +0 -2
  225. package/dist/gateway/static/root/assets/workflows-page-BuH3pC1C.js +0 -6
@@ -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{g as i}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as a}from"./activity-YogQEteU.js";import{t as o}from"./chevron-right-BweFrslA.js";import{t as s}from"./popover-select-BgSdSbCL.js";import{t as c}from"./plus-Q2yW6OE7.js";import{t as l}from"./search-DA7gz22f.js";import{t as u}from"./x-B_N4OPjy.js";import{t as ee}from"./messages-CnM6Qfr7.js";import{t as d}from"./cn-JdwAhgNB.js";import{i as f,n as te,r as p}from"./locale-store-ChN_vjs2.js";import{a as m,n as h,o as g,r as _,s as v,t as y}from"./dist-BGTk37IG.js";import{i as b}from"./vendor-swr-BIWyz7Rc.js";import{t as x}from"./button-CS04eWY9.js";import{i as ne,o as S}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{n as C}from"./index.module-Cd9ENXfk.js";import{Do as re,Ts as ie,_c as w,as as T,ni as E,ti as D,wo as O}from"./index-BXrBL_Hb.js";import{t as k}from"./page-tabs-D2xpUV26.js";import{n as A,r as j,t as M}from"./settings-page-layout-X1x-2Cp9.js";import{t as N}from"./device-pairing-wizard-DVAGb04L.js";import{n as P}from"./settings-loading-skeleton-CAmWMaOT.js";var F=e(t(),1),I=n(),L=720*60*60*1e3;function R(e){let t=[e.access,e.principal].filter(e=>e!==null);return t.length>0&&t.every(e=>e.revokedAt!==void 0)}function z(e){return R(e)?`revoked`:e.endpoints.length>0?`online`:`offline`}function ae(e){return new Set(e.endpoints.flatMap(e=>e.tools.map(({descriptor:e})=>e.name))).size}function oe(e,t=Date.now()){return z(e)===`offline`?(e.lastSeenAt??e.createdAt)<t-L:!1}function se(e,t,n=Date.now()){let r=t.query.trim().toLocaleLowerCase();return e.filter(e=>{let i=z(e),a=t.status===`all`||(t.status===`active`?i!==`revoked`:t.status===`stale`?oe(e,n):i===t.status),o=!t.platform||e.platform===t.platform,s=!r||[e.displayName,e.id,e.kind,e.platform].some(e=>e.toLocaleLowerCase().includes(r));return a&&o&&s})}function ce(e){return e.length>8?e.slice(-8):e}var B=r();function le(e){let t=(0,I.c)(59),{device:n,busy:r,onClose:i,onRevoke:a}=e,o=te(V),s;t[0]===o?s=t[1]:(s=ee(o),t[0]=o,t[1]=s);let c=s.endpointToolsSettings,l=o===`zh`?`zh-CN`:`en`,f;t[2]===l?f=t[3]:(f=new Intl.DateTimeFormat(l,{dateStyle:`medium`,timeStyle:`short`}),t[2]=l,t[3]=f);let p=f,b;t[4]===n?b=t[5]:(b=n?z(n):`offline`,t[4]=n,t[5]=b);let C=b,ie=n!==null,w;t[6]===i?w=t[7]:(w=e=>!e&&i(),t[6]=i,t[7]=w);let T;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,B.jsx)(m,{className:d(`xopc-dialog-overlay fixed inset-0 bg-scrim`,S)}),t[8]=T):T=t[8];let E;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(E=d(`xopc-drawer-right fixed right-0 top-0 flex size-full max-w-lg flex-col border-l border-edge bg-surface-overlay shadow-popover outline-none`,ne),t[9]=E):E=t[9];let D=n?.displayName??c.deviceDetails,O;t[10]===D?O=t[11]:(O=(0,B.jsx)(v,{className:`truncate text-base font-semibold text-fg`,children:D}),t[10]=D,t[11]=O);let k;t[12]===n?k=t[13]:(k=n?(0,B.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[n.kind,` · `,n.platform,` · `,ce(n.id)]}):null,t[12]=n,t[13]=k);let A;t[14]!==O||t[15]!==k?(A=(0,B.jsxs)(`div`,{className:`min-w-0`,children:[O,k]}),t[14]=O,t[15]=k,t[16]=A):A=t[16];let j;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,B.jsx)(u,{className:`size-5`,"aria-hidden":!0}),t[17]=j):j=t[17];let M;t[18]===c.close?M=t[19]:(M=(0,B.jsx)(h,{asChild:!0,children:(0,B.jsx)(x,{variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":c.close,children:j})}),t[18]=c.close,t[19]=M);let N;t[20]!==A||t[21]!==M?(N=(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[A,M]}),t[20]=A,t[21]=M,t[22]=N):N=t[22];let P;t[23]!==c.accessActive||t[24]!==c.accessRevoked||t[25]!==c.accessTitle||t[26]!==c.createdAt||t[27]!==c.endpointCount||t[28]!==c.endpointsTitle||t[29]!==c.identityId||t[30]!==c.identityTitle||t[31]!==c.lastSeen||t[32]!==c.never||t[33]!==c.noAccessIdentity||t[34]!==c.noOnlineEndpoints||t[35]!==c.noPermissions||t[36]!==c.permissions||t[37]!==c.status||t[38]!==c.statusLabel||t[39]!==c.toolCount||t[40]!==n||t[41]!==p||t[42]!==C?(P=n?(0,B.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto p-4`,children:[(0,B.jsxs)(`dl`,{className:`grid grid-cols-2 gap-3 rounded-xl bg-surface-hover/40 p-4`,children:[(0,B.jsx)(H,{label:c.statusLabel,value:c.status[C]}),(0,B.jsx)(H,{label:c.lastSeen,value:n.lastSeenAt?p.format(n.lastSeenAt):c.never}),(0,B.jsx)(H,{label:c.endpointCount,value:String(n.endpoints.length)}),(0,B.jsx)(H,{label:c.toolCount,value:String(ae(n))})]}),(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:c.accessTitle}),(0,B.jsx)(`div`,{className:`mt-2 rounded-xl border border-edge-subtle bg-surface-base p-3 text-xs text-fg-muted`,children:n.access?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`p`,{children:n.access.revokedAt?c.accessRevoked:c.accessActive}),(0,B.jsxs)(`p`,{className:`mt-1 break-words`,children:[c.permissions,`: `,n.access.scopes.join(`, `)||c.noPermissions]})]}):(0,B.jsx)(`p`,{children:c.noAccessIdentity})})]}),(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:c.endpointsTitle}),(0,B.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[n.endpoints.length===0?(0,B.jsx)(`p`,{className:`text-sm text-fg-muted`,children:c.noOnlineEndpoints}):null,n.endpoints.map(e=>(0,B.jsxs)(`article`,{className:`rounded-xl border border-edge-subtle bg-surface-base p-3`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,B.jsx)(`p`,{className:`min-w-0 break-all text-xs font-medium text-fg`,children:e.endpointId}),(0,B.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[c.status[e.availability],` · v`,e.appVersion]})]}),(0,B.jsx)(`div`,{className:`mt-3 space-y-2`,children:e.tools.map(e=>{let{descriptor:t}=e;return(0,B.jsxs)(`div`,{className:`rounded-lg bg-surface-hover/50 px-3 py-2`,children:[(0,B.jsx)(`p`,{className:`break-all text-xs font-medium text-fg`,children:t.name}),(0,B.jsx)(`p`,{className:`mt-0.5 break-words text-xs text-fg-subtle`,children:t.requiredPermissions.join(`, `)||c.noPermissions})]},t.name)})})]},e.connectionId))]})]}),(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:c.identityTitle}),(0,B.jsxs)(`dl`,{className:`mt-2 rounded-xl border border-edge-subtle bg-surface-base p-3 text-xs`,children:[(0,B.jsx)(H,{label:c.identityId,value:n.id,breakAll:!0}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(H,{label:c.createdAt,value:p.format(n.createdAt)})})]})]})]}):null,t[23]=c.accessActive,t[24]=c.accessRevoked,t[25]=c.accessTitle,t[26]=c.createdAt,t[27]=c.endpointCount,t[28]=c.endpointsTitle,t[29]=c.identityId,t[30]=c.identityTitle,t[31]=c.lastSeen,t[32]=c.never,t[33]=c.noAccessIdentity,t[34]=c.noOnlineEndpoints,t[35]=c.noPermissions,t[36]=c.permissions,t[37]=c.status,t[38]=c.statusLabel,t[39]=c.toolCount,t[40]=n,t[41]=p,t[42]=C,t[43]=P):P=t[43];let F;t[44]!==r||t[45]!==c.removeDevice||t[46]!==c.revoking||t[47]!==n||t[48]!==a||t[49]!==C?(F=n&&C!==`revoked`?(0,B.jsx)(`div`,{className:`shrink-0 border-t border-edge px-4 py-3`,children:(0,B.jsxs)(x,{variant:`secondary`,className:`w-full text-danger`,disabled:r,onClick:()=>a(n),children:[(0,B.jsx)(re,{className:`size-4`,"aria-hidden":!0}),r?c.revoking:c.removeDevice]})}):null,t[44]=r,t[45]=c.removeDevice,t[46]=c.revoking,t[47]=n,t[48]=a,t[49]=C,t[50]=F):F=t[50];let L;t[51]!==N||t[52]!==P||t[53]!==F?(L=(0,B.jsxs)(g,{children:[T,(0,B.jsxs)(_,{className:E,"aria-describedby":void 0,children:[N,P,F]})]}),t[51]=N,t[52]=P,t[53]=F,t[54]=L):L=t[54];let R;return t[55]!==L||t[56]!==ie||t[57]!==w?(R=(0,B.jsx)(y,{open:ie,onOpenChange:w,children:L}),t[55]=L,t[56]=ie,t[57]=w,t[58]=R):R=t[58],R}function V(e){return e.language}function H(e){let t=(0,I.c)(10),{label:n,value:r,breakAll:i}=e,a=i===void 0?!1:i,o;t[0]===n?o=t[1]:(o=(0,B.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:n}),t[0]=n,t[1]=o);let s=a&&`break-all font-mono text-xs`,c;t[2]===s?c=t[3]:(c=d(`mt-1 text-sm text-fg`,s),t[2]=s,t[3]=c);let l;t[4]!==c||t[5]!==r?(l=(0,B.jsx)(`dd`,{className:c,children:r}),t[4]=c,t[5]=r,t[6]=l):l=t[6];let u;return t[7]!==o||t[8]!==l?(u=(0,B.jsxs)(`div`,{className:`min-w-0`,children:[o,l]}),t[7]=o,t[8]=l,t[9]=u):u=t[9],u}function ue(e){let t=(0,I.c)(19),{onPaired:n}=e,[r,a]=i(),o=te(de),s;t[0]===o?s=t[1]:(s=ee(o),t[0]=o,t[1]=s);let l=s.endpointToolsSettings.deviceAccess,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u={open:!1},t[2]=u):u=t[2];let[d,f]=(0,F.useState)(u),p,m;t[3]!==r||t[4]!==a?(p=()=>{let e=r.get(`startDevicePairing`);e!==`mobile`&&e!==`browser`||(f({open:!0,target:e}),a(U,{replace:!0}))},m=[r,a],t[3]=r,t[4]=a,t[5]=p,t[6]=m):(p=t[5],m=t[6]),(0,F.useEffect)(p,m);let h,g;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>f({open:!0}),g=(0,B.jsx)(c,{className:`size-4`,"aria-hidden":!0}),t[7]=h,t[8]=g):(h=t[7],g=t[8]);let _;t[9]===l.addDevice?_=t[10]:(_=(0,B.jsxs)(x,{variant:`primary`,onClick:h,children:[g,l.addDevice]}),t[9]=l.addDevice,t[10]=_);let v;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(v=e=>f(t=>({...t,open:e})),t[11]=v):v=t[11];let y;t[12]!==d.open||t[13]!==d.target||t[14]!==n?(y=(0,B.jsx)(N,{open:d.open,onOpenChange:v,onPaired:n,targetKind:d.target}),t[12]=d.open,t[13]=d.target,t[14]=n,t[15]=y):y=t[15];let b;return t[16]!==_||t[17]!==y?(b=(0,B.jsxs)(B.Fragment,{children:[_,y]}),t[16]=_,t[17]=y,t[18]=b):b=t[18],b}function U(e){let t=new URLSearchParams(e);return t.delete(`startDevicePairing`),t}function de(e){return e.language}async function W(e){let t=await e.json().catch(()=>null);if(!e.ok||t?.payload===void 0)throw Error(t?.error?.message??`Endpoint management request failed: ${e.status}`);return t.payload}function fe(){return p(`/api/endpoint-tools/devices`)}function pe(e){let t=new URLSearchParams({page:String(e.page),pageSize:String(e.pageSize)});return e.query.trim()&&t.set(`query`,e.query.trim()),e.principalId&&t.set(`principalId`,e.principalId),e.status&&t.set(`status`,e.status),e.effect&&t.set(`effect`,e.effect),p(`/api/endpoint-tools/invocations?${t}`)}async function me(){return W(await f(fe()))}async function he(e){let t=Array.from({length:Math.ceil(e.length/100)},(t,n)=>e.slice(n*100,(n+1)*100));await Promise.all(t.map(async e=>{await W(await f(p(`/api/endpoint-tools/devices/revoke`),{method:`POST`,body:JSON.stringify({ids:e})}))}))}async function ge(e){return W(await f(pe(e)))}var _e=5e3,G=20,ve=20;function ye(e){return e===`online`||e===`succeeded`?`bg-success-soft text-success`:e===`running`?`bg-accent-soft text-accent-fg`:e===`failed`||e===`revoked`?`bg-danger-soft text-danger`:`bg-surface-hover text-fg-muted`}function be(e){let t=(0,I.c)(5),{status:n,label:r}=e,i;t[0]===n?i=t[1]:(i=d(`rounded-full px-2 py-0.5 text-xs font-medium`,ye(n)),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,B.jsx)(`span`,{className:i,children:r}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a}function xe(){let e=te(e=>e.language),t=ee(e).endpointToolsSettings,[n,r]=i(),c=n.get(`view`)===`activity`?`activity`:`devices`,[u,f]=(0,F.useState)(null),[p,m]=(0,F.useState)([]),[h,g]=(0,F.useState)(!1),[_,v]=(0,F.useState)(!1),[y,ne]=(0,F.useState)(``),[S,N]=(0,F.useState)(`active`),[I,L]=(0,F.useState)(``),[R,V]=(0,F.useState)(1),[H,U]=(0,F.useState)(()=>new Set),[de,W]=(0,F.useState)(``),[ye]=C(de,250),[xe,Se]=(0,F.useState)(``),[Ce,we]=(0,F.useState)(``),[Te,Ee]=(0,F.useState)(``),[De,K]=(0,F.useState)(1),Oe={page:De,pageSize:ve,query:ye,principalId:xe,status:Ce,effect:Te},q=b(fe(),me,{refreshInterval:_e}),J=b(c===`activity`?pe(Oe):null,()=>ge(Oe),{refreshInterval:_e,keepPreviousData:!0}),ke=(0,F.useMemo)(()=>new Intl.DateTimeFormat(e===`zh`?`zh-CN`:`en`,{dateStyle:`medium`,timeStyle:`short`}),[e]);if(q.isLoading&&!q.data)return(0,B.jsx)(j,{children:(0,B.jsx)(P,{sections:2})});let Y=q.data??[],Ae=J.data?.items??[],je=Y.filter(e=>z(e)===`online`).length,Me=Y.filter(e=>z(e)!==`revoked`).length,Ne=Y.filter(e=>oe(e)).length,Pe=[...new Set(Y.map(e=>e.platform))].toSorted(),X=se(Y,{query:y,status:S,platform:I}),Fe=Math.max(1,Math.ceil(X.length/G)),Z=Math.min(R,Fe),Ie=X.slice((Z-1)*G,Z*G),Q=Ie.reduce((e,t)=>(z(t)!==`revoked`&&e.push(t.id),e),[]),Le=Q.length>0&&Q.every(e=>H.has(e)),Re=e=>{r(t=>{let n=new URLSearchParams(t);return e===`devices`?n.delete(`view`):n.set(`view`,e),n},{replace:!0})},ze=async()=>{await Promise.all([q.mutate(),c===`activity`?J.mutate():Promise.resolve()])},Be=async()=>{if(!(p.length===0||h)){g(!0),v(!1);try{await he(p.map(e=>e.id)),m([]),U(new Set),await q.mutate()}catch{v(!0)}finally{g(!1)}}},$=e=>{e(),V(1),U(new Set)};return(0,B.jsxs)(j,{children:[(0,B.jsx)(A,{title:t.title,subtitle:t.subtitle,actions:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(D,{className:`size-9 shrink-0 p-0`,label:t.refresh,onClick:ze}),(0,B.jsx)(ue,{onPaired:()=>void q.mutate()})]})}),q.error||J.error?(0,B.jsx)(`div`,{className:`rounded-xl bg-danger-soft px-4 py-3 text-sm text-danger`,children:t.loadError}):null,(0,B.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[{label:t.activeDevices,value:Me,filter:`active`},{label:t.onlineDevices,value:je,filter:`online`},{label:t.staleDevices,value:Ne,filter:`stale`}].map(({label:e,value:t,filter:n})=>(0,B.jsxs)(`button`,{type:`button`,className:d(`touch-target rounded-xl px-4 py-3 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,S===n?`bg-surface-active`:`bg-surface-hover/20 hover:bg-surface-hover/50`),"aria-pressed":S===n,onClick:()=>{$(()=>N(n)),Re(`devices`)},children:[(0,B.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e}),(0,B.jsx)(`span`,{className:`mt-1 block text-2xl font-semibold text-fg`,children:t})]},n))}),(0,B.jsx)(k,{items:[{id:`devices`,label:t.devicesTab,icon:T,count:Me},{id:`activity`,label:t.activityTab,icon:a,count:J.data?.total}],activeTab:c,onChange:Re,ariaLabel:t.viewsAria,tabIdPrefix:`endpoint-management-tab`,panelIdPrefix:`endpoint-management-panel`}),(0,B.jsxs)(M,{id:`devices`,activeTab:c,tabIdPrefix:`endpoint-management-tab`,panelIdPrefix:`endpoint-management-panel`,title:t.devicesTitle,hint:t.devicesHint,children:[(0,B.jsxs)(`div`,{className:`mb-4 grid gap-2 sm:grid-cols-[minmax(0,1fr)_11rem_11rem]`,children:[(0,B.jsxs)(`label`,{className:`relative block`,children:[(0,B.jsx)(`span`,{className:`sr-only`,children:t.searchDevices}),(0,B.jsx)(l,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,B.jsx)(`input`,{type:`search`,"aria-label":t.searchDevices,value:y,placeholder:t.searchDevices,className:`h-10 w-full rounded-lg border border-edge bg-surface-inset pl-9 pr-3 text-base text-fg placeholder:text-fg-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent sm:text-sm`,onChange:e=>$(()=>ne(e.target.value))})]}),(0,B.jsx)(s,{value:S,options:[{value:`active`,label:t.filterActive},{value:`online`,label:t.status.online},{value:`offline`,label:t.status.offline},{value:`stale`,label:t.filterStale},{value:`revoked`,label:t.status.revoked},{value:`all`,label:t.filterAll}],placeholder:t.statusLabel,allowEmpty:!1,ariaLabel:t.statusLabel,onChange:e=>$(()=>N(e))}),(0,B.jsx)(s,{value:I,options:Pe.map(e=>({value:e,label:e})),placeholder:t.allPlatforms,emptyLabel:t.allPlatforms,ariaLabel:t.platformLabel,onChange:e=>$(()=>L(e))})]}),H.size>0?(0,B.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-3 rounded-xl bg-accent-soft px-3 py-2`,children:[(0,B.jsx)(`p`,{className:`text-sm font-medium text-accent-fg`,children:t.selectedCount.replace(`{{count}}`,String(H.size))}),(0,B.jsxs)(x,{variant:`secondary`,className:`text-danger`,onClick:()=>{v(!1),m(Y.filter(e=>H.has(e.id)))},children:[(0,B.jsx)(re,{className:`size-4`,"aria-hidden":!0}),t.removeSelected]})]}):null,Y.length===0?(0,B.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noDevices}):X.length===0?(0,B.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noMatchingDevices}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`flex min-h-10 items-center gap-3 border-b border-edge-subtle px-1`,children:(0,B.jsxs)(`label`,{className:d(`touch-target flex items-center gap-2 text-xs text-fg-muted`,Q.length>0?`cursor-pointer`:`cursor-not-allowed opacity-50`),children:[(0,B.jsx)(`input`,{type:`checkbox`,"aria-label":t.selectPage,checked:Le,disabled:Q.length===0,className:`size-4 accent-accent`,onChange:e=>{U(t=>{let n=new Set(t);for(let t of Q)e.target.checked?n.add(t):n.delete(t);return n})}}),t.selectPage]})}),(0,B.jsx)(`ul`,{className:`divide-y divide-edge-subtle`,children:Ie.map(e=>{let n=z(e),r=e.kind===`mobile`?O:ie;return(0,B.jsxs)(`li`,{className:`flex items-center gap-3`,children:[(0,B.jsx)(`label`,{className:d(`touch-target flex size-10 shrink-0 items-center justify-center`,n===`revoked`?`cursor-not-allowed opacity-40`:`cursor-pointer`),children:(0,B.jsx)(`input`,{type:`checkbox`,checked:H.has(e.id),disabled:n===`revoked`,"aria-label":t.selectDevice.replace(`{{name}}`,e.displayName),className:`size-4 accent-accent`,onChange:t=>{U(n=>{let r=new Set(n);return t.target.checked?r.add(e.id):r.delete(e.id),r})}})}),(0,B.jsxs)(`button`,{type:`button`,className:`touch-target flex min-w-0 flex-1 items-center gap-3 py-3 text-left hover:bg-surface-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>f(e),children:[(0,B.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-inset text-fg-muted`,children:(0,B.jsx)(r,{className:`size-4`,"aria-hidden":!0})}),(0,B.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.displayName}),(0,B.jsx)(be,{status:n,label:t.status[n]})]}),(0,B.jsxs)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:[e.platform,` · `,ce(e.id),` · `,t.lastSeen,`: `,e.lastSeenAt?ke.format(e.lastSeenAt):t.never]})]}),(0,B.jsx)(`span`,{className:`hidden shrink-0 text-right text-xs text-fg-muted sm:block`,children:t.endpointSummary.replace(`{{endpoints}}`,String(e.endpoints.length)).replace(`{{tools}}`,String(ae(e)))}),(0,B.jsx)(o,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0})]})]},e.id)})}),(0,B.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-between gap-3 border-t border-edge-subtle pt-3`,children:[(0,B.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.paginationSummary.replace(`{{from}}`,String((Z-1)*G+1)).replace(`{{to}}`,String(Math.min(Z*G,X.length))).replace(`{{total}}`,String(X.length))}),(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(x,{variant:`ghost`,className:`size-9 p-0`,"aria-label":t.previousPage,disabled:Z<=1,onClick:()=>V(e=>Math.max(1,e-1)),children:(0,B.jsx)(w,{className:`size-4`,"aria-hidden":!0})}),(0,B.jsx)(x,{variant:`ghost`,className:`size-9 p-0`,"aria-label":t.nextPage,disabled:Z>=Fe,onClick:()=>V(e=>Math.min(Fe,e+1)),children:(0,B.jsx)(o,{className:`size-4`,"aria-hidden":!0})})]})]})]})]}),(0,B.jsxs)(M,{id:`activity`,activeTab:c,tabIdPrefix:`endpoint-management-tab`,panelIdPrefix:`endpoint-management-panel`,title:t.callsTitle,hint:t.callsHint,children:[(0,B.jsxs)(`div`,{className:`mb-4 grid gap-2 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,B.jsxs)(`label`,{className:`relative block sm:col-span-2 lg:col-span-1`,children:[(0,B.jsx)(`span`,{className:`sr-only`,children:t.searchActivity}),(0,B.jsx)(l,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,B.jsx)(`input`,{type:`search`,"aria-label":t.searchActivity,value:de,placeholder:t.searchActivity,className:`h-10 w-full rounded-lg border border-edge bg-surface-inset pl-9 pr-3 text-base text-fg placeholder:text-fg-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent sm:text-sm`,onChange:e=>{W(e.target.value),K(1)}})]}),(0,B.jsx)(s,{value:xe,options:Y.map(e=>({value:e.id,label:`${e.displayName} · ${ce(e.id)}`})),placeholder:t.allDevices,emptyLabel:t.allDevices,ariaLabel:t.deviceLabel,onChange:e=>{Se(e),K(1)}}),(0,B.jsx)(s,{value:Ce,options:[{value:`running`,label:t.status.running},{value:`succeeded`,label:t.status.succeeded},{value:`failed`,label:t.status.failed}],placeholder:t.allStatuses,emptyLabel:t.allStatuses,ariaLabel:t.statusLabel,onChange:e=>{we(e),K(1)}}),(0,B.jsx)(s,{value:Te,options:[{value:`read`,label:t.effects.read},{value:`write`,label:t.effects.write},{value:`destructive`,label:t.effects.destructive}],placeholder:t.allEffects,emptyLabel:t.allEffects,ariaLabel:t.effectLabel,onChange:e=>{Ee(e),K(1)}})]}),J.isLoading&&!J.data?(0,B.jsx)(P,{sections:1}):null,Ae.length===0&&!J.isLoading?(0,B.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noMatchingCalls}):null,(0,B.jsx)(`div`,{className:`space-y-2`,children:Ae.map(e=>(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg bg-surface-base/55 px-3 py-2.5`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`p`,{className:`break-all text-sm font-medium text-fg`,children:e.toolName}),(0,B.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[ke.format(e.startedAt),` · `,t.effects[e.effect],` · `,e.endpointId]}),e.errorMessage?(0,B.jsx)(`p`,{className:`mt-1 text-xs text-danger`,children:e.errorMessage}):null]}),(0,B.jsx)(be,{status:e.status,label:t.status[e.status]})]},e.id))}),J.data&&J.data.total>0?(0,B.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-between gap-3 border-t border-edge-subtle pt-3`,children:[(0,B.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.paginationSummary.replace(`{{from}}`,String((J.data.page-1)*J.data.pageSize+1)).replace(`{{to}}`,String(Math.min(J.data.page*J.data.pageSize,J.data.total))).replace(`{{total}}`,String(J.data.total))}),(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(x,{variant:`ghost`,className:`size-9 p-0`,"aria-label":t.previousPage,disabled:J.data.page<=1,onClick:()=>K(e=>Math.max(1,e-1)),children:(0,B.jsx)(w,{className:`size-4`,"aria-hidden":!0})}),(0,B.jsx)(x,{variant:`ghost`,className:`size-9 p-0`,"aria-label":t.nextPage,disabled:J.data.page>=J.data.totalPages,onClick:()=>K(e=>Math.min(J.data.totalPages,e+1)),children:(0,B.jsx)(o,{className:`size-4`,"aria-hidden":!0})})]})]}):null]}),(0,B.jsx)(le,{device:u,busy:h,onClose:()=>f(null),onRevoke:e=>{f(null),v(!1),m([e])}}),(0,B.jsx)(E,{open:p.length>0,title:p.length>1?t.removeManyTitle:t.removeTitle,description:`${p.length>1?t.removeManyDescription.replace(`{{count}}`,String(p.length)):t.removeDescription.replace(`{{name}}`,p[0]?.displayName??``)}${_?`\n\n${t.revokeError}`:``}`,confirmLabel:h?t.revoking:t.removeDevice,cancelLabel:t.cancel,destructive:!0,onConfirm:()=>void Be(),onCancel:()=>{h||m([])}})]})}export{xe as EndpointToolsManagementSettings};
@@ -1 +0,0 @@
1
- function e(e,t){return e.displayNames?.[t.toLowerCase().startsWith(`zh`)?`zh-CN`:`en`]||e.name}export{e as t};
@@ -1 +0,0 @@
1
- import{r as e}from"./locale-store-ChN_vjs2.js";import{o as t}from"./vendor-swr-BIWyz7Rc.js";import{n}from"./gateway-config-swr-EZxaKXdC.js";import{r}from"./registry-api-BM_81rLe.js";var i=`models-json-config`,a=`model-catalog`,o=`capability-readiness`;async function s(){await Promise.all([n(),t(e(`/api/providers/meta`)),t(i),t(a),t(o),r()])}export{s as i,i as n,a as r,o as t};
@@ -1,8 +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{f as i,g as a,m as o,u as s}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as c}from"./popover-select-BgSdSbCL.js";import{t as l}from"./ellipsis-0k4rZLoy.js";import{f as u}from"./markdown-view-DKlJx4eo.js";import{A as d,D as f,E as p,_ as m,g as h,i as g,p as _,s as v}from"./notes-api-D8nvWMMC.js";import{t as ee}from"./loader-circle-CifKLtgG.js";import{t as y}from"./mic-CuUb7zc-.js";import{t as b}from"./plus-Q2yW6OE7.js";import{t as te}from"./search-DA7gz22f.js";import{t as ne}from"./sparkles-DHlfQFAF.js";import{t as x}from"./x-B_N4OPjy.js";import{t as S}from"./messages-CnM6Qfr7.js";import{t as C}from"./cn-JdwAhgNB.js";import{c as w,f as re,n as ie}from"./locale-store-ChN_vjs2.js";import{i as T}from"./vendor-swr-BIWyz7Rc.js";import{r as E}from"./app-chrome-BeB4KgOf.js";import{t as D}from"./skeleton-BwbyijEw.js";import{n as O}from"./index.module-Cd9ENXfk.js";import{$t as k,Ac as A,As as ae,Dn as oe,En as se,Ic as ce,Jt as j,Ks as le,Nc as ue,No as M,On as de,Pc as fe,Qt as N,Tc as pe,Tn as me,Vs as he,Xt as ge,Yo as P,Yt as _e,Zt as ve,ao as ye,en as F,es as be,jc as I,jn as xe,kn as Se,lo as Ce,ni as we,qi as Te,vc as Ee,yc as De,yo as Oe}from"./index-BXrBL_Hb.js";import{i as ke,t as L}from"./note-detail-panel-CUGVyo2V.js";var Ae=n(),R=e(t(),1),z=r();function je({projectId:e}){let t=ie(e=>e.language)===`zh`,n=i(),r=(0,R.useRef)(null),a=(0,R.useRef)(null),[o,s]=(0,R.useState)(null),[c,l]=(0,R.useState)(null),[u,d]=(0,R.useState)(null);async function f(){let t=a.current;if(!(!t||o!==null)){s(0),l(null);try{let r=await F();if(r.consentAcknowledgedAt==null){d(r.consentPolicyVersion);return}let i=await j(t.file,t.requestId),o=await k({clientRequestId:t.requestId,contextProjectId:e,source:`web`,consentPolicyVersion:r.consentPolicyVersion});t.discussionId=o.discussion.id,await ve({...i,serverDiscussionId:o.discussion.id,projectId:e}),o.discussion.audioAttachmentId||await _e(i,o.discussion.id,s),await ge(t.requestId),a.current=null,n(`/notes/${encodeURIComponent(o.note.id)}`)}catch(e){l(e instanceof Error?e.message:String(e))}finally{s(null)}}}return(0,z.jsxs)(`div`,{className:`inline-flex flex-wrap items-center gap-2 text-xs`,children:[(0,z.jsx)(`input`,{ref:r,hidden:!0,type:`file`,accept:`audio/*,.m4a,.wav,.mp3,.webm,.ogg`,onChange:e=>{let n=e.target.files?.[0];if(e.target.value=``,n){if(!n.size||n.size>1073741824){l(t?`音频须为 1 字节至 1 GiB`:`Audio must be between 1 byte and 1 GiB`);return}a.current={file:n,requestId:crypto.randomUUID()},f()}}}),(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded-md p-2 hover:bg-surface-hover`,disabled:o!==null,onClick:()=>c&&a.current?void f():r.current?.click(),children:[(0,z.jsx)(ye,{className:`size-3.5`}),o===null?c&&a.current?t?`重试导入`:`Retry import`:t?`导入录音`:`Import recording`:`${o}%`]}),u===null?null:(0,z.jsxs)(`span`,{children:[t?`请确认你有权上传此录音,并允许配置的语音服务处理。`:`Confirm permission to upload this recording and process it with your configured speech service.`,(0,z.jsx)(`button`,{type:`button`,className:`p-2 text-accent`,onClick:()=>void N(u).then(()=>(d(null),f())).catch(e=>l(String(e))),children:t?`确认导入`:`Confirm import`})]}),c?(0,z.jsx)(`span`,{role:`alert`,className:`text-danger`,children:c}):null]})}async function Me(e){e.note??=await g({title:e.title,markdown:e.markdown,projectId:e.projectId,channel:`web`},e.requestId);let t=e.note.id;for(let n=e.attachments.length;n<e.files.length;n++)e.attachments.push(await f(t,e.files[n],`${e.requestId}:file:${n}`));if(e.attachments.length){let n=e.attachments.map(e=>`[${e.fileName.replace(/[\\[\]]/g,`\\$&`).replace(/[\r\n]/g,` `)}](${d(t,e.id)})`);e.note=await p(t,{markdown:`${e.markdown}\n\n## ${e.materialHeading}\n\n${n.join(`
2
-
3
- `)}`})}return{noteId:t,conversationId:(await m(t,{projectId:e.projectId})).conversationId}}function B(e,t,n){let r=new URLSearchParams({draft:n.replace(`{{id}}`,t),autoSend:`1`});return`/chat/${encodeURIComponent(e)}?${r}`}var V={meeting:A,requirements:le,research:M,weekly:De};function Ne({projects:e,projectId:t,onProjectChange:n,onCreated:r,labels:a,projectsLoading:o,projectsError:s}){let l=a.home,u=i(),[d,f]=(0,R.useState)(``),[p,m]=(0,R.useState)(null),[h,g]=(0,R.useState)(!1),[_,v]=(0,R.useState)([]),[b,te]=(0,R.useState)(!1),[S,w]=(0,R.useState)(null),[re,ie]=(0,R.useState)(``),T=(0,R.useRef)(null),E=(0,R.useRef)(!1),D=(0,R.useRef)(null),O=(0,R.useRef)(null),k=b||!!T.current,A=p?l.templateOptions[p]:null,ae=!!(d.trim()||_.length);async function oe(){if(!(E.current||!ae&&!T.current)){E.current=!0,te(!0),w(null),T.current??={requestId:crypto.randomUUID(),title:d.trim().split(`
4
- `)[0]?.slice(0,80)||A?.label||a.titlePlaceholder,markdown:`## ${l.requestHeading}\n\n${A?`${A.prompt}\n`:``}${d.trim()}`,projectId:t||void 0,files:[..._],attachments:[],materialHeading:l.materialsHeading};try{let e=await Me(T.current);r(),u(B(e.conversationId,e.noteId,l.agentPrompt))}catch(e){T.current.note&&r(),w(e instanceof Error?e.message:a.quickCaptureFailedHint)}finally{E.current=!1,te(!1)}}}function se(){T.current=null,w(null),f(``),v([]),m(null),g(!1),O.current?.focus()}return(0,z.jsxs)(`section`,{"aria-label":l.askLabel,children:[(0,z.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),oe()},className:`relative rounded-xl border border-edge bg-surface-panel p-4 focus-within:border-accent/60 sm:p-5`,children:[(0,z.jsxs)(`fieldset`,{disabled:k,className:`min-w-0`,children:[(0,z.jsxs)(`label`,{htmlFor:`notes-home-prompt`,className:`flex items-center gap-2 text-xs font-medium text-accent-fg`,children:[(0,z.jsx)(ne,{className:`size-4`,"aria-hidden":!0}),l.askLabel]}),(0,z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:l.agentResultHint}),A?(0,z.jsxs)(`div`,{className:`mt-3 flex items-start gap-2 rounded-lg bg-accent-soft px-3 py-2 text-xs leading-5 text-accent-fg`,children:[(0,z.jsxs)(`p`,{className:`min-w-0 flex-1`,children:[(0,z.jsxs)(`span`,{className:`font-medium`,children:[A.label,` · `]}),A.prompt.split(`
5
-
6
- `)[0]]}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>m(null),"aria-label":a.searchClear,className:`shrink-0 rounded p-1 hover:bg-surface-hover`,children:(0,z.jsx)(x,{className:`size-3.5`})})]}):null,(0,z.jsx)(`textarea`,{ref:O,id:`notes-home-prompt`,value:d,onChange:e=>f(e.target.value),placeholder:A?A.prompt.split(`
7
-
8
- `).at(-1):l.askPlaceholder,rows:2,onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&!e.nativeEvent.isComposing&&(e.preventDefault(),oe())},className:`mt-2 min-h-16 w-full resize-y bg-transparent py-2 text-base leading-6 text-fg outline-none placeholder:text-fg-muted sm:text-sm`}),_.length?(0,z.jsx)(`ul`,{className:`mb-3 flex flex-wrap gap-2`,children:_.map((e,t)=>(0,z.jsxs)(`li`,{className:`flex max-w-full items-center gap-2 rounded-md border border-edge px-2 py-1 text-xs text-fg-muted`,children:[(0,z.jsx)(P,{className:`size-3 shrink-0`,"aria-hidden":!0}),(0,z.jsx)(`span`,{className:`truncate`,children:e.name}),(0,z.jsx)(`button`,{type:`button`,"aria-label":`${l.removeMaterial}: ${e.name}`,onClick:()=>v(e=>e.filter((e,n)=>n!==t)),className:`rounded p-1 hover:bg-surface-hover`,children:(0,z.jsx)(x,{className:`size-3`})})]},`${e.name}-${t}`))}):null,(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 sm:pr-40`,children:[(0,z.jsx)(`div`,{className:`w-44 max-w-full`,children:(0,z.jsx)(c,{value:t,options:e.filter(e=>e.name.toLowerCase().includes(re.toLowerCase())).map(e=>({value:e.id,label:e.name})),selectedLabel:t?e.find(e=>e.id===t)?.name:l.unassigned,placeholder:l.unassigned,emptyLabel:l.unassigned,ariaLabel:l.assignProject,triggerIcon:(0,z.jsx)(he,{className:`size-4 shrink-0`,"aria-hidden":!0}),triggerClassName:`h-8 border-transparent bg-transparent px-2 text-xs text-fg-muted hover:bg-surface-hover`,onChange:n,disabled:k,loading:o,statusMessage:s?l.projectsLoadFailed:void 0,searchPlaceholder:l.projectSearch,searchValue:re,onSearchChange:ie})}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>D.current?.click(),className:`inline-flex h-8 items-center gap-1.5 rounded-md px-2 text-xs text-fg-muted hover:bg-surface-hover`,children:[(0,z.jsx)(P,{className:`size-4`,"aria-hidden":!0}),l.addMaterials]}),(0,z.jsx)(`input`,{ref:D,type:`file`,multiple:!0,className:`hidden`,"aria-label":l.addMaterials,onChange:e=>{let t=Array.from(e.target.files??[]);v(e=>[...e,...t]),e.target.value=``}})]})]}),(0,z.jsx)(`div`,{className:`mt-2 flex justify-end sm:absolute sm:bottom-5 sm:right-5 sm:mt-0`,children:(0,z.jsxs)(`button`,{type:`submit`,disabled:b||!T.current&&!ae,className:`inline-flex h-9 items-center gap-2 rounded-lg bg-accent px-4 text-sm font-medium text-on-accent hover:bg-accent-hover focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50`,children:[b?(0,z.jsx)(ee,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,z.jsx)(I,{className:`size-4`,"aria-hidden":!0}),b?l.creating:S?l.retry:l.agentCreate]})})]}),S?(0,z.jsxs)(`div`,{className:`mt-3 rounded-lg border border-danger/25 bg-danger-soft px-3 py-3 text-xs text-danger`,role:`alert`,children:[(0,z.jsx)(`p`,{children:S}),T.current?.note?(0,z.jsx)(`p`,{className:`mt-1`,children:l.partialFailure}):null,(0,z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-3`,children:[T.current?.note?(0,z.jsx)(`button`,{type:`button`,onClick:()=>u(`/notes/${encodeURIComponent(T.current.note.id)}?edit=1`),className:`underline`,children:l.openSavedDraft}):null,(0,z.jsx)(`button`,{type:`button`,onClick:se,className:`underline`,children:l.newRequest})]})]}):null,(0,z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[(0,z.jsxs)(`button`,{type:`button`,disabled:k,"aria-expanded":h,"aria-controls":`notes-home-templates`,onClick:()=>g(e=>!e),className:`touch-target inline-flex items-center gap-1.5 rounded-md px-2 py-2 hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:[l.templates,(0,z.jsx)(Ee,{className:C(`size-3.5 transition-transform`,h&&`rotate-180`),"aria-hidden":!0})]}),(0,z.jsxs)(`button`,{type:`button`,disabled:b,onClick:()=>me(),className:`touch-target ml-auto inline-flex items-center gap-1.5 rounded-md px-2 py-2 hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,z.jsx)(y,{className:`size-3.5`,"aria-hidden":!0}),l.recordDiscussion]})]}),(0,z.jsxs)(`div`,{id:`notes-home-templates`,hidden:!h,className:C(`mt-1 flex-wrap items-center gap-1 text-xs text-fg-muted`,h?`flex`:`hidden`),children:[Object.keys(V).map(e=>{let t=V[e];return(0,z.jsxs)(`button`,{type:`button`,disabled:k,"aria-pressed":p===e,onClick:()=>{m(p===e?null:e),O.current?.focus()},className:C(`inline-flex items-center gap-1.5 rounded-md px-2 py-2 hover:bg-surface-hover disabled:opacity-50`,p===e&&`bg-accent-soft text-accent-fg`),children:[(0,z.jsx)(t,{className:`size-3.5`,"aria-hidden":!0}),l.templateOptions[e].label]},e)}),(0,z.jsx)(je,{})]})]})}function Pe(e,t){let n=Number(e.get(`page`)??0),r=Number.isSafeInteger(n)&&n>=0?n:0,i=e.get(`view`);return{projectId:e.get(`projectId`)||void 0,unassigned:e.get(`unassigned`)===`true`||i===`unassigned`||void 0,pinned:i===`favorites`?!0:void 0,agentEdited:i===`agent`||void 0,status:i===`archived`?`archived`:void 0,search:t.trim()||void 0,sortBy:`updatedAt`,sortOrder:`desc`,limit:12,offset:r*12}}function Fe(e){let t=e.snippet?.trim()??``,n=e.title?.trim();return n&&t.startsWith(n)?t.slice(n.length).replace(/^[\s::·—-]+/,``):t}var H=`touch-target inline-flex min-h-9 items-center justify-center gap-2 rounded-lg px-3 text-sm text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-50`;function U(){let e=ie(e=>e.language),t=S(e).notes,n=t.home,r=w(e=>e.conversationId),o=Te(e=>e.setPageHeader),u=Te(e=>e.clearPageHeader),d=i(),{pathname:f,search:m}=s(),[y,x]=a(),k=y.get(`projectId`)||``,j=y.get(`view`)||`all`,M=y.get(`unassigned`)===`true`||j===`unassigned`,N=y.get(`search`)||``,[me]=O(N,250),[ge,P]=(0,R.useState)(k),[_e,ve]=(0,R.useState)(``),[ye,F]=(0,R.useState)(null),[I,De]=(0,R.useState)(!1),[L,Ae]=(0,R.useState)(!1),[je,Me]=(0,R.useState)(new Set),[B,V]=(0,R.useState)(null),[U,Ie]=(0,R.useState)(null),W=(0,R.useRef)(new Set),G=(0,R.useRef)(null),Le=(0,R.useRef)(!1),Re=(0,R.useRef)(null),ze=Pe(y,me),K=(ze.offset??0)/12,{data:Be,error:Ve,isLoading:He,mutate:Ue}=T(r?[`notes-home`,r,ze]:null,()=>h(ze)),{data:We,error:Ge,isLoading:q,mutate:Ke}=T(r?[`notes-home-projects`,r]:null,_),J=We?.items??[],qe=J.filter(e=>e.noteCount>0).slice(0,2),Je=J.find(e=>e.id===k)?.name??n.projectNotes,Ye=Be?.items??[],Y=Be?.total??0,Xe=He||N!==me,Ze=(0,R.useMemo)(()=>({justNow:t.justNow,minutesAgo:t.minutesAgo,today:t.today,yesterday:t.yesterday,daysAgo:t.daysAgo,locale:re(e)}),[e,t.justNow,t.minutesAgo,t.today,t.yesterday,t.daysAgo]),[X,Qe]=(0,R.useState)(()=>Date.now());(0,R.useEffect)(()=>{P(k)},[k]),(0,R.useEffect)(()=>{let e=window.setInterval(()=>Qe(Date.now()),6e4);return()=>window.clearInterval(e)},[]);let Z=(0,R.useCallback)(()=>{Ue().catch(()=>void 0),Ke().catch(()=>void 0)},[Ue,Ke]);(0,R.useEffect)(()=>{let e=[`note-updated`,`note-created`,`note-deleted`,`project-updated`,`project-created`,`project-deleted`];return e.forEach(e=>window.addEventListener(e,Z)),()=>e.forEach(e=>window.removeEventListener(e,Z))},[Z]);let $e=(0,R.useCallback)((e,t=!1)=>{let n=`${f}${m}`,r=new URLSearchParams({returnTo:n});t&&r.set(`edit`,`1`),d(`/notes/${encodeURIComponent(e)}?${r}`)},[f,m,d]),Q=(0,R.useCallback)(async()=>{if(!(Le.current||!r)){Le.current=!0,De(!0),F(null),G.current??={key:crypto.randomUUID(),projectId:k||void 0};try{let e=await g({markdown:``,kind:`thought`,projectId:G.current.projectId},G.current.key);G.current=null,Z(),$e(e.id,!0)}catch(e){F(`${t.createBlankFailed}: ${e instanceof Error?e.message:t.createBlankFailedHint}`)}finally{Le.current=!1,De(!1)}}},[k,t.createBlankFailed,t.createBlankFailedHint,$e,Z,r]),et=(0,R.useCallback)(e=>{x(t=>{let n=new URLSearchParams(t);return e?n.set(`search`,e):n.delete(`search`),n.delete(`page`),n},{replace:!0})},[x]);function $(e,t=`all`){let n=new URLSearchParams;e&&n.set(`projectId`,e),t===`unassigned`?n.set(`unassigned`,`true`):t!==`all`&&n.set(`view`,t),P(e),x(n)}function tt(e){x(t=>{let n=new URLSearchParams(t);return M&&n.set(`unassigned`,`true`),e===`all`?n.delete(`view`):n.set(`view`,e),n.delete(`page`),n})}async function nt(e,n){if(!W.current.has(e)){W.current.add(e),Me(new Set(W.current)),F(null);try{await p(e,{pinned:n}),Z()}catch(e){F(`${t.actionFailed}: ${e instanceof Error?e.message:t.quickCaptureFailedHint}`)}finally{W.current.delete(e),Me(new Set(W.current))}}}async function rt(){let e=B;if(!(!e||U)){V(null),Ie(e.id),F(null);try{await v(e.id),window.dispatchEvent(new CustomEvent(`note-deleted`,{detail:{noteId:e.id}})),Z()}catch(e){F(`${t.deleteFailed}: ${e instanceof Error?e.message:t.quickCaptureFailedHint}`)}finally{Ie(null)}}}if((0,R.useLayoutEffect)(()=>{if(!r){u();return}return o({startExtra:null,main:(0,z.jsx)(`h1`,{className:`truncate text-base font-semibold text-fg`,children:t.title}),end:(0,z.jsx)(`div`,{className:C(`flex min-w-0 items-center gap-2`,E),children:(0,z.jsxs)(`label`,{className:`flex h-9 w-32 min-w-0 items-center gap-2 rounded-lg border border-edge bg-surface-panel px-2 sm:w-48`,children:[(0,z.jsx)(te,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,z.jsx)(`input`,{ref:Re,type:`search`,value:N,onChange:e=>et(e.target.value),"aria-label":t.searchDialogTitle,placeholder:t.searchPlaceholder,className:`min-w-0 flex-1 bg-transparent text-sm text-fg outline-none placeholder:text-fg-muted`})]})})}),()=>u()},[u,Q,I,n.blankNote,t.searchDialogTitle,t.searchPlaceholder,t.title,N,o,et,r]),(0,R.useEffect)(()=>{let e=e=>{!(e.metaKey||e.ctrlKey)||e.altKey||e.isComposing||e.target?.closest(`input, textarea, [contenteditable="true"], [role="dialog"]`)||(e.key.toLowerCase()===`n`&&(e.preventDefault(),Q()),e.key.toLowerCase()===`f`&&(e.preventDefault(),Re.current?.focus()))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Q]),!r)return(0,z.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8 text-sm text-fg-muted`,children:t.needToken});let it=[{id:`all`,label:n.homeNav,Icon:be},{id:`favorites`,label:n.favorites,Icon:Oe},{id:`unassigned`,label:n.unassigned,Icon:ae},{id:`archived`,label:t.filterArchived,Icon:ce}],at=k?`project:${k}`:M?`unassigned`:`all`,ot=!Xe&&!Ve&&Y===0&&!k&&!M&&!N&&j===`all`;return(0,z.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-1 overflow-hidden bg-surface-panel`,children:[(0,z.jsxs)(`aside`,{className:`hidden w-44 shrink-0 flex-col gap-1 overflow-y-auto px-3 py-6 xl:flex`,"aria-label":n.homeNav,children:[it.map(({id:e,label:t,Icon:n})=>(0,z.jsxs)(`button`,{type:`button`,onClick:()=>$(``,e),"aria-current":!k&&(e===`unassigned`?M:!M&&j===e)?`page`:void 0,className:C(H,`justify-start px-2 text-left text-xs`,!k&&(e===`unassigned`?M:!M&&j===e)&&`bg-surface-hover font-medium text-fg`),children:[(0,z.jsx)(n,{className:`size-4 shrink-0`,"aria-hidden":!0}),t]},e)),(0,z.jsx)(`span`,{className:`mb-1 mt-7 px-2 text-xs text-fg-muted`,children:n.projects}),q?[0,1,2].map(e=>(0,z.jsx)(D,{className:`mb-2 h-8 w-full`},e)):J.slice(0,8).map(e=>(0,z.jsxs)(`button`,{type:`button`,onClick:()=>$(e.id),"aria-current":k===e.id?`page`:void 0,className:C(H,`justify-start px-2 text-left text-xs`,k===e.id&&`bg-surface-hover font-medium text-fg`),children:[(0,z.jsx)(he,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,z.jsx)(`span`,{className:`truncate`,children:e.name})]},e.id)),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>d(`/projects`),className:C(H,`mt-2 justify-start px-2 text-xs`),children:[n.allProjects,(0,z.jsx)(ue,{className:`ml-auto size-3`,"aria-hidden":!0})]})]}),(0,z.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-7xl flex-col px-4 pb-4 pt-3 sm:px-6 sm:pb-7 lg:px-8 lg:pb-9 lg:pt-4`,children:[(0,z.jsxs)(`div`,{className:`mb-5 flex flex-wrap items-start justify-between gap-4`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{className:`min-w-0 break-words text-2xl font-semibold tracking-tight text-fg`,children:k?Je:M?n.unassigned:ot?n.firstNoteTitle:n.continueTitle}),(0,z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:k?n.projectDescription:ot?n.firstNoteDescription:n.continueDescription})]}),k?(0,z.jsxs)(`button`,{type:`button`,onClick:()=>d(`/projects/${encodeURIComponent(k)}`),className:C(H,`text-xs`),children:[n.openProject,(0,z.jsx)(ue,{className:`size-3.5`,"aria-hidden":!0})]}):null]}),ye?(0,z.jsx)(`p`,{className:`mb-4 rounded-lg border border-danger/25 bg-danger-soft px-3 py-2 text-sm text-danger`,role:`alert`,children:ye}):null,(0,z.jsxs)(`section`,{"aria-label":n.startAction,children:[(0,z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>{Ae(e=>!e),L||window.requestAnimationFrame(()=>document.getElementById(`notes-home-prompt`)?.focus())},"aria-expanded":L,"aria-controls":`notes-home-agent-composer`,className:C(`touch-target flex min-h-20 items-center gap-3 rounded-xl border p-4 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,L?`border-accent/60 bg-accent-soft`:`border-edge bg-surface-panel hover:bg-surface-hover`),children:[(0,z.jsx)(ne,{className:`size-5 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:n.agentAction}),(0,z.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:n.agentActionHint})]}),(0,z.jsx)(Ee,{className:C(`size-4 shrink-0 text-fg-muted transition-transform`,L&&`rotate-180`),"aria-hidden":!0})]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>void Q(),disabled:I,className:`touch-target flex min-h-20 items-center gap-3 rounded-xl border border-edge bg-surface-panel p-4 text-left transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:[I?(0,z.jsx)(ee,{className:`size-5 shrink-0 animate-spin text-fg-muted`,"aria-hidden":!0}):(0,z.jsx)(b,{className:`size-5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:n.blankNote}),(0,z.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:n.blankActionHint})]})]})]}),(0,z.jsx)(`div`,{id:`notes-home-agent-composer`,hidden:!L,className:C(`mt-3`,!L&&`hidden`),children:(0,z.jsx)(Ne,{projects:J,projectId:ge,onProjectChange:P,onCreated:Z,labels:t,projectsLoading:q,projectsError:!!Ge})})]}),Ge?(0,z.jsxs)(`div`,{role:`alert`,className:`mt-4 flex items-center gap-3 text-xs text-danger`,children:[(0,z.jsx)(`span`,{children:n.projectsLoadFailed}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void Ke().catch(()=>void 0),className:`underline`,children:n.retry})]}):null,ot?null:(0,z.jsxs)(`section`,{className:`mt-8 pb-6`,"aria-label":n.recentNotes,children:[(0,z.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-3`,children:[(0,z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:j===`favorites`?n.favorites:j===`archived`?t.filterArchived:k?n.projectNotes:n.recentNotes}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,z.jsx)(`button`,{type:`button`,"aria-pressed":j===`agent`,onClick:()=>tt(j===`agent`?`all`:`agent`),className:C(`touch-target rounded-md px-2 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:ring-2 focus-visible:ring-accent`,j===`agent`&&`bg-accent-soft text-accent-fg`),children:n.agentEdited}),(0,z.jsx)(`span`,{className:`hidden text-xs text-fg-muted xl:inline`,children:n.sortUpdated}),(0,z.jsx)(`div`,{className:`w-48 max-w-full xl:hidden`,children:(0,z.jsx)(c,{value:at,allowEmpty:!1,ariaLabel:n.projects,placeholder:n.allNotes,options:[{value:`all`,label:n.allNotes},{value:`unassigned`,label:n.unassigned},...J.filter(e=>e.name.toLowerCase().includes(_e.toLowerCase())).map(e=>({value:`project:${e.id}`,label:e.name}))],selectedLabel:k?Je:M?n.unassigned:n.allNotes,triggerClassName:`h-8 bg-surface-panel text-xs`,loading:q,searchPlaceholder:n.projectSearch,searchValue:_e,onSearchChange:ve,onChange:e=>$(e.startsWith(`project:`)?e.slice(8):``,e===`unassigned`?e:`all`)})})]})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-5 border-b border-edge xl:hidden`,"aria-label":t.libraryTitle,children:[[{id:`all`,label:t.filterAll},{id:`favorites`,label:n.favorites},{id:`archived`,label:t.filterArchived}].map(({id:e,label:t})=>(0,z.jsx)(`button`,{type:`button`,"aria-pressed":j===e||e===`all`&&j===`unassigned`,onClick:()=>tt(e),className:C(`touch-target border-b-2 border-transparent py-3 text-xs text-fg-muted hover:text-fg`,(j===e||e===`all`&&j===`unassigned`)&&`border-fg font-medium text-fg`),children:t},e)),(0,z.jsx)(`span`,{className:`ml-auto py-3 text-xs text-fg-muted`,children:n.sortUpdated})]}),Ve?(0,z.jsxs)(`div`,{className:`py-10 text-center`,role:`alert`,children:[(0,z.jsx)(`p`,{className:`text-sm text-danger`,children:n.loadFailed}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void Ue().catch(()=>void 0),className:C(H,`mt-2`),children:n.retry})]}):Xe?(0,z.jsx)(`div`,{"aria-busy":`true`,className:`divide-y divide-edge`,children:[0,1,2,3].map(e=>(0,z.jsxs)(`div`,{className:`flex items-center gap-3 py-4`,children:[(0,z.jsx)(D,{className:`h-10 w-8 shrink-0`}),(0,z.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,z.jsx)(D,{className:`h-4 w-2/3`}),(0,z.jsx)(D,{className:`h-3 w-1/2`})]})]},e))}):Ye.length===0?(0,z.jsxs)(`div`,{className:`flex flex-col items-center px-4 py-12 text-center`,children:[(0,z.jsx)(be,{className:`mb-4 size-8 text-fg-muted`,strokeWidth:1.3,"aria-hidden":!0}),(0,z.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:N||j!==`all`&&j!==`unassigned`?n.noMatches:k?n.projectEmpty:n.emptyTitle}),(0,z.jsx)(`p`,{className:`mt-2 max-w-md text-sm leading-6 text-fg-muted`,children:N||j!==`all`&&j!==`unassigned`?n.noMatchesHint:k?n.projectEmptyHint:n.emptyDescription})]}):(0,z.jsx)(`ul`,{className:`divide-y divide-edge`,children:Ye.map(e=>{let r=e.voiceAttachmentId||e.kind===`voice`?A:e.kind===`bookmark`?pe:le,i=Fe(e)||(e.coverAttachmentId?t.imageNote:t.noText);return(0,z.jsxs)(`li`,{className:`group flex min-w-0 items-center gap-3 py-4`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>$e(e.id),className:`touch-target flex min-w-0 flex-1 items-center gap-3 rounded-md text-left focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,z.jsx)(`span`,{className:`flex h-10 w-8 shrink-0 items-center justify-center rounded-md border border-edge text-fg-muted`,children:(0,z.jsx)(r,{className:`size-4`,"aria-hidden":!0})}),(0,z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`span`,{className:`block truncate text-base font-medium text-fg sm:text-sm group-hover:text-accent-fg`,children:e.title||i.slice(0,48)||t.titlePlaceholder}),(0,z.jsxs)(`span`,{className:`mt-1 flex min-w-0 items-center gap-1.5 text-xs text-fg-muted`,children:[e.lastEditTrigger===`ai_edit`?(0,z.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-accent-fg`,children:[(0,z.jsx)(ne,{className:`size-3`,"aria-hidden":!0}),n.agentEditLabel,(0,z.jsx)(`span`,{"aria-hidden":!0,children:`·`})]}):null,(0,z.jsx)(`span`,{className:`truncate`,children:i})]}),(0,z.jsx)(`time`,{dateTime:new Date(e.updatedAt).toISOString(),className:`mt-1.5 block text-xs text-fg-muted sm:hidden`,children:ke(e.updatedAt,X,Ze)})]})]}),(0,z.jsx)(`span`,{className:`hidden max-w-32 truncate text-xs text-fg-muted md:block`,title:e.projects?.map(e=>e.name).join(` · `),children:e.projects?.map(e=>e.name).join(` · `)||n.unassigned}),(0,z.jsx)(`time`,{dateTime:new Date(e.updatedAt).toISOString(),className:`hidden w-24 shrink-0 text-right text-xs text-fg-muted sm:block`,children:ke(e.updatedAt,X,Ze)}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void nt(e.id,!e.pinned),disabled:je.has(e.id),"aria-label":`${e.pinned?n.unfavorite:n.favorite}: ${e.title||t.titlePlaceholder}`,"aria-pressed":!!e.pinned,className:`touch-target inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-50 focus-visible:ring-2 focus-visible:ring-accent`,children:(0,z.jsx)(Oe,{className:C(`size-4`,e.pinned&&`fill-current text-fg`),"aria-hidden":!0})}),(0,z.jsxs)(Se,{children:[(0,z.jsx)(xe,{asChild:!0,children:(0,z.jsx)(`button`,{type:`button`,disabled:U===e.id,"aria-label":`${t.noteActions}: ${e.title||t.titlePlaceholder}`,className:`touch-target inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-50 focus-visible:ring-2 focus-visible:ring-accent`,children:U===e.id?(0,z.jsx)(ee,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,z.jsx)(l,{className:`size-4`,"aria-hidden":!0})})}),(0,z.jsx)(de,{children:(0,z.jsx)(se,{align:`end`,sideOffset:4,className:`z-50 min-w-36 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:(0,z.jsxs)(oe,{className:`touch-target flex cursor-pointer items-center gap-2 rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-danger-soft focus:bg-danger-soft`,onSelect:()=>V(e),children:[(0,z.jsx)(Ce,{className:`size-4`,"aria-hidden":!0}),t.delete]})})})]})]},e.id)})}),!Xe&&!Ve&&Y>0?(0,z.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-between gap-3 text-xs text-fg-muted`,"aria-live":`polite`,children:[(0,z.jsx)(`span`,{children:t.noteCount.replace(`{{count}}`,String(Y))}),Y>12||K>0?(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,"aria-label":n.previousPage,disabled:K===0,className:H,onClick:()=>x(e=>{let t=new URLSearchParams(e);return t.set(`page`,String(K-1)),t}),children:(0,z.jsx)(fe,{className:`size-4`,"aria-hidden":!0})}),(0,z.jsxs)(`span`,{children:[K+1,` / `,Math.max(1,Math.ceil(Y/12))]}),(0,z.jsx)(`button`,{type:`button`,"aria-label":n.nextPage,disabled:(K+1)*12>=Y,className:H,onClick:()=>x(e=>{let t=new URLSearchParams(e);return t.set(`page`,String(K+1)),t}),children:(0,z.jsx)(ue,{className:`size-4`,"aria-hidden":!0})})]}):null]}):null]}),!k&&!M&&(q||qe.length>0)?(0,z.jsxs)(`section`,{className:`mt-8`,"aria-label":n.continueProjects,children:[(0,z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.continueProjects}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>d(`/projects`),className:`text-xs text-fg-muted hover:text-fg`,children:n.allProjects})]}),(0,z.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:q?[0,1].map(e=>(0,z.jsx)(D,{className:`h-28 w-full`},e)):qe.map(e=>(0,z.jsxs)(`button`,{type:`button`,onClick:()=>$(e.id),className:`min-w-0 rounded-lg border border-edge bg-surface-panel p-3 text-left transition-colors sm:p-4 hover:bg-surface-base focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,z.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,z.jsx)(he,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,z.jsx)(`span`,{className:`truncate`,children:e.name})]}),e.description?(0,z.jsx)(`p`,{className:`mt-2 hidden line-clamp-1 text-xs text-fg-muted sm:block`,children:e.description}):null,(0,z.jsxs)(`span`,{className:`mt-2 flex flex-wrap items-center justify-between gap-1 text-xs text-fg-muted sm:mt-3`,children:[(0,z.jsx)(`span`,{children:t.noteCount.replace(`{{count}}`,String(e.noteCount))}),(0,z.jsx)(`span`,{children:e.updatedAt?ke(e.updatedAt,X,Ze):n.emptyProject})]})]},e.id))})]}):null]})}),(0,z.jsx)(we,{open:B!==null,title:t.deleteConfirmTitle,description:t.deleteConfirmDescription.replace(`{{title}}`,B?.title||t.titlePlaceholder),confirmLabel:t.deleteConfirmLabel,cancelLabel:t.deleteCancelLabel,destructive:!0,onConfirm:()=>void rt(),onCancel:()=>V(null)})]})}function Ie(){let e=(0,Ae.c)(12),{noteId:t}=o(),n=i(),[r]=a(),s;e[0]===r?s=e[1]:(s=u(r.get(`returnTo`),`/notes`,[`/chat`,`/projects`,`/notes`,`/tasks`]),e[0]=r,e[1]=s);let c=s,l;e[2]!==n||e[3]!==c?(l=()=>{n(c)},e[2]=n,e[3]=c,e[4]=l):l=e[4];let d=l;if(!t)return null;let f=r.get(`edit`)===`1`?`wysiwyg`:`preview`,p;e[5]===r?p=e[6]:(p=r.get(`edit`),e[5]=r,e[6]=p);let m=p===`1`,h;return e[7]!==d||e[8]!==t||e[9]!==f||e[10]!==m?(h=(0,z.jsx)(`div`,{className:`mx-auto flex h-full min-h-0 w-full max-w-6xl flex-1 flex-col`,children:(0,z.jsx)(L,{noteId:t,onBack:d,initialMode:f,autoFocus:m},t)}),e[7]=d,e[8]=t,e[9]=f,e[10]=m,e[11]=h):h=e[11],h}function W(){let e=(0,Ae.c)(2),{noteId:t}=o(),n;return e[0]===t?n=e[1]:(n=t?(0,z.jsx)(Ie,{}):(0,z.jsx)(U,{}),e[0]=t,e[1]=n),n}export{W as NotesPage};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./popover-select-BgSdSbCL.js";import{b as s}from"./markdown-view-DKlJx4eo.js";import{t as c}from"./play-kxZvpBg8.js";import{t as l}from"./settings-2-D-csvaET.js";import{t as u}from"./x-B_N4OPjy.js";import{t as d}from"./messages-CnM6Qfr7.js";import{a as f,n as p,r as m}from"./locale-store-ChN_vjs2.js";import{t as h,u as g,w as _}from"./session-manager-DDR-gv_e.js";import{a as v,i as y,o as b,r as x,s as ee,t as S}from"./dist-C3DSFZCi.js";import{t as C}from"./skeleton-BwbyijEw.js";import{Cr as w,Hr as T,K as te,Ki as ne,Mc as E,Nc as D,Pc as re,Q as O,Vi as k,_a as ie,ao as ae,ca as A,ha as oe,ia as j,ms as M,n as se,q as ce,qi as le,qo as ue}from"./index-BXrBL_Hb.js";import{l as N,n as P,t as F}from"./voice-config-api-CxGsCDoW.js";var I=n(),L=e(t(),1),R=r(),z=[`intro`,`identity`,`voice`,`connections`],B=[{id:`loopi`,zh:`小环`,en:`Loopi`},{id:`loopi-curious`,zh:`好奇`,en:`Curious`},{id:`loopi-care`,zh:`温和`,en:`Gentle`}];function de(e){return!!(e?.enabled&&(e.status===`connected`||e.connectionStatus===`connected`||e.authStatus===`connected`))}async function fe(e,t){let n=await new Promise((e,n)=>{let r=new FileReader;r.onload=()=>e(String(r.result)),r.onerror=()=>n(r.error),r.readAsDataURL(t)});await f(m(`/api/agents/${encodeURIComponent(e)}/avatar`),{method:`PUT`,body:JSON.stringify({base64:n.slice(n.indexOf(`,`)+1),mimeType:t.type})}),ne(e)}function V({modelsAvailable:e,onCreated:t}){let n=p(e=>e.language)===`zh`,r=p(e=>e.language),[o,s]=(0,L.useState)(`intro`),[l,u]=(0,L.useState)({displayName:`Ada`,appearance:`loopi`,voice:null}),[h,g]=(0,L.useState)(!1),[_,v]=(0,L.useState)(!1),[y,b]=(0,L.useState)(null),[x,ee]=(0,L.useState)(null),[S,w]=(0,L.useState)(null),[T,ne]=(0,L.useState)(null),[E,j]=(0,L.useState)(!0),[M,se]=(0,L.useState)([]),[le,ue]=(0,L.useState)(null),I=(0,L.useRef)(null),V=(0,L.useRef)(null),[pe,H]=(0,L.useState)([]),[me,U]=(0,L.useState)(!0),[he,W]=(0,L.useState)([]),[ge,G]=(0,L.useState)(null);(0,L.useEffect)(()=>{let e=!1;return f(m(`/api/personal-agent/onboarding`)).then(t=>{e||(s(t.payload.step),u(t.payload.draft))}).catch(t=>{e||b(t instanceof Error?t.message:String(t))}).finally(()=>{e||g(!0)}),()=>{e=!0}},[]),(0,L.useEffect)(()=>{if(!h)return;let e=window.setTimeout(()=>{f(m(`/api/personal-agent/onboarding`),{method:`PUT`,body:JSON.stringify({step:o,draft:l})}).catch(()=>{})},350);return()=>window.clearTimeout(e)},[l,h,o]),(0,L.useEffect)(()=>{let e=!1;return F().then(t=>{e||(t.tts&&t.enabled?ne({provider:t.tts.provider,model:t.tts.model,enabled:!0}):j(!1))}).catch(()=>{e||j(!1)}),()=>{e=!0}},[]),(0,L.useEffect)(()=>{if(!T?.enabled)return;let e=!1;return P(T.provider,T.model,`realtime`).then(t=>{e||se(t.slice(0,12))}).catch(()=>{}).finally(()=>{e||j(!1)}),()=>{e=!0}},[T]),(0,L.useEffect)(()=>{if(o!==`connections`)return;let e=!1;return U(!0),Promise.allSettled([oe({page:1,pageSize:24,verification:`verified`}),ie()]).then(([t,n])=>{if(!e){if(t.status===`fulfilled`){let e=[`gmail`,`googlecalendar`,`googledrive`,`github`,`linear`];H(t.value.connectors.filter(t=>t.runtime.type===`composio`&&e.includes(t.runtime.toolkit)).sort((t,n)=>e.indexOf(t.runtime.type===`composio`?t.runtime.toolkit:``)-e.indexOf(n.runtime.type===`composio`?n.runtime.toolkit:``)))}n.status===`fulfilled`&&W(n.value),U(!1)}}),()=>{e=!0}},[o]),(0,L.useEffect)(()=>()=>{V.current?.abort(),I.current?.close()},[]),(0,L.useEffect)(()=>()=>{S&&URL.revokeObjectURL(S)},[S]);let _e=async(e,t=l)=>{await f(m(`/api/personal-agent/onboarding`),{method:`PUT`,body:JSON.stringify({step:e,draft:t})}),s(e)},ve=async e=>{b(null);let t=z[Math.max(0,Math.min(z.length-1,z.indexOf(o)+e))];try{await _e(t)}catch(e){b(e instanceof Error?e.message:String(e))}},ye=async(n=!1)=>{if(!(!e||_)){v(!0),b(null);try{let e=n?{displayName:`Ada`,appearance:`loopi`,voice:null}:l,r=e.voice&&T?.enabled&&M.some(t=>t.id===e.voice)?{provider:T.provider,model:T.model,voice:e.voice}:void 0,i=(await f(m(`/api/personal-agent`),{method:`POST`,body:JSON.stringify({displayName:e.displayName.trim()||`Ada`,appearance:e.appearance,...r?{voicePreference:r}:{}})})).payload,a=!1;if(!n&&x)try{await fe(i.agentId,x),i=(await f(m(`/api/personal-agent/profile`),{method:`PATCH`,body:JSON.stringify({revision:i.revision,displayName:i.displayName,appearance:`custom`,preferences:i.preferences})})).payload}catch{a=!0}t(i,a)}catch(e){b(e instanceof Error?e.message:String(e))}finally{v(!1)}}},be=(0,L.useCallback)(async e=>{V.current?.abort(),I.current?.close();let t=new AbortController;V.current=t,ue(e),b(null);try{let n=new A;I.current=n,await n.start();let r=await N(t.signal,e);if(t.signal.aborted)return;n.enqueue(r,()=>ue(null))}catch(e){t.signal.aborted||b(e instanceof Error?e.message:String(e)),ue(null)}},[]);if(!h)return(0,R.jsxs)(`div`,{className:`mx-auto w-full max-w-xl space-y-4 px-6 py-14`,children:[(0,R.jsx)(C,{className:`h-10 w-2/3`}),(0,R.jsx)(C,{className:`h-64 w-full rounded-2xl`}),(0,R.jsx)(C,{className:`h-12 w-full rounded-xl`})]});let K=z.indexOf(o),xe={intro:n?`创建一个和你一起做事的助手`:`Create an assistant to work with you`,identity:n?`先给它一个形象和名字`:`Choose a look and a name`,voice:n?`想让我用什么声音回应?`:`How should your assistant sound?`,connections:n?`要让我了解哪些信息?`:`What information can your assistant use?`}[o];return(0,R.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-surface-base`,children:[(0,R.jsx)(`header`,{className:`shrink-0 px-5 pt-5 sm:px-8 sm:pt-7`,children:(0,R.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl`,children:[(0,R.jsxs)(`div`,{className:`flex min-h-10 items-center justify-between gap-4`,children:[K>0?(0,R.jsxs)(`button`,{type:`button`,disabled:_,onClick:()=>void ve(-1),className:`-ml-2 inline-flex min-h-10 items-center gap-1.5 rounded-lg px-2 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-40`,children:[(0,R.jsx)(re,{className:`size-4`}),n?`上一步`:`Back`]}):(0,R.jsx)(`span`,{className:`text-sm font-medium text-fg-muted`,children:n?`设置我的助手`:`Set up my assistant`}),(0,R.jsx)(i,{to:`/chat`,className:`-mr-2 inline-flex min-h-10 items-center rounded-lg px-2 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n?`稍后继续`:`Finish later`})]}),(0,R.jsx)(`div`,{className:`mt-4 grid grid-cols-4 gap-1.5`,role:`progressbar`,"aria-label":n?`设置进度`:`Setup progress`,"aria-valuenow":K+1,"aria-valuemin":1,"aria-valuemax":z.length,children:z.map((e,t)=>(0,R.jsx)(`span`,{className:`h-1 rounded-full transition-colors duration-200 ${t<=K?`bg-accent`:`bg-surface-active`}`},e))})]})}),(0,R.jsx)(`main`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-5 py-8 sm:px-8`,children:(0,R.jsxs)(`div`,{className:`mx-auto my-auto w-full max-w-2xl py-6 motion-safe:animate-[page-enter_220ms_ease-out]`,children:[(0,R.jsxs)(`div`,{className:`mb-8 flex items-center gap-4`,children:[(0,R.jsx)(`span`,{className:`flex size-16 shrink-0 items-center justify-center rounded-2xl bg-surface-hover`,children:S?(0,R.jsx)(`img`,{src:S,alt:``,className:`size-14 rounded-xl object-cover`}):(0,R.jsx)(k,{appearance:l.appearance,className:`size-14`})}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`我的助手`:`My assistant`}),(0,R.jsx)(`p`,{className:`mt-1 text-lg font-semibold text-fg`,children:l.displayName||`Ada`})]})]}),(0,R.jsx)(`p`,{className:`mb-3 text-xs font-medium tracking-wide text-fg-subtle`,children:n?`第 ${K+1} 步 · 共 ${z.length} 步`:`Step ${K+1} of ${z.length}`}),(0,R.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-fg sm:text-3xl`,children:xe}),o===`intro`&&(0,R.jsxs)(`div`,{className:`mt-6 max-w-xl space-y-3 text-base leading-8 text-fg-muted`,children:[(0,R.jsx)(`p`,{children:n?`你可以找它讨论问题,也可以交给它一件要推进的事。`:`Talk through a question or give it something to move forward.`}),(0,R.jsx)(`p`,{children:n?`需要深入处理时,它会找合适的 Agent,并把进展带回对话。`:`It can ask a suitable Agent for deeper work and bring the progress back.`}),(0,R.jsx)(`p`,{children:n?`它能使用哪些数据和设备,由你决定。`:`You choose which data and devices it can use.`})]}),o===`identity`&&(0,R.jsxs)(`div`,{className:`mt-7 space-y-7`,children:[(0,R.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[n?`助手名字`:`Assistant name`,(0,R.jsx)(`input`,{value:l.displayName,maxLength:60,onChange:e=>u(t=>({...t,displayName:e.target.value})),onBlur:()=>u(e=>({...e,displayName:e.displayName.trim()||`Ada`})),className:`mt-2 block w-full rounded-xl border border-edge bg-surface-panel px-4 py-3 text-fg outline-none focus-visible:ring-2 focus-visible:ring-accent`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`选择头像`:`Choose an avatar`}),(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[B.map(e=>(0,R.jsxs)(`button`,{type:`button`,"aria-pressed":!x&&l.appearance===e.id,onClick:()=>{ee(null),w(null),u(t=>({...t,appearance:e.id}))},className:`flex min-h-28 flex-col items-center justify-center gap-2 rounded-2xl p-3 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${!x&&l.appearance===e.id?`bg-accent/10 text-fg ring-1 ring-accent/40`:`bg-surface-panel text-fg-muted hover:bg-surface-hover`}`,children:[(0,R.jsx)(k,{appearance:e.id,className:`size-14`}),n?e.zh:e.en]},e.id)),(0,R.jsxs)(`label`,{className:`flex min-h-28 cursor-pointer flex-col items-center justify-center gap-2 rounded-2xl p-3 text-sm transition-colors focus-within:ring-2 focus-within:ring-accent ${x?`bg-accent/10 text-fg ring-1 ring-accent/40`:`bg-surface-panel text-fg-muted hover:bg-surface-hover`}`,children:[(0,R.jsx)(ae,{className:`size-6`}),n?`上传图片`:`Upload image`,(0,R.jsx)(`input`,{className:`sr-only`,type:`file`,accept:`image/png,image/jpeg,image/webp`,onChange:e=>{let t=e.target.files?.[0];if(t){if(t.size>512*1024||![`image/png`,`image/jpeg`,`image/webp`].includes(t.type)){b(n?`请选择不超过 512 KB 的 PNG、JPEG 或 WebP 图片。`:`Choose a PNG, JPEG, or WebP image under 512 KB.`);return}ee(t),w(URL.createObjectURL(t))}}})]})]}),(0,R.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:n?`自定义图片在创建助手时上传;刷新后需要重新选择。`:`Custom images upload when you create the assistant; select again after a refresh.`})]})]}),o===`voice`&&(0,R.jsxs)(`div`,{className:`mt-5`,children:[(0,R.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:n?`用于这个助手的语音通话;文字回答不受影响。试听不会使用麦克风。`:`This affects calls with this assistant. Text stays the same. Preview does not use your microphone.`}),E?(0,R.jsxs)(`div`,{className:`mt-5 grid gap-3 sm:grid-cols-2`,children:[(0,R.jsx)(C,{className:`h-20 rounded-xl`}),(0,R.jsx)(C,{className:`h-20 rounded-xl`})]}):T?.enabled&&M.length>0?(0,R.jsxs)(`div`,{className:`mt-5 grid gap-3 sm:grid-cols-2`,children:[(0,R.jsx)(`button`,{type:`button`,"aria-pressed":!l.voice,onClick:()=>u(e=>({...e,voice:null})),className:`rounded-xl p-4 text-left text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${l.voice?`bg-surface-panel text-fg-muted hover:bg-surface-hover`:`bg-accent/10 text-fg ring-1 ring-accent/40`}`,children:n?`使用默认声音`:`Use the default voice`}),M.map(e=>(0,R.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl p-3 transition-colors ${l.voice===e.id?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,R.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 rounded-lg text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-pressed":l.voice===e.id,onClick:()=>u(t=>({...t,voice:e.id})),children:[(0,R.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.name}),(0,R.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:e.description||e.style||(n?`点击选择`:`Select this voice`)})]}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>void be(e.id),className:`flex size-9 shrink-0 items-center justify-center rounded-full bg-surface-hover text-fg hover:bg-surface-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":n?`试听${e.name}`:`Preview ${e.name}`,children:(0,R.jsx)(c,{className:`size-4 ${le===e.id?`text-accent`:``}`})})]},e.id))]}):(0,R.jsxs)(`div`,{className:`mt-5 rounded-xl bg-surface-panel p-5 text-sm text-fg-muted`,children:[(0,R.jsx)(`p`,{children:n?`当前没有可试听的语音。你可以先用文字对话,稍后再设置。`:`No voice is ready to preview. You can start with text and set it up later.`}),(0,R.jsx)(i,{to:`/settings/capabilities/voice?returnTo=%2Fpersonal`,className:`mt-3 inline-block text-accent hover:underline`,children:n?`设置语音服务`:`Set up voice`})]})]}),o===`connections`&&(0,R.jsxs)(`div`,{className:`mt-5`,children:[(0,R.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:n?`现在连接,或进入对话后再添加。连接不会自动读取历史数据或创建持续关注。`:`Connect now or add sources later. Connecting does not automatically scan history or create ongoing monitoring.`}),me?(0,R.jsxs)(`div`,{className:`mt-5 space-y-2`,children:[(0,R.jsx)(C,{className:`h-18 rounded-xl`}),(0,R.jsx)(C,{className:`h-18 rounded-xl`})]}):(0,R.jsx)(`div`,{className:`mt-5 space-y-2`,children:pe.length?pe.map(e=>{let t=de(he.find(t=>t.connectorId===e.id));return(0,R.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-surface-panel p-4`,children:[(0,R.jsx)(O,{connector:e,size:`sm`}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.displayName}),(0,R.jsx)(`p`,{className:`line-clamp-2 text-xs text-fg-muted`,children:e.description})]}),t?(0,R.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-success`,children:[(0,R.jsx)(a,{className:`size-4`}),n?`已连接`:`Connected`]}):(0,R.jsx)(`button`,{type:`button`,onClick:()=>G(te(e)),className:`rounded-lg bg-surface-hover px-3 py-2 text-xs text-fg transition-colors hover:bg-surface-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n?`连接`:`Connect`})]},e.id)}):(0,R.jsx)(`p`,{className:`rounded-xl bg-surface-panel p-5 text-sm text-fg-muted`,children:n?`暂无可用的推荐服务;你仍可直接进入对话。`:`No suggested services are available. You can continue to chat.`})})]}),!e&&(0,R.jsxs)(`p`,{className:`mt-5 rounded-xl bg-warning/5 p-4 text-sm text-fg-muted`,children:[n?`开始前需要一个可用模型。`:`A compatible model is required before you start.`,` `,(0,R.jsx)(i,{to:`/settings/capabilities/models`,className:`text-accent underline`,children:n?`配置模型`:`Set up a model`})]}),y&&(0,R.jsx)(`p`,{role:`alert`,className:`mt-5 text-sm text-danger`,children:y})]},o)}),(0,R.jsx)(`footer`,{className:`shrink-0 px-5 pb-6 pt-3 sm:px-8 sm:pb-9`,children:(0,R.jsxs)(`div`,{className:`mx-auto flex w-full max-w-2xl flex-col-reverse gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,R.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n?`这些选择以后都能调整`:`You can change these choices later`}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[o===`intro`&&(0,R.jsx)(`button`,{type:`button`,disabled:!e||_,onClick:()=>void ye(!0),className:`min-h-11 rounded-lg px-3 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-40`,children:n?`用默认设置开始`:`Use defaults`}),o===`voice`&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>{let e={...l,voice:null};u(e),b(null),_e(`connections`,e).catch(e=>b(e instanceof Error?e.message:String(e)))},className:`min-h-11 rounded-lg px-3 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n?`跳过`:`Skip`}),(0,R.jsxs)(`button`,{type:`button`,disabled:_||o===`connections`&&!e,onClick:()=>o===`connections`?void ye():void ve(1),className:`flex min-h-11 items-center gap-2 rounded-xl bg-accent px-5 text-sm font-medium text-on-accent transition-colors hover:bg-accent-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 disabled:opacity-40`,children:[_?n?`正在创建…`:`Creating…`:o===`connections`?n?`进入对话`:`Start chatting`:n?`继续`:`Continue`,` `,!_&&(0,R.jsx)(D,{className:`size-4`})]})]})]})}),ge&&(0,R.jsx)(ce,{draft:ge,onChange:G,onClose:()=>G(null),t:d(r).connectorsSettings,onInstalled:async()=>{W(await ie()),G(null)}})]})}function pe({record:e,zh:t,onSelectVoice:n}){let[r,a]=(0,L.useState)(null),[o,s]=(0,L.useState)([]),[l,u]=(0,L.useState)(e.voicePreference?.voice??``),[d,f]=(0,L.useState)(!1),[p,m]=(0,L.useState)(null),[h,g]=(0,L.useState)(null),_=(0,L.useRef)(null),v=(0,L.useRef)(null);(0,L.useEffect)(()=>{let e=!1;return F().then(t=>{!e&&t.enabled&&t.tts&&a({provider:t.tts.provider,model:t.tts.model})}).catch(()=>{}),()=>{e=!0}},[]),(0,L.useEffect)(()=>{if(!r)return;let e=!1;return P(r.provider,r.model,`realtime`).then(t=>{e||s(t)}).catch(t=>{e||m(t instanceof Error?t.message:String(t))}),()=>{e=!0}},[r]),(0,L.useEffect)(()=>()=>{v.current?.abort(),_.current?.close()},[]);let y=async e=>{v.current?.abort(),_.current?.close();let t=new AbortController;v.current=t,g(e);try{let n=new A;_.current=n,await n.start();let r=await N(t.signal,e);t.signal.aborted||n.enqueue(r,()=>g(null))}catch(e){t.signal.aborted||m(e instanceof Error?e.message:String(e)),g(null)}},b=async e=>{if(d)return;let t=l;u(e),f(!0),m(null);try{await n(e&&r?{provider:r.provider,model:r.model,voice:e}:null)||u(t)}catch(e){m(e instanceof Error?e.message:String(e))}finally{f(!1)}};return(0,R.jsxs)(`section`,{className:`border-t border-edge pt-5`,children:[(0,R.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:t?`通话声音`:`Call voice`}),r&&o.length?(0,R.jsxs)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:[(0,R.jsx)(`button`,{type:`button`,disabled:d,onClick:()=>void b(``),"aria-pressed":!l,className:`rounded-xl px-3 py-3 text-left text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50 ${l?`bg-surface-panel text-fg-muted hover:bg-surface-hover`:`bg-accent/10 text-fg ring-1 ring-accent/40`}`,children:t?`默认声音`:`Default voice`}),o.map(e=>(0,R.jsxs)(`div`,{className:`flex items-center rounded-xl px-3 py-2 transition-colors ${l===e.id?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,R.jsxs)(`button`,{type:`button`,disabled:d,"aria-pressed":l===e.id,onClick:()=>void b(e.id),className:`min-w-0 flex-1 rounded-lg text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:[(0,R.jsx)(`span`,{className:`block text-sm text-fg`,children:e.name}),(0,R.jsx)(`span`,{className:`block truncate text-xs text-fg-muted`,children:e.description||e.style})]}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>void y(e.id),className:`flex size-9 items-center justify-center rounded-full hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":t?`试听${e.name}`:`Preview ${e.name}`,children:(0,R.jsx)(c,{className:`size-4 ${h===e.id?`text-accent`:`text-fg-muted`}`})})]},e.id))]}):(0,R.jsxs)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:[t?`当前没有可用音色。`:`No voice is ready.`,` `,(0,R.jsx)(i,{to:`/settings/capabilities/voice?returnTo=%2Fpersonal`,className:`text-accent underline`,children:t?`设置语音服务`:`Set up voice`})]}),p&&(0,R.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:p})]})}var H=new h;function me({conversationId:e,zh:t,onSaved:n}){let r=_(t=>t.sessions[e]),[i,a]=(0,L.useState)(!0),[o,s]=(0,L.useState)(``);(0,L.useEffect)(()=>{let t=!0;return H.loadSessionAgentConfig(e).then(n=>{t&&g(e,n)}).catch(e=>{t&&s(String(e))}).finally(()=>{t&&a(!1)}),()=>{t=!1}},[e]);let c=!!(r?.sending||r?.streaming||r?.modelConfigSaving);async function l(t,i){_.getState().patchSessionMeta(e,{modelConfigSaving:!0});try{g(e,await H.patchSessionAgentConfig(e,{model:t,thinkingLevel:i,configVersion:r?.configVersion})),await n()}catch(t){let n=await H.loadSessionAgentConfig(e).catch(()=>null);throw n&&g(e,n),t}finally{_.getState().patchSessionMeta(e,{modelConfigSaving:!1})}}return(0,R.jsxs)(`section`,{children:[(0,R.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:t?`对话模型与思考强度`:`Conversation model and thinking`}),i?(0,R.jsx)(C,{className:`h-9 w-full`}):(0,R.jsx)(T,{chat:d(t?`zh`:`en`).chat,sessionModel:r?.model??``,thinkingLevel:r?.thinkingLevel??`off`,modelDisabled:c,thinkingDisabled:c,onModelChange:l,onThinkingChange:e=>l(r?.model??``,e)}),o&&(0,R.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-danger`,children:o})]})}var U=5;function he(e){let t=e.replace(/\s+/g,` `).trim();if(t.length<=58)return t;let n=t.replace(/([^)]{1,80})|\([^)]{1,80}\)/g,``).replace(/([A-Za-z0-9])(?=[\u4e00-\u9fff])/g,`$1 `).replace(/\s+/g,` `).trim(),r=n.split(/[。!?;;,]/,1)[0]?.trim()||n;return r.length>58?`${r.slice(0,57).trimEnd()}…`:r}function W(e,t){if(e.phase===`closed`)return{label:t?`已结束`:`Finished`,tone:`bg-fg-subtle`};let n=e.operationalState??e.runStatus;return n===`running`?{label:t?`正在执行`:`Working`,tone:`bg-accent`}:n===`queued`?{label:t?`等待开始`:`Queued`,tone:`bg-fg-subtle`}:n===`failed`?{label:t?`执行失败`:`Failed`,tone:`bg-danger`}:n===`waiting`?{label:t?`等待继续`:`Waiting`,tone:`bg-warning`}:n===`blocked`?{label:t?`已阻塞`:`Blocked`,tone:`bg-warning`}:n===`verifying`?{label:t?`正在验证`:`Verifying`,tone:`bg-accent`}:n===`cancelled`?{label:t?`执行已取消`:`Cancelled`,tone:`bg-fg-subtle`}:e.phase===`review`?{label:t?`等待验收`:`In review`,tone:`bg-warning`}:e.phase===`active`?{label:t?`正在推进`:`In progress`,tone:`bg-accent`}:e.phase===`ready`?{label:t?`准备开始`:`Ready`,tone:`bg-fg-subtle`}:{label:t?`待处理`:`Planned`,tone:`bg-fg-subtle`}}function ge(e){let t=(0,I.c)(30),{item:n,zh:r}=e,a;t[0]!==n||t[1]!==r?(a=W(n,r),t[0]=n,t[1]=r,t[2]=a):a=t[2];let o=a,c;t[3]===n.id?c=t[4]:(c=s(`/personal`,n.id),t[3]=n.id,t[4]=c);let l=`mt-2 size-1.5 shrink-0 rounded-full ${o.tone}`,u;t[5]===l?u=t[6]:(u=(0,R.jsx)(`span`,{className:l,"aria-hidden":!0}),t[5]=l,t[6]=u);let d;t[7]===n.title?d=t[8]:(d=he(n.title),t[7]=n.title,t[8]=d);let f;t[9]===d?f=t[10]:(f=(0,R.jsx)(`span`,{className:`line-clamp-2 break-words text-sm font-medium leading-5 text-fg`,children:d}),t[9]=d,t[10]=f);let p;t[11]===o.label?p=t[12]:(p=(0,R.jsx)(`span`,{children:o.label}),t[11]=o.label,t[12]=p);let m;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,R.jsx)(`span`,{className:`text-fg-subtle`,"aria-hidden":!0,children:`·`}),t[13]=m):m=t[13];let h=r?`zh`:`en`,g;t[14]!==n.updatedAt||t[15]!==h?(g=w(n.updatedAt,h),t[14]=n.updatedAt,t[15]=h,t[16]=g):g=t[16];let _;t[17]===g?_=t[18]:(_=(0,R.jsx)(`span`,{children:g}),t[17]=g,t[18]=_);let v;t[19]!==_||t[20]!==p?(v=(0,R.jsxs)(`span`,{className:`mt-1.5 flex items-center gap-2 text-xs text-fg-muted`,children:[p,m,_]}),t[19]=_,t[20]=p,t[21]=v):v=t[21];let y;t[22]!==v||t[23]!==f?(y=(0,R.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[f,v]}),t[22]=v,t[23]=f,t[24]=y):y=t[24];let b;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,R.jsx)(E,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle opacity-0 transition-opacity duration-150 group-hover:opacity-100 group-focus-visible:opacity-100`,"aria-hidden":!0}),t[25]=b):b=t[25];let x;return t[26]!==y||t[27]!==c||t[28]!==u?(x=(0,R.jsxs)(i,{to:c,className:`group flex min-w-0 items-start gap-3 rounded-2xl bg-surface-panel px-4 py-4 transition-colors duration-150 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[u,y,b]}),t[26]=y,t[27]=c,t[28]=u,t[29]=x):x=t[29],x}var G=[{id:`direct`,warmth:`reserved`,zh:`直接`,en:`Direct`},{id:`natural`,warmth:`balanced`,zh:`自然`,en:`Natural`},{id:`gentle`,warmth:`gentle`,zh:`温和`,en:`Gentle`}],_e=[{id:`loopi`,zh:`小环`,en:`Loopi`,color:`bg-slate-100/50 dark:bg-slate-400/10`},{id:`loopi-curious`,zh:`好奇`,en:`Curious`,color:`bg-blue-100/50 dark:bg-blue-400/10`},{id:`loopi-care`,zh:`温和`,en:`Gentle`,color:`bg-violet-100/50 dark:bg-violet-400/10`}];function ve(e,t){return e.warmth===`reserved`?t?`你可以直接说目标或问题。我会先给结论,需要时再展开。`:`Tell me the goal or question. I’ll lead with the answer and expand when useful.`:e.warmth===`gentle`?t?`想聊一件事,或让我帮你推进工作,都可以从这里开始。我会认真听,也会把下一步说清楚。`:`You can talk something through or ask me to move work forward. I’ll listen carefully and make the next step clear.`:t?`有什么想讨论或推进的事?直接告诉我就好。`:`What would you like to discuss or move forward? Just tell me what is on your mind.`}function ye(e){return G.find(t=>t.warmth===e.warmth)?.id??`natural`}function be(){let e=j(),t=(0,L.useRef)(e);t.current=e;let n=p(e=>e.language)===`zh`,r=le(e=>e.setPageHeader),i=le(e=>e.clearPageHeader),[a,s]=(0,L.useState)(null),c=(0,L.useRef)(null),d=(0,L.useRef)(Promise.resolve()),[h,g]=(0,L.useState)([]),[_,w]=(0,L.useState)(!0),[T,te]=(0,L.useState)(0),[E,D]=(0,L.useState)(null),[re,O]=(0,L.useState)(!0),[ie,A]=(0,L.useState)(!1),[oe,ce]=(0,L.useState)(`natural`),[N,P]=(0,L.useState)(`loopi`),[F,I]=(0,L.useState)(!1),z=(0,L.useRef)(null),B=(0,L.useRef)(null),de=(0,L.useRef)(null),[fe,H]=(0,L.useState)(``),[he,W]=(0,L.useState)(`untangle`),[be,K]=(0,L.useState)(`none`),[xe,Se]=(0,L.useState)(`balanced`),[Ce,we]=(0,L.useState)(`decisions`),[Te,Ee]=(0,L.useState)(!1),[De,q]=(0,L.useState)(!1),[J,Oe]=(0,L.useState)(!1),[Y,ke]=(0,L.useState)(null),[Ae,je]=(0,L.useState)(!1),[X,Me]=(0,L.useState)(!1),[Ne,Pe]=(0,L.useState)(!1),[Z,Fe]=(0,L.useState)(0),Q=(0,L.useRef)(0),Ie=(0,L.useCallback)(()=>{Oe(!1),q(!1),Ee(!0)},[]),Le=(0,L.useCallback)(()=>{Oe(!1),q(!1),Ee(e=>!e)},[]),Re=(0,L.useCallback)(async()=>{try{let[e,t]=await Promise.all([f(m(`/api/personal-agent`)),f(m(`/api/personal-agent/models`))]);if(c.current=e.payload,s(e.payload),e.payload?.state===`ready`){let e=await f(m(`/api/personal-agent/onboarding`));O(!e.payload.completed||e.payload.welcomeDone)}window.dispatchEvent(new CustomEvent(`personal-agent-updated`,{detail:e.payload})),e.payload&&window.dispatchEvent(new Event(`session-updated`)),g(t.payload),e.payload&&(H(e.payload.displayName),P(e.payload.appearance),ce(ye(e.payload.preferences)),W(e.payload.preferences.supportMode??`untangle`),K(e.payload.preferences.humor??`none`),Se(e.payload.preferences.detailLevel??`balanced`),we(e.payload.preferences.proactivity??`decisions`))}catch(e){D(e instanceof Error?e.message:String(e))}finally{w(!1)}},[]);(0,L.useEffect)(()=>{Re()},[Re]);let $=(0,L.useCallback)(e=>{te(e=>e+1),D(null);let t=d.current.then(async()=>{let t=c.current;if(!t)return!1;let n=e.displayName?.trim()||t.displayName,r=e.appearance??t.appearance,i={...t.preferences,...e.preferences},a=e.voicePreference===void 0?t.voicePreference:e.voicePreference;if(n===t.displayName&&r===t.appearance&&JSON.stringify(i)===JSON.stringify(t.preferences)&&JSON.stringify(a)===JSON.stringify(t.voicePreference))return!0;try{let o=await f(m(`/api/personal-agent/profile`),{method:`PATCH`,body:JSON.stringify({revision:t.revision,displayName:n,appearance:r,preferences:i,...e.voicePreference===void 0?{}:{voicePreference:a}})});return c.current=o.payload,s(o.payload),window.dispatchEvent(new CustomEvent(`personal-agent-updated`,{detail:o.payload})),!0}catch(e){return D(e instanceof Error?e.message:String(e)),!1}}).finally(()=>te(e=>e-1));return d.current=t,t},[]),ze=async e=>{if(a){D(null);try{if(e){let t=await f(m(`/api/personal-agent/profile`),{method:`PATCH`,body:JSON.stringify({revision:a.revision,displayName:a.displayName,appearance:a.appearance,preferences:{...a.preferences,supportMode:e}})});c.current=t.payload,s(t.payload)}await f(m(`/api/personal-agent/onboarding/welcome`),{method:`POST`,body:`{}`}),O(!0)}catch(e){D(e instanceof Error?e.message:String(e))}}},Be=(0,L.useCallback)(async()=>{let e=++Q.current;Oe(!0),ke(null),je(!1),Me(!1),Pe(!1),Fe(0);try{let t=await f(m(`/api/personal-agent/activity?limit=${U}&offset=0`));if(e!==Q.current)return;ke(t.payload),Fe(t.payload.items.length)}catch{e===Q.current&&je(!0)}},[]),Ve=(0,L.useCallback)(async()=>{if(!Y||X||Z>=Y.total)return;let e=Q.current;Me(!0),Pe(!1);try{let t=await f(m(`/api/personal-agent/activity?limit=${U}&offset=${Z}`));if(e!==Q.current)return;ke(e=>e?{total:t.payload.total,items:[...e.items,...t.payload.items.filter(t=>!e.items.some(e=>e.id===t.id))]}:t.payload),Fe(e=>e+t.payload.items.length)}catch{e===Q.current&&Pe(!0)}finally{e===Q.current&&Me(!1)}},[Y,Z,X]);(0,L.useEffect)(()=>{if(!J||!Y||X)return;let e,t=()=>{window.clearTimeout(e),e=window.setTimeout(async()=>{let e=Q.current;try{let t=await f(m(`/api/personal-agent/activity?limit=${Math.max(U,Math.min(100,Z))}&offset=0`));if(e!==Q.current)return;ke(t.payload),Fe(t.payload.items.length)}catch{}},120)},n=window.setInterval(t,5e3);return window.addEventListener(`task-changed-v2`,t),window.addEventListener(`gateway-realtime-connected`,t),()=>{window.clearTimeout(e),window.clearInterval(n),window.removeEventListener(`task-changed-v2`,t),window.removeEventListener(`gateway-realtime-connected`,t)}},[Y,Z,X,J]);let He=async e=>{if(!a||![`image/png`,`image/jpeg`,`image/webp`].includes(e.type)){D(n?`请选择 PNG、JPEG 或 WebP 图片。`:`Choose a PNG, JPEG, or WebP image.`);return}if(e.size===0||e.size>512*1024){D(n?`图片大小不能超过 512 KB。`:`Image must be 512 KB or smaller.`);return}I(!0),D(null);try{let t=await new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result)),r.onerror=()=>n(r.error),r.readAsDataURL(e)});await f(m(`/api/agents/${encodeURIComponent(a.agentId)}/avatar`),{method:`PUT`,body:JSON.stringify({base64:t.slice(t.indexOf(`,`)+1),mimeType:e.type})}),ne(a.agentId),P(`custom`),q(!1),await $({appearance:`custom`})}catch(e){D(e instanceof Error?e.message:String(e))}finally{I(!1)}};(0,L.useLayoutEffect)(()=>{let o=a?.state===`ready`,s=o?a.appearance:N,c=o?a.displayName:`Ada`;return r({startExtra:null,main:(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[o?(0,R.jsx)(`button`,{ref:de,type:`button`,onClick:Le,"aria-expanded":Te,className:`touch-target -m-1 shrink-0 rounded-full p-1 transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":n?`编辑${c}的资料`:`Edit ${c}'s profile`,title:n?`资料`:`Profile`,children:(0,R.jsx)(`span`,{className:`flex size-8 items-center justify-center`,children:(0,R.jsx)(k,{appearance:s,agentId:a?.agentId,className:`size-8`})})}):(0,R.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center`,children:(0,R.jsx)(k,{appearance:s,agentId:a?.agentId,className:`size-8`})}),(0,R.jsx)(`h1`,{className:`min-w-0 truncate text-sm font-semibold text-fg sm:text-base`,children:c})]}),end:o?(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(`button`,{type:`button`,disabled:e.active,onClick:()=>{a?.state===`ready`&&t.current.open({conversationId:a.conversationId,name:a.displayName,mode:`assistant`})},className:`touch-target rounded-lg p-2 text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-50`,"aria-label":n?`语音通话`:`Voice call`,title:n?`语音通话`:`Voice call`,children:(0,R.jsx)(ue,{className:`size-5`})}),(0,R.jsxs)(b,{open:J,onOpenChange:e=>{e?Be():Oe(!1)},children:[(0,R.jsx)(ee,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-pressed":J,className:`touch-target rounded-lg p-2 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":n?`正在做的事`:`Activity`,children:(0,R.jsx)(M,{className:`size-5`})})}),(0,R.jsx)(v,{children:(0,R.jsxs)(y,{side:`bottom`,align:`end`,sideOffset:8,collisionPadding:8,"aria-label":n?`派发的任务`:`Delegated tasks`,className:`z-50 flex h-[min(34rem,calc(100dvh-6rem))] w-[min(25rem,calc(100vw-1rem))] min-h-0 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-inset shadow-xl focus:outline-none`,children:[(0,R.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 px-6 pb-3 pt-6`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`h2`,{className:`text-base font-semibold tracking-tight text-fg`,children:n?`交给我推进的事`:`Delegated work`}),(0,R.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:Y?n?`最近更新 · 共 ${Y.total} 项`:`Recently updated · ${Y.total} total`:n?`查看任务进展与结果`:`Follow progress and results`})]}),(0,R.jsx)(x,{className:`touch-target -mr-2 -mt-1 rounded-lg p-2 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":n?`关闭活动`:`Close activity`,children:(0,R.jsx)(u,{className:`size-4`})})]}),(0,R.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 pb-5 pt-3`,children:[!Y&&!Ae&&(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsx)(C,{className:`h-18 rounded-2xl`}),(0,R.jsx)(C,{className:`h-18 rounded-2xl`}),(0,R.jsx)(C,{className:`h-18 rounded-2xl`})]}),Ae&&(0,R.jsxs)(`div`,{className:`px-5 py-12 text-center`,children:[(0,R.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`暂时无法读取任务`:`Could not load tasks`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>void Be(),className:`mt-3 rounded-lg px-3 py-2 text-sm text-accent hover:bg-surface-hover`,children:n?`重试`:`Try again`})]}),Y?.items.length===0&&(0,R.jsxs)(`div`,{className:`px-5 py-16 text-center`,children:[(0,R.jsx)(M,{className:`mx-auto size-7 text-fg-subtle`,"aria-hidden":!0}),(0,R.jsx)(`p`,{className:`mt-4 text-sm font-medium text-fg`,children:n?`还没有派发的任务`:`No delegated work yet`}),(0,R.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n?`你可以在对话里直接告诉我想推进的事。`:`Tell me what you would like to move forward in chat.`})]}),Y&&Y.items.length>0&&(0,R.jsx)(`div`,{className:`space-y-2`,children:Y.items.map(e=>(0,R.jsx)(ge,{item:e,zh:n},e.id))}),Y&&Z<Y.total&&(0,R.jsxs)(`div`,{className:`pt-4 text-center`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>void Ve(),disabled:X,className:`min-h-10 rounded-xl bg-surface-panel px-5 text-sm font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:opacity-50`,children:X?n?`正在加载…`:`Loading…`:n?`加载更多`:`Load more`}),Ne&&(0,R.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-danger`,children:n?`加载失败,请重试`:`Could not load more. Try again.`})]})]})]})})]}),(0,R.jsx)(`button`,{ref:B,type:`button`,onClick:Le,"aria-expanded":Te,className:`touch-target rounded-lg p-2 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":n?`回应偏好`:`Response preferences`,children:(0,R.jsx)(l,{className:`size-5`})})]}):null}),()=>i()},[Y,Ae,Z,X,Ne,N,i,Ve,Be,a,r,J,Te,Le,e.active,n]);function Ue(){return a?(0,R.jsxs)(b,{open:Te,onOpenChange:e=>{Ee(e),e||q(!1)},children:[(0,R.jsx)(S,{virtualRef:B}),(0,R.jsx)(v,{children:(0,R.jsxs)(y,{side:`bottom`,align:`end`,sideOffset:8,collisionPadding:8,"aria-label":n?`编辑 Personal AI`:`Edit Personal AI`,onInteractOutside:e=>{e.target instanceof Node&&(B.current?.contains(e.target)||de.current?.contains(e.target))&&e.preventDefault()},className:`z-50 flex h-[min(38rem,calc(100dvh-6rem))] w-[min(28rem,calc(100vw-1rem))] min-h-0 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-xl outline-none`,children:[(0,R.jsxs)(`div`,{className:`relative flex shrink-0 flex-col items-center px-5 pt-5 text-center`,children:[(0,R.jsx)(`button`,{type:`button`,disabled:F,onClick:()=>q(e=>!e),"aria-expanded":De,"aria-controls":`personal-appearance-options`,"aria-label":n?`选择头像`:`Choose avatar`,className:`rounded-full transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:(0,R.jsx)(k,{appearance:N,agentId:a.agentId,className:`size-20`})}),(0,R.jsx)(`input`,{id:`personal-name`,"aria-label":n?`助手名称`:`Assistant name`,value:fe,onChange:e=>H(e.target.value),onBlur:e=>{let t=e.currentTarget.value.trim();t?(H(t),$({displayName:t})):H(c.current?.displayName??``)},onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(e.currentTarget.value=c.current?.displayName??``,H(e.currentTarget.value),e.currentTarget.blur())},maxLength:60,placeholder:`Ada`,className:`mt-3 w-full min-w-0 rounded-lg border border-transparent bg-transparent px-2 py-1 text-center text-lg font-semibold text-fg outline-none transition-colors hover:border-edge focus:border-edge focus:bg-surface-base focus-visible:ring-2 focus-visible:ring-accent`}),T>0&&(0,R.jsx)(`span`,{className:`absolute right-4 top-4 text-xs text-fg-muted`,children:n?`正在保存…`:`Saving…`})]}),(0,R.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-6 overflow-y-auto overscroll-contain px-5 py-5`,children:[E&&(0,R.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:E}),De&&(0,R.jsxs)(`section`,{id:`personal-appearance-options`,children:[(0,R.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`形象`:`Appearance`}),(0,R.jsxs)(`div`,{className:`grid grid-cols-4 gap-2`,children:[_e.map(e=>(0,R.jsxs)(`button`,{type:`button`,onClick:()=>{P(e.id),q(!1),$({appearance:e.id})},"aria-pressed":N===e.id,className:`flex min-w-0 flex-col items-center gap-1.5 rounded-xl px-1 py-2 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${N===e.id?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,R.jsx)(`span`,{className:`flex size-8 items-center justify-center rounded-full ${e.color}`,children:(0,R.jsx)(k,{appearance:e.id,className:`size-8`})}),(0,R.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:n?e.zh:e.en})]},e.id)),(0,R.jsx)(`input`,{ref:z,type:`file`,accept:`image/png,image/jpeg,image/webp`,className:`sr-only`,"aria-label":n?`上传头像`:`Upload avatar`,onChange:e=>{let t=e.currentTarget.files?.[0];t&&He(t),e.currentTarget.value=``}}),(0,R.jsxs)(`button`,{type:`button`,disabled:F,onClick:()=>z.current?.click(),"aria-pressed":N===`custom`,className:`flex min-w-0 flex-col items-center gap-1.5 rounded-xl px-1 py-2 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50 ${N===`custom`?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,R.jsx)(`span`,{className:`flex size-8 items-center justify-center rounded-full bg-surface-panel`,children:N===`custom`?(0,R.jsx)(k,{appearance:`custom`,agentId:a.agentId,className:`size-8`}):(0,R.jsx)(ae,{className:`size-4 text-fg-muted`,"aria-hidden":!0})}),(0,R.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:F?n?`上传中…`:`Uploading…`:n?`上传`:`Upload`})]})]})]}),(0,R.jsxs)(`section`,{children:[(0,R.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`语气`:`Tone`}),(0,R.jsx)(`div`,{className:`grid grid-cols-3 gap-2`,children:G.map(e=>(0,R.jsx)(`button`,{type:`button`,onClick:()=>{ce(e.id),$({preferences:{warmth:e.warmth}})},"aria-pressed":oe===e.id,className:`min-h-10 rounded-xl px-2 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${oe===e.id?`bg-accent/10 font-medium text-fg ring-1 ring-accent/40`:`bg-surface-panel text-fg-muted hover:bg-surface-hover`}`,children:n?e.zh:e.en},e.id))})]}),(0,R.jsxs)(`section`,{children:[(0,R.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`棘手时`:`When things get tricky`}),(0,R.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:[[`listen`,n?`先听`:`Listen`],[`untangle`,n?`理清`:`Untangle`],[`solutions`,n?`给办法`:`Suggest`]].map(([e,t])=>(0,R.jsx)(`button`,{type:`button`,"aria-pressed":he===e,onClick:()=>{W(e),$({preferences:{supportMode:e}})},className:`min-h-9 rounded-full px-3 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${he===e?`bg-accent/10 text-fg ring-1 ring-accent/40`:`bg-surface-panel text-fg-muted hover:bg-surface-hover`}`,children:t},e))})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`mb-2 text-sm font-medium text-fg`,children:n?`回答长度`:`Length`}),(0,R.jsx)(o,{value:xe??`balanced`,options:[{value:`brief`,label:n?`简短`:`Brief`},{value:`balanced`,label:n?`适中`:`Balanced`},{value:`detailed`,label:n?`详细`:`Detailed`}],placeholder:n?`选择长度`:`Choose length`,allowEmpty:!1,onChange:e=>{let t=e;Se(t),$({preferences:{detailLevel:t}})}})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`mb-2 text-sm font-medium text-fg`,children:n?`主动更新`:`Updates`}),(0,R.jsx)(o,{value:Ce??`decisions`,options:[{value:`decisions`,label:n?`结果与决定`:`Results only`},{value:`important`,label:n?`重要进展`:`Milestones`},{value:`open`,label:n?`多提建议`:`Suggestions`}],placeholder:n?`选择频率`:`Choose frequency`,allowEmpty:!1,onChange:e=>{let t=e;we(t),$({preferences:{proactivity:t}})}})]})]}),(0,R.jsxs)(`details`,{className:`text-sm text-fg-muted`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer select-none`,children:n?`更多偏好`:`More preferences`}),(0,R.jsxs)(`div`,{className:`mt-3`,children:[(0,R.jsx)(`p`,{className:`mb-2 font-medium text-fg`,children:n?`轻松程度`:`Humor`}),(0,R.jsx)(o,{value:be??`none`,options:[{value:`none`,label:n?`不加玩笑`:`None`},{value:`occasional`,label:n?`偶尔轻松`:`Sometimes`},{value:`playful`,label:n?`活泼`:`Playful`}],placeholder:n?`选择程度`:`Choose level`,allowEmpty:!1,onChange:e=>{let t=e;K(t),$({preferences:{humor:t}})}})]})]}),(0,R.jsx)(pe,{record:a,zh:n,onSelectVoice:e=>$({voicePreference:e})}),(0,R.jsx)(`div`,{className:`border-t border-edge pt-5`,children:(0,R.jsx)(me,{conversationId:a.conversationId,zh:n,onSaved:async()=>{let e=await f(m(`/api/personal-agent`));e.ok&&e.payload&&(c.current=e.payload,s(e.payload))}})})]})]})})]}):null}return _?(0,R.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl space-y-5 px-6 py-12`,children:[(0,R.jsx)(C,{className:`h-20 w-20 rounded-full`}),(0,R.jsx)(C,{className:`h-9 w-72`}),(0,R.jsx)(C,{className:`h-44 w-full rounded-2xl`})]}):a?.state===`ready`?(0,R.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col bg-surface-panel`,children:[ie&&(0,R.jsxs)(`div`,{role:`alert`,className:`flex shrink-0 items-center justify-between gap-3 border-b border-warning/30 bg-warning/5 px-5 py-3 text-sm text-fg-muted`,children:[(0,R.jsx)(`span`,{children:n?`助手已创建,头像上传未完成。可在资料设置中重新上传。`:`Your assistant is ready. Upload the avatar again in profile settings.`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>{A(!1),Ie()},className:`shrink-0 text-accent hover:underline`,children:n?`打开设置`:`Open settings`})]}),(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1`,children:(0,R.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,R.jsx)(se,{embedded:!0,personal:!0,personalWelcome:{name:a.displayName,addressAs:a.userCallName??void 0,avatar:(0,R.jsx)(k,{appearance:a.appearance,agentId:a.agentId,className:`size-14`}),opening:ve(a.preferences,n),showSupportChoice:!re,onChooseSupport:e=>void ze(e),onSkipSupport:()=>void ze(),supportChoiceError:E},conversationId:a.conversationId})})}),Ue()]}):(0,R.jsx)(V,{modelsAvailable:h.length>0,onCreated:(e,t)=>{c.current=e,s(e),H(e.displayName),O(!1),A(t),window.dispatchEvent(new CustomEvent(`personal-agent-updated`,{detail:e})),window.dispatchEvent(new Event(`session-updated`))}})}export{be as PersonalPage};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{n as a,r as o}from"./popover-select-BgSdSbCL.js";import{t as s}from"./folder-open-CyzJ19I9.js";import{t as c}from"./loader-circle-CifKLtgG.js";import{t as l}from"./plus-Q2yW6OE7.js";import{t as u}from"./rotate-ccw-JM1TBLpp.js";import{t as d}from"./search-DA7gz22f.js";import{t as f}from"./x-B_N4OPjy.js";import{t as ee}from"./messages-CnM6Qfr7.js";import{t as p}from"./cn-JdwAhgNB.js";import{n as m}from"./locale-store-ChN_vjs2.js";import{a as h,i as g,n as _,o as v,r as y,s as b,t as x}from"./dist-BGTk37IG.js";import{t as S}from"./button-CS04eWY9.js";import{t as C}from"./skeleton-BwbyijEw.js";import{Ci as w,Cr as T,Ei as E,Go as te,Ic as D,Ko as O,Nc as k,Si as A,Us as ne,di as j,fi as M,ii as N,qi as P,ri as re,si as ie,xi as ae}from"./index-BXrBL_Hb.js";var F=n(),I=e(t(),1),L=r();function R(e,t){if(e==null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?t:T(n)}function oe(e){return[...e].sort((e,t)=>{let n=Number(!!t.pinnedAt)-Number(!!e.pinnedAt);return n===0?new Date(t.lastActiveAt??t.updatedAt).getTime()-new Date(e.lastActiveAt??e.updatedAt).getTime():n})}function se(){let e=(0,F.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,L.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,"aria-busy":!0,children:Array.from({length:6},z)}),e[0]=t):t=e[0],t}function z(e,t){return(0,L.jsx)(C,{className:`h-40 rounded-xl`},t)}function ce(e){let t=(0,F.c)(59),{project:n,busy:r,onTogglePin:a,onToggleArchive:o}=e,s=m(B),c,l,d,f,p,h,g,_;if(t[0]!==s||t[1]!==n.brief||t[2]!==n.description||t[3]!==n.id||t[4]!==n.lastActiveAt||t[5]!==n.name||t[6]!==n.status||t[7]!==n.updatedAt||t[8]!==n.workspaceRoot){let e=ee(s).projectsPage;c=e.management,g=`flex h-full flex-col rounded-xl border border-edge-subtle bg-surface-base p-4`;let r;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,L.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover text-fg-muted`,children:(0,L.jsx)(ne,{className:`size-4`,"aria-hidden":!0})}),t[17]=r):r=t[17];let a;t[18]===n.name?a=t[19]:(a=(0,L.jsx)(`h2`,{className:`truncate text-base font-semibold sm:text-sm text-fg`,children:n.name}),t[18]=n.name,t[19]=a);let o=(0,L.jsxs)(`div`,{className:`min-w-0`,children:[a,(0,L.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:e.statuses[n.status]})]}),u;t[20]===o?u=t[21]:(u=(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[r,o]}),t[20]=o,t[21]=u);let m;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,L.jsx)(k,{className:`mt-2 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0}),t[22]=m):m=t[22];let v;t[23]===u?v=t[24]:(v=(0,L.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[u,m]}),t[23]=u,t[24]=v),_=(0,L.jsxs)(i,{to:`/projects/${encodeURIComponent(n.id)}`,className:`group flex min-w-0 flex-1 flex-col rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[v,(0,L.jsx)(`p`,{className:`mt-3 line-clamp-2 min-h-10 text-sm leading-6 sm:text-xs sm:leading-5 text-fg-muted`,children:n.description||n.brief||e.noDescription})]}),h=`mt-3 flex shrink-0 items-end justify-between gap-3 border-t border-edge-subtle pt-3`,f=`min-w-0 text-xs text-fg-muted`,p=(0,L.jsx)(`p`,{className:`hidden truncate sm:block`,children:n.workspaceRoot||e.agentDefault}),l=`mt-1`,d=R(n.lastActiveAt??n.updatedAt,e.never),t[0]=s,t[1]=n.brief,t[2]=n.description,t[3]=n.id,t[4]=n.lastActiveAt,t[5]=n.name,t[6]=n.status,t[7]=n.updatedAt,t[8]=n.workspaceRoot,t[9]=c,t[10]=l,t[11]=d,t[12]=f,t[13]=p,t[14]=h,t[15]=g,t[16]=_}else c=t[9],l=t[10],d=t[11],f=t[12],p=t[13],h=t[14],g=t[15],_=t[16];let v;t[25]!==l||t[26]!==d?(v=(0,L.jsx)(`p`,{className:l,children:d}),t[25]=l,t[26]=d,t[27]=v):v=t[27];let y;t[28]!==f||t[29]!==p||t[30]!==v?(y=(0,L.jsxs)(`div`,{className:f,children:[p,v]}),t[28]=f,t[29]=p,t[30]=v,t[31]=y):y=t[31];let b=n.pinnedAt?c.unpin:c.pin,x=n.pinnedAt?c.unpin:c.pin,C;t[32]===n.pinnedAt?C=t[33]:(C=n.pinnedAt?(0,L.jsx)(te,{className:`size-4`,"aria-hidden":!0}):(0,L.jsx)(O,{className:`size-4`,"aria-hidden":!0}),t[32]=n.pinnedAt,t[33]=C);let w;t[34]!==r||t[35]!==a||t[36]!==b||t[37]!==x||t[38]!==C?(w=(0,L.jsx)(S,{type:`button`,variant:`ghost`,className:`size-8 p-0`,disabled:r,onClick:a,"aria-label":b,title:x,children:C}),t[34]=r,t[35]=a,t[36]=b,t[37]=x,t[38]=C,t[39]=w):w=t[39];let T=n.status===`archived`?c.restore:c.archive,E=n.status===`archived`?c.restore:c.archive,A;t[40]===n.status?A=t[41]:(A=n.status===`archived`?(0,L.jsx)(u,{className:`size-4`,"aria-hidden":!0}):(0,L.jsx)(D,{className:`size-4`,"aria-hidden":!0}),t[40]=n.status,t[41]=A);let j;t[42]!==r||t[43]!==o||t[44]!==T||t[45]!==E||t[46]!==A?(j=(0,L.jsx)(S,{type:`button`,variant:`ghost`,className:`size-8 p-0`,disabled:r,onClick:o,"aria-label":T,title:E,children:A}),t[42]=r,t[43]=o,t[44]=T,t[45]=E,t[46]=A,t[47]=j):j=t[47];let M;t[48]!==w||t[49]!==j?(M=(0,L.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[w,j]}),t[48]=w,t[49]=j,t[50]=M):M=t[50];let N;t[51]!==M||t[52]!==h||t[53]!==y?(N=(0,L.jsxs)(`div`,{className:h,children:[y,M]}),t[51]=M,t[52]=h,t[53]=y,t[54]=N):N=t[54];let P;return t[55]!==N||t[56]!==g||t[57]!==_?(P=(0,L.jsxs)(`article`,{className:g,children:[_,N]}),t[55]=N,t[56]=g,t[57]=_,t[58]=P):P=t[58],P}function B(e){return e.language}function V(){let e=ee(m(e=>e.language)),t=e.projectsPage,n=t.management,r=e.chat.workingDirectory,i=P(e=>e.setPageHeader),u=P(e=>e.clearPageHeader),[C,T]=(0,I.useState)([]),[te,D]=(0,I.useState)(!0),[O,k]=(0,I.useState)(null),[F,R]=(0,I.useState)(``),[z,B]=(0,I.useState)(!1),[V,le]=(0,I.useState)(`active`),[ue,de]=(0,I.useState)(null),[fe,H]=(0,I.useState)(!1),[pe,U]=(0,I.useState)(null),[W,me]=(0,I.useState)(!1),[G,he]=(0,I.useState)(!0),[K,ge]=(0,I.useState)(``),[q,_e]=(0,I.useState)(``),[J,ve]=(0,I.useState)(``),Y=N({initialPath:J,onPicked:ve}),X=(0,I.useRef)(0),Z=(0,I.useCallback)(async(e=!1)=>{let t=++X.current;e||(D(!0),k(null));try{let e=await ae({limit:100,sortBy:`updatedAt`,sortOrder:`desc`});t===X.current&&T(oe(e.items))}catch(n){!e&&t===X.current&&k(n instanceof Error?n.message:String(n))}finally{t===X.current&&D(!1)}},[]);(0,I.useEffect)(()=>(Z(),()=>{X.current++}),[Z]),(0,I.useEffect)(()=>{let e=()=>{Z(!0)};return window.addEventListener(`project-resource-changed`,e),()=>{window.removeEventListener(`project-resource-changed`,e)}},[Z]);let Q=(0,I.useMemo)(()=>{let e=F.trim().toLocaleLowerCase();return C.filter(e=>V===`all`||e.status===V).filter(t=>!e||[t.name,t.description,t.brief,t.workspaceRoot].filter(Boolean).some(t=>t.toLocaleLowerCase().includes(e)))},[V,C,F]),ye=(0,I.useMemo)(()=>(0,L.jsxs)(S,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,onClick:()=>H(!0),children:[(0,L.jsx)(l,{className:`size-4`,"aria-hidden":!0}),t.create]}),[t.create]);(0,I.useLayoutEffect)(()=>(i({startExtra:null,main:(0,L.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title}),end:ye}),()=>u()),[u,ye,n.title,i]);let be=(0,I.useCallback)(async e=>{e.preventDefault();let t=K.trim(),n=J.trim();if(!(!t||!n||W)){me(!0),U(null);try{let e=await M({autoUnderstand:G,name:t,...q.trim()?{description:q.trim()}:{},workspaceRoot:n});T(t=>[e,...t.filter(t=>t.id!==e.id)]),ge(``),_e(``),ve(``),he(!0),H(!1),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}catch(e){U(e instanceof Error?e.message:String(e))}finally{me(!1)}}},[W,q,K,J,G]),xe=(0,I.useCallback)(async(e,t)=>{de(e.id),k(null);try{let n;n=t===`pin`?e.pinnedAt?await E(e.id,e.version):await A(e.id,e.version):e.status===`archived`?await w(e.id,e.version):await j(e.id,e.version),T(e=>e.map(e=>e.id===n.id?n:e)),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}catch(e){k(e instanceof Error?e.message:String(e))}finally{de(null)}},[]),$=[{id:`active`,label:t.statuses.active},{id:`paused`,label:t.statuses.paused},{id:`archived`,label:t.statuses.archived},{id:`all`,label:t.all}],Se=$.find(e=>e.id===V)?.label??t.all,Ce=n.resultCount.replace(`{{status}}`,Se).replace(`{{count}}`,String(Q.length));return(0,L.jsxs)(`main`,{className:`mx-auto flex w-full max-w-7xl flex-1 flex-col gap-5 px-4 pb-7 pt-3 sm:px-6 lg:px-8 lg:pb-9 lg:pt-4`,children:[(0,L.jsx)(x,{open:fe,onOpenChange:e=>{H(e),e||U(null)},children:(0,L.jsxs)(v,{children:[(0,L.jsx)(h,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,L.jsxs)(y,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(34rem,calc(100vh-2rem))] w-[min(38rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-float focus:outline-none`,children:[(0,L.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,L.jsx)(b,{className:`text-base font-semibold text-fg`,children:t.createTitle}),(0,L.jsx)(g,{className:`mt-1 text-sm text-fg-muted`,children:t.createDescription})]}),(0,L.jsxs)(`form`,{onSubmit:be,className:`flex min-h-0 flex-1 flex-col`,children:[(0,L.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[(0,L.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-fg`,children:[t.projectName,(0,L.jsx)(`input`,{className:`h-10 rounded-lg border border-edge bg-surface-base px-3 font-normal outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`,value:K,onChange:e=>ge(e.target.value),maxLength:160})]}),(0,L.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-fg`,children:[n.descriptionLabel,(0,L.jsx)(`textarea`,{className:`min-h-28 resize-none rounded-lg border border-edge bg-surface-base px-3 py-2 font-normal leading-6 outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`,value:q,onChange:e=>_e(e.target.value),maxLength:2e3,placeholder:n.descriptionPlaceholder})]}),(0,L.jsxs)(`div`,{className:`grid gap-1.5 text-sm`,children:[(0,L.jsx)(`span`,{className:`font-medium text-fg`,children:t.workspaceRoot}),(0,L.jsxs)(`button`,{type:`button`,className:`flex min-h-12 w-full items-center gap-3 rounded-lg border border-edge bg-surface-base px-3 py-2 text-left outline-none transition-colors hover:bg-surface-hover focus-visible:border-accent focus-visible:ring-2 focus-visible:ring-accent/20 disabled:cursor-not-allowed disabled:opacity-60`,onClick:Y.pick,disabled:W||Y.picking,children:[Y.picking?(0,L.jsx)(c,{className:`size-5 shrink-0 animate-spin text-accent`,"aria-hidden":!0}):(0,L.jsx)(s,{className:`size-5 shrink-0 text-accent`,"aria-hidden":!0}),(0,L.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:J?r.chooseFolder:r.selectWorkingDirectory}),(0,L.jsx)(`span`,{className:p(`mt-0.5 block truncate font-mono text-xs font-normal`,J?`text-fg-muted`:`text-fg-subtle`),title:J||void 0,children:J||t.workspaceSelectionPlaceholder})]})]}),(0,L.jsx)(`p`,{className:`text-xs font-normal text-fg-subtle`,children:t.workspaceSelectionHint})]}),(0,L.jsx)(ie,{checked:G,onChange:he,disabled:W}),pe?(0,L.jsx)(`p`,{className:`rounded-lg bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,children:pe}):null]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,L.jsx)(_,{asChild:!0,children:(0,L.jsx)(S,{type:`button`,variant:`ghost`,children:t.cancel})}),(0,L.jsx)(S,{type:`submit`,variant:`primary`,disabled:W||!K.trim()||!J.trim(),children:W?t.home.creating:t.create})]})]})]})]})}),Y.hasNativePicker?null:(0,L.jsx)(re,{open:Y.modalOpen,onOpenChange:Y.setModalOpen,initialAbsolutePath:J||void 0,onConfirm:Y.confirmPick,wd:r}),(0,L.jsxs)(`section`,{className:`flex min-h-10 flex-wrap items-center justify-between gap-3`,"aria-label":n.filterLabel,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-fg-muted`,"aria-live":`polite`,children:Ce}),(0,L.jsxs)(`div`,{className:p(`ml-auto flex min-w-0 items-center justify-end gap-2`,z&&`w-full sm:w-auto`),children:[z?(0,L.jsxs)(`div`,{className:`relative min-w-0 flex-1 sm:w-64 sm:flex-none`,children:[(0,L.jsx)(d,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,L.jsx)(`input`,{autoFocus:!0,className:`h-11 w-full rounded-lg border border-edge bg-surface-panel pl-9 pr-12 text-base sm:h-9 sm:text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`,value:F,onChange:e=>R(e.target.value),placeholder:t.searchPlaceholder,"aria-label":t.searchPlaceholder}),(0,L.jsx)(`button`,{type:`button`,className:`touch-target absolute right-0 top-1/2 flex size-6 -translate-y-1/2 items-center justify-center rounded-md text-fg-subtle transition-colors hover:bg-surface-hover hover:text-fg`,onClick:()=>{R(``),B(!1)},"aria-label":n.clearSearch,title:n.clearSearch,children:(0,L.jsx)(f,{className:`size-3.5`,"aria-hidden":!0})})]}):(0,L.jsx)(S,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,onClick:()=>B(!0),"aria-label":t.searchPlaceholder,title:t.searchPlaceholder,children:(0,L.jsx)(d,{className:`size-4`,"aria-hidden":!0})}),(0,L.jsx)(a,{className:`w-28 sm:w-32`,triggerClassName:`h-9 border-edge bg-surface-panel px-2.5 text-xs font-medium`,contentClassName:`min-w-36`,align:`end`,value:V,"aria-label":n.filterLabel,onChange:e=>le(e.target.value),children:$.map(e=>(0,L.jsx)(o,{value:e.id,children:e.label},e.id))})]})]}),O?(0,L.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`,role:`alert`,children:[(0,L.jsx)(`span`,{children:O}),(0,L.jsx)(S,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>void Z(),children:t.home.retry})]}):null,te?(0,L.jsx)(se,{}):Q.length?(0,L.jsx)(`section`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:Q.map(e=>(0,L.jsx)(ce,{project:e,busy:ue===e.id,onTogglePin:()=>void xe(e,`pin`),onToggleArchive:()=>void xe(e,`archive`)},e.id))}):(0,L.jsxs)(`section`,{className:`py-16 text-center`,children:[(0,L.jsx)(ne,{className:`mx-auto size-7 text-fg-subtle`,"aria-hidden":!0}),(0,L.jsx)(`h2`,{className:`mt-3 text-sm font-semibold text-fg`,children:n.emptyTitle}),(0,L.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.emptyHint})]})]})}export{V 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{f as i,g as a,t as o}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as s}from"./check-DUBLcKHA.js";import{t as c}from"./chevron-right-BweFrslA.js";import{t as l}from"./copy-Dv6d4Dvw.js";import{t as u}from"./external-link-DjqjBmc3.js";import{t as d}from"./secret-input-DPl3VYM8.js";import{t as f}from"./globe-DSSGFWFn.js";import{t as p}from"./loader-circle-CifKLtgG.js";import{t as m}from"./messages-CnM6Qfr7.js";import{t as h}from"./cn-JdwAhgNB.js";import{c as g,n as _}from"./locale-store-ChN_vjs2.js";import{a as v,i as y,o as b,r as x,s as S,t as C}from"./dist-BGTk37IG.js";import{t as w}from"./copy-to-clipboard-HOJ79TWv.js";import{i as T}from"./vendor-swr-BIWyz7Rc.js";import{t as E}from"./button-CS04eWY9.js";import{n as D,r as O}from"./gateway-config-swr-EZxaKXdC.js";import{i as k,o as A}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{r as j}from"./settings-form-draft-Dy10ldo8.js";import{t as M}from"./copy-text-row-BHDs3cBa.js";import{a as N,n as P,r as F}from"./oauth-api-BXn1a9qx.js";import{At as I,Ds as L,Eo as R,Nc as z,Ot as B,Pt as ee,Vo as V,co as H,fc as U,jo as W,kt as te,ni as ne,po as re,ts as G,vc as K,wo as ie}from"./index-BXrBL_Hb.js";import{t as q}from"./page-tabs-D2xpUV26.js";import{n as J,r as ae,t as oe}from"./settings-page-layout-X1x-2Cp9.js";import{n as Y,r as se,t as ce}from"./settings-form-section-exRhP9xn.js";import{_ as le,a as ue,b as de,c as fe,h as pe,i as me,n as he,o as X,r as ge,s as _e,t as ve,v as ye,y as be}from"./tunnel-api-H3FheXYH.js";import{t as xe}from"./settings-advanced-gate-CvFVkELy.js";var Z=e(t(),1),Q=n(),$=r();function Se(e){switch(e){case`active`:return`text-emerald-700 dark:text-emerald-400`;case`connecting`:return`text-amber-700 dark:text-amber-400`;default:return`text-fg-muted`}}function Ce(e){let t=(0,Q.c)(11),{label:n,kind:r}=e,i;t[0]===r?i=t[1]:(i=h(`inline-flex items-center gap-1.5 text-xs font-medium`,Se(r)),t[0]=r,t[1]=i);let a=r===`active`&&`bg-emerald-500`,o=r===`connecting`&&`bg-amber-500`,s;t[2]!==a||t[3]!==o?(s=h(`size-1.5 rounded-full bg-fg-subtle/50`,a,o),t[2]=a,t[3]=o,t[4]=s):s=t[4];let c;t[5]===s?c=t[6]:(c=(0,$.jsx)(`span`,{className:s,"aria-hidden":!0}),t[5]=s,t[6]=c);let l;return t[7]!==n||t[8]!==i||t[9]!==c?(l=(0,$.jsxs)(`span`,{className:i,children:[c,n]}),t[7]=n,t[8]=i,t[9]=c,t[10]=l):l=t[10],l}function we(e){let t=(0,Q.c)(31),{onOpenTab:n}=e,r=_(Ee),i;t[0]===r?i=t[1]:(i=m(r),t[0]=r,t[1]=i);let a=i.remoteAccess.guide,o=!!g(Te),s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s={refreshInterval:3e4},t[2]=s):s=t[2];let{data:c}=T(o?`exposure-status`:null,be,s),l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l={refreshInterval:15e3},t[3]=l):l=t[3];let{data:u}=T(o?`tunnel-status`:null,he,l),d=O(o);if(!o)return null;let p=c?.tailscale.active===!0,v=u?.state,y=u?.enabled&&v===`connected`,b=u?.enabled&&(v===`connecting`||v===`reconnecting`||!!u?.startProgress||!!u?.frpcDownload),x=d.data?.payload?.config,S=!!(x&&typeof x==`object`&&!Array.isArray(x)&&x.gateway?.publicUrl),C=p?`active`:`off`,w=p?a.statusActive:a.statusOff,E;t[4]!==a.tailscaleCardTitle||t[5]!==C||t[6]!==w?(E={tab:`tailscale`,icon:f,title:a.tailscaleCardTitle,kind:C,statusLabel:w},t[4]=a.tailscaleCardTitle,t[5]=C,t[6]=w,t[7]=E):E=t[7];let D=y?`active`:b?`connecting`:`off`,k=y?a.statusActive:b?a.statusConnecting:a.statusOff,A;t[8]!==a.publicCardTitle||t[9]!==D||t[10]!==k?(A={tab:`public`,icon:G,title:a.publicCardTitle,kind:D,statusLabel:k},t[8]=a.publicCardTitle,t[9]=D,t[10]=k,t[11]=A):A=t[11];let j=S?`active`:`off`,M=S?a.statusActive:a.statusOff,N;t[12]!==a.reverseProxyCardTitle||t[13]!==j||t[14]!==M?(N={tab:`reverse-proxy`,icon:R,title:a.reverseProxyCardTitle,kind:j,statusLabel:M},t[12]=a.reverseProxyCardTitle,t[13]=j,t[14]=M,t[15]=N):N=t[15];let P;t[16]!==a.sshCardStatus||t[17]!==a.sshCardTitle?(P={tab:`ssh`,icon:re,title:a.sshCardTitle,kind:`off`,statusLabel:a.sshCardStatus},t[16]=a.sshCardStatus,t[17]=a.sshCardTitle,t[18]=P):P=t[18];let F;t[19]!==a.lanCardStatus||t[20]!==a.lanCardTitle?(F={tab:`lan`,icon:W,title:a.lanCardTitle,kind:`off`,statusLabel:a.lanCardStatus},t[19]=a.lanCardStatus,t[20]=a.lanCardTitle,t[21]=F):F=t[21];let I;t[22]!==N||t[23]!==P||t[24]!==F||t[25]!==E||t[26]!==A?(I=[E,A,N,P,F],t[22]=N,t[23]=P,t[24]=F,t[25]=E,t[26]=A,t[27]=I):I=t[27];let L=I,z;return t[28]!==L||t[29]!==n?(z=(0,$.jsx)(`div`,{className:`grid gap-1 rounded-xl bg-surface-hover/20 p-1 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:h(`flex items-start gap-3 rounded-lg bg-surface-base/45 px-2 py-3 text-left transition-colors`,`hover:bg-surface-hover/30`,`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 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)(Ce,{label:e.statusLabel,kind:e.kind})]})]},`${e.tab}-${e.title}`)})}),t[28]=L,t[29]=n,t[30]=z):z=t[30],z}function Te(e){return e.conversationId}function Ee(e){return e.language}function De(e){let t=(0,Q.c)(21),{title:n,description:r,recommended:i,icon:a,onOpen:o,recommendedLabel:s}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=h(`group flex w-full items-start gap-3 px-3 py-4 text-left transition-colors`,`hover:bg-surface-hover/30`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),t[0]=l):l=t[0];let u;t[1]===a?u=t[2]:(u=(0,$.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/70 text-fg-muted`,children:(0,$.jsx)(a,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[1]=a,t[2]=u);let d;t[3]===n?d=t[4]:(d=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[3]=n,t[4]=d);let f;t[5]!==i||t[6]!==s?(f=i&&s?(0,$.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:s}):null,t[5]=i,t[6]=s,t[7]=f):f=t[7];let p;t[8]!==d||t[9]!==f?(p=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[d,f]}),t[8]=d,t[9]=f,t[10]=p):p=t[10];let m;t[11]===r?m=t[12]:(m=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:r}),t[11]=r,t[12]=m);let g;t[13]!==p||t[14]!==m?(g=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[p,m]}),t[13]=p,t[14]=m,t[15]=g):g=t[15];let _;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(c,{className:`mt-2 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5 group-hover:text-fg-muted`,"aria-hidden":!0}),t[16]=_):_=t[16];let v;return t[17]!==o||t[18]!==u||t[19]!==g?(v=(0,$.jsxs)(`button`,{type:`button`,onClick:o,className:l,children:[u,g,_]}),t[17]=o,t[18]=u,t[19]=g,t[20]=v):v=t[20],v}function Oe(e){let t=(0,Q.c)(74),{onOpenTab:n}=e,r=_(je),i;t[0]===r?i=t[1]:(i=m(r),t[0]=r,t[1]=i);let a=i.remoteAccess,o=a.guide,s=!!g(Ae),c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c={refreshInterval:3e4},t[2]=c):c=t[2];let{data:l}=T(s?`exposure-status`:null,be,c),u;t[3]===l?.conflicts?u=t[4]:(u=l?.conflicts??[],t[3]=l?.conflicts,t[4]=u);let d=u;if(!s){let e;return t[5]===o.needToken?e=t[6]:(e=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.needToken}),t[5]=o.needToken,t[6]=e),e}let p;t[7]===n?p=t[8]:(p=(0,$.jsx)(we,{onOpenTab:n}),t[7]=n,t[8]=p);let h;t[9]!==d||t[10]!==o.conflictsHint||t[11]!==o.conflictsTitle?(h=d.length>0?(0,$.jsxs)(`div`,{className:`rounded-xl bg-amber-500/10 px-4 py-3 text-sm text-fg-muted`,children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:o.conflictsTitle}),(0,$.jsx)(`p`,{className:`mt-1`,children:o.conflictsHint}),(0,$.jsx)(`ul`,{className:`mt-2 list-inside list-disc text-xs`,children:d.map(ke)})]}):null,t[9]=d,t[10]=o.conflictsHint,t[11]=o.conflictsTitle,t[12]=h):h=t[12];let v;t[13]===o.pickMethod?v=t[14]:(v=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:o.pickMethod}),t[13]=o.pickMethod,t[14]=v);let y;t[15]===n?y=t[16]:(y=()=>n(`tailscale`),t[15]=n,t[16]=y);let b;t[17]!==o.recommended||t[18]!==o.tailscaleCardDesc||t[19]!==o.tailscaleCardTitle||t[20]!==y?(b=(0,$.jsx)(De,{icon:f,title:o.tailscaleCardTitle,description:o.tailscaleCardDesc,recommended:!0,recommendedLabel:o.recommended,onOpen:y}),t[17]=o.recommended,t[18]=o.tailscaleCardDesc,t[19]=o.tailscaleCardTitle,t[20]=y,t[21]=b):b=t[21];let x;t[22]===n?x=t[23]:(x=()=>n(`public`),t[22]=n,t[23]=x);let S;t[24]!==o.publicCardDesc||t[25]!==o.publicCardTitle||t[26]!==x?(S=(0,$.jsx)(De,{icon:G,title:o.publicCardTitle,description:o.publicCardDesc,onOpen:x}),t[24]=o.publicCardDesc,t[25]=o.publicCardTitle,t[26]=x,t[27]=S):S=t[27];let C;t[28]===n?C=t[29]:(C=()=>n(`reverse-proxy`),t[28]=n,t[29]=C);let w;t[30]!==o.reverseProxyCardDesc||t[31]!==o.reverseProxyCardTitle||t[32]!==C?(w=(0,$.jsx)(De,{icon:R,title:o.reverseProxyCardTitle,description:o.reverseProxyCardDesc,onOpen:C}),t[30]=o.reverseProxyCardDesc,t[31]=o.reverseProxyCardTitle,t[32]=C,t[33]=w):w=t[33];let E;t[34]===n?E=t[35]:(E=()=>n(`ssh`),t[34]=n,t[35]=E);let D;t[36]!==o.sshCardDesc||t[37]!==o.sshCardTitle||t[38]!==E?(D=(0,$.jsx)(De,{icon:re,title:o.sshCardTitle,description:o.sshCardDesc,onOpen:E}),t[36]=o.sshCardDesc,t[37]=o.sshCardTitle,t[38]=E,t[39]=D):D=t[39];let O;t[40]===n?O=t[41]:(O=()=>n(`lan`),t[40]=n,t[41]=O);let k;t[42]!==o.lanCardDesc||t[43]!==o.lanCardTitle||t[44]!==O?(k=(0,$.jsx)(De,{icon:W,title:o.lanCardTitle,description:o.lanCardDesc,onOpen:O}),t[42]=o.lanCardDesc,t[43]=o.lanCardTitle,t[44]=O,t[45]=k):k=t[45];let A;t[46]!==S||t[47]!==w||t[48]!==D||t[49]!==k||t[50]!==b?(A=(0,$.jsxs)(`div`,{className:`mt-2 flex max-w-3xl flex-col gap-1 rounded-xl bg-surface-hover/20 p-1 [&>*]:rounded-lg [&>*]:bg-surface-base/45`,children:[b,S,w,D,k]}),t[46]=S,t[47]=w,t[48]=D,t[49]=k,t[50]=b,t[51]=A):A=t[51];let j;t[52]!==A||t[53]!==v?(j=(0,$.jsxs)(`div`,{children:[v,A]}),t[52]=A,t[53]=v,t[54]=j):j=t[54];let M;t[55]===o.oneAtATimeHint?M=t[56]:(M=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:o.oneAtATimeHint}),t[55]=o.oneAtATimeHint,t[56]=M);let N;t[57]===a.advanced.proxyTitle?N=t[58]:(N=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.advanced.proxyTitle}),t[57]=a.advanced.proxyTitle,t[58]=N);let P;t[59]===a.advanced.proxyBody?P=t[60]:(P=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:a.advanced.proxyBody}),t[59]=a.advanced.proxyBody,t[60]=P);let F;t[61]!==r||t[62]!==a.advanced.proxyDocs?(F=(0,$.jsx)(de,{language:r,label:a.advanced.proxyDocs,section:`advanced`,className:`mt-2`}),t[61]=r,t[62]=a.advanced.proxyDocs,t[63]=F):F=t[63];let I;t[64]!==N||t[65]!==P||t[66]!==F?(I=(0,$.jsxs)(`div`,{className:`max-w-3xl rounded-xl bg-surface-hover/20 px-4 py-4`,children:[N,P,F]}),t[64]=N,t[65]=P,t[66]=F,t[67]=I):I=t[67];let L;return t[68]!==j||t[69]!==M||t[70]!==I||t[71]!==p||t[72]!==h?(L=(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[p,h,j,M,I]}),t[68]=j,t[69]=M,t[70]=I,t[71]=p,t[72]=h,t[73]=L):L=t[73],L}function ke(e){return(0,$.jsx)(`li`,{children:e.message},e.code)}function Ae(e){return e.conversationId}function je(e){return e.language}function Me(){let e=(0,Q.c)(16),t=_(Ne),n;e[0]===t?n=e[1]:(n=m(t),e[0]=t,e[1]=n);let r=n.remoteAccess.lan,i;e[2]!==r.subtitle||e[3]!==r.title?(i=(0,$.jsx)(Y,{icon:W,title:r.title,subtitle:r.subtitle}),e[2]=r.subtitle,e[3]=r.title,e[4]=i):i=e[4];let a;e[5]===r.body?a=e[6]:(a=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.body}),e[5]=r.body,e[6]=a);let s;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(u,{className:`size-3.5`,"aria-hidden":!0}),e[7]=s):s=e[7];let c;e[8]===r.link?c=e[9]:(c=(0,$.jsxs)(o,{to:`/settings/gateway`,className:`inline-flex items-center gap-1.5 text-sm font-medium text-accent hover:underline`,children:[r.link,s]}),e[8]=r.link,e[9]=c);let l;e[10]!==a||e[11]!==c?(l=(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[a,c]}),e[10]=a,e[11]=c,e[12]=l):l=e[12];let d;return e[13]!==i||e[14]!==l?(d=(0,$.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,$.jsxs)(ce,{children:[i,l]})}),e[13]=i,e[14]=l,e[15]=d):d=e[15],d}function Ne(e){return e.language}function Pe(e){let t=(0,Q.c)(30),{embedded:n}=e,r=n===void 0?!1:n,i=_(Fe),a;t[0]===i?a=t[1]:(a=m(i),t[0]=i,t[1]=a);let o=a.remoteAccess.ssh,[s,c]=(0,Z.useState)(!1),u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=async()=>{await w(`xopc gateway ssh-tunnel --target user@your-host --local-port 18790 --remote-port 18790`)&&(c(!0),setTimeout(()=>c(!1),2e3))},t[2]=u):u=t[2];let d=u,f;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(`pre`,{className:`overflow-x-auto rounded-lg bg-surface-base/55 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]=f):f=t[3];let p,h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(p=()=>void d(),h=(0,$.jsx)(l,{className:`mr-1 size-4`}),t[4]=p,t[5]=h):(p=t[4],h=t[5]);let g=s?o.copied:o.copy,v;t[6]===g?v=t[7]:(v=(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsxs)(E,{type:`button`,variant:`ghost`,onClick:p,children:[h,g]})}),t[6]=g,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:[f,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)(Y,{icon:re,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)(ce,{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)(Y,{icon:re,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 T;return t[27]!==S||t[28]!==C?(T=(0,$.jsxs)(ce,{children:[S,C]}),t[27]=S,t[28]=C,t[29]=T):T=t[29],T}function Fe(e){return e.language}function Ie(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Pe,{embedded:!0}),e[0]=t):t=e[0],t}var Le=[`guide`,`tailscale`,`public`,`reverse-proxy`,`ssh`,`lan`];function Re(e){return e&&Le.includes(e)?e:`guide`}function ze(e){let t=(0,Q.c)(32),{showLabel:n,hideLabel:r,icon:i,hint:a,children:o,className:s,defaultOpen:c,advancedOnly:l}=e,u=l===void 0?!1:l,[d,f]=(0,Z.useState)(c??!1),p;t[0]===s?p=t[1]:(p=h(`rounded-xl bg-surface-hover/20`,s),t[0]=s,t[1]=p);let m;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>f(Be),t[2]=m):m=t[2];let g=d&&`rotate-180`,_;t[3]===g?_=t[4]:(_=h(`size-4 shrink-0 text-fg-muted transition-transform duration-200 motion-reduce:transition-none`,g),t[3]=g,t[4]=_);let v;t[5]===_?v=t[6]:(v=(0,$.jsx)(K,{className:_,"aria-hidden":!0}),t[5]=_,t[6]=v);let y;t[7]===i?y=t[8]:(y=i?(0,$.jsx)(i,{className:`size-4 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}):null,t[7]=i,t[8]=y);let b=d?r:n,x;t[9]===b?x=t[10]:(x=(0,$.jsx)(`span`,{children:b}),t[9]=b,t[10]=x);let S;t[11]!==d||t[12]!==v||t[13]!==y||t[14]!==x?(S=(0,$.jsxs)(`button`,{type:`button`,"aria-expanded":d,onClick:m,className:`flex w-full items-center gap-2 rounded-2xl px-4 py-3.5 text-left text-sm font-medium text-fg transition-colors hover:text-fg`,children:[v,y,x]}),t[11]=d,t[12]=v,t[13]=y,t[14]=x,t[15]=S):S=t[15];let C=d?`grid-rows-[1fr] opacity-100`:`grid-rows-[0fr] opacity-0`,w;t[16]===C?w=t[17]:(w=h(`grid transition-[grid-template-rows,opacity] duration-200 ease-out motion-reduce:transition-none`,C),t[16]=C,t[17]=w);let T;t[18]===a?T=t[19]:(T=a?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:a}):null,t[18]=a,t[19]=T);let E;t[20]!==o||t[21]!==T?(E=(0,$.jsx)(`div`,{className:`overflow-hidden`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 px-4 pb-4 pt-1`,children:[T,o]})}),t[20]=o,t[21]=T,t[22]=E):E=t[22];let D;t[23]!==w||t[24]!==E?(D=(0,$.jsx)(`div`,{className:w,children:E}),t[23]=w,t[24]=E,t[25]=D):D=t[25];let O;t[26]!==S||t[27]!==D||t[28]!==p?(O=(0,$.jsxs)(`section`,{className:p,children:[S,D]}),t[26]=S,t[27]=D,t[28]=p,t[29]=O):O=t[29];let k=O;if(u){let e;return t[30]===k?e=t[31]:(e=(0,$.jsx)(xe,{children:k}),t[30]=k,t[31]=e),e}return k}function Be(e){return!e}function Ve(e){let t=(0,Q.c)(40),{open:n,title:r,intro:i,bullets:a,checkboxLabel:o,confirmLabel:s,cancelLabel:c,onConfirm:l,onCancel:u}=e,[d,f]=(0,Z.useState)(!1),p;t[0]===u?p=t[1]:(p=e=>{e||(f(!1),u())},t[0]=u,t[1]=p);let m;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(v,{className:h(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,A)}),t[2]=m):m=t[2];let g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=h(`xopc-dialog-content 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-overlay p-6 shadow-popover outline-none dark:border-edge`,k),t[3]=g):g=t[3];let _;t[4]===r?_=t[5]:(_=(0,$.jsx)(S,{className:`text-base font-semibold text-fg`,children:r}),t[4]=r,t[5]=_);let w;t[6]===i?w=t[7]:(w=(0,$.jsx)(y,{className:`mt-2 text-sm text-fg-muted`,children:i}),t[6]=i,t[7]=w);let T;t[8]===a?T=t[9]:(T=a.map(He),t[8]=a,t[9]=T);let D;t[10]===T?D=t[11]:(D=(0,$.jsx)(`ul`,{className:`mt-4 list-disc space-y-2 pl-5 text-sm text-fg-muted`,children:T}),t[10]=T,t[11]=D);let O;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(O=e=>f(e.target.checked),t[12]=O):O=t[12];let j;t[13]===d?j=t[14]:(j=(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 shrink-0 rounded border-edge accent-accent`,checked:d,onChange:O}),t[13]=d,t[14]=j);let M;t[15]===o?M=t[16]:(M=(0,$.jsx)(`span`,{children:o}),t[15]=o,t[16]=M);let N;t[17]!==M||t[18]!==j?(N=(0,$.jsxs)(`label`,{className:`mt-5 flex cursor-pointer items-start gap-3 text-sm text-fg`,children:[j,M]}),t[17]=M,t[18]=j,t[19]=N):N=t[19];let P;t[20]!==c||t[21]!==u?(P=(0,$.jsx)(E,{type:`button`,variant:`secondary`,onClick:u,children:c}),t[20]=c,t[21]=u,t[22]=P):P=t[22];let F=!d,I;t[23]!==s||t[24]!==l||t[25]!==F?(I=(0,$.jsx)(E,{type:`button`,disabled:F,onClick:l,children:s}),t[23]=s,t[24]=l,t[25]=F,t[26]=I):I=t[26];let L;t[27]!==P||t[28]!==I?(L=(0,$.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[P,I]}),t[27]=P,t[28]=I,t[29]=L):L=t[29];let R;t[30]!==N||t[31]!==L||t[32]!==_||t[33]!==w||t[34]!==D?(R=(0,$.jsxs)(b,{children:[m,(0,$.jsxs)(x,{className:g,onOpenAutoFocus:Ue,children:[_,w,D,N,L]})]}),t[30]=N,t[31]=L,t[32]=_,t[33]=w,t[34]=D,t[35]=R):R=t[35];let z;return t[36]!==n||t[37]!==p||t[38]!==R?(z=(0,$.jsx)(C,{open:n,onOpenChange:p,children:R}),t[36]=n,t[37]=p,t[38]=R,t[39]=z):z=t[39],z}function He(e){return(0,$.jsx)(`li`,{children:e},e)}function Ue(e){return e.preventDefault()}function We(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var Ge=[`preparing_frpc`,`registering`,`starting_frpc`];function Ke(e){return e?e===`reconnecting_frpc`?Ge.indexOf(`starting_frpc`):Ge.indexOf(e):-1}function qe(e,t){if(t.state===`connected`)return`done`;let n=t.startProgress?.phase,r=Ge.indexOf(e),i=Ke(n);return i<0?t.state===`connecting`||t.state===`reconnecting`?`active`:`pending`:r<i?`done`:r===i?`active`:`pending`}function Je(e,t,n){let r=n.startProgress;return qe(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 Ye(e,t){switch(t){case`preparing_frpc`:return e.stepPrepareFrpc;case`registering`:return e.stepRegister;case`starting_frpc`:return e.stepFrpcLogin}}function Xe(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 Ze(e){let t=(0,Q.c)(31),{status:n,t:r}=e,[,i]=(0,Z.useState)(0),a;t[0]!==i||t[1]!==n.state?(a=()=>{if(n.state!==`connecting`&&n.state!==`reconnecting`)return;let e=window.setInterval(()=>i(Qe),1e3);return()=>window.clearInterval(e)},t[0]=i,t[1]=n.state,t[2]=a):a=t[2];let o=n.startProgress?.startedAt,c;if(t[3]!==n.state||t[4]!==o?(c=[n.state,o],t[3]=n.state,t[4]=o,t[5]=c):c=t[5],(0,Z.useEffect)(a,c),!(n.state===`connecting`||n.state===`reconnecting`||n.state===`connected`&&n.startProgress))return null;let l,u,d,f,m;if(t[6]!==n||t[7]!==r){let e=Xe(n.startProgress?.startedAt);l=!!n.publicUrl&&n.state!==`connected`&&n.startProgress?.phase!==`registering`,u=`mt-3 space-y-3 rounded-lg bg-surface-panel/80 p-3 shadow-surface`;let i;t[13]===r.startProgressTitle?i=t[14]:(i=(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:r.startProgressTitle}),t[13]=r.startProgressTitle,t[14]=i);let a;t[15]===r.startProgressHint?a=t[16]:(a=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:r.startProgressHint}),t[15]=r.startProgressHint,t[16]=a),t[17]!==i||t[18]!==a?(d=(0,$.jsxs)(`div`,{children:[i,a]}),t[17]=i,t[18]=a,t[19]=d):d=t[19];let o=Ge.map(e=>{let t=qe(e,n),i=Je(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)(p,{className:`size-3.5 animate-spin text-accent`}):(0,$.jsx)(U,{className:`size-3.5`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:h(`font-medium`,t===`active`?`text-fg`:t===`done`?`text-fg-muted`:`text-fg-subtle`),children:Ye(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:h(`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:[We(n.frpcDownload.bytesReceived),` /`,` `,We(n.frpcDownload.totalBytes)]}):null]}):null,e===`preparing_frpc`&&t===`active`&&n.frpcDownload?.url?(0,$.jsxs)(`p`,{className:`mt-2 text-fg-subtle`,children:[(0,$.jsxs)(`span`,{className:`font-sans`,children:[r.frpcDownloadingUrlLabel,`: `]}),(0,$.jsx)(`a`,{href:n.frpcDownload.url,target:`_blank`,rel:`noopener noreferrer`,className:`break-all font-mono text-[11px] text-accent hover:underline`,children:n.frpcDownload.url})]}):null]})]},e)});t[20]===o?f=t[21]:(f=(0,$.jsx)(`ol`,{className:`space-y-2`,children:o}),t[20]=o,t[21]=f),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]=l,t[9]=u,t[10]=d,t[11]=f,t[12]=m}else l=t[8],u=t[9],d=t[10],f=t[11],m=t[12];let g;t[22]!==l||t[23]!==r.publicUrlPendingNotice?(g=l?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.publicUrlPendingNotice}):null,t[22]=l,t[23]=r.publicUrlPendingNotice,t[24]=g):g=t[24];let _;return t[25]!==u||t[26]!==d||t[27]!==f||t[28]!==m||t[29]!==g?(_=(0,$.jsxs)(`div`,{className:u,children:[d,f,m,g]}),t[25]=u,t[26]=d,t[27]=f,t[28]=m,t[29]=g,t[30]=_):_=t[30],_}function Qe(e){return e+1}function $e(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 et(e){return e.state===`connected`?`connected`:e.state===`error`?`error`:e.state===`connecting`||e.state===`reconnecting`||e.startProgress||e.frpcDownload?`progress`:`off`}function tt(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 nt(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 rt(e){let t=(0,Q.c)(61),{t:n,status:r,isLoading:i,statusErr:a,starting:o,stopping:s,showConsentExpired:c,copyLabels:l,startDisabled:u,startDisabledReason:d,stepLabel:m,onStart:g,onStop:_}=e,v=u===void 0?!1:u,y,b,x,S,C,w,T;t[0]!==r||t[1]!==o?(T=et(r),y=r.enabled||o,b=o||r.state===`connecting`||r.state===`reconnecting`||!!r.startProgress||!!r.frpcDownload,t[9]===Symbol.for(`react.memo_cache_sentinel`)?(w=h(se(),`space-y-4`),t[9]=w):w=t[9],C=`flex flex-wrap items-start justify-between gap-3`,S=`flex items-center gap-2`,x=h(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,tt(T)),t[0]=r,t[1]=o,t[2]=y,t[3]=b,t[4]=x,t[5]=S,t[6]=C,t[7]=w,t[8]=T):(y=t[2],b=t[3],x=t[4],S=t[5],C=t[6],w=t[7],T=t[8]);let D=T===`connected`&&`bg-emerald-500`,O=T===`progress`&&`bg-amber-500 animate-pulse`,k=T===`error`&&`bg-red-500`,A=T===`off`&&`bg-fg-subtle`,j;t[10]!==D||t[11]!==O||t[12]!==k||t[13]!==A?(j=h(`size-1.5 rounded-full`,D,O,k,A),t[10]=D,t[11]=O,t[12]=k,t[13]=A,t[14]=j):j=t[14];let N;t[15]===j?N=t[16]:(N=(0,$.jsx)(`span`,{className:j,"aria-hidden":!0}),t[15]=j,t[16]=N);let P;t[17]!==i||t[18]!==r||t[19]!==n?(P=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`}):$e(n,r),t[17]=i,t[18]=r,t[19]=n,t[20]=P):P=t[20];let F;t[21]!==N||t[22]!==P||t[23]!==x?(F=(0,$.jsxs)(`span`,{className:x,children:[N,P]}),t[21]=N,t[22]=P,t[23]=x,t[24]=F):F=t[24];let I;t[25]!==r.connectedSince||t[26]!==r.state||t[27]!==n.uptime?(I=r.connectedSince&&r.state===`connected`?(0,$.jsxs)(`span`,{className:`text-xs text-fg-subtle`,children:[n.uptime,` `,nt(r.connectedSince)]}):null,t[25]=r.connectedSince,t[26]=r.state,t[27]=n.uptime,t[28]=I):I=t[28];let L;t[29]!==F||t[30]!==I||t[31]!==S?(L=(0,$.jsxs)(`div`,{className:S,children:[F,I]}),t[29]=F,t[30]=I,t[31]=S,t[32]=L):L=t[32];let R;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(f,{className:`size-4 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[33]=R):R=t[33];let z;t[34]!==L||t[35]!==C?(z=(0,$.jsxs)(`div`,{className:C,children:[L,R]}),t[34]=L,t[35]=C,t[36]=z):z=t[36];let B;t[37]===a?B=t[38]:(B=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]=B);let ee;t[39]!==c||t[40]!==n.consentExpiredBanner?(ee=c?(0,$.jsx)(`p`,{className:`rounded-lg bg-amber-500/10 px-3 py-2 text-xs text-fg-muted`,children:n.consentExpiredBanner}):null,t[39]=c,t[40]=n.consentExpiredBanner,t[41]=ee):ee=t[41];let U;t[42]!==y||t[43]!==l||t[44]!==g||t[45]!==_||t[46]!==b||t[47]!==r||t[48]!==v||t[49]!==d||t[50]!==o||t[51]!==m||t[52]!==s||t[53]!==n?(U=y?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[r.publicUrl?(0,$.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,$.jsx)(M,{label:n.publicUrlLabel,text:r.publicUrl,labels:l})}):null,b?(0,$.jsx)(Ze,{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)(E,{type:`button`,variant:`secondary`,disabled:s,onClick:_,children:[s?(0,$.jsx)(p,{className:`size-4 animate-spin`}):null,n.stop]}):(0,$.jsxs)(E,{type:`button`,disabled:o,onClick:g,children:[o?(0,$.jsx)(p,{className:`size-4 animate-spin`}):(0,$.jsx)(V,{className:`size-4`}),n.start]})})]}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[m?(0,$.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:m}):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 bg-amber-500/10 px-3 py-2.5 text-xs text-fg-muted`,children:[(0,$.jsx)(H,{className:`mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-400`}),(0,$.jsx)(`p`,{children:n.riskBannerBody})]}),v&&d?(0,$.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200`,children:d}):null,(0,$.jsxs)(E,{type:`button`,disabled:o||v,onClick:g,className:`w-full sm:w-auto`,children:[o?(0,$.jsx)(p,{className:`size-4 animate-spin`}):(0,$.jsx)(V,{className:`size-4`}),n.start]})]}),t[42]=y,t[43]=l,t[44]=g,t[45]=_,t[46]=b,t[47]=r,t[48]=v,t[49]=d,t[50]=o,t[51]=m,t[52]=s,t[53]=n,t[54]=U):U=t[54];let W;return t[55]!==z||t[56]!==B||t[57]!==ee||t[58]!==U||t[59]!==w?(W=(0,$.jsxs)(`section`,{className:w,children:[z,B,ee,U]}),t[55]=z,t[56]=B,t[57]=ee,t[58]=U,t[59]=w,t[60]=W):W=t[60],W}var it={reconfiguring:!1};function at(e){let t=(0,Q.c)(89),{t:n,brokerSecretReady:r,brokerSecretConfiguredInConfig:i,brokerSecretMaskedValue:a,brokerSecretDraft:o,savingBrokerSecret:c,authorizingBrokerSecret:l,brokerSecretAuthorizationUrl:f,brokerSecretNotice:m,copyFailedLabel:g,onDraftChange:_,onSave:v,onAuthorize:y,onClear:b,sectionRef:x}=e,S=(0,Z.useId)(),C=r,w=!C,[T,D]=(0,Z.useReducer)(j,it),{reconfiguring:O}=T,k;t[0]!==i||t[1]!==o||t[2]!==O?(k=i&&!O&&!o.trim(),t[0]=i,t[1]=o,t[2]=O,t[3]=k):k=t[3];let A=k,M;t[4]!==n.copied||t[5]!==n.copyKey||t[6]!==n.hideKey||t[7]!==n.showKey?(M={show:n.showKey,hide:n.hideKey,copy:n.copyKey,copied:n.copied},t[4]=n.copied,t[5]=n.copyKey,t[6]=n.hideKey,t[7]=n.showKey,t[8]=M):M=t[8];let N=M,P;t[9]===o?P=t[10]:(P=o.trim().length>0&&!ee(o.trim()),t[9]=o,t[10]=P);let F=P,I;t[11]===_?I=t[12]:(I=()=>{D({type:`patch`,patch:{reconfiguring:!1}}),_(``)},t[11]=_,t[12]=I);let R=I,z=w&&`ring-1 ring-amber-500/30`,B;t[13]===z?B=t[14]:(B=h(z),t[13]=z,t[14]=B);let V=C?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`:w?`bg-amber-500/10 text-amber-700 dark:text-amber-400`:`bg-surface-hover text-fg-muted`,H;t[15]===V?H=t[16]:(H=h(`flex size-9 shrink-0 items-center justify-center rounded-lg`,V),t[15]=V,t[16]=H);let U;t[17]===C?U=t[18]:(U=C?(0,$.jsx)(s,{className:`size-4`,strokeWidth:2,"aria-hidden":!0}):(0,$.jsx)(L,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[17]=C,t[18]=U);let W;t[19]!==H||t[20]!==U?(W=(0,$.jsx)(`span`,{className:H,children:U}),t[19]=H,t[20]=U,t[21]=W):W=t[21];let te=C?n.brokerSecretReadyTitle:n.brokerSecretStepTitle,ne;t[22]===te?ne=t[23]:(ne=(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:te}),t[22]=te,t[23]=ne);let re=C?n.brokerSecretReadyHint:n.brokerSecretHint,G;t[24]===re?G=t[25]:(G=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:re}),t[24]=re,t[25]=G);let K;t[26]!==w||t[27]!==n.brokerSecretMissingHint?(K=w?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-amber-800 dark:text-amber-200`,children:n.brokerSecretMissingHint}):null,t[26]=w,t[27]=n.brokerSecretMissingHint,t[28]=K):K=t[28];let ie;t[29]!==ne||t[30]!==G||t[31]!==K?(ie=(0,$.jsxs)(`div`,{children:[ne,G,K]}),t[29]=ne,t[30]=G,t[31]=K,t[32]=ie):ie=t[32];let q;t[33]!==l||t[34]!==w||t[35]!==y||t[36]!==O||t[37]!==c||t[38]!==n.brokerSecretAuthorize||t[39]!==n.brokerSecretAuthorizing||t[40]!==n.brokerSecretConsoleLink?(q=w||O?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(E,{type:`button`,disabled:c||l,onClick:y,children:[l?(0,$.jsx)(p,{className:`size-4 animate-spin`}):null,l?n.brokerSecretAuthorizing:n.brokerSecretAuthorize]}),(0,$.jsxs)(`a`,{href:ve,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex w-fit items-center gap-1 text-xs font-medium text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[n.brokerSecretConsoleLink,(0,$.jsx)(u,{className:`size-3`,"aria-hidden":!0})]})]}):null,t[33]=l,t[34]=w,t[35]=y,t[36]=O,t[37]=c,t[38]=n.brokerSecretAuthorize,t[39]=n.brokerSecretAuthorizing,t[40]=n.brokerSecretConsoleLink,t[41]=q):q=t[41];let J;t[42]!==l||t[43]!==f||t[44]!==n.brokerSecretOpenAuthorization?(J=l&&f?(0,$.jsxs)(`a`,{href:f,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex w-fit items-center gap-1 text-xs font-medium text-accent-fg hover:underline`,children:[n.brokerSecretOpenAuthorization,(0,$.jsx)(u,{className:`size-3`,"aria-hidden":!0})]}):null,t[42]=l,t[43]=f,t[44]=n.brokerSecretOpenAuthorization,t[45]=J):J=t[45];let ae;t[46]!==i||t[47]!==o||t[48]!==a||t[49]!==F||t[50]!==R||t[51]!==g||t[52]!==S||t[53]!==w||t[54]!==b||t[55]!==_||t[56]!==v||t[57]!==O||t[58]!==c||t[59]!==N||t[60]!==A||t[61]!==n.brokerSecretCancelReconfigure||t[62]!==n.brokerSecretClear||t[63]!==n.brokerSecretMaskedHelp||t[64]!==n.brokerSecretNotInConfigFile||t[65]!==n.brokerSecretPlaceholder||t[66]!==n.brokerSecretReconfigure||t[67]!==n.brokerSecretRevealFailed||t[68]!==n.brokerSecretSave||t[69]!==n.brokerSecretSaveAndContinue||t[70]!==n.brokerSecretTitle?(ae=A?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:S,children:n.brokerSecretTitle}),(0,$.jsx)(d,{id:S,value:a,labels:N,reveal:ot,loadFailedLabel:g||n.brokerSecretRevealFailed,maskedHelp:n.brokerSecretMaskedHelp,notInConfigFile:n.brokerSecretNotInConfigFile,readOnly:!0}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(E,{type:`button`,variant:`secondary`,disabled:c,onClick:()=>{D({type:`patch`,patch:{reconfiguring:!0}})},children:n.brokerSecretReconfigure}),(0,$.jsx)(E,{type:`button`,variant:`ghost`,disabled:c,onClick:b,children:n.brokerSecretClear})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:S,children:n.brokerSecretTitle}),(0,$.jsx)(d,{id:S,value:o,onChange:_,placeholder:n.brokerSecretPlaceholder,labels:N,disabled:c}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(E,{type:`button`,disabled:c||!F,onClick:v,children:[c?(0,$.jsx)(p,{className:`size-4 animate-spin`}):null,w?n.brokerSecretSaveAndContinue:n.brokerSecretSave]}),i?(0,$.jsx)(E,{type:`button`,variant:`ghost`,disabled:c,onClick:b,children:n.brokerSecretClear}):null,O?(0,$.jsx)(E,{type:`button`,variant:`ghost`,disabled:c,onClick:R,children:n.brokerSecretCancelReconfigure}):null]})]}),t[46]=i,t[47]=o,t[48]=a,t[49]=F,t[50]=R,t[51]=g,t[52]=S,t[53]=w,t[54]=b,t[55]=_,t[56]=v,t[57]=O,t[58]=c,t[59]=N,t[60]=A,t[61]=n.brokerSecretCancelReconfigure,t[62]=n.brokerSecretClear,t[63]=n.brokerSecretMaskedHelp,t[64]=n.brokerSecretNotInConfigFile,t[65]=n.brokerSecretPlaceholder,t[66]=n.brokerSecretReconfigure,t[67]=n.brokerSecretRevealFailed,t[68]=n.brokerSecretSave,t[69]=n.brokerSecretSaveAndContinue,t[70]=n.brokerSecretTitle,t[71]=ae):ae=t[71];let oe;t[72]===m?oe=t[73]:(oe=m?(0,$.jsx)(`p`,{className:`text-xs text-emerald-700 dark:text-emerald-400`,children:m}):null,t[72]=m,t[73]=oe);let Y;t[74]!==ie||t[75]!==q||t[76]!==J||t[77]!==ae||t[78]!==oe?(Y=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[ie,q,J,ae,oe]}),t[74]=ie,t[75]=q,t[76]=J,t[77]=ae,t[78]=oe,t[79]=Y):Y=t[79];let se;t[80]!==W||t[81]!==Y?(se=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[W,Y]}),t[80]=W,t[81]=Y,t[82]=se):se=t[82];let le;t[83]!==se||t[84]!==B?(le=(0,$.jsx)(ce,{className:B,children:se}),t[83]=se,t[84]=B,t[85]=le):le=t[85];let ue;return t[86]!==x||t[87]!==le?(ue=(0,$.jsx)(`div`,{ref:x,id:`tunnel-broker-secret-setup`,children:le}),t[86]=x,t[87]=le,t[88]=ue):ue=t[88],ue}function ot(){return X().then(st)}function st(e){return e.registrationSecret??null}var ct={actionError:null,starting:!1,stopping:!1,savingAutoStart:!1,consentOpen:!1,autoStartConfirmOpen:!1,releaseConfirmOpen:!1,releasing:!1,brokerSecretDraft:``,savingBrokerSecret:!1,authorizingBrokerSecret:!1,brokerSecretAuthorizationUrl:null,brokerSecretNotice:null};function lt({embedded:e=!1}){let t=_(e=>e.language),n=m(t).tunnelSettings,r=!!g(e=>e.conversationId),[i,a]=(0,Z.useReducer)(j,ct),{actionError:o,starting:s,stopping:c,savingAutoStart:l,consentOpen:u,autoStartConfirmOpen:d,releaseConfirmOpen:v,releasing:y,brokerSecretDraft:b,savingBrokerSecret:x,authorizingBrokerSecret:S,brokerSecretAuthorizationUrl:C,brokerSecretNotice:w}=i,k=(0,Z.useRef)(null),{data:A}=O(r),{data:M,error:L,isLoading:R,mutate:z}=T(r?`tunnel-status`:null,he,{refreshInterval:e=>s?1e3:e?.frpcDownload||e?.state===`connecting`||e?.state===`reconnecting`?2e3:6e4}),V=(0,Z.useMemo)(()=>{let e=A?.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 M?.config?.autoStart===!0},[A,M?.config?.autoStart]),H=(0,Z.useMemo)(()=>{let e=A?.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``},[A]),U=ee(H),W=M?.registrationSecret?.configured??U;(0,Z.useEffect)(()=>{let e=()=>{z()};return window.addEventListener(`tunnel-status`,e),()=>window.removeEventListener(`tunnel-status`,e)},[z]);let re=(0,Z.useMemo)(()=>[n.consentBullet1,n.consentBullet2,n.consentBullet3],[n.consentBullet1,n.consentBullet2,n.consentBullet3]),G=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{actionError:null}}),a({type:`patch`,patch:{starting:!0}});try{await _e(),await z(),D()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{starting:!1}})}},[z]),K=(0,Z.useCallback)(()=>{if(!W){a({type:`patch`,patch:{actionError:n.brokerSecretRequiredBeforeStart}}),k.current?.scrollIntoView({behavior:`smooth`,block:`start`});return}if(M?.consentRequired){a({type:`patch`,patch:{consentOpen:!0}});return}G()},[W,M?.consentRequired,G,n.brokerSecretRequiredBeforeStart]),ie=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{consentOpen:!1}}),a({type:`patch`,patch:{actionError:null}});try{await ue(),await Promise.all([z(),G()])}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}},[z,G]),q=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{actionError:null}}),a({type:`patch`,patch:{stopping:!0}});try{await fe(),await z(),D()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{stopping:!1}})}},[z]),J=(0,Z.useCallback)(async e=>{a({type:`patch`,patch:{savingAutoStart:!0}}),a({type:`patch`,patch:{actionError:null}});try{await ge({autoStart:e}),D()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{savingAutoStart:!1}})}},[]),ae=(0,Z.useCallback)(()=>{if(V){J(!1);return}if(M?.consentRequired){a({type:`patch`,patch:{actionError:n.consentExpiredBanner}});return}if(!M?.canAutoStart){a({type:`patch`,patch:{actionError:n.autoStartHint}});return}a({type:`patch`,patch:{autoStartConfirmOpen:!0}})},[J,M?.canAutoStart,M?.consentRequired,n,V]),oe=(0,Z.useCallback)(async()=>{let e=b.trim();if(e){a({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await ge({registrationSecret:e}),a({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretSaved}}),D(),await z(),a({type:`patch`,patch:{actionError:null}})}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{savingBrokerSecret:!1}})}}},[b,z,n.brokerSecretSaved]),Y=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await ge({registrationSecret:null}),a({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretCleared}}),D(),await z()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{savingBrokerSecret:!1}})}},[z,n.brokerSecretCleared]),se=(0,Z.useCallback)(async()=>{let e=I(),t=null,r=null;a({type:`patch`,patch:{authorizingBrokerSecret:!0,brokerSecretAuthorizationUrl:null,brokerSecretNotice:null,actionError:null}});try{for(t=(await N(`xopc-tunnel`)).sessionId;;){await new Promise(e=>window.setTimeout(e,1e3));let i=await F(t);if(i.authUrl&&i.authUrl!==r&&(r=i.authUrl,a({type:`patch`,patch:{brokerSecretAuthorizationUrl:i.authUrl}}),await te(i.authUrl,e)),i.status===`failed`||i.status===`cancelled`)throw Error(i.error??i.message??`OAuth authorization failed`);if(i.status===`completed`){await me(),await Promise.all([z(),D()]),a({type:`patch`,patch:{brokerSecretNotice:n.brokerSecretSaved,brokerSecretDraft:``}});return}}}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{B(e),t&&P(t).catch(()=>void 0),a({type:`patch`,patch:{authorizingBrokerSecret:!1,brokerSecretAuthorizationUrl:null}})}},[z,n.brokerSecretSaved]),le=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{releaseConfirmOpen:!1,actionError:null,releasing:!0}});try{await fe({release:!0}),await z(),D()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{releasing:!1}})}},[z]),pe=(0,Z.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:m(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]);if(!r)return(0,$.jsx)(`div`,{className:e?void 0:`w-full px-3 py-8 sm:px-5 xl:px-6`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})});let X=M??{enabled:!1,state:`disconnected`,subdomain:null,publicUrl:null,connectedSince:null,frpcPid:null,lastHeartbeatAt:null,lastError:null,consentRequired:!0,config:{autoStart:V,brokerUrl:`https://frp.xopc.ai/api`}},ve=M?.consentRequired&&(X.enabled||V||M?.consent?.acceptedAt),ye=(0,$.jsx)(at,{t:n,brokerSecretReady:W,brokerSecretConfiguredInConfig:U,brokerSecretMaskedValue:U?H:``,brokerSecretDraft:b,savingBrokerSecret:x,authorizingBrokerSecret:S,brokerSecretAuthorizationUrl:C,brokerSecretNotice:w,copyFailedLabel:m(t).clipboard.copyFailed,onDraftChange:e=>a({type:`patch`,patch:{brokerSecretDraft:e}}),onSave:()=>void oe(),onAuthorize:()=>void se(),onClear:()=>void Y(),sectionRef:k}),be=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ve,{open:u,title:n.consentTitle,intro:n.consentIntro,bullets:re,checkboxLabel:n.consentCheckbox,confirmLabel:ve?n.consentReconfirm:n.consentConfirm,cancelLabel:n.consentCancel,onConfirm:()=>void ie(),onCancel:()=>a({type:`patch`,patch:{consentOpen:!1}})},u?`consent-open`:`consent-closed`),(0,$.jsx)(ne,{open:d,title:n.autoStartConfirmTitle,description:n.autoStartConfirmBody,confirmLabel:n.autoStartConfirmLabel,cancelLabel:n.consentCancel,onConfirm:()=>{a({type:`patch`,patch:{autoStartConfirmOpen:!1}}),J(!0)},onCancel:()=>a({type:`patch`,patch:{autoStartConfirmOpen:!1}})}),(0,$.jsx)(ne,{open:v,title:n.releaseConfirmTitle,description:n.releaseConfirmBody,confirmLabel:n.releaseConfirmLabel,cancelLabel:n.consentCancel,destructive:!0,onConfirm:()=>void le(),onCancel:()=>a({type:`patch`,patch:{releaseConfirmOpen:!1}})})]});return e?(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[o?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:o}):null,ye,(0,$.jsx)(rt,{t:n,status:X,isLoading:R,statusErr:L,starting:s,stopping:c,showConsentExpired:!!ve,copyLabels:pe,startDisabled:!W,startDisabledReason:W?void 0:n.brokerSecretRequiredBeforeStart,stepLabel:n.flowStepStart,onStart:K,onStop:()=>void q()}),(0,$.jsxs)(ze,{showLabel:n.showOptions,hideLabel:n.hideOptions,children:[(0,$.jsxs)(`label`,{className:h(`flex items-center gap-3 text-sm text-fg`,!V&&!M?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:V,disabled:l||!V&&!M?.canAutoStart,onChange:ae}),n.autoStart]}),!M?.canAutoStart&&!V?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.autoStartHint}):null,X.subdomain||X.publicUrl?(0,$.jsxs)(`div`,{className:`space-y-2 rounded-xl bg-surface-base/45 p-4`,children:[(0,$.jsxs)(E,{type:`button`,variant:`secondary`,disabled:y||c,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>a({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[y?(0,$.jsx)(p,{className:`size-4 animate-spin`}):null,n.release]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint})]}):null]}),(0,$.jsx)(ze,{showLabel:n.showAdvanced,hideLabel:n.hideAdvanced,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-xl bg-surface-base/45 p-4 text-xs text-fg-subtle`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(f,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)(de,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]})}),be]}):(0,$.jsxs)(`div`,{className:e?`flex w-full flex-col gap-6`:`flex w-full flex-col gap-6 px-3 py-8 sm:px-5 xl:px-6`,children:[e?null:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:n.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.subtitle})]}),o?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:o}):null,ye,(0,$.jsx)(rt,{t:n,status:X,isLoading:R,statusErr:L,starting:s,stopping:c,showConsentExpired:!!ve,copyLabels:pe,startDisabled:!W,startDisabledReason:W?void 0:n.brokerSecretRequiredBeforeStart,onStart:K,onStop:()=>void q()}),X.subdomain||X.publicUrl?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,$.jsxs)(E,{type:`button`,variant:`secondary`,disabled:y||c,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>a({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[y?(0,$.jsx)(p,{className:`size-4 animate-spin`}):null,n.release]})}):null,X.subdomain||X.publicUrl?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint}):null,(0,$.jsxs)(ce,{children:[(0,$.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-fg`,children:n.optionsTitle}),(0,$.jsxs)(`label`,{className:h(`flex items-center gap-3 text-sm text-fg`,!V&&!M?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:V,disabled:l||!V&&!M?.canAutoStart,onChange:ae}),n.autoStart]}),!M?.canAutoStart&&!V?(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)(f,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)(de,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]}),be]})}function ut(e,t){return e.tabs[t]}function dt(e,t){return e.tabIntro[t]}function ft(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 pt(e){let t=(0,Q.c)(7),{tab:n,onOpenTab:r}=e;switch(n){case`guide`:{let e;return t[0]===r?e=t[1]:(e=(0,$.jsx)(Oe,{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)(ye,{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)(lt,{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)(le,{}),t[4]=e):e=t[4],e}case`ssh`:{let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ie,{}),t[5]=e):e=t[5],e}case`lan`:{let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Me,{}),t[6]=e):e=t[6],e}}}function mt(){let e=(0,Q.c)(3),t=i(),n=_(gt),r=m(n).remoteAccess,o=!!g(ht),[s,c]=a(),l=Re(s.get(`tab`)),u=s.get(`intent`)===`mobile-pairing`,d;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(d={refreshInterval:2e3},e[0]=d):d=e[0];let f=T(u?`device-pairing-readiness`:null,pe,d),p;e[1]===c?p=e[2]:(p=e=>{c(t=>{let n=new URLSearchParams(t);return e===`guide`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[1]=c,e[2]=p);let h=p,v=dt(r,l),y=Le.map(e=>({id:e,label:ut(r,e)}));return(0,$.jsxs)(ae,{children:[(0,$.jsx)(J,{title:r.pageTitle,meta:(0,$.jsx)(de,{language:n,label:r.docsLink,section:ft(l),className:`mt-1`})}),o?(0,$.jsxs)($.Fragment,{children:[u?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-xl bg-accent-soft px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(ie,{className:`mt-0.5 size-5 shrink-0 text-accent`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:r.mobilePairingFlow.title}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:f.data?.ready?r.mobilePairingFlow.ready:r.mobilePairingFlow.hint})]})]}),(0,$.jsxs)(E,{variant:`primary`,disabled:!f.data?.ready,onClick:()=>t(`/settings/devices?startDevicePairing=mobile`),children:[f.data?.ready?r.mobilePairingFlow.continue:r.mobilePairingFlow.waiting,(0,$.jsx)(z,{className:`size-4`,"aria-hidden":!0})]})]}):null,(0,$.jsx)(q,{items:y,activeTab:l,onChange:h,ariaLabel:r.tabsAria,tabIdPrefix:`remote-access-tab`,panelIdPrefix:`remote-access-panel`}),(0,$.jsx)(oe,{id:l,activeTab:l,tabIdPrefix:`remote-access-tab`,panelIdPrefix:`remote-access-panel`,title:ut(r,l),hint:l===`public`?void 0:v,showHeading:!1,framed:!1,children:(0,$.jsx)(pt,{tab:l,onOpenTab:h})})]}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.guide.needToken})]})}function ht(e){return e.conversationId}function gt(e){return e.language}export{mt 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{g as i}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{n as a,r as o}from"./popover-select-BgSdSbCL.js";import{t as s}from"./download-Dk-ZjtO6.js";import{t as c}from"./folder-open-CyzJ19I9.js";import{t as l}from"./message-square-fVE7Ghj1.js";import{t as u}from"./minimize-2-DtOGrlpo.js";import{t as d}from"./plus-Q2yW6OE7.js";import{t as f}from"./search-DA7gz22f.js";import{t as p}from"./x-B_N4OPjy.js";import{t as m}from"./messages-CnM6Qfr7.js";import{t as h}from"./cn-JdwAhgNB.js";import{a as g,c as _,n as ee,r as v}from"./locale-store-ChN_vjs2.js";import{a as y,n as b,o as x,r as S,s as te,t as C}from"./dist-BGTk37IG.js";import{a as w,c as T,f as E,n as D,o as O,p as k,r as A,s as j,t as M}from"./session-api-UkGomZfv.js";import{i as N}from"./vendor-swr-BIWyz7Rc.js";import{t as P}from"./button-CS04eWY9.js";import{n as F,t as I}from"./interaction-BdhHBbYa.js";import{n as L,r as R}from"./gateway-config-swr-EZxaKXdC.js";import{n as z,t as B}from"./registry-api-BM_81rLe.js";import{s as V}from"./form-field-width-DJw_jULe.js";import{t as H}from"./skeleton-BwbyijEw.js";import{i as ne,o as re}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{n as U,r as ie,t as W}from"./settings-form-draft-Dy10ldo8.js";import{Ao as G,Go as ae,Hi as oe,Ic as se,Ko as ce,Lc as K,Rt as le,Ss as ue,Ur as de,ac as fe,ec as pe,fc as me,li as he,lo as ge,oi as _e,ui as ve,ws as ye,xs as be,zt as xe}from"./index-BXrBL_Hb.js";import{t as Se}from"./page-tabs-D2xpUV26.js";import{n as Ce,r as we}from"./settings-page-layout-X1x-2Cp9.js";import{n as Te,t as q}from"./settings-form-section-exRhP9xn.js";import{n as J,t as Ee}from"./use-autosave-R3hEHQQq.js";import{t as De}from"./settings-advanced-gate-CvFVkELy.js";var Y=e(t(),1),Oe=n(),X=r();function ke(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 Ae(e,t){return new Intl.NumberFormat(t===`zh`?`zh-CN`:`en-US`).format(e)}function je(e){return`$${Number(e).toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:6})}`}function Me(e){let t=(0,Oe.c)(124),{session:n,variant:r,labels:i,sessionAgentId:a,sessionAgentAvatar:o,onOpen:c,onAction:u}=e,d;t[0]!==i.unnamedSession||t[1]!==n.name?(d=n.name?.trim()||i.unnamedSession,t[0]=i.unnamedSession,t[1]=n.name,t[2]=d):d=t[2];let f=d,p=ee(Ie),g;t[3]!==p||t[4]!==n?(g=ve(n,m(p).sidebar.sessionFilters),t[3]=p,t[4]=n,t[5]=g):g=t[5];let _=g,v;t[6]===n.name?v=t[7]:(v=n.name?.trim(),t[6]=n.name,t[7]=v);let y=!!v,b=n.status===`archived`,x=n.status===`pinned`,S=n.usage,te;t[8]!==i.costUnknown||t[9]!==i.noUsage||t[10]!==S?(te=S?.calls?S.costCompleteness===`unknown`?i.costUnknown:`${S.costCompleteness===`partial`?`≥ `:`≈ `}${je(S.knownCostUsd)}`:i.noUsage,t[8]=i.costUnknown,t[9]=i.noUsage,t[10]=S,t[11]=te):te=t[11];let C=te,w=S?.calls?S.costCompleteness===`partial`?i.costPartial:S.costCompleteness===`unknown`?i.costUnknown:i.cost:i.noUsage,T=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,E;t[12]===T?E=t[13]:(E=h(`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`,T),t[12]=T,t[13]=E);let D;t[14]===c?D=t[15]:(D=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},t[14]=c,t[15]=D);let O=r===`list`&&`sm:py-3`,k;t[16]===O?k=t[17]:(k=h(`flex min-w-0 items-start justify-between gap-2 bg-surface-hover/35 px-3 py-2 dark:bg-surface-hover/25`,O),t[16]=O,t[17]=k);let A;t[18]===n?A=t[19]:(A=(0,X.jsx)(he,{sourceChannel:n.sourceChannel,session:n,className:`size-3.5`}),t[18]=n,t[19]=A);let j;t[20]===_?j=t[21]:(j=(0,X.jsx)(`span`,{className:`truncate text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:_}),t[20]=_,t[21]=j);let M;t[22]!==A||t[23]!==j?(M=(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[A,j]}),t[22]=A,t[23]=j,t[24]=M):M=t[24];let N;t[25]===x?N=t[26]:(N=x?(0,X.jsx)(ce,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[25]=x,t[26]=N);let P;t[27]===n.updatedAt?P=t[28]:(P=ke(n.updatedAt),t[27]=n.updatedAt,t[28]=P);let F;t[29]===P?F=t[30]:(F=(0,X.jsx)(`span`,{children:P}),t[29]=P,t[30]=F);let L;t[31]!==N||t[32]!==F?(L=(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,children:[N,F]}),t[31]=N,t[32]=F,t[33]=L):L=t[33];let R;t[34]!==M||t[35]!==L||t[36]!==k?(R=(0,X.jsxs)(`div`,{className:k,children:[M,L]}),t[34]=M,t[35]=L,t[36]=k,t[37]=R):R=t[37];let z=r===`list`&&`sm:py-3`,B;t[38]===z?B=t[39]:(B=h(`min-w-0 flex-1 px-3 py-2`,z),t[38]=z,t[39]=B);let V=r===`list`&&`sm:items-start`,H;t[40]===V?H=t[41]:(H=h(`flex gap-3`,V),t[40]=V,t[41]=H);let ne;t[42]!==o||t[43]!==a?(ne=(0,X.jsx)(oe,{agentId:a,avatar:o,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}),t[42]=o,t[43]=a,t[44]=ne):ne=t[44];let re;t[45]===f?re=t[46]:(re=(0,X.jsx)(`div`,{className:`min-w-0 max-w-full truncate text-sm font-semibold text-fg`,title:f,children:f}),t[45]=f,t[46]=re);let U;t[47]!==n.key||t[48]!==y?(U=y?(0,X.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[47]=n.key,t[48]=y,t[49]=U):U=t[49];let ie;t[50]!==re||t[51]!==U?(ie=(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[re,U]}),t[50]=re,t[51]=U,t[52]=ie):ie=t[52];let W;t[53]!==H||t[54]!==ne||t[55]!==ie?(W=(0,X.jsxs)(`div`,{className:H,children:[ne,ie]}),t[53]=H,t[54]=ne,t[55]=ie,t[56]=W):W=t[56];let G;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,X.jsx)(l,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[57]=G):G=t[57];let le;t[58]===n.messageCount?le=t[59]:(le=(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[G,n.messageCount]}),t[58]=n.messageCount,t[59]=le);let ue;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,X.jsx)(pe,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[60]=ue):ue=t[60];let de=S?.totalTokens??0,me;t[61]!==p||t[62]!==de?(me=Ae(de,p),t[61]=p,t[62]=de,t[63]=me):me=t[63];let _e;t[64]!==i.tokens||t[65]!==me?(_e=(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[ue,me,` `,i.tokens]}),t[64]=i.tokens,t[65]=me,t[66]=_e):_e=t[66];let ye;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(ye=(0,X.jsx)(fe,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[67]=ye):ye=t[67];let be;t[68]!==C||t[69]!==w?(be=(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1`,title:w,children:[ye,C]}),t[68]=C,t[69]=w,t[70]=be):be=t[70];let xe;t[71]!==le||t[72]!==_e||t[73]!==be?(xe=(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[le,_e,be]}),t[71]=le,t[72]=_e,t[73]=be,t[74]=xe):xe=t[74];let Se;t[75]===n.tags?Se=t[76]:(Se=n.tags.length>0?(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n.tags.slice(0,3).map(Fe),n.tags.length>3?(0,X.jsxs)(`span`,{className:`text-[11px] text-fg-disabled`,children:[`+`,n.tags.length-3]}):null]}):null,t[75]=n.tags,t[76]=Se);let Ce;t[77]!==B||t[78]!==W||t[79]!==xe||t[80]!==Se?(Ce=(0,X.jsxs)(`div`,{className:B,children:[W,xe,Se]}),t[77]=B,t[78]=W,t[79]=xe,t[80]=Se,t[81]=Ce):Ce=t[81];let we;t[82]===u?we=t[83]:(we=()=>u(`continue`),t[82]=u,t[83]=we);let Te;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(Te=(0,X.jsx)(l,{className:`size-4`,strokeWidth:1.75}),t[84]=Te):Te=t[84];let q;t[85]!==i.continueChat||t[86]!==we?(q=(0,X.jsx)(`button`,{type:`button`,className:I,title:i.continueChat,"aria-label":i.continueChat,onClick:we,children:Te}),t[85]=i.continueChat,t[86]=we,t[87]=q):q=t[87];let J;t[88]!==b||t[89]!==i.archive||t[90]!==i.unarchive||t[91]!==u?(J=b?(0,X.jsx)(`button`,{type:`button`,className:I,title:i.unarchive,"aria-label":i.unarchive,onClick:()=>u(`unarchive`),children:(0,X.jsx)(K,{className:`size-4`,strokeWidth:1.75})}):(0,X.jsx)(`button`,{type:`button`,className:I,title:i.archive,"aria-label":i.archive,onClick:()=>u(`archive`),children:(0,X.jsx)(se,{className:`size-4`,strokeWidth:1.75})}),t[88]=b,t[89]=i.archive,t[90]=i.unarchive,t[91]=u,t[92]=J):J=t[92];let Ee;t[93]!==x||t[94]!==i.pin||t[95]!==i.unpin||t[96]!==u?(Ee=x?(0,X.jsx)(`button`,{type:`button`,className:I,title:i.unpin,"aria-label":i.unpin,onClick:()=>u(`unpin`),children:(0,X.jsx)(ae,{className:`size-4`,strokeWidth:1.75})}):(0,X.jsx)(`button`,{type:`button`,className:I,title:i.pin,"aria-label":i.pin,onClick:()=>u(`pin`),children:(0,X.jsx)(ce,{className:`size-4`,strokeWidth:1.75})}),t[93]=x,t[94]=i.pin,t[95]=i.unpin,t[96]=u,t[97]=Ee):Ee=t[97];let De;t[98]===u?De=t[99]:(De=()=>u(`export`),t[98]=u,t[99]=De);let Y;t[100]===Symbol.for(`react.memo_cache_sentinel`)?(Y=(0,X.jsx)(s,{className:`size-4`,strokeWidth:1.75}),t[100]=Y):Y=t[100];let Me;t[101]!==i.export||t[102]!==De?(Me=(0,X.jsx)(`button`,{type:`button`,className:I,title:i.export,"aria-label":i.export,onClick:De,children:Y}),t[101]=i.export,t[102]=De,t[103]=Me):Me=t[103];let Le;t[104]===Symbol.for(`react.memo_cache_sentinel`)?(Le=h(I,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),t[104]=Le):Le=t[104];let Re;t[105]===u?Re=t[106]:(Re=()=>u(`delete`),t[105]=u,t[106]=Re);let ze;t[107]===Symbol.for(`react.memo_cache_sentinel`)?(ze=(0,X.jsx)(ge,{className:`size-4`,strokeWidth:1.75}),t[107]=ze):ze=t[107];let Z;t[108]!==i.delete||t[109]!==Re?(Z=(0,X.jsx)(`button`,{type:`button`,className:Le,title:i.delete,"aria-label":i.delete,onClick:Re,children:ze}),t[108]=i.delete,t[109]=Re,t[110]=Z):Z=t[110];let Be;t[111]!==q||t[112]!==J||t[113]!==Ee||t[114]!==Me||t[115]!==Z?(Be=(0,X.jsxs)(`div`,{role:`group`,className:`m-1 mt-0 flex flex-wrap items-center gap-0.5 rounded-lg bg-surface-hover/35 p-1.5`,onClick:Pe,onKeyDown:Ne,children:[q,J,Ee,Me,Z]}),t[111]=q,t[112]=J,t[113]=Ee,t[114]=Me,t[115]=Z,t[116]=Be):Be=t[116];let Q;return t[117]!==c||t[118]!==R||t[119]!==Ce||t[120]!==Be||t[121]!==E||t[122]!==D?(Q=(0,X.jsxs)(`div`,{role:`button`,tabIndex:0,className:E,onClick:c,onKeyDown:D,children:[R,Ce,Be]}),t[117]=c,t[118]=R,t[119]=Ce,t[120]=Be,t[121]=E,t[122]=D,t[123]=Q):Q=t[123],Q}function Ne(e){return e.stopPropagation()}function Pe(e){return e.stopPropagation()}function Fe(e){return(0,X.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 Ie(e){return e.language}function Le(e,t){return e.routing?.agentId?.trim().toLowerCase()||t.trim().toLowerCase()||`main`}function Re(e,t){return t.find(t=>t.id===e)?.avatar}var ze={enabled:!0,triggerThreshold:.8,reserveTokens:8192,minMessagesBeforeCompact:10,keepRecentTokens:2e4,recentTurnsPreserve:3,summaryMaxTokens:16e3,summaryChunkTokens:24e3,summaryTimeoutMs:18e4,summaryRetries:2,qualityGuard:!0,gapAudit:!0,minToolResultKeepChars:1e3,maxActiveTranscriptBytes:2e6,postCompactionSections:[`Session Startup`,`Red Lines`]};function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Be(e,t,n,r=1/0){return typeof e==`number`&&Number.isFinite(e)&&e>=n&&e<=r?e:t}function Q(e,t,n,r=1/0){return Number.isInteger(e)&&e>=n&&e<=r?e:t}function Ve(e){let t=Z(e)?e:{},n=Z(t.userContext)?t.userContext:{},r=Z(n.contextPlanning)?n.contextPlanning:{},i=Z(r.compaction)?r.compaction:{},a=ze,o=typeof i.model==`string`&&i.model.trim()?i.model.trim():void 0,s=Array.isArray(i.postCompactionSections)&&i.postCompactionSections.length<=12&&i.postCompactionSections.every(e=>typeof e==`string`&&e.trim())?[...new Set(i.postCompactionSections.map(e=>e.trim()))]:[...a.postCompactionSections];return{enabled:typeof i.enabled==`boolean`?i.enabled:a.enabled,triggerThreshold:Be(i.triggerThreshold,a.triggerThreshold,.1,.98),reserveTokens:Q(i.reserveTokens,a.reserveTokens,1024),minMessagesBeforeCompact:Q(i.minMessagesBeforeCompact,a.minMessagesBeforeCompact,2),keepRecentTokens:Q(i.keepRecentTokens,a.keepRecentTokens,1e3),recentTurnsPreserve:Q(i.recentTurnsPreserve,a.recentTurnsPreserve,1,12),summaryMaxTokens:Q(i.summaryMaxTokens,a.summaryMaxTokens,256),summaryChunkTokens:Q(i.summaryChunkTokens,a.summaryChunkTokens,1e3),summaryTimeoutMs:Q(i.summaryTimeoutMs,a.summaryTimeoutMs,1e3,6e5),summaryRetries:Q(i.summaryRetries,a.summaryRetries,0,5),qualityGuard:typeof i.qualityGuard==`boolean`?i.qualityGuard:a.qualityGuard,gapAudit:typeof i.gapAudit==`boolean`?i.gapAudit:a.gapAudit,...o?{model:o}:{},minToolResultKeepChars:Q(i.minToolResultKeepChars,a.minToolResultKeepChars,200),maxActiveTranscriptBytes:Q(i.maxActiveTranscriptBytes,a.maxActiveTranscriptBytes,64e3),postCompactionSections:s}}function He(e){return e.triggerThreshold<.1||e.triggerThreshold>.98?`triggerThreshold`:!Number.isInteger(e.reserveTokens)||e.reserveTokens<1024?`reserveTokens`:!Number.isInteger(e.minMessagesBeforeCompact)||e.minMessagesBeforeCompact<2?`minMessagesBeforeCompact`:!Number.isInteger(e.keepRecentTokens)||e.keepRecentTokens<1e3?`keepRecentTokens`:!Number.isInteger(e.recentTurnsPreserve)||e.recentTurnsPreserve<1||e.recentTurnsPreserve>12?`recentTurnsPreserve`:!Number.isInteger(e.summaryMaxTokens)||e.summaryMaxTokens<256?`summaryMaxTokens`:!Number.isInteger(e.summaryChunkTokens)||e.summaryChunkTokens<1e3?`summaryChunkTokens`:!Number.isInteger(e.summaryTimeoutMs)||e.summaryTimeoutMs<1e3||e.summaryTimeoutMs>6e5?`summaryTimeoutMs`:!Number.isInteger(e.summaryRetries)||e.summaryRetries<0||e.summaryRetries>5?`summaryRetries`:e.model!==void 0&&!e.model.trim()?`model`:!Number.isInteger(e.minToolResultKeepChars)||e.minToolResultKeepChars<200?`minToolResultKeepChars`:!Number.isInteger(e.maxActiveTranscriptBytes)||e.maxActiveTranscriptBytes<64e3?`maxActiveTranscriptBytes`:e.postCompactionSections.length>12||e.postCompactionSections.some(e=>!e.trim())?`postCompactionSections`:null}function Ue(e){let t={...e,...e.model?.trim()?{model:e.model.trim()}:{}};return e.model?.trim()||delete t.model,{userContext:{contextPlanning:{compaction:t}}}}async function We(e){await g(v(`/api/config`),{method:`PATCH`,body:JSON.stringify(Ue(e))}),await L()}var Ge=128e3,Ke={balanced:ze,preserve:{...ze,triggerThreshold:.88,keepRecentTokens:32e3,recentTurnsPreserve:5,maxActiveTranscriptBytes:4e6},early:{...ze,triggerThreshold:.65,reserveTokens:12e3,minMessagesBeforeCompact:6,keepRecentTokens:12e3,recentTurnsPreserve:2}},qe=W();function Je(){return h(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg disabled:cursor-not-allowed disabled:opacity-55`,V,`dark:border-edge`)}function Ye(e){let{enabled:t,model:n,postCompactionSections:r,...i}=e;return JSON.stringify(i)}function Xe(e){let t=Ye(e);for(let[e,n]of Object.entries(Ke))if(t===Ye(n))return e;return`custom`}function Ze(e){return e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}m`:e>=1e3?`${(e/1e3).toFixed(e%1e3==0?0:1)}k`:String(e)}function $(e){let t=(0,Oe.c)(20),{id:n,label:r,hint:i,value:a,min:o,max:s,step:c,disabled:l,onChange:u}=e,d=c===void 0?1:c,f;t[0]!==n||t[1]!==r?(f=(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=f):f=t[2];let p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=Je(),t[3]=p):p=t[3];let m;t[4]===u?m=t[5]:(m=e=>{if(!e.target.value.trim())return;let t=Number(e.target.value);Number.isFinite(t)&&u(t)},t[4]=u,t[5]=m);let h;t[6]!==l||t[7]!==n||t[8]!==s||t[9]!==o||t[10]!==d||t[11]!==m||t[12]!==a?(h=(0,X.jsx)(`input`,{id:n,type:`number`,min:o,max:s,step:d,disabled:l,className:p,value:a,onChange:m}),t[6]=l,t[7]=n,t[8]=s,t[9]=o,t[10]=d,t[11]=m,t[12]=a,t[13]=h):h=t[13];let g;t[14]===i?g=t[15]:(g=i?(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}):null,t[14]=i,t[15]=g);let _;return t[16]!==f||t[17]!==h||t[18]!==g?(_=(0,X.jsxs)(`div`,{children:[f,h,g]}),t[16]=f,t[17]=h,t[18]=g,t[19]=_):_=t[19],_}function Qe(e){let t=(0,Oe.c)(19),{label:n,hint:r,checked:i,disabled:a,onChange:o}=e,s=a?`cursor-not-allowed opacity-55`:`cursor-pointer`,c;t[0]===s?c=t[1]:(c=h(`flex items-start gap-2 text-sm text-fg`,s),t[0]=s,t[1]=c);let l;t[2]===o?l=t[3]:(l=e=>o(e.target.checked),t[2]=o,t[3]=l);let u;t[4]!==i||t[5]!==a||t[6]!==l?(u=(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:i,disabled:a,onChange:l}),t[4]=i,t[5]=a,t[6]=l,t[7]=u):u=t[7];let d;t[8]===n?d=t[9]:(d=(0,X.jsx)(`span`,{className:`font-medium`,children:n}),t[8]=n,t[9]=d);let f;t[10]===r?f=t[11]:(f=(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:r}),t[10]=r,t[11]=f);let p;t[12]!==d||t[13]!==f?(p=(0,X.jsxs)(`span`,{children:[d,f]}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let m;return t[15]!==c||t[16]!==u||t[17]!==p?(m=(0,X.jsxs)(`label`,{className:c,children:[u,p]}),t[15]=c,t[16]=u,t[17]=p,t[18]=m):m=t[18],m}function $e({hasToken:e}){let t=m(ee(e=>e.language)).sessions.compaction,{data:n,isLoading:r}=R(e),{data:i=[],isLoading:a}=N(e?B:null,z,{revalidateOnFocus:!1}),o=(0,Y.useMemo)(()=>n?.payload?.config===void 0?null:Ve(n.payload.config),[n]),[s,c]=(0,Y.useReducer)(qe,{form:null,baseline:null}),[l,f]=(0,Y.useState)(``),g=(0,Y.useRef)(!1),_=(0,Y.useRef)(s.form);_.current=s.form;let v=(0,Y.useRef)(null);U({enabled:e,parsed:o,dirty:g.current,trackedParsedRef:v,dispatch:c,onResetDirty:()=>{g.current=!1}});let y=s.form,b=s.baseline,x=!!(y&&b&&JSON.stringify(y)!==JSON.stringify(b)),S=(0,Y.useCallback)(e=>{g.current=!0,c({type:`patch`,patch:e})},[]),te=(0,Y.useCallback)(e=>({enabled:t.enabled,triggerThreshold:t.triggerThreshold,reserveTokens:t.reserveTokens,minMessagesBeforeCompact:t.minMessagesBeforeCompact,keepRecentTokens:t.keepRecentTokens,recentTurnsPreserve:t.recentTurnsPreserve,summaryMaxTokens:t.summaryMaxTokens,summaryChunkTokens:t.summaryChunkTokens,summaryTimeoutMs:t.summaryTimeoutSeconds,summaryRetries:t.summaryRetries,qualityGuard:t.qualityGuard,gapAudit:t.gapAudit,model:t.summaryModel,minToolResultKeepChars:t.minToolResultKeepChars,maxActiveTranscriptBytes:t.maxActiveTranscriptMb,postCompactionSections:t.postCompactionSections})[e],[t]),C=Ee({value:y,dirty:x,onSave:(0,Y.useCallback)(async e=>{try{await We(e),c({type:`saved`,value:e}),g.current=!!(_.current&&JSON.stringify(_.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError]),validate:e=>{let n=He(e);return n?t.invalidValue.replace(`{{field}}`,te(n)):null}});if(!e||!y)return r?(0,X.jsx)(q,{children:(0,X.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,X.jsx)(H,{className:`h-5 w-48`}),(0,X.jsx)(H,{className:`h-20 w-full rounded-xl`}),(0,X.jsx)(H,{className:`h-36 w-full rounded-xl`})]})}):null;let w=Xe(y),T=Math.max(0,Ge-y.reserveTokens),E=Math.min(Math.floor(Ge*y.triggerThreshold),T),D=Math.min(100,E/Ge*100),O=Math.min(100,T/Ge*100),k=y.model?i.find(e=>e.id===y.model):void 0,A=k?.contextWindow&&y.summaryChunkTokens+y.summaryMaxTokens+4096>k.contextWindow,j=y.keepRecentTokens+y.reserveTokens>E,M=Math.round(y.summaryTimeoutMs*(y.summaryRetries+1)/1e3),I=e=>{let t=Ke[e];S({...t,...y.model?{model:y.model}:{model:void 0},postCompactionSections:y.postCompactionSections})},L={balanced:{title:t.presetBalanced,hint:t.presetBalancedHint},preserve:{title:t.presetPreserve,hint:t.presetPreserveHint},early:{title:t.presetEarly,hint:t.presetEarlyHint}},V=()=>{let e=l.trim();!e||y.postCompactionSections.includes(e)||y.postCompactionSections.length>=12||(S({postCompactionSections:[...y.postCompactionSections,e]}),f(``))};return(0,X.jsxs)(q,{onBlurCapture:C.onBlurCapture,children:[(0,X.jsx)(Te,{icon:u,title:t.title,subtitle:t.hint,trailing:(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(J,{status:C.status,error:C.error}),(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm font-medium text-fg`,children:[(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:y.enabled,onChange:e=>S({enabled:e.target.checked})}),y.enabled?t.enabled:t.disabled]})]})}),C.error?(0,X.jsx)(`p`,{className:`mb-4 rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700 dark:bg-red-950/40 dark:text-red-300`,role:`alert`,children:C.error}):null,y.enabled?null:(0,X.jsx)(`p`,{className:`mb-4 rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.disabledWarning}),(0,X.jsxs)(`fieldset`,{disabled:!y.enabled,className:`space-y-5 disabled:opacity-60`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.presetTitle}),(0,X.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.presetHint})]}),w===`custom`?(0,X.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:t.presetCustom}):null]}),(0,X.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[`balanced`,`preserve`,`early`].map(e=>(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":w===e,className:h(`rounded-xl bg-surface-base/55 px-3 py-3 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,F.transition,F.focusRingPanel,w===e?`bg-accent-soft text-accent-fg shadow-surface`:`text-fg hover:bg-surface-hover`),onClick:()=>I(e),children:[(0,X.jsx)(`span`,{className:`block text-sm font-medium`,children:L[e].title}),(0,X.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:L[e].hint})]},e))})]}),(0,X.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.budgetPreview}),(0,X.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.budgetPreviewHint})]}),(0,X.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2.5 py-1 font-mono text-xs text-fg-muted`,children:t.previewModel128k})]}),(0,X.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,X.jsx)(`span`,{children:t.compactionTrigger}),(0,X.jsx)(`span`,{className:`font-mono text-fg`,children:Ze(E)})]}),(0,X.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,X.jsx)(`div`,{className:`h-full rounded-full bg-accent`,style:{width:`${D}%`}})})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,X.jsx)(`span`,{children:t.hardInputLimit}),(0,X.jsx)(`span`,{className:`font-mono text-fg`,children:Ze(T)})]}),(0,X.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,X.jsx)(`div`,{className:`h-full rounded-full bg-fg-subtle`,style:{width:`${O}%`}})})]})]}),(0,X.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:t.budgetFormula})]}),(0,X.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,X.jsx)($,{id:`compaction-trigger-threshold`,label:t.triggerThreshold,hint:t.triggerThresholdHint,value:Number((y.triggerThreshold*100).toFixed(2)),min:10,max:98,step:.1,onChange:e=>S({triggerThreshold:e/100})}),(0,X.jsx)($,{id:`compaction-reserve-tokens`,label:t.reserveTokens,hint:t.reserveTokensHint.replace(`{{tokens}}`,Ze(y.reserveTokens)),value:y.reserveTokens,min:1024,step:1024,onChange:e=>S({reserveTokens:Math.floor(e)})}),(0,X.jsx)($,{id:`compaction-recent-turns`,label:t.recentTurnsPreserve,hint:t.recentTurnsPreserveHint,value:y.recentTurnsPreserve,min:1,max:12,onChange:e=>S({recentTurnsPreserve:Math.floor(e)})}),(0,X.jsx)($,{id:`compaction-keep-recent-tokens`,label:t.keepRecentTokens,hint:t.keepRecentTokensHint.replace(`{{tokens}}`,Ze(y.keepRecentTokens)),value:y.keepRecentTokens,min:1e3,step:1e3,onChange:e=>S({keepRecentTokens:Math.floor(e)})})]}),j?(0,X.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.retentionWarning}):null,(0,X.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.summaryModel}),(0,X.jsxs)(`div`,{className:`flex min-w-0 gap-2`,children:[(0,X.jsx)(de,{value:y.model??``,disabled:!y.enabled,placeholder:t.summaryModelInherited,searchPlaceholder:t.summaryModelSearch,noMatches:t.summaryModelNoMatches,models:i,modelsLoading:a,className:`min-w-0 flex-1 justify-between`,contentAlign:`start`,showProviderSettingsFooter:!0,onChange:e=>S({model:e})}),y.model?(0,X.jsx)(P,{type:`button`,variant:`secondary`,onClick:()=>S({model:void 0}),children:t.summaryModelUseSession}):null]}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.summaryModelHint})]}),(0,X.jsx)(Qe,{label:t.qualityGuard,hint:t.qualityGuardHint,checked:y.qualityGuard,onChange:e=>S({qualityGuard:e})}),(0,X.jsx)(Qe,{label:t.gapAudit,hint:t.gapAuditHint,checked:y.gapAudit,onChange:e=>S({gapAudit:e})})]}),y.qualityGuard?null:(0,X.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.qualityGuardWarning}),(0,X.jsx)(De,{children:(0,X.jsxs)(`div`,{className:`space-y-5 rounded-xl bg-surface-base/45 p-4`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:t.advancedTitle}),(0,X.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.advancedHint})]}),(0,X.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,X.jsx)($,{id:`compaction-min-messages`,label:t.minMessagesBeforeCompact,hint:t.minMessagesBeforeCompactHint,value:y.minMessagesBeforeCompact,min:2,onChange:e=>S({minMessagesBeforeCompact:Math.floor(e)})}),(0,X.jsx)($,{id:`compaction-max-transcript-mb`,label:t.maxActiveTranscriptMb,hint:t.maxActiveTranscriptMbHint,value:Number((y.maxActiveTranscriptBytes/1e6).toFixed(3)),min:.064,step:.1,onChange:e=>S({maxActiveTranscriptBytes:Math.max(64e3,Math.round(e*1e6))})}),(0,X.jsx)($,{id:`compaction-summary-max-tokens`,label:t.summaryMaxTokens,hint:t.summaryMaxTokensHint,value:y.summaryMaxTokens,min:256,step:256,onChange:e=>S({summaryMaxTokens:Math.floor(e)})}),(0,X.jsx)($,{id:`compaction-summary-chunk-tokens`,label:t.summaryChunkTokens,hint:t.summaryChunkTokensHint,value:y.summaryChunkTokens,min:1e3,step:1e3,onChange:e=>S({summaryChunkTokens:Math.floor(e)})}),(0,X.jsx)($,{id:`compaction-summary-timeout`,label:t.summaryTimeoutSeconds,hint:t.summaryTimeoutSecondsHint.replace(`{{seconds}}`,String(M)),value:y.summaryTimeoutMs/1e3,min:1,max:600,onChange:e=>S({summaryTimeoutMs:Math.round(e*1e3)})}),(0,X.jsx)($,{id:`compaction-summary-retries`,label:t.summaryRetries,hint:t.summaryRetriesHint,value:y.summaryRetries,min:0,max:5,onChange:e=>S({summaryRetries:Math.floor(e)})}),(0,X.jsx)($,{id:`compaction-min-tool-result-chars`,label:t.minToolResultKeepChars,hint:t.minToolResultKeepCharsHint,value:y.minToolResultKeepChars,min:200,step:100,onChange:e=>S({minToolResultKeepChars:Math.floor(e)})})]}),A?(0,X.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:t.summaryBudgetWarning}):null,(0,X.jsxs)(`div`,{className:`rounded-xl bg-surface-base/45 p-4`,children:[(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.postCompactionSections}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.postCompactionSectionsHint}),y.postCompactionSections.length>0?(0,X.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:y.postCompactionSections.map(e=>(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs text-fg`,children:[e,(0,X.jsx)(`button`,{type:`button`,className:h(`text-fg-muted hover:text-fg`,F.press),"aria-label":t.removeSection.replace(`{{section}}`,e),onClick:()=>S({postCompactionSections:y.postCompactionSections.filter(t=>t!==e)}),children:(0,X.jsx)(p,{className:`size-3.5`,"aria-hidden":!0})})]},e))}):(0,X.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.postCompactionSectionsEmpty}),(0,X.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,X.jsx)(`input`,{className:Je(),value:l,maxLength:120,disabled:y.postCompactionSections.length>=12,placeholder:t.postCompactionSectionsPlaceholder,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),V())}}),(0,X.jsxs)(P,{type:`button`,variant:`secondary`,disabled:!l.trim()||y.postCompactionSections.length>=12,onClick:V,children:[(0,X.jsx)(d,{className:`size-4`,"aria-hidden":!0}),t.addSection]})]})]})]})})]})]})}function et(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function tt(e){return e===`main`||e===`per-peer`||e===`per-channel-peer`||e===`per-account-channel-peer`?e:`main`}function nt(e){let t=et(e)?e:{},n=et(t.session)?t.session:{},r=et(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:tt(n.dmScope),pruneAfterDays:i,maxEntries:a}}async function rt(e){await g(v(`/api/config`),{method:`PATCH`,body:JSON.stringify({session:{dmScope:e.dmScope,storage:{pruneAfterMs:e.pruneAfterDays===null?null:e.pruneAfterDays*864e5,maxEntries:e.maxEntries}}})}),L()}function it(){return h(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,V,`dark:border-edge`)}var at=W();function ot({hasToken:e}){let t=m(ee(e=>e.language)).sessions.config,{data:n,isLoading:r}=R(e),i=(0,Y.useMemo)(()=>n?.payload?.config===void 0?null:nt(n.payload.config),[n]),[s,c]=(0,Y.useReducer)(at,{form:null,baseline:null}),l=s.form,u=s.baseline,d=(0,Y.useRef)(!1),f=(0,Y.useRef)(l);f.current=l;let p=(0,Y.useRef)(null);U({enabled:e,parsed:i,dirty:d.current,trackedParsedRef:p,dispatch:c,onResetDirty:()=>{d.current=!1}});let h=!!(l&&u&&JSON.stringify(l)!==JSON.stringify(u)),g=(0,Y.useCallback)(e=>{d.current=!0,c({type:`patch`,patch:e})},[]),_=Ee({value:l,dirty:h,onSave:(0,Y.useCallback)(async e=>{try{await rt(e),c({type:`saved`,value:e}),d.current=!!(f.current&&JSON.stringify(f.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])});return!e||!l?r?(0,X.jsx)(q,{children:(0,X.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,X.jsx)(H,{className:`h-5 w-40`}),(0,X.jsx)(H,{className:`h-24 w-full rounded-xl`})]})}):null:(0,X.jsxs)(q,{onBlurCapture:_.onBlurCapture,children:[(0,X.jsx)(Te,{icon:pe,title:t.title,subtitle:t.hint,trailing:(0,X.jsx)(J,{status:_.status,error:_.error})}),(0,X.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.dmScope}),(0,X.jsxs)(a,{className:it(),value:l.dmScope,onChange:e=>g({dmScope:e.target.value}),children:[(0,X.jsx)(o,{value:`main`,children:t.dmScopeMain}),(0,X.jsx)(o,{value:`per-peer`,children:t.dmScopePerPeer}),(0,X.jsx)(o,{value:`per-channel-peer`,children:t.dmScopePerChannelPeer}),(0,X.jsx)(o,{value:`per-account-channel-peer`,children:t.dmScopePerAccountChannelPeer})]}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.dmScopeHint})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.pruneAfterDays}),(0,X.jsx)(`input`,{type:`number`,min:0,className:it(),value:l.pruneAfterDays??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();g({pruneAfterDays:t===``?null:Math.max(0,Math.floor(Number(t)||0))})}})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.maxEntries}),(0,X.jsx)(`input`,{type:`number`,min:1,className:it(),value:l.maxEntries??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();g({maxEntries:t===``?null:Math.max(1,Math.floor(Number(t)||1))})}})]})]})]})}function st(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 ct(e){let t=(0,Oe.c)(60),{open:n,loading:r,session:i,sessionAgentId:a,sessionAgentAvatar:o,labels:s,onClose:c,onArchive:l,onUnarchive:u,onPin:d,onUnpin:f,onExport:m,onDelete:g}=e,_=i?.status===`archived`,ee=i?.status===`pinned`,v;t[0]===c?v=t[1]:(v=e=>!e&&c(),t[0]=c,t[1]=v);let w;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,X.jsx)(y,{className:h(`xopc-dialog-overlay fixed inset-0 bg-scrim`,re)}),t[2]=w):w=t[2];let T;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(T=h(`xopc-drawer-right fixed right-0 top-0 flex size-full max-w-lg flex-col border-l border-edge bg-surface-overlay shadow-popover outline-none`,ne,`dark:border-edge`),t[3]=T):T=t[3];let E;t[4]!==i||t[5]!==o||t[6]!==a?(E=i&&a?(0,X.jsx)(oe,{agentId:a,avatar:o,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}):null,t[4]=i,t[5]=o,t[6]=a,t[7]=E):E=t[7];let D;t[8]!==s.unnamedSession||t[9]!==i?.name?(D=i?.name?.trim()||s.unnamedSession,t[8]=s.unnamedSession,t[9]=i?.name,t[10]=D):D=t[10];let O;t[11]===D?O=t[12]:(O=(0,X.jsx)(te,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:D}),t[11]=D,t[12]=O);let k;t[13]!==E||t[14]!==O?(k=(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[E,O]}),t[13]=E,t[14]=O,t[15]=k):k=t[15];let A;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,X.jsx)(p,{className:`size-5`,strokeWidth:1.75}),t[16]=A):A=t[16];let j;t[17]===s.close?j=t[18]:(j=(0,X.jsx)(b,{asChild:!0,children:(0,X.jsx)(P,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":s.close,children:A})}),t[17]=s.close,t[18]=j);let M;t[19]!==k||t[20]!==j?(M=(0,X.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:[k,j]}),t[19]=k,t[20]=j,t[21]=M):M=t[21];let N;t[22]!==s.detailLoading||t[23]!==s.detailMessages||t[24]!==r||t[25]!==i?(N=r?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:s.detailLoading}):i?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`dl`,{className:`mb-4 grid gap-2 text-xs text-fg-muted`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-fg-disabled`,children:`Key`}),(0,X.jsx)(`dd`,{className:`mt-0.5 break-all font-mono text-fg`,children:i.key})]}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-4`,children:(0,X.jsxs)(`span`,{children:[i.messageCount,` msgs · `,i.estimatedTokens,` tok`]})})]}),(0,X.jsx)(`h3`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:s.detailMessages}),(0,X.jsx)(`ul`,{className:`space-y-3`,children:i.messages.map(lt)})]}):null,t[22]=s.detailLoading,t[23]=s.detailMessages,t[24]=r,t[25]=i,t[26]=N):N=t[26];let F;t[27]===N?F=t[28]:(F=(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:N}),t[27]=N,t[28]=F);let I;t[29]!==s.detailExport||t[30]!==m?(I=(0,X.jsx)(P,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:m,children:s.detailExport}),t[29]=s.detailExport,t[30]=m,t[31]=I):I=t[31];let L;t[32]!==_||t[33]!==s.archive||t[34]!==s.unarchive||t[35]!==l||t[36]!==u?(L=_?(0,X.jsx)(P,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:u,children:s.unarchive}):(0,X.jsx)(P,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:l,children:s.archive}),t[32]=_,t[33]=s.archive,t[34]=s.unarchive,t[35]=l,t[36]=u,t[37]=L):L=t[37];let R;t[38]!==ee||t[39]!==s.pin||t[40]!==s.unpin||t[41]!==d||t[42]!==f?(R=ee?(0,X.jsx)(P,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:f,children:s.unpin}):(0,X.jsx)(P,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:d,children:s.pin}),t[38]=ee,t[39]=s.pin,t[40]=s.unpin,t[41]=d,t[42]=f,t[43]=R):R=t[43];let z;t[44]!==s.delete||t[45]!==g?(z=(0,X.jsx)(P,{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:g,children:s.delete}),t[44]=s.delete,t[45]=g,t[46]=z):z=t[46];let B;t[47]!==I||t[48]!==L||t[49]!==R||t[50]!==z?(B=(0,X.jsx)(`div`,{className:`shrink-0 border-t border-edge px-4 py-3 dark:border-edge`,children:(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[I,L,R,z]})}),t[47]=I,t[48]=L,t[49]=R,t[50]=z,t[51]=B):B=t[51];let V;t[52]!==M||t[53]!==F||t[54]!==B?(V=(0,X.jsxs)(x,{children:[w,(0,X.jsxs)(S,{className:T,"aria-describedby":void 0,children:[M,F,B]})]}),t[52]=M,t[53]=F,t[54]=B,t[55]=V):V=t[55];let H;return t[56]!==n||t[57]!==v||t[58]!==V?(H=(0,X.jsx)(C,{open:n,onOpenChange:v,children:V}),t[56]=n,t[57]=v,t[58]=V,t[59]=H):H=t[59],H}function lt(e){return(0,X.jsxs)(`li`,{className:`rounded-lg border border-edge-subtle bg-surface-hover/50 p-2 dark:border-edge`,children:[(0,X.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase text-fg-subtle`,children:e.role}),(0,X.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-fg-muted`,children:st(e.content)})]},`${e.timestamp??``}-${e.role}-${st(e.content).slice(0,24)}`)}var ut=20;function dt(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}var ft=new Set([`all`,`active`,`pinned`,`archived`]),pt=new Set([`grid`,`list`]),mt=[`sessions`,`settings`];function ht(e){return e&&mt.includes(e)?e:`sessions`}function gt(e,t){return t===`sessions`?e.tabsSessions:e.tabsSettings}function _t(e,t){return t===`sessions`?e.tabsSessionsHint:e.tabsSettingsHint}function vt(e){let t=(0,Oe.c)(7),{s:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=mt.map(e=>({id:e,label:gt(n,e),icon:e===`sessions`?ye:G})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==n.tabsAriaLabel?(s=(0,X.jsx)(Se,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`sessions-tab`,panelIdPrefix:`sessions-panel`}),t[2]=r,t[3]=o,t[4]=i,t[5]=n.tabsAriaLabel,t[6]=s):s=t[6],s}function yt(e){let t=(0,Oe.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-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,d;t[0]!==o||t[1]!==r||t[2]!==s||t[3]!==n?(d=s?o:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`mb-5`,children:[(0,X.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:gt(n,r)}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:_t(n,r)})]}),(0,X.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,X.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 bt(e){let t=e.get(`status`),n=e.get(`view`);return{searchInput:e.get(`q`)??``,debouncedSearch:(e.get(`q`)??``).trim(),statusFilter:ft.has(t)?t:`all`,viewMode:pt.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 xt(){let e=m(ee(e=>e.language)),t=e.sessions,n=_(e=>e.conversationId),r=!!n,{data:a,mutate:o}=N(r?[`gateway-chat-agents`,n]:null,_e,{revalidateOnFocus:!1}),s=a?.defaultId??`main`,l=a?.items??[],[u,d]=i(),p=ht(u.get(`tab`)),g=(0,Y.useCallback)(e=>{let t=new URLSearchParams(u);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),d(t,{replace:!0})},[u,d]),[v,b]=(0,Y.useReducer)(ie,u,bt),{searchInput:I,debouncedSearch:L,statusFilter:R,viewMode:z,channelFilter:B,sessions:V,loading:H,error:U,hasMore:W,stats:G,detailOpen:ae,detailLoading:oe,detailSession:K,confirmOpen:de,confirmKey:fe}=v;(0,Y.useEffect)(()=>{let e=setTimeout(()=>{let e=I.trim();L!==e&&b({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[I,L]);let pe=u.toString(),he=(0,Y.useRef)(pe);if(he.current!==pe){he.current=pe;let e=u.get(`q`)??``,t=u.get(`status`),n=u.get(`view`),r=(u.get(`channel`)??``).trim(),i=ft.has(t)?t:`all`,a=pt.has(n)?n:`grid`,o=e.trim();b({type:`patch`,patch:{...I===e?{}:{searchInput:e},...L===o?{}:{debouncedSearch:o},...R===i?{}:{statusFilter:i},...z===a?{}:{viewMode:a},...B===r?{}:{channelFilter:r}}})}(0,Y.useEffect)(()=>{let e=new URLSearchParams(u),t=L.trim();t?e.set(`q`,t):e.delete(`q`),R===`all`?e.delete(`status`):e.set(`status`,R),z===`grid`?e.delete(`view`):e.set(`view`,z),B?e.set(`channel`,B):e.delete(`channel`),e.toString()!==u.toString()&&d(e,{replace:!0})},[L,u,d,R,z,B]),(0,Y.useEffect)(()=>{if(!r||p!==`sessions`)return;let e=!1;return(async()=>{b({type:`patch`,patch:{loading:!0,error:null}});try{let t=await j({limit:ut,offset:0,...L?{search:L}:{},...R===`all`?{}:{status:R},...B?{channel:B}:{}});if(e)return;b({type:`patch`,patch:{sessions:t.items,hasMore:t.hasMore}})}catch(n){e||b({type:`patch`,patch:{error:n instanceof Error?n.message:t.loadError}})}finally{e||b({type:`patch`,patch:{loading:!1}})}})(),()=>{e=!0}},[r,p,L,R,B,t.loadError]),(0,Y.useEffect)(()=>{!r||p!==`sessions`||O().then(e=>b({type:`patch`,patch:{stats:e}})).catch(()=>{})},[r,p]),(0,Y.useEffect)(()=>{if(!r||p!==`sessions`)return;let e=()=>void o();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[r,p,o]),(0,Y.useEffect)(()=>{if(!r||p!==`sessions`)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||b({type:`patch`,patch:{sessions:V.map(e=>e.key===t.key?{...e,name:t.name}:e),detailSession:K&&K.key===t.key?{...K,name:t.name}:K}})};return window.addEventListener(`session-updated`,e),()=>{window.removeEventListener(`session-updated`,e)}},[r,p,V,K]);let ge=(0,Y.useCallback)(async()=>{if(!(!r||H||!W)){b({type:`patch`,patch:{loading:!0,error:null}});try{let e=await j({limit:ut,offset:V.length,...L?{search:L}:{},...R===`all`?{}:{status:R},...B?{channel:B}:{}});b({type:`patch`,patch:{sessions:[...V,...e.items],hasMore:e.hasMore}})}catch(e){b({type:`patch`,patch:{error:e instanceof Error?e.message:t.loadError}})}finally{b({type:`patch`,patch:{loading:!1}})}}},[r,H,W,V.length,L,R,B,t.loadError]),ve=(0,Y.useCallback)((e,t)=>{b({type:`patch`,patch:{sessions:V.map(n=>n.key===e?{...n,status:t}:n),detailSession:K&&K.key===e?{...K,status:t}:K}})},[V,K]),Se=(0,Y.useCallback)(async e=>{b({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{b({type:`patch`,patch:{detailSession:await w(e)}})}catch{b({type:`patch`,patch:{detailOpen:!1}})}finally{b({type:`patch`,patch:{detailLoading:!1}})}},[]),Te=e=>{Se(e)},q=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:e},bubbles:!0}));return}if(t===`delete`){b({type:`patch`,patch:{confirmKey:e,confirmOpen:!0}});return}try{switch(t){case`archive`:await M(e),ve(e,`archived`);break;case`unarchive`:await E(e),ve(e,`active`);break;case`pin`:await T(e),ve(e,`pinned`);break;case`unpin`:await k(e),ve(e,`active`);break;case`export`:{let t=await A(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}O().then(e=>b({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},J=async e=>{try{await D(e),b({type:`patch`,patch:{sessions:V.filter(t=>t.key!==e),detailSession:K?.key===e?null:K,...K?.key===e?{detailOpen:!1}:{}}}),O().then(e=>b({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Ee={continueChat:t.continueChat,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,export:t.export,delete:t.delete,tokens:t.tokens,cost:t.cost,costPartial:t.costPartial,costUnknown:t.costUnknown,noUsage:t.noUsage,unnamedSession:e.chat.newSession},De={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},Oe=[{key:`all`,label:t.filterAll,icon:ye},{key:`active`,label:t.filterActive,icon:me},{key:`pinned`,label:t.filterPinned,icon:ce},{key:`archived`,label:t.filterArchived,icon:se}],ke=(()=>{let e=Object.entries(G?.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,X.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-surface-panel`,children:[(0,X.jsxs)(we,{gap:`gap-6`,children:[(0,X.jsx)(Ce,{title:t.title}),(0,X.jsx)(vt,{s:t,activeTab:p,onChange:g}),(0,X.jsx)(yt,{s:t,id:`settings`,activeTab:p,plain:!0,children:(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)($e,{hasToken:r}),(0,X.jsx)(ot,{hasToken:r})]})}),(0,X.jsxs)(yt,{s:t,id:`sessions`,activeTab:p,plain:!0,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Oe.map(({key:e,label:t,icon:n})=>(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":R===e,onClick:()=>b({type:`patch`,patch:{statusFilter:e}}),className:h(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,F.transition,F.focusRingPanel,R===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,X.jsx)(n,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t]},e))}),(0,X.jsxs)(`div`,{className:`flex min-h-11 w-full min-w-0 items-center gap-2 rounded-xl bg-surface-base focus-within:ring-2 focus-within:ring-accent px-3 py-2 transition-colors lg:max-w-md dark:bg-surface-hover/40`,children:[(0,X.jsx)(f,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,X.jsx)(`input`,{type:`search`,value:I,onChange:e=>b({type:`patch`,patch:{searchInput:e.target.value}}),placeholder:t.searchPlaceholder,"aria-label":t.searchPlaceholder,"data-debounced-query":L||void 0,className:`min-w-0 flex-1 border-0 bg-transparent text-base sm:text-sm text-fg placeholder:text-fg-disabled focus:outline-none focus:ring-0`})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`text-xs font-medium text-fg-subtle`,children:t.filterChannelLabel}),(0,X.jsx)(`button`,{type:`button`,"aria-pressed":!B,onClick:()=>b({type:`patch`,patch:{channelFilter:``}}),className:h(`touch-target inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,F.transition,F.focusRingPanel,B?`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}),ke.map(e=>(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":B===e,onClick:()=>b({type:`patch`,patch:{channelFilter:e}}),className:h(`touch-target inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,F.transition,F.focusRingPanel,B===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,G?.byChannel?.[e]==null?null:(0,X.jsx)(`span`,{className:`ml-2 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] text-fg-subtle`,children:G.byChannel[e]})]},e))]}),G?(0,X.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[[G.totalSessions,t.totalSessions],[G.activeSessions,t.activeSessions],[G.pinnedSessions,t.pinnedSessions],[G.archivedSessions,t.archivedSessions]].map(([e,t])=>(0,X.jsxs)(`div`,{className:`rounded-xl bg-surface-base p-3 dark:bg-surface-hover/30`,children:[(0,X.jsx)(`div`,{className:`text-lg font-semibold tabular-nums text-fg`,children:e}),(0,X.jsx)(`div`,{className:`text-xs text-fg-muted`,children:t})]},t))}):null,U?(0,X.jsx)(`div`,{className:`rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700 dark:bg-red-950/40 dark:text-red-300`,children:U}):null,(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:dt(t.sessionCount,{count:V.length})}),(0,X.jsxs)(`div`,{className:xe,role:`group`,"aria-label":t.layoutToggleGroup,children:[(0,X.jsx)(P,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":z===`grid`,onClick:()=>b({type:`patch`,patch:{viewMode:`grid`}}),className:h(le,`size-7 p-0`,z===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,z===`grid`&&`text-accent-fg`),children:(0,X.jsx)(ue,{className:`size-3.5`,strokeWidth:1.5})}),(0,X.jsx)(P,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":z===`list`,onClick:()=>b({type:`patch`,patch:{viewMode:`list`}}),className:h(le,`size-9 p-0`,z===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,z===`list`&&`text-accent-fg`),children:(0,X.jsx)(be,{className:`size-3.5`,strokeWidth:1.5})})]})]}),H&&V.length===0?(0,X.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,X.jsx)(`div`,{className:`h-40 animate-pulse rounded-xl bg-surface-hover/60 dark:bg-surface-hover/40`},t))}):V.length===0?(0,X.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,X.jsx)(c,{className:`mb-3 size-12 text-fg-disabled`,strokeWidth:1.25,"aria-hidden":!0}),(0,X.jsx)(`p`,{className:`text-base font-semibold text-fg`,children:t.noSessions}),(0,X.jsx)(`p`,{className:`mt-1 max-w-sm text-sm text-fg-muted`,children:t.noSessionsDescription}),(0,X.jsx)(P,{variant:`primary`,className:`mt-6`,onClick:()=>{window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:``},bubbles:!0}))},children:t.startNewChat})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:h(`grid min-w-0 gap-3`,z===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":L||void 0,children:V.map(e=>{let t=Le(e,s);return(0,X.jsx)(Me,{session:e,variant:z,labels:Ee,sessionAgentId:t,sessionAgentAvatar:Re(t,l),onOpen:()=>Te(e.key),onAction:t=>void q(e.key,t)},e.key)})}),W?(0,X.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,X.jsx)(P,{type:`button`,variant:`secondary`,disabled:H,onClick:()=>void ge(),children:t.loadMore})}):null]})]})]}),(0,X.jsx)(ct,{open:ae,loading:oe,session:K,sessionAgentId:K?Le(K,s):void 0,sessionAgentAvatar:K?Re(Le(K,s),l):void 0,labels:De,onClose:()=>{b({type:`patch`,patch:{detailOpen:!1,detailSession:null}})},onArchive:()=>K&&void q(K.key,`archive`),onUnarchive:()=>K&&void q(K.key,`unarchive`),onPin:()=>K&&void q(K.key,`pin`),onUnpin:()=>K&&void q(K.key,`unpin`),onExport:()=>K&&void q(K.key,`export`),onDelete:()=>K&&b({type:`patch`,patch:{confirmKey:K.key,confirmOpen:!0}})}),(0,X.jsx)(C,{open:de,onOpenChange:e=>b({type:`patch`,patch:{confirmOpen:e}}),children:(0,X.jsxs)(x,{children:[(0,X.jsx)(y,{className:h(`xopc-dialog-overlay fixed inset-0 bg-scrim`,re)}),(0,X.jsxs)(S,{className:h(`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-overlay p-4 shadow-popover dark:border-edge`,ne),children:[(0,X.jsx)(te,{className:`text-base font-semibold text-fg`,children:t.deleteSessionTitle}),(0,X.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:fe?dt(t.deleteSessionMessage,{name:V.find(e=>e.key===fe)?.name?.trim()||e.chat.newSession}):``}),(0,X.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,X.jsx)(P,{type:`button`,variant:`secondary`,onClick:()=>b({type:`patch`,patch:{confirmOpen:!1}}),children:t.cancel}),(0,X.jsx)(P,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{fe&&J(fe),b({type:`patch`,patch:{confirmOpen:!1,confirmKey:null}})},children:t.delete})]})]})]})})]}):(0,X.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{xt as SessionsPage};
@@ -1 +0,0 @@
1
- import{mn as e}from"./index-BXrBL_Hb.js";function t(t){let{children:n,fallback:r}=t,i=r===void 0?null:r;return e()?n:i}export{t};