@hualinge/relay-web 1.0.0

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 (332) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +31 -0
  3. package/dist/assets/AgentsPage-2u2kFBCH.js +68 -0
  4. package/dist/assets/AgentsPage-2u2kFBCH.js.map +1 -0
  5. package/dist/assets/AgentsPage-BGbbVmeL.css +1 -0
  6. package/dist/assets/Alert-D88Fk6to.js +2 -0
  7. package/dist/assets/Alert-D88Fk6to.js.map +1 -0
  8. package/dist/assets/AppModal-BYZTSuch.js +2 -0
  9. package/dist/assets/AppModal-BYZTSuch.js.map +1 -0
  10. package/dist/assets/CenteredLoadingState-DHor-9vF.js +2 -0
  11. package/dist/assets/CenteredLoadingState-DHor-9vF.js.map +1 -0
  12. package/dist/assets/ChannelsPage-CbI0kqkd.js +2 -0
  13. package/dist/assets/ChannelsPage-CbI0kqkd.js.map +1 -0
  14. package/dist/assets/EmptyDataState-6mNx2Xhl.js +2 -0
  15. package/dist/assets/EmptyDataState-6mNx2Xhl.js.map +1 -0
  16. package/dist/assets/HelpPrompt-BPzDcC8F.js +2 -0
  17. package/dist/assets/HelpPrompt-BPzDcC8F.js.map +1 -0
  18. package/dist/assets/HomePage-t78sDDUj.js +2 -0
  19. package/dist/assets/HomePage-t78sDDUj.js.map +1 -0
  20. package/dist/assets/InspirationPage-BTqLpcHY.js +3 -0
  21. package/dist/assets/InspirationPage-BTqLpcHY.js.map +1 -0
  22. package/dist/assets/ModelsPage-YF0gpUxy.js +2 -0
  23. package/dist/assets/ModelsPage-YF0gpUxy.js.map +1 -0
  24. package/dist/assets/NameInitialIcon-DP-6_HQY.js +7 -0
  25. package/dist/assets/NameInitialIcon-DP-6_HQY.js.map +1 -0
  26. package/dist/assets/NoSearchResultsState-BiiYdZ_Z.js +2 -0
  27. package/dist/assets/NoSearchResultsState-BiiYdZ_Z.js.map +1 -0
  28. package/dist/assets/OverflowTooltip-CE5PjAb-.js +2 -0
  29. package/dist/assets/OverflowTooltip-CE5PjAb-.js.map +1 -0
  30. package/dist/assets/PasswordField-DmzjtnCg.js +2 -0
  31. package/dist/assets/PasswordField-DmzjtnCg.js.map +1 -0
  32. package/dist/assets/RefreshButton-BzYzeo5A.js +2 -0
  33. package/dist/assets/RefreshButton-BzYzeo5A.js.map +1 -0
  34. package/dist/assets/RightContentHeader-DoNDQ9Lo.js +3 -0
  35. package/dist/assets/RightContentHeader-DoNDQ9Lo.js.map +1 -0
  36. package/dist/assets/SchedulePage-CfW6lZVI.js +2 -0
  37. package/dist/assets/SchedulePage-CfW6lZVI.js.map +1 -0
  38. package/dist/assets/SearchInput-tux8xXH1.js +2 -0
  39. package/dist/assets/SearchInput-tux8xXH1.js.map +1 -0
  40. package/dist/assets/SkillAvatar-DwGvsY4f.js +2 -0
  41. package/dist/assets/SkillAvatar-DwGvsY4f.js.map +1 -0
  42. package/dist/assets/SkillsPage-ppqwKMvj.js +2 -0
  43. package/dist/assets/SkillsPage-ppqwKMvj.js.map +1 -0
  44. package/dist/assets/SkillsTab-c_As1DIr.css +1 -0
  45. package/dist/assets/SkillsTab-kY7MNdxy.js +2 -0
  46. package/dist/assets/SkillsTab-kY7MNdxy.js.map +1 -0
  47. package/dist/assets/Tab-FE0F2EQP.js +2 -0
  48. package/dist/assets/Tab-FE0F2EQP.js.map +1 -0
  49. package/dist/assets/ThreadPage-B0jElW5R.js +53 -0
  50. package/dist/assets/ThreadPage-B0jElW5R.js.map +1 -0
  51. package/dist/assets/UploadSkillModal-DHZL12vm.js +8 -0
  52. package/dist/assets/UploadSkillModal-DHZL12vm.js.map +1 -0
  53. package/dist/assets/XlsxDocumentPreview-BY-ht09K.js +5 -0
  54. package/dist/assets/XlsxDocumentPreview-BY-ht09K.js.map +1 -0
  55. package/dist/assets/_commonjs-dynamic-modules-TDtrdbi3.js +2 -0
  56. package/dist/assets/_commonjs-dynamic-modules-TDtrdbi3.js.map +1 -0
  57. package/dist/assets/chat-input-options-CpkOtPgQ.js +2 -0
  58. package/dist/assets/chat-input-options-CpkOtPgQ.js.map +1 -0
  59. package/dist/assets/docx-preview-zfB-orwa.js +28 -0
  60. package/dist/assets/docx-preview-zfB-orwa.js.map +1 -0
  61. package/dist/assets/exceljs.min-BY7KKJsM.js +58 -0
  62. package/dist/assets/exceljs.min-BY7KKJsM.js.map +1 -0
  63. package/dist/assets/helpers-CCilgpNy.js +2 -0
  64. package/dist/assets/helpers-CCilgpNy.js.map +1 -0
  65. package/dist/assets/hub-agent-editor.client-2DmCRGuY.js +2 -0
  66. package/dist/assets/hub-agent-editor.client-2DmCRGuY.js.map +1 -0
  67. package/dist/assets/hub-agent-editor.payload-D4sgJRSH.js +4 -0
  68. package/dist/assets/hub-agent-editor.payload-D4sgJRSH.js.map +1 -0
  69. package/dist/assets/hub-tag-editor-BBdd-aHK.js +2 -0
  70. package/dist/assets/hub-tag-editor-BBdd-aHK.js.map +1 -0
  71. package/dist/assets/index-Bed0I5IL.css +1 -0
  72. package/dist/assets/index-Bxf2_cvh.js +2 -0
  73. package/dist/assets/index-Bxf2_cvh.js.map +1 -0
  74. package/dist/assets/index-Cb4fQgom.js +103 -0
  75. package/dist/assets/index-Cb4fQgom.js.map +1 -0
  76. package/dist/assets/index-DQ2vVjmV.js +30 -0
  77. package/dist/assets/index-DQ2vVjmV.js.map +1 -0
  78. package/dist/assets/index-UBJEdbMO.js +2 -0
  79. package/dist/assets/index-UBJEdbMO.js.map +1 -0
  80. package/dist/assets/jszip.min-DPdj3o0t.js +13 -0
  81. package/dist/assets/jszip.min-DPdj3o0t.js.map +1 -0
  82. package/dist/assets/quick-actions-DzZE-zyP.js +2 -0
  83. package/dist/assets/quick-actions-DzZE-zyP.js.map +1 -0
  84. package/dist/assets/skill-options-cache-D1BJGTCU.js +2 -0
  85. package/dist/assets/skill-options-cache-D1BJGTCU.js.map +1 -0
  86. package/dist/assets/status-helpers-BILdm2MI.js +2 -0
  87. package/dist/assets/status-helpers-BILdm2MI.js.map +1 -0
  88. package/dist/assets/thread-title-Cerb2mHa.js +2 -0
  89. package/dist/assets/thread-title-Cerb2mHa.js.map +1 -0
  90. package/dist/assets/thread-utils-Ct3yp4R3.js +2 -0
  91. package/dist/assets/thread-utils-Ct3yp4R3.js.map +1 -0
  92. package/dist/assets/useAgentData-D-k9cXfg.js +2 -0
  93. package/dist/assets/useAgentData-D-k9cXfg.js.map +1 -0
  94. package/dist/assets/useEscapeKey-CEQ6-8GR.js +2 -0
  95. package/dist/assets/useEscapeKey-CEQ6-8GR.js.map +1 -0
  96. package/dist/assets/useExpertCatalog-BZdw1CYs.js +2 -0
  97. package/dist/assets/useExpertCatalog-BZdw1CYs.js.map +1 -0
  98. package/dist/assets/usePromptBlocks-5sz8Qh51.js +2 -0
  99. package/dist/assets/usePromptBlocks-5sz8Qh51.js.map +1 -0
  100. package/dist/assets/useSocket-YigidotN.css +1 -0
  101. package/dist/assets/useSocket-y3-zWhVL.js +11 -0
  102. package/dist/assets/useSocket-y3-zWhVL.js.map +1 -0
  103. package/dist/assets/utils--_pbLpCq.js +2 -0
  104. package/dist/assets/utils--_pbLpCq.js.map +1 -0
  105. package/dist/assets/vad-web-C_R267y1.js +2 -0
  106. package/dist/assets/vad-web-C_R267y1.js.map +1 -0
  107. package/dist/avatars/agent-avatar-1.png +0 -0
  108. package/dist/avatars/agent-avatar-2.png +0 -0
  109. package/dist/avatars/agent-avatar-3.png +0 -0
  110. package/dist/avatars/agent-avatar-4.png +0 -0
  111. package/dist/avatars/agent-avatar-5.png +0 -0
  112. package/dist/avatars/agent-avatar-6.png +0 -0
  113. package/dist/avatars/agent-avatar-7.png +0 -0
  114. package/dist/avatars/agent-avatar-8.png +0 -0
  115. package/dist/avatars/agent-avatar-9.png +0 -0
  116. package/dist/avatars/agentteams.png +0 -0
  117. package/dist/avatars/antig-opus.png +0 -0
  118. package/dist/avatars/antigravity.png +0 -0
  119. package/dist/avatars/assistant.svg +17 -0
  120. package/dist/avatars/codex-kawaii.png +0 -0
  121. package/dist/avatars/codex.png +0 -0
  122. package/dist/avatars/codex_box.png +0 -0
  123. package/dist/avatars/codex_iquid.png +0 -0
  124. package/dist/avatars/dare.png +0 -0
  125. package/dist/avatars/gemini-kawaii.png +0 -0
  126. package/dist/avatars/gemini.png +0 -0
  127. package/dist/avatars/gemini25.png +0 -0
  128. package/dist/avatars/gpt52.png +0 -0
  129. package/dist/avatars/jiuwenclaw.png +0 -0
  130. package/dist/avatars/office.svg +17 -0
  131. package/dist/avatars/opencode.png +0 -0
  132. package/dist/avatars/opus-45.png +0 -0
  133. package/dist/avatars/opus-kawaii.png +0 -0
  134. package/dist/avatars/opus.png +0 -0
  135. package/dist/avatars/sonnet.png +0 -0
  136. package/dist/favicon.ico +0 -0
  137. package/dist/icons/arrow-left.svg +3 -0
  138. package/dist/icons/arrow-right.svg +3 -0
  139. package/dist/icons/attach.svg +9 -0
  140. package/dist/icons/chart/dislike.svg +3 -0
  141. package/dist/icons/chart/disliked.svg +3 -0
  142. package/dist/icons/chart/folder.svg +15 -0
  143. package/dist/icons/chart/home-loading.webp +0 -0
  144. package/dist/icons/chart/like.svg +3 -0
  145. package/dist/icons/chart/liked.svg +5 -0
  146. package/dist/icons/chart/loading.svg +26 -0
  147. package/dist/icons/chart/success.svg +7 -0
  148. package/dist/icons/check-line.svg +3 -0
  149. package/dist/icons/chevron-left.svg +3 -0
  150. package/dist/icons/chevron-right.svg +3 -0
  151. package/dist/icons/collapse.svg +14 -0
  152. package/dist/icons/common-delete.svg +4 -0
  153. package/dist/icons/common-folder.svg +4 -0
  154. package/dist/icons/copy.svg +4 -0
  155. package/dist/icons/cross-line.svg +4 -0
  156. package/dist/icons/data-analysis.svg +7 -0
  157. package/dist/icons/data-visualization.svg +10 -0
  158. package/dist/icons/deep-research.svg +4 -0
  159. package/dist/icons/document-processing.svg +5 -0
  160. package/dist/icons/edit.svg +4 -0
  161. package/dist/icons/expand.svg +6 -0
  162. package/dist/icons/expert-debate.svg +4 -0
  163. package/dist/icons/eye.svg +4 -0
  164. package/dist/icons/favicon.svg +7 -0
  165. package/dist/icons/file-docx.svg +60 -0
  166. package/dist/icons/file-folder.svg +4 -0
  167. package/dist/icons/file-gitignore.svg +35 -0
  168. package/dist/icons/file-html.svg +6 -0
  169. package/dist/icons/file-ini.svg +63 -0
  170. package/dist/icons/file-json.svg +4 -0
  171. package/dist/icons/file-md.svg +68 -0
  172. package/dist/icons/file-py.svg +4 -0
  173. package/dist/icons/file-sh.svg +7 -0
  174. package/dist/icons/file-txt.svg +37 -0
  175. package/dist/icons/file-zip.svg +21 -0
  176. package/dist/icons/file.svg +4 -0
  177. package/dist/icons/files-csv.svg +14 -0
  178. package/dist/icons/files-docx.svg +10 -0
  179. package/dist/icons/files-pdf.svg +14 -0
  180. package/dist/icons/files-ppt.svg +14 -0
  181. package/dist/icons/files-txt.svg +16 -0
  182. package/dist/icons/files-xlsx.svg +14 -0
  183. package/dist/icons/financial-services.svg +8 -0
  184. package/dist/icons/flie-html.svg +60 -0
  185. package/dist/icons/guided-mode.svg +9 -0
  186. package/dist/icons/icon-192x192.png +0 -0
  187. package/dist/icons/icon-512x512.png +0 -0
  188. package/dist/icons/icon-arrow-down.svg +4 -0
  189. package/dist/icons/icon-arrow-up.svg +4 -0
  190. package/dist/icons/icon-clear-all.svg +3 -0
  191. package/dist/icons/icon-close.svg +4 -0
  192. package/dist/icons/icon-code.svg +38 -0
  193. package/dist/icons/icon-drag-file.svg +26 -0
  194. package/dist/icons/icon-help.svg +4 -0
  195. package/dist/icons/icon-md.svg +53 -0
  196. package/dist/icons/icon-refresh.svg +4 -0
  197. package/dist/icons/icon-toggle.svg +6 -0
  198. package/dist/icons/icon-top.svg +7 -0
  199. package/dist/icons/icon-upload.svg +5 -0
  200. package/dist/icons/information.svg +6 -0
  201. package/dist/icons/inspiration/icon-excel.svg +14 -0
  202. package/dist/icons/inspiration/icon-inspiration.svg +5 -0
  203. package/dist/icons/inspiration/icon-markdown.svg +12 -0
  204. package/dist/icons/inspiration/icon-word.svg +10 -0
  205. package/dist/icons/link.svg +6 -0
  206. package/dist/icons/lock.svg +4 -0
  207. package/dist/icons/menu/agents.svg +39 -0
  208. package/dist/icons/menu/channels.svg +4 -0
  209. package/dist/icons/menu/icon-inspiration.svg +5 -0
  210. package/dist/icons/menu/models.svg +4 -0
  211. package/dist/icons/menu/new-chat.svg +59 -0
  212. package/dist/icons/menu/schedule.svg +4 -0
  213. package/dist/icons/menu/skills.svg +4 -0
  214. package/dist/icons/message-error.svg +6 -0
  215. package/dist/icons/message-prompt.svg +9 -0
  216. package/dist/icons/message-success.svg +6 -0
  217. package/dist/icons/message-warn.svg +8 -0
  218. package/dist/icons/more-trigger.svg +4 -0
  219. package/dist/icons/nss/1.svg +14 -0
  220. package/dist/icons/nss/2.svg +14 -0
  221. package/dist/icons/nss/3.svg +14 -0
  222. package/dist/icons/outline.svg +6 -0
  223. package/dist/icons/query_the_optical_power_border.svg +99 -0
  224. package/dist/icons/schedule.svg +4 -0
  225. package/dist/icons/settings-feedback/feedback-bug.svg +20 -0
  226. package/dist/icons/settings-feedback/feedback-file.svg +4 -0
  227. package/dist/icons/settings-feedback/feedback-idea.svg +14 -0
  228. package/dist/icons/settings-feedback/settings-gear.svg +4 -0
  229. package/dist/icons/settings-feedback/settings-link.svg +4 -0
  230. package/dist/icons/settings-feedback/settings-memory.svg +7 -0
  231. package/dist/icons/settings-feedback/settings-privacy.svg +37 -0
  232. package/dist/icons/settings-feedback/settings-search.svg +2 -0
  233. package/dist/icons/slides.svg +4 -0
  234. package/dist/icons/status/info-error.svg +9 -0
  235. package/dist/icons/style-template.svg +11 -0
  236. package/dist/icons/tool-error.svg +4 -0
  237. package/dist/icons/userprofile/help.svg +5 -0
  238. package/dist/icons/userprofile/keep-awake.svg +4 -0
  239. package/dist/icons/userprofile/question.svg +4 -0
  240. package/dist/icons/userprofile/security.svg +7 -0
  241. package/dist/icons/userprofile/style-template.svg +11 -0
  242. package/dist/icons/userprofile/theme.svg +14 -0
  243. package/dist/icons/userprofile/usage.svg +4 -0
  244. package/dist/icons/userprofile/version.svg +85 -0
  245. package/dist/icons/video-generation.svg +4 -0
  246. package/dist/images/OfficeClaw.svg +21 -0
  247. package/dist/images/add.svg +4 -0
  248. package/dist/images/agent-management-icons/agent-check.svg +23 -0
  249. package/dist/images/agent-management-icons/agent-close.svg +4 -0
  250. package/dist/images/agent-management-icons/agent-collab.svg +4 -0
  251. package/dist/images/agent-management-icons/agent-delete.svg +18 -0
  252. package/dist/images/agent-management-icons/agent-edit.svg +18 -0
  253. package/dist/images/agent-management-icons/agent-more.svg +4 -0
  254. package/dist/images/agent-management-icons/agent-persona.svg +4 -0
  255. package/dist/images/agent-management-icons/agent-random-avatar.svg +39 -0
  256. package/dist/images/agent-management-icons/agent-refresh.svg +4 -0
  257. package/dist/images/agent-management-icons/agent-skills.svg +4 -0
  258. package/dist/images/agent-management-icons/agent-template.svg +12 -0
  259. package/dist/images/agent-management-icons/anchor-current.svg +5 -0
  260. package/dist/images/agent-management-icons/anchor-other.svg +4 -0
  261. package/dist/images/chat-empty-agent.svg +12 -0
  262. package/dist/images/chat-empty-im.svg +14 -0
  263. package/dist/images/connectors/dingtalk.png +0 -0
  264. package/dist/images/connectors/dingtalk.svg +18 -0
  265. package/dist/images/connectors/feishu.png +0 -0
  266. package/dist/images/connectors/feishu.svg +12 -0
  267. package/dist/images/connectors/imessage.png +0 -0
  268. package/dist/images/connectors/wecom-agent.png +0 -0
  269. package/dist/images/connectors/wecom-bot.png +0 -0
  270. package/dist/images/connectors/weixin.png +0 -0
  271. package/dist/images/connectors/weixin.svg +19 -0
  272. package/dist/images/connectors/xiaoyi.png +0 -0
  273. package/dist/images/connectors/xiaoyi.svg +12 -0
  274. package/dist/images/create-agent-random-avatar.svg +39 -0
  275. package/dist/images/deepseek.svg +1 -0
  276. package/dist/images/default-ppt-template.png +0 -0
  277. package/dist/images/file-browser-tree/code.svg +60 -0
  278. package/dist/images/file-browser-tree/gitignore.svg +35 -0
  279. package/dist/images/file-browser-tree/image.svg +12 -0
  280. package/dist/images/file-browser-tree/markdown.svg +68 -0
  281. package/dist/images/file-browser-tree/pdf.svg +4 -0
  282. package/dist/images/file-browser-tree/ppt.svg +4 -0
  283. package/dist/images/file-browser-tree/public-file.svg +37 -0
  284. package/dist/images/file-browser-tree/word.svg +60 -0
  285. package/dist/images/file-browser-tree/xlsx.svg +4 -0
  286. package/dist/images/html-preview-toolbar/copy.svg +4 -0
  287. package/dist/images/html-preview-toolbar/open-external.svg +4 -0
  288. package/dist/images/html-preview-toolbar/refresh.svg +4 -0
  289. package/dist/images/information.svg +4 -0
  290. package/dist/images/inspiration/blue-bg.png +0 -0
  291. package/dist/images/inspiration/doc-example.png +0 -0
  292. package/dist/images/inspiration/excel-example.png +0 -0
  293. package/dist/images/inspiration/green-bg.png +0 -0
  294. package/dist/images/inspiration/markdown-example.png +0 -0
  295. package/dist/images/inspiration/orange-bg.png +0 -0
  296. package/dist/images/inspiration/purple-bg.png +0 -0
  297. package/dist/images/inspiration/task-bg.png +0 -0
  298. package/dist/images/inspiration-bg.png +0 -0
  299. package/dist/images/inspiration-products/default.svg +11 -0
  300. package/dist/images/invitation-background-4x.png +0 -0
  301. package/dist/images/kimi.svg +1 -0
  302. package/dist/images/link-blue.svg +4 -0
  303. package/dist/images/link.svg +4 -0
  304. package/dist/images/lobster.svg +118 -0
  305. package/dist/images/login1.svg +93 -0
  306. package/dist/images/login2.svg +80 -0
  307. package/dist/images/login3.svg +44 -0
  308. package/dist/images/login4.svg +18 -0
  309. package/dist/images/mode-default-icon.svg +22 -0
  310. package/dist/images/no-data.svg +26 -0
  311. package/dist/images/no-search-results.svg +25 -0
  312. package/dist/images/ppt-preview/placeholder-main.webp +0 -0
  313. package/dist/images/ppt-preview/placeholder-thumb.webp +0 -0
  314. package/dist/images/ppt-template/dark-tech.png +0 -0
  315. package/dist/images/ppt-template/huawei.png +0 -0
  316. package/dist/images/ppt-template/light-tech.png +0 -0
  317. package/dist/images/ppt-template/paper-humanities.png +0 -0
  318. package/dist/images/ppt-template/template-default.png +0 -0
  319. package/dist/images/ppt-template/template-error.png +0 -0
  320. package/dist/images/ppt-template/template-generate-bg.svg +9639 -0
  321. package/dist/images/qwen.svg +1 -0
  322. package/dist/images/task-list/empty-state.svg +4 -0
  323. package/dist/images/task-list.svg +1 -0
  324. package/dist/images/vendor.svg +4 -0
  325. package/dist/images/version-bg.svg +85 -0
  326. package/dist/images/version.svg +9 -0
  327. package/dist/images/zhipu.svg +1 -0
  328. package/dist/index.html +74 -0
  329. package/dist/loading-point-style.webp +0 -0
  330. package/dist/loading-small.webp +0 -0
  331. package/dist/manifest.json +25 -0
  332. package/package.json +126 -0
@@ -0,0 +1,2 @@
1
+ import{j as e,r as a,B as ce,M as me,a as Ze,t as $t,I as Dt,u as Ct,z as Ut,d as Ot,c as fe,N as Ft}from"./index-Cb4fQgom.js";import{u as Qe,f as St,e as zt,a as Vt,b as Kt}from"./useAgentData-D-k9cXfg.js";import{a as H,A as et,O as ve,d as Tt,f as Wt,g as Gt,h as Ht,c as Yt}from"./OverflowTooltip-CE5PjAb-.js";import{h as Xt,f as Jt,T as Ye,u as qt,S as Zt}from"./status-helpers-BILdm2MI.js";import{p as _e,f as Qt,g as es}from"./thread-utils-Ct3yp4R3.js";import{u as ts}from"./useExpertCatalog-BZdw1CYs.js";import{a as ss,u as Et,l as as}from"./index-UBJEdbMO.js";import{A as Te}from"./AppModal-BYZTSuch.js";import{S as ns}from"./SearchInput-tux8xXH1.js";import{u as Re}from"./useEscapeKey-CEQ6-8GR.js";import{C as At}from"./CenteredLoadingState-DHor-9vF.js";import{E as st}from"./EmptyDataState-6mNx2Xhl.js";import{R as rs}from"./RefreshButton-BzYzeo5A.js";import{A as ls}from"./Alert-D88Fk6to.js";import{P as os}from"./PasswordField-DmzjtnCg.js";import{n as is}from"./thread-title-Cerb2mHa.js";import"./Tab-FE0F2EQP.js";import"./NoSearchResultsState-BiiYdZ_Z.js";const Me="Asia/Shanghai",cs=new Intl.DateTimeFormat("en-CA",{timeZone:Me,year:"numeric",month:"2-digit",day:"2-digit"});function tt(t,s){var i,x,p;const o=cs.formatToParts(new Date(t)),r=(i=o.find(h=>h.type==="year"))==null?void 0:i.value,l=(x=o.find(h=>h.type==="month"))==null?void 0:x.value,c=(p=o.find(h=>h.type==="day"))==null?void 0:p.value;if(!r||!l||!c)throw new Error(`Failed to format date bucket for timezone "${s}"`);return`${r}-${l}-${c}`}function ds({selectedAgentIds:t,onSelectionChange:s}){const{getAgentsByBreed:n}=Qe(),o=n(),r=c=>{t.includes(c)?s(t.filter(i=>i!==c)):s([...t,c])},l=c=>({anthropic:"Anthropic",openai:"OpenAI",google:"Google"})[c]??c;return e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs text-gray-500 font-medium",children:"默认智能体 (可选)"}),[...o.entries()].map(([c,i])=>{const x=i[0].breedDisplayName??i[0].displayName;return e.jsxs("div",{children:[e.jsxs("div",{className:"text-[10px] text-gray-400 mb-1",children:[x,"家族 · ",l(i[0].provider)]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:i.map(p=>{const h=t.includes(p.id);return e.jsxs("button",{type:"button",onClick:()=>r(p.id),className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs transition-colors border ${h?"font-medium border-current":"border-gray-200 text-gray-500 hover:border-gray-400"}`,style:h?{color:p.color.primary,backgroundColor:Xt(p.color.primary,.1),borderColor:p.color.primary}:void 0,children:[e.jsx("span",{className:"inline-block w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:p.color.primary}}),St(p),!p.variantLabel&&p.nickname?`(${p.nickname})`:""]},p.id)})})]},c)})]})}const Ee="我的电脑",us="当前项目",xs="配置路径不可用,已切换到主目录",ps="取消",fs="确定",Be="__my_computer__";function Xe(t){return/^[A-Za-z]:[\\/]/.test(t)}function ms(t){return t?Xe(t.current)||Xe(t.homePath)||Array.isArray(t.drives):!1}function hs(t,s){const n=t.includes("\\")?"\\":"/";if(Xe(t)){const i=t.split(/[/\\]/).filter(Boolean);if(i.length===0)return[];const x=`${i[0]}\\`,p=[{label:i[0],path:x}];let h=x;for(let m=1;m<i.length;m++)h=h.endsWith(n)?`${h}${i[m]}`:`${h}${n}${i[m]}`,p.push({label:i[m],path:h});return p}if(t===s||t.startsWith(s+n)){const i=[{label:"Home",path:""}];if(t===s)return i;const x=t.slice(s.length+1);if(!x)return i;const p=x.split(/[/\\]/).filter(Boolean);let h=s;for(const m of p)h+=n+m,i.push({label:m,path:h});return i}const o=t.split(/[/\\]/).filter(Boolean),r=[];let l=t.startsWith("/")?"":o[0]??"";const c=t.startsWith("/")?0:1;for(let i=c;i<o.length;i++)l+=n+o[i],r.push({label:o[i],path:l});return r}function gs({initialPath:t,activeProjectPath:s,onSelect:n,onCancel:o}){const[r,l]=a.useState(null),[c,i]=a.useState(!0),[x,p]=a.useState(null),[h,m]=a.useState(null),[d,T]=a.useState(""),[C,P]=a.useState(!1),_=a.useCallback(async(g,v=!1)=>{i(!0),p(null);try{const R=g?`/api/projects/browse?path=${encodeURIComponent(g)}`:"/api/projects/browse",u=await H(R);if(!u.ok){if(v&&g&&u.status===403){m(xs),await _(void 0,!1);return}const D=await u.json();p(D.error||"Failed to browse directory");return}const I=await u.json();l(I),T(I.current),P(!1)}catch{p("Unable to connect to server")}finally{i(!1)}},[]);a.useEffect(()=>{_(t,!!t)},[_,t]);const W=a.useCallback(()=>{const g=d.trim();g&&_(g)},[d,_]),w=ms(r),$=r?hs(r.current,r.homePath):[],M=r&&w?C?[{label:Ee,path:Be}]:[{label:Ee,path:Be},...$]:$,N=r?C?r.drives??[]:r.entries:[];return e.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden rounded-xl border border-[var(--border-default)] bg-[var(--surface-panel)]",children:[e.jsx("div",{className:"flex h-10 flex-shrink-0 items-center gap-1 overflow-x-auto border-b border-[var(--border-default)] bg-[var(--surface-panel)] px-5",children:M.map((g,v)=>e.jsxs("span",{className:"flex flex-shrink-0 items-center gap-1",children:[v>0&&e.jsx("svg",{"aria-hidden":"true",className:"h-3 w-3 text-[var(--text-label-secondary)]",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z",clipRule:"evenodd"})}),e.jsx("button",{type:"button",onClick:()=>{if(g.path===Be){P(!0),p(null);return}_(g.path||void 0)},className:`text-xs transition-colors hover:text-[var(--text-primary)] hover:underline ${v===M.length-1?"font-semibold text-[var(--text-primary)]":"font-medium text-[var(--text-secondary)]"}`,children:v===0&&(g.label==="Home"||g.label===Ee)?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(vs,{}),g.label]}):g.label})]},g.path||`_${v}`))}),e.jsxs("div",{className:"min-h-0 flex-1 space-y-0.5 overflow-y-auto px-3 py-2",children:[c&&e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx("span",{className:"animate-pulse text-xs text-[var(--text-label-secondary)]",children:"Loading..."})}),h&&e.jsx("div",{className:"mb-1 px-3 py-1.5",children:e.jsx("p",{className:"text-[10px] text-[var(--text-secondary)]",children:h})}),x&&e.jsx("div",{className:"mb-1 px-3 py-1.5",children:e.jsx("p",{className:"text-xs text-[var(--state-error-text)]",children:x})}),!c&&r&&N.length===0&&e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx("span",{className:"text-xs text-[var(--text-label-secondary)]",children:C?"No drives":"No subdirectories"})}),!c&&N.map(g=>{const v=!C&&s===g.path;return e.jsxs("button",{type:"button",onClick:()=>_(g.path),className:`flex w-full items-center gap-2.5 rounded-lg px-3 py-2.5 text-left text-sm transition-colors ${v?"bg-[var(--overlay-item-hover-bg)]":"hover:bg-[var(--overlay-item-hover-bg)]"}`,title:g.path,children:[e.jsx(bs,{className:v?"text-[var(--text-primary)]":"text-[var(--text-label-secondary)]"}),e.jsx("span",{className:"flex-1 truncate font-medium text-[var(--text-primary)]",children:g.name}),v&&e.jsx("span",{className:"flex-shrink-0 text-[10px] text-[var(--text-secondary)]",children:us}),e.jsx("svg",{"aria-hidden":"true",className:"h-3.5 w-3.5 flex-shrink-0 text-[var(--text-label-secondary)]",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z",clipRule:"evenodd"})})]},g.path)})]}),e.jsxs("div",{className:"flex-shrink-0 space-y-2 border-t border-[var(--border-default)] px-5 py-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ys,{}),e.jsx("input",{type:"text",value:d,onChange:g=>T(g.target.value),onKeyDown:g=>{g.key==="Enter"&&!g.nativeEvent.isComposing&&W()},placeholder:"Enter path...",className:"ui-input flex-1 rounded-[6px] px-3 py-2 text-sm"}),d.trim()&&e.jsx("button",{type:"button",onClick:W,className:"rounded-[6px] border border-[var(--input-border)] bg-[var(--surface-panel)] px-2.5 py-2 text-[var(--text-secondary)] transition-colors hover:bg-[var(--overlay-item-hover-bg)]","aria-label":"Go to path",children:e.jsx("svg",{"aria-hidden":"true",className:"h-3.5 w-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M10.293 3.293a1 1 0 011.414 0l6 6a1 1 0 010 1.414l-6 6a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-4.293-4.293a1 1 0 010-1.414z",clipRule:"evenodd"})})})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[r&&e.jsx("span",{className:"flex-1 truncate text-[11px] text-[var(--text-secondary)]",title:r.current,children:C?Ee:r.current}),e.jsx(ce,{variant:"default",onClick:o,children:ps}),e.jsx(ce,{onClick:()=>r&&!C&&n(r.current),disabled:!r||C,children:fs})]})]})]})}function vs(){return e.jsx("svg",{"aria-hidden":"true",className:"h-3.5 w-3.5 text-[var(--text-label-secondary)]",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{d:"M10.707 2.293a1 1 0 00-1.414 0l-7 7a1 1 0 001.414 1.414L4 10.414V17a1 1 0 001 1h2a1 1 0 001-1v-2a1 1 0 011-1h2a1 1 0 011 1v2a1 1 0 001 1h2a1 1 0 001-1v-6.586l.293.293a1 1 0 001.414-1.414l-7-7z"})})}function bs({className:t}){return e.jsx("svg",{"aria-hidden":"true",className:`h-4 w-4 flex-shrink-0 ${t??""}`,viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M1 3.5A1.5 1.5 0 012.5 2h3.879a1.5 1.5 0 011.06.44l1.122 1.12A1.5 1.5 0 009.62 4H13.5A1.5 1.5 0 0115 5.5v7a1.5 1.5 0 01-1.5 1.5h-11A1.5 1.5 0 011 12.5v-9z"})})}function ys(){return e.jsx("svg",{"aria-hidden":"true",className:"mt-2.5 h-3.5 w-3.5 text-[var(--text-label-secondary)]",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M2 4.25A2.25 2.25 0 014.25 2h11.5A2.25 2.25 0 0118 4.25v11.5A2.25 2.25 0 0115.75 18H4.25A2.25 2.25 0 012 15.75V4.25zM7.664 6.23a.75.75 0 00-1.078 1.04l2.705 2.805-2.705 2.805a.75.75 0 001.078 1.04l3.25-3.37a.75.75 0 000-1.04l-3.25-3.28zM11 13a.75.75 0 000 1.5h3a.75.75 0 000-1.5h-3z",clipRule:"evenodd"})})}const Lt="office-claw:sidebar:pinned-projects",Pt="cat-cafe:sidebar:pinned-projects";function js(t){try{let s=t.getItem(Lt);if(s||(s=t.getItem(Pt)),s){const n=JSON.parse(s);if(Array.isArray(n)&&n.every(o=>typeof o=="string"))return new Set(n)}}catch{}return new Set}function ws(t,s){var n;try{s.setItem(Lt,JSON.stringify([...t]));try{(n=s.removeItem)==null||n.call(s,Pt)}catch{}}catch{}}function Ns({existingProjects:t,onSelect:s,onCancel:n}){const[o,r]=a.useState([]),[l,c]=a.useState({}),[i,x]=a.useState(!1),[p,h]=a.useState(null),[m,d]=a.useState(null),[T,C]=a.useState(!1),[P,_]=a.useState(""),[W,w]=a.useState(null),{getAgentById:$}=Qe(),M=a.useRef(null),[N,g]=a.useState(null),v=a.useCallback(S=>{w(null),g(S)},[]),[R,u]=a.useState(""),[I,D]=a.useState(!1),[Z,se]=a.useState([]),[Y,X]=a.useState("");a.useEffect(()=>{(async()=>{try{const S=await H("/api/backlog/items");if(S.ok){const k=((await S.json()).items??[]).filter(E=>E.status!=="done"&&E.status!=="cancelled");se(k)}}catch{}})()},[]);const y=a.useCallback(S=>{const U=[];for(const[k,E]of Object.entries(l)){const z=E.trim();z&&o.includes(k)&&U.push({agentId:k,cliSessionId:z})}s({projectPath:S,preferredAgentIds:o.length>0?o:void 0,sessionBindings:U.length>0?U:void 0,title:R.trim()||void 0,pinned:I||void 0,backlogItemId:Y||void 0})},[s,o,l,R,I,Y]),F=a.useCallback(()=>{N!==null&&y(N==="lobby"?void 0:N)},[N,y]),q=a.useCallback(S=>{v(S),C(!1)},[v]),A=a.useCallback(async()=>{const S=P.trim();if(S){w(null);try{const U=await H(`/api/projects/browse?path=${encodeURIComponent(S)}`);if(!U.ok){const E=await U.json();w(E.error||"路径无效");return}const k=await U.json();v(k.current)}catch{w("无法连接到服务器")}}},[P,v]);a.useEffect(()=>{(async()=>{try{const S=await H("/api/projects/cwd");if(S.ok){const U=await S.json();h(typeof(U==null?void 0:U.path)=="string"?U.path:null),d(typeof(U==null?void 0:U.workspacePath)=="string"?U.workspacePath:null)}}catch{}})()},[]),a.useEffect(()=>{const S=U=>{U.key==="Escape"&&n()};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[n]);const[J,Q]=a.useState(!1),ee=m??p,ue=o.length>0?`已选 ${o.length}`:"";return e.jsx("div",{role:"presentation",className:"fixed inset-0 z-50 flex items-center justify-center bg-[var(--overlay-backdrop-medium)]",children:e.jsxs("div",{ref:M,className:"mx-4 flex max-h-[85vh] w-full max-w-[640px] flex-col overflow-hidden rounded-xl border border-[var(--modal-border)] bg-[var(--modal-surface)] shadow-[var(--modal-shadow)]",children:[e.jsxs("div",{className:"border-b border-[var(--modal-divider)] px-5 pb-3 pt-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h2",{className:"text-base font-semibold text-[var(--modal-title-text)]",children:"新建会话"}),e.jsx("button",{type:"button",onClick:n,className:"rounded-md p-1 text-[var(--modal-close-icon)] transition-colors hover:bg-[var(--modal-close-hover-bg)] hover:text-[var(--modal-close-icon-hover)]",children:e.jsx("svg",{"aria-hidden":"true",className:"w-5 h-5",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]}),e.jsx("input",{type:"text",value:R,onChange:S=>u(S.target.value),placeholder:"会话标题(可选)",maxLength:200,className:"ui-input w-full text-sm px-3 py-2 rounded-lg"})]}),e.jsxs("div",{className:`overflow-y-auto px-5 py-3 space-y-1 ${T?"hidden":"flex-1 min-h-[180px]"}`,children:[e.jsx("div",{className:"text-[10px] text-[var(--modal-empty-text)] font-medium mb-1",children:"选择项目"}),ee&&!t.includes(ee)&&e.jsxs("button",{type:"button",onClick:()=>v(ee),className:`w-full text-left px-3 py-2.5 text-sm text-[var(--modal-text)] hover:bg-[var(--modal-selected-surface)] rounded-lg transition-colors flex items-center gap-2 ${N===ee?"border border-[var(--modal-selected-border)] bg-[var(--modal-selected-surface)]":"border border-[var(--modal-selected-border)] bg-[var(--modal-muted-surface)]"}`,title:ee,children:[e.jsx(at,{}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"font-medium block truncate",children:_e(ee)}),e.jsx("span",{className:"text-[10px] text-[var(--modal-empty-text)] block truncate",children:ee})]}),e.jsx("span",{className:"text-[10px] text-[var(--modal-accent-text)] flex-shrink-0",children:"推荐"})]}),t.map(S=>e.jsxs("button",{type:"button",onClick:()=>v(S),className:`w-full text-left px-3 py-2.5 text-sm text-[var(--modal-text)] hover:bg-[var(--modal-selected-surface)] rounded-lg transition-colors flex items-center gap-2 ${N===S?"border border-[var(--modal-selected-border)] bg-[var(--modal-selected-surface)]":""}`,title:S,children:[e.jsx(at,{}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"font-medium block truncate",children:_e(S)}),e.jsx("span",{className:"text-[10px] text-[var(--modal-empty-text)] block truncate",children:S})]})]},S)),e.jsxs("button",{type:"button",onClick:()=>v("lobby"),className:`w-full text-left px-3 py-2.5 text-sm text-[var(--modal-text-muted)] hover:bg-[var(--modal-selected-surface)] rounded-lg transition-colors flex items-center gap-2 ${N==="lobby"?"border border-[var(--modal-selected-border)] bg-[var(--modal-selected-surface)]":""}`,children:[e.jsx("span",{className:"text-base",children:"🏠"}),e.jsx("span",{children:"大厅 (无项目)"})]})]}),e.jsxs("div",{className:`px-5 py-2 border-t border-[var(--modal-divider)] flex items-center gap-3 flex-wrap ${T?"hidden":""}`,children:[Z.length>0&&e.jsx("div",{className:"flex-1 min-w-[140px]",children:e.jsxs("select",{value:Y,onChange:S=>X(S.target.value),className:"w-full text-xs px-2 py-1.5 rounded border border-[var(--modal-muted-border)] bg-[var(--modal-surface)] focus:outline-none focus:ring-1 focus:ring-[var(--border-accent)] text-[var(--modal-text-muted)]",children:[e.jsx("option",{value:"",children:"关联 Feature(可选)"}),Z.map(S=>e.jsx("option",{value:S.id,children:S.title},S.id))]})}),e.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-[var(--modal-text-muted)] cursor-pointer flex-shrink-0",children:[e.jsx("input",{type:"checkbox",checked:I,onChange:S=>D(S.target.checked),className:"rounded border-[var(--modal-muted-border)] text-[var(--modal-accent-text)] focus:ring-[var(--border-accent)]"}),e.jsx("span",{children:"创建后置顶"})]}),e.jsxs("button",{type:"button",onClick:()=>Q(S=>!S),className:"flex items-center gap-1 text-xs text-[var(--modal-text-muted)] hover:text-[var(--modal-text)] transition-colors ml-auto",children:[e.jsx("span",{children:J?"收起列表":"选智能体"}),ue&&e.jsxs("span",{className:"text-[var(--modal-accent-text)]",children:["(",ue,")"]}),e.jsx("svg",{"aria-hidden":"true",className:`w-3 h-3 transition-transform ${J?"rotate-180":""}`,viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"})})]})]}),J&&!T&&e.jsxs("div",{className:"px-5 py-2 border-t border-[var(--modal-divider)]",children:[e.jsx(ds,{selectedAgentIds:o,onSelectionChange:r}),o.length>0&&e.jsxs("div",{className:"mt-2",children:[e.jsxs("button",{type:"button",onClick:()=>x(S=>!S),className:"w-full text-xs text-[var(--modal-text-muted)] hover:text-[var(--modal-text)] flex items-center justify-between transition-colors py-1",children:[e.jsx("span",{children:"绑定外部 Session (可选)"}),e.jsx("svg",{"aria-hidden":"true",className:`w-3.5 h-3.5 transition-transform ${i?"rotate-180":""}`,viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"})})]}),i&&e.jsxs("div",{className:"mt-1.5 space-y-2",children:[e.jsx("p",{className:"text-[10px] text-[var(--modal-empty-text)]",children:"粘贴 Claude Code / Codex 的 Session ID,创建后自动绑定"}),o.map(S=>{const U=$(S),k=U?St(U):S;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[11px] text-[var(--modal-text-muted)] w-16 truncate flex-shrink-0",title:k,children:k}),e.jsx("input",{value:l[S]??"",onChange:E=>c(z=>({...z,[S]:E.target.value})),placeholder:"CLI Session ID",maxLength:500,className:"ui-input ui-input-soft flex-1 text-[11px] font-mono px-2 py-1 rounded"})]},S)})]})]})]}),T&&e.jsx("div",{className:"border-t border-[var(--modal-divider)] flex-1 min-h-0 flex flex-col overflow-hidden",children:e.jsx(gs,{initialPath:N&&N!=="lobby"?N:m??p??void 0,activeProjectPath:N&&N!=="lobby"?N:m??void 0,onSelect:q,onCancel:()=>C(!1)})}),e.jsxs("div",{className:"px-5 py-3 border-t border-[var(--modal-divider)] space-y-2 flex-shrink-0",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>C(S=>!S),className:`flex items-center justify-center gap-1.5 px-4 py-2 rounded-lg text-xs font-medium transition-colors ${T?"bg-[var(--button-primary-bg)] text-[var(--button-primary-text)]":"bg-[var(--modal-button-muted-bg)] hover:bg-[var(--modal-button-muted-bg-hover)] text-[var(--modal-text)]"}`,children:[e.jsx(ks,{}),e.jsx("span",{children:T?"收起浏览":"浏览文件夹..."})]}),e.jsx("input",{type:"text",value:P,onChange:S=>_(S.target.value),onKeyDown:S=>{S.key==="Enter"&&!S.nativeEvent.isComposing&&A()},placeholder:"或输入路径...",className:"ui-input flex-1 text-xs px-3 py-2 rounded-lg"}),P.trim()&&e.jsx("button",{type:"button",onClick:A,className:"px-2.5 py-2 rounded-lg bg-[var(--modal-button-muted-bg)] text-[var(--modal-text)] hover:bg-[var(--modal-button-muted-bg-hover)] transition-colors","aria-label":"跳转到路径",children:e.jsx("svg",{"aria-hidden":"true",className:"w-3.5 h-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M10.293 3.293a1 1 0 011.414 0l6 6a1 1 0 010 1.414l-6 6a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-4.293-4.293a1 1 0 010-1.414z",clipRule:"evenodd"})})})]}),W&&e.jsx("p",{className:"text-[10px] text-[var(--modal-danger-text)]",children:W}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[N&&e.jsxs("span",{className:`truncate flex-1 ${T?"text-xs font-medium text-[var(--modal-accent-text)] bg-[var(--modal-selected-surface)] px-2 py-1 rounded-md":"text-[11px] text-[var(--modal-text-muted)]"}`,title:N==="lobby"?"大厅":N,children:["已选:",N==="lobby"?"大厅 (无项目)":_e(N)]}),e.jsx("button",{type:"button",onClick:F,disabled:N===null,className:"ml-auto px-5 py-2 rounded-lg bg-[var(--button-primary-bg)] hover:bg-[var(--button-primary-bg-hover)] text-[var(--button-primary-text)] text-sm font-medium transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:"创建会话"})]})]})]})})}function at({className:t}){return e.jsx("svg",{"aria-hidden":"true",className:`w-4 h-4 flex-shrink-0 ${t??""}`,viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M1 3.5A1.5 1.5 0 012.5 2h3.879a1.5 1.5 0 011.06.44l1.122 1.12A1.5 1.5 0 009.62 4H13.5A1.5 1.5 0 0115 5.5v7a1.5 1.5 0 01-1.5 1.5h-11A1.5 1.5 0 011 12.5v-9z"})})}function ks(){return e.jsxs("svg",{"aria-hidden":"true",className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:[e.jsx("path",{d:"M2 6a2 2 0 012-2h5l2 2h5a2 2 0 012 2v6a2 2 0 01-2 2H4a2 2 0 01-2-2V6z"}),e.jsx("path",{fillRule:"evenodd",d:"M2 8h16v4a2 2 0 01-2 2H4a2 2 0 01-2-2V8z",clipRule:"evenodd",opacity:"0.4"})]})}const Cs={healthy:{color:"var(--state-success-text)",title:"治理正常"},stale:{color:"var(--state-warning-text)",title:"治理过期"},missing:{color:"var(--state-error-text)",title:"治理缺失"},"never-synced":{color:"var(--text-disabled)",title:"未同步治理"}};function $e({label:t,icon:s,count:n,isCollapsed:o,onToggle:r,hideToggle:l,hideCount:c,projectPath:i,governanceStatus:x,onToggleProjectPin:p,isProjectPinned:h,children:m}){return e.jsxs("div",{className:"mt-0",children:[e.jsxs("button",{type:"button",onClick:r,className:`flex w-full items-center gap-1.5 px-4 py-1.5 text-left transition-colors ${l?"cursor-default":"hover:bg-[var(--overlay-item-hover-bg)]"}`,title:i&&i!=="default"?i:void 0,children:[!l&&e.jsx("svg",{"aria-hidden":"true",className:`h-3 w-3 flex-shrink-0 text-[var(--text-label-secondary)] transition-transform ${o?"":"rotate-90"}`,viewBox:"0 0 12 12",fill:"currentColor",children:e.jsx("path",{d:"M4 2l4 4-4 4V2z"})}),s==="pin"&&e.jsx("svg",{"aria-hidden":"true",className:"h-3 w-3 flex-shrink-0 text-[var(--text-accent)]",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M4.456 2.013a.75.75 0 011.06-.034l6.5 6a.75.75 0 01-.034 1.06l-1.99 1.838.637 3.22a.75.75 0 01-1.196.693L6.5 12.526l-2.933 2.264a.75.75 0 01-1.196-.693l.637-3.22-1.99-1.838a.75.75 0 01-.034-1.06l5.472-5.966z"})}),s==="star"&&e.jsx("svg",{"aria-hidden":"true",className:"h-3 w-3 flex-shrink-0 text-[var(--state-warning-text)]",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M8 1.5l2.09 4.26 4.71.68-3.41 3.32.8 4.69L8 12.26l-4.19 2.19.8-4.69L1.2 6.44l4.71-.68L8 1.5z"})}),s==="clock"&&e.jsx("svg",{"aria-hidden":"true",className:"h-3 w-3 flex-shrink-0 text-[var(--text-label-secondary)]",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M8 1a7 7 0 110 14A7 7 0 018 1zm0 1.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM8 4a.75.75 0 01.75.75v2.69l1.78 1.78a.75.75 0 01-1.06 1.06l-2-2A.75.75 0 017.25 8V4.75A.75.75 0 018 4z"})}),s==="archive"&&e.jsx("svg",{"aria-hidden":"true",className:"h-3 w-3 flex-shrink-0 text-[var(--text-label-secondary)]",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M1.75 2A1.75 1.75 0 000 3.75v1.5C0 5.99.84 6.73 1.91 6.95L2 7v5.25c0 .97.78 1.75 1.75 1.75h8.5A1.75 1.75 0 0014 12.25V7l.09-.05A1.75 1.75 0 0016 5.25v-1.5A1.75 1.75 0 0014.25 2H1.75zM1.5 3.75a.25.25 0 01.25-.25h12.5a.25.25 0 01.25.25v1.5a.25.25 0 01-.25.25H1.75a.25.25 0 01-.25-.25v-1.5zM3.5 7h9v5.25a.25.25 0 01-.25.25h-8.5a.25.25 0 01-.25-.25V7z"})}),e.jsx("span",{className:"truncate text-xs font-medium text-[var(--text-label-secondary)]",children:t}),(()=>{const d=x?Cs[x]:void 0;return d?e.jsx("span",{className:"h-2 w-2 flex-shrink-0 rounded-full",style:{backgroundColor:d.color},title:d.title}):null})(),!c&&e.jsx("span",{className:"ml-auto flex-shrink-0 text-[10px] text-[var(--text-disabled)]",children:n}),p&&e.jsx("span",{role:"button",tabIndex:0,onClick:d=>{d.stopPropagation(),p()},onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&!d.repeat&&(d.preventDefault(),d.stopPropagation(),p())},className:`ml-1 flex-shrink-0 cursor-pointer transition-colors ${h?"text-[var(--text-accent)]":"text-[var(--text-disabled)] hover:text-[var(--text-label-secondary)]"}`,title:h?"取消固定项目":"固定项目到活跃区","data-testid":"project-pin-btn",children:e.jsx("svg",{"aria-hidden":"true",className:"h-3 w-3",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M4.456 2.013a.75.75 0 011.06-.034l6.5 6a.75.75 0 01-.034 1.06l-1.99 1.838.637 3.22a.75.75 0 01-1.196.693L6.5 12.526l-2.933 2.264a.75.75 0 01-1.196-.693l.637-3.22-1.99-1.838a.75.75 0 01-.034-1.06l5.472-5.966z"})})})]}),!o&&m]})}async function Ss(t,s){const n=await H(`/api/export/thread/${t}?format=${s}`);if(!n.ok){const i=await n.json();throw new Error(i.message||i.error||"导出失败")}const o=await n.text(),r="md",l="text/markdown",c=new Blob([o],{type:`${l}; charset=utf-8`});ss(c,`thread-${t}.${r}`)}function Ts(t,s){const n=t.querySelector('button[aria-label="更多操作"]');if(n){const i=n.getBoundingClientRect();if(i.width>0&&i.height>0)return{left:i.left,top:i.top,bottom:i.bottom}}const o=t.getBoundingClientRect(),r=o.right-28,l=o.top+o.height*.62,c=l+16;return s?{left:r,top:l,bottom:c,x:s.clientX,y:s.clientY}:{left:r,top:l,bottom:c}}function Es(t,s){var c;if(!(t!=null&&t.length))return[];const n=Kt(),o=Vt(),r=[],l=new Set;for(let i=t.length-1;i>=0;i-=1){const x=t[i];if(!(x!=null&&x.content))continue;o.lastIndex=0;const p=[...x.content.matchAll(o)];for(const h of p){const m=(c=h[1])==null?void 0:c.toLowerCase();if(!m)continue;const d=n[m]??h[1];d&&s(d)&&(l.has(d)||(l.add(d),r.push(d)))}}return r}function As(t,s){if(!(t!=null&&t.length))return[];const n=[],o=new Set;for(let r=t.length-1;r>=0;r-=1){const l=t[r],c=(l==null?void 0:l.type)==="assistant"?l.agentId:void 0;c&&(o.has(c)||s(c)&&(o.add(c),n.push(c)))}return n}function Ls(t,s){const n=zt(),o=new Set(Object.keys(n).map(l=>l.toLowerCase()));for(const l of s){const c=l.displayName.trim();if(c){o.add(l.id.toLowerCase()),o.add(c.replace(/^@/,"").toLowerCase());for(const i of l.mentionPatterns){const x=i.replace(/^@/,"").trim().toLowerCase();x&&o.add(x)}}}const r=/@([^\s,.:;!?()\[\]{}<>,。!?、:;()【】《》「」『』〈〉]+)/g;return t.replace(r,(l,c)=>o.has(c.toLowerCase())?"":l).replace(/\s{2,}/g," ").replace(/\s+([,.:;!?,。!?、:;])/g,"$1").trim()}function Ps(t){var o,r;const s=t.find(l=>l.id.toLowerCase()==="office")??t.find(l=>l.id.toLowerCase()==="jiuwenclaw")??t.find(l=>l.mentionPatterns.some(c=>c.replace(/^@/,"").toLowerCase()==="office"))??t.find(l=>l.displayName.includes("办公")),n=((o=s==null?void 0:s.avatar)==null?void 0:o.trim())??"";return{avatar:n?n.startsWith("/uploads/")?`${et}${n}`:n:"/avatars/assistant.svg",color:((r=s==null?void 0:s.color)==null?void 0:r.primary)??"var(--accent-primary)",displayName:(s==null?void 0:s.displayName)??"办公智能体"}}function De(t){return/^(https?:\/\/|\/|data:image)/.test(t)}function Ue(t){return((t??"").replace(/^@/,"").trim().slice(0,1)||"智").toUpperCase()}function Rs({id:t,title:s,participants:n,lastActiveAt:o,isActive:r,onSelect:l,onDelete:c,onRename:i,onTogglePin:x,isPinned:p,threadState:h,indented:m,preferredAgentIds:d,invitedExpertIds:T,isHubThread:C,sourceLabel:P,iconOnly:_}){const{agents:W=[],getAgentById:w}=Qe(),$=Et(a.useCallback(j=>j.hasPending(t),[t])),{getExpertById:M}=ts(),N=a.useCallback(j=>w(j)??M(j),[w,M]),g=Math.max(0,(h==null?void 0:h.unreadCount)??0),v=g>0,R=g>99?"99+":String(g),u=!!(h!=null&&h.hasActiveInvocation),I=t!=="default"&&c&&!u,D=t!=="default"&&i,Z=t!=="default"&&x,[se,Y]=a.useState(!1),[X,y]=a.useState(!1),[F,q]=a.useState(s??""),[A,J]=a.useState(null),Q=a.useRef(null);a.useEffect(()=>{X||q(s??"")},[s,X]),a.useEffect(()=>{if(!A)return;const j=()=>J(null),G=ae=>{if(!Q.current)return;const ie=ae.target;ie&&!Q.current.contains(ie)&&j()};return window.addEventListener("mousedown",G),window.addEventListener("scroll",j,!0),window.addEventListener("blur",j),()=>{window.removeEventListener("mousedown",G),window.removeEventListener("scroll",j,!0),window.removeEventListener("blur",j)}},[A]),a.useEffect(()=>{if(!A||!Q.current)return;const j=8,G=6,ae=Q.current.getBoundingClientRect(),ie=window.innerWidth-ae.width-j,he=Math.min(Math.max(A.anchorLeft,j),Math.max(j,ie)),ke=j,ge=Math.max(j,window.innerHeight-ae.height-j),ye=A.anchorBottom+G,je=A.anchorTop-ae.height-G,f=ye+ae.height<=window.innerHeight-j?ye:je,B=Math.min(Math.max(f,ke),ge);(he!==A.x||B!==A.y)&&J({x:he,y:B,anchorLeft:A.anchorLeft,anchorTop:A.anchorTop,anchorBottom:A.anchorBottom})},[A]);const ee=a.useCallback(async()=>{if(!i)return;const j=F.trim();if(!j){q(s??""),y(!1);return}if(j===(s??"")){y(!1);return}Y(!0);try{await i(t,j),y(!1)}finally{Y(!1)}},[i,F,s,t]),S=Ls(s??(t==="default"?"大厅":"未命名会话"),W),U=As(h==null?void 0:h.messages,N),k=U.map(j=>{var G;return((G=N(j))==null?void 0:G.displayName)??j}).join(", "),E=n.map(j=>{var G;return((G=N(j))==null?void 0:G.displayName)??j}).join(", "),z=k||E||(C?"Hub 会话":"暂无智能体"),O=Ps(W),b=Es(h==null?void 0:h.messages,N),L=$?"审批待处理":z,K=Array.from(new Set([...(h==null?void 0:h.targetAgents)??[],...n,...d??[],...b,...T??[]].filter(j=>!!j&&!!N(j)))),V=(U.length>0?U:K).slice(0,4),te="ui-overlay-item block w-full whitespace-nowrap rounded-[4px] px-3 py-2 text-left text-xs text-[var(--overlay-text)] transition-colors focus-visible:outline-none",xe=A!==null,oe=a.useCallback((j,G,ae)=>{J({x:j,y:ae+6,anchorLeft:j,anchorTop:G,anchorBottom:ae})},[]),ne=a.useCallback((j,G)=>{var we,f,B,re;const ae=w(j),ie=ae?null:M(j),he=((f=(we=ae??ie)==null?void 0:we.avatar)==null?void 0:f.trim())??"",ke=((B=ae==null?void 0:ae.color)==null?void 0:B.primary)??((re=ie==null?void 0:ie.color)==null?void 0:re.primary)??"var(--accent-primary)",ge=(ae==null?void 0:ae.displayName)??(ie==null?void 0:ie.displayName)??j,ye=he.startsWith("/uploads/")?`${et}${he}`:he;return De(ye)?e.jsx("div",{className:"overflow-hidden rounded-full bg-gray-100",style:{width:G,height:G},children:e.jsx("img",{src:ye,alt:ge,width:G,height:G,className:"h-full w-full object-cover"})}):e.jsx("div",{className:"inline-flex items-center justify-center rounded-full font-semibold text-[var(--thread-avatar-initial-text)]",style:{width:G,height:G,backgroundColor:ke,fontSize:G<=16?10:12,lineHeight:1},"aria-hidden":"true",title:ge,children:he||Ue(ge)})},[w,M]),de=e.jsxs(e.Fragment,{children:[V.length===1?ne(V[0],32):V.length>1?e.jsxs("div",{className:"relative h-8 w-8",children:[V.length===2&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute left-[1px] top-[6px] z-10",children:ne(V[0],20)}),e.jsx("div",{className:"absolute left-[11px] top-[6px] z-0",children:ne(V[1],20)})]}),V.length===3&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute left-[8px] top-0",children:ne(V[0],16)}),e.jsx("div",{className:"absolute left-0 top-[16px]",children:ne(V[1],16)}),e.jsx("div",{className:"absolute left-[16px] top-[16px]",children:ne(V[2],16)})]}),V.length>=4&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute left-0 top-0",children:ne(V[0],16)}),e.jsx("div",{className:"absolute left-[16px] top-0",children:ne(V[1],16)}),e.jsx("div",{className:"absolute left-0 top-[16px]",children:ne(V[2],16)}),e.jsx("div",{className:"absolute left-[16px] top-[16px]",children:ne(V[3],16)})]})]}):e.jsx("div",{className:"ui-avatar-fallback-shell h-8 w-8",children:De(O.avatar)?e.jsx(e.Fragment,{children:e.jsx("img",{src:O.avatar,alt:"","aria-hidden":"true",className:"h-full w-full object-cover"})}):e.jsx("span",{"aria-hidden":"true",className:"inline-flex h-full w-full items-center justify-center rounded-full text-[12px] font-semibold text-[var(--thread-avatar-initial-text)]",style:{backgroundColor:O.color},children:O.avatar||Ue(O.displayName)})}),v&&e.jsx("span",{className:"ui-thread-unread-badge absolute -right-1 -top-1 inline-flex h-4 min-w-4 items-center justify-center rounded-full border px-1 text-[10px] font-medium leading-none","aria-label":`未读消息 ${g}`,children:R})]}),be=e.jsxs(e.Fragment,{children:[V.length===1?ne(V[0],20):V.length>1?e.jsx("div",{className:"relative h-5 w-5",children:e.jsx("div",{className:"absolute left-0 top-0 origin-top-left scale-[0.625]",children:de})}):e.jsx("div",{className:"ui-avatar-fallback-shell h-5 w-5",children:De(O.avatar)?e.jsx(e.Fragment,{children:e.jsx("img",{src:O.avatar,alt:"","aria-hidden":"true",className:"h-full w-full object-cover"})}):e.jsx("span",{"aria-hidden":"true",className:"inline-flex h-full w-full items-center justify-center rounded-full text-[10px] font-semibold text-[var(--thread-avatar-initial-text)]",style:{backgroundColor:O.color},children:O.avatar||Ue(O.displayName)})}),v&&V.length<=1&&e.jsx("span",{className:"ui-thread-unread-badge absolute -right-1 -top-1 inline-flex h-3.5 min-w-3.5 items-center justify-center rounded-full border px-1 text-[9px] font-medium leading-none","aria-label":`未读消息 ${g}`,children:R})]});return _?e.jsx(ve,{content:S,forceShow:!0,placement:"right",className:"inline-flex",children:e.jsx("div",{className:`ui-thread-item group relative mx-auto mb-0.5 flex h-8 w-8 cursor-pointer items-center rounded-[6px] border-0 border-b-0 transition-colors justify-center ${r?"ui-thread-item-active":"ui-thread-item-inactive"}`,style:{minHeight:0,padding:0},onClick:()=>l(t),"aria-label":S,"data-testid":"thread-item-icon-only",children:e.jsx("div",{className:"relative flex h-5 w-5 shrink-0 items-center justify-center",children:be})})}):e.jsxs("div",{className:`ui-thread-item group relative cursor-pointer transition-colors ${m?"pl-7":""} mx-4 mb-0.5 last:mb-0 border-0 border-b-0 rounded-[8px] ${r?"ui-thread-item-active":"ui-thread-item-inactive"}`,onClick:()=>l(t),onContextMenu:j=>{j.preventDefault(),j.stopPropagation();const G=Ts(j.currentTarget,j.nativeEvent);oe(G.left,G.top,G.bottom)},children:[e.jsxs("div",{className:"flex items-center gap-[10px]",children:[e.jsx("div",{className:"relative shrink-0",children:de}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(ve,{content:S,className:"min-w-0 flex-1",children:e.jsx("span",{className:"ui-thread-title block min-w-0 truncate font-semibold",children:S})}),P&&e.jsx("span",{className:"ui-thread-source-badge shrink-0 rounded-full px-2 py-[1px] text-[10px] leading-4",children:P})]}),e.jsxs("div",{className:"mt-0.5 flex items-center justify-between gap-2",children:[e.jsx(ve,{content:L,className:"min-w-0 flex-1",children:e.jsx("span",{className:"ui-thread-description block min-w-0 truncate",style:$?{color:"rgb(255, 136, 0)"}:void 0,children:L})}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsx("span",{className:`ui-thread-meta shrink-0 ${xe?"hidden":"group-hover:hidden"}`,children:Qt(o,!0)}),e.jsx("button",{type:"button","aria-label":"更多操作",className:`ui-thread-action h-4 w-4 items-center justify-center ${xe?"inline-flex":"hidden group-hover:inline-flex focus-visible:inline-flex"}`,onClick:j=>{j.preventDefault(),j.stopPropagation();const G=j.currentTarget.getBoundingClientRect();oe(G.left,G.top,G.bottom)},children:e.jsx(me,{name:"more",className:"h-4 w-4"})})]})]})]})]}),A&&typeof document<"u"&&Ze.createPortal(e.jsxs("div",{ref:Q,className:"ui-overlay-card fixed z-50 inline-block w-[100px] rounded-[6px] py-2 shadow-[var(--overlay-shadow)]","data-testid":"thread-context-menu",style:{left:A.x,top:A.y},onClick:j=>j.stopPropagation(),onContextMenu:j=>{j.preventDefault(),j.stopPropagation()},children:[D&&e.jsx("button",{type:"button",onClick:()=>{J(null),q(s??""),y(!0)},className:te,children:"重命名"}),Z&&e.jsx("button",{type:"button",onClick:()=>{J(null),x==null||x(t,!p)},className:te,children:p?"取消置顶":"置顶"}),t!=="default"&&e.jsx("button",{type:"button",onClick:()=>{J(null),Ss(t,"md").catch(j=>{console.error("导出失败:",j),alert(`导出失败:${j instanceof Error?j.message:"未知错误"}`)})},className:te,children:"导出会话"}),I&&e.jsx("button",{type:"button",onClick:()=>{J(null),c==null||c(t)},className:te,children:"删除会话"})]}),document.body),e.jsx(Te,{open:X,onClose:()=>y(!1),disableBackdropClose:!0,title:"编辑会话名称",panelClassName:"w-[500px]",bodyClassName:"pt-5",zIndexClassName:"z-[120]",backdropTestId:"thread-rename-modal",panelTestId:"thread-rename-modal-panel",children:e.jsxs("div",{className:"flex flex-col gap-5","data-testid":"thread-rename-modal-content",children:[e.jsx("input",{value:F,onChange:j=>q(j.target.value),onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),ee()),j.key==="Escape"&&(j.preventDefault(),y(!1))},autoFocus:!0,maxLength:200,disabled:se,className:"ui-input h-7 w-full px-3 text-sm"}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>y(!1),className:"ui-button-default",children:"取消"}),e.jsx("button",{type:"button",onClick:()=>void ee(),disabled:se,className:"ui-button-primary",children:"确定"})]})]})})]})}const Ms="preventSleep.enable",Is="preventSleep.disable",_s="preventSleep.syncState",Bs="preventSleep.state";function Ae(){var t;return typeof window>"u"?null:((t=window.chrome)==null?void 0:t.webview)??null}function $s(t){return!t||typeof t!="object"?!1:t.type===Bs}function Ds(){const[t,s]=a.useState(!1),[n,o]=a.useState(null),[r,l]=a.useState(!0),[c,i]=a.useState(!1),x=Ae()!==null;a.useEffect(()=>{const d=Ae();if(!(d!=null&&d.addEventListener)){l(!1);return}const T=C=>{const P=C.data;if(!$s(P))return;const _=P.payload;s(!!(_!=null&&_.enabled)),o((_==null?void 0:_.error)??null),l(!1),i(!1)};return d.addEventListener("message",T),d.postMessage(_s),()=>{var C;(C=d.removeEventListener)==null||C.call(d,"message",T)}},[]);const p=a.useCallback(()=>{const d=Ae();d&&(i(!0),d.postMessage(Ms))},[]),h=a.useCallback(()=>{const d=Ae();d&&(i(!0),d.postMessage(Is))},[]),m=a.useCallback(d=>{d?p():h()},[p,h]);return{isDesktopHost:x,enabled:t,error:n,isLoading:r,isSaving:c,enable:p,disable:h,toggle:m}}function Us({className:t}){return e.jsx("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})}function Os({className:t}){return e.jsx("svg",{className:t,viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e.jsx("path",{d:"M15 8c0-3.87-3.14-7-7-7-3.87 0-7 3.13-7 7 0 3.86 3.13 7 7 7 3.86 0 7-3.14 7-7ZM2 8c0-3.32 2.68-6 6-6 3.31 0 6 2.68 6 6 0 3.31-2.69 6-6 6-3.32 0-6-2.69-6-6Zm8.2-1.28c0-1.23-1-2.22-2.23-2.22s-2.22.99-2.22 2.22c0 .27.22.5.5.5.27 0 .5-.23.5-.5 0-.68.54-1.22 1.22-1.22.68 0 1.23.54 1.23 1.22 0 .67-.55 1.21-1.23 1.21-.27 0-.5.23-.5.5v1.23c0 .27.23.5.5.5l.09-.01c.24-.04.41-.24.41-.49v-.78l.12-.03c.93-.27 1.61-1.12 1.61-2.13Zm-2.27 3.87c.31 0 .57.25.57.56 0 .31-.26.56-.57.56a.56.56 0 0 1-.56-.56c0-.31.25-.56.56-.56Z",clipRule:"evenodd",fillRule:"evenodd",fill:"currentColor"})})}const Ce=1e3,Fs=10,zs=5*1024*1024,Vs=new Set(["image/jpeg","image/png","image/gif","image/jpg","image/pjpeg","image/x-png"]),Ks="https://support.huaweicloud.com/officeclaw-agentarts-pc/officeclaw-agentarts-pc-0040.html";function Oe(t){return/\.(jpe?g|png|gif)$/i.test(t)}function Ws(t){const s=(t.type??"").trim().toLowerCase();return Vs.has(s)?!0:(s.startsWith("image/")||!s||s==="application/octet-stream",Oe(t.name))}function nt(t){if(!(t!=null&&t.types))return!1;const s=t.types,n=s.length;for(let o=0;o<n;o++){const r=s[o];if(r==="Files"||typeof r=="string"&&r.startsWith("image/"))return!0}return!1}function Gs(t){return(t/(1024*1024)).toFixed(2)}function rt(){return e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-[12px] leading-[18px] tracking-[1px] text-[var(--text-label-secondary)]",children:"点击后进行添加,或拖拽/粘贴到此区域,支持添加多个图片"}),e.jsx("p",{className:"mt-1 text-[12px] leading-[18px] text-[var(--text-label-secondary)]",children:"格式为 jpg、png、gif,数量不超过10个,总大小 ≤ 5MB"})]})}function lt({text:t}){return e.jsx(ve,{content:t,forceShow:!0,placement:"top",className:"inline-flex shrink-0",children:e.jsx("button",{type:"button",className:"inline-flex h-[18px] w-[18px] cursor-pointer items-center justify-center bg-transparent text-[var(--text-label-secondary)] transition-colors hover:bg-[var(--surface-panel)] hover:text-[var(--text-primary)]","aria-label":`说明:${t}`,children:e.jsx(Os,{className:"h-4 w-4 shrink-0 text-[var(--text-primary)]"})})})}function Hs({open:t,onClose:s}){const n=a.useId(),o=a.useId(),r=a.useRef(null),l=a.useRef(null),c=a.useRef(0),[i,x]=a.useState("bug"),[p,h]=a.useState(""),[m,d]=a.useState(""),[T,C]=a.useState(!1),[P,_]=a.useState(!1),[W,w]=a.useState([]),[$,M]=a.useState(!1);Re({enabled:t,onEscape:s}),a.useEffect(()=>{if(!t)return;const y=window.requestAnimationFrame(()=>{var F;return(F=l.current)==null?void 0:F.focus()});return()=>window.cancelAnimationFrame(y)},[t]),a.useEffect(()=>{t||(x("bug"),h(""),d(""),C(!1),_(!1),w([]),M(!1),c.current=0)},[t]);const N=W.reduce((y,{file:F})=>y+F.size,0),g=a.useCallback(y=>{const F=y.filter(Ws);F.length!==0&&w(q=>{let A=[...q],J=A.reduce((Q,{file:ee})=>Q+ee.size,0);for(const Q of F){if(A.length>=Fs)break;const ee=J+Q.size;if(ee>zs)break;A=[...A,{id:`${Date.now()}-${Math.random().toString(36).slice(2)}`,file:Q}],J=ee}return A})},[]),v=y=>{var q;const F=(q=y.target.files)!=null&&q.length?Array.from(y.target.files):[];y.target.value="",queueMicrotask(()=>g(F))},R=y=>{w(F=>F.filter(q=>q.id!==y))},u=y=>{y.preventDefault(),y.stopPropagation(),nt(y.dataTransfer)&&(c.current+=1,M(!0))},I=y=>{y.preventDefault(),y.stopPropagation(),c.current=Math.max(0,c.current-1),c.current===0&&M(!1)},D=y=>{y.preventDefault(),y.stopPropagation(),nt(y.dataTransfer)&&(y.dataTransfer.dropEffect="copy")},Z=y=>{y.preventDefault(),y.stopPropagation(),c.current=0,M(!1);const F=Array.from(y.dataTransfer.files??[]);g(F)},se=y=>{var A;const F=Array.from(((A=y.clipboardData)==null?void 0:A.items)??[]),q=[];for(const J of F){if(J.kind!=="file")continue;const Q=J.getAsFile();Q&&q.push(Q)}q.length!==0&&(y.preventDefault(),g(q))},Y=p.length>Ce?Ce:p.length,X=p.slice(0,Ce);return e.jsx(Te,{open:t,onClose:s,title:e.jsx("span",{id:n,className:"text-[18px] font-bold leading-[28px] text-[var(--modal-title-text,var(--text-primary))]",children:"问题反馈"}),panelStyle:{width:700,maxWidth:"calc(100vw - 32px)"},panelClassName:"flex max-h-[min(640px,calc(100vh-120px))] min-h-0 flex-col overflow-hidden rounded-xl bg-[var(--modal-surface)] p-0 shadow-xl",headerClassName:"flex shrink-0 items-center justify-between px-6 pb-4 pt-5",bodyClassName:"flex min-h-0 flex-1 flex-col overflow-hidden p-0",backdropClassName:"p-4",disableBackdropClose:!0,backdropAriaModal:!0,backdropAriaLabel:"问题反馈",panelTestId:"feedback-modal",children:e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[e.jsxs("div",{ref:l,className:"flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-6 pb-4 pt-4 outline-none",onPaste:se,tabIndex:0,role:"presentation",children:[e.jsxs("section",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-[14px] font-medium leading-[22px] text-[var(--text-primary)]",children:"反馈类型"}),e.jsxs("div",{className:"flex gap-4",children:[e.jsxs("div",{role:"button",tabIndex:0,onClick:()=>x("bug"),onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),x("bug"))},className:`flex flex-1 cursor-pointer flex-col rounded-lg border text-left transition-colors ${i==="bug"?"border-[var(--switch-on-bg)] bg-[var(--surface-panel)]":"border-[var(--panel-divider)] hover:border-[var(--text-label-secondary)]"}`,style:{padding:"12px 24px"},"aria-pressed":i==="bug","data-testid":"feedback-type-bug",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("img",{src:"/icons/settings-feedback/feedback-bug.svg",alt:"","aria-hidden":!0,className:"h-[18px] w-[18px] shrink-0"}),e.jsx("span",{className:"text-[14px] leading-[22px] text-[var(--text-primary)]",children:"提交BUG"})]}),e.jsxs("p",{className:"mt-2 text-[12px] leading-[18px] text-[var(--text-label-secondary)]",children:["报告软件问题;如遇到 BUG 类问题,可先查询",e.jsx("a",{href:Ks,target:"_blank",rel:"noopener noreferrer",className:"cursor-pointer border-none text-[var(--switch-on-bg)] hover:text-[var(--switch-on-bg)]",onClick:y=>y.stopPropagation(),children:"官方FAQ文档"})]})]}),e.jsxs("button",{type:"button",onClick:()=>x("suggestion"),className:`flex flex-1 flex-col rounded-lg border text-left transition-colors ${i==="suggestion"?"border-[var(--switch-on-bg)] bg-[var(--surface-panel)]":"border-[var(--panel-divider)] hover:border-[var(--text-label-secondary)]"}`,style:{padding:"12px 24px"},"aria-pressed":i==="suggestion","data-testid":"feedback-type-suggestion",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("img",{src:"/icons/settings-feedback/feedback-idea.svg",alt:"","aria-hidden":!0,className:"h-[18px] w-[18px] shrink-0"}),e.jsx("span",{className:"text-[14px] leading-[22px] text-[var(--text-primary)]",children:"我有建议"})]}),e.jsx("p",{className:"mt-2 text-[12px] leading-[18px] text-[var(--text-label-secondary)]",children:"提交新功能或者改进措施"})]})]})]}),e.jsxs("section",{className:"flex flex-col",children:[e.jsx("span",{className:"text-[14px] font-medium leading-[22px] text-[var(--text-primary)]",children:"描述"}),e.jsx("p",{className:"mt-1 text-[12px] leading-[18px] text-[var(--text-label-secondary)]",children:"若涉及 AI 对话的相关反馈,请尽可能附带会话信息"}),e.jsxs("div",{className:"relative mt-1 pt-2",children:[e.jsx("textarea",{value:X,onChange:y=>h(y.target.value.slice(0,Ce)),className:"box-border w-full resize-none rounded-md border border-[var(--panel-divider)] bg-[var(--modal-surface)] px-3 py-2 text-[14px] leading-[22px] text-[var(--text-label-secondary)] outline-none focus:border-[var(--text-primary)] focus:ring-0 placeholder:text-[var(--text-label-secondary)]",style:{minHeight:136,maxHeight:136,paddingBottom:28},placeholder:"请描述您遇到的问题或建议…","aria-labelledby":n,"data-testid":"feedback-description"}),e.jsxs("span",{className:"pointer-events-none absolute bottom-[7px] right-2 rounded px-1.5 text-[12px] leading-[18px] text-[var(--text-label-secondary)] bg-[var(--modal-surface)]","aria-live":"polite",children:[Y,"/",Ce]})]})]}),e.jsxs("section",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("span",{className:"text-[14px] font-medium leading-[22px] text-[var(--text-primary)]",children:["问题截图",e.jsx("span",{className:"font-normal text-[var(--text-label-secondary)]",children:"(可选)"})]}),e.jsx("button",{type:"button",className:"cursor-pointer border-none bg-transparent p-0 text-[14px] font-medium leading-[22px] text-[var(--switch-on-bg)] underline-offset-2 hover:underline",onClick:()=>{var y;return(y=r.current)==null?void 0:y.click()},"data-testid":"feedback-upload-trigger",children:"上传图片"})]}),e.jsx("input",{ref:r,type:"file",accept:"image/jpeg,image/png,image/gif,.jpg,.jpeg,.png,.gif",multiple:!0,className:"hidden",onChange:v}),e.jsxs("div",{className:"relative",onDragEnter:u,onDragLeave:I,onDragOver:D,onDrop:Z,children:[W.length===0?e.jsx("button",{type:"button",className:"flex h-[100px] w-full flex-col items-center justify-center rounded-[5px] border border-dashed px-4 text-center bg-transparent cursor-pointer",style:{borderColor:"rgba(194,194,194,1)"},onClick:()=>{var y;return(y=r.current)==null?void 0:y.click()},children:e.jsx(rt,{})}):e.jsx("div",{className:"flex min-h-[100px] flex-col gap-2 rounded-[5px] border border-dashed p-3",style:{borderColor:"rgba(194,194,194,1)"},children:W.map(({id:y,file:F})=>e.jsxs("div",{className:"group flex items-center gap-1 px-2 rounded-[2px] rounded-[4px] hover:bg-[rgba(245,245,245,1)]",children:[e.jsx("img",{src:"/icons/file.svg",alt:"",className:"h-5 w-5 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"min-w-0 flex-1 truncate pl-1 text-[12px] leading-[18px]",style:{color:"rgba(89,89,89,1)"},title:F.name,children:F.name}),e.jsx("button",{type:"button","aria-label":`删除 ${F.name}`,className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-[2px] border-none bg-transparent opacity-0 transition-opacity group-hover:opacity-100",onClick:()=>R(y),children:e.jsx("img",{src:"/icons/common-delete.svg",alt:"",className:"h-4 w-4","aria-hidden":!0})})]},y))}),$?e.jsx("div",{className:"pointer-events-none absolute inset-0 flex flex-col items-center justify-center rounded-[5px] bg-[rgba(245,245,245,0.92)] px-4 text-center",children:W.length>0?e.jsx(rt,{}):e.jsx("span",{className:"text-[14px] font-medium text-[var(--text-primary)]",children:"松开以上传到列表"})}):null]}),N>0?e.jsxs("p",{className:"text-[12px] leading-[18px] text-[var(--text-label-secondary)]",children:["已选 ",W.length," 张,约 ",Gs(N)," MB / 5 MB"]}):null]}),i==="bug"?e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"flex flex-col",children:[e.jsx("span",{className:"text-[14px] font-medium leading-[22px] text-[var(--text-primary)]",children:"联系方式"}),e.jsx("p",{className:"mt-1 text-[12px] leading-[18px] text-[var(--text-label-secondary)]",children:"问题排查过程中可能需要补充信息,辛苦提供您的联系方式,帮助我们更好的定位问题"}),e.jsx("input",{id:`${o}-contact`,type:"text",value:m,onChange:y=>d(y.target.value),placeholder:"可提供电子邮件、手机号等联系方式",className:"mt-2 box-border w-full rounded-md border border-[var(--panel-divider)] bg-[var(--modal-surface)] px-3 py-1 text-[14px] leading-[22px] text-[var(--text-primary)] outline-none placeholder:text-[var(--text-label-secondary)] focus:border-[var(--text-primary)] focus:ring-0","data-testid":"feedback-contact"})]}),e.jsxs("section",{className:"flex flex-col",children:[e.jsx("span",{className:"text-[14px] font-medium leading-[22px] text-[var(--text-primary)]",children:"辅助信息"}),e.jsx("p",{className:"mt-1 text-[12px] leading-[18px] text-[var(--text-label-secondary)]",children:"以上信息仅用于问题排查、复现和解决"}),e.jsxs("div",{className:"mt-1 flex gap-6 pt-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{id:`${o}-plugins`,type:"checkbox",checked:T,onChange:y=>C(y.target.checked),className:"h-4 w-4 shrink-0 cursor-pointer rounded-[4px] border border-[rgba(194,194,194,1)] accent-[var(--switch-on-bg)] text-[var(--switch-on-bg)] focus:ring-0 focus:ring-offset-0","data-testid":"feedback-attach-plugins"}),e.jsx("label",{htmlFor:`${o}-plugins`,className:"cursor-pointer select-none text-[14px] leading-[22px] text-[var(--text-primary)]",children:"插件信息"}),e.jsx(lt,{text:"上传已安装的插件的名称、版本及运行状态等信息"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{id:`${o}-logs`,type:"checkbox",checked:P,onChange:y=>_(y.target.checked),className:"h-4 w-4 shrink-0 cursor-pointer rounded-[4px] border border-[rgba(194,194,194,1)] accent-[var(--switch-on-bg)] text-[var(--switch-on-bg)] focus:ring-0 focus:ring-offset-0","data-testid":"feedback-attach-logs"}),e.jsx("label",{htmlFor:`${o}-logs`,className:"cursor-pointer select-none text-[14px] leading-[22px] text-[var(--text-primary)]",children:"应用日志"}),e.jsx(lt,{text:"使用OfficeClaw时产生的日志内容"})]})]})]})]}):null]}),e.jsxs("div",{className:"flex shrink-0 justify-end gap-2 px-6 pb-6 pt-4",children:[e.jsx(ce,{variant:"default",type:"button",onClick:s,children:"取消"}),e.jsx(ce,{type:"button",onClick:s,"data-testid":"feedback-submit",children:"确定"})]})]})})}const Ys=3600*1e3;async function ot(t,s){return await H(t,{signal:s,timeoutMs:Ys})}const Xs={today:1,"3d":3,"7d":7,"30d":30};async function it(t){try{const s=await t.json();if(typeof s.error=="string"&&s.error.trim().length>0)return s.error;if(typeof s.detail=="string"&&s.detail.trim().length>0)return s.detail}catch{}return`Server error: ${t.status}`}function Js(t){return Array.isArray(t)?t:t&&typeof t=="object"&&Array.isArray(t.threads)?t.threads:[]}function qs(t){return Array.isArray(t)?t:t&&typeof t=="object"&&Array.isArray(t.sessions)?t.sessions:[]}function Zs(t,s){if(!t&&!s)return;const n={...(t==null?void 0:t.inputTokens)!=null||(s==null?void 0:s.inputTokens)!=null?{inputTokens:((t==null?void 0:t.inputTokens)??0)+((s==null?void 0:s.inputTokens)??0)}:{},...(t==null?void 0:t.outputTokens)!=null||(s==null?void 0:s.outputTokens)!=null?{outputTokens:((t==null?void 0:t.outputTokens)??0)+((s==null?void 0:s.outputTokens)??0)}:{},...(t==null?void 0:t.cacheReadTokens)!=null||(s==null?void 0:s.cacheReadTokens)!=null?{cacheReadTokens:((t==null?void 0:t.cacheReadTokens)??0)+((s==null?void 0:s.cacheReadTokens)??0)}:{},...(t==null?void 0:t.costUsd)!=null||(s==null?void 0:s.costUsd)!=null?{costUsd:((t==null?void 0:t.costUsd)??0)+((s==null?void 0:s.costUsd)??0)}:{}};return Object.keys(n).length>0?n:void 0}function Qs(t,s){const n=Xs[s],o=[];for(let r=0;r<n;r+=1)o.push(tt(t-r*24*60*60*1e3,Me));return o}function ea(t){return new Date(t).toLocaleString()}function ta(t){var n;const s=(n=t.title)==null?void 0:n.trim();return s&&s.length>0?s:"未命名对话"}function sa(t){const s=t.totalUsage??t.lastUsage,n=t.lastUsageAt??t.updatedAt;if(!(!s||typeof n!="number"))return{[tt(n,Me)]:s}}function aa(t){return t.usageByDay??sa(t)}function ct(t){const s=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t);if(!s)return null;const[,n,o,r]=s,l=Date.parse(`${n}-${o}-${r}T23:59:59.999+08:00`);return Number.isNaN(l)?null:l}function dt(t,s){const n=t==null?void 0:t[s];return typeof n=="number"?n:null}function na(t,s){const n=aa(t);if(!n)return{inputTokensUsed:null,outputTokensUsed:null,latestUsageTimestampInRange:null};let o,r=!1,l=null;for(const x of s){const p=n[x];p&&(o=Zs(o,p),r=!0,l==null&&(l=x))}if(!r)return{inputTokensUsed:null,outputTokensUsed:null,latestUsageTimestampInRange:null};const c=t.usageByDay!=null;let i=null;return c?(i=l!=null?ct(l):null,l!=null&&typeof t.lastUsageAt=="number"&&tt(t.lastUsageAt,Me)===l&&(i=t.lastUsageAt)):i=typeof t.lastUsageAt=="number"?t.lastUsageAt:typeof t.updatedAt=="number"?t.updatedAt:l!=null?ct(l):null,{inputTokensUsed:dt(o,"inputTokens"),outputTokensUsed:dt(o,"outputTokens"),latestUsageTimestampInRange:i}}function ra(t,s,n=Date.now()){const o=Qs(n,s.range),r=t.threads.map(i=>{const x=t.sessionsByThreadId[i.id]??[];let p=null,h=0,m=0,d=!1,T=!1;for(const W of x){const w=na(W,o);typeof w.inputTokensUsed=="number"&&(h+=w.inputTokensUsed,d=!0),typeof w.outputTokensUsed=="number"&&(m+=w.outputTokensUsed,T=!0),typeof w.latestUsageTimestampInRange=="number"&&(p==null||w.latestUsageTimestampInRange>p)&&(p=w.latestUsageTimestampInRange)}if(p==null)return null;const C=d?h:null,P=T?m:null,_=C==null&&P==null?null:(C??0)+(P??0);return{sortKey:p,item:{id:i.id,sessionName:ta(i),totalTokensUsed:_,inputTokensUsed:C,outputTokensUsed:P,occurredAt:ea(p)}}}).filter(i=>i!=null).sort((i,x)=>x.sortKey-i.sortKey).map(i=>i.item),l=Math.max(0,(s.page-1)*s.pageSize);return{items:r.slice(l,l+s.pageSize),page:s.page,pageSize:s.pageSize,total:r.length}}async function la(t){const s=await ot("/api/threads",t==null?void 0:t.signal);if(!s.ok)throw new Error(await it(s));const n=Js(await s.json()),o=await Promise.all(n.map(async r=>{const l=await ot(`/api/threads/${r.id}/sessions`,t==null?void 0:t.signal);if(!l.ok)throw new Error(await it(l));const c=qs(await l.json());return[r.id,c]}));return{threads:n,sessionsByThreadId:Object.fromEntries(o)}}const Fe=5,ut=300,xt=[{value:"today",label:"今日"},{value:"3d",label:"近3日"},{value:"7d",label:"近7日"},{value:"30d",label:"近30日"}],oa={items:[],total:0},ze="h-40";function ia(t,s){if(s<=8)return Array.from({length:s},(l,c)=>c+1);const n=new Set([1,2,s-1,s,t-2,t-1,t,t+1,t+2]),o=Array.from(n).filter(l=>l>=1&&l<=s).sort((l,c)=>l-c),r=[];for(let l=0;l<o.length;l+=1){const c=o[l],i=o[l-1];i!=null&&c-i>1&&r.push("ellipsis"),r.push(c)}return r}function Ve(t){return t==null?"":Jt(t)}function ca({open:t,onClose:s,fetchDataset:n=la}){var R;const o=a.useRef(null),[r,l]=a.useState("7d"),[c,i]=a.useState(1),[x,p]=a.useState(0),[h,m]=a.useState(!1),[d,T]=a.useState(!1),[C,P]=a.useState(null),[_,W]=a.useState(null);a.useEffect(()=>{if(!t)return;let u=!1;const I=new AbortController;let D=null;const Z=async Y=>{u||Y>=ut||await new Promise(X=>{const y=()=>{D!=null&&(clearTimeout(D),D=null),I.signal.removeEventListener("abort",F)},F=()=>{y(),X()};D=setTimeout(()=>{y(),X()},ut-Y),I.signal.addEventListener("abort",F,{once:!0})})};return(async()=>{const Y=Date.now();T(!0),P(null);try{const X=await n({signal:I.signal});if(u)return;W(X)}catch(X){if(u||X instanceof DOMException&&X.name==="AbortError")return;P("用量数据加载失败,请稍后重试"),W(null)}finally{const X=Date.now()-Y;await Z(X),u||T(!1)}})(),()=>{u=!0,I.abort(),D!=null&&(clearTimeout(D),D=null)}},[n,t,x]),Re({enabled:t,onEscape:s}),a.useEffect(()=>{t||(m(!1),W(null),P(null),i(1),l("7d"))},[t]),a.useEffect(()=>{if(!h)return;const u=I=>{var D;(D=o.current)!=null&&D.contains(I.target)||m(!1)};return document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u)}},[h]);const w=_==null?oa:ra(_,{page:c,pageSize:Fe,range:r}),$=Math.max(1,Math.ceil(w.total/Fe)),M=w.total>Fe,N=M?ia(c,$):[];a.useEffect(()=>{c>$&&i($)},[c,$]);const g=()=>{d||p(u=>u+1)},v=u=>{d||(l(u),i(1),m(!1))};return e.jsx(Te,{open:t,onClose:s,title:"用量统计",backdropRole:"dialog",backdropAriaModal:!0,backdropAriaLabel:"用量统计弹窗",panelClassName:"w-full max-w-[900px] overflow-x-auto",bodyClassName:"pt-6",disableBackdropClose:!0,panelTestId:"usage-stats-modal-panel",bodyTestId:"usage-stats-modal-body",closeButtonAriaLabel:"关闭用量统计弹窗",children:e.jsxs("div",{className:"space-y-4 min-w-[300px]",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"text-[14px] font-semibold leading-none text-[var(--modal-title-text)]",children:"Tokens消耗"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative",ref:o,children:[e.jsxs("button",{type:"button",className:"flex items-center gap-1 text-[12px] font-medium text-[var(--modal-text)]",onClick:()=>{d||m(u=>!u)},disabled:d,"data-testid":"usage-stats-range-trigger",children:[((R=xt.find(u=>u.value===r))==null?void 0:R.label)??"近7日",e.jsx("svg",{className:"h-4 w-4 text-[var(--modal-text-subtle)]",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M5 7.5L10 12.5L15 7.5",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})})]}),h?e.jsx("div",{className:"absolute right-0 top-full z-10 mt-2 min-w-[104px] rounded-xl border border-[var(--modal-border)] bg-[var(--modal-surface)] p-1.5 shadow-[var(--modal-shadow)]","data-testid":"usage-stats-range-menu",children:xt.map(u=>e.jsx("button",{type:"button",className:`flex w-full rounded-lg px-3 py-2 text-left text-[12px] ${u.value===r?"text-[var(--modal-accent-text)]":"text-[var(--modal-text)] hover:bg-[var(--modal-muted-surface)]"}`,onClick:()=>v(u.value),children:u.label},u.value))}):null]}),e.jsx("div",{className:"h-4 w-px bg-[var(--modal-table-divider)]","aria-hidden":"true"}),e.jsx(rs,{bordered:!1,onClick:g,"aria-label":"刷新",disabled:d,"data-testid":"usage-stats-refresh",children:e.jsx("img",{src:"/images/agent-management-icons/agent-refresh.svg",alt:"","aria-hidden":"true",width:16,height:16,className:"shrink-0"})})]})]}),e.jsxs("div",{className:"relative overflow-x-auto overflow-y-hidden rounded-[0.5rem] border border-[var(--modal-muted-border)] bg-[var(--modal-surface)] [scrollbar-gutter:auto]",children:[e.jsx("div",{className:"w-full rounded-[0.5rem]",children:e.jsxs("table",{className:"w-full border-collapse table-fixed min-w-[49.5rem]",children:[e.jsx("thead",{className:"bg-[var(--modal-table-header-bg)]",children:e.jsxs("tr",{className:"text-left text-[12px] text-[var(--modal-text-muted)]",children:[e.jsxs("th",{className:"relative h-12 border-b border-[var(--modal-table-divider)] px-4 py-0",children:["会话",e.jsx("span",{className:"absolute right-0 top-1/2 h-4 w-px -translate-y-1/2 bg-[var(--modal-table-divider)]","aria-hidden":"true"})]}),e.jsxs("th",{className:"relative h-12 w-[150px] border-b border-[var(--modal-table-divider)] px-4 py-0",children:["Input Tokens消耗",e.jsx("span",{className:"absolute right-0 top-1/2 h-4 w-px -translate-y-1/2 bg-[var(--modal-table-divider)]","aria-hidden":"true"})]}),e.jsxs("th",{className:"relative h-12 w-[150px] border-b border-[var(--modal-table-divider)] px-4 py-0",children:["Output Tokens消耗",e.jsx("span",{className:"absolute right-0 top-1/2 h-4 w-px -translate-y-1/2 bg-[var(--modal-table-divider)]","aria-hidden":"true"})]}),e.jsxs("th",{className:"relative h-12 w-[132px] border-b border-[var(--modal-table-divider)] px-4 py-0",children:["总Tokens消耗",e.jsx("span",{className:"absolute right-0 top-1/2 h-4 w-px -translate-y-1/2 bg-[var(--modal-table-divider)]","aria-hidden":"true"})]}),e.jsx("th",{className:"h-12 w-[200px] border-b border-[var(--modal-table-divider)] px-4 py-0",children:"时间"})]})}),e.jsx("tbody",{children:C?e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:`${ze} px-4 py-0`,children:e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx(st,{})})})}):d&&w.items.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:`${ze} px-4 py-0`})}):!d&&w.items.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:`${ze} px-4 py-0`,children:e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx(st,{})})})}):w.items.map(u=>e.jsxs("tr",{className:"border-t border-[var(--modal-table-divider)]","data-testid":`usage-stats-row-${u.id}`,children:[e.jsx("td",{className:"h-16 px-4 py-0 text-[14px] text-[var(--modal-text)]",children:e.jsx(ve,{content:u.sessionName,className:"w-full",children:e.jsx("span",{className:"block truncate",children:u.sessionName})})}),e.jsx("td",{className:"h-16 px-4 py-0 text-[14px] text-[var(--modal-text)]",title:u.inputTokensUsed!=null?u.inputTokensUsed.toLocaleString():void 0,children:Ve(u.inputTokensUsed)}),e.jsx("td",{className:"h-16 px-4 py-0 text-[14px] text-[var(--modal-text)]",title:u.outputTokensUsed!=null?u.outputTokensUsed.toLocaleString():void 0,children:Ve(u.outputTokensUsed)}),e.jsx("td",{className:"h-16 px-4 py-0 text-[14px] text-[var(--modal-text)]",title:u.totalTokensUsed!=null?u.totalTokensUsed.toLocaleString():void 0,children:Ve(u.totalTokensUsed)}),e.jsx("td",{className:"h-16 px-4 py-0 text-[12px] text-[var(--modal-text)]",children:u.occurredAt})]},u.id))})]})}),d?e.jsx("div",{className:"absolute inset-x-0 bottom-0 top-12 flex items-center justify-center bg-[var(--modal-loading-overlay)]","data-testid":"usage-stats-loading-overlay",children:e.jsx(At,{})}):null]}),M?e.jsxs("div",{className:"flex items-center justify-end gap-1","data-testid":"usage-stats-pagination",children:[e.jsx("button",{type:"button",className:"flex h-8 w-8 items-center justify-center rounded-full text-[var(--modal-text-subtle)] disabled:cursor-not-allowed disabled:opacity-40",onClick:()=>{d||i(u=>Math.max(1,u-1))},disabled:d||c<=1,"aria-label":"上一页",children:e.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M11.5 5L6.5 10L11.5 15",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})})}),N.map((u,I)=>u==="ellipsis"?e.jsx("span",{className:"px-2 text-[14px] text-[var(--modal-text-subtle)]",children:"..."},`ellipsis-${I}`):e.jsx("button",{type:"button",className:`flex h-8 min-w-8 items-center justify-center rounded-full px-2 text-[12px] ${u===c?"bg-[var(--modal-muted-surface)] text-[var(--modal-text)]":"text-[var(--modal-text-muted)] hover:bg-[var(--modal-muted-surface)]"}`,onClick:()=>{d||i(u)},disabled:d,children:u},u)),e.jsx("button",{type:"button",className:"flex h-8 w-8 items-center justify-center rounded-full text-[var(--modal-text-subtle)] disabled:cursor-not-allowed disabled:opacity-40",onClick:()=>{d||i(u=>Math.min($,u+1))},disabled:d||c>=$,"aria-label":"下一页",children:e.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M8.5 5L13.5 10L8.5 15",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})})})]}):null]})})}const da="desktop.closeAction.sync",ua="desktop.closeAction.set",xa="desktop.closeAction.state";function Ke(){var t;return typeof window>"u"?null:((t=window.chrome)==null?void 0:t.webview)??null}function pa(t){return t==="ask"||t==="minimize"||t==="exit"}function fa(t){if(!t||typeof t!="object")return!1;const s=t;return s.type===xa&&pa(s.value)}function ma(t){const[s,n]=a.useState("ask"),o=a.useMemo(()=>Ke()!==null,[]);a.useEffect(()=>{var i;if(!t||!o)return;const l=Ke();if(!l)return;const c=x=>{fa(x.data)&&n(x.data.value)};return(i=l.addEventListener)==null||i.call(l,"message",c),l.postMessage(JSON.stringify({type:da})),()=>{var x;(x=l.removeEventListener)==null||x.call(l,"message",c)}},[t,o]);const r=a.useCallback(l=>{var c;n(l),(c=Ke())==null||c.postMessage(JSON.stringify({type:ua,value:l}))},[]);return{closeAction:s,isDesktopHost:o,setCloseAction:r}}const ha=[{value:"ask",label:"每次询问"},{value:"minimize",label:"最小化到托盘"},{value:"exit",label:"直接退出"}];function ga({enabled:t}){const{closeAction:s,setCloseAction:n}=ma(t);return e.jsx("section",{children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("h4",{className:"text-[14px] font-medium leading-[22px] text-[var(--text-primary)]",children:"关闭窗口行为设置"})}),e.jsx("select",{value:s,onChange:o=>n(o.target.value),"aria-label":"选择关闭窗口行为","data-testid":"user-settings-desktop-close-action-select",className:"h-[28px] w-[200px] rounded-[8px] border border-[var(--border-default)] bg-[var(--surface-panel)] px-2.5 text-[13px] leading-5 text-[var(--text-primary)] outline-none transition-colors hover:border-[var(--text-secondary)] focus:border-[var(--switch-on-bg)]",children:ha.map(o=>e.jsx("option",{value:o.value,children:o.label},o.value))})]})})}const va=[{id:"business",label:"灰白",swatchBackground:"var(--theme-preview-business-bg)",selectedBadgeBackground:"var(--theme-preview-business-badge)",selectedBadgeColor:"var(--theme-preview-business-check)"},{id:"warm",label:"橙白",swatchBackground:"var(--theme-preview-warm-bg)",selectedBadgeBackground:"var(--theme-preview-warm-badge)",selectedBadgeColor:"var(--theme-preview-warm-check)"}];function ba({theme:t,onSelectTheme:s,optionsTestId:n="user-theme-options"}){return e.jsx("div",{className:"flex items-start gap-4","data-testid":n,children:va.map(o=>{const r=t===o.id;return e.jsxs("button",{type:"button",onClick:()=>s(o.id),className:"ui-overlay-item flex flex-col items-center gap-2 text-center text-[var(--overlay-text)] hover:border-transparent hover:bg-transparent hover:text-[var(--overlay-text)] focus-visible:border-transparent focus-visible:bg-transparent focus-visible:text-[var(--overlay-text)]","data-testid":`user-theme-option-${o.id}`,children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"h-9 w-9 rounded-full","data-testid":`user-theme-swatch-${o.id}`,style:{background:o.swatchBackground}}),r?e.jsx("div",{className:"absolute -right-1 -top-1 flex h-4 w-4 items-center justify-center rounded-full","data-testid":`user-theme-selected-badge-${o.id}`,style:{backgroundColor:o.selectedBadgeBackground,color:o.selectedBadgeColor},children:e.jsx("svg",{className:"h-[12px] w-[12px]",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M4 8.25 6.5 10.75 12 5.25",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}):null]}),e.jsx("span",{className:"whitespace-nowrap text-[12px] font-medium leading-[18px] text-[var(--overlay-text)]",children:o.label})]},o.id)})})}function ya({keepAwakeEnabled:t,isKeepAwakeLoading:s,isKeepAwakeSaving:n,onToggleKeepAwake:o,theme:r,onSelectTheme:l,active:c}){return e.jsxs(e.Fragment,{children:[e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("h4",{className:"min-w-0 flex-1 text-[14px] font-medium leading-[22px] text-[var(--text-primary)]",children:"防休眠"}),e.jsx(Ye,{checked:t,onToggle:o,ariaLabel:"切换防休眠",disabled:s||n,testId:"user-settings-keep-awake-switch"})]}),e.jsx("p",{className:"mt-1 text-[12px] leading-[20px] text-[var(--text-secondary)]",children:"开启后电脑不会进入休眠模式,方便远程操控以及自动化任务持续执行。"})]}),e.jsxs("section",{children:[e.jsx("h4",{className:"text-[14px] font-medium leading-[22px] text-[var(--text-primary)]",children:"主题模式"}),e.jsx("div",{className:"mt-2",children:e.jsx(ba,{theme:r,onSelectTheme:l})})]}),e.jsx(ga,{enabled:c})]})}const We={status:"idle",progress:0,totalBytes:0,receivedBytes:0,fileName:"",filePath:null,errorMessage:null,startTime:null,endTime:null},ja=$t(t=>({taskId:"",progress:We,isLoading:!1,setTaskId:s=>t({taskId:s}),updateProgress:s=>t({progress:s,isLoading:!1}),setLoading:s=>t({isLoading:s}),setInstalling:()=>t({progress:{...We,status:"installing"}}),reset:()=>t({taskId:"",progress:We,isLoading:!1})})),Ge={background:"linear-gradient(160deg, rgba(249, 146, 53, 1), rgba(250, 106, 52, 1) 50%, rgba(253, 77, 99, 1) 72%, rgba(248, 68, 51, 1) 100%)",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",backgroundClip:"text",textFillColor:"transparent",fontFamily:".PingFang SC",fontSize:"20px",fontWeight:700,lineHeight:"30px"};function pt(t){return t.trim().replace(/^[^\d]*/,"").split(/[.\-+_]/).map(s=>Number.parseInt(s,10)).map(s=>Number.isFinite(s)?s:0)}function wa(t,s){const n=pt(t),o=pt(s),r=Math.max(n.length,o.length);for(let l=0;l<r;l+=1){const c=n[l]??0,i=o[l]??0;if(c>i)return 1;if(c<i)return-1}return 0}const Na=({active:t,onDismiss:s,versionInfo:n,variant:o="modal"})=>{const r=ja(),l=a.useRef(null),c=a.useRef(r.reset),i=a.useRef(r.taskId),x=a.useRef(r.setTaskId),p=a.useRef(r.updateProgress);c.current=r.reset,i.current=r.taskId,x.current=r.setTaskId,p.current=r.updateProgress;const h=(n==null?void 0:n.curversion)??"",m=!!(n!=null&&n.lastversion)&&!!(n!=null&&n.curversion)&&wa(n.lastversion,h)>0,d=o==="embedded"||o==="modal"&&m?"justify-start":"justify-center",T=o==="embedded"||o==="modal"&&m?"text-left":"text-center";a.useEffect(()=>{if(!t||!(n!=null&&n.lastversion)||!m)return;const v=`version-${n.lastversion}`;if(i.current&&i.current!==v&&c.current(),!m)return;(async u=>{try{const I=await H(`/api/download/status?taskId=${u}`);if(I.ok){const D=await I.json();x.current(u),p.current(D)}}catch(I){console.error("查询下载状态失败:",I)}})(v)},[t,m,n==null?void 0:n.lastversion,n==null?void 0:n.curversion]),a.useEffect(()=>{t||(l.current&&(clearInterval(l.current),l.current=null),c.current())},[t]),a.useEffect(()=>{t&&(m||r.progress.status==="idle"&&!r.taskId||c.current())},[t,m,r.progress.status,r.taskId]),a.useEffect(()=>{if(r.progress.status!=="downloading"||!r.taskId){l.current&&(clearInterval(l.current),l.current=null);return}if(l.current)return;const v=async()=>{try{const R=await H(`/api/download/status?taskId=${r.taskId}`);if(R.ok){const u=await R.json();p.current(u),(u.status==="success"||u.status==="error"||u.status==="cancelled")&&l.current&&(clearInterval(l.current),l.current=null)}}catch(R){console.error("查询下载进度失败:",R)}};return l.current=setInterval(v,1e3),()=>{l.current&&(clearInterval(l.current),l.current=null)}},[r.progress.status,r.taskId]);const C=async()=>{const v=`version-${(n==null?void 0:n.lastversion)||"latest"}`;r.setTaskId(v),r.setLoading(!0);try{const R=await H("/api/download/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({taskId:v})});if(R.ok){const u=await R.json();r.updateProgress(u)}else{const u=await R.json();r.updateProgress({status:"error",progress:0,totalBytes:0,receivedBytes:0,fileName:"",filePath:null,errorMessage:u.error||"启动下载失败",startTime:null,endTime:null})}}catch(R){r.updateProgress({status:"error",progress:0,totalBytes:0,receivedBytes:0,fileName:"",filePath:null,errorMessage:R instanceof Error?R.message:"启动下载失败",startTime:null,endTime:null})}},P=()=>{(r.progress.status==="success"||r.progress.status==="error")&&r.reset(),s==null||s()},_=async()=>{if(r.taskId){r.setInstalling();try{(await H(`/api/download/open?taskId=${r.taskId}`,{method:"POST"})).ok&&(r.reset(),s==null||s())}catch(v){console.error("打开文件失败:",v),r.updateProgress({...r.progress,status:"error",errorMessage:"打开安装程序失败"})}}},W=()=>m?r.progress.status==="downloading"?e.jsx("div",{className:"text-left w-full flex justify-end",children:e.jsx(ce,{size:"lg",disabled:!0,children:"更新中"})}):r.progress.status==="installing"?e.jsx("div",{className:"text-left",children:e.jsx(ce,{size:"sm",disabled:!0,children:"安装中"})}):r.progress.status==="success"?e.jsx("div",{className:"text-left w-full flex justify-end",children:e.jsx(ce,{size:"lg",onClick:_,children:"重启更新"})}):r.progress.status==="error"?e.jsxs("div",{className:"flex gap-3 justify-start",children:[e.jsx(ce,{variant:"default",size:"sm",onClick:P,children:"关闭"}),e.jsx(ce,{size:"sm",onClick:()=>{r.reset(),C()},children:"重试"})]}):e.jsx("div",{className:"flex w-full flex-wrap justify-end",children:e.jsx(ce,{size:"lg","data-testid":"version-update-confirm",onClick:()=>void C(),children:"立即更新"})}):null,w=o==="modal"?"mb-8":"mb-4",$=o==="modal"?"h-[64px] w-[64px]":"h-[56px] w-[56px]",M=e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`flex ${d} ${w}`,children:e.jsx("img",{src:"/images/lobster.svg",alt:"版本更新",className:`${$} object-contain`})}),e.jsx("div",{className:"mb-1",children:m&&r.progress.status==="error"?e.jsx("span",{"data-testid":"version-update-title",style:Ge,children:"下载失败"}):m&&r.progress.status==="success"?e.jsx("span",{"data-testid":"version-update-title",style:Ge,children:"更新已就绪"}):m?e.jsxs("span",{"data-testid":"version-update-title",style:Ge,children:["发现新版本V",n==null?void 0:n.lastversion]}):e.jsx("span",{"data-testid":"version-update-title",className:"text-[20px] font-bold leading-[30px] text-[var(--text-primary)]",children:"暂无新版本"})}),e.jsx("div",{className:`mb-4 text-[12px] leading-[18px] text-[var(--text-secondary)] ${o==="modal"&&!m?"text-center":""}`,children:m&&r.progress.status==="success"?e.jsxs(e.Fragment,{children:["新版本v",n==null?void 0:n.lastversion,"已下载完成,重启应用即可完成更新"]}):e.jsxs(e.Fragment,{children:["当前版本V",h||"-"]})})]}),N=e.jsxs(e.Fragment,{children:[m&&n?e.jsx("div",{className:`mb-8 min-h-[226px] max-h-[252px] overflow-y-auto rounded-2xl border border-[#DBDBDB] p-4 text-left text-sm ${r.progress.status==="downloading"?"min-h-[152px]":""}`,children:e.jsx("pre",{className:"whitespace-pre-wrap font-sans",children:n.description})}):null,m&&r.progress.status==="downloading"?e.jsxs("div",{className:"mb-6 text-left w-full ",children:[e.jsx("div",{className:"mb-4 text-[12px]",style:{color:"rgb(128, 128, 128)"},children:"下载中......可关闭后台下载"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-[4px] flex-1 rounded-full",style:{backgroundColor:"rgb(230, 230, 230)"},children:e.jsx("div",{className:"h-[4px] rounded-full transition-all duration-300",style:{width:`${r.progress.progress}%`,backgroundColor:"rgb(92, 179, 0)"}})}),e.jsxs("span",{className:"text-sm text-[var(--modal-text-muted)]",children:[r.progress.progress,"%"]})]})]}):null]}),g=W();return o==="embedded"&&!m?e.jsxs("section",{"data-testid":"user-settings-version-update",className:"flex w-full h-[stretch] flex-col items-center justify-center px-6 text-center overflow-hidden",children:[e.jsx("div",{className:"mb-[32px] flex justify-center",children:e.jsx("img",{src:"/images/lobster.svg",alt:"",className:"h-[56px] w-[56px] object-contain","aria-hidden":!0})}),e.jsx("div",{className:"text-center w-full text-[20px] font-bold leading-[30px] text-[var(--text-primary)]","data-testid":"version-update-title",children:"暂无新版本"}),e.jsxs("div",{className:"mt-2 text-[12px] leading-[18px] text-[var(--text-secondary)]",children:["当前版本V",h||"-"]})]}):o==="embedded"?e.jsxs("section",{"data-testid":"user-settings-version-update",className:"text-left flex flex-col items-center content-center",children:[M,N,g]}):e.jsxs(e.Fragment,{children:[e.jsx(Dt,{label:"关闭",size:"sm",className:"absolute right-5 top-5 text-[var(--modal-close-icon)] transition-colors hover:text-[var(--modal-close-icon-hover)]",onClick:P,icon:e.jsx("svg",{className:"h-6 w-6",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})}),e.jsx("div",{"data-testid":"version-update-content",className:`px-8 pt-8 pb-0 ${T}`,children:M}),e.jsx("div",{className:"px-8 pb-0",children:N}),e.jsx("div",{className:"px-8 pb-8",children:g})]})};function ka({engine:t,hasValue:s,onClick:n}){return e.jsxs("div",{className:"flex w-full items-center justify-between rounded-xl bg-[var(--modal-surface)]",style:{height:"76px",padding:"16px",border:"1px solid rgba(230, 230, 230, 1)"},children:[e.jsxs("div",{className:"flex flex-col justify-center w-[calc(100%-80px)]",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("span",{className:"text-[14px] font-medium",style:{color:"rgba(25, 25, 25, 1)"},children:t.name}),e.jsx("span",{className:"ml-1 inline-flex h-[18px] items-center rounded-[2px] px-1.5 text-[12px]",style:{backgroundColor:s?"rgba(213, 242, 220, 1)":"rgba(245, 245, 245, 1)",color:s?"rgba(2, 153, 49, 1)":"rgba(25, 25, 25, 1)"},children:s?"已配置":"未配置"})]}),e.jsx("span",{className:"mt-[6px] truncate text-[12px]",style:{color:"rgba(128, 128, 128, 1)"},title:t.description,children:t.description})]}),e.jsxs("button",{type:"button",onClick:n,className:"flex items-center gap-1 rounded-md p-1 text-[12px] hover:bg-[var(--surface-hover-muted)] transition-colors",style:{color:"rgba(25, 25, 25, 1)"},children:[s?"修改":"立即配置",e.jsx(me,{name:"chevronRight",className:"h-4 w-4"})]})]})}const Ca={perplexity:"https://console.perplexity.ai/",serper:"https://serper.dev/",jina:"https://jina.ai/api-dashboard/",bocha:"https://open.bochaai.com/api-keys"};function Sa({engine:t,value:s,configured:n=!1,onSave:o,onCancel:r,saving:l=!1}){const[c,i]=a.useState(s),[x,p]=a.useState(!0),h=()=>{o(t.id,c.trim())};return e.jsxs("div",{className:"flex flex-col h-full gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:r,className:"inline-flex items-center justify-center rounded-md p-1 text-[var(--text-primary)] hover:bg-[var(--surface-hover-muted)] transition-colors",children:e.jsx(me,{name:"chevronLeft",className:"h-4 w-4"})}),e.jsx("span",{className:"text-[16px] font-medium",style:{color:"rgba(25, 25, 25, 1)"},children:"配置"})]}),x&&e.jsx(ls,{mode:"prompt",closable:!0,onClose:()=>p(!1),children:e.jsxs("span",{className:"text-[12px]",children:["请前往对应网站获取API key后填入此处;如需后续修改,请勿在智能体任务运行期间操作。",e.jsxs("a",{href:Ca[t.id]??"#",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[var(--text-accent)] hover:underline",children:["前往获取",e.jsx(me,{name:"link-blue",className:"h-4 w-4"})]})]})}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{htmlFor:`search-engine-${t.id}`,className:"text-[12px] text-[var(--text-primary)]",children:t.inputLabel}),e.jsx(os,{id:`search-engine-${t.id}`,value:c,onChange:m=>i(m.target.value),placeholder:"请输入",autoComplete:"new-password",autoCapitalize:"off",autoCorrect:"off",spellCheck:!1,"data-form-type":"other","data-1p-ignore":"true","data-lpignore":"true",className:"ui-input w-full",disabled:l})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 mt-auto",children:[e.jsx(ce,{variant:"default",onClick:r,disabled:l,children:"取消"}),e.jsx(ce,{variant:"major",onClick:h,disabled:l,children:l?"保存中...":"保存"})]})]})}const Je=[{id:"bocha",name:"Bocha(博查)",description:"基于多模态混合检索和语义排序技术的新一代搜索引擎",type:"paid",inputLabel:"bocha_api_key",envVar:"BOCHA_API_KEY"},{id:"jina",name:"Jina(Jina AI)",description:"面向企业与开发者的神经搜索基础设施,提供多语言、多模态向量搜索与重排序能力,助力构建高性能RAG与企业搜索",type:"paid",inputLabel:"jina_api_key",envVar:"JINA_API_KEY"},{id:"perplexity",name:"Perplexity",description:"AI驱动的对话式答案引擎,实时联网搜索并直接给出带权威引用的精准回答,重塑知识探索方式",type:"paid",inputLabel:"perplexity_api_key",envVar:"PERPLEXITY_API_KEY"},{id:"serper",name:"Serper",description:"通过SerperAPI,将Google搜索功能集成到启用MCP的应用程序中,提供丰富的搜索结果,可配置的参数和高效的响应处理",type:"paid",inputLabel:"serper_api_key",envVar:"SERPER_API_KEY"}],ft={perplexityApiKey:"",serperApiKey:"",jinaApiKey:"",bochaApiKey:""},mt={perplexity:!1,serper:!1,jina:!1,bocha:!1},ht={PERPLEXITY_API_KEY:"perplexityApiKey",SERPER_API_KEY:"serperApiKey",JINA_API_KEY:"jinaApiKey",BOCHA_API_KEY:"bochaApiKey"},Ta={PERPLEXITY_API_KEY:"perplexity",SERPER_API_KEY:"serper",JINA_API_KEY:"jina",BOCHA_API_KEY:"bocha"};function Ea(t){return t==="***"}async function gt(t,s){try{const n=await t.clone().json();return n.error||n.message||s}catch{return s}}function Aa(){const[t,s]=a.useState(ft),[n,o]=a.useState(mt),[r,l]=a.useState(!1),[c,i]=a.useState(!1),[x,p]=a.useState(null),h=Ct(w=>w.addToast),m=a.useCallback(async()=>{l(!0);try{const w=await H("/api/config/env-summary");if(!w.ok)throw new Error(await gt(w,"加载搜索引擎配置失败"));const M=(await w.json()).variables??[],N={...ft},g={...mt};for(const v of M){const R=ht[v.name],u=Ta[v.name];!R||!u||v.currentValue==null||v.currentValue===""||(g[u]=!0,Ea(v.currentValue)||(N[R]=v.currentValue))}s(N),o(g)}catch(w){const $=w instanceof Error?w.message:"加载搜索引擎配置失败";h({type:"error",title:"加载失败",message:$,duration:3e3})}finally{l(!1)}},[h]),d=a.useCallback(async w=>{var $;i(!0);try{const M=($=Je.find(R=>R.id===w.engineId))==null?void 0:$.envVar;if(!M)throw new Error("未知的搜索引擎");const N=ht[M];if(!N)throw new Error("未知的搜索引擎");const g=w.value==="",v=await H("/api/config/env",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({updates:[{name:M,value:w.value}]})});if(!v.ok)throw new Error(await gt(v,"保存失败"));s(R=>({...R,[N]:w.value})),o(R=>({...R,[w.engineId]:!g})),h({type:"success",title:g?"已删除":"保存成功",message:"",duration:2e3}),p(null)}catch(M){const N=M instanceof Error?M.message:"保存失败";h({type:"error",title:"保存失败",message:N,duration:3e3}),p(null)}finally{i(!1)}},[h]),T=a.useCallback(w=>{p(w)},[]),C=a.useCallback(()=>{p(null)},[]),P=a.useCallback(w=>{switch(w){case"perplexity":return t.perplexityApiKey??"";case"serper":return t.serperApiKey??"";case"jina":return t.jinaApiKey??"";case"bocha":return t.bochaApiKey??"";default:return""}},[t]),_=a.useCallback(w=>n[w],[n]);return{loading:r,saving:c,editingEngineId:x,title:x?"配置":"搜索引擎",loadConfig:m,saveConfig:d,startEdit:T,cancelEdit:C,getEngineValue:P,isEngineConfigured:_}}function La(){const{loading:t,saving:s,editingEngineId:n,title:o,loadConfig:r,saveConfig:l,startEdit:c,cancelEdit:i,getEngineValue:x,isEngineConfigured:p}=Aa();a.useEffect(()=>{r()},[r]);const h=a.useCallback((d,T)=>l({engineId:d,value:T}),[l]),m=n?Je.find(d=>d.id===n)??null:null;return t?e.jsx("div",{className:"flex h-[200px] items-center justify-center",children:e.jsx(At,{})}):m?e.jsx(Sa,{engine:m,value:x(m.id),configured:p(m.id),onSave:h,onCancel:i,saving:s}):e.jsxs("div",{className:"space-y-6",children:[e.jsx("h2",{className:"text-[16px] font-medium",style:{color:"rgba(25, 25, 25, 1)"},children:o}),e.jsxs("section",{children:[e.jsx("h3",{className:"mb-3 text-[14px] font-medium leading-[22px] text-[var(--text-primary)]",children:"付费搜索引擎"}),e.jsx("div",{className:"space-y-2",children:Je.map(d=>{const T=p(d.id);return e.jsx(ka,{engine:d,hasValue:T,onClick:()=>c(d.id)},d.id)})})]})]})}const Pa="https://www.huaweicloud.com/declaration/agentarts.html",vt=[{id:"general",label:"通用设置",iconSrc:"/icons/settings-feedback/settings-gear.svg"},{id:"memory",label:"记忆",iconSrc:"/icons/settings-feedback/settings-memory.svg"},{id:"search",label:"搜索引擎",iconSrc:"/icons/settings-feedback/settings-search.svg"},{id:"privacy",label:"隐私与数据",iconSrc:"/icons/settings-feedback/settings-privacy.svg"},{id:"about",label:"关于我们",iconSrc:"/images/information.svg"}];function Ra({title:t,description:s,switchNode:n}){return e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("h4",{className:"min-w-0 flex-1 text-[14px] font-medium leading-[22px] text-[var(--text-primary)]",children:t}),n??null]}),s?e.jsx("p",{className:"mt-1 text-[12px] leading-[20px] text-[var(--text-secondary)]",children:s}):null]})}function Ma({open:t,onClose:s,keepAwakeEnabled:n,isKeepAwakeLoading:o,isKeepAwakeSaving:r,onToggleKeepAwake:l,theme:c,onSelectTheme:i,onOpenPrivacyDeclaration:x,onAboutTabEnter:p,versionInfo:h}){const[m,d]=a.useState("general"),[T,C]=a.useState(!1),[P,_]=a.useState(!1),[W,w]=a.useState(!1),$=a.useRef(!1);Re({enabled:t,onEscape:s}),a.useEffect(()=>{t&&d("general")},[t]),a.useEffect(()=>{if(!t)return;let g=!1;return H("/api/config").then(async v=>v.ok?await v.json():null).then(v=>{var u,I;const R=(I=(u=v==null?void 0:v.config)==null?void 0:u.memory)==null?void 0:I.enabled;!g&&typeof R=="boolean"&&C(R)}).catch(()=>{}),()=>{g=!0}},[t]),a.useEffect(()=>{if(!t){$.current=!1;return}if(m!=="about"){$.current=!1;return}$.current||($.current=!0,p==null||p())},[t,m,p]);const M=a.useMemo(()=>{var g;return((g=vt.find(v=>v.id===m))==null?void 0:g.label)??"设置"},[m]),N=async g=>{const v=T;C(g),_(!0);try{(await H("/api/handle_memory_toggle",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:g})})).ok||C(v)}catch{C(v)}finally{_(!1)}};return e.jsxs(Te,{open:t,onClose:s,disableBackdropClose:!0,showCloseButton:!1,backdropClassName:"p-0",panelClassName:"relative flex max-h-[90vh] w-[900px] min-h-[480px] h-[550px] max-w-[calc(100vw-32px)] flex-col overflow-hidden !p-0 rounded-[12px] bg-[var(--modal-surface)]",bodyClassName:"flex min-h-0 flex-1 flex-row p-0",panelTestId:"user-settings-modal",bodyTestId:"user-settings-modal-body",backdropTestId:"user-settings-modal-backdrop",children:[e.jsx("button",{type:"button",onClick:s,"aria-label":"关闭设置弹窗",className:"absolute right-4 top-4 flex h-8 w-8 items-center justify-center rounded-full text-[var(--text-secondary)] transition-colors hover:text-[var(--text-primary)]",children:e.jsx(Us,{className:"h-4 w-4"})}),e.jsxs("aside",{className:"ui-sidebar-shell flex w-[180px] shrink-0 flex-col self-stretch px-[12px] py-[24px]",children:[e.jsx("h3",{className:"px-[12px] text-[18px] font-medium leading-[28px] text-[var(--text-primary)]",children:"设置"}),e.jsx("nav",{className:"mt-4 flex flex-col gap-[10px]",children:vt.map(g=>{const v=g.id===m;return e.jsxs("button",{type:"button",onClick:()=>d(g.id),"data-testid":`user-settings-tab-${g.id}`,className:`flex h-[38px] w-[156px] items-center text-[var(--text-primary)] gap-2 rounded-[8px] py-[8px] pl-[8px] pr-[12px] text-left text-[14px] leading-[22px] transition-colors ${v?"bg-[var(--surface-selected)] font-medium":"font-normal hover:bg-[var(--surface-neutral-white)]"}`,children:[e.jsx(me,{src:g.iconSrc,className:"h-5 w-5 shrink-0 object-contain"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:g.label})]},g.id)})})]}),e.jsxs("section",{className:"w-[720px] min-h-0 shrink-0 self-stretch bg-[var(--surface-panel)] px-[24px] py-[24px] overflow-hidden",children:[m!=="search"&&e.jsx("h3",{className:"text-[16px] font-medium leading-[24px] text-[var(--text-primary)]",children:M}),e.jsxs("div",{className:`h-full flex flex-col divide-y divide-[var(--panel-divider)] overflow-y-auto pr-1 [&>*]:py-4 [&>*:first-child]:pt-0 ${m==="search"?"":"pt-6"} ${m==="about"?"content-center":""}`,children:[m==="general"?e.jsx(ya,{keepAwakeEnabled:n,isKeepAwakeLoading:o,isKeepAwakeSaving:r,onToggleKeepAwake:l,theme:c,onSelectTheme:i,active:t&&m==="general"}):null,m==="memory"?e.jsx(Ra,{title:"长期记忆",description:"开启后,大模型会记住你对话中提到的偏好和习惯,提供个性化的回复。",switchNode:e.jsx(Ye,{checked:T,onToggle:g=>void N(g),ariaLabel:"切换长期记忆",disabled:P,testId:"user-settings-memory-switch"})}):null,m==="search"?e.jsx(La,{}):null,m==="privacy"?e.jsxs(e.Fragment,{children:[e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("h4",{className:"text-[14px] font-medium leading-[22px] text-[var(--text-primary)]",children:"数据用于帮助模型改进效果"}),e.jsx(Ye,{checked:W,onToggle:w,ariaLabel:"切换数据用于帮助模型改进效果",testId:"user-settings-improve-data-switch"})]}),e.jsxs("p",{className:"mt-1 text-[12px] leading-[20px] text-[var(--text-secondary)]",children:["开启后,我们将收集您提交的对话内容、OfficeClaw 相应生成的内容及执行链路日志等数据,相关数据会在脱敏处理后用于模型优化和服务改进。您可随时开启或关闭。详情见",e.jsx("button",{type:"button",className:"ml-1 cursor-pointer border-none bg-transparent p-0 text-[var(--switch-on-bg)] underline-offset-2 hover:bg-transparent",onClick:()=>window.open(Pa,"_blank","noopener,noreferrer"),children:"《AgentArts服务声明》"})]})]}),e.jsx("div",{className:"flex items-center",children:e.jsxs("button",{type:"button",onClick:x,"aria-label":"打开隐私声明",className:"inline-flex items-center gap-1.5 border-none bg-transparent p-0 text-left hover:bg-transparent focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--switch-on-bg)] focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--surface-panel)]","data-testid":"user-settings-privacy-declaration",children:[e.jsx("span",{className:"text-[14px] font-medium leading-[22px] text-[var(--text-primary)]",children:"隐私声明"}),e.jsx(me,{src:"/icons/settings-feedback/settings-link.svg",className:"h-4 w-4 shrink-0"})]})})]}):null,m==="about"?e.jsx(Na,{variant:"embedded",active:t&&m==="about",versionInfo:h}):null]})]})]})}function bt(t){return t.trim().replace(/^[^\d]*/,"").split(/[.\-+_]/).map(s=>Number.parseInt(s,10)).map(s=>Number.isFinite(s)?s:0)}function Ia(t,s){const n=bt(t),o=bt(s),r=Math.max(n.length,o.length);for(let l=0;l<r;l+=1){const c=n[l]??0,i=o[l]??0;if(c>i)return 1;if(c<i)return-1}return 0}const _a="https://support.huaweicloud.com/officeclaw-agentarts-pc/officeclaw-agentarts-pc-0001.html",Ba="https://www.huaweicloud.com/declaration/sa_prp.html",$a=Yt("NEXT_PUBLIC_CAS_LOGOUT_URL")||"https://auth.huaweicloud.com/authui/login.html?service=https://auth.huaweicloud.com/authui/v1/oauth2/authorize?";async function Da(t){if(!(t.headers.get("content-type")||"").includes("application/json"))return null;try{return await t.json()}catch{return null}}function Ua({className:t,collapsed:s}){const[n,o]=a.useState(!1),[r,l]=a.useState(!1),[c,i]=a.useState(!1),[x,p]=a.useState(!1),[h,m]=a.useState(!1),[d,T]=a.useState(!1),[C,P]=a.useState(!1),[_,W]=a.useState(!1),[w,$]=a.useState(0),[M,N]=a.useState(0),[g,v]=a.useState(null),[R,u]=a.useState(null),I=a.useRef(null),D=a.useRef(null),Z=a.useRef(null),se=a.useRef(null),Y=a.useRef(null),X=Tt(),y=Wt(),{theme:F,setTheme:q}=qt(),{enabled:A,isLoading:J,isSaving:Q,toggle:ee}=Ds(),ue=a.useCallback(async()=>{if(!(typeof window>"u"))try{const f=await H("/api/lastversion");if(!f.ok)return;const B=await f.json();if(!(B!=null&&B.curversion))return;if(u(B),!(!!B.lastversion&&!!B.curversion&&Ia(B.lastversion,B.curversion)>0)){const pe=`version-${B.curversion}`;try{await H("/api/download/clear",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({taskId:pe})})}catch{}}}catch{}},[]),S=a.useCallback(()=>{ue()},[ue]),U=y||(X==="default-user"?"未登录":X),k=U.charAt(0).toUpperCase(),E="ui-overlay-item flex w-full items-center gap-2 rounded-[8px] px-3 py-2 text-[14px] font-normal leading-[22px] text-[var(--overlay-text)]",z="ui-overlay-item flex w-full items-center justify-between gap-3 rounded-[8px] px-3 py-2 text-left text-[14px] font-normal leading-[22px] text-[var(--overlay-text)]",O=f=>{if(!D.current||!f)return null;const B=D.current.getBoundingClientRect();return{top:f.getBoundingClientRect().top,left:B.right}},b=()=>{const f=O(se.current);f&&($(f.top),N(f.left))},L=a.useCallback(()=>{if(!s||!I.current)return;const f=I.current.getBoundingClientRect();v({left:f.right+8,bottom:Math.max(8,window.innerHeight-f.bottom)})},[s]),K=()=>{o(f=>{const B=!f;return B&&s&&L(),B||i(!1),B})},V=()=>{p(!0),i(!1),o(!1)},te=()=>{l(!0),i(!1),o(!1)},xe=()=>{l(!1)},oe=()=>{p(!1)},ne=()=>{m(!0),i(!1),o(!1)},de=()=>{m(!1)},be=()=>{T(!0),i(!1),o(!1)},j=()=>{T(!1)},G=f=>{q(f)},ae=()=>{window.open(_a,"_blank","noopener,noreferrer"),i(!1),o(!1)},ie=()=>{b(),i(!0)},he=()=>{if(c){i(!1);return}ie()},ke=()=>{window.open(Ba,"_blank","noopener,noreferrer"),i(!1),o(!1)},ge=f=>{Ht(),i(!1),o(!1),window.location.assign(f||$a)},ye=async()=>{P(!0);let f=!1;try{const B=await H("/api/logout",{method:"POST"});if(B.ok){const re=await Da(B);f=!0,ge(typeof(re==null?void 0:re.logoutUrl)=="string"?re.logoutUrl:void 0);return}f=!0,ge();return}catch(B){console.error("退出登录错误:",B),f=!0,ge();return}finally{f||P(!1)}};a.useEffect(()=>{const f=B=>{var Ne,le;const re=B.target;((Ne=I.current)==null?void 0:Ne.contains(re))||((le=Y.current)==null?void 0:le.contains(re))||(o(!1),i(!1))};return(n||c)&&document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[n,c]),a.useEffect(()=>{if(!n||!c)return;b();const f=()=>{c&&b()},B=Z.current;return window.addEventListener("resize",f),B==null||B.addEventListener("scroll",f,{passive:!0}),()=>{window.removeEventListener("resize",f),B==null||B.removeEventListener("scroll",f)}},[n,c]),a.useEffect(()=>{if(!(!n||!s))return L(),window.addEventListener("resize",L),window.addEventListener("scroll",L,!0),()=>{window.removeEventListener("resize",L),window.removeEventListener("scroll",L,!0)}},[s,n,L]),a.useEffect(()=>{W(Gt())},[]);const je=s&&g?{left:g.left,bottom:g.bottom}:void 0,we=e.jsxs("button",{type:"button",onClick:K,className:`group border-none flex w-full items-center text-left text-[var(--text-primary)] transition-colors hover:bg-[var(--overlay-item-hover-bg)] ${s?"h-12 justify-center px-0 py-0":"gap-3 px-3 py-3"}`,"data-testid":"user-profile-toggle","aria-label":s?U:void 0,children:[e.jsx("div",{className:`flex flex-shrink-0 items-center justify-center rounded-full bg-[var(--surface-avatar-shell)] ${s?"h-[20px] w-[20px]":"h-9 w-9"}`,children:e.jsx("span",{className:`font-bold text-[var(--text-primary)] ${s?"text-xs":"text-sm"}`,children:k})}),!s&&e.jsxs(e.Fragment,{children:[e.jsx(ve,{content:U,className:"min-w-0 flex-1",children:e.jsx("div",{"data-testid":"user-profile-name",className:"truncate text-[16px] font-medium text-[var(--text-primary)]",children:U})}),e.jsx("svg",{className:"h-4 w-4 shrink-0 text-[var(--text-primary)] transition-transform",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M9 5l7 7-7 7"})})]})]});return e.jsxs("div",{className:`border-none relative ${t??""}`,ref:I,children:[s?e.jsx(ve,{content:U,forceShow:!0,placement:"right",className:"block",children:we}):we,n&&e.jsx("div",{className:`ui-overlay-card z-50 rounded-[var(--radius-lg)] ${s?"fixed w-[240px]":"absolute bottom-full left-3 right-3 -mb-[4px]"}`,style:je,"data-testid":"user-profile-panel",ref:D,children:e.jsxs("div",{className:"p-4 border-none","data-testid":"user-profile-panel-scroll",ref:Z,children:[e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-[var(--surface-avatar-shell)]",children:e.jsx("span",{className:"text-base font-bold text-[var(--text-primary)]",children:k})}),e.jsx(ve,{content:U,className:"min-w-0 flex-1",children:e.jsx("div",{"data-testid":"user-profile-panel-name",className:"truncate text-[16px] font-normal text-[var(--text-primary)]",children:U})})]})}),e.jsx("div",{className:"mb-3 border-t border-[var(--panel-divider)]"}),e.jsxs("div",{className:"space-y-3","data-testid":"user-profile-content-actions",children:[e.jsxs("button",{type:"button",className:E,onClick:te,"data-testid":"user-profile-settings-trigger",children:[e.jsx(me,{src:"/icons/settings-feedback/settings-gear.svg",className:"h-5 w-5 shrink-0"}),"设置"]}),e.jsxs("button",{className:E,onClick:be,children:[e.jsx(me,{src:"/icons/userprofile/security.svg",className:"h-5 w-5 text-[var(--mask-icon)]"}),"安全管理"]}),e.jsxs("button",{className:E,onClick:V,children:[e.jsx(me,{src:"/icons/userprofile/usage.svg",className:"h-5 w-5 text-[var(--mask-icon)]"}),"用量统计"]}),e.jsx("div",{className:"relative","data-testid":"user-profile-about-anchor",ref:se,children:e.jsxs("button",{type:"button",className:E,onClick:he,"data-testid":"user-profile-about-trigger",children:[e.jsx("span",{className:"flex-1 text-left",children:"帮助与反馈"}),e.jsx("svg",{"data-testid":"user-profile-about-arrow",className:"h-4 w-4 shrink-0 text-[var(--overlay-text)]",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M9 5l7 7-7 7"})})]})})]}),!_&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-3 border-t border-[var(--panel-divider)]"}),e.jsx(ce,{onClick:ye,disabled:C,variant:"default",className:"mt-4 h-7 w-full text-[12px]",children:C?"退出中...":"退出登录"})]})]})}),n&&c&&typeof document<"u"?Ze.createPortal(e.jsx("div",{ref:Y,className:"ui-overlay-card fixed z-[99999] min-w-[180px] rounded-[var(--radius-md)] shadow-[var(--overlay-shadow)]","data-testid":"user-about-popover",style:{top:`${w}px`,left:`${M}px`},children:e.jsx("div",{className:"p-[16px]",children:e.jsxs("div",{className:"flex flex-col","data-testid":"user-about-options",children:[e.jsx("button",{type:"button",className:z+" hidden","data-testid":"user-about-feedback-action",onClick:ne,children:e.jsx("span",{className:"flex-1 text-left",children:"问题反馈"})}),e.jsxs("button",{type:"button",className:z,"data-testid":"user-about-help-action",onClick:ae,children:[e.jsx("span",{className:"flex-1 text-left",children:"帮助文档"}),e.jsx(me,{name:"link",className:"h-4 w-4 shrink-0"})]})]})})}),document.body):null,x?e.jsx(ca,{open:x,onClose:oe}):null,e.jsx(Zt,{open:d,onClose:j}),e.jsx(Hs,{open:h,onClose:de}),e.jsx(Ma,{open:r,onClose:xe,keepAwakeEnabled:A,isKeepAwakeLoading:J,isKeepAwakeSaving:Q,onToggleKeepAwake:ee,theme:F,onSelectTheme:G,onOpenPrivacyDeclaration:ke,onAboutTabEnter:S,versionInfo:R})]})}function Oa(){const[t,s]=a.useState(!1),n=a.useRef(null),o=a.useRef(null),r=a.useRef(null);return a.useEffect(()=>{if(!t)return;const l=c=>{var x;const i=c.target;i&&((x=r.current)!=null&&x.contains(i)||s(!1))};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[t]),e.jsx("div",{ref:r,className:"relative px-4 mx-4 mb-[12px] rounded-[8px]",style:{background:"var(--menu-hover-bg)"},children:e.jsxs("div",{ref:n,className:"relative flex items-center gap-2 h-[44px] cursor-pointer transition-colors group",onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),"data-testid":"wechat-group-invite",children:[e.jsx("img",{src:"/images/connectors/weixin.svg",alt:"",className:"w-[24px] h-[24px] shrink-0 relative z-10"}),e.jsx("span",{className:"text-[14px] font-normal text-[var(--text-primary)] truncate relative z-10",children:"扫码加入体验官交流群"}),t&&e.jsx("div",{ref:o,className:"ui-overlay-card absolute left-[-12px] right-[-12px] bottom-[calc(100%+12px)] z-50",onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),"data-testid":"wechat-group-qr-popover",children:e.jsx("div",{className:"p-4 flex items-center justify-center rounded-[inherit]",style:{aspectRatio:"1/1"},children:e.jsx("img",{src:"https://openjiuwen-ci.obs.cn-north-4.myhuaweicloud.com/office-claw/image/wechat-officeclaw.jpg",alt:"微信交流群二维码",className:"w-full h-full object-contain"})})})]})})}function Fa({isSidebarCollapsedLayout:t,sidebarContentRevealClassName:s}){return e.jsxs(e.Fragment,{children:[!t&&e.jsx("div",{className:`transition-[opacity,transform] duration-150 ease-out ${s}`,children:e.jsx(Oa,{})}),!t&&e.jsx("div",{className:"mx-4 border-t border-[var(--border-default)]"}),e.jsx(Ua,{collapsed:t})]})}function za({deleteTarget:t,deleteTargetSharedCount:s,deleteTargetIsShared:n,deleteWorkspace:o,setDeleteWorkspace:r,onClose:l,onConfirm:c}){return e.jsx(Te,{open:!!t,onClose:l,disableBackdropClose:!0,title:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("svg",{className:"h-6 w-6 text-[var(--state-warning-text)]",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{d:"M12.866 3.5a1 1 0 0 0-1.732 0l-8.25 14.5A1 1 0 0 0 3.75 19.5h16.5a1 1 0 0 0 .866-1.5l-8.25-14.5ZM12 8a1 1 0 0 1 1 1v4a1 1 0 1 1-2 0V9a1 1 0 0 1 1-1Zm0 9a1.25 1.25 0 1 1 0-2.5A1.25 1.25 0 0 1 12 17Z"})}),e.jsx("h3",{className:"text-[16px] font-bold text-[var(--modal-title-text)]",children:"确认删除会话"})]}),panelClassName:"w-[500px]",bodyClassName:"pt-5",backdropTestId:"thread-delete-modal",panelTestId:"thread-delete-modal-panel",children:e.jsxs("div",{className:"flex flex-col gap-5","data-testid":"thread-delete-modal-content",children:[e.jsx("div",{className:"space-y-1",children:e.jsx("p",{className:"text-sm text-[var(--modal-text-muted)]",children:"删除后,该会话及相关聊天记录将全部清空且不可恢复,关联的定时任务也会一并删除。"})}),e.jsxs("div",{className:"space-y-2 rounded-[10px] border border-[var(--border-default)] bg-[var(--surface-secondary)] px-4 py-3",children:[e.jsx("div",{className:"text-xs font-semibold text-[var(--text-secondary)]",children:"工作目录"}),e.jsx("div",{className:"break-all font-mono text-xs text-[var(--text-primary)]","data-testid":"thread-delete-project-path",children:(t==null?void 0:t.projectPath)??"未设置"})]}),e.jsxs("div",{className:"space-y-1","data-testid":"thread-delete-shared-status",children:[e.jsx("div",{className:"text-xs font-semibold text-[var(--text-secondary)]",children:"共享状态"}),e.jsx("p",{className:`text-sm ${n?"text-[var(--state-warning-text)]":"text-[var(--text-muted)]"}`,children:n?`该工作目录当前被 ${s} 个其他会话共享,不能在删除会话时一并删除。`:"该工作目录当前未发现其他会话共享。"})]}),e.jsxs("label",{className:`flex items-start gap-3 ${n?"cursor-not-allowed opacity-70":""}`,"data-testid":"thread-delete-workspace-option",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5 h-4 w-4 rounded border-[var(--border-strong)]",checked:n?!1:o,disabled:n,onChange:i=>r(i.target.checked)}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--text-primary)]",children:"同时删除工作目录(危险操作)"}),e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:"危险操作:将永久删除该目录及其中所有文件,请确认这不是需要保留的重要目录。"}),n&&e.jsx("p",{className:"text-xs text-[var(--state-warning-text)]",children:"共享工作目录不可在这里删除,请先处理其他会话后再手动清理该目录。"})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(ce,{variant:"default",onClick:l,children:"取消"}),e.jsx(ce,{onClick:c,children:"确定"})]})]})})}const Va=90,Rt="office-claw:sidebar-scroll:v1",Mt="cat-cafe:sidebar-scroll:v1",Le=200,Ka=1280,Wa=1920,Ga=80,Ha=200,Se=8,Ya={all:"全部","1m":"近1个月","3m":"近3个月","6m":"近6个月"},Xa={feishu:"飞书",wechat:"微信",slack:"Slack",discord:"Discord",dingtalk:"钉钉"},Ja=[{key:"all",label:"全部"},{key:"1m",label:"近1个月"},{key:"3m",label:"近3个月"},{key:"6m",label:"近6个月"}];function qa(){if(typeof window>"u")return 0;try{let t=window.sessionStorage.getItem(Rt);if(t||(t=window.sessionStorage.getItem(Mt)),!t)return 0;const s=Number(t);return Number.isFinite(s)&&s>0?s:0}catch{return 0}}function qe(t){if(typeof window>"u")return;const s=Number.isFinite(t)&&t>0?t:0;try{window.sessionStorage.setItem(Rt,String(s));try{window.sessionStorage.removeItem(Mt)}catch{}}catch{}}function Za(t=!1){if(typeof window>"u")return!1;const s=t?Wa:Ka;return window.innerWidth<=s}function Qa(t,s){return[(t??"shrink-0").split(/\s+/).filter(r=>r&&!r.startsWith("w-")).join(" "),s?"w-12":"w-[256px]","ui-sidebar-shell flex h-full flex-col overflow-hidden transition-[width] duration-200 ease-out"].filter(Boolean).join(" ")}function en(t){var n;const s=(n=t.connectorHubState)==null?void 0:n.connectorId;if(s)return Xa[s]??s}function tn(t){const s=Number(t.lastActiveAt);return Number.isFinite(s)?s:0}function sn(t){return t.trim().toLowerCase()}function Pe(t){typeof window<"u"&&window.innerWidth<768&&(t==null||t())}function yt(t){return t.filter(s=>s.id!=="default").length}function jt({direction:t}){const s=t==="collapse"?"/icons/collapse.svg":"/icons/expand.svg";return e.jsx("img",{src:s,alt:"","aria-hidden":"true",className:"h-4 w-4"})}function an({label:t,testId:s,icon:n,active:o,onClick:r,collapsed:l,revealClassName:c,hidden:i}){const x=e.jsxs("button",{type:"button",onClick:r,className:`ui-menu-item flex ${l?"h-8 w-8 items-center justify-center px-0":"h-[38px] w-full items-center gap-2 px-2.5"} ${o?"ui-menu-item-active":"ui-menu-item-inactive"}`,"data-testid":s,"aria-label":l?t:void 0,hidden:i,children:[e.jsx(me,{src:n,className:"h-5 w-5 text-[var(--mask-icon)]"}),e.jsx("span",{className:l?"sr-only":`whitespace-nowrap transition-[opacity,transform] duration-150 ease-out ${c}`,children:t})]});return!l||i?x:e.jsx(ve,{content:t,forceShow:!0,placement:"right",className:"inline-flex",children:x})}function nn(t){const{startDrag:s}=Ut(),n=a.useRef({isDragging:!1,startX:0,startY:0}),{className:o,pathname:r,threads:l,isLoadingThreads:c,getThreadState:i,scrollRegionRef:x,normalizedQuery:p,displayThreadGroups:h,collapsedThreadItems:m,showNoResults:d,activeThreadIdFromRoute:T,existingProjects:C,govHealth:P,pinnedProjects:_,isCollapsed:W,toggleGroup:w,toggleProjectPin:$,handleNewChat:M,handleMenuNavigate:N,handleRename:g,handleDeleteRequest:v,handleTogglePin:R,handleToggleFavorite:u,handleUpdatePreferredAgents:I,handleSelect:D,showPicker:Z,createInProject:se,bindWarning:Y,filterPanelStyle:X,filterPanelRef:y,filterToggleRef:F,isSidebarCollapsed:q,isSidebarCollapsedLayout:A,sidebarContentRevealClassName:J,toggleSidebarCollapsed:Q,searchQuery:ee,isSearchOpen:ue,showFilter:S,filterOption:U,handleSearchChange:k,handleSearchClear:E,toggleSearch:z,toggleFilter:O,selectFilter:b,deleteTarget:L,deleteTargetSharedCount:K,deleteTargetIsShared:V,deleteWorkspace:te,setDeleteWorkspace:xe,closePicker:oe,closeDeleteDialog:ne,handleDeleteConfirm:de}=t,be=a.useCallback(f=>{f.button===0&&(n.current={isDragging:!1,startX:f.clientX,startY:f.clientY})},[]);a.useEffect(()=>{const f=re=>{const pe=n.current;if(pe.startX===0||pe.isDragging)return;const Ne=Math.abs(re.clientX-pe.startX),le=Math.abs(re.clientY-pe.startY);Ne<=5&&le<=5||(pe.isDragging=!0,s())},B=()=>{n.current={isDragging:!1,startX:0,startY:0}};return document.addEventListener("mousemove",f),document.addEventListener("mouseup",B),()=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",B)}},[s]);const ye=[{label:"新建会话",testId:"sidebar-new-chat",icon:"/icons/menu/new-chat.svg",active:r==="/",onClick:M},{label:"模型",testId:"sidebar-menu-models",icon:"/icons/menu/models.svg",active:r==="/models",onClick:()=>N("/models")},{label:"智能体",testId:"sidebar-menu-agents",icon:"/icons/menu/agents.svg",active:r==="/agents",onClick:()=>N("/agents")},{label:"渠道",testId:"sidebar-menu-channels",icon:"/icons/menu/channels.svg",active:r==="/channels",onClick:()=>N("/channels")},{label:"技能",testId:"sidebar-menu-skills",icon:"/icons/menu/skills.svg",active:r==="/skills",onClick:()=>N("/skills")},{label:"定时任务",testId:"sidebar-menu-scheduled-tasks",icon:"/icons/menu/schedule.svg",active:r==="/schedule",onClick:()=>N("/schedule")},{label:"灵感广场",testId:"sidebar-menu-inspiration",icon:"/icons/menu/icon-inspiration.svg",active:r==="/inspiration",onClick:()=>N("/inspiration")}],je=(f,B=!1,re=!1)=>e.jsx(Rs,{id:f.id,title:f.title,participants:f.participants,lastActiveAt:f.lastActiveAt,isActive:T===f.id,onSelect:D,onDelete:v,onRename:g,onTogglePin:R,onToggleFavorite:u,onUpdatePreferredAgents:I,isPinned:f.pinned,isFavorited:f.favorited,threadState:i(f.id),indented:B,preferredAgentIds:f.preferredAgentIds,invitedExpertIds:f.invitedExpertIds,isHubThread:!!f.connectorHubState,sourceLabel:en(f),iconOnly:re},f.id),we=f=>{var pe,Ne;const B=f.projectPath??f.type,re=f.type==="favorites"?"star":f.type==="archived-container"?"archive":void 0;return f.type==="archived-container"?e.jsx($e,{label:f.label,icon:"archive",count:((pe=f.archivedGroups)==null?void 0:pe.length)??0,isCollapsed:W("archived-container"),onToggle:()=>w("archived-container"),children:(Ne=f.archivedGroups)==null?void 0:Ne.map(le=>{const Ie=le.projectPath??le.type;return e.jsx($e,{label:le.label,count:le.threads.length,isCollapsed:W(Ie),onToggle:()=>w(Ie),projectPath:le.projectPath,governanceStatus:le.projectPath?P[le.projectPath]:void 0,onToggleProjectPin:le.projectPath?()=>$(le.projectPath):void 0,isProjectPinned:le.projectPath?_.has(le.projectPath):void 0,children:le.threads.map(Bt=>je(Bt,!0))},Ie)})},"archived-container"):e.jsx($e,{label:f.label,icon:re,count:f.threads.length,isCollapsed:f.type==="pinned"||f.type==="recent"?!1:W(B),onToggle:f.type==="pinned"||f.type==="recent"?()=>{}:()=>w(B),hideToggle:f.type==="pinned"||f.type==="recent",hideCount:f.type==="pinned"||f.type==="recent",projectPath:f.projectPath,governanceStatus:f.projectPath?P[f.projectPath]:void 0,onToggleProjectPin:f.type==="project"&&f.projectPath?()=>$(f.projectPath):void 0,isProjectPinned:f.type==="project"&&f.projectPath?_.has(f.projectPath):void 0,children:f.threads.map(le=>je(le,f.type==="project"))},B)};return e.jsxs(e.Fragment,{children:[e.jsxs("aside",{className:Qa(o,q),"data-testid":"thread-sidebar-shell",children:[e.jsxs("div",{className:`ui-sidebar-section ui-sidebar-section-no-divider flex ${A?"flex-col items-center gap-2 px-0 pt-[3px] pb-1":"items-center justify-between border-0 px-3 py-[14px]"}`,children:[q&&e.jsx("div",{className:"flex w-8 flex-col items-center border-b border-[var(--border-default)]",children:e.jsx(ve,{content:"展开侧边栏",forceShow:!0,placement:"right",className:"inline-flex",children:e.jsx("button",{type:"button",onClick:Q,className:"inline-flex h-8 w-8 items-center justify-center rounded-[6px] text-[var(--text-secondary)] transition-colors hover:bg-[var(--menu-hover-bg)] hover:text-[var(--text-primary)]","aria-label":"展开侧边栏",children:e.jsx(jt,{direction:"expand"})})})}),!A&&e.jsxs("div",{className:"flex select-none items-center gap-3",onMouseDown:be,"data-testid":"thread-sidebar-brand-drag",children:[e.jsx("img",{src:"/images/lobster.svg",alt:"OfficeClaw",draggable:!1,className:"h-[48px] w-[48px] rounded-lg"}),e.jsx("span",{className:`whitespace-nowrap text-[20px] font-semibold leading-none tracking-tight text-[var(--text-primary)] transition-[opacity,transform] duration-150 ease-out ${J}`,children:"OfficeClaw"})]}),!A&&e.jsx("button",{type:"button",onClick:Q,className:"inline-flex h-8 w-8 items-center justify-center rounded-[6px] text-[var(--text-secondary)] transition-colors hover:bg-[var(--menu-hover-bg)] hover:text-[var(--text-primary)]","aria-label":"收起侧边栏",title:"收起侧边栏",children:e.jsx(jt,{direction:"collapse"})})]}),e.jsx("div",{className:`ui-sidebar-section ${A?"ui-sidebar-section-no-divider px-0 py-2.5":"px-3 py-2.5"}`,children:e.jsx("div",{className:`flex flex-col ${A?"items-center gap-0.5":"items-start gap-1.5"}`,children:ye.map(f=>e.jsx(an,{...f,collapsed:A,revealClassName:J},f.testId))})}),A&&e.jsx("div",{className:"mx-auto flex h-6 w-8 items-center justify-center","aria-hidden":"true",children:e.jsx("div",{className:"h-1 w-1 rounded-full bg-[#dbdbdb]"})}),!A&&Y&&e.jsx("div",{className:"ui-status-warning border-b border-[var(--border-default)] px-3 py-1.5 text-[10px]",children:Y}),!A&&e.jsxs("div",{className:`relative px-4 pb-1 pt-2 transition-[opacity,transform] duration-150 ease-out ${J}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-semibold text-[var(--text-secondary)]",children:"会话消息"}),e.jsxs("div",{className:"flex items-center",children:[e.jsx("button",{ref:F,type:"button",onClick:O,className:`rounded p-1 transition-colors ${S||U!=="all"?"text-[var(--text-accent)]":"text-[var(--text-muted)] hover:text-[var(--text-accent)]"}`,title:"筛选会话","data-testid":"thread-filter-toggle",children:e.jsx("svg",{className:"h-4 w-4 align-middle",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{id:"_减去顶层",d:"M12.308 1.84961L3.68802 1.84961C3.38802 1.84961 3.09802 1.94961 2.86802 2.13961C2.40802 2.60961 2.26802 3.44961 2.68802 3.96961L5.86802 7.85961L5.86802 13.6396C5.86802 13.9196 6.08802 14.1396 6.36802 14.1396L9.72802 14.1396C9.95802 14.0896 10.138 13.8896 10.138 13.6396L10.138 7.85961L13.328 3.96961C13.518 3.73961 13.618 3.44961 13.618 3.14961C13.618 2.42961 13.028 1.84961 12.308 1.84961ZM12.608 3.14961C12.608 2.97961 12.478 2.84961 12.308 2.84961L3.68802 2.84961C3.61802 2.84961 3.54802 2.86961 3.49802 2.91961C3.36802 3.01961 3.34802 3.20961 3.45802 3.33961L6.74802 7.36961C6.81802 7.45961 6.85802 7.56961 6.85802 7.68961L6.85802 13.1496L9.12802 13.1496L9.12802 7.68961C9.12802 7.59961 9.14802 7.51961 9.19802 7.43961L12.548 3.33961C12.588 3.28961 12.608 3.21961 12.608 3.14961Z",fillRule:"evenodd"})})}),e.jsx("button",{type:"button",onClick:z,className:`rounded p-1 transition-colors ${ue||p.length>0?"text-[var(--text-accent)]":"text-[var(--text-muted)] hover:text-[var(--text-accent)]"}`,title:"搜索会话","data-testid":"thread-search-toggle",children:e.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{d:"M1.72656 7.17676C1.72656 4.13919 4.189 1.67676 7.22656 1.67676C10.2641 1.67676 12.7266 4.13919 12.7266 7.17676C12.7266 8.50784 12.2537 9.72845 11.4668 10.6798L14.2009 13.3786C14.3974 13.5726 14.3995 13.8892 14.2055 14.0857C14.033 14.2604 13.7637 14.2814 13.568 14.1477L10.7625 11.3897C9.80641 12.1929 8.57299 12.6768 7.22656 12.6768C4.189 12.6768 1.72656 10.2143 1.72656 7.17676ZM11.7266 7.17676C11.7266 4.69147 9.71184 2.67676 7.22656 2.67676C4.74128 2.67676 2.72656 4.69147 2.72656 7.17676C2.72656 9.66205 4.74128 11.6768 7.22656 11.6768C9.71184 11.6768 11.7266 9.66205 11.7266 7.17676Z",fillRule:"evenodd"})})})]})]}),(ue||p.length>0)&&e.jsx(ns,{wrapperClassName:"mt-2",value:ee,onChange:k,onClear:E,placeholder:"搜索会话",autoComplete:"off","aria-label":"搜索会话"}),S&&X&&typeof document<"u"&&Ze.createPortal(e.jsxs("div",{ref:y,className:"ui-overlay-card fixed z-[99999] w-[200px] rounded-[6px] p-4",style:X,children:[e.jsx("div",{className:"text-[12px] font-[400] leading-[18px] text-[var(--text-label-secondary)]",children:"会话时间"}),e.jsx("div",{className:"mt-3 flex flex-col",children:Ja.map(f=>e.jsx("button",{type:"button",className:`block w-full whitespace-nowrap px-3 py-2 text-left text-xs font-[400] leading-[18px] text-[var(--overlay-text)] transition-colors hover:bg-[var(--overlay-item-hover-bg)] focus-visible:bg-[var(--overlay-item-hover-bg)] focus-visible:outline-none ${U===f.key?"text-[var(--text-accent)]":""}`,style:{marginBottom:f.key==="6m"?"0":"14px"},onClick:()=>b(f.key),children:f.label},f.key))})]}),document.body)]}),e.jsxs("div",{ref:x,className:`flex-1 overflow-y-auto ${A?"ui-sidebar-collapsed-scroll overflow-x-hidden":`transition-[opacity,transform] duration-150 ease-out ${J}`}`,"data-testid":"thread-sidebar-scroll-region",children:[c&&l.length===0&&e.jsx("div",{className:"py-4 text-center text-xs text-[var(--text-label-secondary)]",children:"加载中.."}),A?e.jsx("div",{className:"flex flex-col items-center gap-1 py-2",children:m.map(f=>je(f,!1,!0))}):d?e.jsxs("div",{className:"flex h-full min-h-[120px] flex-col items-center justify-center px-3 py-4 text-center text-xs text-[var(--text-label-secondary)]",children:[e.jsx("div",{className:"text-[14px] font-[400] text-[var(--text-primary)]",children:"没有结果"}),e.jsxs("div",{className:"mt-1 flex gap-1 text-[12px] font-[400] text-[var(--text-secondary)]",children:["请",e.jsx("button",{type:"button",onClick:M,className:"text-[12px] font-[400] text-[var(--text-accent)]",children:"新建会话"})]})]}):h.map(f=>we(f))]}),e.jsx(Fa,{isSidebarCollapsedLayout:A,sidebarContentRevealClassName:J})]}),Z&&e.jsx(Ns,{existingProjects:C,onSelect:se,onCancel:oe}),e.jsx(za,{deleteTarget:L,deleteTargetSharedCount:K,deleteTargetIsShared:V,deleteWorkspace:te,setDeleteWorkspace:xe,onClose:ne,onConfirm:de})]})}function wt(t){const s=t.seqMap??new Map;async function n(r,l,c){try{const i=await t.fetch(`/api/threads/${r}`);if(!i.ok)return;const x=await i.json(),p=x[t.field];if(p!==void 0&&s.get(r)===l&&t.onUpdate(r,p),t.siblingField&&t.onUpdateSibling){const h=x[t.siblingField];h!==void 0&&(t.siblingSeqMap.get(r)??0)===c&&t.onUpdateSibling(r,h)}}catch{}}async function o(r,l){const c=(s.get(r)??0)+1;s.set(r,c);const i=t.siblingSeqMap.get(r)??0;try{const x=await t.fetch(`/api/threads/${r}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[t.field]:l})});if(!x.ok){s.get(r)===c&&n(r,c,i);return}if(s.get(r)!==c)return;const p=await x.json();t.onUpdate(r,p[t.field]??l)}catch{s.get(r)===c&&n(r,c,i)}}return{toggle:o,seqMap:s}}function rn({pathname:t,currentThreadId:s,threads:n,showTrash:o,trashedThreads:r,loadThreads:l,loadTrash:c,resetSearchAndFilter:i,onClose:x,onThreadSelect:p,getThreadState:h,scrollRegionRef:m}){const d=Ot(),{addToast:T}=Ct(),{setCurrentThread:C,setCurrentProject:P,updateThreadTitle:_}=fe(),[W,w]=a.useState(!1),[$,M]=a.useState(!1),[N,g]=a.useState(null),[v,R]=a.useState(null),[u,I]=a.useState(!1),D=a.useRef(null),Z=a.useRef(new Map),se=a.useRef(new Map),Y=a.useRef(),X=a.useRef();Y.current||(Y.current=wt({fetch:H,onUpdate:(b,L)=>fe.getState().updateThreadPin(b,L),field:"pinned",seqMap:Z.current,siblingSeqMap:se.current,onUpdateSibling:(b,L)=>fe.getState().updateThreadFavorite(b,L),siblingField:"favorited"})),X.current||(X.current=wt({fetch:H,onUpdate:(b,L)=>fe.getState().updateThreadFavorite(b,L),field:"favorited",seqMap:se.current,siblingSeqMap:Z.current,onUpdateSibling:(b,L)=>fe.getState().updateThreadPin(b,L),siblingField:"pinned"})),Re({enabled:v!==null,onEscape:()=>R(null)}),a.useEffect(()=>{v&&I(!1)},[v]);const y=a.useMemo(()=>{if(!(v!=null&&v.projectPath))return 0;const b=[...n,...r];return new Set(b.filter(K=>K.id!==v.id&&K.projectPath===v.projectPath).map(K=>K.id)).size},[v,n,r]),F=y>0;a.useEffect(()=>{F&&I(!1)},[F]),a.useEffect(()=>()=>{D.current&&clearTimeout(D.current)},[]);const q=a.useCallback(b=>{g(b),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>{g(null),D.current=null},6e3)},[]),A=a.useCallback(b=>{d(b==="default"?"/":`/thread/${b}`,{preventScrollReset:!0})},[d]),J=a.useCallback(()=>{if(yt(n)>=Le){T({type:"error",title:"会话数量已达上限",message:`当前会话数量已达到 ${Le} 个上限,请删除一些会话后再创建新会话。`,duration:5e3});return}i(),C("default"),P("default"),A("default"),Pe(x)},[T,A,x,i,P,C,n]),Q=a.useCallback(async b=>{var K,V;if(yt(n)>=Le){T({type:"error",title:"会话数量已达上限",message:`当前会话数量已达到 ${Le} 个上限,请删除一些会话后再创建新会话。`,duration:5e3});return}w(!0),M(!1);try{const te=await H("/api/threads",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...b.projectPath?{projectPath:b.projectPath}:{},...(K=b.preferredAgentIds)!=null&&K.length?{preferredAgentIds:b.preferredAgentIds}:{},...b.title?{title:b.title}:{},...b.pinned?{pinned:b.pinned}:{},...b.backlogItemId?{backlogItemId:b.backlogItemId}:{}})});if(!te.ok)return;const xe=await te.json();if((V=b.sessionBindings)!=null&&V.length){const oe=await Promise.allSettled(b.sessionBindings.map(({agentId:de,cliSessionId:be})=>H(`/api/threads/${xe.id}/sessions/${de}/bind`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({cliSessionId:be})}))),ne=oe.filter(de=>de.status==="rejected"||de.status==="fulfilled"&&!de.value.ok);ne.length>0&&q(`Session 绑定部分失败(${ne.length}/${oe.length}),可在 Session 面板重试`)}b.projectPath&&P(b.projectPath),A(xe.id),Pe(x),await l()}catch{}finally{w(!1)}},[T,l,A,x,P,n,q]),ee=a.useCallback(b=>{const L=h(b);if(L!=null&&L.hasActiveInvocation)return;const K=n.find(V=>V.id===b);K&&R(K)},[h,n]),ue=a.useCallback(async()=>{if(!v)return;const b=v.id,L=y,K=u&&!F;R(null);try{const te=await H(`/api/threads/${b}${K?"?deleteWorkspace=true":""}`,{method:"DELETE"});if(!te.ok&&te.status!==204)return;if(K){const xe=te.headers.get("x-office-claw-workspace-delete-succeeded")==="true",oe=te.headers.get("x-office-claw-workspace-delete-reason"),ne=te.headers.get("x-office-claw-workspace-delete-shared")==="true",de=Number(te.headers.get("x-office-claw-workspace-delete-shared-count")??L),be=te.headers.get("x-office-claw-memory-preserved")==="true";if(xe)T(be?{type:"success",title:"工作目录已删除",message:"工作目录内容已删除,memory 目录已保留(包含 agent 索引缓存)。如需彻底清理可手动删除。",duration:5e3}:ne?{type:"info",title:"工作目录删除成功",message:`工作目录已删除。该目录在删除前被 ${de} 个其他会话共享,其他会话可能异常。`,duration:5e3}:{type:"success",title:"工作目录已删除",message:"工作目录已完全删除。",duration:5e3});else{const j=oe==="shared_workspace";T({type:j?"info":"error",title:j?"工作目录已保留":"工作目录未删除",message:j?"该工作目录正在被其他会话共享,系统已保留,避免影响其他会话。":oe==="unsafe_root"?"系统判定该路径过于危险,已跳过删除。":oe==="not_directory"?"该路径不是目录,已跳过删除。":oe==="path_resolution_failed"?"目录路径解析失败,请检查目录是否仍然存在。":oe==="delete_failed"?"目录删除失败,可能是文件占用或权限不足。":"工作目录未删除,请手动检查。",duration:6e3})}}b===s&&A("default"),await l(),o&&c()}catch{}},[T,s,v,F,y,u,l,c,A,o]),S=a.useCallback(async(b,L)=>{const K=L.trim();if(K)try{const V=await H(`/api/threads/${b}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:K})});if(!V.ok)return;const te=await V.json();_(b,te.title??K)}catch{}},[_]),U=a.useCallback((b,L)=>{var K;return void((K=Y.current)==null?void 0:K.toggle(b,L))},[]),k=a.useCallback((b,L)=>{var K;return void((K=X.current)==null?void 0:K.toggle(b,L))},[]),E=a.useCallback(async(b,L)=>{if(!(await H(`/api/threads/${b}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({preferredAgentIds:L})})).ok)throw new Error("保存失败");fe.getState().updateThreadPreferredAgents(b,L)},[]),z=a.useCallback(b=>{p==null||p();const L=m.current;L&&qe(L.scrollTop);const K=b==="default"&&t==="/"||t===`/thread/${b}`;if(b===s&&K)return;const V=n.find(te=>te.id===b);P((V==null?void 0:V.projectPath)??"default"),C(b),A(b),Pe(x)},[s,A,x,p,t,m,P,C,n]),O=a.useCallback(b=>{d(b),Pe(x)},[x,d]);return{isCreating:W,showPicker:$,bindWarning:N,deleteTarget:v,deleteWorkspace:u,deleteTargetSharedCount:y,deleteTargetIsShared:F,handleNewChat:J,handleMenuNavigate:O,createInProject:Q,handleDeleteRequest:ee,handleDeleteConfirm:ue,handleRename:S,handleTogglePin:U,handleToggleFavorite:k,handleUpdatePreferredAgents:E,handleSelect:z,setShowPicker:M,setDeleteWorkspace:I,closePicker:()=>M(!1),closeDeleteDialog:()=>R(null)}}const It="office-claw:sidebar:collapsed-groups",_t="cat-cafe:sidebar:collapsed-groups";function ln(t){try{let s=t.getItem(It);if(s||(s=t.getItem(_t)),s){const n=JSON.parse(s);if(Array.isArray(n)&&n.every(o=>typeof o=="string"))return n}}catch{}return null}function on(t,s){var n;try{s.setItem(It,JSON.stringify(t));try{(n=s.removeItem)==null||n.call(s,_t)}catch{}}catch{}}function cn(t,s){const n=ln(s);return n!==null?new Set(n):new Set(t)}function dn(t,s,n){return n.length>0?!1:s.has(t)}function un(t){return!0}function xn(t,s,n,o){return n.length>0?!1:o?dn(t,s,n):un()}function pn(){return new Set}function fn(t){return new Set(t)}function mn(t,s){let n;for(const o of s)if(o.threadIds.includes(t))if(o.type==="recent")n||(n=o.groupKey);else return o.groupKey;return n}function He(t){return t.projectPath??t.type}function Nt(){return typeof window<"u"?window.localStorage:{getItem:()=>null,setItem:()=>{}}}function hn({threadGroups:t,searchQuery:s,currentThreadId:n}){const o=a.useRef(!1),r=a.useRef(new Set),l=a.useRef(void 0),[c,i]=a.useState(()=>new Set);for(const d of t)r.current.add(He(d));a.useEffect(()=>{if(o.current||t.length===0)return;const d=t.map(He);i(cn(d,Nt())),o.current=!0},[t]),a.useEffect(()=>{o.current&&on([...c],Nt())},[c]),a.useEffect(()=>{if(l.current&&l.current!==n&&(l.current=void 0),!n||!o.current||l.current===n)return;const d=t.map(C=>({groupKey:He(C),threadIds:C.threads.map(P=>P.id),type:C.type})),T=mn(n,d);T&&(l.current=n,i(C=>{if(!C.has(T))return C;const P=new Set(C);return P.delete(T),P}))},[n,t]);const x=a.useCallback(d=>xn(d,c,s,o.current),[c,s]),p=a.useCallback(d=>{i(T=>{const C=new Set(T);return C.has(d)?C.delete(d):C.add(d),C})},[]),h=a.useCallback(()=>i(pn()),[]),m=a.useCallback(()=>{i(fn([...r.current]))},[]);return{isCollapsed:x,toggleGroup:p,expandAll:h,collapseAll:m}}function kt(){return typeof window<"u"?window.localStorage:{getItem:()=>null,setItem:()=>{}}}function gn(){const t=a.useRef(!1),[s,n]=a.useState(()=>new Set);a.useEffect(()=>{t.current||(n(js(kt())),t.current=!0)},[]),a.useEffect(()=>{t.current&&ws(s,kt())},[s]);const o=a.useCallback(r=>{n(l=>{const c=new Set(l);return c.has(r)?c.delete(r):c.add(r),c})},[]);return{pinnedProjects:s,toggleProjectPin:o}}function vn({searchQuery:t,filterOption:s}){const{pathname:n}=Ft(),{threads:o,currentThreadId:r,setThreads:l,isLoadingThreads:c,setLoadingThreads:i,getThreadState:x}=fe(),[p,h]=a.useState(!1),[m,d]=a.useState([]),[T,C]=a.useState(!1),[P,_]=a.useState({}),[W,w]=a.useState(!1),$=a.useRef(null),M=a.useRef(null),N=sn(t),g=a.useCallback(async()=>{i(!0);try{const k=await H("/api/threads");if(!k.ok)return;const z=((await k.json()).threads??[]).map(b=>({...b,title:is(b.title)}));l(z);const O=fe.getState().initThreadUnread;if(typeof O=="function")for(const b of z)O(b.id,b.unreadCount??0,!!b.hasUserMention)}catch{}finally{i(!1)}},[i,l]);a.useEffect(()=>{g()},[g]),a.useEffect(()=>{let k=!1;return(async()=>{try{const E=await H("/api/authorization/pending");if(!E.ok)return;const z=await E.json();if(k)return;Et.getState().syncAllPending(z.pending??[])}catch{}})(),()=>{k=!0}},[]),a.useEffect(()=>{const k=()=>void g();return window.addEventListener("office-claw:threads-refresh",k),()=>window.removeEventListener("office-claw:threads-refresh",k)},[g]),a.useEffect(()=>{const k=Tt(),E=as(et,{transports:["websocket","polling"],auth:{userId:k}});return E.on("connect",()=>{E.emit("join_room",`user:${k}`)}),E.on("thread_created",z=>{z.source==="connector_auto"&&g()}),E.on("connector_message",z=>{var L,K;const O=fe.getState();if(!O.threads.some(V=>V.id===z.threadId)){g();return}(K=O.updateThreadLastActive)==null||K.call(O,z.threadId,((L=z.message)==null?void 0:L.timestamp)??Date.now())}),()=>{E.disconnect()}},[g]);const v=a.useCallback(()=>{M.current!==null&&(cancelAnimationFrame(M.current),M.current=null)},[]);a.useEffect(()=>{const k=$.current;if(!k)return;const E=()=>{qe(k.scrollTop)};return k.addEventListener("scroll",E,{passive:!0}),()=>k.removeEventListener("scroll",E)},[]);const R=a.useCallback(k=>{if(v(),!Number.isFinite(k)||k<=0)return;let E=Va;const z=()=>{const O=$.current;if(!O){M.current=null;return}const b=Math.max(0,O.scrollHeight-O.clientHeight),L=Math.min(k,b);O.scrollTop=L;const K=b>=k,V=Math.abs(O.scrollTop-L)<=1;if(K&&V||E<=0){qe(O.scrollTop),M.current=null;return}E-=1,M.current=requestAnimationFrame(z)};z()},[v]);a.useLayoutEffect(()=>(R(qa()),v),[o.length,c,n,R,v]),a.useEffect(()=>{(async()=>{try{const k=await H("/api/governance/health");if(!k.ok)return;const E=await k.json(),z={};for(const O of E.projects)z[O.projectPath]=O.status;_(z)}catch{}})()},[]);const u=a.useCallback(async()=>{C(!0);try{const k=await H("/api/threads?deleted=true");if(!k.ok)return;const E=await k.json();d(E.threads??[])}catch{}finally{C(!1)}},[]),I=a.useCallback(()=>{h(k=>{const E=!k;return E&&u(),E})},[u]),D=a.useCallback(async k=>{try{if(!(await H(`/api/threads/${k}/restore`,{method:"POST"})).ok)return;await g(),await u()}catch{}},[g,u]),Z=a.useMemo(()=>{let k=o;if(N&&(k=k.filter(E=>{var O;return(((O=E.title)==null?void 0:O.trim())||(E.id==="default"?"大厅":"未命名会话")).toLowerCase().includes(N)})),s!=="all"){const O=Date.now()-(s==="1m"?30:s==="3m"?90:180)*24*60*60*1e3;k=k.filter(b=>tn(b)>=O)}return k},[s,N,o]),se=a.useMemo(()=>{const E=[...Z.filter(L=>L.id!=="default")].sort((L,K)=>K.lastActiveAt-L.lastActiveAt),z=E.filter(L=>L.pinned),O=E.filter(L=>!L.pinned),b=[];return z.length>0&&b.push({type:"pinned",label:"置顶",threads:z}),b.push({type:"recent",label:Ya[s],threads:O}),b},[s,Z]),Y=a.useMemo(()=>se,[se]),X=a.useMemo(()=>Y.flatMap(k=>{var E;return k.type==="archived-container"?((E=k.archivedGroups)==null?void 0:E.flatMap(z=>z.threads))??k.threads:k.threads}),[Y]),y=a.useMemo(()=>Y.some(k=>{var E;return(((E=k.threads)==null?void 0:E.length)??0)>0}),[Y]),F=N.length===0||"大厅".includes(N),q=!y&&!F&&(N.length>0||s!=="all"),{pinnedProjects:A,toggleProjectPin:J}=gn(),{isCollapsed:Q,toggleGroup:ee}=hn({threadGroups:se,searchQuery:N,currentThreadId:r}),ue=n.startsWith("/thread/")?n.slice(8):null,S=a.useMemo(()=>es(o),[o]),U=a.useCallback(async()=>{var k,E;w(!0);try{(await H("/api/threads/read/mark-all",{method:"POST"})).ok&&((E=(k=fe.getState()).clearAllUnread)==null||E.call(k))}catch(z){console.debug("[F072] mark-all-read failed:",z)}finally{w(!1)}},[]);return{pathname:n,threads:o,currentThreadId:r,isLoadingThreads:c,getThreadState:x,scrollRegionRef:$,normalizedQuery:N,displayThreadGroups:Y,collapsedThreadItems:X,showNoResults:q,activeThreadIdFromRoute:ue,existingProjects:S,govHealth:P,pinnedProjects:A,isCollapsed:Q,toggleGroup:ee,toggleProjectPin:J,loadThreads:g,showTrash:p,trashedThreads:m,isLoadingTrash:T,loadTrash:u,toggleTrashVisibility:I,restoreThread:D,isMarkingAllRead:W,handleMarkAllRead:U}}function bn(t){const[s,n]=a.useState(!1),[o,r]=a.useState(!0),l=a.useRef(null),c=a.useRef(!1),i=a.useRef(null),x=a.useCallback(()=>{i.current&&(clearTimeout(i.current),i.current=null)},[]),p=a.useCallback((m,d)=>{if(x(),n(m),m){r(!1);return}if(d){r(!0);return}r(!1),i.current=setTimeout(()=>{r(!0),i.current=null},Ga)},[x]);a.useLayoutEffect(()=>{const m=()=>{const d=Za(t);if(l.current===d)return;const T=l.current===null;l.current=d,!c.current&&p(d,T)};return m(),window.addEventListener("resize",m),()=>{window.removeEventListener("resize",m),x()}},[p,x,t]);const h=a.useCallback(()=>{c.current=!0,p(!s,!1)},[p,s]);return{isSidebarCollapsed:s,isExpandedContentVisible:o,toggleSidebarCollapsed:h}}function yn(){const[t,s]=a.useState(""),[n,o]=a.useState(!1),[r,l]=a.useState(!1),[c,i]=a.useState("all"),[x,p]=a.useState(null),h=a.useRef(null),m=a.useRef(null),d=fe(u=>u.rightPanelMode),T=d==="pptStudio"||d==="fileBrowser"||d==="documentPreview"||d==="outlinePreview",{isSidebarCollapsed:C,isExpandedContentVisible:P,toggleSidebarCollapsed:_}=bn(T),W=C,w=P?"opacity-100 translate-x-0":"opacity-0 -translate-x-1 pointer-events-none";a.useLayoutEffect(()=>{if(!r){p(null);return}const u=()=>{var Z;const I=(Z=m.current)==null?void 0:Z.getBoundingClientRect();if(!I)return;const D=Math.max(Se,window.innerWidth-Ha-Se);p({top:Math.max(Se,I.bottom+Se),right:Math.min(Math.max(Se,window.innerWidth-I.right),D)})};return u(),window.addEventListener("resize",u),window.addEventListener("scroll",u,!0),()=>{window.removeEventListener("resize",u),window.removeEventListener("scroll",u,!0)}},[r]),a.useLayoutEffect(()=>{if(!r)return;const u=I=>{var Z,se;const D=I.target;D&&((Z=h.current)!=null&&Z.contains(D)||(se=m.current)!=null&&se.contains(D)||l(!1))};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[r]);const $=a.useCallback(u=>{s(u),i("all")},[]),M=a.useCallback(()=>{s(""),l(!1)},[]),N=a.useCallback(()=>{o(u=>!u),l(!1),i("all")},[]),g=a.useCallback(()=>{l(u=>!u),o(!1),s("")},[]),v=a.useCallback(u=>{i(u),l(!1)},[]),R=a.useCallback(()=>{s(""),o(!1),l(!1),i("all")},[]);return{searchQuery:t,isSearchOpen:n,showFilter:r,filterOption:c,filterPanelStyle:x,filterPanelRef:h,filterToggleRef:m,isSidebarCollapsed:C,isExpandedContentVisible:P,isSidebarCollapsedLayout:W,sidebarContentRevealClassName:w,toggleSidebarCollapsed:_,handleSearchChange:$,handleSearchClear:M,toggleSearch:N,toggleFilter:g,selectFilter:v,resetSearchAndFilter:R}}function jn({onClose:t,className:s,onThreadSelect:n}){const o=yn(),r=vn({searchQuery:o.searchQuery,filterOption:o.filterOption}),l=rn({pathname:r.pathname,currentThreadId:r.currentThreadId,threads:r.threads,showTrash:r.showTrash,trashedThreads:r.trashedThreads,loadThreads:r.loadThreads,loadTrash:r.loadTrash,resetSearchAndFilter:o.resetSearchAndFilter,onClose:t,onThreadSelect:n,getThreadState:r.getThreadState,scrollRegionRef:r.scrollRegionRef});return{className:s,...o,...r,...l}}function On(t){const s=jn(t);return e.jsx(nn,{...s})}export{On as ThreadSidebar};
2
+ //# sourceMappingURL=index-Bxf2_cvh.js.map